2001-09-29 00:14:13 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2014-08-20 05:24:58 +04:00
|
|
|
|
|
|
|
#include "mozilla/Maybe.h"
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableRowFrame.h"
|
2001-11-05 18:15:24 +03:00
|
|
|
#include "nsTableRowGroupFrame.h"
|
1999-07-28 12:09:02 +04:00
|
|
|
#include "nsIPresShell.h"
|
2004-08-01 03:15:21 +04:00
|
|
|
#include "nsPresContext.h"
|
2003-02-22 03:32:13 +03:00
|
|
|
#include "nsStyleContext.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsStyleConsts.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsIContent.h"
|
|
|
|
#include "nsTableFrame.h"
|
|
|
|
#include "nsTableCellFrame.h"
|
1998-07-21 03:56:17 +04:00
|
|
|
#include "nsCSSRendering.h"
|
1999-07-28 12:09:02 +04:00
|
|
|
#include "nsHTMLParts.h"
|
|
|
|
#include "nsTableColGroupFrame.h"
|
|
|
|
#include "nsTableColFrame.h"
|
|
|
|
#include "nsCOMPtr.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
2013-10-02 01:00:38 +04:00
|
|
|
#include "nsIFrameInlines.h"
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
1998-04-23 21:29:07 +04:00
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2000-05-05 03:16:42 +04:00
|
|
|
struct nsTableCellReflowState : public 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 08:38:33 +03:00
|
|
|
nsTableCellReflowState(nsPresContext* aPresContext,
|
2000-05-05 03:16:42 +04:00
|
|
|
const nsHTMLReflowState& aParentReflowState,
|
|
|
|
nsIFrame* aFrame,
|
2014-07-24 12:28:46 +04:00
|
|
|
const LogicalSize& aAvailableSpace,
|
2013-09-10 00:29:05 +04:00
|
|
|
uint32_t aFlags = 0)
|
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 08:38:33 +03:00
|
|
|
: nsHTMLReflowState(aPresContext, aParentReflowState, aFrame,
|
2015-06-04 13:43:02 +03:00
|
|
|
aAvailableSpace, nullptr, aFlags)
|
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 08:38:33 +03:00
|
|
|
{
|
|
|
|
}
|
2000-05-05 03:16:42 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
void FixUp(const LogicalSize& aAvailSpace);
|
2000-05-05 03:16:42 +04:00
|
|
|
};
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
void nsTableCellReflowState::FixUp(const LogicalSize& aAvailSpace)
|
2000-05-05 03:16:42 +04:00
|
|
|
{
|
2002-02-19 18:48:28 +03:00
|
|
|
// fix the mComputed values during a pass 2 reflow since the cell can be a percentage base
|
2015-06-20 23:00:26 +03:00
|
|
|
NS_WARN_IF_FALSE(NS_UNCONSTRAINEDSIZE != aAvailSpace.ISize(mWritingMode),
|
|
|
|
"have unconstrained inline-size; this should only result from "
|
|
|
|
"very large sizes, not attempts at intrinsic inline size "
|
2009-10-29 06:22:28 +03:00
|
|
|
"calculation");
|
2015-06-20 23:00:26 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedISize()) {
|
|
|
|
nscoord computedISize = aAvailSpace.ISize(mWritingMode) -
|
|
|
|
ComputedLogicalBorderPadding().IStartEnd(mWritingMode);
|
|
|
|
computedISize = std::max(0, computedISize);
|
|
|
|
SetComputedISize(computedISize);
|
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 08:38:33 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != ComputedBSize() &&
|
|
|
|
NS_UNCONSTRAINEDSIZE != aAvailSpace.BSize(mWritingMode)) {
|
|
|
|
nscoord computedBSize = aAvailSpace.BSize(mWritingMode) -
|
|
|
|
ComputedLogicalBorderPadding().BStartEnd(mWritingMode);
|
|
|
|
computedBSize = std::max(0, computedBSize);
|
|
|
|
SetComputedBSize(computedBSize);
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::InitChildReflowState(nsPresContext& aPresContext,
|
|
|
|
const LogicalSize& aAvailSize,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aBorderCollapse,
|
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 08:38:33 +03:00
|
|
|
nsTableCellReflowState& aReflowState)
|
2002-02-19 18:48:28 +03:00
|
|
|
{
|
|
|
|
nsMargin collapseBorder;
|
2012-07-30 18:20:58 +04:00
|
|
|
nsMargin* pCollapseBorder = nullptr;
|
2002-02-19 18:48:28 +03:00
|
|
|
if (aBorderCollapse) {
|
|
|
|
// we only reflow cells, so don't need to check frame type
|
|
|
|
nsBCTableCellFrame* bcCellFrame = (nsBCTableCellFrame*)aReflowState.frame;
|
|
|
|
if (bcCellFrame) {
|
2015-05-04 10:09:25 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
collapseBorder = bcCellFrame->GetBorderWidth(wm).GetPhysicalMargin(wm);
|
|
|
|
pCollapseBorder = &collapseBorder;
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
|
|
|
}
|
2015-06-04 13:43:02 +03:00
|
|
|
aReflowState.Init(&aPresContext, nullptr, pCollapseBorder);
|
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 08:38:33 +03:00
|
|
|
aReflowState.FixUp(aAvailSize);
|
2000-05-05 03:16:42 +04:00
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::SetFixedBSize(nscoord aValue)
|
2001-11-05 03:15:51 +03:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bsize = std::max(0, aValue);
|
|
|
|
if (HasFixedBSize()) {
|
|
|
|
if (bsize > mStyleFixedBSize) {
|
|
|
|
mStyleFixedBSize = bsize;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2003-01-05 17:16:58 +03:00
|
|
|
}
|
|
|
|
else {
|
2015-06-20 23:00:26 +03:00
|
|
|
mStyleFixedBSize = bsize;
|
|
|
|
if (bsize > 0) {
|
|
|
|
SetHasFixedBSize(true);
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::SetPctBSize(float aPctValue,
|
|
|
|
bool aForce)
|
2001-11-05 03:15:51 +03:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bsize = std::max(0, NSToCoordRound(aPctValue * 100.0f));
|
|
|
|
if (HasPctBSize()) {
|
|
|
|
if ((bsize > mStylePctBSize) || aForce) {
|
|
|
|
mStylePctBSize = bsize;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2015-06-20 23:00:26 +03:00
|
|
|
mStylePctBSize = bsize;
|
|
|
|
if (bsize > 0) {
|
|
|
|
SetHasPctBSize(true);
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ----------- nsTableRowFrame ---------- */
|
1998-04-23 21:29:07 +04:00
|
|
|
|
2009-03-25 01:10:06 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsTableRowFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsTableRowFrame)
|
2011-12-28 00:18:48 +04:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
2009-03-25 01:10:06 +03:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsTableRowFrame::nsTableRowFrame(nsStyleContext* aContext)
|
2011-12-28 00:18:48 +04:00
|
|
|
: nsContainerFrame(aContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
mBits.mRowIndex = mBits.mFirstInserted = 0;
|
2015-06-20 23:00:26 +03:00
|
|
|
ResetBSize(0);
|
2001-01-25 18:55:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowFrame::~nsTableRowFrame()
|
|
|
|
{
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2013-03-20 05:47:48 +04:00
|
|
|
void
|
2014-05-25 02:20:40 +04:00
|
|
|
nsTableRowFrame::Init(nsIContent* aContent,
|
|
|
|
nsContainerFrame* aParent,
|
|
|
|
nsIFrame* aPrevInFlow)
|
1999-02-25 08:31:15 +03:00
|
|
|
{
|
2005-11-21 01:05:24 +03:00
|
|
|
// Let the base class do its initialization
|
2013-03-20 05:47:48 +04:00
|
|
|
nsContainerFrame::Init(aContent, aParent, aPrevInFlow);
|
1999-02-25 08:31:15 +03:00
|
|
|
|
2013-02-17 01:51:02 +04:00
|
|
|
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_ROW == StyleDisplay()->mDisplay,
|
2008-08-14 07:49:57 +04:00
|
|
|
"wrong display on table row frame");
|
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
if (aPrevInFlow) {
|
|
|
|
// Set the row index
|
|
|
|
nsTableRowFrame* rowFrame = (nsTableRowFrame*)aPrevInFlow;
|
2015-04-17 21:42:05 +03:00
|
|
|
|
1999-02-25 08:31:15 +03:00
|
|
|
SetRowIndex(rowFrame->GetRowIndex());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-11 02:41:17 +04:00
|
|
|
void
|
|
|
|
nsTableRowFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
|
|
|
{
|
2015-06-23 23:41:29 +03:00
|
|
|
if (HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)) {
|
2014-03-11 02:41:17 +04:00
|
|
|
nsTableFrame::UnregisterPositionedTablePart(this, aDestructRoot);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
|
|
|
}
|
|
|
|
|
2008-10-26 13:11:34 +03:00
|
|
|
/* virtual */ void
|
|
|
|
nsTableRowFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
|
|
|
|
{
|
2012-08-14 01:13:34 +04:00
|
|
|
nsContainerFrame::DidSetStyleContext(aOldStyleContext);
|
|
|
|
|
2008-10-26 13:11:34 +03:00
|
|
|
if (!aOldStyleContext) //avoid this on init
|
|
|
|
return;
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2008-10-26 13:11:34 +03:00
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
2013-02-16 09:38:33 +04:00
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
|
2015-05-01 00:46:59 +03:00
|
|
|
TableArea damageArea(0, GetRowIndex(), tableFrame->GetColCount(), 1);
|
2011-10-27 17:58:44 +04:00
|
|
|
tableFrame->AddBCDamageArea(damageArea);
|
2008-10-26 13:11:34 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-03 06:41:27 +04:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::AppendFrames(ChildListID aListID,
|
|
|
|
nsFrameList& aFrameList)
|
1999-08-03 06:41:27 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 06:32:36 +04:00
|
|
|
|
2015-04-11 03:21:06 +03:00
|
|
|
DrainSelfOverflowList(); // ensure the last frame is in mFrames
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsFrameList::Slice& newCells = mFrames.AppendFrames(nullptr, aFrameList);
|
1999-08-03 06:41:27 +04:00
|
|
|
|
|
|
|
// Add the new cell frames to the table
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2009-07-30 21:23:32 +04:00
|
|
|
for (nsFrameList::Enumerator e(newCells) ; !e.AtEnd(); e.Next()) {
|
2011-12-27 12:31:22 +04:00
|
|
|
nsIFrame *childFrame = e.get();
|
2015-06-20 23:00:26 +03:00
|
|
|
NS_ASSERTION(IS_TABLE_CELL(childFrame->GetType()),
|
|
|
|
"Not a table cell frame/pseudo frame construction failure");
|
2011-12-27 12:31:22 +04:00
|
|
|
tableFrame->AppendCell(static_cast<nsTableCellFrame&>(*childFrame), GetRowIndex());
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
2007-05-06 23:16:51 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-12-13 06:45:28 +03:00
|
|
|
tableFrame->SetGeometryDirty();
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::InsertFrames(ChildListID aListID,
|
|
|
|
nsIFrame* aPrevFrame,
|
|
|
|
nsFrameList& aFrameList)
|
1999-08-03 06:41:27 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 06:32:36 +04:00
|
|
|
NS_ASSERTION(!aPrevFrame || aPrevFrame->GetParent() == this,
|
|
|
|
"inserting after sibling frame with different parent");
|
2015-04-11 03:21:06 +03:00
|
|
|
DrainSelfOverflowList(); // ensure aPrevFrame is in mFrames
|
2011-12-27 12:31:22 +04:00
|
|
|
//Insert Frames in the frame list
|
2012-07-30 18:20:58 +04:00
|
|
|
const nsFrameList::Slice& newCells = mFrames.InsertFrames(nullptr, aPrevFrame, aFrameList);
|
2006-06-29 06:32:36 +04:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Get the table frame
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2012-01-17 03:38:10 +04:00
|
|
|
nsIAtom* cellFrameType = tableFrame->IsBorderCollapse() ? nsGkAtoms::bcTableCellFrame : nsGkAtoms::tableCellFrame;
|
2004-01-18 13:28:40 +03:00
|
|
|
nsTableCellFrame* prevCellFrame = (nsTableCellFrame *)nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame, cellFrameType);
|
2009-02-05 12:09:50 +03:00
|
|
|
nsTArray<nsTableCellFrame*> cellChildren;
|
2011-12-27 12:31:22 +04:00
|
|
|
for (nsFrameList::Enumerator e(newCells); !e.AtEnd(); e.Next()) {
|
|
|
|
nsIFrame *childFrame = e.get();
|
2015-06-20 23:00:26 +03:00
|
|
|
NS_ASSERTION(IS_TABLE_CELL(childFrame->GetType()),
|
|
|
|
"Not a table cell frame/pseudo frame construction failure");
|
2011-12-27 12:31:22 +04:00
|
|
|
cellChildren.AppendElement(static_cast<nsTableCellFrame*>(childFrame));
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
// insert the cells into the cell map
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex = -1;
|
1999-12-14 01:56:31 +03:00
|
|
|
if (prevCellFrame) {
|
|
|
|
prevCellFrame->GetColIndex(colIndex);
|
|
|
|
}
|
2005-02-07 04:58:25 +03:00
|
|
|
tableFrame->InsertCells(cellChildren, GetRowIndex(), colIndex);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2007-05-06 23:16:51 +04:00
|
|
|
PresContext()->PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
2006-12-13 06:45:28 +03:00
|
|
|
tableFrame->SetGeometryDirty();
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::RemoveFrame(ChildListID aListID,
|
|
|
|
nsIFrame* aOldFrame)
|
1999-08-03 06:41:27 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 06:32:36 +04:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
MOZ_ASSERT((nsTableCellFrame*)do_QueryFrame(aOldFrame));
|
|
|
|
nsTableCellFrame* cellFrame = static_cast<nsTableCellFrame*>(aOldFrame);
|
|
|
|
// remove the cell from the cell map
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2014-05-28 23:36:58 +04:00
|
|
|
tableFrame->RemoveCell(cellFrame, GetRowIndex());
|
|
|
|
|
|
|
|
// Remove the frame and destroy it
|
|
|
|
mFrames.DestroyFrame(aOldFrame);
|
1998-09-16 21:19:20 +04:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
|
|
|
|
tableFrame->SetGeometryDirty();
|
1999-08-30 04:01:09 +04:00
|
|
|
}
|
|
|
|
|
2006-12-14 02:04:57 +03:00
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableRowFrame::GetUsedMargin() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableRowFrame::GetUsedBorder() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableRowFrame::GetUsedPadding() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
nscoord
|
2015-06-20 23:00:26 +03:00
|
|
|
GetBSizeOfRowsSpannedBelowFirst(nsTableCellFrame& aTableCellFrame,
|
|
|
|
nsTableFrame& aTableFrame,
|
|
|
|
const WritingMode aWM)
|
2000-09-05 18:57:34 +04:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bsize = 0;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowSpan = aTableFrame.GetEffectiveRowSpan(aTableCellFrame);
|
2015-06-20 23:00:26 +03:00
|
|
|
// add in bsize of rows spanned beyond the 1st one
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIFrame* nextRow = aTableCellFrame.GetParent()->GetNextSibling();
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t rowX = 1; ((rowX < rowSpan) && nextRow);) {
|
2006-12-26 20:47:52 +03:00
|
|
|
if (nsGkAtoms::tableRowFrame == nextRow->GetType()) {
|
2015-06-20 23:00:26 +03:00
|
|
|
bsize += nextRow->BSize(aWM);
|
2000-09-05 18:57:34 +04:00
|
|
|
rowX++;
|
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
bsize += aTableFrame.GetRowSpacing(rowX);
|
2003-07-07 06:01:29 +04:00
|
|
|
nextRow = nextRow->GetNextSibling();
|
2000-09-05 18:57:34 +04:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
return bsize;
|
2000-09-05 18:57:34 +04:00
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
nsTableCellFrame*
|
|
|
|
nsTableRowFrame::GetFirstCell()
|
2001-11-05 03:15:51 +03:00
|
|
|
{
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* childFrame : mFrames) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableCellFrame *cellFrame = do_QueryFrame(childFrame);
|
|
|
|
if (cellFrame) {
|
|
|
|
return cellFrame;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2000-09-05 18:57:34 +04:00
|
|
|
|
1998-07-03 00:35:23 +04:00
|
|
|
/**
|
|
|
|
* Post-reflow hook. This is where the table row does its post-processing
|
|
|
|
*/
|
1998-11-20 04:01:25 +03:00
|
|
|
void
|
2007-01-28 01:22:24 +03:00
|
|
|
nsTableRowFrame::DidResize()
|
1998-07-03 00:35:23 +04:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
// Resize and re-align the cell frames based on our row bsize
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2014-07-24 12:30:07 +04:00
|
|
|
|
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
nsHTMLReflowMetrics desiredSize(wm);
|
2014-08-12 03:52:01 +04:00
|
|
|
desiredSize.SetSize(wm, GetLogicalSize(wm));
|
2010-10-07 08:25:46 +04:00
|
|
|
desiredSize.SetOverflowAreasToDesiredBounds();
|
1999-05-04 23:15:56 +04:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize = mRect.Size();
|
2015-06-27 02:50:21 +03:00
|
|
|
|
2015-06-23 21:47:45 +03:00
|
|
|
for (nsIFrame* childFrame : mFrames) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableCellFrame *cellFrame = do_QueryFrame(childFrame);
|
|
|
|
if (cellFrame) {
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord cellBSize = BSize(wm) +
|
|
|
|
GetBSizeOfRowsSpannedBelowFirst(*cellFrame, *tableFrame, wm);
|
1999-05-04 23:15:56 +04:00
|
|
|
|
2015-06-27 02:50:21 +03:00
|
|
|
// If the bsize for the cell has changed, we need to reset it;
|
|
|
|
// and in vertical-rl mode, we need to update the cell's block position
|
2015-07-16 12:07:57 +03:00
|
|
|
// to account for the containerSize, which may not have been known
|
2015-06-27 02:50:21 +03:00
|
|
|
// earlier, so we always apply it here.
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalSize cellSize = cellFrame->GetLogicalSize(wm);
|
2015-06-27 02:50:21 +03:00
|
|
|
if (cellSize.BSize(wm) != cellBSize || wm.IsVerticalRL()) {
|
2015-06-20 23:00:26 +03:00
|
|
|
nsRect cellOldRect = cellFrame->GetRect();
|
2015-06-27 02:50:21 +03:00
|
|
|
nsRect cellVisualOverflow = cellFrame->GetVisualOverflowRect();
|
|
|
|
|
|
|
|
if (wm.IsVerticalRL()) {
|
|
|
|
// Get the old position of the cell, as we want to preserve its
|
|
|
|
// inline coordinate.
|
|
|
|
LogicalPoint oldPos =
|
2015-07-16 12:07:57 +03:00
|
|
|
cellFrame->GetLogicalPosition(wm, containerSize);
|
2015-06-27 02:50:21 +03:00
|
|
|
|
|
|
|
// The cell should normally be aligned with the row's block-start,
|
|
|
|
// so set the B component of the position to zero:
|
|
|
|
LogicalPoint newPos(wm, oldPos.I(wm), 0);
|
|
|
|
|
|
|
|
// ...unless relative positioning is in effect, in which case the
|
|
|
|
// cell may have been moved away from the row's block-start
|
|
|
|
if (cellFrame->IsRelativelyPositioned()) {
|
|
|
|
// Find out where the cell would have been without relative
|
|
|
|
// positioning.
|
|
|
|
LogicalPoint oldNormalPos =
|
2015-07-16 12:07:57 +03:00
|
|
|
cellFrame->GetLogicalNormalPosition(wm, containerSize);
|
2015-06-27 02:50:21 +03:00
|
|
|
// The difference (if any) between oldPos and oldNormalPos reflects
|
|
|
|
// relative positioning that was applied to the cell, and which we
|
|
|
|
// need to incorporate when resetting the position.
|
|
|
|
newPos.B(wm) = oldPos.B(wm) - oldNormalPos.B(wm);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldPos != newPos) {
|
2015-07-16 12:07:57 +03:00
|
|
|
cellFrame->SetPosition(wm, newPos, containerSize);
|
2015-06-27 02:50:21 +03:00
|
|
|
nsTableFrame::RePositionViews(cellFrame);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
cellSize.BSize(wm) = cellBSize;
|
2015-06-20 23:00:26 +03:00
|
|
|
cellFrame->SetSize(wm, cellSize);
|
|
|
|
nsTableFrame::InvalidateTableFrame(cellFrame, cellOldRect,
|
2012-08-29 09:48:45 +04:00
|
|
|
cellVisualOverflow,
|
|
|
|
false);
|
1998-07-03 00:35:23 +04:00
|
|
|
}
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2015-06-18 12:11:40 +03:00
|
|
|
// realign cell content based on the new bsize. We might be able to
|
|
|
|
// skip this if the bsize didn't change... maybe. Hard to tell.
|
|
|
|
cellFrame->BlockDirAlignChild(wm, mMaxCellAscent);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2008-02-08 12:36:32 +03:00
|
|
|
// Always store the overflow, even if the height didn't change, since
|
|
|
|
// we'll lose part of our overflow area otherwise.
|
2010-10-07 08:25:46 +04:00
|
|
|
ConsiderChildOverflow(desiredSize.mOverflowAreas, cellFrame);
|
2008-02-08 12:36:32 +03:00
|
|
|
|
|
|
|
// Note that if the cell's *content* needs to change in response
|
2015-06-22 12:33:34 +03:00
|
|
|
// to this height, it will get a special bsize reflow.
|
1998-07-03 00:35:23 +04:00
|
|
|
}
|
|
|
|
}
|
2004-07-16 20:56:21 +04:00
|
|
|
FinishAndStoreOverflow(&desiredSize);
|
2004-04-14 10:22:52 +04:00
|
|
|
if (HasView()) {
|
2010-10-07 08:25:46 +04:00
|
|
|
nsContainerFrame::SyncFrameViewAfterReflow(PresContext(), this, GetView(),
|
|
|
|
desiredSize.VisualOverflow(), 0);
|
2004-04-14 10:22:52 +04:00
|
|
|
}
|
1998-07-03 00:35:23 +04:00
|
|
|
// Let our base class do the usual work
|
|
|
|
}
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
// returns max-ascent amongst all cells that have 'vertical-align: baseline'
|
2000-07-28 13:19:26 +04:00
|
|
|
// *including* cells with rowspans
|
2000-06-05 12:25:11 +04:00
|
|
|
nscoord nsTableRowFrame::GetMaxCellAscent() const
|
|
|
|
{
|
|
|
|
return mMaxCellAscent;
|
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord nsTableRowFrame::GetRowBaseline(WritingMode aWM)
|
2005-10-04 19:47:21 +04:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
if (mMaxCellAscent) {
|
2005-10-04 19:47:21 +04:00
|
|
|
return mMaxCellAscent;
|
2015-06-20 23:00:26 +03:00
|
|
|
}
|
2005-10-04 19:47:21 +04:00
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
// If we don't have a baseline on any of the cells we go for the lowest
|
|
|
|
// content edge of the inner block frames.
|
2005-10-04 19:47:21 +04:00
|
|
|
// Every table cell has a cell frame with its border and padding. Inside
|
|
|
|
// the cell is a block frame. The cell is as high as the tallest cell in
|
|
|
|
// the parent row. As a consequence the block frame might not touch both
|
|
|
|
// the top and the bottom padding of it parent cell frame at the same time.
|
2015-04-17 21:42:05 +03:00
|
|
|
//
|
2005-10-04 19:47:21 +04:00
|
|
|
// bbbbbbbbbbbbbbbbbb cell border: b
|
|
|
|
// bppppppppppppppppb cell padding: p
|
|
|
|
// bpxxxxxxxxxxxxxxpb inner block: x
|
|
|
|
// bpx xpb
|
|
|
|
// bpx xpb
|
|
|
|
// bpx xpb
|
|
|
|
// bpxxxxxxxxxxxxxxpb base line
|
|
|
|
// bp pb
|
|
|
|
// bp pb
|
|
|
|
// bppppppppppppppppb
|
|
|
|
// bbbbbbbbbbbbbbbbbb
|
|
|
|
|
|
|
|
nscoord ascent = 0;
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize = GetSize();
|
2015-06-23 21:47:45 +03:00
|
|
|
for (nsIFrame* childFrame : mFrames) {
|
2005-10-04 19:47:21 +04:00
|
|
|
if (IS_TABLE_CELL(childFrame->GetType())) {
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* firstKid = childFrame->GetFirstPrincipalChild();
|
2015-06-20 23:00:26 +03:00
|
|
|
ascent = std::max(ascent,
|
|
|
|
LogicalRect(aWM, firstKid->GetNormalRect(),
|
2015-07-16 12:07:57 +03:00
|
|
|
containerSize).BEnd(aWM));
|
2005-10-04 19:47:21 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ascent;
|
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord
|
2015-06-23 23:41:31 +03:00
|
|
|
nsTableRowFrame::GetInitialBSize(nscoord aPctBasis) const
|
2000-05-26 02:40:21 +04:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bsize = 0;
|
|
|
|
if ((aPctBasis > 0) && HasPctBSize()) {
|
|
|
|
bsize = NSToCoordRound(GetPctBSize() * (float)aPctBasis);
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
if (HasFixedBSize()) {
|
|
|
|
bsize = std::max(bsize, GetFixedBSize());
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
return std::max(bsize, GetContentBSize());
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::ResetBSize(nscoord aFixedBSize)
|
2000-05-26 02:40:21 +04:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
SetHasFixedBSize(false);
|
|
|
|
SetHasPctBSize(false);
|
|
|
|
SetFixedBSize(0);
|
|
|
|
SetPctBSize(0);
|
|
|
|
SetContentBSize(0);
|
|
|
|
|
|
|
|
if (aFixedBSize > 0) {
|
|
|
|
SetFixedBSize(aFixedBSize);
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
|
2000-06-05 12:25:11 +04:00
|
|
|
mMaxCellAscent = 0;
|
|
|
|
mMaxCellDescent = 0;
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::UpdateBSize(nscoord aBSize,
|
|
|
|
nscoord aAscent,
|
|
|
|
nscoord aDescent,
|
|
|
|
nsTableFrame* aTableFrame,
|
|
|
|
nsTableCellFrame* aCellFrame)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
if (!aTableFrame || !aCellFrame) {
|
2011-10-17 18:59:28 +04:00
|
|
|
NS_ASSERTION(false , "invalid call");
|
2001-11-05 03:15:51 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (aBSize != NS_UNCONSTRAINEDSIZE) {
|
2000-06-05 12:25:11 +04:00
|
|
|
if (!(aCellFrame->HasVerticalAlignBaseline())) { // only the cell's height matters
|
2015-06-23 23:41:31 +03:00
|
|
|
if (GetInitialBSize() < aBSize) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowSpan = aTableFrame->GetEffectiveRowSpan(*aCellFrame);
|
2000-06-05 12:25:11 +04:00
|
|
|
if (rowSpan == 1) {
|
2015-06-20 23:00:26 +03:00
|
|
|
SetContentBSize(aBSize);
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
else { // the alignment on the baseline can change the bsize
|
|
|
|
NS_ASSERTION((aAscent != NS_UNCONSTRAINEDSIZE) &&
|
|
|
|
(aDescent != NS_UNCONSTRAINEDSIZE), "invalid call");
|
2000-06-05 12:25:11 +04:00
|
|
|
// see if this is a long ascender
|
|
|
|
if (mMaxCellAscent < aAscent) {
|
|
|
|
mMaxCellAscent = aAscent;
|
|
|
|
}
|
|
|
|
// see if this is a long descender and without rowspan
|
|
|
|
if (mMaxCellDescent < aDescent) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowSpan = aTableFrame->GetEffectiveRowSpan(*aCellFrame);
|
2000-06-05 12:25:11 +04:00
|
|
|
if (rowSpan == 1) {
|
|
|
|
mMaxCellDescent = aDescent;
|
|
|
|
}
|
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
// keep the tallest bsize in sync
|
2015-06-23 23:41:31 +03:00
|
|
|
if (GetInitialBSize() < mMaxCellAscent + mMaxCellDescent) {
|
2015-06-20 23:00:26 +03:00
|
|
|
SetContentBSize(mMaxCellAscent + mMaxCellDescent);
|
2000-06-05 12:25:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::CalcBSize(const nsHTMLReflowState& aReflowState)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord computedBSize = (NS_UNCONSTRAINEDSIZE == aReflowState.ComputedBSize())
|
|
|
|
? 0 : aReflowState.ComputedBSize();
|
|
|
|
ResetBSize(computedBSize);
|
2000-05-26 02:40:21 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePosition* position = StylePosition();
|
2015-06-20 23:00:26 +03:00
|
|
|
const nsStyleCoord& bsizeStyleCoord = position->BSize(wm);
|
|
|
|
if (bsizeStyleCoord.ConvertsToLength()) {
|
|
|
|
SetFixedBSize(nsRuleNode::ComputeCoordPercentCalc(bsizeStyleCoord, 0));
|
2001-11-05 18:15:24 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
else if (eStyleUnit_Percent == bsizeStyleCoord.GetUnit()) {
|
|
|
|
SetPctBSize(bsizeStyleCoord.GetPercentValue());
|
2001-11-05 18:15:24 +03:00
|
|
|
}
|
2012-11-21 20:19:30 +04:00
|
|
|
// calc() with percentages is treated like 'auto' on table rows.
|
2001-11-05 18:15:24 +03:00
|
|
|
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* kidFrame : mFrames) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableCellFrame *cellFrame = do_QueryFrame(kidFrame);
|
|
|
|
if (cellFrame) {
|
2015-06-20 23:00:26 +03:00
|
|
|
MOZ_ASSERT(cellFrame->GetWritingMode() == wm);
|
2014-07-24 12:30:07 +04:00
|
|
|
LogicalSize desSize = cellFrame->GetDesiredSize();
|
2015-06-20 23:00:26 +03:00
|
|
|
if ((NS_UNCONSTRAINEDSIZE == aReflowState.AvailableBSize()) && !GetPrevInFlow()) {
|
|
|
|
CalculateCellActualBSize(cellFrame, desSize.BSize(wm), wm);
|
2001-11-29 18:41:07 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
// bsize may have changed, adjust descent to absorb any excess difference
|
2005-10-04 19:47:21 +04:00
|
|
|
nscoord ascent;
|
2011-08-25 00:54:30 +04:00
|
|
|
if (!kidFrame->GetFirstPrincipalChild()->GetFirstPrincipalChild())
|
2014-07-24 12:30:07 +04:00
|
|
|
ascent = desSize.BSize(wm);
|
2005-10-04 19:47:21 +04:00
|
|
|
else
|
2009-03-25 01:10:06 +03:00
|
|
|
ascent = cellFrame->GetCellBaseline();
|
2014-07-24 12:30:07 +04:00
|
|
|
nscoord descent = desSize.BSize(wm) - ascent;
|
2015-06-20 23:00:26 +03:00
|
|
|
UpdateBSize(desSize.BSize(wm), ascent, descent, tableFrame, cellFrame);
|
2000-05-26 02:40:21 +04:00
|
|
|
}
|
|
|
|
}
|
2015-06-23 23:41:31 +03:00
|
|
|
return GetInitialBSize();
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
/**
|
|
|
|
* We need a custom display item for table row backgrounds. This is only used
|
|
|
|
* when the table row is the root of a stacking context (e.g., has 'opacity').
|
|
|
|
* Table row backgrounds can extend beyond the row frame bounds, when
|
|
|
|
* the row contains row-spanning cells.
|
|
|
|
*/
|
2008-04-06 15:34:14 +04:00
|
|
|
class nsDisplayTableRowBackground : public nsDisplayTableItem {
|
2006-01-26 05:29:17 +03:00
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayTableRowBackground(nsDisplayListBuilder* aBuilder,
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame* aFrame) :
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayTableItem(aBuilder, aFrame) {
|
2006-01-29 21:48:58 +03:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayTableRowBackground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayTableRowBackground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayTableRowBackground);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2015-06-20 23:00:26 +03:00
|
|
|
nsRenderingContext* aCtx) override;
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("TableRowBackground", TYPE_TABLE_ROW_BACKGROUND)
|
2006-01-26 05:29:17 +03:00
|
|
|
};
|
1999-11-02 01:12:45 +03:00
|
|
|
|
2006-01-26 05:29:17 +03:00
|
|
|
void
|
|
|
|
nsDisplayTableRowBackground::Paint(nsDisplayListBuilder* aBuilder,
|
2015-06-20 23:00:26 +03:00
|
|
|
nsRenderingContext* aCtx)
|
2012-01-17 03:38:10 +04:00
|
|
|
{
|
2015-04-30 07:24:59 +03:00
|
|
|
auto rowFrame = static_cast<nsTableRowFrame*>(mFrame);
|
|
|
|
TableBackgroundPainter painter(rowFrame->GetTableFrame(),
|
2006-01-26 05:29:17 +03:00
|
|
|
TableBackgroundPainter::eOrigin_TableRow,
|
2007-03-31 01:11:41 +04:00
|
|
|
mFrame->PresContext(), *aCtx,
|
2010-08-13 14:01:58 +04:00
|
|
|
mVisibleRect, ToReferenceFrame(),
|
2009-09-13 02:44:18 +04:00
|
|
|
aBuilder->GetBackgroundPaintFlags());
|
2015-02-06 07:45:56 +03:00
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
DrawResult result = painter.PaintRow(rowFrame);
|
2015-03-04 14:02:14 +03:00
|
|
|
nsDisplayTableItemGeometry::UpdateDrawResult(this, result);
|
2006-01-26 05:29:17 +03:00
|
|
|
}
|
2004-03-09 09:48:35 +03:00
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsTableRowFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
nsDisplayTableItem* item = nullptr;
|
2012-04-03 04:30:45 +04:00
|
|
|
if (IsVisibleInSelection(aBuilder)) {
|
|
|
|
bool isRoot = aBuilder->IsAtRootOfPseudoStackingContext();
|
|
|
|
if (isRoot) {
|
|
|
|
// This background is created regardless of whether this frame is
|
|
|
|
// visible or not. Visibility decisions are delegated to the
|
|
|
|
// table background painter.
|
|
|
|
// We would use nsDisplayGeneric for this rare case except that we
|
|
|
|
// need the background to be larger than the row frame in some
|
|
|
|
// cases.
|
|
|
|
item = new (aBuilder) nsDisplayTableRowBackground(aBuilder, this);
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(item);
|
2012-04-03 04:30:45 +04:00
|
|
|
}
|
2002-02-21 08:36:16 +03:00
|
|
|
}
|
2013-02-14 15:08:08 +04:00
|
|
|
nsTableFrame::DisplayGenericTablePart(aBuilder, this, aDirtyRect, aLists, item);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
nsIFrame::LogicalSides
|
2014-03-13 11:39:33 +04:00
|
|
|
nsTableRowFrame::GetLogicalSkipSides(const nsHTMLReflowState* aReflowState) const
|
1998-10-20 21:45:07 +04:00
|
|
|
{
|
2014-05-05 21:55:54 +04:00
|
|
|
if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
|
|
|
|
NS_STYLE_BOX_DECORATION_BREAK_CLONE)) {
|
2014-06-28 14:13:13 +04:00
|
|
|
return LogicalSides();
|
2014-05-05 21:55:54 +04:00
|
|
|
}
|
|
|
|
|
2014-06-28 14:13:13 +04:00
|
|
|
LogicalSides skip;
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr != GetPrevInFlow()) {
|
2014-06-28 14:13:14 +04:00
|
|
|
skip |= eLogicalSideBitsBStart;
|
1998-10-20 21:45:07 +04:00
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
if (nullptr != GetNextInFlow()) {
|
2014-06-28 14:13:14 +04:00
|
|
|
skip |= eLogicalSideBitsBEnd;
|
1998-10-20 21:45:07 +04:00
|
|
|
}
|
|
|
|
return skip;
|
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// Calculate the cell's actual bsize given its pass2 bsize.
|
|
|
|
// Takes into account the specified bsize (in the style).
|
|
|
|
// Modifies the desired bsize that is passed in.
|
1999-08-22 00:16:32 +04:00
|
|
|
nsresult
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::CalculateCellActualBSize(nsTableCellFrame* aCellFrame,
|
|
|
|
nscoord& aDesiredBSize,
|
|
|
|
WritingMode aWM)
|
1999-08-22 00:16:32 +04:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord specifiedBSize = 0;
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// Get the bsize specified in the style information
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePosition* position = aCellFrame->StylePosition();
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
int32_t rowSpan = GetTableFrame()->GetEffectiveRowSpan(*aCellFrame);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
const nsStyleCoord& bsizeStyleCoord = position->BSize(aWM);
|
|
|
|
switch (bsizeStyleCoord.GetUnit()) {
|
2012-11-21 20:19:30 +04:00
|
|
|
case eStyleUnit_Calc: {
|
2015-06-20 23:00:26 +03:00
|
|
|
if (bsizeStyleCoord.CalcHasPercent()) {
|
2012-11-21 20:19:30 +04:00
|
|
|
// Treat this like "auto"
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Fall through to the coord case
|
|
|
|
}
|
2012-06-30 20:01:31 +04:00
|
|
|
case eStyleUnit_Coord: {
|
|
|
|
nscoord outsideBoxSizing = 0;
|
2015-06-20 23:00:26 +03:00
|
|
|
// In quirks mode, table cell isize should be content-box, but bsize
|
2012-06-30 20:01:31 +04:00
|
|
|
// should be border-box.
|
|
|
|
// Because of this historic anomaly, we do not use quirk.css
|
2015-06-20 23:00:26 +03:00
|
|
|
// (since we can't specify one value of box-sizing for isize and another
|
|
|
|
// for bsize)
|
2012-06-30 20:01:31 +04:00
|
|
|
if (PresContext()->CompatibilityMode() != eCompatibility_NavQuirks) {
|
2015-05-29 22:16:53 +03:00
|
|
|
switch (position->mBoxSizing) {
|
2015-11-20 05:09:29 +03:00
|
|
|
case StyleBoxSizing::Content:
|
2015-06-20 23:00:26 +03:00
|
|
|
outsideBoxSizing =
|
|
|
|
aCellFrame->GetLogicalUsedBorderAndPadding(aWM).BStartEnd(aWM);
|
2015-05-29 22:16:53 +03:00
|
|
|
break;
|
2015-11-20 05:09:29 +03:00
|
|
|
case StyleBoxSizing::Padding:
|
2015-06-20 23:00:26 +03:00
|
|
|
outsideBoxSizing =
|
|
|
|
aCellFrame->GetLogicalUsedBorder(aWM).BStartEnd(aWM);
|
2015-05-29 22:16:53 +03:00
|
|
|
break;
|
2015-11-20 05:09:29 +03:00
|
|
|
case StyleBoxSizing::Border:
|
2015-05-29 22:16:53 +03:00
|
|
|
break;
|
2012-06-30 20:01:31 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
specifiedBSize =
|
|
|
|
nsRuleNode::ComputeCoordPercentCalc(bsizeStyleCoord, 0) +
|
|
|
|
outsideBoxSizing;
|
2012-06-30 20:01:31 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (1 == rowSpan) {
|
|
|
|
SetFixedBSize(specifiedBSize);
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
break;
|
2012-06-30 20:01:31 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
case eStyleUnit_Percent: {
|
2015-06-20 23:00:26 +03:00
|
|
|
if (1 == rowSpan) {
|
|
|
|
SetPctBSize(bsizeStyleCoord.GetPercentValue());
|
|
|
|
}
|
|
|
|
// pct bsizes are handled when all of the cells are finished,
|
|
|
|
// so don't set specifiedBSize
|
1999-08-26 01:49:18 +04:00
|
|
|
break;
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
case eStyleUnit_Auto:
|
2012-11-21 20:19:30 +04:00
|
|
|
default:
|
2001-03-13 09:38:59 +03:00
|
|
|
break;
|
1999-08-22 00:16:32 +04:00
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// If the specified bsize is greater than the desired bsize,
|
|
|
|
// then use the specified bsize
|
|
|
|
if (specifiedBSize > aDesiredBSize) {
|
|
|
|
aDesiredBSize = specifiedBSize;
|
|
|
|
}
|
1999-08-22 00:16:32 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-06-18 12:11:40 +03:00
|
|
|
// Calculates the available isize for the table cell based on the known
|
|
|
|
// column isizes taking into account column spans and column spacing
|
2009-01-13 22:50:40 +03:00
|
|
|
static nscoord
|
2015-06-18 12:11:40 +03:00
|
|
|
CalcAvailISize(nsTableFrame& aTableFrame,
|
2014-06-18 14:47:00 +04:00
|
|
|
nsTableCellFrame& aCellFrame)
|
1999-08-22 00:16:32 +04:00
|
|
|
{
|
2015-06-18 12:11:40 +03:00
|
|
|
nscoord cellAvailISize = 0;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex;
|
2002-09-09 22:46:06 +04:00
|
|
|
aCellFrame.GetColIndex(colIndex);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colspan = aTableFrame.GetEffectiveColSpan(aCellFrame);
|
2009-01-13 22:50:40 +03:00
|
|
|
NS_ASSERTION(colspan > 0, "effective colspan should be positive");
|
2015-06-23 21:44:36 +03:00
|
|
|
nsTableFrame* fifTable =
|
|
|
|
static_cast<nsTableFrame*>(aTableFrame.FirstInFlow());
|
2002-09-09 22:46:06 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t spanX = 0; spanX < colspan; spanX++) {
|
2015-06-23 21:44:36 +03:00
|
|
|
cellAvailISize +=
|
|
|
|
fifTable->GetColumnISizeFromFirstInFlow(colIndex + spanX);
|
2009-01-13 22:50:40 +03:00
|
|
|
if (spanX > 0 &&
|
|
|
|
aTableFrame.ColumnHasCellSpacingBefore(colIndex + spanX)) {
|
2015-06-18 12:11:40 +03:00
|
|
|
cellAvailISize += aTableFrame.GetColSpacing(colIndex + spanX - 1);
|
2001-10-26 06:30:38 +04:00
|
|
|
}
|
|
|
|
}
|
2015-06-18 12:11:40 +03:00
|
|
|
return cellAvailISize;
|
1999-08-22 00:16:32 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord
|
2012-08-22 19:56:38 +04:00
|
|
|
GetSpaceBetween(int32_t aPrevColIndex,
|
|
|
|
int32_t aColIndex,
|
|
|
|
int32_t aColSpan,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableFrame& aTableFrame,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aCheckVisibility)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2001-03-13 09:38:59 +03:00
|
|
|
nscoord space = 0;
|
2015-06-23 21:45:17 +03:00
|
|
|
int32_t colIdx;
|
2015-06-23 21:44:36 +03:00
|
|
|
nsTableFrame* fifTable =
|
|
|
|
static_cast<nsTableFrame*>(aTableFrame.FirstInFlow());
|
2015-06-23 21:45:17 +03:00
|
|
|
for (colIdx = aPrevColIndex + 1; aColIndex > colIdx; colIdx++) {
|
2015-06-20 23:00:26 +03:00
|
|
|
bool isCollapsed = false;
|
|
|
|
if (!aCheckVisibility) {
|
2015-06-23 21:45:17 +03:00
|
|
|
space += fifTable->GetColumnISizeFromFirstInFlow(colIdx);
|
2015-06-20 23:00:26 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
else {
|
2015-06-23 21:45:17 +03:00
|
|
|
nsTableColFrame* colFrame = aTableFrame.GetColFrame(colIdx);
|
2015-06-20 23:00:26 +03:00
|
|
|
const nsStyleVisibility* colVis = colFrame->StyleVisibility();
|
|
|
|
bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE == colVis->mVisible);
|
|
|
|
nsIFrame* cgFrame = colFrame->GetParent();
|
|
|
|
const nsStyleVisibility* groupVis = cgFrame->StyleVisibility();
|
|
|
|
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE ==
|
|
|
|
groupVis->mVisible);
|
|
|
|
isCollapsed = collapseCol || collapseGroup;
|
|
|
|
if (!isCollapsed)
|
2015-06-23 21:45:17 +03:00
|
|
|
space += fifTable->GetColumnISizeFromFirstInFlow(colIdx);
|
2015-06-20 23:00:26 +03:00
|
|
|
}
|
2015-06-23 21:45:17 +03:00
|
|
|
if (!isCollapsed && aTableFrame.ColumnHasCellSpacingBefore(colIdx)) {
|
|
|
|
space += aTableFrame.GetColSpacing(colIdx - 1);
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
return space;
|
|
|
|
}
|
1999-04-22 07:51:58 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// subtract the bsizes of aRow's prev in flows from the unpaginated bsize
|
2002-03-27 08:50:24 +03:00
|
|
|
static
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord CalcBSizeFromUnpaginatedBSize(nsPresContext* aPresContext,
|
|
|
|
nsTableRowFrame& aRow,
|
|
|
|
WritingMode aWM)
|
2002-03-27 08:50:24 +03:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bsize = 0;
|
2012-01-17 03:38:10 +04:00
|
|
|
nsTableRowFrame* firstInFlow =
|
2013-09-25 15:42:34 +04:00
|
|
|
static_cast<nsTableRowFrame*>(aRow.FirstInFlow());
|
2015-06-20 23:00:26 +03:00
|
|
|
if (firstInFlow->HasUnpaginatedBSize()) {
|
|
|
|
bsize = firstInFlow->GetUnpaginatedBSize(aPresContext);
|
2003-07-07 06:01:29 +04:00
|
|
|
for (nsIFrame* prevInFlow = aRow.GetPrevInFlow(); prevInFlow;
|
2004-09-14 06:28:03 +04:00
|
|
|
prevInFlow = prevInFlow->GetPrevInFlow()) {
|
2015-06-20 23:00:26 +03:00
|
|
|
bsize -= prevInFlow->BSize(aWM);
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
return std::max(bsize, 0);
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:53 +04:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::ReflowChildren(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsTableFrame& aTableFrame,
|
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 08:38:33 +03:00
|
|
|
nsReflowStatus& aStatus)
|
2001-03-13 09:38:59 +03:00
|
|
|
{
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-11-20 04:01:25 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// XXXldb Should we be checking constrained bsize instead?
|
2012-01-17 03:38:10 +04:00
|
|
|
const bool isPaginated = aPresContext->IsPaginated();
|
|
|
|
const bool borderCollapse = aTableFrame.IsBorderCollapse();
|
2014-05-13 04:47:53 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t cellColSpan = 1; // must be defined here so it's set properly for non-cell kids
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// remember the col index of the previous cell to handle rowspans into this row
|
2015-06-23 21:45:17 +03:00
|
|
|
int32_t prevColIndex = -1;
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord iCoord = 0; // running total of children inline-coord offset
|
1999-05-04 23:15:56 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// This computes the max of all cell bsizes
|
|
|
|
nscoord cellMaxBSize = 0;
|
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 08:38:33 +03:00
|
|
|
|
1998-07-11 02:56:13 +04:00
|
|
|
// Reflow each of our existing cell frames
|
2015-06-20 23:00:26 +03:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize =
|
|
|
|
aReflowState.ComputedSizeAsContainerIfConstrained();
|
2015-06-20 23:00:26 +03:00
|
|
|
|
2015-06-23 21:47:45 +03:00
|
|
|
for (nsIFrame* kidFrame : mFrames) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableCellFrame *cellFrame = do_QueryFrame(kidFrame);
|
|
|
|
if (!cellFrame) {
|
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 08:38:33 +03:00
|
|
|
// XXXldb nsCSSFrameConstructor needs to enforce this!
|
|
|
|
NS_NOTREACHED("yikes, a non-row child");
|
|
|
|
|
|
|
|
// it's an unknown frame type, give it a generic reflow and ignore the results
|
2014-07-24 12:28:46 +04:00
|
|
|
nsTableCellReflowState
|
|
|
|
kidReflowState(aPresContext, aReflowState, kidFrame,
|
|
|
|
LogicalSize(kidFrame->GetWritingMode(), 0, 0),
|
|
|
|
nsHTMLReflowState::CALLER_WILL_INIT);
|
2015-06-20 23:00:26 +03:00
|
|
|
InitChildReflowState(*aPresContext, LogicalSize(wm), false, kidReflowState);
|
2013-12-31 17:50:31 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(aReflowState);
|
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 08:38:33 +03:00
|
|
|
nsReflowStatus status;
|
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState, 0, 0, 0, status);
|
2012-11-14 10:47:33 +04:00
|
|
|
kidFrame->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);
|
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 08:38:33 +03:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// See if we should only reflow the dirty child frames
|
2011-09-29 10:19:26 +04:00
|
|
|
bool doReflowChild = true;
|
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 08:38:33 +03:00
|
|
|
if (!aReflowState.ShouldReflowAllKids() &&
|
2006-12-13 06:45:28 +03:00
|
|
|
!aTableFrame.IsGeometryDirty() &&
|
2007-05-06 23:16:51 +04:00
|
|
|
!NS_SUBTREE_DIRTY(kidFrame)) {
|
2015-06-22 12:33:34 +03:00
|
|
|
if (!aReflowState.mFlags.mSpecialBSizeReflow)
|
2011-10-17 18:59:28 +04:00
|
|
|
doReflowChild = false;
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
else if ((NS_UNCONSTRAINEDSIZE != aReflowState.AvailableBSize())) {
|
|
|
|
// We don't reflow a rowspan >1 cell here with a constrained bsize.
|
2002-10-03 18:33:23 +04:00
|
|
|
// That happens in nsTableRowGroupFrame::SplitSpanningCells.
|
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 08:38:33 +03:00
|
|
|
if (aTableFrame.GetEffectiveRowSpan(*cellFrame) > 1) {
|
2011-10-17 18:59:28 +04:00
|
|
|
doReflowChild = false;
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
|
|
|
}
|
2015-06-22 12:33:34 +03:00
|
|
|
if (aReflowState.mFlags.mSpecialBSizeReflow) {
|
2015-06-23 23:41:29 +03:00
|
|
|
if (!isPaginated &&
|
|
|
|
!cellFrame->HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE)) {
|
2001-11-05 03:15:51 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2001-03-13 09:38:59 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t cellColIndex;
|
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 08:38:33 +03:00
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
|
|
|
cellColSpan = aTableFrame.GetEffectiveColSpan(*cellFrame);
|
|
|
|
|
|
|
|
// If the adjacent cell is in a prior row (because of a rowspan) add in the space
|
2015-06-20 23:00:26 +03:00
|
|
|
if (prevColIndex != (cellColIndex - 1)) {
|
|
|
|
iCoord += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan, aTableFrame,
|
|
|
|
false);
|
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 08:38:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// remember the rightmost (ltr) or leftmost (rtl) column this cell spans into
|
2015-06-20 23:00:26 +03:00
|
|
|
prevColIndex = cellColIndex + (cellColSpan - 1);
|
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 08:38:33 +03:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Reflow the child frame
|
2008-02-08 12:36:32 +03:00
|
|
|
nsRect kidRect = kidFrame->GetRect();
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalPoint origKidNormalPosition =
|
2015-07-16 12:07:57 +03:00
|
|
|
kidFrame->GetLogicalNormalPosition(wm, containerSize);
|
2015-06-20 23:00:26 +03:00
|
|
|
// All cells' no-relative-positioning position should be snapped to the
|
|
|
|
// row's bstart edge.
|
2015-06-27 02:50:21 +03:00
|
|
|
// This doesn't hold in vertical-rl mode, where we don't yet know the
|
2015-07-16 12:07:57 +03:00
|
|
|
// correct containerSize for the row frame. In that case, we'll have to
|
2015-06-27 02:50:21 +03:00
|
|
|
// fix up child positions later, after determining our desiredSize.
|
|
|
|
NS_ASSERTION(origKidNormalPosition.B(wm) == 0 || wm.IsVerticalRL(),
|
|
|
|
"unexpected kid position");
|
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
nsRect kidVisualOverflow = kidFrame->GetVisualOverflowRect();
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalPoint kidPosition(wm, iCoord, 0);
|
2015-06-23 23:41:29 +03:00
|
|
|
bool firstReflow = kidFrame->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
|
2008-02-08 12:36:32 +03:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
if (doReflowChild) {
|
2015-06-18 12:11:40 +03:00
|
|
|
// Calculate the available isize for the table cell using the known
|
|
|
|
// column isizes
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord availCellISize = CalcAvailISize(aTableFrame, *cellFrame);
|
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 08:38:33 +03:00
|
|
|
|
2014-08-20 05:24:58 +04:00
|
|
|
Maybe<nsTableCellReflowState> kidReflowState;
|
2013-12-31 17:50:31 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(aReflowState);
|
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 08:38:33 +03:00
|
|
|
|
2015-06-18 12:11:40 +03:00
|
|
|
// If the avail isize is not the same as last time we reflowed the cell or
|
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 08:38:33 +03:00
|
|
|
// the cell wants to be bigger than what was available last time or
|
|
|
|
// it is a style change reflow or we are printing, then we must reflow the
|
|
|
|
// cell. Otherwise we can skip the reflow.
|
|
|
|
// XXXldb Why is this condition distinct from doReflowChild above?
|
2015-06-18 12:11:40 +03:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
NS_ASSERTION(cellFrame->GetWritingMode() == wm,
|
|
|
|
"expected consistent writing-mode within table");
|
2014-07-24 12:30:07 +04:00
|
|
|
LogicalSize cellDesiredSize = cellFrame->GetDesiredSize();
|
2015-06-23 23:41:29 +03:00
|
|
|
if ((availCellISize != cellFrame->GetPriorAvailISize()) ||
|
2015-06-18 12:11:40 +03:00
|
|
|
(cellDesiredSize.ISize(wm) > cellFrame->GetPriorAvailISize()) ||
|
2015-06-23 23:41:29 +03:00
|
|
|
HasAnyStateBits(NS_FRAME_IS_DIRTY) ||
|
|
|
|
isPaginated ||
|
|
|
|
NS_SUBTREE_DIRTY(cellFrame) ||
|
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 08:38:33 +03:00
|
|
|
// See if it needs a special reflow, or if it had one that we need to undo.
|
2015-06-23 23:41:29 +03:00
|
|
|
cellFrame->HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE) ||
|
2015-06-20 23:00:26 +03:00
|
|
|
HasPctBSize()) {
|
2015-06-18 12:11:40 +03:00
|
|
|
// Reflow the cell to fit the available isize, bsize
|
|
|
|
// XXX The old IR_ChildIsDirty code used availCellISize here.
|
|
|
|
LogicalSize kidAvailSize(wm, availCellISize, aReflowState.AvailableBSize());
|
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 08:38:33 +03:00
|
|
|
|
|
|
|
// Reflow the child
|
2014-08-20 05:24:58 +04:00
|
|
|
kidReflowState.emplace(aPresContext, aReflowState, kidFrame,
|
2015-06-18 12:11:40 +03:00
|
|
|
kidAvailSize,
|
2015-06-23 21:44:59 +03:00
|
|
|
nsHTMLReflowState::CALLER_WILL_INIT);
|
2015-06-20 23:00:26 +03:00
|
|
|
InitChildReflowState(*aPresContext, kidAvailSize, borderCollapse,
|
|
|
|
*kidReflowState);
|
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 08:38:33 +03:00
|
|
|
|
|
|
|
nsReflowStatus status;
|
2014-08-20 05:24:58 +04:00
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, *kidReflowState,
|
2015-07-16 12:07:57 +03:00
|
|
|
wm, kidPosition, containerSize, 0, status);
|
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 08:38:33 +03:00
|
|
|
|
|
|
|
// allow the table to determine if/how the table needs to be rebalanced
|
|
|
|
// If any of the cells are not complete, then we're not complete
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(status)) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
1998-10-06 04:27:22 +04:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
} else {
|
|
|
|
if (iCoord != origKidNormalPosition.I(wm)) {
|
2010-08-31 04:49:12 +04:00
|
|
|
kidFrame->InvalidateFrameSubtree();
|
2008-02-08 12:36:32 +03:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-18 12:11:40 +03:00
|
|
|
desiredSize.SetSize(wm, cellDesiredSize);
|
2010-10-07 08:25:46 +04:00
|
|
|
desiredSize.mOverflowAreas = cellFrame->GetOverflowAreas();
|
|
|
|
|
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 08:38:33 +03:00
|
|
|
// if we are in a floated table, our position is not yet established, so we cannot reposition our views
|
2009-02-13 02:10:59 +03:00
|
|
|
// the containing block will do this for us after positioning the table
|
2012-08-02 15:38:49 +04:00
|
|
|
if (!aTableFrame.IsFloating()) {
|
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 08:38:33 +03:00
|
|
|
// Because we may have moved the frame we need to make sure any views are
|
|
|
|
// positioned properly. We have to do this, because any one of our parent
|
|
|
|
// frames could have moved and we have no way of knowing...
|
|
|
|
nsTableFrame::RePositionViews(kidFrame);
|
2001-11-15 17:58:27 +03: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 08:38:33 +03:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE == aReflowState.AvailableBSize()) {
|
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 08:38:33 +03:00
|
|
|
if (!GetPrevInFlow()) {
|
2015-06-20 23:00:26 +03:00
|
|
|
// Calculate the cell's actual bsize given its pass2 bsize. This
|
|
|
|
// function takes into account the specified bsize (in the style)
|
|
|
|
CalculateCellActualBSize(cellFrame, desiredSize.BSize(wm), wm);
|
2001-11-15 17:58:27 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
// bsize may have changed, adjust descent to absorb any excess difference
|
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 08:38:33 +03:00
|
|
|
nscoord ascent;
|
2014-07-24 12:30:07 +04:00
|
|
|
if (!kidFrame->GetFirstPrincipalChild()->GetFirstPrincipalChild()) {
|
2015-06-18 12:11:40 +03:00
|
|
|
ascent = desiredSize.BSize(wm);
|
2014-07-24 12:30:07 +04:00
|
|
|
} else {
|
2007-01-23 07:06:56 +03:00
|
|
|
ascent = ((nsTableCellFrame *)kidFrame)->GetCellBaseline();
|
2014-07-24 12:30:07 +04:00
|
|
|
}
|
2015-06-18 12:11:40 +03:00
|
|
|
nscoord descent = desiredSize.BSize(wm) - ascent;
|
2015-06-20 23:00:26 +03:00
|
|
|
UpdateBSize(desiredSize.BSize(wm), ascent, descent, &aTableFrame, cellFrame);
|
|
|
|
} else {
|
|
|
|
cellMaxBSize = std::max(cellMaxBSize, desiredSize.BSize(wm));
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowSpan = aTableFrame.GetEffectiveRowSpan((nsTableCellFrame&)*kidFrame);
|
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 08:38:33 +03:00
|
|
|
if (1 == rowSpan) {
|
2015-06-20 23:00:26 +03:00
|
|
|
SetContentBSize(cellMaxBSize);
|
2001-10-26 06:30:38 +04:00
|
|
|
}
|
1998-09-16 04:48:14 +04: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 08:38:33 +03:00
|
|
|
|
|
|
|
// Place the child
|
2015-06-18 12:11:40 +03:00
|
|
|
desiredSize.ISize(wm) = availCellISize;
|
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 08:38:33 +03:00
|
|
|
|
2014-08-20 05:24:58 +04:00
|
|
|
if (kidReflowState) {
|
|
|
|
// We reflowed. Apply relative positioning in the normal way.
|
2015-07-16 12:07:57 +03:00
|
|
|
kidReflowState->ApplyRelativePositioning(&kidPosition, containerSize);
|
2014-12-29 03:42:54 +03:00
|
|
|
} else if (kidFrame->IsRelativelyPositioned()) {
|
|
|
|
// We didn't reflow. Do the positioning part of what
|
|
|
|
// MovePositionBy does internally. (This codepath should really
|
|
|
|
// be merged into the else below if we can.)
|
2015-07-17 00:53:52 +03:00
|
|
|
nsMargin* computedOffsetProp = static_cast<nsMargin*>
|
|
|
|
(kidFrame->Properties().Get(nsIFrame::ComputedOffsetProperty()));
|
|
|
|
// Bug 975644: a position:sticky kid can end up with a null
|
|
|
|
// property value here.
|
|
|
|
LogicalMargin computedOffsets(wm, computedOffsetProp ?
|
|
|
|
*computedOffsetProp : nsMargin());
|
2015-06-20 23:00:26 +03:00
|
|
|
nsHTMLReflowState::ApplyRelativePositioning(kidFrame, wm, computedOffsets,
|
2015-07-16 12:07:57 +03:00
|
|
|
&kidPosition, containerSize);
|
2014-08-20 05:24:58 +04:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
// In vertical-rl mode, we are likely to have containerSize.width = 0
|
|
|
|
// because ComputedWidth() was NS_UNCONSTRAINEDSIZE.
|
2015-06-20 23:00:26 +03:00
|
|
|
// For cases where that's wrong, we will fix up the position later.
|
2014-08-20 05:24:58 +04:00
|
|
|
FinishReflowChild(kidFrame, aPresContext, desiredSize, nullptr,
|
2015-07-16 12:07:57 +03:00
|
|
|
wm, kidPosition, containerSize, 0);
|
2012-07-04 04:24:55 +04:00
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableFrame::InvalidateTableFrame(kidFrame, kidRect, kidVisualOverflow,
|
|
|
|
firstReflow);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
iCoord += desiredSize.ISize(wm);
|
|
|
|
} else {
|
|
|
|
if (iCoord != origKidNormalPosition.I(wm)) {
|
2008-02-08 12:36:32 +03:00
|
|
|
// Invalidate the old position
|
2010-08-31 04:49:12 +04:00
|
|
|
kidFrame->InvalidateFrameSubtree();
|
2014-08-20 05:24:58 +04:00
|
|
|
// Move to the new position. As above, we need to account for relative
|
|
|
|
// positioning.
|
2015-06-20 23:00:26 +03:00
|
|
|
kidFrame->MovePositionBy(wm,
|
|
|
|
LogicalPoint(wm, iCoord - origKidNormalPosition.I(wm), 0));
|
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 08:38:33 +03:00
|
|
|
nsTableFrame::RePositionViews(kidFrame);
|
2008-02-08 12:36:32 +03:00
|
|
|
// invalidate the new position
|
2010-08-31 04:49:12 +04:00
|
|
|
kidFrame->InvalidateFrameSubtree();
|
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 08:38:33 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
// we need to account for the cell's isize even if it isn't reflowed
|
|
|
|
iCoord += kidFrame->ISize(wm);
|
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 08:38:33 +03:00
|
|
|
|
|
|
|
if (kidFrame->GetNextInFlow()) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
2000-11-15 17:59:47 +03:00
|
|
|
}
|
2010-10-07 08:25:46 +04:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, kidFrame);
|
2015-06-20 23:00:26 +03:00
|
|
|
iCoord += aTableFrame.GetColSpacing(cellColIndex);
|
1998-09-16 21:19:20 +04:00
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// Just set our isize to what was available.
|
|
|
|
// The table will calculate the isize and not use our value.
|
|
|
|
aDesiredSize.ISize(wm) = aReflowState.AvailableISize();
|
2002-03-27 08:50:24 +03:00
|
|
|
|
2015-06-22 12:33:34 +03:00
|
|
|
if (aReflowState.mFlags.mSpecialBSizeReflow) {
|
2015-06-20 23:00:26 +03:00
|
|
|
aDesiredSize.BSize(wm) = BSize(wm);
|
|
|
|
} else if (NS_UNCONSTRAINEDSIZE == aReflowState.AvailableBSize()) {
|
|
|
|
aDesiredSize.BSize(wm) = CalcBSize(aReflowState);
|
2006-02-22 00:33:47 +03:00
|
|
|
if (GetPrevInFlow()) {
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bsize = CalcBSizeFromUnpaginatedBSize(aPresContext, *this, wm);
|
|
|
|
aDesiredSize.BSize(wm) = std::max(aDesiredSize.BSize(wm), bsize);
|
|
|
|
} else {
|
|
|
|
if (isPaginated && HasStyleBSize()) {
|
|
|
|
// set the unpaginated bsize so next in flows can try to honor it
|
|
|
|
SetHasUnpaginatedBSize(true);
|
|
|
|
SetUnpaginatedBSize(aPresContext, aDesiredSize.BSize(wm));
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
if (isPaginated && HasUnpaginatedBSize()) {
|
|
|
|
aDesiredSize.BSize(wm) = std::max(aDesiredSize.BSize(wm),
|
|
|
|
GetUnpaginatedBSize(aPresContext));
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
} else { // constrained bsize, paginated
|
|
|
|
// Compute the bsize we should have from style (subtracting the
|
|
|
|
// bsize from our prev-in-flows from the style bsize)
|
|
|
|
nscoord styleBSize = CalcBSizeFromUnpaginatedBSize(aPresContext, *this,
|
|
|
|
wm);
|
|
|
|
if (styleBSize > aReflowState.AvailableBSize()) {
|
|
|
|
styleBSize = aReflowState.AvailableBSize();
|
2015-06-21 08:41:07 +03:00
|
|
|
NS_FRAME_SET_INCOMPLETE(aStatus);
|
2015-06-20 23:00:26 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
aDesiredSize.BSize(wm) = std::max(cellMaxBSize, styleBSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wm.IsVerticalRL()) {
|
|
|
|
// Any children whose width was not the same as our final
|
|
|
|
// aDesiredSize.BSize will have been misplaced earlier at the
|
|
|
|
// FinishReflowChild stage. So fix them up now.
|
2015-06-23 21:47:45 +03:00
|
|
|
for (nsIFrame* kidFrame : mFrames) {
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableCellFrame *cellFrame = do_QueryFrame(kidFrame);
|
|
|
|
if (!cellFrame) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (kidFrame->BSize(wm) != aDesiredSize.BSize(wm)) {
|
|
|
|
kidFrame->MovePositionBy(wm,
|
|
|
|
LogicalPoint(wm, 0, kidFrame->BSize(wm) - aDesiredSize.BSize(wm)));
|
|
|
|
nsTableFrame::RePositionViews(kidFrame);
|
|
|
|
// Do we need to InvalidateFrameSubtree() here?
|
|
|
|
}
|
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.UnionOverflowAreasWithDesiredBounds();
|
2004-07-16 20:56:21 +04:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
1998-04-23 21:29:07 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Layout the entire row.
|
2015-06-20 23:00:26 +03:00
|
|
|
* This method stacks cells in the inline dir according to HTML 4.0 rules.
|
1998-04-23 21:29:07 +04:00
|
|
|
*/
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-23 21:29:07 +04:00
|
|
|
{
|
2015-03-30 01:38:40 +03:00
|
|
|
MarkInReflow();
|
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 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableRowFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleVisibility* rowVis = StyleVisibility();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
|
2004-04-28 20:42:59 +04:00
|
|
|
if (collapseRow) {
|
2011-10-17 18:59:28 +04:00
|
|
|
tableFrame->SetNeedToCollapse(true);
|
2004-04-28 20:42:59 +04:00
|
|
|
}
|
|
|
|
|
2015-06-22 12:33:34 +03:00
|
|
|
// see if a special bsize reflow needs to occur due to having a pct bsize
|
2015-06-22 12:33:34 +03:00
|
|
|
nsTableFrame::CheckRequestSpecialBSizeReflow(aReflowState);
|
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 08:38:33 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// See if we have a cell with specified/pct bsize
|
|
|
|
InitHasCellWithStyleBSize(tableFrame);
|
2007-06-26 00:34:35 +04:00
|
|
|
|
2014-05-13 04:47:52 +04:00
|
|
|
ReflowChildren(aPresContext, aDesiredSize, aReflowState, *tableFrame, aStatus);
|
1998-07-02 09:39:10 +04:00
|
|
|
|
2012-11-08 20:09:38 +04:00
|
|
|
if (aPresContext->IsPaginated() && !NS_FRAME_IS_FULLY_COMPLETE(aStatus) &&
|
|
|
|
ShouldAvoidBreakInside(aReflowState)) {
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// Just set our isize to what was available.
|
|
|
|
// The table will calculate the isize and not use our value.
|
|
|
|
aDesiredSize.ISize(wm) = aReflowState.AvailableISize();
|
1999-08-31 02:30:32 +04:00
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
// If our parent is in initial reflow, it'll handle invalidating our
|
|
|
|
// entire overflow rect.
|
2015-06-23 23:41:29 +03:00
|
|
|
if (!GetParent()->HasAnyStateBits(NS_FRAME_FIRST_REFLOW) &&
|
2013-12-27 21:59:52 +04:00
|
|
|
nsSize(aDesiredSize.Width(), aDesiredSize.Height()) != mRect.Size()) {
|
2012-08-29 09:48:45 +04:00
|
|
|
InvalidateFrame();
|
|
|
|
}
|
|
|
|
|
2014-08-21 04:48:56 +04:00
|
|
|
// Any absolutely-positioned children will get reflowed in
|
|
|
|
// nsFrame::FixupPositionedTableParts in another pass, so propagate our
|
|
|
|
// dirtiness to them before our parent clears our dirty bits.
|
|
|
|
PushDirtyBitToAbsoluteFrames();
|
|
|
|
|
2002-05-29 02:50:43 +04:00
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
/**
|
|
|
|
* This function is called by the row group frame's SplitRowGroup() code when
|
|
|
|
* pushing a row frame that has cell frames that span into it. The cell frame
|
|
|
|
* should be reflowed with the specified height
|
|
|
|
*/
|
2015-04-17 21:42:05 +03:00
|
|
|
nscoord
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::ReflowCellFrame(nsPresContext* aPresContext,
|
2001-04-16 18:51:52 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aIsTopOfPage,
|
2001-04-16 18:51:52 +04:00
|
|
|
nsTableCellFrame* aCellFrame,
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord aAvailableBSize,
|
2001-04-16 18:51:52 +04:00
|
|
|
nsReflowStatus& aStatus)
|
1999-02-22 06:28:00 +03:00
|
|
|
{
|
2015-06-18 12:11:40 +03:00
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
|
1999-02-22 06:28:00 +03:00
|
|
|
// Reflow the cell frame with the specified height. Use the existing width
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize = aCellFrame->GetSize();
|
|
|
|
LogicalRect cellRect = aCellFrame->GetLogicalRect(wm, containerSize);
|
2010-10-07 08:25:46 +04:00
|
|
|
nsRect cellVisualOverflow = aCellFrame->GetVisualOverflowRect();
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalSize cellSize = cellRect.Size(wm);
|
|
|
|
LogicalSize availSize(wm, cellRect.ISize(wm), aAvailableBSize);
|
2015-04-30 07:24:59 +03:00
|
|
|
bool borderCollapse = GetTableFrame()->IsBorderCollapse();
|
2015-06-18 12:11:40 +03:00
|
|
|
NS_ASSERTION(aCellFrame->GetWritingMode() == wm,
|
|
|
|
"expected consistent writing-mode within table");
|
2014-07-24 12:28:46 +04:00
|
|
|
nsTableCellReflowState
|
2015-06-20 23:00:26 +03:00
|
|
|
cellReflowState(aPresContext, aReflowState, aCellFrame, availSize,
|
2014-07-24 12:28:46 +04:00
|
|
|
nsHTMLReflowState::CALLER_WILL_INIT);
|
2007-02-07 10:46:44 +03:00
|
|
|
InitChildReflowState(*aPresContext, availSize, borderCollapse, cellReflowState);
|
2007-02-21 22:42:21 +03:00
|
|
|
cellReflowState.mFlags.mIsTopOfPage = aIsTopOfPage;
|
2002-02-19 18:48:28 +03:00
|
|
|
|
2013-12-31 17:50:31 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(aReflowState);
|
1999-02-22 06:28:00 +03:00
|
|
|
|
1999-11-19 18:33:29 +03:00
|
|
|
ReflowChild(aCellFrame, aPresContext, desiredSize, cellReflowState,
|
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool fullyComplete = NS_FRAME_IS_COMPLETE(aStatus) && !NS_FRAME_IS_TRUNCATED(aStatus);
|
2007-12-02 22:19:00 +03:00
|
|
|
if (fullyComplete) {
|
2015-06-20 23:00:26 +03:00
|
|
|
desiredSize.BSize(wm) = aAvailableBSize;
|
2007-12-02 22:19:00 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
aCellFrame->SetSize(wm, LogicalSize(wm, cellSize.ISize(wm),
|
|
|
|
desiredSize.BSize(wm)));
|
2001-04-16 18:51:52 +04:00
|
|
|
|
2015-06-18 12:11:40 +03:00
|
|
|
// Note: BlockDirAlignChild can affect the overflow rect.
|
2000-06-05 12:25:11 +04:00
|
|
|
// XXX What happens if this cell has 'vertical-align: baseline' ?
|
|
|
|
// XXX Why is it assumed that the cell's ascent hasn't changed ?
|
2002-10-03 18:33:23 +04:00
|
|
|
if (fullyComplete) {
|
2015-06-18 12:11:40 +03:00
|
|
|
aCellFrame->BlockDirAlignChild(wm, mMaxCellAscent);
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableFrame::InvalidateTableFrame(aCellFrame,
|
2015-07-16 12:07:57 +03:00
|
|
|
cellRect.GetPhysicalRect(wm, containerSize),
|
2012-08-29 09:48:45 +04:00
|
|
|
cellVisualOverflow,
|
2015-06-23 23:41:29 +03:00
|
|
|
aCellFrame->
|
|
|
|
HasAnyStateBits(NS_FRAME_FIRST_REFLOW));
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2012-11-14 10:47:33 +04:00
|
|
|
aCellFrame->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);
|
2001-04-16 18:51:52 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
return desiredSize.BSize(wm);
|
1999-02-22 06:28:00 +03:00
|
|
|
}
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nscoord
|
|
|
|
nsTableRowFrame::CollapseRowIfNecessary(nscoord aRowOffset,
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord aISize,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aCollapseGroup,
|
2015-06-20 23:00:26 +03:00
|
|
|
bool& aDidCollapse)
|
2006-03-04 08:26:57 +03:00
|
|
|
{
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleVisibility* rowVis = StyleVisibility();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool collapseRow = (NS_STYLE_VISIBILITY_COLLAPSE == rowVis->mVisible);
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame =
|
|
|
|
static_cast<nsTableFrame*>(GetTableFrame()->FirstInFlow());
|
2006-03-04 08:26:57 +03:00
|
|
|
if (collapseRow) {
|
2011-10-17 18:59:28 +04:00
|
|
|
tableFrame->SetNeedToCollapse(true);
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
|
|
|
|
2008-02-08 12:36:32 +03:00
|
|
|
if (aRowOffset != 0) {
|
|
|
|
// We're moving, so invalidate our old position
|
2010-08-31 04:49:12 +04:00
|
|
|
InvalidateFrameSubtree();
|
2008-02-08 12:36:32 +03:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize parentSize = GetParent()->GetSize();
|
|
|
|
LogicalRect rowRect = GetLogicalRect(wm, parentSize);
|
2015-06-20 23:00:26 +03:00
|
|
|
nsRect oldRect = mRect;
|
2012-08-29 09:48:45 +04:00
|
|
|
nsRect oldVisualOverflow = GetVisualOverflowRect();
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
rowRect.BStart(wm) -= aRowOffset;
|
|
|
|
rowRect.ISize(wm) = aISize;
|
2010-10-07 08:25:45 +04:00
|
|
|
nsOverflowAreas overflow;
|
2006-03-04 08:26:57 +03:00
|
|
|
nscoord shift = 0;
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize = mRect.Size();
|
2006-03-26 19:58:34 +04:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
if (aCollapseGroup || collapseRow) {
|
2011-10-17 18:59:28 +04:00
|
|
|
aDidCollapse = true;
|
2015-06-20 23:00:26 +03:00
|
|
|
shift = rowRect.BSize(wm);
|
2014-07-01 21:58:13 +04:00
|
|
|
nsTableCellFrame* cellFrame = GetFirstCell();
|
|
|
|
if (cellFrame) {
|
|
|
|
int32_t rowIndex;
|
|
|
|
cellFrame->GetRowIndex(rowIndex);
|
2015-03-20 07:16:00 +03:00
|
|
|
shift += tableFrame->GetRowSpacing(rowIndex);
|
2014-07-01 21:58:13 +04:00
|
|
|
while (cellFrame) {
|
2015-07-16 12:07:57 +03:00
|
|
|
LogicalRect cRect = cellFrame->GetLogicalRect(wm, containerSize);
|
2014-07-01 21:58:13 +04:00
|
|
|
// If aRowOffset != 0, there's no point in invalidating the cells, since
|
|
|
|
// we've already invalidated our overflow area. Note that we _do_ still
|
|
|
|
// need to invalidate if our row is not moving, because the cell might
|
|
|
|
// span out of this row, so invalidating our row rect won't do enough.
|
|
|
|
if (aRowOffset == 0) {
|
|
|
|
InvalidateFrame();
|
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
cRect.BSize(wm) = 0;
|
2015-07-16 12:07:57 +03:00
|
|
|
cellFrame->SetRect(wm, cRect, containerSize);
|
2014-07-01 21:58:13 +04:00
|
|
|
cellFrame = cellFrame->GetNextCell();
|
2008-02-08 12:36:32 +03:00
|
|
|
}
|
2014-07-01 21:58:13 +04:00
|
|
|
} else {
|
2015-03-20 07:16:00 +03:00
|
|
|
shift += tableFrame->GetRowSpacing(GetRowIndex());
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
rowRect.BSize(wm) = 0;
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
|
|
|
else { // row is not collapsed
|
|
|
|
// remember the col index of the previous cell to handle rowspans into this
|
|
|
|
// row
|
2015-06-23 21:45:17 +03:00
|
|
|
int32_t prevColIndex = -1;
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord iPos = 0; // running total of children inline-axis offset
|
2015-06-23 21:44:36 +03:00
|
|
|
nsTableFrame* fifTable =
|
|
|
|
static_cast<nsTableFrame*>(tableFrame->FirstInFlow());
|
2006-03-04 08:26:57 +03:00
|
|
|
|
2015-06-23 21:47:45 +03:00
|
|
|
for (nsIFrame* kidFrame : mFrames) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableCellFrame *cellFrame = do_QueryFrame(kidFrame);
|
|
|
|
if (cellFrame) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t cellColIndex;
|
2006-03-04 08:26:57 +03:00
|
|
|
cellFrame->GetColIndex(cellColIndex);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t cellColSpan = tableFrame->GetEffectiveColSpan(*cellFrame);
|
2006-03-04 08:26:57 +03:00
|
|
|
|
|
|
|
// If the adjacent cell is in a prior row (because of a rowspan) add in
|
|
|
|
// the space
|
2015-06-20 23:00:26 +03:00
|
|
|
if (prevColIndex != (cellColIndex - 1)) {
|
|
|
|
iPos += GetSpaceBetween(prevColIndex, cellColIndex, cellColSpan,
|
|
|
|
*tableFrame, true);
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalRect cRect(wm, iPos, 0, 0, rowRect.BSize(wm));
|
|
|
|
|
|
|
|
// remember the last (iend-wards-most) column this cell spans into
|
|
|
|
prevColIndex = cellColIndex + cellColSpan - 1;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t actualColSpan = cellColSpan;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isVisible = false;
|
2015-06-23 21:45:17 +03:00
|
|
|
for (int32_t colIdx = cellColIndex; actualColSpan > 0;
|
|
|
|
colIdx++, actualColSpan--) {
|
2006-03-04 08:26:57 +03:00
|
|
|
|
2015-06-23 21:45:17 +03:00
|
|
|
nsTableColFrame* colFrame = tableFrame->GetColFrame(colIdx);
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleVisibility* colVis = colFrame->StyleVisibility();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool collapseCol = (NS_STYLE_VISIBILITY_COLLAPSE ==
|
2006-03-04 08:26:57 +03:00
|
|
|
colVis->mVisible);
|
|
|
|
nsIFrame* cgFrame = colFrame->GetParent();
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleVisibility* groupVis = cgFrame->StyleVisibility();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE ==
|
2006-03-04 08:26:57 +03:00
|
|
|
groupVis->mVisible);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isCollapsed = collapseCol || collapseGroup;
|
2009-05-16 18:22:56 +04:00
|
|
|
if (!isCollapsed) {
|
2015-06-23 21:45:17 +03:00
|
|
|
cRect.ISize(wm) += fifTable->GetColumnISizeFromFirstInFlow(colIdx);
|
2011-10-17 18:59:28 +04:00
|
|
|
isVisible = true;
|
2009-05-16 18:22:56 +04:00
|
|
|
if ((actualColSpan > 1)) {
|
|
|
|
nsTableColFrame* nextColFrame =
|
2015-06-23 21:45:17 +03:00
|
|
|
tableFrame->GetColFrame(colIdx + 1);
|
2009-05-16 18:22:56 +04:00
|
|
|
const nsStyleVisibility* nextColVis =
|
2013-02-17 01:51:02 +04:00
|
|
|
nextColFrame->StyleVisibility();
|
2009-05-16 18:22:56 +04:00
|
|
|
if ( (NS_STYLE_VISIBILITY_COLLAPSE != nextColVis->mVisible) &&
|
2015-06-23 21:45:17 +03:00
|
|
|
tableFrame->ColumnHasCellSpacingBefore(colIdx + 1)) {
|
2015-06-20 23:00:26 +03:00
|
|
|
cRect.ISize(wm) += tableFrame->GetColSpacing(cellColIndex);
|
2009-05-16 18:22:56 +04:00
|
|
|
}
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
iPos += cRect.ISize(wm);
|
|
|
|
if (isVisible) {
|
|
|
|
iPos += tableFrame->GetColSpacing(cellColIndex);
|
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t actualRowSpan = tableFrame->GetEffectiveRowSpan(*cellFrame);
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableRowFrame* rowFrame = GetNextRow();
|
|
|
|
for (actualRowSpan--; actualRowSpan > 0 && rowFrame; actualRowSpan--) {
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleVisibility* nextRowVis = rowFrame->StyleVisibility();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool collapseNextRow = (NS_STYLE_VISIBILITY_COLLAPSE ==
|
2006-03-04 08:26:57 +03:00
|
|
|
nextRowVis->mVisible);
|
|
|
|
if (!collapseNextRow) {
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalRect nextRect = rowFrame->GetLogicalRect(wm,
|
2015-07-16 12:07:57 +03:00
|
|
|
containerSize);
|
2015-06-20 23:00:26 +03:00
|
|
|
cRect.BSize(wm) +=
|
|
|
|
nextRect.BSize(wm) +
|
|
|
|
tableFrame->GetRowSpacing(rowFrame->GetRowIndex());
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
|
|
|
rowFrame = rowFrame->GetNextRow();
|
|
|
|
}
|
2008-02-08 12:36:32 +03:00
|
|
|
|
|
|
|
nsRect oldCellRect = cellFrame->GetRect();
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalPoint oldCellNormalPos =
|
2015-07-16 12:07:57 +03:00
|
|
|
cellFrame->GetLogicalNormalPosition(wm, containerSize);
|
2015-06-20 23:00:26 +03:00
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
nsRect oldCellVisualOverflow = cellFrame->GetVisualOverflowRect();
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (aRowOffset == 0 && cRect.Origin(wm) != oldCellNormalPos) {
|
2008-02-08 12:36:32 +03:00
|
|
|
// We're moving the cell. Invalidate the old overflow area
|
2010-08-31 04:49:12 +04:00
|
|
|
cellFrame->InvalidateFrameSubtree();
|
2008-02-08 12:36:32 +03:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
cellFrame->MovePositionBy(wm, cRect.Origin(wm) - oldCellNormalPos);
|
|
|
|
cellFrame->SetSize(wm, cRect.Size(wm));
|
2008-02-08 12:36:32 +03:00
|
|
|
|
|
|
|
// XXXbz This looks completely bogus in the cases when we didn't
|
|
|
|
// collapse the cell!
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalRect cellBounds(wm, 0, 0, cRect.ISize(wm), cRect.BSize(wm));
|
|
|
|
nsRect cellPhysicalBounds =
|
2015-07-16 12:07:57 +03:00
|
|
|
cellBounds.GetPhysicalRect(wm, containerSize);
|
2015-06-20 23:00:26 +03:00
|
|
|
nsOverflowAreas cellOverflow(cellPhysicalBounds, cellPhysicalBounds);
|
|
|
|
cellFrame->FinishAndStoreOverflow(cellOverflow,
|
|
|
|
cRect.Size(wm).GetPhysicalSize(wm));
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame::RePositionViews(cellFrame);
|
2010-10-07 08:25:45 +04:00
|
|
|
ConsiderChildOverflow(overflow, cellFrame);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
if (aRowOffset == 0) {
|
|
|
|
nsTableFrame::InvalidateTableFrame(cellFrame, oldCellRect,
|
2015-06-20 23:00:26 +03:00
|
|
|
oldCellVisualOverflow, false);
|
2012-08-29 09:48:45 +04:00
|
|
|
}
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
SetRect(wm, rowRect, containerSize);
|
2015-06-20 23:00:26 +03:00
|
|
|
overflow.UnionAllWith(nsRect(0, 0, rowRect.Width(wm), rowRect.Height(wm)));
|
|
|
|
FinishAndStoreOverflow(overflow, rowRect.Size(wm).GetPhysicalSize(wm));
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame::RePositionViews(this);
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableFrame::InvalidateTableFrame(this, oldRect, oldVisualOverflow, false);
|
2006-03-04 08:26:57 +03:00
|
|
|
return shift;
|
|
|
|
}
|
|
|
|
|
2009-09-05 01:07:43 +04:00
|
|
|
/*
|
|
|
|
* The following method is called by the row group frame's SplitRowGroup()
|
|
|
|
* when it creates a continuing cell frame and wants to insert it into the
|
|
|
|
* row's child list.
|
1999-02-22 06:28:00 +03:00
|
|
|
*/
|
2015-04-17 21:42:05 +03:00
|
|
|
void
|
2001-04-16 18:51:52 +04:00
|
|
|
nsTableRowFrame::InsertCellFrame(nsTableCellFrame* aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aColIndex)
|
2001-04-16 18:51:52 +04:00
|
|
|
{
|
|
|
|
// Find the cell frame where col index < aColIndex
|
2012-07-30 18:20:58 +04:00
|
|
|
nsTableCellFrame* priorCell = nullptr;
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* child : mFrames) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableCellFrame *cellFrame = do_QueryFrame(child);
|
|
|
|
if (cellFrame) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex;
|
2001-04-16 18:51:52 +04:00
|
|
|
cellFrame->GetColIndex(colIndex);
|
|
|
|
if (colIndex < aColIndex) {
|
|
|
|
priorCell = cellFrame;
|
|
|
|
}
|
|
|
|
else break;
|
|
|
|
}
|
|
|
|
}
|
2009-09-05 01:07:43 +04:00
|
|
|
mFrames.InsertFrame(this, priorCell, aFrame);
|
1999-02-22 06:28:00 +03:00
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableRowFrame::GetType() const
|
1999-02-24 08:54:31 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::tableRowFrame;
|
1999-02-24 08:54:31 +03:00
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
nsTableRowFrame*
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableRowFrame::GetNextRow() const
|
|
|
|
{
|
2003-07-07 06:01:29 +04:00
|
|
|
nsIFrame* childFrame = GetNextSibling();
|
2001-11-05 03:15:51 +03:00
|
|
|
while (childFrame) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableRowFrame *rowFrame = do_QueryFrame(childFrame);
|
|
|
|
if (rowFrame) {
|
2013-02-17 01:51:02 +04:00
|
|
|
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_ROW == childFrame->StyleDisplay()->mDisplay, "wrong display type on rowframe");
|
2009-03-25 01:10:06 +03:00
|
|
|
return rowFrame;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2003-07-07 06:01:29 +04:00
|
|
|
childFrame = childFrame->GetNextSibling();
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
1999-02-24 08:54:31 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(RowUnpaginatedHeightProperty, nullptr)
|
2010-03-29 05:46:55 +04:00
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::SetUnpaginatedBSize(nsPresContext* aPresContext,
|
|
|
|
nscoord aValue)
|
2001-11-29 18:41:07 +03:00
|
|
|
{
|
2006-02-22 00:33:47 +03:00
|
|
|
NS_ASSERTION(!GetPrevInFlow(), "program error");
|
2010-03-29 05:46:55 +04:00
|
|
|
// Get the property
|
|
|
|
aPresContext->PropertyTable()->
|
|
|
|
Set(this, RowUnpaginatedHeightProperty(), NS_INT32_TO_PTR(aValue));
|
2001-11-29 18:41:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame::GetUnpaginatedBSize(nsPresContext* aPresContext)
|
2001-11-29 18:41:07 +03:00
|
|
|
{
|
2013-09-25 15:42:34 +04:00
|
|
|
FrameProperties props = FirstInFlow()->Properties();
|
2010-03-29 05:46:55 +04:00
|
|
|
return NS_PTR_TO_INT32(props.Get(RowUnpaginatedHeightProperty()));
|
2001-11-29 18:41:07 +03:00
|
|
|
}
|
|
|
|
|
2015-05-04 10:09:25 +03:00
|
|
|
void nsTableRowFrame::SetContinuousBCBorderWidth(LogicalSide aForSide,
|
2004-03-09 09:48:35 +03:00
|
|
|
BCPixelSize aPixelValue)
|
|
|
|
{
|
|
|
|
switch (aForSide) {
|
2015-05-04 10:09:25 +03:00
|
|
|
case eLogicalSideIEnd:
|
|
|
|
mIEndContBorderWidth = aPixelValue;
|
2004-03-09 09:48:35 +03:00
|
|
|
return;
|
2015-05-04 10:09:25 +03:00
|
|
|
case eLogicalSideBStart:
|
|
|
|
mBStartContBorderWidth = aPixelValue;
|
2004-03-09 09:48:35 +03:00
|
|
|
return;
|
2015-05-04 10:09:25 +03:00
|
|
|
case eLogicalSideIStart:
|
|
|
|
mIStartContBorderWidth = aPixelValue;
|
2004-03-09 09:48:35 +03:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_ERROR("invalid NS_SIDE arg");
|
|
|
|
}
|
|
|
|
}
|
2012-04-25 07:06:21 +04:00
|
|
|
#ifdef ACCESSIBILITY
|
2012-09-29 01:53:44 +04:00
|
|
|
a11y::AccType
|
|
|
|
nsTableRowFrame::AccessibleType()
|
2012-04-25 07:06:21 +04:00
|
|
|
{
|
2012-12-18 05:25:52 +04:00
|
|
|
return a11y::eHTMLTableRowType;
|
2012-04-25 07:06:21 +04:00
|
|
|
}
|
|
|
|
#endif
|
2007-06-26 00:34:35 +04:00
|
|
|
/**
|
2015-06-22 12:33:34 +03:00
|
|
|
* Sets the NS_ROW_HAS_CELL_WITH_STYLE_BSIZE bit to indicate whether
|
|
|
|
* this row has any cells that have non-auto-bsize. (Row-spanning
|
2007-06-26 00:34:35 +04:00
|
|
|
* cells are ignored.)
|
|
|
|
*/
|
2015-06-20 23:00:26 +03:00
|
|
|
void nsTableRowFrame::InitHasCellWithStyleBSize(nsTableFrame* aTableFrame)
|
2007-06-26 00:34:35 +04:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
2007-06-26 00:34:35 +04:00
|
|
|
|
2015-06-23 21:47:45 +03:00
|
|
|
for (nsIFrame* kidFrame : mFrames) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableCellFrame *cellFrame = do_QueryFrame(kidFrame);
|
|
|
|
if (!cellFrame) {
|
2007-06-26 00:34:35 +04:00
|
|
|
NS_NOTREACHED("Table row has a non-cell child.");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Ignore row-spanning cells
|
2015-06-20 23:00:26 +03:00
|
|
|
const nsStyleCoord &cellBSize = cellFrame->StylePosition()->BSize(wm);
|
2007-06-26 00:34:35 +04:00
|
|
|
if (aTableFrame->GetEffectiveRowSpan(*cellFrame) == 1 &&
|
2015-06-20 23:00:26 +03:00
|
|
|
cellBSize.GetUnit() != eStyleUnit_Auto &&
|
2012-11-21 20:19:30 +04:00
|
|
|
/* calc() with percentages treated like 'auto' */
|
2015-06-20 23:00:26 +03:00
|
|
|
(!cellBSize.IsCalcUnit() || !cellBSize.HasPercent())) {
|
2015-06-22 12:33:34 +03:00
|
|
|
AddStateBits(NS_ROW_HAS_CELL_WITH_STYLE_BSIZE);
|
2007-06-26 00:34:35 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-06-22 12:33:34 +03:00
|
|
|
RemoveStateBits(NS_ROW_HAS_CELL_WITH_STYLE_BSIZE);
|
2007-06-26 00:34:35 +04:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
|
|
|
void
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableRowFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
nsIFrame::InvalidateFrame(aDisplayItemKey);
|
|
|
|
GetParent()->InvalidateFrameWithRect(GetVisualOverflowRect() + GetPosition(), aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableRowFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey)
|
2012-08-29 09:39:31 +04:00
|
|
|
{
|
2012-08-29 09:48:45 +04:00
|
|
|
nsIFrame::InvalidateFrameWithRect(aRect, aDisplayItemKey);
|
|
|
|
// If we have filters applied that would affects our bounds, then
|
|
|
|
// we get an inactive layer created and this is computed
|
|
|
|
// within FrameLayerBuilder
|
|
|
|
GetParent()->InvalidateFrameWithRect(aRect + GetPosition(), aDisplayItemKey);
|
2012-08-29 09:39:31 +04:00
|
|
|
}
|
2007-06-26 00:34:35 +04:00
|
|
|
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
nsTableRowFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewTableRowFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsTableRowFrame(aContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableRowFrame)
|
|
|
|
|
2014-01-06 03:31:14 +04:00
|
|
|
#ifdef DEBUG_FRAME_DUMP
|
2014-02-18 11:47:48 +04:00
|
|
|
nsresult
|
2001-11-14 04:33:42 +03:00
|
|
|
nsTableRowFrame::GetFrameName(nsAString& aResult) const
|
1998-11-19 20:22:29 +03:00
|
|
|
{
|
2001-11-14 04:33:42 +03:00
|
|
|
return MakeFrameName(NS_LITERAL_STRING("TableRow"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|