Bug 1492664 - vendor taskcluster-urls; r=gps
[gecko.git] / layout / xul / nsStackFrame.cpp
blob1c44e6b9f053f43d6a09823900c71938343bd63b
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 //
8 // Eric Vaughan
9 // Netscape Communications
11 // See documentation in associated header file
14 #include "nsStackFrame.h"
15 #include "mozilla/ComputedStyle.h"
16 #include "nsIContent.h"
17 #include "nsCOMPtr.h"
18 #include "nsHTMLParts.h"
19 #include "nsIPresShell.h"
20 #include "nsCSSRendering.h"
21 #include "nsBoxLayoutState.h"
22 #include "nsStackLayout.h"
23 #include "nsDisplayList.h"
25 using namespace mozilla;
27 nsIFrame* NS_NewStackFrame(nsIPresShell* aPresShell, ComputedStyle* aStyle) {
28 return new (aPresShell) nsStackFrame(aStyle);
31 NS_IMPL_FRAMEARENA_HELPERS(nsStackFrame)
33 nsStackFrame::nsStackFrame(ComputedStyle* aStyle)
34 : nsBoxFrame(aStyle, kClassID) {
35 nsCOMPtr<nsBoxLayout> layout;
36 NS_NewStackLayout(layout);
37 SetXULLayoutManager(layout);
40 // REVIEW: The old code put everything in the background layer. To be more
41 // consistent with the way other frames work, I'm putting everything in the
42 // Content() (i.e., foreground) layer (see nsFrame::BuildDisplayListForChild,
43 // the case for stacking context but non-positioned, non-floating frames).
44 // This could easily be changed back by hacking
45 // nsBoxFrame::BuildDisplayListInternal a bit more.
46 void nsStackFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
47 const nsDisplayListSet& aLists) {
48 // BuildDisplayListForChild puts stacking contexts into the
49 // PositionedDescendants list. So we need to map that list to
50 // aLists.Content(). This is an easy way to do that.
51 nsDisplayList* content = aLists.Content();
52 nsDisplayListSet kidLists(content, content, content, content, content,
53 content);
54 nsIFrame* kid = mFrames.FirstChild();
55 while (kid) {
56 // Force each child into its own true stacking context.
57 BuildDisplayListForChild(aBuilder, kid, kidLists,
58 DISPLAY_CHILD_FORCE_STACKING_CONTEXT);
59 kid = kid->GetNextSibling();