Bug 933264. If we have to flatten scroll layer items make sure to clip their child items properly. r=roc

The scroll layer item has the clip induced by the scroll frame, but the scrolled items are only clipped to the (larger) display port so we can async scroll the display port area. But if we can't merge all the scroll layer items then we can't render the expanded display port content so we have to clip the scrolled items to the scroll frame by propagating the clip on the scroll layer item to its children.
This commit is contained in:
Timothy Nikkel 2013-12-10 12:05:18 -06:00
parent 6e00c79ea8
commit 76f3bda08c

View File

@ -3566,10 +3566,33 @@ nsDisplayScrollLayer::TryMerge(nsDisplayListBuilder* aBuilder,
return true;
}
void
PropagateClip(nsDisplayListBuilder* aBuilder, const DisplayItemClip& aClip,
nsDisplayList* aList)
{
for (nsDisplayItem* i = aList->GetBottom(); i != nullptr; i = i->GetAbove()) {
DisplayItemClip clip(i->GetClip());
clip.IntersectWith(aClip);
i->SetClip(aBuilder, clip);
nsDisplayList* list = i->GetSameCoordinateSystemChildren();
if (list) {
PropagateClip(aBuilder, aClip, list);
}
}
}
bool
nsDisplayScrollLayer::ShouldFlattenAway(nsDisplayListBuilder* aBuilder)
{
return GetScrollLayerCount() > 1;
if (GetScrollLayerCount() > 1) {
// Propagate our clip to our children. The clip for the scroll frame is
// on this item, but not our child items so that they can draw non-visible
// parts of the display port. But if we are flattening we failed and can't
// draw the extra content, so it needs to be clipped.
PropagateClip(aBuilder, GetClip(), &mList);
return true;
}
return false;
}
intptr_t