2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Pierre Phaneuf <pp@ludusdesign.com>
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* 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"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
#include "nsTableOuterFrame.h"
|
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsStyleContext.h"
|
|
|
|
#include "nsStyleConsts.h"
|
|
|
|
#include "nsPresContext.h"
|
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "prinrval.h"
|
|
|
|
#include "nsGkAtoms.h"
|
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#ifdef ACCESSIBILITY
|
2011-01-27 20:38:14 -08:00
|
|
|
#include "nsAccessibilityService.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#endif
|
|
|
|
#include "nsIServiceManager.h"
|
|
|
|
#include "nsIDOMNode.h"
|
|
|
|
#include "nsDisplayList.h"
|
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
|
|
|
|
/* ----------- nsTableCaptionFrame ---------- */
|
|
|
|
|
|
|
|
#define NS_TABLE_FRAME_CAPTION_LIST_INDEX 0
|
|
|
|
#define NO_SIDE 100
|
|
|
|
|
|
|
|
// caption frame
|
|
|
|
nsTableCaptionFrame::nsTableCaptionFrame(nsStyleContext* aContext):
|
|
|
|
nsBlockFrame(aContext)
|
|
|
|
{
|
|
|
|
// shrink wrap
|
2009-01-04 16:39:54 -08:00
|
|
|
SetFlags(NS_BLOCK_FLOAT_MGR);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableCaptionFrame::~nsTableCaptionFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsTableCaptionFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::tableCaptionFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
|
|
|
nsTableOuterFrame::GetBaseline() const
|
|
|
|
{
|
|
|
|
nsIFrame* kid = mFrames.FirstChild();
|
|
|
|
if (!kid) {
|
|
|
|
NS_NOTREACHED("no inner table");
|
|
|
|
return nsHTMLContainerFrame::GetBaseline();
|
|
|
|
}
|
|
|
|
|
|
|
|
return kid->GetBaseline() + kid->GetPosition().y;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsSize
|
2011-04-07 18:04:40 -07:00
|
|
|
nsTableCaptionFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
|
|
|
nsSize aPadding, PRBool aShrinkWrap)
|
|
|
|
{
|
|
|
|
nsSize result = nsBlockFrame::ComputeAutoSize(aRenderingContext, aCBSize,
|
|
|
|
aAvailableWidth, aMargin, aBorder, aPadding, aShrinkWrap);
|
2008-02-26 18:02:20 -08:00
|
|
|
PRUint8 captionSide = GetStyleTableBorder()->mCaptionSide;
|
|
|
|
if (captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT) {
|
2007-03-22 10:30:00 -07:00
|
|
|
result.width = GetMinWidth(aRenderingContext);
|
2008-02-26 18:02:20 -08: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;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-09-12 09:08:07 -07:00
|
|
|
nsIFrame*
|
|
|
|
nsTableCaptionFrame::GetParentStyleContextFrame()
|
2007-04-22 12:15:24 -07:00
|
|
|
{
|
2007-05-07 20:59:12 -07:00
|
|
|
NS_PRECONDITION(mContent->GetParent(),
|
|
|
|
"How could we not have a parent here?");
|
|
|
|
|
2007-04-22 12:15:24 -07: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 13:54:30 -07:00
|
|
|
nsIFrame* innerFrame = outerFrame->GetFirstPrincipalChild();
|
2007-04-22 12:15:24 -07:00
|
|
|
if (innerFrame) {
|
2011-09-12 09:08:07 -07:00
|
|
|
return nsFrame::CorrectStyleParentFrame(innerFrame,
|
|
|
|
GetStyleContext()->GetPseudo());
|
2007-04-22 12:15:24 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_NOTREACHED("Where is our inner table frame?");
|
2011-09-12 09:08:07 -07:00
|
|
|
return nsBlockFrame::GetParentStyleContextFrame();
|
2007-04-22 12:15:24 -07:00
|
|
|
}
|
|
|
|
|
2007-07-05 08:39:29 -07:00
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 05:02:03 -07:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsTableCaptionFrame::CreateAccessible()
|
2007-07-05 08:39:29 -07:00
|
|
|
{
|
|
|
|
if (!GetRect().IsEmpty()) {
|
2011-01-27 20:38:14 -08:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2007-07-05 08:39:29 -07:00
|
|
|
if (accService) {
|
2010-06-28 05:02:03 -07:00
|
|
|
return accService->CreateHTMLCaptionAccessible(mContent,
|
|
|
|
PresContext()->PresShell());
|
2007-07-05 08:39:29 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-28 05:02:03 -07:00
|
|
|
return nsnull;
|
2007-07-05 08:39:29 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef NS_DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableCaptionFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("Caption"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewTableCaptionFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsTableCaptionFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableCaptionFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* ----------- nsTableOuterFrame ---------- */
|
|
|
|
|
|
|
|
nsTableOuterFrame::nsTableOuterFrame(nsStyleContext* aContext):
|
|
|
|
nsHTMLContainerFrame(aContext)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsTableOuterFrame::~nsTableOuterFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-12 11:20:59 -08:00
|
|
|
NS_QUERYFRAME_HEAD(nsTableOuterFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsITableLayout)
|
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsHTMLContainerFrame)
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef ACCESSIBILITY
|
2010-06-28 05:02:03 -07:00
|
|
|
already_AddRefed<nsAccessible>
|
|
|
|
nsTableOuterFrame::CreateAccessible()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-01-27 20:38:14 -08:00
|
|
|
nsAccessibilityService* accService = nsIPresShell::AccService();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (accService) {
|
2010-06-28 05:02:03 -07:00
|
|
|
return accService->CreateHTMLTableAccessible(mContent,
|
|
|
|
PresContext()->PresShell());
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-06-28 05:02:03 -07:00
|
|
|
return nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* virtual */ PRBool
|
|
|
|
nsTableOuterFrame::IsContainingBlock() const
|
|
|
|
{
|
|
|
|
return PR_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-23 21:21:15 -08:00
|
|
|
nsTableOuterFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-12-23 21:21:15 -08:00
|
|
|
mCaptionFrames.DestroyFramesFrom(aDestructRoot);
|
|
|
|
nsHTMLContainerFrame::DestroyFrom(aDestructRoot);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-07-28 05:51:09 -07:00
|
|
|
nsFrameList
|
2011-08-24 13:54:29 -07:00
|
|
|
nsTableOuterFrame::GetChildList(ChildListID aListID) const
|
|
|
|
{
|
|
|
|
switch (aListID) {
|
|
|
|
case kPrincipalList:
|
|
|
|
return mFrames;
|
|
|
|
case kCaptionList:
|
|
|
|
return mCaptionFrames;
|
|
|
|
default:
|
|
|
|
return nsFrameList::EmptyList();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-24 13:54:29 -07:00
|
|
|
void
|
|
|
|
nsTableOuterFrame::GetChildLists(nsTArray<ChildList>* aLists) const
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-08-24 13:54:29 -07:00
|
|
|
mFrames.AppendIfNonempty(aLists, kPrincipalList);
|
|
|
|
mCaptionFrames.AppendIfNonempty(aLists, kCaptionList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 13:54:30 -07:00
|
|
|
nsTableOuterFrame::SetInitialChildList(ChildListID aListID,
|
2009-07-28 05:53:20 -07:00
|
|
|
nsFrameList& aChildList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-08-24 13:54:30 -07:00
|
|
|
if (kCaptionList == aListID) {
|
2007-03-22 10:30:00 -07:00
|
|
|
// the frame constructor already checked for table-caption display type
|
|
|
|
mCaptionFrames.SetFrames(aChildList);
|
2009-07-28 05:53:20 -07:00
|
|
|
mCaptionFrame = mCaptionFrames.FirstChild();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
2011-08-24 13:54:30 -07:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "wrong childlist");
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(mFrames.IsEmpty(), "Frame leak!");
|
|
|
|
mInnerTableFrame = nsnull;
|
2009-07-28 05:53:20 -07:00
|
|
|
if (aChildList.NotEmpty()) {
|
|
|
|
if (nsGkAtoms::tableFrame == aChildList.FirstChild()->GetType()) {
|
|
|
|
mInnerTableFrame = (nsTableFrame*)aChildList.FirstChild();
|
|
|
|
mFrames.SetFrames(aChildList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_ERROR("expected a table frame");
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 13:54:30 -07:00
|
|
|
nsTableOuterFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
// We only have two child frames: the inner table and a caption frame.
|
|
|
|
// The inner frame is provided when we're initialized, and it cannot change
|
2011-08-24 13:54:30 -07:00
|
|
|
if (kCaptionList == aListID) {
|
2009-07-30 10:23:32 -07:00
|
|
|
NS_ASSERTION(aFrameList.IsEmpty() ||
|
|
|
|
aFrameList.FirstChild()->GetType() == nsGkAtoms::tableCaptionFrame,
|
2007-03-22 10:30:00 -07:00
|
|
|
"appending non-caption frame to captionList");
|
|
|
|
mCaptionFrames.AppendFrames(this, aFrameList);
|
|
|
|
mCaptionFrame = mCaptionFrames.FirstChild();
|
|
|
|
rv = NS_OK;
|
|
|
|
|
|
|
|
// Reflow the new caption frame. It's already marked dirty, so
|
|
|
|
// just tell the pres shell.
|
2007-03-30 14:11:41 -07:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 12:16:51 -07:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_PRECONDITION(PR_FALSE, "unexpected child list");
|
|
|
|
rv = NS_ERROR_UNEXPECTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 13:54:30 -07:00
|
|
|
nsTableOuterFrame::InsertFrames(ChildListID aListID,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 10:23:32 -07:00
|
|
|
nsFrameList& aFrameList)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-08-24 13:54:30 -07:00
|
|
|
if (kCaptionList == aListID) {
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
2009-07-30 10:23:32 -07:00
|
|
|
NS_ASSERTION(aFrameList.IsEmpty() ||
|
|
|
|
aFrameList.FirstChild()->GetType() == nsGkAtoms::tableCaptionFrame,
|
2007-03-22 10:30:00 -07:00
|
|
|
"inserting non-caption frame into captionList");
|
|
|
|
mCaptionFrames.InsertFrames(nsnull, aPrevFrame, aFrameList);
|
|
|
|
mCaptionFrame = mCaptionFrames.FirstChild();
|
2007-08-02 14:34:58 -07: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);
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NS_PRECONDITION(!aPrevFrame, "invalid previous frame");
|
2011-08-24 13:54:30 -07:00
|
|
|
return AppendFrames(aListID, aFrameList);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-08-24 13:54:30 -07:00
|
|
|
nsTableOuterFrame::RemoveFrame(ChildListID aListID,
|
2007-03-22 10:30:00 -07: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 13:54:30 -07:00
|
|
|
NS_PRECONDITION(kCaptionList == aListID, "can't remove inner frame");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-02-26 18:02:20 -08:00
|
|
|
if (HasSideCaption()) {
|
2007-03-22 10:30:00 -07: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
|
|
|
|
mInnerTableFrame->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Remove the frame and destroy it
|
|
|
|
mCaptionFrames.DestroyFrame(aOldFrame);
|
|
|
|
mCaptionFrame = mCaptionFrames.FirstChild();
|
|
|
|
|
2007-03-30 14:11:41 -07:00
|
|
|
PresContext()->PresShell()->
|
2007-05-06 12:16:51 -07:00
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN); // also means child removed
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD
|
|
|
|
nsTableOuterFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
// No border, background or outline are painted because they all belong
|
|
|
|
// to the inner table.
|
|
|
|
if (!IsVisibleInSelection(aBuilder))
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// If there's no caption, take a short cut to avoid having to create
|
|
|
|
// the special display list set and then sort it.
|
|
|
|
if (!mCaptionFrame)
|
|
|
|
return BuildDisplayListForInnerTable(aBuilder, aDirtyRect, aLists);
|
|
|
|
|
|
|
|
nsDisplayListCollection set;
|
|
|
|
nsresult rv = BuildDisplayListForInnerTable(aBuilder, aDirtyRect, set);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsDisplayListSet captionSet(set, set.BlockBorderBackgrounds());
|
|
|
|
rv = BuildDisplayListForChild(aBuilder, mCaptionFrame, aDirtyRect, captionSet);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::BuildDisplayListForInnerTable(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2009-07-26 15:05:41 -07:00
|
|
|
void
|
|
|
|
nsTableOuterFrame::SetSelected(PRBool aSelected,
|
|
|
|
SelectionType aType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-07-26 15:05:41 -07:00
|
|
|
nsFrame::SetSelected(aSelected, aType);
|
|
|
|
if (mInnerTableFrame) {
|
|
|
|
mInnerTableFrame->SetSelected(aSelected, aType);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-12 09:08:07 -07:00
|
|
|
nsIFrame*
|
|
|
|
nsTableOuterFrame::GetParentStyleContextFrame()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// The table outer frame and the (inner) table frame split the style
|
|
|
|
// data by giving the table frame the style context associated with
|
|
|
|
// the table content node and creating a style context for the outer
|
|
|
|
// frame that is a *child* of the table frame's style context,
|
|
|
|
// matching the ::-moz-table-outer pseudo-element. html.css has a
|
|
|
|
// rule that causes that pseudo-element (and thus the outer table)
|
|
|
|
// to inherit *some* style properties from the table frame. The
|
|
|
|
// children of the table inherit directly from the inner table, and
|
|
|
|
// the outer table's style context is a leaf.
|
|
|
|
|
|
|
|
if (!mInnerTableFrame) {
|
2011-09-12 09:08:07 -07:00
|
|
|
return this;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2011-09-12 09:08:07 -07:00
|
|
|
return mInnerTableFrame;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// INCREMENTAL REFLOW HELPER FUNCTIONS
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableOuterFrame::InitChildReflowState(nsPresContext& aPresContext,
|
|
|
|
nsHTMLReflowState& aReflowState)
|
|
|
|
|
|
|
|
{
|
|
|
|
nsMargin collapseBorder;
|
|
|
|
nsMargin collapsePadding(0,0,0,0);
|
|
|
|
nsMargin* pCollapseBorder = nsnull;
|
|
|
|
nsMargin* pCollapsePadding = nsnull;
|
|
|
|
if ((aReflowState.frame == mInnerTableFrame) && (mInnerTableFrame->IsBorderCollapse())) {
|
|
|
|
collapseBorder = mInnerTableFrame->GetIncludedOuterBCBorder();
|
|
|
|
pCollapseBorder = &collapseBorder;
|
|
|
|
pCollapsePadding = &collapsePadding;
|
|
|
|
}
|
|
|
|
aReflowState.Init(&aPresContext, -1, -1, pCollapseBorder, pCollapsePadding);
|
|
|
|
}
|
|
|
|
|
|
|
|
// get the margin and padding data. nsHTMLReflowState doesn't handle the
|
|
|
|
// case of auto margins
|
|
|
|
void
|
2009-12-22 18:59:29 -08:00
|
|
|
nsTableOuterFrame::GetChildMargin(nsPresContext* aPresContext,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
nscoord aAvailWidth,
|
|
|
|
nsMargin& aMargin)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// construct a reflow state to compute margin and padding. Auto margins
|
|
|
|
// will not be computed at this time.
|
|
|
|
|
|
|
|
// create and init the child reflow state
|
|
|
|
// XXX We really shouldn't construct a reflow state to do this.
|
|
|
|
nsHTMLReflowState childRS(aPresContext, aOuterRS, aChildFrame,
|
|
|
|
nsSize(aAvailWidth, aOuterRS.availableHeight),
|
|
|
|
-1, -1, PR_FALSE);
|
|
|
|
InitChildReflowState(*aPresContext, childRS);
|
|
|
|
|
|
|
|
aMargin = childRS.mComputedMargin;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsSize
|
|
|
|
GetContainingBlockSize(const nsHTMLReflowState& aOuterRS)
|
|
|
|
{
|
|
|
|
nsSize size(0,0);
|
|
|
|
const nsHTMLReflowState* containRS =
|
|
|
|
aOuterRS.mCBReflowState;
|
|
|
|
|
|
|
|
if (containRS) {
|
|
|
|
size.width = containRS->ComputedWidth();
|
|
|
|
if (NS_UNCONSTRAINEDSIZE == size.width) {
|
|
|
|
size.width = 0;
|
|
|
|
}
|
2007-08-02 11:08:05 -07:00
|
|
|
size.height = containRS->ComputedHeight();
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == size.height) {
|
|
|
|
size.height = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-07 18:04:40 -07:00
|
|
|
nsTableOuterFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nscoord width = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mInnerTableFrame, nsLayoutUtils::MIN_WIDTH);
|
|
|
|
DISPLAY_MIN_WIDTH(this, width);
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
nscoord capWidth =
|
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, mCaptionFrame,
|
|
|
|
nsLayoutUtils::MIN_WIDTH);
|
2008-02-26 18:02:20 -08:00
|
|
|
if (HasSideCaption()) {
|
2007-03-22 10:30:00 -07:00
|
|
|
width += capWidth;
|
2008-02-26 18:02:20 -08:00
|
|
|
} else {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (capWidth > width) {
|
|
|
|
width = capWidth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nscoord
|
2011-04-07 18:04:40 -07:00
|
|
|
nsTableOuterFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nscoord maxWidth;
|
|
|
|
DISPLAY_PREF_WIDTH(this, maxWidth);
|
|
|
|
|
|
|
|
maxWidth = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
|
|
|
mInnerTableFrame, nsLayoutUtils::PREF_WIDTH);
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
switch(captionSide) {
|
2008-02-26 18:02:20 -08:00
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_RIGHT:
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
nscoord capMin =
|
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, mCaptionFrame,
|
|
|
|
nsLayoutUtils::MIN_WIDTH);
|
|
|
|
maxWidth += capMin;
|
|
|
|
}
|
|
|
|
break;
|
2008-02-26 18:02:20 -08:00
|
|
|
default:
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-02-26 18:02:20 -08: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;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord capPref =
|
|
|
|
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, mCaptionFrame,
|
2008-02-26 18:02:20 -08:00
|
|
|
iwt);
|
2009-09-16 08:01:36 -07:00
|
|
|
maxWidth = NS_MAX(maxWidth, capPref);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2008-02-26 18:02:20 -08:00
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return maxWidth;
|
|
|
|
}
|
|
|
|
|
2008-02-28 09:55:04 -08: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-07 18:04:40 -07:00
|
|
|
ChildShrinkWrapWidth(nsRenderingContext *aRenderingContext,
|
2008-02-28 09:55:04 -08:00
|
|
|
nsIFrame *aChildFrame,
|
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nscoord *aMarginResult = nsnull)
|
|
|
|
{
|
|
|
|
// The outer table's children do not use it as a containing block.
|
|
|
|
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()),
|
|
|
|
PR_TRUE);
|
|
|
|
if (aMarginResult)
|
|
|
|
*aMarginResult = offsets.mComputedMargin.LeftRight();
|
|
|
|
return size.width + offsets.mComputedMargin.LeftRight() +
|
|
|
|
offsets.mComputedBorderPadding.LeftRight();
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/* virtual */ nsSize
|
2011-04-07 18:04:40 -07:00
|
|
|
nsTableOuterFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize aCBSize, nscoord aAvailableWidth,
|
|
|
|
nsSize aMargin, nsSize aBorder,
|
|
|
|
nsSize aPadding, PRBool aShrinkWrap)
|
|
|
|
{
|
|
|
|
if (!aShrinkWrap)
|
|
|
|
return nsHTMLContainerFrame::ComputeAutoSize(aRenderingContext, aCBSize,
|
|
|
|
aAvailableWidth, aMargin, aBorder, aPadding, aShrinkWrap);
|
|
|
|
|
|
|
|
// 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 09:55:04 -08:00
|
|
|
// Match the availableWidth logic in Reflow.
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
nscoord width;
|
|
|
|
if (captionSide == NO_SIDE) {
|
|
|
|
width = ChildShrinkWrapWidth(aRenderingContext, mInnerTableFrame,
|
|
|
|
aCBSize, aAvailableWidth);
|
|
|
|
} else if (captionSide == NS_STYLE_CAPTION_SIDE_LEFT ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_RIGHT) {
|
|
|
|
nscoord capWidth = ChildShrinkWrapWidth(aRenderingContext, mCaptionFrame,
|
|
|
|
aCBSize, aAvailableWidth);
|
|
|
|
width = capWidth + ChildShrinkWrapWidth(aRenderingContext,
|
|
|
|
mInnerTableFrame, aCBSize,
|
|
|
|
aAvailableWidth - capWidth);
|
|
|
|
} else if (captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM) {
|
|
|
|
nscoord margin;
|
|
|
|
width = ChildShrinkWrapWidth(aRenderingContext, mInnerTableFrame,
|
|
|
|
aCBSize, aAvailableWidth, &margin);
|
|
|
|
nscoord capWidth = ChildShrinkWrapWidth(aRenderingContext,
|
|
|
|
mCaptionFrame, aCBSize,
|
|
|
|
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");
|
|
|
|
width = ChildShrinkWrapWidth(aRenderingContext, mInnerTableFrame,
|
|
|
|
aCBSize, aAvailableWidth);
|
|
|
|
nscoord capWidth = ChildShrinkWrapWidth(aRenderingContext,
|
|
|
|
mCaptionFrame, aCBSize,
|
|
|
|
aAvailableWidth);
|
|
|
|
if (capWidth > width)
|
|
|
|
width = capWidth;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsSize(width, NS_UNCONSTRAINEDSIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint8
|
|
|
|
nsTableOuterFrame::GetCaptionSide()
|
|
|
|
{
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
return mCaptionFrame->GetStyleTableBorder()->mCaptionSide;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return NO_SIDE; // no caption
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint8
|
|
|
|
nsTableOuterFrame::GetCaptionVerticalAlign()
|
|
|
|
{
|
|
|
|
const nsStyleCoord& va = mCaptionFrame->GetStyleTextReset()->mVerticalAlign;
|
|
|
|
return (va.GetUnit() == eStyleUnit_Enumerated)
|
|
|
|
? va.GetIntValue()
|
|
|
|
: NS_STYLE_VERTICAL_ALIGN_TOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableOuterFrame::SetDesiredSize(PRUint8 aCaptionSide,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
nscoord& aWidth,
|
|
|
|
nscoord& aHeight)
|
|
|
|
{
|
|
|
|
aWidth = aHeight = 0;
|
|
|
|
|
|
|
|
nsRect innerRect = mInnerTableFrame->GetRect();
|
|
|
|
nscoord innerWidth = innerRect.width;
|
|
|
|
|
|
|
|
nsRect captionRect(0,0,0,0);
|
|
|
|
nscoord captionWidth = 0;
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
captionRect = mCaptionFrame->GetRect();
|
|
|
|
captionWidth = captionRect.width;
|
|
|
|
}
|
|
|
|
switch(aCaptionSide) {
|
2008-02-26 18:02:20 -08:00
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT:
|
2009-09-16 08:01:36 -07:00
|
|
|
aWidth = NS_MAX(aInnerMargin.left, aCaptionMargin.left + captionWidth + aCaptionMargin.right) +
|
2007-03-22 10:30:00 -07:00
|
|
|
innerWidth + aInnerMargin.right;
|
|
|
|
break;
|
2008-02-26 18:02:20 -08:00
|
|
|
case NS_STYLE_CAPTION_SIDE_RIGHT:
|
2009-09-16 08:01:36 -07:00
|
|
|
aWidth = NS_MAX(aInnerMargin.right, aCaptionMargin.left + captionWidth + aCaptionMargin.right) +
|
2007-03-22 10:30:00 -07:00
|
|
|
innerWidth + aInnerMargin.left;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
aWidth = aInnerMargin.left + innerWidth + aInnerMargin.right;
|
2009-09-16 08:01:36 -07:00
|
|
|
aWidth = NS_MAX(aWidth, captionRect.XMost() + aCaptionMargin.right);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
aHeight = innerRect.YMost() + aInnerMargin.bottom;
|
2009-06-28 06:51:46 -07:00
|
|
|
if (NS_STYLE_CAPTION_SIDE_BOTTOM != aCaptionSide) {
|
2009-09-16 08:01:36 -07:00
|
|
|
aHeight = NS_MAX(aHeight, captionRect.YMost() + aCaptionMargin.bottom);
|
2009-06-28 06:51:46 -07:00
|
|
|
}
|
|
|
|
else {
|
2009-09-16 08:01:36 -07:00
|
|
|
aHeight = NS_MAX(aHeight, captionRect.YMost() + aCaptionMargin.bottom +
|
2009-06-28 06:51:46 -07:00
|
|
|
aInnerMargin.bottom);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::GetCaptionOrigin(PRUint32 aCaptionSide,
|
|
|
|
const nsSize& aContainBlockSize,
|
|
|
|
const nsSize& aInnerSize,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
nsMargin& aCaptionMargin,
|
|
|
|
nsPoint& aOrigin)
|
|
|
|
{
|
|
|
|
aOrigin.x = aOrigin.y = 0;
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aInnerSize.width) || (NS_UNCONSTRAINEDSIZE == aInnerSize.height) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aCaptionSize.width) || (NS_UNCONSTRAINEDSIZE == aCaptionSize.height)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
if (!mCaptionFrame) return NS_OK;
|
2009-06-28 06:51:46 -07: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?");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-28 06:51:46 -07:00
|
|
|
// horizontal computation
|
2007-03-22 10:30:00 -07:00
|
|
|
switch(aCaptionSide) {
|
2008-02-26 18:02:20 -08:00
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE: {
|
2009-06-28 06:51:46 -07:00
|
|
|
// FIXME: Position relative to right edge for RTL. (Based on table
|
|
|
|
// direction or table parent direction?)
|
2007-03-22 10:30:00 -07:00
|
|
|
aOrigin.x = aCaptionMargin.left;
|
2008-02-26 18:03:11 -08: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;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
} break;
|
2008-02-26 18:02:20 -08:00
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT: {
|
2007-03-22 10:30:00 -07:00
|
|
|
aOrigin.x = aCaptionMargin.left;
|
|
|
|
} break;
|
2008-02-26 18:02:20 -08:00
|
|
|
case NS_STYLE_CAPTION_SIDE_RIGHT: {
|
2007-03-22 10:30:00 -07:00
|
|
|
aOrigin.x = aInnerMargin.left + aInnerSize.width + aCaptionMargin.left;
|
|
|
|
} break;
|
|
|
|
default: { // top
|
2008-02-26 18:02:20 -08:00
|
|
|
NS_ASSERTION(aCaptionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE,
|
|
|
|
"unexpected caption side");
|
2009-06-28 06:51:46 -07:00
|
|
|
// FIXME: Position relative to right edge for RTL. (Based on table
|
|
|
|
// direction or table parent direction?)
|
2007-03-22 10:30:00 -07:00
|
|
|
aOrigin.x = aCaptionMargin.left;
|
2008-02-26 18:03:11 -08: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 06:51:46 -07: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 08:01:36 -07:00
|
|
|
aOrigin.y = NS_MAX(0, aInnerMargin.top + ((aInnerSize.height - aCaptionSize.height) / 2));
|
2009-06-28 06:51:46 -07:00
|
|
|
break;
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
2009-09-16 08:01:36 -07:00
|
|
|
aOrigin.y = NS_MAX(0, aInnerMargin.top + aInnerSize.height - aCaptionSize.height);
|
2009-06-28 06:51:46 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM: {
|
|
|
|
aOrigin.y = aInnerMargin.top + aInnerSize.height + aCaptionMargin.top;
|
|
|
|
} break;
|
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE: {
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCollapsingMargin marg;
|
2009-06-28 06:51:46 -07:00
|
|
|
marg.Include(aCaptionMargin.top);
|
|
|
|
marg.Include(aInnerMargin.bottom);
|
2007-03-22 10:30:00 -07:00
|
|
|
nscoord collapseMargin = marg.get();
|
2009-06-28 06:51:46 -07:00
|
|
|
aOrigin.y = aInnerMargin.top + aInnerSize.height + collapseMargin;
|
|
|
|
} break;
|
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP: {
|
|
|
|
aOrigin.y = aInnerMargin.top + aCaptionMargin.top;
|
|
|
|
} break;
|
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE: {
|
|
|
|
aOrigin.y = aCaptionMargin.top;
|
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Unknown caption alignment type");
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::GetInnerOrigin(PRUint32 aCaptionSide,
|
|
|
|
const nsSize& aContainBlockSize,
|
|
|
|
const nsSize& aCaptionSize,
|
|
|
|
const nsMargin& aCaptionMargin,
|
|
|
|
const nsSize& aInnerSize,
|
|
|
|
nsMargin& aInnerMargin,
|
|
|
|
nsPoint& aOrigin)
|
|
|
|
{
|
2009-06-28 06:51:46 -07: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?");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
aOrigin.x = aOrigin.y = 0;
|
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aInnerSize.width) || (NS_UNCONSTRAINEDSIZE == aInnerSize.height) ||
|
|
|
|
(NS_UNCONSTRAINEDSIZE == aCaptionSize.width) || (NS_UNCONSTRAINEDSIZE == aCaptionSize.height)) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord minCapWidth = aCaptionSize.width;
|
2009-06-28 06:51:46 -07:00
|
|
|
|
|
|
|
minCapWidth += aCaptionMargin.left;
|
|
|
|
minCapWidth += aCaptionMargin.right;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-06-28 06:51:46 -07:00
|
|
|
// horizontal computation
|
|
|
|
switch (aCaptionSide) {
|
2008-02-26 18:02:20 -08:00
|
|
|
case NS_STYLE_CAPTION_SIDE_LEFT: {
|
2007-03-22 10:30:00 -07:00
|
|
|
if (aInnerMargin.left < minCapWidth) {
|
|
|
|
// shift the inner table to get some place for the caption
|
|
|
|
aInnerMargin.right += aInnerMargin.left - minCapWidth;
|
2009-09-16 08:01:36 -07:00
|
|
|
aInnerMargin.right = NS_MAX(0, aInnerMargin.right);
|
2007-03-22 10:30:00 -07:00
|
|
|
aInnerMargin.left = minCapWidth;
|
|
|
|
}
|
|
|
|
aOrigin.x = aInnerMargin.left;
|
|
|
|
} break;
|
2009-06-28 06:51:46 -07:00
|
|
|
default: {
|
2008-02-26 18:02:20 -08:00
|
|
|
NS_ASSERTION(aCaptionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE ||
|
2009-06-28 06:51:46 -07:00
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_BOTTOM ||
|
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE ||
|
|
|
|
aCaptionSide == NS_STYLE_CAPTION_SIDE_RIGHT ||
|
2008-02-26 18:02:20 -08:00
|
|
|
aCaptionSide == NO_SIDE,
|
|
|
|
"unexpected caption side");
|
2007-03-22 10:30:00 -07:00
|
|
|
aOrigin.x = aInnerMargin.left;
|
|
|
|
} break;
|
|
|
|
}
|
2009-06-28 06:51:46 -07: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 08:01:36 -07:00
|
|
|
aOrigin.y = NS_MAX(aInnerMargin.top, (aCaptionSize.height - aInnerSize.height) / 2);
|
2009-06-28 06:51:46 -07:00
|
|
|
break;
|
|
|
|
case NS_STYLE_VERTICAL_ALIGN_BOTTOM:
|
2009-09-16 08:01:36 -07:00
|
|
|
aOrigin.y = NS_MAX(aInnerMargin.top, aCaptionSize.height - aInnerSize.height);
|
2009-06-28 06:51:46 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
case NO_SIDE:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP: {
|
|
|
|
aOrigin.y = aInnerMargin.top + aCaptionMargin.top + aCaptionSize.height +
|
|
|
|
aCaptionMargin.bottom;
|
|
|
|
} break;
|
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE: {
|
|
|
|
nsCollapsingMargin marg;
|
|
|
|
marg.Include(aCaptionMargin.bottom);
|
|
|
|
marg.Include(aInnerMargin.top);
|
|
|
|
nscoord collapseMargin = marg.get();
|
|
|
|
aOrigin.y = aCaptionMargin.top + aCaptionSize.height + collapseMargin;
|
|
|
|
} break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Unknown caption alignment type");
|
|
|
|
break;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2008-02-26 18:01:33 -08:00
|
|
|
void
|
|
|
|
nsTableOuterFrame::OuterBeginReflowChild(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
void* aChildRSSpace,
|
|
|
|
nscoord aAvailWidth)
|
2007-03-22 10:30:00 -07: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) {
|
2007-12-20 19:25:36 -08:00
|
|
|
if (mCaptionFrame == aChildFrame) {
|
|
|
|
availHeight = NS_UNCONSTRAINEDSIZE;
|
|
|
|
} else {
|
|
|
|
nsMargin margin;
|
2009-12-22 18:59:29 -08:00
|
|
|
GetChildMargin(aPresContext, aOuterRS, aChildFrame,
|
|
|
|
aOuterRS.availableWidth, margin);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-12-20 19:25:36 -08: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;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
nsSize availSize(aAvailWidth, availHeight);
|
|
|
|
// 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,
|
|
|
|
-1, -1, PR_FALSE);
|
|
|
|
InitChildReflowState(*aPresContext, childRS);
|
|
|
|
|
|
|
|
// see if we need to reset top of page due to a caption
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
2008-02-26 18:02:20 -08:00
|
|
|
if (((captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE) &&
|
|
|
|
mCaptionFrame == aChildFrame) ||
|
|
|
|
((captionSide == NS_STYLE_CAPTION_SIDE_TOP ||
|
|
|
|
captionSide == NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE) &&
|
|
|
|
mInnerTableFrame == aChildFrame)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
childRS.mFlags.mIsTopOfPage = PR_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2008-02-26 18:01:33 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsTableOuterFrame::OuterDoReflowChild(nsPresContext* aPresContext,
|
|
|
|
nsIFrame* aChildFrame,
|
|
|
|
const nsHTMLReflowState& aChildRS,
|
|
|
|
nsHTMLReflowMetrics& aMetrics,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// use the current position as a best guess for placement
|
|
|
|
nsPoint childPt = aChildFrame->GetPosition();
|
2008-02-26 18:01:33 -08:00
|
|
|
return ReflowChild(aChildFrame, aPresContext, aMetrics, aChildRS,
|
|
|
|
childPt.x, childPt.y, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableOuterFrame::UpdateReflowMetrics(PRUint8 aCaptionSide,
|
|
|
|
nsHTMLReflowMetrics& aMet,
|
|
|
|
const nsMargin& aInnerMargin,
|
|
|
|
const nsMargin& aCaptionMargin)
|
|
|
|
{
|
|
|
|
SetDesiredSize(aCaptionSide, aInnerMargin, aCaptionMargin,
|
|
|
|
aMet.width, aMet.height);
|
|
|
|
|
2010-10-06 21:25:46 -07:00
|
|
|
aMet.SetOverflowAreasToDesiredBounds();
|
|
|
|
ConsiderChildOverflow(aMet.mOverflowAreas, mInnerTableFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (mCaptionFrame) {
|
2010-10-06 21:25:46 -07:00
|
|
|
ConsiderChildOverflow(aMet.mOverflowAreas, mCaptionFrame);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
FinishAndStoreOverflow(&aMet);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_METHOD nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aOuterRS,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableOuterFrame");
|
|
|
|
DISPLAY_REFLOW(aPresContext, this, aOuterRS, aDesiredSize, aStatus);
|
|
|
|
|
|
|
|
// We desperately need an inner table frame,
|
|
|
|
// if this fails fix the frame constructor
|
|
|
|
if (mFrames.IsEmpty() || !mInnerTableFrame) {
|
|
|
|
NS_ERROR("incomplete children");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
nsresult rv = NS_OK;
|
|
|
|
PRUint8 captionSide = GetCaptionSide();
|
|
|
|
|
|
|
|
// Initialize out parameters
|
|
|
|
aDesiredSize.width = aDesiredSize.height = 0;
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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-26 18:01:33 -08:00
|
|
|
nsHTMLReflowState *captionRS =
|
|
|
|
static_cast<nsHTMLReflowState*>((void*)captionRSSpace);
|
2008-02-26 18:02:20 -08:00
|
|
|
long innerRSSpace[LONGS_IN_HTMLRS];
|
|
|
|
nsHTMLReflowState *innerRS =
|
|
|
|
static_cast<nsHTMLReflowState*>((void*) innerRSSpace);
|
|
|
|
|
2008-04-01 14:53:19 -07:00
|
|
|
nsRect origInnerRect = mInnerTableFrame->GetRect();
|
2010-10-06 21:25:46 -07:00
|
|
|
nsRect origInnerVisualOverflow = mInnerTableFrame->GetVisualOverflowRect();
|
2008-04-01 14:53:19 -07:00
|
|
|
PRBool innerFirstReflow =
|
|
|
|
(mInnerTableFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
|
|
|
nsRect origCaptionRect;
|
2010-10-06 21:25:46 -07:00
|
|
|
nsRect origCaptionVisualOverflow;
|
2008-04-01 14:53:19 -07:00
|
|
|
PRBool captionFirstReflow;
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
origCaptionRect = mCaptionFrame->GetRect();
|
2010-10-06 21:25:46 -07:00
|
|
|
origCaptionVisualOverflow = mCaptionFrame->GetVisualOverflowRect();
|
2008-04-01 14:53:19 -07:00
|
|
|
captionFirstReflow =
|
|
|
|
(mCaptionFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
|
|
|
}
|
|
|
|
|
2008-02-28 09:55:04 -08:00
|
|
|
// ComputeAutoSize has to match this logic.
|
2008-02-26 18:02:20 -08:00
|
|
|
if (captionSide == NO_SIDE) {
|
|
|
|
// We don't have a caption.
|
|
|
|
OuterBeginReflowChild(aPresContext, mInnerTableFrame, aOuterRS,
|
|
|
|
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.
|
|
|
|
OuterBeginReflowChild(aPresContext, mCaptionFrame, aOuterRS,
|
|
|
|
captionRSSpace, aOuterRS.ComputedWidth());
|
|
|
|
nscoord innerAvailWidth = aOuterRS.ComputedWidth() -
|
|
|
|
(captionRS->ComputedWidth() + captionRS->mComputedMargin.LeftRight() +
|
|
|
|
captionRS->mComputedBorderPadding.LeftRight());
|
|
|
|
OuterBeginReflowChild(aPresContext, mInnerTableFrame, aOuterRS,
|
|
|
|
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.
|
|
|
|
OuterBeginReflowChild(aPresContext, mInnerTableFrame, aOuterRS,
|
|
|
|
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-26 18:03:11 -08:00
|
|
|
// neither are auto). (We take advantage of that later when we call
|
|
|
|
// GetCaptionOrigin, though.)
|
2008-02-26 18:02:20 -08:00
|
|
|
nscoord innerBorderWidth = innerRS->ComputedWidth() +
|
|
|
|
innerRS->mComputedBorderPadding.LeftRight();
|
|
|
|
OuterBeginReflowChild(aPresContext, mCaptionFrame, aOuterRS,
|
|
|
|
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.
|
2008-02-26 18:01:33 -08:00
|
|
|
OuterBeginReflowChild(aPresContext, mCaptionFrame, aOuterRS,
|
|
|
|
captionRSSpace, aOuterRS.ComputedWidth());
|
2008-02-26 18:02:20 -08:00
|
|
|
OuterBeginReflowChild(aPresContext, mInnerTableFrame, aOuterRS,
|
|
|
|
innerRSSpace, aOuterRS.ComputedWidth());
|
|
|
|
}
|
|
|
|
|
|
|
|
// First reflow the caption.
|
|
|
|
nsHTMLReflowMetrics captionMet;
|
|
|
|
nsSize captionSize;
|
|
|
|
nsMargin captionMargin;
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
nsReflowStatus capStatus; // don't let the caption cause incomplete
|
2008-02-26 18:01:33 -08:00
|
|
|
rv = OuterDoReflowChild(aPresContext, mCaptionFrame, *captionRS,
|
|
|
|
captionMet, capStatus);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_FAILED(rv)) return rv;
|
2008-02-26 18:01:33 -08:00
|
|
|
captionSize.width = captionMet.width;
|
|
|
|
captionSize.height = captionMet.height;
|
|
|
|
captionMargin = captionRS->mComputedMargin;
|
2011-07-26 10:22:46 -07: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:
|
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM: {
|
|
|
|
captionHeight = captionSize.height + captionMargin.TopBottom();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_STYLE_CAPTION_SIDE_TOP_OUTSIDE: {
|
|
|
|
nsCollapsingMargin belowCaptionMargin;
|
|
|
|
belowCaptionMargin.Include(captionMargin.bottom);
|
|
|
|
belowCaptionMargin.Include(innerRS->mComputedMargin.top);
|
|
|
|
captionHeight = captionSize.height + captionMargin.top +
|
|
|
|
belowCaptionMargin.get();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NS_STYLE_CAPTION_SIDE_BOTTOM_OUTSIDE: {
|
|
|
|
nsCollapsingMargin aboveCaptionMargin;
|
|
|
|
aboveCaptionMargin.Include(captionMargin.top);
|
|
|
|
aboveCaptionMargin.Include(innerRS->mComputedMargin.bottom);
|
|
|
|
captionHeight = captionSize.height + captionMargin.bottom +
|
|
|
|
aboveCaptionMargin.get();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
innerRS->availableHeight =
|
|
|
|
NS_MAX(0, innerRS->availableHeight - captionHeight);
|
|
|
|
}
|
2007-03-22 10:30:00 -07: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;
|
2008-02-26 18:02:20 -08:00
|
|
|
rv = OuterDoReflowChild(aPresContext, mInnerTableFrame, *innerRS,
|
|
|
|
innerMet, aStatus);
|
|
|
|
if (NS_FAILED(rv)) return rv;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsSize innerSize;
|
2008-02-26 18:02:20 -08:00
|
|
|
innerSize.width = innerMet.width;
|
|
|
|
innerSize.height = innerMet.height;
|
|
|
|
nsMargin innerMargin = innerRS->mComputedMargin;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsSize containSize = GetContainingBlockSize(aOuterRS);
|
|
|
|
|
|
|
|
// Now that we've reflowed both we can place them.
|
|
|
|
// XXXldb Most of the input variables here are now uninitialized!
|
|
|
|
|
|
|
|
// 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.)
|
|
|
|
|
|
|
|
if (mCaptionFrame) {
|
|
|
|
nsPoint captionOrigin;
|
|
|
|
GetCaptionOrigin(captionSide, containSize, innerSize,
|
|
|
|
innerMargin, captionSize, captionMargin, captionOrigin);
|
2008-02-26 18:02:20 -08:00
|
|
|
FinishReflowChild(mCaptionFrame, aPresContext, captionRS, captionMet,
|
|
|
|
captionOrigin.x, captionOrigin.y, 0);
|
|
|
|
captionRS->~nsHTMLReflowState();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
// XXX If the height is constrained then we need to check whether
|
|
|
|
// everything still fits...
|
|
|
|
|
|
|
|
nsPoint innerOrigin;
|
|
|
|
GetInnerOrigin(captionSide, containSize, captionSize,
|
|
|
|
captionMargin, innerSize, innerMargin, innerOrigin);
|
2008-02-26 18:02:20 -08:00
|
|
|
FinishReflowChild(mInnerTableFrame, aPresContext, innerRS, innerMet,
|
|
|
|
innerOrigin.x, innerOrigin.y, 0);
|
|
|
|
innerRS->~nsHTMLReflowState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-01 14:53:19 -07:00
|
|
|
nsTableFrame::InvalidateFrame(mInnerTableFrame, origInnerRect,
|
2010-10-06 21:25:46 -07:00
|
|
|
origInnerVisualOverflow, innerFirstReflow);
|
2008-04-01 14:53:19 -07:00
|
|
|
if (mCaptionFrame) {
|
|
|
|
nsTableFrame::InvalidateFrame(mCaptionFrame, origCaptionRect,
|
2010-10-06 21:25:46 -07:00
|
|
|
origCaptionVisualOverflow,
|
|
|
|
captionFirstReflow);
|
2008-04-01 14:53:19 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
UpdateReflowMetrics(captionSide, aDesiredSize, innerMargin, captionMargin);
|
|
|
|
|
|
|
|
// Return our desired rect
|
|
|
|
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aOuterRS, aDesiredSize);
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsTableOuterFrame::GetType() const
|
|
|
|
{
|
|
|
|
return nsGkAtoms::tableOuterFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
|
|
|
/*------------------ nsITableLayout methods ------------------------------*/
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetCellDataAt(PRInt32 aRowIndex, PRInt32 aColIndex,
|
|
|
|
nsIDOMElement* &aCell, //out params
|
|
|
|
PRInt32& aStartRowIndex, PRInt32& aStartColIndex,
|
|
|
|
PRInt32& aRowSpan, PRInt32& aColSpan,
|
|
|
|
PRInt32& aActualRowSpan, PRInt32& aActualColSpan,
|
|
|
|
PRBool& aIsSelected)
|
|
|
|
{
|
2008-02-06 23:03:26 -08:00
|
|
|
NS_ASSERTION(mInnerTableFrame, "no inner table frame yet?");
|
|
|
|
|
2008-02-06 23:23:00 -08:00
|
|
|
return mInnerTableFrame->GetCellDataAt(aRowIndex, aColIndex, aCell,
|
|
|
|
aStartRowIndex, aStartColIndex,
|
|
|
|
aRowSpan, aColSpan, aActualRowSpan,
|
|
|
|
aActualColSpan, aIsSelected);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-02-06 23:03:26 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetTableSize(PRInt32& aRowCount, PRInt32& aColCount)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-02-06 23:03:26 -08:00
|
|
|
NS_ASSERTION(mInnerTableFrame, "no inner table frame yet?");
|
|
|
|
|
2008-02-06 23:23:00 -08:00
|
|
|
return mInnerTableFrame->GetTableSize(aRowCount, aColCount);
|
2008-02-06 23:03:26 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetIndexByRowAndColumn(PRInt32 aRow, PRInt32 aColumn,
|
|
|
|
PRInt32 *aIndex)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aIndex);
|
|
|
|
|
|
|
|
NS_ASSERTION(mInnerTableFrame, "no inner table frame yet?");
|
|
|
|
return mInnerTableFrame->GetIndexByRowAndColumn(aRow, aColumn, aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetRowAndColumnByIndex(PRInt32 aIndex,
|
|
|
|
PRInt32 *aRow, PRInt32 *aColumn)
|
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aRow);
|
|
|
|
NS_ENSURE_ARG_POINTER(aColumn);
|
|
|
|
|
|
|
|
NS_ASSERTION(mInnerTableFrame, "no inner table frame yet?");
|
|
|
|
return mInnerTableFrame->GetRowAndColumnByIndex(aIndex, aRow, aColumn);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*---------------- end of nsITableLayout implementation ------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
NS_NewTableOuterFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
|
|
|
{
|
|
|
|
return new (aPresShell) nsTableOuterFrame(aContext);
|
|
|
|
}
|
|
|
|
|
2009-09-12 09:49:24 -07:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableOuterFrame)
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#ifdef DEBUG
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsTableOuterFrame::GetFrameName(nsAString& aResult) const
|
|
|
|
{
|
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableOuter"), aResult);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|