Bug 502288. Provide finer-grained style change hints for triggering reflow. r=dbaron

This commit is contained in:
Boris Zbarsky
2009-08-03 21:22:13 -04:00
parent bcf5ceb041
commit 311d82ece6
8 changed files with 150 additions and 37 deletions

View File

@@ -7571,7 +7571,8 @@ InvalidateCanvasIfNeeded(nsIPresShell* presShell, nsIContent* node)
}
nsresult
nsCSSFrameConstructor::StyleChangeReflow(nsIFrame* aFrame)
nsCSSFrameConstructor::StyleChangeReflow(nsIFrame* aFrame,
nsChangeHint aHint)
{
// If the frame hasn't even received an initial reflow, then don't
// send it a style-change reflow!
@@ -7586,17 +7587,27 @@ nsCSSFrameConstructor::StyleChangeReflow(nsIFrame* aFrame)
}
#endif
// If the frame is part of a split block-in-inline hierarchy, then
// target the style-change reflow at the first ``normal'' ancestor
// so we're sure that the style change will propagate to any
// anonymously created siblings.
if (IsFrameSpecial(aFrame))
aFrame = GetIBContainingBlockFor(aFrame);
nsIPresShell::IntrinsicDirty dirtyType;
if (aHint & nsChangeHint_ClearDescendantIntrinsics) {
NS_ASSERTION(aHint & nsChangeHint_ClearAncestorIntrinsics,
"Please read the comments in nsChangeHint.h");
dirtyType = nsIPresShell::eStyleChange;
} else if (aHint & nsChangeHint_ClearAncestorIntrinsics) {
dirtyType = nsIPresShell::eTreeChange;
} else {
dirtyType = nsIPresShell::eResize;
}
nsFrameState dirtyBits;
if (aHint & nsChangeHint_NeedDirtyReflow) {
dirtyBits = NS_FRAME_IS_DIRTY;
} else {
dirtyBits = NS_FRAME_HAS_DIRTY_CHILDREN;
}
do {
mPresShell->FrameNeedsReflow(aFrame, nsIPresShell::eStyleChange,
NS_FRAME_IS_DIRTY);
aFrame = aFrame->GetNextContinuation();
mPresShell->FrameNeedsReflow(aFrame, dirtyType, dirtyBits);
aFrame = nsLayoutUtils::GetNextContinuationOrSpecialSibling(aFrame);
} while (aFrame);
return NS_OK;
@@ -7718,6 +7729,11 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
nsIContent* content;
nsChangeHint hint;
aChangeList.ChangeAt(index, frame, content, hint);
NS_ASSERTION(!(hint & nsChangeHint_ReflowFrame) ||
(hint & nsChangeHint_NeedReflow),
"Reflow hint bits set without actually asking for a reflow");
if (frame && frame->GetContent() != content) {
// XXXbz this is due to image maps messing with the primary frame map.
// See bug 135040. Remove this block once that's fixed.
@@ -7746,8 +7762,8 @@ nsCSSFrameConstructor::ProcessRestyledFrames(nsStyleChangeList& aChangeList)
nsSVGEffects::UpdateEffects(frame);
}
#endif
if (hint & nsChangeHint_ReflowFrame) {
StyleChangeReflow(frame);
if (hint & nsChangeHint_NeedReflow) {
StyleChangeReflow(frame, hint);
didReflow = PR_TRUE;
}
if (hint & (nsChangeHint_RepaintFrame | nsChangeHint_SyncFrameView)) {