Bug 1879449 [wpt PR 44489] - [wptrunner] Add `infrastructure/expected-fail/` test...
[gecko.git] / layout / style / CSSFontFaceRule.h
blobb29249b8a3229bf45a49cf5340dc50cb804fcf75
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 #ifndef mozilla_CSSFontFaceRule_h
8 #define mozilla_CSSFontFaceRule_h
10 #include "mozilla/ServoBindingTypes.h"
11 #include "mozilla/css/Rule.h"
12 #include "nsICSSDeclaration.h"
14 namespace mozilla::dom {
16 // A CSSFontFaceRuleDecl is always embeded in a CSSFontFaceRule.
17 class CSSFontFaceRule;
18 class CSSFontFaceRuleDecl final : public nsICSSDeclaration {
19 public:
20 NS_DECL_ISUPPORTS_INHERITED
21 NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER
23 nsINode* GetAssociatedNode() const final;
24 nsISupports* GetParentObject() const final;
25 void IndexedGetter(uint32_t aIndex, bool& aFound,
26 nsACString& aPropName) final;
28 void GetPropertyValue(nsCSSFontDesc aFontDescID, nsACString& aResult) const;
30 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
32 protected:
33 // For accessing the constructor.
34 friend class CSSFontFaceRule;
36 explicit CSSFontFaceRuleDecl(already_AddRefed<StyleLockedFontFaceRule> aDecl)
37 : mRawRule(std::move(aDecl)) {}
39 ~CSSFontFaceRuleDecl() = default;
41 inline CSSFontFaceRule* ContainingRule();
42 inline const CSSFontFaceRule* ContainingRule() const;
44 RefPtr<StyleLockedFontFaceRule> mRawRule;
45 void SetRawAfterClone(RefPtr<StyleLockedFontFaceRule>);
47 private:
48 void* operator new(size_t size) noexcept(true) = delete;
51 class CSSFontFaceRule final : public css::Rule {
52 public:
53 CSSFontFaceRule(already_AddRefed<StyleLockedFontFaceRule> aRawRule,
54 StyleSheet* aSheet, css::Rule* aParentRule, uint32_t aLine,
55 uint32_t aColumn)
56 : css::Rule(aSheet, aParentRule, aLine, aColumn),
57 mDecl(std::move(aRawRule)) {}
59 CSSFontFaceRule(const CSSFontFaceRule&) = delete;
61 NS_DECL_ISUPPORTS_INHERITED
62 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSFontFaceRule,
63 css::Rule)
64 bool IsCCLeaf() const final;
66 StyleLockedFontFaceRule* Raw() const { return mDecl.mRawRule; }
67 void SetRawAfterClone(RefPtr<StyleLockedFontFaceRule>);
69 // WebIDL interface
70 StyleCssRuleType Type() const final;
71 void GetCssText(nsACString& aCssText) const final;
72 nsICSSDeclaration* Style();
74 // Methods of mozilla::css::Rule
75 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final;
77 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
79 #ifdef DEBUG
80 void List(FILE* out = stdout, int32_t aIndent = 0) const final;
81 #endif
83 private:
84 virtual ~CSSFontFaceRule() = default;
86 // For computing the offset of mDecl.
87 friend class CSSFontFaceRuleDecl;
89 CSSFontFaceRuleDecl mDecl;
92 inline CSSFontFaceRule* CSSFontFaceRuleDecl::ContainingRule() {
93 return reinterpret_cast<CSSFontFaceRule*>(reinterpret_cast<char*>(this) -
94 offsetof(CSSFontFaceRule, mDecl));
97 inline const CSSFontFaceRule* CSSFontFaceRuleDecl::ContainingRule() const {
98 return reinterpret_cast<const CSSFontFaceRule*>(
99 reinterpret_cast<const char*>(this) - offsetof(CSSFontFaceRule, mDecl));
102 } // namespace mozilla::dom
104 #endif // mozilla_CSSFontFaceRule_h