2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 18:30:37 +04:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-14 00:24:54 +04:00
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-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.
|
|
|
|
*
|
2004-04-18 18:30:37 +04:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-29 00:14:13 +04:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 06:40:37 +03:00
|
|
|
*
|
2001-09-29 00:14:13 +04:00
|
|
|
* Contributor(s):
|
2000-02-03 01:24:56 +03:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 18:30:37 +04:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-29 00:14:13 +04:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 18:30:37 +04:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-29 00:14:13 +04:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 18:30:37 +04:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-29 00:14:13 +04:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
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"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIRenderingContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
1998-07-02 21:40:56 +04:00
|
|
|
#include "prinrval.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"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.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
|
2002-12-19 03:12:08 +03:00
|
|
|
SetFlags(NS_BLOCK_SPACE_MGR);
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
|
|
|
|
2000-03-02 09:09:37 +03:00
|
|
|
nsTableCaptionFrame::~nsTableCaptionFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::Destroy(nsPresContext* aPresContext)
|
2000-03-02 09:09:37 +03:00
|
|
|
{
|
2005-12-03 18:13:08 +03:00
|
|
|
mCaptionFrames.DestroyFrames(aPresContext);
|
2000-03-02 09:09:37 +03:00
|
|
|
return nsHTMLContainerFrame::Destroy(aPresContext);
|
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableCaptionFrame::GetType() const
|
2000-01-28 05:19:45 +03:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::tableCaptionFrame;
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewTableCaptionFrame(nsIPresShell* aPresShell)
|
2000-01-28 05:19:45 +03:00
|
|
|
{
|
2005-11-04 05:38:33 +03:00
|
|
|
return new (aPresShell) nsTableCaptionFrame;
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
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
|
|
|
|
2004-03-12 07:40:17 +03:00
|
|
|
/* virtual */ PRBool
|
|
|
|
nsTableOuterFrame::IsContainingBlock() const
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
2004-03-12 07:40:17 +03:00
|
|
|
return PR_FALSE;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
|
2000-01-28 18:43:25 +03:00
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::Init(nsPresContext* aPresContext,
|
2000-01-28 18:43:25 +03:00
|
|
|
nsIContent* aContent,
|
|
|
|
nsIFrame* aParent,
|
2003-02-22 03:32:13 +03:00
|
|
|
nsStyleContext* aContext,
|
2000-01-28 18:43:25 +03:00
|
|
|
nsIFrame* aPrevInFlow)
|
|
|
|
{
|
|
|
|
nsresult rv = nsHTMLContainerFrame::Init(aPresContext, aContent, aParent,
|
|
|
|
aContext, aPrevInFlow);
|
|
|
|
if (NS_FAILED(rv) || !mStyleContext) return rv;
|
2002-11-08 08:29:34 +03:00
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIFrame*
|
|
|
|
nsTableOuterFrame::GetFirstChild(nsIAtom* aListName) const
|
2000-01-28 05:19:45 +03:00
|
|
|
{
|
2004-01-09 17:20:53 +03:00
|
|
|
if (nsLayoutAtoms::captionList == aListName) {
|
2005-12-03 18:13:08 +03:00
|
|
|
return mCaptionFrames.FirstChild();
|
2004-01-09 17:20:53 +03:00
|
|
|
}
|
|
|
|
if (!aListName) {
|
|
|
|
return mFrames.FirstChild();
|
|
|
|
}
|
|
|
|
return nsnull;
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
|
|
|
|
2004-01-09 17:20:53 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableOuterFrame::GetAdditionalChildListName(PRInt32 aIndex) const
|
2000-01-28 05:19:45 +03:00
|
|
|
{
|
2004-01-09 17:20:53 +03:00
|
|
|
if (aIndex == NS_TABLE_FRAME_CAPTION_LIST_INDEX) {
|
|
|
|
return nsLayoutAtoms::captionList;
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
2004-01-09 17:20:53 +03:00
|
|
|
return nsnull;
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::SetInitialChildList(nsPresContext* aPresContext,
|
2000-01-28 05:19:45 +03:00
|
|
|
nsIAtom* aListName,
|
|
|
|
nsIFrame* aChildList)
|
|
|
|
{
|
|
|
|
if (nsLayoutAtoms::captionList == aListName) {
|
|
|
|
// the frame constructor already checked for table-caption display type
|
2005-12-03 18:13:08 +03:00
|
|
|
mCaptionFrames.SetFrames(aChildList);
|
|
|
|
mCaptionFrame = mCaptionFrames.FirstChild();
|
2000-01-28 05:19:45 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
mFrames.SetFrames(aChildList);
|
2002-02-19 18:48:28 +03:00
|
|
|
mInnerTableFrame = nsnull;
|
|
|
|
if (aChildList) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableFrame == aChildList->GetType()) {
|
2002-02-19 18:48:28 +03:00
|
|
|
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
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableOuterFrame::AppendFrames(nsIAtom* aListName,
|
1999-08-10 07:52:15 +04:00
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2000-01-28 05:19:45 +03:00
|
|
|
nsresult rv;
|
1999-08-10 07:52:15 +04:00
|
|
|
|
2005-12-03 18:13:08 +03:00
|
|
|
// We only have two child frames: the inner table and a caption frame.
|
1999-08-10 07:52:15 +04:00
|
|
|
// 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) {
|
2005-12-03 18:13:08 +03:00
|
|
|
mCaptionFrames.AppendFrames(this, aFrameList);
|
|
|
|
mCaptionFrame = mCaptionFrames.FirstChild();
|
|
|
|
|
|
|
|
// Reflow the new caption frame. It's already marked dirty, so generate a reflow
|
|
|
|
// command that tells us to reflow our dirty child frames
|
|
|
|
rv = GetPresContext()->
|
|
|
|
PresShell()->AppendReflowCommand(this, eReflowType_ReflowDirty,
|
2005-02-08 03:59:52 +03:00
|
|
|
nsnull);
|
2005-12-03 18:13:08 +03:00
|
|
|
|
1999-08-10 07:52:15 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unexpected child frame type");
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableOuterFrame::InsertFrames(nsIAtom* aListName,
|
1999-08-10 07:52:15 +04:00
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsIFrame* aFrameList)
|
|
|
|
{
|
2005-12-03 18:13:08 +03:00
|
|
|
if (nsLayoutAtoms::captionList == aListName) {
|
|
|
|
mCaptionFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
mCaptionFrame = mCaptionFrames.FirstChild();
|
2006-01-26 05:29:17 +03:00
|
|
|
return NS_OK;
|
2005-12-03 18:13:08 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_PRECONDITION(!aPrevFrame, "invalid previous frame");
|
|
|
|
return AppendFrames(aListName, aFrameList);
|
|
|
|
}
|
1999-08-10 07:52:15 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2005-02-07 04:58:25 +03:00
|
|
|
nsTableOuterFrame::RemoveFrame(nsIAtom* aListName,
|
1999-08-10 07:52:15 +04:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
|
|
|
// 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");
|
1999-08-10 07:52:15 +04:00
|
|
|
|
2002-11-08 08:29:34 +03:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
|
|
|
|
// See if the (top/bottom) caption's minimum width impacted the inner table or there
|
|
|
|
// is a left/right caption (that likely impacts the inner table)
|
|
|
|
if ((mMinCaptionWidth == mRect.width) ||
|
|
|
|
(NS_SIDE_LEFT == captionSide) || (NS_SIDE_RIGHT == captionSide)) {
|
1999-08-10 07:52:15 +04:00
|
|
|
// The old caption width had an effect on the inner table width so
|
|
|
|
// we're going to need to reflow it. Mark it dirty
|
2003-07-07 06:01:29 +04:00
|
|
|
mInnerTableFrame->AddStateBits(NS_FRAME_IS_DIRTY);
|
1999-08-10 07:52:15 +04:00
|
|
|
}
|
|
|
|
|
2005-12-03 18:13:08 +03:00
|
|
|
// Remove the frame and destroy it
|
|
|
|
mCaptionFrames.DestroyFrame(GetPresContext(), aOldFrame);
|
|
|
|
mCaptionFrame = mCaptionFrames.FirstChild();
|
|
|
|
|
|
|
|
mMinCaptionWidth = 0;
|
1999-08-10 07:52:15 +04:00
|
|
|
|
|
|
|
// Generate a reflow command so we get reflowed
|
2005-02-08 03:59:52 +03:00
|
|
|
GetPresContext()->PresShell()->AppendReflowCommand(this,
|
|
|
|
eReflowType_ReflowDirty,
|
|
|
|
nsnull);
|
1999-08-10 07:52:15 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-09-19 16:35:19 +04:00
|
|
|
NS_METHOD
|
2006-01-26 05:29:17 +03:00
|
|
|
nsTableOuterFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2006-01-26 05:29:17 +03:00
|
|
|
// No border, background or outline are painted because they all belong
|
|
|
|
// to the inner table.
|
|
|
|
if (!IsVisibleInSelection(aBuilder))
|
2001-01-27 17:09:34 +03:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
// If there's no caption, take a short cut to avoid having to create
|
|
|
|
// the special display list set and then sort it.
|
|
|
|
if (!mCaptionFrame)
|
|
|
|
return BuildDisplayListForInnerTable(aBuilder, aDirtyRect, aLists);
|
|
|
|
|
|
|
|
nsDisplayListCollection set;
|
|
|
|
nsresult rv = BuildDisplayListForInnerTable(aBuilder, aDirtyRect, set);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-12-09 08:39:45 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsDisplayListSet captionSet(set, set.BlockBorderBackgrounds());
|
|
|
|
rv = BuildDisplayListForChild(aBuilder, mCaptionFrame, aDirtyRect, captionSet);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-01-28 05:19:45 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
// Now we have to sort everything by content order, since the caption
|
|
|
|
// may be somewhere inside the table
|
|
|
|
set.SortAllByContentOrder(aBuilder, GetContent());
|
|
|
|
set.MoveTo(aLists);
|
1998-04-17 05:41:24 +04:00
|
|
|
return NS_OK;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::BuildDisplayListForInnerTable(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2000-03-22 05:43:08 +03:00
|
|
|
{
|
2006-01-26 05:29:17 +03:00
|
|
|
// Just paint the regular children, but the children's background is our
|
|
|
|
// true background (there should only be one, the real table)
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
// The children should be in content order
|
|
|
|
while (kid) {
|
|
|
|
nsresult rv = BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
kid = kid->GetNextSibling();
|
2000-05-16 15:35:12 +04:00
|
|
|
}
|
2006-01-26 05:29:17 +03:00
|
|
|
return NS_OK;
|
2000-03-22 05:43:08 +03:00
|
|
|
}
|
|
|
|
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_IMETHODIMP nsTableOuterFrame::SetSelected(nsPresContext* aPresContext,
|
1999-10-26 08:44:41 +04:00
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::GetParentStyleContextFrame(nsPresContext* aPresContext,
|
2002-03-27 05:38:13 +03:00
|
|
|
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,
|
2003-07-08 01:57:01 +04:00
|
|
|
// matching the ::-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.
|
2002-03-27 05:38:13 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2005-04-07 22:04:38 +04:00
|
|
|
static 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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::InitChildReflowState(nsPresContext& aPresContext,
|
2002-02-19 18:48:28 +03:00
|
|
|
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()) {
|
2005-02-07 04:58:25 +03:00
|
|
|
mInnerTableFrame->CalcBCBorders();
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
2003-12-28 20:02:40 +03:00
|
|
|
collapseBorder = mInnerTableFrame->GetBCBorder();
|
2003-09-13 20:26:30 +04:00
|
|
|
pCollapseBorder = &collapseBorder;
|
2002-02-19 18:48:28 +03:00
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::GetMarginPadding(nsPresContext* aPresContext,
|
2002-02-19 18:48:28 +03:00
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsIFrame* aChildFrame,
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord aAvailWidth,
|
2002-02-19 18:48:28 +03:00
|
|
|
nsMargin& aMargin,
|
|
|
|
nsMargin& aMarginNoAuto,
|
|
|
|
nsMargin& aPadding)
|
|
|
|
{
|
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
|
|
|
|
2002-11-08 08:29:34 +03:00
|
|
|
// create and init the child reflow state
|
2000-04-29 01:05:31 +04:00
|
|
|
nsHTMLReflowState childRS(aPresContext, aOuterRS, aChildFrame,
|
2002-11-08 08:29:34 +03:00
|
|
|
nsSize(aAvailWidth, aOuterRS.availableHeight),
|
2002-02-19 18:48:28 +03:00
|
|
|
eReflowReason_Resize, PR_FALSE);
|
|
|
|
InitChildReflowState(*aPresContext, childRS);
|
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
FixAutoMargins(aAvailWidth, aChildFrame->GetSize().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;
|
|
|
|
}
|
|
|
|
|
2005-04-07 22:04:38 +04:00
|
|
|
static
|
2000-04-29 01:05:31 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2005-04-07 22:04:38 +04:00
|
|
|
static void
|
2004-12-27 18:05:18 +03:00
|
|
|
MoveFrameTo(nsIFrame* aFrame,
|
|
|
|
nscoord aX,
|
|
|
|
nscoord aY)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
2003-07-07 06:01:29 +04:00
|
|
|
nsPoint pt = aFrame->GetPosition();
|
|
|
|
if ((pt.x != aX) || (pt.y != aY)) {
|
|
|
|
aFrame->SetPosition(nsPoint(aX, aY));
|
2004-12-27 18:05:18 +03:00
|
|
|
nsTableFrame::RePositionViews(aFrame);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-07 22:04:38 +04:00
|
|
|
static nsSize
|
2000-04-29 01:05:31 +04:00
|
|
|
GetContainingBlockSize(const nsHTMLReflowState& aOuterRS)
|
|
|
|
{
|
|
|
|
nsSize size(0,0);
|
2002-05-14 16:59:55 +04:00
|
|
|
const nsHTMLReflowState* containRS =
|
2004-04-24 21:56:23 +04:00
|
|
|
aOuterRS.mCBReflowState;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
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
|
2004-12-27 18:05:18 +03:00
|
|
|
nsTableOuterFrame::InvalidateDamage(PRUint8 aCaptionSide,
|
2003-11-09 14:35:52 +03:00
|
|
|
const nsSize& aOuterSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
PRBool aInnerChanged,
|
2003-09-13 20:26:30 +04:00
|
|
|
PRBool aCaptionChanged,
|
|
|
|
nsRect* aOldOverflowArea)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
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);
|
2003-09-13 20:26:30 +04:00
|
|
|
if (aOldOverflowArea) {
|
|
|
|
damage.UnionRect(damage, *aOldOverflowArea);
|
|
|
|
}
|
2004-07-16 20:56:21 +04:00
|
|
|
nsRect* overflowArea = GetOverflowAreaProperty();
|
2003-09-13 20:26:30 +04:00
|
|
|
if (overflowArea) {
|
|
|
|
damage.UnionRect(damage, *overflowArea);
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
else {
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect captionRect(0,0,0,0);
|
|
|
|
nsRect innerRect = mInnerTableFrame->GetRect();
|
2000-04-29 01:05:31 +04:00
|
|
|
if (mCaptionFrame) {
|
2003-07-07 06:01:29 +04:00
|
|
|
captionRect = mCaptionFrame->GetRect();
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2003-09-13 20:26:30 +04:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
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
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
else { // aInnerChanged
|
2000-05-10 18:51:37 +04:00
|
|
|
damage.y = 0;
|
|
|
|
damage.height = captionRect.y;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
break;
|
2002-11-08 08:29:34 +03:00
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
if (aCaptionChanged) {
|
|
|
|
damage.width = innerRect.x;
|
|
|
|
damage.y = 0;
|
|
|
|
damage.height = captionRect.YMost();
|
|
|
|
}
|
|
|
|
else { // aInnerChanged
|
|
|
|
damage.x = captionRect.XMost();
|
|
|
|
damage.width = innerRect.XMost() - damage.x;
|
|
|
|
damage.y = 0;
|
|
|
|
damage.height = innerRect.YMost();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
if (aCaptionChanged) {
|
|
|
|
damage.x = innerRect.XMost();
|
|
|
|
damage.width -= damage.x;
|
|
|
|
damage.y = 0;
|
|
|
|
damage.height = captionRect.YMost();
|
|
|
|
}
|
|
|
|
else { // aInnerChanged
|
|
|
|
damage.width -= captionRect.width;
|
|
|
|
damage.y = 0;
|
|
|
|
damage.height = innerRect.YMost();
|
|
|
|
}
|
|
|
|
break;
|
2003-09-13 20:26:30 +04:00
|
|
|
default: // NS_SIDE_TOP
|
2000-04-29 01:05:31 +04:00
|
|
|
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
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
else { // aInnerChanged
|
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
|
|
|
}
|
2003-09-13 20:26:30 +04:00
|
|
|
|
|
|
|
nsIFrame* kidFrame = aCaptionChanged ? mCaptionFrame : mInnerTableFrame;
|
2004-12-27 18:05:18 +03:00
|
|
|
ConsiderChildOverflow(damage, kidFrame);
|
2003-09-13 20:26:30 +04:00
|
|
|
if (aOldOverflowArea) {
|
|
|
|
damage.UnionRect(damage, *aOldOverflowArea);
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2004-03-10 06:09:05 +03:00
|
|
|
Invalidate(damage);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::GetCaptionAvailWidth(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
nsIFrame* aCaptionFrame,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
2002-11-08 08:29:34 +03:00
|
|
|
nsMargin& aCaptionMargin,
|
|
|
|
nsMargin& aCaptionPad,
|
2000-04-29 01:05:31 +04:00
|
|
|
nscoord* aInnerWidth,
|
2002-11-08 08:29:34 +03:00
|
|
|
const nsMargin* aInnerMarginNoAuto,
|
|
|
|
const nsMargin* aInnerMargin)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord availWidth;
|
2000-04-29 01:05:31 +04:00
|
|
|
if (aInnerWidth) {
|
|
|
|
nscoord innerWidth = *aInnerWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == innerWidth) {
|
2002-11-08 08:29:34 +03:00
|
|
|
availWidth = innerWidth;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
else {
|
2002-11-08 08:29:34 +03:00
|
|
|
nsMargin innerMarginNoAuto(0,0,0,0);
|
2000-09-11 04:02:04 +04:00
|
|
|
if (aInnerMarginNoAuto) {
|
2002-11-08 08:29:34 +03:00
|
|
|
innerMarginNoAuto = *aInnerMarginNoAuto;
|
|
|
|
}
|
|
|
|
nsMargin innerMargin(0,0,0,0);
|
|
|
|
if (aInnerMargin) {
|
|
|
|
innerMargin = *aInnerMargin;
|
|
|
|
}
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
switch (captionSide) {
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
availWidth = (NS_SIDE_LEFT == captionSide) ? innerMargin.left : innerMargin.right;
|
|
|
|
break;
|
|
|
|
default: // NS_SIDE_TOP, NS_SIDE_BOTTOM
|
|
|
|
availWidth = innerWidth + innerMarginNoAuto.left + innerMarginNoAuto.right;
|
|
|
|
break;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2003-07-07 06:01:29 +04:00
|
|
|
availWidth = GetSize().width;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
|
2002-11-08 08:29:34 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == availWidth) {
|
|
|
|
return availWidth;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
else {
|
2002-11-08 08:29:34 +03:00
|
|
|
nsMargin marginIgnore;
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, aCaptionFrame, availWidth,
|
|
|
|
marginIgnore, aCaptionMargin, aCaptionPad);
|
|
|
|
availWidth -= aCaptionMargin.left + aCaptionMargin.right;
|
|
|
|
return (PR_MAX(availWidth, mMinCaptionWidth));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::GetInnerTableAvailWidth(nsPresContext* aPresContext,
|
2002-11-08 08:29:34 +03:00
|
|
|
nsIFrame* aInnerTable,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nscoord* aCaptionWidth,
|
|
|
|
nsMargin& aInnerMargin,
|
|
|
|
nsMargin& aInnerPadding)
|
|
|
|
{
|
|
|
|
nscoord availWidth;
|
|
|
|
nscoord captionWidth = 0;
|
|
|
|
if (aCaptionWidth) {
|
|
|
|
captionWidth = *aCaptionWidth;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == captionWidth) {
|
|
|
|
availWidth = captionWidth;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
availWidth = aOuterRS.availableWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2003-07-07 06:01:29 +04:00
|
|
|
availWidth = GetSize().width;
|
2002-11-08 08:29:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == availWidth) {
|
|
|
|
return availWidth;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
nsMargin marginIgnore;
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, aInnerTable, availWidth, marginIgnore, aInnerMargin, aInnerPadding);
|
|
|
|
availWidth -= aInnerMargin.left + aInnerMargin.right;
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
switch (captionSide) {
|
|
|
|
case NS_SIDE_LEFT:
|
2003-09-13 20:26:30 +04:00
|
|
|
if (captionWidth > marginIgnore.left) {
|
2002-11-08 08:29:34 +03:00
|
|
|
availWidth -= captionWidth - aInnerMargin.left;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_SIDE_RIGHT:
|
2003-09-13 20:26:30 +04:00
|
|
|
if (captionWidth > marginIgnore.right) {
|
2002-11-08 08:29:34 +03:00
|
|
|
availWidth -= captionWidth - aInnerMargin.right;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
availWidth = PR_MAX(availWidth, mMinCaptionWidth);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return(availWidth);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
nscoord
|
|
|
|
nsTableOuterFrame::GetMaxElementWidth(PRUint8 aCaptionSide,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aInnerPadding,
|
|
|
|
const nsMargin& aCaptionMargin)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
2003-01-09 17:26:32 +03:00
|
|
|
nscoord width = aInnerMargin.left +
|
|
|
|
((nsTableFrame *)mInnerTableFrame)->GetMinWidth() +
|
|
|
|
aInnerMargin.right;
|
2002-11-08 08:29:34 +03:00
|
|
|
if (mCaptionFrame) {
|
2000-04-29 01:05:31 +04:00
|
|
|
nscoord capWidth = mMinCaptionWidth + aCaptionMargin.left + aCaptionMargin.right;
|
2002-11-08 08:29:34 +03:00
|
|
|
switch(aCaptionSide) {
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
if (capWidth > aInnerMargin.left) {
|
2003-01-09 17:26:32 +03:00
|
|
|
width += capWidth - aInnerMargin.left;
|
2002-11-08 08:29:34 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_SIDE_RIGHT:
|
2003-09-13 20:26:30 +04:00
|
|
|
if (capWidth > aInnerMargin.right) {
|
2003-01-09 17:26:32 +03:00
|
|
|
width += capWidth - aInnerMargin.right;
|
2002-11-08 08:29:34 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2003-01-09 17:26:32 +03:00
|
|
|
if (capWidth > width) {
|
|
|
|
width = capWidth;
|
2002-11-08 08:29:34 +03:00
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
2003-01-09 17:26:32 +03:00
|
|
|
return width;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
|
|
|
nsTableOuterFrame::GetMaxWidth(PRUint8 aCaptionSide,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin)
|
|
|
|
{
|
|
|
|
nscoord maxWidth;
|
2002-11-08 08:29:34 +03:00
|
|
|
|
|
|
|
maxWidth = ((nsTableFrame *)mInnerTableFrame)->GetPreferredWidth() +
|
2001-03-13 09:38:59 +03:00
|
|
|
aInnerMargin.left + aInnerMargin.right;
|
2002-11-08 08:29:34 +03:00
|
|
|
if (mCaptionFrame) {
|
|
|
|
switch(aCaptionSide) {
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
case NS_SIDE_RIGHT:
|
2005-04-07 22:04:38 +04:00
|
|
|
maxWidth += mCaptionFrame->GetSize().width + aCaptionMargin.left + aCaptionMargin.right;
|
2002-11-08 08:29:34 +03:00
|
|
|
// the caption plus it margins should cover the corresponding inner table side
|
|
|
|
// margin - don't count it twice.
|
2005-04-07 22:04:38 +04:00
|
|
|
maxWidth -= (NS_SIDE_LEFT == aCaptionSide) ? aInnerMargin.left : aInnerMargin.right;
|
2002-11-08 08:29:34 +03:00
|
|
|
break;
|
|
|
|
case NS_SIDE_TOP:
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
default: // no caption
|
2000-04-29 01:05:31 +04:00
|
|
|
maxWidth = PR_MAX(maxWidth, mMinCaptionWidth + aCaptionMargin.left + aCaptionMargin.right);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return maxWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
PRUint8
|
|
|
|
nsTableOuterFrame::GetCaptionSide()
|
1998-06-19 04:34:12 +04:00
|
|
|
{
|
2000-04-29 01:05:31 +04:00
|
|
|
if (mCaptionFrame) {
|
2003-05-15 07:42:21 +04:00
|
|
|
return mCaptionFrame->GetStyleTableBorder()->mCaptionSide;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NO_SIDE; // no caption
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 08:29:34 +03:00
|
|
|
PRUint8
|
|
|
|
nsTableOuterFrame::GetCaptionVerticalAlign()
|
|
|
|
{
|
2005-04-07 22:04:38 +04:00
|
|
|
const nsStyleCoord& va = mCaptionFrame->GetStyleTextReset()->mVerticalAlign;
|
|
|
|
return (va.GetUnit() == eStyleUnit_Enumerated)
|
|
|
|
? va.GetIntValue()
|
|
|
|
: NS_STYLE_VERTICAL_ALIGN_TOP;
|
2002-11-08 08:29:34 +03:00
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
void
|
2004-12-27 18:05:18 +03:00
|
|
|
nsTableOuterFrame::SetDesiredSize(PRUint8 aCaptionSide,
|
2000-04-29 01:05:31 +04:00
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin,
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord aAvailableWidth,
|
2000-04-29 01:05:31 +04:00
|
|
|
nscoord& aWidth,
|
|
|
|
nscoord& aHeight)
|
|
|
|
{
|
|
|
|
aWidth = aHeight = 0;
|
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect innerRect = mInnerTableFrame->GetRect();
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord innerWidth = innerRect.width;
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
nsRect captionRect(0,0,0,0);
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord captionWidth = 0;
|
2000-04-29 01:05:31 +04:00
|
|
|
if (mCaptionFrame) {
|
2003-07-07 06:01:29 +04:00
|
|
|
captionRect = mCaptionFrame->GetRect();
|
2002-11-08 08:29:34 +03:00
|
|
|
captionWidth = captionRect.width;
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aAvailableWidth) &&
|
|
|
|
((NS_SIDE_LEFT == aCaptionSide) || (NS_SIDE_RIGHT == aCaptionSide))) {
|
2004-12-27 18:05:18 +03:00
|
|
|
BalanceLeftRightCaption(aCaptionSide, aInnerMargin, aCaptionMargin,
|
2002-11-08 08:29:34 +03:00
|
|
|
innerWidth, captionWidth);
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
switch(aCaptionSide) {
|
2002-11-08 08:29:34 +03:00
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
aWidth = PR_MAX(aInnerMargin.left, aCaptionMargin.left + captionWidth + aCaptionMargin.right) +
|
|
|
|
innerWidth + aInnerMargin.right;
|
|
|
|
break;
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
aWidth = PR_MAX(aInnerMargin.right, aCaptionMargin.left + captionWidth + aCaptionMargin.right) +
|
|
|
|
innerWidth + aInnerMargin.left;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aWidth = aInnerMargin.left + innerWidth + aInnerMargin.right;
|
|
|
|
aWidth = PR_MAX(aWidth, captionRect.XMost() + aCaptionMargin.right);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
aHeight = innerRect.YMost() + aInnerMargin.bottom;
|
|
|
|
aHeight = PR_MAX(aHeight, captionRect.YMost() + aCaptionMargin.bottom);
|
1998-06-19 04:34:12 +04:00
|
|
|
|
2002-11-08 08:29:34 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::PctAdjustMinCaptionWidth(nsPresContext* aPresContext,
|
2002-11-08 08:29:34 +03:00
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
PRUint8 aCaptionSide,
|
|
|
|
nscoord& capMin)
|
|
|
|
{
|
|
|
|
if (NS_SIDE_LEFT == aCaptionSide || NS_SIDE_RIGHT == aCaptionSide) {
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
nsMargin capMarginIgnore;
|
|
|
|
nsMargin capMarginNoAuto;
|
|
|
|
nsMargin captionPaddingIgnore;
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mCaptionFrame, aOuterRS.availableWidth, capMarginIgnore,
|
|
|
|
capMarginNoAuto, captionPaddingIgnore);
|
|
|
|
PRBool isPctWidth;
|
|
|
|
IsAutoWidth(*mCaptionFrame,&isPctWidth);
|
|
|
|
if (isPctWidth) {
|
2003-07-07 06:01:29 +04:00
|
|
|
capMin = mCaptionFrame->GetSize().width;
|
2002-11-08 08:29:34 +03:00
|
|
|
}
|
|
|
|
capMin += capMarginNoAuto.left + capMarginNoAuto.right;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
void
|
2004-12-27 18:05:18 +03:00
|
|
|
nsTableOuterFrame::BalanceLeftRightCaption(PRUint8 aCaptionSide,
|
2002-11-08 08:29:34 +03:00
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
nscoord& aInnerWidth,
|
|
|
|
nscoord& aCaptionWidth)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* balance the caption and inner table widths to ensure space for percent widths
|
|
|
|
* Percent widths for captions or the inner table frame can determine how much of the
|
|
|
|
* available width is used and how the available width is distributed between those frames
|
|
|
|
* The inner table frame has already a quite sophisticated treatment of percentage widths
|
|
|
|
* (see BasicTableLayoutStrategy.cpp). So it acts as master in the below computations.
|
|
|
|
* There are four possible scenarios
|
|
|
|
* a) None of the frames have a percentage width - then the aInnerWidth and aCaptionwidth will not change
|
|
|
|
* b) Only the inner frame has a percentage width - this is handled in BasicTableLayoutStrategy.cpp,
|
|
|
|
* both widths will not change
|
|
|
|
* c) Only the caption has a percentage width - then the overall width (ow) will be different depending on
|
|
|
|
* the caption side. For the left side
|
|
|
|
* ow = aCaptionMargin.left + aCaptionWidth + aCaptionMargin.right + aInnerwidth + aInnerMargin.right
|
|
|
|
* aCaptionWidth = capPercent * ow
|
|
|
|
* solving this equation for aCaptionWidth gives:
|
|
|
|
* aCaptionWidth = capPercent/(1-capPercent) *
|
|
|
|
* (aCaptionMargin.left + aCaptionMargin.right + aInnerwidth + aInnerMargin.right)
|
|
|
|
* this result will cause problems for capPercent >= 1, in these cases the algorithm will now bail out
|
2003-03-19 07:35:08 +03:00
|
|
|
* a similar expression can be found for the right case
|
2002-11-08 08:29:34 +03:00
|
|
|
* d) both frames have percent widths in this case the caption width will be the inner width multiplied
|
|
|
|
* by the weight capPercent/innerPercent
|
|
|
|
*/
|
|
|
|
|
1998-06-19 04:34:12 +04:00
|
|
|
|
2002-11-08 08:29:34 +03:00
|
|
|
float capPercent = -1.0;
|
|
|
|
float innerPercent = -1.0;
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStylePosition* position = mCaptionFrame->GetStylePosition();
|
2002-11-08 08:29:34 +03:00
|
|
|
if (eStyleUnit_Percent == position->mWidth.GetUnit()) {
|
|
|
|
capPercent = position->mWidth.GetPercentValue();
|
|
|
|
if (capPercent >= 1.0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-05-15 07:42:21 +04:00
|
|
|
position = mInnerTableFrame->GetStylePosition();
|
2002-11-08 08:29:34 +03:00
|
|
|
if (eStyleUnit_Percent == position->mWidth.GetUnit()) {
|
|
|
|
innerPercent = position->mWidth.GetPercentValue();
|
|
|
|
if (innerPercent >= 1.0)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((capPercent <= 0.0) && (innerPercent <= 0.0))
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (innerPercent <= 0.0) {
|
|
|
|
if (NS_SIDE_LEFT == aCaptionSide)
|
|
|
|
aCaptionWidth= (nscoord) ((capPercent / (1.0 - capPercent)) * (aCaptionMargin.left + aCaptionMargin.right +
|
|
|
|
aInnerWidth + aInnerMargin.right));
|
|
|
|
else
|
|
|
|
aCaptionWidth= (nscoord) ((capPercent / (1.0 - capPercent)) * (aCaptionMargin.left + aCaptionMargin.right +
|
|
|
|
aInnerWidth + aInnerMargin.left));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aCaptionWidth = (nscoord) ((capPercent / innerPercent) * aInnerWidth);
|
|
|
|
}
|
2004-07-29 23:41:39 +04:00
|
|
|
aCaptionWidth = nsTableFrame::RoundToPixel(aCaptionWidth,
|
2004-12-27 18:05:18 +03:00
|
|
|
GetPresContext()->ScaledPixelsToTwips(),
|
2004-07-29 23:41:39 +04:00
|
|
|
eAlwaysRoundDown);
|
2002-11-08 08:29:34 +03:00
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult
|
2006-01-21 12:54:07 +03:00
|
|
|
nsTableOuterFrame::GetCaptionOrigin(PRUint32 aCaptionSide,
|
2000-04-29 01:05:31 +04:00
|
|
|
const nsSize& aContainBlockSize,
|
|
|
|
const nsSize& aInnerSize,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
nsMargin& aCaptionMargin,
|
|
|
|
nsPoint& aOrigin)
|
|
|
|
{
|
|
|
|
aOrigin.x = aOrigin.y = 0;
|
2002-11-08 08:29:34 +03:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aInnerSize.width) || (NS_UNCONSTRAINEDSIZE == aInnerSize.height) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aCaptionSize.width) || (NS_UNCONSTRAINEDSIZE == aCaptionSize.height)) {
|
2000-04-29 01:05:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (!mCaptionFrame) return NS_OK;
|
|
|
|
|
2006-01-21 12:54:07 +03:00
|
|
|
GET_PIXELS_TO_TWIPS(GetPresContext(), p2t);
|
2001-11-19 18:51:28 +03:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
switch(aCaptionSide) {
|
2003-07-24 03:04: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
|
|
|
}
|
2003-07-24 03:04:37 +04:00
|
|
|
nsCollapsingMargin marg;
|
|
|
|
marg.Include(aCaptionMargin.top);
|
|
|
|
marg.Include(aInnerMargin.bottom);
|
|
|
|
nscoord collapseMargin = marg.get();
|
2000-05-10 18:51:37 +04:00
|
|
|
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;
|
2003-07-24 03:04:37 +04:00
|
|
|
} break;
|
|
|
|
case NS_SIDE_LEFT: {
|
2002-11-08 08:29:34 +03:00
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.left) {
|
|
|
|
if (NS_AUTOMARGIN != aInnerMargin.left) {
|
|
|
|
aCaptionMargin.left = CalcAutoMargin(aCaptionMargin.left, aCaptionMargin.right,
|
|
|
|
aInnerMargin.left, aCaptionSize.width, p2t);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// zero for now
|
|
|
|
aCaptionMargin.left = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aOrigin.x = aCaptionMargin.left;
|
|
|
|
aOrigin.y = aInnerMargin.top;
|
|
|
|
switch(GetCaptionVerticalAlign()) {
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
|
|
|
aOrigin.y = PR_MAX(0, aInnerMargin.top + ((aInnerSize.height - aCaptionSize.height) / 2));
|
|
|
|
break;
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
|
|
|
aOrigin.y = PR_MAX(0, aInnerMargin.top + aInnerSize.height - aCaptionSize.height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-07-24 03:04:37 +04:00
|
|
|
} break;
|
|
|
|
case NS_SIDE_RIGHT: {
|
2002-11-08 08:29:34 +03:00
|
|
|
if (NS_AUTOMARGIN == aCaptionMargin.left) {
|
|
|
|
if (NS_AUTOMARGIN != aInnerMargin.right) {
|
|
|
|
aCaptionMargin.left = CalcAutoMargin(aCaptionMargin.left, aCaptionMargin.right,
|
|
|
|
aInnerMargin.right, aCaptionSize.width, p2t);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// zero for now
|
|
|
|
aCaptionMargin.left = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aOrigin.x = aInnerMargin.left + aInnerSize.width + aCaptionMargin.left;
|
|
|
|
aOrigin.y = aInnerMargin.top;
|
|
|
|
switch(GetCaptionVerticalAlign()) {
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
|
|
|
aOrigin.y += PR_MAX(0, (aInnerSize.height - aCaptionSize.height) / 2);
|
|
|
|
break;
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
|
|
|
aOrigin.y += PR_MAX(0, aInnerSize.height - aCaptionSize.height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-07-24 03:04:37 +04:00
|
|
|
} break;
|
|
|
|
default: { // top
|
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) {
|
2003-07-24 03:04:37 +04:00
|
|
|
nsCollapsingMargin marg;
|
|
|
|
marg.Include(aCaptionMargin.bottom);
|
|
|
|
marg.Include(aInnerMargin.top);
|
|
|
|
nscoord collapseMargin = marg.get();
|
2000-05-10 18:51:37 +04:00
|
|
|
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;
|
2003-07-24 03:04:37 +04:00
|
|
|
} break;
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2006-01-21 12:54:07 +03:00
|
|
|
nsTableOuterFrame::GetInnerOrigin(PRUint32 aCaptionSide,
|
2000-04-29 01:05:31 +04:00
|
|
|
const nsSize& aContainBlockSize,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
const nsSize& aInnerSize,
|
|
|
|
nsMargin& aInnerMargin,
|
|
|
|
nsPoint& aOrigin)
|
|
|
|
{
|
|
|
|
aOrigin.x = aOrigin.y = 0;
|
2002-11-08 08:29:34 +03:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aInnerSize.width) || (NS_UNCONSTRAINEDSIZE == aInnerSize.height) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aCaptionSize.width) || (NS_UNCONSTRAINEDSIZE == aCaptionSize.height)) {
|
2000-04-29 01:05:31 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-01-21 12:54:07 +03:00
|
|
|
GET_PIXELS_TO_TWIPS(GetPresContext(), p2t);
|
2001-11-19 18:51:28 +03:00
|
|
|
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord minCapWidth = aCaptionSize.width;
|
|
|
|
if (NS_AUTOMARGIN != aCaptionMargin.left)
|
|
|
|
minCapWidth += aCaptionMargin.left;
|
|
|
|
if (NS_AUTOMARGIN != aCaptionMargin.right)
|
|
|
|
minCapWidth += aCaptionMargin.right;
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
switch(aCaptionSide) {
|
2003-07-24 03:04: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) {
|
2003-07-24 03:04:37 +04:00
|
|
|
nsCollapsingMargin marg;
|
|
|
|
marg.Include(aInnerMargin.bottom);
|
|
|
|
marg.Include(aCaptionMargin.top);
|
|
|
|
nscoord collapseMargin = marg.get();
|
2000-04-29 01:05:31 +04:00
|
|
|
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;
|
2003-07-24 03:04:37 +04:00
|
|
|
} break;
|
|
|
|
case NS_SIDE_LEFT: {
|
2002-11-08 08:29:34 +03:00
|
|
|
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.left) {
|
|
|
|
aInnerMargin.left = CalcAutoMargin(aInnerMargin.left, aInnerMargin.right,
|
|
|
|
aContainBlockSize.width, aInnerSize.width, p2t);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (aInnerMargin.left < minCapWidth) {
|
|
|
|
// shift the inner table to get some place for the caption
|
|
|
|
aInnerMargin.right += aInnerMargin.left - minCapWidth;
|
|
|
|
aInnerMargin.right = PR_MAX(0, aInnerMargin.right);
|
|
|
|
aInnerMargin.left = minCapWidth;
|
|
|
|
}
|
|
|
|
aOrigin.x = aInnerMargin.left;
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.top) {
|
|
|
|
aInnerMargin.top = 0;
|
|
|
|
}
|
|
|
|
aOrigin.y = aInnerMargin.top;
|
|
|
|
switch(GetCaptionVerticalAlign()) {
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
|
|
|
aOrigin.y = PR_MAX(aInnerMargin.top, (aCaptionSize.height - aInnerSize.height) / 2);
|
|
|
|
break;
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
|
|
|
aOrigin.y = PR_MAX(aInnerMargin.top, aCaptionSize.height - aInnerSize.height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-07-24 03:04:37 +04:00
|
|
|
} break;
|
|
|
|
case NS_SIDE_RIGHT: {
|
2002-11-08 08:29:34 +03:00
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.right) {
|
|
|
|
aInnerMargin.right = CalcAutoMargin(aInnerMargin.left, aInnerMargin.right,
|
|
|
|
aContainBlockSize.width, aInnerSize.width, p2t);
|
|
|
|
if (aInnerMargin.right < minCapWidth) {
|
|
|
|
// shift the inner table to get some place for the caption
|
|
|
|
aInnerMargin.left -= aInnerMargin.right - minCapWidth;
|
|
|
|
aInnerMargin.left = PR_MAX(0, aInnerMargin.left);
|
|
|
|
aInnerMargin.right = minCapWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
aOrigin.x = aInnerMargin.left;
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.top) {
|
|
|
|
aInnerMargin.top = 0;
|
|
|
|
}
|
|
|
|
aOrigin.y = aInnerMargin.top;
|
|
|
|
switch(GetCaptionVerticalAlign()) {
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
|
|
|
aOrigin.y = PR_MAX(aInnerMargin.top, (aCaptionSize.height - aInnerSize.height) / 2);
|
|
|
|
break;
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
|
|
|
aOrigin.y = PR_MAX(aInnerMargin.top, aCaptionSize.height - aInnerSize.height);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2003-07-24 03:04:37 +04:00
|
|
|
} break;
|
|
|
|
default: { // top
|
2000-05-10 18:51:37 +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-05-10 18:51:37 +04:00
|
|
|
}
|
|
|
|
aOrigin.x = aInnerMargin.left;
|
|
|
|
if (NS_AUTOMARGIN == aInnerMargin.top) {
|
|
|
|
aInnerMargin.top = 0;
|
|
|
|
}
|
2003-07-24 03:04:37 +04:00
|
|
|
nsCollapsingMargin marg;
|
|
|
|
marg.Include(aCaptionMargin.bottom);
|
|
|
|
marg.Include(aInnerMargin.top);
|
|
|
|
nscoord collapseMargin = marg.get();
|
2000-05-10 18:51:37 +04:00
|
|
|
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;
|
2003-07-24 03:04:37 +04:00
|
|
|
} 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
|
|
|
|
{
|
|
|
|
// Walk up the reflow state chain until we find a cell or the root
|
|
|
|
const nsHTMLReflowState* rs = aReflowState.parentReflowState;
|
|
|
|
while (rs) {
|
2003-10-31 23:19:18 +03:00
|
|
|
if (nsLayoutAtoms::tableFrame == rs->frame->GetType()) {
|
|
|
|
return PR_TRUE;
|
2001-03-29 01:19:31 +04:00
|
|
|
}
|
|
|
|
rs = rs->parentReflowState;
|
|
|
|
}
|
2003-10-31 23:19:18 +03:00
|
|
|
return PR_FALSE;
|
2001-03-29 01:19:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
PRBool
|
|
|
|
nsTableOuterFrame::IsAutoWidth(nsIFrame& aTableOrCaption,
|
|
|
|
PRBool* aIsPctWidth)
|
|
|
|
{
|
|
|
|
PRBool isAuto = PR_TRUE; // the default
|
|
|
|
if (aIsPctWidth) {
|
|
|
|
*aIsPctWidth = PR_FALSE;
|
|
|
|
}
|
|
|
|
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStylePosition* position = aTableOrCaption.GetStylePosition();
|
2001-03-29 01:19:31 +04:00
|
|
|
|
2004-04-08 17:46:57 +04:00
|
|
|
#ifdef __SUNPRO_CC
|
|
|
|
// Bug 239962, this is a workaround to avoid incorrect code generation by Sun Forte compiler.
|
|
|
|
float percent = position->mWidth.GetPercentValue();
|
|
|
|
#endif
|
|
|
|
|
2001-03-29 01:19:31 +04:00
|
|
|
switch (position->mWidth.GetUnit()) {
|
|
|
|
case eStyleUnit_Auto: // specified auto width
|
|
|
|
case eStyleUnit_Proportional: // illegal for table, so ignored
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Coord:
|
|
|
|
isAuto = PR_FALSE;
|
|
|
|
break;
|
|
|
|
case eStyleUnit_Percent:
|
2004-04-08 17:46:57 +04:00
|
|
|
#ifdef __SUNPRO_CC
|
|
|
|
if (percent > 0.0f) {
|
|
|
|
#else
|
2001-03-29 01:19:31 +04:00
|
|
|
if (position->mWidth.GetPercentValue() > 0.0f) {
|
2004-04-08 17:46:57 +04:00
|
|
|
#endif
|
2001-03-29 01:19:31 +04:00
|
|
|
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
|
2002-11-08 08:29:34 +03:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::OuterReflowChild(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord aAvailWidth,
|
2000-04-29 01:05:31 +04:00
|
|
|
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,
|
2003-11-09 14:35:52 +03:00
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
PRBool* aNeedToReflowCaption)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
|
|
|
aMargin = aPadding = nsMargin(0,0,0,0);
|
|
|
|
|
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
|
|
|
|
nscoord availHeight = aOuterRS.availableHeight;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availHeight) {
|
2005-03-19 20:59:11 +03:00
|
|
|
nsMargin margin, marginNoAuto, padding;
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, aChildFrame, aOuterRS.availableWidth, margin,
|
|
|
|
marginNoAuto, padding);
|
|
|
|
|
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != margin.top, "No unconstrainedsize arithmetic, please");
|
|
|
|
availHeight -= margin.top;
|
|
|
|
|
|
|
|
NS_ASSERTION(NS_UNCONSTRAINEDSIZE != margin.bottom, "No unconstrainedsize arithmetic, please");
|
|
|
|
availHeight -= margin.bottom;
|
|
|
|
|
2004-07-29 23:41:39 +04:00
|
|
|
availHeight = nsTableFrame::RoundToPixel(availHeight,
|
|
|
|
aPresContext->ScaledPixelsToTwips(),
|
|
|
|
eAlwaysRoundDown);
|
2001-11-07 05:38:49 +03:00
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
nsSize availSize(aAvailWidth, availHeight);
|
|
|
|
if (mCaptionFrame == aChildFrame) {
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
if ((NS_SIDE_LEFT == captionSide) || (NS_SIDE_RIGHT != captionSide)) {
|
|
|
|
PRBool isPctWidth;
|
|
|
|
IsAutoWidth(*aChildFrame, &isPctWidth);
|
|
|
|
if (isPctWidth) {
|
|
|
|
availSize.width = aOuterRS.availableWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-02-19 18:48:28 +03:00
|
|
|
// create and init the child reflow state
|
2002-11-08 08:29:34 +03:00
|
|
|
nsHTMLReflowState childRS(aPresContext, aOuterRS, aChildFrame, availSize,
|
2002-02-19 18:48:28 +03:00
|
|
|
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
|
2005-11-21 01:05:24 +03:00
|
|
|
// then adjust mComputedWidth based on availableWidth if this isn't the initial reflow
|
2004-08-31 22:57:06 +04:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE != childRS.mComputedWidth) &&
|
2001-03-29 01:19:31 +04:00
|
|
|
(eReflowReason_Initial != aReflowReason) &&
|
2004-08-31 22:57:06 +04:00
|
|
|
(childRS.mComputedWidth + childRS.mComputedBorderPadding.left +
|
|
|
|
childRS.mComputedBorderPadding.right > childRS.availableWidth) &&
|
2001-03-29 01:19:31 +04:00
|
|
|
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;
|
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
if ((mCaptionFrame == aChildFrame) && (NS_SIDE_LEFT != captionSide)
|
|
|
|
&& (NS_SIDE_RIGHT != captionSide)) {
|
|
|
|
aAvailWidth = aOuterRS.availableWidth;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2003-11-09 14:35:52 +03:00
|
|
|
// see if we need to reflow the caption in addition
|
|
|
|
if (aNeedToReflowCaption && !*aNeedToReflowCaption &&
|
2004-10-16 22:21:15 +04:00
|
|
|
mInnerTableFrame == aChildFrame && childRS.reason == eReflowReason_Incremental) {
|
2003-11-09 14:35:52 +03:00
|
|
|
nsHTMLReflowCommand* command = childRS.path->mReflowCommand;
|
|
|
|
if (command) {
|
2005-02-08 03:59:52 +03:00
|
|
|
*aNeedToReflowCaption = eReflowType_StyleChanged == command->Type();
|
2003-11-09 14:35:52 +03:00
|
|
|
}
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
// use the current position as a best guess for placement
|
2003-07-07 06:01:29 +04:00
|
|
|
nsPoint childPt = aChildFrame->GetPosition();
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult rv = ReflowChild(aChildFrame, aPresContext, aMetrics, childRS,
|
2003-07-07 06:01:29 +04:00
|
|
|
childPt.x, childPt.y, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2002-11-08 08:29:34 +03:00
|
|
|
|
|
|
|
FixAutoMargins(aAvailWidth, 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
|
2004-12-27 18:05:18 +03:00
|
|
|
nsTableOuterFrame::UpdateReflowMetrics(PRUint8 aCaptionSide,
|
2000-04-29 01:05:31 +04:00
|
|
|
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,
|
2002-11-08 08:29:34 +03:00
|
|
|
const nsMargin& aCaptionMarginNoAuto,
|
|
|
|
const nscoord aAvailableWidth)
|
2000-04-29 01:05:31 +04:00
|
|
|
{
|
2004-12-27 18:05:18 +03:00
|
|
|
SetDesiredSize(aCaptionSide, aInnerMargin, aCaptionMargin, aAvailableWidth, aMet.width, aMet.height);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
// set maxElementSize width if requested
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aMet.mComputeMEW) {
|
|
|
|
aMet.mMaxElementWidth = GetMaxElementWidth(aCaptionSide, 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
|
|
|
}
|
2003-09-13 20:26:30 +04:00
|
|
|
|
|
|
|
aMet.mOverflowArea = nsRect(0, 0, aMet.width, aMet.height);
|
2004-12-27 18:05:18 +03:00
|
|
|
ConsiderChildOverflow(aMet.mOverflowArea, mInnerTableFrame);
|
2003-09-13 20:26:30 +04:00
|
|
|
if (mCaptionFrame) {
|
2004-12-27 18:05:18 +03:00
|
|
|
ConsiderChildOverflow(aMet.mOverflowArea, mCaptionFrame);
|
2003-09-13 20:26:30 +04:00
|
|
|
}
|
2004-07-16 20:56:21 +04:00
|
|
|
FinishAndStoreOverflow(&aMet);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::IncrementalReflow(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-06-19 04:34:12 +04:00
|
|
|
{
|
2003-03-14 13:31:55 +03:00
|
|
|
// At this point, we need an inner table frame, and we might have a caption.
|
|
|
|
// Due to the logic in nsCSSFrameConstructor::ConstructTableFrame, we can
|
|
|
|
// end here without an inner table frame.
|
|
|
|
if (mFrames.IsEmpty() || !mInnerTableFrame) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "incomplete children");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::IR_TargetIsChild(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
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 {
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStyleDisplay* nextDisplay = aNextFrame->GetStyleDisplay();
|
1998-10-22 02:29:00 +04:00
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::IR_TargetIsInnerTableFrame(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::IR_TargetIsCaptionFrame(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
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();
|
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
nsSize captionSize;
|
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
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect prevInnerRect = mInnerTableFrame->GetRect();
|
2002-11-08 08:29:34 +03:00
|
|
|
nsMargin prevInnerMargin(prevInnerRect.x, 0, mRect.width - prevInnerRect.x - prevInnerRect.width, 0);
|
2005-03-24 22:02:59 +03:00
|
|
|
nscoord availCaptionWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS, captionMargin,
|
|
|
|
captionPadding, &prevInnerRect.width, nsnull, &prevInnerMargin);
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics captionMet(PR_TRUE);
|
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
|
|
|
// for now just reflow the table if a style changed. This should be improved
|
2002-05-23 22:51:02 +04:00
|
|
|
PRBool needInnerReflow = PR_FALSE;
|
2002-11-08 08:29:34 +03:00
|
|
|
nsReflowReason reflowReason = eReflowReason_Incremental;
|
2002-05-23 22:51:02 +04:00
|
|
|
nsHTMLReflowCommand* command = aOuterRS.path->mReflowCommand;
|
|
|
|
if (command) {
|
2005-02-08 03:59:52 +03:00
|
|
|
switch(command->Type()) {
|
2002-11-08 08:29:34 +03:00
|
|
|
case eReflowType_StyleChanged:
|
|
|
|
needInnerReflow = PR_TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2002-05-23 22:51:02 +04:00
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
|
2005-03-24 22:02:59 +03:00
|
|
|
OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, availCaptionWidth, captionSize,
|
2002-11-08 08:29:34 +03:00
|
|
|
captionMargin, captionMarginNoAuto, captionPadding, reflowReason, capStatus);
|
|
|
|
|
|
|
|
nsMargin innerMargin, innerMarginNoAuto, innerPadding;
|
|
|
|
nsPoint innerOrigin;
|
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
|
|
|
nscoord capMin = mMinCaptionWidth + captionMarginNoAuto.left + captionMarginNoAuto.right;
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
if (mMinCaptionWidth != captionMet.mMaxElementWidth) {
|
1999-04-04 04:06:48 +04:00
|
|
|
// set the new caption min width, and set state to reflow the inner table if necessary
|
2003-01-09 17:26:32 +03:00
|
|
|
mMinCaptionWidth = captionMet.mMaxElementWidth;
|
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
|
2002-11-08 08:29:34 +03:00
|
|
|
if ((capMin) > 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
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
if (NS_SIDE_LEFT == captionSide || NS_SIDE_RIGHT == captionSide) {
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
PRBool isPctWidth;
|
|
|
|
IsAutoWidth( *mCaptionFrame,&isPctWidth);
|
|
|
|
if (isPctWidth) {
|
|
|
|
capMin = captionSize.width + captionMarginNoAuto.left + captionMarginNoAuto.right;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-10-09 23:59:45 +04:00
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
nsPoint captionOrigin;
|
|
|
|
if (needInnerReflow) {
|
|
|
|
nsSize innerSize;
|
2003-09-13 20:26:30 +04:00
|
|
|
nsHTMLReflowMetrics innerMet(PR_FALSE);
|
2005-03-24 22:02:59 +03:00
|
|
|
nscoord availTableWidth = GetInnerTableAvailWidth(aPresContext, mInnerTableFrame, aOuterRS,
|
|
|
|
&capMin, innerMargin, innerPadding);
|
|
|
|
OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet, availTableWidth, innerSize,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerMargin, innerMarginNoAuto, innerPadding, eReflowReason_Resize, aStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
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;
|
|
|
|
|
2006-01-21 12:54:07 +03:00
|
|
|
GetCaptionOrigin(captionSide, containSize, innerSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
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
|
2003-07-07 06:01:29 +04:00
|
|
|
nsSize innerSize = mInnerTableFrame->GetSize();
|
2002-11-08 08:29:34 +03:00
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mInnerTableFrame, aOuterRS.availableWidth, innerMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerMarginNoAuto, innerPadding);
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2006-01-21 12:54:07 +03:00
|
|
|
GetCaptionOrigin(captionSide, containSize, innerSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
2004-12-27 18:05:18 +03:00
|
|
|
MoveFrameTo(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);
|
2004-07-16 20:56:21 +04:00
|
|
|
nsRect* oldOverflowArea = GetOverflowAreaProperty();
|
2003-12-04 23:13:09 +03:00
|
|
|
nsRect* overflowStorage = nsnull;
|
|
|
|
nsRect overflow;
|
|
|
|
if (oldOverflowArea) {
|
|
|
|
overflow = *oldOverflowArea;
|
|
|
|
overflowStorage = &overflow;
|
|
|
|
}
|
|
|
|
|
2004-12-27 18:05:18 +03:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
2002-11-08 08:29:34 +03:00
|
|
|
innerPadding, captionMargin, captionMarginNoAuto, aOuterRS.availableWidth);
|
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);
|
2004-12-27 18:05:18 +03:00
|
|
|
InvalidateDamage(captionSide, desSize, innerMoved, PR_TRUE, overflowStorage);
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::IR_ReflowDirty(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-10-08 19:34:48 +04:00
|
|
|
{
|
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) {
|
2003-07-07 06:01:29 +04:00
|
|
|
if (mCaptionFrame->GetStateBits() & NS_FRAME_IS_DIRTY) {
|
1999-08-10 07:52:15 +04:00
|
|
|
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
|
2003-07-07 06:01:29 +04:00
|
|
|
if (mInnerTableFrame->GetStateBits() & 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
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect innerRect = mInnerTableFrame->GetRect();
|
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;
|
2002-11-08 08:29:34 +03:00
|
|
|
GetMarginPadding(aPresContext, aReflowState, mInnerTableFrame, aReflowState.availableWidth, innerMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerMarginNoAuto, innerPadding);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize containSize = GetContainingBlockSize(aReflowState);
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(NO_SIDE, containSize, nsSize(0,0),
|
2000-04-29 01:05:31 +04:00
|
|
|
nsMargin(0,0,0,0), innerSize, innerMargin, innerOrigin);
|
2004-12-27 18:05:18 +03:00
|
|
|
MoveFrameTo(mInnerTableFrame, innerOrigin.x, innerOrigin.y);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
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
|
2004-07-16 20:56:21 +04:00
|
|
|
nsRect* oldOverflowArea = GetOverflowAreaProperty();
|
2003-09-13 20:26:30 +04:00
|
|
|
PRBool innerMoved = (innerRect.x != innerOrigin.x) ||
|
|
|
|
(innerRect.y != innerOrigin.y);
|
2003-12-13 02:00:54 +03:00
|
|
|
nsSize desSize(aDesiredSize.width, aDesiredSize.height);
|
2004-12-27 18:05:18 +03:00
|
|
|
InvalidateDamage((PRUint8) NO_SIDE, desSize, innerMoved, PR_FALSE, oldOverflowArea);
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
|
|
|
if (!sizeSet) {
|
|
|
|
// set our desired size to what it was before
|
2003-07-07 06:01:29 +04:00
|
|
|
nsSize size = GetSize();
|
2000-04-29 01:05:31 +04:00
|
|
|
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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsresult nsTableOuterFrame::IR_TargetIsMe(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1999-08-10 07:52:15 +04:00
|
|
|
{
|
|
|
|
nsresult rv = NS_OK;
|
2005-02-08 03:59:52 +03:00
|
|
|
switch (aReflowState.path->mReflowCommand->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
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::IR_InnerTableReflow(nsPresContext* 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();
|
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
nsSize priorInnerSize = mInnerTableFrame->GetSize();
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
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
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics innerMet(aOuterMet.mComputeMEW, 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
|
2003-10-21 08:30:10 +04:00
|
|
|
// don't over-optimize their reflow. Also make sure we reflow the caption.
|
|
|
|
PRBool reflowCaption = PR_FALSE;
|
2002-11-08 08:29:34 +03:00
|
|
|
nsReflowReason reflowReason = eReflowReason_Incremental;
|
2002-05-10 22:22:41 +04:00
|
|
|
nsHTMLReflowCommand* command = aOuterRS.path->mReflowCommand;
|
|
|
|
if (command) {
|
2005-02-08 03:59:52 +03:00
|
|
|
if (eReflowType_StyleChanged == command->Type()) {
|
2002-11-08 08:29:34 +03:00
|
|
|
reflowReason = eReflowReason_StyleChange;
|
2003-10-21 08:30:10 +04:00
|
|
|
reflowCaption = PR_TRUE;
|
2001-11-14 14:40:03 +03:00
|
|
|
}
|
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord capMin = mMinCaptionWidth;
|
|
|
|
PctAdjustMinCaptionWidth(aPresContext, aOuterRS, captionSide, capMin);
|
2005-03-24 22:02:59 +03:00
|
|
|
nscoord availTableWidth = GetInnerTableAvailWidth(aPresContext, mInnerTableFrame, aOuterRS,
|
|
|
|
&capMin, innerMargin, innerPadding);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet,
|
2005-03-24 22:02:59 +03:00
|
|
|
availTableWidth, innerSize, innerMargin, innerMarginNoAuto,
|
|
|
|
innerPadding, reflowReason, aStatus, &reflowCaption);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2003-11-09 14:35:52 +03:00
|
|
|
|
|
|
|
if (eReflowReason_StyleChange != reflowReason && reflowCaption) {
|
|
|
|
// inner table frame was target for a style change reflow issue a style
|
|
|
|
// change reflow for the caption too.
|
|
|
|
reflowReason = eReflowReason_StyleChange;
|
|
|
|
}
|
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;
|
2003-07-07 06:01:29 +04:00
|
|
|
nsRect prevCaptionRect = mCaptionFrame->GetRect();
|
2000-05-26 02:40:21 +04:00
|
|
|
|
2003-10-21 08:30:10 +04:00
|
|
|
reflowCaption = reflowCaption ||
|
|
|
|
priorInnerSize.width != innerMet.width;
|
|
|
|
|
|
|
|
if (reflowCaption) {
|
2000-04-29 01:05:31 +04:00
|
|
|
nsMargin ignorePadding;
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics captionMet(eReflowReason_StyleChange == reflowReason);
|
2005-03-24 22:02:59 +03:00
|
|
|
nscoord availCaptionWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS, captionMargin,
|
|
|
|
ignorePadding, &innerSize.width, &innerMarginNoAuto);
|
2000-05-05 03:16:42 +04:00
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
2002-11-08 08:29:34 +03:00
|
|
|
if (reflowReason == eReflowReason_Incremental) {
|
|
|
|
reflowReason = eReflowReason_Resize;
|
2001-11-14 14:40:03 +03:00
|
|
|
}
|
2005-03-24 22:02:59 +03:00
|
|
|
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet, availCaptionWidth,
|
2000-09-11 04:02:04 +04:00
|
|
|
captionSize, captionMargin, captionMarginNoAuto,
|
2002-11-08 08:29:34 +03:00
|
|
|
ignorePadding, reflowReason, capStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2006-01-21 12:54:07 +03:00
|
|
|
GetCaptionOrigin(captionSide, containSize, innerSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
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);
|
|
|
|
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
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
|
2003-07-07 06:01:29 +04:00
|
|
|
captionSize = mCaptionFrame->GetSize();
|
2000-04-29 01:05:31 +04:00
|
|
|
nsMargin captionPadding;
|
2002-11-08 08:29:34 +03:00
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mCaptionFrame, aOuterRS.availableWidth, captionMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
captionMarginNoAuto, captionPadding);
|
2006-01-21 12:54:07 +03:00
|
|
|
GetCaptionOrigin(captionSide, containSize, innerSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2004-12-27 18:05:18 +03:00
|
|
|
MoveFrameTo(mCaptionFrame, captionOrigin.x, captionOrigin.y);
|
1998-10-08 19:34:48 +04:00
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
if ((captionOrigin.x != prevCaptionRect.x) || (captionOrigin.y != prevCaptionRect.y)) {
|
2000-05-26 02:40:21 +04:00
|
|
|
captionMoved = PR_TRUE;
|
|
|
|
}
|
2002-11-08 08:29:34 +03:00
|
|
|
if ((captionSize.width != prevCaptionRect.width) || (captionSize.height != prevCaptionRect.height)) {
|
2000-05-26 02:40:21 +04:00
|
|
|
captionMoved = PR_TRUE;
|
|
|
|
}
|
1998-10-08 19:34:48 +04:00
|
|
|
}
|
2000-05-04 18:49:35 +04:00
|
|
|
else {
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
2000-05-04 18:49:35 +04:00
|
|
|
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);
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aOuterMet.mComputeMEW) {
|
|
|
|
aOuterMet.mMaxElementWidth = innerMet.mMaxElementWidth;
|
|
|
|
}
|
2004-07-16 20:56:21 +04:00
|
|
|
nsRect* oldOverflowArea = GetOverflowAreaProperty();
|
2003-12-04 23:13:09 +03:00
|
|
|
nsRect* overflowStorage = nsnull;
|
|
|
|
nsRect overflow;
|
|
|
|
if (oldOverflowArea) {
|
|
|
|
overflow = *oldOverflowArea;
|
|
|
|
overflowStorage = &overflow;
|
|
|
|
}
|
|
|
|
|
2004-12-27 18:05:18 +03:00
|
|
|
UpdateReflowMetrics(captionSide, aOuterMet, innerMargin, innerMarginNoAuto,
|
2002-11-08 08:29:34 +03:00
|
|
|
innerPadding, captionMargin, captionMarginNoAuto, aOuterRS.availableWidth);
|
2001-01-25 19:00:59 +03:00
|
|
|
nsSize desSize(aOuterMet.width, aOuterMet.height);
|
2004-12-27 18:05:18 +03:00
|
|
|
InvalidateDamage(captionSide, desSize, (innerSize.width != priorInnerSize.width),
|
|
|
|
captionMoved, overflowStorage);
|
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
|
2003-01-09 17:26:32 +03:00
|
|
|
checks the old maxElementWidth and reflows the table only if it
|
1998-10-08 19:34:48 +04:00
|
|
|
has changed
|
|
|
|
*/
|
2000-04-29 01:05:31 +04:00
|
|
|
nsresult
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableOuterFrame::IR_CaptionInserted(nsPresContext* aPresContext,
|
2000-04-29 01:05:31 +04:00
|
|
|
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;
|
2002-11-08 08:29:34 +03:00
|
|
|
nsMargin captionMargin, captionMarginNoAuto, captionPadding;
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics captionMet(PR_TRUE);
|
2000-04-29 01:05:31 +04:00
|
|
|
// reflow the caption
|
2005-03-24 22:02:59 +03:00
|
|
|
nscoord availCaptionWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS, captionMargin, captionPadding);
|
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,
|
2005-03-24 22:02:59 +03:00
|
|
|
availCaptionWidth, captionSize, captionMargin, captionMarginNoAuto,
|
2002-11-08 08:29:34 +03:00
|
|
|
captionPadding, eReflowReason_Initial, capStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2003-01-09 17:26:32 +03:00
|
|
|
mMinCaptionWidth = captionMet.mMaxElementWidth;
|
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);
|
2003-07-07 06:01:29 +04:00
|
|
|
nsPoint prevInnerOrigin = mInnerTableFrame->GetPosition();
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord capMin = mMinCaptionWidth + captionMarginNoAuto.left + captionMarginNoAuto.right;
|
|
|
|
|
2000-04-29 01:05:31 +04:00
|
|
|
// if the caption's MES + margins > outer width, reflow the inner table
|
2002-11-08 08:29:34 +03:00
|
|
|
if (capMin > mRect.width) {
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics innerMet(aDesiredSize.mComputeMEW);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize innerSize;
|
2005-03-24 22:02:59 +03:00
|
|
|
nscoord availTableWidth = GetInnerTableAvailWidth(aPresContext, mInnerTableFrame, aOuterRS,
|
|
|
|
&capMin, innerMargin, innerPadding);
|
2000-04-29 01:05:31 +04:00
|
|
|
rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet,
|
2005-03-24 22:02:59 +03:00
|
|
|
availTableWidth, innerSize, innerMargin, innerMarginNoAuto,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerPadding, eReflowReason_Resize, aStatus);
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
|
|
|
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
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);
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = innerMet.mMaxElementWidth;
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2006-01-21 12:54:07 +03:00
|
|
|
GetCaptionOrigin(captionSide, containSize, innerSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
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
|
2003-07-07 06:01:29 +04:00
|
|
|
nsSize innerSize = mInnerTableFrame->GetSize();
|
2002-11-08 08:29:34 +03:00
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mInnerTableFrame, aOuterRS.availableWidth, innerMargin,
|
2000-09-11 04:02:04 +04:00
|
|
|
innerMarginNoAuto, innerPadding);
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2006-01-21 12:54:07 +03:00
|
|
|
GetCaptionOrigin(captionSide, containSize, innerSize,
|
2000-04-29 01:05:31 +04:00
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
2004-12-27 18:05:18 +03:00
|
|
|
MoveFrameTo(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);
|
|
|
|
|
2004-07-16 20:56:21 +04:00
|
|
|
nsRect* oldOverflowArea = GetOverflowAreaProperty();
|
2003-12-04 23:13:09 +03:00
|
|
|
nsRect* overflowStorage = nsnull;
|
|
|
|
nsRect overflow;
|
|
|
|
if (oldOverflowArea) {
|
|
|
|
overflow = *oldOverflowArea;
|
|
|
|
overflowStorage = &overflow;
|
|
|
|
}
|
2004-12-27 18:05:18 +03:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
2002-11-08 08:29:34 +03:00
|
|
|
innerPadding, captionMargin, captionMarginNoAuto, aOuterRS.availableWidth);
|
2000-04-29 01:05:31 +04:00
|
|
|
nsSize desSize(aDesiredSize.width, aDesiredSize.height);
|
2003-07-07 06:01:29 +04:00
|
|
|
PRBool innerMoved = innerOrigin != prevInnerOrigin;
|
2004-12-27 18:05:18 +03:00
|
|
|
InvalidateDamage(captionSide, desSize, innerMoved, PR_TRUE, overflowStorage);
|
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) {
|
2003-05-15 07:42:21 +04:00
|
|
|
const nsStylePosition* position = aFrame->GetStylePosition();
|
2001-08-06 18:23:50 +04:00
|
|
|
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
|
|
|
*/
|
2004-08-01 03:15:21 +04:00
|
|
|
NS_METHOD nsTableOuterFrame::Reflow(nsPresContext* 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;
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = 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 needUpdateMetrics = PR_TRUE;
|
2004-10-29 21:31:53 +04:00
|
|
|
PRBool isPctWidth;
|
|
|
|
IsAutoWidth(*mInnerTableFrame, &isPctWidth);
|
2001-06-13 06:27:22 +04:00
|
|
|
if ((eReflowReason_Resize == aOuterRS.reason) &&
|
2001-03-13 09:38:59 +03:00
|
|
|
(aOuterRS.availableWidth == mPriorAvailWidth) &&
|
2004-03-03 21:24:20 +03:00
|
|
|
!aPresContext->IsPaginated() &&
|
2004-10-29 21:31:53 +04:00
|
|
|
!::IsPctHeight(mInnerTableFrame) &&
|
|
|
|
!isPctWidth) {
|
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
|
|
|
|
2003-10-14 01:51:02 +04:00
|
|
|
// for floats, our view has not been positioned yet as we have not been placed
|
|
|
|
// - the block code will position our views after the float is placed
|
2002-04-07 22:26:35 +04:00
|
|
|
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.
|
2004-12-27 18:05:18 +03:00
|
|
|
nsContainerFrame::PositionChildViews(this);
|
2002-04-07 22:26:35 +04:00
|
|
|
}
|
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) {
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics captionMet(PR_TRUE);
|
2000-04-29 01:05:31 +04:00
|
|
|
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);
|
2003-01-09 17:26:32 +03:00
|
|
|
mMinCaptionWidth = captionMet.mMaxElementWidth;
|
1998-07-09 00:21:17 +04:00
|
|
|
}
|
1998-06-19 04:34:12 +04:00
|
|
|
}
|
2003-03-14 13:31:55 +03:00
|
|
|
// At this point, we need an inner table frame, and we might have a
|
|
|
|
// caption. Due to the logic in
|
|
|
|
// nsCSSFrameConstructor::ConstructTableFrame, we can end here
|
|
|
|
// without an inner table frame.
|
|
|
|
if (mFrames.IsEmpty() || !mInnerTableFrame) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "incomplete children");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
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
|
2003-01-09 17:26:32 +03:00
|
|
|
nsHTMLReflowMetrics innerMet(aDesiredSize.mComputeMEW);
|
2002-11-08 08:29:34 +03:00
|
|
|
|
|
|
|
nscoord capMin = mMinCaptionWidth;
|
|
|
|
PctAdjustMinCaptionWidth(aPresContext, aOuterRS, captionSide, capMin);
|
|
|
|
|
2005-03-24 22:02:59 +03:00
|
|
|
nscoord availTableWidth = GetInnerTableAvailWidth(aPresContext, mInnerTableFrame, aOuterRS,
|
2002-11-08 08:29:34 +03:00
|
|
|
&capMin, innerMargin, innerPadding);
|
2001-03-13 09:38:59 +03:00
|
|
|
rv = OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet,
|
2005-03-24 22:02:59 +03:00
|
|
|
availTableWidth, innerSize, innerMargin, innerMarginNoAuto,
|
2001-03-13 09:38:59 +03:00
|
|
|
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
|
2005-03-24 22:02:59 +03:00
|
|
|
nscoord availCaptionWidth = GetCaptionAvailWidth(aPresContext, mCaptionFrame, aOuterRS, captionMargin,
|
|
|
|
ignorePadding, &innerSize.width, &innerMarginNoAuto, &innerMargin);
|
2003-09-13 20:26:30 +04:00
|
|
|
nsHTMLReflowMetrics captionMet(PR_FALSE);
|
2004-09-11 10:08:53 +04:00
|
|
|
nsReflowReason reason = aOuterRS.reason;
|
|
|
|
if (eReflowReason_Initial == aOuterRS.reason) {
|
|
|
|
reason = eReflowReason_Resize; // we have already done the initial reflow
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
|
|
|
rv = OuterReflowChild(aPresContext, mCaptionFrame, aOuterRS, captionMet,
|
2005-03-24 22:02:59 +03:00
|
|
|
availCaptionWidth, captionSize, captionMargin, captionMarginNoAuto,
|
2004-09-11 10:08:53 +04:00
|
|
|
ignorePadding, 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
|
|
|
|
2006-01-21 12:54:07 +03:00
|
|
|
GetCaptionOrigin(captionSide, containSize, innerSize,
|
2001-03-13 09:38:59 +03:00
|
|
|
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
|
|
|
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
2001-03-13 09:38:59 +03:00
|
|
|
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 {
|
2006-01-21 12:54:07 +03:00
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
2001-03-13 09:38:59 +03:00
|
|
|
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);
|
2003-01-09 17:26:32 +03:00
|
|
|
if (aDesiredSize.mComputeMEW) {
|
|
|
|
aDesiredSize.mMaxElementWidth = innerMet.mMaxElementWidth;
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
|
2004-12-27 18:05:18 +03:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
2002-11-08 08:29:34 +03:00
|
|
|
innerPadding, captionMargin, captionMarginNoAuto, aOuterRS.availableWidth);
|
2001-03-13 09:38:59 +03:00
|
|
|
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
|
2005-10-04 19:47:21 +04:00
|
|
|
if (mInnerTableFrame) {
|
|
|
|
aDesiredSize.ascent = mInnerTableFrame->GetAscent();
|
|
|
|
aDesiredSize.descent = aDesiredSize.height - aDesiredSize.ascent;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aDesiredSize.ascent = aDesiredSize.height;
|
|
|
|
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);
|
2002-11-08 08:29:34 +03:00
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mInnerTableFrame, aOuterRS.availableWidth,
|
2001-03-13 09:38:59 +03:00
|
|
|
innerMargin, innerMarginNoAuto, innerPadding);
|
|
|
|
if (mCaptionFrame) {
|
2002-11-08 08:29:34 +03:00
|
|
|
nscoord outerWidth;
|
|
|
|
switch (captionSide) {
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
outerWidth = innerMargin.left;
|
|
|
|
break;
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
outerWidth = innerMargin.right;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
outerWidth = aOuterRS.availableWidth;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
GetMarginPadding(aPresContext, aOuterRS, mCaptionFrame, outerWidth,
|
2001-03-13 09:38:59 +03:00
|
|
|
capMargin, capMarginNoAuto, capPadding);
|
|
|
|
}
|
2004-12-27 18:05:18 +03:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, innerMarginNoAuto,
|
2002-11-08 08:29:34 +03:00
|
|
|
innerPadding, capMargin, capMarginNoAuto, aOuterRS.availableWidth);
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
|
|
|
#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
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aOuterRS, aDesiredSize);
|
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
|
|
|
|
*/
|
2004-08-01 03:15:21 +04:00
|
|
|
void nsTableOuterFrame::DeleteChildsNextInFlow(nsPresContext* 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
|
|
|
|
2004-09-14 06:28:03 +04:00
|
|
|
nsIFrame* nextInFlow = aChild->GetNextInFlow();
|
2001-11-29 18:55:27 +03:00
|
|
|
if (!nextInFlow) {
|
|
|
|
NS_ASSERTION(PR_FALSE, "null next-in-flow");
|
|
|
|
return;
|
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
|
|
|
|
nsTableOuterFrame* parent = NS_STATIC_CAST(nsTableOuterFrame*,
|
|
|
|
nextInFlow->GetParent());
|
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).
|
2004-09-14 06:28:03 +04:00
|
|
|
nsIFrame* nextNextInFlow = nextInFlow->GetNextInFlow();
|
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) {
|
2003-07-07 06:01:29 +04:00
|
|
|
parent->mFrames.SetFrames(nextInFlow->GetNextSibling());
|
1998-04-17 02:21:32 +04:00
|
|
|
} else {
|
|
|
|
// 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)
|
2003-07-07 06:01:29 +04:00
|
|
|
NS_ASSERTION(aChild->GetNextSibling() == nextInFlow, "unexpected sibling");
|
1998-04-17 02:21:32 +04:00
|
|
|
|
2003-07-07 06:01:29 +04:00
|
|
|
aChild->SetNextSibling(nextInFlow->GetNextSibling());
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
|
|
|
|
2005-11-21 01:05:24 +03:00
|
|
|
// Delete the next-in-flow frame and adjust its parent's child count
|
1999-07-22 06:24:52 +04:00
|
|
|
nextInFlow->Destroy(aPresContext);
|
1998-04-17 02:21:32 +04:00
|
|
|
|
2004-09-14 06:28:03 +04:00
|
|
|
NS_POSTCONDITION(!aChild->GetNextInFlow(), "non null next-in-flow");
|
1998-04-17 02:21:32 +04:00
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableOuterFrame::GetType() const
|
1999-02-24 08:54:31 +03:00
|
|
|
{
|
2003-10-31 23:19:18 +03:00
|
|
|
return nsLayoutAtoms::tableOuterFrame;
|
1999-02-24 08:54:31 +03:00
|
|
|
}
|
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;
|
2002-12-03 08:22:32 +03:00
|
|
|
if (NS_SUCCEEDED(CallQueryInterface(mInnerTableFrame, &inner))) {
|
1999-08-01 02:11:50 +04:00
|
|
|
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;
|
2002-12-03 08:22:32 +03:00
|
|
|
if (NS_SUCCEEDED(CallQueryInterface(mInnerTableFrame, &inner))) {
|
1999-08-01 20:20:14 +04:00
|
|
|
return (inner->GetTableSize(aRowCount, aColCount));
|
|
|
|
}
|
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------- end of nsITableLayout implementation ------------------*/
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2005-11-04 05:38:33 +03:00
|
|
|
nsIFrame*
|
|
|
|
NS_NewTableOuterFrame(nsIPresShell* aPresShell)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2005-11-04 05:38:33 +03:00
|
|
|
return new (aPresShell) nsTableOuterFrame;
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
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-09-01 05:02:16 +04:00
|
|
|
#endif
|
2003-10-21 08:32:57 +04:00
|
|
|
|