From 927ea89c0da83d88b7f04a3771206167d49cf508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 21 Dec 2017 19:34:48 +0100 Subject: [PATCH] Bug 1426649: Remove nsCSSFrameConstructor updates. r=mats They used to do quote updates and such but they where moved long ago, and do nothing now. MozReview-Commit-ID: 188vzGctbty --HG-- extra : rebase_source : dd638875f9ef9ceb2343df5f8677a23d820c7a36 --- layout/base/AccessibleCaret.cpp | 3 -- layout/base/GeckoRestyleManager.cpp | 6 ---- layout/base/PresShell.cpp | 24 +-------------- layout/base/RestyleManager.cpp | 6 ---- layout/base/nsCSSFrameConstructor.cpp | 43 --------------------------- layout/base/nsCSSFrameConstructor.h | 6 ---- layout/xul/nsListBoxBodyFrame.cpp | 33 +++++--------------- 7 files changed, 9 insertions(+), 112 deletions(-) diff --git a/layout/base/AccessibleCaret.cpp b/layout/base/AccessibleCaret.cpp index 3fffa37ac7cd..1178908d74bb 100644 --- a/layout/base/AccessibleCaret.cpp +++ b/layout/base/AccessibleCaret.cpp @@ -269,10 +269,7 @@ AccessibleCaret::RemoveCaretElement(nsIDocument* aDocument) frame = frame->GetPlaceholderFrame(); } nsAutoScriptBlocker scriptBlocker; - nsCSSFrameConstructor* fc = frame->PresShell()->FrameConstructor(); - fc->BeginUpdate(); frame->GetParent()->RemoveFrame(nsIFrame::kPrincipalList, frame); - fc->EndUpdate(); } ErrorResult rv; diff --git a/layout/base/GeckoRestyleManager.cpp b/layout/base/GeckoRestyleManager.cpp index ef9b115e75a2..0af064376797 100644 --- a/layout/base/GeckoRestyleManager.cpp +++ b/layout/base/GeckoRestyleManager.cpp @@ -637,10 +637,6 @@ GeckoRestyleManager::ProcessPendingRestyles() void GeckoRestyleManager::BeginProcessingRestyles(RestyleTracker& aRestyleTracker) { - // Make sure to not rebuild quote or counter lists while we're - // processing restyles - PresContext()->FrameConstructor()->BeginUpdate(); - mInStyleRefresh = true; if (ShouldStartRebuildAllFor(aRestyleTracker)) { @@ -666,8 +662,6 @@ GeckoRestyleManager::EndProcessingRestyles() FinishRebuildAllStyleData(); } - PresContext()->FrameConstructor()->EndUpdate(); - #ifdef DEBUG PresContext()->PresShell()->VerifyStyleTree(); #endif diff --git a/layout/base/PresShell.cpp b/layout/base/PresShell.cpp index c60184ad03a8..258d78c97ff5 100644 --- a/layout/base/PresShell.cpp +++ b/layout/base/PresShell.cpp @@ -1772,10 +1772,8 @@ PresShell::Initialize(nscoord aWidth, nscoord aHeight) if (!rootFrame) { nsAutoScriptBlocker scriptBlocker; - mFrameConstructor->BeginUpdate(); rootFrame = mFrameConstructor->ConstructRootFrame(); mFrameConstructor->SetRootFrame(rootFrame); - mFrameConstructor->EndUpdate(); } NS_ENSURE_STATE(!mHaveShutDown); @@ -1811,8 +1809,6 @@ PresShell::Initialize(nscoord aWidth, nscoord aHeight) if (root) { { nsAutoCauseReflowNotifier reflowNotifier(this); - mFrameConstructor->BeginUpdate(); - // Have the style sheet processor construct frame for the root // content object down mFrameConstructor->ContentInserted( @@ -1822,8 +1818,6 @@ PresShell::Initialize(nscoord aWidth, nscoord aHeight) // Something in mFrameConstructor->ContentInserted may have caused // Destroy() to get called, bug 337586. NS_ENSURE_STATE(!mHaveShutDown); - - mFrameConstructor->EndUpdate(); } // nsAutoCauseReflowNotifier (which sets up a script blocker) going out of @@ -2535,8 +2529,6 @@ PresShell::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) #ifdef DEBUG mUpdateCount++; #endif - mFrameConstructor->BeginUpdate(); - if (aUpdateType & UPDATE_STYLE) mStyleSet->BeginUpdate(); } @@ -2555,8 +2547,6 @@ PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType) RestyleForCSSRuleChanges(); } } - - mFrameConstructor->EndUpdate(); } void @@ -2950,11 +2940,7 @@ PresShell::DestroyFramesForAndRestyle(Element* aElement) // Mark ourselves as not safe to flush while we're doing frame destruction. ++mChangeNestCount; - nsCSSFrameConstructor* fc = FrameConstructor(); - fc->BeginUpdate(); - bool didReconstruct = fc->DestroyFramesFor(aElement); - fc->EndUpdate(); - + const bool didReconstruct = FrameConstructor()->DestroyFramesFor(aElement); if (aElement->IsStyledByServo()) { if (aElement->GetFlattenedTreeParentNode()) { // The element is still in the flat tree, but their children may not be @@ -4561,9 +4547,7 @@ void PresShell::NotifyCounterStylesAreDirty() { nsAutoCauseReflowNotifier reflowNotifier(this); - mFrameConstructor->BeginUpdate(); mFrameConstructor->NotifyCounterStylesAreDirty(); - mFrameConstructor->EndUpdate(); } void @@ -4590,10 +4574,8 @@ PresShell::ReconstructFrames() } nsAutoCauseReflowNotifier crNotifier(this); - mFrameConstructor->BeginUpdate(); mFrameConstructor->ReconstructDocElementHierarchy(nsCSSFrameConstructor::InsertionKind::Sync); VERIFY_STYLE_TREE; - mFrameConstructor->EndUpdate(); } void @@ -8813,16 +8795,12 @@ PresShell::WillDoReflow() mPresContext->FlushFontFeatureValues(); - mFrameConstructor->BeginUpdate(); - mLastReflowStart = GetPerformanceNow(); } void PresShell::DidDoReflow(bool aInterruptible) { - mFrameConstructor->EndUpdate(); - HandlePostedReflowCallbacks(aInterruptible); nsCOMPtr docShell = mPresContext->GetDocShell(); diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index 96e7f13a8813..a37974356d74 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -1373,10 +1373,6 @@ RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList) } } - // Make sure to not rebuild quote or counter lists while we're - // processing restyles - frameConstructor->BeginUpdate(); - bool didUpdateCursor = false; for (size_t i = 0; i < aChangeList.Length(); ++i) { @@ -1722,8 +1718,6 @@ RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList) } } - frameConstructor->EndUpdate(); - #ifdef DEBUG // Verify the style tree. Note that this needs to happen once we've // processed the whole list, since until then the tree is not in fact in a diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index f27d0a9fdedb..90baf5918ffe 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -1608,9 +1608,6 @@ nsCSSFrameConstructor::nsCSSFrameConstructor(nsIDocument* aDocument, , mFirstFreeFCItem(nullptr) , mFCItemsInUse(0) , mCurrentDepth(0) -#ifdef DEBUG - , mUpdateCount(0) -#endif , mQuotesDirty(false) , mCountersDirty(false) , mIsDestroyingFrameTree(false) @@ -1671,9 +1668,6 @@ nsCSSFrameConstructor::nsCSSFrameConstructor(nsIDocument* aDocument, void nsCSSFrameConstructor::NotifyDestroyingFrame(nsIFrame* aFrame) { - NS_PRECONDITION(mUpdateCount != 0, - "Should be in an update while destroying frames"); - if (aFrame->GetStateBits() & NS_FRAME_GENERATED_CONTENT) { if (mQuoteList.DestroyNodesFor(aFrame)) QuotesDirty(); @@ -5174,7 +5168,6 @@ nsCSSFrameConstructor::InitAndRestoreFrame(const nsFrameConstructorState& aState nsIFrame* aNewFrame, bool aAllowCounters) { - MOZ_ASSERT(mUpdateCount != 0, "Should be in an update while creating frames"); MOZ_ASSERT(aNewFrame, "Null frame cannot be initialized"); // Initialize the frame @@ -7386,12 +7379,10 @@ nsCSSFrameConstructor::CreateNeededFrames() NS_ASSERTION(!rootElement || !rootElement->HasFlag(NODE_NEEDS_FRAME), "root element should not have frame created lazily"); if (rootElement && rootElement->HasFlag(NODE_DESCENDANTS_NEED_FRAMES)) { - BeginUpdate(); TreeMatchContext treeMatchContext( mDocument, TreeMatchContext::ForFrameConstruction); treeMatchContext.InitAncestors(rootElement); CreateNeededFrames(rootElement, treeMatchContext); - EndUpdate(); } } @@ -7556,7 +7547,6 @@ nsCSSFrameConstructor::ContentAppended(nsIContent* aContainer, !RestyleManager()->IsInStyleRefresh()); AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC); - MOZ_ASSERT(mUpdateCount != 0, "Should be in an update while creating frames"); #ifdef DEBUG if (gNoisyContentUpdates) { @@ -7958,7 +7948,6 @@ nsCSSFrameConstructor::ContentRangeInserted(nsIContent* aContainer, !RestyleManager()->IsInStyleRefresh()); AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC); - MOZ_ASSERT(mUpdateCount != 0, "Should be in an update while creating frames"); NS_PRECONDITION(aStartChild, "must always pass a child"); @@ -8457,8 +8446,6 @@ nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer, { MOZ_ASSERT(aChild); AUTO_LAYOUT_PHASE_ENTRY_POINT(mPresShell->GetPresContext(), FrameC); - NS_PRECONDITION(mUpdateCount != 0, - "Should be in an update while destroying frames"); nsPresContext* presContext = mPresShell->GetPresContext(); MOZ_ASSERT(presContext, "Our presShell should have a valid presContext"); @@ -8911,25 +8898,6 @@ nsCSSFrameConstructor::CharacterDataChanged(nsIContent* aContent, } } -void -nsCSSFrameConstructor::BeginUpdate() { - NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(), - "Someone forgot a script blocker"); - -#ifdef DEBUG - ++mUpdateCount; -#endif -} - -void -nsCSSFrameConstructor::EndUpdate() -{ -#ifdef DEBUG - NS_ASSERTION(mUpdateCount, "Negative mUpdateCount!"); - --mUpdateCount; -#endif -} - void nsCSSFrameConstructor::RecalcQuotesAndCounters() { @@ -8952,7 +8920,6 @@ nsCSSFrameConstructor::RecalcQuotesAndCounters() void nsCSSFrameConstructor::NotifyCounterStylesAreDirty() { - NS_PRECONDITION(mUpdateCount != 0, "Should be in an update"); mCounterManager.SetAllDirty(); CountersDirty(); } @@ -11975,8 +11942,6 @@ nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame* aParentFrame, return; } - BeginUpdate(); - AutoFrameConstructionItemList items(this); AddFrameConstructionItemsInternal(state, aChild, aParentFrame, aChild->NodeInfo()->NameAtom(), @@ -11998,8 +11963,6 @@ nsCSSFrameConstructor::CreateListBoxContent(nsContainerFrame* aParentFrame, ((nsListBoxBodyFrame*)aParentFrame)->ListBoxInsertFrames(aPrevFrame, frameItems); } - EndUpdate(); - #ifdef ACCESSIBILITY if (newFrame) { nsAccessibilityService* accService = nsIPresShell::AccService(); @@ -12831,8 +12794,6 @@ nsCSSFrameConstructor::GenerateChildFrames(nsContainerFrame* aFrame) { { nsAutoScriptBlocker scriptBlocker; - BeginUpdate(); - nsFrameItems childItems; TreeMatchContextHolder matchContext(mDocument); nsFrameConstructorState state(mPresShell, matchContext, nullptr, nullptr, nullptr); @@ -12844,8 +12805,6 @@ nsCSSFrameConstructor::GenerateChildFrames(nsContainerFrame* aFrame) nullptr); aFrame->SetInitialChildList(kPrincipalList, childItems); - - EndUpdate(); } #ifdef ACCESSIBILITY @@ -13120,7 +13079,6 @@ Iterator::DeleteItemsTo(nsCSSFrameConstructor* aFCtor, const Iterator& aEnd) void nsCSSFrameConstructor::QuotesDirty() { - NS_PRECONDITION(mUpdateCount != 0, "Instant quote updates are bad news"); mQuotesDirty = true; mPresShell->SetNeedLayoutFlush(); } @@ -13128,7 +13086,6 @@ nsCSSFrameConstructor::QuotesDirty() void nsCSSFrameConstructor::CountersDirty() { - NS_PRECONDITION(mUpdateCount != 0, "Instant counter updates are bad news"); mCountersDirty = true; mPresShell->SetNeedLayoutFlush(); } diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index afc22dca5d04..e0ad15fe9d05 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -62,7 +62,6 @@ public: nsCSSFrameConstructor(nsIDocument* aDocument, nsIPresShell* aPresShell); ~nsCSSFrameConstructor() { - MOZ_ASSERT(mUpdateCount == 0, "Dying in the middle of our own update?"); MOZ_ASSERT(mFCItemsInUse == 0); } @@ -334,8 +333,6 @@ public: // WillDestroyFrameTree hasn't been called yet. void NotifyDestroyingFrame(nsIFrame* aFrame); - void BeginUpdate(); - void EndUpdate(); void RecalcQuotesAndCounters(); // Called when any counter style is changed. @@ -2254,9 +2251,6 @@ private: nsCounterManager mCounterManager; // Current ProcessChildren depth. uint16_t mCurrentDepth; -#ifdef DEBUG - uint16_t mUpdateCount; -#endif bool mQuotesDirty : 1; bool mCountersDirty : 1; bool mIsDestroyingFrameTree : 1; diff --git a/layout/xul/nsListBoxBodyFrame.cpp b/layout/xul/nsListBoxBodyFrame.cpp index d589252de9aa..7cf726bcbb98 100644 --- a/layout/xul/nsListBoxBodyFrame.cpp +++ b/layout/xul/nsListBoxBodyFrame.cpp @@ -714,11 +714,10 @@ nsListBoxBodyFrame::ComputeIntrinsicISize(nsBoxLayoutState& aBoxLayoutState) nsCOMPtr firstRowContent(do_QueryInterface(firstRowEl)); if (firstRowContent) { - RefPtr styleContext; - nsPresContext *presContext = aBoxLayoutState.PresContext(); - styleContext = presContext->StyleSet()-> - ResolveStyleFor(firstRowContent->AsElement(), nullptr, - LazyComputeBehavior::Allow); + nsPresContext* presContext = aBoxLayoutState.PresContext(); + RefPtr styleContext = + presContext->StyleSet()->ResolveStyleFor( + firstRowContent->AsElement(), nullptr, LazyComputeBehavior::Allow); nscoord width = 0; nsMargin margin(0,0,0,0); @@ -920,14 +919,11 @@ nsListBoxBodyFrame::DoInternalPositionChanged(bool aUp, int32_t aDelta) // We have scrolled so much that all of our current frames will // go off screen, so blow them all away. Weeee! nsIFrame *currBox = mFrames.FirstChild(); - nsCSSFrameConstructor* fc = presContext->PresShell()->FrameConstructor(); - fc->BeginUpdate(); while (currBox) { nsIFrame *nextBox = currBox->GetNextSibling(); RemoveChildFrame(state, currBox); currBox = nextBox; } - fc->EndUpdate(); } // clear frame markers so that CreateRows will re-create @@ -1072,8 +1068,6 @@ nsListBoxBodyFrame::DestroyRows(int32_t& aRowsToLose) nsIFrame* childFrame = GetFirstFrame(); nsBoxLayoutState state(PresContext()); - nsCSSFrameConstructor* fc = PresShell()->FrameConstructor(); - fc->BeginUpdate(); while (childFrame && aRowsToLose > 0) { --aRowsToLose; @@ -1082,7 +1076,6 @@ nsListBoxBodyFrame::DestroyRows(int32_t& aRowsToLose) mTopFrame = childFrame = nextFrame; } - fc->EndUpdate(); PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, @@ -1097,8 +1090,6 @@ nsListBoxBodyFrame::ReverseDestroyRows(int32_t& aRowsToLose) nsIFrame* childFrame = GetLastFrame(); nsBoxLayoutState state(PresContext()); - nsCSSFrameConstructor* fc = PresShell()->FrameConstructor(); - fc->BeginUpdate(); while (childFrame && aRowsToLose > 0) { --aRowsToLose; @@ -1108,7 +1099,6 @@ nsListBoxBodyFrame::ReverseDestroyRows(int32_t& aRowsToLose) mBottomFrame = childFrame = prevFrame; } - fc->EndUpdate(); PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange, @@ -1191,10 +1181,9 @@ nsListBoxBodyFrame::GetFirstItemBox(int32_t aOffset, bool* aCreated) // display: none was on listitem content bool isAppend = mRowsToPrepend <= 0; - nsPresContext* presContext = PresContext(); - nsCSSFrameConstructor* fc = presContext->PresShell()->FrameConstructor(); nsIFrame* topFrame = nullptr; - fc->CreateListBoxContent(this, nullptr, startContent, &topFrame, isAppend); + PresContext()->FrameConstructor()->CreateListBoxContent( + this, nullptr, startContent, &topFrame, isAppend); mTopFrame = topFrame; if (mTopFrame) { if (aCreated) @@ -1244,10 +1233,8 @@ nsListBoxBodyFrame::GetNextItemBox(nsIFrame* aBox, int32_t aOffset, bool isAppend = result != mLinkupFrame && mRowsToPrepend <= 0; nsIFrame* prevFrame = isAppend ? nullptr : aBox; - nsPresContext* presContext = PresContext(); - nsCSSFrameConstructor* fc = presContext->PresShell()->FrameConstructor(); - fc->CreateListBoxContent(this, prevFrame, nextContent, - &result, isAppend); + PresContext()->FrameConstructor()->CreateListBoxContent( + this, prevFrame, nextContent, &result, isAppend); if (result) { if (aCreated) @@ -1298,15 +1285,11 @@ nsListBoxBodyFrame::ContinueReflow(nscoord height) nsIFrame* currFrame = startingPoint->GetNextSibling(); nsBoxLayoutState state(PresContext()); - nsCSSFrameConstructor* fc = - PresShell()->FrameConstructor(); - fc->BeginUpdate(); while (currFrame) { nsIFrame* nextFrame = currFrame->GetNextSibling(); RemoveChildFrame(state, currFrame); currFrame = nextFrame; } - fc->EndUpdate(); PresShell()-> FrameNeedsReflow(this, nsIPresShell::eTreeChange,