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-04-14 00:24:54 +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-04-14 00:24:54 +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-04-14 00:24:54 +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-04-14 00:24:54 +04:00
|
|
|
#include "nsTableOuterFrame.h"
|
|
|
|
#include "nsTableFrame.h"
|
2001-12-18 01:39:59 +03:00
|
|
|
#include "nsHTMLReflowCommand.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsVoidArray.h"
|
1998-07-02 21:40:56 +04:00
|
|
|
#include "prinrval.h"
|
1998-10-01 08:46:11 +04:00
|
|
|
#include "nsHTMLIIDs.h"
|
1999-02-24 08:54:31 +03:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-08-10 07:52:15 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIPresShell.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-04-01 05:01:33 +04:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2001-02-27 17:52:07 +03:00
|
|
|
#include "nsIPrintContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-03-02 09:09:37 +03:00
|
|
|
/* ----------- nsTableCaptionFrame ---------- */
|
|
|
|
|
2000-01-28 05:19:45 +03:00
|
|
|
#define NS_TABLE_FRAME_CAPTION_LIST_INDEX 0
|
2000-04-29 01:05:31 +04:00
|
|
|
#define NO_SIDE 100
|
2000-01-28 05:19:45 +03:00
|
|
|
|
|
|
|
// caption frame
|
|
|
|
nsTableCaptionFrame::nsTableCaptionFrame()
|
|
|
|
{
|
|
|
|
// shrink wrap
|
|
|
|
SetFlags(NS_BLOCK_SPACE_MGR|NS_BLOCK_WRAP_SIZE);
|
|
|
|
}
|
|
|
|
|
2000-03-02 09:09:37 +03:00
|
|
|
nsTableCaptionFrame::~nsTableCaptionFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::Destroy(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
mCaptionFrame->Destroy(aPresContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsHTMLContainerFrame::Destroy(aPresContext);
|
|
|
|
}
|
|
|
|
|
2000-01-28 05:19:45 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCaptionFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableCaptionFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
NS_NewTableCaptionFrame(nsIPresShell* aPresShell,
|
|
|
|
nsIFrame** aNewFrame)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
nsTableCaptionFrame* it = new (aPresShell) nsTableCaptionFrame;
|
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
|
|
|
*aNewFrame = it;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/* ----------- nsTableOuterFrame ---------- */
|
|
|
|
|
1999-08-01 22:26:45 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
|
|
|
|
|
2000-03-02 09:09:37 +03:00
|
|
|
nsTableOuterFrame::nsTableOuterFrame()
|
|
|
|
{
|
2001-02-07 07:31:38 +03:00
|
|
|
mPriorAvailWidth = 0;
|
2001-01-25 18:55:51 +03:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
mTimer = new nsReflowTimer(this);
|
|
|
|
#endif
|
2000-03-02 09:09:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableOuterFrame::~nsTableOuterFrame()
|
|
|
|
{
|
2001-01-25 18:55:51 +03:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflowDone(this);
|
|
|
|
#endif
|
2000-03-02 09:09:37 +03:00
|
|
|
}
|
|
|
|
|
1999-08-01 22:26:45 +04:00
|
|
|
nsresult nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2001-04-01 05:01:33 +04:00
|
|
|
|
2000-02-03 01:24:56 +03:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsITableLayout)))
|
1999-08-01 22:26:45 +04:00
|
|
|
{ // note there is no addref here, frames are not addref'd
|
|
|
|
*aInstancePtr = (void*)(nsITableLayout*)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-05-18 03:52:32 +04:00
|
|
|
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-08-17 07:13:07 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-18 03:52:32 +04:00
|
|
|
NS_IMETHODIMP nsTableOuterFrame::GetAccessible(nsIAccessible** aAccessible)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessibilityService> accService = do_GetService("@mozilla.org/accessibilityService;1");
|
|
|
|
|
|
|
|
if (accService) {
|
|
|
|
nsIAccessible* acc = nsnull;
|
|
|
|
return accService->CreateHTMLTableAccessible(NS_STATIC_CAST(nsIFrame*, this), aAccessible);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
1999-08-01 22:26:45 +04:00
|
|
|
}
|
2001-08-17 07:13:07 +04:00
|
|
|
#endif
|
2001-05-18 03:52:32 +04:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::IsPercentageBase(PRBool& aBase) const
|
|
|
|
{
|
|
|
|
aBase = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-28 18:43:25 +03:00
|
|
|
// tables change 0 width into auto, trees override this and do nothing
|
2000-01-28 05:19:45 +03:00
|
|
|
NS_IMETHODIMP
|
2000-01-28 18:43:25 +03:00
|
|
|
nsTableOuterFrame::AdjustZeroWidth()
|
1998-09-16 21:19:20 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
/* It does not appear that this function is needed any longer, since
|
|
|
|
the content node handles the deprecated width="0" attribute case. -- dwh
|
|
|
|
*/
|
2000-01-28 18:43:25 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::Init(nsIPresContext* aPresContext,
|
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
|
|
|
nsIStyleContext* aContext,
|
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent,
|
|
|
|
aContext, aPrevInFlow);
|
|
|
|
if (NS_FAILED(rv) || !mStyleContext) return rv;
|
|
|
|
AdjustZeroWidth();
|
|
|
|
|
2001-02-23 15:35:34 +03:00
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
2000-01-28 05:19:45 +03:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::FirstChild(nsIPresContext* aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame** aFirstChild) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aFirstChild, "null OUT parameter pointer");
|
|
|
|
*aFirstChild = (nsLayoutAtoms::captionList == aListName)
|
|
|
|
? mCaptionFrame : mFrames.FirstChild();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetAdditionalChildListName(PRInt32 aIndex,
|
|
|
|
nsIAtom** aListName) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aListName, "null OUT parameter pointer");
|
|
|
|
if (aIndex < 0) {
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
*aListName = nsnull;
|
|
|
|
switch (aIndex) {
|
|
|
|
case NS_TABLE_FRAME_CAPTION_LIST_INDEX:
|
|
|
|
*aListName = nsLayoutAtoms::captionList;
|
|
|
|
NS_ADDREF(*aListName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::SetInitialChildList(nsIPresContext* aPresContext,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
if (nsLayoutAtoms::captionList == aListName) {
|
|
|
|
// the frame constructor already checked for table-caption display type
|
|
|
|
mCaptionFrame = aChildList;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mFrames.SetFrames(aChildList);
|
2002-02-19 18:48:28 +03:00
|
|
|
mInnerTableFrame = nsnull;
|
|
|
|
if (aChildList) {
|
|
|
|
nsCOMPtr<nsIAtom> fType;
|
|
|
|
aChildList->GetFrameType(getter_AddRefs(fType));
|
|
|
|
if (nsLayoutAtoms::tableFrame == fType.get()) {
|
|
|
|
mInnerTableFrame = (nsTableFrame*)aChildList;
|
|
|
|
}
|
|
|
|
}
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
|
|
|
|
1998-09-16 21:19:20 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-10 07:52:15 +04:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableOuterFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-08-10 07:52:15 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2000-01-28 05:19:45 +03:00
|
|
|
nsresult rv;
|
1999-08-10 07:52:15 +04:00
|
|
|
|
|
|
|
// We only have two child frames: the inner table and one caption frame.
|
|
|
|
// The inner frame is provided when we're initialized, and it cannot change
|
2000-01-28 05:19:45 +03:00
|
|
|
if (nsLayoutAtoms::captionList == aListName) {
|
1999-08-10 07:52:15 +04:00
|
|
|
NS_PRECONDITION(!mCaptionFrame, "already have a caption frame");
|
|
|
|
// We only support having a single caption frame
|
|
|
|
if (mCaptionFrame || (LengthOf(aFrameList) > 1)) {
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
|
|
|
} else {
|
|
|
|
// Insert the caption frame into the child list
|
|
|
|
mCaptionFrame = aFrameList;
|
|
|
|
|
|
|
|
// Reflow the new caption frame. It's already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
2001-12-18 01:39:59 +03:00
|
|
|
nsHTMLReflowCommand* reflowCmd;
|
1999-08-10 07:52:15 +04:00
|
|
|
|
2001-12-18 01:39:59 +03:00
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
1999-08-10 07:52:15 +04:00
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unexpected child frame type");
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableOuterFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-08-10 07:52:15 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(!aPrevFrame, "invalid previous frame");
|
|
|
|
return AppendFrames(aPresContext, aPresShell, aListName, aFrameList);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 09:03:41 +03:00
|
|
|
nsTableOuterFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-10 07:52:15 +04:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2000-01-28 05:19:45 +03:00
|
|
|
nsresult rv;
|
1999-08-10 07:52:15 +04:00
|
|
|
|
|
|
|
// We only have two child frames: the inner table and one caption frame.
|
|
|
|
// The inner frame can't be removed so this should be the caption
|
2000-01-28 05:19:45 +03:00
|
|
|
NS_PRECONDITION(nsLayoutAtoms::captionList == aListName, "can't remove inner frame");
|
|
|
|
NS_PRECONDITION(aOldFrame == mCaptionFrame, "invalid caption frame");
|
1999-08-10 07:52:15 +04:00
|
|
|
|
|
|
|
// See if the caption's minimum width impacted the inner table
|
|
|
|
if (mMinCaptionWidth > mRect.width) {
|
|
|
|
// The old caption width had an effect on the inner table width so
|
|
|
|
// we're going to need to reflow it. Mark it dirty
|
|
|
|
nsFrameState frameState;
|
|
|
|
mInnerTableFrame->GetFrameState(&frameState);
|
|
|
|
frameState |= NS_FRAME_IS_DIRTY;
|
|
|
|
mInnerTableFrame->SetFrameState(frameState);
|
|
|
|
}
|
|
|
|
|
2000-01-28 05:19:45 +03:00
|
|
|
// Remove the caption frame and destroy it
|
|
|
|
if (mCaptionFrame && (mCaptionFrame == aOldFrame)) {
|
|
|
|
mCaptionFrame->Destroy(aPresContext);
|
|
|
|
mCaptionFrame = nsnull;
|
|
|
|
mMinCaptionWidth = 0;
|
|
|
|
}
|
1999-08-10 07:52:15 +04:00
|
|
|
|
|
|
|
// Generate a reflow command so we get reflowed
|
2001-12-18 01:39:59 +03:00
|
|
|
nsHTMLReflowCommand* reflowCmd;
|
1999-08-10 07:52:15 +04:00
|
|
|
|
2001-12-18 01:39:59 +03:00
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, this, eReflowType_ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv))
|
1999-08-10 07:52:15 +04:00
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
NS_METHOD
|
|
|
|
nsTableOuterFrame::Paint(nsIPresContext* aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-04-14 00:24:54 +04:00
|
|
|
// for debug...
|
1999-03-26 03:39:35 +03:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
1998-04-14 00:24:54 +04:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1999-11-02 01:12:45 +03:00
|
|
|
#endif
|
2001-01-27 17:09:34 +03:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-01-28 05:19:45 +03:00
|
|
|
// the remaining code was copied from nsContainerFrame::PaintChildren since
|
|
|
|
// it only paints the primary child list
|
|
|
|
|
|
|
|
const nsStyleDisplay* disp = (const nsStyleDisplay*)
|
|
|
|
mStyleContext->GetStyleData(eStyleStruct_Display);
|
|
|
|
|
|
|
|
// Child elements have the opportunity to override the visibility property
|
|
|
|
// of their parent and display even if the parent is hidden
|
2001-12-09 08:39:45 +03:00
|
|
|
|
2000-01-28 05:19:45 +03:00
|
|
|
// If overflow is hidden then set the clip rect so that children
|
|
|
|
// don't leak out of us
|
|
|
|
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
|
|
|
|
aRenderingContext.PushState();
|
2001-12-09 08:39:45 +03:00
|
|
|
SetOverflowClipRect(aRenderingContext);
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect, mCaptionFrame, aWhichLayer);
|
|
|
|
}
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
while (nsnull != kid) {
|
|
|
|
PaintChild(aPresContext, aRenderingContext, aDirtyRect, kid, aWhichLayer);
|
|
|
|
kid->GetNextSibling(&kid);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
|
2001-12-09 08:39:45 +03:00
|
|
|
PRBool clipState;
|
2000-01-28 05:19:45 +03:00
|
|
|
aRenderingContext.PopState(clipState);
|
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2000-03-22 05:43:08 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
nsIFrame** aFrame)
|
|
|
|
{
|
2000-05-16 15:35:12 +04:00
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// caption frames live in a different list which we need to check separately
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
rv = GetFrameForPointUsing(aPresContext, aPoint, nsLayoutAtoms::captionList, NS_FRAME_PAINT_LAYER_FOREGROUND, PR_FALSE, aFrame);
|
|
|
|
if (NS_OK == rv) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
2000-03-22 05:43:08 +03:00
|
|
|
// this should act like a block, so we need to override
|
|
|
|
return GetFrameForPointUsing(aPresContext, aPoint, nsnull, aWhichLayer, (aWhichLayer == NS_FRAME_PAINT_LAYER_BACKGROUND), aFrame);
|
|
|
|
}
|
|
|
|
|
1999-10-26 08:44:41 +04:00
|
|
|
NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsIPresContext* aPresContext,
|
|
|
|
nsIDOMRange *aRange,
|
|
|
|
PRBool aSelected,
|
|
|
|
nsSpread aSpread)
|
1999-05-20 04:52:00 +04:00
|
|
|
{
|
1999-10-26 08:44:41 +04:00
|
|
|
nsresult result = nsFrame::SetSelected(aPresContext, aRange,aSelected, aSpread);
|
1999-05-20 04:52:00 +04:00
|
|
|
if (NS_SUCCEEDED(result) && mInnerTableFrame)
|
1999-10-26 08:44:41 +04:00
|
|
|
return mInnerTableFrame->SetSelected(aPresContext, aRange,aSelected, aSpread);
|
1999-05-20 04:52:00 +04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-09-13 02:48:35 +04:00
|
|
|
NS_IMETHODIMP
|
2002-03-27 05:38:13 +03:00
|
|
|
nsTableOuterFrame::GetParentStyleContextFrame(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame** aProviderFrame,
|
|
|
|
PRBool* aIsChild)
|
2000-09-13 02:48:35 +04:00
|
|
|
{
|
2002-03-27 05:38:13 +03:00
|
|
|
// The table outer frame and the (inner) table frame split the style
|
|
|
|
// data by giving the table frame the style context associated with
|
|
|
|
// the table content node and creating a style context for the outer
|
|
|
|
// frame that is a *child* of the table frame's style context,
|
|
|
|
// matching the :table-outer (should be :-moz-table-outer!)
|
|
|
|
// pseudo-element. html.css has a rule that causes that
|
|
|
|
// pseudo-element (and thus the outer table) to inherit *some* style
|
|
|
|
// properties from the table frame. The children of the table inherit
|
|
|
|
// directly from the inner table, and the outer table's style context
|
|
|
|
// is a leaf.
|
|
|
|
|
|
|
|
if (!mInnerTableFrame) {
|
|
|
|
*aProviderFrame = this;
|
|
|
|
*aIsChild = PR_FALSE;
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-09-13 02:48:35 +04:00
|
|
|
}
|
2002-03-27 05:38:13 +03:00
|
|
|
*aProviderFrame = mInnerTableFrame;
|
|
|
|
*aIsChild = PR_TRUE;
|
|
|
|
return NS_OK;
|
2000-09-13 02:48:35 +04:00
|
|
|
}
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
// INCREMENTAL REFLOW HELPER FUNCTIONS
|
|
|
|
|
|
|
|
nsSize
|
|
|
|
GetFrameSize(nsIFrame& aFrame)
|
|
|
|
{
|
|
|
|
nsRect rect;
|
|
|
|
aFrame.GetRect(rect);
|
|
|
|
nsSize size(rect.width, rect.height);
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-09-11 04:02:04 +04:00
|
|
|
nsTableOuterFrame::ZeroAutoMargin(nsHTMLReflowState& aReflowState,
|
|
|
|
nsMargin& aMargin)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
2001-02-07 12:57:26 +03:00
|
|
|
if (eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetLeftUnit()) {
|
2000-04-29 01:05:31 +04:00
|
|
|
aMargin.left = 0;
|
2000-09-11 04:02:04 +04:00
|
|
|
}
|
2001-02-07 12:57:26 +03:00
|
|
|
if (eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetRightUnit()) {
|
2000-09-11 04:02:04 +04:00
|
|
|
aMargin.right = 0;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-05-05 03:16:42 +04:00
|
|
|
FixAutoMargins(nscoord aAvailWidth,
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord aChildWidth,
|
2000-05-05 03:16:42 +04:00
|
|
|
nsHTMLReflowState& aReflowState)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
2000-05-05 03:16:42 +04:00
|
|
|
// see if there are auto margins. they may have been set to 0 in mComputedMargin
|
2001-02-07 12:57:26 +03:00
|
|
|
PRBool hasAutoMargin = eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetLeftUnit() ||
|
|
|
|
eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetRightUnit();
|
2000-05-05 03:16:42 +04:00
|
|
|
if (hasAutoMargin) {
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord width = aChildWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == width) {
|
|
|
|
width = 0;
|
|
|
|
}
|
|
|
|
aReflowState.CalculateBlockSideMargins(aAvailWidth, width);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
void
|
|
|
|
nsTableOuterFrame::InitChildReflowState(nsIPresContext& aPresContext,
|
|
|
|
nsHTMLReflowState& aReflowState)
|
|
|
|
|
|
|
|
{
|
|
|
|
nsMargin collapseBorder;
|
|
|
|
nsMargin collapsePadding(0,0,0,0);
|
|
|
|
nsMargin* pCollapseBorder = nsnull;
|
|
|
|
nsMargin* pCollapsePadding = nsnull;
|
|
|
|
if ((aReflowState.frame == mInnerTableFrame) && (mInnerTableFrame->IsBorderCollapse())) {
|
|
|
|
if (mInnerTableFrame->NeedToCalcBCBorders()) {
|
|
|
|
mInnerTableFrame->CalcBCBorders(aPresContext);
|
|
|
|
}
|
|
|
|
pCollapseBorder = mInnerTableFrame->GetBCBorder(aPresContext, PR_FALSE, collapseBorder);
|
|
|
|
pCollapsePadding = &collapsePadding;
|
|
|
|
}
|
|
|
|
aReflowState.Init(&aPresContext, -1, -1, pCollapseBorder, pCollapsePadding);
|
|
|
|
}
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
// get the margin and padding data. nsHTMLReflowState doesn't handle the
|
|
|
|
// case of auto margins
|
|
|
|
void
|
2002-02-19 18:48:28 +03:00
|
|
|
nsTableOuterFrame::GetMarginPadding(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
nsMargin& aMargin,
|
|
|
|
nsMargin& aMarginNoAuto,
|
|
|
|
nsMargin& aPadding)
|
|
|
|
{
|
|
|
|
if (!aPresContext) ABORT0();
|
|
|
|
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
|
2000-04-29 01:05:31 +04:00
|
|
|
// construct a reflow state to compute margin and padding. Auto margins
|
|
|
|
// will not be computed at this time.
|
2002-02-19 18:48:28 +03:00
|
|
|
|
|
|
|
// create an init the child reflow state
|
2000-04-29 01:05:31 +04:00
|
|
|
nsHTMLReflowState childRS(aPresContext, aOuterRS, aChildFrame,
|
|
|
|
nsSize(aOuterRS.availableWidth, aOuterRS.availableHeight),
|
2002-02-19 18:48:28 +03:00
|
|
|
eReflowReason_Resize, PR_FALSE);
|
|
|
|
InitChildReflowState(*aPresContext, childRS);
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsRect childRect;
|
|
|
|
aChildFrame->GetRect(childRect);
|
|
|
|
FixAutoMargins(aOuterRS.availableWidth, childRect.width, childRS);
|
2000-09-11 04:02:04 +04:00
|
|
|
aMargin = childRS.mComputedMargin;
|
|
|
|
aMarginNoAuto = aMargin;
|
|
|
|
nsTableOuterFrame::ZeroAutoMargin(childRS, aMarginNoAuto);
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
aPadding = childRS.mComputedPadding;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord CalcAutoMargin(nscoord aAutoMargin,
|
|
|
|
nscoord aOppositeMargin,
|
|
|
|
nscoord aContainBlockSize,
|
2001-11-19 18:51:28 +03:00
|
|
|
nscoord aFrameSize,
|
|
|
|
float aPixelToTwips)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
|
|
|
nscoord margin;
|
2001-11-19 18:51:28 +03:00
|
|
|
if (NS_AUTOMARGIN == aOppositeMargin)
|
|
|
|
margin = nsTableFrame::RoundToPixel((aContainBlockSize - aFrameSize) / 2, aPixelToTwips);
|
2000-04-29 01:05:31 +04:00
|
|
|
else {
|
|
|
|
margin = aContainBlockSize - aFrameSize - aOppositeMargin;
|
|
|
|
}
|
|
|
|
return PR_MAX(0, margin);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsTableOuterFrame::GetChildAvailWidth(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nscoord aOuterWidth,
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin& aMarginNoAuto,
|
2000-04-29 01:05:31 +04:00
|
|
|
nsMargin& aPadding)
|
|
|
|
{
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aOuterWidth) return aOuterWidth;
|
|
|
|
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin marginIgnore;
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, aChildFrame, marginIgnore, aMarginNoAuto, aPadding);
|
2000-04-29 01:05:31 +04:00
|
|
|
nscoord width = aOuterWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != width) {
|
2001-06-06 11:35:03 +04:00
|
|
|
width = aOuterWidth - aMarginNoAuto.left - aMarginNoAuto.right;
|
2000-04-29 01:05:31 +04:00
|
|
|
width = PR_MAX(width, mMinCaptionWidth);
|
|
|
|
}
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MoveFrameTo(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aFrame,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY)
|
|
|
|
{
|
|
|
|
nsRect oldRect;
|
|
|
|
aFrame->GetRect(oldRect);
|
|
|
|
if ((oldRect.x != aX) || (oldRect.y != aY)) {
|
|
|
|
aFrame->MoveTo(aPresContext, aX, aY);
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame::RePositionViews(aPresContext, aFrame);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSize
|
|
|
|
GetContainingBlockSize(const nsHTMLReflowState& aOuterRS)
|
|
|
|
{
|
|
|
|
nsSize size(0,0);
|
|
|
|
const nsHTMLReflowState* containRS =
|
|
|
|
nsHTMLReflowState::GetContainingBlockReflowState(aOuterRS.parentReflowState);
|
|
|
|
|
|
|
|
if (containRS) {
|
|
|
|
size.width = containRS->mComputedWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == size.width) {
|
|
|
|
size.width = 0;
|
|
|
|
}
|
|
|
|
size.height = containRS->mComputedHeight;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == size.height) {
|
|
|
|
size.height = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableOuterFrame::InvalidateDamage(nsIPresContext* aPresContext,
|
|
|
|
PRUint8 aCaptionSide,
|
|
|
|
nsSize& aOuterSize,
|
|
|
|
PRBool aInnerChanged,
|
|
|
|
PRBool aCaptionChanged)
|
|
|
|
{
|
2000-05-26 02:40:21 +04:00
|
|
|
if (!aInnerChanged && !aCaptionChanged) return;
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsRect damage;
|
|
|
|
if (aInnerChanged && aCaptionChanged) {
|
|
|
|
damage = nsRect(0, 0, aOuterSize.width, aOuterSize.height);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsRect innerRect, captionRect(0,0,0,0);
|
|
|
|
mInnerTableFrame->GetRect(innerRect);
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
mCaptionFrame->GetRect(captionRect);
|
|
|
|
}
|
|
|
|
// only works for vertical captions {
|
|
|
|
damage.x = 0;
|
|
|
|
damage.width = aOuterSize.width;
|
|
|
|
switch(aCaptionSide) {
|
2000-05-10 18:51:37 +04:00
|
|
|
case NS_SIDE_BOTTOM:
|
2000-04-29 01:05:31 +04:00
|
|
|
if (aCaptionChanged) {
|
2000-05-10 18:51:37 +04:00
|
|
|
damage.y = innerRect.y;
|
|
|
|
damage.height = aOuterSize.height - damage.y;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
else {
|
2000-05-10 18:51:37 +04:00
|
|
|
damage.y = 0;
|
|
|
|
damage.height = captionRect.y;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (aCaptionChanged) {
|
2000-05-10 18:51:37 +04:00
|
|
|
damage.y = 0;
|
|
|
|
damage.height = innerRect.y;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
else {
|
2000-05-10 18:51:37 +04:00
|
|
|
damage.y = captionRect.y;
|
|
|
|
damage.height = aOuterSize.height - damage.y;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2000-05-10 18:51:37 +04:00
|
|
|
break;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Invalidate(aPresContext, damage);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsTableOuterFrame::GetCaptionAvailWidth(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aCaptionFrame,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nscoord* aInnerWidth,
|
2000-09-11 04:02:04 +04:00
|
|
|
const nsMargin* aInnerMarginNoAuto)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
|
|
|
nscoord outerWidth;
|
|
|
|
if (aInnerWidth) {
|
|
|
|
nscoord innerWidth = *aInnerWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == innerWidth) {
|
|
|
|
outerWidth = innerWidth;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsMargin innerMargin(0,0,0,0);
|
2000-09-11 04:02:04 +04:00
|
|
|
if (aInnerMarginNoAuto) {
|
|
|
|
innerMargin = *aInnerMarginNoAuto;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
outerWidth = innerWidth + innerMargin.left + innerMargin.right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsSize outerSize = GetFrameSize(*this);
|
|
|
|
outerWidth = outerSize.width;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == outerWidth) {
|
|
|
|
return outerWidth;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsMargin capMargin, capPad;
|
|
|
|
return GetChildAvailWidth(aPresContext, aCaptionFrame, aOuterRS,
|
|
|
|
outerWidth, capMargin, capPad);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsSize
|
|
|
|
nsTableOuterFrame::GetMaxElementSize(const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aInnerPadding,
|
|
|
|
const nsMargin& aCaptionMargin)
|
|
|
|
{
|
2001-03-13 09:38:59 +03:00
|
|
|
nsSize size(0,0);
|
|
|
|
size.width += aInnerMargin.left +
|
|
|
|
((nsTableFrame *)mInnerTableFrame)->GetMinWidth() +
|
|
|
|
aInnerMargin.right;
|
2000-04-29 01:05:31 +04:00
|
|
|
if (mCaptionFrame) {
|
|
|
|
nscoord capWidth = mMinCaptionWidth + aCaptionMargin.left + aCaptionMargin.right;
|
|
|
|
if (capWidth > size.width) {
|
|
|
|
size.width = capWidth;
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
// leave max element height set to 0. It is not used for anything
|
2000-04-29 01:05:31 +04:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsTableOuterFrame::GetMaxWidth(PRUint8 aCaptionSide,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin)
|
|
|
|
{
|
|
|
|
nscoord maxWidth;
|
|
|
|
switch(aCaptionSide) {
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
default: // no caption
|
2001-03-13 09:38:59 +03:00
|
|
|
maxWidth = ((nsTableFrame *)mInnerTableFrame)->GetPreferredWidth() +
|
|
|
|
aInnerMargin.left + aInnerMargin.right;
|
2000-04-29 01:05:31 +04:00
|
|
|
if (mCaptionFrame) {
|
|
|
|
maxWidth = PR_MAX(maxWidth, mMinCaptionWidth + aCaptionMargin.left + aCaptionMargin.right);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return maxWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRUint8
|
|
|
|
nsTableOuterFrame::GetCaptionSide()
|
1998-06-19 04:34:12 +04:00
|
|
|
{
|
2001-06-01 02:19:43 +04:00
|
|
|
const nsStyleTableBorder* tableStyle;
|
2000-04-29 01:05:31 +04:00
|
|
|
if (mCaptionFrame) {
|
2001-06-01 02:19:43 +04:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_TableBorder, ((const nsStyleStruct *&)tableStyle));
|
2000-04-29 01:05:31 +04:00
|
|
|
return tableStyle->mCaptionSide;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NO_SIDE; // no caption
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableOuterFrame::SetDesiredSize(PRUint8 aCaptionSide,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
nscoord& aWidth,
|
|
|
|
nscoord& aHeight)
|
|
|
|
{
|
|
|
|
aWidth = aHeight = 0;
|
|
|
|
|
|
|
|
nsRect innerRect;
|
|
|
|
mInnerTableFrame->GetRect(innerRect);
|
|
|
|
|
|
|
|
nsRect captionRect(0,0,0,0);
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
mCaptionFrame->GetRect(captionRect);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(aCaptionSide) {
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
default: // no caption
|
|
|
|
aWidth = innerRect.XMost() + aInnerMargin.right;
|
|
|
|
aWidth = PR_MAX(aWidth, captionRect.XMost() + aCaptionMargin.right);
|
|
|
|
break;
|
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
switch(aCaptionSide) {
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
aHeight = captionRect.YMost() + aCaptionMargin.bottom;
|
|
|
|
break;
|
|
|
|
default: // top caption or no caption
|
|
|
|
aHeight = innerRect.YMost() + aInnerMargin.bottom;
|
|
|
|
}
|
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::GetCaptionOrigin(nsIPresContext* aPresContext,
|
|
|
|
PRUint32 aCaptionSide,
|
|
|
|
const nsSize& aContainBlockSize,
|
|
|
|
const nsSize& aInnerSize,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
nsMargin& aCaptionMargin,
|
|
|
|
nsPoint& aOrigin)
|
|
|
|
{
|
|
|
|
aOrigin.x = aOrigin.y = 0;
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aInnerSize.width) || (NS_UNCONSTRAINEDSIZE == aInnerSize.width) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aCaptionSize.width) || (NS_UNCONSTRAINEDSIZE == aCaptionSize.width)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (!mCaptionFrame) return NS_OK;
|
|
|
|
|
2001-11-19 18:51:28 +03:00
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
|
2000-05-10 18:51:37 +04:00
|
|
|
nscoord collapseMargin;
|
2000-04-29 01:05:31 +04:00
|
|
|
switch(aCaptionSide) {
|
2000-05-10 18:51:37 +04:00
|
|
|
case NS_SIDE_BOTTOM:
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.left) {
|
|
|
|
aCaptionMargin.left = CalcAutoMargin(aCaptionMargin.left, aCaptionMargin.right,
|
2001-11-19 18:51:28 +03:00
|
|
|
aContainBlockSize.width, aCaptionSize.width, p2t);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
aOrigin.x = aCaptionMargin.left;
|
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.top) {
|
2000-05-10 18:51:37 +04:00
|
|
|
aCaptionMargin.top = 0;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2000-05-10 18:51:37 +04:00
|
|
|
collapseMargin = PR_MAX(aCaptionMargin.top, aInnerMargin.bottom);
|
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.bottom) {
|
|
|
|
nscoord height = aInnerSize.height + collapseMargin + aCaptionSize.height;
|
|
|
|
aCaptionMargin.bottom = CalcAutoMargin(aCaptionMargin.bottom, aInnerMargin.top,
|
2001-11-19 18:51:28 +03:00
|
|
|
aContainBlockSize.height, height, p2t);
|
2000-05-10 18:51:37 +04:00
|
|
|
}
|
|
|
|
aOrigin.y = aInnerMargin.top + aInnerSize.height + collapseMargin;
|
2000-04-29 01:05:31 +04:00
|
|
|
break;
|
2000-05-10 18:51:37 +04:00
|
|
|
default: // all others are treated as top for now
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.left) {
|
|
|
|
aCaptionMargin.left = CalcAutoMargin(aCaptionMargin.left, aCaptionMargin.right,
|
2001-11-19 18:51:28 +03:00
|
|
|
aContainBlockSize.width, aCaptionSize.width, p2t);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
aOrigin.x = aCaptionMargin.left;
|
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.bottom) {
|
2000-05-10 18:51:37 +04:00
|
|
|
aCaptionMargin.bottom = 0;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2000-05-10 18:51:37 +04:00
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.top) {
|
|
|
|
collapseMargin = PR_MAX(aCaptionMargin.bottom, aInnerMargin.top);
|
|
|
|
nscoord height = aCaptionSize.height + collapseMargin + aInnerSize.height;
|
|
|
|
aCaptionMargin.top = CalcAutoMargin(aCaptionMargin.top, aInnerMargin.bottom,
|
2001-11-19 18:51:28 +03:00
|
|
|
aContainBlockSize.height, height, p2t);
|
2000-05-10 18:51:37 +04:00
|
|
|
}
|
|
|
|
aOrigin.y = aCaptionMargin.top;
|
2000-04-29 01:05:31 +04:00
|
|
|
break;
|
2000-05-10 18:51:37 +04:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::GetInnerOrigin(nsIPresContext* aPresContext,
|
|
|
|
PRUint32 aCaptionSide,
|
|
|
|
const nsSize& aContainBlockSize,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
const nsSize& aInnerSize,
|
|
|
|
nsMargin& aInnerMargin,
|
|
|
|
nsPoint& aOrigin)
|
|
|
|
{
|
|
|
|
aOrigin.x = aOrigin.y = 0;
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aInnerSize.width) || (NS_UNCONSTRAINEDSIZE == aInnerSize.width) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aCaptionSize.width) || (NS_UNCONSTRAINEDSIZE == aCaptionSize.width)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-19 18:51:28 +03:00
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nscoord collapseMargin;
|
|
|
|
switch(aCaptionSide) {
|
2000-05-10 18:51:37 +04:00
|
|
|
case NS_SIDE_BOTTOM:
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.left) {
|
|
|
|
aInnerMargin.left = CalcAutoMargin(aInnerMargin.left, aInnerMargin.right,
|
2001-11-19 18:51:28 +03:00
|
|
|
aContainBlockSize.width, aInnerSize.width, p2t);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
aOrigin.x = aInnerMargin.left;
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.bottom) {
|
|
|
|
aInnerMargin.bottom = 0;
|
|
|
|
}
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.top) {
|
|
|
|
collapseMargin = PR_MAX(aInnerMargin.bottom, aCaptionMargin.top);
|
|
|
|
nscoord height = aInnerSize.height + collapseMargin + aCaptionSize.height;
|
|
|
|
aInnerMargin.top = CalcAutoMargin(aInnerMargin.top, aCaptionMargin.bottom,
|
2001-11-19 18:51:28 +03:00
|
|
|
aContainBlockSize.height, height, p2t);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
aOrigin.y = aInnerMargin.top;
|
|
|
|
break;
|
2000-05-10 18:51:37 +04:00
|
|
|
|
|
|
|
default: // all others are treated as top for now
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.left) {
|
|
|
|
aInnerMargin.left = CalcAutoMargin(aInnerMargin.left, aInnerMargin.right,
|
2001-11-19 18:51:28 +03:00
|
|
|
aContainBlockSize.width, aInnerSize.width, p2t);
|
2000-05-10 18:51:37 +04:00
|
|
|
}
|
|
|
|
aOrigin.x = aInnerMargin.left;
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.top) {
|
|
|
|
aInnerMargin.top = 0;
|
|
|
|
}
|
|
|
|
collapseMargin = PR_MAX(aCaptionMargin.bottom, aInnerMargin.top);
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.bottom) {
|
|
|
|
nscoord height = aCaptionSize.height + collapseMargin + aInnerSize.height;
|
|
|
|
aInnerMargin.bottom = CalcAutoMargin(aCaptionMargin.bottom, aInnerMargin.top,
|
2001-11-19 18:51:28 +03:00
|
|
|
aContainBlockSize.height, height, p2t);
|
2000-05-10 18:51:37 +04:00
|
|
|
}
|
|
|
|
aOrigin.y = aCaptionMargin.top + aCaptionSize.height + collapseMargin;
|
|
|
|
break;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-03-29 01:19:31 +04:00
|
|
|
// helper method for determining if this is a nested table or not
|
|
|
|
PRBool
|
|
|
|
nsTableOuterFrame::IsNested(const nsHTMLReflowState& aReflowState) const
|
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
// Walk up the reflow state chain until we find a cell or the root
|
|
|
|
const nsHTMLReflowState* rs = aReflowState.parentReflowState;
|
|
|
|
while (rs) {
|
|
|
|
nsCOMPtr<nsIAtom> frameType;
|
|
|
|
rs->frame->GetFrameType(getter_AddRefs(frameType));
|
|
|
|
if (nsLayoutAtoms::tableFrame == frameType.get()) {
|
|
|
|
result = PR_TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rs = rs->parentReflowState;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsTableOuterFrame::IsAutoWidth(nsIFrame& aTableOrCaption,
|
|
|
|
PRBool* aIsPctWidth)
|
|
|
|
{
|
|
|
|
PRBool isAuto = PR_TRUE; // the default
|
|
|
|
if (aIsPctWidth) {
|
|
|
|
*aIsPctWidth = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStyleContext> styleContext;
|
|
|
|
aTableOrCaption.GetStyleContext(getter_AddRefs(styleContext));
|
|
|
|
|
|
|
|
nsStylePosition* position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position);
|
|
|
|
|
|
|
|
switch (position->mWidth.GetUnit()) {
|
|
|
|
case eStyleUnit_Auto: // specified auto width
|
|
|
|
case eStyleUnit_Proportional: // illegal for table, so ignored
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Inherit:
|
|
|
|
// get width of parent and see if it is a specified value or not
|
|
|
|
// XXX for now, just return true
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
isAuto = PR_FALSE;
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Percent:
|
|
|
|
if (position->mWidth.GetPercentValue() > 0.0f) {
|
|
|
|
isAuto = PR_FALSE;
|
|
|
|
if (aIsPctWidth) {
|
|
|
|
*aIsPctWidth = PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return isAuto;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
// eReflowReason_Resize was being used for incremental cases
|
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::OuterReflowChild(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nscoord* aAvailWidth,
|
|
|
|
nsSize& aDesiredSize,
|
|
|
|
nsMargin& aMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin& aMarginNoAuto,
|
2000-04-29 01:05:31 +04:00
|
|
|
nsMargin& aPadding,
|
|
|
|
nsReflowReason aReflowReason,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2002-02-19 18:48:28 +03:00
|
|
|
if (!aPresContext) ABORT1(NS_ERROR_NULL_POINTER);
|
2000-04-29 01:05:31 +04:00
|
|
|
aMargin = aPadding = nsMargin(0,0,0,0);
|
|
|
|
|
|
|
|
nscoord availWidth = GetChildAvailWidth(aPresContext, aChildFrame, aOuterRS,
|
|
|
|
aOuterRS.availableWidth, aMargin, aPadding);
|
|
|
|
if (aAvailWidth) {
|
|
|
|
availWidth = *aAvailWidth;
|
|
|
|
}
|
2001-11-07 05:38:49 +03:00
|
|
|
// work around pixel rounding errors, round down to ensure we don't exceed the avail height in
|
|
|
|
float p2t;
|
|
|
|
aPresContext->GetScaledPixelsToTwips(&p2t);
|
|
|
|
nscoord availHeight = aOuterRS.availableHeight;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availHeight) {
|
|
|
|
availHeight = nsTableFrame::RoundToPixel(availHeight, p2t, eAlwaysRoundDown);
|
|
|
|
}
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
// create and init the child reflow state
|
|
|
|
nsHTMLReflowState childRS(aPresContext, aOuterRS, aChildFrame, nsSize(availWidth, availHeight),
|
|
|
|
aReflowReason);
|
|
|
|
InitChildReflowState(*aPresContext, childRS);
|
2001-12-07 17:51:12 +03:00
|
|
|
childRS.mPercentHeightObserver = nsnull; // the observer is for non table related frames inside cells
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
|
2001-11-01 07:17:30 +03:00
|
|
|
// If mComputedWidth > availWidth and availWidth >= minWidth for a nested percent table
|
|
|
|
// then adjust mComputedWidth based on availableWidth if this isn't the intial reflow
|
2001-03-29 01:19:31 +04:00
|
|
|
if ((childRS.mComputedWidth > childRS.availableWidth) &&
|
|
|
|
(NS_UNCONSTRAINEDSIZE != childRS.mComputedWidth) &&
|
|
|
|
(eReflowReason_Initial != aReflowReason) &&
|
|
|
|
IsNested(aOuterRS)) {
|
|
|
|
PRBool isPctWidth;
|
|
|
|
IsAutoWidth(*aChildFrame, &isPctWidth);
|
|
|
|
if (isPctWidth) {
|
2001-11-01 07:17:30 +03:00
|
|
|
if ( ((aChildFrame == mInnerTableFrame) &&
|
|
|
|
((nsTableFrame*)aChildFrame)->GetMinWidth() <= childRS.availableWidth) ||
|
|
|
|
(aChildFrame != mInnerTableFrame)) {
|
|
|
|
childRS.mComputedWidth = childRS.availableWidth - childRS.mComputedBorderPadding.left -
|
|
|
|
childRS.mComputedBorderPadding.right;
|
|
|
|
}
|
2000-05-01 06:25:08 +04:00
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// see if we need to reset top of page due to a caption
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
if (((NS_SIDE_BOTTOM == captionSide) && (mCaptionFrame == aChildFrame)) ||
|
|
|
|
((NS_SIDE_TOP == captionSide) && (mInnerTableFrame == aChildFrame))) {
|
|
|
|
childRS.mFlags.mIsTopOfPage = PR_FALSE;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// use the current position as a best guess for placement
|
|
|
|
nsRect childRect;
|
|
|
|
aChildFrame->GetRect(childRect);
|
|
|
|
nsresult rv = ReflowChild(aChildFrame, aPresContext, aMetrics, childRS,
|
|
|
|
childRect.x, childRect.y, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
FixAutoMargins(aOuterRS.availableWidth, aMetrics.width, childRS);
|
2000-04-29 01:05:31 +04:00
|
|
|
aMargin = childRS.mComputedMargin;
|
2000-09-11 04:02:04 +04:00
|
|
|
aMarginNoAuto = childRS.mComputedMargin;
|
|
|
|
ZeroAutoMargin(childRS, aMarginNoAuto);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
aDesiredSize.width = aMetrics.width;
|
|
|
|
aDesiredSize.height = aMetrics.height;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableOuterFrame::UpdateReflowMetrics(PRUint8 aCaptionSide,
|
|
|
|
nsHTMLReflowMetrics& aMet,
|
|
|
|
const nsMargin& aInnerMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
const nsMargin& aInnerMarginNoAuto,
|
2000-04-29 01:05:31 +04:00
|
|
|
const nsMargin& aInnerPadding,
|
2000-09-11 04:02:04 +04:00
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
const nsMargin& aCaptionMarginNoAuto)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
|
|
|
SetDesiredSize(aCaptionSide, aInnerMargin, aCaptionMargin, aMet.width, aMet.height);
|
|
|
|
|
|
|
|
// set maxElementSize width if requested
|
|
|
|
if (aMet.maxElementSize) {
|
2000-09-11 04:02:04 +04:00
|
|
|
*aMet.maxElementSize = GetMaxElementSize(aInnerMarginNoAuto, aInnerPadding, aCaptionMarginNoAuto);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
// set maximum width if requested
|
|
|
|
if (aMet.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
|
2000-09-11 04:02:04 +04:00
|
|
|
aMet.mMaximumWidth = GetMaxWidth(aCaptionSide, aInnerMarginNoAuto, aCaptionMarginNoAuto);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-06-19 04:34:12 +04:00
|
|
|
{
|
2002-05-10 22:22:41 +04:00
|
|
|
// the outer table is a target if its path has a reflow command
|
|
|
|
nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
|
|
|
|
if (command)
|
|
|
|
IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
|
|
|
|
// see if the chidren are targets as well
|
|
|
|
nsReflowPath::iterator iter = aReflowState.path->FirstChild();
|
|
|
|
nsReflowPath::iterator end = aReflowState.path->EndChildren();
|
|
|
|
for (; iter != end; ++iter)
|
|
|
|
IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aStatus, *iter);
|
|
|
|
|
|
|
|
return NS_OK;
|
1998-10-08 19:34:48 +04:00
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame* aNextFrame)
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-01-28 05:19:45 +03:00
|
|
|
if (!aNextFrame) {
|
|
|
|
// this will force Reflow to return the height of the last reflow rather than 0
|
2000-04-29 01:05:31 +04:00
|
|
|
aDesiredSize.height = mRect.height;
|
1999-07-02 09:28:32 +04:00
|
|
|
return NS_OK;
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
1999-07-02 09:28:32 +04:00
|
|
|
|
1999-04-04 04:06:48 +04:00
|
|
|
if (aNextFrame == mInnerTableFrame) {
|
1998-10-08 19:34:48 +04:00
|
|
|
rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 04:06:48 +04:00
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
else if (aNextFrame == mCaptionFrame) {
|
1998-10-08 19:34:48 +04:00
|
|
|
rv = IR_TargetIsCaptionFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 04:06:48 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-10-22 02:29:00 +04:00
|
|
|
const nsStyleDisplay* nextDisplay;
|
|
|
|
aNextFrame->GetStyleData(eStyleStruct_Display, (const nsStyleStruct *&)nextDisplay);
|
|
|
|
if (NS_STYLE_DISPLAY_TABLE_HEADER_GROUP==nextDisplay->mDisplay ||
|
|
|
|
NS_STYLE_DISPLAY_TABLE_FOOTER_GROUP==nextDisplay->mDisplay ||
|
|
|
|
NS_STYLE_DISPLAY_TABLE_ROW_GROUP ==nextDisplay->mDisplay ||
|
1999-04-04 04:06:48 +04:00
|
|
|
NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP==nextDisplay->mDisplay) {
|
1998-10-22 02:29:00 +04:00
|
|
|
rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 04:06:48 +04:00
|
|
|
}
|
|
|
|
else {
|
1998-10-22 02:29:00 +04:00
|
|
|
NS_ASSERTION(PR_FALSE, "illegal next frame in incremental reflow.");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
}
|
|
|
|
}
|
1998-10-08 19:34:48 +04:00
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_TargetIsInnerTableFrame(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
|
|
|
nsresult rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 09:21:45 +04:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult rv = NS_OK;
|
2000-05-05 03:16:42 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2000-04-29 01:05:31 +04:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
|
|
|
|
nsSize captionSize, captionMES;
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin captionMargin, captionMarginNoAuto, captionPadding;
|
2000-04-29 01:05:31 +04:00
|
|
|
// reflow the caption frame, getting it's MES
|
|
|
|
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS);
|
|
|
|
nsHTMLReflowMetrics captionMet(&captionMES);
|
2000-05-05 03:16:42 +04:00
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
2000-04-29 01:05:31 +04:00
|
|
|
OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, &availWidth, captionSize,
|
2000-09-11 04:02:04 +04:00
|
|
|
captionMargin, captionMarginNoAuto, captionPadding, eReflowReason_Incremental, capStatus);
|
2000-05-26 02:40:21 +04:00
|
|
|
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
2000-04-29 01:05:31 +04:00
|
|
|
nsPoint innerOrigin;
|
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
|
|
|
|
|
|
|
// for now just reflow the table if a style changed. This should be improved
|
2002-05-10 22:22:41 +04:00
|
|
|
// XXXwaterson danger! assuming aOuterRS.tree->mReflowCommand...
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType reflowCommandType;
|
2002-05-10 22:22:41 +04:00
|
|
|
aOuterRS.path->mReflowCommand->GetType(reflowCommandType);
|
2001-12-18 01:39:59 +03:00
|
|
|
PRBool needInnerReflow = (eReflowType_StyleChanged == reflowCommandType)
|
2000-04-29 01:05:31 +04:00
|
|
|
? PR_TRUE : PR_FALSE;
|
|
|
|
|
1999-04-04 04:06:48 +04:00
|
|
|
if (mMinCaptionWidth != captionMES.width) {
|
|
|
|
// set the new caption min width, and set state to reflow the inner table if necessary
|
1998-10-09 23:59:45 +04:00
|
|
|
mMinCaptionWidth = captionMES.width;
|
2000-04-29 01:05:31 +04:00
|
|
|
// see if the captions min width could cause the table to be wider
|
|
|
|
// XXX this really only affects an auto width table
|
2000-09-11 04:02:04 +04:00
|
|
|
if ((mMinCaptionWidth + captionMarginNoAuto.left + captionMarginNoAuto.right) > mRect.width) {
|
2000-04-29 01:05:31 +04:00
|
|
|
needInnerReflow = PR_TRUE;
|
1999-04-04 04:06:48 +04:00
|
|
|
}
|
1998-10-09 23:59:45 +04:00
|
|
|
}
|
|
|
|
|
2000-05-26 02:40:21 +04:00
|
|
|
nsRect prevInnerRect;
|
|
|
|
mInnerTableFrame->GetRect(prevInnerRect);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsPoint captionOrigin;
|
|
|
|
if (needInnerReflow) {
|
|
|
|
nsSize innerSize;
|
|
|
|
nsHTMLReflowMetrics innerMet(nsnull);
|
|
|
|
OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet, nsnull, innerSize,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerMargin, innerMarginNoAuto, innerPadding, eReflowReason_Resize, aStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2001-12-07 17:51:12 +03:00
|
|
|
rv = FinishReflowChild(mInnerTableFrame, aPresContext, nsnull, innerMet,
|
2000-04-29 01:05:31 +04:00
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
1998-10-09 23:59:45 +04:00
|
|
|
}
|
1999-04-04 04:06:48 +04:00
|
|
|
else {
|
2000-04-29 01:05:31 +04:00
|
|
|
// reposition the inner frame if necessary and set the caption's origin
|
|
|
|
nsSize innerSize = GetFrameSize(*mInnerTableFrame);
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mInnerTableFrame, innerMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerMarginNoAuto, innerPadding);
|
2000-04-29 01:05:31 +04:00
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
|
|
|
MoveFrameTo(aPresContext, mInnerTableFrame, innerOrigin.x, innerOrigin.y);
|
1998-10-09 23:59:45 +04:00
|
|
|
}
|
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
rv = FinishReflowChild(mCaptionFrame, aPresContext, nsnull, captionMet,
|
2000-04-29 01:05:31 +04:00
|
|
|
captionOrigin.x, captionOrigin.y, 0);
|
1998-10-09 23:59:45 +04:00
|
|
|
|
2000-09-11 04:02:04 +04:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, captionMargin, captionMarginNoAuto);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize desSize(aDesiredSize.width, aDesiredSize.height);
|
2000-05-26 02:40:21 +04:00
|
|
|
PRBool innerMoved = (innerOrigin.x != prevInnerRect.x) || (innerOrigin.y != prevInnerRect.y);
|
|
|
|
InvalidateDamage(aPresContext, captionSide, desSize, innerMoved, PR_TRUE);
|
1998-10-08 19:34:48 +04:00
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 09:21:45 +04:00
|
|
|
|
1999-08-10 07:52:15 +04:00
|
|
|
nsresult
|
2000-04-29 01:05:31 +04:00
|
|
|
nsTableOuterFrame::IR_ReflowDirty(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
1999-08-10 07:52:15 +04:00
|
|
|
nsFrameState frameState;
|
2001-02-07 07:00:40 +03:00
|
|
|
nsresult rv = NS_OK;
|
2000-04-29 01:05:31 +04:00
|
|
|
PRBool sizeSet = PR_FALSE;
|
1999-08-10 07:52:15 +04:00
|
|
|
// See if the caption frame is dirty. This would be because of a newly
|
|
|
|
// inserted caption
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
mCaptionFrame->GetFrameState(&frameState);
|
|
|
|
if (frameState & NS_FRAME_IS_DIRTY) {
|
|
|
|
rv = IR_CaptionInserted(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
sizeSet = PR_TRUE;
|
1999-08-10 07:52:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if the inner table frame is dirty
|
|
|
|
mInnerTableFrame->GetFrameState(&frameState);
|
|
|
|
if (frameState & NS_FRAME_IS_DIRTY) {
|
1999-08-02 02:01:37 +04:00
|
|
|
rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
sizeSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (!mCaptionFrame) {
|
1999-08-10 07:52:15 +04:00
|
|
|
// The inner table isn't dirty so we don't need to reflow it, but make
|
|
|
|
// sure it's placed correctly. It could be that we're dirty because the
|
|
|
|
// caption was removed
|
2000-04-29 01:05:31 +04:00
|
|
|
nsRect innerRect;
|
1999-08-10 07:52:15 +04:00
|
|
|
mInnerTableFrame->GetRect(innerRect);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize innerSize(innerRect.width, innerRect.height);
|
|
|
|
nsPoint innerOrigin;
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
2000-04-29 01:05:31 +04:00
|
|
|
GetMarginPadding(aPresContext, aReflowState, mInnerTableFrame, innerMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerMarginNoAuto, innerPadding);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize containSize = GetContainingBlockSize(aReflowState);
|
|
|
|
GetInnerOrigin(aPresContext, NO_SIDE, containSize, nsSize(0,0),
|
|
|
|
nsMargin(0,0,0,0), innerSize, innerMargin, innerOrigin);
|
|
|
|
MoveFrameTo(aPresContext, mInnerTableFrame, innerOrigin.x, innerOrigin.y);
|
|
|
|
|
|
|
|
aDesiredSize.width = innerRect.XMost() + innerMargin.right;
|
|
|
|
aDesiredSize.height = innerRect.YMost() + innerMargin.bottom;
|
|
|
|
sizeSet = PR_TRUE;
|
2000-05-26 02:40:21 +04:00
|
|
|
// Repaint the inner's entire bounds if it moved
|
|
|
|
if ((innerRect.x != innerOrigin.x) || (innerRect.y != innerOrigin.y)) {
|
|
|
|
Invalidate(aPresContext, nsRect(0, 0, aDesiredSize.width, aDesiredSize.height));
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
if (!sizeSet) {
|
|
|
|
// set our desired size to what it was before
|
|
|
|
nsSize size = GetFrameSize(*this);
|
|
|
|
aDesiredSize.width = size.width;
|
|
|
|
aDesiredSize.height = size.height;
|
1998-06-19 09:21:45 +04:00
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
|
1999-08-10 07:52:15 +04:00
|
|
|
return rv;
|
|
|
|
}
|
1998-06-23 09:43:27 +04:00
|
|
|
|
1999-08-10 07:52:15 +04:00
|
|
|
// IR_TargetIsMe is free to foward the request to the inner table frame
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult nsTableOuterFrame::IR_TargetIsMe(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-08-10 07:52:15 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowCommand* command = aReflowState.path->mReflowCommand;
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType type;
|
2002-05-10 22:22:41 +04:00
|
|
|
command->GetType(type);
|
1999-08-10 07:52:15 +04:00
|
|
|
nsIFrame* objectFrame;
|
2002-05-10 22:22:41 +04:00
|
|
|
command->GetChildFrame(objectFrame);
|
1999-08-10 07:52:15 +04:00
|
|
|
switch (type) {
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_ReflowDirty:
|
1999-08-19 23:52:37 +04:00
|
|
|
rv = IR_ReflowDirty(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-08 19:34:48 +04:00
|
|
|
break;
|
1998-09-30 22:11:48 +04:00
|
|
|
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_StyleChanged :
|
1998-10-30 10:57:44 +03:00
|
|
|
rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-08 19:34:48 +04:00
|
|
|
break;
|
|
|
|
|
2001-12-18 01:39:59 +03:00
|
|
|
case eReflowType_ContentChanged :
|
1998-10-08 19:34:48 +04:00
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1999-03-05 07:19:09 +03:00
|
|
|
default:
|
1999-08-10 07:52:15 +04:00
|
|
|
NS_NOTYETIMPLEMENTED("unexpected reflow command type");
|
1998-10-08 19:34:48 +04:00
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext,
|
2001-01-25 19:00:59 +03:00
|
|
|
nsHTMLReflowMetrics& aOuterMet,
|
2000-04-29 01:05:31 +04:00
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
2000-05-05 03:16:42 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2000-04-29 01:05:31 +04:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
|
|
|
|
nsRect priorInnerRect;
|
|
|
|
mInnerTableFrame->GetRect(priorInnerRect);
|
|
|
|
|
|
|
|
nsSize innerSize;
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// pass along the reflow command to the inner table, requesting the same info in our flags
|
|
|
|
nsHTMLReflowMetrics innerMet(aOuterMet.maxElementSize, aOuterMet.mFlags);
|
2000-01-10 06:04:05 +03:00
|
|
|
|
2001-11-14 14:40:03 +03:00
|
|
|
// If the incremental reflow command is a StyleChanged reflow and
|
|
|
|
// it's target is the current frame, then make sure we send
|
|
|
|
// StyleChange reflow reasons down to the children so that they
|
|
|
|
// don't over-optimize their reflow.
|
|
|
|
nsReflowReason ReflowReason = eReflowReason_Incremental;
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowCommand* command = aOuterRS.path->mReflowCommand;
|
|
|
|
if (command) {
|
2001-12-18 01:39:59 +03:00
|
|
|
nsReflowType type;
|
2002-05-10 22:22:41 +04:00
|
|
|
command->GetType(type);
|
2001-12-18 01:39:59 +03:00
|
|
|
if (eReflowType_StyleChanged == type) {
|
2001-11-14 14:40:03 +03:00
|
|
|
ReflowReason = eReflowReason_StyleChange;
|
|
|
|
}
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet,
|
2000-09-11 04:02:04 +04:00
|
|
|
nsnull, innerSize, innerMargin, innerMarginNoAuto, innerPadding,
|
2001-11-14 14:40:03 +03:00
|
|
|
ReflowReason, aStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-01-11 18:55:31 +03:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsPoint innerOrigin(0,0);
|
2000-02-12 04:55:40 +03:00
|
|
|
nsMargin captionMargin(0,0,0,0);
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin captionMarginNoAuto(0,0,0,0);
|
2000-05-04 18:49:35 +04:00
|
|
|
nsSize captionSize(0,0);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
2000-05-26 02:40:21 +04:00
|
|
|
PRBool captionMoved = PR_FALSE;
|
2000-04-29 01:05:31 +04:00
|
|
|
// if there is a caption and the width or height of the inner table changed
|
|
|
|
// from a reflow, then reflow or move the caption as needed
|
|
|
|
if (mCaptionFrame) {
|
2000-05-26 02:40:21 +04:00
|
|
|
nsPoint captionOrigin;
|
|
|
|
nsRect prevCaptionRect;
|
|
|
|
mCaptionFrame->GetRect(prevCaptionRect);
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
if (priorInnerRect.width != innerMet.width) {
|
|
|
|
nsMargin ignorePadding;
|
|
|
|
// XXX only need to reflow if the caption is auto width
|
|
|
|
nsHTMLReflowMetrics captionMet(nsnull); // don't ask for MES, it hasn't changed
|
|
|
|
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS,
|
2000-09-11 04:02:04 +04:00
|
|
|
&innerSize.width, &innerMarginNoAuto);
|
2000-05-05 03:16:42 +04:00
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
2001-11-14 14:40:03 +03:00
|
|
|
if (ReflowReason == eReflowReason_Incremental) {
|
|
|
|
ReflowReason = eReflowReason_Resize;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, &availWidth,
|
2000-09-11 04:02:04 +04:00
|
|
|
captionSize, captionMargin, captionMarginNoAuto,
|
2001-11-14 14:40:03 +03:00
|
|
|
ignorePadding, ReflowReason, capStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(mCaptionFrame, aPresContext, nsnull, captionMet,
|
2000-04-29 01:05:31 +04:00
|
|
|
captionOrigin.x, captionOrigin.y, 0);
|
|
|
|
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
1998-10-08 19:34:48 +04:00
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
else {
|
|
|
|
// reposition the caption frame if necessary and set the inner's origin
|
2000-05-04 18:49:35 +04:00
|
|
|
captionSize = GetFrameSize(*mCaptionFrame);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsMargin captionPadding;
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mCaptionFrame, captionMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
captionMarginNoAuto, captionPadding);
|
2000-04-29 01:05:31 +04:00
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
|
|
|
MoveFrameTo(aPresContext, mCaptionFrame, captionOrigin.x, captionOrigin.y);
|
1998-10-08 19:34:48 +04:00
|
|
|
}
|
2000-05-26 02:40:21 +04:00
|
|
|
if ((captionOrigin.x != prevCaptionRect.x) || (captionOrigin.x != prevCaptionRect.x)) {
|
|
|
|
captionMoved = PR_TRUE;
|
|
|
|
}
|
|
|
|
if ((captionOrigin.x != prevCaptionRect.x) || (captionOrigin.x != prevCaptionRect.x)) {
|
|
|
|
captionMoved = PR_TRUE;
|
|
|
|
}
|
1998-10-08 19:34:48 +04:00
|
|
|
}
|
2000-05-04 18:49:35 +04:00
|
|
|
else {
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
|
|
|
}
|
1998-10-08 19:34:48 +04:00
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(mInnerTableFrame, aPresContext, nsnull, innerMet,
|
2000-04-29 01:05:31 +04:00
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
|
2001-01-25 19:00:59 +03:00
|
|
|
UpdateReflowMetrics(captionSide, aOuterMet, innerMargin, innerMarginNoAuto,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerPadding, captionMargin, captionMarginNoAuto);
|
2001-01-25 19:00:59 +03:00
|
|
|
nsSize desSize(aOuterMet.width, aOuterMet.height);
|
2001-10-22 18:24:54 +04:00
|
|
|
InvalidateDamage(aPresContext, captionSide, desSize, (innerSize.width != priorInnerRect.width), captionMoved);
|
1998-10-09 23:59:45 +04:00
|
|
|
|
1998-10-08 19:34:48 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* the only difference between an insert and a replace is a replace
|
|
|
|
checks the old maxElementSize and reflows the table only if it
|
|
|
|
has changed
|
|
|
|
*/
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_CaptionInserted(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
2000-05-05 03:16:42 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-10-08 19:34:48 +04:00
|
|
|
|
|
|
|
// reflow the caption frame, getting it's MES
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize captionSize;
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin captionMargin, captionMarginNoAuto, ignorePadding;
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize maxElementSize(0,0);
|
|
|
|
nsHTMLReflowMetrics captionMet(&maxElementSize);
|
|
|
|
// reflow the caption
|
|
|
|
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS);
|
2000-05-05 03:16:42 +04:00
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet,
|
2000-09-11 04:02:04 +04:00
|
|
|
&availWidth, captionSize, captionMargin, captionMarginNoAuto,
|
|
|
|
ignorePadding, eReflowReason_Initial, capStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
1999-10-30 06:52:11 +04:00
|
|
|
mMinCaptionWidth = maxElementSize.width;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
nsPoint captionOrigin(0,0);
|
|
|
|
|
2000-09-11 04:02:04 +04:00
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
2000-05-26 02:40:21 +04:00
|
|
|
nsPoint innerOrigin;
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
2000-05-26 02:40:21 +04:00
|
|
|
nsRect prevInnerRect;
|
|
|
|
mInnerTableFrame->GetRect(prevInnerRect);
|
1999-10-30 06:52:11 +04:00
|
|
|
// XXX: caption align = left|right ignored here!
|
2000-04-29 01:05:31 +04:00
|
|
|
// if the caption's MES + margins > outer width, reflow the inner table
|
2000-09-11 04:02:04 +04:00
|
|
|
if (mMinCaptionWidth + captionMarginNoAuto.left + captionMarginNoAuto.right > mRect.width) {
|
2000-04-29 01:05:31 +04:00
|
|
|
nsHTMLReflowMetrics innerMet(aDesiredSize.maxElementSize);
|
|
|
|
nsSize innerSize;
|
|
|
|
|
|
|
|
rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet,
|
2000-09-11 04:02:04 +04:00
|
|
|
nsnull, innerSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, eReflowReason_Resize, aStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2001-12-07 17:51:12 +03:00
|
|
|
rv = FinishReflowChild(mInnerTableFrame, aPresContext, nsnull, innerMet,
|
2000-04-29 01:05:31 +04:00
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
1999-10-30 06:52:11 +04:00
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
else {
|
|
|
|
// reposition the inner frame if necessary and set the caption's origin
|
|
|
|
nsSize innerSize = GetFrameSize(*mInnerTableFrame);
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mInnerTableFrame, innerMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerMarginNoAuto, innerPadding);
|
2000-04-29 01:05:31 +04:00
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
|
|
|
MoveFrameTo(aPresContext, mInnerTableFrame, innerOrigin.x, innerOrigin.y);
|
1998-10-08 19:34:48 +04:00
|
|
|
}
|
1999-10-30 06:52:11 +04:00
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
rv = FinishReflowChild(mCaptionFrame, aPresContext, nsnull, captionMet,
|
2000-04-29 01:05:31 +04:00
|
|
|
captionOrigin.x, captionOrigin.y, 0);
|
|
|
|
|
2000-09-11 04:02:04 +04:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, captionMargin, captionMarginNoAuto);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize desSize(aDesiredSize.width, aDesiredSize.height);
|
2000-05-26 02:40:21 +04:00
|
|
|
PRBool innerMoved = (innerOrigin.x != prevInnerRect.x) || (innerOrigin.y != prevInnerRect.y);
|
|
|
|
InvalidateDamage(aPresContext, captionSide, desSize, innerMoved, PR_TRUE);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
1998-10-08 19:34:48 +04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-09-02 04:07:14 +04:00
|
|
|
PRBool nsTableOuterFrame::IR_CaptionChangedAxis(const nsStyleTable* aOldStyle,
|
|
|
|
const nsStyleTable* aNewStyle) const
|
1998-10-09 23:59:45 +04:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
//XXX: write me to support left|right captions!
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
|
2001-08-06 18:23:50 +04:00
|
|
|
static PRBool
|
|
|
|
IsPctHeight(nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
if (aFrame) {
|
|
|
|
nsCOMPtr<nsIStyleContext> styleContext;
|
|
|
|
aFrame->GetStyleContext(getter_AddRefs(styleContext));
|
|
|
|
nsStylePosition* position = (nsStylePosition*)styleContext->GetStyleData(eStyleStruct_Position);
|
|
|
|
if (eStyleUnit_Percent == position->mHeight.GetUnit()) {
|
|
|
|
float percent = position->mHeight.GetPercentValue();
|
|
|
|
if (percent > 0.0f) {
|
|
|
|
return PR_TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
1998-10-09 23:59:45 +04:00
|
|
|
|
1998-07-09 18:30:34 +04:00
|
|
|
/**
|
|
|
|
* Reflow is a multi-step process.
|
|
|
|
* 1. First we reflow the caption frame and get its maximum element size. We
|
|
|
|
* do this once during our initial reflow and whenever the caption changes
|
|
|
|
* incrementally
|
|
|
|
* 2. Next we reflow the inner table. This gives us the actual table width.
|
|
|
|
* The table must be at least as wide as the caption maximum element size
|
|
|
|
* 3. Now that we have the table width we reflow the caption and gets its
|
|
|
|
* desired height
|
|
|
|
* 4. Then we place the caption and the inner table
|
|
|
|
*
|
|
|
|
* If the table height is constrained, e.g. page mode, then it's possible the
|
|
|
|
* inner table no longer fits and has to be reflowed again this time with s
|
|
|
|
* smaller available height
|
1998-04-14 00:24:54 +04:00
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
1999-04-04 04:06:48 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
const nsHTMLReflowState& aOuterRS,
|
1999-04-04 04:06:48 +04:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2000-12-01 00:51:21 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableOuterFrame", aOuterRS.reason);
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aOuterRS, aDesiredSize, aStatus);
|
2001-10-29 04:43:59 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aOuterRS);
|
|
|
|
#endif
|
2000-04-29 01:05:31 +04:00
|
|
|
|
1998-10-09 23:59:45 +04:00
|
|
|
nsresult rv = NS_OK;
|
2000-04-29 01:05:31 +04:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
|
1998-06-23 01:59:43 +04:00
|
|
|
// Initialize out parameters
|
2000-04-29 01:05:31 +04:00
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
1998-05-25 21:31:49 +04:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
2000-04-29 01:05:31 +04:00
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
1998-05-25 21:31:49 +04:00
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
1998-06-23 01:59:43 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
PRBool isPaginated;
|
|
|
|
aPresContext->IsPaginated(&isPaginated);
|
|
|
|
PRBool needUpdateMetrics = PR_TRUE;
|
|
|
|
|
2001-06-13 06:27:22 +04:00
|
|
|
if ((eReflowReason_Resize == aOuterRS.reason) &&
|
2001-03-13 09:38:59 +03:00
|
|
|
(aOuterRS.availableWidth == mPriorAvailWidth) &&
|
2001-08-06 18:23:50 +04:00
|
|
|
!isPaginated &&
|
|
|
|
!::IsPctHeight(mInnerTableFrame)) {
|
2001-03-13 09:38:59 +03:00
|
|
|
// don't do much if we are resize reflowed exactly like last time
|
|
|
|
aDesiredSize.width = mRect.width;
|
|
|
|
aDesiredSize.height = mRect.height;
|
2001-09-21 04:53:29 +04:00
|
|
|
|
2002-04-07 22:26:35 +04:00
|
|
|
// for floaters, our view has not been positioned yet as we have not been placed
|
|
|
|
// - the block code will position our views after the floater is placed
|
|
|
|
if (aOuterRS.mStyleDisplay &&
|
|
|
|
!aOuterRS.mStyleDisplay->IsFloating()) {
|
|
|
|
// We know our view (if we have one) has been positioned
|
|
|
|
// correctly, but it's up to us to make sure that our child views
|
|
|
|
// are correctly positioned, too.
|
|
|
|
nsContainerFrame::PositionChildViews(aPresContext, this);
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
|
|
|
else if (eReflowReason_Incremental == aOuterRS.reason) {
|
2000-04-29 01:05:31 +04:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, aOuterRS, aStatus);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (eReflowReason_Initial == aOuterRS.reason) {
|
1998-06-23 01:59:43 +04:00
|
|
|
// Set up our kids. They're already present, on an overflow list,
|
|
|
|
// or there are none so we'll create them now
|
1999-11-24 09:03:41 +03:00
|
|
|
MoveOverflowToChildList(aPresContext);
|
1998-06-23 01:59:43 +04:00
|
|
|
|
1998-07-09 18:30:34 +04:00
|
|
|
// Lay out the caption and get its maximum element size
|
1998-07-09 00:21:17 +04:00
|
|
|
if (nsnull != mCaptionFrame) {
|
2000-02-04 05:47:13 +03:00
|
|
|
nsSize maxElementSize;
|
2000-04-29 01:05:31 +04:00
|
|
|
nsHTMLReflowMetrics captionMet(&maxElementSize);
|
|
|
|
captionMet.maxElementSize = &maxElementSize;
|
|
|
|
nsHTMLReflowState captionReflowState(aPresContext, aOuterRS, mCaptionFrame,
|
2000-02-04 05:47:13 +03:00
|
|
|
nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE),
|
|
|
|
eReflowReason_Initial);
|
1998-10-01 08:46:11 +04:00
|
|
|
|
1999-10-30 06:52:11 +04:00
|
|
|
mCaptionFrame->WillReflow(aPresContext);
|
2000-04-29 01:05:31 +04:00
|
|
|
rv = mCaptionFrame->Reflow(aPresContext, captionMet, captionReflowState, aStatus);
|
2001-12-07 17:51:12 +03:00
|
|
|
mCaptionFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
|
1999-10-30 06:52:11 +04:00
|
|
|
mMinCaptionWidth = maxElementSize.width;
|
1998-07-09 00:21:17 +04:00
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
// At this point, we must have an inner table frame, and we might have a caption
|
|
|
|
NS_ASSERTION(mFrames.NotEmpty() && mInnerTableFrame, "incomplete children");
|
|
|
|
nsSize innerSize;
|
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
2001-02-27 17:52:07 +03:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// First reflow the inner table
|
|
|
|
nsHTMLReflowMetrics innerMet(aDesiredSize.maxElementSize);
|
|
|
|
rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet,
|
|
|
|
nsnull, innerSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, aOuterRS.reason, aStatus);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
nsPoint innerOrigin(0,0);
|
|
|
|
nsMargin captionMargin(0,0,0,0), captionMarginNoAuto(0,0,0,0), ignorePadding;
|
|
|
|
nsSize captionSize(0,0);
|
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
|
|
|
|
|
|
|
// Now that we know the table width we can reflow the caption, and
|
|
|
|
// place the caption and the inner table
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
// reflow the caption
|
|
|
|
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS,
|
|
|
|
&innerSize.width, &innerMarginNoAuto);
|
|
|
|
nsHTMLReflowMetrics captionMet(nsnull);
|
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
|
|
|
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet,
|
|
|
|
&availWidth, captionSize, captionMargin, captionMarginNoAuto,
|
|
|
|
ignorePadding, aOuterRS.reason, capStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1998-07-09 18:30:34 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nsPoint captionOrigin;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(mCaptionFrame, aPresContext, nsnull, captionMet,
|
2001-03-13 09:38:59 +03:00
|
|
|
captionOrigin.x, captionOrigin.y, 0);
|
1999-11-19 18:33:29 +03:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// XXX If the height is constrained then we need to check whether the inner table still fits...
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2001-02-07 07:31:38 +03:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
|
2001-12-07 17:51:12 +03:00
|
|
|
FinishReflowChild(mInnerTableFrame, aPresContext, nsnull, innerMet,
|
2001-03-13 09:38:59 +03:00
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
|
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, captionMargin, captionMarginNoAuto);
|
|
|
|
needUpdateMetrics = PR_FALSE;
|
1998-06-19 09:21:45 +04:00
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
|
1998-07-09 18:30:34 +04:00
|
|
|
// Return our desired rect
|
1999-04-04 04:06:48 +04:00
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
1998-07-03 01:24:56 +04:00
|
|
|
aDesiredSize.descent = 0;
|
2001-03-13 09:38:59 +03:00
|
|
|
|
|
|
|
// compute max element size and maximum width if it hasn't already been
|
|
|
|
if (needUpdateMetrics) {
|
|
|
|
nsMargin innerMargin, innerMarginNoAuto, capMargin(0,0,0,0),
|
|
|
|
capMarginNoAuto(0,0,0,0), innerPadding, capPadding(0,0,0,0);
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mInnerTableFrame,
|
|
|
|
innerMargin, innerMarginNoAuto, innerPadding);
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mCaptionFrame,
|
|
|
|
capMargin, capMarginNoAuto, capPadding);
|
|
|
|
}
|
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, capMargin, capMarginNoAuto);
|
|
|
|
}
|
|
|
|
#ifdef CHECK_THIS_AND_REMOVE
|
2000-11-30 01:30:09 +03:00
|
|
|
// See if we are supposed to compute our maximum width
|
|
|
|
if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
|
|
|
|
// XXX this needs to consider the possibility of a caption being wider
|
|
|
|
// than the inner table, but this is the safest way to fix bug 55545
|
|
|
|
if (mInnerTableFrame) {
|
|
|
|
aDesiredSize.mMaximumWidth = ((nsTableFrame*)mInnerTableFrame)->GetPreferredWidth();
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
#endif
|
|
|
|
|
2001-02-07 07:31:38 +03:00
|
|
|
mPriorAvailWidth = aOuterRS.availableWidth;
|
1998-06-19 09:21:45 +04:00
|
|
|
|
2001-10-29 04:43:59 +03:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 18:55:51 +03:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aOuterRS, &aDesiredSize, aStatus);
|
|
|
|
#endif
|
1998-10-09 23:59:45 +04:00
|
|
|
return rv;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_METHOD nsTableOuterFrame::VerifyTree() const
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
/**
|
|
|
|
* Remove and delete aChild's next-in-flow(s). Updates the sibling and flow
|
|
|
|
* pointers.
|
|
|
|
*
|
|
|
|
* Updates the child count and content offsets of all containers that are
|
|
|
|
* affected
|
|
|
|
*
|
|
|
|
* Overloaded here because nsContainerFrame makes assumptions about pseudo-frames
|
|
|
|
* that are not true for tables.
|
|
|
|
*
|
|
|
|
* @param aChild child this child's next-in-flow
|
|
|
|
* @return PR_TRUE if successful and PR_FALSE otherwise
|
|
|
|
*/
|
1999-11-24 09:03:41 +03:00
|
|
|
void nsTableOuterFrame::DeleteChildsNextInFlow(nsIPresContext* aPresContext,
|
1999-04-04 04:06:48 +04:00
|
|
|
nsIFrame* aChild)
|
1998-04-17 02:21:32 +04:00
|
|
|
{
|
2001-11-29 18:55:27 +03:00
|
|
|
if (!aChild) return;
|
1999-04-13 03:46:02 +04:00
|
|
|
NS_PRECONDITION(mFrames.ContainsFrame(aChild), "bad geometric parent");
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* nextInFlow;
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
aChild->GetNextInFlow(&nextInFlow);
|
1998-04-17 05:41:24 +04:00
|
|
|
|
2001-11-29 18:55:27 +03:00
|
|
|
if (!nextInFlow) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "null next-in-flow");
|
|
|
|
return;
|
|
|
|
}
|
1998-04-17 05:41:24 +04:00
|
|
|
nsTableOuterFrame* parent;
|
|
|
|
|
1999-02-10 04:36:30 +03:00
|
|
|
nextInFlow->GetParent((nsIFrame**)&parent);
|
2001-11-29 18:55:27 +03:00
|
|
|
if (!parent) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "null parent");
|
|
|
|
return;
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
// If the next-in-flow has a next-in-flow then delete it too (and
|
|
|
|
// delete it first).
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* nextNextInFlow;
|
|
|
|
|
1999-02-24 07:48:08 +03:00
|
|
|
nextInFlow->GetNextInFlow(&nextNextInFlow);
|
2001-11-29 18:55:27 +03:00
|
|
|
if (nextNextInFlow) {
|
1998-08-28 07:02:39 +04:00
|
|
|
parent->DeleteChildsNextInFlow(aPresContext, nextInFlow);
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disconnect the next-in-flow from the flow list
|
1999-10-22 18:53:52 +04:00
|
|
|
nsSplittableFrame::BreakFromPrevFlow(nextInFlow);
|
1998-04-17 02:21:32 +04:00
|
|
|
|
|
|
|
// Take the next-in-flow out of the parent's child list
|
1999-01-16 01:52:05 +03:00
|
|
|
if (parent->mFrames.FirstChild() == nextInFlow) {
|
|
|
|
nsIFrame* nextSibling;
|
1999-02-10 09:13:38 +03:00
|
|
|
nextInFlow->GetNextSibling(&nextSibling);
|
1999-01-16 01:52:05 +03:00
|
|
|
parent->mFrames.SetFrames(nextSibling);
|
1998-04-17 02:21:32 +04:00
|
|
|
} else {
|
1998-04-17 05:41:24 +04:00
|
|
|
nsIFrame* nextSibling;
|
|
|
|
|
1998-04-17 02:21:32 +04:00
|
|
|
// Because the next-in-flow is not the first child of the parent
|
|
|
|
// we know that it shares a parent with aChild. Therefore, we need
|
|
|
|
// to capture the next-in-flow's next sibling (in case the
|
|
|
|
// next-in-flow is the last next-in-flow for aChild AND the
|
|
|
|
// next-in-flow is not the last child in parent)
|
1999-02-10 09:13:38 +03:00
|
|
|
aChild->GetNextSibling(&nextSibling);
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_ASSERTION(nextSibling == nextInFlow, "unexpected sibling");
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1999-02-10 09:13:38 +03:00
|
|
|
nextInFlow->GetNextSibling(&nextSibling);
|
1998-04-17 05:41:24 +04:00
|
|
|
aChild->SetNextSibling(nextSibling);
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the next-in-flow frame and adjust it's parent's child count
|
1999-07-22 06:24:52 +04:00
|
|
|
nextInFlow->Destroy(aPresContext);
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1998-04-17 05:41:24 +04:00
|
|
|
#ifdef NS_DEBUG
|
1999-02-24 07:48:08 +03:00
|
|
|
aChild->GetNextInFlow(&nextInFlow);
|
1998-04-17 05:41:24 +04:00
|
|
|
NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow");
|
|
|
|
#endif
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
|
|
|
|
1999-02-24 08:54:31 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetFrameType(nsIAtom** aType) const
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer");
|
|
|
|
*aType = nsLayoutAtoms::tableOuterFrame;
|
|
|
|
NS_ADDREF(*aType);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
1999-08-01 20:20:14 +04:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
|
|
|
/*------------------ nsITableLayout methods ------------------------------*/
|
1999-08-01 02:11:50 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
nsIDOMElement* &aCell, //out params
|
|
|
|
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
|
|
|
PRInt32& aRowSpan, PRInt32& aColSpan,
|
2000-01-26 17:56:06 +03:00
|
|
|
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
|
1999-08-01 02:11:50 +04:00
|
|
|
PRBool& aIsSelected)
|
|
|
|
{
|
|
|
|
if (!mInnerTableFrame) { return NS_ERROR_NOT_INITIALIZED; }
|
|
|
|
nsITableLayout *inner;
|
2000-02-03 01:24:56 +03:00
|
|
|
nsresult result = mInnerTableFrame->QueryInterface(NS_GET_IID(nsITableLayout), (void **)&inner);
|
1999-08-01 02:11:50 +04:00
|
|
|
if (NS_SUCCEEDED(result) && inner)
|
|
|
|
{
|
|
|
|
return (inner->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
|
|
|
aStartRowIndex, aStartColIndex,
|
2000-01-26 17:56:06 +03:00
|
|
|
aRowSpan, aColSpan, aActualRowSpan, aActualColSpan,
|
|
|
|
aIsSelected));
|
1999-08-01 02:11:50 +04:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
1999-08-01 20:20:14 +04:00
|
|
|
NS_IMETHODIMP nsTableOuterFrame::GetTableSize(PRInt32& aRowCount, PRInt32& aColCount)
|
|
|
|
{
|
|
|
|
if (!mInnerTableFrame) { return NS_ERROR_NOT_INITIALIZED; }
|
|
|
|
nsITableLayout *inner;
|
2000-02-03 01:24:56 +03:00
|
|
|
nsresult result = mInnerTableFrame->QueryInterface(NS_GET_IID(nsITableLayout), (void **)&inner);
|
1999-08-01 20:20:14 +04:00
|
|
|
if (NS_SUCCEEDED(result) && inner)
|
|
|
|
{
|
|
|
|
return (inner->GetTableSize(aRowCount, aColCount));
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------- end of nsITableLayout implementation ------------------*/
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
nsresult
|
1999-12-05 02:49:50 +03:00
|
|
|
NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
1999-05-12 02:03:29 +04:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-05 02:49:50 +03:00
|
|
|
nsTableOuterFrame* it = new (aPresShell) nsTableOuterFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-12 02:03:29 +04:00
|
|
|
*aNewFrame = it;
|
1998-04-14 00:24:54 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-03 01:59:54 +04:00
|
|
|
|
1999-11-02 01:12:45 +03:00
|
|
|
#ifdef DEBUG
|
1998-11-19 20:22:29 +03:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 04:33:42 +03:00
|
|
|
nsTableOuterFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 20:22:29 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableOuter"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-08-31 07:09:40 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 05:02:16 +04:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
PRUint32 sum = sizeof(*this);
|
|
|
|
*aResult = sum;
|
|
|
|
return NS_OK;
|
1999-08-31 07:09:40 +04:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|