michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: // michael@0: // Eric Vaughan michael@0: // Netscape Communications michael@0: // michael@0: // See documentation in associated header file michael@0: // michael@0: michael@0: #include "nsStackFrame.h" michael@0: #include "nsStyleContext.h" michael@0: #include "nsIContent.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsHTMLParts.h" michael@0: #include "nsIPresShell.h" michael@0: #include "nsCSSRendering.h" michael@0: #include "nsBoxLayoutState.h" michael@0: #include "nsStackLayout.h" michael@0: #include "nsDisplayList.h" michael@0: michael@0: nsIFrame* michael@0: NS_NewStackFrame(nsIPresShell* aPresShell, nsStyleContext* aContext) michael@0: { michael@0: return new (aPresShell) nsStackFrame(aPresShell, aContext); michael@0: } michael@0: michael@0: NS_IMPL_FRAMEARENA_HELPERS(nsStackFrame) michael@0: michael@0: nsStackFrame::nsStackFrame(nsIPresShell* aPresShell, nsStyleContext* aContext): michael@0: nsBoxFrame(aPresShell, aContext) michael@0: { michael@0: nsCOMPtr layout; michael@0: NS_NewStackLayout(aPresShell, layout); michael@0: SetLayoutManager(layout); michael@0: } michael@0: michael@0: // REVIEW: The old code put everything in the background layer. To be more michael@0: // consistent with the way other frames work, I'm putting everything in the michael@0: // Content() (i.e., foreground) layer (see nsFrame::BuildDisplayListForChild, michael@0: // the case for stacking context but non-positioned, non-floating frames). michael@0: // This could easily be changed back by hacking nsBoxFrame::BuildDisplayListInternal michael@0: // a bit more. michael@0: void michael@0: nsStackFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder, michael@0: const nsRect& aDirtyRect, michael@0: const nsDisplayListSet& aLists) michael@0: { michael@0: // BuildDisplayListForChild puts stacking contexts into the PositionedDescendants michael@0: // list. So we need to map that list to aLists.Content(). This is an easy way to michael@0: // do that. michael@0: nsDisplayList* content = aLists.Content(); michael@0: nsDisplayListSet kidLists(content, content, content, content, content, content); michael@0: nsIFrame* kid = mFrames.FirstChild(); michael@0: while (kid) { michael@0: // Force each child into its own true stacking context. michael@0: BuildDisplayListForChild(aBuilder, kid, aDirtyRect, kidLists, michael@0: DISPLAY_CHILD_FORCE_STACKING_CONTEXT); michael@0: kid = kid->GetNextSibling(); michael@0: } michael@0: }