From a438107cde7ab7d366815633f8ff5c46eef8c038 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 : 0db68211898c111a465dc641bed8e3b2923f0e4e --- 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 7bf5abf89e14..60aae868fc44 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -1017,16 +1017,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); } } @@ -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(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, @@ -1136,43 +1106,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; @@ -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; } diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index 449566085f28..202ab118f88e 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -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* aElements); - nsDisplayItemLink mSentinel; nsDisplayItemLink* mTop;