Bug 1879449 [wpt PR 44489] - [wptrunner] Add `infrastructure/expected-fail/` test...
[gecko.git] / layout / style / nsROCSSPrimitiveValue.h
blobd782a2346966a7739199e4f95dcab0a1c5728983
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 /**
17 * Read-only CSS primitive value - a DOM object representing values in DOM
18 * computed style.
20 class nsROCSSPrimitiveValue final : public mozilla::dom::CSSValue {
21 public:
22 enum : uint16_t {
23 CSS_UNKNOWN,
24 CSS_NUMBER,
25 CSS_PERCENTAGE,
26 CSS_PX,
27 CSS_DEG,
28 CSS_S,
29 CSS_STRING,
30 CSS_RGBCOLOR,
31 CSS_NUMBER_INT32,
32 CSS_NUMBER_UINT32,
35 // CSSValue
36 void GetCssText(nsAString&) final;
37 uint16_t CssValueType() const final;
39 // CSSPrimitiveValue
40 uint16_t PrimitiveType();
42 // nsROCSSPrimitiveValue
43 nsROCSSPrimitiveValue();
45 void SetNumber(float aValue);
46 void SetNumber(int32_t aValue);
47 void SetNumber(uint32_t aValue);
48 void SetPercent(float aValue);
49 void SetDegree(float aValue);
50 void SetPixels(float aValue);
51 void SetAppUnits(nscoord aValue);
52 void SetAppUnits(float aValue);
53 void SetString(const nsACString& aString);
54 void SetString(const nsAString& aString);
56 template <size_t N>
57 void SetString(const char (&aString)[N]) {
58 SetString(nsLiteralCString(aString));
61 void SetTime(float aValue);
62 void Reset();
64 virtual ~nsROCSSPrimitiveValue();
66 protected:
67 uint16_t mType;
69 union {
70 float mFloat;
71 int32_t mInt32;
72 uint32_t mUint32;
73 char16_t* mString;
74 } mValue;
77 inline nsROCSSPrimitiveValue* mozilla::dom::CSSValue::AsPrimitiveValue() {
78 return CssValueType() == mozilla::dom::CSSValue::CSS_PRIMITIVE_VALUE
79 ? static_cast<nsROCSSPrimitiveValue*>(this)
80 : nullptr;
83 #endif /* nsROCSSPrimitiveValue_h___ */