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)
|
|
|
|
{
|
2015-06-23 23:41:29 +03:00
|
|
|
if (HasAnyStateBits(NS_FRAME_CAN_HAVE_ABSPOS_CHILDREN)) {
|
2014-03-11 02:41:17 +04:00
|
|
|
nsTableFrame::UnregisterPositionedTablePart(this, aDestructRoot);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsContainerFrame::DestroyFrom(aDestructRoot);
|
|
|
|
}
|
|
|
|
|
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
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2009-09-18 22:52:58 +04:00
|
|
|
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) {
|
2015-04-30 07:24:59 +03:00
|
|
|
return GetTableFrame()->GetStartRowIndex(this);
|
2000-09-14 10:49:47 +04:00
|
|
|
}
|
2015-04-17 21:42:05 +03: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
|
|
|
{
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* rowFrame : mFrames) {
|
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);
|
2015-04-17 21:42:05 +03: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
|
|
|
}
|
2015-04-17 21:42:05 +03: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,
|
2015-03-21 19:28:04 +03:00
|
|
|
nsRenderingContext* aCtx) 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)
|
|
|
|
{
|
2015-04-30 07:24:59 +03:00
|
|
|
auto rgFrame = static_cast<nsTableRowGroupFrame*>(mFrame);
|
|
|
|
TableBackgroundPainter painter(rgFrame->GetTableFrame(),
|
2006-01-26 05:29:17 +03:00
|
|
|
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
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
DrawResult result = painter.PaintRowGroup(rgFrame);
|
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);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
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
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
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);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
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
|
|
|
}
|
2015-04-17 21:42:05 +03: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;
|
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// Position and size aKidFrame and update our reflow state.
|
2015-04-17 21:42:05 +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,
|
2015-06-20 23:00:26 +03:00
|
|
|
WritingMode aWM,
|
|
|
|
const LogicalPoint& aKidPosition,
|
2015-07-16 12:07:57 +03:00
|
|
|
const nsSize& aContainerSize,
|
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
|
|
|
{
|
2015-06-23 23:41:29 +03:00
|
|
|
bool isFirstReflow = aKidFrame->HasAnyStateBits(NS_FRAME_FIRST_REFLOW);
|
2012-08-29 09:48:45 +04:00
|
|
|
|
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,
|
2015-07-16 12:07:57 +03:00
|
|
|
aWM, aKidPosition, aContainerSize, 0);
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableFrame::InvalidateTableFrame(aKidFrame, aOriginalKidRect,
|
|
|
|
aOriginalKidVisualOverflow, isFirstReflow);
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// Adjust the running block-offset
|
|
|
|
aReflowState.bCoord += aDesiredSize.BSize(aWM);
|
1998-04-14 00:24:54 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// If our block-size is constrained then update the available bsize
|
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.BSize(aWM)) {
|
|
|
|
aReflowState.availSize.BSize(aWM) -= aDesiredSize.BSize(aWM);
|
1998-04-14 00:24:54 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-02-19 18:48:28 +03:00
|
|
|
void
|
2015-04-17 21:42:05 +03:00
|
|
|
nsTableRowGroupFrame::InitChildReflowState(nsPresContext& aPresContext,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aBorderCollapse,
|
2015-04-17 21:42:05 +03:00
|
|
|
nsHTMLReflowState& aReflowState)
|
2002-02-19 18:48:28 +03:00
|
|
|
{
|
|
|
|
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) {
|
2015-05-04 10:09:25 +03:00
|
|
|
WritingMode wm = GetWritingMode();
|
|
|
|
LogicalMargin border = rowFrame->GetBCBorderWidth(wm);
|
|
|
|
collapseBorder = border.GetPhysicalMargin(wm);
|
|
|
|
pCollapseBorder = &collapseBorder;
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
|
|
|
}
|
2015-06-04 13:43:02 +03:00
|
|
|
aReflowState.Init(&aPresContext, nullptr, pCollapseBorder, &padding);
|
2002-02-19 18:48:28 +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
|
|
|
static void
|
2015-06-20 23:00:26 +03:00
|
|
|
CacheRowBSizesForPrinting(nsPresContext* aPresContext,
|
|
|
|
nsTableRowFrame* aFirstRow,
|
|
|
|
WritingMode aWM)
|
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* row = aFirstRow; row; row = row->GetNextRow()) {
|
|
|
|
if (!row->GetPrevInFlow()) {
|
2015-06-20 23:00:26 +03:00
|
|
|
row->SetHasUnpaginatedBSize(true);
|
|
|
|
row->SetUnpaginatedBSize(aPresContext, row->BSize(aWM));
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-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
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
if (aPageBreakBeforeEnd) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aPageBreakBeforeEnd = false;
|
2015-06-20 23:00:26 +03:00
|
|
|
}
|
2002-03-18 00:35:08 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
WritingMode wm = aReflowState.reflowState.GetWritingMode();
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2012-01-17 03:38:10 +04:00
|
|
|
const bool borderCollapse = tableFrame->IsBorderCollapse();
|
1999-06-23 07:02:21 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// XXXldb Should we really be checking IsPaginated(),
|
|
|
|
// or should we *only* check available block-size?
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
// (Think about multi-column layout!)
|
2015-04-17 21:42:05 +03:00
|
|
|
bool isPaginated = aPresContext->IsPaginated() &&
|
2015-06-20 23:00:26 +03:00
|
|
|
NS_UNCONSTRAINEDSIZE != aReflowState.availSize.BSize(wm);
|
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();
|
2015-06-27 02:50:21 +03:00
|
|
|
|
|
|
|
// in vertical-rl mode, we always need the row bsizes in order to
|
2015-07-16 12:07:57 +03:00
|
|
|
// get the necessary containerSize for placing our kids
|
2015-06-27 02:50:21 +03:00
|
|
|
bool needToCalcRowBSizes = reflowAllKids || wm.IsVerticalRL();
|
2015-06-20 23:00:26 +03:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize =
|
|
|
|
aReflowState.reflowState.ComputedSizeAsContainerIfConstrained();
|
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
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord cellSpacingB = tableFrame->GetRowSpacing(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) ||
|
2015-06-22 12:33:34 +03:00
|
|
|
(aReflowState.reflowState.mFlags.mSpecialBSizeReflow &&
|
2015-06-23 23:41:29 +03:00
|
|
|
(isPaginated ||
|
|
|
|
kidFrame->HasAnyStateBits(NS_FRAME_CONTAINS_RELATIVE_BSIZE)))) {
|
2015-07-16 12:07:57 +03:00
|
|
|
LogicalRect oldKidRect = kidFrame->GetLogicalRect(wm, containerSize);
|
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();
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// Reflow the child into the available space, giving it as much bsize as
|
1999-08-02 02:01:37 +04:00
|
|
|
// it wants. We'll deal with splitting later after we've computed the row
|
2015-06-20 23:00:26 +03:00
|
|
|
// bsizes, taking into account cells with row spans...
|
|
|
|
LogicalSize kidAvailSize = aReflowState.availSize;
|
2014-07-24 12:28:46 +04:00
|
|
|
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,
|
2015-06-04 13:43:02 +03:00
|
|
|
nullptr,
|
2013-09-10 00:29:05 +04:00
|
|
|
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.
|
2015-06-20 23:00:26 +03:00
|
|
|
if (aReflowState.reflowState.IsIResize()) {
|
|
|
|
kidReflowState.SetIResize(true);
|
2014-11-28 12:44:02 +03:00
|
|
|
}
|
2015-04-17 21:42:05 +03: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
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalPoint kidPosition(wm, 0, aReflowState.bCoord);
|
2014-05-13 04:47:53 +04:00
|
|
|
ReflowChild(kidFrame, aPresContext, desiredSize, kidReflowState,
|
2015-07-16 12:07:57 +03:00
|
|
|
wm, kidPosition, containerSize, 0, aStatus);
|
|
|
|
kidReflowState.ApplyRelativePositioning(&kidPosition, containerSize);
|
2001-08-22 08:18:48 +04:00
|
|
|
|
1999-08-03 06:41:27 +04:00
|
|
|
// Place the child
|
2015-06-20 23:00:26 +03:00
|
|
|
PlaceChild(aPresContext, aReflowState, kidFrame,
|
2015-07-16 12:07:57 +03:00
|
|
|
wm, kidPosition, containerSize,
|
|
|
|
desiredSize, oldKidRect.GetPhysicalRect(wm, containerSize),
|
2015-06-20 23:00:26 +03:00
|
|
|
oldKidVisualOverflow);
|
|
|
|
aReflowState.bCoord += cellSpacingB;
|
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) {
|
2015-06-27 02:50:21 +03:00
|
|
|
if (IsSimpleRowFrame(aReflowState.tableFrame, rowFrame)) {
|
2015-06-20 23:00:26 +03:00
|
|
|
// Inform the row of its new bsize.
|
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();
|
2015-06-20 23:00:26 +03:00
|
|
|
nsStyleUnit unit = stylePos->BSize(wm).GetUnit();
|
2015-06-22 12:33:34 +03:00
|
|
|
if (aReflowState.tableFrame->IsAutoBSize(wm) &&
|
2008-09-20 13:30:30 +04:00
|
|
|
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();
|
2015-06-20 23:00:26 +03:00
|
|
|
} else if (oldKidRect.BSize(wm) != desiredSize.BSize(wm)) {
|
|
|
|
needToCalcRowBSizes = 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 {
|
2015-06-20 23:00:26 +03:00
|
|
|
needToCalcRowBSizes = 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);
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// Adjust the running b-offset so we know where the next row should be placed
|
|
|
|
nscoord bSize = kidFrame->BSize(wm) + cellSpacingB;
|
|
|
|
aReflowState.bCoord += bSize;
|
1999-06-23 07:02:21 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (NS_UNCONSTRAINEDSIZE != aReflowState.availSize.BSize(wm)) {
|
|
|
|
aReflowState.availSize.BSize(wm) -= bSize;
|
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
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (haveRow) {
|
|
|
|
aReflowState.bCoord -= tableFrame->GetRowSpacing(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
|
2015-06-20 23:00:26 +03:00
|
|
|
aDesiredSize.ISize(wm) = aReflowState.reflowState.AvailableISize();
|
|
|
|
aDesiredSize.BSize(wm) = aReflowState.bCoord;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2015-06-22 12:33:34 +03:00
|
|
|
if (aReflowState.reflowState.mFlags.mSpecialBSizeReflow) {
|
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) {
|
2015-06-20 23:00:26 +03:00
|
|
|
CacheRowBSizesForPrinting(aPresContext, GetFirstRow(), wm);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
}
|
2002-03-31 21:44:57 +04:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
else if (needToCalcRowBSizes) {
|
|
|
|
CalculateRowBSizes(aPresContext, aDesiredSize, aReflowState.reflowState);
|
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) {
|
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
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
nsTableRowFrame*
|
|
|
|
nsTableRowGroupFrame::GetFirstRow()
|
1999-03-17 02:42:38 +03:00
|
|
|
{
|
2015-06-29 23:02:21 +03:00
|
|
|
for (nsIFrame* childFrame : mFrames) {
|
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 {
|
2015-06-20 23:00:26 +03:00
|
|
|
RowInfo() { bSize = pctBSize = hasStyleBSize = hasPctBSize = isSpecial = 0; }
|
|
|
|
unsigned bSize; // content bsize or fixed bsize, excluding pct bsize
|
|
|
|
unsigned pctBSize:29; // pct bsize
|
|
|
|
unsigned hasStyleBSize:1;
|
|
|
|
unsigned hasPctBSize: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
|
2015-06-20 23:00:26 +03:00
|
|
|
// least 2 cells spanning the row and there is no style bsize on the row
|
2001-11-05 03:15:51 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2015-06-20 23:00:26 +03:00
|
|
|
UpdateBSizes(RowInfo& aRowInfo,
|
|
|
|
nscoord aAdditionalBSize,
|
|
|
|
nscoord& aTotal,
|
|
|
|
nscoord& aUnconstrainedTotal)
|
2001-11-05 03:15:51 +03:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
aRowInfo.bSize += aAdditionalBSize;
|
|
|
|
aTotal += aAdditionalBSize;
|
|
|
|
if (!aRowInfo.hasStyleBSize) {
|
|
|
|
aUnconstrainedTotal += aAdditionalBSize;
|
1999-03-17 02:42:38 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
void
|
2007-01-28 01:22:24 +03:00
|
|
|
nsTableRowGroupFrame::DidResizeRows(nsHTMLReflowMetrics& aDesiredSize)
|
2000-02-03 17:04:49 +03:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
// Update the cells spanning rows with their new bsizes.
|
|
|
|
// This is the place where all of the cells in the row get set to the bsize
|
|
|
|
// of the row.
|
|
|
|
// 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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// This calculates the bsize of all the rows and takes into account
|
|
|
|
// style bsize on the row group, style bsizes on rows and cells, style bsizes on rowspans.
|
|
|
|
// Actual row bsizes will be adjusted later if the table has a style bsize.
|
|
|
|
// Even if rows don't change bsize, this method must be called to set the bsizes of each
|
|
|
|
// cell in the row to the bsize of its row.
|
2015-04-17 21:42:05 +03:00
|
|
|
void
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowGroupFrame::CalculateRowBSizes(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
|
|
|
{
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
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();
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (!startRowFrame) {
|
|
|
|
return;
|
|
|
|
}
|
2001-08-22 08:18:48 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// The current row group block-size is the block-origin of the 1st row
|
|
|
|
// we are about to calculate a block-size for.
|
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize; // actual value is unimportant as we're initially
|
|
|
|
// computing sizes, not physical positions
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord startRowGroupBSize =
|
2015-07-16 12:07:57 +03:00
|
|
|
startRowFrame->GetLogicalNormalPosition(wm, containerSize).B(wm);
|
2001-08-22 08:18:48 +04:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t numRows = GetRowCount() - (startRowFrame->GetRowIndex() - GetStartRowIndex());
|
2015-06-20 23:00:26 +03:00
|
|
|
// Collect the current bsize of each row.
|
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;
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bSizeOfRows = 0;
|
|
|
|
nscoord bSizeOfUnStyledRows = 0;
|
|
|
|
// Get the bsize of each row without considering rowspans. This will be the max of
|
|
|
|
// the largest desired bsize of each cell, the largest style bsize of each cell,
|
|
|
|
// the style bsize of the row.
|
|
|
|
nscoord pctBSizeBasis = GetBSizeBasis(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++) {
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord nonPctBSize = rowFrame->GetContentBSize();
|
2002-03-27 08:50:24 +03:00
|
|
|
if (isPaginated) {
|
2015-06-20 23:00:26 +03:00
|
|
|
nonPctBSize = std::max(nonPctBSize, rowFrame->BSize(wm));
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
if (!rowFrame->GetPrevInFlow()) {
|
2015-06-20 23:00:26 +03:00
|
|
|
if (rowFrame->HasPctBSize()) {
|
|
|
|
rowInfo[rowIndex].hasPctBSize = true;
|
2015-06-23 23:41:31 +03:00
|
|
|
rowInfo[rowIndex].pctBSize = rowFrame->GetInitialBSize(pctBSizeBasis);
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
rowInfo[rowIndex].hasStyleBSize = rowFrame->HasStyleBSize();
|
|
|
|
nonPctBSize = std::max(nonPctBSize, rowFrame->GetFixedBSize());
|
2001-11-14 16:44:38 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
UpdateBSizes(rowInfo[rowIndex], nonPctBSize, bSizeOfRows, bSizeOfUnStyledRows);
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (!rowInfo[rowIndex].hasStyleBSize) {
|
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);
|
2015-04-17 21:42:05 +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;
|
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
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) {
|
2015-06-20 23:00:26 +03:00
|
|
|
// Get the bsize of cells with rowspans and allocate any extra space to the rows they span
|
2001-11-05 03:15:51 +03:00
|
|
|
// iteratate the child frames and process the row frames among them
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
2015-04-17 21:42:05 +03:00
|
|
|
// See if the row has an originating cell with rowspan > 1. We cannot determine this for a row in a
|
2002-03-27 08:50:24 +03:00
|
|
|
// 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();
|
2015-04-17 21:42:05 +03:00
|
|
|
// iteratate the row's cell frames
|
2001-11-05 03:15:51 +03:00
|
|
|
while (cellFrame) {
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord cellSpacingB = tableFrame->GetRowSpacing(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;
|
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
if (rowSpan > 1) { // a cell with rowspan > 1, determine the bsize of the rows it spans
|
|
|
|
nscoord bsizeOfRowsSpanned = 0;
|
|
|
|
nscoord bsizeOfUnStyledRowsSpanned = 0;
|
2015-04-17 21:42:05 +03:00
|
|
|
nscoord numSpecialRowsSpanned = 0;
|
2001-11-05 03:15:51 +03:00
|
|
|
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++) {
|
2015-06-20 23:00:26 +03:00
|
|
|
bsizeOfRowsSpanned += rowInfo[rowIndex + spanX].bSize;
|
|
|
|
if (!rowInfo[rowIndex + spanX].hasStyleBSize) {
|
|
|
|
bsizeOfUnStyledRowsSpanned += rowInfo[rowIndex + spanX].bSize;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
if (0 != spanX) {
|
2015-06-20 23:00:26 +03:00
|
|
|
cellSpacingTotal += cellSpacingB;
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
if (rowInfo[rowIndex + spanX].isSpecial) {
|
|
|
|
numSpecialRowsSpanned++;
|
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bsizeOfAreaSpanned = bsizeOfRowsSpanned + cellSpacingTotal;
|
|
|
|
// get the bsize of the cell
|
|
|
|
LogicalSize cellFrameSize = cellFrame->GetLogicalSize(wm);
|
|
|
|
LogicalSize cellDesSize = cellFrame->GetDesiredSize();
|
|
|
|
rowFrame->CalculateCellActualBSize(cellFrame, cellDesSize.BSize(wm), wm);
|
|
|
|
cellFrameSize.BSize(wm) = cellDesSize.BSize(wm);
|
2001-11-05 03:15:51 +03:00
|
|
|
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.
|
2015-06-20 23:00:26 +03:00
|
|
|
cellFrameSize.BSize(wm) += rowFrame->GetMaxCellAscent() -
|
|
|
|
cellFrame->GetCellBaseline();
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (bsizeOfAreaSpanned < cellFrameSize.BSize(wm)) {
|
|
|
|
// the cell's bsize is larger than the available space of the rows it
|
|
|
|
// spans so distribute the excess bsize to the rows affected
|
|
|
|
nscoord extra = cellFrameSize.BSize(wm) - bsizeOfAreaSpanned;
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord extraUsed = 0;
|
|
|
|
if (0 == numSpecialRowsSpanned) {
|
2015-06-20 23:00:26 +03:00
|
|
|
//NS_ASSERTION(bsizeOfRowsSpanned > 0, "invalid row span situation");
|
|
|
|
bool haveUnStyledRowsSpanned = (bsizeOfUnStyledRowsSpanned > 0);
|
2015-04-17 21:42:05 +03:00
|
|
|
nscoord divisor = (haveUnStyledRowsSpanned)
|
2015-06-20 23:00:26 +03:00
|
|
|
? bsizeOfUnStyledRowsSpanned : bsizeOfRowsSpanned;
|
2001-11-05 03:15:51 +03:00
|
|
|
if (divisor > 0) {
|
|
|
|
for (spanX = rowSpan - 1; spanX >= 0; spanX--) {
|
2015-06-20 23:00:26 +03:00
|
|
|
if (!haveUnStyledRowsSpanned || !rowInfo[rowIndex + spanX].hasStyleBSize) {
|
|
|
|
// The amount of additional space each row gets is proportional to its bsize
|
|
|
|
float percent = ((float)rowInfo[rowIndex + spanX].bSize) / ((float)divisor);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
// give rows their percentage, except for the first row which gets the remainder
|
2015-04-17 21:42:05 +03:00
|
|
|
nscoord extraForRow = (0 == spanX) ? extra - extraUsed
|
2001-11-05 03:15:51 +03:00
|
|
|
: NSToCoordRound(((float)(extra)) * percent);
|
2013-01-15 16:22:03 +04:00
|
|
|
extraForRow = std::min(extraForRow, extra - extraUsed);
|
2015-06-20 23:00:26 +03:00
|
|
|
// update the row bsize
|
|
|
|
UpdateBSizes(rowInfo[rowIndex + spanX], extraForRow, bSizeOfRows, bSizeOfUnStyledRows);
|
2001-11-05 03:15:51 +03:00
|
|
|
extraUsed += extraForRow;
|
|
|
|
if (extraUsed >= extra) {
|
2015-06-20 23:00:26 +03:00
|
|
|
NS_ASSERTION((extraUsed == extra), "invalid row bsize calculation");
|
2001-11-05 03:15:51 +03:00
|
|
|
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
|
2015-06-20 23:00:26 +03:00
|
|
|
UpdateBSizes(rowInfo[rowIndex + rowSpan - 1], extra, bSizeOfRows, bSizeOfUnStyledRows);
|
2001-11-05 03:15:51 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2001-11-05 03:15:51 +03:00
|
|
|
// give rows their percentage, except for the first row which gets the remainder
|
2015-04-17 21:42:05 +03:00
|
|
|
nscoord extraForRow = (numSpecialRowsSpanned - 1 == numSpecialRowsAllocated)
|
|
|
|
? extra - extraUsed
|
2001-11-05 03:15:51 +03:00
|
|
|
: NSToCoordRound(((float)(extra)) * percent);
|
2013-01-15 16:22:03 +04:00
|
|
|
extraForRow = std::min(extraForRow, extra - extraUsed);
|
2015-06-20 23:00:26 +03:00
|
|
|
// update the row bsize
|
|
|
|
UpdateBSizes(rowInfo[rowIndex + spanX], extraForRow, bSizeOfRows, bSizeOfUnStyledRows);
|
2001-11-05 03:15:51 +03:00
|
|
|
extraUsed += extraForRow;
|
|
|
|
if (extraUsed >= extra) {
|
2015-06-20 23:00:26 +03:00
|
|
|
NS_ASSERTION((extraUsed == extra), "invalid row bsize calculation");
|
2001-11-05 03:15:51 +03:00
|
|
|
break;
|
2000-02-04 05:49:27 +03:00
|
|
|
}
|
|
|
|
}
|
1998-09-16 00:36:42 +04:00
|
|
|
}
|
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
}
|
2001-11-05 03:15:51 +03:00
|
|
|
} // if (rowSpan > 1)
|
2015-04-17 21:42:05 +03:00
|
|
|
cellFrame = cellFrame->GetNextCell();
|
2001-11-05 03:15:51 +03:00
|
|
|
} // while (cellFrame)
|
|
|
|
} // if (tableFrame->RowHasSpanningCells(startRowIndex + rowIndex) {
|
|
|
|
} // while (rowFrame)
|
|
|
|
}
|
1999-12-14 01:56:31 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// pct bsize rows have already got their content bsizes.
|
|
|
|
// Give them their pct bsizes up to pctBSizeBasis
|
|
|
|
nscoord extra = pctBSizeBasis - bSizeOfRows;
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame && (extra > 0);
|
|
|
|
rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
2001-11-14 16:44:38 +03:00
|
|
|
RowInfo& rInfo = rowInfo[rowIndex];
|
2015-06-20 23:00:26 +03:00
|
|
|
if (rInfo.hasPctBSize) {
|
|
|
|
nscoord rowExtra = (rInfo.pctBSize > rInfo.bSize)
|
|
|
|
? rInfo.pctBSize - rInfo.bSize: 0;
|
2013-01-15 16:22:03 +04:00
|
|
|
rowExtra = std::min(rowExtra, extra);
|
2015-06-20 23:00:26 +03:00
|
|
|
UpdateBSizes(rInfo, rowExtra, bSizeOfRows, bSizeOfUnStyledRows);
|
2001-11-14 16:44:38 +03:00
|
|
|
extra -= rowExtra;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
bool styleBSizeAllocation = false;
|
|
|
|
nscoord rowGroupBSize = startRowGroupBSize + bSizeOfRows +
|
2015-03-20 07:16:00 +03:00
|
|
|
tableFrame->GetRowSpacing(0, numRows-1);
|
2015-06-20 23:00:26 +03:00
|
|
|
// if we have a style bsize, allocate the extra bsize to unconstrained rows
|
|
|
|
if ((aReflowState.ComputedBSize() > rowGroupBSize) &&
|
|
|
|
(NS_UNCONSTRAINEDSIZE != aReflowState.ComputedBSize())) {
|
|
|
|
nscoord extraComputedBSize = aReflowState.ComputedBSize() - rowGroupBSize;
|
2001-11-05 03:15:51 +03:00
|
|
|
nscoord extraUsed = 0;
|
2015-06-20 23:00:26 +03:00
|
|
|
bool haveUnStyledRows = (bSizeOfUnStyledRows > 0);
|
2015-04-17 21:42:05 +03:00
|
|
|
nscoord divisor = (haveUnStyledRows)
|
2015-06-20 23:00:26 +03:00
|
|
|
? bSizeOfUnStyledRows : bSizeOfRows;
|
2001-11-05 03:15:51 +03:00
|
|
|
if (divisor > 0) {
|
2015-06-20 23:00:26 +03:00
|
|
|
styleBSizeAllocation = true;
|
2001-11-05 03:15:51 +03:00
|
|
|
for (rowIndex = 0; rowIndex < numRows; rowIndex++) {
|
2015-06-20 23:00:26 +03:00
|
|
|
if (!haveUnStyledRows || !rowInfo[rowIndex].hasStyleBSize) {
|
2001-11-05 03:15:51 +03:00
|
|
|
// The amount of additional space each row gets is based on the
|
|
|
|
// percentage of space it occupies
|
2015-06-20 23:00:26 +03:00
|
|
|
float percent = ((float)rowInfo[rowIndex].bSize) / ((float)divisor);
|
2001-11-05 03:15:51 +03:00
|
|
|
// give rows their percentage, except for the last row which gets the remainder
|
2015-04-17 21:42:05 +03:00
|
|
|
nscoord extraForRow = (numRows - 1 == rowIndex)
|
2015-06-20 23:00:26 +03:00
|
|
|
? extraComputedBSize - extraUsed
|
|
|
|
: NSToCoordRound(((float)extraComputedBSize) * percent);
|
|
|
|
extraForRow = std::min(extraForRow, extraComputedBSize - extraUsed);
|
|
|
|
// update the row bsize
|
|
|
|
UpdateBSizes(rowInfo[rowIndex], extraForRow, bSizeOfRows, bSizeOfUnStyledRows);
|
2001-11-05 03:15:51 +03:00
|
|
|
extraUsed += extraForRow;
|
2015-06-20 23:00:26 +03:00
|
|
|
if (extraUsed >= extraComputedBSize) {
|
|
|
|
NS_ASSERTION((extraUsed == extraComputedBSize), "invalid row bsize calculation");
|
2001-11-05 03:15:51 +03:00
|
|
|
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
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
rowGroupBSize = aReflowState.ComputedBSize();
|
2015-06-20 23:00:26 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (wm.IsVertical()) {
|
2015-07-16 12:07:57 +03:00
|
|
|
// we need the correct containerSize below for block positioning in
|
2015-06-20 23:00:26 +03:00
|
|
|
// vertical-rl writing mode
|
2015-07-16 12:07:57 +03:00
|
|
|
containerSize.width = rowGroupBSize;
|
2015-06-20 23:00:26 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
nscoord bOrigin = startRowGroupBSize;
|
|
|
|
// update the rows with their (potentially) new bsizes
|
|
|
|
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame;
|
|
|
|
rowFrame = rowFrame->GetNextRow(), rowIndex++) {
|
2008-03-16 23:32:48 +03:00
|
|
|
nsRect rowBounds = rowFrame->GetRect();
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalSize rowBoundsSize(wm, rowBounds.Size());
|
2012-08-29 09:48:45 +04:00
|
|
|
nsRect rowVisualOverflow = rowFrame->GetVisualOverflowRect();
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord deltaB =
|
2015-07-16 12:07:57 +03:00
|
|
|
bOrigin - rowFrame->GetLogicalNormalPosition(wm, containerSize).B(wm);
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord rowBSize = (rowInfo[rowIndex].bSize > 0) ? rowInfo[rowIndex].bSize : 0;
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (deltaB != 0 || (rowBSize != rowBoundsSize.BSize(wm))) {
|
2008-02-08 12:36:32 +03:00
|
|
|
// Resize/move the row to its final size and position
|
2015-06-20 23:00:26 +03:00
|
|
|
if (deltaB != 0) {
|
2010-08-31 04:49:12 +04:00
|
|
|
rowFrame->InvalidateFrameSubtree();
|
2008-02-08 12:36:32 +03:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
rowFrame->MovePositionBy(wm, LogicalPoint(wm, 0, deltaB));
|
|
|
|
rowFrame->SetSize(LogicalSize(wm, rowBoundsSize.ISize(wm), rowBSize));
|
2012-08-29 09:48:45 +04:00
|
|
|
|
|
|
|
nsTableFrame::InvalidateTableFrame(rowFrame, rowBounds, rowVisualOverflow,
|
|
|
|
false);
|
2014-08-20 05:24:58 +04:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (deltaB != 0) {
|
2014-08-20 05:24:58 +04:00
|
|
|
nsTableFrame::RePositionViews(rowFrame);
|
|
|
|
// XXXbz we don't need to update our overflow area?
|
|
|
|
}
|
2000-04-29 01:05:31 +04:00
|
|
|
}
|
2015-06-20 23:00:26 +03:00
|
|
|
bOrigin += rowBSize + tableFrame->GetRowSpacing(startRowIndex + rowIndex);
|
1998-11-20 04:01:25 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (isPaginated && styleBSizeAllocation) {
|
|
|
|
// since the row group has a style bsize, cache the row bsizes,
|
|
|
|
// so next in flows can honor them
|
|
|
|
CacheRowBSizesForPrinting(aPresContext, GetFirstRow(), wm);
|
2002-03-27 08:50:24 +03:00
|
|
|
}
|
|
|
|
|
2007-01-28 01:22:24 +03:00
|
|
|
DidResizeRows(aDesiredSize);
|
2001-11-05 03:15:51 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
aDesiredSize.BSize(wm) = rowGroupBSize; // Adjust our desired size
|
1998-06-30 06:11:07 +04:00
|
|
|
}
|
|
|
|
|
2006-03-04 08:26:57 +03:00
|
|
|
nscoord
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowGroupFrame::CollapseRowGroupIfNecessary(nscoord aBTotalOffset,
|
2015-06-22 12:33:34 +03:00
|
|
|
nscoord aISize,
|
|
|
|
WritingMode aWM)
|
2006-03-04 08:26:57 +03:00
|
|
|
{
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize = tableFrame->GetSize();
|
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
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowFrame* rowFrame = GetFirstRow();
|
2011-09-29 10:19:26 +04:00
|
|
|
bool didCollapse = false;
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bGroupOffset = 0;
|
2006-03-04 08:26:57 +03:00
|
|
|
while (rowFrame) {
|
2015-06-20 23:00:26 +03:00
|
|
|
bGroupOffset += rowFrame->CollapseRowIfNecessary(bGroupOffset,
|
|
|
|
aISize, collapseGroup,
|
2006-03-04 08:26:57 +03:00
|
|
|
didCollapse);
|
2010-10-07 08:25:45 +04:00
|
|
|
ConsiderChildOverflow(overflow, rowFrame);
|
2006-03-04 08:26:57 +03:00
|
|
|
rowFrame = rowFrame->GetNextRow();
|
|
|
|
}
|
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
LogicalRect groupRect = GetLogicalRect(aWM, containerSize);
|
2015-06-20 23:00:26 +03:00
|
|
|
nsRect oldGroupRect = GetRect();
|
2012-08-29 09:48:45 +04:00
|
|
|
nsRect oldGroupVisualOverflow = GetVisualOverflowRect();
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-22 12:33:34 +03:00
|
|
|
groupRect.BSize(aWM) -= bGroupOffset;
|
2006-03-04 08:26:57 +03:00
|
|
|
if (didCollapse) {
|
|
|
|
// add back the cellspacing between rowgroups
|
2015-06-22 12:33:34 +03:00
|
|
|
groupRect.BSize(aWM) += tableFrame->GetRowSpacing(GetStartRowIndex() +
|
|
|
|
GetRowCount());
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
|
|
|
|
2015-06-22 12:33:34 +03:00
|
|
|
groupRect.BStart(aWM) -= aBTotalOffset;
|
|
|
|
groupRect.ISize(aWM) = aISize;
|
2008-02-08 12:36:32 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
if (aBTotalOffset != 0) {
|
2010-08-31 04:49:12 +04:00
|
|
|
InvalidateFrameSubtree();
|
2008-02-08 12:36:32 +03:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-07-16 12:07:57 +03:00
|
|
|
SetRect(aWM, groupRect, containerSize);
|
2015-06-22 12:33:34 +03:00
|
|
|
overflow.UnionAllWith(nsRect(0, 0, groupRect.Width(aWM),
|
|
|
|
groupRect.Height(aWM)));
|
|
|
|
FinishAndStoreOverflow(overflow, groupRect.Size(aWM).GetPhysicalSize(aWM));
|
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);
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
return bGroupOffset;
|
2006-03-04 08:26:57 +03:00
|
|
|
}
|
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
|
|
|
{
|
2015-07-16 12:07:57 +03:00
|
|
|
// Move the frame if we need to.
|
2015-06-20 23:00:26 +03:00
|
|
|
WritingMode wm = aReflowState.reflowState.GetWritingMode();
|
2015-07-16 12:07:57 +03:00
|
|
|
const nsSize containerSize =
|
|
|
|
aReflowState.reflowState.ComputedSizeAsContainerIfConstrained();
|
|
|
|
LogicalPoint oldPosition =
|
|
|
|
aKidFrame->GetLogicalNormalPosition(wm, containerSize);
|
2015-06-20 23:00:26 +03:00
|
|
|
LogicalPoint newPosition = oldPosition;
|
|
|
|
newPosition.B(wm) = aReflowState.bCoord;
|
|
|
|
if (oldPosition.B(wm) != newPosition.B(wm)) {
|
2010-08-31 04:49:12 +04:00
|
|
|
aKidFrame->InvalidateFrameSubtree();
|
2015-07-16 12:07:57 +03:00
|
|
|
aReflowState.reflowState.ApplyRelativePositioning(&newPosition,
|
|
|
|
containerSize);
|
|
|
|
aKidFrame->SetPosition(wm, newPosition, containerSize);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nsTableFrame::RePositionViews(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
|
2015-04-17 21:42:05 +03:00
|
|
|
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
|
2015-04-17 21:42:05 +03:00
|
|
|
// 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,
|
2015-04-17 21:42:05 +03:00
|
|
|
nsTableRowFrame& aFirstRow,
|
|
|
|
nsTableRowFrame& aLastRow,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aFirstRowIsTopOfPage,
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord aSpanningRowBEnd,
|
2002-10-03 18:33:23 +04:00
|
|
|
nsTableRowFrame*& aContRow,
|
|
|
|
nsTableRowFrame*& aFirstTruncatedRow,
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord& aDesiredBSize)
|
2001-04-16 18:51:52 +04:00
|
|
|
{
|
2015-06-20 23:00:26 +03:00
|
|
|
NS_ASSERTION(aSpanningRowBEnd >= 0, "Can't split negative bsizes");
|
2012-07-30 18:20:58 +04:00
|
|
|
aFirstTruncatedRow = nullptr;
|
2015-06-20 23:00:26 +03:00
|
|
|
aDesiredBSize = 0;
|
2002-10-03 18:33:23 +04:00
|
|
|
|
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
|
2015-06-20 23:00:26 +03:00
|
|
|
// were reflowed correctly during the unconstrained bsize reflow.
|
2002-10-03 18:33:23 +04:00
|
|
|
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;
|
2015-06-20 23:00:26 +03:00
|
|
|
// Ask the row to reflow the cell to the bsize of all the rows it spans up through aLastRow
|
|
|
|
// cellAvailBSize is the space between the row group start and the end of the page
|
|
|
|
nscoord cellAvailBSize = aSpanningRowBEnd - rowPos.y;
|
|
|
|
NS_ASSERTION(cellAvailBSize >= 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
|
2015-06-20 23:00:26 +03:00
|
|
|
// CalculateRowBSizes 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),
|
2015-06-04 13:43:02 +03:00
|
|
|
nullptr,
|
2013-09-10 00:29:05 +04:00
|
|
|
nsHTMLReflowState::CALLER_WILL_INIT);
|
2011-11-24 06:48:23 +04:00
|
|
|
InitChildReflowState(aPresContext, borderCollapse, rowReflowState);
|
|
|
|
rowReflowState.mFlags.mIsTopOfPage = isTopOfPage; // set top of page
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord cellBSize = row->ReflowCellFrame(&aPresContext, rowReflowState,
|
2007-02-21 22:42:21 +03:00
|
|
|
isTopOfPage, cell,
|
2015-06-20 23:00:26 +03:00
|
|
|
cellAvailBSize, status);
|
|
|
|
aDesiredBSize = std::max(aDesiredBSize, rowPos.y + cellBSize);
|
2002-10-03 18:33:23 +04:00
|
|
|
if (NS_FRAME_IS_COMPLETE(status)) {
|
2015-06-20 23:00:26 +03:00
|
|
|
if (cellBSize > cellAvailBSize) {
|
2002-10-03 18:33:23 +04:00
|
|
|
aFirstTruncatedRow = row;
|
|
|
|
if ((row != &aFirstRow) || !aFirstRowIsTopOfPage) {
|
2015-04-17 21:42:05 +03:00
|
|
|
// return now, since we will be getting another reflow after either (1) row is
|
2002-10-03 18:33:23 +04:00
|
|
|
// 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) {
|
2015-04-17 21:42:05 +03:00
|
|
|
// aContRow needs a continuation for cell, since cell spanned into aLastRow
|
2002-10-03 18:33:23 +04:00
|
|
|
// 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) {
|
2015-06-20 23:00:26 +03:00
|
|
|
aDesiredBSize = aLastRow.GetNormalRect().YMost();
|
2011-12-27 12:31:10 +04:00
|
|
|
}
|
2001-04-16 18:51:52 +04:00
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03: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.
|
2002-10-03 18:33:23 +04:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
static nsTableRowFrame*
|
2002-10-03 18:33:23 +04:00
|
|
|
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
|
|
|
{
|
2015-04-17 21:42:05 +03:00
|
|
|
NS_PRECONDITION(aPresContext->IsPaginated(), "SplitRowGroup currently supports only paged media");
|
2006-06-07 02:45:14 +04:00
|
|
|
|
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();
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2012-01-17 03:38:10 +04:00
|
|
|
const bool borderCollapse = aTableFrame->IsBorderCollapse();
|
2015-04-17 21:42:05 +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;
|
2015-04-17 21:42:05 +03:00
|
|
|
NS_ASSERTION(pageHeight != NS_UNCONSTRAINEDSIZE,
|
2006-03-30 04:27:42 +04:00
|
|
|
"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();
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
// Walk each of the row frames looking for the first row frame that doesn't fit
|
2002-10-03 18:33:23 +04:00
|
|
|
// in the available space
|
|
|
|
for (nsTableRowFrame* rowFrame = firstRowThisPage; rowFrame; rowFrame = rowFrame->GetNextRow()) {
|
2011-09-29 10:19:26 +04:00
|
|
|
bool rowIsOnPage = true;
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord cellSpacingB = aTableFrame->GetRowSpacing(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
|
2015-04-17 21:42:05 +03:00
|
|
|
// row (on the page) or there is at least 5% of the current page available
|
|
|
|
// XXX this 5% should be made a preference
|
|
|
|
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),
|
2015-06-04 13:43:02 +03:00
|
|
|
nullptr,
|
2013-09-10 00:29:05 +04:00
|
|
|
nsHTMLReflowState::CALLER_WILL_INIT);
|
2015-04-17 21:42:05 +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
|
2015-04-17 21:42:05 +03: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();
|
2015-04-17 21:42:05 +03:00
|
|
|
if (prevRowFrame)
|
2015-06-20 23:00:26 +03:00
|
|
|
aDesiredSize.Height() += cellSpacingB;
|
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 {
|
2015-04-17 21:42:05 +03: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
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
}
|
2002-03-27 08:50:24 +03:00
|
|
|
else {
|
2015-04-17 21:42:05 +03:00
|
|
|
// The row frame is complete because either (1) its minimum height is greater than the
|
|
|
|
// 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)
|
2015-04-17 21:42:05 +03:00
|
|
|
if (isTopOfPage) {
|
2002-10-03 18:33:23 +04:00
|
|
|
// 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();
|
2015-04-17 21:42:05 +03:00
|
|
|
if (prevRowFrame)
|
2015-06-20 23:00:26 +03:00
|
|
|
aDesiredSize.Height() += cellSpacingB;
|
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 {
|
2015-04-17 21:42:05 +03: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))
|
2015-04-17 21:42:05 +03: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;
|
2015-06-20 23:00:26 +03:00
|
|
|
nscoord bMost;
|
2004-01-08 01:30:53 +03:00
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *aTableFrame, *firstRowThisPage,
|
2015-04-17 21:42:05 +03:00
|
|
|
*lastRowThisPage, aReflowState.mFlags.mIsTopOfPage, spanningRowBottom, contRow,
|
2015-06-20 23:00:26 +03:00
|
|
|
firstTruncatedRow, bMost);
|
2002-10-03 18:33:23 +04:00
|
|
|
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)
|
2015-04-17 21:42:05 +03:00
|
|
|
// Try to put firstTruncateRow on the next page
|
2002-10-03 18:33:23 +04:00
|
|
|
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
|
2015-04-17 21:42:05 +03:00
|
|
|
SplitSpanningCells(*aPresContext, aReflowState, *aTableFrame,
|
|
|
|
*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,
|
2015-04-17 21:42:05 +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 {
|
2015-06-20 23:00:26 +03:00
|
|
|
aDesiredSize.Height() = std::max(aDesiredSize.Height(), bMost);
|
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)
|
2015-04-17 21:42:05 +03:00
|
|
|
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
|
|
|
{
|
2015-03-30 01:38:40 +03:00
|
|
|
MarkInReflow();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("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();
|
|
|
|
|
2015-06-22 12:33:34 +03:00
|
|
|
// see if a special bsize reflow needs to occur due to having a pct bsize
|
2015-06-22 12:33:34 +03:00
|
|
|
nsTableFrame::CheckRequestSpecialBSizeReflow(aReflowState);
|
2002-04-11 01:32:41 +04:00
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
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
|
|
|
|
2015-04-17 21:42:05 +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() &&
|
2015-04-17 21:42:05 +03:00
|
|
|
(NS_FRAME_NOT_COMPLETE == aStatus || splitDueToPageBreak ||
|
2013-12-27 21:59:52 +04:00
|
|
|
aDesiredSize.Height() > aReflowState.AvailableHeight())) {
|
2015-04-17 21:42:05 +03:00
|
|
|
// Nope, find a place to split the row group
|
2015-06-22 12:33:34 +03:00
|
|
|
bool specialReflow = (bool)aReflowState.mFlags.mSpecialBSizeReflow;
|
|
|
|
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialBSizeReflow = 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
|
|
|
|
2015-06-22 12:33:34 +03:00
|
|
|
((nsHTMLReflowState::ReflowStateFlags&)aReflowState.mFlags).mSpecialBSizeReflow = specialReflow;
|
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-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
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
SetHasStyleBSize((NS_UNCONSTRAINEDSIZE != aReflowState.ComputedBSize()) &&
|
|
|
|
(aReflowState.ComputedBSize() > 0));
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
// Just set our isize to what was available.
|
|
|
|
// The table will calculate the isize and not use our value.
|
|
|
|
WritingMode wm = aReflowState.GetWritingMode();
|
|
|
|
aDesiredSize.ISize(wm) = aReflowState.AvailableISize();
|
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.
|
2015-06-23 23:41:29 +03:00
|
|
|
if (!GetParent()->HasAnyStateBits(NS_FRAME_FIRST_REFLOW) &&
|
2013-12-27 21:59:52 +04:00
|
|
|
nsSize(aDesiredSize.Width(), aDesiredSize.Height()) != mRect.Size()) {
|
2012-08-29 09:48:45 +04:00
|
|
|
InvalidateFrame();
|
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
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;
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2008-10-26 13:11:34 +03:00
|
|
|
if (tableFrame->IsBorderCollapse() &&
|
2013-02-16 09:38:33 +04:00
|
|
|
tableFrame->BCRecalcNeeded(aOldStyleContext, StyleContext())) {
|
2015-05-01 00:46:59 +03:00
|
|
|
TableArea damageArea(0, GetStartRowIndex(), tableFrame->GetColCount(),
|
2012-01-23 02:48:34 +04:00
|
|
|
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
|
|
|
|
2015-04-11 03:21:06 +03:00
|
|
|
DrainSelfOverflowList(); // ensure the last frame is in mFrames
|
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,
|
2015-04-17 21:42:05 +03: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) {
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
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");
|
|
|
|
|
2015-04-11 03:21:06 +03:00
|
|
|
DrainSelfOverflowList(); // ensure aPrevFrame is in mFrames
|
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.
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
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,
|
2015-04-17 21:42:05 +03: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();
|
|
|
|
|
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) {
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2012-01-17 03:38:10 +04:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
nscoord
|
2015-06-20 23:00:26 +03:00
|
|
|
nsTableRowGroupFrame::GetBSizeBasis(const nsHTMLReflowState& aReflowState)
|
2001-11-05 03:15:51 +03:00
|
|
|
{
|
|
|
|
nscoord result = 0;
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* tableFrame = GetTableFrame();
|
2014-06-18 14:47:00 +04:00
|
|
|
int32_t startRowIndex = GetStartRowIndex();
|
2015-06-20 23:00:26 +03:00
|
|
|
if ((aReflowState.ComputedBSize() > 0) && (aReflowState.ComputedBSize() < NS_UNCONSTRAINEDSIZE)) {
|
2015-03-20 07:16:00 +03:00
|
|
|
nscoord cellSpacing = tableFrame->GetRowSpacing(startRowIndex,
|
|
|
|
std::max(startRowIndex,
|
|
|
|
startRowIndex + GetRowCount() - 1));
|
2015-06-20 23:00:26 +03:00
|
|
|
result = aReflowState.ComputedBSize() - cellSpacing;
|
2012-01-17 03:38:10 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
const nsHTMLReflowState* parentRS = aReflowState.parentReflowState;
|
|
|
|
if (parentRS && (tableFrame != parentRS->frame)) {
|
|
|
|
parentRS = parentRS->parentReflowState;
|
2001-11-05 18:15:24 +03:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
if (parentRS && (tableFrame == parentRS->frame) &&
|
2015-06-20 23:00:26 +03:00
|
|
|
(parentRS->ComputedBSize() > 0) && (parentRS->ComputedBSize() < NS_UNCONSTRAINEDSIZE)) {
|
2015-03-20 07:16:00 +03:00
|
|
|
nscoord cellSpacing = tableFrame->GetRowSpacing(-1, tableFrame->GetRowCount());
|
2015-06-20 23:00:26 +03:00
|
|
|
result = parentRS->ComputedBSize() - 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,
|
2015-06-27 02:50:21 +03:00
|
|
|
nsTableRowFrame* aRowFrame)
|
1999-09-01 09:16:12 +04:00
|
|
|
{
|
2015-06-27 02:50:21 +03:00
|
|
|
int32_t rowIndex = aRowFrame->GetRowIndex();
|
|
|
|
|
|
|
|
// It's a simple row frame if there are no cells that span into or
|
|
|
|
// across the row
|
|
|
|
int32_t numEffCols = aTableFrame->GetEffectiveColCount();
|
|
|
|
if (!aTableFrame->RowIsSpannedInto(rowIndex, numEffCols) &&
|
|
|
|
!aTableFrame->RowHasSpanningCells(rowIndex, numEffCols)) {
|
|
|
|
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 **/
|
2015-04-17 21:42:05 +03:00
|
|
|
bool
|
2010-05-13 18:15:49 +04:00
|
|
|
nsTableRowGroupFrame::HasInternalBreakBefore() const
|
|
|
|
{
|
2015-04-17 21:42:05 +03:00
|
|
|
nsIFrame* firstChild = mFrames.FirstChild();
|
2010-05-13 18:15:49 +04:00
|
|
|
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 **/
|
2015-04-17 21:42:05 +03:00
|
|
|
bool
|
2010-05-13 18:15:49 +04:00
|
|
|
nsTableRowGroupFrame::HasInternalBreakAfter() const
|
|
|
|
{
|
2015-04-17 21:42:05 +03:00
|
|
|
nsIFrame* lastChild = mFrames.LastChild();
|
2010-05-13 18:15:49 +04:00
|
|
|
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
|
|
|
|
2015-05-04 10:09:25 +03:00
|
|
|
LogicalMargin
|
|
|
|
nsTableRowGroupFrame::GetBCBorderWidth(WritingMode aWM)
|
2002-02-19 18:48:28 +03:00
|
|
|
{
|
2015-05-04 10:09:25 +03:00
|
|
|
LogicalMargin border(aWM);
|
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) {
|
2015-05-04 10:09:25 +03:00
|
|
|
border.BStart(aWM) = nsPresContext::
|
|
|
|
CSSPixelsToAppUnits(firstRowFrame->GetBStartBCBorderWidth());
|
|
|
|
border.BEnd(aWM) = nsPresContext::
|
|
|
|
CSSPixelsToAppUnits(lastRowFrame->GetBEndBCBorderWidth());
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
2015-05-04 10:09:25 +03:00
|
|
|
return border;
|
2002-02-19 18:48:28 +03:00
|
|
|
}
|
|
|
|
|
2015-06-20 23:00:26 +03:00
|
|
|
void nsTableRowGroupFrame::SetContinuousBCBorderWidth(LogicalSide aForSide,
|
2004-03-09 09:48:35 +03:00
|
|
|
BCPixelSize aPixelValue)
|
|
|
|
{
|
|
|
|
switch (aForSide) {
|
2015-06-20 23:00:26 +03:00
|
|
|
case eLogicalSideIEnd:
|
|
|
|
mIEndContBorderWidth = aPixelValue;
|
2004-03-09 09:48:35 +03:00
|
|
|
return;
|
2015-06-20 23:00:26 +03:00
|
|
|
case eLogicalSideBEnd:
|
|
|
|
mBEndContBorderWidth = aPixelValue;
|
2004-03-09 09:48:35 +03:00
|
|
|
return;
|
2015-06-20 23:00:26 +03:00
|
|
|
case eLogicalSideIStart:
|
|
|
|
mIStartContBorderWidth = aPixelValue;
|
2004-03-09 09:48:35 +03:00
|
|
|
return;
|
|
|
|
default:
|
2015-06-20 23:00:26 +03:00
|
|
|
NS_ERROR("invalid LogicalSide argument");
|
2004-03-09 09:48:35 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-10-30 22:17:59 +03:00
|
|
|
return (NS_STYLE_DIRECTION_RTL ==
|
2015-04-30 07:24:59 +03:00
|
|
|
GetTableFrame()->StyleVisibility()->mDirection);
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2000-05-11 05:04:39 +04:00
|
|
|
NS_IMETHODIMP
|
2015-04-17 21:42:05 +03:00
|
|
|
nsTableRowGroupFrame::GetLine(int32_t aLineNumber,
|
|
|
|
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);
|
|
|
|
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* table = GetTableFrame();
|
2008-02-20 23:22:18 +03:00
|
|
|
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);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2008-02-20 23:22:18 +03:00
|
|
|
if ((aLineNumber < 0) || (aLineNumber >= GetRowCount())) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
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
|
|
|
}
|
2015-04-17 21:42:05 +03: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);
|
2015-04-17 21:42:05 +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
|
2015-04-17 21:42:05 +03:00
|
|
|
nsTableRowGroupFrame::FindFrameAt(int32_t aLineNumber,
|
|
|
|
nsPoint aPos,
|
2001-03-13 09:38:59 +03:00
|
|
|
nsIFrame** aFrameFound,
|
2015-04-17 21:42:05 +03:00
|
|
|
bool* aPosIsBeforeFirstFrame,
|
2014-11-22 17:39:03 +03:00
|
|
|
bool* aPosIsAfterLastFrame)
|
2000-05-11 05:04:39 +04:00
|
|
|
{
|
2015-04-30 07:24:59 +03:00
|
|
|
nsTableFrame* table = GetTableFrame();
|
2014-11-22 17:39:03 +03:00
|
|
|
nsTableCellMap* cellMap = table->GetCellMap();
|
|
|
|
|
|
|
|
WritingMode wm = table->GetWritingMode();
|
2015-07-16 12:07:57 +03:00
|
|
|
nsSize containerSize = table->GetSize();
|
|
|
|
LogicalPoint pos(wm, aPos, containerSize);
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2014-11-22 17:39:03 +03:00
|
|
|
*aFrameFound = nullptr;
|
|
|
|
*aPosIsBeforeFirstFrame = true;
|
|
|
|
*aPosIsAfterLastFrame = false;
|
|
|
|
|
|
|
|
aLineNumber += GetStartRowIndex();
|
|
|
|
int32_t numCells = cellMap->GetNumCellsOriginatingInRow(aLineNumber);
|
|
|
|
if (numCells == 0) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2014-11-22 17:39:03 +03:00
|
|
|
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);
|
2015-04-17 21:42:05 +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--) {
|
2015-07-16 12:07:57 +03:00
|
|
|
LogicalRect rect = frame->GetLogicalRect(wm, containerSize);
|
2014-11-22 17:39:03 +03:00
|
|
|
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 ||
|
2015-07-16 12:07:57 +03:00
|
|
|
rect.IEnd(wm) > closestFromStart->
|
|
|
|
GetLogicalRect(wm, containerSize).IEnd(wm))
|
2014-11-22 17:39:03 +03:00
|
|
|
closestFromStart = frame;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (!closestFromEnd ||
|
2015-07-16 12:07:57 +03:00
|
|
|
rect.IStart(wm) < closestFromEnd->
|
|
|
|
GetLogicalRect(wm, containerSize).IStart(wm))
|
2014-11-22 17:39:03 +03:00
|
|
|
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
|
2015-07-16 12:07:57 +03:00
|
|
|
nscoord delta =
|
|
|
|
closestFromEnd->GetLogicalRect(wm, containerSize).IStart(wm) -
|
|
|
|
closestFromStart->GetLogicalRect(wm, containerSize).IEnd(wm);
|
|
|
|
if (pos.I(wm) < closestFromStart->
|
|
|
|
GetLogicalRect(wm, containerSize).IEnd(wm) + delta/2) {
|
2014-11-22 17:39:03 +03:00
|
|
|
*aFrameFound = closestFromStart;
|
|
|
|
} else {
|
|
|
|
*aFrameFound = closestFromEnd;
|
|
|
|
}
|
2000-05-11 05:04:39 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-04-17 21:42:05 +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()
|
|
|
|
{
|
2015-06-23 23:41:29 +03:00
|
|
|
if (!HasAnyStateBits(NS_ROWGROUP_HAS_ROW_CURSOR)) {
|
2006-09-20 01:39:33 +04:00
|
|
|
return;
|
2015-06-23 23:41:29 +03:00
|
|
|
}
|
2006-09-20 01:39:33 +04:00
|
|
|
|
|
|
|
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()
|
|
|
|
{
|
2015-06-23 23:41:29 +03:00
|
|
|
if (HasAnyStateBits(NS_ROWGROUP_HAS_ROW_CURSOR)) {
|
2006-09-20 01:39:33 +04:00
|
|
|
// 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)
|
|
|
|
{
|
2015-06-23 23:41:29 +03:00
|
|
|
if (!HasAnyStateBits(NS_ROWGROUP_HAS_ROW_CURSOR)) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2015-06-23 23:41:29 +03:00
|
|
|
}
|
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.
|
2015-04-17 21:42:05 +03:00
|
|
|
|
2006-09-20 01:39:33 +04:00
|
|
|
// 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
|
|
|
}
|
2015-04-17 21:42:05 +03:00
|
|
|
|
|
|
|
void
|
2012-08-29 09:48:45 +04:00
|
|
|
nsTableRowGroupFrame::InvalidateFrame(uint32_t aDisplayItemKey)
|
|
|
|
{
|
|
|
|
nsIFrame::InvalidateFrame(aDisplayItemKey);
|
|
|
|
GetParent()->InvalidateFrameWithRect(GetVisualOverflowRect() + GetPosition(), aDisplayItemKey);
|
|
|
|
}
|
|
|
|
|
2015-04-17 21:42:05 +03:00
|
|
|
void
|
2012-08-29 09:48:45 +04:00
|
|
|
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
|
|
|
}
|