Line data Source code
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/. */
6 :
7 : /* representation of CSSPageRule for stylo */
8 :
9 : #ifndef mozilla_ServoPageRule_h
10 : #define mozilla_ServoPageRule_h
11 :
12 : #include "mozilla/dom/CSSPageRule.h"
13 : #include "mozilla/ServoBindingTypes.h"
14 :
15 : #include "nsDOMCSSDeclaration.h"
16 :
17 : namespace mozilla {
18 :
19 : class ServoDeclarationBlock;
20 : class ServoPageRule;
21 :
22 : class ServoPageRuleDeclaration final : public nsDOMCSSDeclaration
23 : {
24 : public:
25 : NS_DECL_ISUPPORTS_INHERITED
26 :
27 : NS_IMETHOD GetParentRule(nsIDOMCSSRule** aParent) final;
28 : nsINode* GetParentObject() final;
29 :
30 : protected:
31 : DeclarationBlock* GetCSSDeclaration(Operation aOperation) final;
32 : nsresult SetCSSDeclaration(DeclarationBlock* aDecl) final;
33 : nsIDocument* DocToUpdate() final;
34 : void GetCSSParsingEnvironment(CSSParsingEnvironment& aCSSParseEnv) final;
35 : nsDOMCSSDeclaration::ServoCSSParsingEnvironment GetServoCSSParsingEnvironment() const final;
36 :
37 : private:
38 : // For accessing the constructor.
39 : friend class ServoPageRule;
40 :
41 : explicit ServoPageRuleDeclaration(
42 : already_AddRefed<RawServoDeclarationBlock> aDecls);
43 : ~ServoPageRuleDeclaration();
44 :
45 : inline ServoPageRule* Rule();
46 : inline const ServoPageRule* Rule() const;
47 :
48 : RefPtr<ServoDeclarationBlock> mDecls;
49 : };
50 :
51 : class ServoPageRule final : public dom::CSSPageRule
52 : {
53 : public:
54 : ServoPageRule(RefPtr<RawServoPageRule> aRawRule,
55 : uint32_t aLine, uint32_t aColumn);
56 :
57 : NS_DECL_ISUPPORTS_INHERITED
58 0 : NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
59 : ServoPageRule, dom::CSSPageRule
60 : )
61 : bool IsCCLeaf() const final;
62 :
63 0 : RawServoPageRule* Raw() const { return mRawRule; }
64 :
65 : // WebIDL interface
66 : void GetCssTextImpl(nsAString& aCssText) const final;
67 : nsICSSDeclaration* Style() final;
68 :
69 : // Methods of mozilla::css::Rule
70 : already_AddRefed<css::Rule> Clone() const final;
71 : size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
72 : const final;
73 : #ifdef DEBUG
74 : void List(FILE* out = stdout, int32_t aIndent = 0) const final;
75 : #endif
76 :
77 : private:
78 : virtual ~ServoPageRule();
79 :
80 : // For computing the offset of mDecls.
81 : friend class ServoPageRuleDeclaration;
82 :
83 : RefPtr<RawServoPageRule> mRawRule;
84 : ServoPageRuleDeclaration mDecls;
85 : };
86 :
87 : ServoPageRule*
88 0 : ServoPageRuleDeclaration::Rule()
89 : {
90 : return reinterpret_cast<ServoPageRule*>(
91 0 : reinterpret_cast<uint8_t*>(this) - offsetof(ServoPageRule, mDecls));
92 : }
93 :
94 : const ServoPageRule*
95 0 : ServoPageRuleDeclaration::Rule() const
96 : {
97 : return reinterpret_cast<const ServoPageRule*>(
98 0 : reinterpret_cast<const uint8_t*>(this) - offsetof(ServoPageRule, mDecls));
99 : }
100 :
101 : } // namespace mozilla
102 :
103 : #endif // mozilla_ServoPageRule_h
|