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
--- 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.