Bug 1347381: Tell Servo earlier about stylesheet changes. r?heycam
MozReview-Commit-ID: 4FcFzvSTckm
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -4575,34 +4575,40 @@ nsIPresShell::RestyleForCSSRuleChanges()
}
mDocument->RebuildUserFontSet();
if (mPresContext) {
mPresContext->RebuildCounterStyles();
}
+ // Tell Servo that the contents of style sheets have changed.
+ //
+ // NB: It's important to do so before bailing out.
+ //
+ // Even if we have no frames, we can end up styling those when creating
+ // them, and it's important for Servo to know that it needs to use the
+ // correct styles.
+ if (mStyleSet->IsServo()) {
+ mStyleSet->AsServo()->NoteStyleSheetsChanged();
+ }
+
Element* root = mDocument->GetRootElement();
if (!mDidInitialize) {
// Nothing to do here, since we have no frames yet
return;
}
if (!root) {
// No content to restyle
return;
}
RestyleManager* restyleManager = mPresContext->RestyleManager();
- if (mStyleSet->IsServo()) {
- // Tell Servo that the contents of style sheets have changed.
- mStyleSet->AsServo()->NoteStyleSheetsChanged();
- }
-
if (scopeRoots.IsEmpty()) {
// If scopeRoots is empty, we know that mStylesHaveChanged was true at
// the beginning of this function, and that we need to restyle the whole
// document.
restyleManager->PostRestyleEvent(root, eRestyle_Subtree,
nsChangeHint(0));
} else {
for (Element* scopeRoot : scopeRoots) {