Bug 1374181 Part 1: Don't attempt EnsureUniqueInner on incomplete sheets in a StyleSet.
One remaining issue is that requesters of CSSRules might also want to know if those rules are complete, and to listen for completion if the rules are incomplete.
Bug 1404538 will fix this up at least for devtools.
MozReview-Commit-ID: COnkS40Ooe2
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -1274,17 +1274,25 @@ ServoStyleSet::EnsureUniqueInnerOnCSSShe
// Bug 1290276 will replicate the nsStyleSet work of checking
// a nsBindingManager
while (!queue.IsEmpty()) {
uint32_t idx = queue.Length() - 1;
StyleSheet* sheet = queue[idx];
queue.RemoveElementAt(idx);
- sheet->EnsureUniqueInner();
+ // Only call EnsureUniqueInner for complete sheets. If we do call it on
+ // incomplete sheets, we'll cause problems when the sheet is actually
+ // loaded. We don't care about incomplete sheets here anyway, because this
+ // method is only invoked by nsPresContext::EnsureSafeToHandOutCSSRules.
+ // The CSSRule objects we are handing out won't contain any rules derived
+ // from incomplete sheets (because they aren't yet applied in styling).
+ if (sheet->IsComplete()) {
+ sheet->EnsureUniqueInner();
+ }
// Enqueue all the sheet's children.
sheet->AppendAllChildSheets(queue);
}
if (mNeedsRestyleAfterEnsureUniqueInner) {
// TODO(emilio): We could make this faster if needed tracking the specific
// origins and all that, but the only caller of this doesn't seem to really
--- a/layout/style/nsStyleSet.cpp
+++ b/layout/style/nsStyleSet.cpp
@@ -2724,17 +2724,25 @@ nsStyleSet::EnsureUniqueInnerOnCSSSheets
}
}
while (!queue.IsEmpty()) {
uint32_t idx = queue.Length() - 1;
StyleSheet* sheet = queue[idx];
queue.RemoveElementAt(idx);
- sheet->EnsureUniqueInner();
+ // Only call EnsureUniqueInner for complete sheets. If we do call it on
+ // incomplete sheets, we'll cause problems when the sheet is actually
+ // loaded. We don't care about incomplete sheets here anyway, because this
+ // method is only invoked by nsPresContext::EnsureSafeToHandOutCSSRules.
+ // The CSSRule objects we are handing out won't contain any rules derived
+ // from incomplete sheets (because they aren't yet applied in styling).
+ if (sheet->IsComplete()) {
+ sheet->EnsureUniqueInner();
+ }
// Enqueue all the sheet's children.
sheet->AppendAllChildSheets(queue);
}
bool res = mNeedsRestyleAfterEnsureUniqueInner;
mNeedsRestyleAfterEnsureUniqueInner = false;
return res;