Bug 1290335: Make ProcessRestyledFrames non static, and tidy up a bit.
MozReview-Commit-ID: 4aALVtI5DXT
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -131,27 +131,16 @@ private:
Element* aElement,
nsChangeHint aMinChange,
RestyleTracker& aRestyleTracker,
nsRestyleHint aRestyleHint,
const RestyleHintData& aRestyleHintData);
public:
- // Note: It's the caller's responsibility to make sure to wrap a
- // ProcessRestyledFrames call in a view update batch and a script blocker.
- // This function does not call ProcessAttachedQueue() on the binding manager.
- // If the caller wants that to happen synchronously, it needs to handle that
- // itself.
- nsresult ProcessRestyledFrames(nsStyleChangeList& aChangeList) {
- return base_type::ProcessRestyledFrames(aChangeList,
- *PresContext(),
- mOverflowChangedTracker);
- }
-
/**
* In order to start CSS transitions on elements that are being
* reframed, we need to stash their style contexts somewhere during
* the reframing process.
*
* In all cases, the content node in the hash table is the real
* content node, not the anonymous content node we create for ::before
* or ::after. The content node passed to the Get and Put methods is,
--- a/layout/base/RestyleManagerBase.cpp
+++ b/layout/base/RestyleManagerBase.cpp
@@ -750,17 +750,17 @@ DoApplyRenderingChangeToTree(nsIFrame* a
needInvalidatingPaint = true;
}
aFrame->SchedulePaint(needInvalidatingPaint
? nsIFrame::PAINT_DEFAULT
: nsIFrame::PAINT_COMPOSITE_ONLY);
}
}
-/* static */ void
+static void
SyncViewsAndInvalidateDescendants(nsIFrame* aFrame, nsChangeHint aChange)
{
NS_PRECONDITION(gInApplyRenderingChangeToTree,
"should only be called within ApplyRenderingChangeToTree");
NS_ASSERTION(nsChangeHint_size_t(aChange) ==
(aChange & (nsChangeHint_RepaintFrame |
nsChangeHint_SyncFrameView |
nsChangeHint_UpdateOpacityLayer |
@@ -790,17 +790,17 @@ SyncViewsAndInvalidateDescendants(nsIFra
} else { // regular frame
SyncViewsAndInvalidateDescendants(child, aChange);
}
}
}
}
}
-void
+static void
ApplyRenderingChangeToTree(nsIPresShell* aPresShell,
nsIFrame* aFrame,
nsChangeHint aChange)
{
// We check StyleDisplay()->HasTransformStyle() in addition to checking
// IsTransformed() since we can get here for some frames that don't support
// CSS transforms.
NS_ASSERTION(!(aChange & nsChangeHint_UpdateTransformLayer) ||
@@ -950,32 +950,31 @@ RestyleManagerBase::GetNextContinuationW
nextContinuation = nullptr;
if (aHaveMoreContinuations) {
*aHaveMoreContinuations = true;
}
}
return nextContinuation;
}
-/* static */ nsresult
-RestyleManagerBase::ProcessRestyledFrames(
- nsStyleChangeList& aChangeList, nsPresContext& aPresContext,
- OverflowChangedTracker& aOverflowChangedTracker)
+nsresult
+RestyleManagerBase::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
{
NS_ASSERTION(!nsContentUtils::IsSafeToRunScript(),
"Someone forgot a script blocker");
int32_t count = aChangeList.Count();
if (!count)
return NS_OK;
PROFILER_LABEL("RestyleManager", "ProcessRestyledFrames",
js::ProfileEntry::Category::CSS);
- FramePropertyTable* propTable = aPresContext.PropertyTable();
- nsCSSFrameConstructor* frameConstructor = aPresContext.FrameConstructor();
+ nsPresContext* presContext = PresContext();
+ FramePropertyTable* propTable = presContext->PropertyTable();
+ nsCSSFrameConstructor* frameConstructor = presContext->FrameConstructor();
// Make sure to not rebuild quote or counter lists while we're
// processing restyles
frameConstructor->BeginUpdate();
// Mark frames so that we skip frames that die along the way, bug 123049.
// A frame can be in the list multiple times with different hints. Further
// optmization is possible if nsStyleChangeList::AppendChange could coalesce
@@ -1127,17 +1126,17 @@ RestyleManagerBase::ProcessRestyledFrame
// these frames. Repaint the whole frame.
hint |= nsChangeHint_RepaintFrame;
}
}
if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView |
nsChangeHint_UpdateOpacityLayer | nsChangeHint_UpdateTransformLayer |
nsChangeHint_ChildrenOnlyTransform | nsChangeHint_SchedulePaint)) {
- ApplyRenderingChangeToTree(aPresContext.PresShell(), frame, hint);
+ ApplyRenderingChangeToTree(presContext->PresShell(), frame, hint);
}
if ((hint & nsChangeHint_RecomputePosition) && !didReflowThisFrame) {
ActiveLayerTracker::NotifyOffsetRestyle(frame);
// It is possible for this to fall back to a reflow
if (!RecomputePosition(frame)) {
didReflowThisFrame = true;
}
}
@@ -1147,17 +1146,17 @@ RestyleManagerBase::ProcessRestyledFrame
if (!didReflowThisFrame &&
(hint & (nsChangeHint_UpdateOverflow |
nsChangeHint_UpdatePostTransformOverflow |
nsChangeHint_UpdateParentOverflow |
nsChangeHint_UpdateSubtreeOverflow))) {
if (hint & nsChangeHint_UpdateSubtreeOverflow) {
for (nsIFrame* cont = frame; cont; cont =
nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
- AddSubtreeToOverflowTracker(cont, aOverflowChangedTracker);
+ AddSubtreeToOverflowTracker(cont, mOverflowChangedTracker);
}
// The work we just did in AddSubtreeToOverflowTracker
// subsumes some of the other hints:
hint &= ~(nsChangeHint_UpdateOverflow |
nsChangeHint_UpdatePostTransformOverflow);
}
if (hint & nsChangeHint_ChildrenOnlyTransform) {
// The overflow areas of the child frames need to be updated:
@@ -1171,17 +1170,17 @@ RestyleManagerBase::ProcessRestyledFrame
"or ib-split siblings");
for ( ; childFrame; childFrame = childFrame->GetNextSibling()) {
MOZ_ASSERT(childFrame->IsFrameOfType(nsIFrame::eSVG),
"Not expecting non-SVG children");
// If |childFrame| is dirty or has dirty children, we don't bother
// updating overflows since that will happen when it's reflowed.
if (!(childFrame->GetStateBits() &
(NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN))) {
- aOverflowChangedTracker.AddFrame(childFrame,
+ mOverflowChangedTracker.AddFrame(childFrame,
OverflowChangedTracker::CHILDREN_CHANGED);
}
NS_ASSERTION(!nsLayoutUtils::GetNextContinuationOrIBSplitSibling(childFrame),
"SVG frames should not have continuations "
"or ib-split siblings");
NS_ASSERTION(childFrame->GetParent() == hintFrame,
"SVG child frame not expected to have different parent");
}
@@ -1199,36 +1198,36 @@ RestyleManagerBase::ProcessRestyledFrame
// strictly stronger.
if (hint & nsChangeHint_UpdateOverflow) {
changeKind = OverflowChangedTracker::CHILDREN_CHANGED;
} else {
changeKind = OverflowChangedTracker::TRANSFORM_CHANGED;
}
for (nsIFrame* cont = frame; cont; cont =
nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
- aOverflowChangedTracker.AddFrame(cont, changeKind);
+ mOverflowChangedTracker.AddFrame(cont, changeKind);
}
}
// UpdateParentOverflow hints need to be processed in addition
// to the above, since if the processing of the above hints
// yields no change, the update will not propagate to the
// parent.
if (hint & nsChangeHint_UpdateParentOverflow) {
MOZ_ASSERT(frame->GetParent(),
"shouldn't get style hints for the root frame");
for (nsIFrame* cont = frame; cont; cont =
nsLayoutUtils::GetNextContinuationOrIBSplitSibling(cont)) {
- aOverflowChangedTracker.AddFrame(cont->GetParent(),
+ mOverflowChangedTracker.AddFrame(cont->GetParent(),
OverflowChangedTracker::CHILDREN_CHANGED);
}
}
}
}
if ((hint & nsChangeHint_UpdateCursor) && !didUpdateCursor) {
- aPresContext.PresShell()->SynthesizeMouseMove(false);
+ presContext->PresShell()->SynthesizeMouseMove(false);
didUpdateCursor = true;
}
}
}
frameConstructor->EndUpdate();
// cleanup references and verify the style tree. Note that the latter needs
--- a/layout/base/RestyleManagerBase.h
+++ b/layout/base/RestyleManagerBase.h
@@ -59,16 +59,23 @@ public:
}
// Should be called when a frame is going to be destroyed and
// WillDestroyFrameTree hasn't been called yet.
void NotifyDestroyingFrame(nsIFrame* aFrame) {
mOverflowChangedTracker.RemoveFrame(aFrame);
}
+ // Note: It's the caller's responsibility to make sure to wrap a
+ // ProcessRestyledFrames call in a view update batch and a script blocker.
+ // This function does not call ProcessAttachedQueue() on the binding manager.
+ // If the caller wants that to happen synchronously, it needs to handle that
+ // itself.
+ nsresult ProcessRestyledFrames(nsStyleChangeList& aChangeList);
+
protected:
void ContentStateChangedInternal(Element* aElement,
EventStates aStateMask,
nsChangeHint* aOutChangeHint,
nsRestyleHint* aOutRestyleHint);
bool IsDisconnected() { return mPresContext == nullptr; }
@@ -121,21 +128,16 @@ protected:
* processing bits of the restyle managers.
*/
static nsIFrame*
GetNearestAncestorFrame(nsIContent* aContent);
static nsIFrame*
GetNextBlockInInlineSibling(FramePropertyTable* aPropTable, nsIFrame* aFrame);
- static nsresult
- ProcessRestyledFrames(nsStyleChangeList& aChangeList,
- nsPresContext& aPresContext,
- OverflowChangedTracker& aOverflowChangedTracker);
-
/**
* Get the next continuation or similar ib-split sibling (assuming
* block/inline alternation), conditionally on it having the same style.
*
* Since this is used when deciding to copy the new style context, it
* takes as an argument the old style context to check if the style is
* the same. When it is used in other contexts (i.e., where the next
* continuation would already have the new style context), the current
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -358,16 +358,9 @@ ServoRestyleManager::ReparentStyleContex
ServoElementSnapshot*
ServoRestyleManager::SnapshotForElement(Element* aElement)
{
// NB: aElement is the argument for the construction of the snapshot in the
// not found case.
return mModifiedElements.LookupOrAdd(aElement, aElement);
}
-nsresult
-ServoRestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
-{
- return base_type::ProcessRestyledFrames(aChangeList, *PresContext(),
- mOverflowChangedTracker);
-}
-
} // namespace mozilla
--- a/layout/base/ServoRestyleManager.h
+++ b/layout/base/ServoRestyleManager.h
@@ -69,17 +69,16 @@ public:
void AttributeChanged(dom::Element* aElement, int32_t aNameSpaceID,
nsIAtom* aAttribute, int32_t aModType,
const nsAttrValue* aOldValue)
{
MOZ_ASSERT(SnapshotForElement(aElement)->HasAttrs());
}
nsresult ReparentStyleContext(nsIFrame* aFrame);
- nsresult ProcessRestyledFrames(nsStyleChangeList& aChangeList);
bool HasPendingRestyles() { return !mModifiedElements.IsEmpty(); }
protected:
~ServoRestyleManager() {}
private:
ServoElementSnapshot* SnapshotForElement(Element* aElement);