2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-10-01 01:35:29 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04: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/
|
1998-10-01 01:35:29 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04: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.
|
1998-10-01 01:35:29 +04:00
|
|
|
*
|
1999-11-06 06:40:37 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2007-07-26 08:03:29 +04:00
|
|
|
* Elika J. Etemad ("fantasai") <fantasai@inkedblade.net>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04: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-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04: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 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
2006-03-29 22:29:03 +04:00
|
|
|
|
|
|
|
/* base class #1 for rendering objects that have child lists */
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
#include "nsContainerFrame.h"
|
2007-07-26 08:03:29 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1998-10-01 01:35:29 +04:00
|
|
|
#include "nsIContent.h"
|
2003-04-06 06:49:40 +04:00
|
|
|
#include "nsIDocument.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-10-01 01:35:29 +04:00
|
|
|
#include "nsIRenderingContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-10-01 01:35:29 +04:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIView.h"
|
1999-04-13 04:15:13 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
2004-02-24 00:29:06 +03:00
|
|
|
#include "nsFrameManager.h"
|
1999-10-21 09:11:43 +04:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2002-11-17 18:37:56 +03:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1999-11-19 18:33:29 +03:00
|
|
|
#include "nsIViewManager.h"
|
2001-07-16 06:40:48 +04:00
|
|
|
#include "nsIWidget.h"
|
2001-12-01 17:31:45 +03:00
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2002-01-14 18:00:30 +03:00
|
|
|
#include "nsCSSRendering.h"
|
2002-06-18 03:35:15 +04:00
|
|
|
#include "nsTransform2D.h"
|
2002-08-30 07:32:05 +04:00
|
|
|
#include "nsRegion.h"
|
2002-11-25 14:21:22 +03:00
|
|
|
#include "nsLayoutErrors.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2006-03-22 21:36:36 +03:00
|
|
|
#include "nsContentErrors.h"
|
2006-08-30 02:00:26 +04:00
|
|
|
#include "nsIEventStateManager.h"
|
2007-12-23 00:07:58 +03:00
|
|
|
#include "nsListControlFrame.h"
|
2008-01-10 01:50:29 +03:00
|
|
|
#include "nsIBaseWindow.h"
|
2008-08-13 04:44:14 +04:00
|
|
|
#include "nsThemeConstants.h"
|
|
|
|
#include "nsCSSFrameConstructor.h"
|
|
|
|
#include "nsThemeConstants.h"
|
2010-04-30 17:12:05 +04:00
|
|
|
#include "Element.h"
|
2001-12-01 17:31:45 +03:00
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
#undef NOISY
|
|
|
|
#else
|
|
|
|
#undef NOISY
|
|
|
|
#endif
|
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
using namespace mozilla;
|
2010-04-30 17:12:05 +04:00
|
|
|
using namespace mozilla::dom;
|
2010-03-29 05:46:55 +04:00
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsContainerFrame)
|
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
nsContainerFrame::~nsContainerFrame()
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-09-18 15:09:35 +04:00
|
|
|
NS_QUERYFRAME_HEAD(nsContainerFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsContainerFrame)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsSplittableFrame)
|
|
|
|
|
2001-04-17 10:43:01 +04:00
|
|
|
NS_IMETHODIMP
|
2006-12-25 21:53:52 +03:00
|
|
|
nsContainerFrame::Init(nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
2001-04-17 10:43:01 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
nsresult rv = nsSplittableFrame::Init(aContent, aParent, aPrevInFlow);
|
2001-04-17 10:43:01 +04:00
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Make sure we copy bits from our prev-in-flow that will affect
|
|
|
|
// us. A continuation for a container frame needs to know if it
|
|
|
|
// has a child with a view so that we'll properly reposition it.
|
2003-06-26 15:30:17 +04:00
|
|
|
if (aPrevInFlow->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW)
|
|
|
|
AddStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW);
|
2001-04-17 10:43:01 +04:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
NS_IMETHODIMP
|
2009-07-28 16:53:20 +04:00
|
|
|
nsContainerFrame::SetInitialChildList(nsIAtom* aListName,
|
|
|
|
nsFrameList& aChildList)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
1999-01-16 01:53:39 +03:00
|
|
|
nsresult result;
|
2009-09-18 15:09:36 +04:00
|
|
|
if (mFrames.NotEmpty()) {
|
1999-07-25 01:41:15 +04:00
|
|
|
// We already have child frames which means we've already been
|
|
|
|
// initialized
|
2002-06-12 07:27:48 +04:00
|
|
|
NS_NOTREACHED("unexpected second call to SetInitialChildList");
|
1998-11-10 09:05:32 +03:00
|
|
|
result = NS_ERROR_UNEXPECTED;
|
1999-07-25 01:41:15 +04:00
|
|
|
} else if (aListName) {
|
|
|
|
// All we know about is the unnamed principal child list
|
2002-06-12 07:27:48 +04:00
|
|
|
NS_NOTREACHED("unknown frame list");
|
1998-11-10 09:05:32 +03:00
|
|
|
result = NS_ERROR_INVALID_ARG;
|
|
|
|
} else {
|
1999-07-25 01:41:15 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsFrame::VerifyDirtyBitSet(aChildList);
|
|
|
|
#endif
|
1999-01-16 01:53:39 +03:00
|
|
|
mFrames.SetFrames(aChildList);
|
1998-11-10 09:05:32 +03:00
|
|
|
result = NS_OK;
|
|
|
|
}
|
|
|
|
return result;
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
2006-12-25 21:53:52 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContainerFrame::AppendFrames(nsIAtom* aListName,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2006-12-25 21:53:52 +03:00
|
|
|
{
|
|
|
|
if (nsnull != aListName) {
|
|
|
|
#ifdef IBMBIDI
|
2006-12-26 21:34:59 +03:00
|
|
|
if (aListName != nsGkAtoms::nextBidi)
|
2006-12-25 21:53:52 +03:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
NS_ERROR("unexpected child list");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
2009-07-30 21:23:32 +04:00
|
|
|
if (aFrameList.NotEmpty()) {
|
2006-12-25 21:53:52 +03:00
|
|
|
mFrames.AppendFrames(this, aFrameList);
|
|
|
|
|
|
|
|
// Ask the parent frame to reflow me.
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
if (nsnull == aListName)
|
|
|
|
#endif
|
|
|
|
{
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2009-04-11 00:42:29 +04:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-12-25 21:53:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContainerFrame::InsertFrames(nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
2006-12-25 21:53:52 +03:00
|
|
|
{
|
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
|
|
|
|
|
|
|
if (nsnull != aListName) {
|
|
|
|
#ifdef IBMBIDI
|
2006-12-26 21:34:59 +03:00
|
|
|
if (aListName != nsGkAtoms::nextBidi)
|
2006-12-25 21:53:52 +03:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
NS_ERROR("unexpected child list");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
2009-07-30 21:23:32 +04:00
|
|
|
if (aFrameList.NotEmpty()) {
|
2006-12-25 21:53:52 +03:00
|
|
|
// Insert frames after aPrevFrame
|
|
|
|
mFrames.InsertFrames(this, aPrevFrame, aFrameList);
|
|
|
|
|
|
|
|
#ifdef IBMBIDI
|
|
|
|
if (nsnull == aListName)
|
|
|
|
#endif
|
2007-02-13 21:11:24 +03:00
|
|
|
{
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2009-04-11 00:42:29 +04:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2007-02-13 21:11:24 +03:00
|
|
|
}
|
2006-12-25 21:53:52 +03:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContainerFrame::RemoveFrame(nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
if (nsnull != aListName) {
|
|
|
|
#ifdef IBMBIDI
|
2006-12-26 21:34:59 +03:00
|
|
|
if (nsGkAtoms::nextBidi != aListName)
|
2006-12-25 21:53:52 +03:00
|
|
|
#endif
|
|
|
|
{
|
|
|
|
NS_ERROR("unexpected child list");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aOldFrame) {
|
|
|
|
// Loop and destroy the frame and all of its continuations.
|
|
|
|
// If the frame we are removing is a brFrame, we need a reflow so
|
|
|
|
// the line the brFrame was on can attempt to pull up any frames
|
|
|
|
// that can fit from lines below it.
|
2007-12-11 04:14:25 +03:00
|
|
|
PRBool generateReflowCommand = PR_TRUE;
|
2006-12-25 21:53:52 +03:00
|
|
|
#ifdef IBMBIDI
|
2007-12-11 04:14:25 +03:00
|
|
|
if (nsGkAtoms::nextBidi == aListName) {
|
|
|
|
generateReflowCommand = PR_FALSE;
|
|
|
|
}
|
2006-12-25 21:53:52 +03:00
|
|
|
#endif
|
2007-12-11 04:14:25 +03:00
|
|
|
nsContainerFrame* parent = static_cast<nsContainerFrame*>(aOldFrame->GetParent());
|
|
|
|
while (aOldFrame) {
|
2006-12-25 21:53:52 +03:00
|
|
|
// When the parent is an inline frame we have a simple task - just
|
|
|
|
// remove the frame from its parents list and generate a reflow
|
|
|
|
// command.
|
|
|
|
nsIFrame* oldFrameNextContinuation = aOldFrame->GetNextContinuation();
|
2007-07-26 08:03:29 +04:00
|
|
|
//XXXfr probably should use StealFrame here. I'm not sure if we need to
|
|
|
|
// check the overflow lists atm, but we'll need a prescontext lookup
|
|
|
|
// for overflow containers once we can split abspos elements with
|
|
|
|
// inline containing blocks.
|
2007-10-03 07:44:18 +04:00
|
|
|
if (parent == this) {
|
2009-09-18 15:09:36 +04:00
|
|
|
if (!parent->mFrames.DestroyFrameIfPresent(aOldFrame)) {
|
2008-01-15 04:12:01 +03:00
|
|
|
// Try to remove it from our overflow list, if we have one.
|
|
|
|
// The simplest way is to reuse StealFrame.
|
2009-09-18 15:09:36 +04:00
|
|
|
StealFrame(PresContext(), aOldFrame, PR_TRUE);
|
2008-01-15 04:12:01 +03:00
|
|
|
aOldFrame->Destroy();
|
|
|
|
}
|
2007-10-03 07:44:18 +04:00
|
|
|
} else {
|
|
|
|
// This recursive call takes care of all continuations after aOldFrame,
|
|
|
|
// so we don't need to loop anymore.
|
|
|
|
parent->RemoveFrame(nsnull, aOldFrame);
|
|
|
|
break;
|
|
|
|
}
|
2006-12-25 21:53:52 +03:00
|
|
|
aOldFrame = oldFrameNextContinuation;
|
|
|
|
if (aOldFrame) {
|
2007-07-08 11:08:04 +04:00
|
|
|
parent = static_cast<nsContainerFrame*>(aOldFrame->GetParent());
|
2006-12-25 21:53:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (generateReflowCommand) {
|
2007-03-31 01:11:41 +04:00
|
|
|
PresContext()->PresShell()->
|
2009-04-11 00:42:29 +04:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-12-25 21:53:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-04-10 04:16:29 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsContainerFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
1998-11-14 22:25:34 +03:00
|
|
|
// Prevent event dispatch during destruction
|
2003-06-20 03:44:01 +04:00
|
|
|
if (HasView()) {
|
2003-06-26 15:30:17 +04:00
|
|
|
GetView()->SetClientData(nsnull);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
1998-11-14 22:25:34 +03:00
|
|
|
// Delete the primary child list
|
2009-12-24 08:21:15 +03:00
|
|
|
mFrames.DestroyFramesFrom(aDestructRoot);
|
2007-07-26 08:03:29 +04:00
|
|
|
|
|
|
|
// Destroy auxiliary frame lists
|
|
|
|
nsPresContext* prescontext = PresContext();
|
|
|
|
|
2009-12-24 08:21:15 +03:00
|
|
|
DestroyOverflowList(prescontext, aDestructRoot);
|
1998-11-14 22:25:34 +03:00
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
if (IsFrameOfType(nsIFrame::eCanContainOverflowContainers)) {
|
2010-03-29 05:46:55 +04:00
|
|
|
nsFrameList* frameList =
|
|
|
|
RemovePropTableFrames(prescontext, OverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
if (frameList)
|
2009-12-24 08:21:15 +03:00
|
|
|
frameList->DestroyFrom(aDestructRoot);
|
2007-07-26 08:03:29 +04:00
|
|
|
|
|
|
|
frameList = RemovePropTableFrames(prescontext,
|
2010-03-29 05:46:55 +04:00
|
|
|
ExcessOverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
if (frameList)
|
2009-12-24 08:21:15 +03:00
|
|
|
frameList->DestroyFrom(aDestructRoot);
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
|
2002-10-30 18:33:36 +03:00
|
|
|
// Destroy the frame and remove the flow pointers
|
2009-12-24 08:21:15 +03:00
|
|
|
nsSplittableFrame::DestroyFrom(aDestructRoot);
|
1998-11-14 22:25:34 +03:00
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Child frame enumeration
|
|
|
|
|
2009-07-28 16:51:09 +04:00
|
|
|
nsFrameList
|
|
|
|
nsContainerFrame::GetChildList(nsIAtom* aListName) const
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
2000-01-22 04:16:50 +03:00
|
|
|
// We only know about the unnamed principal child list and the overflow
|
2009-07-28 16:51:09 +04:00
|
|
|
// lists
|
1998-11-09 22:40:27 +03:00
|
|
|
if (nsnull == aListName) {
|
2009-07-28 16:51:09 +04:00
|
|
|
return mFrames;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsGkAtoms::overflowList == aListName) {
|
2009-07-28 16:51:09 +04:00
|
|
|
nsFrameList* frameList = GetOverflowFrames();
|
2009-07-28 16:51:09 +04:00
|
|
|
return frameList ? *frameList : nsFrameList::EmptyList();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsGkAtoms::overflowContainersList == aListName) {
|
2007-07-26 08:03:29 +04:00
|
|
|
nsFrameList* list = GetPropTableFrames(PresContext(),
|
2010-03-29 05:46:55 +04:00
|
|
|
OverflowContainersProperty());
|
2009-07-28 16:51:09 +04:00
|
|
|
return list ? *list : nsFrameList::EmptyList();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsGkAtoms::excessOverflowContainersList == aListName) {
|
2007-07-26 08:03:29 +04:00
|
|
|
nsFrameList* list = GetPropTableFrames(PresContext(),
|
2010-03-29 05:46:55 +04:00
|
|
|
ExcessOverflowContainersProperty());
|
2009-07-28 16:51:09 +04:00
|
|
|
return list ? *list : nsFrameList::EmptyList();
|
1998-11-09 22:40:27 +03:00
|
|
|
}
|
2009-07-28 16:51:09 +04:00
|
|
|
|
|
|
|
return nsFrameList::EmptyList();
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
#define NS_CONTAINER_FRAME_OVERFLOW_LIST_INDEX 0
|
|
|
|
#define NS_CONTAINER_FRAME_OVERFLOW_CONTAINERS_LIST_INDEX 1
|
|
|
|
#define NS_CONTAINER_FRAME_EXCESS_OVERFLOW_CONTAINERS_LIST_INDEX 2
|
|
|
|
// If adding/removing lists, don't forget to update count in .h file
|
|
|
|
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsContainerFrame::GetAdditionalChildListName(PRInt32 aIndex) const
|
2003-06-02 08:03:07 +04:00
|
|
|
{
|
2007-07-26 08:03:29 +04:00
|
|
|
if (NS_CONTAINER_FRAME_OVERFLOW_LIST_INDEX == aIndex)
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::overflowList;
|
2007-07-26 08:03:29 +04:00
|
|
|
else if (IsFrameOfType(nsIFrame::eCanContainOverflowContainers)) {
|
|
|
|
if (NS_CONTAINER_FRAME_OVERFLOW_CONTAINERS_LIST_INDEX == aIndex)
|
|
|
|
return nsGkAtoms::overflowContainersList;
|
|
|
|
else if (NS_CONTAINER_FRAME_EXCESS_OVERFLOW_CONTAINERS_LIST_INDEX == aIndex)
|
|
|
|
return nsGkAtoms::excessOverflowContainersList;
|
2003-06-02 08:03:07 +04:00
|
|
|
}
|
2007-07-26 08:03:29 +04:00
|
|
|
return nsnull;
|
2003-06-02 08:03:07 +04:00
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1999-01-16 01:53:39 +03:00
|
|
|
// Painting/Events
|
1998-10-01 01:35:29 +04:00
|
|
|
|
1998-10-31 01:11:06 +03:00
|
|
|
NS_IMETHODIMP
|
2006-01-26 05:29:17 +03:00
|
|
|
nsContainerFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
2006-01-26 05:29:17 +03:00
|
|
|
nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
1998-10-01 01:35:29 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
return BuildDisplayListForNonBlockChildren(aBuilder, aDirtyRect, aLists);
|
1998-10-31 01:11:06 +03:00
|
|
|
}
|
1998-10-07 01:00:58 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsresult
|
|
|
|
nsContainerFrame::BuildDisplayListForNonBlockChildren(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists,
|
|
|
|
PRUint32 aFlags)
|
1998-10-31 01:11:06 +03:00
|
|
|
{
|
2006-01-26 05:29:17 +03:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
// Put each child's background directly onto the content list
|
|
|
|
nsDisplayListSet set(aLists, aLists.Content());
|
|
|
|
// The children should be in content order
|
2003-06-26 15:30:17 +04:00
|
|
|
while (kid) {
|
2006-01-26 05:29:17 +03:00
|
|
|
nsresult rv = BuildDisplayListForChild(aBuilder, kid, aDirtyRect, set, aFlags);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2003-06-26 15:30:17 +04:00
|
|
|
kid = kid->GetNextSibling();
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
return NS_OK;
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
/* virtual */ void
|
|
|
|
nsContainerFrame::ChildIsDirty(nsIFrame* aChild)
|
2000-01-12 11:28:24 +03:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN);
|
2000-01-12 11:28:24 +03:00
|
|
|
}
|
|
|
|
|
2005-08-17 02:52:48 +04:00
|
|
|
PRBool
|
|
|
|
nsContainerFrame::IsLeaf() const
|
|
|
|
{
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2000-01-12 11:28:24 +03:00
|
|
|
|
2006-12-15 12:32:24 +03:00
|
|
|
PRBool
|
|
|
|
nsContainerFrame::PeekOffsetNoAmount(PRBool aForward, PRInt32* aOffset)
|
|
|
|
{
|
|
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
|
|
|
// Don't allow the caret to stay in an empty (leaf) container frame.
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsContainerFrame::PeekOffsetCharacter(PRBool aForward, PRInt32* aOffset)
|
|
|
|
{
|
|
|
|
NS_ASSERTION (aOffset && *aOffset <= 1, "aOffset out of range");
|
|
|
|
// Don't allow the caret to stay in an empty (leaf) container frame.
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helper member functions
|
|
|
|
|
2001-09-21 04:53:29 +04:00
|
|
|
/**
|
|
|
|
* Position the view associated with |aKidFrame|, if there is one. A
|
|
|
|
* container frame should call this method after positioning a frame,
|
|
|
|
* but before |Reflow|.
|
|
|
|
*/
|
1999-11-19 18:33:29 +03:00
|
|
|
void
|
2004-12-27 18:05:18 +03:00
|
|
|
nsContainerFrame::PositionFrameView(nsIFrame* aKidFrame)
|
1999-11-19 18:33:29 +03:00
|
|
|
{
|
2005-04-04 01:00:41 +04:00
|
|
|
nsIFrame* parentFrame = aKidFrame->GetParent();
|
|
|
|
if (!aKidFrame->HasView() || !parentFrame)
|
|
|
|
return;
|
2001-09-21 04:53:29 +04:00
|
|
|
|
2005-04-04 01:00:41 +04:00
|
|
|
nsIView* view = aKidFrame->GetView();
|
|
|
|
nsIViewManager* vm = view->GetViewManager();
|
|
|
|
nsPoint pt;
|
|
|
|
nsIView* ancestorView = parentFrame->GetClosestView(&pt);
|
2005-03-31 07:40:12 +04:00
|
|
|
|
2005-04-04 01:00:41 +04:00
|
|
|
if (ancestorView != view->GetParent()) {
|
|
|
|
NS_ASSERTION(ancestorView == view->GetParent()->GetParent(),
|
|
|
|
"Allowed only one anonymous view between frames");
|
|
|
|
// parentFrame is responsible for positioning aKidFrame's view
|
|
|
|
// explicitly
|
|
|
|
return;
|
2005-03-31 22:04:50 +04:00
|
|
|
}
|
2005-04-04 01:00:41 +04:00
|
|
|
|
|
|
|
pt += aKidFrame->GetPosition();
|
|
|
|
vm->MoveViewTo(view, pt.x, pt.y);
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
2009-08-13 00:48:30 +04:00
|
|
|
static nsIWidget*
|
|
|
|
GetPresContextContainerWidget(nsPresContext* aPresContext)
|
2008-01-10 01:50:29 +03:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsISupports> container = aPresContext->Document()->GetContainer();
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(container);
|
|
|
|
if (!baseWindow)
|
2009-08-13 00:48:30 +04:00
|
|
|
return nsnull;
|
2008-01-10 01:50:29 +03:00
|
|
|
|
|
|
|
nsCOMPtr<nsIWidget> mainWidget;
|
|
|
|
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
|
2009-08-13 00:48:30 +04:00
|
|
|
return mainWidget;
|
|
|
|
}
|
2008-01-10 01:50:29 +03:00
|
|
|
|
2009-08-13 00:48:30 +04:00
|
|
|
static PRBool
|
|
|
|
IsTopLevelWidget(nsIWidget* aWidget)
|
|
|
|
{
|
2008-01-10 01:50:29 +03:00
|
|
|
nsWindowType windowType;
|
2009-08-13 00:48:30 +04:00
|
|
|
aWidget->GetWindowType(windowType);
|
2008-01-10 01:50:29 +03:00
|
|
|
return windowType == eWindowType_toplevel ||
|
2010-04-27 20:15:01 +04:00
|
|
|
windowType == eWindowType_dialog ||
|
2009-08-13 00:48:30 +04:00
|
|
|
windowType == eWindowType_sheet;
|
2008-01-10 01:50:29 +03:00
|
|
|
// popups aren't toplevel so they're not handled here
|
|
|
|
}
|
|
|
|
|
2009-08-13 00:48:30 +04:00
|
|
|
void
|
|
|
|
nsContainerFrame::SyncWindowProperties(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIView* aView)
|
2002-09-30 15:56:37 +04:00
|
|
|
{
|
2008-12-29 11:17:08 +03:00
|
|
|
#ifdef MOZ_XUL
|
2009-08-13 00:48:30 +04:00
|
|
|
if (!aView || !nsCSSRendering::IsCanvasFrame(aFrame) || !aView->HasWidget())
|
2009-02-16 04:11:34 +03:00
|
|
|
return;
|
2002-09-30 15:56:37 +04:00
|
|
|
|
2009-08-13 00:48:30 +04:00
|
|
|
nsIWidget* windowWidget = GetPresContextContainerWidget(aPresContext);
|
|
|
|
if (!windowWidget || !IsTopLevelWidget(windowWidget))
|
2008-12-29 11:17:08 +03:00
|
|
|
return;
|
|
|
|
|
2009-02-16 04:11:34 +03:00
|
|
|
nsIViewManager* vm = aView->GetViewManager();
|
2008-12-29 11:17:08 +03:00
|
|
|
nsIView* rootView;
|
|
|
|
vm->GetRootView(rootView);
|
|
|
|
|
2009-02-16 04:11:34 +03:00
|
|
|
if (aView != rootView)
|
2008-12-29 11:17:08 +03:00
|
|
|
return;
|
|
|
|
|
2010-04-30 17:12:05 +04:00
|
|
|
Element* rootElement = aPresContext->Document()->GetRootElement();
|
|
|
|
if (!rootElement || !rootElement->IsXUL()) {
|
2008-12-29 11:17:08 +03:00
|
|
|
// Scrollframes use native widgets which don't work well with
|
|
|
|
// translucent windows, at least in Windows XP. So if the document
|
|
|
|
// has a root scrollrame it's useless to try to make it transparent,
|
|
|
|
// we'll just get something broken.
|
|
|
|
// nsCSSFrameConstructor::ConstructRootFrame constructs root
|
|
|
|
// scrollframes whenever the root element is not a XUL element, so
|
|
|
|
// we test for that here. We can't just call
|
|
|
|
// presShell->GetRootScrollFrame() since that might not have
|
|
|
|
// been constructed yet.
|
|
|
|
// We can change this to allow translucent toplevel HTML documents
|
|
|
|
// (e.g. to do something like Dashboard widgets), once we
|
|
|
|
// have broad support for translucent scrolled documents, but be
|
|
|
|
// careful because apparently some Firefox extensions expect
|
|
|
|
// openDialog("something.html") to produce an opaque window
|
|
|
|
// even if the HTML doesn't have a background-color set.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-13 00:48:30 +04:00
|
|
|
nsIFrame *rootFrame = aPresContext->PresShell()->FrameConstructor()->GetRootElementStyleFrame();
|
|
|
|
if (!rootFrame)
|
|
|
|
return;
|
|
|
|
|
2009-08-14 02:08:13 +04:00
|
|
|
nsTransparencyMode mode = nsLayoutUtils::GetFrameTransparency(aFrame, rootFrame);
|
2009-08-13 00:48:30 +04:00
|
|
|
nsIWidget* viewWidget = aView->GetWidget();
|
|
|
|
viewWidget->SetTransparencyMode(mode);
|
|
|
|
windowWidget->SetWindowShadowStyle(rootFrame->GetStyleUIReset()->mWindowShadow);
|
2008-12-29 11:17:08 +03:00
|
|
|
#endif
|
2002-09-30 15:56:37 +04:00
|
|
|
}
|
|
|
|
|
2002-10-08 08:09:38 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(nsPresContext* aPresContext,
|
2002-10-08 08:09:38 +04:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIView* aView,
|
|
|
|
const nsRect* aCombinedArea,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
if (!aView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-26 05:12:49 +04:00
|
|
|
NS_ASSERTION(aCombinedArea, "Combined area must be passed in now");
|
|
|
|
|
2002-10-08 08:09:38 +04:00
|
|
|
// Make sure the view is sized and positioned correctly
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) {
|
2004-12-27 18:05:18 +03:00
|
|
|
PositionFrameView(aFrame);
|
2002-10-08 08:09:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) {
|
2003-06-27 22:13:48 +04:00
|
|
|
nsIViewManager* vm = aView->GetViewManager();
|
2002-10-08 08:09:38 +04:00
|
|
|
|
2007-03-26 05:12:49 +04:00
|
|
|
vm->ResizeView(aView, *aCombinedArea, PR_TRUE);
|
2002-10-08 08:09:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsContainerFrame::SyncFrameViewProperties(nsPresContext* aPresContext,
|
2002-09-30 15:56:37 +04:00
|
|
|
nsIFrame* aFrame,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext,
|
2002-09-30 15:56:37 +04:00
|
|
|
nsIView* aView,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
2003-10-17 06:38:37 +04:00
|
|
|
NS_ASSERTION(!aStyleContext || aFrame->GetStyleContext() == aStyleContext,
|
|
|
|
"Wrong style context for frame?");
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
if (!aView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-06-27 22:13:48 +04:00
|
|
|
nsIViewManager* vm = aView->GetViewManager();
|
2010-04-27 20:15:01 +04:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
if (nsnull == aStyleContext) {
|
2003-02-22 03:32:13 +03:00
|
|
|
aStyleContext = aFrame->GetStyleContext();
|
2002-09-30 15:56:37 +04:00
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2009-08-25 11:44:42 +04:00
|
|
|
// Make sure visibility is correct. This only affects nsSubdocumentFrame.
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_VISIBILITY) &&
|
|
|
|
!aFrame->SupportsVisibilityHidden()) {
|
1999-11-19 18:33:29 +03:00
|
|
|
// See if the view should be hidden or visible
|
2009-08-25 11:44:42 +04:00
|
|
|
vm->SetViewVisibility(aView,
|
|
|
|
aStyleContext->GetStyleVisibility()->IsVisible()
|
|
|
|
? nsViewVisibility_kShow : nsViewVisibility_kHide);
|
2002-09-30 15:56:37 +04:00
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
// See if the frame is being relatively positioned or absolutely
|
|
|
|
// positioned
|
2007-02-24 03:23:42 +03:00
|
|
|
PRBool isPositioned = aStyleContext->GetStyleDisplay()->IsPositioned();
|
2000-04-25 08:43:11 +04:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
PRInt32 zIndex = 0;
|
|
|
|
PRBool autoZIndex = PR_FALSE;
|
2002-06-04 08:44:03 +04:00
|
|
|
|
2005-06-15 03:53:56 +04:00
|
|
|
if (!isPositioned) {
|
2002-09-30 15:56:37 +04:00
|
|
|
autoZIndex = PR_TRUE;
|
2005-06-15 03:53:56 +04:00
|
|
|
} else {
|
|
|
|
// Make sure z-index is correct
|
|
|
|
const nsStylePosition* position = aStyleContext->GetStylePosition();
|
|
|
|
|
|
|
|
if (position->mZIndex.GetUnit() == eStyleUnit_Integer) {
|
|
|
|
zIndex = position->mZIndex.GetIntValue();
|
|
|
|
} else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) {
|
|
|
|
autoZIndex = PR_TRUE;
|
|
|
|
}
|
2002-09-30 15:56:37 +04:00
|
|
|
}
|
2000-04-25 08:43:11 +04:00
|
|
|
|
2005-06-15 03:53:56 +04:00
|
|
|
vm->SetViewZIndex(aView, autoZIndex, zIndex, isPositioned);
|
2002-09-30 15:56:37 +04:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
static nscoord GetCoord(const nsStyleCoord& aCoord, nscoord aIfNotCoord)
|
|
|
|
{
|
|
|
|
return aCoord.GetUnit() == eStyleUnit_Coord
|
|
|
|
? aCoord.GetCoordValue()
|
|
|
|
: aIfNotCoord;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsContainerFrame::DoInlineIntrinsicWidth(nsIRenderingContext *aRenderingContext,
|
|
|
|
InlineIntrinsicWidthData *aData,
|
|
|
|
nsLayoutUtils::IntrinsicWidthType aType)
|
|
|
|
{
|
|
|
|
if (GetPrevInFlow())
|
|
|
|
return; // Already added.
|
|
|
|
|
|
|
|
NS_PRECONDITION(aType == nsLayoutUtils::MIN_WIDTH ||
|
|
|
|
aType == nsLayoutUtils::PREF_WIDTH, "bad type");
|
|
|
|
|
2010-04-27 20:15:02 +04:00
|
|
|
mozilla::css::Side startSide, endSide;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
if (GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_LTR) {
|
|
|
|
startSide = NS_SIDE_LEFT;
|
|
|
|
endSide = NS_SIDE_RIGHT;
|
|
|
|
} else {
|
|
|
|
startSide = NS_SIDE_RIGHT;
|
|
|
|
endSide = NS_SIDE_LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsStylePadding *stylePadding = GetStylePadding();
|
|
|
|
const nsStyleBorder *styleBorder = GetStyleBorder();
|
|
|
|
const nsStyleMargin *styleMargin = GetStyleMargin();
|
|
|
|
|
|
|
|
// This goes at the beginning no matter how things are broken and how
|
|
|
|
// messy the bidi situations are, since per CSS2.1 section 8.6
|
|
|
|
// (implemented in bug 328168), the startSide border is always on the
|
|
|
|
// first line.
|
2008-03-12 00:54:34 +03:00
|
|
|
// This frame is a first-in-flow, but it might have a previous bidi
|
2010-04-27 20:15:01 +04:00
|
|
|
// continuation, in which case that continuation should handle the startSide
|
2008-03-12 00:54:34 +03:00
|
|
|
// border.
|
|
|
|
if (!GetPrevContinuation()) {
|
|
|
|
aData->currentLine +=
|
|
|
|
GetCoord(stylePadding->mPadding.Get(startSide), 0) +
|
2008-07-17 10:30:25 +04:00
|
|
|
styleBorder->GetActualBorderWidth(startSide) +
|
2008-03-12 00:54:34 +03:00
|
|
|
GetCoord(styleMargin->mMargin.Get(startSide), 0);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2008-01-10 06:18:44 +03:00
|
|
|
const nsLineList_iterator* savedLine = aData->line;
|
2009-02-19 23:18:52 +03:00
|
|
|
nsIFrame* const savedLineContainer = aData->lineContainer;
|
2008-01-10 06:18:44 +03:00
|
|
|
|
2008-03-12 00:54:34 +03:00
|
|
|
nsContainerFrame *lastInFlow;
|
2008-01-10 06:23:35 +03:00
|
|
|
for (nsContainerFrame *nif = this; nif;
|
2009-02-19 23:18:52 +03:00
|
|
|
nif = static_cast<nsContainerFrame*>(nif->GetNextInFlow())) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
for (nsIFrame *kid = nif->mFrames.FirstChild(); kid;
|
|
|
|
kid = kid->GetNextSibling()) {
|
|
|
|
if (aType == nsLayoutUtils::MIN_WIDTH)
|
|
|
|
kid->AddInlineMinWidth(aRenderingContext,
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<InlineMinWidthData*>(aData));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
else
|
|
|
|
kid->AddInlinePrefWidth(aRenderingContext,
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<InlinePrefWidthData*>(aData));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2010-04-27 20:15:01 +04:00
|
|
|
|
2009-02-19 23:18:52 +03:00
|
|
|
// After we advance to our next-in-flow, the stored line and line container
|
|
|
|
// may no longer be correct. Just forget them.
|
2008-01-10 06:23:35 +03:00
|
|
|
aData->line = nsnull;
|
2009-02-19 23:18:52 +03:00
|
|
|
aData->lineContainer = nsnull;
|
|
|
|
|
2008-03-12 00:54:34 +03:00
|
|
|
lastInFlow = nif;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2010-04-27 20:15:01 +04:00
|
|
|
|
2008-01-10 06:18:44 +03:00
|
|
|
aData->line = savedLine;
|
2009-02-19 23:18:52 +03:00
|
|
|
aData->lineContainer = savedLineContainer;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
// This goes at the end no matter how things are broken and how
|
|
|
|
// messy the bidi situations are, since per CSS2.1 section 8.6
|
|
|
|
// (implemented in bug 328168), the endSide border is always on the
|
|
|
|
// last line.
|
2008-03-12 00:54:34 +03:00
|
|
|
// We reached the last-in-flow, but it might have a next bidi
|
2010-04-27 20:15:01 +04:00
|
|
|
// continuation, in which case that continuation should handle
|
2008-03-12 00:54:34 +03:00
|
|
|
// the endSide border.
|
|
|
|
if (!lastInFlow->GetNextContinuation()) {
|
|
|
|
aData->currentLine +=
|
|
|
|
GetCoord(stylePadding->mPadding.Get(endSide), 0) +
|
2008-07-17 10:30:25 +04:00
|
|
|
styleBorder->GetActualBorderWidth(endSide) +
|
2008-03-12 00:54:34 +03:00
|
|
|
GetCoord(styleMargin->mMargin.Get(endSide), 0);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
|
|
|
nsContainerFrame::ComputeAutoSize(nsIRenderingContext *aRenderingContext,
|
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
|
|
|
nsSize aPadding, PRBool aShrinkWrap)
|
|
|
|
{
|
|
|
|
nsSize result(0xdeadbeef, NS_UNCONSTRAINEDSIZE);
|
|
|
|
nscoord availBased = aAvailableWidth - aMargin.width - aBorder.width -
|
|
|
|
aPadding.width;
|
|
|
|
// replaced elements always shrink-wrap
|
|
|
|
if (aShrinkWrap || IsFrameOfType(eReplaced)) {
|
|
|
|
// don't bother setting it if the result won't be used
|
|
|
|
if (GetStylePosition()->mWidth.GetUnit() == eStyleUnit_Auto) {
|
|
|
|
result.width = ShrinkWidthToFit(aRenderingContext, availBased);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
result.width = availBased;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
/**
|
1999-11-19 18:33:29 +03:00
|
|
|
* Invokes the WillReflow() function, positions the frame and its view (if
|
|
|
|
* requested), and then calls Reflow(). If the reflow succeeds and the child
|
2002-10-09 00:35:26 +04:00
|
|
|
* frame is complete, deletes any next-in-flows using DeleteNextInFlowChild()
|
1998-10-01 01:35:29 +04:00
|
|
|
*/
|
1998-10-06 04:27:22 +04:00
|
|
|
nsresult
|
|
|
|
nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
2005-04-29 01:57:22 +04:00
|
|
|
nsPresContext* aPresContext,
|
1998-10-06 04:27:22 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-11-19 18:33:29 +03:00
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
PRUint32 aFlags,
|
2007-07-26 08:03:29 +04:00
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsOverflowContinuationTracker* aTracker)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");
|
|
|
|
|
1999-10-30 06:52:11 +04:00
|
|
|
nsresult result;
|
1998-10-01 01:35:29 +04:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
// Send the WillReflow() notification, and position the child frame
|
|
|
|
// and its view if requested
|
1999-10-30 06:52:11 +04:00
|
|
|
aKidFrame->WillReflow(aPresContext);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2008-09-06 12:52:56 +04:00
|
|
|
if (NS_FRAME_NO_MOVE_FRAME != (aFlags & NS_FRAME_NO_MOVE_FRAME)) {
|
2008-02-08 12:36:32 +03:00
|
|
|
if ((aFlags & NS_FRAME_INVALIDATE_ON_MOVE) &&
|
|
|
|
!(aKidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) &&
|
|
|
|
aKidFrame->GetPosition() != nsPoint(aX, aY)) {
|
|
|
|
aKidFrame->InvalidateOverflowRect();
|
|
|
|
}
|
2003-06-26 15:30:17 +04:00
|
|
|
aKidFrame->SetPosition(nsPoint(aX, aY));
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) {
|
2004-12-27 18:05:18 +03:00
|
|
|
PositionFrameView(aKidFrame);
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the child frame
|
1999-10-30 06:52:11 +04:00
|
|
|
result = aKidFrame->Reflow(aPresContext, aDesiredSize, aReflowState,
|
|
|
|
aStatus);
|
1998-10-06 04:27:22 +04:00
|
|
|
|
|
|
|
// If the reflow was successful and the child frame is complete, delete any
|
|
|
|
// next-in-flows
|
2007-07-26 08:03:29 +04:00
|
|
|
if (NS_SUCCEEDED(result) && NS_FRAME_IS_FULLY_COMPLETE(aStatus)) {
|
2004-09-14 06:28:03 +04:00
|
|
|
nsIFrame* kidNextInFlow = aKidFrame->GetNextInFlow();
|
1998-10-01 01:35:29 +04:00
|
|
|
if (nsnull != kidNextInFlow) {
|
|
|
|
// Remove all of the childs next-in-flows. Make sure that we ask
|
|
|
|
// the right parent to do the removal (it's possible that the
|
|
|
|
// parent is not this because we are executing pullup code)
|
2007-10-02 09:57:45 +04:00
|
|
|
if (aTracker) aTracker->Finish(aKidFrame);
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsContainerFrame*>(kidNextInFlow->GetParent())
|
2008-12-03 04:27:19 +03:00
|
|
|
->DeleteNextInFlowChild(aPresContext, kidNextInFlow, PR_TRUE);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
}
|
1998-10-06 04:27:22 +04:00
|
|
|
return result;
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
2001-03-12 07:19:10 +03:00
|
|
|
|
2001-09-21 04:53:29 +04:00
|
|
|
/**
|
|
|
|
* Position the views of |aFrame|'s descendants. A container frame
|
|
|
|
* should call this method if it moves a frame after |Reflow|.
|
|
|
|
*/
|
1999-11-19 18:33:29 +03:00
|
|
|
void
|
2004-12-27 18:05:18 +03:00
|
|
|
nsContainerFrame::PositionChildViews(nsIFrame* aFrame)
|
1999-11-19 18:33:29 +03:00
|
|
|
{
|
2003-06-26 15:30:17 +04:00
|
|
|
if (!(aFrame->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW)) {
|
2001-03-12 07:19:10 +03:00
|
|
|
return;
|
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2001-03-30 09:25:49 +04:00
|
|
|
nsIAtom* childListName = nsnull;
|
|
|
|
PRInt32 childListIndex = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
// Recursively walk aFrame's child frames
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame* childFrame = aFrame->GetFirstChild(childListName);
|
2001-03-30 09:25:49 +04:00
|
|
|
while (childFrame) {
|
2004-01-10 08:36:32 +03:00
|
|
|
// Position the frame's view (if it has one) otherwise recursively
|
2001-09-21 04:53:29 +04:00
|
|
|
// process its children
|
2004-01-10 08:36:32 +03:00
|
|
|
if (childFrame->HasView()) {
|
2004-12-27 18:05:18 +03:00
|
|
|
PositionFrameView(childFrame);
|
2004-01-10 08:36:32 +03:00
|
|
|
} else {
|
2004-12-27 18:05:18 +03:00
|
|
|
PositionChildViews(childFrame);
|
2004-01-10 08:36:32 +03:00
|
|
|
}
|
2001-03-30 09:25:49 +04:00
|
|
|
|
|
|
|
// Get the next sibling child frame
|
2003-06-26 15:30:17 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
2001-03-30 09:25:49 +04:00
|
|
|
|
2007-07-04 19:49:38 +04:00
|
|
|
// also process the additional child lists, but skip the popup list as the
|
|
|
|
// view for popups is managed by the parent. Currently only nsMenuFrame
|
|
|
|
// has a popupList and during layout will call nsMenuPopupFrame::AdjustView.
|
|
|
|
do {
|
|
|
|
childListName = aFrame->GetAdditionalChildListName(childListIndex++);
|
|
|
|
} while (childListName == nsGkAtoms::popupList);
|
2004-01-09 17:20:53 +03:00
|
|
|
} while (childListName);
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The second half of frame reflow. Does the following:
|
|
|
|
* - sets the frame's bounds
|
|
|
|
* - sizes and positions (if requested) the frame's view. If the frame's final
|
|
|
|
* position differs from the current position and the frame itself does not
|
|
|
|
* have a view, then any child frames with views are positioned so they stay
|
|
|
|
* in sync
|
|
|
|
* - sets the view's visibility, opacity, content transparency, and clip
|
|
|
|
* - invoked the DidReflow() function
|
|
|
|
*
|
|
|
|
* Flags:
|
|
|
|
* NS_FRAME_NO_MOVE_FRAME - don't move the frame. aX and aY are ignored in this
|
|
|
|
* case. Also implies NS_FRAME_NO_MOVE_VIEW
|
|
|
|
* NS_FRAME_NO_MOVE_VIEW - don't position the frame's view. Set this if you
|
|
|
|
* don't want to automatically sync the frame and view
|
|
|
|
* NS_FRAME_NO_SIZE_VIEW - don't size the frame's view
|
2001-09-06 00:27:19 +04:00
|
|
|
*/
|
1999-11-19 18:33:29 +03:00
|
|
|
nsresult
|
2008-01-03 07:33:21 +03:00
|
|
|
nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
const nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
PRUint32 aFlags)
|
1999-11-19 18:33:29 +03:00
|
|
|
{
|
2003-06-26 15:30:17 +04:00
|
|
|
nsPoint curOrigin = aKidFrame->GetPosition();
|
1999-11-19 18:33:29 +03:00
|
|
|
nsRect bounds(aX, aY, aDesiredSize.width, aDesiredSize.height);
|
|
|
|
|
2003-06-26 15:30:17 +04:00
|
|
|
aKidFrame->SetRect(bounds);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2003-06-20 03:44:01 +04:00
|
|
|
if (aKidFrame->HasView()) {
|
2003-06-26 15:30:17 +04:00
|
|
|
nsIView* view = aKidFrame->GetView();
|
1999-11-19 18:33:29 +03:00
|
|
|
// Make sure the frame's view is properly sized and positioned and has
|
|
|
|
// things like opacity correct
|
1999-11-24 09:03:41 +03:00
|
|
|
SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
|
1999-12-06 18:49:53 +03:00
|
|
|
&aDesiredSize.mOverflowArea,
|
1999-11-19 18:33:29 +03:00
|
|
|
aFlags);
|
2001-09-06 00:27:19 +04:00
|
|
|
}
|
2004-02-22 06:31:30 +03:00
|
|
|
|
|
|
|
if (!(aFlags & NS_FRAME_NO_MOVE_VIEW) &&
|
|
|
|
(curOrigin.x != aX || curOrigin.y != aY)) {
|
|
|
|
if (!aKidFrame->HasView()) {
|
|
|
|
// If the frame has moved, then we need to make sure any child views are
|
|
|
|
// correctly positioned
|
2004-12-27 18:05:18 +03:00
|
|
|
PositionChildViews(aKidFrame);
|
2004-02-22 06:31:30 +03:00
|
|
|
}
|
|
|
|
|
2004-03-10 06:09:05 +03:00
|
|
|
// We also need to redraw everything associated with the frame
|
|
|
|
// because if the frame's Reflow issued any invalidates, then they
|
|
|
|
// will be at the wrong offset ... note that this includes
|
|
|
|
// invalidates issued against the frame's children, so we need to
|
|
|
|
// invalidate the overflow area too.
|
2004-02-22 06:31:30 +03:00
|
|
|
aKidFrame->Invalidate(aDesiredSize.mOverflowArea);
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
2010-04-27 20:15:01 +04:00
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
return aKidFrame->DidReflow(aPresContext, aReflowState, NS_FRAME_REFLOW_FINISHED);
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
nsresult
|
|
|
|
nsContainerFrame::ReflowOverflowContainerChildren(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsRect& aOverflowRect,
|
|
|
|
PRUint32 aFlags,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aPresContext, "null pointer");
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
|
|
|
nsFrameList* overflowContainers =
|
|
|
|
GetPropTableFrames(aPresContext,
|
2010-03-29 05:46:55 +04:00
|
|
|
OverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
|
|
|
|
NS_ASSERTION(!(overflowContainers && GetPrevInFlow()
|
|
|
|
&& static_cast<nsContainerFrame*>(GetPrevInFlow())
|
|
|
|
->GetPropTableFrames(aPresContext,
|
2010-03-29 05:46:55 +04:00
|
|
|
ExcessOverflowContainersProperty())),
|
2007-07-26 08:03:29 +04:00
|
|
|
"conflicting overflow containers lists");
|
|
|
|
|
|
|
|
if (!overflowContainers) {
|
|
|
|
// Drain excess from previnflow
|
|
|
|
nsContainerFrame* prev = (nsContainerFrame*) GetPrevInFlow();
|
|
|
|
if (prev) {
|
|
|
|
nsFrameList* excessFrames =
|
|
|
|
prev->RemovePropTableFrames(aPresContext,
|
2010-03-29 05:46:55 +04:00
|
|
|
ExcessOverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
if (excessFrames) {
|
2009-09-18 15:09:36 +04:00
|
|
|
excessFrames->ApplySetParent(this);
|
|
|
|
nsHTMLContainerFrame::ReparentFrameViewList(aPresContext, *excessFrames,
|
2007-07-26 08:03:29 +04:00
|
|
|
prev, this);
|
|
|
|
overflowContainers = excessFrames;
|
|
|
|
rv = SetPropTableFrames(aPresContext, overflowContainers,
|
2010-03-29 05:46:55 +04:00
|
|
|
OverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
excessFrames->DestroyFrames();
|
|
|
|
delete excessFrames;
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!overflowContainers)
|
|
|
|
return NS_OK; // nothing to reflow
|
|
|
|
|
2007-10-02 09:57:45 +04:00
|
|
|
nsOverflowContinuationTracker tracker(aPresContext, this, PR_FALSE, PR_FALSE);
|
2007-07-26 08:03:29 +04:00
|
|
|
for (nsIFrame* frame = overflowContainers->FirstChild(); frame;
|
|
|
|
frame = frame->GetNextSibling()) {
|
2009-05-09 05:53:44 +04:00
|
|
|
if (frame->GetPrevInFlow()->GetParent() != GetPrevInFlow()) {
|
|
|
|
// frame's prevInFlow has moved, skip reflowing this frame;
|
|
|
|
// it will get reflowed once it's been placed
|
|
|
|
continue;
|
|
|
|
}
|
2007-07-26 08:03:29 +04:00
|
|
|
if (NS_SUBTREE_DIRTY(frame)) {
|
|
|
|
// Get prev-in-flow
|
|
|
|
nsIFrame* prevInFlow = frame->GetPrevInFlow();
|
|
|
|
NS_ASSERTION(prevInFlow,
|
|
|
|
"overflow container frame must have a prev-in-flow");
|
|
|
|
NS_ASSERTION(frame->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER,
|
|
|
|
"overflow container frame must have overflow container bit set");
|
|
|
|
nsRect prevRect = prevInFlow->GetRect();
|
|
|
|
|
|
|
|
// Initialize reflow params
|
|
|
|
nsSize availSpace(prevRect.width, aReflowState.availableHeight);
|
|
|
|
nsHTMLReflowMetrics desiredSize;
|
|
|
|
nsHTMLReflowState frameState(aPresContext, aReflowState,
|
|
|
|
frame, availSpace);
|
|
|
|
nsReflowStatus frameStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
2007-10-02 09:57:45 +04:00
|
|
|
// Cache old bounds
|
|
|
|
nsRect oldRect = frame->GetRect();
|
|
|
|
nsRect oldOverflow = frame->GetOverflowRect();
|
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
// Reflow
|
|
|
|
rv = ReflowChild(frame, aPresContext, desiredSize, frameState,
|
2007-10-02 09:57:45 +04:00
|
|
|
prevRect.x, 0, aFlags, frameStatus, &tracker);
|
2007-07-26 08:03:29 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
//XXXfr Do we need to override any shrinkwrap effects here?
|
|
|
|
// e.g. desiredSize.width = prevRect.width;
|
|
|
|
rv = FinishReflowChild(frame, aPresContext, &frameState, desiredSize,
|
|
|
|
prevRect.x, 0, aFlags);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2007-10-02 09:57:45 +04:00
|
|
|
// Invalidate if there was a position or size change
|
|
|
|
nsRect rect = frame->GetRect();
|
|
|
|
if (rect != oldRect) {
|
|
|
|
nsRect dirtyRect = oldOverflow;
|
|
|
|
dirtyRect.MoveBy(oldRect.x, oldRect.y);
|
|
|
|
Invalidate(dirtyRect);
|
|
|
|
|
|
|
|
dirtyRect = frame->GetOverflowRect();
|
|
|
|
dirtyRect.MoveBy(rect.x, rect.y);
|
|
|
|
Invalidate(dirtyRect);
|
|
|
|
}
|
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
// Handle continuations
|
|
|
|
if (!NS_FRAME_IS_FULLY_COMPLETE(frameStatus)) {
|
2007-10-02 09:57:45 +04:00
|
|
|
if (frame->GetStateBits() & NS_FRAME_OUT_OF_FLOW) {
|
|
|
|
// Abspos frames can't cause their parent to be incomplete,
|
|
|
|
// only overflow incomplete.
|
|
|
|
NS_FRAME_SET_OVERFLOW_INCOMPLETE(frameStatus);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ASSERTION(NS_FRAME_IS_COMPLETE(frameStatus),
|
|
|
|
"overflow container frames can't be incomplete, only overflow-incomplete");
|
|
|
|
}
|
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
// Acquire a next-in-flow, creating it if necessary
|
|
|
|
nsIFrame* nif = frame->GetNextInFlow();
|
|
|
|
if (!nif) {
|
|
|
|
NS_ASSERTION(frameStatus & NS_FRAME_REFLOW_NEXTINFLOW,
|
|
|
|
"Someone forgot a REFLOW_NEXTINFLOW flag");
|
2009-09-18 15:09:35 +04:00
|
|
|
rv = aPresContext->PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(aPresContext, frame, this, &nif);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
else if (!(nif->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) {
|
|
|
|
// used to be a normal next-in-flow; steal it from the child list
|
|
|
|
rv = static_cast<nsContainerFrame*>(nif->GetParent())
|
|
|
|
->StealFrame(aPresContext, nif);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
tracker.Insert(nif, frameStatus);
|
|
|
|
}
|
2008-05-28 17:39:41 +04:00
|
|
|
NS_MergeReflowStatusInto(&aStatus, frameStatus);
|
2007-07-26 08:03:29 +04:00
|
|
|
// At this point it would be nice to assert !frame->GetOverflowRect().IsEmpty(),
|
|
|
|
// but we have some unsplittable frames that, when taller than
|
|
|
|
// availableHeight will push zero-height content into a next-in-flow.
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
tracker.Skip(frame, aStatus);
|
2009-08-31 22:25:36 +04:00
|
|
|
if (aReflowState.mFloatManager)
|
|
|
|
nsBlockFrame::RecoverFloatsFor(frame, *aReflowState.mFloatManager);
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
ConsiderChildOverflow(aOverflowRect, frame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsContainerFrame::DisplayOverflowContainers(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2010-03-29 05:46:55 +04:00
|
|
|
nsFrameList* overflowconts =
|
|
|
|
GetPropTableFrames(PresContext(), OverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
if (overflowconts) {
|
|
|
|
for (nsIFrame* frame = overflowconts->FirstChild(); frame;
|
|
|
|
frame = frame->GetNextSibling()) {
|
|
|
|
BuildDisplayListForChild(aBuilder, frame, aDirtyRect, aLists);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsContainerFrame::StealFrame(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aChild,
|
|
|
|
PRBool aForceNormal)
|
|
|
|
{
|
|
|
|
PRBool removed = PR_TRUE;
|
|
|
|
if ((aChild->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)
|
|
|
|
&& !aForceNormal) {
|
|
|
|
// Try removing from the overflow container list
|
|
|
|
if (!RemovePropTableFrame(aPresContext, aChild,
|
2010-03-29 05:46:55 +04:00
|
|
|
OverflowContainersProperty())) {
|
2007-07-26 08:03:29 +04:00
|
|
|
// It must be in the excess overflow container list
|
|
|
|
removed = RemovePropTableFrame(aPresContext, aChild,
|
2010-03-29 05:46:55 +04:00
|
|
|
ExcessOverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2009-09-18 15:09:36 +04:00
|
|
|
if (!mFrames.RemoveFrameIfPresent(aChild)) {
|
|
|
|
removed = PR_FALSE;
|
2007-07-26 08:03:29 +04:00
|
|
|
// We didn't find the child in the parent's principal child list.
|
|
|
|
// Maybe it's on the overflow list?
|
2009-07-28 16:51:09 +04:00
|
|
|
nsFrameList* frameList = GetOverflowFrames();
|
|
|
|
if (frameList) {
|
2009-09-18 15:09:36 +04:00
|
|
|
removed = frameList->RemoveFrameIfPresent(aChild);
|
2009-07-28 16:51:09 +04:00
|
|
|
if (frameList->IsEmpty()) {
|
|
|
|
DestroyOverflowList(aPresContext);
|
|
|
|
}
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-09-18 15:09:36 +04:00
|
|
|
|
|
|
|
NS_POSTCONDITION(removed, "StealFrame: can't find aChild");
|
|
|
|
return removed ? NS_OK : NS_ERROR_UNEXPECTED;
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
|
2009-09-18 15:09:35 +04:00
|
|
|
nsFrameList
|
|
|
|
nsContainerFrame::StealFramesAfter(nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!aChild ||
|
|
|
|
!(aChild->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER),
|
|
|
|
"StealFramesAfter doesn't handle overflow containers");
|
|
|
|
NS_ASSERTION(GetType() != nsGkAtoms::blockFrame, "unexpected call");
|
|
|
|
|
|
|
|
if (!aChild) {
|
|
|
|
nsFrameList copy(mFrames);
|
|
|
|
mFrames.Clear();
|
|
|
|
return copy;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (nsFrameList::FrameLinkEnumerator iter(mFrames); !iter.AtEnd();
|
|
|
|
iter.Next()) {
|
|
|
|
if (iter.PrevFrame() == aChild) {
|
|
|
|
return mFrames.ExtractTail(iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// We didn't find the child in the principal child list.
|
|
|
|
// Maybe it's on the overflow list?
|
|
|
|
nsFrameList* overflowFrames = GetOverflowFrames();
|
|
|
|
if (overflowFrames) {
|
|
|
|
for (nsFrameList::FrameLinkEnumerator iter(*overflowFrames); !iter.AtEnd();
|
|
|
|
iter.Next()) {
|
|
|
|
if (iter.PrevFrame() == aChild) {
|
|
|
|
return overflowFrames->ExtractTail(iter);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ERROR("StealFramesAfter: can't find aChild");
|
|
|
|
return nsFrameList::EmptyList();
|
|
|
|
}
|
|
|
|
|
2009-07-28 16:51:09 +04:00
|
|
|
void
|
2009-12-24 08:21:15 +03:00
|
|
|
nsContainerFrame::DestroyOverflowList(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aDestructRoot)
|
2009-07-28 16:51:09 +04:00
|
|
|
{
|
|
|
|
nsFrameList* list =
|
2010-03-29 05:46:55 +04:00
|
|
|
RemovePropTableFrames(aPresContext, OverflowProperty());
|
2009-07-28 16:51:09 +04:00
|
|
|
if (list)
|
2009-12-24 08:21:15 +03:00
|
|
|
list->DestroyFrom(aDestructRoot);
|
2009-07-28 16:51:09 +04:00
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
/**
|
2002-10-09 00:35:26 +04:00
|
|
|
* Remove and delete aNextInFlow and its next-in-flows. Updates the sibling and flow
|
1998-10-01 01:35:29 +04:00
|
|
|
* pointers
|
|
|
|
*/
|
1999-01-16 01:53:39 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsContainerFrame::DeleteNextInFlowChild(nsPresContext* aPresContext,
|
2008-12-03 04:27:19 +03:00
|
|
|
nsIFrame* aNextInFlow,
|
|
|
|
PRBool aDeletingEmptyFrames)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
2008-09-20 17:42:03 +04:00
|
|
|
#ifdef DEBUG
|
2008-09-08 18:00:32 +04:00
|
|
|
nsIFrame* prevInFlow = aNextInFlow->GetPrevInFlow();
|
2008-09-20 17:42:03 +04:00
|
|
|
#endif
|
2008-09-08 18:00:32 +04:00
|
|
|
NS_PRECONDITION(prevInFlow, "bad prev-in-flow");
|
1998-10-01 01:35:29 +04:00
|
|
|
|
|
|
|
// If the next-in-flow has a next-in-flow then delete it, too (and
|
|
|
|
// delete it first).
|
2005-09-06 05:26:50 +04:00
|
|
|
// Do this in a loop so we don't overflow the stack for frames
|
|
|
|
// with very many next-in-flows
|
2004-09-14 06:28:03 +04:00
|
|
|
nsIFrame* nextNextInFlow = aNextInFlow->GetNextInFlow();
|
2002-10-09 00:35:26 +04:00
|
|
|
if (nextNextInFlow) {
|
2009-02-03 17:42:18 +03:00
|
|
|
nsAutoTArray<nsIFrame*, 8> frames;
|
2005-09-06 05:26:50 +04:00
|
|
|
for (nsIFrame* f = nextNextInFlow; f; f = f->GetNextInFlow()) {
|
|
|
|
frames.AppendElement(f);
|
|
|
|
}
|
2009-02-03 17:42:18 +03:00
|
|
|
for (PRInt32 i = frames.Length() - 1; i >= 0; --i) {
|
|
|
|
nsIFrame* delFrame = frames.ElementAt(i);
|
2007-07-08 11:08:04 +04:00
|
|
|
static_cast<nsContainerFrame*>(delFrame->GetParent())
|
2008-12-03 04:27:19 +03:00
|
|
|
->DeleteNextInFlowChild(aPresContext, delFrame, aDeletingEmptyFrames);
|
2005-09-06 05:26:50 +04:00
|
|
|
}
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
2010-03-29 05:46:58 +04:00
|
|
|
aNextInFlow->InvalidateOverflowRect();
|
2007-10-02 09:57:45 +04:00
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
// Take the next-in-flow out of the parent's child list
|
2008-09-20 17:42:03 +04:00
|
|
|
#ifdef DEBUG
|
2010-04-27 20:15:01 +04:00
|
|
|
nsresult rv =
|
2008-09-20 17:42:03 +04:00
|
|
|
#endif
|
|
|
|
StealFrame(aPresContext, aNextInFlow);
|
2007-07-26 08:03:29 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(rv), "StealFrame failure");
|
1998-10-01 01:35:29 +04:00
|
|
|
|
2008-12-08 03:39:11 +03:00
|
|
|
// Delete the next-in-flow frame and its descendants. This will also
|
|
|
|
// remove it from its next-in-flow/prev-in-flow chain.
|
2006-04-10 04:16:29 +04:00
|
|
|
aNextInFlow->Destroy();
|
1998-10-01 01:35:29 +04:00
|
|
|
|
2004-09-14 06:28:03 +04:00
|
|
|
NS_POSTCONDITION(!prevInFlow->GetNextInFlow(), "non null next-in-flow");
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
2007-07-04 02:49:00 +04:00
|
|
|
/**
|
|
|
|
* Set the frames on the overflow list
|
|
|
|
*/
|
1999-10-21 09:11:43 +04:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsContainerFrame::SetOverflowFrames(nsPresContext* aPresContext,
|
2009-07-28 16:51:09 +04:00
|
|
|
const nsFrameList& aOverflowFrames)
|
1999-10-21 09:11:43 +04:00
|
|
|
{
|
2009-07-28 16:51:09 +04:00
|
|
|
NS_PRECONDITION(aOverflowFrames.NotEmpty(), "Shouldn't be called");
|
|
|
|
nsFrameList* newList = new nsFrameList(aOverflowFrames);
|
|
|
|
if (!newList) {
|
|
|
|
// XXXbz should really destroy the frames here, but callers are holding
|
|
|
|
// pointers to them.... We should switch all callers to framelists, then
|
|
|
|
// audit and do that.
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
aPresContext->PropertyTable()->Set(this, OverflowProperty(), newList);
|
|
|
|
return NS_OK;
|
1999-10-21 09:11:43 +04:00
|
|
|
}
|
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
nsFrameList*
|
2010-03-29 05:46:55 +04:00
|
|
|
nsContainerFrame::GetPropTableFrames(nsPresContext* aPresContext,
|
|
|
|
const FramePropertyDescriptor* aProperty) const
|
2007-07-26 08:03:29 +04:00
|
|
|
{
|
2010-03-29 05:46:55 +04:00
|
|
|
FramePropertyTable* propTable = aPresContext->PropertyTable();
|
|
|
|
return static_cast<nsFrameList*>(propTable->Get(this, aProperty));
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsFrameList*
|
2010-03-29 05:46:55 +04:00
|
|
|
nsContainerFrame::RemovePropTableFrames(nsPresContext* aPresContext,
|
|
|
|
const FramePropertyDescriptor* aProperty)
|
2007-07-26 08:03:29 +04:00
|
|
|
{
|
2010-03-29 05:46:55 +04:00
|
|
|
FramePropertyTable* propTable = aPresContext->PropertyTable();
|
|
|
|
return static_cast<nsFrameList*>(propTable->Remove(this, aProperty));
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
2010-03-29 05:46:55 +04:00
|
|
|
nsContainerFrame::RemovePropTableFrame(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
const FramePropertyDescriptor* aProperty)
|
2007-07-26 08:03:29 +04:00
|
|
|
{
|
2010-03-29 05:46:55 +04:00
|
|
|
nsFrameList* frameList = RemovePropTableFrames(aPresContext, aProperty);
|
2007-12-18 22:22:12 +03:00
|
|
|
if (!frameList) {
|
|
|
|
// No such list
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2009-09-18 15:09:36 +04:00
|
|
|
if (!frameList->RemoveFrameIfPresent(aFrame)) {
|
2007-12-18 22:22:12 +03:00
|
|
|
// Found list, but it doesn't have the frame. Put list back.
|
2010-03-29 05:46:55 +04:00
|
|
|
SetPropTableFrames(aPresContext, frameList, aProperty);
|
2007-07-26 08:03:29 +04:00
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frameList->IsEmpty()) {
|
|
|
|
// Removed frame and now list is empty. Delete it.
|
|
|
|
delete frameList;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Removed frame, but list not empty. Put it back.
|
2010-03-29 05:46:55 +04:00
|
|
|
SetPropTableFrames(aPresContext, frameList, aProperty);
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2010-03-29 05:46:55 +04:00
|
|
|
nsContainerFrame::SetPropTableFrames(nsPresContext* aPresContext,
|
|
|
|
nsFrameList* aFrameList,
|
|
|
|
const FramePropertyDescriptor* aProperty)
|
2007-07-26 08:03:29 +04:00
|
|
|
{
|
2010-03-29 05:46:55 +04:00
|
|
|
NS_PRECONDITION(aPresContext && aProperty && aFrameList, "null ptr");
|
2010-04-12 22:36:58 +04:00
|
|
|
NS_PRECONDITION(
|
|
|
|
(aProperty != nsContainerFrame::OverflowContainersProperty() &&
|
|
|
|
aProperty != nsContainerFrame::ExcessOverflowContainersProperty()) ||
|
|
|
|
IsFrameOfType(nsIFrame::eCanContainOverflowContainers),
|
|
|
|
"this type of frame can't have overflow containers");
|
2010-03-29 05:46:55 +04:00
|
|
|
aPresContext->PropertyTable()->Set(this, aProperty, aFrameList);
|
|
|
|
return NS_OK;
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
/**
|
|
|
|
* Push aFromChild and its next siblings to the next-in-flow. Change the
|
|
|
|
* geometric parent of each frame that's pushed. If there is no next-in-flow
|
|
|
|
* the frames are placed on the overflow list (and the geometric parent is
|
|
|
|
* left unchanged).
|
|
|
|
*
|
|
|
|
* Updates the next-in-flow's child count. Does <b>not</b> update the
|
|
|
|
* pusher's child count.
|
|
|
|
*
|
|
|
|
* @param aFromChild the first child frame to push. It is disconnected from
|
|
|
|
* aPrevSibling
|
|
|
|
* @param aPrevSibling aFromChild's previous sibling. Must not be null. It's
|
|
|
|
* an error to push a parent's first child frame
|
|
|
|
*/
|
1999-01-16 01:53:39 +03:00
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsContainerFrame::PushChildren(nsPresContext* aPresContext,
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* aFromChild,
|
|
|
|
nsIFrame* aPrevSibling)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
2009-09-18 15:09:35 +04:00
|
|
|
NS_PRECONDITION(aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(aPrevSibling, "pushing first child");
|
2003-06-26 15:30:17 +04:00
|
|
|
NS_PRECONDITION(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
|
1998-10-01 01:35:29 +04:00
|
|
|
|
|
|
|
// Disconnect aFromChild from its previous sibling
|
2009-09-18 15:09:35 +04:00
|
|
|
nsFrameList tail = mFrames.RemoveFramesAfter(aPrevSibling);
|
1998-10-01 01:35:29 +04:00
|
|
|
|
2009-09-18 15:09:35 +04:00
|
|
|
nsContainerFrame* nextInFlow =
|
|
|
|
static_cast<nsContainerFrame*>(GetNextInFlow());
|
|
|
|
if (nextInFlow) {
|
1999-02-01 20:29:58 +03:00
|
|
|
// XXX This is not a very good thing to do. If it gets removed
|
|
|
|
// then remove the copy of this routine that doesn't do this from
|
|
|
|
// nsInlineFrame.
|
1999-04-13 04:15:13 +04:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
2003-06-26 15:30:17 +04:00
|
|
|
for (nsIFrame* f = aFromChild; f; f = f->GetNextSibling()) {
|
2006-02-22 00:33:47 +03:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, this, nextInFlow);
|
1999-04-13 04:15:13 +04:00
|
|
|
}
|
2009-09-18 15:09:35 +04:00
|
|
|
nextInFlow->mFrames.InsertFrames(nextInFlow, nsnull, tail);
|
1999-01-16 01:53:39 +03:00
|
|
|
}
|
|
|
|
else {
|
1998-10-01 01:35:29 +04:00
|
|
|
// Add the frames to our overflow list
|
2009-09-18 15:09:36 +04:00
|
|
|
SetOverflowFrames(aPresContext, tail);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-01-08 02:16:05 +03:00
|
|
|
* Moves any frames on the overflow lists (the prev-in-flow's overflow list and
|
1998-10-01 01:35:29 +04:00
|
|
|
* the receiver's overflow list) to the child list.
|
|
|
|
*
|
|
|
|
* Updates this frame's child count and content mapping.
|
|
|
|
*
|
|
|
|
* @return PR_TRUE if any frames were moved and PR_FALSE otherwise
|
|
|
|
*/
|
1999-01-16 01:53:39 +03:00
|
|
|
PRBool
|
2004-08-01 03:15:21 +04:00
|
|
|
nsContainerFrame::MoveOverflowToChildList(nsPresContext* aPresContext)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
1999-01-16 01:53:39 +03:00
|
|
|
PRBool result = PR_FALSE;
|
1998-10-01 01:35:29 +04:00
|
|
|
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
2006-02-22 00:33:47 +03:00
|
|
|
nsContainerFrame* prevInFlow = (nsContainerFrame*)GetPrevInFlow();
|
1998-10-01 01:35:29 +04:00
|
|
|
if (nsnull != prevInFlow) {
|
2009-07-28 16:51:09 +04:00
|
|
|
nsAutoPtr<nsFrameList> prevOverflowFrames(prevInFlow->StealOverflowFrames());
|
1999-10-21 09:11:43 +04:00
|
|
|
if (prevOverflowFrames) {
|
2009-07-28 16:51:09 +04:00
|
|
|
// Tables are special; they can have repeated header/footer
|
|
|
|
// frames on mFrames at this point.
|
|
|
|
NS_ASSERTION(mFrames.IsEmpty() || GetType() == nsGkAtoms::tableFrame,
|
|
|
|
"bad overflow list");
|
1999-04-13 04:15:13 +04:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
2009-07-28 16:51:09 +04:00
|
|
|
nsHTMLContainerFrame::ReparentFrameViewList(aPresContext,
|
|
|
|
*prevOverflowFrames,
|
|
|
|
prevInFlow, this);
|
|
|
|
mFrames.AppendFrames(this, *prevOverflowFrames);
|
1998-10-01 01:35:29 +04:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
2009-07-28 16:51:09 +04:00
|
|
|
nsAutoPtr<nsFrameList> overflowFrames(StealOverflowFrames());
|
1999-10-21 09:11:43 +04:00
|
|
|
if (overflowFrames) {
|
1999-01-16 01:53:39 +03:00
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
2009-07-28 16:51:09 +04:00
|
|
|
mFrames.AppendFrames(nsnull, *overflowFrames);
|
1998-10-01 01:35:29 +04:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
nsOverflowContinuationTracker::nsOverflowContinuationTracker(nsPresContext* aPresContext,
|
|
|
|
nsContainerFrame* aFrame,
|
2007-10-02 09:57:45 +04:00
|
|
|
PRBool aWalkOOFFrames,
|
2007-07-26 08:03:29 +04:00
|
|
|
PRBool aSkipOverflowContainerChildren)
|
|
|
|
: mOverflowContList(nsnull),
|
|
|
|
mPrevOverflowCont(nsnull),
|
|
|
|
mSentry(nsnull),
|
|
|
|
mParent(aFrame),
|
2007-10-02 09:57:45 +04:00
|
|
|
mSkipOverflowContainerChildren(aSkipOverflowContainerChildren),
|
|
|
|
mWalkOOFFrames(aWalkOOFFrames)
|
2007-07-26 08:03:29 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aFrame, "null frame pointer");
|
|
|
|
nsContainerFrame* next = static_cast<nsContainerFrame*>
|
|
|
|
(aFrame->GetNextInFlow());
|
|
|
|
if (next) {
|
2010-03-29 05:46:55 +04:00
|
|
|
mOverflowContList = next->GetPropTableFrames(aPresContext,
|
|
|
|
nsContainerFrame::OverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
if (mOverflowContList) {
|
|
|
|
mParent = next;
|
|
|
|
SetUpListWalker();
|
|
|
|
}
|
|
|
|
}
|
2007-10-09 23:46:21 +04:00
|
|
|
if (!mOverflowContList) {
|
2010-03-29 05:46:55 +04:00
|
|
|
mOverflowContList = mParent->GetPropTableFrames(aPresContext,
|
|
|
|
nsContainerFrame::ExcessOverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
if (mOverflowContList) {
|
|
|
|
SetUpListWalker();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to walk past overflow continuations whose prev-in-flow
|
|
|
|
* isn't a normal child and to set mSentry and mPrevOverflowCont correctly.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsOverflowContinuationTracker::SetUpListWalker()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(!mSentry && !mPrevOverflowCont,
|
|
|
|
"forgot to reset mSentry or mPrevOverflowCont");
|
|
|
|
if (mOverflowContList) {
|
|
|
|
nsIFrame* cur = mOverflowContList->FirstChild();
|
|
|
|
if (mSkipOverflowContainerChildren) {
|
|
|
|
while (cur && (cur->GetPrevInFlow()->GetStateBits()
|
|
|
|
& NS_FRAME_IS_OVERFLOW_CONTAINER)) {
|
|
|
|
mPrevOverflowCont = cur;
|
|
|
|
cur = cur->GetNextSibling();
|
|
|
|
}
|
2007-12-02 06:13:23 +03:00
|
|
|
while (cur && (!(cur->GetStateBits() & NS_FRAME_OUT_OF_FLOW)
|
|
|
|
== mWalkOOFFrames)) {
|
2007-10-02 09:57:45 +04:00
|
|
|
mPrevOverflowCont = cur;
|
|
|
|
cur = cur->GetNextSibling();
|
|
|
|
}
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
if (cur) {
|
|
|
|
mSentry = cur->GetPrevInFlow();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Helper function to step forward through the overflow continuations list.
|
2007-10-02 09:57:45 +04:00
|
|
|
* Sets mSentry and mPrevOverflowCont, skipping over OOF or non-OOF frames
|
|
|
|
* as appropriate. May only be called when we have already set up an
|
|
|
|
* mOverflowContList; mOverflowContList cannot be null.
|
2007-07-26 08:03:29 +04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
nsOverflowContinuationTracker::StepForward()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(mOverflowContList, "null list");
|
|
|
|
|
|
|
|
// Step forward
|
|
|
|
if (mPrevOverflowCont) {
|
|
|
|
mPrevOverflowCont = mPrevOverflowCont->GetNextSibling();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mPrevOverflowCont = mOverflowContList->FirstChild();
|
|
|
|
}
|
|
|
|
|
2007-10-02 09:57:45 +04:00
|
|
|
// Skip over oof or non-oof frames as appropriate
|
|
|
|
if (mSkipOverflowContainerChildren) {
|
|
|
|
nsIFrame* cur = mPrevOverflowCont->GetNextSibling();
|
2007-12-02 06:13:23 +03:00
|
|
|
while (cur && (!(cur->GetStateBits() & NS_FRAME_OUT_OF_FLOW)
|
|
|
|
== mWalkOOFFrames)) {
|
2007-10-02 09:57:45 +04:00
|
|
|
mPrevOverflowCont = cur;
|
|
|
|
cur = cur->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-26 08:03:29 +04:00
|
|
|
// Set up the sentry
|
|
|
|
mSentry = (mPrevOverflowCont->GetNextSibling())
|
|
|
|
? mPrevOverflowCont->GetNextSibling()->GetPrevInFlow()
|
|
|
|
: nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsOverflowContinuationTracker::Insert(nsIFrame* aOverflowCont,
|
|
|
|
nsReflowStatus& aReflowStatus)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aOverflowCont, "null frame pointer");
|
2007-12-02 06:13:23 +03:00
|
|
|
NS_PRECONDITION(!mSkipOverflowContainerChildren || mWalkOOFFrames ==
|
|
|
|
!!(aOverflowCont->GetStateBits() & NS_FRAME_OUT_OF_FLOW),
|
|
|
|
"shouldn't insert frame that doesn't match walker type");
|
2007-07-26 08:03:29 +04:00
|
|
|
NS_PRECONDITION(aOverflowCont->GetPrevInFlow(),
|
|
|
|
"overflow containers must have a prev-in-flow");
|
|
|
|
nsresult rv = NS_OK;
|
2008-09-06 12:48:09 +04:00
|
|
|
PRBool convertedToOverflowContainer = PR_FALSE;
|
|
|
|
nsPresContext* presContext = aOverflowCont->PresContext();
|
2007-07-26 08:03:29 +04:00
|
|
|
if (!mSentry || aOverflowCont != mSentry->GetNextInFlow()) {
|
|
|
|
// Not in our list, so we need to add it
|
2007-11-15 22:23:07 +03:00
|
|
|
if (aOverflowCont->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) {
|
|
|
|
// aOverflowCont is in some other overflow container list,
|
2007-07-26 08:03:29 +04:00
|
|
|
// steal it first
|
2007-11-15 22:23:07 +03:00
|
|
|
NS_ASSERTION(!(mOverflowContList &&
|
|
|
|
mOverflowContList->ContainsFrame(aOverflowCont)),
|
|
|
|
"overflow containers out of order");
|
2007-07-26 08:03:29 +04:00
|
|
|
rv = static_cast<nsContainerFrame*>(aOverflowCont->GetParent())
|
|
|
|
->StealFrame(presContext, aOverflowCont);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aOverflowCont->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
|
2008-09-06 12:48:09 +04:00
|
|
|
convertedToOverflowContainer = PR_TRUE;
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
if (!mOverflowContList) {
|
|
|
|
mOverflowContList = new nsFrameList();
|
2010-03-29 05:46:55 +04:00
|
|
|
rv = mParent->SetPropTableFrames(presContext, mOverflowContList,
|
|
|
|
nsContainerFrame::ExcessOverflowContainersProperty());
|
2007-07-26 08:03:29 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
SetUpListWalker();
|
|
|
|
}
|
|
|
|
if (aOverflowCont->GetParent() != mParent) {
|
|
|
|
nsHTMLContainerFrame::ReparentFrameView(presContext, aOverflowCont,
|
|
|
|
aOverflowCont->GetParent(),
|
|
|
|
mParent);
|
|
|
|
}
|
|
|
|
mOverflowContList->InsertFrame(mParent, mPrevOverflowCont, aOverflowCont);
|
|
|
|
aReflowStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we need to reflow it, mark it dirty
|
|
|
|
if (aReflowStatus & NS_FRAME_REFLOW_NEXTINFLOW)
|
|
|
|
aOverflowCont->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
|
|
|
|
// It's in our list, just step forward
|
|
|
|
StepForward();
|
2007-12-02 06:13:23 +03:00
|
|
|
NS_ASSERTION(mPrevOverflowCont == aOverflowCont ||
|
|
|
|
(mSkipOverflowContainerChildren &&
|
|
|
|
(mPrevOverflowCont->GetStateBits() & NS_FRAME_OUT_OF_FLOW) !=
|
|
|
|
(aOverflowCont->GetStateBits() & NS_FRAME_OUT_OF_FLOW)),
|
|
|
|
"OverflowContTracker in unexpected state");
|
2008-09-06 12:48:09 +04:00
|
|
|
|
|
|
|
if (convertedToOverflowContainer) {
|
|
|
|
// Convert all non-overflow-container continuations of aOverflowCont
|
|
|
|
// into overflow containers and move them to our overflow
|
|
|
|
// tracker. This preserves the invariant that the next-continuations
|
|
|
|
// of an overflow container are also overflow containers.
|
|
|
|
nsIFrame* f = aOverflowCont->GetNextContinuation();
|
|
|
|
if (f && !(f->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) {
|
|
|
|
nsContainerFrame* parent = static_cast<nsContainerFrame*>(f->GetParent());
|
|
|
|
rv = parent->StealFrame(presContext, f);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
Insert(f, aReflowStatus);
|
|
|
|
}
|
|
|
|
}
|
2007-07-26 08:03:29 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsOverflowContinuationTracker::Finish(nsIFrame* aChild)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aChild, "null ptr");
|
|
|
|
NS_PRECONDITION(aChild->GetNextInFlow(),
|
2007-10-02 09:57:45 +04:00
|
|
|
"supposed to call Finish *before* deleting next-in-flow!");
|
2008-09-06 12:48:09 +04:00
|
|
|
|
|
|
|
for (nsIFrame* f = aChild; f; f = f->GetNextInFlow()) {
|
|
|
|
if (f == mSentry) {
|
|
|
|
// Make sure we drop all references if this was the only frame
|
|
|
|
// in the overflow containers list
|
|
|
|
if (mOverflowContList->FirstChild() == f->GetNextInFlow()
|
|
|
|
&& !f->GetNextInFlow()->GetNextSibling()) {
|
|
|
|
mOverflowContList = nsnull;
|
|
|
|
mPrevOverflowCont = nsnull;
|
|
|
|
mSentry = nsnull;
|
|
|
|
mParent = static_cast<nsContainerFrame*>(f->GetParent());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Step past aChild
|
|
|
|
nsIFrame* prevOverflowCont = mPrevOverflowCont;
|
|
|
|
StepForward();
|
|
|
|
if (mPrevOverflowCont == f->GetNextInFlow()) {
|
|
|
|
// Pull mPrevOverflowChild back to aChild's prevSibling:
|
|
|
|
// aChild will be removed from our list by our caller
|
|
|
|
mPrevOverflowCont = prevOverflowCont;
|
|
|
|
}
|
2007-12-02 06:13:23 +03:00
|
|
|
}
|
2007-07-26 08:03:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Debugging
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
2005-09-07 01:34:50 +04:00
|
|
|
nsContainerFrame::List(FILE* out, PRInt32 aIndent) const
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
1999-01-16 03:00:50 +03:00
|
|
|
IndentBy(out, aIndent);
|
|
|
|
ListTag(out);
|
2000-07-27 09:16:08 +04:00
|
|
|
#ifdef DEBUG_waterson
|
2007-07-08 11:08:04 +04:00
|
|
|
fprintf(out, " [parent=%p]", static_cast<void*>(mParent));
|
2000-07-27 09:16:08 +04:00
|
|
|
#endif
|
2003-06-20 03:44:01 +04:00
|
|
|
if (HasView()) {
|
2007-07-08 11:08:04 +04:00
|
|
|
fprintf(out, " [view=%p]", static_cast<void*>(GetView()));
|
1999-01-16 03:00:50 +03:00
|
|
|
}
|
2009-09-18 15:09:36 +04:00
|
|
|
if (GetNextSibling()) {
|
|
|
|
fprintf(out, " next=%p", static_cast<void*>(GetNextSibling()));
|
1999-04-28 02:11:21 +04:00
|
|
|
}
|
2006-02-22 00:33:47 +03:00
|
|
|
if (nsnull != GetPrevContinuation()) {
|
2007-07-08 11:08:04 +04:00
|
|
|
fprintf(out, " prev-continuation=%p", static_cast<void*>(GetPrevContinuation()));
|
1999-01-16 03:00:50 +03:00
|
|
|
}
|
2006-02-22 00:33:47 +03:00
|
|
|
if (nsnull != GetNextContinuation()) {
|
2007-07-08 11:08:04 +04:00
|
|
|
fprintf(out, " next-continuation=%p", static_cast<void*>(GetNextContinuation()));
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
2010-03-29 05:46:55 +04:00
|
|
|
void* IBsibling = Properties().Get(IBSplitSpecialSibling());
|
2009-10-16 06:47:03 +04:00
|
|
|
if (IBsibling) {
|
|
|
|
fprintf(out, " IBSplitSpecialSibling=%p", IBsibling);
|
|
|
|
}
|
2010-03-29 05:46:55 +04:00
|
|
|
void* IBprevsibling = Properties().Get(IBSplitSpecialPrevSibling());
|
2009-10-16 06:47:03 +04:00
|
|
|
if (IBprevsibling) {
|
|
|
|
fprintf(out, " IBSplitSpecialPrevSibling=%p", IBprevsibling);
|
|
|
|
}
|
1999-03-05 07:22:54 +03:00
|
|
|
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
|
1999-01-16 03:19:10 +03:00
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
2007-07-08 11:08:04 +04:00
|
|
|
fprintf(out, " [content=%p]", static_cast<void*>(mContent));
|
|
|
|
nsContainerFrame* f = const_cast<nsContainerFrame*>(this);
|
2009-04-06 04:31:50 +04:00
|
|
|
if (f->HasOverflowRect()) {
|
2008-02-20 10:08:55 +03:00
|
|
|
nsRect overflowArea = f->GetOverflowRect();
|
|
|
|
fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea.x, overflowArea.y,
|
|
|
|
overflowArea.width, overflowArea.height);
|
2004-08-26 04:07:56 +04:00
|
|
|
}
|
2007-07-08 11:08:04 +04:00
|
|
|
fprintf(out, " [sc=%p]", static_cast<void*>(mStyleContext));
|
2009-10-30 00:17:56 +03:00
|
|
|
nsIAtom* pseudoTag = mStyleContext->GetPseudo();
|
2004-11-11 20:48:09 +03:00
|
|
|
if (pseudoTag) {
|
|
|
|
nsAutoString atomString;
|
|
|
|
pseudoTag->ToString(atomString);
|
|
|
|
fprintf(out, " pst=%s",
|
2006-02-03 17:18:39 +03:00
|
|
|
NS_LossyConvertUTF16toASCII(atomString).get());
|
2004-11-11 20:48:09 +03:00
|
|
|
}
|
1999-01-16 03:19:10 +03:00
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
// Output the children
|
1999-01-16 03:19:10 +03:00
|
|
|
nsIAtom* listName = nsnull;
|
|
|
|
PRInt32 listIndex = 0;
|
|
|
|
PRBool outputOneList = PR_FALSE;
|
|
|
|
do {
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame* kid = GetFirstChild(listName);
|
1999-01-16 03:19:10 +03:00
|
|
|
if (nsnull != kid) {
|
1999-02-01 20:29:58 +03:00
|
|
|
if (outputOneList) {
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
}
|
1999-01-16 03:19:10 +03:00
|
|
|
outputOneList = PR_TRUE;
|
|
|
|
nsAutoString tmp;
|
|
|
|
if (nsnull != listName) {
|
|
|
|
listName->ToString(tmp);
|
2006-02-03 17:18:39 +03:00
|
|
|
fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out);
|
1999-01-16 03:19:10 +03:00
|
|
|
}
|
|
|
|
fputs("<\n", out);
|
|
|
|
while (nsnull != kid) {
|
2000-01-22 04:16:50 +03:00
|
|
|
// Verify the child frame's parent frame pointer is correct
|
2003-06-26 20:44:48 +04:00
|
|
|
NS_ASSERTION(kid->GetParent() == (nsIFrame*)this, "bad parent frame pointer");
|
1999-11-02 01:12:45 +03:00
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
// Have the child frame list
|
2009-08-21 01:52:48 +04:00
|
|
|
kid->List(out, aIndent + 1);
|
2003-06-26 15:30:17 +04:00
|
|
|
kid = kid->GetNextSibling();
|
1999-01-16 03:19:10 +03:00
|
|
|
}
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fputs(">\n", out);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
2004-01-09 17:20:53 +03:00
|
|
|
listName = GetAdditionalChildListName(listIndex++);
|
1999-01-16 03:19:10 +03:00
|
|
|
} while(nsnull != listName);
|
|
|
|
|
|
|
|
if (!outputOneList) {
|
1999-01-16 03:00:50 +03:00
|
|
|
fputs("<>\n", out);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|