2001-09-28 20:14:13 +00: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-13 20:24:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00: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-13 20:24:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2001-09-28 20:14:13 +00: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 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* 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-13 20:24:54 +00:00
|
|
|
#include "nsTableOuterFrame.h"
|
|
|
|
#include "nsTableFrame.h"
|
1998-06-09 04:51:44 +00:00
|
|
|
#include "nsIReflowCommand.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsIStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsIPresContext.h"
|
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsVoidArray.h"
|
1998-04-22 06:37:57 +00:00
|
|
|
#include "nsIPtr.h"
|
1998-07-02 17:40:56 +00:00
|
|
|
#include "prinrval.h"
|
1998-10-01 04:46:11 +00:00
|
|
|
#include "nsHTMLIIDs.h"
|
1999-02-24 05:54:31 +00:00
|
|
|
#include "nsLayoutAtoms.h"
|
1999-08-10 03:52:15 +00:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIPresShell.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-04-01 01:01:33 +00:00
|
|
|
#include "nsIAccessibilityService.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-04-01 01:01:33 +00:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2001-02-27 14:52:07 +00:00
|
|
|
#include "nsIPrintContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-03-02 06:09:37 +00:00
|
|
|
/* ----------- nsTableCaptionFrame ---------- */
|
|
|
|
|
2000-01-28 02:19:45 +00:00
|
|
|
#define NS_TABLE_FRAME_CAPTION_LIST_INDEX 0
|
2000-04-28 21:05:31 +00:00
|
|
|
#define NO_SIDE 100
|
2000-01-28 02:19:45 +00:00
|
|
|
|
|
|
|
// caption frame
|
|
|
|
nsTableCaptionFrame::nsTableCaptionFrame()
|
|
|
|
{
|
|
|
|
// shrink wrap
|
|
|
|
SetFlags(NS_BLOCK_SPACE_MGR|NS_BLOCK_WRAP_SIZE);
|
|
|
|
}
|
|
|
|
|
2000-03-02 06:09:37 +00:00
|
|
|
nsTableCaptionFrame::~nsTableCaptionFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::Destroy(nsIPresContext* aPresContext)
|
|
|
|
{
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
mCaptionFrame->Destroy(aPresContext);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsHTMLContainerFrame::Destroy(aPresContext);
|
|
|
|
}
|
|
|
|
|
2000-01-28 02:19:45 +00: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-13 20:24:54 +00:00
|
|
|
/* ----------- nsTableOuterFrame ---------- */
|
|
|
|
|
1999-08-01 18:26:45 +00:00
|
|
|
NS_IMPL_ADDREF_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(nsTableOuterFrame, nsHTMLContainerFrame)
|
|
|
|
|
2000-03-02 06:09:37 +00:00
|
|
|
nsTableOuterFrame::nsTableOuterFrame()
|
|
|
|
{
|
2001-02-07 04:31:38 +00:00
|
|
|
mPriorAvailWidth = 0;
|
2001-01-25 15:55:51 +00:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
mTimer = new nsReflowTimer(this);
|
|
|
|
#endif
|
2000-03-02 06:09:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableOuterFrame::~nsTableOuterFrame()
|
|
|
|
{
|
2001-01-25 15:55:51 +00:00
|
|
|
#ifdef DEBUG_TABLE_REFLOW_TIMING
|
|
|
|
nsTableFrame::DebugReflowDone(this);
|
|
|
|
#endif
|
2000-03-02 06:09:37 +00:00
|
|
|
}
|
|
|
|
|
1999-08-01 18:26:45 +00:00
|
|
|
nsresult nsTableOuterFrame::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
|
|
|
{
|
|
|
|
if (NULL == aInstancePtr) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
2001-04-01 01:01:33 +00:00
|
|
|
|
2000-02-02 22:24:56 +00:00
|
|
|
if (aIID.Equals(NS_GET_IID(nsITableLayout)))
|
1999-08-01 18:26:45 +00:00
|
|
|
{ // note there is no addref here, frames are not addref'd
|
|
|
|
*aInstancePtr = (void*)(nsITableLayout*)this;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-05-17 23:52:32 +00:00
|
|
|
|
|
|
|
return nsHTMLContainerFrame::QueryInterface(aIID, aInstancePtr);
|
|
|
|
}
|
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2001-05-17 23:52:32 +00: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 18:26:45 +00:00
|
|
|
}
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-05-17 23:52:32 +00:00
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::IsPercentageBase(PRBool& aBase) const
|
|
|
|
{
|
|
|
|
aBase = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-01-28 15:43:25 +00:00
|
|
|
// tables change 0 width into auto, trees override this and do nothing
|
2000-01-28 02:19:45 +00:00
|
|
|
NS_IMETHODIMP
|
2000-01-28 15:43:25 +00:00
|
|
|
nsTableOuterFrame::AdjustZeroWidth()
|
1998-09-16 17:19:20 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00: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 15:43:25 +00: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 12:35:34 +00:00
|
|
|
// record that children that are ignorable whitespace should be excluded
|
|
|
|
mState |= NS_FRAME_EXCLUDE_IGNORABLE_WHITESPACE;
|
|
|
|
|
2000-01-28 02:19:45 +00: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);
|
|
|
|
mInnerTableFrame = aChildList;
|
|
|
|
}
|
|
|
|
|
1998-09-16 17:19:20 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-10 03:52:15 +00:00
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsTableOuterFrame::AppendFrames(nsIPresContext* aPresContext,
|
1999-08-10 03:52:15 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2000-01-28 02:19:45 +00:00
|
|
|
nsresult rv;
|
1999-08-10 03:52:15 +00: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 02:19:45 +00:00
|
|
|
if (nsLayoutAtoms::captionList == aListName) {
|
1999-08-10 03:52:15 +00: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
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unexpected child frame type");
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
1999-11-24 06:03:41 +00:00
|
|
|
nsTableOuterFrame::InsertFrames(nsIPresContext* aPresContext,
|
1999-08-10 03:52:15 +00: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 06:03:41 +00:00
|
|
|
nsTableOuterFrame::RemoveFrame(nsIPresContext* aPresContext,
|
1999-08-10 03:52:15 +00:00
|
|
|
nsIPresShell& aPresShell,
|
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2000-01-28 02:19:45 +00:00
|
|
|
nsresult rv;
|
1999-08-10 03:52:15 +00: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 02:19:45 +00:00
|
|
|
NS_PRECONDITION(nsLayoutAtoms::captionList == aListName, "can't remove inner frame");
|
|
|
|
NS_PRECONDITION(aOldFrame == mCaptionFrame, "invalid caption frame");
|
1999-08-10 03:52:15 +00: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 02:19:45 +00:00
|
|
|
// Remove the caption frame and destroy it
|
|
|
|
if (mCaptionFrame && (mCaptionFrame == aOldFrame)) {
|
|
|
|
mCaptionFrame->Destroy(aPresContext);
|
|
|
|
mCaptionFrame = nsnull;
|
|
|
|
mMinCaptionWidth = 0;
|
|
|
|
}
|
1999-08-10 03:52:15 +00:00
|
|
|
|
|
|
|
// Generate a reflow command so we get reflowed
|
|
|
|
nsIReflowCommand* reflowCmd;
|
|
|
|
|
|
|
|
rv = NS_NewHTMLReflowCommand(&reflowCmd, this, nsIReflowCommand::ReflowDirty);
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
aPresShell.AppendReflowCommand(reflowCmd);
|
|
|
|
NS_RELEASE(reflowCmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-09-19 12:35:19 +00:00
|
|
|
NS_METHOD
|
|
|
|
nsTableOuterFrame::Paint(nsIPresContext* aPresContext,
|
|
|
|
nsIRenderingContext& aRenderingContext,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
PRUint32 aFlags)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-04-13 20:24:54 +00:00
|
|
|
// for debug...
|
1999-03-26 00:39:35 +00:00
|
|
|
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
|
1998-04-13 20:24:54 +00:00
|
|
|
aRenderingContext.SetColor(NS_RGB(255,0,0));
|
|
|
|
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
|
|
|
|
}
|
1999-11-01 22:12:45 +00:00
|
|
|
#endif
|
2001-01-27 14:09:34 +00:00
|
|
|
PRBool isVisible;
|
|
|
|
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_FALSE, &isVisible)) && !isVisible) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2000-01-28 02:19:45 +00: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
|
|
|
|
PRBool clipState;
|
|
|
|
|
|
|
|
// 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();
|
|
|
|
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
|
|
|
|
nsClipCombine_kIntersect, clipState);
|
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
|
|
|
aRenderingContext.PopState(clipState);
|
|
|
|
}
|
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2000-03-22 02:43:08 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetFrameForPoint(nsIPresContext* aPresContext,
|
|
|
|
const nsPoint& aPoint,
|
|
|
|
nsFramePaintLayer aWhichLayer,
|
|
|
|
nsIFrame** aFrame)
|
|
|
|
{
|
2000-05-16 11:35:12 +00: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 02:43:08 +00: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 04:44:41 +00:00
|
|
|
NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsIPresContext* aPresContext,
|
|
|
|
nsIDOMRange *aRange,
|
|
|
|
PRBool aSelected,
|
|
|
|
nsSpread aSpread)
|
1999-05-20 00:52:00 +00:00
|
|
|
{
|
1999-10-26 04:44:41 +00:00
|
|
|
nsresult result = nsFrame::SetSelected(aPresContext, aRange,aSelected, aSpread);
|
1999-05-20 00:52:00 +00:00
|
|
|
if (NS_SUCCEEDED(result) && mInnerTableFrame)
|
1999-10-26 04:44:41 +00:00
|
|
|
return mInnerTableFrame->SetSelected(aPresContext, aRange,aSelected, aSpread);
|
1999-05-20 00:52:00 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-09-12 22:48:35 +00:00
|
|
|
// GetParentStyleContextProvider:
|
|
|
|
// The innerTableFame is he parent style context provider
|
|
|
|
// Fortunately, we cache that as a data member, so just return the cached pointer value
|
|
|
|
//
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetParentStyleContextProvider(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame** aProviderFrame,
|
|
|
|
nsContextProviderRelationship& aRelationship)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(aProviderFrame && aPresContext, "null argument: aPresContext and-or aProviderFrame");
|
|
|
|
if (aProviderFrame) {
|
|
|
|
// parent context provider is the innerTableFrame
|
|
|
|
NS_ASSERTION(mInnerTableFrame, "innerTableFrame should not be null");
|
|
|
|
*aProviderFrame = mInnerTableFrame;
|
|
|
|
aRelationship = eContextProvider_Descendant;
|
|
|
|
}
|
|
|
|
return ((aProviderFrame != nsnull) && (*aProviderFrame != nsnull)) ? NS_OK : NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2000-04-28 21:05:31 +00: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 00:02:04 +00:00
|
|
|
nsTableOuterFrame::ZeroAutoMargin(nsHTMLReflowState& aReflowState,
|
|
|
|
nsMargin& aMargin)
|
2000-04-28 21:05:31 +00:00
|
|
|
{
|
2001-02-07 09:57:26 +00:00
|
|
|
if (eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetLeftUnit()) {
|
2000-04-28 21:05:31 +00:00
|
|
|
aMargin.left = 0;
|
2000-09-11 00:02:04 +00:00
|
|
|
}
|
2001-02-07 09:57:26 +00:00
|
|
|
if (eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetRightUnit()) {
|
2000-09-11 00:02:04 +00:00
|
|
|
aMargin.right = 0;
|
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-05-04 23:16:42 +00:00
|
|
|
FixAutoMargins(nscoord aAvailWidth,
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord aChildWidth,
|
2000-05-04 23:16:42 +00:00
|
|
|
nsHTMLReflowState& aReflowState)
|
2000-04-28 21:05:31 +00:00
|
|
|
{
|
2000-05-04 23:16:42 +00:00
|
|
|
// see if there are auto margins. they may have been set to 0 in mComputedMargin
|
2001-02-07 09:57:26 +00:00
|
|
|
PRBool hasAutoMargin = eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetLeftUnit() ||
|
|
|
|
eStyleUnit_Auto == aReflowState.mStyleMargin->mMargin.GetRightUnit();
|
2000-05-04 23:16:42 +00:00
|
|
|
if (hasAutoMargin) {
|
2001-03-13 06:38:59 +00:00
|
|
|
nscoord width = aChildWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == width) {
|
|
|
|
width = 0;
|
|
|
|
}
|
|
|
|
aReflowState.CalculateBlockSideMargins(aAvailWidth, width);
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the margin and padding data. nsHTMLReflowState doesn't handle the
|
|
|
|
// case of auto margins
|
|
|
|
void
|
|
|
|
GetMarginPadding(nsIPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
nsMargin& aMargin,
|
2000-09-11 00:02:04 +00:00
|
|
|
nsMargin& aMarginNoAuto,
|
|
|
|
nsMargin& aPadding)
|
2000-04-28 21:05:31 +00:00
|
|
|
{
|
|
|
|
// construct a reflow state to compute margin and padding. Auto margins
|
|
|
|
// will not be computed at this time.
|
|
|
|
nsHTMLReflowState childRS(aPresContext, aOuterRS, aChildFrame,
|
|
|
|
nsSize(aOuterRS.availableWidth, aOuterRS.availableHeight),
|
|
|
|
eReflowReason_Resize);
|
2001-03-13 06:38:59 +00:00
|
|
|
nsRect childRect;
|
|
|
|
aChildFrame->GetRect(childRect);
|
|
|
|
FixAutoMargins(aOuterRS.availableWidth, childRect.width, childRS);
|
2000-09-11 00:02:04 +00:00
|
|
|
aMargin = childRS.mComputedMargin;
|
|
|
|
aMarginNoAuto = aMargin;
|
|
|
|
nsTableOuterFrame::ZeroAutoMargin(childRS, aMarginNoAuto);
|
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
aPadding = childRS.mComputedPadding;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord CalcAutoMargin(nscoord aAutoMargin,
|
|
|
|
nscoord aOppositeMargin,
|
|
|
|
nscoord aContainBlockSize,
|
|
|
|
nscoord aFrameSize)
|
|
|
|
{
|
|
|
|
nscoord margin;
|
|
|
|
if (NS_AUTOMARGIN == aOppositeMargin) {
|
|
|
|
margin = (aContainBlockSize - aFrameSize) / 2;
|
|
|
|
}
|
|
|
|
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 00:02:04 +00:00
|
|
|
nsMargin& aMarginNoAuto,
|
2000-04-28 21:05:31 +00:00
|
|
|
nsMargin& aPadding)
|
|
|
|
{
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == aOuterWidth) return aOuterWidth;
|
|
|
|
|
2000-09-11 00:02:04 +00:00
|
|
|
nsMargin marginIgnore;
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, aChildFrame, marginIgnore, aMarginNoAuto, aPadding);
|
2000-04-28 21:05:31 +00:00
|
|
|
nscoord width = aOuterWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != width) {
|
2001-06-06 07:35:03 +00:00
|
|
|
width = aOuterWidth - aMarginNoAuto.left - aMarginNoAuto.right;
|
2000-04-28 21:05:31 +00: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 06:38:59 +00:00
|
|
|
nsTableFrame::RePositionViews(aPresContext, aFrame);
|
2000-04-28 21:05:31 +00: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-25 22:40:21 +00:00
|
|
|
if (!aInnerChanged && !aCaptionChanged) return;
|
|
|
|
|
2000-04-28 21:05:31 +00: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 14:51:37 +00:00
|
|
|
case NS_SIDE_BOTTOM:
|
2000-04-28 21:05:31 +00:00
|
|
|
if (aCaptionChanged) {
|
2000-05-10 14:51:37 +00:00
|
|
|
damage.y = innerRect.y;
|
|
|
|
damage.height = aOuterSize.height - damage.y;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-05-10 14:51:37 +00:00
|
|
|
damage.y = 0;
|
|
|
|
damage.height = captionRect.y;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (aCaptionChanged) {
|
2000-05-10 14:51:37 +00:00
|
|
|
damage.y = 0;
|
|
|
|
damage.height = innerRect.y;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
else {
|
2000-05-10 14:51:37 +00:00
|
|
|
damage.y = captionRect.y;
|
|
|
|
damage.height = aOuterSize.height - damage.y;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
2000-05-10 14:51:37 +00:00
|
|
|
break;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
Invalidate(aPresContext, damage);
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsTableOuterFrame::GetCaptionAvailWidth(nsIPresContext* aPresContext,
|
|
|
|
nsIFrame* aCaptionFrame,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nscoord* aInnerWidth,
|
2000-09-11 00:02:04 +00:00
|
|
|
const nsMargin* aInnerMarginNoAuto)
|
2000-04-28 21:05:31 +00:00
|
|
|
{
|
|
|
|
nscoord outerWidth;
|
|
|
|
if (aInnerWidth) {
|
|
|
|
nscoord innerWidth = *aInnerWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == innerWidth) {
|
|
|
|
outerWidth = innerWidth;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsMargin innerMargin(0,0,0,0);
|
2000-09-11 00:02:04 +00:00
|
|
|
if (aInnerMarginNoAuto) {
|
|
|
|
innerMargin = *aInnerMarginNoAuto;
|
2000-04-28 21:05:31 +00: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 06:38:59 +00:00
|
|
|
nsSize size(0,0);
|
|
|
|
size.width += aInnerMargin.left +
|
|
|
|
((nsTableFrame *)mInnerTableFrame)->GetMinWidth() +
|
|
|
|
aInnerMargin.right;
|
2000-04-28 21:05:31 +00:00
|
|
|
if (mCaptionFrame) {
|
|
|
|
nscoord capWidth = mMinCaptionWidth + aCaptionMargin.left + aCaptionMargin.right;
|
|
|
|
if (capWidth > size.width) {
|
|
|
|
size.width = capWidth;
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
// leave max element height set to 0. It is not used for anything
|
2000-04-28 21:05:31 +00: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 06:38:59 +00:00
|
|
|
maxWidth = ((nsTableFrame *)mInnerTableFrame)->GetPreferredWidth() +
|
|
|
|
aInnerMargin.left + aInnerMargin.right;
|
2000-04-28 21:05:31 +00:00
|
|
|
if (mCaptionFrame) {
|
|
|
|
maxWidth = PR_MAX(maxWidth, mMinCaptionWidth + aCaptionMargin.left + aCaptionMargin.right);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return maxWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRUint8
|
|
|
|
nsTableOuterFrame::GetCaptionSide()
|
1998-06-19 00:34:12 +00:00
|
|
|
{
|
2001-05-31 22:19:43 +00:00
|
|
|
const nsStyleTableBorder* tableStyle;
|
2000-04-28 21:05:31 +00:00
|
|
|
if (mCaptionFrame) {
|
2001-05-31 22:19:43 +00:00
|
|
|
mCaptionFrame->GetStyleData(eStyleStruct_TableBorder, ((const nsStyleStruct *&)tableStyle));
|
2000-04-28 21:05:31 +00: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 00:34:12 +00:00
|
|
|
|
2000-04-28 21:05:31 +00: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 00:34:12 +00:00
|
|
|
|
|
|
|
|
2000-04-28 21:05:31 +00: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;
|
|
|
|
|
2000-05-10 14:51:37 +00:00
|
|
|
nscoord collapseMargin;
|
2000-04-28 21:05:31 +00:00
|
|
|
switch(aCaptionSide) {
|
2000-05-10 14:51:37 +00:00
|
|
|
case NS_SIDE_BOTTOM:
|
2000-04-28 21:05:31 +00:00
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.left) {
|
|
|
|
aCaptionMargin.left = CalcAutoMargin(aCaptionMargin.left, aCaptionMargin.right,
|
|
|
|
aContainBlockSize.width, aCaptionSize.width);
|
|
|
|
}
|
|
|
|
aOrigin.x = aCaptionMargin.left;
|
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.top) {
|
2000-05-10 14:51:37 +00:00
|
|
|
aCaptionMargin.top = 0;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
2000-05-10 14:51:37 +00: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,
|
|
|
|
aContainBlockSize.height, height);
|
|
|
|
}
|
|
|
|
aOrigin.y = aInnerMargin.top + aInnerSize.height + collapseMargin;
|
2000-04-28 21:05:31 +00:00
|
|
|
break;
|
2000-05-10 14:51:37 +00:00
|
|
|
default: // all others are treated as top for now
|
2000-04-28 21:05:31 +00:00
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.left) {
|
|
|
|
aCaptionMargin.left = CalcAutoMargin(aCaptionMargin.left, aCaptionMargin.right,
|
|
|
|
aContainBlockSize.width, aCaptionSize.width);
|
|
|
|
}
|
|
|
|
aOrigin.x = aCaptionMargin.left;
|
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.bottom) {
|
2000-05-10 14:51:37 +00:00
|
|
|
aCaptionMargin.bottom = 0;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
2000-05-10 14:51:37 +00: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,
|
|
|
|
aContainBlockSize.height, height);
|
|
|
|
}
|
|
|
|
aOrigin.y = aCaptionMargin.top;
|
2000-04-28 21:05:31 +00:00
|
|
|
break;
|
2000-05-10 14:51:37 +00:00
|
|
|
|
2000-04-28 21:05:31 +00: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord collapseMargin;
|
|
|
|
switch(aCaptionSide) {
|
2000-05-10 14:51:37 +00:00
|
|
|
case NS_SIDE_BOTTOM:
|
2000-04-28 21:05:31 +00:00
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.left) {
|
|
|
|
aInnerMargin.left = CalcAutoMargin(aInnerMargin.left, aInnerMargin.right,
|
|
|
|
aContainBlockSize.width, aInnerSize.width);
|
|
|
|
}
|
|
|
|
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,
|
|
|
|
aContainBlockSize.height, height);
|
|
|
|
}
|
|
|
|
aOrigin.y = aInnerMargin.top;
|
|
|
|
break;
|
2000-05-10 14:51:37 +00:00
|
|
|
|
|
|
|
default: // all others are treated as top for now
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.left) {
|
|
|
|
aInnerMargin.left = CalcAutoMargin(aInnerMargin.left, aInnerMargin.right,
|
|
|
|
aContainBlockSize.width, aInnerSize.width);
|
|
|
|
}
|
|
|
|
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,
|
|
|
|
aContainBlockSize.height, height);
|
|
|
|
}
|
|
|
|
aOrigin.y = aCaptionMargin.top + aCaptionSize.height + collapseMargin;
|
|
|
|
break;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-03-28 21:19:31 +00: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-28 21:05:31 +00: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 00:02:04 +00:00
|
|
|
nsMargin& aMarginNoAuto,
|
2000-04-28 21:05:31 +00:00
|
|
|
nsMargin& aPadding,
|
|
|
|
nsReflowReason aReflowReason,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
aMargin = aPadding = nsMargin(0,0,0,0);
|
|
|
|
|
|
|
|
nscoord availWidth = GetChildAvailWidth(aPresContext, aChildFrame, aOuterRS,
|
|
|
|
aOuterRS.availableWidth, aMargin, aPadding);
|
|
|
|
if (aAvailWidth) {
|
|
|
|
availWidth = *aAvailWidth;
|
|
|
|
}
|
2001-11-07 02:38:49 +00: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);
|
|
|
|
}
|
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
nsHTMLReflowState childRS(aPresContext, aOuterRS, aChildFrame,
|
|
|
|
nsSize(availWidth, aOuterRS.availableHeight));
|
|
|
|
childRS.reason = aReflowReason;
|
|
|
|
|
2001-11-01 04:17:30 +00: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-28 21:19:31 +00: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 04:17:30 +00:00
|
|
|
if ( ((aChildFrame == mInnerTableFrame) &&
|
|
|
|
((nsTableFrame*)aChildFrame)->GetMinWidth() <= childRS.availableWidth) ||
|
|
|
|
(aChildFrame != mInnerTableFrame)) {
|
|
|
|
childRS.mComputedWidth = childRS.availableWidth - childRS.mComputedBorderPadding.left -
|
|
|
|
childRS.mComputedBorderPadding.right;
|
|
|
|
}
|
2000-05-01 02:25:08 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00: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 06:38:59 +00:00
|
|
|
FixAutoMargins(aOuterRS.availableWidth, aMetrics.width, childRS);
|
2000-04-28 21:05:31 +00:00
|
|
|
aMargin = childRS.mComputedMargin;
|
2000-09-11 00:02:04 +00:00
|
|
|
aMarginNoAuto = childRS.mComputedMargin;
|
|
|
|
ZeroAutoMargin(childRS, aMarginNoAuto);
|
2000-04-28 21:05:31 +00:00
|
|
|
|
|
|
|
aDesiredSize.width = aMetrics.width;
|
|
|
|
aDesiredSize.height = aMetrics.height;
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableOuterFrame::UpdateReflowMetrics(PRUint8 aCaptionSide,
|
|
|
|
nsHTMLReflowMetrics& aMet,
|
|
|
|
const nsMargin& aInnerMargin,
|
2000-09-11 00:02:04 +00:00
|
|
|
const nsMargin& aInnerMarginNoAuto,
|
2000-04-28 21:05:31 +00:00
|
|
|
const nsMargin& aInnerPadding,
|
2000-09-11 00:02:04 +00:00
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
const nsMargin& aCaptionMarginNoAuto)
|
2000-04-28 21:05:31 +00:00
|
|
|
{
|
|
|
|
SetDesiredSize(aCaptionSide, aInnerMargin, aCaptionMargin, aMet.width, aMet.height);
|
|
|
|
|
|
|
|
// set maxElementSize width if requested
|
|
|
|
if (aMet.maxElementSize) {
|
2000-09-11 00:02:04 +00:00
|
|
|
*aMet.maxElementSize = GetMaxElementSize(aInnerMarginNoAuto, aInnerPadding, aCaptionMarginNoAuto);
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
// set maximum width if requested
|
|
|
|
if (aMet.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
|
2000-09-11 00:02:04 +00:00
|
|
|
aMet.mMaximumWidth = GetMaxWidth(aCaptionSide, aInnerMarginNoAuto, aCaptionMarginNoAuto);
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IncrementalReflow(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-06-19 00:34:12 +00:00
|
|
|
{
|
1998-10-01 04:46:11 +00:00
|
|
|
nsresult rv = NS_OK;
|
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
// determine if this frame is the target or not
|
1999-04-04 00:06:48 +00:00
|
|
|
nsIFrame* target=nsnull;
|
2000-04-28 21:05:31 +00:00
|
|
|
rv = aReflowState.reflowCommand->GetTarget(target);
|
|
|
|
if (NS_SUCCEEDED(rv) && target) {
|
1999-04-04 00:06:48 +00:00
|
|
|
if (this == target) {
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_TargetIsMe(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-10-08 15:34:48 +00:00
|
|
|
// Get the next frame in the reflow chain
|
|
|
|
nsIFrame* nextFrame;
|
2000-04-28 21:05:31 +00:00
|
|
|
aReflowState.reflowCommand->GetNext(nextFrame);
|
2000-01-26 22:11:47 +00:00
|
|
|
NS_ASSERTION(nextFrame, "next frame in reflow command is null");
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_TargetIsChild(aPresContext, aDesiredSize, aReflowState, aStatus, nextFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_TargetIsChild(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
nsIFrame* aNextFrame)
|
1998-10-08 15:34:48 +00:00
|
|
|
{
|
|
|
|
nsresult rv;
|
2000-01-28 02:19:45 +00:00
|
|
|
if (!aNextFrame) {
|
|
|
|
// this will force Reflow to return the height of the last reflow rather than 0
|
2000-04-28 21:05:31 +00:00
|
|
|
aDesiredSize.height = mRect.height;
|
1999-07-02 05:28:32 +00:00
|
|
|
return NS_OK;
|
2000-01-28 02:19:45 +00:00
|
|
|
}
|
1999-07-02 05:28:32 +00:00
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
if (aNextFrame == mInnerTableFrame) {
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
else if (aNextFrame == mCaptionFrame) {
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = IR_TargetIsCaptionFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-10-21 22:29:00 +00: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 00:06:48 +00:00
|
|
|
NS_STYLE_DISPLAY_TABLE_COLUMN_GROUP==nextDisplay->mDisplay) {
|
1998-10-21 22:29:00 +00:00
|
|
|
rv = IR_TargetIsInnerTableFrame(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
|
|
|
else {
|
1998-10-21 22:29:00 +00:00
|
|
|
NS_ASSERTION(PR_FALSE, "illegal next frame in incremental reflow.");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
}
|
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_TargetIsInnerTableFrame(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 15:34:48 +00:00
|
|
|
{
|
|
|
|
nsresult rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 05:21:45 +00:00
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_TargetIsCaptionFrame(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 15:34:48 +00:00
|
|
|
{
|
2000-04-28 21:05:31 +00:00
|
|
|
nsresult rv = NS_OK;
|
2000-05-04 23:16:42 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2000-04-28 21:05:31 +00:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
|
|
|
|
nsSize captionSize, captionMES;
|
2000-09-11 00:02:04 +00:00
|
|
|
nsMargin captionMargin, captionMarginNoAuto, captionPadding;
|
2000-04-28 21:05:31 +00:00
|
|
|
// reflow the caption frame, getting it's MES
|
|
|
|
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS);
|
|
|
|
nsHTMLReflowMetrics captionMet(&captionMES);
|
2000-05-04 23:16:42 +00:00
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
2000-04-28 21:05:31 +00:00
|
|
|
OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, &availWidth, captionSize,
|
2000-09-11 00:02:04 +00:00
|
|
|
captionMargin, captionMarginNoAuto, captionPadding, eReflowReason_Incremental, capStatus);
|
2000-05-25 22:40:21 +00:00
|
|
|
|
2000-09-11 00:02:04 +00:00
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
2000-04-28 21:05:31 +00:00
|
|
|
nsPoint innerOrigin;
|
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
|
|
|
|
|
|
|
// for now just reflow the table if a style changed. This should be improved
|
1998-10-09 19:59:45 +00:00
|
|
|
nsIReflowCommand::ReflowType reflowCommandType;
|
2000-04-28 21:05:31 +00:00
|
|
|
aOuterRS.reflowCommand->GetType(reflowCommandType);
|
|
|
|
PRBool needInnerReflow = (nsIReflowCommand::StyleChanged == reflowCommandType)
|
|
|
|
? PR_TRUE : PR_FALSE;
|
|
|
|
|
1999-04-04 00:06:48 +00:00
|
|
|
if (mMinCaptionWidth != captionMES.width) {
|
|
|
|
// set the new caption min width, and set state to reflow the inner table if necessary
|
1998-10-09 19:59:45 +00:00
|
|
|
mMinCaptionWidth = captionMES.width;
|
2000-04-28 21:05:31 +00: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 00:02:04 +00:00
|
|
|
if ((mMinCaptionWidth + captionMarginNoAuto.left + captionMarginNoAuto.right) > mRect.width) {
|
2000-04-28 21:05:31 +00:00
|
|
|
needInnerReflow = PR_TRUE;
|
1999-04-04 00:06:48 +00:00
|
|
|
}
|
1998-10-09 19:59:45 +00:00
|
|
|
}
|
|
|
|
|
2000-05-25 22:40:21 +00:00
|
|
|
nsRect prevInnerRect;
|
|
|
|
mInnerTableFrame->GetRect(prevInnerRect);
|
2000-04-28 21:05:31 +00:00
|
|
|
nsPoint captionOrigin;
|
|
|
|
if (needInnerReflow) {
|
|
|
|
nsSize innerSize;
|
|
|
|
nsHTMLReflowMetrics innerMet(nsnull);
|
|
|
|
OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet, nsnull, innerSize,
|
2000-09-11 00:02:04 +00:00
|
|
|
innerMargin, innerMarginNoAuto, innerPadding, eReflowReason_Resize, aStatus);
|
2000-04-28 21:05:31 +00:00
|
|
|
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
|
|
|
rv = FinishReflowChild(mInnerTableFrame, aPresContext, innerMet,
|
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
1998-10-09 19:59:45 +00:00
|
|
|
}
|
1999-04-04 00:06:48 +00:00
|
|
|
else {
|
2000-04-28 21:05:31 +00: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 00:02:04 +00:00
|
|
|
innerMarginNoAuto, innerPadding);
|
2000-04-28 21:05:31 +00: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 19:59:45 +00:00
|
|
|
}
|
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
rv = FinishReflowChild(mCaptionFrame, aPresContext, captionMet,
|
|
|
|
captionOrigin.x, captionOrigin.y, 0);
|
1998-10-09 19:59:45 +00:00
|
|
|
|
2000-09-11 00:02:04 +00:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, captionMargin, captionMarginNoAuto);
|
2000-04-28 21:05:31 +00:00
|
|
|
nsSize desSize(aDesiredSize.width, aDesiredSize.height);
|
2000-05-25 22:40:21 +00:00
|
|
|
PRBool innerMoved = (innerOrigin.x != prevInnerRect.x) || (innerOrigin.y != prevInnerRect.y);
|
|
|
|
InvalidateDamage(aPresContext, captionSide, desSize, innerMoved, PR_TRUE);
|
1998-10-08 15:34:48 +00:00
|
|
|
return rv;
|
|
|
|
}
|
1998-06-19 05:21:45 +00:00
|
|
|
|
1999-08-10 03:52:15 +00:00
|
|
|
nsresult
|
2000-04-28 21:05:31 +00:00
|
|
|
nsTableOuterFrame::IR_ReflowDirty(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 15:34:48 +00:00
|
|
|
{
|
1999-08-10 03:52:15 +00:00
|
|
|
nsFrameState frameState;
|
2001-02-07 04:00:40 +00:00
|
|
|
nsresult rv = NS_OK;
|
2000-04-28 21:05:31 +00:00
|
|
|
PRBool sizeSet = PR_FALSE;
|
1999-08-10 03:52:15 +00: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-28 21:05:31 +00:00
|
|
|
sizeSet = PR_TRUE;
|
1999-08-10 03:52:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if the inner table frame is dirty
|
|
|
|
mInnerTableFrame->GetFrameState(&frameState);
|
|
|
|
if (frameState & NS_FRAME_IS_DIRTY) {
|
1999-08-01 22:01:37 +00:00
|
|
|
rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
2000-04-28 21:05:31 +00:00
|
|
|
sizeSet = PR_TRUE;
|
|
|
|
}
|
|
|
|
else if (!mCaptionFrame) {
|
1999-08-10 03:52:15 +00: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-28 21:05:31 +00:00
|
|
|
nsRect innerRect;
|
1999-08-10 03:52:15 +00:00
|
|
|
mInnerTableFrame->GetRect(innerRect);
|
2000-04-28 21:05:31 +00:00
|
|
|
nsSize innerSize(innerRect.width, innerRect.height);
|
|
|
|
nsPoint innerOrigin;
|
2000-09-11 00:02:04 +00:00
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
2000-04-28 21:05:31 +00:00
|
|
|
GetMarginPadding(aPresContext, aReflowState, mInnerTableFrame, innerMargin,
|
2000-09-11 00:02:04 +00:00
|
|
|
innerMarginNoAuto, innerPadding);
|
2000-04-28 21:05:31 +00: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-25 22:40:21 +00: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-28 21:05:31 +00: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 05:21:45 +00:00
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
|
1999-08-10 03:52:15 +00:00
|
|
|
return rv;
|
|
|
|
}
|
1998-06-23 05:43:27 +00:00
|
|
|
|
1999-08-10 03:52:15 +00:00
|
|
|
// IR_TargetIsMe is free to foward the request to the inner table frame
|
2000-04-28 21:05:31 +00:00
|
|
|
nsresult nsTableOuterFrame::IR_TargetIsMe(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-08-10 03:52:15 +00:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
nsIReflowCommand::ReflowType type;
|
2000-04-28 21:05:31 +00:00
|
|
|
aReflowState.reflowCommand->GetType(type);
|
1999-08-10 03:52:15 +00:00
|
|
|
nsIFrame* objectFrame;
|
2000-04-28 21:05:31 +00:00
|
|
|
aReflowState.reflowCommand->GetChildFrame(objectFrame);
|
1999-08-10 03:52:15 +00:00
|
|
|
switch (type) {
|
|
|
|
case nsIReflowCommand::ReflowDirty:
|
1999-08-19 19:52:37 +00:00
|
|
|
rv = IR_ReflowDirty(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-08 15:34:48 +00:00
|
|
|
break;
|
1998-09-30 18:11:48 +00:00
|
|
|
|
1999-08-19 19:52:37 +00:00
|
|
|
case nsIReflowCommand::StyleChanged :
|
2001-03-13 06:38:59 +00:00
|
|
|
case nsIReflowCommand::Timeout :
|
1998-10-30 07:57:44 +00:00
|
|
|
rv = IR_InnerTableReflow(aPresContext, aDesiredSize, aReflowState, aStatus);
|
1998-10-08 15:34:48 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case nsIReflowCommand::ContentChanged :
|
|
|
|
NS_ASSERTION(PR_FALSE, "illegal reflow type: ContentChanged");
|
|
|
|
rv = NS_ERROR_ILLEGAL_VALUE;
|
|
|
|
break;
|
1998-10-01 04:46:11 +00:00
|
|
|
|
1999-03-05 04:19:09 +00:00
|
|
|
default:
|
1999-08-10 03:52:15 +00:00
|
|
|
NS_NOTYETIMPLEMENTED("unexpected reflow command type");
|
1998-10-08 15:34:48 +00:00
|
|
|
rv = NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_InnerTableReflow(nsIPresContext* aPresContext,
|
2001-01-25 16:00:59 +00:00
|
|
|
nsHTMLReflowMetrics& aOuterMet,
|
2000-04-28 21:05:31 +00:00
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 15:34:48 +00:00
|
|
|
{
|
2000-05-04 23:16:42 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2000-04-28 21:05:31 +00:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
|
|
|
|
nsRect priorInnerRect;
|
|
|
|
mInnerTableFrame->GetRect(priorInnerRect);
|
|
|
|
|
|
|
|
nsSize innerSize;
|
2000-09-11 00:02:04 +00:00
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
2000-04-28 21:05:31 +00:00
|
|
|
|
2001-03-13 06:38:59 +00: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 03:04:05 +00:00
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
nsresult rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet,
|
2000-09-11 00:02:04 +00:00
|
|
|
nsnull, innerSize, innerMargin, innerMarginNoAuto, innerPadding,
|
2000-04-28 21:05:31 +00:00
|
|
|
eReflowReason_Incremental, aStatus);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2000-01-11 15:55:31 +00:00
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
nsPoint innerOrigin(0,0);
|
2000-02-12 01:55:40 +00:00
|
|
|
nsMargin captionMargin(0,0,0,0);
|
2000-09-11 00:02:04 +00:00
|
|
|
nsMargin captionMarginNoAuto(0,0,0,0);
|
2000-05-04 14:49:35 +00:00
|
|
|
nsSize captionSize(0,0);
|
2000-04-28 21:05:31 +00:00
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
2000-05-25 22:40:21 +00:00
|
|
|
PRBool captionMoved = PR_FALSE;
|
2000-04-28 21:05:31 +00: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-25 22:40:21 +00:00
|
|
|
nsPoint captionOrigin;
|
|
|
|
nsRect prevCaptionRect;
|
|
|
|
mCaptionFrame->GetRect(prevCaptionRect);
|
|
|
|
|
2000-04-28 21:05:31 +00: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 00:02:04 +00:00
|
|
|
&innerSize.width, &innerMarginNoAuto);
|
2000-05-04 23:16:42 +00:00
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
2000-04-28 21:05:31 +00:00
|
|
|
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, &availWidth,
|
2000-09-11 00:02:04 +00:00
|
|
|
captionSize, captionMargin, captionMarginNoAuto,
|
|
|
|
ignorePadding, eReflowReason_Resize, capStatus);
|
2000-04-28 21:05:31 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
|
|
|
FinishReflowChild(mCaptionFrame, aPresContext, captionMet,
|
|
|
|
captionOrigin.x, captionOrigin.y, 0);
|
|
|
|
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
1998-10-08 15:34:48 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
else {
|
|
|
|
// reposition the caption frame if necessary and set the inner's origin
|
2000-05-04 14:49:35 +00:00
|
|
|
captionSize = GetFrameSize(*mCaptionFrame);
|
2000-04-28 21:05:31 +00:00
|
|
|
nsMargin captionPadding;
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mCaptionFrame, captionMargin,
|
2000-09-11 00:02:04 +00:00
|
|
|
captionMarginNoAuto, captionPadding);
|
2000-04-28 21:05:31 +00: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 15:34:48 +00:00
|
|
|
}
|
2000-05-25 22:40:21 +00: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 15:34:48 +00:00
|
|
|
}
|
2000-05-04 14:49:35 +00:00
|
|
|
else {
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
|
|
|
}
|
1998-10-08 15:34:48 +00:00
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
FinishReflowChild(mInnerTableFrame, aPresContext, innerMet,
|
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
|
2001-01-25 16:00:59 +00:00
|
|
|
UpdateReflowMetrics(captionSide, aOuterMet, innerMargin, innerMarginNoAuto,
|
2000-09-11 00:02:04 +00:00
|
|
|
innerPadding, captionMargin, captionMarginNoAuto);
|
2001-01-25 16:00:59 +00:00
|
|
|
nsSize desSize(aOuterMet.width, aOuterMet.height);
|
2001-10-22 14:24:54 +00:00
|
|
|
InvalidateDamage(aPresContext, captionSide, desSize, (innerSize.width != priorInnerRect.width), captionMoved);
|
1998-10-09 19:59:45 +00:00
|
|
|
|
1998-10-08 15:34:48 +00: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-28 21:05:31 +00:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::IR_CaptionInserted(nsIPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
2000-05-04 23:16:42 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-10-08 15:34:48 +00:00
|
|
|
|
|
|
|
// reflow the caption frame, getting it's MES
|
2000-04-28 21:05:31 +00:00
|
|
|
nsSize captionSize;
|
2000-09-11 00:02:04 +00:00
|
|
|
nsMargin captionMargin, captionMarginNoAuto, ignorePadding;
|
2000-04-28 21:05:31 +00:00
|
|
|
nsSize maxElementSize(0,0);
|
|
|
|
nsHTMLReflowMetrics captionMet(&maxElementSize);
|
|
|
|
// reflow the caption
|
|
|
|
nscoord availWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS);
|
2000-05-04 23:16:42 +00:00
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
2000-04-28 21:05:31 +00:00
|
|
|
nsresult rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet,
|
2000-09-11 00:02:04 +00:00
|
|
|
&availWidth, captionSize, captionMargin, captionMarginNoAuto,
|
|
|
|
ignorePadding, eReflowReason_Initial, capStatus);
|
2000-04-28 21:05:31 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
1999-10-30 02:52:11 +00:00
|
|
|
mMinCaptionWidth = maxElementSize.width;
|
2000-04-28 21:05:31 +00:00
|
|
|
|
|
|
|
nsPoint captionOrigin(0,0);
|
|
|
|
|
2000-09-11 00:02:04 +00:00
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
2000-05-25 22:40:21 +00:00
|
|
|
nsPoint innerOrigin;
|
2000-04-28 21:05:31 +00:00
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
2000-05-25 22:40:21 +00:00
|
|
|
nsRect prevInnerRect;
|
|
|
|
mInnerTableFrame->GetRect(prevInnerRect);
|
1999-10-30 02:52:11 +00:00
|
|
|
// XXX: caption align = left|right ignored here!
|
2000-04-28 21:05:31 +00:00
|
|
|
// if the caption's MES + margins > outer width, reflow the inner table
|
2000-09-11 00:02:04 +00:00
|
|
|
if (mMinCaptionWidth + captionMarginNoAuto.left + captionMarginNoAuto.right > mRect.width) {
|
2000-04-28 21:05:31 +00:00
|
|
|
nsHTMLReflowMetrics innerMet(aDesiredSize.maxElementSize);
|
|
|
|
nsSize innerSize;
|
|
|
|
|
|
|
|
rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet,
|
2000-09-11 00:02:04 +00:00
|
|
|
nsnull, innerSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, eReflowReason_Resize, aStatus);
|
2000-04-28 21:05:31 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
|
|
|
rv = FinishReflowChild(mInnerTableFrame, aPresContext, innerMet,
|
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
1999-10-30 02:52:11 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00: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 00:02:04 +00:00
|
|
|
innerMarginNoAuto, innerPadding);
|
2000-04-28 21:05:31 +00: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 15:34:48 +00:00
|
|
|
}
|
1999-10-30 02:52:11 +00:00
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
rv = FinishReflowChild(mCaptionFrame, aPresContext, captionMet,
|
|
|
|
captionOrigin.x, captionOrigin.y, 0);
|
|
|
|
|
2000-09-11 00:02:04 +00:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, captionMargin, captionMarginNoAuto);
|
2000-04-28 21:05:31 +00:00
|
|
|
nsSize desSize(aDesiredSize.width, aDesiredSize.height);
|
2000-05-25 22:40:21 +00:00
|
|
|
PRBool innerMoved = (innerOrigin.x != prevInnerRect.x) || (innerOrigin.y != prevInnerRect.y);
|
|
|
|
InvalidateDamage(aPresContext, captionSide, desSize, innerMoved, PR_TRUE);
|
2000-04-28 21:05:31 +00:00
|
|
|
|
1998-10-08 15:34:48 +00:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
1999-09-02 00:07:14 +00:00
|
|
|
PRBool nsTableOuterFrame::IR_CaptionChangedAxis(const nsStyleTable* aOldStyle,
|
|
|
|
const nsStyleTable* aNewStyle) const
|
1998-10-09 19:59:45 +00:00
|
|
|
{
|
|
|
|
PRBool result = PR_FALSE;
|
|
|
|
//XXX: write me to support left|right captions!
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
|
2001-08-06 14:23:50 +00: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 19:59:45 +00:00
|
|
|
|
1998-07-09 14:30:34 +00: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-13 20:24:54 +00:00
|
|
|
*/
|
1999-11-24 06:03:41 +00:00
|
|
|
NS_METHOD nsTableOuterFrame::Reflow(nsIPresContext* aPresContext,
|
1999-04-04 00:06:48 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2000-04-28 21:05:31 +00:00
|
|
|
const nsHTMLReflowState& aOuterRS,
|
1999-04-04 00:06:48 +00:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2000-11-30 21:51:21 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableOuterFrame", aOuterRS.reason);
|
2001-10-29 01:43:59 +00:00
|
|
|
DISPLAY_REFLOW(this, aOuterRS, aDesiredSize, aStatus);
|
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 15:55:51 +00:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aOuterRS);
|
|
|
|
#endif
|
2000-04-28 21:05:31 +00:00
|
|
|
|
1998-10-09 19:59:45 +00:00
|
|
|
nsresult rv = NS_OK;
|
2000-04-28 21:05:31 +00:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
|
1998-06-22 21:59:43 +00:00
|
|
|
// Initialize out parameters
|
2000-04-28 21:05:31 +00:00
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
1998-05-25 17:31:49 +00:00
|
|
|
if (nsnull != aDesiredSize.maxElementSize) {
|
2000-04-28 21:05:31 +00:00
|
|
|
aDesiredSize.maxElementSize->width = 0;
|
1998-05-25 17:31:49 +00:00
|
|
|
aDesiredSize.maxElementSize->height = 0;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-06-22 21:59:43 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
PRBool isPaginated;
|
|
|
|
aPresContext->IsPaginated(&isPaginated);
|
|
|
|
PRBool needUpdateMetrics = PR_TRUE;
|
|
|
|
|
2001-06-13 02:27:22 +00:00
|
|
|
if ((eReflowReason_Resize == aOuterRS.reason) &&
|
2001-03-13 06:38:59 +00:00
|
|
|
(aOuterRS.availableWidth == mPriorAvailWidth) &&
|
2001-08-06 14:23:50 +00:00
|
|
|
!isPaginated &&
|
|
|
|
!::IsPctHeight(mInnerTableFrame)) {
|
2001-03-13 06:38:59 +00: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 00:53:29 +00:00
|
|
|
|
|
|
|
// 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 06:38:59 +00:00
|
|
|
}
|
|
|
|
else if (eReflowReason_Incremental == aOuterRS.reason) {
|
2000-04-28 21:05:31 +00:00
|
|
|
rv = IncrementalReflow(aPresContext, aDesiredSize, aOuterRS, aStatus);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (eReflowReason_Initial == aOuterRS.reason) {
|
1998-06-22 21:59:43 +00: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 06:03:41 +00:00
|
|
|
MoveOverflowToChildList(aPresContext);
|
1998-06-22 21:59:43 +00:00
|
|
|
|
1998-07-09 14:30:34 +00:00
|
|
|
// Lay out the caption and get its maximum element size
|
1998-07-08 20:21:17 +00:00
|
|
|
if (nsnull != mCaptionFrame) {
|
2000-02-04 02:47:13 +00:00
|
|
|
nsSize maxElementSize;
|
2000-04-28 21:05:31 +00:00
|
|
|
nsHTMLReflowMetrics captionMet(&maxElementSize);
|
|
|
|
captionMet.maxElementSize = &maxElementSize;
|
|
|
|
nsHTMLReflowState captionReflowState(aPresContext, aOuterRS, mCaptionFrame,
|
2000-02-04 02:47:13 +00:00
|
|
|
nsSize(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE),
|
|
|
|
eReflowReason_Initial);
|
1998-10-01 04:46:11 +00:00
|
|
|
|
1999-10-30 02:52:11 +00:00
|
|
|
mCaptionFrame->WillReflow(aPresContext);
|
2000-04-28 21:05:31 +00:00
|
|
|
rv = mCaptionFrame->Reflow(aPresContext, captionMet, captionReflowState, aStatus);
|
1999-11-19 15:33:29 +00:00
|
|
|
mCaptionFrame->DidReflow(aPresContext, NS_FRAME_REFLOW_FINISHED);
|
1999-10-30 02:52:11 +00:00
|
|
|
mMinCaptionWidth = maxElementSize.width;
|
1998-07-08 20:21:17 +00:00
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
}
|
2001-03-13 06:38:59 +00: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 14:52:07 +00:00
|
|
|
|
2001-03-13 06:38:59 +00: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-28 21:05:31 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
1998-07-09 14:30:34 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
nsPoint captionOrigin;
|
2000-04-28 21:05:31 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
|
|
|
FinishReflowChild(mCaptionFrame, aPresContext, captionMet,
|
|
|
|
captionOrigin.x, captionOrigin.y, 0);
|
1999-11-19 15:33:29 +00:00
|
|
|
|
2001-03-13 06:38:59 +00:00
|
|
|
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2000-04-28 21:05:31 +00:00
|
|
|
|
2001-03-13 06:38:59 +00: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 04:31:38 +00:00
|
|
|
}
|
2001-03-13 06:38:59 +00:00
|
|
|
|
|
|
|
FinishReflowChild(mInnerTableFrame, aPresContext, innerMet,
|
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
|
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, captionMargin, captionMarginNoAuto);
|
|
|
|
needUpdateMetrics = PR_FALSE;
|
1998-06-19 05:21:45 +00:00
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
|
1998-07-09 14:30:34 +00:00
|
|
|
// Return our desired rect
|
1999-04-04 00:06:48 +00:00
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
1998-07-02 21:24:56 +00:00
|
|
|
aDesiredSize.descent = 0;
|
2001-03-13 06:38:59 +00: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-29 22:30:09 +00: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 06:38:59 +00:00
|
|
|
#endif
|
|
|
|
|
2001-02-07 04:31:38 +00:00
|
|
|
mPriorAvailWidth = aOuterRS.availableWidth;
|
1998-06-19 05:21:45 +00:00
|
|
|
|
2001-10-29 01:43:59 +00:00
|
|
|
#if defined DEBUG_TABLE_REFLOW_TIMING
|
2001-01-25 15:55:51 +00:00
|
|
|
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aOuterRS, &aDesiredSize, aStatus);
|
|
|
|
#endif
|
1998-10-09 19:59:45 +00:00
|
|
|
return rv;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
NS_METHOD nsTableOuterFrame::VerifyTree() const
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1998-04-17 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
1998-04-16 22:21:32 +00: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 06:03:41 +00:00
|
|
|
void nsTableOuterFrame::DeleteChildsNextInFlow(nsIPresContext* aPresContext,
|
1999-04-04 00:06:48 +00:00
|
|
|
nsIFrame* aChild)
|
1998-04-16 22:21:32 +00:00
|
|
|
{
|
1999-04-12 23:46:02 +00:00
|
|
|
NS_PRECONDITION(mFrames.ContainsFrame(aChild), "bad geometric parent");
|
1998-04-16 22:21:32 +00:00
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIFrame* nextInFlow;
|
|
|
|
|
1999-02-24 04:48:08 +00:00
|
|
|
aChild->GetNextInFlow(&nextInFlow);
|
1998-04-17 01:41:24 +00:00
|
|
|
|
|
|
|
NS_PRECONDITION(nsnull != nextInFlow, "null next-in-flow");
|
|
|
|
nsTableOuterFrame* parent;
|
|
|
|
|
1999-02-10 01:36:30 +00:00
|
|
|
nextInFlow->GetParent((nsIFrame**)&parent);
|
1998-04-16 22:21:32 +00:00
|
|
|
|
|
|
|
// If the next-in-flow has a next-in-flow then delete it too (and
|
|
|
|
// delete it first).
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIFrame* nextNextInFlow;
|
|
|
|
|
1999-02-24 04:48:08 +00:00
|
|
|
nextInFlow->GetNextInFlow(&nextNextInFlow);
|
1998-04-17 01:41:24 +00:00
|
|
|
if (nsnull != nextNextInFlow) {
|
1998-08-28 03:02:39 +00:00
|
|
|
parent->DeleteChildsNextInFlow(aPresContext, nextInFlow);
|
1998-04-16 22:21:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Disconnect the next-in-flow from the flow list
|
1999-10-22 14:53:52 +00:00
|
|
|
nsSplittableFrame::BreakFromPrevFlow(nextInFlow);
|
1998-04-16 22:21:32 +00:00
|
|
|
|
|
|
|
// Take the next-in-flow out of the parent's child list
|
1999-01-15 22:52:05 +00:00
|
|
|
if (parent->mFrames.FirstChild() == nextInFlow) {
|
|
|
|
nsIFrame* nextSibling;
|
1999-02-10 06:13:38 +00:00
|
|
|
nextInFlow->GetNextSibling(&nextSibling);
|
1999-01-15 22:52:05 +00:00
|
|
|
parent->mFrames.SetFrames(nextSibling);
|
1998-04-16 22:21:32 +00:00
|
|
|
|
|
|
|
} else {
|
1998-04-17 01:41:24 +00:00
|
|
|
nsIFrame* nextSibling;
|
|
|
|
|
1998-04-16 22:21:32 +00: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 06:13:38 +00:00
|
|
|
aChild->GetNextSibling(&nextSibling);
|
1998-04-17 01:41:24 +00:00
|
|
|
NS_ASSERTION(nextSibling == nextInFlow, "unexpected sibling");
|
1998-04-16 22:21:32 +00:00
|
|
|
|
1999-02-10 06:13:38 +00:00
|
|
|
nextInFlow->GetNextSibling(&nextSibling);
|
1998-04-17 01:41:24 +00:00
|
|
|
aChild->SetNextSibling(nextSibling);
|
1998-04-16 22:21:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Delete the next-in-flow frame and adjust it's parent's child count
|
1999-07-22 02:24:52 +00:00
|
|
|
nextInFlow->Destroy(aPresContext);
|
1998-04-16 22:21:32 +00:00
|
|
|
|
1998-04-17 01:41:24 +00:00
|
|
|
#ifdef NS_DEBUG
|
1999-02-24 04:48:08 +00:00
|
|
|
aChild->GetNextInFlow(&nextInFlow);
|
1998-04-17 01:41:24 +00:00
|
|
|
NS_POSTCONDITION(nsnull == nextInFlow, "non null next-in-flow");
|
|
|
|
#endif
|
1998-04-16 22:21:32 +00:00
|
|
|
}
|
|
|
|
|
1999-02-24 05:54:31 +00: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-16 22:21:32 +00:00
|
|
|
|
1999-08-01 16:20:14 +00:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
|
|
|
/*------------------ nsITableLayout methods ------------------------------*/
|
1999-07-31 22:11:50 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
nsIDOMElement* &aCell, //out params
|
|
|
|
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
|
|
|
PRInt32& aRowSpan, PRInt32& aColSpan,
|
2000-01-26 14:56:06 +00:00
|
|
|
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
|
1999-07-31 22:11:50 +00:00
|
|
|
PRBool& aIsSelected)
|
|
|
|
{
|
|
|
|
if (!mInnerTableFrame) { return NS_ERROR_NOT_INITIALIZED; }
|
|
|
|
nsITableLayout *inner;
|
2000-02-02 22:24:56 +00:00
|
|
|
nsresult result = mInnerTableFrame->QueryInterface(NS_GET_IID(nsITableLayout), (void **)&inner);
|
1999-07-31 22:11:50 +00:00
|
|
|
if (NS_SUCCEEDED(result) && inner)
|
|
|
|
{
|
|
|
|
return (inner->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
|
|
|
aStartRowIndex, aStartColIndex,
|
2000-01-26 14:56:06 +00:00
|
|
|
aRowSpan, aColSpan, aActualRowSpan, aActualColSpan,
|
|
|
|
aIsSelected));
|
1999-07-31 22:11:50 +00:00
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
1999-08-01 16:20:14 +00:00
|
|
|
NS_IMETHODIMP nsTableOuterFrame::GetTableSize(PRInt32& aRowCount, PRInt32& aColCount)
|
|
|
|
{
|
|
|
|
if (!mInnerTableFrame) { return NS_ERROR_NOT_INITIALIZED; }
|
|
|
|
nsITableLayout *inner;
|
2000-02-02 22:24:56 +00:00
|
|
|
nsresult result = mInnerTableFrame->QueryInterface(NS_GET_IID(nsITableLayout), (void **)&inner);
|
1999-08-01 16:20:14 +00:00
|
|
|
if (NS_SUCCEEDED(result) && inner)
|
|
|
|
{
|
|
|
|
return (inner->GetTableSize(aRowCount, aColCount));
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------- end of nsITableLayout implementation ------------------*/
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
|
1998-09-15 17:58:24 +00:00
|
|
|
nsresult
|
1999-12-04 23:49:50 +00:00
|
|
|
NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
1999-05-11 22:03:29 +00:00
|
|
|
NS_PRECONDITION(aNewFrame, "null OUT ptr");
|
|
|
|
if (nsnull == aNewFrame) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
1999-12-04 23:49:50 +00:00
|
|
|
nsTableOuterFrame* it = new (aPresShell) nsTableOuterFrame;
|
1998-04-13 20:24:54 +00:00
|
|
|
if (nsnull == it) {
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
}
|
1999-05-11 22:03:29 +00:00
|
|
|
*aNewFrame = it;
|
1998-04-13 20:24:54 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-09-02 21:59:54 +00:00
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsTableOuterFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableOuter"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
1999-08-31 03:09:40 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const
|
|
|
|
{
|
1999-09-01 01:02:16 +00:00
|
|
|
if (!aResult) {
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
1999-08-31 03:09:40 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
PRUint32 sum = sizeof(*this);
|
|
|
|
*aResult = sum;
|
|
|
|
return NS_OK;
|
1999-08-31 03:09:40 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|