tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

CSSMarginRule.h (3293B)


      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/. */
      6 
      7 #ifndef mozilla_dom_CSSMarginRule_h
      8 #define mozilla_dom_CSSMarginRule_h
      9 
     10 #include "mozilla/ServoBindingTypes.h"
     11 #include "mozilla/css/Rule.h"
     12 #include "nsDOMCSSDeclaration.h"
     13 #include "nsICSSDeclaration.h"
     14 
     15 namespace mozilla {
     16 class DeclarationBlock;
     17 
     18 namespace dom {
     19 class CSSMarginRule;
     20 
     21 class CSSMarginRuleDeclaration final : public nsDOMCSSDeclaration {
     22 public:
     23  NS_DECL_ISUPPORTS_INHERITED
     24 
     25  css::Rule* GetParentRule() final;
     26  nsINode* GetAssociatedNode() const final;
     27  nsISupports* GetParentObject() const final;
     28 
     29 protected:
     30  DeclarationBlock* GetOrCreateCSSDeclaration(
     31      Operation aOperation, DeclarationBlock** aCreated) final;
     32  nsresult SetCSSDeclaration(DeclarationBlock* aDecl,
     33                             MutationClosureData* aClosureData) final;
     34  Document* DocToUpdate() final { return nullptr; }
     35  nsDOMCSSDeclaration::ParsingEnvironment GetParsingEnvironment(
     36      nsIPrincipal* aSubjectPrincipal) const final;
     37 
     38 private:
     39  // For accessing the constructor.
     40  friend class CSSMarginRule;
     41 
     42  explicit CSSMarginRuleDeclaration(
     43      already_AddRefed<StyleLockedDeclarationBlock> aDecls);
     44  void SetRawAfterClone(RefPtr<StyleLockedDeclarationBlock>);
     45 
     46  ~CSSMarginRuleDeclaration();
     47 
     48  inline CSSMarginRule* Rule();
     49  inline const CSSMarginRule* Rule() const;
     50 
     51  RefPtr<DeclarationBlock> mDecls;
     52 };
     53 
     54 class CSSMarginRule final : public css::Rule {
     55 public:
     56  CSSMarginRule(RefPtr<StyleMarginRule> aRawRule, StyleSheet* aSheet,
     57                css::Rule* aParentRule, uint32_t aLine, uint32_t aColumn);
     58 
     59  NS_DECL_ISUPPORTS_INHERITED
     60  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(CSSMarginRule,
     61                                                         css::Rule)
     62 
     63  bool IsCCLeaf() const final;
     64 
     65  StyleMarginRule* Raw() const { return mRawRule; }
     66  void SetRawAfterClone(RefPtr<StyleMarginRule>);
     67 
     68  // WebIDL interfaces
     69  StyleCssRuleType Type() const final;
     70  void GetCssText(nsACString& aCssText) const final;
     71  nsICSSDeclaration* Style() { return &mDecls; }
     72 
     73  void GetName(nsACString& aRuleName) const;
     74 
     75  size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const final;
     76 
     77 #ifdef DEBUG
     78  void List(FILE* out = stdout, int32_t aIndent = 0) const final;
     79 #endif
     80 
     81  JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
     82 
     83 private:
     84  ~CSSMarginRule() = default;
     85 
     86  // For computing the offset of mDecls.
     87  friend class CSSMarginRuleDeclaration;
     88 
     89  RefPtr<StyleMarginRule> mRawRule;
     90  CSSMarginRuleDeclaration mDecls;
     91 };
     92 
     93 CSSMarginRule* CSSMarginRuleDeclaration::Rule() {
     94  return reinterpret_cast<CSSMarginRule*>(reinterpret_cast<uint8_t*>(this) -
     95                                          offsetof(CSSMarginRule, mDecls));
     96 }
     97 
     98 const CSSMarginRule* CSSMarginRuleDeclaration::Rule() const {
     99  return reinterpret_cast<const CSSMarginRule*>(
    100      reinterpret_cast<const uint8_t*>(this) - offsetof(CSSMarginRule, mDecls));
    101 }
    102 
    103 }  // namespace dom
    104 }  // namespace mozilla
    105 
    106 #endif  // mozilla_dom_CSSMarginRule_h