2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2000-03-02 03:01:30 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2000-03-02 03:01:30 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
2000-03-02 03:01:30 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Mozilla Communicator client code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
2000-03-02 03:01:30 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2000-03-02 03:01:30 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Eric Vaughan
|
|
|
|
// Netscape Communications
|
|
|
|
//
|
|
|
|
// See documentation in associated header file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "nsStackFrame.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
2000-03-02 03:01:30 +00:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsCSSRendering.h"
|
2000-03-31 07:02:06 +00:00
|
|
|
#include "nsBoxLayoutState.h"
|
|
|
|
#include "nsStackLayout.h"
|
2006-08-03 21:39:39 +00:00
|
|
|
#include "nsDisplayList.h"
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2005-10-26 21:46:39 +00:00
|
|
|
nsIFrame*
|
2009-01-19 18:31:33 +00:00
|
|
|
NS_NewStackFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2000-03-02 03:01:30 +00:00
|
|
|
{
|
2009-01-19 18:31:33 +00:00
|
|
|
return new (aPresShell) nsStackFrame(aPresShell, aContext);
|
2000-03-31 07:02:06 +00:00
|
|
|
} // NS_NewStackFrame
|
2000-03-02 03:01:30 +00:00
|
|
|
|
2009-01-19 18:31:33 +00:00
|
|
|
nsStackFrame::nsStackFrame(nsIPresShell* aPresShell, nsStyleContext* aContext):
|
2006-03-26 21:30:36 +00:00
|
|
|
nsBoxFrame(aPresShell, aContext)
|
2000-03-02 03:01:30 +00:00
|
|
|
{
|
2009-01-19 18:31:33 +00:00
|
|
|
nsCOMPtr<nsIBoxLayout> layout;
|
|
|
|
NS_NewStackLayout(aPresShell, layout);
|
2000-04-05 00:19:00 +00:00
|
|
|
SetLayoutManager(layout);
|
2000-03-02 03:01:30 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// REVIEW: The old code put everything in the background layer. To be more
|
|
|
|
// consistent with the way other frames work, I'm putting everything in the
|
|
|
|
// Content() (i.e., foreground) layer (see nsFrame::BuildDisplayListForChild,
|
|
|
|
// the case for stacking context but non-positioned, non-floating frames).
|
|
|
|
// This could easily be changed back by hacking nsBoxFrame::BuildDisplayListInternal
|
|
|
|
// a bit more.
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsStackFrame::BuildDisplayListForChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2004-04-22 18:59:21 +00:00
|
|
|
{
|
2006-08-03 21:39:39 +00:00
|
|
|
// BuildDisplayListForChild puts stacking contexts into the PositionedDescendants
|
|
|
|
// list. So we need to map that list to aLists.Content(). This is an easy way to
|
|
|
|
// do that.
|
|
|
|
nsDisplayList* content = aLists.Content();
|
|
|
|
nsDisplayListSet kidLists(content, content, content, content, content, content);
|
2006-01-26 02:29:17 +00:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
while (kid) {
|
2006-08-03 21:39:39 +00:00
|
|
|
// Force each child into its own true stacking context.
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult rv =
|
2006-08-03 21:39:39 +00:00
|
|
|
BuildDisplayListForChild(aBuilder, kid, aDirtyRect, kidLists,
|
|
|
|
DISPLAY_CHILD_FORCE_STACKING_CONTEXT);
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
kid = kid->GetNextSibling();
|
2000-03-02 03:01:30 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
2000-03-02 03:01:30 +00:00
|
|
|
}
|