Bug 1459529: Remove ServoStyleSet::{Begin,End}Update. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 11 May 2018 13:04:08 +0200
changeset 418335 f04194f1a3d07c4f838101417eccf770fb354df4
parent 418334 699f1d745e76e50106be19aa30116b0a31453471
child 418336 0c1c3fb200c0c7ba67fe99b06574e823709da712
push id33998
push userdluca@mozilla.com
push dateTue, 15 May 2018 21:53:06 +0000
treeherdermozilla-central@9260cc524bb5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1459529
milestone62.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 1459529: Remove ServoStyleSet::{Begin,End}Update. r=heycam They're empty, and make PresShell::BeginUpdate useless. Now we don't have document observers that listen for these anymore. MozReview-Commit-ID: GpDDNonFUFC
layout/base/PresShell.cpp
layout/base/nsDocumentViewer.cpp
layout/printing/nsPrintJob.cpp
layout/style/ServoStyleSet.cpp
layout/style/ServoStyleSet.h
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -1493,28 +1493,24 @@ PresShell::UpdatePreferenceStyles()
     mPresContext->IsChromeOriginImage() ?
       cache->ChromePreferenceSheet(mPresContext) :
       cache->ContentPreferenceSheet(mPresContext);
 
   if (mPrefStyleSheet == newPrefSheet) {
     return;
   }
 
-  mStyleSet->BeginUpdate();
-
   RemovePreferenceStyles();
 
   // NOTE(emilio): This sheet is added as an agent sheet, because we don't want
   // it to be modifiable from devtools and similar, see bugs 1239336 and
   // 1436782. I think it conceptually should be a user sheet, and could be
   // without too much trouble I'd think.
   mStyleSet->AppendStyleSheet(SheetType::Agent, newPrefSheet);
   mPrefStyleSheet = newPrefSheet;
-
-  mStyleSet->EndUpdate();
 }
 
 void
 PresShell::RemovePreferenceStyles()
 {
   if (mPrefStyleSheet) {
     mStyleSet->RemoveStyleSheet(SheetType::Agent, mPrefStyleSheet);
     mPrefStyleSheet = nullptr;
@@ -1527,33 +1523,30 @@ PresShell::AddUserSheet(StyleSheet* aShe
   // Make sure this does what nsDocumentViewer::CreateStyleSet does wrt
   // ordering. We want this new sheet to come after all the existing stylesheet
   // service sheets, but before other user sheets; see nsIStyleSheetService.idl
   // for the ordering.  Just remove and readd all the nsStyleSheetService
   // sheets.
   nsCOMPtr<nsIStyleSheetService> dummy =
     do_GetService(NS_STYLESHEETSERVICE_CONTRACTID);
 
-  mStyleSet->BeginUpdate();
-
   nsStyleSheetService* sheetService = nsStyleSheetService::gInstance;
   nsTArray<RefPtr<StyleSheet>>& userSheets = *sheetService->UserStyleSheets();
   // Iterate forwards when removing so the searches for RemoveStyleSheet are as
   // short as possible.
   for (StyleSheet* sheet : userSheets) {
     mStyleSet->RemoveStyleSheet(SheetType::User, sheet);
   }
 
   // Now iterate backwards, so that the order of userSheets will be the same as
   // the order of sheets from it in the style set.
   for (StyleSheet* sheet : Reversed(userSheets)) {
     mStyleSet->PrependStyleSheet(SheetType::User, sheet);
   }
 
-  mStyleSet->EndUpdate();
   RestyleForCSSRuleChanges();
 }
 
 void
 PresShell::AddAgentSheet(StyleSheet* aSheet)
 {
   // Make sure this does what nsDocumentViewer::CreateStyleSet does
   // wrt ordering.
@@ -2529,30 +2522,27 @@ PresShell::GetCanvasFrame() const
 }
 
 void
 PresShell::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
 {
 #ifdef DEBUG
   mUpdateCount++;
 #endif
-  if (aUpdateType & UPDATE_STYLE)
-    mStyleSet->BeginUpdate();
 }
 
 void
 PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
 {
 #ifdef DEBUG
   MOZ_ASSERT(0 != mUpdateCount, "too many EndUpdate's");
   --mUpdateCount;
 #endif
 
   if (aUpdateType & UPDATE_STYLE) {
-    mStyleSet->EndUpdate();
     if (mStyleSet->StyleSheetsHaveChanged()) {
       RestyleForCSSRuleChanges();
     }
   }
 }
 
 void
 PresShell::RestoreRootScrollPosition()
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -686,19 +686,16 @@ nsDocumentViewer::InitPresentationStuff(
 
   // Now make the shell for the document
   mPresShell = mDocument->CreateShell(mPresContext, mViewManager,
                                       mozilla::Move(styleSet));
   if (!mPresShell) {
     return NS_ERROR_FAILURE;
   }
 
-  // We're done creating the style set
-  mPresShell->StyleSet()->EndUpdate();
-
   if (aDoInitialReflow) {
     // Since Initialize() will create frames for *all* items
     // that are currently in the document tree, we need to flush
     // any pending notifications to prevent the content sink from
     // duplicating layout frames for content it has added to the tree
     // but hasn't notified the document about. (Bug 154018)
     //
     // Note that we are flushing before we add mPresShell as an observer
@@ -2310,31 +2307,27 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
 {
   // Make sure this does the same thing as PresShell::AddSheet wrt ordering.
 
   // this should eventually get expanded to allow for creating
   // different sets for different media
 
   UniquePtr<ServoStyleSet> styleSet = MakeUnique<ServoStyleSet>();
 
-  styleSet->BeginUpdate();
-
   // The document will fill in the document sheets when we create the presshell
 
   if (aDocument->IsBeingUsedAsImage()) {
     MOZ_ASSERT(aDocument->IsSVGDocument(),
                "Do we want to skip most sheets for this new image type?");
 
     // SVG-as-an-image must be kept as light and small as possible. We
     // deliberately skip loading everything and leave svg.css (and html.css and
     // xul.css) to be loaded on-demand.
     // XXXjwatt Nothing else is loaded on-demand, but I don't think that
     // should matter for SVG-as-an-image. If it does, I want to know why!
-
-    // Caller will handle calling EndUpdate, per contract.
     return styleSet;
   }
 
   auto cache = nsLayoutStylesheetCache::Singleton();
 
   // Handle the user sheets.
   StyleSheet* sheet = nullptr;
   if (nsContentUtils::IsInChromeDocshell(aDocument)) {
@@ -2431,17 +2424,16 @@ nsDocumentViewer::CreateStyleSet(nsIDocu
     for (StyleSheet* sheet : *sheetService->AgentStyleSheets()) {
       styleSet->AppendStyleSheet(SheetType::Agent, sheet);
     }
     for (StyleSheet* sheet : Reversed(*sheetService->UserStyleSheets())) {
       styleSet->PrependStyleSheet(SheetType::User, sheet);
     }
   }
 
-  // Caller will handle calling EndUpdate, per contract.
   return styleSet;
 }
 
 NS_IMETHODIMP
 nsDocumentViewer::ClearHistoryEntry()
 {
   if (mDocument) {
     nsJSContext::PokeGC(JS::gcreason::PAGE_HIDE,
--- a/layout/printing/nsPrintJob.cpp
+++ b/layout/printing/nsPrintJob.cpp
@@ -2360,21 +2360,18 @@ nsPrintJob::ReflowPrintObject(const Uniq
   // If we're printing selection then remove the unselected nodes from our
   // cloned document.
   int16_t printRangeType = nsIPrintSettings::kRangeAllPages;
   printData->mPrintSettings->GetPrintRange(&printRangeType);
   if (printRangeType == nsIPrintSettings::kRangeSelection) {
     DeleteUnselectedNodes(aPO->mDocument->GetOriginalDocument(), aPO->mDocument);
   }
 
-  aPO->mPresShell->StyleSet()->EndUpdate();
-
   // The pres shell now owns the style set object.
 
-
   bool doReturn = false;;
   bool documentIsTopLevel = false;
   nsSize adjSize;
 
   rv = SetRootView(aPO.get(), doReturn, documentIsTopLevel, adjSize);
 
   if (NS_FAILED(rv) || doReturn) {
     return rv;
--- a/layout/style/ServoStyleSet.cpp
+++ b/layout/style/ServoStyleSet.cpp
@@ -381,27 +381,16 @@ ServoStyleSet::SetAuthorStyleDisabled(bo
   // XXX Workaround for the assertion in InvalidateStyleForDocumentStateChanges
   // which is called by nsIPresShell::SetAuthorStyleDisabled via nsIPresShell::
   // RestyleForCSSRuleChanges. It is not really necessary because we don't need
   // to rebuild stylist for this change. But we have bug around this, and we
   // may want to rethink how things should work. See bug 1437785.
   SetStylistStyleSheetsDirty();
 }
 
-void
-ServoStyleSet::BeginUpdate()
-{
-}
-
-nsresult
-ServoStyleSet::EndUpdate()
-{
-  return NS_OK;
-}
-
 already_AddRefed<ComputedStyle>
 ServoStyleSet::ResolveStyleFor(Element* aElement,
                                ComputedStyle* aParentContext,
                                LazyComputeBehavior aMayCompute)
 {
   if (aMayCompute == LazyComputeBehavior::Allow) {
     PreTraverseSync();
     return ResolveStyleLazilyInternal(
--- a/layout/style/ServoStyleSet.h
+++ b/layout/style/ServoStyleSet.h
@@ -142,19 +142,16 @@ public:
 
   bool GetAuthorStyleDisabled() const
   {
     return mAuthorStyleDisabled;
   }
 
   void SetAuthorStyleDisabled(bool aStyleDisabled);
 
-  void BeginUpdate();
-  nsresult EndUpdate();
-
   already_AddRefed<ComputedStyle>
   ResolveStyleFor(dom::Element* aElement,
                   ComputedStyle* aParentContext,
                   LazyComputeBehavior aMayCompute);
 
   // Get a CopmutedStyle for a text node (which no rules will match).
   //
   // The returned ComputedStyle will have nsCSSAnonBoxes::mozText as its pseudo.