From 775fd8f7d9c7851b1605a174ec47856e631e6077 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 9 Jun 2014 16:48:02 +1200 Subject: [PATCH] Bug 1022612. Part 24: Simplify nsDisplayList::ComputeVisibilityForSublist now that FrameLayerBuilder does most of the work. r=mattwoodrow --HG-- extra : rebase_source : 566019828bc5c021e15bb148accc4262c69232e1 --- layout/base/nsDisplayList.cpp | 79 +++-------------------------------- layout/base/nsDisplayList.h | 3 -- 2 files changed, 5 insertions(+), 77 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index b7b4b045f83..b26d1c10dd8 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -1020,16 +1020,11 @@ void nsDisplayListSet::MoveTo(const nsDisplayListSet& aDestination) const aDestination.Outlines()->AppendToTop(Outlines()); } -void -nsDisplayList::FlattenTo(nsTArray* aElements) { +static void +MoveListTo(nsDisplayList* aList, nsTArray* aElements) { nsDisplayItem* item; - while ((item = RemoveBottom()) != nullptr) { - if (item->GetType() == nsDisplayItem::TYPE_WRAP_LIST) { - item->GetSameCoordinateSystemChildren()->FlattenTo(aElements); - item->~nsDisplayItem(); - } else { - aElements->AppendElement(item); - } + while ((item = aList->RemoveBottom()) != nullptr) { + aElements->AppendElement(item); } } @@ -1088,31 +1083,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(aPotentialScrollItem); - nsDisplayOwnLayer* layerItem = - static_cast(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, @@ -1130,43 +1100,10 @@ nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder, bool anyVisible = false; nsAutoTArray 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; @@ -1210,17 +1147,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; } diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index efe084dc964..bfa170b9cf4 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -1687,9 +1687,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* aElements); - nsDisplayItemLink mSentinel; nsDisplayItemLink* mTop;