Bug 1352968 part 9 - Notify document about rule insertion only if a rule doesn't have pending child sheet. r=heycam draft
authorXidorn Quan <me@upsuper.org>
Tue, 02 May 2017 11:39:32 +0800
changeset 586234 17633a6e12bf4f9651d35ae0c40fa2b6bca2faa0
parent 586233 cedc65c6376373d54e623dc5cfadaa2de92909cb
child 586235 7e4d56217e0b2ea883b3b803d44e95aca5342c48
push id61334
push userxquan@mozilla.com
push dateTue, 30 May 2017 01:07:29 +0000
reviewersheycam
bugs1352968
milestone55.0a1
Bug 1352968 part 9 - Notify document about rule insertion only if a rule doesn't have pending child sheet. r=heycam MozReview-Commit-ID: 3ADpnJuhHXf
layout/style/ServoStyleSheet.cpp
--- a/layout/style/ServoStyleSheet.cpp
+++ b/layout/style/ServoStyleSheet.cpp
@@ -242,22 +242,23 @@ ServoStyleSheet::InsertRuleInternal(cons
   // Ensure mRuleList is constructed.
   GetCssRulesInternal(aRv);
 
   mozAutoDocUpdate updateBatch(mDocument, UPDATE_STYLE, true);
   aRv = mRuleList->InsertRule(aRule, aIndex);
   if (aRv.Failed()) {
     return 0;
   }
-  // XXX If the inserted rule is an import rule, we should only notify
-  // the document if its associated child stylesheet has been loaded.
   if (mDocument) {
-    // XXX We may not want to get the rule when stylesheet change event
-    // is not enabled.
-    mDocument->StyleRuleAdded(this, mRuleList->GetRule(aIndex));
+    if (mRuleList->GetRuleType(aIndex) != css::Rule::IMPORT_RULE ||
+        !RuleHasPendingChildSheet(mRuleList->GetRule(aIndex))) {
+      // XXX We may not want to get the rule when stylesheet change event
+      // is not enabled.
+      mDocument->StyleRuleAdded(this, mRuleList->GetRule(aIndex));
+    }
   }
   return aIndex;
 }
 
 void
 ServoStyleSheet::DeleteRuleInternal(uint32_t aIndex, ErrorResult& aRv)
 {
   // Ensure mRuleList is constructed.