Bug 1361938 - Introduce a dirty flag that represents DeclarationBlock has been modified but not restyled. r=heycam
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Wed, 31 May 2017 08:33:03 +0900
changeset 409544 c3bf3996068d2ce6468aa92d6682d11af923e4a9
parent 409543 47660663c12f2851cfbe6a2f2da4bf915ff0afac
child 409545 2585796d42803deb0e4e89e95beabc8e8f52040a
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1361938
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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