Bug 1459529: Remove ServoStyleSet::{Begin,End}Update. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 11 May 2018 13:04:08 +0200
changeset 794259 29dfd16ea517c5b763a38fe177dc65aa3eadee9b
parent 794258 52c0eb9a282537cf644a05c7004c11eb645bd9ba
child 794260 344706edc85a7bb0db31b3d75735a6d4997e2cd1
push id109630
push userbmo:emilio@crisal.io
push dateFri, 11 May 2018 16:44:07 +0000
reviewersheycam
bugs1459529
milestone62.0a1
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
@@ -1494,28 +1494,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;
@@ -1528,33 +1524,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.
@@ -2530,30 +2523,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
@@ -687,19 +687,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
@@ -2309,31 +2306,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)) {
@@ -2430,17 +2423,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
@@ -2363,21 +2363,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.