Bug 1457102: Ensure a style flush happens after a compat mode change. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 26 Apr 2018 16:11:48 +0200
changeset 788399 8b1910d875a10e9c89ac22a9a6d56302f1eb4b4b
parent 788398 c073567bd8dd67289d54fad1925902718b9feece
child 788676 41a8ca71812dbb65bcf98f3ef8679a51379ccb60
push id107983
push userbmo:emilio@crisal.io
push dateThu, 26 Apr 2018 14:14:28 +0000
reviewersheycam
bugs1457102
milestone61.0a1
Bug 1457102: Ensure a style flush happens after a compat mode change. r?heycam This is the actual fix. The compat mode changed (well, it didn't), but we were not scheduling a style flush. Then someone called getComputedStyle on an element in this document, and the styles were thought clean, thus we didn't flush style, and we assert when style resolution happened. MozReview-Commit-ID: KkM6NwzD640
layout/base/nsPresContext.cpp
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1171,25 +1171,22 @@ nsPresContext::GetRootPresContext()
 
 void
 nsPresContext::CompatibilityModeChanged()
 {
   if (!mShell) {
     return;
   }
 
-  nsIDocument* doc = mShell->GetDocument();
-  if (!doc) {
-    return;
-  }
-
   ServoStyleSet* styleSet = mShell->StyleSet();
   styleSet->CompatibilityModeChanged();
 
-  if (doc->IsSVGDocument()) {
+  mShell->EnsureStyleFlush();
+
+  if (mDocument->IsSVGDocument()) {
     // SVG documents never load quirk.css.
     return;
   }
 
   bool needsQuirkSheet = CompatibilityMode() == eCompatibility_NavQuirks;
   if (mQuirkSheetAdded == needsQuirkSheet) {
     return;
   }