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/. */
|
1999-02-12 20:45:58 +03:00
|
|
|
#include "nsCOMPtr.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableRowGroupFrame.h"
|
|
|
|
#include "nsTableRowFrame.h"
|
1998-11-11 22:56:02 +03:00
|
|
|
#include "nsTableFrame.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
#include "nsTableCellFrame.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"
|
|
|
|
#include "nsIContent.h"
|
2007-01-30 03:06:41 +03:00
|
|
|
#include "nsGkAtoms.h"
|
2006-12-26 20:47:52 +03:00
|
|
|
#include "nsIPresShell.h"
|
1999-06-08 01:10:25 +04:00
|
|
|
#include "nsCSSRendering.h"
|
1999-08-02 02:01:37 +04:00
|
|
|
#include "nsHTMLParts.h"
|
2004-01-22 02:05:10 +03:00
|
|
|
#include "nsCSSFrameConstructor.h"
|
2006-01-26 05:29:17 +03:00
|
|
|
#include "nsDisplayList.h"
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2000-05-11 05:04:39 +04:00
|
|
|
#include "nsCellMap.h"//table cell navigation
|
2013-01-15 16:22:03 +04:00
|
|
|
#include <algorithm>
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2010-03-29 05:46:55 +04:00
|
|
|
using namespace mozilla;
|
2013-04-01 19:26:02 +04:00
|
|
|
using namespace mozilla::layout;
|
2010-03-29 05:46:55 +04:00
|
|
|
|
2006-03-27 01:30:36 +04:00
|
|
|
nsTableRowGroupFrame::nsTableRowGroupFrame(nsStyleContext* aContext):
|
2011-12-28 00:18:48 +04:00
|
|
|
nsContainerFrame(aContext)
|
2001-01-25 18:55:51 +03:00
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
SetRepeatable(false);
|
2001-01-25 18:55:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowGroupFrame::~nsTableRowGroupFrame()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-03-11 02:41:17 +04:00
|
|
|
void
|
|
|
|
nsTableRowGroupFrame::DestroyFrom(nsIFrame* aDestructRoot)
|
|
|
|
{
|
|
|
|
if (GetStateBits() & NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN) {
|
|
|
|
nsTableFrame::UnregisterPositionedTablePart(this, aDestructRoot);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
|
|
|
}
|
|
|
|
|
2009-01-12 22:20:59 +03:00
|
|
|
NS_QUERYFRAME_HEAD(nsTableRowGroupFrame)
|
|
|
|
NS_QUERYFRAME_ENTRY(nsTableRowGroupFrame)
|
2011-12-28 00:18:48 +04:00
|
|
|
NS_QUERYFRAME_TAIL_INHERITING(nsContainerFrame)
|
1999-01-30 18:52:19 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowGroupFrame::GetRowCount()
|
2009-09-18 22:52:58 +04:00
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
|
2013-02-17 01:51:02 +04:00
|
|
|
NS_ASSERTION(e.get()->StyleDisplay()->mDisplay ==
|
2009-09-18 22:52:58 +04:00
|
|
|
NS_STYLE_DISPLAY_TABLE_ROW,
|
|
|
|
"Unexpected display");
|
|
|
|
NS_ASSERTION(e.get()->GetType() == nsGkAtoms::tableRowFrame,
|
|
|
|
"Unexpected frame type");
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
2009-09-18 22:52:58 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return mFrames.GetLength();
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t nsTableRowGroupFrame::GetStartRowIndex()
|
1998-12-23 18:47:43 +03:00
|
|
|
{
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t result = -1;
|
2009-09-18 22:52:58 +04:00
|
|
|
if (mFrames.NotEmpty()) {
|
|
|
|
NS_ASSERTION(mFrames.FirstChild()->GetType() == nsGkAtoms::tableRowFrame,
|
|
|
|
"Unexpected frame type");
|
|
|
|
result = static_cast<nsTableRowFrame*>(mFrames.FirstChild())->GetRowIndex();
|
1998-12-23 18:47:43 +03:00
|
|
|
}
|
2000-09-14 10:49:47 +04:00
|
|
|
// if the row group doesn't have any children, get it the hard way
|
|
|
|
if (-1 == result) {
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2012-01-17 03:38:10 +04:00
|
|
|
return tableFrame->GetStartRowIndex(this);
|
2000-09-14 10:49:47 +04:00
|
|
|
}
|
|
|
|
|
1998-12-23 18:47:43 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsTableRowGroupFrame::AdjustRowIndices(int32_t aRowIndex,
|
|
|
|
int32_t anAdjustment)
|
2006-08-04 23:15:50 +04:00
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
nsIFrame* rowFrame = GetFirstPrincipalChild();
|
2006-08-04 23:15:50 +04:00
|
|
|
for ( ; rowFrame; rowFrame = rowFrame->GetNextSibling()) {
|
2013-02-17 01:51:02 +04:00
|
|
|
if (NS_STYLE_DISPLAY_TABLE_ROW==rowFrame->StyleDisplay()->mDisplay) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = ((nsTableRowFrame*)rowFrame)->GetRowIndex();
|
2006-08-04 23:15:50 +04:00
|
|
|
if (index >= aRowIndex)
|
|
|
|
((nsTableRowFrame *)rowFrame)->SetRowIndex(index+anAdjustment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-03-03 19:33:57 +03:00
|
|
|
nsresult
|
2008-04-03 01:52:04 +04:00
|
|
|
nsTableRowGroupFrame::InitRepeatedFrame(nsPresContext* aPresContext,
|
2000-01-22 04:16:50 +03:00
|
|
|
nsTableRowGroupFrame* aHeaderFooterFrame)
|
1999-03-03 19:33:57 +03:00
|
|
|
{
|
2003-06-07 12:48:24 +04:00
|
|
|
nsTableRowFrame* copyRowFrame = GetFirstRow();
|
|
|
|
nsTableRowFrame* originalRowFrame = aHeaderFooterFrame->GetFirstRow();
|
2005-02-05 07:23:52 +03:00
|
|
|
AddStateBits(NS_REPEATED_ROW_OR_ROWGROUP);
|
2003-06-07 12:48:24 +04:00
|
|
|
while (copyRowFrame && originalRowFrame) {
|
2005-02-05 07:23:52 +03:00
|
|
|
copyRowFrame->AddStateBits(NS_REPEATED_ROW_OR_ROWGROUP);
|
2003-06-07 12:48:24 +04:00
|
|
|
int rowIndex = originalRowFrame->GetRowIndex();
|
|
|
|
copyRowFrame->SetRowIndex(rowIndex);
|
1999-03-03 19:33:57 +03:00
|
|
|
|
|
|
|
// For each table cell frame set its column index
|
2003-06-07 12:48:24 +04:00
|
|
|
nsTableCellFrame* originalCellFrame = originalRowFrame->GetFirstCell();
|
|
|
|
nsTableCellFrame* copyCellFrame = copyRowFrame->GetFirstCell();
|
|
|
|
while (copyCellFrame && originalCellFrame) {
|
2003-07-07 06:01:29 +04:00
|
|
|
NS_ASSERTION(originalCellFrame->GetContent() == copyCellFrame->GetContent(),
|
|
|
|
"cell frames have different content");
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex;
|
2003-06-07 12:48:24 +04:00
|
|
|
originalCellFrame->GetColIndex(colIndex);
|
2004-04-21 19:49:29 +04:00
|
|
|
copyCellFrame->SetColIndex(colIndex);
|
2003-06-07 12:48:24 +04:00
|
|
|
|
1999-03-03 19:33:57 +03:00
|
|
|
// Move to the next cell frame
|
2003-06-07 12:48:24 +04:00
|
|
|
copyCellFrame = copyCellFrame->GetNextCell();
|
|
|
|
originalCellFrame = originalCellFrame->GetNextCell();
|
1999-03-03 19:33:57 +03:00
|
|
|
}
|
2003-06-07 12:48:24 +04:00
|
|
|
|
1999-03-03 19:33:57 +03:00
|
|
|
// Move to the next row frame
|
2003-06-07 12:48:24 +04:00
|
|
|
originalRowFrame = originalRowFrame->GetNextRow();
|
|
|
|
copyRowFrame = copyRowFrame->GetNextRow();
|
1999-03-03 19:33:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
1998-10-22 09:27:11 +04:00
|
|
|
|
2008-04-06 15:34:14 +04: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.
|
|
|
|
*/
|
|
|
|
class nsDisplayTableRowGroupBackground : public nsDisplayTableItem {
|
|
|
|
public:
|
2010-08-13 14:01:13 +04:00
|
|
|
nsDisplayTableRowGroupBackground(nsDisplayListBuilder* aBuilder,
|
|
|
|
nsTableRowGroupFrame* aFrame) :
|
|
|
|
nsDisplayTableItem(aBuilder, aFrame) {
|
2008-04-06 15:34:14 +04:00
|
|
|
MOZ_COUNT_CTOR(nsDisplayTableRowGroupBackground);
|
|
|
|
}
|
|
|
|
#ifdef NS_BUILD_REFCNT_LOGGING
|
|
|
|
virtual ~nsDisplayTableRowGroupBackground() {
|
|
|
|
MOZ_COUNT_DTOR(nsDisplayTableRowGroupBackground);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-07 04:35:14 +04:00
|
|
|
virtual void Paint(nsDisplayListBuilder* aBuilder,
|
2014-02-24 18:41:56 +04:00
|
|
|
nsRenderingContext* aCtx) MOZ_OVERRIDE;
|
2008-04-06 15:34:14 +04:00
|
|
|
|
2010-07-16 01:07:49 +04:00
|
|
|
NS_DISPLAY_DECL_NAME("TableRowGroupBackground", TYPE_TABLE_ROW_GROUP_BACKGROUND)
|
2008-04-06 15:34:14 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
nsDisplayTableRowGroupBackground::Paint(nsDisplayListBuilder* aBuilder,
|
2012-01-17 03:38:10 +04:00
|
|
|
nsRenderingContext* aCtx)
|
|
|
|
{
|
2008-04-06 15:34:14 +04:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(mFrame);
|
2006-01-26 05:29:17 +03:00
|
|
|
TableBackgroundPainter painter(tableFrame,
|
|
|
|
TableBackgroundPainter::eOrigin_TableRowGroup,
|
2008-04-06 15:34:14 +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
|
|
|
|
|
|
|
DrawResult result =
|
|
|
|
painter.PaintRowGroup(static_cast<nsTableRowGroupFrame*>(mFrame));
|
|
|
|
|
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
|
|
|
|
2006-09-20 01:39:33 +04:00
|
|
|
// Handle the child-traversal part of DisplayGenericTablePart
|
2013-02-14 15:12:27 +04:00
|
|
|
static void
|
2006-09-20 01:39:33 +04:00
|
|
|
DisplayRows(nsDisplayListBuilder* aBuilder, nsFrame* aFrame,
|
|
|
|
const nsRect& aDirtyRect, const nsDisplayListSet& aLists)
|
|
|
|
{
|
|
|
|
nscoord overflowAbove;
|
2007-07-08 11:08:04 +04:00
|
|
|
nsTableRowGroupFrame* f = static_cast<nsTableRowGroupFrame*>(aFrame);
|
2006-09-20 01:39:33 +04:00
|
|
|
// Don't try to use the row cursor if we have to descend into placeholders;
|
|
|
|
// we might have rows containing placeholders, where the row's overflow
|
|
|
|
// area doesn't intersect the dirty rect but we need to descend into the row
|
2010-12-07 16:54:50 +03:00
|
|
|
// to see out of flows.
|
|
|
|
// Note that we really want to check ShouldDescendIntoFrame for all
|
|
|
|
// the rows in |f|, but that's exactly what we're trying to avoid, so we
|
|
|
|
// approximate it by checking it for |f|: if it's true for any row
|
|
|
|
// in |f| then it's true for |f| itself.
|
|
|
|
nsIFrame* kid = aBuilder->ShouldDescendIntoFrame(f) ?
|
2012-07-30 18:20:58 +04:00
|
|
|
nullptr : f->GetFirstRowContaining(aDirtyRect.y, &overflowAbove);
|
2006-09-20 01:39:33 +04:00
|
|
|
|
|
|
|
if (kid) {
|
|
|
|
// have a cursor, use it
|
|
|
|
while (kid) {
|
2014-08-20 05:24:58 +04:00
|
|
|
if (kid->GetRect().y - overflowAbove >= aDirtyRect.YMost() &&
|
|
|
|
kid->GetNormalRect().y - overflowAbove >= aDirtyRect.YMost())
|
2006-09-20 01:39:33 +04:00
|
|
|
break;
|
2013-02-14 15:08:08 +04:00
|
|
|
f->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
|
2006-09-20 01:39:33 +04:00
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2006-09-20 01:39:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// No cursor. Traverse children the hard way and build a cursor while we're at it
|
|
|
|
nsTableRowGroupFrame::FrameCursorData* cursor = f->SetupRowCursor();
|
2011-08-25 00:54:30 +04:00
|
|
|
kid = f->GetFirstPrincipalChild();
|
2006-09-20 01:39:33 +04:00
|
|
|
while (kid) {
|
2013-02-14 15:08:08 +04:00
|
|
|
f->BuildDisplayListForChild(aBuilder, kid, aDirtyRect, aLists);
|
2006-09-20 01:39:33 +04:00
|
|
|
|
|
|
|
if (cursor) {
|
|
|
|
if (!cursor->AppendFrame(kid)) {
|
|
|
|
f->ClearRowCursor();
|
2013-02-14 15:12:27 +04:00
|
|
|
return;
|
2006-09-20 01:39:33 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
kid = kid->GetNextSibling();
|
|
|
|
}
|
|
|
|
if (cursor) {
|
|
|
|
cursor->FinishBuildingCursor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-14 15:12:27 +04:00
|
|
|
void
|
2006-01-26 05:29:17 +03:00
|
|
|
nsTableRowGroupFrame::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.
|
|
|
|
item = new (aBuilder) nsDisplayTableRowGroupBackground(aBuilder, this);
|
2013-02-14 15:08:08 +04:00
|
|
|
aLists.BorderBackground()->AppendNewToTop(item);
|
2012-04-03 04:30:45 +04:00
|
|
|
}
|
|
|
|
}
|
2013-02-14 15:08:08 +04:00
|
|
|
nsTableFrame::DisplayGenericTablePart(aBuilder, this, aDirtyRect,
|
|
|
|
aLists, item, DisplayRows);
|
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
|
|
|
nsTableRowGroupFrame::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;
|
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Position and size aKidFrame and update our reflow state. The origin of
|
1999-01-05 03:41:40 +03:00
|
|
|
// aKidRect is relative to the upper-left origin of our frame
|
2001-03-13 09:38:59 +03:00
|
|
|
void
|
2008-04-03 01:52:04 +04:00
|
|
|
nsTableRowGroupFrame::PlaceChild(nsPresContext* aPresContext,
|
2004-03-09 09:48:35 +03:00
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame,
|
2014-08-20 05:24:58 +04:00
|
|
|
nsPoint aKidPosition,
|
2008-02-08 12:36:32 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
2008-03-16 23:32:48 +03:00
|
|
|
const nsRect& aOriginalKidRect,
|
2010-10-07 08:25:46 +04:00
|
|
|
const nsRect& aOriginalKidVisualOverflow)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2012-08-29 09:48:45 +04:00
|
|
|
bool isFirstReflow =
|
|
|
|
(aKidFrame->GetStateBits() & NS_FRAME_FIRST_REFLOW) != 0;
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Place and size the child
|
2014-08-20 05:24:58 +04:00
|
|
|
FinishReflowChild(aKidFrame, aPresContext, aDesiredSize, nullptr,
|
|
|
|
aKidPosition.x, aKidPosition.y, 0);
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableFrame::InvalidateTableFrame(aKidFrame, aOriginalKidRect,
|
|
|
|
aOriginalKidVisualOverflow, isFirstReflow);
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
// Adjust the running y-offset
|
2013-12-27 21:59:52 +04:00
|
|
|
aReflowState.y += aDesiredSize.Height();
|
1998-04-14 00:24:54 +04:00
|
|
|
|
|
|
|
// If our height is constrained then update the available height
|
2001-03-13 09:38:59 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height) {
|
2013-12-27 21:59:52 +04:00
|
|
|
aReflowState.availSize.height -= aDesiredSize.Height();
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
void
|
2008-04-03 01:52:04 +04:00
|
|
|
nsTableRowGroupFrame::InitChildReflowState(nsPresContext& aPresContext,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aBorderCollapse,
|
2002-02-19 18:48:28 +03:00
|
|
|
nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
nsMargin collapseBorder;
|
|
|
|
nsMargin padding(0,0,0,0);
|
2012-07-30 18:20:58 +04:00
|
|
|
nsMargin* pCollapseBorder = nullptr;
|
2002-02-19 18:48:28 +03:00
|
|
|
if (aBorderCollapse) {
|
2010-03-06 12:53:03 +03:00
|
|
|
nsTableRowFrame *rowFrame = do_QueryFrame(aReflowState.frame);
|
|
|
|
if (rowFrame) {
|
|
|
|
pCollapseBorder = rowFrame->GetBCBorderWidth(collapseBorder);
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
aReflowState.Init(&aPresContext, -1, -1, pCollapseBorder, &padding);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static void
|
2009-01-15 01:16:43 +03:00
|
|
|
CacheRowHeightsForPrinting(nsPresContext* aPresContext,
|
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
|
|
|
nsTableRowFrame* aFirstRow)
|
|
|
|
{
|
|
|
|
for (nsTableRowFrame* row = aFirstRow; row; row = row->GetNextRow()) {
|
|
|
|
if (!row->GetPrevInFlow()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
row->SetHasUnpaginatedHeight(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
|
|
|
row->SetUnpaginatedHeight(aPresContext, row->GetSize().height);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:53 +04:00
|
|
|
void
|
2008-04-03 01:52:04 +04:00
|
|
|
nsTableRowGroupFrame::ReflowChildren(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsRowGroupReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aPageBreakBeforeEnd)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2002-03-18 00:35:08 +03:00
|
|
|
if (aPageBreakBeforeEnd)
|
2011-10-17 18:59:28 +04:00
|
|
|
*aPageBreakBeforeEnd = false;
|
2002-03-18 00:35:08 +03:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2012-01-17 03:38:10 +04:00
|
|
|
const bool borderCollapse = tableFrame->IsBorderCollapse();
|
1999-06-23 07:02:21 +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
|
|
|
// XXXldb Should we really be checking this rather than available height?
|
|
|
|
// (Think about multi-column layout!)
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isPaginated = aPresContext->IsPaginated() &&
|
2010-05-13 18:15:49 +04:00
|
|
|
NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height;
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool haveRow = false;
|
|
|
|
bool reflowAllKids = aReflowState.reflowState.ShouldReflowAllKids() ||
|
2006-12-13 06:45:28 +03:00
|
|
|
tableFrame->IsGeometryDirty();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool needToCalcRowHeights = reflowAllKids;
|
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
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsIFrame *prevKidFrame = nullptr;
|
2009-09-18 15:09:35 +04:00
|
|
|
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame;
|
2008-04-17 22:18:41 +04:00
|
|
|
prevKidFrame = kidFrame, kidFrame = kidFrame->GetNextSibling()) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableRowFrame *rowFrame = do_QueryFrame(kidFrame);
|
|
|
|
if (!rowFrame) {
|
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");
|
|
|
|
continue;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2014-06-18 14:47:00 +04:00
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY(rowFrame->GetRowIndex());
|
2011-10-17 18:59:28 +04:00
|
|
|
haveRow = 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
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Reflow the row frame
|
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 (reflowAllKids ||
|
2007-05-06 23:16:51 +04:00
|
|
|
NS_SUBTREE_DIRTY(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
|
|
|
(aReflowState.reflowState.mFlags.mSpecialHeightReflow &&
|
|
|
|
(isPaginated || (kidFrame->GetStateBits() &
|
|
|
|
NS_FRAME_CONTAINS_RELATIVE_HEIGHT)))) {
|
2008-02-08 12:36:32 +03:00
|
|
|
nsRect oldKidRect = kidFrame->GetRect();
|
2010-10-07 08:25:46 +04:00
|
|
|
nsRect oldKidVisualOverflow = kidFrame->GetVisualOverflowRect();
|
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 We used to only pass aDesiredSize.mFlags through for the
|
|
|
|
// incremental reflow codepath.
|
2013-12-31 17:50:31 +04:00
|
|
|
nsHTMLReflowMetrics desiredSize(aReflowState.reflowState,
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.mFlags);
|
2014-07-24 12:30:07 +04:00
|
|
|
desiredSize.ClearSize();
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Reflow the child into the available space, giving it as much height as
|
1999-08-02 02:01:37 +04:00
|
|
|
// it wants. We'll deal with splitting later after we've computed the row
|
|
|
|
// heights, taking into account cells with row spans...
|
2014-07-24 12:28:46 +04:00
|
|
|
WritingMode wm = kidFrame->GetWritingMode();
|
|
|
|
LogicalSize kidAvailSize(wm, aReflowState.availSize);
|
|
|
|
kidAvailSize.BSize(wm) = NS_UNCONSTRAINEDSIZE;
|
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 kidReflowState(aPresContext, aReflowState.reflowState,
|
|
|
|
kidFrame, kidAvailSize,
|
2013-09-10 00:29:05 +04:00
|
|
|
-1, -1,
|
|
|
|
nsHTMLReflowState::CALLER_WILL_INIT);
|
2007-02-07 10:46:44 +03:00
|
|
|
InitChildReflowState(*aPresContext, 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
|
|
|
|
|
|
|
// This can indicate that columns were resized.
|
2014-11-28 12:44:02 +03:00
|
|
|
if (aReflowState.reflowState.IsHResize()) {
|
|
|
|
kidReflowState.SetHResize(true);
|
|
|
|
}
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2009-09-18 15:09:35 +04:00
|
|
|
NS_ASSERTION(kidFrame == mFrames.FirstChild() || prevKidFrame,
|
2008-04-17 22:18:41 +04:00
|
|
|
"If we're not on the first frame, we should have a "
|
|
|
|
"previous sibling...");
|
|
|
|
// If prev row has nonzero YMost, then we can't be at the top of the page
|
2014-08-20 05:24:58 +04:00
|
|
|
if (prevKidFrame && prevKidFrame->GetNormalRect().YMost() > 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
kidReflowState.mFlags.mIsTopOfPage = false;
|
1999-08-03 06:41:27 +04:00
|
|
|
}
|
|
|
|
|
2014-05-13 04:47:53 +04:00
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
|
|
|
0, aReflowState.y, 0, aStatus);
|
2014-08-20 05:24:58 +04:00
|
|
|
nsPoint kidPosition(0, aReflowState.y);
|
|
|
|
kidReflowState.ApplyRelativePositioning(&kidPosition);
|
2001-08-22 08:18:48 +04:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Place the child
|
2014-08-20 05:24:58 +04:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame, kidPosition,
|
|
|
|
desiredSize, oldKidRect, oldKidVisualOverflow);
|
2000-04-29 01:05:31 +04:00
|
|
|
aReflowState.y += cellSpacingY;
|
2001-08-22 08:18:48 +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
|
|
|
if (!reflowAllKids) {
|
|
|
|
if (IsSimpleRowFrame(aReflowState.tableFrame, kidFrame)) {
|
|
|
|
// Inform the row of its new height.
|
2009-03-25 01:10:06 +03:00
|
|
|
rowFrame->DidResize();
|
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 overflow area may have changed inflate the overflow area
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePosition *stylePos = StylePosition();
|
2008-09-20 13:30:30 +04:00
|
|
|
nsStyleUnit unit = stylePos->mHeight.GetUnit();
|
|
|
|
if (aReflowState.tableFrame->IsAutoHeight() &&
|
|
|
|
unit != eStyleUnit_Coord) {
|
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 other cells in the row may need to be aligned
|
|
|
|
// differently, repaint the entire row
|
2012-08-29 09:39:31 +04:00
|
|
|
InvalidateFrame();
|
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
|
|
|
}
|
2013-12-27 21:59:52 +04:00
|
|
|
else if (oldKidRect.height != desiredSize.Height())
|
2011-10-17 18:59:28 +04:00
|
|
|
needToCalcRowHeights = 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
|
|
|
} else {
|
2011-10-17 18:59:28 +04:00
|
|
|
needToCalcRowHeights = true;
|
2001-08-22 08:18:48 +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
|
|
|
|
|
|
|
if (isPaginated && aPageBreakBeforeEnd && !*aPageBreakBeforeEnd) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableRowFrame* nextRow = rowFrame->GetNextRow();
|
2002-03-18 00:35:08 +03:00
|
|
|
if (nextRow) {
|
2010-05-13 18:15:49 +04:00
|
|
|
*aPageBreakBeforeEnd = nsTableFrame::PageBreakAfter(kidFrame, nextRow);
|
2002-03-18 00:35:08 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-03 06:41:27 +04:00
|
|
|
} else {
|
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
|
|
|
SlideChild(aReflowState, kidFrame);
|
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// Adjust the running y-offset so we know where the next row should be placed
|
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 height = kidFrame->GetSize().height + cellSpacingY;
|
|
|
|
aReflowState.y += height;
|
1999-06-23 07:02:21 +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
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.height) {
|
|
|
|
aReflowState.availSize.height -= height;
|
2001-03-13 09:38:59 +03:00
|
|
|
}
|
|
|
|
}
|
2010-10-07 08:25:46 +04:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, kidFrame);
|
1998-04-14 00:24:54 +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
|
|
|
if (haveRow)
|
2014-06-18 14:47:00 +04:00
|
|
|
aReflowState.y -= tableFrame->GetCellSpacingY(GetStartRowIndex() +
|
|
|
|
GetRowCount());
|
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
|
|
|
|
|
|
|
// Return our desired rect
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() = aReflowState.reflowState.AvailableWidth();
|
|
|
|
aDesiredSize.Height() = aReflowState.y;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2002-03-31 21:44:57 +04:00
|
|
|
if (aReflowState.reflowState.mFlags.mSpecialHeightReflow) {
|
2007-01-28 01:22:24 +03:00
|
|
|
DidResizeRows(aDesiredSize);
|
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 (isPaginated) {
|
|
|
|
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
|
|
|
|
}
|
2002-03-31 21:44:57 +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
|
|
|
else if (needToCalcRowHeights) {
|
|
|
|
CalculateRowHeights(aPresContext, aDesiredSize, aReflowState.reflowState);
|
|
|
|
if (!reflowAllKids) {
|
2012-08-29 09:39:31 +04:00
|
|
|
InvalidateFrame();
|
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-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableRowFrame*
|
|
|
|
nsTableRowGroupFrame::GetFirstRow()
|
1999-03-17 02:42:38 +03:00
|
|
|
{
|
2009-09-18 15:09:35 +04:00
|
|
|
for (nsIFrame* childFrame = mFrames.FirstChild(); childFrame;
|
2003-07-07 06:01:29 +04:00
|
|
|
childFrame = childFrame->GetNextSibling()) {
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableRowFrame *rowFrame = do_QueryFrame(childFrame);
|
|
|
|
if (rowFrame) {
|
|
|
|
return rowFrame;
|
1999-03-17 02:42:38 +03:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct RowInfo {
|
2001-11-14 16:44:38 +03:00
|
|
|
RowInfo() { height = pctHeight = hasStyleHeight = hasPctHeight = isSpecial = 0; }
|
|
|
|
unsigned height; // content height or fixed height, excluding pct height
|
|
|
|
unsigned pctHeight:29; // pct height
|
2001-11-05 03:15:51 +03:00
|
|
|
unsigned hasStyleHeight:1;
|
2001-11-14 16:44:38 +03:00
|
|
|
unsigned hasPctHeight:1;
|
2001-11-05 03:15:51 +03:00
|
|
|
unsigned isSpecial:1; // there is no cell originating in the row with rowspan=1 and there are at
|
|
|
|
// least 2 cells spanning the row and there is no style height on the row
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
UpdateHeights(RowInfo& aRowInfo,
|
|
|
|
nscoord aAdditionalHeight,
|
|
|
|
nscoord& aTotal,
|
|
|
|
nscoord& aUnconstrainedTotal)
|
|
|
|
{
|
|
|
|
aRowInfo.height += aAdditionalHeight;
|
|
|
|
aTotal += aAdditionalHeight;
|
|
|
|
if (!aRowInfo.hasStyleHeight) {
|
|
|
|
aUnconstrainedTotal += aAdditionalHeight;
|
1999-03-17 02:42:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-03 17:04:49 +03:00
|
|
|
void
|
2007-01-28 01:22:24 +03:00
|
|
|
nsTableRowGroupFrame::DidResizeRows(nsHTMLReflowMetrics& aDesiredSize)
|
2000-02-03 17:04:49 +03:00
|
|
|
{
|
2001-11-05 03:15:51 +03:00
|
|
|
// update the cells spanning rows with their new heights
|
|
|
|
// this is the place where all of the cells in the row get set to the height of the row
|
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
|
|
|
// Reset the overflow area
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.mOverflowAreas.Clear();
|
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
|
|
|
for (nsTableRowFrame* rowFrame = GetFirstRow();
|
|
|
|
rowFrame; rowFrame = rowFrame->GetNextRow()) {
|
2007-01-28 01:22:24 +03:00
|
|
|
rowFrame->DidResize();
|
2010-10-07 08:25:46 +04:00
|
|
|
ConsiderChildOverflow(aDesiredSize.mOverflowAreas, rowFrame);
|
2000-02-03 17:04:49 +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
|
|
|
// This calculates the height of all the rows and takes into account
|
2001-11-05 03:15:51 +03:00
|
|
|
// style height on the row group, style heights on rows and cells, style heights on rowspans.
|
|
|
|
// Actual row heights will be adjusted later if the table has a style height.
|
|
|
|
// Even if rows don't change height, this method must be called to set the heights of each
|
|
|
|
// cell in the row to the height of its row.
|
2001-03-13 09:38:59 +03:00
|
|
|
void
|
2008-04-03 01:52:04 +04:00
|
|
|
nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
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
|
|
|
const nsHTMLReflowState& aReflowState)
|
1998-06-30 06:11:07 +04:00
|
|
|
{
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2012-01-17 03:38:10 +04:00
|
|
|
const bool isPaginated = aPresContext->IsPaginated();
|
2002-03-27 08:50:24 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t numEffCols = tableFrame->GetEffectiveColCount();
|
1999-05-27 02:22:23 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t startRowIndex = GetStartRowIndex();
|
2002-06-14 18:17:01 +04:00
|
|
|
// find the row corresponding to the row index we just found
|
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
|
|
|
nsTableRowFrame* startRowFrame = GetFirstRow();
|
|
|
|
|
2001-08-22 08:18:48 +04:00
|
|
|
if (!startRowFrame) return;
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
// the current row group height is the y origin of the 1st row we are about to calculated a height for
|
2014-08-20 05:24:58 +04:00
|
|
|
nscoord startRowGroupHeight = startRowFrame->GetNormalPosition().y;
|
2001-08-22 08:18:48 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t numRows = GetRowCount() - (startRowFrame->GetRowIndex() - GetStartRowIndex());
|
2012-07-30 18:20:58 +04:00
|
|
|
// collect the current height of each row. nscoord* rowHeights = nullptr;
|
2007-02-21 22:42:21 +03:00
|
|
|
if (numRows <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
nsTArray<RowInfo> rowInfo;
|
|
|
|
if (!rowInfo.AppendElements(numRows)) {
|
|
|
|
return;
|
|
|
|
}
|
2001-08-08 05:13:35 +04:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool hasRowSpanningCell = false;
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord heightOfRows = 0;
|
|
|
|
nscoord heightOfUnStyledRows = 0;
|
|
|
|
// Get the height of each row without considering rowspans. This will be the max of
|
|
|
|
// the largest desired height of each cell, the largest style height of each cell,
|
|
|
|
// the style height of the row.
|
|
|
|
nscoord pctHeightBasis = GetHeightBasis(aReflowState);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowIndex; // the index in rowInfo, not among the rows in the row group
|
2001-11-14 16:44:38 +03:00
|
|
|
nsTableRowFrame* rowFrame;
|
2001-11-05 03:15:51 +03:00
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
2002-03-27 08:50:24 +03:00
|
|
|
nscoord nonPctHeight = rowFrame->GetContentHeight();
|
|
|
|
if (isPaginated) {
|
2013-01-15 16:22:03 +04:00
|
|
|
nonPctHeight = std::max(nonPctHeight, rowFrame->GetSize().height);
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
if (!rowFrame->GetPrevInFlow()) {
|
|
|
|
if (rowFrame->HasPctHeight()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
rowInfo[rowIndex].hasPctHeight = true;
|
2007-02-22 23:22:12 +03:00
|
|
|
rowInfo[rowIndex].pctHeight = rowFrame->GetHeight(pctHeightBasis);
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
rowInfo[rowIndex].hasStyleHeight = rowFrame->HasStyleHeight();
|
2013-01-15 16:22:03 +04:00
|
|
|
nonPctHeight = std::max(nonPctHeight, rowFrame->GetFixedHeight());
|
2001-11-14 16:44:38 +03:00
|
|
|
}
|
|
|
|
UpdateHeights(rowInfo[rowIndex], nonPctHeight, heightOfRows, heightOfUnStyledRows);
|
2001-11-05 03:15:51 +03:00
|
|
|
|
|
|
|
if (!rowInfo[rowIndex].hasStyleHeight) {
|
2004-04-13 10:21:16 +04:00
|
|
|
if (isPaginated || tableFrame->HasMoreThanOneCell(rowIndex + startRowIndex)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
rowInfo[rowIndex].isSpecial = true;
|
2001-11-05 03:15:51 +03:00
|
|
|
// iteratate the row's cell frames to see if any do not have rowspan > 1
|
|
|
|
nsTableCellFrame* cellFrame = rowFrame->GetFirstCell();
|
|
|
|
while (cellFrame) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowSpan = tableFrame->GetEffectiveRowSpan(rowIndex + startRowIndex, *cellFrame);
|
2001-11-05 03:15:51 +03:00
|
|
|
if (1 == rowSpan) {
|
2011-10-17 18:59:28 +04:00
|
|
|
rowInfo[rowIndex].isSpecial = false;
|
2001-11-05 03:15:51 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
cellFrame = cellFrame->GetNextCell();
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
// See if a cell spans into the row. If so we'll have to do the next step
|
|
|
|
if (!hasRowSpanningCell) {
|
2005-11-04 21:41:32 +03:00
|
|
|
if (tableFrame->RowIsSpannedInto(rowIndex + startRowIndex, numEffCols)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
hasRowSpanningCell = true;
|
2000-02-03 17:04:49 +03:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
1999-05-27 02:22:23 +04:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
if (hasRowSpanningCell) {
|
|
|
|
// Get the height of cells with rowspans and allocate any extra space to the rows they span
|
|
|
|
// iteratate the child frames and process the row frames among them
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
2002-03-27 08:50:24 +03:00
|
|
|
// See if the row has an originating cell with rowspan > 1. We cannot determine this for a row in a
|
|
|
|
// continued row group by calling RowHasSpanningCells, because the row's fif may not have any originating
|
|
|
|
// cells yet the row may have a continued cell which originates in it.
|
2006-02-22 00:33:47 +03:00
|
|
|
if (GetPrevInFlow() || tableFrame->RowHasSpanningCells(startRowIndex + rowIndex, numEffCols)) {
|
2001-11-05 03:15:51 +03:00
|
|
|
nsTableCellFrame* cellFrame = rowFrame->GetFirstCell();
|
|
|
|
// iteratate the row's cell frames
|
|
|
|
while (cellFrame) {
|
2014-06-18 14:47:00 +04:00
|
|
|
nscoord cellSpacingY = tableFrame->GetCellSpacingY(startRowIndex + rowIndex);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowSpan = tableFrame->GetEffectiveRowSpan(rowIndex + startRowIndex, *cellFrame);
|
2007-02-21 22:42:21 +03:00
|
|
|
if ((rowIndex + rowSpan) > numRows) {
|
|
|
|
// there might be rows pushed already to the nextInFlow
|
|
|
|
rowSpan = numRows - rowIndex;
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
if (rowSpan > 1) { // a cell with rowspan > 1, determine the height of the rows it spans
|
|
|
|
nscoord heightOfRowsSpanned = 0;
|
|
|
|
nscoord heightOfUnStyledRowsSpanned = 0;
|
|
|
|
nscoord numSpecialRowsSpanned = 0;
|
|
|
|
nscoord cellSpacingTotal = 0;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t spanX;
|
2001-11-05 03:15:51 +03:00
|
|
|
for (spanX = 0; spanX < rowSpan; spanX++) {
|
|
|
|
heightOfRowsSpanned += rowInfo[rowIndex + spanX].height;
|
|
|
|
if (!rowInfo[rowIndex + spanX].hasStyleHeight) {
|
|
|
|
heightOfUnStyledRowsSpanned += rowInfo[rowIndex + spanX].height;
|
|
|
|
}
|
|
|
|
if (0 != spanX) {
|
|
|
|
cellSpacingTotal += cellSpacingY;
|
|
|
|
}
|
|
|
|
if (rowInfo[rowIndex + spanX].isSpecial) {
|
|
|
|
numSpecialRowsSpanned++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nscoord heightOfAreaSpanned = heightOfRowsSpanned + cellSpacingTotal;
|
|
|
|
// get the height of the cell
|
2003-07-07 06:01:29 +04:00
|
|
|
nsSize cellFrameSize = cellFrame->GetSize();
|
2014-07-24 12:30:07 +04:00
|
|
|
nsSize cellDesSize =
|
|
|
|
cellFrame->GetDesiredSize().GetPhysicalSize(cellFrame->GetWritingMode());
|
2010-03-06 12:53:02 +03:00
|
|
|
rowFrame->CalculateCellActualHeight(cellFrame, cellDesSize.height);
|
2001-11-05 03:15:51 +03:00
|
|
|
cellFrameSize.height = cellDesSize.height;
|
|
|
|
if (cellFrame->HasVerticalAlignBaseline()) {
|
|
|
|
// to ensure that a spanning cell with a long descender doesn't
|
|
|
|
// collide with the next row, we need to take into account the shift
|
|
|
|
// that will be done to align the cell on the baseline of the row.
|
2007-01-23 07:06:56 +03:00
|
|
|
cellFrameSize.height += rowFrame->GetMaxCellAscent() -
|
|
|
|
cellFrame->GetCellBaseline();
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
if (heightOfAreaSpanned < cellFrameSize.height) {
|
|
|
|
// the cell's height is larger than the available space of the rows it
|
|
|
|
// spans so distribute the excess height to the rows affected
|
|
|
|
nscoord extra = cellFrameSize.height - heightOfAreaSpanned;
|
|
|
|
nscoord extraUsed = 0;
|
|
|
|
if (0 == numSpecialRowsSpanned) {
|
|
|
|
//NS_ASSERTION(heightOfRowsSpanned > 0, "invalid row span situation");
|
2011-09-29 10:19:26 +04:00
|
|
|
bool haveUnStyledRowsSpanned = (heightOfUnStyledRowsSpanned > 0);
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord divisor = (haveUnStyledRowsSpanned)
|
|
|
|
? heightOfUnStyledRowsSpanned : heightOfRowsSpanned;
|
|
|
|
if (divisor > 0) {
|
|
|
|
for (spanX = rowSpan - 1; spanX >= 0; spanX--) {
|
|
|
|
if (!haveUnStyledRowsSpanned || !rowInfo[rowIndex + spanX].hasStyleHeight) {
|
|
|
|
// The amount of additional space each row gets is proportional to its height
|
|
|
|
float percent = ((float)rowInfo[rowIndex + spanX].height) / ((float)divisor);
|
1999-08-21 03:27:39 +04:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
// give rows their percentage, except for the first row which gets the remainder
|
|
|
|
nscoord extraForRow = (0 == spanX) ? extra - extraUsed
|
|
|
|
: NSToCoordRound(((float)(extra)) * percent);
|
2013-01-15 16:22:03 +04:00
|
|
|
extraForRow = std::min(extraForRow, extra - extraUsed);
|
2000-02-03 17:04:49 +03:00
|
|
|
// update the row height
|
2001-11-05 03:15:51 +03:00
|
|
|
UpdateHeights(rowInfo[rowIndex + spanX], extraForRow, heightOfRows, heightOfUnStyledRows);
|
|
|
|
extraUsed += extraForRow;
|
|
|
|
if (extraUsed >= extra) {
|
|
|
|
NS_ASSERTION((extraUsed == extra), "invalid row height calculation");
|
|
|
|
break;
|
|
|
|
}
|
2000-02-03 17:04:49 +03:00
|
|
|
}
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// put everything in the last row
|
|
|
|
UpdateHeights(rowInfo[rowIndex + rowSpan - 1], extra, heightOfRows, heightOfUnStyledRows);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// give the extra to the special rows
|
|
|
|
nscoord numSpecialRowsAllocated = 0;
|
|
|
|
for (spanX = rowSpan - 1; spanX >= 0; spanX--) {
|
|
|
|
if (rowInfo[rowIndex + spanX].isSpecial) {
|
|
|
|
// The amount of additional space each degenerate row gets is proportional to the number of them
|
|
|
|
float percent = 1.0f / ((float)numSpecialRowsSpanned);
|
|
|
|
|
|
|
|
// give rows their percentage, except for the first row which gets the remainder
|
|
|
|
nscoord extraForRow = (numSpecialRowsSpanned - 1 == numSpecialRowsAllocated)
|
|
|
|
? extra - extraUsed
|
|
|
|
: NSToCoordRound(((float)(extra)) * percent);
|
2013-01-15 16:22:03 +04:00
|
|
|
extraForRow = std::min(extraForRow, extra - extraUsed);
|
2001-11-05 03:15:51 +03:00
|
|
|
// update the row height
|
|
|
|
UpdateHeights(rowInfo[rowIndex + spanX], extraForRow, heightOfRows, heightOfUnStyledRows);
|
|
|
|
extraUsed += extraForRow;
|
|
|
|
if (extraUsed >= extra) {
|
|
|
|
NS_ASSERTION((extraUsed == extra), "invalid row height calculation");
|
|
|
|
break;
|
2000-02-04 05:49:27 +03:00
|
|
|
}
|
|
|
|
}
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
} // if (rowSpan > 1)
|
|
|
|
cellFrame = cellFrame->GetNextCell();
|
|
|
|
} // while (cellFrame)
|
|
|
|
} // if (tableFrame->RowHasSpanningCells(startRowIndex + rowIndex) {
|
|
|
|
} // while (rowFrame)
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2001-11-14 16:44:38 +03:00
|
|
|
// pct height rows have already got their content heights. Give them their pct heights up to pctHeightBasis
|
|
|
|
nscoord extra = pctHeightBasis - heightOfRows;
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame && (extra > 0); rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
|
|
|
RowInfo& rInfo = rowInfo[rowIndex];
|
|
|
|
if (rInfo.hasPctHeight) {
|
2002-12-13 18:21:38 +03:00
|
|
|
nscoord rowExtra = (rInfo.pctHeight > rInfo.height)
|
|
|
|
? rInfo.pctHeight - rInfo.height: 0;
|
2013-01-15 16:22:03 +04:00
|
|
|
rowExtra = std::min(rowExtra, extra);
|
2001-11-14 16:44:38 +03:00
|
|
|
UpdateHeights(rInfo, rowExtra, heightOfRows, heightOfUnStyledRows);
|
|
|
|
extra -= rowExtra;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool styleHeightAllocation = false;
|
2014-06-18 14:47:00 +04:00
|
|
|
nscoord rowGroupHeight = startRowGroupHeight + heightOfRows +
|
|
|
|
tableFrame->GetCellSpacingY(0, numRows-1);
|
2001-11-05 03:15:51 +03:00
|
|
|
// if we have a style height, allocate the extra height to unconstrained rows
|
2007-08-02 22:08:05 +04:00
|
|
|
if ((aReflowState.ComputedHeight() > rowGroupHeight) &&
|
|
|
|
(NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight())) {
|
|
|
|
nscoord extraComputedHeight = aReflowState.ComputedHeight() - rowGroupHeight;
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord extraUsed = 0;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool haveUnStyledRows = (heightOfUnStyledRows > 0);
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord divisor = (haveUnStyledRows)
|
|
|
|
? heightOfUnStyledRows : heightOfRows;
|
|
|
|
if (divisor > 0) {
|
2011-10-17 18:59:28 +04:00
|
|
|
styleHeightAllocation = true;
|
2001-11-05 03:15:51 +03:00
|
|
|
for (rowIndex = 0; rowIndex < numRows; rowIndex++) {
|
|
|
|
if (!haveUnStyledRows || !rowInfo[rowIndex].hasStyleHeight) {
|
|
|
|
// The amount of additional space each row gets is based on the
|
|
|
|
// percentage of space it occupies
|
|
|
|
float percent = ((float)rowInfo[rowIndex].height) / ((float)divisor);
|
|
|
|
// give rows their percentage, except for the last row which gets the remainder
|
|
|
|
nscoord extraForRow = (numRows - 1 == rowIndex)
|
|
|
|
? extraComputedHeight - extraUsed
|
|
|
|
: NSToCoordRound(((float)extraComputedHeight) * percent);
|
2013-01-15 16:22:03 +04:00
|
|
|
extraForRow = std::min(extraForRow, extraComputedHeight - extraUsed);
|
2001-11-05 03:15:51 +03:00
|
|
|
// update the row height
|
|
|
|
UpdateHeights(rowInfo[rowIndex], extraForRow, heightOfRows, heightOfUnStyledRows);
|
|
|
|
extraUsed += extraForRow;
|
|
|
|
if (extraUsed >= extraComputedHeight) {
|
|
|
|
NS_ASSERTION((extraUsed == extraComputedHeight), "invalid row height calculation");
|
|
|
|
break;
|
1999-08-21 03:27:39 +04:00
|
|
|
}
|
1999-08-19 07:51:25 +04:00
|
|
|
}
|
1999-06-23 07:02:21 +04:00
|
|
|
}
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
2007-08-02 22:08:05 +04:00
|
|
|
rowGroupHeight = aReflowState.ComputedHeight();
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord yOrigin = startRowGroupHeight;
|
|
|
|
// update the rows with their (potentially) new heights
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
2008-03-16 23:32:48 +03:00
|
|
|
nsRect rowBounds = rowFrame->GetRect();
|
2012-08-29 09:48:45 +04:00
|
|
|
nsRect rowVisualOverflow = rowFrame->GetVisualOverflowRect();
|
2014-08-20 05:24:58 +04:00
|
|
|
nscoord deltaY = yOrigin - rowFrame->GetNormalPosition().y;
|
2001-11-05 03:15:51 +03:00
|
|
|
|
|
|
|
nscoord rowHeight = (rowInfo[rowIndex].height > 0) ? rowInfo[rowIndex].height : 0;
|
|
|
|
|
2014-08-20 05:24:58 +04:00
|
|
|
if (deltaY != 0 || (rowHeight != rowBounds.height)) {
|
2008-02-08 12:36:32 +03:00
|
|
|
// Resize/move the row to its final size and position
|
2014-08-20 05:24:58 +04:00
|
|
|
if (deltaY != 0) {
|
2010-08-31 04:49:12 +04:00
|
|
|
rowFrame->InvalidateFrameSubtree();
|
2008-02-08 12:36:32 +03:00
|
|
|
}
|
|
|
|
|
2014-08-20 05:24:58 +04:00
|
|
|
rowFrame->MovePositionBy(nsPoint(0, deltaY));
|
|
|
|
rowFrame->SetSize(nsSize(rowBounds.width, rowHeight));
|
2012-08-29 09:48:45 +04:00
|
|
|
|
|
|
|
nsTableFrame::InvalidateTableFrame(rowFrame, rowBounds, rowVisualOverflow,
|
|
|
|
false);
|
2014-08-20 05:24:58 +04:00
|
|
|
|
|
|
|
if (deltaY != 0) {
|
|
|
|
nsTableFrame::RePositionViews(rowFrame);
|
|
|
|
// XXXbz we don't need to update our overflow area?
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2014-06-18 14:47:00 +04:00
|
|
|
yOrigin += rowHeight + tableFrame->GetCellSpacingY(startRowIndex + rowIndex);
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
|
|
|
|
2002-03-27 08:50:24 +03:00
|
|
|
if (isPaginated && styleHeightAllocation) {
|
|
|
|
// since the row group has a style height, cache the row heights, so next in flows can honor them
|
|
|
|
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
|
|
|
|
}
|
|
|
|
|
2007-01-28 01:22:24 +03:00
|
|
|
DidResizeRows(aDesiredSize);
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() = rowGroupHeight; // Adjust our desired size
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nscoord
|
|
|
|
nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aYTotalOffset,
|
|
|
|
nscoord aWidth)
|
|
|
|
{
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleVisibility* groupVis = StyleVisibility();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
|
2006-03-04 08:26:57 +03:00
|
|
|
if (collapseGroup) {
|
2011-10-17 18:59:28 +04:00
|
|
|
tableFrame->SetNeedToCollapse(true);
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
|
|
|
|
2010-10-07 08:25:45 +04:00
|
|
|
nsOverflowAreas overflow;
|
2006-03-04 08:26:57 +03:00
|
|
|
|
|
|
|
nsTableRowFrame* rowFrame= GetFirstRow();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool didCollapse = false;
|
2006-03-04 08:26:57 +03:00
|
|
|
nscoord yGroupOffset = 0;
|
|
|
|
while (rowFrame) {
|
|
|
|
yGroupOffset += rowFrame->CollapseRowIfNecessary(yGroupOffset,
|
|
|
|
aWidth, collapseGroup,
|
|
|
|
didCollapse);
|
2010-10-07 08:25:45 +04:00
|
|
|
ConsiderChildOverflow(overflow, rowFrame);
|
2006-03-04 08:26:57 +03:00
|
|
|
rowFrame = rowFrame->GetNextRow();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRect groupRect = GetRect();
|
2012-08-29 09:48:45 +04:00
|
|
|
nsRect oldGroupRect = groupRect;
|
|
|
|
nsRect oldGroupVisualOverflow = GetVisualOverflowRect();
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
groupRect.height -= yGroupOffset;
|
|
|
|
if (didCollapse) {
|
|
|
|
// add back the cellspacing between rowgroups
|
2014-06-18 14:47:00 +04:00
|
|
|
groupRect.height += tableFrame->GetCellSpacingY(GetStartRowIndex() +
|
|
|
|
GetRowCount());
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
groupRect.y -= aYTotalOffset;
|
|
|
|
groupRect.width = aWidth;
|
2008-02-08 12:36:32 +03:00
|
|
|
|
|
|
|
if (aYTotalOffset != 0) {
|
2010-08-31 04:49:12 +04:00
|
|
|
InvalidateFrameSubtree();
|
2008-02-08 12:36:32 +03:00
|
|
|
}
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
SetRect(groupRect);
|
2010-10-07 08:25:45 +04:00
|
|
|
overflow.UnionAllWith(nsRect(0, 0, groupRect.width, groupRect.height));
|
2013-08-14 16:27:20 +04:00
|
|
|
FinishAndStoreOverflow(overflow, groupRect.Size());
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame::RePositionViews(this);
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableFrame::InvalidateTableFrame(this, oldGroupRect, oldGroupVisualOverflow,
|
|
|
|
false);
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
return yGroupOffset;
|
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2008-08-24 12:06:57 +04:00
|
|
|
// Move a child that was skipped during a reflow.
|
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
|
|
|
void
|
|
|
|
nsTableRowGroupFrame::SlideChild(nsRowGroupReflowState& aReflowState,
|
|
|
|
nsIFrame* aKidFrame)
|
1998-07-03 03:19:31 +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
|
|
|
// Move the frame if we need to
|
2014-08-20 05:24:58 +04:00
|
|
|
nsPoint oldPosition = aKidFrame->GetNormalPosition();
|
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
|
|
|
nsPoint newPosition = oldPosition;
|
|
|
|
newPosition.y = aReflowState.y;
|
|
|
|
if (oldPosition.y != newPosition.y) {
|
2010-08-31 04:49:12 +04:00
|
|
|
aKidFrame->InvalidateFrameSubtree();
|
2014-08-20 05:24:58 +04:00
|
|
|
aReflowState.reflowState.ApplyRelativePositioning(&newPosition);
|
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
|
|
|
aKidFrame->SetPosition(newPosition);
|
|
|
|
nsTableFrame::RePositionViews(aKidFrame);
|
2010-08-31 04:49:12 +04:00
|
|
|
aKidFrame->InvalidateFrameSubtree();
|
1998-07-03 03:19:31 +04:00
|
|
|
}
|
|
|
|
}
|
1998-04-17 02:21:32 +04:00
|
|
|
|
2001-04-16 18:51:52 +04:00
|
|
|
// Create a continuing frame, add it to the child list, and then push it
|
|
|
|
// and the frames that follow
|
|
|
|
void
|
2004-08-01 03:15:21 +04:00
|
|
|
nsTableRowGroupFrame::CreateContinuingRowFrame(nsPresContext& aPresContext,
|
2008-04-03 01:52:04 +04:00
|
|
|
nsIFrame& aRowFrame,
|
|
|
|
nsIFrame** aContRowFrame)
|
2001-04-16 18:51:52 +04:00
|
|
|
{
|
2002-03-27 08:50:24 +03:00
|
|
|
// XXX what is the row index?
|
2011-10-17 18:59:28 +04:00
|
|
|
if (!aContRowFrame) {NS_ASSERTION(false, "bad call"); return;}
|
2001-04-16 18:51:52 +04:00
|
|
|
// create the continuing frame which will create continuing cell frames
|
2013-03-20 05:47:49 +04:00
|
|
|
*aContRowFrame = aPresContext.PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(&aPresContext, &aRowFrame, this);
|
2001-04-16 18:51:52 +04:00
|
|
|
|
|
|
|
// Add the continuing row frame to the child list
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.InsertFrame(nullptr, &aRowFrame, *aContRowFrame);
|
2009-09-18 15:09:35 +04:00
|
|
|
|
2001-04-16 18:51:52 +04:00
|
|
|
// Push the continuing row frame and the frames that follow
|
2014-02-07 02:07:47 +04:00
|
|
|
PushChildren(*aContRowFrame, &aRowFrame);
|
2001-04-16 18:51:52 +04:00
|
|
|
}
|
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
// Reflow the cells with rowspan > 1 which originate between aFirstRow
|
|
|
|
// and end on or after aLastRow. aFirstTruncatedRow is the highest row on the
|
|
|
|
// page that contains a cell which cannot split on this page
|
2002-03-27 08:50:24 +03:00
|
|
|
void
|
2008-04-03 01:52:04 +04:00
|
|
|
nsTableRowGroupFrame::SplitSpanningCells(nsPresContext& aPresContext,
|
2001-04-16 18:51:52 +04:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableFrame& aTable,
|
|
|
|
nsTableRowFrame& aFirstRow,
|
|
|
|
nsTableRowFrame& aLastRow,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aFirstRowIsTopOfPage,
|
2007-12-02 22:19:00 +03:00
|
|
|
nscoord aSpanningRowBottom,
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame*& aContRow,
|
|
|
|
nsTableRowFrame*& aFirstTruncatedRow,
|
|
|
|
nscoord& aDesiredHeight)
|
2001-04-16 18:51:52 +04:00
|
|
|
{
|
2007-12-02 22:19:00 +03:00
|
|
|
NS_ASSERTION(aSpanningRowBottom >= 0, "Can't split negative heights");
|
2012-07-30 18:20:58 +04:00
|
|
|
aFirstTruncatedRow = nullptr;
|
2002-10-03 18:33:23 +04:00
|
|
|
aDesiredHeight = 0;
|
|
|
|
|
2012-01-17 03:38:10 +04:00
|
|
|
const bool borderCollapse = aTable.IsBorderCollapse();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t lastRowIndex = aLastRow.GetRowIndex();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool wasLast = false;
|
2011-12-27 12:31:10 +04:00
|
|
|
bool haveRowSpan = false;
|
2002-10-03 18:33:23 +04:00
|
|
|
// Iterate the rows between aFirstRow and aLastRow
|
2003-06-06 07:22:01 +04:00
|
|
|
for (nsTableRowFrame* row = &aFirstRow; !wasLast; row = row->GetNextRow()) {
|
|
|
|
wasLast = (row == &aLastRow);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowIndex = row->GetRowIndex();
|
2014-08-20 05:24:58 +04:00
|
|
|
nsPoint rowPos = row->GetNormalPosition();
|
2002-10-03 18:33:23 +04:00
|
|
|
// Iterate the cells looking for those that have rowspan > 1
|
|
|
|
for (nsTableCellFrame* cell = row->GetFirstCell(); cell; cell = cell->GetNextCell()) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowSpan = aTable.GetEffectiveRowSpan(rowIndex, *cell);
|
2002-10-03 18:33:23 +04:00
|
|
|
// Only reflow rowspan > 1 cells which span aLastRow. Those which don't span aLastRow
|
|
|
|
// were reflowed correctly during the unconstrained height reflow.
|
|
|
|
if ((rowSpan > 1) && (rowIndex + rowSpan > lastRowIndex)) {
|
2011-12-27 12:31:10 +04:00
|
|
|
haveRowSpan = true;
|
2002-10-03 18:33:23 +04:00
|
|
|
nsReflowStatus status;
|
|
|
|
// Ask the row to reflow the cell to the height of all the rows it spans up through aLastRow
|
|
|
|
// aAvailHeight is the space between the row group start and the end of the page
|
2007-12-02 22:19:00 +03:00
|
|
|
nscoord cellAvailHeight = aSpanningRowBottom - rowPos.y;
|
|
|
|
NS_ASSERTION(cellAvailHeight >= 0, "No space for cell?");
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isTopOfPage = (row == &aFirstRow) && aFirstRowIsTopOfPage;
|
2011-11-24 06:48:23 +04:00
|
|
|
|
2014-08-20 05:24:58 +04:00
|
|
|
nsRect rowRect = row->GetNormalRect();
|
2013-12-27 21:59:21 +04:00
|
|
|
nsSize rowAvailSize(aReflowState.AvailableWidth(),
|
|
|
|
std::max(aReflowState.AvailableHeight() - rowRect.y,
|
2011-11-24 06:48:23 +04:00
|
|
|
0));
|
|
|
|
// don't let the available height exceed what
|
|
|
|
// CalculateRowHeights set for it
|
2013-01-15 16:22:03 +04:00
|
|
|
rowAvailSize.height = std::min(rowAvailSize.height, rowRect.height);
|
2014-07-24 12:28:46 +04:00
|
|
|
nsHTMLReflowState rowReflowState(&aPresContext, aReflowState, row,
|
|
|
|
LogicalSize(row->GetWritingMode(),
|
|
|
|
rowAvailSize),
|
2013-09-10 00:29:05 +04:00
|
|
|
-1, -1,
|
|
|
|
nsHTMLReflowState::CALLER_WILL_INIT);
|
2011-11-24 06:48:23 +04:00
|
|
|
InitChildReflowState(aPresContext, borderCollapse, rowReflowState);
|
|
|
|
rowReflowState.mFlags.mIsTopOfPage = isTopOfPage; // set top of page
|
|
|
|
|
|
|
|
nscoord cellHeight = row->ReflowCellFrame(&aPresContext, rowReflowState,
|
2007-02-21 22:42:21 +03:00
|
|
|
isTopOfPage, cell,
|
2002-10-03 18:33:23 +04:00
|
|
|
cellAvailHeight, status);
|
2013-01-15 16:22:03 +04:00
|
|
|
aDesiredHeight = std::max(aDesiredHeight, rowPos.y + cellHeight);
|
2002-10-03 18:33:23 +04:00
|
|
|
if (NS_FRAME_IS_COMPLETE(status)) {
|
|
|
|
if (cellHeight > cellAvailHeight) {
|
|
|
|
aFirstTruncatedRow = row;
|
|
|
|
if ((row != &aFirstRow) || !aFirstRowIsTopOfPage) {
|
|
|
|
// return now, since we will be getting another reflow after either (1) row is
|
|
|
|
// moved to the next page or (2) the row group is moved to the next page
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!aContRow) {
|
2004-01-08 01:30:53 +03:00
|
|
|
CreateContinuingRowFrame(aPresContext, aLastRow, (nsIFrame**)&aContRow);
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
|
|
|
if (aContRow) {
|
|
|
|
if (row != &aLastRow) {
|
|
|
|
// aContRow needs a continuation for cell, since cell spanned into aLastRow
|
|
|
|
// but does not originate there
|
2013-03-20 05:47:49 +04:00
|
|
|
nsTableCellFrame* contCell = static_cast<nsTableCellFrame*>(
|
|
|
|
aPresContext.PresShell()->FrameConstructor()->
|
|
|
|
CreateContinuingFrame(&aPresContext, cell, &aLastRow));
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colIndex;
|
2002-10-03 18:33:23 +04:00
|
|
|
cell->GetColIndex(colIndex);
|
|
|
|
aContRow->InsertCellFrame(contCell, colIndex);
|
|
|
|
}
|
2001-04-16 18:51:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-12-27 12:31:10 +04:00
|
|
|
if (!haveRowSpan) {
|
2014-08-20 05:24:58 +04:00
|
|
|
aDesiredHeight = aLastRow.GetNormalRect().YMost();
|
2011-12-27 12:31:10 +04:00
|
|
|
}
|
2001-04-16 18:51:52 +04:00
|
|
|
}
|
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
// Remove the next-in-flow of the row, its cells and their cell blocks. This
|
|
|
|
// is necessary in case the row doesn't need a continuation later on or needs
|
|
|
|
// a continuation which doesn't have the same number of cells that now exist.
|
|
|
|
void
|
2008-04-03 01:52:04 +04:00
|
|
|
nsTableRowGroupFrame::UndoContinuedRow(nsPresContext* aPresContext,
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame* aRow)
|
|
|
|
{
|
|
|
|
if (!aRow) return; // allow null aRow to avoid callers doing null checks
|
|
|
|
|
|
|
|
// rowBefore was the prev-sibling of aRow's next-sibling before aRow was created
|
|
|
|
nsTableRowFrame* rowBefore = (nsTableRowFrame*)aRow->GetPrevInFlow();
|
2009-07-28 16:51:09 +04:00
|
|
|
NS_PRECONDITION(mFrames.ContainsFrame(rowBefore),
|
|
|
|
"rowBefore not in our frame list?");
|
2002-10-03 18:33:23 +04:00
|
|
|
|
2013-04-01 19:26:02 +04:00
|
|
|
AutoFrameListPtr overflows(aPresContext, StealOverflowFrames());
|
2009-07-28 16:51:09 +04:00
|
|
|
if (!rowBefore || !overflows || overflows->IsEmpty() ||
|
|
|
|
overflows->FirstChild() != aRow) {
|
|
|
|
NS_ERROR("invalid continued row");
|
2002-10-03 18:33:23 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-07-28 16:51:09 +04:00
|
|
|
// Destroy aRow, its cells, and their cell blocks. Cell blocks that have split
|
2002-10-03 18:33:23 +04:00
|
|
|
// will not have reflowed yet to pick up content from any overflow lines.
|
2009-07-28 16:51:09 +04:00
|
|
|
overflows->DestroyFrame(aRow);
|
|
|
|
|
|
|
|
// Put the overflow rows into our child list
|
2013-04-01 19:26:02 +04:00
|
|
|
if (!overflows->IsEmpty()) {
|
|
|
|
mFrames.InsertFrames(nullptr, rowBefore, *overflows);
|
|
|
|
}
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsTableRowFrame*
|
|
|
|
GetRowBefore(nsTableRowFrame& aStartRow,
|
|
|
|
nsTableRowFrame& aRow)
|
|
|
|
{
|
2012-07-30 18:20:58 +04:00
|
|
|
nsTableRowFrame* rowBefore = nullptr;
|
2002-10-03 18:33:23 +04:00
|
|
|
for (nsTableRowFrame* sib = &aStartRow; sib && (sib != &aRow); sib = sib->GetNextRow()) {
|
|
|
|
rowBefore = sib;
|
|
|
|
}
|
|
|
|
return rowBefore;
|
|
|
|
}
|
|
|
|
|
1998-12-14 04:24:11 +03:00
|
|
|
nsresult
|
2008-04-03 01:52:04 +04:00
|
|
|
nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
|
1998-12-14 04:24:11 +03:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
1999-02-22 06:28:00 +03:00
|
|
|
nsTableFrame* aTableFrame,
|
2012-11-08 20:09:38 +04:00
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
bool aRowForcedPageBreak)
|
1998-12-14 04:24:11 +03:00
|
|
|
{
|
2006-06-07 02:45:14 +04:00
|
|
|
NS_PRECONDITION(aPresContext->IsPaginated(), "SplitRowGroup currently supports only paged media");
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsTableRowFrame* prevRowFrame = nullptr;
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() = 0;
|
2001-04-16 18:51:52 +04:00
|
|
|
|
2013-12-27 21:59:21 +04:00
|
|
|
nscoord availWidth = aReflowState.AvailableWidth();
|
|
|
|
nscoord availHeight = aReflowState.AvailableHeight();
|
2003-04-05 19:36:31 +04:00
|
|
|
|
2012-01-17 03:38:10 +04:00
|
|
|
const bool borderCollapse = aTableFrame->IsBorderCollapse();
|
2004-11-11 20:27:38 +03:00
|
|
|
|
2002-03-27 08:50:24 +03:00
|
|
|
// get the page height
|
2006-03-30 04:27:42 +04:00
|
|
|
nscoord pageHeight = aPresContext->GetPageSize().height;
|
|
|
|
NS_ASSERTION(pageHeight != NS_UNCONSTRAINEDSIZE,
|
|
|
|
"The table shouldn't be split when there should be space");
|
2002-03-27 08:50:24 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool isTopOfPage = aReflowState.mFlags.mIsTopOfPage;
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame* firstRowThisPage = GetFirstRow();
|
|
|
|
|
2008-01-27 04:54:48 +03:00
|
|
|
// Need to dirty the table's geometry, or else the row might skip
|
|
|
|
// reflowing its cell as an optimization.
|
|
|
|
aTableFrame->SetGeometryDirty();
|
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
// Walk each of the row frames looking for the first row frame that doesn't fit
|
|
|
|
// in the available space
|
|
|
|
for (nsTableRowFrame* rowFrame = firstRowThisPage; rowFrame; rowFrame = rowFrame->GetNextRow()) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool rowIsOnPage = true;
|
2014-06-18 14:47:00 +04:00
|
|
|
nscoord cellSpacingY = aTableFrame->GetCellSpacingY(rowFrame->GetRowIndex());
|
2014-08-20 05:24:58 +04:00
|
|
|
nsRect rowRect = rowFrame->GetNormalRect();
|
2002-10-03 18:33:23 +04:00
|
|
|
// See if the row fits on this page
|
|
|
|
if (rowRect.YMost() > availHeight) {
|
2012-07-30 18:20:58 +04:00
|
|
|
nsTableRowFrame* contRow = nullptr;
|
2002-10-03 18:33:23 +04:00
|
|
|
// Reflow the row in the availabe space and have it split if it is the 1st
|
|
|
|
// row (on the page) or there is at least 5% of the current page available
|
|
|
|
// XXX this 5% should be made a preference
|
2013-12-27 21:59:52 +04:00
|
|
|
if (!prevRowFrame || (availHeight - aDesiredSize.Height() > pageHeight / 20)) {
|
2013-01-15 16:22:03 +04:00
|
|
|
nsSize availSize(availWidth, std::max(availHeight - rowRect.y, 0));
|
2002-03-27 08:50:24 +03:00
|
|
|
// don't let the available height exceed what CalculateRowHeights set for it
|
2013-01-15 16:22:03 +04:00
|
|
|
availSize.height = std::min(availSize.height, rowRect.height);
|
2002-03-27 08:50:24 +03:00
|
|
|
|
2014-07-24 12:28:46 +04:00
|
|
|
nsHTMLReflowState rowReflowState(aPresContext, aReflowState, rowFrame,
|
|
|
|
LogicalSize(rowFrame->GetWritingMode(),
|
|
|
|
availSize),
|
2013-09-10 00:29:05 +04:00
|
|
|
-1, -1,
|
|
|
|
nsHTMLReflowState::CALLER_WILL_INIT);
|
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
|
|
|
|
2007-02-07 10:46:44 +03:00
|
|
|
InitChildReflowState(*aPresContext, borderCollapse, rowReflowState);
|
2002-03-27 08:50:24 +03:00
|
|
|
rowReflowState.mFlags.mIsTopOfPage = isTopOfPage; // set top of page
|
2013-12-31 17:50:31 +04:00
|
|
|
nsHTMLReflowMetrics rowMetrics(aReflowState);
|
2002-02-19 18:48:28 +03:00
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
// Get the old size before we reflow.
|
|
|
|
nsRect oldRowRect = rowFrame->GetRect();
|
|
|
|
nsRect oldRowVisualOverflow = rowFrame->GetVisualOverflowRect();
|
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
// Reflow the cell with the constrained height. A cell with rowspan >1 will get this
|
|
|
|
// reflow later during SplitSpanningCells.
|
2014-05-13 04:47:53 +04:00
|
|
|
ReflowChild(rowFrame, aPresContext, rowMetrics, rowReflowState,
|
|
|
|
0, 0, NS_FRAME_NO_MOVE_FRAME, aStatus);
|
2013-12-27 21:59:52 +04:00
|
|
|
rowFrame->SetSize(nsSize(rowMetrics.Width(), rowMetrics.Height()));
|
2012-11-14 10:47:33 +04:00
|
|
|
rowFrame->DidReflow(aPresContext, nullptr, nsDidReflowStatus::FINISHED);
|
2007-01-28 01:22:24 +03:00
|
|
|
rowFrame->DidResize();
|
1998-12-14 04:24:11 +03:00
|
|
|
|
2012-11-08 20:09:38 +04:00
|
|
|
if (!aRowForcedPageBreak && !NS_FRAME_IS_FULLY_COMPLETE(aStatus) &&
|
|
|
|
ShouldAvoidBreakInside(aReflowState)) {
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableFrame::InvalidateTableFrame(rowFrame, oldRowRect,
|
|
|
|
oldRowVisualOverflow,
|
|
|
|
false);
|
|
|
|
|
1998-12-16 00:26:05 +03:00
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
|
2002-10-03 18:33:23 +04:00
|
|
|
// The row frame is incomplete and all of the rowspan 1 cells' block frames split
|
2013-12-27 21:59:52 +04:00
|
|
|
if ((rowMetrics.Height() <= rowReflowState.AvailableHeight()) || isTopOfPage) {
|
2002-10-03 18:33:23 +04:00
|
|
|
// The row stays on this page because either it split ok or we're on the top of page.
|
|
|
|
// If top of page and the height exceeded the avail height, then there will be data loss
|
2013-12-27 21:59:52 +04:00
|
|
|
NS_ASSERTION(rowMetrics.Height() <= rowReflowState.AvailableHeight(),
|
2006-03-30 22:40:56 +04:00
|
|
|
"data loss - incomplete row needed more height than available, on top of page");
|
2004-01-08 01:30:53 +03:00
|
|
|
CreateContinuingRowFrame(*aPresContext, *rowFrame, (nsIFrame**)&contRow);
|
2002-10-03 18:33:23 +04:00
|
|
|
if (contRow) {
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() += rowMetrics.Height();
|
2002-10-03 18:33:23 +04:00
|
|
|
if (prevRowFrame)
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() += cellSpacingY;
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
|
|
|
else return NS_ERROR_NULL_POINTER;
|
2001-11-01 18:31:13 +03:00
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
else {
|
2002-10-03 18:33:23 +04:00
|
|
|
// Put the row on the next page to give it more height
|
2011-10-17 18:59:28 +04:00
|
|
|
rowIsOnPage = false;
|
2001-04-02 07:21:58 +04:00
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
else {
|
2005-11-21 01:05:24 +03:00
|
|
|
// The row frame is complete because either (1) its minimum height is greater than the
|
2002-10-03 18:33:23 +04:00
|
|
|
// available height we gave it, or (2) it may have been given a larger height through
|
2005-11-21 01:05:24 +03:00
|
|
|
// style than its content, or (3) it contains a rowspan >1 cell which hasn't been
|
2002-10-03 18:33:23 +04:00
|
|
|
// reflowed with a constrained height yet (we will find out when SplitSpanningCells is
|
|
|
|
// called below)
|
2013-12-27 21:59:52 +04:00
|
|
|
if (rowMetrics.Height() > availSize.height ||
|
2012-11-08 20:09:38 +04:00
|
|
|
(NS_INLINE_IS_BREAK_BEFORE(aStatus) && !aRowForcedPageBreak)) {
|
2002-10-03 18:33:23 +04:00
|
|
|
// cases (1) and (2)
|
|
|
|
if (isTopOfPage) {
|
|
|
|
// We're on top of the page, so keep the row on this page. There will be data loss.
|
|
|
|
// Push the row frame that follows
|
|
|
|
nsTableRowFrame* nextRowFrame = rowFrame->GetNextRow();
|
|
|
|
if (nextRowFrame) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() += rowMetrics.Height();
|
2002-10-03 18:33:23 +04:00
|
|
|
if (prevRowFrame)
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() += cellSpacingY;
|
2002-10-03 18:33:23 +04:00
|
|
|
NS_WARNING("data loss - complete row needed more height than available, on top of page");
|
|
|
|
}
|
2007-12-02 22:19:00 +03:00
|
|
|
else {
|
2002-10-03 18:33:23 +04:00
|
|
|
// We're not on top of the page, so put the row on the next page to give it more height
|
2011-10-17 18:59:28 +04:00
|
|
|
rowIsOnPage = false;
|
2001-04-02 07:21:58 +04:00
|
|
|
}
|
1999-03-09 18:35:43 +03:00
|
|
|
}
|
1998-12-16 00:26:05 +03:00
|
|
|
}
|
2013-12-27 21:59:52 +04:00
|
|
|
} //if (!prevRowFrame || (availHeight - aDesiredSize.Height() > pageHeight / 20))
|
2002-10-03 18:33:23 +04:00
|
|
|
else {
|
2002-03-27 08:50:24 +03:00
|
|
|
// put the row on the next page to give it more height
|
2011-10-17 18:59:28 +04:00
|
|
|
rowIsOnPage = false;
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
1998-12-16 00:26:05 +03:00
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame* lastRowThisPage = rowFrame;
|
2007-12-02 22:19:00 +03:00
|
|
|
nscoord spanningRowBottom = availHeight;
|
2002-10-03 18:33:23 +04:00
|
|
|
if (!rowIsOnPage) {
|
2007-11-12 04:45:56 +03:00
|
|
|
NS_ASSERTION(!contRow, "We should not have created a continuation if none of this row fits");
|
2012-11-08 20:09:38 +04:00
|
|
|
if (!aRowForcedPageBreak && ShouldAvoidBreakInside(aReflowState)) {
|
|
|
|
aStatus = NS_INLINE_LINE_BREAK_BEFORE();
|
|
|
|
break;
|
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
if (prevRowFrame) {
|
2014-08-20 05:24:58 +04:00
|
|
|
spanningRowBottom = prevRowFrame->GetNormalRect().YMost();
|
2002-10-03 18:33:23 +04:00
|
|
|
lastRowThisPage = prevRowFrame;
|
|
|
|
isTopOfPage = (lastRowThisPage == firstRowThisPage) && aReflowState.mFlags.mIsTopOfPage;
|
2002-03-27 08:50:24 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// We can't push children, so let our parent reflow us again with more space
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() = rowRect.YMost();
|
2007-11-12 04:45:56 +03:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
2002-10-03 18:33:23 +04:00
|
|
|
break;
|
2001-04-16 18:51:52 +04:00
|
|
|
}
|
|
|
|
}
|
2002-10-03 18:33:23 +04:00
|
|
|
// reflow the cells with rowspan >1 that occur on the page
|
|
|
|
|
|
|
|
nsTableRowFrame* firstTruncatedRow;
|
|
|
|
nscoord yMost;
|
2004-01-08 01:30:53 +03:00
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *aTableFrame, *firstRowThisPage,
|
2007-12-02 22:19:00 +03:00
|
|
|
*lastRowThisPage, aReflowState.mFlags.mIsTopOfPage, spanningRowBottom, contRow,
|
2002-10-03 18:33:23 +04:00
|
|
|
firstTruncatedRow, yMost);
|
|
|
|
if (firstTruncatedRow) {
|
|
|
|
// A rowspan >1 cell did not fit (and could not split) in the space we gave it
|
|
|
|
if (firstTruncatedRow == firstRowThisPage) {
|
|
|
|
if (aReflowState.mFlags.mIsTopOfPage) {
|
|
|
|
NS_WARNING("data loss in a row spanned cell");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// We can't push children, so let our parent reflow us again with more space
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() = rowRect.YMost();
|
2002-10-03 18:33:23 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
UndoContinuedRow(aPresContext, contRow);
|
2012-07-30 18:20:58 +04:00
|
|
|
contRow = nullptr;
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else { // (firstTruncatedRow != firstRowThisPage)
|
|
|
|
// Try to put firstTruncateRow on the next page
|
|
|
|
nsTableRowFrame* rowBefore = ::GetRowBefore(*firstRowThisPage, *firstTruncatedRow);
|
2007-12-02 22:19:00 +03:00
|
|
|
nscoord oldSpanningRowBottom = spanningRowBottom;
|
2014-08-20 05:24:58 +04:00
|
|
|
spanningRowBottom = rowBefore->GetNormalRect().YMost();
|
2002-10-03 18:33:23 +04:00
|
|
|
|
|
|
|
UndoContinuedRow(aPresContext, contRow);
|
2012-07-30 18:20:58 +04:00
|
|
|
contRow = nullptr;
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame* oldLastRowThisPage = lastRowThisPage;
|
2011-12-01 10:34:30 +04:00
|
|
|
lastRowThisPage = rowBefore;
|
2002-10-03 18:33:23 +04:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
2002-03-27 08:50:24 +03:00
|
|
|
|
2002-10-03 18:33:23 +04:00
|
|
|
// Call SplitSpanningCells again with rowBefore as the last row on the page
|
2004-01-08 01:30:53 +03:00
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *aTableFrame,
|
2002-10-03 18:33:23 +04:00
|
|
|
*firstRowThisPage, *rowBefore, aReflowState.mFlags.mIsTopOfPage,
|
2013-12-27 21:59:52 +04:00
|
|
|
spanningRowBottom, contRow, firstTruncatedRow, aDesiredSize.Height());
|
2002-10-03 18:33:23 +04:00
|
|
|
if (firstTruncatedRow) {
|
|
|
|
if (aReflowState.mFlags.mIsTopOfPage) {
|
|
|
|
// We were better off with the 1st call to SplitSpanningCells, do it again
|
|
|
|
UndoContinuedRow(aPresContext, contRow);
|
2012-07-30 18:20:58 +04:00
|
|
|
contRow = nullptr;
|
2002-10-03 18:33:23 +04:00
|
|
|
lastRowThisPage = oldLastRowThisPage;
|
2007-12-02 22:19:00 +03:00
|
|
|
spanningRowBottom = oldSpanningRowBottom;
|
2004-01-08 01:30:53 +03:00
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *aTableFrame, *firstRowThisPage,
|
2007-12-02 22:19:00 +03:00
|
|
|
*lastRowThisPage, aReflowState.mFlags.mIsTopOfPage, spanningRowBottom, contRow,
|
2013-12-27 21:59:52 +04:00
|
|
|
firstTruncatedRow, aDesiredSize.Height());
|
2002-10-03 18:33:23 +04:00
|
|
|
NS_WARNING("data loss in a row spanned cell");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Let our parent reflow us again with more space
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() = rowRect.YMost();
|
2002-10-03 18:33:23 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
UndoContinuedRow(aPresContext, contRow);
|
2012-07-30 18:20:58 +04:00
|
|
|
contRow = nullptr;
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} // if (firstTruncatedRow == firstRowThisPage)
|
2004-04-14 00:47:52 +04:00
|
|
|
} // if (firstTruncatedRow)
|
2002-10-03 18:33:23 +04:00
|
|
|
else {
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() = std::max(aDesiredSize.Height(), yMost);
|
2002-10-03 18:33:23 +04:00
|
|
|
if (contRow) {
|
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NS_FRAME_IS_NOT_COMPLETE(aStatus) && !contRow) {
|
|
|
|
nsTableRowFrame* nextRow = lastRowThisPage->GetNextRow();
|
|
|
|
if (nextRow) {
|
2014-02-07 02:07:47 +04:00
|
|
|
PushChildren(nextRow, lastRowThisPage);
|
2002-10-03 18:33:23 +04:00
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
1998-12-14 04:24:11 +03:00
|
|
|
break;
|
2002-10-03 18:33:23 +04:00
|
|
|
} // if (rowRect.YMost() > availHeight)
|
|
|
|
else {
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() = rowRect.YMost();
|
2001-04-17 18:39:54 +04:00
|
|
|
prevRowFrame = rowFrame;
|
2002-03-18 00:35:08 +03:00
|
|
|
// see if there is a page break after the row
|
|
|
|
nsTableRowFrame* nextRow = rowFrame->GetNextRow();
|
2010-05-13 18:15:49 +04:00
|
|
|
if (nextRow && nsTableFrame::PageBreakAfter(rowFrame, nextRow)) {
|
2014-02-07 02:07:47 +04:00
|
|
|
PushChildren(nextRow, rowFrame);
|
2002-03-18 00:35:08 +03:00
|
|
|
aStatus = NS_FRAME_NOT_COMPLETE;
|
|
|
|
break;
|
|
|
|
}
|
2001-04-17 18:39:54 +04:00
|
|
|
}
|
2008-04-17 22:18:41 +04:00
|
|
|
// after the 1st row that has a height, we can't be on top
|
|
|
|
// of the page anymore.
|
|
|
|
isTopOfPage = isTopOfPage && rowRect.YMost() == 0;
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
2002-12-13 18:21:38 +03:00
|
|
|
return NS_OK;
|
1998-12-14 04:24:11 +03:00
|
|
|
}
|
|
|
|
|
1998-04-14 00:24:54 +04:00
|
|
|
/** Layout the entire row group.
|
|
|
|
* This method stacks rows vertically according to HTML 4.0 rules.
|
|
|
|
* Rows are responsible for layout of their children.
|
|
|
|
*/
|
2014-05-13 04:47:52 +04:00
|
|
|
void
|
2008-04-03 01:52:04 +04:00
|
|
|
nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext,
|
1998-10-02 08:10:00 +04:00
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
1998-04-14 00:24:54 +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
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsTableRowGroupFrame");
|
2001-11-14 16:40:03 +03:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
2001-09-24 18:48:38 +04:00
|
|
|
|
2002-04-01 10:46:17 +04:00
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
1998-11-04 23:09:19 +03:00
|
|
|
|
2006-09-20 01:39:33 +04:00
|
|
|
// Row geometry may be going to change so we need to invalidate any row cursor.
|
|
|
|
ClearRowCursor();
|
|
|
|
|
2002-04-11 01:32:41 +04:00
|
|
|
// see if a special height reflow needs to occur due to having a pct height
|
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::CheckRequestSpecialHeightReflow(aReflowState);
|
2002-04-11 01:32:41 +04:00
|
|
|
|
2012-01-17 03:38:10 +04:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2001-03-13 09:38:59 +03:00
|
|
|
nsRowGroupReflowState state(aReflowState, tableFrame);
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStyleVisibility* groupVis = StyleVisibility();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool collapseGroup = (NS_STYLE_VISIBILITY_COLLAPSE == groupVis->mVisible);
|
2004-04-28 20:42:59 +04:00
|
|
|
if (collapseGroup) {
|
2011-10-17 18:59:28 +04:00
|
|
|
tableFrame->SetNeedToCollapse(true);
|
2004-04-28 20:42:59 +04:00
|
|
|
}
|
1998-07-03 03:19:31 +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
|
|
|
// Check for an overflow list
|
2014-02-07 02:07:47 +04:00
|
|
|
MoveOverflowToChildList();
|
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 existing frames.
|
2011-09-29 10:19:26 +04:00
|
|
|
bool splitDueToPageBreak = false;
|
2014-05-13 04:47:52 +04:00
|
|
|
ReflowChildren(aPresContext, aDesiredSize, state, aStatus,
|
|
|
|
&splitDueToPageBreak);
|
1998-12-14 04:24:11 +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
|
|
|
// See if all the frames fit. Do not try to split anything if we're
|
|
|
|
// not paginated ... we can't split across columns yet.
|
2007-01-21 20:51:33 +03:00
|
|
|
if (aReflowState.mFlags.mTableIsSplittable &&
|
2013-12-27 21:59:21 +04:00
|
|
|
NS_UNCONSTRAINEDSIZE != aReflowState.AvailableHeight() &&
|
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
|
|
|
(NS_FRAME_NOT_COMPLETE == aStatus || splitDueToPageBreak ||
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() > aReflowState.AvailableHeight())) {
|
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
|
|
|
// Nope, find a place to split the row group
|
2011-09-29 10:19:26 +04:00
|
|
|
bool specialReflow = (bool)aReflowState.mFlags.mSpecialHeightReflow;
|
2011-10-17 18:59:28 +04:00
|
|
|
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = false;
|
2001-11-29 18:41:07 +03:00
|
|
|
|
2012-11-08 20:09:38 +04:00
|
|
|
SplitRowGroup(aPresContext, aDesiredSize, aReflowState, tableFrame, aStatus,
|
|
|
|
splitDueToPageBreak);
|
2001-11-29 18:41:07 +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
|
|
|
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialHeightReflow = specialReflow;
|
|
|
|
}
|
|
|
|
|
2012-11-08 20:09:38 +04:00
|
|
|
// XXXmats The following is just bogus. We leave it here for now because
|
|
|
|
// ReflowChildren should pull up rows from our next-in-flow before returning
|
|
|
|
// a Complete status, but doesn't (bug 804888).
|
|
|
|
if (GetNextInFlow() && GetNextInFlow()->GetFirstPrincipalChild()) {
|
|
|
|
NS_FRAME_SET_INCOMPLETE(aStatus);
|
1998-04-14 00:24:54 +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
|
|
|
|
2007-08-02 22:08:05 +04:00
|
|
|
SetHasStyleHeight((NS_UNCONSTRAINEDSIZE != aReflowState.ComputedHeight()) &&
|
|
|
|
(aReflowState.ComputedHeight() > 0));
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2001-03-13 09:38:59 +03:00
|
|
|
// just set our width to what was available. The table will calculate the width and not use our value.
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Width() = aReflowState.AvailableWidth();
|
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
|
|
|
|
2010-10-07 08:25:46 +04:00
|
|
|
aDesiredSize.UnionOverflowAreasWithDesiredBounds();
|
2008-03-16 23:32:48 +03:00
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
// If our parent is in initial reflow, it'll handle invalidating our
|
|
|
|
// entire overflow rect.
|
|
|
|
if (!(GetParent()->GetStateBits() & 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();
|
|
|
|
}
|
|
|
|
|
2004-07-16 20:56:21 +04:00
|
|
|
FinishAndStoreOverflow(&aDesiredSize);
|
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-10-14 20:32:45 +04:00
|
|
|
}
|
|
|
|
|
2013-05-30 08:44:37 +04:00
|
|
|
bool
|
|
|
|
nsTableRowGroupFrame::UpdateOverflow()
|
|
|
|
{
|
|
|
|
// Row cursor invariants depend on the visual overflow area of the rows,
|
|
|
|
// which may have changed, so we need to clear the cursor now.
|
|
|
|
ClearRowCursor();
|
|
|
|
return nsContainerFrame::UpdateOverflow();
|
|
|
|
}
|
|
|
|
|
2008-10-26 13:11:34 +03:00
|
|
|
/* virtual */ void
|
|
|
|
nsTableRowGroupFrame::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;
|
|
|
|
|
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
2013-02-16 09:38:33 +04:00
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
|
2012-01-23 02:48:34 +04:00
|
|
|
nsIntRect damageArea(0, GetStartRowIndex(), tableFrame->GetColCount(),
|
|
|
|
GetRowCount());
|
2011-10-27 17:58:44 +04:00
|
|
|
tableFrame->AddBCDamageArea(damageArea);
|
2008-10-26 13:11:34 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsTableRowGroupFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-02 02:01:37 +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
|
|
|
|
2006-09-20 01:39:33 +04:00
|
|
|
ClearRowCursor();
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// collect the new row frames in an array
|
2009-07-30 21:23:32 +04:00
|
|
|
// XXXbz why are we doing the QI stuff? There shouldn't be any non-rows here.
|
2009-02-05 12:09:50 +03:00
|
|
|
nsAutoTArray<nsTableRowFrame*, 8> rows;
|
2009-07-30 21:23:32 +04:00
|
|
|
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
|
|
|
|
nsTableRowFrame *rowFrame = do_QueryFrame(e.get());
|
|
|
|
NS_ASSERTION(rowFrame, "Unexpected frame; frame constructor screwed up");
|
2009-03-25 01:10:06 +03:00
|
|
|
if (rowFrame) {
|
2008-08-14 07:49:57 +04:00
|
|
|
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_ROW ==
|
2013-02-17 01:51:02 +04:00
|
|
|
e.get()->StyleDisplay()->mDisplay,
|
2008-08-14 07:49:57 +04:00
|
|
|
"wrong display type on rowframe");
|
2009-03-25 01:10:06 +03:00
|
|
|
rows.AppendElement(rowFrame);
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowIndex = GetRowCount();
|
1999-12-14 01:56:31 +03:00
|
|
|
// Append the frames to the sibling chain
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.AppendFrames(nullptr, aFrameList);
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2009-02-05 12:09:50 +03:00
|
|
|
if (rows.Length() > 0) {
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2012-01-17 03:38:10 +04:00
|
|
|
tableFrame->AppendRows(this, rowIndex, rows);
|
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
tableFrame->SetGeometryDirty();
|
1999-08-02 06:18:33 +04:00
|
|
|
}
|
|
|
|
}
|
1999-08-02 02:01:37 +04:00
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsTableRowGroupFrame::InsertFrames(ChildListID aListID,
|
1999-08-02 06:18:33 +04:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 21:23:32 +04:00
|
|
|
nsFrameList& aFrameList)
|
1999-08-02 06:18:33 +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");
|
|
|
|
|
2006-09-20 01:39:33 +04:00
|
|
|
ClearRowCursor();
|
|
|
|
|
1999-12-14 01:56:31 +03:00
|
|
|
// collect the new row frames in an array
|
2009-07-30 21:23:32 +04:00
|
|
|
// XXXbz why are we doing the QI stuff? There shouldn't be any non-rows here.
|
2012-01-17 03:38:10 +04:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2009-02-05 12:09:50 +03:00
|
|
|
nsTArray<nsTableRowFrame*> rows;
|
2011-09-29 10:19:26 +04:00
|
|
|
bool gotFirstRow = false;
|
2009-07-30 21:23:32 +04:00
|
|
|
for (nsFrameList::Enumerator e(aFrameList); !e.AtEnd(); e.Next()) {
|
|
|
|
nsTableRowFrame *rowFrame = do_QueryFrame(e.get());
|
|
|
|
NS_ASSERTION(rowFrame, "Unexpected frame; frame constructor screwed up");
|
2009-03-25 01:10:06 +03:00
|
|
|
if (rowFrame) {
|
2008-08-14 07:49:57 +04:00
|
|
|
NS_ASSERTION(NS_STYLE_DISPLAY_TABLE_ROW ==
|
2013-02-17 01:51:02 +04:00
|
|
|
e.get()->StyleDisplay()->mDisplay,
|
2008-08-14 07:49:57 +04:00
|
|
|
"wrong display type on rowframe");
|
2009-03-25 01:10:06 +03:00
|
|
|
rows.AppendElement(rowFrame);
|
2001-08-06 18:48:09 +04:00
|
|
|
if (!gotFirstRow) {
|
2011-10-17 18:59:28 +04:00
|
|
|
rowFrame->SetFirstInserted(true);
|
|
|
|
gotFirstRow = true;
|
|
|
|
tableFrame->SetRowInserted(true);
|
2001-08-06 18:48:09 +04:00
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
}
|
|
|
|
}
|
1999-08-02 06:18:33 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t startRowIndex = GetStartRowIndex();
|
1999-12-14 01:56:31 +03:00
|
|
|
// Insert the frames in the sibling chain
|
2012-07-30 18:20:58 +04:00
|
|
|
mFrames.InsertFrames(nullptr, aPrevFrame, aFrameList);
|
1999-08-02 06:18:33 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t numRows = rows.Length();
|
2001-03-13 09:38:59 +03:00
|
|
|
if (numRows > 0) {
|
2006-12-26 20:47:52 +03:00
|
|
|
nsTableRowFrame* prevRow = (nsTableRowFrame *)nsTableFrame::GetFrameAtOrBefore(this, aPrevFrame, nsGkAtoms::tableRowFrame);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowIndex = (prevRow) ? prevRow->GetRowIndex() + 1 : startRowIndex;
|
2011-10-17 18:59:28 +04:00
|
|
|
tableFrame->InsertRows(this, rows, rowIndex, true);
|
2001-08-06 18:48:09 +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-12-14 01:56:31 +03:00
|
|
|
}
|
1999-08-02 06:18:33 +04:00
|
|
|
}
|
|
|
|
|
2014-05-28 23:36:58 +04:00
|
|
|
void
|
2011-08-25 00:54:30 +04:00
|
|
|
nsTableRowGroupFrame::RemoveFrame(ChildListID aListID,
|
1999-08-02 06:18:33 +04:00
|
|
|
nsIFrame* aOldFrame)
|
|
|
|
{
|
2011-08-25 00:54:30 +04:00
|
|
|
NS_ASSERTION(aListID == kPrincipalList, "unexpected child list");
|
2006-06-29 06:32:36 +04:00
|
|
|
|
2006-09-20 01:39:33 +04:00
|
|
|
ClearRowCursor();
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2012-01-17 03:38:10 +04:00
|
|
|
// XXX why are we doing the QI stuff? There shouldn't be any non-rows here.
|
|
|
|
nsTableRowFrame* rowFrame = do_QueryFrame(aOldFrame);
|
|
|
|
if (rowFrame) {
|
|
|
|
// remove the rows from the table (and flag a rebalance)
|
|
|
|
tableFrame->RemoveRows(*rowFrame, 1, true);
|
1999-08-02 06:18:33 +04:00
|
|
|
|
2012-01-17 03:38:10 +04:00
|
|
|
PresContext()->PresShell()->
|
|
|
|
FrameNeedsReflow(this, nsIPresShell::eTreeChange,
|
|
|
|
NS_FRAME_HAS_DIRTY_CHILDREN);
|
|
|
|
tableFrame->SetGeometryDirty();
|
1999-08-02 02:01:37 +04:00
|
|
|
}
|
2006-04-10 04:16:29 +04:00
|
|
|
mFrames.DestroyFrame(aOldFrame);
|
1999-08-02 02:01:37 +04:00
|
|
|
}
|
|
|
|
|
2006-12-14 02:04:57 +03:00
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableRowGroupFrame::GetUsedMargin() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableRowGroupFrame::GetUsedBorder() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ nsMargin
|
|
|
|
nsTableRowGroupFrame::GetUsedPadding() const
|
|
|
|
{
|
|
|
|
return nsMargin(0,0,0,0);
|
|
|
|
}
|
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord
|
|
|
|
nsTableRowGroupFrame::GetHeightBasis(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
|
|
|
nscoord result = 0;
|
2006-03-04 08:26:57 +03:00
|
|
|
nsTableFrame* tableFrame = nsTableFrame::GetTableFrame(this);
|
2014-06-18 14:47:00 +04:00
|
|
|
int32_t startRowIndex = GetStartRowIndex();
|
2012-01-17 03:38:10 +04:00
|
|
|
if ((aReflowState.ComputedHeight() > 0) && (aReflowState.ComputedHeight() < NS_UNCONSTRAINEDSIZE)) {
|
2014-06-18 14:47:00 +04:00
|
|
|
nscoord cellSpacing = tableFrame->GetCellSpacingY(startRowIndex,
|
|
|
|
std::max(startRowIndex,
|
|
|
|
startRowIndex + GetRowCount() - 1));
|
2012-01-17 03:38:10 +04:00
|
|
|
result = aReflowState.ComputedHeight() - cellSpacing;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
const nsHTMLReflowState* parentRS = aReflowState.parentReflowState;
|
|
|
|
if (parentRS && (tableFrame != parentRS->frame)) {
|
|
|
|
parentRS = parentRS->parentReflowState;
|
2001-11-05 18:15:24 +03:00
|
|
|
}
|
2012-01-17 03:38:10 +04:00
|
|
|
if (parentRS && (tableFrame == parentRS->frame) &&
|
|
|
|
(parentRS->ComputedHeight() > 0) && (parentRS->ComputedHeight() < NS_UNCONSTRAINEDSIZE)) {
|
2014-06-18 14:47:00 +04:00
|
|
|
nscoord cellSpacing = tableFrame->GetCellSpacingY(-1, tableFrame->GetRowCount());
|
2012-01-17 03:38:10 +04:00
|
|
|
result = parentRS->ComputedHeight() - cellSpacing;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
}
|
2001-11-05 18:15:24 +03:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
1999-09-01 09:16:12 +04:00
|
|
|
nsTableRowGroupFrame::IsSimpleRowFrame(nsTableFrame* aTableFrame,
|
|
|
|
nsIFrame* aFrame)
|
|
|
|
{
|
|
|
|
// Make sure it's a row frame and not a row group frame
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableRowFrame *rowFrame = do_QueryFrame(aFrame);
|
|
|
|
if (rowFrame) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowIndex = rowFrame->GetRowIndex();
|
1999-09-01 09:16:12 +04:00
|
|
|
|
|
|
|
// It's a simple row frame if there are no cells that span into or
|
|
|
|
// across the row
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t numEffCols = aTableFrame->GetEffectiveColCount();
|
2005-11-04 21:41:32 +03:00
|
|
|
if (!aTableFrame->RowIsSpannedInto(rowIndex, numEffCols) &&
|
|
|
|
!aTableFrame->RowHasSpanningCells(rowIndex, numEffCols)) {
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
1999-09-01 09:16:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
1999-09-01 09:16:12 +04:00
|
|
|
}
|
|
|
|
|
2003-10-31 23:19:18 +03:00
|
|
|
nsIAtom*
|
|
|
|
nsTableRowGroupFrame::GetType() const
|
1999-02-24 08:54:31 +03:00
|
|
|
{
|
2006-12-26 20:47:52 +03:00
|
|
|
return nsGkAtoms::tableRowGroupFrame;
|
1999-02-24 08:54:31 +03:00
|
|
|
}
|
|
|
|
|
2010-05-13 18:15:49 +04:00
|
|
|
/** find page break before the first row **/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-05-13 18:15:49 +04:00
|
|
|
nsTableRowGroupFrame::HasInternalBreakBefore() const
|
|
|
|
{
|
|
|
|
nsIFrame* firstChild = mFrames.FirstChild();
|
|
|
|
if (!firstChild)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2013-02-17 01:51:02 +04:00
|
|
|
return firstChild->StyleDisplay()->mBreakBefore;
|
2010-05-13 18:15:49 +04:00
|
|
|
}
|
1999-02-24 08:54:31 +03:00
|
|
|
|
2010-05-13 18:15:49 +04:00
|
|
|
/** find page break after the last row **/
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2010-05-13 18:15:49 +04:00
|
|
|
nsTableRowGroupFrame::HasInternalBreakAfter() const
|
|
|
|
{
|
|
|
|
nsIFrame* lastChild = mFrames.LastChild();
|
|
|
|
if (!lastChild)
|
2011-10-17 18:59:28 +04:00
|
|
|
return false;
|
2013-02-17 01:51:02 +04:00
|
|
|
return lastChild->StyleDisplay()->mBreakAfter;
|
2010-05-13 18:15:49 +04:00
|
|
|
}
|
1998-09-15 21:58:24 +04:00
|
|
|
/* ----- global methods ----- */
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2014-05-25 02:20:40 +04:00
|
|
|
nsTableRowGroupFrame*
|
2006-03-27 01:30:36 +04:00
|
|
|
NS_NewTableRowGroupFrame(nsIPresShell* aPresShell, nsStyleContext* aContext)
|
1998-04-14 00:24:54 +04:00
|
|
|
{
|
2006-03-27 01:30:36 +04:00
|
|
|
return new (aPresShell) nsTableRowGroupFrame(aContext);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
|
2009-09-12 20:49:24 +04:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsTableRowGroupFrame)
|
|
|
|
|
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
|
|
|
nsTableRowGroupFrame::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("TableRowGroup"), aResult);
|
1998-11-19 20:22:29 +03:00
|
|
|
}
|
1999-09-01 05:02:16 +04:00
|
|
|
#endif
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
nsMargin*
|
2007-02-07 10:46:44 +03:00
|
|
|
nsTableRowGroupFrame::GetBCBorderWidth(nsMargin& aBorder)
|
2002-02-19 18:48:28 +03:00
|
|
|
{
|
2008-04-06 16:12:04 +04:00
|
|
|
aBorder.left = aBorder.right = aBorder.top = aBorder.bottom = 0;
|
2002-02-19 18:48:28 +03:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
nsTableRowFrame* firstRowFrame = nullptr;
|
|
|
|
nsTableRowFrame* lastRowFrame = nullptr;
|
2002-02-19 18:48:28 +03:00
|
|
|
for (nsTableRowFrame* rowFrame = GetFirstRow(); rowFrame; rowFrame = rowFrame->GetNextRow()) {
|
2003-09-13 20:26:30 +04:00
|
|
|
if (!firstRowFrame) {
|
2002-02-19 18:48:28 +03:00
|
|
|
firstRowFrame = rowFrame;
|
|
|
|
}
|
|
|
|
lastRowFrame = rowFrame;
|
|
|
|
}
|
|
|
|
if (firstRowFrame) {
|
2007-02-07 10:46:44 +03:00
|
|
|
aBorder.top = nsPresContext::CSSPixelsToAppUnits(firstRowFrame->GetTopBCBorderWidth());
|
|
|
|
aBorder.bottom = nsPresContext::CSSPixelsToAppUnits(lastRowFrame->GetBottomBCBorderWidth());
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return &aBorder;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
void nsTableRowGroupFrame::SetContinuousBCBorderWidth(uint8_t aForSide,
|
2004-03-09 09:48:35 +03:00
|
|
|
BCPixelSize aPixelValue)
|
|
|
|
{
|
|
|
|
switch (aForSide) {
|
|
|
|
case NS_SIDE_RIGHT:
|
|
|
|
mRightContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
case NS_SIDE_BOTTOM:
|
|
|
|
mBottomContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
case NS_SIDE_LEFT:
|
|
|
|
mLeftContBorderWidth = aPixelValue;
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
NS_ERROR("invalid NS_SIDE argument");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-02-20 23:22:18 +03:00
|
|
|
//nsILineIterator methods
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
2008-10-30 22:17:59 +03:00
|
|
|
nsTableRowGroupFrame::GetNumLines()
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
2008-10-30 22:17:59 +03:00
|
|
|
return GetRowCount();
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2008-10-30 22:17:59 +03:00
|
|
|
nsTableRowGroupFrame::GetDirection()
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
2008-02-20 23:22:18 +03:00
|
|
|
nsTableFrame* table = nsTableFrame::GetTableFrame(this);
|
2008-10-30 22:17:59 +03:00
|
|
|
return (NS_STYLE_DIRECTION_RTL ==
|
2013-02-17 01:51:02 +04:00
|
|
|
table->StyleVisibility()->mDirection);
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTableRowGroupFrame::GetLine(int32_t aLineNumber,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame** aFirstFrameOnLine,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t* aNumFramesOnLine,
|
2014-12-19 17:55:30 +03:00
|
|
|
nsRect& aLineBounds)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFirstFrameOnLine);
|
|
|
|
NS_ENSURE_ARG_POINTER(aNumFramesOnLine);
|
|
|
|
|
2008-02-20 23:22:18 +03:00
|
|
|
nsTableFrame* table = nsTableFrame::GetTableFrame(this);
|
|
|
|
nsTableCellMap* cellMap = table->GetCellMap();
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
*aFirstFrameOnLine = nullptr;
|
2008-02-20 23:22:18 +03:00
|
|
|
*aNumFramesOnLine = 0;
|
|
|
|
aLineBounds.SetRect(0, 0, 0, 0);
|
2000-05-11 05:04:39 +04:00
|
|
|
|
2008-02-20 23:22:18 +03:00
|
|
|
if ((aLineNumber < 0) || (aLineNumber >= GetRowCount())) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
aLineNumber += GetStartRowIndex();
|
2001-01-27 02:40:36 +03:00
|
|
|
|
2005-10-17 04:03:05 +04:00
|
|
|
*aNumFramesOnLine = cellMap->GetNumCellsOriginatingInRow(aLineNumber);
|
2008-02-20 23:22:18 +03:00
|
|
|
if (*aNumFramesOnLine == 0) {
|
|
|
|
return NS_OK;
|
2000-05-14 04:10:25 +04:00
|
|
|
}
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colCount = table->GetColCount();
|
|
|
|
for (int32_t i = 0; i < colCount; i++) {
|
2008-02-20 23:22:18 +03:00
|
|
|
CellData* data = cellMap->GetDataAt(aLineNumber, i);
|
|
|
|
if (data && data->IsOrig()) {
|
|
|
|
*aFirstFrameOnLine = (nsIFrame*)data->GetCellFrame();
|
|
|
|
nsIFrame* parent = (*aFirstFrameOnLine)->GetParent();
|
|
|
|
aLineBounds = parent->GetRect();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-10-17 04:03:05 +04:00
|
|
|
}
|
2008-02-20 23:22:18 +03:00
|
|
|
NS_ERROR("cellmap is lying");
|
|
|
|
return NS_ERROR_FAILURE;
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t
|
|
|
|
nsTableRowGroupFrame::FindLineContaining(nsIFrame* aFrame, int32_t aStartLine)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
2012-07-27 18:03:25 +04:00
|
|
|
NS_ENSURE_TRUE(aFrame, -1);
|
2008-02-20 23:22:18 +03:00
|
|
|
|
2009-03-25 01:10:06 +03:00
|
|
|
nsTableRowFrame *rowFrame = do_QueryFrame(aFrame);
|
|
|
|
NS_ASSERTION(rowFrame, "RowGroup contains a frame that is not a row");
|
2001-07-18 00:27:01 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t rowIndexInGroup = rowFrame->GetRowIndex() - GetStartRowIndex();
|
2011-09-07 06:57:46 +04:00
|
|
|
|
|
|
|
return rowIndexInGroup >= aStartLine ? rowIndexInGroup : -1;
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
|
|
|
|
2001-03-13 01:25:55 +03:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTableRowGroupFrame::CheckLineOrder(int32_t aLine,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool *aIsReordered,
|
2001-03-13 01:25:55 +03:00
|
|
|
nsIFrame **aFirstVisual,
|
|
|
|
nsIFrame **aLastVisual)
|
|
|
|
{
|
2011-10-17 18:59:28 +04:00
|
|
|
*aIsReordered = false;
|
2012-07-30 18:20:58 +04:00
|
|
|
*aFirstVisual = nullptr;
|
|
|
|
*aLastVisual = nullptr;
|
2001-03-13 01:25:55 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2014-04-24 05:15:29 +04:00
|
|
|
|
2000-05-11 05:04:39 +04:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTableRowGroupFrame::FindFrameAt(int32_t aLineNumber,
|
2014-11-22 17:39:03 +03:00
|
|
|
nsPoint aPos,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame** aFrameFound,
|
2014-11-22 17:39:03 +03:00
|
|
|
bool* aPosIsBeforeFirstFrame,
|
|
|
|
bool* aPosIsAfterLastFrame)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
2014-11-22 17:39:03 +03:00
|
|
|
nsTableFrame* table = nsTableFrame::GetTableFrame(this);
|
|
|
|
nsTableCellMap* cellMap = table->GetCellMap();
|
|
|
|
|
|
|
|
WritingMode wm = table->GetWritingMode();
|
|
|
|
nscoord cw = table->GetRect().width;
|
|
|
|
LogicalPoint pos(wm, aPos, cw);
|
|
|
|
|
|
|
|
*aFrameFound = nullptr;
|
|
|
|
*aPosIsBeforeFirstFrame = true;
|
|
|
|
*aPosIsAfterLastFrame = false;
|
|
|
|
|
|
|
|
aLineNumber += GetStartRowIndex();
|
|
|
|
int32_t numCells = cellMap->GetNumCellsOriginatingInRow(aLineNumber);
|
|
|
|
if (numCells == 0) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* frame = nullptr;
|
|
|
|
int32_t colCount = table->GetColCount();
|
|
|
|
for (int32_t i = 0; i < colCount; i++) {
|
|
|
|
CellData* data = cellMap->GetDataAt(aLineNumber, i);
|
|
|
|
if (data && data->IsOrig()) {
|
|
|
|
frame = (nsIFrame*)data->GetCellFrame();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NS_ASSERTION(frame, "cellmap is lying");
|
|
|
|
bool isRTL = (NS_STYLE_DIRECTION_RTL ==
|
|
|
|
table->StyleVisibility()->mDirection);
|
2008-02-20 23:22:18 +03:00
|
|
|
|
2014-11-22 17:39:03 +03:00
|
|
|
nsIFrame* closestFromStart = nullptr;
|
|
|
|
nsIFrame* closestFromEnd = nullptr;
|
|
|
|
int32_t n = numCells;
|
|
|
|
nsIFrame* firstFrame = frame;
|
|
|
|
while (n--) {
|
|
|
|
LogicalRect rect = frame->GetLogicalRect(wm, cw);
|
|
|
|
if (rect.ISize(wm) > 0) {
|
|
|
|
// If pos.I() is inside this frame - this is it
|
|
|
|
if (rect.IStart(wm) <= pos.I(wm) && rect.IEnd(wm) > pos.I(wm)) {
|
|
|
|
closestFromStart = closestFromEnd = frame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (rect.IStart(wm) < pos.I(wm)) {
|
|
|
|
if (!closestFromStart ||
|
|
|
|
rect.IEnd(wm) > closestFromStart->GetLogicalRect(wm, cw).IEnd(wm))
|
|
|
|
closestFromStart = frame;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!closestFromEnd ||
|
|
|
|
rect.IStart(wm) < closestFromEnd->GetLogicalRect(wm, cw).IStart(wm))
|
|
|
|
closestFromEnd = frame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
frame = frame->GetNextSibling();
|
|
|
|
}
|
|
|
|
if (!closestFromStart && !closestFromEnd) {
|
|
|
|
// All frames were zero-width. Just take the first one.
|
|
|
|
closestFromStart = closestFromEnd = firstFrame;
|
|
|
|
}
|
|
|
|
*aPosIsBeforeFirstFrame = isRTL ? !closestFromEnd : !closestFromStart;
|
|
|
|
*aPosIsAfterLastFrame = isRTL ? !closestFromStart : !closestFromEnd;
|
|
|
|
if (closestFromStart == closestFromEnd) {
|
|
|
|
*aFrameFound = closestFromStart;
|
|
|
|
}
|
|
|
|
else if (!closestFromStart) {
|
|
|
|
*aFrameFound = closestFromEnd;
|
|
|
|
}
|
|
|
|
else if (!closestFromEnd) {
|
|
|
|
*aFrameFound = closestFromStart;
|
|
|
|
}
|
|
|
|
else { // we're between two frames
|
|
|
|
nscoord delta = closestFromEnd->GetLogicalRect(wm, cw).IStart(wm) -
|
|
|
|
closestFromStart->GetLogicalRect(wm, cw).IEnd(wm);
|
|
|
|
if (pos.I(wm) < closestFromStart->GetLogicalRect(wm, cw).IEnd(wm) + delta/2) {
|
|
|
|
*aFrameFound = closestFromStart;
|
|
|
|
} else {
|
|
|
|
*aFrameFound = closestFromEnd;
|
|
|
|
}
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2001-03-13 09:38:59 +03:00
|
|
|
nsTableRowGroupFrame::GetNextSiblingOnLine(nsIFrame*& aFrame,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aLineNumber)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aFrame);
|
2008-02-09 20:10:58 +03:00
|
|
|
aFrame = aFrame->GetNextSibling();
|
2000-05-11 05:04:39 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2000-05-11 18:56:29 +04:00
|
|
|
//end nsLineIterator methods
|
|
|
|
|
2015-02-05 02:22:27 +03:00
|
|
|
NS_DECLARE_FRAME_PROPERTY(RowCursorProperty,
|
|
|
|
DeleteValue<nsTableRowGroupFrame::FrameCursorData>)
|
2010-03-29 05:46:55 +04:00
|
|
|
|
2006-09-20 01:39:33 +04:00
|
|
|
void
|
|
|
|
nsTableRowGroupFrame::ClearRowCursor()
|
|
|
|
{
|
|
|
|
if (!(GetStateBits() & NS_ROWGROUP_HAS_ROW_CURSOR))
|
|
|
|
return;
|
|
|
|
|
|
|
|
RemoveStateBits(NS_ROWGROUP_HAS_ROW_CURSOR);
|
2010-03-29 05:46:55 +04:00
|
|
|
Properties().Delete(RowCursorProperty());
|
2006-09-20 01:39:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsTableRowGroupFrame::FrameCursorData*
|
|
|
|
nsTableRowGroupFrame::SetupRowCursor()
|
|
|
|
{
|
|
|
|
if (GetStateBits() & NS_ROWGROUP_HAS_ROW_CURSOR) {
|
|
|
|
// We already have a valid row cursor. Don't waste time rebuilding it.
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-09-20 01:39:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame* f = mFrames.FirstChild();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t count;
|
2006-09-20 01:39:33 +04:00
|
|
|
for (count = 0; f && count < MIN_ROWS_NEEDING_CURSOR; ++count) {
|
|
|
|
f = f->GetNextSibling();
|
|
|
|
}
|
|
|
|
if (!f) {
|
|
|
|
// Less than MIN_ROWS_NEEDING_CURSOR rows, so just don't bother
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-09-20 01:39:33 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
FrameCursorData* data = new FrameCursorData();
|
|
|
|
if (!data)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-03-29 05:46:55 +04:00
|
|
|
Properties().Set(RowCursorProperty(), data);
|
2006-09-20 01:39:33 +04:00
|
|
|
AddStateBits(NS_ROWGROUP_HAS_ROW_CURSOR);
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIFrame*
|
|
|
|
nsTableRowGroupFrame::GetFirstRowContaining(nscoord aY, nscoord* aOverflowAbove)
|
|
|
|
{
|
|
|
|
if (!(GetStateBits() & NS_ROWGROUP_HAS_ROW_CURSOR))
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-09-20 01:39:33 +04:00
|
|
|
|
2007-07-08 11:08:04 +04:00
|
|
|
FrameCursorData* property = static_cast<FrameCursorData*>
|
2010-03-29 05:46:55 +04:00
|
|
|
(Properties().Get(RowCursorProperty()));
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t cursorIndex = property->mCursorIndex;
|
|
|
|
uint32_t frameCount = property->mFrames.Length();
|
2006-09-20 01:39:33 +04:00
|
|
|
if (cursorIndex >= frameCount)
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2006-09-20 01:39:33 +04:00
|
|
|
nsIFrame* cursorFrame = property->mFrames[cursorIndex];
|
|
|
|
|
|
|
|
// The cursor's frame list excludes frames with empty overflow-area, so
|
|
|
|
// we don't need to check that here.
|
|
|
|
|
|
|
|
// We use property->mOverflowBelow here instead of computing the frame's
|
|
|
|
// true overflowArea.YMost(), because it is essential for the thresholds
|
|
|
|
// to form a monotonically increasing sequence. Otherwise we would break
|
|
|
|
// encountering a row whose overflowArea.YMost() is <= aY but which has
|
|
|
|
// a row above it containing cell(s) that span to include aY.
|
|
|
|
while (cursorIndex > 0 &&
|
2014-08-20 05:24:58 +04:00
|
|
|
cursorFrame->GetNormalRect().YMost() + property->mOverflowBelow > aY) {
|
2006-09-20 01:39:33 +04:00
|
|
|
--cursorIndex;
|
|
|
|
cursorFrame = property->mFrames[cursorIndex];
|
|
|
|
}
|
|
|
|
while (cursorIndex + 1 < frameCount &&
|
2014-08-20 05:24:58 +04:00
|
|
|
cursorFrame->GetNormalRect().YMost() + property->mOverflowBelow <= aY) {
|
2006-09-20 01:39:33 +04:00
|
|
|
++cursorIndex;
|
|
|
|
cursorFrame = property->mFrames[cursorIndex];
|
|
|
|
}
|
|
|
|
|
|
|
|
property->mCursorIndex = cursorIndex;
|
|
|
|
*aOverflowAbove = property->mOverflowAbove;
|
|
|
|
return cursorFrame;
|
|
|
|
}
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2006-09-20 01:39:33 +04:00
|
|
|
nsTableRowGroupFrame::FrameCursorData::AppendFrame(nsIFrame* aFrame)
|
|
|
|
{
|
2014-08-20 05:24:58 +04:00
|
|
|
// Relative positioning can cause table parts to move, but we will still paint
|
|
|
|
// the backgrounds for the parts under them at their 'normal' position. That
|
|
|
|
// means that we must consider the overflow rects at both positions. For
|
|
|
|
// example, if we use relative positioning to move a row-spanning cell, we
|
|
|
|
// will still paint the row background for that cell at its normal position,
|
|
|
|
// which will overflow the row.
|
|
|
|
// XXX(seth): This probably isn't correct in the presence of transforms.
|
|
|
|
nsRect positionedOverflowRect = aFrame->GetVisualOverflowRect();
|
|
|
|
nsPoint positionedToNormal = aFrame->GetNormalPosition() - aFrame->GetPosition();
|
|
|
|
nsRect normalOverflowRect = positionedOverflowRect + positionedToNormal;
|
|
|
|
|
|
|
|
nsRect overflowRect = positionedOverflowRect.Union(normalOverflowRect);
|
2006-09-20 01:39:33 +04:00
|
|
|
if (overflowRect.IsEmpty())
|
2011-10-17 18:59:28 +04:00
|
|
|
return true;
|
2006-09-20 01:39:33 +04:00
|
|
|
nscoord overflowAbove = -overflowRect.y;
|
|
|
|
nscoord overflowBelow = overflowRect.YMost() - aFrame->GetSize().height;
|
2013-01-15 16:22:03 +04:00
|
|
|
mOverflowAbove = std::max(mOverflowAbove, overflowAbove);
|
|
|
|
mOverflowBelow = std::max(mOverflowBelow, overflowBelow);
|
2012-07-30 18:20:58 +04:00
|
|
|
return mFrames.AppendElement(aFrame) != nullptr;
|
2006-09-20 01:39:33 +04:00
|
|
|
}
|
2012-08-29 09:39:31 +04:00
|
|
|
|
|
|
|
void
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableRowGroupFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
nsIFrame::InvalidateFrame(aDisplayItemKey);
|
|
|
|
GetParent()->InvalidateFrameWithRect(GetVisualOverflowRect() + GetPosition(), aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsTableRowGroupFrame::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
|
|
|
}
|