Bug 1486536 - Explicitly flush the StyleSet from FlushPendingNotifications. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 27 Aug 2018 20:44:20 +0200
changeset 488741 15d80c644e1e8e07c5196d58f6707611c8fac4b0
parent 488740 15e5faa7e1d9a290118f9c05c1480d1f6f3b9a6b
child 488742 a47f6d2d38a4d7e46770f43a137d456fa02525ba
push id9734
push usershindli@mozilla.com
push dateThu, 30 Aug 2018 12:18:07 +0000
treeherdermozilla-beta@71c71ab3afae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1486536
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1486536 - Explicitly flush the StyleSet from FlushPendingNotifications. r=heycam When CSS rules change, we usually do this implicitly from FlushUserFontSet & co. However there's a code path that dirties the stylist but not the CSS rules, and that's when the compat mode changes and we're an SVG document. I don't think that can get hit (easily, at least?), but it's pretty easy to do so and I think this is cleaner too. This fixes that case so the stylist can't assert in that case either, and so that we still rebuild the cascade data so that the hash maps use the right keys for a given quirks-mode. Differential Revision: https://phabricator.services.mozilla.com/D4361
layout/base/PresShell.cpp
layout/style/ServoStyleSet.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -4264,16 +4264,20 @@ PresShell::DoFlushPendingNotifications(m
     mDocument->UpdateSVGUseElementShadowTrees();
 
     // Process pending restyles, since any flush of the presshell wants
     // up-to-date style data.
     if (!mIsDestroying) {
       viewManager->FlushDelayedResize(false);
       mPresContext->FlushPendingMediaFeatureValuesChanged();
 
+      // Now that we have flushed media queries, update the rules before looking
+      // up @font-face / @counter-style / @font-feature-values rules.
+      mStyleSet->UpdateStylistIfNeeded();
+
       // Flush any pending update of the user font set, since that could
       // cause style changes (for updating ex/ch units, and to cause a
       // reflow).
       mDocument->FlushUserFontSet();
 
       mPresContext->FlushCounterStyles();
 
       mPresContext->FlushFontFeatureValues();
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -1406,34 +1406,33 @@ ServoStyleSet::ResolveStyleLazilyInterna
                         aElement->OwnerDoc()->GetBFCacheEntry());
 
   return computedValues.forget();
 }
 
 bool
 ServoStyleSet::AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray)
 {
+  // TODO(emilio): Can we make this so this asserts instead?
   UpdateStylistIfNeeded();
   Servo_StyleSet_GetFontFaceRules(mRawSet.get(), &aArray);
   return true;
 }
 
 const RawServoCounterStyleRule*
 ServoStyleSet::CounterStyleRuleForName(nsAtom* aName)
 {
   MOZ_ASSERT(!StylistNeedsUpdate());
   return Servo_StyleSet_GetCounterStyleRule(mRawSet.get(), aName);
 }
 
 already_AddRefed<gfxFontFeatureValueSet>
 ServoStyleSet::BuildFontFeatureValueSet()
 {
-  // FIXME(emilio): This should assert once we update the stylist from
-  // FlushPendingNotifications explicitly.
-  UpdateStylistIfNeeded();
+  MOZ_ASSERT(!StylistNeedsUpdate());
   RefPtr<gfxFontFeatureValueSet> set =
     Servo_StyleSet_BuildFontFeatureValueSet(mRawSet.get());
   return set.forget();
 }
 
 already_AddRefed<ComputedStyle>
 ServoStyleSet::ResolveForDeclarations(
   const ComputedStyle* aParentOrNull,