From a489a716b52931fee986f864bc72dc339dd9633d Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 4 Mar 2010 14:01:45 +1300 Subject: [PATCH] Bug 564993. Part 2: Don't flatten the layer tree in layout. r=mats --- layout/base/nsDisplayList.cpp | 48 ++++++++++++++++------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index 421782f43403..b1b6f9c7aa28 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -699,9 +699,8 @@ void nsDisplayList::BuildLayers(nsDisplayListBuilder* aBuilder, } /** - * We build a single layer by first building a list of layers needed for - * all the display items, and then if there's not just one layer in the - * list, we build a container layer to hold them. + * We build a single layer by building a list of layers needed for + * all the display items and building a container layer to hold them. */ already_AddRefed nsDisplayList::BuildLayer(nsDisplayListBuilder* aBuilder, @@ -709,30 +708,27 @@ nsDisplayList::BuildLayer(nsDisplayListBuilder* aBuilder, nsTArray* aLayers) const { BuildLayers(aBuilder, aManager, aLayers); - nsRefPtr layer; - if (aLayers->Length() == 1) { - // We can just return the one layer - layer = aLayers->ElementAt(0).mLayer; - } else { - // We need to group multiple layers together into a container - nsRefPtr container = - aManager->CreateContainerLayer(); - if (!container) - return nsnull; - - Layer* lastChild = nsnull; - nsIntRect visibleRect; - for (PRUint32 i = 0; i < aLayers->Length(); ++i) { - LayerItems* layerItems = &aLayers->ElementAt(i); - visibleRect.UnionRect(visibleRect, layerItems->mVisibleRect); - Layer* child = layerItems->mLayer; - container->InsertAfter(child, lastChild); - lastChild = child; - } - container->SetVisibleRegion(nsIntRegion(visibleRect)); - layer = container.forget(); + // If there's only one layer, then in principle we can try to flatten + // things by returning that layer here. But that adds complexity to + // retained layer management so we don't do it. Layer backends can + // flatten internally. + nsRefPtr container = + aManager->CreateContainerLayer(); + if (!container) + return nsnull; + + Layer* lastChild = nsnull; + nsIntRect visibleRect; + for (PRUint32 i = 0; i < aLayers->Length(); ++i) { + LayerItems* layerItems = &aLayers->ElementAt(i); + visibleRect.UnionRect(visibleRect, layerItems->mVisibleRect); + Layer* child = layerItems->mLayer; + container->InsertAfter(child, lastChild); + lastChild = child; } - layer->SetIsOpaqueContent(mIsOpaque); + container->SetVisibleRegion(nsIntRegion(visibleRect)); + container->SetIsOpaqueContent(mIsOpaque); + nsRefPtr layer = container.forget(); return layer.forget(); }