2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
1998-10-01 01:35:29 +04:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The contents of this file are subject to the Netscape 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/NPL/
|
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.
|
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* 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>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the NPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-10-01 01:35:29 +04:00
|
|
|
#include "nsContainerFrame.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#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"
|
2001-09-21 04:53:29 +04:00
|
|
|
#include "nsIScrollableView.h"
|
1998-10-01 01:35:29 +04:00
|
|
|
#include "nsVoidArray.h"
|
2001-12-18 01:39:59 +03:00
|
|
|
#include "nsHTMLReflowCommand.h"
|
1999-04-13 04:15:13 +04:00
|
|
|
#include "nsHTMLContainerFrame.h"
|
1999-10-21 09:11:43 +04:00
|
|
|
#include "nsIFrameManager.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsLayoutAtoms.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"
|
2001-12-01 17:31:45 +03:00
|
|
|
|
|
|
|
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
|
1998-10-01 01:35:29 +04:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
#undef NOISY
|
|
|
|
#else
|
|
|
|
#undef NOISY
|
|
|
|
#endif
|
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
nsContainerFrame::nsContainerFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsContainerFrame::~nsContainerFrame()
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-04-17 10:43:01 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContainerFrame::Init(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2001-04-17 10:43:01 +04: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.
|
|
|
|
nsFrameState state;
|
|
|
|
aPrevInFlow->GetFrameState(&state);
|
|
|
|
if (state & NS_FRAME_HAS_CHILD_WITH_VIEW)
|
|
|
|
mState |= NS_FRAME_HAS_CHILD_WITH_VIEW;
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsContainerFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
1998-11-10 09:05:32 +03:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
1999-01-16 01:53:39 +03:00
|
|
|
nsresult result;
|
1999-07-25 01:41:15 +04:00
|
|
|
if (!mFrames.IsEmpty()) {
|
|
|
|
// We already have child frames which means we've already been
|
|
|
|
// initialized
|
2003-01-17 00:05:09 +03:00
|
|
|
#ifdef DEBUG_dbaron_off // XXX Fix asserts and remove this ifdef.
|
2002-06-12 07:27:48 +04:00
|
|
|
NS_NOTREACHED("unexpected second call to SetInitialChildList");
|
|
|
|
#endif
|
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
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsContainerFrame::Destroy(nsIPresContext* aPresContext)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
1998-11-14 22:25:34 +03:00
|
|
|
// Prevent event dispatch during destruction
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIView* view;
|
1999-11-24 09:03:41 +03:00
|
|
|
GetView(aPresContext, &view);
|
1998-10-31 02:38:03 +03:00
|
|
|
if (nsnull != view) {
|
|
|
|
view->SetClientData(nsnull);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
1998-11-14 22:25:34 +03:00
|
|
|
// Delete the primary child list
|
1999-07-22 08:00:57 +04:00
|
|
|
mFrames.DestroyFrames(aPresContext);
|
1998-11-14 22:25:34 +03:00
|
|
|
|
2002-10-30 18:33:36 +03:00
|
|
|
// Destroy the frame and remove the flow pointers
|
|
|
|
return nsSplittableFrame::Destroy(aPresContext);
|
1998-11-14 22:25:34 +03:00
|
|
|
}
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Child frame enumeration
|
|
|
|
|
1998-11-14 22:25:34 +03:00
|
|
|
NS_IMETHODIMP
|
2000-01-22 04:16:50 +03:00
|
|
|
nsContainerFrame::FirstChild(nsIPresContext* aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame** aFirstChild) const
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
1999-02-10 05:25:01 +03:00
|
|
|
NS_PRECONDITION(nsnull != aFirstChild, "null OUT parameter pointer");
|
2000-01-22 04:16:50 +03:00
|
|
|
// We only know about the unnamed principal child list and the overflow
|
|
|
|
// list
|
1998-11-09 22:40:27 +03:00
|
|
|
if (nsnull == aListName) {
|
1999-02-10 05:25:01 +03:00
|
|
|
*aFirstChild = mFrames.FirstChild();
|
1998-11-09 22:40:27 +03:00
|
|
|
return NS_OK;
|
2000-01-22 04:16:50 +03:00
|
|
|
} else if (nsLayoutAtoms::overflowList == aListName) {
|
|
|
|
*aFirstChild = GetOverflowFrames(aPresContext, PR_FALSE);
|
|
|
|
return NS_OK;
|
1998-11-09 22:40:27 +03:00
|
|
|
} else {
|
1999-02-10 05:25:01 +03:00
|
|
|
*aFirstChild = nsnull;
|
1998-11-09 22:40:27 +03:00
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
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
|
1999-11-24 09:03:41 +03:00
|
|
|
nsContainerFrame::Paint(nsIPresContext* aPresContext,
|
1998-10-31 01:11:06 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
2001-09-19 16:35:19 +04:00
|
|
|
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer, aFlags);
|
1998-10-01 01:35:29 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-10-31 01:11:06 +03: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
|
1999-11-24 09:03:41 +03:00
|
|
|
nsContainerFrame::PaintChildren(nsIPresContext* aPresContext,
|
1998-10-31 01:11:06 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
1998-12-18 18:54:23 +03:00
|
|
|
const nsRect& aDirtyRect,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
1999-01-16 01:53:39 +03:00
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
1998-11-19 06:52:29 +03:00
|
|
|
while (nsnull != kid) {
|
2001-09-19 16:35:19 +04:00
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid, aWhichLayer, aFlags);
|
1999-02-10 09:13:38 +03:00
|
|
|
kid->GetNextSibling(&kid);
|
1998-11-19 06:52:29 +03:00
|
|
|
}
|
1998-10-31 01:11:06 +03:00
|
|
|
}
|
1998-10-07 01:00:58 +04:00
|
|
|
|
1998-10-31 01:11:06 +03:00
|
|
|
// Paint one child frame
|
|
|
|
void
|
1999-11-24 09:03:41 +03:00
|
|
|
nsContainerFrame::PaintChild(nsIPresContext* aPresContext,
|
1998-10-31 01:11:06 +03:00
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
1998-12-18 18:54:23 +03:00
|
|
|
nsIFrame* aFrame,
|
2001-09-19 16:35:19 +04:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-10-31 01:11:06 +03:00
|
|
|
{
|
2002-02-28 07:54:50 +03:00
|
|
|
NS_ASSERTION(aFrame, "no frame to paint!");
|
|
|
|
if (!aFrame) return;
|
1998-10-31 01:11:06 +03:00
|
|
|
nsIView *pView;
|
1999-11-24 09:03:41 +03:00
|
|
|
aFrame->GetView(aPresContext, &pView);
|
2002-02-28 07:54:50 +03:00
|
|
|
if (!pView) {
|
1998-10-31 01:11:06 +03:00
|
|
|
nsRect kidRect;
|
|
|
|
aFrame->GetRect(kidRect);
|
|
|
|
nsFrameState state;
|
1999-02-10 07:17:06 +03:00
|
|
|
aFrame->GetFrameState(&state);
|
1998-10-01 01:35:29 +04:00
|
|
|
|
1998-10-31 01:11:06 +03: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;
|
|
|
|
if (NS_FRAME_OUTSIDE_CHILDREN & state) {
|
|
|
|
// 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-10 02:58:25 +04:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
if (!overlap && (0 == kidRect.width) && (0 == kidRect.height)) {
|
|
|
|
overlap = PR_TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
1998-10-31 01:11:06 +03: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-18 03:35:15 +04:00
|
|
|
|
|
|
|
|
|
|
|
// The transform components are saved and restored instead
|
|
|
|
// of using PushState and PopState because they are too slow
|
|
|
|
// because they also save and restore the clip state.
|
|
|
|
// Note: Setting a negative translation to restore the
|
|
|
|
// state does not work because the floating point errors can accumulate
|
|
|
|
// causing the display of some frames to be off by one pixel.
|
|
|
|
// This happens frequently when running in 120DPI mode where frames are
|
|
|
|
// often positioned at 1/2 pixel locations and small floating point errors
|
|
|
|
// will cause the frames to vary their pixel x location during scrolling
|
|
|
|
// operations causes a single scan line of pixels to be shifted left relative
|
|
|
|
// to the other scan lines for the same text.
|
|
|
|
|
|
|
|
// Save the transformation matrix's translation components.
|
|
|
|
float xMatrix;
|
|
|
|
float yMatrix;
|
|
|
|
nsTransform2D *theTransform;
|
|
|
|
aRenderingContext.GetCurrentTransform(theTransform);
|
|
|
|
NS_ASSERTION(theTransform != nsnull, "The rendering context transform is null");
|
|
|
|
theTransform->GetTranslation(&xMatrix, &yMatrix);
|
|
|
|
|
1998-10-31 01:11:06 +03:00
|
|
|
aRenderingContext.Translate(kidRect.x, kidRect.y);
|
|
|
|
|
|
|
|
// Paint the kid
|
2001-09-19 16:35:19 +04:00
|
|
|
aFrame->Paint(aPresContext, aRenderingContext, damageArea, aWhichLayer, aFlags);
|
2002-06-18 03:35:15 +04:00
|
|
|
|
|
|
|
// Restore the transformation matrix's translation components.
|
|
|
|
theTransform->SetTranslation(xMatrix, yMatrix);
|
1998-10-31 01:11:06 +03:00
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
#ifdef NS_DEBUG
|
1998-10-31 01:11:06 +03:00
|
|
|
// Draw a border around the child
|
1999-11-02 01:12:45 +03:00
|
|
|
if (nsIFrameDebug::GetShowFrameBorders() && !kidRect.IsEmpty()) {
|
1998-10-31 01:11:06 +03:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(kidRect);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
1998-10-31 01:11:06 +03:00
|
|
|
#endif
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-18 08:25:26 +03:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsContainerFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
1998-11-18 08:25:26 +03:00
|
|
|
nsIFrame** aFrame)
|
1998-11-19 21:09:03 +03:00
|
|
|
{
|
2000-03-22 05:43:08 +03:00
|
|
|
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_FOREGROUND), aFrame);
|
1998-11-19 21:09:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
1999-10-26 08:44:41 +04:00
|
|
|
nsContainerFrame::GetFrameForPointUsing(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
1998-11-19 21:09:03 +03:00
|
|
|
nsIAtom* aList,
|
2000-03-22 05:43:08 +03:00
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRBool aConsiderSelf,
|
1998-11-19 21:09:03 +03:00
|
|
|
nsIFrame** aFrame)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
2000-03-22 05:43:08 +03:00
|
|
|
nsIFrame *kid, *hit;
|
1998-11-18 08:25:26 +03:00
|
|
|
nsPoint tmp;
|
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
PRBool inThisFrame = mRect.Contains(aPoint);
|
|
|
|
|
|
|
|
if (! ((mState & NS_FRAME_OUTSIDE_CHILDREN) || inThisFrame ) ) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
1999-11-24 01:05:05 +03:00
|
|
|
|
2000-01-22 04:16:50 +03:00
|
|
|
FirstChild(aPresContext, aList, &kid);
|
2000-03-22 05:43:08 +03:00
|
|
|
*aFrame = nsnull;
|
|
|
|
tmp.MoveTo(aPoint.x - mRect.x, aPoint.y - mRect.y);
|
2002-02-08 01:39:15 +03:00
|
|
|
|
|
|
|
nsPoint originOffset;
|
|
|
|
nsIView *view = nsnull;
|
|
|
|
nsresult rv = GetOriginToViewOffset(aPresContext, originOffset, &view);
|
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && view)
|
|
|
|
tmp += originOffset;
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
while (nsnull != kid) {
|
2002-02-08 01:39:15 +03:00
|
|
|
rv = kid->GetFrameForPoint(aPresContext, tmp, aWhichLayer, &hit);
|
2000-03-22 05:43:08 +03:00
|
|
|
|
|
|
|
if (NS_SUCCEEDED(rv) && hit) {
|
|
|
|
*aFrame = hit;
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
kid->GetNextSibling(&kid);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
if (*aFrame) {
|
|
|
|
return NS_OK;
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
1999-11-24 01:05:05 +03:00
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
if ( inThisFrame && aConsiderSelf ) {
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleVisibility* vis =
|
|
|
|
(const nsStyleVisibility*)mStyleContext->GetStyleData(eStyleStruct_Visibility);
|
|
|
|
if (vis->IsVisible()) {
|
2000-03-22 05:43:08 +03:00
|
|
|
*aFrame = this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-11-24 01:05:05 +03:00
|
|
|
}
|
|
|
|
|
1999-05-07 04:08:02 +04:00
|
|
|
return NS_ERROR_FAILURE;
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
1999-07-22 08:32:31 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsContainerFrame::ReplaceFrame(nsIPresContext* aPresContext,
|
1999-07-22 08:32:31 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame,
|
|
|
|
nsIFrame* aNewFrame)
|
|
|
|
{
|
|
|
|
nsIFrame* prevFrame;
|
|
|
|
nsIFrame* firstChild;
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// Get the old frame's previous sibling frame
|
2000-01-22 04:16:50 +03:00
|
|
|
FirstChild(aPresContext, aListName, &firstChild);
|
1999-07-22 08:32:31 +04:00
|
|
|
nsFrameList frames(firstChild);
|
|
|
|
NS_ASSERTION(frames.ContainsFrame(aOldFrame), "frame is not a valid child frame");
|
|
|
|
prevFrame = frames.GetPrevSiblingFor(aOldFrame);
|
|
|
|
|
|
|
|
// Default implementation treats it like two separate operations
|
|
|
|
rv = RemoveFrame(aPresContext, aPresShell, aListName, aOldFrame);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = InsertFrames(aPresContext, aPresShell, aListName, prevFrame, aNewFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-01-12 11:28:24 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsContainerFrame::ReflowDirtyChild(nsIPresShell* aPresShell, nsIFrame* aChild)
|
|
|
|
{
|
2000-01-13 00:52:58 +03:00
|
|
|
// The container frame always generates a reflow command
|
|
|
|
// targeted at its child
|
2001-04-18 03:12:36 +04: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-13 00:52:58 +03:00
|
|
|
|
2001-04-18 03:12:36 +04:00
|
|
|
nsFrame::CreateAndPostReflowCommand(aPresShell, aChild,
|
2001-12-18 01:39:59 +03:00
|
|
|
eReflowType_ReflowDirty, nsnull, nsnull, nsnull);
|
2000-01-12 11:28:24 +03:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Helper member functions
|
|
|
|
|
1999-11-20 09:03:16 +03:00
|
|
|
static PRBool
|
|
|
|
TranslatePointTo(nsPoint& aPoint, nsIView* aChildView, nsIView* aParentView)
|
|
|
|
{
|
|
|
|
do {
|
2002-01-27 10:56:23 +03:00
|
|
|
nscoord x, y;
|
1999-11-20 09:03:16 +03:00
|
|
|
|
2002-01-27 10:56:23 +03:00
|
|
|
aChildView->GetPosition(&x, &y);
|
|
|
|
aPoint.x += x;
|
|
|
|
aPoint.y += y;
|
1999-11-20 09:03:16 +03:00
|
|
|
aChildView->GetParent(aChildView);
|
|
|
|
} while (aChildView && (aChildView != aParentView));
|
|
|
|
|
|
|
|
return aChildView == aParentView;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
nsContainerFrame::PositionFrameView(nsIPresContext* aPresContext,
|
2001-09-06 00:27:19 +04:00
|
|
|
nsIFrame* aKidFrame)
|
1999-11-19 18:33:29 +03:00
|
|
|
{
|
2001-09-06 00:27:19 +04:00
|
|
|
nsIView* view;
|
|
|
|
aKidFrame->GetView(aPresContext, &view);
|
|
|
|
if (view) {
|
1999-11-19 18:33:29 +03:00
|
|
|
// Position view relative to its parent, not relative to aKidFrame's
|
|
|
|
// frame which may not have a view
|
1999-11-20 09:03:16 +03:00
|
|
|
nsIView* parentView;
|
2001-09-06 00:27:19 +04:00
|
|
|
view->GetParent(parentView);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2001-09-06 00:27:19 +04:00
|
|
|
nsIView* containingView;
|
|
|
|
nsPoint origin;
|
1999-11-19 18:33:29 +03:00
|
|
|
aKidFrame->GetOffsetFromView(aPresContext, origin, &containingView);
|
1999-11-20 09:03:16 +03:00
|
|
|
|
2001-09-06 00:27:19 +04:00
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
view->GetViewManager(*getter_AddRefs(vm));
|
|
|
|
|
2002-02-20 00:33:26 +03:00
|
|
|
// it's possible for the parentView to be nonnull but containingView to be
|
|
|
|
// null, when the parent view doesn't belong to this frame tree but to
|
|
|
|
// the frame tree of some enclosing document. We do nothing in that case,
|
|
|
|
// but we have to check that containingView is nonnull or we will crash.
|
|
|
|
if (nsnull != containingView && containingView != parentView) {
|
2000-05-17 08:45:44 +04:00
|
|
|
// it is possible for parent view not to have a frame attached to it
|
|
|
|
// kind of an anonymous view. This happens with native scrollbars and
|
|
|
|
// the clip view. To fix this we need to go up and parentView chain
|
|
|
|
// until we find a view with client data. This is total HACK to fix
|
|
|
|
// the HACK below. COMBO box code should NOT be in the container code!!!
|
|
|
|
// And the case it looks from does not just happen for combo boxes. Native
|
|
|
|
// scrollframes get in this situation too!!
|
|
|
|
while(parentView) {
|
|
|
|
void *data = 0;
|
|
|
|
parentView->GetClientData(data);
|
|
|
|
if (data)
|
|
|
|
break;
|
|
|
|
|
2002-01-27 10:56:23 +03:00
|
|
|
nscoord x, y;
|
|
|
|
parentView->GetPosition(&x, &y);
|
|
|
|
origin.x -= x;
|
|
|
|
origin.y -= y;
|
2000-05-17 08:45:44 +04:00
|
|
|
parentView->GetParent(parentView);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (containingView != parentView)
|
|
|
|
{
|
|
|
|
// Huh, the view's parent view isn't the same as the containing view.
|
|
|
|
// This happens for combo box drop-down frames.
|
|
|
|
//
|
|
|
|
// We have the origin in the coordinate space of the containing view,
|
|
|
|
// but we need it in the coordinate space of the parent view so do a
|
|
|
|
// view translation
|
2002-01-24 12:20:51 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
PRBool ok =
|
|
|
|
#endif
|
|
|
|
TranslatePointTo(origin, containingView, parentView);
|
|
|
|
|
|
|
|
NS_ASSERTION(ok, "translation failed");
|
2000-05-17 08:45:44 +04:00
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
1999-11-20 09:03:16 +03:00
|
|
|
|
2001-09-21 04:53:29 +04:00
|
|
|
if (parentView) {
|
|
|
|
// If the parent view is scrollable, then adjust the origin by
|
|
|
|
// the parent's scroll position.
|
|
|
|
nsIScrollableView* scrollable = nsnull;
|
|
|
|
CallQueryInterface(parentView, &scrollable);
|
|
|
|
if (scrollable) {
|
|
|
|
nscoord scrollX = 0, scrollY = 0;
|
|
|
|
scrollable->GetScrollPosition(scrollX, scrollY);
|
|
|
|
|
|
|
|
origin.x -= scrollX;
|
|
|
|
origin.y -= scrollY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-06 00:27:19 +04:00
|
|
|
vm->MoveViewTo(view, origin.x, origin.y);
|
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
2003-01-19 03:28:02 +03: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 03:32:13 +03:00
|
|
|
HasNonZeroBorderRadius(nsStyleContext* aStyleContext) {
|
2003-01-19 03:28:02 +03:00
|
|
|
const nsStyleBorder* border;
|
|
|
|
::GetStyleData(aStyleContext, &border);
|
|
|
|
|
|
|
|
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 15:56:37 +04:00
|
|
|
static void
|
|
|
|
SyncFrameViewGeometryDependentProperties(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext,
|
2002-09-30 15:56:37 +04:00
|
|
|
nsIView* aView,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
aView->GetViewManager(*getter_AddRefs(vm));
|
|
|
|
|
|
|
|
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
|
|
|
|
PRBool fixedBackground = hasBG &&
|
|
|
|
NS_STYLE_BG_ATTACHMENT_FIXED == bg->mBackgroundAttachment;
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
PRBool viewHasTransparentContent =
|
|
|
|
!hasBG ||
|
|
|
|
(bg->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT) ||
|
2003-01-19 03:28:02 +03:00
|
|
|
!aFrame->CanPaintBackground() ||
|
|
|
|
HasNonZeroBorderRadius(aStyleContext);
|
2002-09-30 15:56:37 +04:00
|
|
|
if (isCanvas && viewHasTransparentContent) {
|
|
|
|
nsIView* rootView;
|
|
|
|
vm->GetRootView(rootView);
|
|
|
|
nsIView* rootParent;
|
|
|
|
rootView->GetParent(rootParent);
|
|
|
|
if (nsnull == rootParent) {
|
|
|
|
viewHasTransparentContent = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
::GetStyleData(aStyleContext, &display);
|
|
|
|
nsFrameState kidState;
|
|
|
|
aFrame->GetFrameState(&kidState);
|
|
|
|
|
|
|
|
if (!viewHasTransparentContent) {
|
|
|
|
// If we're showing the view but the frame is hidden, then the view is transparent
|
|
|
|
nsViewVisibility visibility;
|
|
|
|
aView->GetVisibility(visibility);
|
|
|
|
const nsStyleVisibility* vis;
|
|
|
|
::GetStyleData(aStyleContext, &vis);
|
|
|
|
if ((nsViewVisibility_kShow == visibility
|
|
|
|
&& NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible)
|
|
|
|
|| (NS_STYLE_OVERFLOW_VISIBLE == display->mOverflow
|
|
|
|
&& (kidState & NS_FRAME_OUTSIDE_CHILDREN) != 0)) {
|
|
|
|
viewHasTransparentContent = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
// - 'overflow-clip' which only applies to block-level elements and replaced
|
|
|
|
// elements that have 'overflow' set to 'hidden'. 'overflow-clip' is relative
|
|
|
|
// to the content area and applies to content only (not border or background).
|
|
|
|
// 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...
|
|
|
|
PRBool isBlockLevel = display->IsBlockLevel() || (kidState & NS_FRAME_OUT_OF_FLOW);
|
|
|
|
PRBool hasClip = display->IsAbsolutelyPositioned() && (display->mClipFlags & NS_STYLE_CLIP_RECT);
|
|
|
|
PRBool hasOverflowClip = isBlockLevel && (display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN);
|
|
|
|
if (hasClip || hasOverflowClip) {
|
|
|
|
nsSize frameSize;
|
1999-11-19 18:33:29 +03:00
|
|
|
aFrame->GetSize(frameSize);
|
2002-09-30 15:56:37 +04: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 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
if (hasOverflowClip) {
|
|
|
|
const nsStyleBorder* borderStyle;
|
|
|
|
::GetStyleData(aStyleContext, &borderStyle);
|
|
|
|
const nsStylePadding* paddingStyle;
|
|
|
|
::GetStyleData(aStyleContext, &paddingStyle);
|
|
|
|
|
|
|
|
nsMargin border, padding;
|
|
|
|
// XXX We don't support the 'overflow-clip' property yet so just use the
|
|
|
|
// content area (which is the default value) as the clip shape
|
|
|
|
nsRect overflowClipRect(0, 0, frameSize.width, frameSize.height);
|
|
|
|
borderStyle->GetBorder(border);
|
|
|
|
overflowClipRect.Deflate(border);
|
|
|
|
// XXX We need to handle percentage padding
|
|
|
|
if (paddingStyle->GetPadding(padding)) {
|
|
|
|
overflowClipRect.Deflate(padding);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hasClip) {
|
|
|
|
// If both 'clip' and 'overflow-clip' apply then use the intersection
|
|
|
|
// of the two
|
|
|
|
clipRect.IntersectRect(clipRect, overflowClipRect);
|
1999-11-19 18:33:29 +03:00
|
|
|
} else {
|
2002-09-30 15:56:37 +04:00
|
|
|
clipRect = overflowClipRect;
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
nsRect newSize;
|
|
|
|
aView->GetBounds(newSize);
|
|
|
|
nscoord x, y;
|
|
|
|
aView->GetPosition(&x, &y);
|
|
|
|
newSize.x -= x;
|
|
|
|
newSize.y -= y;
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
nsRegion region;
|
|
|
|
region.Copy(nsRectFast(clipRect));
|
|
|
|
vm->SetViewChildClipRegion(aView, ®ion);
|
|
|
|
} else {
|
|
|
|
// Remove clipping of child views.
|
|
|
|
vm->SetViewChildClipRegion(aView, nsnull);
|
|
|
|
}
|
|
|
|
|
|
|
|
vm->SetViewContentTransparency(aView, viewHasTransparentContent);
|
|
|
|
}
|
|
|
|
|
2002-10-08 08:09:38 +04:00
|
|
|
void
|
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(nsIPresContext* aPresContext,
|
|
|
|
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)) {
|
|
|
|
PositionFrameView(aPresContext, aFrame);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_SIZE_VIEW)) {
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
aView->GetViewManager(*getter_AddRefs(vm));
|
|
|
|
nsRect oldBounds;
|
|
|
|
aView->GetBounds(oldBounds);
|
|
|
|
nsFrameState kidState;
|
|
|
|
aFrame->GetFrameState(&kidState);
|
|
|
|
|
|
|
|
// If the frame has child frames that stick outside the content
|
|
|
|
// area, then size the view large enough to include those child
|
|
|
|
// frames
|
|
|
|
if ((kidState & NS_FRAME_OUTSIDE_CHILDREN) && aCombinedArea) {
|
|
|
|
vm->ResizeView(aView, *aCombinedArea);
|
|
|
|
} else {
|
|
|
|
// If the width is unchanged and the height is not decreased
|
|
|
|
// then repaint only the newly exposed or contracted area,
|
|
|
|
// otherwise repaint the union of the old and new areas
|
|
|
|
|
|
|
|
// XXX: We currently invalidate the newly exposed areas only
|
|
|
|
// when the container frame's width is unchanged and the height
|
|
|
|
// is either unchanged or increased This is because some frames
|
|
|
|
// do not invalidate themselves properly. see bug 73825. Once
|
|
|
|
// bug 73825 is fixed, we should always pass PR_TRUE instead of
|
|
|
|
// frameSize.width == width && frameSize.height >= height.
|
|
|
|
nsSize frameSize;
|
|
|
|
aFrame->GetSize(frameSize);
|
|
|
|
nsRect newSize(0, 0, frameSize.width, frameSize.height);
|
|
|
|
vm->ResizeView(aView, newSize,
|
|
|
|
(frameSize.width == oldBounds.width && frameSize.height >= oldBounds.height));
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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 03:32:13 +03:00
|
|
|
nsStyleContext* savedStyleContext = aFrame->GetStyleContext();
|
2002-10-08 08:09:38 +04:00
|
|
|
SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, savedStyleContext, aView, aFlags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
void
|
|
|
|
nsContainerFrame::SyncFrameViewAfterSizeChange(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext,
|
2002-09-30 15:56:37 +04:00
|
|
|
nsIView* aView,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
if (!aView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nsnull == aStyleContext) {
|
2003-02-22 03:32:13 +03:00
|
|
|
aStyleContext = aFrame->GetStyleContext();
|
2002-09-30 15:56:37 +04:00
|
|
|
}
|
|
|
|
|
2002-10-08 08:09:38 +04:00
|
|
|
SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags);
|
2002-09-30 15:56:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsContainerFrame::SyncFrameViewProperties(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext,
|
2002-09-30 15:56:37 +04:00
|
|
|
nsIView* aView,
|
|
|
|
PRUint32 aFlags)
|
|
|
|
{
|
|
|
|
if (!aView) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIViewManager> vm;
|
|
|
|
aView->GetViewManager(*getter_AddRefs(vm));
|
|
|
|
|
|
|
|
if (nsnull == aStyleContext) {
|
2003-02-22 03:32:13 +03:00
|
|
|
aStyleContext = aFrame->GetStyleContext();
|
2002-09-30 15:56:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleVisibility* vis;
|
|
|
|
::GetStyleData(aStyleContext, &vis);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
// Set the view's opacity
|
|
|
|
vm->SetViewOpacity(aView, vis->mOpacity);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
// Make sure visibility is correct
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_VISIBILITY)) {
|
1999-11-19 18:33:29 +03:00
|
|
|
// See if the view should be hidden or visible
|
|
|
|
PRBool viewIsVisible = PR_TRUE;
|
|
|
|
|
2001-06-01 02:19:43 +04:00
|
|
|
if (NS_STYLE_VISIBILITY_COLLAPSE == vis->mVisible) {
|
1999-11-19 18:33:29 +03:00
|
|
|
viewIsVisible = PR_FALSE;
|
|
|
|
}
|
2001-06-01 02:19:43 +04:00
|
|
|
else if (NS_STYLE_VISIBILITY_HIDDEN == vis->mVisible) {
|
1999-11-19 18:33:29 +03:00
|
|
|
// If it has a widget, hide the view because the widget can't deal with it
|
2002-09-17 06:49:30 +04:00
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
aView->GetWidget(*getter_AddRefs(widget));
|
1999-11-19 18:33:29 +03:00
|
|
|
if (widget) {
|
|
|
|
viewIsVisible = PR_FALSE;
|
|
|
|
}
|
|
|
|
else {
|
2002-04-05 16:13:23 +04:00
|
|
|
// If it's a scroll frame or a list control frame which is derived from the scrollframe,
|
|
|
|
// then hide the view. This means that
|
1999-11-19 18:33:29 +03:00
|
|
|
// 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
|
2002-09-17 06:49:30 +04:00
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
aFrame->GetFrameType(getter_AddRefs(frameType));
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2002-04-05 16:13:23 +04:00
|
|
|
if (frameType == nsLayoutAtoms::scrollFrame || frameType == nsLayoutAtoms::listControlFrame) {
|
1999-11-19 18:33:29 +03:00
|
|
|
viewIsVisible = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2002-09-30 15:56:37 +04:00
|
|
|
} else {
|
|
|
|
// if the view is for a popup, don't show the view if the popup is closed
|
|
|
|
nsCOMPtr<nsIWidget> widget;
|
|
|
|
aView->GetWidget(*getter_AddRefs(widget));
|
|
|
|
if (widget) {
|
|
|
|
nsWindowType windowType;
|
|
|
|
widget->GetWindowType(windowType);
|
|
|
|
if (windowType == eWindowType_popup) {
|
|
|
|
widget->IsVisible(viewIsVisible);
|
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
vm->SetViewVisibility(aView, viewIsVisible ? nsViewVisibility_kShow :
|
|
|
|
nsViewVisibility_kHide);
|
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
const nsStyleDisplay* display;
|
|
|
|
::GetStyleData(aStyleContext, &display);
|
|
|
|
// See if the frame is being relatively positioned or absolutely
|
|
|
|
// positioned
|
|
|
|
PRBool isTopMostView = display->IsPositioned();
|
2000-04-25 08:43:11 +04:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
// Make sure z-index is correct
|
|
|
|
const nsStylePosition* position;
|
|
|
|
::GetStyleData(aStyleContext, &position);
|
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
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
if (position->mZIndex.GetUnit() == eStyleUnit_Integer) {
|
|
|
|
zIndex = position->mZIndex.GetIntValue();
|
|
|
|
} else if (position->mZIndex.GetUnit() == eStyleUnit_Auto) {
|
|
|
|
autoZIndex = PR_TRUE;
|
|
|
|
}
|
2000-04-25 08:43:11 +04:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
vm->SetViewZIndex(aView, autoZIndex, zIndex, isTopMostView);
|
2000-04-25 08:43:11 +04:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
SyncFrameViewGeometryDependentProperties(aPresContext, aFrame, aStyleContext, aView, aFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsContainerFrame::FrameNeedsView(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aStyleContext)
|
2002-09-30 15:56:37 +04:00
|
|
|
{
|
|
|
|
const nsStyleVisibility* vis;
|
|
|
|
::GetStyleData(aStyleContext, &vis);
|
|
|
|
|
|
|
|
if (vis->mOpacity != 1.0f) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2002-09-30 15:56:37 +04:00
|
|
|
// See if the frame has a fixed background attachment
|
|
|
|
const nsStyleBackground *color;
|
|
|
|
PRBool isCanvas;
|
|
|
|
PRBool hasBackground =
|
|
|
|
nsCSSRendering::FindBackground(aPresContext, aFrame, &color, &isCanvas);
|
|
|
|
if (hasBackground &&
|
|
|
|
NS_STYLE_BG_ATTACHMENT_FIXED == color->mBackgroundAttachment) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsStyleDisplay* display;
|
|
|
|
::GetStyleData(aStyleContext, &display);
|
|
|
|
|
|
|
|
if (NS_STYLE_POSITION_RELATIVE == display->mPosition) {
|
|
|
|
return PR_TRUE;
|
|
|
|
} else if (display->IsAbsolutelyPositioned()) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
2003-02-22 03:32:13 +03:00
|
|
|
nsCOMPtr<nsIAtom> pseudoTag = aStyleContext->GetPseudoType();
|
2002-11-17 18:37:56 +03:00
|
|
|
if (pseudoTag == nsCSSAnonBoxes::scrolledContent) {
|
2002-09-30 15:56:37 +04:00
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if the frame is block-level and has 'overflow' set to 'hidden'. 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
|
|
|
|
if ((display->IsBlockLevel() || display->IsFloating()) &&
|
|
|
|
(display->mOverflow == NS_STYLE_OVERFLOW_HIDDEN)) {
|
|
|
|
// 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...
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
|
|
|
|
aFrame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if ((frameType == nsLayoutAtoms::blockFrame) ||
|
|
|
|
(frameType == nsLayoutAtoms::areaFrame)) {
|
|
|
|
return PR_TRUE;
|
2001-12-06 06:16:35 +03:00
|
|
|
}
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
2002-09-30 15:56:37 +04:00
|
|
|
|
|
|
|
return PR_FALSE;
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
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,
|
1999-11-24 09:03:41 +03:00
|
|
|
nsIPresContext* 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,
|
1998-10-06 04:27:22 +04:00
|
|
|
nsReflowStatus& aStatus)
|
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-03-08 22:25:18 +03:00
|
|
|
#ifdef DEBUG
|
1999-07-14 21:27:48 +04:00
|
|
|
#ifdef REALLY_NOISY_MAX_ELEMENT_SIZE
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = nscoord(0xdeadbeef);
|
1999-03-08 22:25:18 +03:00
|
|
|
}
|
1999-07-14 21:27:48 +04:00
|
|
|
#endif
|
1999-03-08 22:25:18 +03:00
|
|
|
#endif
|
|
|
|
|
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
|
|
|
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_MOVE_FRAME)) {
|
1999-11-24 09:03:41 +03:00
|
|
|
aKidFrame->MoveTo(aPresContext, aX, aY);
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW)) {
|
2001-09-06 00:27:19 +04:00
|
|
|
PositionFrameView(aPresContext, 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
|
|
|
|
1999-03-08 22:25:18 +03:00
|
|
|
#ifdef DEBUG
|
1999-07-14 21:27:48 +04:00
|
|
|
#ifdef REALLY_NOISY_MAX_ELEMENT_SIZE
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW &&
|
|
|
|
(nscoord(0xdeadbeef) == aDesiredSize.mMaxElementWidth)) {
|
2000-10-29 02:17:53 +04:00
|
|
|
printf("nsContainerFrame: ");
|
1999-03-08 22:25:18 +03:00
|
|
|
nsFrame::ListTag(stdout, aKidFrame);
|
2003-01-09 17:26:32 +03:00
|
|
|
printf(" didn't set max-element-width!\n");
|
1999-03-08 22:25:18 +03:00
|
|
|
}
|
1999-07-14 21:27:48 +04:00
|
|
|
#endif
|
1999-03-08 22:25:18 +03:00
|
|
|
#endif
|
|
|
|
|
1998-10-06 04:27:22 +04: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)) {
|
1998-10-01 01:35:29 +04:00
|
|
|
nsIFrame* kidNextInFlow;
|
1999-02-24 07:48:08 +03:00
|
|
|
aKidFrame->GetNextInFlow(&kidNextInFlow);
|
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)
|
2002-10-09 00:35:26 +04:00
|
|
|
nsContainerFrame* parent;
|
|
|
|
kidNextInFlow->GetParent((nsIFrame**)&parent);
|
|
|
|
parent->DeleteNextInFlowChild(aPresContext, kidNextInFlow);
|
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
|
|
|
|
nsContainerFrame::PositionChildViews(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame)
|
|
|
|
{
|
2001-03-30 09:25:49 +04:00
|
|
|
nsFrameState frameState;
|
|
|
|
aFrame->GetFrameState(&frameState);
|
|
|
|
if (! ((frameState & NS_FRAME_HAS_CHILD_WITH_VIEW) == 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
|
|
|
|
nsIFrame* childFrame;
|
|
|
|
aFrame->FirstChild(aPresContext, childListName, &childFrame);
|
|
|
|
while (childFrame) {
|
2001-09-21 04:53:29 +04:00
|
|
|
// Position the frame's view (if it has one) and recursively
|
|
|
|
// process its children
|
2001-09-06 00:27:19 +04:00
|
|
|
PositionFrameView(aPresContext, childFrame);
|
2001-09-21 04:53:29 +04:00
|
|
|
PositionChildViews(aPresContext, childFrame);
|
2001-03-30 09:25:49 +04:00
|
|
|
|
|
|
|
// Get the next sibling child frame
|
|
|
|
childFrame->GetNextSibling(&childFrame);
|
1999-11-19 18:33:29 +03:00
|
|
|
}
|
2001-03-30 09:25:49 +04:00
|
|
|
|
|
|
|
NS_IF_RELEASE(childListName);
|
|
|
|
aFrame->GetAdditionalChildListName(childListIndex++, &childListName);
|
|
|
|
} 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
|
2001-12-07 17:51:12 +03:00
|
|
|
nsContainerFrame::FinishReflowChild(nsIFrame* aKidFrame,
|
|
|
|
nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState* aReflowState,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY,
|
|
|
|
PRUint32 aFlags)
|
1999-11-19 18:33:29 +03:00
|
|
|
{
|
|
|
|
nsPoint curOrigin;
|
|
|
|
nsRect bounds(aX, aY, aDesiredSize.width, aDesiredSize.height);
|
|
|
|
|
|
|
|
aKidFrame->GetOrigin(curOrigin);
|
1999-11-24 09:03:41 +03:00
|
|
|
aKidFrame->SetRect(aPresContext, bounds);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
|
|
|
nsIView* view;
|
1999-11-24 09:03:41 +03:00
|
|
|
aKidFrame->GetView(aPresContext, &view);
|
1999-11-19 18:33:29 +03:00
|
|
|
if (view) {
|
|
|
|
// 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
|
|
|
}
|
|
|
|
else if (0 == (aFlags & NS_FRAME_NO_MOVE_VIEW) &&
|
|
|
|
((curOrigin.x != aX) || (curOrigin.y != aY))) {
|
1999-11-19 18:33:29 +03:00
|
|
|
// If the frame has moved, then we need to make sure any child views are
|
|
|
|
// correctly positioned
|
2001-09-06 00:27:19 +04:00
|
|
|
PositionChildViews(aPresContext, aKidFrame);
|
1999-11-19 18:33:29 +03: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
|
|
|
}
|
|
|
|
|
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
|
2002-10-09 00:35:26 +04:00
|
|
|
nsContainerFrame::DeleteNextInFlowChild(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aNextInFlow)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
2002-10-09 00:35:26 +04:00
|
|
|
nsIFrame* prevInFlow;
|
|
|
|
aNextInFlow->GetPrevInFlow(&prevInFlow);
|
|
|
|
NS_PRECONDITION(prevInFlow, "bad prev-in-flow");
|
|
|
|
NS_PRECONDITION(mFrames.ContainsFrame(aNextInFlow), "bad geometric parent");
|
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).
|
|
|
|
nsIFrame* nextNextInFlow;
|
2002-10-09 00:35:26 +04:00
|
|
|
aNextInFlow->GetNextInFlow(&nextNextInFlow);
|
|
|
|
if (nextNextInFlow) {
|
|
|
|
nsContainerFrame* parent;
|
|
|
|
nextNextInFlow->GetParent((nsIFrame**)&parent);
|
|
|
|
parent->DeleteNextInFlowChild(aPresContext, nextNextInFlow);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
|
|
|
|
2001-03-09 06:29:00 +03:00
|
|
|
#ifdef IBMBIDI
|
|
|
|
nsIFrame* nextBidi;
|
2002-10-09 00:35:26 +04:00
|
|
|
prevInFlow->GetBidiProperty(aPresContext, nsLayoutAtoms::nextBidi,
|
|
|
|
(void**) &nextBidi,sizeof(nextBidi));
|
|
|
|
if (nextBidi == aNextInFlow) {
|
2001-03-09 06:29:00 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
#endif // IBMBIDI
|
|
|
|
|
1998-10-01 01:35:29 +04:00
|
|
|
// Disconnect the next-in-flow from the flow list
|
2002-10-09 00:35:26 +04:00
|
|
|
nsSplittableFrame::BreakFromPrevFlow(aNextInFlow);
|
1998-10-01 01:35:29 +04:00
|
|
|
|
|
|
|
// Take the next-in-flow out of the parent's child list
|
2002-10-09 00:35:26 +04:00
|
|
|
PRBool result = mFrames.RemoveFrame(aNextInFlow);
|
2000-03-21 02:11:39 +03: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-09 00:35:26 +04:00
|
|
|
nsFrameList overflowFrames(GetOverflowFrames(aPresContext, PR_TRUE));
|
2000-03-21 02:11:39 +03:00
|
|
|
|
2002-10-09 00:35:26 +04:00
|
|
|
if (overflowFrames.IsEmpty() || !overflowFrames.RemoveFrame(aNextInFlow)) {
|
2000-03-21 02:11:39 +03:00
|
|
|
NS_ASSERTION(result, "failed to remove frame");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the overflow property again
|
|
|
|
if (overflowFrames.NotEmpty()) {
|
2002-10-09 00:35:26 +04:00
|
|
|
SetOverflowFrames(aPresContext, overflowFrames.FirstChild());
|
2000-03-21 02:11:39 +03:00
|
|
|
}
|
|
|
|
}
|
1998-10-01 01:35:29 +04:00
|
|
|
|
2002-10-30 18:33:36 +03:00
|
|
|
// Delete the next-in-flow frame and its descendants.
|
2002-10-09 00:35:26 +04:00
|
|
|
aNextInFlow->Destroy(aPresContext);
|
1998-10-01 01:35:29 +04:00
|
|
|
|
|
|
|
#ifdef NS_DEBUG
|
2002-10-09 00:35:26 +04:00
|
|
|
nsIFrame* nextInFlow;
|
|
|
|
prevInFlow->GetNextInFlow(&nextInFlow);
|
|
|
|
NS_POSTCONDITION(!nextInFlow, "non null next-in-flow");
|
1998-10-01 01:35:29 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame*
|
|
|
|
nsContainerFrame::GetOverflowFrames(nsIPresContext* aPresContext,
|
2000-01-22 04:16:50 +03:00
|
|
|
PRBool aRemoveProperty) const
|
1999-10-21 09:11:43 +04:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
1999-10-22 06:06:22 +04:00
|
|
|
|
1999-10-21 09:11:43 +04:00
|
|
|
if (presShell) {
|
1999-10-22 06:06:22 +04:00
|
|
|
nsCOMPtr<nsIFrameManager> frameManager;
|
1999-10-21 09:11:43 +04:00
|
|
|
presShell->GetFrameManager(getter_AddRefs(frameManager));
|
|
|
|
|
|
|
|
if (frameManager) {
|
|
|
|
PRUint32 options = 0;
|
|
|
|
void* value;
|
|
|
|
|
|
|
|
if (aRemoveProperty) {
|
|
|
|
options |= NS_IFRAME_MGR_REMOVE_PROP;
|
|
|
|
}
|
2000-01-22 04:16:50 +03:00
|
|
|
frameManager->GetFrameProperty((nsIFrame*)this, nsLayoutAtoms::overflowProperty,
|
1999-10-21 09:11:43 +04:00
|
|
|
options, &value);
|
|
|
|
return (nsIFrame*)value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destructor function for the overflow frame property
|
|
|
|
static void
|
|
|
|
DestroyOverflowFrames(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nsIAtom* aPropertyName,
|
|
|
|
void* aPropertyValue)
|
|
|
|
{
|
|
|
|
if (aPropertyValue) {
|
|
|
|
nsFrameList frames((nsIFrame*)aPropertyValue);
|
|
|
|
|
1999-11-24 09:03:41 +03:00
|
|
|
frames.DestroyFrames(aPresContext);
|
1999-10-21 09:11:43 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsContainerFrame::SetOverflowFrames(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aOverflowFrames)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
nsresult rv = NS_ERROR_FAILURE;
|
|
|
|
|
|
|
|
aPresContext->GetShell(getter_AddRefs(presShell));
|
|
|
|
if (presShell) {
|
1999-10-22 06:06:22 +04:00
|
|
|
nsCOMPtr<nsIFrameManager> frameManager;
|
1999-10-21 09:11:43 +04:00
|
|
|
presShell->GetFrameManager(getter_AddRefs(frameManager));
|
|
|
|
|
|
|
|
if (frameManager) {
|
|
|
|
rv = frameManager->SetFrameProperty(this, nsLayoutAtoms::overflowProperty,
|
|
|
|
aOverflowFrames, DestroyOverflowFrames);
|
|
|
|
|
|
|
|
// Verify that we didn't overwrite an existing overflow list
|
|
|
|
NS_ASSERTION(rv != NS_IFRAME_MGR_PROP_OVERWRITTEN,
|
|
|
|
"existing overflow list");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
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
|
1999-10-21 09:11:43 +04:00
|
|
|
nsContainerFrame::PushChildren(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFromChild,
|
|
|
|
nsIFrame* aPrevSibling)
|
1998-10-01 01:35:29 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFromChild, "null pointer");
|
|
|
|
NS_PRECONDITION(nsnull != aPrevSibling, "pushing first child");
|
|
|
|
#ifdef NS_DEBUG
|
|
|
|
nsIFrame* prevNextSibling;
|
1999-02-10 09:13:38 +03:00
|
|
|
aPrevSibling->GetNextSibling(&prevNextSibling);
|
1998-10-01 01:35:29 +04:00
|
|
|
NS_PRECONDITION(prevNextSibling == aFromChild, "bad prev sibling");
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Disconnect aFromChild from its previous sibling
|
|
|
|
aPrevSibling->SetNextSibling(nsnull);
|
|
|
|
|
1999-01-16 01:53:39 +03:00
|
|
|
if (nsnull != mNextInFlow) {
|
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-01-16 01:53:39 +03:00
|
|
|
nsContainerFrame* nextInFlow = (nsContainerFrame*)mNextInFlow;
|
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.
|
|
|
|
for (nsIFrame* f = aFromChild; f; f->GetNextSibling(&f)) {
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, this, mNextInFlow);
|
1999-04-13 04:15:13 +04:00
|
|
|
}
|
1999-01-16 01:53:39 +03:00
|
|
|
nextInFlow->mFrames.InsertFrames(mNextInFlow, nsnull, aFromChild);
|
|
|
|
}
|
|
|
|
else {
|
1998-10-01 01:35:29 +04:00
|
|
|
// Add the frames to our overflow list
|
1999-10-21 09:11:43 +04:00
|
|
|
SetOverflowFrames(aPresContext, aFromChild);
|
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
|
1999-10-21 09:11:43 +04:00
|
|
|
nsContainerFrame::MoveOverflowToChildList(nsIPresContext* 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
|
|
|
|
nsContainerFrame* prevInFlow = (nsContainerFrame*)mPrevInFlow;
|
|
|
|
if (nsnull != prevInFlow) {
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* prevOverflowFrames = prevInFlow->GetOverflowFrames(aPresContext,
|
|
|
|
PR_TRUE);
|
|
|
|
if (prevOverflowFrames) {
|
1999-01-16 01:53:39 +03:00
|
|
|
NS_ASSERTION(mFrames.IsEmpty(), "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.
|
1999-10-21 09:11:43 +04:00
|
|
|
for (nsIFrame* f = prevOverflowFrames; f; f->GetNextSibling(&f)) {
|
1999-10-26 08:44:41 +04:00
|
|
|
nsHTMLContainerFrame::ReparentFrameView(aPresContext, f, prevInFlow, this);
|
1999-04-13 04:15:13 +04:00
|
|
|
}
|
1999-10-21 09:11:43 +04:00
|
|
|
mFrames.InsertFrames(this, nsnull, prevOverflowFrames);
|
1998-10-01 01:35:29 +04:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// It's also possible that we have an overflow list for ourselves
|
1999-10-21 09:11:43 +04:00
|
|
|
nsIFrame* overflowFrames = GetOverflowFrames(aPresContext, PR_TRUE);
|
|
|
|
if (overflowFrames) {
|
1999-01-16 01:53:39 +03:00
|
|
|
NS_ASSERTION(mFrames.NotEmpty(), "overflow list w/o frames");
|
1999-10-21 09:11:43 +04:00
|
|
|
mFrames.AppendFrames(nsnull, overflowFrames);
|
1998-10-01 01:35:29 +04:00
|
|
|
result = PR_TRUE;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Debugging
|
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef NS_DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
1999-10-26 08:44:41 +04:00
|
|
|
nsContainerFrame::List(nsIPresContext* aPresContext, 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
|
2001-10-25 05:08:40 +04:00
|
|
|
fprintf(out, " [parent=%p]", NS_STATIC_CAST(void*, mParent));
|
2000-07-27 09:16:08 +04:00
|
|
|
#endif
|
1999-01-16 03:00:50 +03:00
|
|
|
nsIView* view;
|
1999-10-26 08:44:41 +04:00
|
|
|
GetView(aPresContext, &view);
|
1999-01-16 03:00:50 +03:00
|
|
|
if (nsnull != view) {
|
2001-10-25 05:08:40 +04:00
|
|
|
fprintf(out, " [view=%p]", NS_STATIC_CAST(void*, view));
|
1999-01-16 03:00:50 +03:00
|
|
|
}
|
1999-04-28 02:11:21 +04:00
|
|
|
if (nsnull != mNextSibling) {
|
2001-10-25 05:08:40 +04:00
|
|
|
fprintf(out, " next=%p", NS_STATIC_CAST(void*, mNextSibling));
|
1999-04-28 02:11:21 +04:00
|
|
|
}
|
1999-01-16 03:00:50 +03:00
|
|
|
if (nsnull != mPrevInFlow) {
|
2001-10-25 05:08:40 +04:00
|
|
|
fprintf(out, " prev-in-flow=%p", NS_STATIC_CAST(void*, mPrevInFlow));
|
1999-01-16 03:00:50 +03:00
|
|
|
}
|
|
|
|
if (nsnull != mNextInFlow) {
|
2001-10-25 05:08:40 +04:00
|
|
|
fprintf(out, " next-in-flow=%p", NS_STATIC_CAST(void*, mNextInFlow));
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
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);
|
|
|
|
}
|
2001-10-25 05:08:40 +04:00
|
|
|
fprintf(out, " [content=%p]", NS_STATIC_CAST(void*, mContent));
|
|
|
|
fprintf(out, " [sc=%p]", NS_STATIC_CAST(void*, mStyleContext));
|
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 {
|
|
|
|
nsIFrame* kid;
|
2000-01-22 04:16:50 +03:00
|
|
|
FirstChild(aPresContext, listName, &kid);
|
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);
|
2001-10-16 07:53:44 +04:00
|
|
|
fputs(NS_LossyConvertUCS2toASCII(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
|
|
|
|
nsIFrame* parentFrame;
|
|
|
|
kid->GetParent(&parentFrame);
|
|
|
|
NS_ASSERTION(parentFrame == (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
|
|
|
|
nsIFrameDebug* frameDebug;
|
2000-02-03 01:24:56 +03:00
|
|
|
if (NS_SUCCEEDED(kid->QueryInterface(NS_GET_IID(nsIFrameDebug), (void**)&frameDebug))) {
|
1999-11-02 01:12:45 +03:00
|
|
|
frameDebug->List(aPresContext, out, aIndent + 1);
|
|
|
|
}
|
1999-02-10 09:13:38 +03:00
|
|
|
kid->GetNextSibling(&kid);
|
1999-01-16 03:19:10 +03:00
|
|
|
}
|
|
|
|
IndentBy(out, aIndent);
|
|
|
|
fputs(">\n", out);
|
1998-10-01 01:35:29 +04:00
|
|
|
}
|
1999-01-16 03:19:10 +03:00
|
|
|
NS_IF_RELEASE(listName);
|
1999-02-10 05:25:01 +03:00
|
|
|
GetAdditionalChildListName(listIndex++, &listName);
|
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
|