Bug 1361938 - Introduce a dirty flag that represents DeclarationBlock has been modified but not restyled. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 31 May 2017 08:33:03 +0900
changeset 586725 010162149de271d11122305030a5222cdb432b1c
parent 586654 02c2ade8e3ece2b1fd39df5bac82e78bb62cb3d1
child 586726 9ec35af239a0ced410432647903c42bbc8996ec2
push id61507
push userhikezoe@mozilla.com
push dateWed, 31 May 2017 00:25:44 +0000
reviewersheycam
bugs1361938
milestone55.0a1
Bug 1361938 - Introduce a dirty flag that represents DeclarationBlock has been modified but not restyled. r?heycam MozReview-Commit-ID: 757XcVxSvQn
layout/style/DeclarationBlock.h
--- a/layout/style/DeclarationBlock.h
+++ b/layout/style/DeclarationBlock.h
@@ -27,17 +27,22 @@ namespace css {
 class Declaration;
 class Rule;
 } // namespace css
 
 class DeclarationBlock
 {
 protected:
   explicit DeclarationBlock(StyleBackendType aType)
-    : mImmutable(false), mType(aType) { mContainer.mRaw = 0; }
+    : mImmutable(false)
+    , mIsDirty(false)
+    , mType(aType)
+  {
+    mContainer.mRaw = 0;
+  }
 
   DeclarationBlock(const DeclarationBlock& aCopy)
     : DeclarationBlock(aCopy.mType) {}
 
 public:
   MOZ_DECL_STYLO_METHODS(css::Declaration, ServoDeclarationBlock)
 
   inline MozExternalRefCountType AddRef();
@@ -61,16 +66,31 @@ public:
 
   /**
    * Mark this declaration as unmodifiable.  It's 'const' so it can
    * be called from ToString.
    */
   void SetImmutable() { mImmutable = true; }
 
   /**
+   * Return whether |this| has been restyled after modified.
+   */
+  bool IsDirty() const { return mIsDirty; }
+
+  /**
+   * Mark this declaration as dirty.
+   */
+  void SetDirty() { mIsDirty = true; }
+
+  /**
+   * Mark this declaration as not dirty.
+   */
+  void UnsetDirty() { mIsDirty = false; }
+
+  /**
    * Copy |this|, if necessary to ensure that it can be modified.
    */
   inline already_AddRefed<DeclarationBlock> EnsureMutable();
 
   void SetOwningRule(css::Rule* aRule) {
     MOZ_ASSERT(!mContainer.mOwningRule || !aRule,
                "should never overwrite one rule with another");
     mContainer.mOwningRule = aRule;
@@ -131,15 +151,17 @@ private:
 
     // The nsHTMLCSSStyleSheet that is responsible for this declaration.
     // Only non-null for style attributes.
     nsHTMLCSSStyleSheet* mHTMLCSSStyleSheet;
   } mContainer;
 
   // set when declaration put in the rule tree;
   bool mImmutable;
+  // True if this declaration has not been restyled after modified.
+  bool mIsDirty;
 
   const StyleBackendType mType;
 };
 
 } // namespace mozilla
 
 #endif // mozilla_DeclarationBlock_h