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
|
1998-09-30 21:35:29 +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/
|
1998-09-30 21:35:29 +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.
|
1998-09-30 21:35:29 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org 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.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* 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 ***** */
|
1998-09-30 21:35:29 +00:00
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsIContent.h"
|
2003-04-06 02:49:40 +00:00
|
|
|
#include "nsIDocument.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1998-09-30 21:35:29 +00:00
|
|
|
#include "nsIRenderingContext.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-09-30 21:35:29 +00:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsPoint.h"
|
|
|
|
#include "nsGUIEvent.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIView.h"
|
2001-09-21 00:53:29 +00:00
|
|
|
#include "nsIScrollableView.h"
|
1998-09-30 21:35:29 +00:00
|
|
|
#include "nsVoidArray.h"
|
1999-04-13 00:15:13 +00:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
2004-02-23 21:29:06 +00:00
|
|
|
#include "nsFrameManager.h"
|
1999-10-21 05:11:43 +00:00
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsLayoutAtoms.h"
|
2002-11-17 15:37:56 +00:00
|
|
|
#include "nsCSSAnonBoxes.h"
|
1999-11-19 15:33:29 +00:00
|
|
|
#include "nsIViewManager.h"
|
2001-07-16 02:40:48 +00:00
|
|
|
#include "nsIWidget.h"
|
2001-12-01 14:31:45 +00:00
|
|
|
#include "nsGfxCIID.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2002-01-14 15:00:30 +00:00
|
|
|
#include "nsCSSRendering.h"
|
2002-06-17 23:35:15 +00:00
|
|
|
#include "nsTransform2D.h"
|
2002-08-30 03:32:05 +00:00
|
|
|
#include "nsRegion.h"
|
2002-11-25 11:21:22 +00:00
|
|
|
#include "nsLayoutErrors.h"
|
2001-12-01 14:31:45 +00:00
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
#undef NOISY
|
|
|
|
#else
|
|
|
|
#undef NOISY
|
|
|
|
#endif
|
|
|
|
|
1999-01-15 22:53:39 +00:00
|
|
|
nsContainerFrame::nsContainerFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsContainerFrame::~nsContainerFrame()
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-04-17 06:43:01 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::Init(nsPresContext* aPresContext,
|
2001-04-17 06:43:01 +00:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aContext,
|
2001-04-17 06:43:01 +00:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
rv = nsSplittableFrame::Init(aPresContext, aContent, aParent, aContext, aPrevInFlow);
|
|
|
|
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 11:30:17 +00:00
|
|
|
if (aPrevInFlow->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW)
|
|
|
|
AddStateBits(NS_FRAME_HAS_CHILD_WITH_VIEW);
|
2001-04-17 06:43:01 +00:00
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::SetInitialChildList(nsPresContext* aPresContext,
|
1998-11-10 06:05:32 +00:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
1999-01-15 22:53:39 +00:00
|
|
|
nsresult result;
|
1999-07-24 21:41:15 +00:00
|
|
|
if (!mFrames.IsEmpty()) {
|
|
|
|
// We already have child frames which means we've already been
|
|
|
|
// initialized
|
2002-06-12 03:27:48 +00:00
|
|
|
NS_NOTREACHED("unexpected second call to SetInitialChildList");
|
1998-11-10 06:05:32 +00:00
|
|
|
result = NS_ERROR_UNEXPECTED;
|
1999-07-24 21:41:15 +00:00
|
|
|
} else if (aListName) {
|
|
|
|
// All we know about is the unnamed principal child list
|
2002-06-12 03:27:48 +00:00
|
|
|
NS_NOTREACHED("unknown frame list");
|
1998-11-10 06:05:32 +00:00
|
|
|
result = NS_ERROR_INVALID_ARG;
|
|
|
|
} else {
|
1999-07-24 21:41:15 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsFrame::VerifyDirtyBitSet(aChildList);
|
|
|
|
#endif
|
1999-01-15 22:53:39 +00:00
|
|
|
mFrames.SetFrames(aChildList);
|
1998-11-10 06:05:32 +00:00
|
|
|
result = NS_OK;
|
|
|
|
}
|
|
|
|
return result;
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
|
2004-04-20 19:20:16 +00:00
|
|
|
static void
|
|
|
|
CleanupGeneratedContentIn(nsIContent* aRealContent, nsIFrame* aRoot) {
|
|
|
|
nsIAtom* frameList = nsnull;
|
|
|
|
PRInt32 listIndex = 0;
|
|
|
|
do {
|
|
|
|
nsIFrame* child = aRoot->GetFirstChild(frameList);
|
|
|
|
while (child) {
|
|
|
|
nsIContent* content = child->GetContent();
|
|
|
|
if (content && content != aRealContent) {
|
2005-04-05 23:54:35 +00:00
|
|
|
content->UnbindFromTree();
|
2004-04-20 19:20:16 +00:00
|
|
|
}
|
|
|
|
::CleanupGeneratedContentIn(aRealContent, child);
|
|
|
|
child = child->GetNextSibling();
|
|
|
|
}
|
|
|
|
frameList = aRoot->GetAdditionalChildListName(listIndex++);
|
|
|
|
} while (frameList);
|
|
|
|
}
|
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::Destroy(nsPresContext* aPresContext)
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
1998-11-14 19:25:34 +00:00
|
|
|
// Prevent event dispatch during destruction
|
2003-06-19 23:44:01 +00:00
|
|
|
if (HasView()) {
|
2003-06-26 11:30:17 +00:00
|
|
|
GetView()->SetClientData(nsnull);
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
|
2004-04-20 19:20:16 +00:00
|
|
|
if (mState & NS_FRAME_GENERATED_CONTENT) {
|
|
|
|
// Make sure all the content nodes for the generated content inside
|
|
|
|
// this frame know it's going away.
|
|
|
|
// XXXbz would this be better done via a global structure in
|
|
|
|
// nsCSSFrameConstructor that could key off of
|
|
|
|
// GeneratedContentFrameRemoved or something? The problem is that
|
|
|
|
// our kids are gone by the time that's called.
|
|
|
|
::CleanupGeneratedContentIn(mContent, this);
|
|
|
|
}
|
|
|
|
|
1998-11-14 19:25:34 +00:00
|
|
|
// Delete the primary child list
|
1999-07-22 04:00:57 +00:00
|
|
|
mFrames.DestroyFrames(aPresContext);
|
2003-06-02 04:03:07 +00:00
|
|
|
|
|
|
|
// Destroy overflow frames now
|
|
|
|
nsFrameList overflowFrames(GetOverflowFrames(aPresContext, PR_TRUE));
|
|
|
|
overflowFrames.DestroyFrames(aPresContext);
|
1998-11-14 19:25:34 +00:00
|
|
|
|
2002-10-30 15:33:36 +00:00
|
|
|
// Destroy the frame and remove the flow pointers
|
|
|
|
return nsSplittableFrame::Destroy(aPresContext);
|
1998-11-14 19:25:34 +00:00
|
|
|
}
|
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Child frame enumeration
|
|
|
|
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame*
|
|
|
|
nsContainerFrame::GetFirstChild(nsIAtom* aListName) const
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
2000-01-22 01:16:50 +00:00
|
|
|
// We only know about the unnamed principal child list and the overflow
|
|
|
|
// list
|
1998-11-09 19:40:27 +00:00
|
|
|
if (nsnull == aListName) {
|
2004-01-09 14:20:53 +00:00
|
|
|
return mFrames.FirstChild();
|
2000-01-22 01:16:50 +00:00
|
|
|
} else if (nsLayoutAtoms::overflowList == aListName) {
|
2004-01-09 14:20:53 +00:00
|
|
|
return GetOverflowFrames(GetPresContext(), PR_FALSE);
|
1998-11-09 19:40:27 +00:00
|
|
|
} else {
|
2004-01-09 14:20:53 +00:00
|
|
|
return nsnull;
|
1998-11-09 19:40:27 +00:00
|
|
|
}
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsContainerFrame::GetAdditionalChildListName(PRInt32 aIndex) const
|
2003-06-02 04:03:07 +00:00
|
|
|
{
|
|
|
|
if (aIndex == 0) {
|
2004-01-09 14:20:53 +00:00
|
|
|
return nsLayoutAtoms::overflowList;
|
2003-06-02 04:03:07 +00:00
|
|
|
} else {
|
2004-01-09 14:20:53 +00:00
|
|
|
return nsnull;
|
2003-06-02 04:03:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1999-01-15 22:53:39 +00:00
|
|
|
// Painting/Events
|
1998-09-30 21:35:29 +00:00
|
|
|
|
1998-10-30 22:11:06 +00:00
|
|
|
NS_IMETHODIMP
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::Paint(nsPresContext* aPresContext,
|
1998-10-30 22:11:06 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 12:35:19 +00:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
2001-09-19 12:35:19 +00:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
|
1998-09-30 21:35:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-30 22:11:06 +00:00
|
|
|
// Paint the children of a container, assuming nothing about the
|
|
|
|
// childrens spatial arrangement. Given relative positioning, negative
|
|
|
|
// margins, etc, that's probably a good thing.
|
|
|
|
//
|
|
|
|
// Note: aDirtyRect is in our coordinate system (and of course, child
|
|
|
|
// rect's are also in our coordinate system)
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::PaintChildren(nsPresContext* aPresContext,
|
1998-10-30 22:11:06 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 15:54:23 +00:00
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 12:35:19 +00:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
1999-01-15 22:53:39 +00:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
2003-06-26 11:30:17 +00:00
|
|
|
while (kid) {
|
2001-09-19 12:35:19 +00:00
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid, aWhichLayer, aFlags);
|
2003-06-26 11:30:17 +00:00
|
|
|
kid = kid->GetNextSibling();
|
1998-11-19 03:52:29 +00:00
|
|
|
}
|
1998-10-30 22:11:06 +00:00
|
|
|
}
|
1998-10-06 21:00:58 +00:00
|
|
|
|
1998-10-30 22:11:06 +00:00
|
|
|
// Paint one child frame
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::PaintChild(nsPresContext* aPresContext,
|
1998-10-30 22:11:06 +00:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
1998-12-18 15:54:23 +00:00
|
|
|
nsIFrame* aFrame,
|
2001-09-19 12:35:19 +00:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-10-30 22:11:06 +00:00
|
|
|
{
|
2002-02-28 04:54:50 +00:00
|
|
|
NS_ASSERTION(aFrame, "no frame to paint!");
|
2003-06-19 23:44:01 +00:00
|
|
|
if (!aFrame->HasView()) {
|
2003-06-26 11:30:17 +00:00
|
|
|
nsRect kidRect = aFrame->GetRect();
|
1998-09-30 21:35:29 +00:00
|
|
|
|
1998-10-30 22:11:06 +00:00
|
|
|
// Compute the constrained damage area; set the overlap flag to
|
|
|
|
// PR_TRUE if any portion of the child frame intersects the
|
|
|
|
// dirty rect.
|
|
|
|
nsRect damageArea;
|
|
|
|
PRBool overlap;
|
2003-06-26 11:30:17 +00:00
|
|
|
if (NS_FRAME_OUTSIDE_CHILDREN & aFrame->GetStateBits()) {
|
1998-10-30 22:11:06 +00:00
|
|
|
// If the child frame has children that leak out of our box
|
|
|
|
// then we don't constrain the damageArea to just the childs
|
|
|
|
// bounding rect.
|
|
|
|
damageArea = aDirtyRect;
|
|
|
|
overlap = PR_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Compute the intersection of the dirty rect and the childs
|
|
|
|
// rect (both are in our coordinate space). This limits the
|
|
|
|
// damageArea to just the portion that intersects the childs
|
|
|
|
// rect.
|
|
|
|
overlap = damageArea.IntersectRect(aDirtyRect, kidRect);
|
1998-10-09 22:58:25 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
if (!overlap && (0 == kidRect.width) && (0 == kidRect.height)) {
|
|
|
|
overlap = PR_TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
1998-10-30 22:11:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (overlap) {
|
|
|
|
// Translate damage area into the kids coordinate
|
|
|
|
// system. Translate rendering context into the kids
|
|
|
|
// coordinate system.
|
|
|
|
damageArea.x -= kidRect.x;
|
|
|
|
damageArea.y -= kidRect.y;
|
2002-06-17 23:35:15 +00:00
|
|
|
|
2005-04-19 22:58:33 +00:00
|
|
|
{
|
|
|
|
nsIRenderingContext::AutoPushTranslation
|
|
|
|
translate(&aRenderingContext, kidRect.x, kidRect.y);
|
|
|
|
|
|
|
|
// Paint the kid
|
|
|
|
aFrame->Paint(aPresContext, aRenderingContext, damageArea, aWhichLayer, aFlags);
|
|
|
|
}
|
1998-10-30 22:11:06 +00:00
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
#ifdef NS_DEBUG
|
1998-10-30 22:11:06 +00:00
|
|
|
// Draw a border around the child
|
1999-11-01 22:12:45 +00:00
|
|
|
if (nsIFrameDebug::GetShowFrameBorders() && !kidRect.IsEmpty()) {
|
1998-10-30 22:11:06 +00:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(kidRect);
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
1998-10-30 22:11:06 +00:00
|
|
|
#endif
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-18 05:25:26 +00:00
|
|
|
NS_IMETHODIMP
|
2005-01-01 17:26:29 +00:00
|
|
|
nsContainerFrame::GetFrameForPoint(const nsPoint& aPoint,
|
2000-03-22 02:43:08 +00:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1998-11-18 05:25:26 +00:00
|
|
|
nsIFrame** aFrame)
|
1998-11-19 18:09:03 +00:00
|
|
|
{
|
2005-01-01 17:26:29 +00:00
|
|
|
return GetFrameForPointUsing(aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND), aFrame);
|
1998-11-19 18:09:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2005-01-01 17:26:29 +00:00
|
|
|
nsContainerFrame::GetFrameForPointUsing(const nsPoint& aPoint,
|
1998-11-19 18:09:03 +00:00
|
|
|
nsIAtom* aList,
|
2000-03-22 02:43:08 +00:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRBool aConsiderSelf,
|
1998-11-19 18:09:03 +00:00
|
|
|
nsIFrame** aFrame)
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame *hit;
|
1998-11-18 05:25:26 +00:00
|
|
|
nsPoint tmp;
|
|
|
|
|
2000-03-22 02:43:08 +00:00
|
|
|
PRBool inThisFrame = mRect.Contains(aPoint);
|
|
|
|
|
|
|
|
if (! ((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame ) ) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-11-23 22:05:05 +00:00
|
|
|
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame* kid = GetFirstChild(aList);
|
2000-03-22 02:43:08 +00:00
|
|
|
*aFrame = nsnull;
|
|
|
|
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
|
2002-02-07 22:39:15 +00:00
|
|
|
|
|
|
|
nsPoint originOffset;
|
|
|
|
nsIView *view = nsnull;
|
2005-01-01 17:26:29 +00:00
|
|
|
nsresult rv = GetOriginToViewOffset(originOffset, &view);
|
2002-02-07 22:39:15 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && view)
|
|
|
|
tmp += originOffset;
|
|
|
|
|
2003-06-26 11:30:17 +00:00
|
|
|
while (kid) {
|
2004-08-10 22:24:00 +00:00
|
|
|
if (aWhichLayer == NS_FRAME_PAINT_LAYER_ALL) {
|
|
|
|
// Check all layers on this kid before moving on to the next one
|
2005-01-01 17:26:29 +00:00
|
|
|
rv = kid->GetFrameForPoint(tmp, NS_FRAME_PAINT_LAYER_FOREGROUND, &hit);
|
2004-08-10 22:24:00 +00:00
|
|
|
if (NS_FAILED(rv) || !hit) {
|
2005-01-01 17:26:29 +00:00
|
|
|
rv = kid->GetFrameForPoint(tmp, NS_FRAME_PAINT_LAYER_FLOATS, &hit);
|
2004-08-10 22:24:00 +00:00
|
|
|
if (NS_FAILED(rv) || !hit) {
|
2005-01-01 17:26:29 +00:00
|
|
|
rv = kid->GetFrameForPoint(tmp, NS_FRAME_PAINT_LAYER_BACKGROUND, &hit);
|
2004-08-10 22:24:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
2005-01-01 17:26:29 +00:00
|
|
|
rv = kid->GetFrameForPoint(tmp, aWhichLayer, &hit);
|
2004-08-10 22:24:00 +00:00
|
|
|
}
|
2000-03-22 02:43:08 +00:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && hit) {
|
|
|
|
*aFrame = hit;
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
2003-06-26 11:30:17 +00:00
|
|
|
kid = kid->GetNextSibling();
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
|
2000-03-22 02:43:08 +00:00
|
|
|
if (*aFrame) {
|
|
|
|
return NS_OK;
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
1999-11-23 22:05:05 +00:00
|
|
|
|
2000-03-22 02:43:08 +00:00
|
|
|
if ( inThisFrame && aConsiderSelf ) {
|
2003-05-15 03:42:21 +00:00
|
|
|
if (GetStyleVisibility()->IsVisible()) {
|
2000-03-22 02:43:08 +00:00
|
|
|
*aFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-23 22:05:05 +00:00
|
|
|
}
|
|
|
|
|
1999-05-07 00:08:02 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
|
1999-07-22 04:32:31 +00:00
|
|
|
NS_IMETHODIMP
|
2005-02-07 01:58:25 +00:00
|
|
|
nsContainerFrame::ReplaceFrame(nsIAtom* aListName,
|
1999-07-22 04:32:31 +00:00
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
nsIFrame* aNewFrame)
|
|
|
|
{
|
|
|
|
nsIFrame* prevFrame;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Get the old frame's previous sibling frame
|
2004-01-09 14:20:53 +00:00
|
|
|
nsFrameList frames(GetFirstChild(aListName));
|
1999-07-22 04:32:31 +00:00
|
|
|
NS_ASSERTION(frames.ContainsFrame(aOldFrame), "frame is not a valid child frame");
|
|
|
|
prevFrame = frames.GetPrevSiblingFor(aOldFrame);
|
|
|
|
|
|
|
|
// Default implementation treats it like two separate operations
|
2005-02-07 01:58:25 +00:00
|
|
|
rv = RemoveFrame(aListName, aOldFrame);
|
1999-07-22 04:32:31 +00:00
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2005-02-07 01:58:25 +00:00
|
|
|
rv = InsertFrames(aListName, prevFrame, aNewFrame);
|
1999-07-22 04:32:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-01-12 08:28:24 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContainerFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
|
|
|
|
{
|
2000-01-12 21:52:58 +00:00
|
|
|
// The container frame always generates a reflow command
|
|
|
|
// targeted at its child
|
2001-04-17 23:12:36 +00:00
|
|
|
// Note that even if this flag is already set, we still need to reflow the
|
|
|
|
// child because the frame may have more than one child
|
|
|
|
mState |= NS_FRAME_HAS_DIRTY_CHILDREN;
|
2000-01-12 21:52:58 +00:00
|
|
|
|
2005-02-08 00:59:52 +00:00
|
|
|
aPresShell->AppendReflowCommand(aChild, eReflowType_ReflowDirty, nsnull);
|
2000-01-12 08:28:24 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-16 22:52:48 +00:00
|
|
|
PRBool
|
|
|
|
nsContainerFrame::IsLeaf() const
|
|
|
|
{
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
2000-01-12 08:28:24 +00:00
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helper member functions
|
|
|
|
|
2001-09-21 00:53:29 +00: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 15:33:29 +00:00
|
|
|
void
|
2004-12-27 15:05:18 +00:00
|
|
|
nsContainerFrame::PositionFrameView(nsIFrame* aKidFrame)
|
1999-11-19 15:33:29 +00:00
|
|
|
{
|
2005-04-03 21:00:41 +00:00
|
|
|
nsIFrame* parentFrame = aKidFrame->GetParent();
|
|
|
|
if (!aKidFrame->HasView() || !parentFrame)
|
|
|
|
return;
|
2001-09-21 00:53:29 +00:00
|
|
|
|
2005-04-03 21:00:41 +00:00
|
|
|
nsIView* view = aKidFrame->GetView();
|
|
|
|
nsIViewManager* vm = view->GetViewManager();
|
|
|
|
nsPoint pt;
|
|
|
|
nsIView* ancestorView = parentFrame->GetClosestView(&pt);
|
2005-03-31 03:40:12 +00:00
|
|
|
|
2005-04-03 21:00:41 +00: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 18:04:50 +00:00
|
|
|
}
|
2005-04-03 21:00:41 +00:00
|
|
|
|
|
|
|
pt += aKidFrame->GetPosition();
|
|
|
|
vm->MoveViewTo(view, pt.x, pt.y);
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
2003-01-19 00:28:02 +00:00
|
|
|
static PRBool
|
|
|
|
NonZeroStyleCoord(const nsStyleCoord& aCoord) {
|
|
|
|
switch (aCoord.GetUnit()) {
|
|
|
|
case eStyleUnit_Percent:
|
|
|
|
return aCoord.GetPercentValue() > 0;
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
return aCoord.GetCoordValue() > 0;
|
|
|
|
case eStyleUnit_Null:
|
|
|
|
return PR_FALSE;
|
|
|
|
default:
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static PRBool
|
2003-02-22 00:32:13 +00:00
|
|
|
HasNonZeroBorderRadius(nsStyleContext* aStyleContext) {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleBorder* border = aStyleContext->GetStyleBorder();
|
2003-01-19 00:28:02 +00:00
|
|
|
|
|
|
|
nsStyleCoord coord;
|
|
|
|
border->mBorderRadius.GetTop(coord);
|
|
|
|
if (NonZeroStyleCoord(coord)) return PR_TRUE;
|
|
|
|
border->mBorderRadius.GetRight(coord);
|
|
|
|
if (NonZeroStyleCoord(coord)) return PR_TRUE;
|
|
|
|
border->mBorderRadius.GetBottom(coord);
|
|
|
|
if (NonZeroStyleCoord(coord)) return PR_TRUE;
|
|
|
|
border->mBorderRadius.GetLeft(coord);
|
|
|
|
if (NonZeroStyleCoord(coord)) return PR_TRUE;
|
|
|
|
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
static void
|
2004-07-31 23:15:21 +00:00
|
|
|
SyncFrameViewGeometryDependentProperties(nsPresContext* aPresContext,
|
2002-09-30 11:56:37 +00:00
|
|
|
nsIFrame* aFrame,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aStyleContext,
|
2002-09-30 11:56:37 +00:00
|
|
|
nsIView* aView,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
2003-06-27 18:13:48 +00:00
|
|
|
nsIViewManager* vm = aView->GetViewManager();
|
2002-09-30 11:56:37 +00:00
|
|
|
|
|
|
|
PRBool isCanvas;
|
|
|
|
const nsStyleBackground* bg;
|
|
|
|
PRBool hasBG =
|
|
|
|
nsCSSRendering::FindBackground(aPresContext, aFrame, &bg, &isCanvas);
|
|
|
|
|
|
|
|
// background-attachment: fixed is not really geometry dependent, but
|
|
|
|
// we set it here because it's cheap to do so
|
2004-09-13 05:39:27 +00:00
|
|
|
PRBool fixedBackground = hasBG && bg->HasFixedBackground();
|
2002-09-30 11:56:37 +00:00
|
|
|
// If the frame has a fixed background attachment, then indicate that the
|
|
|
|
// view's contents should be repainted and not bitblt'd
|
|
|
|
vm->SetViewBitBltEnabled(aView, !fixedBackground);
|
|
|
|
|
2005-06-21 21:53:10 +00:00
|
|
|
const nsStyleDisplay* display = aStyleContext->GetStyleDisplay();
|
2003-10-11 12:00:05 +00:00
|
|
|
// If the frame has a solid background color, 'background-clip:border',
|
|
|
|
// and it's a kind of frame that paints its background, and rounded borders aren't
|
|
|
|
// clipping the background, then it's opaque.
|
2005-06-21 21:53:10 +00:00
|
|
|
// If the frame has a native theme appearance then its background
|
|
|
|
// color is actually not relevant.
|
2002-09-30 11:56:37 +00:00
|
|
|
PRBool viewHasTransparentContent =
|
2003-10-11 12:00:05 +00:00
|
|
|
!(hasBG && !(bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) &&
|
2005-06-21 21:53:10 +00:00
|
|
|
!display->mAppearance && bg->mBackgroundClip == NS_STYLE_BG_CLIP_BORDER &&
|
2003-10-11 12:00:05 +00:00
|
|
|
aFrame->CanPaintBackground() &&
|
|
|
|
!HasNonZeroBorderRadius(aStyleContext));
|
|
|
|
|
|
|
|
PRBool drawnOnUniformField = PR_FALSE;
|
2003-10-17 02:38:37 +00:00
|
|
|
if (aStyleContext->GetPseudoType() == nsCSSAnonBoxes::scrolledContent) {
|
2003-10-11 12:00:05 +00:00
|
|
|
// If the nsGfxScrollFrame draws a solid unclipped background
|
|
|
|
// color, and nothing else, then tell the view system that we're
|
|
|
|
// drawn on a uniform field. Note that it's OK if the background
|
|
|
|
// is clipped to the padding area, since the scrollport is within
|
|
|
|
// the borders.
|
|
|
|
nsIFrame* scrollFrame = aFrame->GetParent();
|
2003-10-17 02:38:37 +00:00
|
|
|
while (scrollFrame->GetStyleContext()->GetPseudoType()
|
2003-10-11 12:00:05 +00:00
|
|
|
== nsCSSAnonBoxes::scrolledContent) {
|
|
|
|
scrollFrame = scrollFrame->GetParent();
|
|
|
|
}
|
|
|
|
PRBool scrollFrameIsCanvas;
|
|
|
|
const nsStyleBackground* scrollFrameBG;
|
|
|
|
PRBool scrollFrameHasBG =
|
|
|
|
nsCSSRendering::FindBackground(aPresContext, scrollFrame, &scrollFrameBG,
|
|
|
|
&scrollFrameIsCanvas);
|
2004-03-28 21:05:29 +00:00
|
|
|
const nsStyleDisplay* bgDisplay = scrollFrame->GetStyleDisplay();
|
2003-10-11 12:00:05 +00:00
|
|
|
drawnOnUniformField = scrollFrameHasBG &&
|
|
|
|
!(scrollFrameBG->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) &&
|
|
|
|
(scrollFrameBG->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE) &&
|
2004-03-28 21:05:29 +00:00
|
|
|
!HasNonZeroBorderRadius(scrollFrame->GetStyleContext()) &&
|
|
|
|
!(bgDisplay->IsAbsolutelyPositioned()
|
|
|
|
&& (bgDisplay->mClipFlags & NS_STYLE_CLIP_RECT));
|
2003-10-11 12:00:05 +00:00
|
|
|
}
|
|
|
|
aView->SetHasUniformBackground(drawnOnUniformField);
|
2003-04-06 02:49:40 +00:00
|
|
|
|
|
|
|
if (isCanvas) {
|
2004-05-17 16:29:13 +00:00
|
|
|
nsIView* rootView;
|
|
|
|
vm->GetRootView(rootView);
|
2003-06-27 18:13:48 +00:00
|
|
|
nsIView* rootParent = rootView->GetParent();
|
2003-04-06 02:49:40 +00:00
|
|
|
if (!rootParent) {
|
|
|
|
// We're the root of a view manager hierarchy. We will have to
|
|
|
|
// paint something. NOTE: this can be overridden below.
|
2002-09-30 11:56:37 +00:00
|
|
|
viewHasTransparentContent = PR_FALSE;
|
|
|
|
}
|
2003-04-06 02:49:40 +00:00
|
|
|
|
2004-08-02 04:52:55 +00:00
|
|
|
nsIDocument *doc = aPresContext->PresShell()->GetDocument();
|
2003-04-06 02:49:40 +00:00
|
|
|
if (doc) {
|
2003-10-22 06:09:48 +00:00
|
|
|
nsIContent *rootElem = doc->GetRootContent();
|
|
|
|
if (!doc->GetParentDocument() &&
|
|
|
|
rootElem && rootElem->IsContentOfType(nsIContent::eXUL)) {
|
2003-04-06 02:49:40 +00:00
|
|
|
// we're XUL at the root of the document hierarchy. Try to make our
|
|
|
|
// window translucent.
|
|
|
|
// don't proceed unless this is the root view
|
|
|
|
// (sometimes the non-root-view is a canvas)
|
2003-06-27 18:13:48 +00:00
|
|
|
if (aView->HasWidget() && aView == rootView) {
|
2003-04-06 02:49:40 +00:00
|
|
|
viewHasTransparentContent = hasBG && (bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT);
|
2003-06-27 18:13:48 +00:00
|
|
|
aView->GetWidget()->SetWindowTranslucency(viewHasTransparentContent);
|
2003-04-06 02:49:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-09-30 11:56:37 +00:00
|
|
|
}
|
2003-04-06 02:49:40 +00:00
|
|
|
// XXX we should also set widget transparency for XUL popups
|
2002-09-30 11:56:37 +00:00
|
|
|
|
2003-06-26 11:30:17 +00:00
|
|
|
nsFrameState kidState = aFrame->GetStateBits();
|
2005-02-02 00:29:43 +00:00
|
|
|
PRBool isBlockLevel =
|
|
|
|
display->IsBlockLevel() || (kidState & NS_FRAME_OUT_OF_FLOW);
|
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
if (!viewHasTransparentContent) {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleVisibility* vis = aStyleContext->GetStyleVisibility();
|
2005-02-02 00:29:43 +00:00
|
|
|
if (// If we're showing the view but the frame is hidden, then the
|
|
|
|
// view is transparent
|
|
|
|
(nsViewVisibility_kShow == aView->GetVisibility() &&
|
2005-05-18 14:02:20 +00:00
|
|
|
NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible)) {
|
2002-09-30 11:56:37 +00:00
|
|
|
viewHasTransparentContent = PR_TRUE;
|
2005-05-18 14:02:20 +00:00
|
|
|
} else {
|
|
|
|
PRBool isScrolledContent = aView->GetParent() &&
|
|
|
|
aView->GetParent()->ToScrollableView();
|
|
|
|
// If we have overflowing kids and we're not clipped by a parent
|
|
|
|
// scrolling view, then the view must be transparent.
|
|
|
|
if (!isScrolledContent && (kidState & NS_FRAME_OUTSIDE_CHILDREN)) {
|
|
|
|
viewHasTransparentContent = PR_TRUE;
|
|
|
|
}
|
2002-09-30 11:56:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the frame has visible content that overflows the content area, then we
|
|
|
|
// need the view marked as having transparent content
|
|
|
|
|
|
|
|
// There are two types of clipping:
|
|
|
|
// - 'clip' which only applies to absolutely positioned elements, and is
|
|
|
|
// relative to the element's border edge. 'clip' applies to the entire
|
|
|
|
// element
|
2005-03-07 22:12:53 +00:00
|
|
|
// - 'overflow:-moz-hidden-unscrollable' which only applies to
|
|
|
|
// block-level elements and replaced elements. Note
|
|
|
|
// that out-of-flow frames like floated or absolutely positioned
|
|
|
|
// frames are block-level, but we can't rely on the 'display' value
|
|
|
|
// being set correctly in the style context...
|
2002-09-30 11:56:37 +00:00
|
|
|
PRBool hasClip = display->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT);
|
2004-09-05 00:04:04 +00:00
|
|
|
PRBool hasOverflowClip = isBlockLevel && (display->mOverflowX == NS_STYLE_OVERFLOW_CLIP);
|
2002-09-30 11:56:37 +00:00
|
|
|
if (hasClip || hasOverflowClip) {
|
2003-06-26 11:30:17 +00:00
|
|
|
nsSize frameSize = aFrame->GetSize();
|
2002-09-30 11:56:37 +00:00
|
|
|
nsRect clipRect;
|
|
|
|
|
|
|
|
if (hasClip) {
|
|
|
|
// Start with the 'auto' values and then factor in user specified values
|
|
|
|
clipRect.SetRect(0, 0, frameSize.width, frameSize.height);
|
|
|
|
|
|
|
|
if (display->mClipFlags & NS_STYLE_CLIP_RECT) {
|
|
|
|
if (0 == (NS_STYLE_CLIP_TOP_AUTO & display->mClipFlags)) {
|
|
|
|
clipRect.y = display->mClip.y;
|
|
|
|
}
|
|
|
|
if (0 == (NS_STYLE_CLIP_LEFT_AUTO & display->mClipFlags)) {
|
|
|
|
clipRect.x = display->mClip.x;
|
|
|
|
}
|
|
|
|
if (0 == (NS_STYLE_CLIP_RIGHT_AUTO & display->mClipFlags)) {
|
|
|
|
clipRect.width = display->mClip.width;
|
|
|
|
}
|
|
|
|
if (0 == (NS_STYLE_CLIP_BOTTOM_AUTO & display->mClipFlags)) {
|
|
|
|
clipRect.height = display->mClip.height;
|
|
|
|
}
|
|
|
|
}
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
if (hasOverflowClip) {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleBorder* borderStyle = aStyleContext->GetStyleBorder();
|
|
|
|
const nsStylePadding* paddingStyle = aStyleContext->GetStylePadding();
|
2002-09-30 11:56:37 +00:00
|
|
|
|
2005-04-29 15:44:38 +00:00
|
|
|
nsMargin padding;
|
2002-09-30 11:56:37 +00:00
|
|
|
nsRect overflowClipRect(0, 0, frameSize.width, frameSize.height);
|
2005-04-29 15:44:38 +00:00
|
|
|
overflowClipRect.Deflate(borderStyle->GetBorder());
|
2002-09-30 11:56:37 +00:00
|
|
|
// XXX We need to handle percentage padding
|
|
|
|
if (paddingStyle->GetPadding(padding)) {
|
|
|
|
overflowClipRect.Deflate(padding);
|
|
|
|
}
|
2005-04-29 15:44:38 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
else {
|
|
|
|
NS_WARNING("Percentage padding and CLIP overflow don't mix");
|
|
|
|
}
|
|
|
|
#endif
|
2002-09-30 11:56:37 +00:00
|
|
|
|
|
|
|
if (hasClip) {
|
|
|
|
// If both 'clip' and 'overflow-clip' apply then use the intersection
|
|
|
|
// of the two
|
|
|
|
clipRect.IntersectRect(clipRect, overflowClipRect);
|
1999-11-19 15:33:29 +00:00
|
|
|
} else {
|
2002-09-30 11:56:37 +00:00
|
|
|
clipRect = overflowClipRect;
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-06-27 18:13:48 +00:00
|
|
|
nsRect newSize = aView->GetBounds();
|
|
|
|
newSize -= aView->GetPosition();
|
2002-09-30 11:56:37 +00:00
|
|
|
|
|
|
|
// If part of the view is being clipped out, then mark it transparent
|
|
|
|
if (clipRect.y > newSize.y
|
|
|
|
|| clipRect.x > newSize.x
|
|
|
|
|| clipRect.XMost() < newSize.XMost()
|
|
|
|
|| clipRect.YMost() < newSize.YMost()) {
|
|
|
|
viewHasTransparentContent = PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set clipping of child views.
|
2004-01-11 00:24:37 +00:00
|
|
|
nsRegion region(clipRect);
|
|
|
|
vm->SetViewChildClipRegion(aView, ®ion);
|
2002-09-30 11:56:37 +00:00
|
|
|
} else {
|
|
|
|
// Remove clipping of child views.
|
|
|
|
vm->SetViewChildClipRegion(aView, nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
vm->SetViewContentTransparency(aView, viewHasTransparentContent);
|
|
|
|
}
|
|
|
|
|
2002-10-08 04:09:38 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(nsPresContext* aPresContext,
|
2002-10-08 04:09:38 +00:00
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIView* aView,
|
|
|
|
const nsRect* aCombinedArea,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
if (!aView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure the view is sized and positioned correctly
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) {
|
2004-12-27 15:05:18 +00:00
|
|
|
PositionFrameView(aFrame);
|
2002-10-08 04:09:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) {
|
2003-06-27 18:13:48 +00:00
|
|
|
nsIViewManager* vm = aView->GetViewManager();
|
2002-10-08 04:09:38 +00:00
|
|
|
|
|
|
|
// If the frame has child frames that stick outside the content
|
|
|
|
// area, then size the view large enough to include those child
|
|
|
|
// frames
|
2003-07-23 00:14:16 +00:00
|
|
|
NS_ASSERTION(!(aFrame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) ||
|
|
|
|
aCombinedArea,
|
|
|
|
"resizing view for frame with overflow to the wrong size");
|
2003-06-26 11:30:17 +00:00
|
|
|
if ((aFrame->GetStateBits() & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) {
|
2003-02-22 21:53:42 +00:00
|
|
|
vm->ResizeView(aView, *aCombinedArea, PR_TRUE);
|
2002-10-08 04:09:38 +00:00
|
|
|
} else {
|
2003-06-26 11:30:17 +00:00
|
|
|
nsSize frameSize = aFrame->GetSize();
|
2002-10-08 04:09:38 +00:00
|
|
|
nsRect newSize(0, 0, frameSize.width, frameSize.height);
|
2003-02-22 21:53:42 +00:00
|
|
|
vm->ResizeView(aView, newSize, PR_TRUE);
|
2002-10-08 04:09:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Even if the size hasn't changed, we need to sync up the
|
|
|
|
// geometry dependent properties, because (kidState &
|
|
|
|
// NS_FRAME_OUTSIDE_CHILDREN) might have changed, and we can't
|
|
|
|
// detect whether it has or not. Likewise, whether the view size
|
|
|
|
// has changed or not, we may need to change the transparency
|
|
|
|
// state even if there is no clip.
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* savedStyleContext = aFrame->GetStyleContext();
|
2002-10-08 04:09:38 +00:00
|
|
|
SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, savedStyleContext, aView, aFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::SyncFrameViewAfterSizeChange(nsPresContext* aPresContext,
|
2002-09-30 11:56:37 +00:00
|
|
|
nsIFrame* aFrame,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aStyleContext,
|
2002-09-30 11:56:37 +00:00
|
|
|
nsIView* aView,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
2003-10-17 02:38:37 +00:00
|
|
|
NS_ASSERTION(!aStyleContext || aFrame->GetStyleContext() == aStyleContext,
|
|
|
|
"Wrong style context for frame?");
|
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
if (!aView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull == aStyleContext) {
|
2003-02-22 00:32:13 +00:00
|
|
|
aStyleContext = aFrame->GetStyleContext();
|
2002-09-30 11:56:37 +00:00
|
|
|
}
|
|
|
|
|
2002-10-08 04:09:38 +00:00
|
|
|
SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags);
|
2002-09-30 11:56:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::SyncFrameViewProperties(nsPresContext* aPresContext,
|
2002-09-30 11:56:37 +00:00
|
|
|
nsIFrame* aFrame,
|
2003-02-22 00:32:13 +00:00
|
|
|
nsStyleContext* aStyleContext,
|
2002-09-30 11:56:37 +00:00
|
|
|
nsIView* aView,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
2003-10-17 02:38:37 +00:00
|
|
|
NS_ASSERTION(!aStyleContext || aFrame->GetStyleContext() == aStyleContext,
|
|
|
|
"Wrong style context for frame?");
|
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
if (!aView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-06-27 18:13:48 +00:00
|
|
|
nsIViewManager* vm = aView->GetViewManager();
|
2002-09-30 11:56:37 +00:00
|
|
|
|
|
|
|
if (nsnull == aStyleContext) {
|
2003-02-22 00:32:13 +00:00
|
|
|
aStyleContext = aFrame->GetStyleContext();
|
2002-09-30 11:56:37 +00:00
|
|
|
}
|
|
|
|
|
2003-11-01 22:34:59 +00:00
|
|
|
const nsStyleDisplay* display = aStyleContext->GetStyleDisplay();
|
1999-11-19 15:33:29 +00:00
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
// Set the view's opacity
|
2003-11-01 22:34:59 +00:00
|
|
|
vm->SetViewOpacity(aView, display->mOpacity);
|
1999-11-19 15:33:29 +00:00
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
// Make sure visibility is correct
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_VISIBILITY)) {
|
1999-11-19 15:33:29 +00:00
|
|
|
// See if the view should be hidden or visible
|
|
|
|
PRBool viewIsVisible = PR_TRUE;
|
|
|
|
|
2004-10-13 15:12:14 +00:00
|
|
|
if (!aStyleContext->GetStyleVisibility()->IsVisible() &&
|
|
|
|
!aFrame->SupportsVisibilityHidden()) {
|
2003-02-23 02:22:14 +00:00
|
|
|
// If it's a scrollable frame that can't hide its scrollbars,
|
|
|
|
// hide the view. This means that child elements can't override
|
|
|
|
// their parent's visibility, but it's not practical to leave it
|
|
|
|
// visible in all cases because the scrollbars will be showing
|
2004-10-13 15:12:14 +00:00
|
|
|
// XXXldb Does the view system really enforce this correctly?
|
2003-03-05 14:26:31 +00:00
|
|
|
viewIsVisible = PR_FALSE;
|
2002-09-30 11:56:37 +00:00
|
|
|
} else {
|
|
|
|
// if the view is for a popup, don't show the view if the popup is closed
|
2003-06-27 18:13:48 +00:00
|
|
|
nsIWidget* widget = aView->GetWidget();
|
2002-09-30 11:56:37 +00:00
|
|
|
if (widget) {
|
|
|
|
nsWindowType windowType;
|
|
|
|
widget->GetWindowType(windowType);
|
|
|
|
if (windowType == eWindowType_popup) {
|
|
|
|
widget->IsVisible(viewIsVisible);
|
|
|
|
}
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
vm->SetViewVisibility(aView, viewIsVisible ? nsViewVisibility_kShow :
|
|
|
|
nsViewVisibility_kHide);
|
|
|
|
}
|
1999-11-19 15:33:29 +00:00
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
// See if the frame is being relatively positioned or absolutely
|
|
|
|
// positioned
|
2005-06-14 23:53:56 +00:00
|
|
|
PRBool isPositioned = display->IsPositioned();
|
2000-04-25 04:43:11 +00:00
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
PRInt32 zIndex = 0;
|
|
|
|
PRBool autoZIndex = PR_FALSE;
|
2002-06-04 04:44:03 +00:00
|
|
|
|
2005-06-14 23:53:56 +00:00
|
|
|
if (!isPositioned) {
|
2002-09-30 11:56:37 +00:00
|
|
|
autoZIndex = PR_TRUE;
|
2005-06-14 23:53:56 +00: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 11:56:37 +00:00
|
|
|
}
|
2000-04-25 04:43:11 +00:00
|
|
|
|
2005-06-14 23:53:56 +00:00
|
|
|
vm->SetViewZIndex(aView, autoZIndex, zIndex, isPositioned);
|
2000-04-25 04:43:11 +00:00
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
2003-10-17 02:38:37 +00:00
|
|
|
nsContainerFrame::FrameNeedsView(nsIFrame* aFrame)
|
2002-09-30 11:56:37 +00:00
|
|
|
{
|
2005-04-03 21:00:41 +00:00
|
|
|
if (aFrame->NeedsView()) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2003-10-17 02:38:37 +00:00
|
|
|
nsStyleContext* sc = aFrame->GetStyleContext();
|
2003-11-01 22:34:59 +00:00
|
|
|
const nsStyleDisplay* display = sc->GetStyleDisplay();
|
|
|
|
if (display->mOpacity != 1.0f) {
|
2002-09-30 11:56:37 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1999-11-19 15:33:29 +00:00
|
|
|
|
2002-09-30 11:56:37 +00:00
|
|
|
// See if the frame has a fixed background attachment
|
|
|
|
const nsStyleBackground *color;
|
|
|
|
PRBool isCanvas;
|
|
|
|
PRBool hasBackground =
|
2003-10-17 02:38:37 +00:00
|
|
|
nsCSSRendering::FindBackground(aFrame->GetPresContext(),
|
|
|
|
aFrame, &color, &isCanvas);
|
2004-09-13 05:39:27 +00:00
|
|
|
if (hasBackground && color->HasFixedBackground()) {
|
2002-09-30 11:56:37 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_STYLE_POSITION_RELATIVE == display->mPosition) {
|
|
|
|
return PR_TRUE;
|
|
|
|
} else if (display->IsAbsolutelyPositioned()) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2003-10-17 02:38:37 +00:00
|
|
|
if (sc->GetPseudoType() == nsCSSAnonBoxes::scrolledContent) {
|
2002-09-30 11:56:37 +00:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2005-03-07 22:12:53 +00:00
|
|
|
// See if the frame is block-level and has 'overflow' set to
|
|
|
|
// '-moz-hidden-unscrollable'. If so, then we need to give it a view
|
|
|
|
// so clipping of any child views works correctly. Note that if it's
|
|
|
|
// floated it is also block-level, but we can't trust that the style
|
|
|
|
// context 'display' value is set correctly.
|
2002-09-30 11:56:37 +00:00
|
|
|
if ((display->IsBlockLevel() || display->IsFloating()) &&
|
2004-09-05 00:04:04 +00:00
|
|
|
(display->mOverflowX == NS_STYLE_OVERFLOW_CLIP)) {
|
2002-09-30 11:56:37 +00:00
|
|
|
// XXX Check for the frame being a block frame and only force a view
|
|
|
|
// in that case, because adding a view for box frames seems to cause
|
|
|
|
// problems for XUL...
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom* frameType = aFrame->GetType();
|
2002-09-30 11:56:37 +00:00
|
|
|
if ((frameType == nsLayoutAtoms::blockFrame) ||
|
|
|
|
(frameType == nsLayoutAtoms::areaFrame)) {
|
|
|
|
return PR_TRUE;
|
2001-12-06 03:16:35 +00:00
|
|
|
}
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
2002-09-30 11:56:37 +00:00
|
|
|
|
|
|
|
return PR_FALSE;
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
/**
|
1999-11-19 15:33:29 +00: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-08 20:35:26 +00:00
|
|
|
* frame is complete, deletes any next-in-flows using DeleteNextInFlowChild()
|
1998-09-30 21:35:29 +00:00
|
|
|
*/
|
1998-10-06 00:27:22 +00:00
|
|
|
nsresult
|
|
|
|
nsContainerFrame::ReflowChild(nsIFrame* aKidFrame,
|
2005-04-28 21:57:22 +00:00
|
|
|
nsPresContext* aPresContext,
|
1998-10-06 00:27:22 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-11-19 15:33:29 +00:00
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
PRUint32 aFlags,
|
1998-10-06 00:27:22 +00:00
|
|
|
nsReflowStatus& aStatus)
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(aReflowState.frame == aKidFrame, "bad reflow state");
|
|
|
|
|
1999-10-30 02:52:11 +00:00
|
|
|
nsresult result;
|
1998-09-30 21:35:29 +00:00
|
|
|
|
1999-03-08 19:25:18 +00:00
|
|
|
#ifdef DEBUG
|
1999-07-14 17:27:48 +00:00
|
|
|
#ifdef REALLY_NOISY_MAX_ELEMENT_SIZE
|
2003-01-09 14:26:32 +00:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = nscoord(0xdeadbeef);
|
1999-03-08 19:25:18 +00:00
|
|
|
}
|
1999-07-14 17:27:48 +00:00
|
|
|
#endif
|
1999-03-08 19:25:18 +00:00
|
|
|
#endif
|
|
|
|
|
1999-11-19 15:33:29 +00:00
|
|
|
// Send the WillReflow() notification, and position the child frame
|
|
|
|
// and its view if requested
|
1999-10-30 02:52:11 +00:00
|
|
|
aKidFrame->WillReflow(aPresContext);
|
1999-11-19 15:33:29 +00:00
|
|
|
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_MOVE_FRAME)) {
|
2003-06-26 11:30:17 +00:00
|
|
|
aKidFrame->SetPosition(nsPoint(aX, aY));
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) {
|
2004-12-27 15:05:18 +00:00
|
|
|
PositionFrameView(aKidFrame);
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Reflow the child frame
|
1999-10-30 02:52:11 +00:00
|
|
|
result = aKidFrame->Reflow(aPresContext, aDesiredSize, aReflowState,
|
|
|
|
aStatus);
|
1998-10-06 00:27:22 +00:00
|
|
|
|
1999-03-08 19:25:18 +00:00
|
|
|
#ifdef DEBUG
|
1999-07-14 17:27:48 +00:00
|
|
|
#ifdef REALLY_NOISY_MAX_ELEMENT_SIZE
|
2003-01-09 14:26:32 +00:00
|
|
|
if (aDesiredSize.mComputeMEW &&
|
|
|
|
(nscoord(0xdeadbeef) == aDesiredSize.mMaxElementWidth)) {
|
2000-10-28 22:17:53 +00:00
|
|
|
printf("nsContainerFrame: ");
|
1999-03-08 19:25:18 +00:00
|
|
|
nsFrame::ListTag(stdout, aKidFrame);
|
2003-01-09 14:26:32 +00:00
|
|
|
printf(" didn't set max-element-width!\n");
|
1999-03-08 19:25:18 +00:00
|
|
|
}
|
1999-07-14 17:27:48 +00:00
|
|
|
#endif
|
1999-03-08 19:25:18 +00:00
|
|
|
#endif
|
|
|
|
|
1998-10-06 00:27:22 +00:00
|
|
|
// If the reflow was successful and the child frame is complete, delete any
|
|
|
|
// next-in-flows
|
|
|
|
if (NS_SUCCEEDED(result) && NS_FRAME_IS_COMPLETE(aStatus)) {
|
2004-09-14 02:28:03 +00:00
|
|
|
nsIFrame* kidNextInFlow = aKidFrame->GetNextInFlow();
|
1998-09-30 21:35:29 +00: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)
|
2003-06-26 11:30:17 +00:00
|
|
|
NS_STATIC_CAST(nsContainerFrame*, kidNextInFlow->GetParent())
|
|
|
|
->DeleteNextInFlowChild(aPresContext, kidNextInFlow);
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
}
|
1998-10-06 00:27:22 +00:00
|
|
|
return result;
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
|
2001-03-12 04:19:10 +00:00
|
|
|
|
2001-09-21 00:53:29 +00: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 15:33:29 +00:00
|
|
|
void
|
2004-12-27 15:05:18 +00:00
|
|
|
nsContainerFrame::PositionChildViews(nsIFrame* aFrame)
|
1999-11-19 15:33:29 +00:00
|
|
|
{
|
2003-06-26 11:30:17 +00:00
|
|
|
if (!(aFrame->GetStateBits() & NS_FRAME_HAS_CHILD_WITH_VIEW)) {
|
2001-03-12 04:19:10 +00:00
|
|
|
return;
|
|
|
|
}
|
1999-11-19 15:33:29 +00:00
|
|
|
|
2001-03-30 05:25:49 +00:00
|
|
|
nsIAtom* childListName = nsnull;
|
|
|
|
PRInt32 childListIndex = 0;
|
|
|
|
|
|
|
|
do {
|
|
|
|
// Recursively walk aFrame's child frames
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame* childFrame = aFrame->GetFirstChild(childListName);
|
2001-03-30 05:25:49 +00:00
|
|
|
while (childFrame) {
|
2004-01-10 05:36:32 +00:00
|
|
|
// Position the frame's view (if it has one) otherwise recursively
|
2001-09-21 00:53:29 +00:00
|
|
|
// process its children
|
2004-01-10 05:36:32 +00:00
|
|
|
if (childFrame->HasView()) {
|
2004-12-27 15:05:18 +00:00
|
|
|
PositionFrameView(childFrame);
|
2004-01-10 05:36:32 +00:00
|
|
|
} else {
|
2004-12-27 15:05:18 +00:00
|
|
|
PositionChildViews(childFrame);
|
2004-01-10 05:36:32 +00:00
|
|
|
}
|
2001-03-30 05:25:49 +00:00
|
|
|
|
|
|
|
// Get the next sibling child frame
|
2003-06-26 11:30:17 +00:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
2001-03-30 05:25:49 +00:00
|
|
|
|
2004-01-09 14:20:53 +00:00
|
|
|
childListName = aFrame->GetAdditionalChildListName(childListIndex++);
|
|
|
|
} while (childListName);
|
1999-11-19 15:33:29 +00: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-05 20:27:19 +00:00
|
|
|
*/
|
1999-11-19 15:33:29 +00:00
|
|
|
nsresult
|
2001-12-07 14:51:12 +00:00
|
|
|
nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
|
2005-04-28 21:57:22 +00:00
|
|
|
nsPresContext* aPresContext,
|
2001-12-07 14:51:12 +00:00
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
PRUint32 aFlags)
|
1999-11-19 15:33:29 +00:00
|
|
|
{
|
2003-06-26 11:30:17 +00:00
|
|
|
nsPoint curOrigin = aKidFrame->GetPosition();
|
1999-11-19 15:33:29 +00:00
|
|
|
nsRect bounds(aX, aY, aDesiredSize.width, aDesiredSize.height);
|
|
|
|
|
2003-06-26 11:30:17 +00:00
|
|
|
aKidFrame->SetRect(bounds);
|
1999-11-19 15:33:29 +00:00
|
|
|
|
2003-06-19 23:44:01 +00:00
|
|
|
if (aKidFrame->HasView()) {
|
2003-06-26 11:30:17 +00:00
|
|
|
nsIView* view = aKidFrame->GetView();
|
1999-11-19 15:33:29 +00:00
|
|
|
// Make sure the frame's view is properly sized and positioned and has
|
|
|
|
// things like opacity correct
|
1999-11-24 06:03:41 +00:00
|
|
|
SyncFrameViewAfterReflow(aPresContext, aKidFrame, view,
|
1999-12-06 15:49:53 +00:00
|
|
|
&aDesiredSize.mOverflowArea,
|
1999-11-19 15:33:29 +00:00
|
|
|
aFlags);
|
2001-09-05 20:27:19 +00:00
|
|
|
}
|
2004-02-22 03:31:30 +00: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 15:05:18 +00:00
|
|
|
PositionChildViews(aKidFrame);
|
2004-02-22 03:31:30 +00:00
|
|
|
}
|
|
|
|
|
2004-03-10 03:09:05 +00: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 03:31:30 +00:00
|
|
|
aKidFrame->Invalidate(aDesiredSize.mOverflowArea);
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
2001-12-07 14:51:12 +00:00
|
|
|
return aKidFrame->DidReflow(aPresContext, aReflowState, NS_FRAME_REFLOW_FINISHED);
|
1999-11-19 15:33:29 +00:00
|
|
|
}
|
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
/**
|
2002-10-08 20:35:26 +00:00
|
|
|
* Remove and delete aNextInFlow and its next-in-flows. Updates the sibling and flow
|
1998-09-30 21:35:29 +00:00
|
|
|
* pointers
|
|
|
|
*/
|
1999-01-15 22:53:39 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::DeleteNextInFlowChild(nsPresContext* aPresContext,
|
2002-10-08 20:35:26 +00:00
|
|
|
nsIFrame* aNextInFlow)
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
2004-09-14 02:28:03 +00:00
|
|
|
nsIFrame* prevInFlow = aNextInFlow->GetPrevInFlow();
|
2002-10-08 20:35:26 +00:00
|
|
|
NS_PRECONDITION(prevInFlow, "bad prev-in-flow");
|
|
|
|
NS_PRECONDITION(mFrames.ContainsFrame(aNextInFlow), "bad geometric parent");
|
1998-09-30 21:35:29 +00:00
|
|
|
|
|
|
|
// If the next-in-flow has a next-in-flow then delete it, too (and
|
|
|
|
// delete it first).
|
2005-09-06 01:26:50 +00:00
|
|
|
// Do this in a loop so we don't overflow the stack for frames
|
|
|
|
// with very many next-in-flows
|
2004-09-14 02:28:03 +00:00
|
|
|
nsIFrame* nextNextInFlow = aNextInFlow->GetNextInFlow();
|
2002-10-08 20:35:26 +00:00
|
|
|
if (nextNextInFlow) {
|
2005-09-06 01:26:50 +00:00
|
|
|
nsAutoVoidArray frames;
|
|
|
|
for (nsIFrame* f = nextNextInFlow; f; f = f->GetNextInFlow()) {
|
|
|
|
frames.AppendElement(f);
|
|
|
|
}
|
|
|
|
for (PRInt32 i = frames.Count() - 1; i >= 0; --i) {
|
|
|
|
nsIFrame* delFrame = NS_STATIC_CAST(nsIFrame*, frames.ElementAt(i));
|
|
|
|
NS_STATIC_CAST(nsContainerFrame*, delFrame->GetParent())
|
|
|
|
->DeleteNextInFlowChild(aPresContext, delFrame);
|
|
|
|
}
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
|
2001-03-09 03:29:00 +00:00
|
|
|
#ifdef IBMBIDI
|
2004-06-01 06:20:16 +00:00
|
|
|
if ((prevInFlow->GetStateBits() & NS_FRAME_IS_BIDI) &&
|
|
|
|
(NS_STATIC_CAST(nsIFrame*,
|
2004-08-24 18:50:29 +00:00
|
|
|
aPresContext->PropertyTable()->GetProperty(prevInFlow, nsLayoutAtoms::nextBidi)) ==
|
2004-06-01 06:20:16 +00:00
|
|
|
aNextInFlow)) {
|
2001-03-09 03:29:00 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
// Disconnect the next-in-flow from the flow list
|
2002-10-08 20:35:26 +00:00
|
|
|
nsSplittableFrame::BreakFromPrevFlow(aNextInFlow);
|
1998-09-30 21:35:29 +00:00
|
|
|
|
|
|
|
// Take the next-in-flow out of the parent's child list
|
2002-10-08 20:35:26 +00:00
|
|
|
PRBool result = mFrames.RemoveFrame(aNextInFlow);
|
2000-03-20 23:11:39 +00:00
|
|
|
if (!result) {
|
|
|
|
// We didn't find the child in the parent's principal child list.
|
|
|
|
// Maybe it's on the overflow list?
|
2002-10-08 20:35:26 +00:00
|
|
|
nsFrameList overflowFrames(GetOverflowFrames(aPresContext, PR_TRUE));
|
2000-03-20 23:11:39 +00:00
|
|
|
|
2002-10-08 20:35:26 +00:00
|
|
|
if (overflowFrames.IsEmpty() || !overflowFrames.RemoveFrame(aNextInFlow)) {
|
2000-03-20 23:11:39 +00:00
|
|
|
NS_ASSERTION(result, "failed to remove frame");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the overflow property again
|
|
|
|
if (overflowFrames.NotEmpty()) {
|
2002-10-08 20:35:26 +00:00
|
|
|
SetOverflowFrames(aPresContext, overflowFrames.FirstChild());
|
2000-03-20 23:11:39 +00:00
|
|
|
}
|
|
|
|
}
|
1998-09-30 21:35:29 +00:00
|
|
|
|
2002-10-30 15:33:36 +00:00
|
|
|
// Delete the next-in-flow frame and its descendants.
|
2002-10-08 20:35:26 +00:00
|
|
|
aNextInFlow->Destroy(aPresContext);
|
1998-09-30 21:35:29 +00:00
|
|
|
|
2004-09-14 02:28:03 +00:00
|
|
|
NS_POSTCONDITION(!prevInFlow->GetNextInFlow(), "non null next-in-flow");
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
|
1999-10-21 05:11:43 +00:00
|
|
|
nsIFrame*
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::GetOverflowFrames(nsPresContext* aPresContext,
|
2000-01-22 01:16:50 +00:00
|
|
|
PRBool aRemoveProperty) const
|
1999-10-21 05:11:43 +00:00
|
|
|
{
|
2004-08-24 18:50:29 +00:00
|
|
|
nsPropertyTable *propTable = aPresContext->PropertyTable();
|
2004-02-23 21:29:06 +00:00
|
|
|
if (aRemoveProperty) {
|
2004-08-24 18:50:29 +00:00
|
|
|
return (nsIFrame*) propTable->UnsetProperty(this,
|
|
|
|
nsLayoutAtoms::overflowProperty);
|
1999-10-21 05:11:43 +00:00
|
|
|
}
|
|
|
|
|
2004-08-24 18:50:29 +00:00
|
|
|
return (nsIFrame*) propTable->GetProperty(this,
|
|
|
|
nsLayoutAtoms::overflowProperty);
|
1999-10-21 05:11:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Destructor function for the overflow frame property
|
|
|
|
static void
|
2004-08-24 18:50:29 +00:00
|
|
|
DestroyOverflowFrames(void* aFrame,
|
1999-10-21 05:11:43 +00:00
|
|
|
nsIAtom* aPropertyName,
|
2004-08-24 18:50:29 +00:00
|
|
|
void* aPropertyValue,
|
|
|
|
void* aDtorData)
|
1999-10-21 05:11:43 +00:00
|
|
|
{
|
|
|
|
if (aPropertyValue) {
|
|
|
|
nsFrameList frames((nsIFrame*)aPropertyValue);
|
|
|
|
|
2004-08-24 18:50:29 +00:00
|
|
|
frames.DestroyFrames(NS_STATIC_CAST(nsPresContext*, aDtorData));
|
1999-10-21 05:11:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::SetOverflowFrames(nsPresContext* aPresContext,
|
1999-10-21 05:11:43 +00:00
|
|
|
nsIFrame* aOverflowFrames)
|
|
|
|
{
|
2004-08-24 18:50:29 +00:00
|
|
|
nsresult rv =
|
|
|
|
aPresContext->PropertyTable()->SetProperty(this,
|
|
|
|
nsLayoutAtoms::overflowProperty,
|
|
|
|
aOverflowFrames,
|
|
|
|
DestroyOverflowFrames,
|
|
|
|
aPresContext);
|
1999-10-21 05:11:43 +00:00
|
|
|
|
2004-02-23 21:29:06 +00:00
|
|
|
// Verify that we didn't overwrite an existing overflow list
|
2004-08-24 18:50:29 +00:00
|
|
|
NS_ASSERTION(rv != NS_PROPTABLE_PROP_OVERWRITTEN, "existing overflow list");
|
1999-10-21 05:11:43 +00:00
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-09-30 21:35:29 +00: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-15 22:53:39 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::PushChildren(nsPresContext* aPresContext,
|
1999-10-21 05:11:43 +00:00
|
|
|
nsIFrame* aFromChild,
|
|
|
|
nsIFrame* aPrevSibling)
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(nsnull != aPrevSibling, "pushing first child");
|
2003-06-26 11:30:17 +00:00
|
|
|
NS_PRECONDITION(aPrevSibling->GetNextSibling() == aFromChild, "bad prev sibling");
|
1998-09-30 21:35:29 +00:00
|
|
|
|
|
|
|
// Disconnect aFromChild from its previous sibling
|
|
|
|
aPrevSibling->SetNextSibling(nsnull);
|
|
|
|
|
1999-01-15 22:53:39 +00:00
|
|
|
if (nsnull != mNextInFlow) {
|
1999-02-01 17:29:58 +00: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-01-15 22:53:39 +00:00
|
|
|
nsContainerFrame* nextInFlow = (nsContainerFrame*)mNextInFlow;
|
1999-04-13 00:15:13 +00:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
2003-06-26 11:30:17 +00:00
|
|
|
for (nsIFrame* f = aFromChild; f; f = f->GetNextSibling()) {
|
1999-10-26 04:44:41 +00:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, this, mNextInFlow);
|
1999-04-13 00:15:13 +00:00
|
|
|
}
|
1999-01-15 22:53:39 +00:00
|
|
|
nextInFlow->mFrames.InsertFrames(mNextInFlow, nsnull, aFromChild);
|
|
|
|
}
|
|
|
|
else {
|
1998-09-30 21:35:29 +00:00
|
|
|
// Add the frames to our overflow list
|
1999-10-21 05:11:43 +00:00
|
|
|
SetOverflowFrames(aPresContext, aFromChild);
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2003-01-07 23:16:05 +00:00
|
|
|
* Moves any frames on the overflow lists (the prev-in-flow's overflow list and
|
1998-09-30 21:35:29 +00: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-15 22:53:39 +00:00
|
|
|
PRBool
|
2004-07-31 23:15:21 +00:00
|
|
|
nsContainerFrame::MoveOverflowToChildList(nsPresContext* aPresContext)
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
1999-01-15 22:53:39 +00:00
|
|
|
PRBool result = PR_FALSE;
|
1998-09-30 21:35:29 +00:00
|
|
|
|
|
|
|
// Check for an overflow list with our prev-in-flow
|
|
|
|
nsContainerFrame* prevInFlow = (nsContainerFrame*)mPrevInFlow;
|
|
|
|
if (nsnull != prevInFlow) {
|
1999-10-21 05:11:43 +00:00
|
|
|
nsIFrame* prevOverflowFrames = prevInFlow->GetOverflowFrames(aPresContext,
|
|
|
|
PR_TRUE);
|
|
|
|
if (prevOverflowFrames) {
|
1999-01-15 22:53:39 +00:00
|
|
|
NS_ASSERTION(mFrames.IsEmpty(), "bad overflow list");
|
1999-04-13 00:15:13 +00:00
|
|
|
// When pushing and pulling frames we need to check for whether any
|
|
|
|
// views need to be reparented.
|
2003-06-26 11:30:17 +00:00
|
|
|
for (nsIFrame* f = prevOverflowFrames; f; f = f->GetNextSibling()) {
|
1999-10-26 04:44:41 +00:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, prevInFlow, this);
|
1999-04-13 00:15:13 +00:00
|
|
|
}
|
1999-10-21 05:11:43 +00:00
|
|
|
mFrames.InsertFrames(this, nsnull, prevOverflowFrames);
|
1998-09-30 21:35:29 +00:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
1999-10-21 05:11:43 +00:00
|
|
|
nsIFrame* overflowFrames = GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (overflowFrames) {
|
1999-01-15 22:53:39 +00:00
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
1999-10-21 05:11:43 +00:00
|
|
|
mFrames.AppendFrames(nsnull, overflowFrames);
|
1998-09-30 21:35:29 +00:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Debugging
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef NS_DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2005-09-06 21:34:50 +00:00
|
|
|
nsContainerFrame::List(FILE* out, PRInt32 aIndent) const
|
1998-09-30 21:35:29 +00:00
|
|
|
{
|
1999-01-16 00:00:50 +00:00
|
|
|
IndentBy(out, aIndent);
|
|
|
|
ListTag(out);
|
2000-07-27 05:16:08 +00:00
|
|
|
#ifdef DEBUG_waterson
|
2001-10-25 01:08:40 +00:00
|
|
|
fprintf(out, " [parent=%p]", NS_STATIC_CAST(void*, mParent));
|
2000-07-27 05:16:08 +00:00
|
|
|
#endif
|
2003-06-19 23:44:01 +00:00
|
|
|
if (HasView()) {
|
2003-06-26 11:30:17 +00:00
|
|
|
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, GetView()));
|
1999-01-16 00:00:50 +00:00
|
|
|
}
|
1999-04-27 22:11:21 +00:00
|
|
|
if (nsnull != mNextSibling) {
|
2001-10-25 01:08:40 +00:00
|
|
|
fprintf(out, " next=%p", NS_STATIC_CAST(void*, mNextSibling));
|
1999-04-27 22:11:21 +00:00
|
|
|
}
|
1999-01-16 00:00:50 +00:00
|
|
|
if (nsnull != mPrevInFlow) {
|
2001-10-25 01:08:40 +00:00
|
|
|
fprintf(out, " prev-in-flow=%p", NS_STATIC_CAST(void*, mPrevInFlow));
|
1999-01-16 00:00:50 +00:00
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
2001-10-25 01:08:40 +00:00
|
|
|
fprintf(out, " next-in-flow=%p", NS_STATIC_CAST(void*, mNextInFlow));
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
1999-03-05 04:22:54 +00:00
|
|
|
fprintf(out, " {%d,%d,%d,%d}", mRect.x, mRect.y, mRect.width, mRect.height);
|
1999-01-16 00:19:10 +00:00
|
|
|
if (0 != mState) {
|
|
|
|
fprintf(out, " [state=%08x]", mState);
|
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
fprintf(out, " [content=%p]", NS_STATIC_CAST(void*, mContent));
|
2004-08-26 00:07:56 +00:00
|
|
|
nsContainerFrame* f = NS_CONST_CAST(nsContainerFrame*, this);
|
|
|
|
nsRect* overflowArea = f->GetOverflowAreaProperty(PR_FALSE);
|
|
|
|
if (overflowArea) {
|
|
|
|
fprintf(out, " [overflow=%d,%d,%d,%d]", overflowArea->x, overflowArea->y,
|
|
|
|
overflowArea->width, overflowArea->height);
|
|
|
|
}
|
2001-10-25 01:08:40 +00:00
|
|
|
fprintf(out, " [sc=%p]", NS_STATIC_CAST(void*, mStyleContext));
|
2004-11-11 17:48:09 +00:00
|
|
|
nsIAtom* pseudoTag = mStyleContext->GetPseudoType();
|
|
|
|
if (pseudoTag) {
|
|
|
|
nsAutoString atomString;
|
|
|
|
pseudoTag->ToString(atomString);
|
|
|
|
fprintf(out, " pst=%s",
|
|
|
|
NS_LossyConvertUCS2toASCII(atomString).get());
|
|
|
|
}
|
1999-01-16 00:19:10 +00:00
|
|
|
|
1998-09-30 21:35:29 +00:00
|
|
|
// Output the children
|
1999-01-16 00:19:10 +00:00
|
|
|
nsIAtom* listName = nsnull;
|
|
|
|
PRInt32 listIndex = 0;
|
|
|
|
PRBool outputOneList = PR_FALSE;
|
|
|
|
do {
|
2004-01-09 14:20:53 +00:00
|
|
|
nsIFrame* kid = GetFirstChild(listName);
|
1999-01-16 00:19:10 +00:00
|
|
|
if (nsnull != kid) {
|
1999-02-01 17:29:58 +00:00
|
|
|
if (outputOneList) {
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
}
|
1999-01-16 00:19:10 +00:00
|
|
|
outputOneList = PR_TRUE;
|
|
|
|
nsAutoString tmp;
|
|
|
|
if (nsnull != listName) {
|
|
|
|
listName->ToString(tmp);
|
2001-10-16 03:53:44 +00:00
|
|
|
fputs(NS_LossyConvertUCS2toASCII(tmp).get(), out);
|
1999-01-16 00:19:10 +00:00
|
|
|
}
|
|
|
|
fputs("<\n", out);
|
|
|
|
while (nsnull != kid) {
|
2000-01-22 01:16:50 +00:00
|
|
|
// Verify the child frame's parent frame pointer is correct
|
2003-06-26 16:44:48 +00:00
|
|
|
NS_ASSERTION(kid->GetParent() == (nsIFrame*)this, "bad parent frame pointer");
|
1999-11-01 22:12:45 +00:00
|
|
|
|
2000-01-22 01:16:50 +00:00
|
|
|
// Have the child frame list
|
|
|
|
nsIFrameDebug* frameDebug;
|
2000-02-02 22:24:56 +00:00
|
|
|
if (NS_SUCCEEDED(kid->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) {
|
2005-09-06 21:34:50 +00:00
|
|
|
frameDebug->List(out, aIndent + 1);
|
1999-11-01 22:12:45 +00:00
|
|
|
}
|
2003-06-26 11:30:17 +00:00
|
|
|
kid = kid->GetNextSibling();
|
1999-01-16 00:19:10 +00:00
|
|
|
}
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fputs(">\n", out);
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
2004-01-09 14:20:53 +00:00
|
|
|
listName = GetAdditionalChildListName(listIndex++);
|
1999-01-16 00:19:10 +00:00
|
|
|
} while(nsnull != listName);
|
|
|
|
|
|
|
|
if (!outputOneList) {
|
1999-01-16 00:00:50 +00:00
|
|
|
fputs("<>\n", out);
|
1998-09-30 21:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|