Bug 1541925 - Avoid accounting for @font-face rules the style set when there's no pres shell. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 04 Apr 2019 21:40:55 +0000
changeset 468084 1b9a86e36a4c161794d82f6cadc3a6ccb11dadf4
parent 468083 812b90269ab5eb9a2d775956df789864174d5fb2
child 468085 8b7df8a21b431fa62f9cc57d850102d780388ca6
push id112682
push userbtara@mozilla.com
push dateFri, 05 Apr 2019 09:57:50 +0000
treeherdermozilla-inbound@a9c1e80ab315 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1541925, 1471231
milestone68.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 1541925 - Avoid accounting for @font-face rules the style set when there's no pres shell. r=heycam This preserves the behavior of not having FontFace objects for @font-face rules in display: none iframes. Note, however that we may want to always track stylesheets to both not have this limitation and to fix bug 1471231 & co. But that's a separate bug in any case. The assertion that is failing ultimately in this bug is not really relevant anymore, so remove it while at it. Differential Revision: https://phabricator.services.mozilla.com/D26196
dom/base/Document.cpp
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -11822,35 +11822,36 @@ void Document::FlushUserFontSet() {
   if (!mFontFaceSetDirty) {
     return;
   }
 
   mFontFaceSetDirty = false;
 
   if (gfxPlatform::GetPlatform()->DownloadableFontsEnabled()) {
     nsTArray<nsFontFaceRuleContainer> rules;
-    if (mStyleSetFilled && !mStyleSet->AppendFontFaceRules(rules)) {
-      return;
+    RefPtr<PresShell> presShell = GetPresShell();
+    if (presShell) {
+      MOZ_ASSERT(mStyleSetFilled);
+      mStyleSet->AppendFontFaceRules(rules);
     }
 
     if (!mFontFaceSet && !rules.IsEmpty()) {
       nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(GetScopeObject());
       mFontFaceSet = new FontFaceSet(window, this);
     }
 
     bool changed = false;
     if (mFontFaceSet) {
       changed = mFontFaceSet->UpdateRules(rules);
     }
 
     // We need to enqueue a style change reflow (for later) to
     // reflect that we're modifying @font-face rules.  (However,
     // without a reflow, nothing will happen to start any downloads
     // that are needed.)
-    PresShell* presShell = GetPresShell();
     if (changed && presShell) {
       if (nsPresContext* presContext = presShell->GetPresContext()) {
         presContext->UserFontSetUpdated();
       }
     }
   }
 }
 
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -1207,22 +1207,21 @@ already_AddRefed<ComputedStyle> ServoSty
                                  pseudoTypeForStyleResolution, aRuleInclusion,
                                  &Snapshots(), mRawSet.get())
             .Consume();
   }
 
   return computedValues.forget();
 }
 
-bool ServoStyleSet::AppendFontFaceRules(
+void 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);
 }
 
@@ -1254,18 +1253,16 @@ void ServoStyleSet::UpdateStylist() {
     const ServoElementSnapshotTable* snapshots = nullptr;
     if (nsPresContext* pc = GetPresContext()) {
       snapshots = &pc->RestyleManager()->Snapshots();
     }
     Servo_StyleSet_FlushStyleSheets(mRawSet.get(), root, snapshots);
   }
 
   if (MOZ_UNLIKELY(mStylistState & StylistState::XBLStyleSheetsDirty)) {
-    MOZ_ASSERT(GetPresContext(), "How did they get dirty?");
-
     EnumerateShadowRoots(*mDocument, [&](ShadowRoot& aShadowRoot) {
       if (auto* authorStyles = aShadowRoot.GetServoStyles()) {
         Servo_AuthorStyles_Flush(authorStyles, mRawSet.get());
       }
     });
 
     mDocument->BindingManager()->EnumerateBoundContentProtoBindings(
         [&](nsXBLPrototypeBinding* aProto) {
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -317,17 +317,17 @@ class ServoStyleSet {
       const nsTArray<Keyframe>& aKeyframes, dom::Element* aElement,
       const ComputedStyle* aStyle);
 
   void GetAnimationValues(
       RawServoDeclarationBlock* aDeclarations, dom::Element* aElement,
       const mozilla::ComputedStyle* aStyle,
       nsTArray<RefPtr<RawServoAnimationValue>>& aAnimationValues);
 
-  bool AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
+  void AppendFontFaceRules(nsTArray<nsFontFaceRuleContainer>& aArray);
 
   const RawServoCounterStyleRule* CounterStyleRuleForName(nsAtom* aName);
 
   // Get all the currently-active font feature values set.
   already_AddRefed<gfxFontFeatureValueSet> BuildFontFeatureValueSet();
 
   already_AddRefed<ComputedStyle> GetBaseContextForElement(
       dom::Element* aElement, const ComputedStyle* aStyle);