Bug 1022612. Part 24: Simplify nsDisplayList::ComputeVisibilityForSublist now that FrameLayerBuilder does most of the work. r=mattwoodrow

--HG--
extra : rebase_source : 0db68211898c111a465dc641bed8e3b2923f0e4e
This commit is contained in:
Robert O'Callahan 2014-06-09 16:48:02 +12:00
Родитель f00b9f098c
Коммит a438107cde
2 изменённых файлов: 5 добавлений и 77 удалений

Просмотреть файл

@ -1017,17 +1017,12 @@ void nsDisplayListSet::MoveTo(const nsDisplayListSet& aDestination) const
aDestination.Outlines()->AppendToTop(Outlines());
}
void
nsDisplayList::FlattenTo(nsTArray<nsDisplayItem*>* aElements) {
static void
MoveListTo(nsDisplayList* aList, nsTArray<nsDisplayItem*>* aElements) {
nsDisplayItem* item;
while ((item = RemoveBottom()) != nullptr) {
if (item->GetType() == nsDisplayItem::TYPE_WRAP_LIST) {
item->GetSameCoordinateSystemChildren()->FlattenTo(aElements);
item->~nsDisplayItem();
} else {
while ((item = aList->RemoveBottom()) != nullptr) {
aElements->AppendElement(item);
}
}
}
nsRect
@ -1094,31 +1089,6 @@ TreatAsOpaque(nsDisplayItem* aItem, nsDisplayListBuilder* aBuilder)
return opaqueClipped;
}
/* Checks if aPotentialScrollItem is a scroll layer item and aPotentialScrollbarItem
* is an overlay scrollbar item for the same scroll frame.
*/
static bool
IsScrollLayerItemAndOverlayScrollbarForScrollFrame(
nsDisplayItem* aPotentialScrollItem, nsDisplayItem* aPotentialScrollbarItem)
{
if (aPotentialScrollItem->GetType() == nsDisplayItem::TYPE_SCROLL_LAYER &&
aPotentialScrollbarItem &&
aPotentialScrollbarItem->GetType() == nsDisplayItem::TYPE_OWN_LAYER &&
LookAndFeel::GetInt(LookAndFeel::eIntID_UseOverlayScrollbars)) {
nsDisplayScrollLayer* scrollItem =
static_cast<nsDisplayScrollLayer*>(aPotentialScrollItem);
nsDisplayOwnLayer* layerItem =
static_cast<nsDisplayOwnLayer*>(aPotentialScrollbarItem);
if ((layerItem->GetFlags() &
(nsDisplayOwnLayer::VERTICAL_SCROLLBAR |
nsDisplayOwnLayer::HORIZONTAL_SCROLLBAR)) &&
layerItem->Frame()->GetParent() == scrollItem->GetScrollFrame()) {
return true;
}
}
return false;
}
bool
nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
@ -1136,43 +1106,10 @@ nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
bool anyVisible = false;
nsAutoTArray<nsDisplayItem*, 512> elements;
FlattenTo(&elements);
bool forceTransparentSurface = false;
MoveListTo(this, &elements);
for (int32_t i = elements.Length() - 1; i >= 0; --i) {
nsDisplayItem* item = elements[i];
nsDisplayItem* belowItem = i < 1 ? nullptr : elements[i - 1];
nsDisplayList* list = item->GetSameCoordinateSystemChildren();
if (aBuilder->AllowMergingAndFlattening()) {
if (belowItem && item->TryMerge(aBuilder, belowItem)) {
belowItem->~nsDisplayItem();
elements.ReplaceElementsAt(i - 1, 1, item);
continue;
}
// If an overlay scrollbar item is between a scroll layer item and the
// other scroll layer items that we need to merge with just move the
// scrollbar item up, that way it will be on top of the scrolled content
// and we can try to merge all the scroll layer items.
if (IsScrollLayerItemAndOverlayScrollbarForScrollFrame(item, belowItem)) {
elements[i] = belowItem;
elements[i-1] = item;
i++;
continue;
}
if (list && item->ShouldFlattenAway(aBuilder)) {
// The elements on the list >= i no longer serve any use.
elements.SetLength(i);
list->FlattenTo(&elements);
i = elements.Length();
item->~nsDisplayItem();
continue;
}
}
nsRect bounds = item->GetClippedBounds(aBuilder);
nsRegion itemVisible;
@ -1216,17 +1153,11 @@ nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
aVisibleRegion->SetEmpty();
}
}
if (aBuilder->NeedToForceTransparentSurfaceForItem(item) ||
(list && list->NeedsTransparentSurface())) {
forceTransparentSurface = true;
}
}
AppendToBottom(item);
}
mIsOpaque = !aVisibleRegion->Intersects(mVisibleRect);
mForceTransparentSurface = forceTransparentSurface;
return anyVisible;
}

Просмотреть файл

@ -1699,9 +1699,6 @@ private:
// it. Don't let us be heap-allocated!
void* operator new(size_t sz) CPP_THROW_NEW;
// Utility function used to massage the list during ComputeVisibility.
void FlattenTo(nsTArray<nsDisplayItem*>* aElements);
nsDisplayItemLink mSentinel;
nsDisplayItemLink* mTop;