2001-09-28 20:14:13 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-18 14:30:37 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
1998-04-13 20:24:54 +00:00
|
|
|
*
|
1999-11-06 03:40:37 +00:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-18 14:30:37 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-09-28 20:14:13 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
1999-11-06 03:40:37 +00:00
|
|
|
*
|
2001-09-28 20:14:13 +00:00
|
|
|
* Contributor(s):
|
2000-02-02 22:24:56 +00:00
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-18 14:30:37 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-09-28 20:14:13 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-18 14:30:37 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-09-28 20:14:13 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-18 14:30:37 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-09-28 20:14:13 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsTableOuterFrame.h"
|
|
|
|
#include "nsTableFrame.h"
|
2003-02-22 00:32:13 +00:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsStyleConsts.h"
|
2004-07-31 23:15:21 +00:00
|
|
|
#include "nsPresContext.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
1998-07-02 17:40:56 +00:00
|
|
|
#include "prinrval.h"
|
2007-01-30 00:06:41 +00:00
|
|
|
#include "nsGkAtoms.h"
|
1999-08-10 03:52:15 +00:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIPresShell.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2011-01-28 04:38:14 +00:00
|
|
|
#include "nsAccessibilityService.h"
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-04-01 01:01:33 +00:00
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
2006-01-26 02:29:17 +00:00
|
|
|
#include "nsDisplayList.h"
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
#include "nsLayoutUtils.h"
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2012-01-25 01:21:29 +00:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::layout;
|
|
|
|
|
2000-03-02 06:09:37 +00:00
|
|
|
/* ----------- nsTableCaptionFrame ---------- */
|
|
|
|
|
2011-05-10 00:36:10 +00:00
|
|
|
#define NS_TABLE_FRAME_CAPTION_LIST_INDEX 1
|
2000-04-28 21:05:31 +00:00
|
|
|
#define NO_SIDE 100
|
2000-01-28 02:19:45 +00:00
|
|
|
|
|
|
|
// caption frame
|
2006-03-26 21:30:36 +00:00
|
|
|
nsTableCaptionFrame::nsTableCaptionFrame(nsStyleContext* aContext):
|
|
|
|
nsBlockFrame(aContext)
|
2000-01-28 02:19:45 +00:00
|
|
|
{
|
|
|
|
// shrink wrap
|
2009-01-05 00:39:54 +00:00
|
|
|
SetFlags(NS_BLOCK_FLOAT_MGR);
|
2000-01-28 02:19:45 +00:00
|
|
|
}
|
|
|
|
|
2000-03-02 06:09:37 +00:00
|
|
|
nsTableCaptionFrame::~nsTableCaptionFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsTableCaptionFrame::GetType() const
|
2000-01-28 02:19:45 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::tableCaptionFrame;
|
2000-01-28 02:19:45 +00:00
|
|
|
}
|
|
|
|
|
2007-01-23 04:06:56 +00:00
|
|
|
/* virtual */ nscoord
|
|
|
|
nsTableOuterFrame::GetBaseline() const
|
|
|
|
{
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
if (!kid) {
|
|
|
|
NS_NOTREACHED("no inner table");
|
2011-12-27 20:18:48 +00:00
|
|
|
return nsContainerFrame::GetBaseline();
|
2007-01-23 04:06:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return kid->GetBaseline() + kid->GetPosition().y;
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ nsSize
|
2011-04-08 01:04:40 +00:00
|
|
|
nsTableCaptionFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSize aPadding, bool aShrinkWrap)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
nsSize result = nsBlockFrame::ComputeAutoSize(aRenderingContext, aCBSize,
|
|
|
|
aAvailableWidth, aMargin, aBorder, aPadding, aShrinkWrap);
|
2012-01-25 01:21:29 +00:00
|
|
|
|
|
|
|
// If we're a container for font size inflation, then shrink
|
|
|
|
// wrapping inside of us should not apply font size inflation.
|
|
|
|
AutoMaybeNullInflationContainer an(this);
|
|
|
|
|
2008-02-27 02:02:20 +00:00
|
|
|
PRUint8 captionSide = GetStyleTableBorder()->mCaptionSide;
|
|
|
|
if (captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
result.width = GetMinWidth(aRenderingContext);
|
2008-02-27 02:02:20 +00:00
|
|
|
} else if (captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
|
|
|
|
// The outer frame constrains our available width to the width of
|
|
|
|
// the table. Grow if our min-width is bigger than that, but not
|
|
|
|
// larger than the containing block width. (It would really be nice
|
|
|
|
// to transmit that information another way, so we could grow up to
|
|
|
|
// the table's available width, but that's harder.)
|
|
|
|
nscoord min = GetMinWidth(aRenderingContext);
|
|
|
|
if (min > aCBSize.width)
|
|
|
|
min = aCBSize.width;
|
|
|
|
if (min > result.width)
|
|
|
|
result.width = min;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame*
|
2012-02-15 09:28:21 +00:00
|
|
|
nsTableCaptionFrame::GetParentStyleContextFrame() const
|
2007-04-22 19:15:24 +00:00
|
|
|
{
|
2007-05-08 03:59:12 +00:00
|
|
|
NS_PRECONDITION(mContent->GetParent(),
|
|
|
|
"How could we not have a parent here?");
|
|
|
|
|
2007-04-22 19:15:24 +00:00
|
|
|
// The caption's style context parent is the inner frame, unless
|
|
|
|
// it's anonymous.
|
|
|
|
nsIFrame* outerFrame = GetParent();
|
|
|
|
if (outerFrame && outerFrame->GetType() == nsGkAtoms::tableOuterFrame) {
|
2011-08-24 20:54:30 +00:00
|
|
|
nsIFrame* innerFrame = outerFrame->GetFirstPrincipalChild();
|
2007-04-22 19:15:24 +00:00
|
|
|
if (innerFrame) {
|
2011-09-12 16:08:07 +00:00
|
|
|
return nsFrame::CorrectStyleParentFrame(innerFrame,
|
|
|
|
GetStyleContext()->GetPseudo());
|
2007-04-22 19:15:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_NOTREACHED("Where is our inner table frame?");
|
2011-09-12 16:08:07 +00:00
|
|
|
return nsBlockFrame::GetParentStyleContextFrame();
|
2007-04-22 19:15:24 +00:00
|
|
|
}
|
|
|
|
|
2007-07-05 15:39:29 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 12:02:03 +00:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsTableCaptionFrame::CreateAccessible()
|
2007-07-05 15:39:29 +00:00
|
|
|
{
|
|
|
|
if (!GetRect().IsEmpty()) {
|
2011-01-28 04:38:14 +00:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2007-07-05 15:39:29 +00:00
|
|
|
if (accService) {
|
2010-06-28 12:02:03 +00:00
|
|
|
return accService->CreateHTMLCaptionAccessible(mContent,
|
|
|
|
PresContext()->PresShell());
|
2007-07-05 15:39:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-28 12:02:03 +00:00
|
|
|
return nsnull;
|
2007-07-05 15:39:29 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-07-20 08:50:26 +00:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCaptionFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Caption"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
2000-01-28 02:19:45 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsTableCaptionFrame(aContext);
|
2000-01-28 02:19:45 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableCaptionFrame)
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
/* ----------- nsTableOuterFrame ---------- */
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsTableOuterFrame::nsTableOuterFrame(nsStyleContext* aContext):
|
2011-12-27 20:18:48 +00:00
|
|
|
nsContainerFrame(aContext)
|
2000-03-02 06:09:37 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableOuterFrame::~nsTableOuterFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-12 19:20:59 +00:00
|
|
|
NS_QUERYFRAME_HEAD(nsTableOuterFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsITableLayout)
|
2011-12-27 20:18:48 +00:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2001-05-17 23:52:32 +00:00
|
|
|
|
2001-08-17 03:13:07 +00:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 12:02:03 +00:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsTableOuterFrame::CreateAccessible()
|
2001-05-17 23:52:32 +00:00
|
|
|
{
|
2011-01-28 04:38:14 +00:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2001-05-17 23:52:32 +00:00
|
|
|
if (accService) {
|
2010-06-28 12:02:03 +00:00
|
|
|
return accService->CreateHTMLTableAccessible(mContent,
|
|
|
|
PresContext()->PresShell());
|
2001-05-17 23:52:32 +00:00
|
|
|
}
|
|
|
|
|
2010-06-28 12:02:03 +00:00
|
|
|
return nsnull;
|
1999-08-01 18:26:45 +00:00
|
|
|
}
|
2001-08-17 03:13:07 +00:00
|
|
|
#endif
|
2001-05-17 23:52:32 +00:00
|
|
|
|
2006-07-20 08:50:26 +00:00
|
|
|
void
|
2009-12-24 05:21:15 +00:00
|
|
|
nsTableOuterFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2006-07-20 08:50:26 +00:00
|
|
|
{
|
2011-05-10 00:36:10 +00:00
|
|
|
DestroyAbsoluteFrames(aDestructRoot);
|
2009-12-24 05:21:15 +00:00
|
|
|
mCaptionFrames.DestroyFramesFrom(aDestructRoot);
|
2011-12-27 20:18:48 +00:00
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
2006-07-20 08:50:26 +00:00
|
|
|
}
|
|
|
|
|
2012-03-08 01:57:37 +00:00
|
|
|
const nsFrameList&
|
2011-08-24 20:54:29 +00:00
|
|
|
nsTableOuterFrame::GetChildList(ChildListID aListID) const
|
|
|
|
{
|
2011-04-29 23:02:33 +00:00
|
|
|
if (aListID == kCaptionList) {
|
|
|
|
return mCaptionFrames;
|
2004-01-09 14:20:53 +00:00
|
|
|
}
|
2011-04-29 23:02:33 +00:00
|
|
|
|
2011-12-27 20:18:48 +00:00
|
|
|
return nsContainerFrame::GetChildList(aListID);
|
2000-01-28 02:19:45 +00:00
|
|
|
}
|
|
|
|
|
2011-08-24 20:54:29 +00:00
|
|
|
void
|
|
|
|
nsTableOuterFrame::GetChildLists(nsTArray<ChildList>* aLists) const
|
2000-01-28 02:19:45 +00:00
|
|
|
{
|
2011-12-27 20:18:48 +00:00
|
|
|
nsContainerFrame::GetChildLists(aLists);
|
2011-08-24 20:54:29 +00:00
|
|
|
mCaptionFrames.AppendIfNonempty(aLists, kCaptionList);
|
2000-01-28 02:19:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsTableOuterFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 12:53:20 +00:00
|
|
|
nsFrameList& aChildList)
|
2000-01-28 02:19:45 +00:00
|
|
|
{
|
2011-08-24 20:54:30 +00:00
|
|
|
if (kCaptionList == aListID) {
|
2000-01-28 02:19:45 +00:00
|
|
|
// the frame constructor already checked for table-caption display type
|
2005-12-03 15:13:08 +00:00
|
|
|
mCaptionFrames.SetFrames(aChildList);
|
2000-01-28 02:19:45 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "wrong childlist");
|
2006-03-18 07:18:54 +00:00
|
|
|
NS_ASSERTION(mFrames.IsEmpty(), "Frame leak!");
|
2011-09-12 16:08:07 +00:00
|
|
|
NS_ASSERTION(aChildList.FirstChild() &&
|
|
|
|
nsGkAtoms::tableFrame == aChildList.FirstChild()->GetType(),
|
|
|
|
"expected a table frame");
|
|
|
|
mFrames.SetFrames(aChildList);
|
2000-01-28 02:19:45 +00:00
|
|
|
}
|
|
|
|
|
1998-09-16 17:19:20 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
1999-08-10 03:52:15 +00:00
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsTableOuterFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-10 03:52:15 +00:00
|
|
|
{
|
2000-01-28 02:19:45 +00:00
|
|
|
nsresult rv;
|
1999-08-10 03:52:15 +00:00
|
|
|
|
2005-12-03 15:13:08 +00:00
|
|
|
// We only have two child frames: the inner table and a caption frame.
|
1999-08-10 03:52:15 +00:00
|
|
|
// The inner frame is provided when we're initialized, and it cannot change
|
2011-08-24 20:54:30 +00:00
|
|
|
if (kCaptionList == aListID) {
|
2009-07-30 17:23:32 +00:00
|
|
|
NS_ASSERTION(aFrameList.IsEmpty() ||
|
|
|
|
aFrameList.FirstChild()->GetType() == nsGkAtoms::tableCaptionFrame,
|
2006-06-29 02:32:36 +00:00
|
|
|
"appending non-caption frame to captionList");
|
2005-12-03 15:13:08 +00:00
|
|
|
mCaptionFrames.AppendFrames(this, aFrameList);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
rv = NS_OK;
|
2005-12-03 15:13:08 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Reflow the new caption frame. It's already marked dirty, so
|
|
|
|
// just tell the pres shell.
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
1999-08-10 03:52:15 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-10-17 14:59:28 +00:00
|
|
|
NS_PRECONDITION(false, "unexpected child list");
|
1999-08-10 03:52:15 +00:00
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsTableOuterFrame::InsertFrames(ChildListID aListID,
|
1999-08-10 03:52:15 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-10 03:52:15 +00:00
|
|
|
{
|
2011-08-24 20:54:30 +00:00
|
|
|
if (kCaptionList == aListID) {
|
2006-06-29 02:32:36 +00:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
2009-07-30 17:23:32 +00:00
|
|
|
NS_ASSERTION(aFrameList.IsEmpty() ||
|
|
|
|
aFrameList.FirstChild()->GetType() == nsGkAtoms::tableCaptionFrame,
|
2006-06-29 02:32:36 +00:00
|
|
|
"inserting non-caption frame into captionList");
|
2005-12-03 15:13:08 +00:00
|
|
|
mCaptionFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
2007-08-02 21:34:58 +00:00
|
|
|
|
|
|
|
// Reflow the new caption frame. It's already marked dirty, so
|
|
|
|
// just tell the pres shell.
|
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
2005-12-03 15:13:08 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_PRECONDITION(!aPrevFrame, "invalid previous frame");
|
2011-08-24 20:54:30 +00:00
|
|
|
return AppendFrames(aListID, aFrameList);
|
2005-12-03 15:13:08 +00:00
|
|
|
}
|
1999-08-10 03:52:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 20:54:30 +00:00
|
|
|
nsTableOuterFrame::RemoveFrame(ChildListID aListID,
|
1999-08-10 03:52:15 +00: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
|
2011-08-24 20:54:30 +00:00
|
|
|
NS_PRECONDITION(kCaptionList == aListID, "can't remove inner frame");
|
1999-08-10 03:52:15 +00:00
|
|
|
|
2008-02-27 02:02:20 +00:00
|
|
|
if (HasSideCaption()) {
|
1999-08-10 03:52:15 +00: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
|
2011-09-12 16:08:07 +00:00
|
|
|
InnerTableFrame()->AddStateBits(NS_FRAME_IS_DIRTY);
|
1999-08-10 03:52:15 +00:00
|
|
|
}
|
|
|
|
|
2005-12-03 15:13:08 +00:00
|
|
|
// Remove the frame and destroy it
|
2006-04-10 00:16:29 +00:00
|
|
|
mCaptionFrames.DestroyFrame(aOldFrame);
|
2005-12-03 15:13:08 +00:00
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 19:16:51 +00:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN); // also means child removed
|
1999-08-10 03:52:15 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-09-19 12:35:19 +00:00
|
|
|
NS_METHOD
|
2006-01-26 02:29:17 +00:00
|
|
|
nsTableOuterFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00:00
|
|
|
// No border, background or outline are painted because they all belong
|
|
|
|
// to the inner table.
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// If there's no caption, take a short cut to avoid having to create
|
|
|
|
// the special display list set and then sort it.
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.IsEmpty())
|
2006-01-26 02:29:17 +00:00
|
|
|
return BuildDisplayListForInnerTable(aBuilder, aDirtyRect, aLists);
|
|
|
|
|
|
|
|
nsDisplayListCollection set;
|
|
|
|
nsresult rv = BuildDisplayListForInnerTable(aBuilder, aDirtyRect, set);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2001-12-09 05:39:45 +00:00
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsDisplayListSet captionSet(set, set.BlockBorderBackgrounds());
|
2011-09-12 16:08:07 +00:00
|
|
|
rv = BuildDisplayListForChild(aBuilder, mCaptionFrames.FirstChild(),
|
|
|
|
aDirtyRect, captionSet);
|
2006-01-26 02:29:17 +00:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2000-01-28 02:19:45 +00:00
|
|
|
|
2006-01-26 02:29:17 +00: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 01:41:24 +00:00
|
|
|
return NS_OK;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::BuildDisplayListForInnerTable(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
2000-03-22 02:43:08 +00:00
|
|
|
{
|
2006-01-26 02:29:17 +00: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 11:35:12 +00:00
|
|
|
}
|
2006-01-26 02:29:17 +00:00
|
|
|
return NS_OK;
|
2000-03-22 02:43:08 +00:00
|
|
|
}
|
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
nsIFrame*
|
2012-02-15 09:28:21 +00:00
|
|
|
nsTableOuterFrame::GetParentStyleContextFrame() const
|
2000-09-12 22:48:35 +00:00
|
|
|
{
|
2002-03-27 02:38:13 +00: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-07 21:57:01 +00: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 02:38:13 +00:00
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
return InnerTableFrame();
|
2000-09-12 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
// INCREMENTAL REFLOW HELPER FUNCTIONS
|
|
|
|
|
2002-02-19 15:48:28 +00:00
|
|
|
void
|
2004-07-31 23:15:21 +00:00
|
|
|
nsTableOuterFrame::InitChildReflowState(nsPresContext& aPresContext,
|
2002-02-19 15:48:28 +00:00
|
|
|
nsHTMLReflowState& aReflowState)
|
|
|
|
|
|
|
|
{
|
|
|
|
nsMargin collapseBorder;
|
|
|
|
nsMargin collapsePadding(0,0,0,0);
|
|
|
|
nsMargin* pCollapseBorder = nsnull;
|
|
|
|
nsMargin* pCollapsePadding = nsnull;
|
2011-09-12 16:08:07 +00:00
|
|
|
if (aReflowState.frame == InnerTableFrame() &&
|
|
|
|
InnerTableFrame()->IsBorderCollapse()) {
|
|
|
|
collapseBorder = InnerTableFrame()->GetIncludedOuterBCBorder();
|
2003-09-13 16:26:30 +00:00
|
|
|
pCollapseBorder = &collapseBorder;
|
2002-02-19 15:48:28 +00:00
|
|
|
pCollapsePadding = &collapsePadding;
|
|
|
|
}
|
|
|
|
aReflowState.Init(&aPresContext, -1, -1, pCollapseBorder, pCollapsePadding);
|
|
|
|
}
|
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
// get the margin and padding data. nsHTMLReflowState doesn't handle the
|
|
|
|
// case of auto margins
|
|
|
|
void
|
2009-12-23 02:59:29 +00:00
|
|
|
nsTableOuterFrame::GetChildMargin(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
nscoord aAvailWidth,
|
|
|
|
nsMargin& aMargin)
|
2002-02-19 15:48:28 +00:00
|
|
|
{
|
2000-04-28 21:05:31 +00:00
|
|
|
// construct a reflow state to compute margin and padding. Auto margins
|
|
|
|
// will not be computed at this time.
|
2002-02-19 15:48:28 +00:00
|
|
|
|
2002-11-08 05:29:34 +00:00
|
|
|
// create and init the child reflow state
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// XXX We really shouldn't construct a reflow state to do this.
|
|
|
|
nsHTMLReflowState childRS(aPresContext, aOuterRS, aChildFrame,
|
|
|
|
nsSize(aAvailWidth, aOuterRS.availableHeight),
|
2011-10-17 14:59:28 +00:00
|
|
|
-1, -1, false);
|
2002-02-19 15:48:28 +00:00
|
|
|
InitChildReflowState(*aPresContext, childRS);
|
|
|
|
|
2000-09-11 00:02:04 +00:00
|
|
|
aMargin = childRS.mComputedMargin;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
|
2005-04-07 18:04:38 +00:00
|
|
|
static nsSize
|
2000-04-28 21:05:31 +00:00
|
|
|
GetContainingBlockSize(const nsHTMLReflowState& aOuterRS)
|
|
|
|
{
|
|
|
|
nsSize size(0,0);
|
2002-05-14 12:59:55 +00:00
|
|
|
const nsHTMLReflowState* containRS =
|
2004-04-24 17:56:23 +00:00
|
|
|
aOuterRS.mCBReflowState;
|
2000-04-28 21:05:31 +00:00
|
|
|
|
|
|
|
if (containRS) {
|
2007-01-26 00:05:12 +00:00
|
|
|
size.width = containRS->ComputedWidth();
|
2000-04-28 21:05:31 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == size.width) {
|
|
|
|
size.width = 0;
|
|
|
|
}
|
2007-08-02 18:08:05 +00:00
|
|
|
size.height = containRS->ComputedHeight();
|
2000-04-28 21:05:31 +00:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == size.height) {
|
|
|
|
size.height = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsTableOuterFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2000-04-28 21:05:31 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord width = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
2011-09-12 16:08:07 +00:00
|
|
|
InnerTableFrame(), nsLayoutUtils::MIN_WIDTH);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DISPLAY_MIN_WIDTH(this, width);
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord capWidth =
|
2011-09-12 16:08:07 +00:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mCaptionFrames.FirstChild(),
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsLayoutUtils::MIN_WIDTH);
|
2008-02-27 02:02:20 +00:00
|
|
|
if (HasSideCaption()) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
width += capWidth;
|
2008-02-27 02:02:20 +00:00
|
|
|
} else {
|
2003-01-09 14:26:32 +00:00
|
|
|
if (capWidth > width) {
|
|
|
|
width = capWidth;
|
2002-11-08 05:29:34 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
}
|
2003-01-09 14:26:32 +00:00
|
|
|
return width;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsTableOuterFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
2000-04-28 21:05:31 +00:00
|
|
|
{
|
|
|
|
nscoord maxWidth;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DISPLAY_PREF_WIDTH(this, maxWidth);
|
2002-11-08 05:29:34 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
maxWidth = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
2011-09-12 16:08:07 +00:00
|
|
|
InnerTableFrame(), nsLayoutUtils::PREF_WIDTH);
|
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
switch(captionSide) {
|
2008-02-27 02:02:20 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_RIGHT:
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
|
|
|
nscoord capMin =
|
2011-09-12 16:08:07 +00:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mCaptionFrames.FirstChild(),
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsLayoutUtils::MIN_WIDTH);
|
|
|
|
maxWidth += capMin;
|
|
|
|
}
|
2002-11-08 05:29:34 +00:00
|
|
|
break;
|
2008-02-27 02:02:20 +00:00
|
|
|
default:
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
2008-02-27 02:02:20 +00:00
|
|
|
nsLayoutUtils::IntrinsicWidthType iwt;
|
|
|
|
if (captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
|
|
|
|
// Don't let the caption's pref width expand the table's pref
|
|
|
|
// width.
|
|
|
|
iwt = nsLayoutUtils::MIN_WIDTH;
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(captionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE,
|
|
|
|
"unexpected caption side");
|
|
|
|
iwt = nsLayoutUtils::PREF_WIDTH;
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nscoord capPref =
|
2011-09-12 16:08:07 +00:00
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mCaptionFrames.FirstChild(),
|
2008-02-27 02:02:20 +00:00
|
|
|
iwt);
|
2009-09-16 15:01:36 +00:00
|
|
|
maxWidth = NS_MAX(maxWidth, capPref);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
2008-02-27 02:02:20 +00:00
|
|
|
break;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return maxWidth;
|
|
|
|
}
|
|
|
|
|
2008-02-28 17:55:04 +00:00
|
|
|
// Compute the margin-box width of aChildFrame given the inputs. If
|
|
|
|
// aMarginResult is non-null, fill it with the part of the margin-width
|
|
|
|
// that was contributed by the margin.
|
|
|
|
static nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
ChildShrinkWrapWidth(nsRenderingContext *aRenderingContext,
|
2008-02-28 17:55:04 +00:00
|
|
|
nsIFrame *aChildFrame,
|
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nscoord *aMarginResult = nsnull)
|
|
|
|
{
|
2012-01-25 01:21:29 +00:00
|
|
|
AutoMaybeNullInflationContainer an(aChildFrame);
|
|
|
|
|
2008-02-28 17:55:04 +00:00
|
|
|
nsCSSOffsetState offsets(aChildFrame, aRenderingContext, aCBSize.width);
|
|
|
|
nsSize size = aChildFrame->ComputeSize(aRenderingContext, aCBSize,
|
|
|
|
aAvailableWidth,
|
|
|
|
nsSize(offsets.mComputedMargin.LeftRight(),
|
|
|
|
offsets.mComputedMargin.TopBottom()),
|
|
|
|
nsSize(offsets.mComputedBorderPadding.LeftRight() -
|
|
|
|
offsets.mComputedPadding.LeftRight(),
|
|
|
|
offsets.mComputedBorderPadding.TopBottom() -
|
|
|
|
offsets.mComputedPadding.TopBottom()),
|
|
|
|
nsSize(offsets.mComputedPadding.LeftRight(),
|
|
|
|
offsets.mComputedPadding.TopBottom()),
|
2011-10-17 14:59:28 +00:00
|
|
|
true);
|
2008-02-28 17:55:04 +00:00
|
|
|
if (aMarginResult)
|
|
|
|
*aMarginResult = offsets.mComputedMargin.LeftRight();
|
|
|
|
return size.width + offsets.mComputedMargin.LeftRight() +
|
|
|
|
offsets.mComputedBorderPadding.LeftRight();
|
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
/* virtual */ nsSize
|
2011-04-08 01:04:40 +00:00
|
|
|
nsTableOuterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
2011-09-29 06:19:26 +00:00
|
|
|
nsSize aPadding, bool aShrinkWrap)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
{
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
nscoord kidAvailableWidth = aAvailableWidth - aMargin.width;
|
|
|
|
NS_ASSERTION(aBorder == nsSize(0, 0) &&
|
|
|
|
aPadding == nsSize(0, 0),
|
|
|
|
"Table outer frames cannot hae borders or paddings");
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
|
|
|
// When we're shrink-wrapping, our auto size needs to wrap around the
|
|
|
|
// actual size of the table, which (if it is specified as a percent)
|
|
|
|
// could be something that is not reflected in our GetMinWidth and
|
|
|
|
// GetPrefWidth. See bug 349457 for an example.
|
|
|
|
|
2008-02-28 17:55:04 +00:00
|
|
|
// Match the availableWidth logic in Reflow.
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
nscoord width;
|
|
|
|
if (captionSide == NO_SIDE) {
|
2011-09-12 16:08:07 +00:00
|
|
|
width = ChildShrinkWrapWidth(aRenderingContext, InnerTableFrame(),
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
aCBSize, kidAvailableWidth);
|
2008-02-28 17:55:04 +00:00
|
|
|
} else if (captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT) {
|
2011-09-12 16:08:07 +00:00
|
|
|
nscoord capWidth = ChildShrinkWrapWidth(aRenderingContext,
|
|
|
|
mCaptionFrames.FirstChild(),
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
aCBSize, kidAvailableWidth);
|
2008-02-28 17:55:04 +00:00
|
|
|
width = capWidth + ChildShrinkWrapWidth(aRenderingContext,
|
2011-09-12 16:08:07 +00:00
|
|
|
InnerTableFrame(), aCBSize,
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
kidAvailableWidth - capWidth);
|
2008-02-28 17:55:04 +00:00
|
|
|
} else if (captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
|
|
|
|
nscoord margin;
|
2011-09-12 16:08:07 +00:00
|
|
|
width = ChildShrinkWrapWidth(aRenderingContext, InnerTableFrame(),
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
aCBSize, kidAvailableWidth, &margin);
|
2008-02-28 17:55:04 +00:00
|
|
|
nscoord capWidth = ChildShrinkWrapWidth(aRenderingContext,
|
2011-09-12 16:08:07 +00:00
|
|
|
mCaptionFrames.FirstChild(), aCBSize,
|
2008-02-28 17:55:04 +00:00
|
|
|
width - margin);
|
|
|
|
if (capWidth > width)
|
|
|
|
width = capWidth;
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(captionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE,
|
|
|
|
"unexpected caption-side");
|
2011-09-12 16:08:07 +00:00
|
|
|
width = ChildShrinkWrapWidth(aRenderingContext, InnerTableFrame(),
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
aCBSize, kidAvailableWidth);
|
2008-02-28 17:55:04 +00:00
|
|
|
nscoord capWidth = ChildShrinkWrapWidth(aRenderingContext,
|
2011-09-12 16:08:07 +00:00
|
|
|
mCaptionFrames.FirstChild(),
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
aCBSize, kidAvailableWidth);
|
2008-02-28 17:55:04 +00:00
|
|
|
if (capWidth > width)
|
|
|
|
width = capWidth;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsSize(width, NS_UNCONSTRAINEDSIZE);
|
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
|
|
|
|
PRUint8
|
|
|
|
nsTableOuterFrame::GetCaptionSide()
|
1998-06-19 00:34:12 +00:00
|
|
|
{
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
|
|
|
return mCaptionFrames.FirstChild()->GetStyleTableBorder()->mCaptionSide;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NO_SIDE; // no caption
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-11-08 05:29:34 +00:00
|
|
|
PRUint8
|
|
|
|
nsTableOuterFrame::GetCaptionVerticalAlign()
|
|
|
|
{
|
2011-09-12 16:08:07 +00:00
|
|
|
const nsStyleCoord& va =
|
|
|
|
mCaptionFrames.FirstChild()->GetStyleTextReset()->mVerticalAlign;
|
2005-04-07 18:04:38 +00:00
|
|
|
return (va.GetUnit() == eStyleUnit_Enumerated)
|
|
|
|
? va.GetIntValue()
|
|
|
|
: NS_STYLE_VERTICAL_ALIGN_TOP;
|
2002-11-08 05:29:34 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
|
|
|
|
void
|
2004-12-27 15:05:18 +00:00
|
|
|
nsTableOuterFrame::SetDesiredSize(PRUint8 aCaptionSide,
|
2000-04-28 21:05:31 +00:00
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
nscoord& aWidth,
|
|
|
|
nscoord& aHeight)
|
|
|
|
{
|
|
|
|
aWidth = aHeight = 0;
|
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
nsRect innerRect = InnerTableFrame()->GetRect();
|
2002-11-08 05:29:34 +00:00
|
|
|
nscoord innerWidth = innerRect.width;
|
2000-04-28 21:05:31 +00:00
|
|
|
|
|
|
|
nsRect captionRect(0,0,0,0);
|
2002-11-08 05:29:34 +00:00
|
|
|
nscoord captionWidth = 0;
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
|
|
|
captionRect = mCaptionFrames.FirstChild()->GetRect();
|
2002-11-08 05:29:34 +00:00
|
|
|
captionWidth = captionRect.width;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
switch(aCaptionSide) {
|
2008-02-27 02:02:20 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT:
|
2009-09-16 15:01:36 +00:00
|
|
|
aWidth = NS_MAX(aInnerMargin.left, aCaptionMargin.left + captionWidth + aCaptionMargin.right) +
|
2002-11-08 05:29:34 +00:00
|
|
|
innerWidth + aInnerMargin.right;
|
|
|
|
break;
|
2008-02-27 02:02:20 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_RIGHT:
|
2009-09-16 15:01:36 +00:00
|
|
|
aWidth = NS_MAX(aInnerMargin.right, aCaptionMargin.left + captionWidth + aCaptionMargin.right) +
|
2002-11-08 05:29:34 +00:00
|
|
|
innerWidth + aInnerMargin.left;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aWidth = aInnerMargin.left + innerWidth + aInnerMargin.right;
|
2009-09-16 15:01:36 +00:00
|
|
|
aWidth = NS_MAX(aWidth, captionRect.XMost() + aCaptionMargin.right);
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
2002-11-08 05:29:34 +00:00
|
|
|
aHeight = innerRect.YMost() + aInnerMargin.bottom;
|
2009-06-28 13:51:46 +00:00
|
|
|
if (NS_STYLE_CAPTION_SIDE_BOTTOM != aCaptionSide) {
|
2009-09-16 15:01:36 +00:00
|
|
|
aHeight = NS_MAX(aHeight, captionRect.YMost() + aCaptionMargin.bottom);
|
2009-06-28 13:51:46 +00:00
|
|
|
}
|
|
|
|
else {
|
2009-09-16 15:01:36 +00:00
|
|
|
aHeight = NS_MAX(aHeight, captionRect.YMost() + aCaptionMargin.bottom +
|
2009-06-28 13:51:46 +00:00
|
|
|
aInnerMargin.bottom);
|
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
|
2002-11-08 05:29:34 +00:00
|
|
|
}
|
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
nsresult
|
2006-01-21 09:54:07 +00:00
|
|
|
nsTableOuterFrame::GetCaptionOrigin(PRUint32 aCaptionSide,
|
2000-04-28 21:05:31 +00: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 05:29:34 +00:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aInnerSize.width) || (NS_UNCONSTRAINEDSIZE == aInnerSize.height) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aCaptionSize.width) || (NS_UNCONSTRAINEDSIZE == aCaptionSize.height)) {
|
2000-04-28 21:05:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.IsEmpty()) return NS_OK;
|
2009-06-28 13:51:46 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(NS_AUTOMARGIN != aCaptionMargin.left, "The computed caption margin is auto?");
|
|
|
|
NS_ASSERTION(NS_AUTOMARGIN != aCaptionMargin.top, "The computed caption margin is auto?");
|
|
|
|
NS_ASSERTION(NS_AUTOMARGIN != aCaptionMargin.bottom, "The computed caption margin is auto?");
|
2000-04-28 21:05:31 +00:00
|
|
|
|
2009-06-28 13:51:46 +00:00
|
|
|
// horizontal computation
|
2000-04-28 21:05:31 +00:00
|
|
|
switch(aCaptionSide) {
|
2008-02-27 02:02:20 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE: {
|
2009-06-28 13:51:46 +00:00
|
|
|
// FIXME: Position relative to right edge for RTL. (Based on table
|
|
|
|
// direction or table parent direction?)
|
2000-04-28 21:05:31 +00:00
|
|
|
aOrigin.x = aCaptionMargin.left;
|
2008-02-27 02:03:11 +00:00
|
|
|
if (aCaptionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
|
|
|
|
// We placed the caption using only the table's width as available
|
|
|
|
// width, and we should position it this way as well.
|
|
|
|
aOrigin.x += aInnerMargin.left;
|
|
|
|
}
|
2003-07-23 23:04:37 +00:00
|
|
|
} break;
|
2008-02-27 02:02:20 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT: {
|
2002-11-08 05:29:34 +00:00
|
|
|
aOrigin.x = aCaptionMargin.left;
|
2003-07-23 23:04:37 +00:00
|
|
|
} break;
|
2008-02-27 02:02:20 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_RIGHT: {
|
2002-11-08 05:29:34 +00:00
|
|
|
aOrigin.x = aInnerMargin.left + aInnerSize.width + aCaptionMargin.left;
|
2003-07-23 23:04:37 +00:00
|
|
|
} break;
|
|
|
|
default: { // top
|
2008-02-27 02:02:20 +00:00
|
|
|
NS_ASSERTION(aCaptionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE,
|
|
|
|
"unexpected caption side");
|
2009-06-28 13:51:46 +00:00
|
|
|
// FIXME: Position relative to right edge for RTL. (Based on table
|
|
|
|
// direction or table parent direction?)
|
2000-04-28 21:05:31 +00:00
|
|
|
aOrigin.x = aCaptionMargin.left;
|
2008-02-27 02:03:11 +00:00
|
|
|
if (aCaptionSide == NS_STYLE_CAPTION_SIDE_TOP) {
|
|
|
|
// We placed the caption using only the table's width as available
|
|
|
|
// width, and we should position it this way as well.
|
|
|
|
aOrigin.x += aInnerMargin.left;
|
|
|
|
}
|
2009-06-28 13:51:46 +00:00
|
|
|
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
// vertical computation
|
|
|
|
switch (aCaptionSide) {
|
|
|
|
case NS_STYLE_CAPTION_SIDE_RIGHT:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT:
|
|
|
|
aOrigin.y = aInnerMargin.top;
|
|
|
|
switch (GetCaptionVerticalAlign()) {
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
2009-09-16 15:01:36 +00:00
|
|
|
aOrigin.y = NS_MAX(0, aInnerMargin.top + ((aInnerSize.height - aCaptionSize.height) / 2));
|
2009-06-28 13:51:46 +00:00
|
|
|
break;
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
2009-09-16 15:01:36 +00:00
|
|
|
aOrigin.y = NS_MAX(0, aInnerMargin.top + aInnerSize.height - aCaptionSize.height);
|
2009-06-28 13:51:46 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE:
|
2009-06-28 13:51:46 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM: {
|
|
|
|
aOrigin.y = aInnerMargin.top + aInnerSize.height + aCaptionMargin.top;
|
|
|
|
} break;
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE:
|
2009-06-28 13:51:46 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP: {
|
|
|
|
aOrigin.y = aInnerMargin.top + aCaptionMargin.top;
|
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Unknown caption alignment type");
|
|
|
|
break;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2006-01-21 09:54:07 +00:00
|
|
|
nsTableOuterFrame::GetInnerOrigin(PRUint32 aCaptionSide,
|
2000-04-28 21:05:31 +00:00
|
|
|
const nsSize& aContainBlockSize,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
const nsSize& aInnerSize,
|
|
|
|
nsMargin& aInnerMargin,
|
|
|
|
nsPoint& aOrigin)
|
|
|
|
{
|
2009-06-28 13:51:46 +00:00
|
|
|
|
|
|
|
NS_ASSERTION(NS_AUTOMARGIN != aCaptionMargin.left, "The computed caption margin is auto?");
|
|
|
|
NS_ASSERTION(NS_AUTOMARGIN != aCaptionMargin.right, "The computed caption margin is auto?");
|
|
|
|
NS_ASSERTION(NS_AUTOMARGIN != aInnerMargin.left, "The computed inner margin is auto?");
|
|
|
|
NS_ASSERTION(NS_AUTOMARGIN != aInnerMargin.right, "The computed inner margin is auto?");
|
|
|
|
NS_ASSERTION(NS_AUTOMARGIN != aInnerMargin.top, "The computed inner margin is auto?");
|
|
|
|
NS_ASSERTION(NS_AUTOMARGIN != aInnerMargin.bottom, "The computed inner margin is auto?");
|
|
|
|
|
2000-04-28 21:05:31 +00:00
|
|
|
aOrigin.x = aOrigin.y = 0;
|
2002-11-08 05:29:34 +00:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aInnerSize.width) || (NS_UNCONSTRAINEDSIZE == aInnerSize.height) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aCaptionSize.width) || (NS_UNCONSTRAINEDSIZE == aCaptionSize.height)) {
|
2000-04-28 21:05:31 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-11-08 05:29:34 +00:00
|
|
|
nscoord minCapWidth = aCaptionSize.width;
|
2009-06-28 13:51:46 +00:00
|
|
|
|
|
|
|
minCapWidth += aCaptionMargin.left;
|
|
|
|
minCapWidth += aCaptionMargin.right;
|
2002-11-08 05:29:34 +00:00
|
|
|
|
2009-06-28 13:51:46 +00:00
|
|
|
// horizontal computation
|
|
|
|
switch (aCaptionSide) {
|
2008-02-27 02:02:20 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT: {
|
2002-11-08 05:29:34 +00:00
|
|
|
if (aInnerMargin.left < minCapWidth) {
|
|
|
|
// shift the inner table to get some place for the caption
|
|
|
|
aInnerMargin.right += aInnerMargin.left - minCapWidth;
|
2009-09-16 15:01:36 +00:00
|
|
|
aInnerMargin.right = NS_MAX(0, aInnerMargin.right);
|
2002-11-08 05:29:34 +00:00
|
|
|
aInnerMargin.left = minCapWidth;
|
|
|
|
}
|
|
|
|
aOrigin.x = aInnerMargin.left;
|
2003-07-23 23:04:37 +00:00
|
|
|
} break;
|
2009-06-28 13:51:46 +00:00
|
|
|
default: {
|
2008-02-27 02:02:20 +00:00
|
|
|
NS_ASSERTION(aCaptionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE ||
|
2009-06-28 13:51:46 +00:00
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_BOTTOM ||
|
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE ||
|
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_RIGHT ||
|
2008-02-27 02:02:20 +00:00
|
|
|
aCaptionSide == NO_SIDE,
|
|
|
|
"unexpected caption side");
|
2000-05-10 14:51:37 +00:00
|
|
|
aOrigin.x = aInnerMargin.left;
|
2003-07-23 23:04:37 +00:00
|
|
|
} break;
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
2009-06-28 13:51:46 +00:00
|
|
|
|
|
|
|
// vertical computation
|
|
|
|
switch (aCaptionSide) {
|
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE: {
|
|
|
|
aOrigin.y = aInnerMargin.top;
|
|
|
|
} break;
|
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_RIGHT: {
|
|
|
|
aOrigin.y = aInnerMargin.top;
|
|
|
|
switch (GetCaptionVerticalAlign()) {
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
|
2009-09-16 15:01:36 +00:00
|
|
|
aOrigin.y = NS_MAX(aInnerMargin.top, (aCaptionSize.height - aInnerSize.height) / 2);
|
2009-06-28 13:51:46 +00:00
|
|
|
break;
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
2009-09-16 15:01:36 +00:00
|
|
|
aOrigin.y = NS_MAX(aInnerMargin.top, aCaptionSize.height - aInnerSize.height);
|
2009-06-28 13:51:46 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case NO_SIDE:
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE:
|
2009-06-28 13:51:46 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP: {
|
|
|
|
aOrigin.y = aInnerMargin.top + aCaptionMargin.top + aCaptionSize.height +
|
|
|
|
aCaptionMargin.bottom;
|
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Unknown caption alignment type");
|
|
|
|
break;
|
|
|
|
}
|
1998-06-19 00:34:12 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-02-27 02:01:33 +00:00
|
|
|
void
|
|
|
|
nsTableOuterFrame::OuterBeginReflowChild(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
void* aChildRSSpace,
|
|
|
|
nscoord aAvailWidth)
|
2000-04-28 21:05:31 +00:00
|
|
|
{
|
2001-11-07 02:38:49 +00:00
|
|
|
// work around pixel rounding errors, round down to ensure we don't exceed the avail height in
|
|
|
|
nscoord availHeight = aOuterRS.availableHeight;
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != availHeight) {
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.FirstChild() == aChildFrame) {
|
2007-12-21 03:25:36 +00:00
|
|
|
availHeight = NS_UNCONSTRAINEDSIZE;
|
|
|
|
} else {
|
|
|
|
nsMargin margin;
|
2009-12-23 02:59:29 +00:00
|
|
|
GetChildMargin(aPresContext, aOuterRS, aChildFrame,
|
|
|
|
aOuterRS.availableWidth, margin);
|
2005-03-19 17:59:11 +00:00
|
|
|
|
2007-12-21 03:25:36 +00:00
|
|
|
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;
|
|
|
|
}
|
2001-11-07 02:38:49 +00:00
|
|
|
}
|
2002-11-08 05:29:34 +00:00
|
|
|
nsSize availSize(aAvailWidth, availHeight);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// create and init the child reflow state, using placement new on
|
|
|
|
// stack space allocated by the caller, so that the caller can destroy
|
|
|
|
// it
|
|
|
|
nsHTMLReflowState &childRS = * new (aChildRSSpace)
|
|
|
|
nsHTMLReflowState(aPresContext, aOuterRS, aChildFrame, availSize,
|
2011-10-17 14:59:28 +00:00
|
|
|
-1, -1, false);
|
2002-02-19 15:48:28 +00:00
|
|
|
InitChildReflowState(*aPresContext, childRS);
|
2002-03-27 05:50:24 +00:00
|
|
|
|
|
|
|
// see if we need to reset top of page due to a caption
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
2002-03-27 05:50:24 +00:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
2008-02-27 02:02:20 +00:00
|
|
|
if (((captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE) &&
|
2011-09-12 16:08:07 +00:00
|
|
|
mCaptionFrames.FirstChild() == aChildFrame) ||
|
2008-02-27 02:02:20 +00:00
|
|
|
((captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE) &&
|
2011-09-12 16:08:07 +00:00
|
|
|
InnerTableFrame() == aChildFrame)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
childRS.mFlags.mIsTopOfPage = false;
|
2002-03-27 05:50:24 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
2008-02-27 02:01:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::OuterDoReflowChild(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
const nsHTMLReflowState& aChildRS,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2000-04-28 21:05:31 +00:00
|
|
|
|
|
|
|
// use the current position as a best guess for placement
|
2003-07-07 02:01:29 +00:00
|
|
|
nsPoint childPt = aChildFrame->GetPosition();
|
2008-02-27 02:01:33 +00:00
|
|
|
return ReflowChild(aChildFrame, aPresContext, aMetrics, aChildRS,
|
|
|
|
childPt.x, childPt.y, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-12-27 15:05:18 +00:00
|
|
|
nsTableOuterFrame::UpdateReflowMetrics(PRUint8 aCaptionSide,
|
2000-04-28 21:05:31 +00:00
|
|
|
nsHTMLReflowMetrics& aMet,
|
|
|
|
const nsMargin& aInnerMargin,
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
const nsMargin& aCaptionMargin)
|
2000-04-28 21:05:31 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
SetDesiredSize(aCaptionSide, aInnerMargin, aCaptionMargin,
|
|
|
|
aMet.width, aMet.height);
|
2000-04-28 21:05:31 +00:00
|
|
|
|
2010-10-07 04:25:46 +00:00
|
|
|
aMet.SetOverflowAreasToDesiredBounds();
|
2011-09-12 16:08:07 +00:00
|
|
|
ConsiderChildOverflow(aMet.mOverflowAreas, InnerTableFrame());
|
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
|
|
|
ConsiderChildOverflow(aMet.mOverflowAreas, mCaptionFrames.FirstChild());
|
2003-09-13 16:26:30 +00:00
|
|
|
}
|
2000-04-28 21:05:31 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
NS_METHOD nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
|
1999-04-04 00:06:48 +00:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2000-04-28 21:05:31 +00:00
|
|
|
const nsHTMLReflowState& aOuterRS,
|
1999-04-04 00:06:48 +00:00
|
|
|
nsReflowStatus& aStatus)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableOuterFrame");
|
2001-11-14 13:40:03 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aOuterRS, aDesiredSize, aStatus);
|
2000-04-28 21:05:31 +00:00
|
|
|
|
1998-10-09 19:59:45 +00:00
|
|
|
nsresult rv = NS_OK;
|
2000-04-28 21:05:31 +00:00
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
|
1998-06-22 21:59:43 +00:00
|
|
|
// Initialize out parameters
|
2000-04-28 21:05:31 +00:00
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
1998-06-22 21:59:43 +00:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-04-13 20:24:54 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (!(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
|
|
|
|
// Set up our kids. They're already present, on an overflow list,
|
|
|
|
// or there are none so we'll create them now
|
|
|
|
MoveOverflowToChildList(aPresContext);
|
2001-03-13 06:38:59 +00:00
|
|
|
}
|
2001-02-27 14:52:07 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Use longs to get more-aligned space.
|
|
|
|
#define LONGS_IN_HTMLRS \
|
|
|
|
((sizeof(nsHTMLReflowState) + sizeof(long) - 1) / sizeof(long))
|
|
|
|
long captionRSSpace[LONGS_IN_HTMLRS];
|
2008-02-27 02:01:33 +00:00
|
|
|
nsHTMLReflowState *captionRS =
|
|
|
|
static_cast<nsHTMLReflowState*>((void*)captionRSSpace);
|
2008-02-27 02:02:20 +00:00
|
|
|
long innerRSSpace[LONGS_IN_HTMLRS];
|
|
|
|
nsHTMLReflowState *innerRS =
|
|
|
|
static_cast<nsHTMLReflowState*>((void*) innerRSSpace);
|
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
nsRect origInnerRect = InnerTableFrame()->GetRect();
|
|
|
|
nsRect origInnerVisualOverflow = InnerTableFrame()->GetVisualOverflowRect();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool innerFirstReflow =
|
2011-09-12 16:08:07 +00:00
|
|
|
(InnerTableFrame()->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
2008-04-01 21:53:19 +00:00
|
|
|
nsRect origCaptionRect;
|
2010-10-07 04:25:46 +00:00
|
|
|
nsRect origCaptionVisualOverflow;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool captionFirstReflow;
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
|
|
|
origCaptionRect = mCaptionFrames.FirstChild()->GetRect();
|
|
|
|
origCaptionVisualOverflow =
|
|
|
|
mCaptionFrames.FirstChild()->GetVisualOverflowRect();
|
2008-04-01 21:53:19 +00:00
|
|
|
captionFirstReflow =
|
2011-09-12 16:08:07 +00:00
|
|
|
(mCaptionFrames.FirstChild()->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
2008-04-01 21:53:19 +00:00
|
|
|
}
|
|
|
|
|
2008-02-28 17:55:04 +00:00
|
|
|
// ComputeAutoSize has to match this logic.
|
2008-02-27 02:02:20 +00:00
|
|
|
if (captionSide == NO_SIDE) {
|
|
|
|
// We don't have a caption.
|
2011-09-12 16:08:07 +00:00
|
|
|
OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRS,
|
2008-02-27 02:02:20 +00:00
|
|
|
innerRSSpace, aOuterRS.ComputedWidth());
|
|
|
|
} else if (captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT) {
|
|
|
|
// nsTableCaptionFrame::ComputeAutoSize takes care of making side
|
|
|
|
// captions small. Compute the caption's size first, and tell the
|
|
|
|
// table to fit in what's left.
|
2011-09-12 16:08:07 +00:00
|
|
|
OuterBeginReflowChild(aPresContext, mCaptionFrames.FirstChild(), aOuterRS,
|
2008-02-27 02:02:20 +00:00
|
|
|
captionRSSpace, aOuterRS.ComputedWidth());
|
|
|
|
nscoord innerAvailWidth = aOuterRS.ComputedWidth() -
|
|
|
|
(captionRS->ComputedWidth() + captionRS->mComputedMargin.LeftRight() +
|
|
|
|
captionRS->mComputedBorderPadding.LeftRight());
|
2011-09-12 16:08:07 +00:00
|
|
|
OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRS,
|
2008-02-27 02:02:20 +00:00
|
|
|
innerRSSpace, innerAvailWidth);
|
|
|
|
|
|
|
|
} else if (captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
|
|
|
|
// Compute the table's size first, and then prevent the caption from
|
|
|
|
// being wider unless it has to be.
|
|
|
|
//
|
|
|
|
// Note that CSS 2.1 (but not 2.0) says:
|
|
|
|
// The width of the anonymous box is the border-edge width of the
|
|
|
|
// table box inside it
|
|
|
|
// We don't actually make our anonymous box that width (if we did,
|
|
|
|
// it would break 'auto' margins), but this effectively does that.
|
2011-09-12 16:08:07 +00:00
|
|
|
OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRS,
|
2008-02-27 02:02:20 +00:00
|
|
|
innerRSSpace, aOuterRS.ComputedWidth());
|
|
|
|
// It's good that CSS 2.1 says not to include margins, since we
|
|
|
|
// can't, since they already been converted so they exactly
|
|
|
|
// fill the available width (ignoring the margin on one side if
|
2008-02-27 02:03:11 +00:00
|
|
|
// neither are auto). (We take advantage of that later when we call
|
|
|
|
// GetCaptionOrigin, though.)
|
2008-02-27 02:02:20 +00:00
|
|
|
nscoord innerBorderWidth = innerRS->ComputedWidth() +
|
|
|
|
innerRS->mComputedBorderPadding.LeftRight();
|
2011-09-12 16:08:07 +00:00
|
|
|
OuterBeginReflowChild(aPresContext, mCaptionFrames.FirstChild(), aOuterRS,
|
2008-02-27 02:02:20 +00:00
|
|
|
captionRSSpace, innerBorderWidth);
|
|
|
|
} else {
|
|
|
|
NS_ASSERTION(captionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE,
|
|
|
|
"unexpected caption-side");
|
|
|
|
// Size the table and the caption independently.
|
2011-09-12 16:08:07 +00:00
|
|
|
OuterBeginReflowChild(aPresContext, mCaptionFrames.FirstChild(), aOuterRS,
|
2008-02-27 02:01:33 +00:00
|
|
|
captionRSSpace, aOuterRS.ComputedWidth());
|
2011-09-12 16:08:07 +00:00
|
|
|
OuterBeginReflowChild(aPresContext, InnerTableFrame(), aOuterRS,
|
2008-02-27 02:02:20 +00:00
|
|
|
innerRSSpace, aOuterRS.ComputedWidth());
|
|
|
|
}
|
|
|
|
|
|
|
|
// First reflow the caption.
|
|
|
|
nsHTMLReflowMetrics captionMet;
|
|
|
|
nsSize captionSize;
|
|
|
|
nsMargin captionMargin;
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
2008-02-27 02:02:20 +00:00
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
2011-09-12 16:08:07 +00:00
|
|
|
rv = OuterDoReflowChild(aPresContext, mCaptionFrames.FirstChild(),
|
|
|
|
*captionRS, captionMet, capStatus);
|
2001-03-13 06:38:59 +00:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2008-02-27 02:01:33 +00:00
|
|
|
captionSize.width = captionMet.width;
|
|
|
|
captionSize.height = captionMet.height;
|
|
|
|
captionMargin = captionRS->mComputedMargin;
|
2011-07-26 17:22:46 +00:00
|
|
|
// Now that we know the height of the caption, reduce the available height
|
|
|
|
// for the table frame if we are height constrained and the caption is above
|
|
|
|
// or below the inner table.
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aOuterRS.availableHeight) {
|
|
|
|
nscoord captionHeight = 0;
|
|
|
|
switch (captionSide) {
|
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP:
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE:
|
2011-07-26 17:22:46 +00:00
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE: {
|
Bug 659828 - Part 1: Apply table margins to the outer table frame instead of the inner table frame (also fixes bug 87277); r=dbaron
Outer table frames act as CSS2.1 table wrapper boxes. We used to lay them out
without taking their margins into the account, which meant that their width was
always equal to the available width. This breaks horizontal positioning of
absolutely positioned kids of a table frame.
The main purpose of this patch is to apply the margins of tables to their outer
frame, instead of the inner frame. This means that the inner table frame will
always have a zero margin, which means that a lot of the stuff which used to
rely on the fact that table margins are applied to the inner frame need to
change.
In particular, in order to get the computed margins of a table, we used to query
the inner table frame, and this patch corrects that. Also, when shrink wrapping
tables, we used to not take the margins of the inner table frame into account,
which is fixed by this patch too. nsBlockReflowState::
ComputeReplacedBlockOffsetsForFloats also needed to be changed to read the
margin values from the outer frame too.
Also, as part of this patch, we start to respect the CSS2.1 margin model for
captions on all sides. This means that in particular, the top/bottom margins on
the top-outside and bottom-outside captions will not be collapsed with the
top/bottom margins of the table, and that the margins of the caption element
contribute to the width and height of the outer table frame. The
427129-table-caption reftest has been modified to match this new behavior.
Another side effect of this bug is fixing bug 87277, and the reftests for that
bug are marked as passing in this patch.
2011-05-31 23:02:56 +00:00
|
|
|
captionHeight = captionSize.height + captionMargin.TopBottom();
|
2011-07-26 17:22:46 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
innerRS->availableHeight =
|
|
|
|
NS_MAX(0, innerRS->availableHeight - captionHeight);
|
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
} else {
|
|
|
|
captionSize.SizeTo(0,0);
|
|
|
|
captionMargin.SizeTo(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Then, now that we know how much to reduce the width of the inner
|
|
|
|
// table to account for side captions, reflow the inner table.
|
|
|
|
nsHTMLReflowMetrics innerMet;
|
2011-09-12 16:08:07 +00:00
|
|
|
rv = OuterDoReflowChild(aPresContext, InnerTableFrame(), *innerRS,
|
2008-02-27 02:02:20 +00:00
|
|
|
innerMet, aStatus);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize innerSize;
|
2008-02-27 02:02:20 +00:00
|
|
|
innerSize.width = innerMet.width;
|
|
|
|
innerSize.height = innerMet.height;
|
|
|
|
nsMargin innerMargin = innerRS->mComputedMargin;
|
2001-03-13 06:38:59 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
2001-03-13 06:38:59 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// Now that we've reflowed both we can place them.
|
|
|
|
// XXXldb Most of the input variables here are now uninitialized!
|
1998-07-09 14:30:34 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
// XXX Need to recompute inner table's auto margins for the case of side
|
|
|
|
// captions. (Caption's are broken too, but that should be fixed earlier.)
|
2000-04-28 21:05:31 +00:00
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsPoint captionOrigin;
|
|
|
|
GetCaptionOrigin(captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
2011-09-12 16:08:07 +00:00
|
|
|
FinishReflowChild(mCaptionFrames.FirstChild(), aPresContext, captionRS,
|
|
|
|
captionMet, captionOrigin.x, captionOrigin.y, 0);
|
2008-02-27 02:02:20 +00:00
|
|
|
captionRS->~nsHTMLReflowState();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
}
|
|
|
|
// XXX If the height is constrained then we need to check whether
|
|
|
|
// everything still fits...
|
2001-03-13 06:38:59 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
nsPoint innerOrigin;
|
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2011-09-12 16:08:07 +00:00
|
|
|
FinishReflowChild(InnerTableFrame(), aPresContext, innerRS, innerMet,
|
2008-02-27 02:02:20 +00:00
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
innerRS->~nsHTMLReflowState();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
|
2011-09-12 16:08:07 +00:00
|
|
|
nsTableFrame::InvalidateFrame(InnerTableFrame(), origInnerRect,
|
2010-10-07 04:25:46 +00:00
|
|
|
origInnerVisualOverflow, innerFirstReflow);
|
2011-09-12 16:08:07 +00:00
|
|
|
if (mCaptionFrames.NotEmpty()) {
|
|
|
|
nsTableFrame::InvalidateFrame(mCaptionFrames.FirstChild(), origCaptionRect,
|
2010-10-07 04:25:46 +00:00
|
|
|
origCaptionVisualOverflow,
|
|
|
|
captionFirstReflow);
|
2008-04-01 21:53:19 +00:00
|
|
|
}
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, captionMargin);
|
2011-05-10 00:36:10 +00:00
|
|
|
FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize, aOuterRS, aStatus);
|
|
|
|
|
1998-07-09 14:30:34 +00:00
|
|
|
// Return our desired rect
|
1998-06-19 05:21:45 +00:00
|
|
|
|
2002-05-28 22:50:43 +00:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aOuterRS, aDesiredSize);
|
1998-10-09 19:59:45 +00:00
|
|
|
return rv;
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
|
|
|
|
2003-10-31 20:19:18 +00:00
|
|
|
nsIAtom*
|
|
|
|
nsTableOuterFrame::GetType() const
|
1999-02-24 05:54:31 +00:00
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::tableOuterFrame;
|
1999-02-24 05:54:31 +00:00
|
|
|
}
|
1998-04-16 22:21:32 +00:00
|
|
|
|
1999-08-01 16:20:14 +00:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
|
|
|
/*------------------ nsITableLayout methods ------------------------------*/
|
1999-07-31 22:11:50 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
nsIDOMElement* &aCell, //out params
|
|
|
|
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
|
|
|
PRInt32& aRowSpan, PRInt32& aColSpan,
|
2000-01-26 14:56:06 +00:00
|
|
|
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool& aIsSelected)
|
1999-07-31 22:11:50 +00:00
|
|
|
{
|
2011-09-12 16:08:07 +00:00
|
|
|
return InnerTableFrame()->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
|
|
|
aStartRowIndex, aStartColIndex,
|
|
|
|
aRowSpan, aColSpan, aActualRowSpan,
|
|
|
|
aActualColSpan, aIsSelected);
|
1999-07-31 22:11:50 +00:00
|
|
|
}
|
|
|
|
|
2008-02-07 07:03:26 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetTableSize(PRInt32& aRowCount, PRInt32& aColCount)
|
1999-08-01 16:20:14 +00:00
|
|
|
{
|
2011-09-12 16:08:07 +00:00
|
|
|
return InnerTableFrame()->GetTableSize(aRowCount, aColCount);
|
2008-02-07 07:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetIndexByRowAndColumn(PRInt32 aRow, PRInt32 aColumn,
|
|
|
|
PRInt32 *aIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIndex);
|
2011-09-12 16:08:07 +00:00
|
|
|
return InnerTableFrame()->GetIndexByRowAndColumn(aRow, aColumn, aIndex);
|
2008-02-07 07:03:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetRowAndColumnByIndex(PRInt32 aIndex,
|
|
|
|
PRInt32 *aRow, PRInt32 *aColumn)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRow);
|
|
|
|
NS_ENSURE_ARG_POINTER(aColumn);
|
2011-09-12 16:08:07 +00:00
|
|
|
return InnerTableFrame()->GetRowAndColumnByIndex(aIndex, aRow, aColumn);
|
1999-08-01 16:20:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------- end of nsITableLayout implementation ------------------*/
|
|
|
|
|
1998-04-13 20:24:54 +00:00
|
|
|
|
2005-11-04 02:38:33 +00:00
|
|
|
nsIFrame*
|
2006-03-26 21:30:36 +00:00
|
|
|
NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-04-13 20:24:54 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
return new (aPresShell) nsTableOuterFrame(aContext);
|
1998-04-13 20:24:54 +00:00
|
|
|
}
|
1998-09-02 21:59:54 +00:00
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableOuterFrame)
|
|
|
|
|
1999-11-01 22:12:45 +00:00
|
|
|
#ifdef DEBUG
|
1998-11-19 17:22:29 +00:00
|
|
|
NS_IMETHODIMP
|
2001-11-14 01:33:42 +00:00
|
|
|
nsTableOuterFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 17:22:29 +00:00
|
|
|
{
|
2001-11-14 01:33:42 +00:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableOuter"), aResult);
|
1998-11-19 17:22:29 +00:00
|
|
|
}
|
1999-09-01 01:02:16 +00:00
|
|
|
#endif
|
2003-10-21 04:32:57 +00:00
|
|
|
|