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_dom_CSSPageRule_h
8 #define mozilla_dom_CSSPageRule_h
10 #include "mozilla/css/Rule.h"
11 #include "mozilla/ServoBindingTypes.h"
13 #include "nsDOMCSSDeclaration.h"
14 #include "nsICSSDeclaration.h"
17 class DeclarationBlock
;
23 class CSSPageRuleDeclaration final
: public nsDOMCSSDeclaration
{
25 NS_DECL_ISUPPORTS_INHERITED
27 css::Rule
* GetParentRule() final
;
28 nsINode
* GetAssociatedNode() const final
;
29 nsISupports
* GetParentObject() const final
;
32 DeclarationBlock
* GetOrCreateCSSDeclaration(
33 Operation aOperation
, DeclarationBlock
** aCreated
) final
;
34 nsresult
SetCSSDeclaration(DeclarationBlock
* aDecl
,
35 MutationClosureData
* aClosureData
) final
;
36 Document
* DocToUpdate() final
{ return nullptr; }
37 nsDOMCSSDeclaration::ParsingEnvironment
GetParsingEnvironment(
38 nsIPrincipal
* aSubjectPrincipal
) const final
;
41 // For accessing the constructor.
42 friend class CSSPageRule
;
44 explicit CSSPageRuleDeclaration(
45 already_AddRefed
<RawServoDeclarationBlock
> aDecls
);
46 void SetRawAfterClone(RefPtr
<RawServoDeclarationBlock
>);
48 ~CSSPageRuleDeclaration();
50 inline CSSPageRule
* Rule();
51 inline const CSSPageRule
* Rule() const;
53 RefPtr
<DeclarationBlock
> mDecls
;
56 class CSSPageRule final
: public css::Rule
{
58 CSSPageRule(RefPtr
<RawServoPageRule
> aRawRule
, StyleSheet
* aSheet
,
59 css::Rule
* aParentRule
, uint32_t aLine
, uint32_t aColumn
);
61 NS_DECL_ISUPPORTS_INHERITED
62 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSPageRule
, css::Rule
)
64 bool IsCCLeaf() const final
;
66 RawServoPageRule
* Raw() const { return mRawRule
; }
67 void SetRawAfterClone(RefPtr
<RawServoPageRule
>);
70 StyleCssRuleType
Type() const final
;
71 void GetCssText(nsACString
& aCssText
) const final
;
72 nsICSSDeclaration
* Style();
74 void GetSelectorText(nsACString
& aSelectorText
) const;
75 void SetSelectorText(const nsACString
& aSelectorText
);
77 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf
) const final
;
80 void List(FILE* out
= stdout
, int32_t aIndent
= 0) const final
;
83 JSObject
* WrapObject(JSContext
* aCx
, JS::Handle
<JSObject
*> aGivenProto
) final
;
86 ~CSSPageRule() = default;
88 // For computing the offset of mDecls.
89 friend class CSSPageRuleDeclaration
;
91 RefPtr
<RawServoPageRule
> mRawRule
;
92 CSSPageRuleDeclaration mDecls
;
95 CSSPageRule
* CSSPageRuleDeclaration::Rule() {
96 return reinterpret_cast<CSSPageRule
*>(reinterpret_cast<uint8_t*>(this) -
97 offsetof(CSSPageRule
, mDecls
));
100 const CSSPageRule
* CSSPageRuleDeclaration::Rule() const {
101 return reinterpret_cast<const CSSPageRule
*>(
102 reinterpret_cast<const uint8_t*>(this) - offsetof(CSSPageRule
, mDecls
));
106 } // namespace mozilla
108 #endif // mozilla_dom_CSSPageRule_h