From ef0bbab82b62541d0efdeac6bebec6dd2f453c14 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 18 Jun 2010 12:23:05 -0400 Subject: [PATCH] Bug 479655 part 5. Pass the relevant restyle tracker through to style reresolution. r=dbaron --- layout/base/RestyleTracker.cpp | 6 ++++-- layout/base/nsCSSFrameConstructor.cpp | 10 +++++++--- layout/base/nsCSSFrameConstructor.h | 3 ++- layout/base/nsFrameManager.cpp | 22 +++++++++++++++------- layout/base/nsFrameManager.h | 14 ++++++++++++-- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/layout/base/RestyleTracker.cpp b/layout/base/RestyleTracker.cpp index 5f8b5f9111e5..64c7e71be5c3 100644 --- a/layout/base/RestyleTracker.cpp +++ b/layout/base/RestyleTracker.cpp @@ -78,7 +78,8 @@ RestyleTracker::ProcessOneRestyle(Element* aElement, nsIFrame* primaryFrame = aElement->GetPrimaryFrame(); if (aRestyleHint & eRestyle_Self) { - mFrameConstructor->RestyleElement(aElement, primaryFrame, aChangeHint); + mFrameConstructor->RestyleElement(aElement, primaryFrame, aChangeHint, + *this); } else if (aChangeHint && (primaryFrame || (aChangeHint & nsChangeHint_ReconstructFrame))) { @@ -97,7 +98,8 @@ RestyleTracker::ProcessOneRestyle(Element* aElement, mFrameConstructor->RestyleElement(sibling->AsElement(), sibling->GetPrimaryFrame(), - NS_STYLE_HINT_NONE); + NS_STYLE_HINT_NONE, + *this); } } } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 7aa8fda00a64..fc149164c7ce 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -8083,7 +8083,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList) void nsCSSFrameConstructor::RestyleElement(Element *aElement, nsIFrame *aPrimaryFrame, - nsChangeHint aMinHint) + nsChangeHint aMinHint, + RestyleTracker& aRestyleTracker) { NS_ASSERTION(aPrimaryFrame == aElement->GetPrimaryFrame(), "frame/content mismatch"); @@ -8100,7 +8101,8 @@ nsCSSFrameConstructor::RestyleElement(Element *aElement, } else if (aPrimaryFrame) { nsStyleChangeList changeList; mPresShell->FrameManager()-> - ComputeStyleChangeFor(aPrimaryFrame, &changeList, aMinHint); + ComputeStyleChangeFor(aPrimaryFrame, &changeList, aMinHint, + aRestyleTracker); ProcessRestyledFrames(changeList); } else { // no frames, reconstruct for content @@ -11623,8 +11625,10 @@ nsCSSFrameConstructor::RebuildAllStyleData(nsChangeHint aExtraHint) 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. mPresShell->FrameManager()->ComputeStyleChangeFor(mPresShell->GetRootFrame(), - &changeList, aExtraHint); + &changeList, aExtraHint, + mPendingRestyles); // Process the required changes ProcessRestyledFrames(changeList); // Tell the style set it's safe to destroy the old rule tree. We diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 00cd231c4751..154f1b5ee746 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -452,7 +452,8 @@ private: // XXXbz do we really need the aPrimaryFrame argument here? void RestyleElement(Element* aElement, nsIFrame* aPrimaryFrame, - nsChangeHint aMinHint); + nsChangeHint aMinHint, + RestyleTracker& aRestyleTracker); nsresult InitAndRestoreFrame (const nsFrameConstructorState& aState, nsIContent* aContent, diff --git a/layout/base/nsFrameManager.cpp b/layout/base/nsFrameManager.cpp index 31660454d330..92d3903c58dd 100644 --- a/layout/base/nsFrameManager.cpp +++ b/layout/base/nsFrameManager.cpp @@ -91,6 +91,7 @@ #include "nsAutoPtr.h" #include "imgIRequest.h" #include "nsTransitionManager.h" +#include "RestyleTracker.h" #include "nsFrameManager.h" #ifdef ACCESSIBILITY @@ -961,7 +962,8 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext, nsIContent *aParentContent, nsStyleChangeList *aChangeList, nsChangeHint aMinChange, - PRBool aFireAccessibilityEvents) + PRBool aFireAccessibilityEvents, + RestyleTracker& aRestyleTracker) { if (!NS_IsHintSubset(nsChangeHint_NeedDirtyReflow, aMinChange)) { // If aMinChange doesn't include nsChangeHint_NeedDirtyReflow, clear out @@ -1049,7 +1051,8 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext, // frame because it is visible or hidden withitn this frame. assumeDifferenceHint = ReResolveStyleContext(aPresContext, providerFrame, aParentContent, aChangeList, - aMinChange, PR_FALSE); + aMinChange, PR_FALSE, + aRestyleTracker); // The provider's new context becomes the parent context of // aFrame's context. @@ -1390,19 +1393,22 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext, content, aChangeList, NS_SubtractHint(aMinChange, nsChangeHint_ReflowFrame), - fireAccessibilityEvents); + fireAccessibilityEvents, + aRestyleTracker); // reresolve placeholder's context under the same parent // as the out-of-flow frame ReResolveStyleContext(aPresContext, child, content, aChangeList, aMinChange, - fireAccessibilityEvents); + fireAccessibilityEvents, + aRestyleTracker); } else { // regular child frame if (child != resolvedChild) { ReResolveStyleContext(aPresContext, child, content, aChangeList, aMinChange, - fireAccessibilityEvents); + fireAccessibilityEvents, + aRestyleTracker); } else { NOISY_TRACE_FRAME("child frame already resolved as descendant, skipping",aFrame); } @@ -1424,7 +1430,8 @@ nsFrameManager::ReResolveStyleContext(nsPresContext *aPresContext, void nsFrameManager::ComputeStyleChangeFor(nsIFrame *aFrame, nsStyleChangeList *aChangeList, - nsChangeHint aMinChange) + nsChangeHint aMinChange, + RestyleTracker& aRestyleTracker) { if (aMinChange) { aChangeList->AppendChange(aFrame, aFrame->GetContent(), aMinChange); @@ -1449,7 +1456,8 @@ nsFrameManager::ComputeStyleChangeFor(nsIFrame *aFrame, // Inner loop over next-in-flows of the current frame nsChangeHint frameChange = ReResolveStyleContext(GetPresContext(), frame, nsnull, - aChangeList, topLevelChange, PR_TRUE); + aChangeList, topLevelChange, PR_TRUE, + aRestyleTracker); NS_UpdateHint(topLevelChange, frameChange); if (topLevelChange & nsChangeHint_ReconstructFrame) { diff --git a/layout/base/nsFrameManager.h b/layout/base/nsFrameManager.h index ae32641e30c5..3087a56efee1 100644 --- a/layout/base/nsFrameManager.h +++ b/layout/base/nsFrameManager.h @@ -57,6 +57,12 @@ #include "nsChangeHint.h" #include "nsFrameManagerBase.h" +namespace mozilla { +namespace css { +class RestyleTracker; +} // namespace css +} // namespace mozilla + /** * Frame manager interface. The frame manager serves two purposes: *
  • provides a service for mapping from content to frame and from @@ -70,6 +76,8 @@ class nsFrameManager : public nsFrameManagerBase { + typedef mozilla::css::RestyleTracker RestyleTracker; + public: nsFrameManager() NS_HIDDEN; ~nsFrameManager() NS_HIDDEN; @@ -151,7 +159,8 @@ public: NS_HIDDEN_(void) ComputeStyleChangeFor(nsIFrame* aFrame, nsStyleChangeList* aChangeList, - nsChangeHint aMinChange); + nsChangeHint aMinChange, + RestyleTracker& aRestyleTracker); /* * Capture/restore frame state for the frame subtree rooted at aFrame. @@ -198,7 +207,8 @@ private: nsIContent *aParentContent, nsStyleChangeList *aChangeList, nsChangeHint aMinChange, - PRBool aFireAccessibilityEvents); + PRBool aFireAccessibilityEvents, + RestyleTracker& aRestyleTracker); }; #endif