Bug 1936278 - Prevent search mode chiclet from being dismissed when clicking in page...
[gecko.git] / dom / canvas / TextMetrics.h
blob6453705fff8e9f06f97eecbbb27a8058334029f9
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef mozilla_dom_TextMetrics_h
7 #define mozilla_dom_TextMetrics_h
9 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
10 #include "mozilla/dom/NonRefcountedDOMObject.h"
12 namespace mozilla::dom {
14 class TextMetrics final : public NonRefcountedDOMObject {
15 public:
16 explicit TextMetrics(double aWidth, double aActualBoundingBoxLeft,
17 double aActualBoundingBoxRight,
18 double aFontBoundingBoxAscent,
19 double aFontBoundingBoxDescent,
20 double aActualBoundingBoxAscent,
21 double aActualBoundingBoxDescent, double aEmHeightAscent,
22 double aEmHeightDescent, double aHangingBaseline,
23 double aAlphabeticBaseline, double aIdeographicBaseline)
24 : width(aWidth),
25 actualBoundingBoxLeft(aActualBoundingBoxLeft),
26 actualBoundingBoxRight(aActualBoundingBoxRight),
27 fontBoundingBoxAscent(aFontBoundingBoxAscent),
28 fontBoundingBoxDescent(aFontBoundingBoxDescent),
29 actualBoundingBoxAscent(aActualBoundingBoxAscent),
30 actualBoundingBoxDescent(aActualBoundingBoxDescent),
31 emHeightAscent(aEmHeightAscent),
32 emHeightDescent(aEmHeightDescent),
33 hangingBaseline(aHangingBaseline),
34 alphabeticBaseline(aAlphabeticBaseline),
35 ideographicBaseline(aIdeographicBaseline) {
36 MOZ_COUNT_CTOR(TextMetrics);
39 MOZ_COUNTED_DTOR(TextMetrics)
41 double Width() const { return width; }
43 double ActualBoundingBoxLeft() const { return actualBoundingBoxLeft; }
45 double ActualBoundingBoxRight() const { return actualBoundingBoxRight; }
47 // y-direction
49 double FontBoundingBoxAscent() const { return fontBoundingBoxAscent; }
51 double FontBoundingBoxDescent() const { return fontBoundingBoxDescent; }
53 double ActualBoundingBoxAscent() const { return actualBoundingBoxAscent; }
55 double ActualBoundingBoxDescent() const { return actualBoundingBoxDescent; }
57 double EmHeightAscent() const { return emHeightAscent; }
59 double EmHeightDescent() const { return emHeightDescent; }
61 double HangingBaseline() const { return hangingBaseline; }
63 double AlphabeticBaseline() const { return alphabeticBaseline; }
65 double IdeographicBaseline() const { return ideographicBaseline; }
67 bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto,
68 JS::MutableHandle<JSObject*> aReflector) {
69 return TextMetrics_Binding::Wrap(aCx, this, aGivenProto, aReflector);
72 private:
73 double width;
74 double actualBoundingBoxLeft;
75 double actualBoundingBoxRight;
76 double fontBoundingBoxAscent;
77 double fontBoundingBoxDescent;
78 double actualBoundingBoxAscent;
79 double actualBoundingBoxDescent;
80 double emHeightAscent;
81 double emHeightDescent;
82 double hangingBaseline;
83 double alphabeticBaseline;
84 double ideographicBaseline;
87 } // namespace mozilla::dom
89 #endif // mozilla_dom_TextMetrics_h