Bug 1026768 - Pass the restyle hint through from ProcessOneRestyle to ComputeStyleChangeFor rather than converting it to a boolean and back. r=heycam
authorL. David Baron <dbaron@dbaron.org>
Wed, 18 Jun 2014 17:07:26 -0700
changeset 203279 bdf18e88d83427e06f0948b1120ee0499650fef1
parent 203278 6e62d26d659c75a7be32298e259133e68c571d82
child 203280 8eeb287c59fd0b7a8b3a0b66161b52c5833ac523
push id6561
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 21:23:20 +0000
treeherdermozilla-aurora@428d4d3c8588 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1026768, 996796, 931668
milestone33.0a1
Bug 1026768 - Pass the restyle hint through from ProcessOneRestyle to ComputeStyleChangeFor rather than converting it to a boolean and back. r=heycam This was originally bug 996796 patch 6, but it's also needed bug 931668, so I'm moving it into its own bug.
layout/base/RestyleManager.cpp
layout/base/RestyleManager.h
layout/base/RestyleTracker.cpp
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -844,17 +844,17 @@ RestyleManager::ProcessRestyledFrames(ns
   return NS_OK;
 }
 
 void
 RestyleManager::RestyleElement(Element*        aElement,
                                nsIFrame*       aPrimaryFrame,
                                nsChangeHint    aMinHint,
                                RestyleTracker& aRestyleTracker,
-                               bool            aRestyleDescendants)
+                               nsRestyleHint   aRestyleHint)
 {
   NS_ASSERTION(aPrimaryFrame == aElement->GetPrimaryFrame(),
                "frame/content mismatch");
   if (aPrimaryFrame && aPrimaryFrame->GetContent() != aElement) {
     // XXXbz this is due to image maps messing with the primary frame pointer
     // of <area>s.  See bug 135040.  We can remove this block once that's fixed.
     aPrimaryFrame = nullptr;
   }
@@ -881,17 +881,17 @@ RestyleManager::RestyleElement(Element* 
     }
   }
 
   if (aMinHint & nsChangeHint_ReconstructFrame) {
     FrameConstructor()->RecreateFramesForContent(aElement, false);
   } else if (aPrimaryFrame) {
     nsStyleChangeList changeList;
     ComputeStyleChangeFor(aPrimaryFrame, &changeList, aMinHint,
-                          aRestyleTracker, aRestyleDescendants);
+                          aRestyleTracker, aRestyleHint);
     ProcessRestyledFrames(changeList);
   } else {
     // no frames, reconstruct for content
     FrameConstructor()->MaybeRecreateFramesForElement(aElement);
   }
 }
 
 static inline dom::Element*
@@ -1417,17 +1417,17 @@ RestyleManager::DoRebuildAllStyleData(Re
   // (but note that nsPresShell::SetPreferenceStyleRules currently depends
   // on us re-running rule matching here
   nsStyleChangeList changeList;
   // XXX Does it matter that we're passing aExtraHint to the real root
   // frame and not the root node's primary frame?
   // Note: The restyle tracker we pass in here doesn't matter.
   ComputeStyleChangeFor(mPresContext->PresShell()->GetRootFrame(),
                         &changeList, aExtraHint,
-                        aRestyleTracker, true);
+                        aRestyleTracker, eRestyle_Subtree);
   // Process the required changes
   ProcessRestyledFrames(changeList);
   FlushOverflowChangedTracker();
 
   // Tell the style set it's safe to destroy the old rule tree.  We
   // must do this after the ProcessRestyledFrames call in case the
   // change list has frame reconstructs in it (since frames to be
   // reconstructed will still have their old style context pointers
@@ -2296,16 +2296,19 @@ ElementRestyler::Restyle(nsRestyleHint a
   // fix bug 242277 we should be able to make this make more sense.
   NS_ASSERTION(mFrame->GetContent() || !mParentContent ||
                !mParentContent->GetParent(),
                "frame must have content (unless at the top of the tree)");
 
   NS_ASSERTION(!GetPrevContinuationWithSameStyle(mFrame),
                "should not be trying to restyle this frame separately");
 
+  MOZ_ASSERT(!(aRestyleHint & eRestyle_LaterSiblings),
+             "eRestyle_LaterSiblings must not be part of aRestyleHint");
+
   if (mContent && mContent->IsElement()) {
     mContent->OwnerDoc()->FlushPendingLinkUpdates();
     RestyleTracker::RestyleData restyleData;
     if (mRestyleTracker.GetRestyleData(mContent->AsElement(), &restyleData)) {
       if (NS_UpdateHint(mHintsHandled, restyleData.mChangeHint)) {
         mChangeList->AppendChange(mFrame, mContent, restyleData.mChangeHint);
       }
       aRestyleHint = nsRestyleHint(aRestyleHint | restyleData.mRestyleHint);
@@ -2331,16 +2334,19 @@ ElementRestyler::Restyle(nsRestyleHint a
   }
 
   RestyleChildren(childRestyleHint);
 }
 
 void
 ElementRestyler::RestyleSelf(nsIFrame* aSelf, nsRestyleHint aRestyleHint)
 {
+  MOZ_ASSERT(!(aRestyleHint & eRestyle_LaterSiblings),
+             "eRestyle_LaterSiblings must not be part of aRestyleHint");
+
   // XXXldb get new context from prev-in-flow if possible, to avoid
   // duplication.  (Or should we just let |GetContext| handle that?)
   // Getting the hint would be nice too, but that's harder.
 
   // XXXbryner we may be able to avoid some of the refcounting goop here.
   // We do need a reference to oldContext for the lifetime of this function, and it's possible
   // that the frame has the last reference to it, so AddRef it here.
 
@@ -2924,17 +2930,17 @@ GetNextBlockInInlineSibling(FramePropert
     (aPropTable->Get(aFrame, nsIFrame::IBSplitSibling()));
 }
 
 void
 RestyleManager::ComputeStyleChangeFor(nsIFrame*          aFrame,
                                       nsStyleChangeList* aChangeList,
                                       nsChangeHint       aMinChange,
                                       RestyleTracker&    aRestyleTracker,
-                                      bool               aRestyleDescendants)
+                                      nsRestyleHint      aRestyleHint)
 {
   PROFILER_LABEL("RestyleManager", "ComputeStyleChangeFor",
     js::ProfileEntry::Category::CSS);
 
   nsIContent *content = aFrame->GetContent();
   if (aMinChange) {
     aChangeList->AppendChange(aFrame, content, aMinChange);
   }
@@ -2973,17 +2979,17 @@ RestyleManager::ComputeStyleChangeFor(ns
       }
 
       // Inner loop over next-in-flows of the current frame
       ElementRestyler restyler(mPresContext, cont, aChangeList,
                                aMinChange, aRestyleTracker,
                                treeMatchContext,
                                visibleKidsOfHiddenElement);
 
-      restyler.Restyle(aRestyleDescendants ? eRestyle_Subtree : eRestyle_Self);
+      restyler.Restyle(aRestyleHint);
 
       if (restyler.HintsHandledForFrame() & nsChangeHint_ReconstructFrame) {
         // If it's going to cause a framechange, then don't bother
         // with the continuations or ib-split siblings since they'll be
         // clobbered by the frame reconstruct anyway.
         NS_ASSERTION(!cont->GetPrevContinuation(),
                      "continuing frame had more severe impact than first-in-flow");
         return;
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -102,17 +102,17 @@ public:
    * aChangeList based on the resulting style changes, plus aMinChange
    * applied to aFrame.
    */
   void
     ComputeStyleChangeFor(nsIFrame* aFrame,
                           nsStyleChangeList* aChangeList,
                           nsChangeHint aMinChange,
                           RestyleTracker& aRestyleTracker,
-                          bool aRestyleDescendants);
+                          nsRestyleHint aRestyleHint);
 
 #ifdef DEBUG
   /**
    * DEBUG ONLY method to verify integrity of style tree versus frame tree
    */
   void DebugVerifyStyleTree(nsIFrame* aFrame);
 #endif
 
@@ -236,17 +236,17 @@ public:
 
 private:
   /* aMinHint is the minimal change that should be made to the element */
   // XXXbz do we really need the aPrimaryFrame argument here?
   void RestyleElement(Element*        aElement,
                       nsIFrame*       aPrimaryFrame,
                       nsChangeHint    aMinHint,
                       RestyleTracker& aRestyleTracker,
-                      bool            aRestyleDescendants);
+                      nsRestyleHint   aRestyleHint);
 
   void StyleChangeReflow(nsIFrame* aFrame, nsChangeHint aHint);
 
   // Recursively add all the given frame and all children to the tracker.
   void AddSubtreeToOverflowTracker(nsIFrame* aFrame);
 
   // Returns true if this function managed to successfully move a frame, and
   // false if it could not process the position change, and a reflow should
--- a/layout/base/RestyleTracker.cpp
+++ b/layout/base/RestyleTracker.cpp
@@ -114,18 +114,17 @@ RestyleTracker::ProcessOneRestyle(Elemen
                   "Someone should have handled this before calling us");
   NS_PRECONDITION(Document(), "Must have a document");
   NS_PRECONDITION(aElement->GetCrossShadowCurrentDoc() == Document(),
                   "Element has unexpected document");
 
   nsIFrame* primaryFrame = aElement->GetPrimaryFrame();
   if (aRestyleHint & (eRestyle_Self | eRestyle_Subtree)) {
     mRestyleManager->RestyleElement(aElement, primaryFrame, aChangeHint,
-                                    *this,
-                                    (aRestyleHint & eRestyle_Subtree) != 0);
+                                    *this, aRestyleHint);
   } else if (aChangeHint &&
              (primaryFrame ||
               (aChangeHint & nsChangeHint_ReconstructFrame))) {
     // Don't need to recompute style; just apply the hint
     nsStyleChangeList changeList;
     changeList.AppendChange(primaryFrame, aElement, aChangeHint);
     mRestyleManager->ProcessRestyledFrames(changeList);
   }