Bug 1541952 - Move ApplicableStylesChanged() to Document. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 06 Apr 2019 19:25:25 +0000
changeset 468336 334b4e0ab3f56246cffd972dc52a170e420e4710
parent 468335 83024ed7327b6d06e74624257a92299b0380ee63
child 468337 14a35beff07e14dfcdee8e230747a7ce2fd461e0
push id112710
push userdvarga@mozilla.com
push dateMon, 08 Apr 2019 16:30:07 +0000
treeherdermozilla-inbound@8a568333a0b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1541952
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 1541952 - Move ApplicableStylesChanged() to Document. r=heycam It's the right place for it to be now that it owns the StyleSet. Differential Revision: https://phabricator.services.mozilla.com/D26213
dom/base/Document.cpp
dom/base/Document.h
dom/base/ShadowRoot.cpp
dom/html/nsHTMLDocument.cpp
editor/libeditor/HTMLEditor.cpp
layout/base/PresShell.cpp
layout/base/nsIPresShell.h
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -20,16 +20,17 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/EffectSet.h"
 #include "mozilla/EnumSet.h"
 #include "mozilla/IdentifierMapEntry.h"
 #include "mozilla/IntegerRange.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/Likely.h"
 #include "mozilla/PresShell.h"
+#include "mozilla/RestyleManager.h"
 #include "mozilla/StaticPrefs.h"
 #include "mozilla/URLExtraData.h"
 #include <algorithm>
 
 #include "mozilla/Logging.h"
 #include "plstr.h"
 #include "mozilla/Sprintf.h"
 
@@ -2255,19 +2256,17 @@ void Document::ResetStylesheetsToURI(nsI
   if (!mStyleAttrStyleSheet) {
     mStyleAttrStyleSheet = new nsHTMLCSSStyleSheet();
   }
 
   if (mStyleSetFilled) {
     FillStyleSetDocumentSheets();
 
     if (mStyleSet->StyleSheetsHaveChanged()) {
-      if (PresShell* presShell = GetPresShell()) {
-        presShell->ApplicableStylesChanged();
-      }
+      ApplicableStylesChanged();
     }
   }
 }
 
 static void AppendSheetsToStyleSet(ServoStyleSet* aStyleSet,
                                    const nsTArray<RefPtr<StyleSheet>>& aSheets,
                                    SheetType aType) {
   for (StyleSheet* sheet : Reversed(aSheets)) {
@@ -2387,19 +2386,17 @@ void Document::CompatibilityModeChanged(
   auto cache = nsLayoutStylesheetCache::Singleton();
   StyleSheet* sheet = cache->QuirkSheet();
   if (mQuirkSheetAdded) {
     mStyleSet->RemoveStyleSheet(SheetType::Agent, sheet);
   } else {
     mStyleSet->AppendStyleSheet(SheetType::Agent, sheet);
   }
   mQuirkSheetAdded = !mQuirkSheetAdded;
-  if (PresShell* presShell = GetPresShell()) {
-    presShell->ApplicableStylesChanged();
-  }
+  ApplicableStylesChanged();
 }
 
 static void WarnIfSandboxIneffective(nsIDocShell* aDocShell,
                                      uint32_t aSandboxFlags,
                                      nsIChannel* aChannel) {
   // If the document is sandboxed (via the HTML5 iframe sandbox
   // attribute) and both the allow-scripts and allow-same-origin
   // keywords are supplied, the sandboxed document can call into its
@@ -3991,20 +3988,47 @@ void Document::RemoveChildNode(nsIConten
   MOZ_ASSERT(mCachedRootElement != aKid,
              "Stale pointer in mCachedRootElement, after we tried to clear it "
              "(maybe somebody called GetRootElement() too early?)");
 }
 
 void Document::AddStyleSheetToStyleSets(StyleSheet* aSheet) {
   if (mStyleSetFilled) {
     mStyleSet->AddDocStyleSheet(aSheet, this);
-    if (PresShell* presShell = GetPresShell()) {
-      presShell->ApplicableStylesChanged();
-    }
-  }
+    ApplicableStylesChanged();
+  }
+}
+
+void Document::RecordShadowStyleChange(ShadowRoot& aShadowRoot) {
+  mStyleSet->RecordShadowStyleChange(aShadowRoot);
+  ApplicableStylesChanged();
+}
+
+void Document::ApplicableStylesChanged() {
+  // TODO(emilio): if we decide to resolve style in display: none iframes, then
+  // we need to always track style changes and remove the mStyleSetFilled.
+  if (!mStyleSetFilled) {
+    return;
+  }
+
+  MarkUserFontSetDirty();
+  PresShell* ps = GetPresShell();
+  if (!ps) {
+    return;
+  }
+
+  ps->EnsureStyleFlush();
+  nsPresContext* pc = ps->GetPresContext();
+  if (!pc) {
+    return;
+  }
+
+  pc->MarkCounterStylesDirty();
+  pc->MarkFontFeatureValuesDirty();
+  pc->RestyleManager()->NextRestyleIsForCSSRuleChanges();
 }
 
 #define DO_STYLESHEET_NOTIFICATION(className, type, memberName, argName) \
   do {                                                                   \
     className##Init init;                                                \
     init.mBubbles = true;                                                \
     init.mCancelable = true;                                             \
     init.mStylesheet = aSheet;                                           \
@@ -4033,19 +4057,17 @@ void Document::NotifyStyleSheetRemoved(S
     DO_STYLESHEET_NOTIFICATION(StyleSheetChangeEvent, "StyleSheetRemoved",
                                mDocumentSheet, aDocumentSheet);
   }
 }
 
 void Document::RemoveStyleSheetFromStyleSets(StyleSheet* aSheet) {
   if (mStyleSetFilled) {
     mStyleSet->RemoveDocStyleSheet(aSheet);
-    if (PresShell* presShell = GetPresShell()) {
-      presShell->ApplicableStylesChanged();
-    }
+    ApplicableStylesChanged();
   }
 }
 
 void Document::RemoveStyleSheet(StyleSheet* aSheet) {
   MOZ_ASSERT(aSheet);
   RefPtr<StyleSheet> sheet = DocumentOrShadowRoot::RemoveSheet(*aSheet);
 
   if (!sheet) {
@@ -4218,19 +4240,17 @@ nsresult Document::AddAdditionalStyleShe
 
   if (!aSheet->IsApplicable()) return NS_ERROR_INVALID_ARG;
 
   mAdditionalSheets[aType].AppendElement(aSheet);
 
   if (mStyleSetFilled) {
     SheetType type = ConvertAdditionalSheetType(aType);
     mStyleSet->AppendStyleSheet(type, aSheet);
-    if (PresShell* presShell = GetPresShell()) {
-      presShell->ApplicableStylesChanged();
-    }
+    ApplicableStylesChanged();
   }
 
   // Passing false, so documet.styleSheets.length will not be affected by
   // these additional sheets.
   NotifyStyleSheetAdded(aSheet, false);
   return NS_OK;
 }
 
@@ -4245,19 +4265,17 @@ void Document::RemoveAdditionalStyleShee
     RefPtr<StyleSheet> sheetRef = sheets[i];
     sheets.RemoveElementAt(i);
 
     if (!mIsGoingAway) {
       MOZ_ASSERT(sheetRef->IsApplicable());
       if (mStyleSetFilled) {
         SheetType type = ConvertAdditionalSheetType(aType);
         mStyleSet->RemoveStyleSheet(type, sheetRef);
-        if (PresShell* presShell = GetPresShell()) {
-          presShell->ApplicableStylesChanged();
-        }
+        ApplicableStylesChanged();
       }
     }
 
     // Passing false, so documet.styleSheets.length will not be affected by
     // these additional sheets.
     NotifyStyleSheetRemoved(sheetRef, false);
     sheetRef->ClearAssociatedDocumentOrShadowRoot();
   }
@@ -5027,45 +5045,39 @@ void Document::ContentStateChanged(nsICo
 }
 
 void Document::DocumentStatesChanged(EventStates aStateMask) {
   UpdateDocumentStates(aStateMask);
   NS_DOCUMENT_NOTIFY_OBSERVERS(DocumentStatesChanged, (this, aStateMask));
 }
 
 void Document::StyleRuleChanged(StyleSheet* aSheet, css::Rule* aStyleRule) {
-  if (PresShell* presShell = GetPresShell()) {
-    presShell->ApplicableStylesChanged();
-  }
+  ApplicableStylesChanged();
 
   if (!StyleSheetChangeEventsEnabled()) {
     return;
   }
 
   DO_STYLESHEET_NOTIFICATION(StyleRuleChangeEvent, "StyleRuleChanged", mRule,
                              aStyleRule);
 }
 
 void Document::StyleRuleAdded(StyleSheet* aSheet, css::Rule* aStyleRule) {
-  if (PresShell* presShell = GetPresShell()) {
-    presShell->ApplicableStylesChanged();
-  }
+  ApplicableStylesChanged();
 
   if (!StyleSheetChangeEventsEnabled()) {
     return;
   }
 
   DO_STYLESHEET_NOTIFICATION(StyleRuleChangeEvent, "StyleRuleAdded", mRule,
                              aStyleRule);
 }
 
 void Document::StyleRuleRemoved(StyleSheet* aSheet, css::Rule* aStyleRule) {
-  if (PresShell* presShell = GetPresShell()) {
-    presShell->ApplicableStylesChanged();
-  }
+  ApplicableStylesChanged();
 
   if (!StyleSheetChangeEventsEnabled()) {
     return;
   }
 
   DO_STYLESHEET_NOTIFICATION(StyleRuleChangeEvent, "StyleRuleRemoved", mRule,
                              aStyleRule);
 }
@@ -5583,20 +5595,18 @@ void Document::EnableStyleSheetsForSetIn
     sheet->GetTitle(title);
     if (!title.IsEmpty()) {
       sheet->SetEnabled(title.Equals(aSheetSet));
     }
   }
   if (aUpdateCSSLoader) {
     CSSLoader()->DocumentStyleSheetSetChanged();
   }
-  if (PresShell* presShell = GetPresShell()) {
-    if (presShell->StyleSet()->StyleSheetsHaveChanged()) {
-      presShell->ApplicableStylesChanged();
-    }
+  if (mStyleSet->StyleSheetsHaveChanged()) {
+    ApplicableStylesChanged();
   }
 }
 
 void Document::GetCharacterSet(nsAString& aCharacterSet) const {
   nsAutoCString charset;
   GetDocumentCharacterSet()->Name(charset);
   CopyASCIItoUTF16(charset, aCharacterSet);
 }
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -1630,16 +1630,24 @@ class Document : public nsINode,
   void SetBody(nsGenericHTMLElement* aBody, ErrorResult& rv);
   // Get the "head" element in the sense of document.head.
   HTMLSharedElement* GetHead();
 
   ServoStyleSet* StyleSetForPresShellOrMediaQueryEvaluation() const {
     return mStyleSet.get();
   }
 
+  // ShadowRoot has APIs that can change styles. This notifies the shell that
+  // stlyes applicable in the shadow tree have potentially changed.
+  void RecordShadowStyleChange(ShadowRoot&);
+
+  // Needs to be called any time the applicable style can has changed, in order
+  // to schedule a style flush and setup all the relevant state.
+  void ApplicableStylesChanged();
+
   // Whether we filled the style set with any style sheet. Only meant to be used
   // from DocumentOrShadowRoot::Traverse.
   bool StyleSetFilled() const { return mStyleSetFilled; }
 
   /**
    * Accessors to the collection of stylesheets owned by this document.
    * Style sheets are ordered, most significant last.
    */
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -325,23 +325,18 @@ void ShadowRoot::RuleChanged(StyleSheet&
   }
 
   MOZ_ASSERT(mServoStyles);
   Servo_AuthorStyles_ForceDirty(mServoStyles.get());
   ApplicableRulesChanged();
 }
 
 void ShadowRoot::ApplicableRulesChanged() {
-  Document* doc = GetComposedDoc();
-  if (!doc) {
-    return;
-  }
-
-  if (PresShell* presShell = doc->GetPresShell()) {
-    presShell->RecordShadowStyleChange(*this);
+  if (Document* doc = GetComposedDoc()) {
+    doc->RecordShadowStyleChange(*this);
   }
 }
 
 void ShadowRoot::InsertSheetAt(size_t aIndex, StyleSheet& aSheet) {
   DocumentOrShadowRoot::InsertSheetAt(aIndex, aSheet);
   if (aSheet.IsApplicable()) {
     InsertSheetIntoAuthorData(aIndex, aSheet);
   }
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -1879,18 +1879,17 @@ void nsHTMLDocument::TearingDownEditor()
 
     auto cache = nsLayoutStylesheetCache::Singleton();
 
     agentSheets.RemoveElement(cache->ContentEditableSheet());
     if (oldState == eDesignMode)
       agentSheets.RemoveElement(cache->DesignModeSheet());
 
     presShell->SetAgentStyleSheets(agentSheets);
-
-    presShell->ApplicableStylesChanged();
+    ApplicableStylesChanged();
   }
 }
 
 nsresult nsHTMLDocument::TurnEditingOff() {
   NS_ASSERTION(mEditingState != eOff, "Editing is already off.");
 
   nsPIDOMWindowOuter* window = GetWindow();
   if (!window) return NS_ERROR_FAILURE;
@@ -2050,17 +2049,17 @@ nsresult nsHTMLDocument::EditingStateCha
       // designMode is being turned off (contentEditable is still on).
       agentSheets.RemoveElement(cache->DesignModeSheet());
       updateState = true;
     }
 
     rv = presShell->SetAgentStyleSheets(agentSheets);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    presShell->ApplicableStylesChanged();
+    ApplicableStylesChanged();
 
     // Adjust focused element with new style but blur event shouldn't be fired
     // until mEditingState is modified with newState.
     nsAutoScriptBlocker scriptBlocker;
     if (designMode) {
       nsCOMPtr<nsPIDOMWindowOuter> focusedWindow;
       nsIContent* focusedContent = nsFocusManager::GetFocusedDescendant(
           window, nsFocusManager::eOnlyCurrentWindow,
--- a/editor/libeditor/HTMLEditor.cpp
+++ b/editor/libeditor/HTMLEditor.cpp
@@ -3100,17 +3100,17 @@ nsresult HTMLEditor::AddOverrideStyleShe
   // Synchronous loads should ALWAYS return completed
   if (NS_WARN_IF(!sheet)) {
     return NS_ERROR_FAILURE;
   }
 
   // Add the override style sheet
   // (This checks if already exists)
   presShell->AddOverrideStyleSheet(sheet);
-  presShell->ApplicableStylesChanged();
+  presShell->GetDocument()->ApplicableStylesChanged();
 
   // Save as the last-loaded sheet
   mLastOverrideStyleSheetURL = aURL;
 
   // Add URL and style sheet to our lists
   rv = AddNewStyleSheetToList(aURL, sheet);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -3178,17 +3178,17 @@ nsresult HTMLEditor::RemoveOverrideStyle
   }
 
   RefPtr<PresShell> presShell = GetPresShell();
   if (NS_WARN_IF(!presShell)) {
     return NS_ERROR_NOT_INITIALIZED;
   }
 
   presShell->RemoveOverrideStyleSheet(sheet);
-  presShell->ApplicableStylesChanged();
+  presShell->GetDocument()->ApplicableStylesChanged();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 HTMLEditor::EnableStyleSheet(const nsAString& aURL, bool aEnable) {
   AutoEditActionDataSetter editActionData(*this, EditAction::eEnableStyleSheet);
   if (NS_WARN_IF(!editActionData.CanHandle())) {
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -1393,17 +1393,17 @@ void nsIPresShell::StartObservingRefresh
 
 nsRefreshDriver* nsIPresShell::GetRefreshDriver() const {
   return mPresContext ? mPresContext->RefreshDriver() : nullptr;
 }
 
 void nsIPresShell::SetAuthorStyleDisabled(bool aStyleDisabled) {
   if (aStyleDisabled != StyleSet()->GetAuthorStyleDisabled()) {
     StyleSet()->SetAuthorStyleDisabled(aStyleDisabled);
-    ApplicableStylesChanged();
+    mDocument->ApplicableStylesChanged();
 
     nsCOMPtr<nsIObserverService> observerService =
         mozilla::services::GetObserverService();
     if (observerService) {
       observerService->NotifyObservers(
           ToSupports(mDocument), "author-style-disabled-changed", nullptr);
     }
   }
@@ -1487,43 +1487,43 @@ void nsIPresShell::AddUserSheet(StyleShe
 
   if (index == static_cast<size_t>(StyleSet()->SheetCount(SheetType::User))) {
     StyleSet()->AppendStyleSheet(SheetType::User, aSheet);
   } else {
     StyleSheet* ref = StyleSet()->StyleSheetAt(SheetType::User, index);
     StyleSet()->InsertStyleSheetBefore(SheetType::User, aSheet, ref);
   }
 
-  ApplicableStylesChanged();
+  mDocument->ApplicableStylesChanged();
 }
 
 void nsIPresShell::AddAgentSheet(StyleSheet* aSheet) {
   // Make sure this does what nsDocumentViewer::CreateStyleSet does
   // wrt ordering.
   StyleSet()->AppendStyleSheet(SheetType::Agent, aSheet);
-  ApplicableStylesChanged();
+  mDocument->ApplicableStylesChanged();
 }
 
 void nsIPresShell::AddAuthorSheet(StyleSheet* aSheet) {
   // Document specific "additional" Author sheets should be stronger than the
   // ones added with the StyleSheetService.
   StyleSheet* firstAuthorSheet = mDocument->GetFirstAdditionalAuthorSheet();
   if (firstAuthorSheet) {
     StyleSet()->InsertStyleSheetBefore(SheetType::Doc, aSheet,
                                        firstAuthorSheet);
   } else {
     StyleSet()->AppendStyleSheet(SheetType::Doc, aSheet);
   }
 
-  ApplicableStylesChanged();
+  mDocument->ApplicableStylesChanged();
 }
 
 void nsIPresShell::RemoveSheet(SheetType aType, StyleSheet* aSheet) {
   StyleSet()->RemoveStyleSheet(aType, aSheet);
-  ApplicableStylesChanged();
+  mDocument->ApplicableStylesChanged();
 }
 
 NS_IMETHODIMP
 PresShell::SetDisplaySelection(int16_t aToggle) {
   RefPtr<nsFrameSelection> frameSelection = mSelection;
   frameSelection->SetDisplaySelection(aToggle);
   return NS_OK;
 }
@@ -4378,32 +4378,16 @@ void PresShell::ReconstructFrames() {
     return;
   }
 
   nsAutoCauseReflowNotifier crNotifier(this);
   mFrameConstructor->ReconstructDocElementHierarchy(
       nsCSSFrameConstructor::InsertionKind::Sync);
 }
 
-void nsIPresShell::ApplicableStylesChanged() {
-  if (mIsDestroying) {
-    // We don't want to mess with restyles at this point
-    return;
-  }
-
-  EnsureStyleFlush();
-  mDocument->MarkUserFontSetDirty();
-
-  if (mPresContext) {
-    mPresContext->MarkCounterStylesDirty();
-    mPresContext->MarkFontFeatureValuesDirty();
-    mPresContext->RestyleManager()->NextRestyleIsForCSSRuleChanges();
-  }
-}
-
 nsresult PresShell::RenderDocument(const nsRect& aRect, uint32_t aFlags,
                                    nscolor aBackgroundColor,
                                    gfxContext* aThebesContext) {
   NS_ENSURE_TRUE(!(aFlags & RENDER_IS_UNTRUSTED), NS_ERROR_NOT_IMPLEMENTED);
 
   nsRootPresContext* rootPresContext = mPresContext->GetRootPresContext();
   if (rootPresContext) {
     rootPresContext->FlushWillPaintObservers();
@@ -5885,21 +5869,16 @@ class nsAutoNotifyDidPaint {
     }
   }
 
  private:
   PresShell* mShell;
   uint32_t mFlags;
 };
 
-void nsIPresShell::RecordShadowStyleChange(ShadowRoot& aShadowRoot) {
-  StyleSet()->RecordShadowStyleChange(aShadowRoot);
-  ApplicableStylesChanged();
-}
-
 void PresShell::Paint(nsView* aViewToPaint, const nsRegion& aDirtyRegion,
                       uint32_t aFlags) {
   nsCString url;
   nsIURI* uri = mDocument->GetDocumentURI();
   Document* contentRoot = GetPrimaryContentDocument();
   if (contentRoot) {
     uri = contentRoot->GetDocumentURI();
   }
--- a/layout/base/nsIPresShell.h
+++ b/layout/base/nsIPresShell.h
@@ -282,22 +282,16 @@ class nsIPresShell : public nsStubDocume
    * entire author level of the cascade, including the HTML preshint level.
    */
   // XXX these could easily be inlined, but there is a circular #include
   // problem with nsStyleSet.
   void SetAuthorStyleDisabled(bool aDisabled);
   bool GetAuthorStyleDisabled() const;
 
   /**
-   * Needs to be called any time the applicable style can has changed, in order
-   * to schedule a style flush and setup all the relevant state.
-   */
-  void ApplicableStylesChanged();
-
-  /**
    * Update the style set somehow to take into account changed prefs which
    * affect document styling.
    */
   void UpdatePreferenceStyles();
 
   /**
    * FrameSelection will return the Frame based selection API.
    * You cannot go back and forth anymore with QI between nsIDOM sel and
@@ -530,20 +524,16 @@ class nsIPresShell : public nsStubDocume
    */
   void SlotAssignmentWillChange(mozilla::dom::Element& aElement,
                                 mozilla::dom::HTMLSlotElement* aOldSlot,
                                 mozilla::dom::HTMLSlotElement* aNewSlot);
 
   void PostRecreateFramesFor(mozilla::dom::Element*);
   void RestyleForAnimation(mozilla::dom::Element*, mozilla::RestyleHint);
 
-  // ShadowRoot has APIs that can change styles. This notifies the shell that
-  // stlyes applicable in the shadow tree have potentially changed.
-  void RecordShadowStyleChange(mozilla::dom::ShadowRoot& aShadowRoot);
-
   /**
    * Determine if it is safe to flush all pending notifications.
    */
   bool IsSafeToFlush() const;
 
   /**
    * Informs the document's FontFaceSet that the refresh driver ticked,
    * flushing style and layout.
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -109,42 +109,33 @@ ServoStyleSet::~ServoStyleSet() {
     }
   }
 }
 
 nsPresContext* ServoStyleSet::GetPresContext() {
   return mDocument->GetPresContext();
 }
 
-void ServoStyleSet::ShellAttachedToDocument() {
-  // We may have Shadow DOM style changes that we weren't notified about because
-  // the document didn't have a shell, if the ShadowRoot was created in a
-  // display: none iframe.
-  //
-  // Now that we got a shell, we may need to get them up-to-date.
-  //
-  // TODO(emilio, bug 1418159): This wouldn't be needed if the StyleSet was
-  // owned by the document.
-  SetStylistXBLStyleSheetsDirty();
-}
-
 template <typename Functor>
 void EnumerateShadowRoots(const Document& aDoc, const Functor& aCb) {
   const Document::ShadowRootSet& shadowRoots = aDoc.ComposedShadowRoots();
   for (auto iter = shadowRoots.ConstIter(); !iter.Done(); iter.Next()) {
     ShadowRoot* root = iter.Get()->GetKey();
     MOZ_ASSERT(root);
     MOZ_DIAGNOSTIC_ASSERT(root->IsInComposedDoc());
     aCb(*root);
   }
 }
 
 void ServoStyleSet::ShellDetachedFromDocument() {
   // Make sure we drop our cached styles before the presshell arena starts going
   // away.
+  //
+  // TODO(emilio): The presshell arena comment is no longer relevant. We could
+  // avoid doing this if we wanted to.
   ClearNonInheritingComputedStyles();
   mStyleRuleMap = nullptr;
 }
 
 void ServoStyleSet::RecordShadowStyleChange(ShadowRoot& aShadowRoot) {
   // TODO(emilio): We could keep track of the actual shadow roots that need
   // their styles recomputed.
   SetStylistXBLStyleSheetsDirty();
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -93,17 +93,16 @@ class ServoStyleSet {
   static bool IsCurrentThreadInServoTraversal();
 #endif
 
   static ServoStyleSet* Current() { return sInServoTraversal; }
 
   explicit ServoStyleSet(dom::Document&);
   ~ServoStyleSet();
 
-  void ShellAttachedToDocument();
   void ShellDetachedFromDocument();
 
   // Called when a rules in a stylesheet in this set, or a child sheet of that,
   // are mutated from CSSOM.
   void RuleAdded(StyleSheet&, css::Rule&);
   void RuleRemoved(StyleSheet&, css::Rule&);
   void RuleChanged(StyleSheet& aSheet, css::Rule* aRule);