Bug 1415940 Part 3: Make StyleSheets clear their MODIFIED_RULES flag when the sheet is reparsed. draft
authorBrad Werth <bwerth@mozilla.com>
Thu, 11 Jan 2018 16:43:58 -0800
changeset 721875 5aeb29ffe4fcace90642e2b5a3a84ed09d8ac7a0
parent 721874 c8e8fbc16ee346928e2f6c74c11d3c8de3ac57d1
child 721876 907b05d9ff666be7956aa7546a2b3f053a076155
push id95979
push userbwerth@mozilla.com
push dateThu, 18 Jan 2018 00:40:34 +0000
bugs1415940
milestone59.0a1
Bug 1415940 Part 3: Make StyleSheets clear their MODIFIED_RULES flag when the sheet is reparsed. MozReview-Commit-ID: F7g2CstgjT8
layout/style/CSSStyleSheet.cpp
layout/style/ServoStyleSheet.cpp
layout/style/StyleSheet.h
--- a/layout/style/CSSStyleSheet.cpp
+++ b/layout/style/CSSStyleSheet.cpp
@@ -925,12 +925,16 @@ CSSStyleSheet::ReparseSheet(const nsAStr
   for (int32_t index = 0; index < Inner()->mOrderedRules.Count(); ++index) {
     RefPtr<css::Rule> rule = Inner()->mOrderedRules.ObjectAt(index);
     if (rule->GetType() == css::Rule::IMPORT_RULE &&
         RuleHasPendingChildSheet(rule)) {
       continue; // notify when loaded (see StyleSheetLoaded)
     }
     RuleAdded(*rule);
   }
+
+  // Our rules are no longer considered modified.
+  ClearModifiedRules();
+
   return NS_OK;
 }
 
 } // namespace mozilla
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -323,16 +323,19 @@ ServoStyleSheet::ReparseSheet(const nsAS
           RuleHasPendingChildSheet(rule)) {
         continue; // notify when loaded (see StyleSheetLoaded)
       }
 
       RuleAdded(*rule);
     }
   }
 
+  // Our rules are no longer considered modified.
+  ClearModifiedRules();
+
   return NS_OK;
 }
 
 // nsICSSLoaderObserver implementation
 NS_IMETHODIMP
 ServoStyleSheet::StyleSheetLoaded(StyleSheet* aSheet,
                                   bool aWasAlternate,
                                   nsresult aStatus)
--- a/layout/style/StyleSheet.h
+++ b/layout/style/StyleSheet.h
@@ -131,16 +131,17 @@ public:
                                              dom::CSSImportRule* aCloneOwnerRule,
                                              nsIDocument* aCloneDocument,
                                              nsINode* aCloneOwningNode) const = 0;
 
   bool HasForcedUniqueInner() const { return mDirtyFlags &
                                              FORCED_UNIQUE_INNER; }
   bool HasModifiedRules() const { return mDirtyFlags &
                                          MODIFIED_RULES; }
+  void ClearModifiedRules() { 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