From 1986ba6f20787606184aeb25a2358a1bcc899b0f Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 27 Aug 2010 18:15:08 -0500 Subject: [PATCH] Bug 590468. Part 1: Add support for XUL 'layer' attribute. r=tnikkel sr=vlad --- layout/xul/base/src/nsBoxFrame.cpp | 39 +++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/layout/xul/base/src/nsBoxFrame.cpp b/layout/xul/base/src/nsBoxFrame.cpp index f464abfe603..2c3bfb67f60 100644 --- a/layout/xul/base/src/nsBoxFrame.cpp +++ b/layout/xul/base/src/nsBoxFrame.cpp @@ -1307,27 +1307,54 @@ nsBoxFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, const nsRect& aDirtyRect, const nsDisplayListSet& aLists) { - nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists); + // forcelayer is only supported on XUL elements with box layout + PRBool forceLayer = + GetContent()->HasAttr(kNameSpaceID_None, nsGkAtoms::layer) && + GetContent()->IsXUL(); + + nsDisplayListCollection tempLists; + const nsDisplayListSet& destination = forceLayer ? tempLists : aLists; + + nsresult rv = DisplayBorderBackgroundOutline(aBuilder, destination); NS_ENSURE_SUCCESS(rv, rv); #ifdef DEBUG_LAYOUT - // REVIEW: From GetFrameForPoint if (mState & NS_STATE_CURRENTLY_IN_DEBUG) { - rv = aLists.BorderBackground()->AppendNewToTop(new (aBuilder) + rv = destination.BorderBackground()->AppendNewToTop(new (aBuilder) nsDisplayGeneric(aBuilder, this, PaintXULDebugBackground, "XULDebugBackground")); NS_ENSURE_SUCCESS(rv, rv); - rv = aLists.Outlines()->AppendNewToTop(new (aBuilder) + rv = destination.Outlines()->AppendNewToTop(new (aBuilder) nsDisplayXULDebug(aBuilder, this)); NS_ENSURE_SUCCESS(rv, rv); } #endif - rv = BuildDisplayListForChildren(aBuilder, aDirtyRect, aLists); + rv = BuildDisplayListForChildren(aBuilder, aDirtyRect, destination); NS_ENSURE_SUCCESS(rv, rv); // see if we have to draw a selection frame around this container - return DisplaySelectionOverlay(aBuilder, aLists); + rv = DisplaySelectionOverlay(aBuilder, destination); + NS_ENSURE_SUCCESS(rv, rv); + + if (forceLayer) { + // This is a bit of a hack. Collect up all descendant display items + // and merge them into a single Content() list. This can cause us + // to violate CSS stacking order, but forceLayer is a magic + // XUL-only extension anyway. + nsDisplayList masterList; + masterList.AppendToTop(tempLists.BorderBackground()); + masterList.AppendToTop(tempLists.BlockBorderBackgrounds()); + masterList.AppendToTop(tempLists.Floats()); + masterList.AppendToTop(tempLists.Content()); + masterList.AppendToTop(tempLists.PositionedDescendants()); + masterList.AppendToTop(tempLists.Outlines()); + // Wrap the list to make it its own layer + rv = aLists.Content()->AppendNewToTop(new (aBuilder) + nsDisplayOwnLayer(aBuilder, this, &masterList)); + NS_ENSURE_SUCCESS(rv, rv); + } + return NS_OK; } NS_IMETHODIMP