2004-10-08 12:17:10 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2006-03-29 18:29:03 +00:00
|
|
|
/* rendering object for css3 multi-column layout */
|
|
|
|
|
2013-04-16 12:52:49 +00:00
|
|
|
#include "nsColumnSetFrame.h"
|
2013-08-22 18:32:52 +00:00
|
|
|
#include "nsCSSRendering.h"
|
|
|
|
#include "nsDisplayList.h"
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2011-10-28 18:33:28 +00:00
|
|
|
using namespace mozilla;
|
2013-04-01 15:26:02 +00:00
|
|
|
using namespace mozilla::layout;
|
2011-10-28 18:33:28 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
/**
|
|
|
|
* Tracking issues:
|
|
|
|
*
|
|
|
|
* XXX cursor movement around the top and bottom of colums seems to make the editor
|
|
|
|
* lose the caret.
|
|
|
|
*
|
|
|
|
* XXX should we support CSS columns applied to table elements?
|
|
|
|
*/
|
2014-05-24 22:20:40 +00:00
|
|
|
nsContainerFrame*
|
2014-02-05 01:59:39 +00:00
|
|
|
NS_NewColumnSetFrame(nsIPresShell* aPresShell, nsStyleContext* aContext, nsFrameState aStateFlags)
|
2004-10-08 12:17:10 +00:00
|
|
|
{
|
2006-03-26 21:30:36 +00:00
|
|
|
nsColumnSetFrame* it = new (aPresShell) nsColumnSetFrame(aContext);
|
2012-11-07 19:55:53 +00:00
|
|
|
it->AddStateBits(aStateFlags | NS_BLOCK_MARGIN_ROOT);
|
2005-11-04 02:38:33 +00:00
|
|
|
return it;
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2009-09-12 16:49:24 +00:00
|
|
|
NS_IMPL_FRAMEARENA_HELPERS(nsColumnSetFrame)
|
|
|
|
|
2006-03-26 21:30:36 +00:00
|
|
|
nsColumnSetFrame::nsColumnSetFrame(nsStyleContext* aContext)
|
2011-12-27 20:18:48 +00:00
|
|
|
: nsContainerFrame(aContext), mLastBalanceHeight(NS_INTRINSICSIZE),
|
2004-10-08 12:17:10 +00:00
|
|
|
mLastFrameStatus(NS_FRAME_COMPLETE)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIAtom*
|
|
|
|
nsColumnSetFrame::GetType() const
|
|
|
|
{
|
2006-12-26 17:47:52 +00:00
|
|
|
return nsGkAtoms::columnSetFrame;
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2008-07-19 10:38:25 +00:00
|
|
|
static void
|
2011-04-08 01:04:40 +00:00
|
|
|
PaintColumnRule(nsIFrame* aFrame, nsRenderingContext* aCtx,
|
2008-07-19 10:38:25 +00:00
|
|
|
const nsRect& aDirtyRect, nsPoint aPt)
|
|
|
|
{
|
|
|
|
static_cast<nsColumnSetFrame*>(aFrame)->PaintColumnRule(aCtx, aDirtyRect, aPt);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-04-08 01:04:40 +00:00
|
|
|
nsColumnSetFrame::PaintColumnRule(nsRenderingContext* aCtx,
|
2008-07-19 10:38:25 +00:00
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsPoint& aPt)
|
|
|
|
{
|
|
|
|
nsIFrame* child = mFrames.FirstChild();
|
|
|
|
if (!child)
|
|
|
|
return; // no columns
|
|
|
|
|
|
|
|
nsIFrame* nextSibling = child->GetNextSibling();
|
|
|
|
if (!nextSibling)
|
|
|
|
return; // 1 column only - this means no gap to draw on
|
|
|
|
|
2013-02-16 21:51:02 +00:00
|
|
|
bool isRTL = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
|
|
|
const nsStyleColumn* colStyle = StyleColumn();
|
2008-07-19 10:38:25 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t ruleStyle;
|
2008-07-19 10:38:25 +00:00
|
|
|
// Per spec, inset => ridge and outset => groove
|
|
|
|
if (colStyle->mColumnRuleStyle == NS_STYLE_BORDER_STYLE_INSET)
|
|
|
|
ruleStyle = NS_STYLE_BORDER_STYLE_RIDGE;
|
|
|
|
else if (colStyle->mColumnRuleStyle == NS_STYLE_BORDER_STYLE_OUTSET)
|
|
|
|
ruleStyle = NS_STYLE_BORDER_STYLE_GROOVE;
|
|
|
|
else
|
|
|
|
ruleStyle = colStyle->mColumnRuleStyle;
|
|
|
|
|
|
|
|
nsPresContext* presContext = PresContext();
|
|
|
|
nscoord ruleWidth = colStyle->GetComputedColumnRuleWidth();
|
|
|
|
if (!ruleWidth)
|
|
|
|
return;
|
|
|
|
|
2010-04-07 02:03:12 +00:00
|
|
|
nscolor ruleColor =
|
|
|
|
GetVisitedDependentColor(eCSSProperty__moz_column_rule_color);
|
2008-07-19 10:38:25 +00:00
|
|
|
|
|
|
|
// In order to re-use a large amount of code, we treat the column rule as a border.
|
|
|
|
// We create a new border style object and fill in all the details of the column rule as
|
|
|
|
// the left border. PaintBorder() does all the rendering for us, so we not
|
|
|
|
// only save an enormous amount of code but we'll support all the line styles that
|
|
|
|
// we support on borders!
|
|
|
|
nsStyleBorder border(presContext);
|
|
|
|
border.SetBorderWidth(NS_SIDE_LEFT, ruleWidth);
|
|
|
|
border.SetBorderStyle(NS_SIDE_LEFT, ruleStyle);
|
|
|
|
border.SetBorderColor(NS_SIDE_LEFT, ruleColor);
|
|
|
|
|
2008-07-22 06:16:06 +00:00
|
|
|
// Get our content rect as an absolute coordinate, not relative to
|
|
|
|
// our parent (which is what the X and Y normally is)
|
|
|
|
nsRect contentRect = GetContentRect() - GetRect().TopLeft() + aPt;
|
|
|
|
nsSize ruleSize(ruleWidth, contentRect.height);
|
|
|
|
|
2008-07-19 10:38:25 +00:00
|
|
|
while (nextSibling) {
|
|
|
|
// The frame tree goes RTL in RTL
|
|
|
|
nsIFrame* leftSibling = isRTL ? nextSibling : child;
|
|
|
|
nsIFrame* rightSibling = isRTL ? child : nextSibling;
|
|
|
|
|
|
|
|
// Each child frame's position coordinates is actually relative to this nsColumnSetFrame.
|
|
|
|
// linePt will be at the top-left edge to paint the line.
|
|
|
|
nsPoint edgeOfLeftSibling = leftSibling->GetRect().TopRight() + aPt;
|
|
|
|
nsPoint edgeOfRightSibling = rightSibling->GetRect().TopLeft() + aPt;
|
|
|
|
nsPoint linePt((edgeOfLeftSibling.x + edgeOfRightSibling.x - ruleWidth) / 2,
|
2008-07-22 06:16:06 +00:00
|
|
|
contentRect.y);
|
2008-07-19 10:38:25 +00:00
|
|
|
|
2008-07-22 06:16:06 +00:00
|
|
|
nsRect lineRect(linePt, ruleSize);
|
2014-06-28 10:13:13 +00:00
|
|
|
// Remember, we only have the "left" "border". Skip everything else.
|
|
|
|
Sides skipSides(mozilla::eSideBitsTopBottom);
|
|
|
|
skipSides |= mozilla::eSideBitsRight;
|
2010-04-03 01:58:26 +00:00
|
|
|
nsCSSRendering::PaintBorderWithStyleBorder(presContext, *aCtx, this,
|
2013-02-16 05:38:33 +00:00
|
|
|
aDirtyRect, lineRect, border, StyleContext(),
|
2014-06-28 10:13:13 +00:00
|
|
|
skipSides);
|
2008-07-19 10:38:25 +00:00
|
|
|
|
|
|
|
child = nextSibling;
|
|
|
|
nextSibling = nextSibling->GetNextSibling();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-04 17:48:19 +00:00
|
|
|
static nscoord
|
|
|
|
GetAvailableContentWidth(const nsHTMLReflowState& aReflowState)
|
|
|
|
{
|
2013-12-27 17:59:21 +00:00
|
|
|
if (aReflowState.AvailableWidth() == NS_INTRINSICSIZE) {
|
2004-10-08 12:17:10 +00:00
|
|
|
return NS_INTRINSICSIZE;
|
|
|
|
}
|
|
|
|
nscoord borderPaddingWidth =
|
2013-12-27 17:59:21 +00:00
|
|
|
aReflowState.ComputedPhysicalBorderPadding().left +
|
|
|
|
aReflowState.ComputedPhysicalBorderPadding().right;
|
|
|
|
return std::max(0, aReflowState.AvailableWidth() - borderPaddingWidth);
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2013-07-25 15:34:31 +00:00
|
|
|
nscoord
|
|
|
|
nsColumnSetFrame::GetAvailableContentHeight(const nsHTMLReflowState& aReflowState)
|
2008-01-04 17:48:19 +00:00
|
|
|
{
|
2013-12-27 17:59:21 +00:00
|
|
|
if (aReflowState.AvailableHeight() == NS_INTRINSICSIZE) {
|
2004-10-08 12:17:10 +00:00
|
|
|
return NS_INTRINSICSIZE;
|
|
|
|
}
|
2013-07-25 15:34:31 +00:00
|
|
|
|
2013-12-27 17:59:21 +00:00
|
|
|
nsMargin bp = aReflowState.ComputedPhysicalBorderPadding();
|
2014-06-24 17:52:19 +00:00
|
|
|
bp.ApplySkipSides(GetSkipSides(&aReflowState));
|
2013-12-27 17:59:21 +00:00
|
|
|
bp.bottom = aReflowState.ComputedPhysicalBorderPadding().bottom;
|
|
|
|
return std::max(0, aReflowState.AvailableHeight() - bp.TopBottom());
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2007-07-20 02:21:43 +00:00
|
|
|
static nscoord
|
2008-01-04 17:48:19 +00:00
|
|
|
GetColumnGap(nsColumnSetFrame* aFrame,
|
2008-07-17 23:37:12 +00:00
|
|
|
const nsStyleColumn* aColStyle)
|
2008-01-04 17:48:19 +00:00
|
|
|
{
|
|
|
|
if (eStyleUnit_Normal == aColStyle->mColumnGap.GetUnit())
|
2013-02-16 21:51:02 +00:00
|
|
|
return aFrame->StyleFont()->mFont.size;
|
2008-07-17 23:37:12 +00:00
|
|
|
if (eStyleUnit_Coord == aColStyle->mColumnGap.GetUnit()) {
|
|
|
|
nscoord colGap = aColStyle->mColumnGap.GetCoordValue();
|
2008-02-17 04:45:58 +00:00
|
|
|
NS_ASSERTION(colGap >= 0, "negative column gap");
|
2008-01-04 17:48:19 +00:00
|
|
|
return colGap;
|
2008-02-17 04:45:58 +00:00
|
|
|
}
|
2008-01-04 17:48:19 +00:00
|
|
|
|
|
|
|
NS_NOTREACHED("Unknown gap type");
|
2007-07-20 02:21:43 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
nsColumnSetFrame::ReflowConfig
|
2013-03-01 03:56:48 +00:00
|
|
|
nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState,
|
2013-04-16 12:52:51 +00:00
|
|
|
bool aForceAuto = false,
|
|
|
|
nscoord aFeasibleHeight = NS_INTRINSICSIZE,
|
|
|
|
nscoord aInfeasibleHeight = 0)
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
{
|
2013-04-16 12:52:51 +00:00
|
|
|
nscoord knownFeasibleHeight = aFeasibleHeight;
|
|
|
|
nscoord knownInfeasibleHeight = aInfeasibleHeight;
|
|
|
|
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleColumn* colStyle = StyleColumn();
|
2004-10-08 12:17:10 +00:00
|
|
|
nscoord availContentWidth = GetAvailableContentWidth(aReflowState);
|
2007-01-26 00:05:12 +00:00
|
|
|
if (aReflowState.ComputedWidth() != NS_INTRINSICSIZE) {
|
|
|
|
availContentWidth = aReflowState.ComputedWidth();
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2013-07-25 15:34:31 +00:00
|
|
|
|
2014-06-20 09:55:35 +00:00
|
|
|
nscoord consumedBSize = GetConsumedBSize();
|
2013-07-25 15:34:31 +00:00
|
|
|
|
|
|
|
// The effective computed height is the height of the current continuation
|
|
|
|
// of the column set frame. This should be the same as the computed height
|
|
|
|
// if we have an unconstrained available height.
|
2014-06-20 09:55:35 +00:00
|
|
|
nscoord computedBSize = GetEffectiveComputedBSize(aReflowState,
|
|
|
|
consumedBSize);
|
2004-10-08 12:17:10 +00:00
|
|
|
nscoord colHeight = GetAvailableContentHeight(aReflowState);
|
2013-07-25 15:34:31 +00:00
|
|
|
|
2007-08-02 18:08:05 +00:00
|
|
|
if (aReflowState.ComputedHeight() != NS_INTRINSICSIZE) {
|
|
|
|
colHeight = aReflowState.ComputedHeight();
|
2013-12-27 17:59:21 +00:00
|
|
|
} else if (aReflowState.ComputedMaxHeight() != NS_INTRINSICSIZE) {
|
|
|
|
colHeight = std::min(colHeight, aReflowState.ComputedMaxHeight());
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2008-07-17 23:37:12 +00:00
|
|
|
nscoord colGap = GetColumnGap(this, colStyle);
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numColumns = colStyle->mColumnCount;
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2012-12-27 21:24:08 +00:00
|
|
|
// If column-fill is set to 'balance', then we want to balance the columns.
|
2013-03-01 03:56:48 +00:00
|
|
|
const bool isBalancing = colStyle->mColumnFill == NS_STYLE_COLUMN_FILL_BALANCE
|
|
|
|
&& !aForceAuto;
|
2012-12-27 21:24:08 +00:00
|
|
|
if (isBalancing) {
|
|
|
|
const uint32_t MAX_NESTED_COLUMN_BALANCING = 2;
|
|
|
|
uint32_t cnt = 0;
|
|
|
|
for (const nsHTMLReflowState* rs = aReflowState.parentReflowState;
|
|
|
|
rs && cnt < MAX_NESTED_COLUMN_BALANCING; rs = rs->parentReflowState) {
|
|
|
|
if (rs->mFlags.mIsColumnBalancing) {
|
|
|
|
++cnt;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (cnt == MAX_NESTED_COLUMN_BALANCING) {
|
|
|
|
numColumns = 1;
|
2012-02-12 21:21:51 +00:00
|
|
|
}
|
2012-06-13 16:00:56 +00:00
|
|
|
}
|
2012-02-12 21:21:51 +00:00
|
|
|
|
2008-01-04 17:48:19 +00:00
|
|
|
nscoord colWidth;
|
2008-07-17 23:37:12 +00:00
|
|
|
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
2008-02-17 04:45:58 +00:00
|
|
|
NS_ASSERTION(colWidth >= 0, "negative column width");
|
2005-11-20 22:05:24 +00:00
|
|
|
// Reduce column count if necessary to make columns fit in the
|
2004-10-08 12:17:10 +00:00
|
|
|
// available width. Compute max number of columns that fit in
|
|
|
|
// availContentWidth, satisfying colGap*(maxColumns - 1) +
|
|
|
|
// colWidth*maxColumns <= availContentWidth
|
2008-02-17 04:45:58 +00:00
|
|
|
if (availContentWidth != NS_INTRINSICSIZE && colGap + colWidth > 0
|
2004-10-08 12:17:10 +00:00
|
|
|
&& numColumns > 0) {
|
|
|
|
// This expression uses truncated rounding, which is what we
|
|
|
|
// want
|
2013-05-31 15:51:43 +00:00
|
|
|
int32_t maxColumns =
|
|
|
|
std::min(nscoord(nsStyleColumn::kMaxColumnCount),
|
|
|
|
(availContentWidth + colGap)/(colGap + colWidth));
|
2013-01-15 12:22:03 +00:00
|
|
|
numColumns = std::max(1, std::min(numColumns, maxColumns));
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
} else if (numColumns > 0 && availContentWidth != NS_INTRINSICSIZE) {
|
|
|
|
nscoord widthMinusGaps = availContentWidth - colGap*(numColumns - 1);
|
|
|
|
colWidth = widthMinusGaps/numColumns;
|
2008-01-04 17:48:19 +00:00
|
|
|
} else {
|
|
|
|
colWidth = NS_INTRINSICSIZE;
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
// Take care of the situation where there's only one column but it's
|
|
|
|
// still too wide
|
2013-01-15 12:22:03 +00:00
|
|
|
colWidth = std::max(1, std::min(colWidth, availContentWidth));
|
2004-10-08 12:17:10 +00:00
|
|
|
|
|
|
|
nscoord expectedWidthLeftOver = 0;
|
|
|
|
|
|
|
|
if (colWidth != NS_INTRINSICSIZE && availContentWidth != NS_INTRINSICSIZE) {
|
|
|
|
// distribute leftover space
|
|
|
|
|
|
|
|
// First, determine how many columns will be showing if the column
|
|
|
|
// count is auto
|
|
|
|
if (numColumns <= 0) {
|
|
|
|
// choose so that colGap*(nominalColumnCount - 1) +
|
|
|
|
// colWidth*nominalColumnCount is nearly availContentWidth
|
|
|
|
// make sure to round down
|
2008-02-17 04:45:58 +00:00
|
|
|
if (colGap + colWidth > 0) {
|
|
|
|
numColumns = (availContentWidth + colGap)/(colGap + colWidth);
|
2013-05-31 15:51:43 +00:00
|
|
|
// The number of columns should never exceed kMaxColumnCount.
|
|
|
|
numColumns = std::min(nscoord(nsStyleColumn::kMaxColumnCount),
|
|
|
|
numColumns);
|
2008-02-17 04:45:58 +00:00
|
|
|
}
|
2005-03-23 03:35:08 +00:00
|
|
|
if (numColumns <= 0) {
|
|
|
|
numColumns = 1;
|
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Compute extra space and divide it among the columns
|
2007-04-21 00:42:58 +00:00
|
|
|
nscoord extraSpace =
|
2013-01-15 12:22:03 +00:00
|
|
|
std::max(0, availContentWidth - (colWidth*numColumns + colGap*(numColumns - 1)));
|
2004-10-08 12:17:10 +00:00
|
|
|
nscoord extraToColumns = extraSpace/numColumns;
|
|
|
|
colWidth += extraToColumns;
|
|
|
|
expectedWidthLeftOver = extraSpace - (extraToColumns*numColumns);
|
|
|
|
}
|
|
|
|
|
2012-12-27 21:24:08 +00:00
|
|
|
if (isBalancing) {
|
2004-10-08 12:17:10 +00:00
|
|
|
if (numColumns <= 0) {
|
|
|
|
// Hmm, auto column count, column width or available width is unknown,
|
|
|
|
// and balancing is required. Let's just use one column then.
|
|
|
|
numColumns = 1;
|
|
|
|
}
|
2013-01-15 12:22:03 +00:00
|
|
|
colHeight = std::min(mLastBalanceHeight, colHeight);
|
2004-10-08 12:17:10 +00:00
|
|
|
} else {
|
2012-07-31 16:21:19 +00:00
|
|
|
// This is the case when the column-fill property is set to 'auto'.
|
2004-10-08 12:17:10 +00:00
|
|
|
// No balancing, so don't limit the column count
|
2012-09-28 06:57:33 +00:00
|
|
|
numColumns = INT32_MAX;
|
2013-03-01 03:56:48 +00:00
|
|
|
|
|
|
|
// XXX_jwir3: If a page's height is set to 0, we could continually
|
|
|
|
// create continuations, resulting in an infinite loop, since
|
|
|
|
// no progress is ever made. This is an issue with the spec
|
|
|
|
// (css3-multicol, css3-page, and css3-break) that is
|
|
|
|
// unresolved as of 27 Feb 2013. For the time being, we set this
|
|
|
|
// to have a minimum of 1 css px. Once a resolution is made
|
|
|
|
// on what minimum to have for a page height, we may need to
|
|
|
|
// change this value to match the appropriate spec(s).
|
|
|
|
colHeight = std::max(colHeight, nsPresContext::CSSPixelsToAppUnits(1));
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_roc
|
|
|
|
printf("*** nsColumnSetFrame::ChooseColumnStrategy: numColumns=%d, colWidth=%d, expectedWidthLeftOver=%d, colHeight=%d, colGap=%d\n",
|
|
|
|
numColumns, colWidth, expectedWidthLeftOver, colHeight, colGap);
|
|
|
|
#endif
|
2013-03-08 15:43:46 +00:00
|
|
|
ReflowConfig config = { numColumns, colWidth, expectedWidthLeftOver, colGap,
|
2013-04-16 12:52:51 +00:00
|
|
|
colHeight, isBalancing, knownFeasibleHeight,
|
2014-06-20 09:55:35 +00:00
|
|
|
knownInfeasibleHeight, computedBSize, consumedBSize };
|
2004-10-08 12:17:10 +00:00
|
|
|
return config;
|
|
|
|
}
|
|
|
|
|
2013-04-24 15:02:36 +00:00
|
|
|
bool
|
|
|
|
nsColumnSetFrame::ReflowColumns(nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aReflowStatus,
|
|
|
|
ReflowConfig& aConfig,
|
|
|
|
bool aLastColumnUnbounded,
|
|
|
|
nsCollapsingMargin* aCarriedOutBottomMargin,
|
|
|
|
ColumnBalanceData& aColData)
|
|
|
|
{
|
|
|
|
bool feasible = ReflowChildren(aDesiredSize, aReflowState,
|
|
|
|
aReflowStatus, aConfig, aLastColumnUnbounded,
|
|
|
|
aCarriedOutBottomMargin, aColData);
|
|
|
|
|
|
|
|
if (aColData.mHasExcessHeight) {
|
|
|
|
aConfig = ChooseColumnStrategy(aReflowState, true);
|
|
|
|
|
|
|
|
// We need to reflow our children again one last time, otherwise we might
|
|
|
|
// end up with a stale column height for some of our columns, since we
|
|
|
|
// bailed out of balancing.
|
2013-07-09 20:24:27 +00:00
|
|
|
feasible = ReflowChildren(aDesiredSize, aReflowState, aReflowStatus,
|
|
|
|
aConfig, aLastColumnUnbounded,
|
|
|
|
aCarriedOutBottomMargin, aColData);
|
2013-04-24 15:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return feasible;
|
|
|
|
}
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
static void MoveChildTo(nsIFrame* aParent, nsIFrame* aChild, nsPoint aOrigin) {
|
|
|
|
if (aChild->GetPosition() == aOrigin) {
|
|
|
|
return;
|
|
|
|
}
|
2013-11-15 13:19:02 +00:00
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
aChild->SetPosition(aOrigin);
|
2013-11-15 13:19:02 +00:00
|
|
|
nsContainerFrame::PlaceFrameView(aChild);
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2007-07-20 02:21:43 +00:00
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsColumnSetFrame::GetMinWidth(nsRenderingContext *aRenderingContext) {
|
2007-07-20 02:21:43 +00:00
|
|
|
nscoord width = 0;
|
2009-04-18 08:22:34 +00:00
|
|
|
DISPLAY_MIN_WIDTH(this, width);
|
2007-07-20 02:21:43 +00:00
|
|
|
if (mFrames.FirstChild()) {
|
|
|
|
width = mFrames.FirstChild()->GetMinWidth(aRenderingContext);
|
|
|
|
}
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleColumn* colStyle = StyleColumn();
|
2008-01-04 17:48:19 +00:00
|
|
|
nscoord colWidth;
|
2008-07-17 23:37:12 +00:00
|
|
|
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
|
|
|
// As available width reduces to zero, we reduce our number of columns
|
|
|
|
// to one, and don't enforce the column width, so just return the min
|
|
|
|
// of the child's min-width with any specified column width.
|
2013-01-15 12:22:03 +00:00
|
|
|
width = std::min(width, colWidth);
|
2007-07-20 02:21:43 +00:00
|
|
|
} else {
|
2008-07-17 23:37:12 +00:00
|
|
|
NS_ASSERTION(colStyle->mColumnCount > 0,
|
|
|
|
"column-count and column-width can't both be auto");
|
|
|
|
// As available width reduces to zero, we still have mColumnCount columns,
|
|
|
|
// so multiply the child's min-width by the number of columns.
|
2008-04-03 03:11:13 +00:00
|
|
|
colWidth = width;
|
2007-07-20 02:21:43 +00:00
|
|
|
width *= colStyle->mColumnCount;
|
2008-04-03 03:11:13 +00:00
|
|
|
// The multiplication above can make 'width' negative (integer overflow),
|
2013-01-15 12:22:03 +00:00
|
|
|
// so use std::max to protect against that.
|
|
|
|
width = std::max(width, colWidth);
|
2007-07-20 02:21:43 +00:00
|
|
|
}
|
|
|
|
// XXX count forced column breaks here? Maybe we should return the child's
|
|
|
|
// min-width times the minimum number of columns.
|
|
|
|
return width;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord
|
2011-04-08 01:04:40 +00:00
|
|
|
nsColumnSetFrame::GetPrefWidth(nsRenderingContext *aRenderingContext) {
|
2008-07-17 23:37:12 +00:00
|
|
|
// Our preferred width is our desired column width, if specified, otherwise
|
|
|
|
// the child's preferred width, times the number of columns, plus the width
|
|
|
|
// of any required column gaps
|
2007-07-20 02:21:43 +00:00
|
|
|
// XXX what about forced column breaks here?
|
2009-04-18 08:22:34 +00:00
|
|
|
nscoord result = 0;
|
|
|
|
DISPLAY_PREF_WIDTH(this, result);
|
2013-02-16 21:51:02 +00:00
|
|
|
const nsStyleColumn* colStyle = StyleColumn();
|
2008-07-17 23:37:12 +00:00
|
|
|
nscoord colGap = GetColumnGap(this, colStyle);
|
2007-07-20 02:21:43 +00:00
|
|
|
|
|
|
|
nscoord colWidth;
|
2008-07-17 23:37:12 +00:00
|
|
|
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
|
|
|
|
colWidth = colStyle->mColumnWidth.GetCoordValue();
|
|
|
|
} else if (mFrames.FirstChild()) {
|
|
|
|
colWidth = mFrames.FirstChild()->GetPrefWidth(aRenderingContext);
|
|
|
|
} else {
|
|
|
|
colWidth = 0;
|
2007-07-20 02:21:43 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
int32_t numColumns = colStyle->mColumnCount;
|
2008-04-03 03:11:13 +00:00
|
|
|
if (numColumns <= 0) {
|
2007-07-20 02:21:43 +00:00
|
|
|
// if column-count is auto, assume one column
|
|
|
|
numColumns = 1;
|
|
|
|
}
|
2008-04-03 03:11:13 +00:00
|
|
|
|
|
|
|
nscoord width = colWidth*numColumns + colGap*(numColumns - 1);
|
|
|
|
// The multiplication above can make 'width' negative (integer overflow),
|
2013-01-15 12:22:03 +00:00
|
|
|
// so use std::max to protect against that.
|
|
|
|
result = std::max(width, colWidth);
|
2009-04-18 08:22:34 +00:00
|
|
|
return result;
|
2007-07-20 02:21:43 +00:00
|
|
|
}
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool
|
2004-10-08 12:17:10 +00:00
|
|
|
nsColumnSetFrame::ReflowChildren(nsHTMLReflowMetrics& aDesiredSize,
|
2005-08-02 20:05:52 +00:00
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus,
|
|
|
|
const ReflowConfig& aConfig,
|
2011-09-29 06:19:26 +00:00
|
|
|
bool aUnboundedLastColumn,
|
2008-04-18 07:40:35 +00:00
|
|
|
nsCollapsingMargin* aBottomMarginCarriedOut,
|
|
|
|
ColumnBalanceData& aColData)
|
|
|
|
{
|
|
|
|
aColData.Reset();
|
2011-09-29 06:19:26 +00:00
|
|
|
bool allFit = true;
|
2013-02-16 21:51:02 +00:00
|
|
|
bool RTL = StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool shrinkingHeightOnly = !NS_SUBTREE_DIRTY(this) &&
|
2004-10-08 12:17:10 +00:00
|
|
|
mLastBalanceHeight > aConfig.mColMaxHeight;
|
|
|
|
|
|
|
|
#ifdef DEBUG_roc
|
|
|
|
printf("*** Doing column reflow pass: mLastBalanceHeight=%d, mColMaxHeight=%d, RTL=%d\n, mBalanceColCount=%d, mColWidth=%d, mColGap=%d\n",
|
|
|
|
mLastBalanceHeight, aConfig.mColMaxHeight, RTL, aConfig.mBalanceColCount,
|
|
|
|
aConfig.mColWidth, aConfig.mColGap);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DrainOverflowColumns();
|
2013-03-19 14:05:05 +00:00
|
|
|
|
2013-04-08 18:38:33 +00:00
|
|
|
const bool colHeightChanged = mLastBalanceHeight != aConfig.mColMaxHeight;
|
|
|
|
|
|
|
|
if (colHeightChanged) {
|
2004-10-08 12:17:10 +00:00
|
|
|
mLastBalanceHeight = aConfig.mColMaxHeight;
|
|
|
|
// XXX Seems like this could fire if incremental reflow pushed the column set
|
|
|
|
// down so we reflow incrementally with a different available height.
|
|
|
|
// We need a way to do an incremental reflow and be sure availableHeight
|
|
|
|
// changes are taken account of! Right now I think block frames with absolute
|
|
|
|
// children might exit early.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
//NS_ASSERTION(aKidReason != eReflowReason_Incremental,
|
|
|
|
// "incremental reflow should not have changed the balance height");
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// get our border and padding
|
2013-12-27 17:59:21 +00:00
|
|
|
nsMargin borderPadding = aReflowState.ComputedPhysicalBorderPadding();
|
2014-06-24 17:52:19 +00:00
|
|
|
borderPadding.ApplySkipSides(GetSkipSides(&aReflowState));
|
2004-10-08 12:17:10 +00:00
|
|
|
|
|
|
|
nsRect contentRect(0, 0, 0, 0);
|
2010-10-07 04:25:46 +00:00
|
|
|
nsOverflowAreas overflowRects;
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
nsIFrame* child = mFrames.FirstChild();
|
|
|
|
nsPoint childOrigin = nsPoint(borderPadding.left, borderPadding.top);
|
|
|
|
// For RTL, figure out where the last column's left edge should be. Since the
|
|
|
|
// columns might not fill the frame exactly, we need to account for the
|
|
|
|
// slop. Otherwise we'll waste time moving the columns by some tiny
|
|
|
|
// amount unnecessarily.
|
|
|
|
if (RTL) {
|
2013-12-27 17:59:21 +00:00
|
|
|
nscoord availWidth = aReflowState.AvailableWidth();
|
2007-01-26 00:05:12 +00:00
|
|
|
if (aReflowState.ComputedWidth() != NS_INTRINSICSIZE) {
|
|
|
|
availWidth = aReflowState.ComputedWidth();
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
if (availWidth != NS_INTRINSICSIZE) {
|
|
|
|
childOrigin.x += availWidth - aConfig.mColWidth;
|
|
|
|
#ifdef DEBUG_roc
|
|
|
|
printf("*** childOrigin.x = %d\n", childOrigin.x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2008-04-18 07:40:35 +00:00
|
|
|
int columnCount = 0;
|
2014-06-17 12:19:38 +00:00
|
|
|
int contentBEnd = 0;
|
2011-09-29 06:19:26 +00:00
|
|
|
bool reflowNext = false;
|
2004-10-08 12:17:10 +00:00
|
|
|
|
|
|
|
while (child) {
|
|
|
|
// Try to skip reflowing the child. We can't skip if the child is dirty. We also can't
|
|
|
|
// skip if the next column is dirty, because the next column's first line(s)
|
2005-08-02 20:05:52 +00:00
|
|
|
// might be pullable back to this column. We can't skip if it's the last child
|
2009-02-11 01:20:59 +00:00
|
|
|
// because we need to obtain the bottom margin. We can't skip
|
|
|
|
// if this is the last column and we're supposed to assign unbounded
|
|
|
|
// height to it, because that could change the available height from
|
|
|
|
// the last time we reflowed it and we should try to pull all the
|
|
|
|
// content from its next sibling. (Note that it might be the last
|
|
|
|
// column, but not be the last child because the desired number of columns
|
|
|
|
// has changed.)
|
2011-09-29 06:19:26 +00:00
|
|
|
bool skipIncremental = !aReflowState.ShouldReflowAllKids()
|
2007-07-26 04:03:29 +00:00
|
|
|
&& !NS_SUBTREE_DIRTY(child)
|
2005-08-02 20:05:52 +00:00
|
|
|
&& child->GetNextSibling()
|
2009-02-11 01:20:59 +00:00
|
|
|
&& !(aUnboundedLastColumn && columnCount == aConfig.mBalanceColCount - 1)
|
2007-07-26 04:03:29 +00:00
|
|
|
&& !NS_SUBTREE_DIRTY(child->GetNextSibling());
|
2005-03-30 20:31:13 +00:00
|
|
|
// If we need to pull up content from the prev-in-flow then this is not just
|
|
|
|
// a height shrink. The prev in flow will have set the dirty bit.
|
2006-11-09 21:38:34 +00:00
|
|
|
// Check the overflow rect YMost instead of just the child's content height. The child
|
|
|
|
// may have overflowing content that cares about the available height boundary.
|
|
|
|
// (It may also have overflowing content that doesn't care about the available height
|
|
|
|
// boundary, but if so, too bad, this optimization is defeated.)
|
2010-10-07 04:25:47 +00:00
|
|
|
// We want scrollable overflow here since this is a calculation that
|
|
|
|
// affects layout.
|
2011-09-29 06:19:26 +00:00
|
|
|
bool skipResizeHeightShrink = shrinkingHeightOnly
|
2010-10-07 04:25:47 +00:00
|
|
|
&& child->GetScrollableOverflowRect().YMost() <= aConfig.mColMaxHeight;
|
2008-04-18 07:40:35 +00:00
|
|
|
|
2014-06-17 12:19:38 +00:00
|
|
|
nscoord childContentBEnd = 0;
|
|
|
|
WritingMode wm = child->GetWritingMode();
|
2004-10-08 12:17:10 +00:00
|
|
|
if (!reflowNext && (skipIncremental || skipResizeHeightShrink)) {
|
|
|
|
// This child does not need to be reflowed, but we may need to move it
|
|
|
|
MoveChildTo(this, child, childOrigin);
|
|
|
|
|
|
|
|
// If this is the last frame then make sure we get the right status
|
2007-07-26 04:03:29 +00:00
|
|
|
nsIFrame* kidNext = child->GetNextSibling();
|
|
|
|
if (kidNext) {
|
|
|
|
aStatus = (kidNext->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)
|
|
|
|
? NS_FRAME_OVERFLOW_INCOMPLETE
|
|
|
|
: NS_FRAME_NOT_COMPLETE;
|
2004-10-08 12:17:10 +00:00
|
|
|
} else {
|
|
|
|
aStatus = mLastFrameStatus;
|
|
|
|
}
|
2014-06-17 12:19:38 +00:00
|
|
|
childContentBEnd = nsLayoutUtils::CalculateContentBEnd(wm, child);
|
2004-10-08 12:17:10 +00:00
|
|
|
#ifdef DEBUG_roc
|
|
|
|
printf("*** Skipping child #%d %p (incremental %d, resize height shrink %d): status = %d\n",
|
|
|
|
columnCount, (void*)child, skipIncremental, skipResizeHeightShrink, aStatus);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
nsSize availSize(aConfig.mColWidth, aConfig.mColMaxHeight);
|
|
|
|
|
|
|
|
if (aUnboundedLastColumn && columnCount == aConfig.mBalanceColCount - 1) {
|
|
|
|
availSize.height = GetAvailableContentHeight(aReflowState);
|
|
|
|
}
|
2013-03-01 03:56:48 +00:00
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (reflowNext)
|
|
|
|
child->AddStateBits(NS_FRAME_IS_DIRTY);
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2007-03-30 21:11:41 +00:00
|
|
|
nsHTMLReflowState kidReflowState(PresContext(), aReflowState, child,
|
2005-02-01 01:21:25 +00:00
|
|
|
availSize, availSize.width,
|
2007-08-02 18:08:05 +00:00
|
|
|
aReflowState.ComputedHeight());
|
2011-10-17 14:59:28 +00:00
|
|
|
kidReflowState.mFlags.mIsTopOfPage = true;
|
|
|
|
kidReflowState.mFlags.mTableIsSplittable = false;
|
2012-09-28 06:57:33 +00:00
|
|
|
kidReflowState.mFlags.mIsColumnBalancing = aConfig.mBalanceColCount < INT32_MAX;
|
2012-06-13 16:00:56 +00:00
|
|
|
|
2013-04-08 18:38:33 +00:00
|
|
|
// We need to reflow any float placeholders, even if our column height
|
|
|
|
// hasn't changed.
|
|
|
|
kidReflowState.mFlags.mMustReflowPlaceholders = !colHeightChanged;
|
|
|
|
|
2012-06-13 17:14:31 +00:00
|
|
|
#ifdef DEBUG_roc
|
2006-12-10 22:06:53 +00:00
|
|
|
printf("*** Reflowing child #%d %p: availHeight=%d\n",
|
|
|
|
columnCount, (void*)child,availSize.height);
|
2004-10-08 12:17:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Note if the column's next in flow is not being changed by this incremental reflow.
|
|
|
|
// This may allow the current column to avoid trying to pull lines from the next column.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
if (child->GetNextSibling() &&
|
|
|
|
!(GetStateBits() & NS_FRAME_IS_DIRTY) &&
|
2004-10-08 12:17:10 +00:00
|
|
|
!(child->GetNextSibling()->GetStateBits() & NS_FRAME_IS_DIRTY)) {
|
2011-10-17 14:59:28 +00:00
|
|
|
kidReflowState.mFlags.mNextInFlowUntouched = true;
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2014-06-17 12:19:38 +00:00
|
|
|
nsHTMLReflowMetrics kidDesiredSize(wm, aDesiredSize.mFlags);
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2009-01-05 00:39:54 +00:00
|
|
|
// XXX it would be cool to consult the float manager for the
|
2004-10-08 12:17:10 +00:00
|
|
|
// previous block to figure out the region of floats from the
|
|
|
|
// previous column that extend into this column, and subtract
|
2009-01-05 00:39:54 +00:00
|
|
|
// that region from the new float manager. So you could stick a
|
2004-10-08 12:17:10 +00:00
|
|
|
// really big float in the first column and text in following
|
|
|
|
// columns would flow around it.
|
|
|
|
|
|
|
|
// Reflow the frame
|
2007-03-30 21:11:41 +00:00
|
|
|
ReflowChild(child, PresContext(), kidDesiredSize, kidReflowState,
|
2013-12-27 17:59:21 +00:00
|
|
|
childOrigin.x + kidReflowState.ComputedPhysicalMargin().left,
|
|
|
|
childOrigin.y + kidReflowState.ComputedPhysicalMargin().top,
|
2004-10-08 12:17:10 +00:00
|
|
|
0, aStatus);
|
|
|
|
|
|
|
|
reflowNext = (aStatus & NS_FRAME_REFLOW_NEXTINFLOW) != 0;
|
|
|
|
|
|
|
|
#ifdef DEBUG_roc
|
2012-07-20 18:27:04 +00:00
|
|
|
printf("*** Reflowed child #%d %p: status = %d, desiredSize=%d,%d CarriedOutBottomMargin=%d\n",
|
2013-12-27 17:59:52 +00:00
|
|
|
columnCount, (void*)child, aStatus, kidDesiredSize.Width(), kidDesiredSize.Height(),
|
2012-07-20 18:27:04 +00:00
|
|
|
kidDesiredSize.mCarriedOutBottomMargin.get());
|
2004-10-08 12:17:10 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
NS_FRAME_TRACE_REFLOW_OUT("Column::Reflow", aStatus);
|
|
|
|
|
2005-08-02 20:05:52 +00:00
|
|
|
*aBottomMarginCarriedOut = kidDesiredSize.mCarriedOutBottomMargin;
|
|
|
|
|
2014-01-17 01:34:44 +00:00
|
|
|
FinishReflowChild(child, PresContext(), kidDesiredSize,
|
|
|
|
&kidReflowState, childOrigin.x, childOrigin.y, 0);
|
2008-04-18 07:40:35 +00:00
|
|
|
|
2014-06-17 12:19:38 +00:00
|
|
|
childContentBEnd = nsLayoutUtils::CalculateContentBEnd(wm, child);
|
|
|
|
if (childContentBEnd > aConfig.mColMaxHeight) {
|
2011-10-17 14:59:28 +00:00
|
|
|
allFit = false;
|
2008-04-18 07:40:35 +00:00
|
|
|
}
|
2014-06-17 12:19:38 +00:00
|
|
|
if (childContentBEnd > availSize.height) {
|
|
|
|
aColData.mMaxOverflowingHeight = std::max(childContentBEnd,
|
2008-11-04 22:01:27 +00:00
|
|
|
aColData.mMaxOverflowingHeight);
|
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
contentRect.UnionRect(contentRect, child->GetRect());
|
|
|
|
|
2010-10-07 04:25:46 +00:00
|
|
|
ConsiderChildOverflow(overflowRects, child);
|
2014-06-17 12:19:38 +00:00
|
|
|
contentBEnd = std::max(contentBEnd, childContentBEnd);
|
|
|
|
aColData.mLastHeight = childContentBEnd;
|
|
|
|
aColData.mSumHeight += childContentBEnd;
|
2004-10-08 12:17:10 +00:00
|
|
|
|
|
|
|
// Build a continuation column if necessary
|
|
|
|
nsIFrame* kidNextInFlow = child->GetNextInFlow();
|
|
|
|
|
2007-07-26 04:03:29 +00:00
|
|
|
if (NS_FRAME_IS_FULLY_COMPLETE(aStatus) && !NS_FRAME_IS_TRUNCATED(aStatus)) {
|
2004-10-08 12:17:10 +00:00
|
|
|
NS_ASSERTION(!kidNextInFlow, "next in flow should have been deleted");
|
2012-07-30 14:20:58 +00:00
|
|
|
child = nullptr;
|
2004-10-08 12:17:10 +00:00
|
|
|
break;
|
|
|
|
} else {
|
2008-04-18 07:40:35 +00:00
|
|
|
++columnCount;
|
2004-10-08 12:17:10 +00:00
|
|
|
// Make sure that the column has a next-in-flow. If not, we must
|
|
|
|
// create one to hold the overflowing stuff, even if we're just
|
|
|
|
// going to put it on our overflow list and let *our*
|
|
|
|
// next in flow handle it.
|
|
|
|
if (!kidNextInFlow) {
|
|
|
|
NS_ASSERTION(aStatus & NS_FRAME_REFLOW_NEXTINFLOW,
|
|
|
|
"We have to create a continuation, but the block doesn't want us to reflow it?");
|
|
|
|
|
|
|
|
// We need to create a continuing column
|
2014-02-06 22:07:47 +00:00
|
|
|
nsresult rv = CreateNextInFlow(child, kidNextInFlow);
|
2004-10-08 12:17:10 +00:00
|
|
|
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_NOTREACHED("Couldn't create continuation");
|
2012-07-30 14:20:58 +00:00
|
|
|
child = nullptr;
|
2004-10-08 12:17:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-07-26 04:03:29 +00:00
|
|
|
|
|
|
|
// Make sure we reflow a next-in-flow when it switches between being
|
|
|
|
// normal or overflow container
|
|
|
|
if (NS_FRAME_OVERFLOW_IS_INCOMPLETE(aStatus)) {
|
|
|
|
if (!(kidNextInFlow->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER)) {
|
|
|
|
aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
2011-10-17 14:59:28 +00:00
|
|
|
reflowNext = true;
|
2007-07-26 04:03:29 +00:00
|
|
|
kidNextInFlow->AddStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (kidNextInFlow->GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) {
|
|
|
|
aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
2011-10-17 14:59:28 +00:00
|
|
|
reflowNext = true;
|
2007-07-26 04:03:29 +00:00
|
|
|
kidNextInFlow->RemoveStateBits(NS_FRAME_IS_OVERFLOW_CONTAINER);
|
|
|
|
}
|
2012-07-31 16:21:19 +00:00
|
|
|
|
2014-06-17 12:19:38 +00:00
|
|
|
if ((contentBEnd > aReflowState.ComputedMaxBSize() ||
|
|
|
|
contentBEnd > aReflowState.ComputedBSize()) &&
|
2013-03-06 14:20:24 +00:00
|
|
|
aConfig.mBalanceColCount < INT32_MAX) {
|
2013-04-24 15:02:36 +00:00
|
|
|
// We overflowed vertically, but have not exceeded the number of
|
|
|
|
// columns. We're going to go into overflow columns now, so balancing
|
|
|
|
// no longer applies.
|
|
|
|
aColData.mHasExcessHeight = true;
|
2012-07-31 16:21:19 +00:00
|
|
|
}
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
if (columnCount >= aConfig.mBalanceColCount) {
|
2013-03-06 14:20:24 +00:00
|
|
|
// No more columns allowed here. Stop.
|
|
|
|
aStatus |= NS_FRAME_REFLOW_NEXTINFLOW;
|
|
|
|
kidNextInFlow->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
// Move any of our leftover columns to our overflow list. Our
|
|
|
|
// next-in-flow will eventually pick them up.
|
|
|
|
const nsFrameList& continuationColumns = mFrames.RemoveFramesAfter(child);
|
|
|
|
if (continuationColumns.NotEmpty()) {
|
2014-02-06 22:07:47 +00:00
|
|
|
SetOverflowFrames(continuationColumns);
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2013-03-06 14:20:24 +00:00
|
|
|
child = nullptr;
|
|
|
|
break;
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-11 14:35:08 +00:00
|
|
|
if (PresContext()->HasPendingInterrupt()) {
|
2009-04-21 23:53:52 +00:00
|
|
|
// Stop the loop now while |child| still points to the frame that bailed
|
|
|
|
// out. We could keep going here and condition a bunch of the code in
|
|
|
|
// this loop on whether there's an interrupt, or even just keep going and
|
|
|
|
// trying to reflow the blocks (even though we know they'll interrupt
|
|
|
|
// right after their first line), but stopping now is conceptually the
|
2009-06-11 14:35:08 +00:00
|
|
|
// simplest (and probably fastest) thing.
|
2009-04-21 23:53:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
// Advance to the next column
|
|
|
|
child = child->GetNextSibling();
|
|
|
|
|
|
|
|
if (child) {
|
|
|
|
if (!RTL) {
|
|
|
|
childOrigin.x += aConfig.mColWidth + aConfig.mColGap;
|
|
|
|
} else {
|
|
|
|
childOrigin.x -= aConfig.mColWidth + aConfig.mColGap;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_roc
|
|
|
|
printf("*** NEXT CHILD ORIGIN.x = %d\n", childOrigin.x);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
2009-04-21 23:53:52 +00:00
|
|
|
|
2009-06-11 14:35:08 +00:00
|
|
|
if (PresContext()->CheckForInterrupt(this) &&
|
2009-04-21 23:53:52 +00:00
|
|
|
(GetStateBits() & NS_FRAME_IS_DIRTY)) {
|
|
|
|
// Mark all our kids starting with |child| dirty
|
2009-06-11 14:35:08 +00:00
|
|
|
|
|
|
|
// Note that this is a CheckForInterrupt call, not a HasPendingInterrupt,
|
|
|
|
// because we might have interrupted while reflowing |child|, and since
|
|
|
|
// we're about to add a dirty bit to |child| we need to make sure that
|
|
|
|
// |this| is scheduled to have dirty bits marked on it and its ancestors.
|
|
|
|
// Otherwise, when we go to mark dirty bits on |child|'s ancestors we'll
|
|
|
|
// bail out immediately, since it'll already have a dirty bit.
|
2009-04-21 23:53:52 +00:00
|
|
|
for (; child; child = child->GetNextSibling()) {
|
|
|
|
child->AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
}
|
|
|
|
}
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2014-06-17 12:19:38 +00:00
|
|
|
aColData.mMaxHeight = contentBEnd;
|
|
|
|
contentRect.height = std::max(contentRect.height, contentBEnd);
|
2004-10-08 12:17:10 +00:00
|
|
|
mLastFrameStatus = aStatus;
|
|
|
|
|
|
|
|
// contentRect included the borderPadding.left,borderPadding.top of the child rects
|
|
|
|
contentRect -= nsPoint(borderPadding.left, borderPadding.top);
|
|
|
|
|
|
|
|
nsSize contentSize = nsSize(contentRect.XMost(), contentRect.YMost());
|
|
|
|
|
|
|
|
// Apply computed and min/max values
|
2013-07-25 15:34:31 +00:00
|
|
|
if (aConfig.mComputedHeight != NS_INTRINSICSIZE) {
|
2013-12-27 17:59:21 +00:00
|
|
|
if (aReflowState.AvailableHeight() != NS_INTRINSICSIZE) {
|
2013-07-25 15:34:31 +00:00
|
|
|
contentSize.height = std::min(contentSize.height,
|
|
|
|
aConfig.mComputedHeight);
|
|
|
|
} else {
|
|
|
|
contentSize.height = aConfig.mComputedHeight;
|
2013-07-24 19:14:04 +00:00
|
|
|
}
|
2013-07-25 15:34:31 +00:00
|
|
|
} else {
|
|
|
|
// We add the "consumed" height back in so that we're applying
|
|
|
|
// constraints to the correct height value, then subtract it again
|
|
|
|
// after we've finished with the min/max calculation. This prevents us from
|
|
|
|
// having a last continuation that is smaller than the min height. but which
|
|
|
|
// has prev-in-flows, trigger a larger height than actually required.
|
|
|
|
contentSize.height = aReflowState.ApplyMinMaxHeight(contentSize.height,
|
|
|
|
aConfig.mConsumedHeight);
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2007-01-26 00:05:12 +00:00
|
|
|
if (aReflowState.ComputedWidth() != NS_INTRINSICSIZE) {
|
|
|
|
contentSize.width = aReflowState.ComputedWidth();
|
2004-10-08 12:17:10 +00:00
|
|
|
} else {
|
2013-07-25 15:34:31 +00:00
|
|
|
contentSize.width = aReflowState.ApplyMinMaxWidth(contentSize.width);
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2013-07-25 15:34:31 +00:00
|
|
|
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Height() = contentSize.height +
|
2013-07-25 15:34:31 +00:00
|
|
|
borderPadding.TopBottom();
|
2013-12-27 17:59:52 +00:00
|
|
|
aDesiredSize.Width() = contentSize.width +
|
2013-07-25 15:34:31 +00:00
|
|
|
borderPadding.LeftRight();
|
2010-10-07 04:25:46 +00:00
|
|
|
aDesiredSize.mOverflowAreas = overflowRects;
|
|
|
|
aDesiredSize.UnionOverflowAreasWithDesiredBounds();
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
#ifdef DEBUG_roc
|
2008-04-18 07:40:35 +00:00
|
|
|
printf("*** DONE PASS feasible=%d\n", allFit && NS_FRAME_IS_FULLY_COMPLETE(aStatus)
|
2004-10-08 12:17:10 +00:00
|
|
|
&& !NS_FRAME_IS_TRUNCATED(aStatus));
|
|
|
|
#endif
|
2008-04-18 07:40:35 +00:00
|
|
|
return allFit && NS_FRAME_IS_FULLY_COMPLETE(aStatus)
|
2004-10-08 12:17:10 +00:00
|
|
|
&& !NS_FRAME_IS_TRUNCATED(aStatus);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsColumnSetFrame::DrainOverflowColumns()
|
|
|
|
{
|
|
|
|
// First grab the prev-in-flows overflows and reparent them to this
|
|
|
|
// frame.
|
2013-04-01 15:26:02 +00:00
|
|
|
nsPresContext* presContext = PresContext();
|
2007-07-08 07:08:04 +00:00
|
|
|
nsColumnSetFrame* prev = static_cast<nsColumnSetFrame*>(GetPrevInFlow());
|
2004-10-08 12:17:10 +00:00
|
|
|
if (prev) {
|
2013-04-01 15:26:02 +00:00
|
|
|
AutoFrameListPtr overflows(presContext, prev->StealOverflowFrames());
|
2004-10-08 12:17:10 +00:00
|
|
|
if (overflows) {
|
2014-02-06 22:07:47 +00:00
|
|
|
nsContainerFrame::ReparentFrameViewList(*overflows, prev, this);
|
2004-10-08 12:17:10 +00:00
|
|
|
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrames.InsertFrames(this, nullptr, *overflows);
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Now pull back our own overflows and append them to our children.
|
|
|
|
// We don't need to reparent them since we're already their parent.
|
2013-04-01 15:26:02 +00:00
|
|
|
AutoFrameListPtr overflows(presContext, StealOverflowFrames());
|
2004-10-08 12:17:10 +00:00
|
|
|
if (overflows) {
|
2009-07-28 12:51:09 +00:00
|
|
|
// We're already the parent for these frames, so no need to set
|
|
|
|
// their parent again.
|
2012-07-30 14:20:58 +00:00
|
|
|
mFrames.AppendFrames(nullptr, *overflows);
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-09 20:24:27 +00:00
|
|
|
void
|
|
|
|
nsColumnSetFrame::FindBestBalanceHeight(const nsHTMLReflowState& aReflowState,
|
|
|
|
nsPresContext* aPresContext,
|
|
|
|
ReflowConfig& aConfig,
|
|
|
|
ColumnBalanceData& aColData,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
nsCollapsingMargin& aOutMargin,
|
|
|
|
bool& aUnboundedLastColumn,
|
|
|
|
bool& aRunWasFeasible,
|
|
|
|
nsReflowStatus& aStatus)
|
|
|
|
{
|
|
|
|
bool feasible = aRunWasFeasible;
|
2013-07-25 15:34:31 +00:00
|
|
|
|
2013-12-27 17:59:21 +00:00
|
|
|
nsMargin bp = aReflowState.ComputedPhysicalBorderPadding();
|
2014-06-24 17:52:19 +00:00
|
|
|
bp.ApplySkipSides(GetSkipSides());
|
2013-12-27 17:59:21 +00:00
|
|
|
bp.bottom = aReflowState.ComputedPhysicalBorderPadding().bottom;
|
2013-07-25 15:34:31 +00:00
|
|
|
|
|
|
|
nscoord availableContentHeight =
|
|
|
|
GetAvailableContentHeight(aReflowState);
|
2013-07-09 20:24:27 +00:00
|
|
|
|
|
|
|
// Termination of the algorithm below is guaranteed because
|
|
|
|
// aConfig.knownFeasibleHeight - aConfig.knownInfeasibleHeight decreases in every
|
|
|
|
// iteration.
|
|
|
|
|
|
|
|
// We set this flag when we detect that we may contain a frame
|
|
|
|
// that can break anywhere (thus foiling the linear decrease-by-one
|
|
|
|
// search)
|
|
|
|
bool maybeContinuousBreakingDetected = false;
|
|
|
|
|
|
|
|
while (!aPresContext->HasPendingInterrupt()) {
|
|
|
|
nscoord lastKnownFeasibleHeight = aConfig.mKnownFeasibleHeight;
|
|
|
|
|
|
|
|
// Record what we learned from the last reflow
|
|
|
|
if (feasible) {
|
|
|
|
// maxHeight is feasible. Also, mLastBalanceHeight is feasible.
|
|
|
|
aConfig.mKnownFeasibleHeight = std::min(aConfig.mKnownFeasibleHeight,
|
|
|
|
aColData.mMaxHeight);
|
|
|
|
aConfig.mKnownFeasibleHeight = std::min(aConfig.mKnownFeasibleHeight,
|
|
|
|
mLastBalanceHeight);
|
|
|
|
|
|
|
|
// Furthermore, no height less than the height of the last
|
|
|
|
// column can ever be feasible. (We might be able to reduce the
|
|
|
|
// height of a non-last column by moving content to a later column,
|
|
|
|
// but we can't do that with the last column.)
|
|
|
|
if (mFrames.GetLength() == aConfig.mBalanceColCount) {
|
|
|
|
aConfig.mKnownInfeasibleHeight = std::max(aConfig.mKnownInfeasibleHeight,
|
|
|
|
aColData.mLastHeight - 1);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
aConfig.mKnownInfeasibleHeight = std::max(aConfig.mKnownInfeasibleHeight,
|
|
|
|
mLastBalanceHeight);
|
|
|
|
// If a column didn't fit in its available height, then its current
|
|
|
|
// height must be the minimum height for unbreakable content in
|
|
|
|
// the column, and therefore no smaller height can be feasible.
|
|
|
|
aConfig.mKnownInfeasibleHeight = std::max(aConfig.mKnownInfeasibleHeight,
|
|
|
|
aColData.mMaxOverflowingHeight - 1);
|
|
|
|
|
|
|
|
if (aUnboundedLastColumn) {
|
|
|
|
// The last column is unbounded, so all content got reflowed, so the
|
|
|
|
// mColMaxHeight is feasible.
|
|
|
|
aConfig.mKnownFeasibleHeight = std::min(aConfig.mKnownFeasibleHeight,
|
|
|
|
aColData.mMaxHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_roc
|
|
|
|
printf("*** nsColumnSetFrame::Reflow balancing knownInfeasible=%d knownFeasible=%d\n",
|
|
|
|
aConfig.mKnownInfeasibleHeight, aConfig.mKnownFeasibleHeight);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
if (aConfig.mKnownInfeasibleHeight >= aConfig.mKnownFeasibleHeight - 1) {
|
|
|
|
// aConfig.mKnownFeasibleHeight is where we want to be
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aConfig.mKnownInfeasibleHeight >= availableContentHeight) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastKnownFeasibleHeight - aConfig.mKnownFeasibleHeight == 1) {
|
|
|
|
// We decreased the feasible height by one twip only. This could
|
|
|
|
// indicate that there is a continuously breakable child frame
|
|
|
|
// that we are crawling through.
|
|
|
|
maybeContinuousBreakingDetected = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nscoord nextGuess = (aConfig.mKnownFeasibleHeight + aConfig.mKnownInfeasibleHeight)/2;
|
|
|
|
// The constant of 600 twips is arbitrary. It's about two line-heights.
|
|
|
|
if (aConfig.mKnownFeasibleHeight - nextGuess < 600 &&
|
|
|
|
!maybeContinuousBreakingDetected) {
|
|
|
|
// We're close to our target, so just try shrinking just the
|
|
|
|
// minimum amount that will cause one of our columns to break
|
|
|
|
// differently.
|
|
|
|
nextGuess = aConfig.mKnownFeasibleHeight - 1;
|
|
|
|
} else if (aUnboundedLastColumn) {
|
|
|
|
// Make a guess by dividing that into N columns. Add some slop
|
|
|
|
// to try to make it on the feasible side. The constant of
|
|
|
|
// 600 twips is arbitrary. It's about two line-heights.
|
|
|
|
nextGuess = aColData.mSumHeight/aConfig.mBalanceColCount + 600;
|
|
|
|
// Sanitize it
|
|
|
|
nextGuess = clamped(nextGuess, aConfig.mKnownInfeasibleHeight + 1,
|
|
|
|
aConfig.mKnownFeasibleHeight - 1);
|
|
|
|
} else if (aConfig.mKnownFeasibleHeight == NS_INTRINSICSIZE) {
|
|
|
|
// This can happen when we had a next-in-flow so we didn't
|
|
|
|
// want to do an unbounded height measuring step. Let's just increase
|
|
|
|
// from the infeasible height by some reasonable amount.
|
|
|
|
nextGuess = aConfig.mKnownInfeasibleHeight*2 + 600;
|
|
|
|
}
|
|
|
|
// Don't bother guessing more than our height constraint.
|
|
|
|
nextGuess = std::min(availableContentHeight, nextGuess);
|
|
|
|
|
|
|
|
#ifdef DEBUG_roc
|
|
|
|
printf("*** nsColumnSetFrame::Reflow balancing choosing next guess=%d\n", nextGuess);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
aConfig.mColMaxHeight = nextGuess;
|
|
|
|
|
|
|
|
aUnboundedLastColumn = false;
|
|
|
|
AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
feasible = ReflowColumns(aDesiredSize, aReflowState, aStatus, aConfig, false,
|
|
|
|
&aOutMargin, aColData);
|
|
|
|
|
|
|
|
if (!aConfig.mIsBalancing) {
|
|
|
|
// Looks like we had excess height when balancing, so we gave up on
|
|
|
|
// trying to balance.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aConfig.mIsBalancing && !feasible &&
|
|
|
|
!aPresContext->HasPendingInterrupt()) {
|
|
|
|
// We may need to reflow one more time at the feasible height to
|
|
|
|
// get a valid layout.
|
|
|
|
bool skip = false;
|
|
|
|
if (aConfig.mKnownInfeasibleHeight >= availableContentHeight) {
|
|
|
|
aConfig.mColMaxHeight = availableContentHeight;
|
|
|
|
if (mLastBalanceHeight == availableContentHeight) {
|
|
|
|
skip = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
aConfig.mColMaxHeight = aConfig.mKnownFeasibleHeight;
|
|
|
|
}
|
|
|
|
if (!skip) {
|
|
|
|
// If our height is unconstrained, make sure that the last column is
|
|
|
|
// allowed to have arbitrary height here, even though we were balancing.
|
|
|
|
// Otherwise we'd have to split, and it's not clear what we'd do with
|
|
|
|
// that.
|
|
|
|
AddStateBits(NS_FRAME_IS_DIRTY);
|
|
|
|
feasible = ReflowColumns(aDesiredSize, aReflowState, aStatus, aConfig,
|
|
|
|
availableContentHeight == NS_UNCONSTRAINEDSIZE,
|
|
|
|
&aOutMargin, aColData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aRunWasFeasible = feasible;
|
|
|
|
}
|
|
|
|
|
2014-05-13 00:47:52 +00:00
|
|
|
void
|
2007-12-28 04:00:35 +00:00
|
|
|
nsColumnSetFrame::Reflow(nsPresContext* aPresContext,
|
|
|
|
nsHTMLReflowMetrics& aDesiredSize,
|
|
|
|
const nsHTMLReflowState& aReflowState,
|
|
|
|
nsReflowStatus& aStatus)
|
2004-10-08 12:17:10 +00:00
|
|
|
{
|
2009-07-24 13:32:32 +00:00
|
|
|
// Don't support interruption in columns
|
|
|
|
nsPresContext::InterruptPreventer noInterrupts(aPresContext);
|
|
|
|
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 05:38:33 +00:00
|
|
|
DO_GLOBAL_REFLOW_COUNT("nsColumnSetFrame");
|
2004-10-08 12:17:10 +00:00
|
|
|
DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
|
|
|
|
|
|
|
|
// Initialize OUT parameter
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
|
2009-07-07 01:23:24 +00:00
|
|
|
// Our children depend on our height if we have a fixed height.
|
|
|
|
if (aReflowState.ComputedHeight() != NS_AUTOHEIGHT) {
|
|
|
|
NS_ASSERTION(aReflowState.ComputedHeight() != NS_INTRINSICSIZE,
|
2013-07-25 15:34:31 +00:00
|
|
|
"Unexpected computed height");
|
2009-07-07 01:23:24 +00:00
|
|
|
AddStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
RemoveStateBits(NS_FRAME_CONTAINS_RELATIVE_HEIGHT);
|
|
|
|
}
|
|
|
|
|
2014-06-03 14:17:14 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
nsFrameList::Enumerator oc(GetChildList(kOverflowContainersList));
|
|
|
|
for (; !oc.AtEnd(); oc.Next()) {
|
|
|
|
MOZ_ASSERT(!IS_TRUE_OVERFLOW_CONTAINER(oc.get()));
|
|
|
|
}
|
|
|
|
nsFrameList::Enumerator eoc(GetChildList(kExcessOverflowContainersList));
|
|
|
|
for (; !eoc.AtEnd(); eoc.Next()) {
|
|
|
|
MOZ_ASSERT(!IS_TRUE_OVERFLOW_CONTAINER(eoc.get()));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
nsOverflowAreas ocBounds;
|
|
|
|
nsReflowStatus ocStatus = NS_FRAME_COMPLETE;
|
|
|
|
if (GetPrevInFlow()) {
|
|
|
|
ReflowOverflowContainerChildren(aPresContext, aReflowState, ocBounds, 0,
|
|
|
|
ocStatus);
|
|
|
|
}
|
|
|
|
|
2004-10-08 12:17:10 +00:00
|
|
|
//------------ Handle Incremental Reflow -----------------
|
|
|
|
|
|
|
|
ReflowConfig config = ChooseColumnStrategy(aReflowState);
|
|
|
|
|
|
|
|
// If balancing, then we allow the last column to grow to unbounded
|
|
|
|
// height during the first reflow. This gives us a way to estimate
|
|
|
|
// what the average column height should be, because we can measure
|
|
|
|
// the heights of all the columns and sum them up. But don't do this
|
|
|
|
// if we have a next in flow because we don't want to suck all its
|
|
|
|
// content back here and then have to push it out again!
|
|
|
|
nsIFrame* nextInFlow = GetNextInFlow();
|
2013-03-08 15:43:46 +00:00
|
|
|
bool unboundedLastColumn = config.mIsBalancing && !nextInFlow;
|
2005-08-02 20:05:52 +00:00
|
|
|
nsCollapsingMargin carriedOutBottomMargin;
|
2008-04-18 07:40:35 +00:00
|
|
|
ColumnBalanceData colData;
|
2013-04-24 15:02:36 +00:00
|
|
|
colData.mHasExcessHeight = false;
|
|
|
|
|
|
|
|
bool feasible = ReflowColumns(aDesiredSize, aReflowState, aStatus, config,
|
|
|
|
unboundedLastColumn, &carriedOutBottomMargin,
|
|
|
|
colData);
|
|
|
|
|
2013-07-09 20:24:27 +00:00
|
|
|
// If we're not balancing, then we're already done, since we should have
|
|
|
|
// reflown all of our children, and there is no need for a binary search to
|
|
|
|
// determine proper column height.
|
2013-04-24 15:02:36 +00:00
|
|
|
if (config.mIsBalancing && !aPresContext->HasPendingInterrupt()) {
|
2013-07-09 20:24:27 +00:00
|
|
|
FindBestBalanceHeight(aReflowState, aPresContext, config, colData,
|
|
|
|
aDesiredSize, carriedOutBottomMargin,
|
|
|
|
unboundedLastColumn, feasible, aStatus);
|
2013-04-24 15:02:36 +00:00
|
|
|
}
|
2009-04-21 23:53:52 +00:00
|
|
|
|
2013-04-24 15:02:36 +00:00
|
|
|
if (aPresContext->HasPendingInterrupt() &&
|
2013-12-27 17:59:21 +00:00
|
|
|
aReflowState.AvailableHeight() == NS_UNCONSTRAINEDSIZE) {
|
2013-04-24 15:02:36 +00:00
|
|
|
// In this situation, we might be lying about our reflow status, because
|
|
|
|
// our last kid (the one that got interrupted) was incomplete. Fix that.
|
|
|
|
aStatus = NS_FRAME_COMPLETE;
|
|
|
|
}
|
2012-07-31 16:21:19 +00:00
|
|
|
|
2014-06-03 14:17:14 +00:00
|
|
|
NS_ASSERTION(NS_FRAME_IS_FULLY_COMPLETE(aStatus) ||
|
|
|
|
aReflowState.AvailableHeight() != NS_UNCONSTRAINEDSIZE,
|
|
|
|
"Column set should be complete if the available height is unconstrained");
|
|
|
|
|
|
|
|
// Merge overflow container bounds and status.
|
|
|
|
aDesiredSize.mOverflowAreas.UnionWith(ocBounds);
|
|
|
|
NS_MergeReflowStatusInto(&aStatus, ocStatus);
|
|
|
|
|
2013-04-24 15:02:36 +00:00
|
|
|
FinishReflowWithAbsoluteFrames(aPresContext, aDesiredSize, aReflowState, aStatus, false);
|
2012-02-10 17:06:23 +00:00
|
|
|
|
2013-04-24 15:02:36 +00:00
|
|
|
aDesiredSize.mCarriedOutBottomMargin = carriedOutBottomMargin;
|
2004-10-08 12:17:10 +00:00
|
|
|
|
|
|
|
NS_FRAME_SET_TRUNCATION(aStatus, aReflowState, aDesiredSize);
|
|
|
|
}
|
|
|
|
|
2013-02-14 11:12:27 +00:00
|
|
|
void
|
2006-01-26 02:29:17 +00:00
|
|
|
nsColumnSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|
|
|
const nsRect& aDirtyRect,
|
|
|
|
const nsDisplayListSet& aLists) {
|
2013-02-14 11:08:08 +00:00
|
|
|
DisplayBorderBackgroundOutline(aBuilder, aLists);
|
2008-07-19 10:38:25 +00:00
|
|
|
|
2013-10-01 01:30:06 +00:00
|
|
|
if (IsVisibleForPainting(aBuilder)) {
|
|
|
|
aLists.BorderBackground()->AppendNewToTop(new (aBuilder)
|
2013-08-20 21:38:29 +00:00
|
|
|
nsDisplayGenericOverflow(aBuilder, this, ::PaintColumnRule, "ColumnRule",
|
|
|
|
nsDisplayItem::TYPE_COLUMN_RULE));
|
2013-10-01 01:30:06 +00:00
|
|
|
}
|
|
|
|
|
2006-01-26 02:29:17 +00:00
|
|
|
// Our children won't have backgrounds so it doesn't matter where we put them.
|
2012-08-18 01:12:01 +00:00
|
|
|
for (nsFrameList::Enumerator e(mFrames); !e.AtEnd(); e.Next()) {
|
2013-02-14 11:08:08 +00:00
|
|
|
BuildDisplayListForChild(aBuilder, e.get(), aDirtyRect, aLists);
|
2006-01-26 02:29:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
nsColumnSetFrame::SetInitialChildList(ChildListID aListID,
|
|
|
|
nsFrameList& aChildList)
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(aListID == kPrincipalList, "unexpected child list");
|
|
|
|
MOZ_ASSERT(aChildList.OnlyChild(),
|
|
|
|
"initial child list must have exactly one child");
|
|
|
|
nsContainerFrame::SetInitialChildList(kPrincipalList, aChildList);
|
|
|
|
}
|
2014-05-28 19:36:58 +00:00
|
|
|
|
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsColumnSetFrame::AppendFrames(ChildListID aListID,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2004-10-08 12:17:10 +00:00
|
|
|
{
|
2014-05-28 19:36:58 +00:00
|
|
|
MOZ_CRASH("unsupported operation");
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsColumnSetFrame::InsertFrames(ChildListID aListID,
|
2005-02-07 01:58:25 +00:00
|
|
|
nsIFrame* aPrevFrame,
|
2009-07-30 17:23:32 +00:00
|
|
|
nsFrameList& aFrameList)
|
2004-10-08 12:17:10 +00:00
|
|
|
{
|
2014-05-28 19:36:58 +00:00
|
|
|
MOZ_CRASH("unsupported operation");
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
|
|
|
|
2014-05-28 19:36:58 +00:00
|
|
|
void
|
2011-08-24 20:54:30 +00:00
|
|
|
nsColumnSetFrame::RemoveFrame(ChildListID aListID,
|
2005-02-07 01:58:25 +00:00
|
|
|
nsIFrame* aOldFrame)
|
2004-10-08 12:17:10 +00:00
|
|
|
{
|
2014-05-28 19:36:58 +00:00
|
|
|
MOZ_CRASH("unsupported operation");
|
2004-10-08 12:17:10 +00:00
|
|
|
}
|
2014-05-28 19:36:58 +00:00
|
|
|
#endif
|