Bug 846901 - Skip nsDisplayWrapList construction if there's only one item to wrap and it already has the right frame. r=mattwoodrow

This commit is contained in:
Robert O'Callahan 2013-03-19 09:08:28 -04:00
parent 14c8261e29
commit b916edc330

View File

@ -2054,6 +2054,18 @@ IsRootScrollFrameActive(nsIPresShell* aPresShell)
return sf && sf->IsScrollingActive();
}
static nsDisplayItem*
WrapInWrapList(nsDisplayListBuilder* aBuilder,
nsIFrame* aFrame, nsDisplayList* aList)
{
nsDisplayItem* item = aList->GetBottom();
if (!item || item->GetAbove() || item->GetUnderlyingFrame() != aFrame) {
return new (aBuilder) nsDisplayWrapList(aBuilder, aFrame, aList);
}
aList->RemoveBottom();
return item;
}
void
nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
nsIFrame* aChild,
@ -2288,7 +2300,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
if (buildFixedPositionItem) {
item = new (aBuilder) nsDisplayFixedPosition(aBuilder, child, child, &list);
} else {
item = new (aBuilder) nsDisplayWrapList(aBuilder, child, &list);
item = WrapInWrapList(aBuilder, child, &list);
}
if (isSVG) {
aLists.Content()->AppendNewToTop(item);
@ -2311,8 +2323,7 @@ nsIFrame::BuildDisplayListForChild(nsDisplayListBuilder* aBuilder,
}
} else if (!isSVG && disp->IsFloating(child)) {
if (!list.IsEmpty()) {
aLists.Floats()->AppendNewToTop(new (aBuilder)
nsDisplayWrapList(aBuilder, child, &list));
aLists.Floats()->AppendNewToTop(WrapInWrapList(aBuilder, child, &list));
}
} else {
aLists.Content()->AppendToTop(&list);