Bug 1426649: Remove nsCSSFrameConstructor updates. r?mats draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 21 Dec 2017 19:34:48 +0100
changeset 714294 488301ffe7040ee68650e8811fe81c9ecc5821e3
parent 714293 97b172e81088c65ed95f28d38cb12811fb50cead
child 744563 24a7455d4336126c38c00730e7d0cadc4808278c
push id93893
push userbmo:emilio@crisal.io
push dateFri, 22 Dec 2017 10:17:45 +0000
reviewersmats
bugs1426649
milestone59.0a1
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
layout/base/AccessibleCaret.cpp
layout/base/GeckoRestyleManager.cpp
layout/base/PresShell.cpp
layout/base/RestyleManager.cpp
layout/base/nsCSSFrameConstructor.cpp
layout/base/nsCSSFrameConstructor.h
layout/xul/nsListBoxBodyFrame.cpp
--- a/layout/base/AccessibleCaret.cpp
+++ b/layout/base/AccessibleCaret.cpp
@@ -264,20 +264,17 @@ AccessibleCaret::RemoveCaretElement(nsID
   CaretElement()->RemoveEventListener(NS_LITERAL_STRING("touchstart"),
                                       mDummyTouchListener, false);
 
   if (nsIFrame* frame = CaretElement()->GetPrimaryFrame()) {
     if (frame->HasAnyStateBits(NS_FRAME_OUT_OF_FLOW)) {
       frame = frame->GetPlaceholderFrame();
     }
     nsAutoScriptBlocker scriptBlocker;
-    nsCSSFrameConstructor* fc = frame->PresShell()->FrameConstructor();
-    fc->BeginUpdate();
     frame->GetParent()->RemoveFrame(nsIFrame::kPrincipalList, frame);
-    fc->EndUpdate();
   }
 
   ErrorResult rv;
   aDocument->RemoveAnonymousContent(*mCaretElementHolder, rv);
   // It's OK rv is failed since nsCanvasFrame might not exists now.
   rv.SuppressException();
 }
 
--- a/layout/base/GeckoRestyleManager.cpp
+++ b/layout/base/GeckoRestyleManager.cpp
@@ -630,20 +630,16 @@ GeckoRestyleManager::ProcessPendingResty
 
   MOZ_ASSERT(!mInRebuildAllStyleData,
              "should have called FinishRebuildAllStyleData");
 }
 
 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)) {
     mDoRebuildAllStyleData = false;
     StartRebuildAllStyleData(aRestyleTracker);
   }
 }
 
@@ -659,18 +655,16 @@ GeckoRestyleManager::EndProcessingRestyl
   // Set mInStyleRefresh to false now, since the EndUpdate call might
   // add more restyles.
   mInStyleRefresh = false;
 
   if (mInRebuildAllStyleData) {
     FinishRebuildAllStyleData();
   }
 
-  PresContext()->FrameConstructor()->EndUpdate();
-
 #ifdef DEBUG
   PresContext()->PresShell()->VerifyStyleTree();
 #endif
 }
 
 void
 GeckoRestyleManager::UpdateOnlyAnimationStyles()
 {
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -1768,20 +1768,18 @@ PresShell::Initialize(nscoord aWidth, ns
   // XXXbz it would be nice to move this somewhere else... like frame manager
   // Init(), say.  But we need to make sure our views are all set up by the
   // time we do this!
   nsIFrame* rootFrame = mFrameConstructor->GetRootFrame();
   NS_ASSERTION(!rootFrame, "How did that happen, exactly?");
 
   if (!rootFrame) {
     nsAutoScriptBlocker scriptBlocker;
-    mFrameConstructor->BeginUpdate();
     rootFrame = mFrameConstructor->ConstructRootFrame();
     mFrameConstructor->SetRootFrame(rootFrame);
-    mFrameConstructor->EndUpdate();
   }
 
   NS_ENSURE_STATE(!mHaveShutDown);
 
   if (!rootFrame) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
@@ -1807,29 +1805,25 @@ PresShell::Initialize(nscoord aWidth, ns
     invalidateFrame->InvalidateFrameSubtree();
   }
 
   Element *root = mDocument->GetRootElement();
 
   if (root) {
     {
       nsAutoCauseReflowNotifier reflowNotifier(this);
-      mFrameConstructor->BeginUpdate();
-
       // Have the style sheet processor construct frame for the root
       // content object down
       mFrameConstructor->ContentInserted(
           nullptr, root, nullptr, nsCSSFrameConstructor::InsertionKind::Sync);
       VERIFY_STYLE_TREE;
 
       // 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
     // scope may have killed us too
     NS_ENSURE_STATE(!mHaveShutDown);
 
     // Run the XBL binding constructors for any new frames we've constructed.
     // (Do this in a script runner, since our caller might have a script
@@ -2526,18 +2520,16 @@ PresShell::GetCanvasFrame() const
 }
 
 void
 PresShell::BeginUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
 {
 #ifdef DEBUG
   mUpdateCount++;
 #endif
-  mFrameConstructor->BeginUpdate();
-
   if (aUpdateType & UPDATE_STYLE)
     mStyleSet->BeginUpdate();
 }
 
 void
 PresShell::EndUpdate(nsIDocument *aDocument, nsUpdateType aUpdateType)
 {
 #ifdef DEBUG
@@ -2546,18 +2538,16 @@ PresShell::EndUpdate(nsIDocument *aDocum
 #endif
 
   if (aUpdateType & UPDATE_STYLE) {
     mStyleSet->EndUpdate();
     if (mStyleSet->StyleSheetsHaveChanged()) {
       RestyleForCSSRuleChanges();
     }
   }
-
-  mFrameConstructor->EndUpdate();
 }
 
 void
 PresShell::RestoreRootScrollPosition()
 {
   nsIScrollableFrame* scrollableFrame = GetRootScrollFrameAsScrollable();
   if (scrollableFrame) {
     scrollableFrame->ScrollToRestoredPosition();
@@ -2941,21 +2931,17 @@ PresShell::DestroyFramesForAndRestyle(El
     return;
   }
 
   nsAutoScriptBlocker scriptBlocker;
 
   // 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
       // anymore in a second.
       //
       // This is the case of a new shadow root or XBL binding about to be
       // attached.
       //
@@ -4552,19 +4538,17 @@ PresShell::ContentRemoved(nsIDocument *a
 
   VERIFY_STYLE_TREE;
 }
 
 void
 PresShell::NotifyCounterStylesAreDirty()
 {
   nsAutoCauseReflowNotifier reflowNotifier(this);
-  mFrameConstructor->BeginUpdate();
   mFrameConstructor->NotifyCounterStylesAreDirty();
-  mFrameConstructor->EndUpdate();
 }
 
 void
 PresShell::ReconstructFrames()
 {
   NS_PRECONDITION(!mFrameConstructor->GetRootFrame() || mDidInitialize,
                   "Must not have root frame before initial reflow");
   if (!mDidInitialize || mIsDestroying) {
@@ -4581,20 +4565,18 @@ PresShell::ReconstructFrames()
   // constructor, since that's what it expects.
   mDocument->FlushPendingNotifications(FlushType::Style);
 
   if (mIsDestroying) {
     return;
   }
 
   nsAutoCauseReflowNotifier crNotifier(this);
-  mFrameConstructor->BeginUpdate();
   mFrameConstructor->ReconstructDocElementHierarchy(nsCSSFrameConstructor::InsertionKind::Sync);
   VERIFY_STYLE_TREE;
-  mFrameConstructor->EndUpdate();
 }
 
 void
 nsIPresShell::RestyleForCSSRuleChanges()
 {
   if (mIsDestroying) {
     // We don't want to mess with restyles at this point
     return;
@@ -8813,26 +8795,22 @@ void
 PresShell::WillDoReflow()
 {
   mDocument->FlushUserFontSet();
 
   mPresContext->FlushCounterStyles();
 
   mPresContext->FlushFontFeatureValues();
 
-  mFrameConstructor->BeginUpdate();
-
   mLastReflowStart = GetPerformanceNow();
 }
 
 void
 PresShell::DidDoReflow(bool aInterruptible)
 {
-  mFrameConstructor->EndUpdate();
-
   HandlePostedReflowCallbacks(aInterruptible);
 
   nsCOMPtr<nsIDocShell> docShell = mPresContext->GetDocShell();
   if (docShell) {
     DOMHighResTimeStamp now = GetPerformanceNow();
     docShell->NotifyReflowObservers(aInterruptible, mLastReflowStart, now);
   }
 
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -1377,20 +1377,16 @@ RestyleManager::ProcessRestyledFrames(ns
         }
       }
       if (doReconstruct) {
         data.mHint |= nsChangeHint_ReconstructFrame;
       }
     }
   }
 
-  // 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) {
 
     // Collect and coalesce adjacent siblings for lazy frame construction.
     // Eventually it would be even better to make RecreateFramesForContent
     // accept a range and coalesce all adjacent reconstructs (bug 1344139).
     size_t lazyRangeStart = i;
@@ -1726,18 +1722,16 @@ RestyleManager::ProcessRestyledFrames(ns
         frame->UpdateWidgetProperties();
       }
       if (hint & nsChangeHint_UpdateTableCellSpans) {
         frameConstructor->UpdateTableCellSpans(content);
       }
     }
   }
 
-  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
   // consistent state.
   for (const nsStyleChangeData& data : aChangeList) {
     // reget frame from content since it may have been regenerated...
     if (data.mContent) {
       nsIFrame* frame = data.mContent->GetPrimaryFrame();
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -1603,19 +1603,16 @@ nsCSSFrameConstructor::nsCSSFrameConstru
   , mDocument(aDocument)
   , mRootElementFrame(nullptr)
   , mRootElementStyleFrame(nullptr)
   , mDocElementContainingBlock(nullptr)
   , mPageSequenceFrame(nullptr)
   , mFirstFreeFCItem(nullptr)
   , mFCItemsInUse(0)
   , mCurrentDepth(0)
-#ifdef DEBUG
-  , mUpdateCount(0)
-#endif
   , mQuotesDirty(false)
   , mCountersDirty(false)
   , mIsDestroyingFrameTree(false)
   , mHasRootAbsPosContainingBlock(false)
   , mAlwaysCreateFramesForIgnorableWhitespace(false)
 {
 #ifdef DEBUG
   static bool gFirstTime = true;
@@ -1666,19 +1663,16 @@ nsCSSFrameConstructor::nsCSSFrameConstru
     }
   }
 #endif
 }
 
 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();
   }
 
   if (aFrame->HasAnyStateBits(NS_FRAME_HAS_CSS_COUNTER_STYLE) &&
       mCounterManager.DestroyNodesFor(aFrame)) {
     // Technically we don't need to update anything if we destroyed only
@@ -5121,17 +5115,16 @@ nsCSSFrameConstructor::ConstructNonScrol
 
 void
 nsCSSFrameConstructor::InitAndRestoreFrame(const nsFrameConstructorState& aState,
                                            nsIContent*              aContent,
                                            nsContainerFrame*        aParentFrame,
                                            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
   aNewFrame->Init(aContent, aParentFrame, nullptr);
   aNewFrame->AddStateBits(aState.mAdditionalStateBits);
 
   if (aState.mFrameState) {
     // Restore frame state for just the newly created frame.
@@ -7312,22 +7305,20 @@ nsCSSFrameConstructor::CreateNeededFrame
 {
   NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
                "Someone forgot a script blocker");
 
   Element* rootElement = mDocument->GetRootElement();
   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();
   }
 }
 
 void
 nsCSSFrameConstructor::IssueSingleInsertNofications(nsIContent* aContainer,
                                                     nsIContent* aStartChild,
                                                     nsIContent* aEndChild,
                                                     InsertionKind aInsertionKind)
@@ -7463,17 +7454,16 @@ nsCSSFrameConstructor::ContentAppended(n
                                        TreeMatchContext* aProvidedTreeMatchContext)
 {
   MOZ_ASSERT(!aProvidedTreeMatchContext ||
              aInsertionKind == InsertionKind::Sync);
   MOZ_ASSERT(aInsertionKind == InsertionKind::Sync ||
              !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) {
     printf("nsCSSFrameConstructor::ContentAppended container=%p "
            "first-child=%p lazy=%d\n",
            static_cast<void*>(aContainer), aFirstNewContent,
            aInsertionKind == InsertionKind::Async);
     if (gReallyNoisyContentUpdates && aContainer) {
@@ -7866,17 +7856,16 @@ nsCSSFrameConstructor::ContentRangeInser
                                             TreeMatchContext* aProvidedTreeMatchContext)
 {
   MOZ_ASSERT(!aProvidedTreeMatchContext ||
              aInsertionKind == InsertionKind::Sync);
   MOZ_ASSERT(aInsertionKind == InsertionKind::Sync ||
              !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");
 
 #ifdef DEBUG
   if (gNoisyContentUpdates) {
     printf("nsCSSFrameConstructor::ContentRangeInserted container=%p "
            "start-child=%p end-child=%p lazy=%d\n",
            static_cast<void*>(aContainer),
@@ -8368,18 +8357,16 @@ nsCSSFrameConstructor::ContentRangeInser
 bool
 nsCSSFrameConstructor::ContentRemoved(nsIContent* aContainer,
                                       nsIContent* aChild,
                                       nsIContent* aOldNextSibling,
                                       RemoveFlags aFlags)
 {
   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");
 
   // We want to detect when the viewport override element stored in the
   // prescontext is in the subtree being removed.  Except in fullscreen cases
   // (which are handled in Element::UnbindFromTree and do not get stored on the
   // prescontext), the override element is always either the root element or a
   // <body> child of the root element.  So we can only be removing the stored
@@ -8823,35 +8810,16 @@ nsCSSFrameConstructor::CharacterDataChan
 
     if (haveFirstLetterStyle) {
       RecoverLetterFrames(block);
     }
   }
 }
 
 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()
 {
   nsAutoScriptBlocker scriptBlocker;
 
   if (mQuotesDirty) {
     mQuotesDirty = false;
     mQuoteList.RecalcAll();
   }
@@ -8863,17 +8831,16 @@ nsCSSFrameConstructor::RecalcQuotesAndCo
 
   NS_ASSERTION(!mQuotesDirty, "Quotes updates will be lost");
   NS_ASSERTION(!mCountersDirty, "Counter updates will be lost");
 }
 
 void
 nsCSSFrameConstructor::NotifyCounterStylesAreDirty()
 {
-  NS_PRECONDITION(mUpdateCount != 0, "Should be in an update");
   mCounterManager.SetAllDirty();
   CountersDirty();
 }
 
 void
 nsCSSFrameConstructor::WillDestroyFrameTree()
 {
 #if defined(DEBUG_dbaron_off)
@@ -11945,18 +11912,16 @@ nsCSSFrameConstructor::CreateListBoxCont
     // any frame at all
     const nsStyleDisplay* display = styleContext->StyleDisplay();
 
     if (StyleDisplay::None == display->mDisplay) {
       *aNewFrame = nullptr;
       return;
     }
 
-    BeginUpdate();
-
     AutoFrameConstructionItemList items(this);
     AddFrameConstructionItemsInternal(state, aChild, aParentFrame,
                                       aChild->NodeInfo()->NameAtom(),
                                       aChild->GetNameSpaceID(),
                                       true, styleContext,
                                       ITEM_ALLOW_XBL_BASE, nullptr, items);
     ConstructFramesFromItemList(state, items, aParentFrame,
                                 /* aParentIsWrapperAnonBox = */ false,
@@ -11968,18 +11933,16 @@ nsCSSFrameConstructor::CreateListBoxCont
     if (newFrame) {
       // Notify the parent frame
       if (aIsAppend)
         ((nsListBoxBodyFrame*)aParentFrame)->ListBoxAppendFrames(frameItems);
       else
         ((nsListBoxBodyFrame*)aParentFrame)->ListBoxInsertFrames(aPrevFrame, frameItems);
     }
 
-    EndUpdate();
-
 #ifdef ACCESSIBILITY
     if (newFrame) {
       nsAccessibilityService* accService = nsIPresShell::AccService();
       if (accService) {
         accService->ContentRangeInserted(mPresShell, aChild->GetParent(),
                                          aChild, aChild->GetNextSibling());
       }
     }
@@ -12800,31 +12763,27 @@ nsCSSFrameConstructor::ReframeContaining
                            InsertionKind::Async);
 }
 
 void
 nsCSSFrameConstructor::GenerateChildFrames(nsContainerFrame* aFrame)
 {
   {
     nsAutoScriptBlocker scriptBlocker;
-    BeginUpdate();
-
     nsFrameItems childItems;
     TreeMatchContextHolder matchContext(mDocument);
     nsFrameConstructorState state(mPresShell, matchContext, nullptr, nullptr, nullptr);
     // We don't have a parent frame with a pending binding constructor here,
     // so no need to worry about ordering of the kids' constructors with it.
     // Pass null for the PendingBinding.
     ProcessChildren(state, aFrame->GetContent(), aFrame->StyleContext(),
                     aFrame, false, childItems, false,
                     nullptr);
 
     aFrame->SetInitialChildList(kPrincipalList, childItems);
-
-    EndUpdate();
   }
 
 #ifdef ACCESSIBILITY
   nsAccessibilityService* accService = nsIPresShell::AccService();
   if (accService) {
     nsIContent* container = aFrame->GetContent();
     nsIContent* child = container->GetFirstChild();
     if (child) {
@@ -13089,25 +13048,23 @@ Iterator::DeleteItemsTo(nsCSSFrameConstr
     mList.AdjustCountsForItem(item, -1);
     item->Delete(aFCtor);
   } while (*this != aEnd);
 }
 
 void
 nsCSSFrameConstructor::QuotesDirty()
 {
-  NS_PRECONDITION(mUpdateCount != 0, "Instant quote updates are bad news");
   mQuotesDirty = true;
   mPresShell->SetNeedLayoutFlush();
 }
 
 void
 nsCSSFrameConstructor::CountersDirty()
 {
-  NS_PRECONDITION(mUpdateCount != 0, "Instant counter updates are bad news");
   mCountersDirty = true;
   mPresShell->SetNeedLayoutFlush();
 }
 
 void*
 nsCSSFrameConstructor::AllocateFCItem()
 {
   void* item;
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -57,17 +57,16 @@ public:
   typedef mozilla::dom::Element Element;
 
   friend class mozilla::RestyleManager;
   friend class mozilla::GeckoRestyleManager;
   friend class mozilla::ServoRestyleManager;
 
   nsCSSFrameConstructor(nsIDocument* aDocument, nsIPresShell* aPresShell);
   ~nsCSSFrameConstructor() {
-    MOZ_ASSERT(mUpdateCount == 0, "Dying in the middle of our own update?");
     MOZ_ASSERT(mFCItemsInUse == 0);
   }
 
   // get the alternate text for a content node
   static void GetAlternateTextFor(nsIContent* aContent,
                                   nsAtom* aTag,  // content object's tag
                                   nsAString& aAltText);
 
@@ -325,18 +324,16 @@ public:
 
   // Generate the child frames and process bindings
   void GenerateChildFrames(nsContainerFrame* aFrame);
 
   // Should be called when a frame is going to be destroyed and
   // WillDestroyFrameTree hasn't been called yet.
   void NotifyDestroyingFrame(nsIFrame* aFrame);
 
-  void BeginUpdate();
-  void EndUpdate();
   void RecalcQuotesAndCounters();
 
   // Called when any counter style is changed.
   void NotifyCounterStylesAreDirty();
 
   // Gets called when the presshell is destroying itself and also
   // when we tear down our frame tree to reconstruct it
   void WillDestroyFrameTree();
@@ -2244,19 +2241,16 @@ private:
   struct FreeFCItemLink { FreeFCItemLink* mNext; };
   FreeFCItemLink* mFirstFreeFCItem;
   size_t mFCItemsInUse;
 
   nsQuoteList         mQuoteList;
   nsCounterManager    mCounterManager;
   // Current ProcessChildren depth.
   uint16_t            mCurrentDepth;
-#ifdef DEBUG
-  uint16_t            mUpdateCount;
-#endif
   bool                mQuotesDirty : 1;
   bool                mCountersDirty : 1;
   bool                mIsDestroyingFrameTree : 1;
   // This is true if mDocElementContainingBlock supports absolute positioning
   bool                mHasRootAbsPosContainingBlock : 1;
   bool                mAlwaysCreateFramesForIgnorableWhitespace : 1;
 
   nsCOMPtr<nsILayoutHistoryState> mTempFrameTreeState;
--- a/layout/xul/nsListBoxBodyFrame.cpp
+++ b/layout/xul/nsListBoxBodyFrame.cpp
@@ -710,21 +710,20 @@ nsListBoxBodyFrame::ComputeIntrinsicISiz
   nscoord largestWidth = 0;
 
   int32_t index = 0;
   nsCOMPtr<nsIDOMElement> firstRowEl;
   GetItemAtIndex(index, getter_AddRefs(firstRowEl));
   nsCOMPtr<nsIContent> firstRowContent(do_QueryInterface(firstRowEl));
 
   if (firstRowContent) {
-    RefPtr<nsStyleContext> styleContext;
-    nsPresContext *presContext = aBoxLayoutState.PresContext();
-    styleContext = presContext->StyleSet()->
-      ResolveStyleFor(firstRowContent->AsElement(), nullptr,
-                      LazyComputeBehavior::Allow);
+    nsPresContext* presContext = aBoxLayoutState.PresContext();
+    RefPtr<nsStyleContext> styleContext =
+      presContext->StyleSet()->ResolveStyleFor(
+          firstRowContent->AsElement(), nullptr, LazyComputeBehavior::Allow);
 
     nscoord width = 0;
     nsMargin margin(0,0,0,0);
 
     if (styleContext->StylePadding()->GetPadding(margin))
       width += margin.LeftRight();
     width += styleContext->StyleBorder()->GetComputedBorder().LeftRight();
     if (styleContext->StyleMargin()->GetMargin(margin))
@@ -917,24 +916,21 @@ nsListBoxBodyFrame::DoInternalPositionCh
         DestroyRows(loseRows);
         mRowsToPrepend = 0;
       }
     }
     else {
       // 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
     mTopFrame = mBottomFrame = nullptr;
 
     mYPosition = mCurrentIndex*mRowHeight;
     mScrolling = true;
     presContext->PresShell()->
@@ -1069,53 +1065,47 @@ nsListBoxBodyFrame::CreateRows()
 void
 nsListBoxBodyFrame::DestroyRows(int32_t& aRowsToLose)
 {
   // We need to destroy frames until our row count has been properly
   // reduced.  A reflow will then pick up and create the new frames.
   nsIFrame* childFrame = GetFirstFrame();
   nsBoxLayoutState state(PresContext());
 
-  nsCSSFrameConstructor* fc = PresShell()->FrameConstructor();
-  fc->BeginUpdate();
   while (childFrame && aRowsToLose > 0) {
     --aRowsToLose;
 
     nsIFrame* nextFrame = childFrame->GetNextSibling();
     RemoveChildFrame(state, childFrame);
 
     mTopFrame = childFrame = nextFrame;
   }
-  fc->EndUpdate();
 
   PresShell()->
     FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                      NS_FRAME_HAS_DIRTY_CHILDREN);
 }
 
 void
 nsListBoxBodyFrame::ReverseDestroyRows(int32_t& aRowsToLose)
 {
   // We need to destroy frames until our row count has been properly
   // reduced.  A reflow will then pick up and create the new frames.
   nsIFrame* childFrame = GetLastFrame();
   nsBoxLayoutState state(PresContext());
 
-  nsCSSFrameConstructor* fc = PresShell()->FrameConstructor();
-  fc->BeginUpdate();
   while (childFrame && aRowsToLose > 0) {
     --aRowsToLose;
 
     nsIFrame* prevFrame;
     prevFrame = childFrame->GetPrevSibling();
     RemoveChildFrame(state, childFrame);
 
     mBottomFrame = childFrame = prevFrame;
   }
-  fc->EndUpdate();
 
   PresShell()->
     FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                      NS_FRAME_HAS_DIRTY_CHILDREN);
 }
 
 static bool
 IsListItemChild(nsListBoxBodyFrame* aParent, nsIContent* aChild,
@@ -1188,20 +1178,19 @@ nsListBoxBodyFrame::GetFirstItemBox(int3
       return existingFrame->IsXULBoxFrame() ? existingFrame : nullptr;
     }
 
     // Either append the new frame, or prepend it (at index 0)
     // XXX check here if frame was even created, it may not have been if
     //     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)
         *aCreated = true;
 
       mBottomFrame = mTopFrame;
 
       return mTopFrame->IsXULBoxFrame() ? mTopFrame.GetFrame() : nullptr;
@@ -1241,20 +1230,18 @@ nsListBoxBodyFrame::GetNextItemBox(nsIFr
       if (!IsListItemChild(this, nextContent, &existingFrame)) {
         return GetNextItemBox(aBox, ++aOffset, aCreated);
       }
       if (!existingFrame) {
         // Either append the new frame, or insert it after the current frame
         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)
             *aCreated = true;
         } else
           return GetNextItemBox(aBox, ++aOffset, aCreated);
       } else {
         result = existingFrame;
@@ -1295,25 +1282,21 @@ nsListBoxBodyFrame::ContinueReflow(nscoo
     }
 
     if (lastChild != startingPoint) {
       // We have some hangers on (probably caused by shrinking the size of the window).
       // Nuke them.
       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,
                          NS_FRAME_HAS_DIRTY_CHILDREN);
     }
     return false;
   }
   else