Bug 539356 - Part 18 - Mark frames with only invalid children as an optimization to use when invalidating further frames. r=roc

This commit is contained in:
Matt Woodrow 2012-06-30 15:06:12 +12:00
parent fc782c15da
commit dbca7f19d8
2 changed files with 23 additions and 2 deletions

View File

@ -4597,6 +4597,12 @@ void
nsIFrame::InvalidateFrameSubtree(PRUint32 aFlags) nsIFrame::InvalidateFrameSubtree(PRUint32 aFlags)
{ {
InvalidateFrame(aFlags); InvalidateFrame(aFlags);
if (HasAnyStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT)) {
return;
}
AddStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT);
nsAutoTArray<nsIFrame::ChildList,4> childListArray; nsAutoTArray<nsIFrame::ChildList,4> childListArray;
GetCrossDocChildLists(&childListArray); GetCrossDocChildLists(&childListArray);
@ -4627,7 +4633,9 @@ nsIFrame::ClearInvalidationStateBits()
} }
} }
RemoveStateBits(NS_FRAME_NEEDS_PAINT | NS_FRAME_DESCENDANT_NEEDS_PAINT); RemoveStateBits(NS_FRAME_NEEDS_PAINT |
NS_FRAME_DESCENDANT_NEEDS_PAINT |
NS_FRAME_ALL_DESCENDANTS_NEED_PAINT);
} }
void void
@ -7784,6 +7792,13 @@ nsFrame::SetParent(nsIFrame* aParent)
} else { } else {
RemoveInPopupStateBitFromDescendants(this); RemoveInPopupStateBitFromDescendants(this);
} }
// If our new parent only has invalid children, then we just invalidate
// ourselves too. This is probably faster than clearing the flag all
// the way up the frame tree.
if (aParent->HasAnyStateBits(NS_FRAME_ALL_DESCENDANTS_NEED_PAINT)) {
InvalidateFrame(INVALIDATE_DONT_SCHEDULE_PAINT);
}
} }
void void

View File

@ -286,8 +286,14 @@ typedef PRUint64 nsFrameState;
// cross-doc children. // cross-doc children.
#define NS_FRAME_DESCENDANT_NEEDS_PAINT NS_FRAME_STATE_BIT(46) #define NS_FRAME_DESCENDANT_NEEDS_PAINT NS_FRAME_STATE_BIT(46)
// Frame has only descendant frames that needs painting - This includes
// cross-doc children. This guarantees that all descendents have
// NS_FRAME_NEEDS_PAINT and NS_FRAME_ALL_DESCENDANTS_NEED_PAINT, or they
// have no display items.
#define NS_FRAME_ALL_DESCENDANTS_NEED_PAINT NS_FRAME_STATE_BIT(47)
// Frame is a descendant of a popup // Frame is a descendant of a popup
#define NS_FRAME_IN_POPUP NS_FRAME_STATE_BIT(47) #define NS_FRAME_IN_POPUP NS_FRAME_STATE_BIT(48)
// Box layout bits // Box layout bits
#define NS_STATE_IS_HORIZONTAL NS_FRAME_STATE_BIT(22) #define NS_STATE_IS_HORIZONTAL NS_FRAME_STATE_BIT(22)