Bug 1415940 Part 2: Give StyleSheet a dirty flag of MODIFIED_RULES, and a method to test it. draft
authorBrad Werth <bwerth@mozilla.com>
Wed, 03 Jan 2018 15:02:43 -0800
changeset 721874 c8e8fbc16ee346928e2f6c74c11d3c8de3ac57d1
parent 721873 5cbd8b28ea8c17580209c2aa7f66af1b5e5f6483
child 721875 5aeb29ffe4fcace90642e2b5a3a84ed09d8ac7a0
push id95979
push userbwerth@mozilla.com
push dateThu, 18 Jan 2018 00:40:34 +0000
bugs1415940
milestone59.0a1
Bug 1415940 Part 2: Give StyleSheet a dirty flag of MODIFIED_RULES, and a method to test it. MozReview-Commit-ID: D52NghCopH2
layout/style/StyleSheet.cpp
layout/style/StyleSheet.h
--- a/layout/style/StyleSheet.cpp
+++ b/layout/style/StyleSheet.cpp
@@ -553,38 +553,41 @@ StyleSheet::DeleteRuleFromGroup(css::Gro
     current = current->mParent;                           \
   } while (current);                                      \
 } while (0)
 
 void
 StyleSheet::RuleAdded(css::Rule& aRule)
 {
   DidDirty();
+  mDirtyFlags |= MODIFIED_RULES;
   NOTIFY_STYLE_SETS(RuleAdded, (*this, aRule));
 
   if (mDocument) {
     mDocument->StyleRuleAdded(this, &aRule);
   }
 }
 
 void
 StyleSheet::RuleRemoved(css::Rule& aRule)
 {
   DidDirty();
+  mDirtyFlags |= MODIFIED_RULES;
   NOTIFY_STYLE_SETS(RuleRemoved, (*this, aRule));
 
   if (mDocument) {
     mDocument->StyleRuleRemoved(this, &aRule);
   }
 }
 
 void
 StyleSheet::RuleChanged(css::Rule* aRule)
 {
   DidDirty();
+  mDirtyFlags |= MODIFIED_RULES;
   NOTIFY_STYLE_SETS(RuleChanged, (*this, aRule));
 
   if (mDocument) {
     mDocument->StyleRuleChanged(this, aRule);
   }
 }
 
 nsresult
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -129,16 +129,18 @@ public:
 
   virtual already_AddRefed<StyleSheet> Clone(StyleSheet* aCloneParent,
                                              dom::CSSImportRule* aCloneOwnerRule,
                                              nsIDocument* aCloneDocument,
                                              nsINode* aCloneOwningNode) const = 0;
 
   bool HasForcedUniqueInner() const { return mDirtyFlags &
                                              FORCED_UNIQUE_INNER; }
+  bool HasModifiedRules() const { return mDirtyFlags &
+                                         MODIFIED_RULES; }
 
   inline bool HasUniqueInner() const;
   void EnsureUniqueInner();
 
   // Append all of this sheet's child sheets to aArray.
   void AppendAllChildSheets(nsTArray<StyleSheet*>& aArray);
 
   // style sheet owner info
@@ -336,16 +338,17 @@ protected:
   // and/or useful in user sheets.
   css::SheetParsingMode mParsingMode;
 
   const StyleBackendType mType;
   bool                  mDisabled;
 
   enum dirtyFlagAttributes {
     FORCED_UNIQUE_INNER = 0x1,
+    MODIFIED_RULES = 0x2,
   };
   uint8_t mDirtyFlags; // has been modified
 
   // mDocumentAssociationMode determines whether mDocument directly owns us (in
   // the sense that if it's known-live then we're known-live).  Always
   // NotOwnedByDocument when mDocument is null.
   DocumentAssociationMode mDocumentAssociationMode;