Backed out changeset 1b14354719c0 (bug 1895254) for causing bustages on NavigationTra...
[gecko.git] / layout / style / CSSMarginRule.h
blob0ad5f60dbda743777463bb27fa1f8341e5a1a61a
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=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_CSSMarginRule_h
8 #define mozilla_dom_CSSMarginRule_h
10 #include "mozilla/css/Rule.h"
11 #include "mozilla/ServoBindingTypes.h"
13 #include "nsDOMCSSDeclaration.h"
14 #include "nsICSSDeclaration.h"
16 namespace mozilla {
17 class DeclarationBlock;
19 namespace dom {
20 class CSSMarginRule;
22 class CSSMarginRuleDeclaration final : public nsDOMCSSDeclaration {
23 public:
24 NS_DECL_ISUPPORTS_INHERITED
26 css::Rule* GetParentRule() final;
27 nsINode* GetAssociatedNode() const final;
28 nsISupports* GetParentObject() const final;
30 protected:
31 DeclarationBlock* GetOrCreateCSSDeclaration(
32 Operation aOperation, DeclarationBlock** aCreated) final;
33 nsresult SetCSSDeclaration(DeclarationBlock* aDecl,
34 MutationClosureData* aClosureData) final;
35 Document* DocToUpdate() final { return nullptr; }
36 nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment(
37 nsIPrincipal* aSubjectPrincipal) const final;
39 private:
40 // For accessing the constructor.
41 friend class CSSMarginRule;
43 explicit CSSMarginRuleDeclaration(
44 already_AddRefed<StyleLockedDeclarationBlock> aDecls);
45 void SetRawAfterClone(RefPtr<StyleLockedDeclarationBlock>);
47 ~CSSMarginRuleDeclaration();
49 inline CSSMarginRule* Rule();
50 inline const CSSMarginRule* Rule() const;
52 RefPtr<DeclarationBlock> mDecls;
55 class CSSMarginRule final : public css::Rule {
56 public:
57 CSSMarginRule(RefPtr<StyleMarginRule> aRawRule, StyleSheet* aSheet,
58 css::Rule* aParentRule, uint32_t aLine, uint32_t aColumn);
60 NS_DECL_ISUPPORTS_INHERITED
61 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSMarginRule,
62 css::Rule)
64 bool IsCCLeaf() const final;
66 StyleMarginRule* Raw() const { return mRawRule; }
67 void SetRawAfterClone(RefPtr<StyleMarginRule>);
69 // WebIDL interfaces
70 StyleCssRuleType Type() const final;
71 void GetCssText(nsACString& aCssText) const final;
72 nsICSSDeclaration* Style() { return &mDecls; }
74 void GetName(nsACString& aRuleName) const;
76 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
78 #ifdef DEBUG
79 void List(FILE* out = stdout, int32_t aIndent = 0) const final;
80 #endif
82 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
84 private:
85 ~CSSMarginRule() = default;
87 // For computing the offset of mDecls.
88 friend class CSSMarginRuleDeclaration;
90 RefPtr<StyleMarginRule> mRawRule;
91 CSSMarginRuleDeclaration mDecls;
94 CSSMarginRule* CSSMarginRuleDeclaration::Rule() {
95 return reinterpret_cast<CSSMarginRule*>(reinterpret_cast<uint8_t*>(this) -
96 offsetof(CSSMarginRule, mDecls));
99 const CSSMarginRule* CSSMarginRuleDeclaration::Rule() const {
100 return reinterpret_cast<const CSSMarginRule*>(
101 reinterpret_cast<const uint8_t*>(this) - offsetof(CSSMarginRule, mDecls));
104 } // namespace dom
105 } // namespace mozilla
107 #endif // mozilla_dom_CSSMarginRule_h