Bug 1700051: part 35) Reduce accessibility of `mSoftText.mDOMMapping` to `private...
[gecko.git] / layout / style / nsROCSSPrimitiveValue.h
blobb3393eef6c1765c88eeb5da633ffe3379b8df4f6
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* DOM object representing values in DOM computed style */
9 #ifndef nsROCSSPrimitiveValue_h___
10 #define nsROCSSPrimitiveValue_h___
12 #include "CSSValue.h"
13 #include "nsCoord.h"
14 #include "nsString.h"
16 class nsIURI;
18 /**
19 * Read-only CSS primitive value - a DOM object representing values in DOM
20 * computed style.
22 class nsROCSSPrimitiveValue final : public mozilla::dom::CSSValue {
23 public:
24 enum : uint16_t {
25 CSS_UNKNOWN,
26 CSS_NUMBER,
27 CSS_PERCENTAGE,
28 CSS_EMS,
29 CSS_EXS,
30 CSS_PX,
31 CSS_CM,
32 CSS_MM,
33 CSS_IN,
34 CSS_PT,
35 CSS_PC,
36 CSS_DEG,
37 CSS_MS,
38 CSS_S,
39 CSS_HZ,
40 CSS_KHZ,
41 CSS_DIMENSION,
42 CSS_STRING,
43 CSS_URI,
44 CSS_RGBCOLOR,
45 CSS_NUMBER_INT32,
46 CSS_NUMBER_UINT32,
49 // CSSValue
50 void GetCssText(nsString& aText, mozilla::ErrorResult& aRv) final;
51 uint16_t CssValueType() const final;
53 // CSSPrimitiveValue
54 uint16_t PrimitiveType();
56 // nsROCSSPrimitiveValue
57 nsROCSSPrimitiveValue();
59 void SetNumber(float aValue);
60 void SetNumber(int32_t aValue);
61 void SetNumber(uint32_t aValue);
62 void SetPercent(float aValue);
63 void SetDegree(float aValue);
64 void SetPixels(float aValue);
65 void SetAppUnits(nscoord aValue);
66 void SetAppUnits(float aValue);
67 void SetString(const nsACString& aString);
68 void SetString(const nsAString& aString);
70 template <size_t N>
71 void SetString(const char (&aString)[N]) {
72 SetString(nsLiteralCString(aString));
75 void SetURI(nsIURI* aURI);
76 void SetTime(float aValue);
77 void Reset();
79 virtual ~nsROCSSPrimitiveValue();
81 protected:
82 uint16_t mType;
84 union {
85 float mFloat;
86 int32_t mInt32;
87 uint32_t mUint32;
88 char16_t* mString;
89 nsIURI* MOZ_OWNING_REF mURI;
90 } mValue;
93 inline nsROCSSPrimitiveValue* mozilla::dom::CSSValue::AsPrimitiveValue() {
94 return CssValueType() == mozilla::dom::CSSValue::CSS_PRIMITIVE_VALUE
95 ? static_cast<nsROCSSPrimitiveValue*>(this)
96 : nullptr;
99 #endif /* nsROCSSPrimitiveValue_h___ */