Bug 1635702 [wpt PR 23413] - Move some internal scroll anchoring tests to wpt, a...
[gecko.git] / layout / style / CSSFontFaceRule.h
blob167c40bda28f62c7fc6fa33dbe8f184c595fc889
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 {
15 namespace dom {
17 // A CSSFontFaceRuleDecl is always embeded in a CSSFontFaceRule.
18 class CSSFontFaceRule;
19 class CSSFontFaceRuleDecl final : public nsICSSDeclaration {
20 public:
21 NS_DECL_ISUPPORTS_INHERITED
22 NS_DECL_NSIDOMCSSSTYLEDECLARATION_HELPER
24 nsINode* GetParentObject() final;
25 void IndexedGetter(uint32_t aIndex, bool& aFound,
26 nsACString& aPropName) final;
28 void GetPropertyValue(nsCSSFontDesc aFontDescID, nsAString& 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<RawServoFontFaceRule> aDecl)
37 : mRawRule(std::move(aDecl)) {}
39 ~CSSFontFaceRuleDecl() = default;
41 inline CSSFontFaceRule* ContainingRule();
42 inline const CSSFontFaceRule* ContainingRule() const;
44 RefPtr<RawServoFontFaceRule> mRawRule;
46 private:
47 void* operator new(size_t size) noexcept(true) = delete;
50 class CSSFontFaceRule final : public css::Rule {
51 public:
52 CSSFontFaceRule(already_AddRefed<RawServoFontFaceRule> aRawRule,
53 StyleSheet* aSheet, css::Rule* aParentRule, uint32_t aLine,
54 uint32_t aColumn)
55 : css::Rule(aSheet, aParentRule, aLine, aColumn),
56 mDecl(std::move(aRawRule)) {}
58 CSSFontFaceRule(const CSSFontFaceRule&) = delete;
60 NS_DECL_ISUPPORTS_INHERITED
61 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSFontFaceRule,
62 css::Rule)
63 bool IsCCLeaf() const final;
65 RawServoFontFaceRule* Raw() const { return mDecl.mRawRule; }
67 // WebIDL interface
68 uint16_t Type() const final;
69 void GetCssText(nsAString& aCssText) const final;
70 nsICSSDeclaration* Style();
72 // Methods of mozilla::css::Rule
73 size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const final;
75 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
77 #ifdef DEBUG
78 void List(FILE* out = stdout, int32_t aIndent = 0) const final;
79 #endif
81 private:
82 virtual ~CSSFontFaceRule() = default;
84 // For computing the offset of mDecl.
85 friend class CSSFontFaceRuleDecl;
87 CSSFontFaceRuleDecl mDecl;
90 inline CSSFontFaceRule* CSSFontFaceRuleDecl::ContainingRule() {
91 return reinterpret_cast<CSSFontFaceRule*>(reinterpret_cast<char*>(this) -
92 offsetof(CSSFontFaceRule, mDecl));
95 inline const CSSFontFaceRule* CSSFontFaceRuleDecl::ContainingRule() const {
96 return reinterpret_cast<const CSSFontFaceRule*>(
97 reinterpret_cast<const char*>(this) - offsetof(CSSFontFaceRule, mDecl));
100 } // namespace dom
101 } // namespace mozilla
103 #endif // mozilla_CSSFontFaceRule_h