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
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
// vim:cindent:ts=4:et:sw=4:
|
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/. */
|
1998-04-30 21:57:09 +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
|
|
|
/*
|
|
|
|
* Web-compatible algorithms that determine column and table widths,
|
|
|
|
* used for CSS2's 'table-layout: auto'.
|
|
|
|
*/
|
2004-07-16 05:49:18 +04:00
|
|
|
|
1998-04-30 21:57:09 +04:00
|
|
|
#include "BasicTableLayoutStrategy.h"
|
2014-08-06 09:19:25 +04:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
1998-04-30 21:57:09 +04:00
|
|
|
#include "nsTableFrame.h"
|
2015-04-30 07:24:59 +03:00
|
|
|
#include "nsTableColFrame.h"
|
1998-04-30 21:57:09 +04:00
|
|
|
#include "nsTableCellFrame.h"
|
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
|
|
|
#include "nsLayoutUtils.h"
|
|
|
|
#include "nsGkAtoms.h"
|
2007-01-13 04:04:56 +03:00
|
|
|
#include "SpanningCellSorter.h"
|
2014-08-06 09:19:25 +04:00
|
|
|
#include "nsIContent.h"
|
2004-04-13 03:51:33 +04:00
|
|
|
|
2012-01-25 05:21:29 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::layout;
|
|
|
|
|
2010-08-11 23:32:53 +04:00
|
|
|
namespace css = mozilla::css;
|
|
|
|
|
2006-12-19 01:34:30 +03:00
|
|
|
#undef DEBUG_TABLE_STRATEGY
|
|
|
|
|
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
|
|
|
BasicTableLayoutStrategy::BasicTableLayoutStrategy(nsTableFrame *aTableFrame)
|
2008-09-24 21:14:35 +04:00
|
|
|
: nsITableLayoutStrategy(nsITableLayoutStrategy::Auto)
|
|
|
|
, mTableFrame(aTableFrame)
|
1999-10-04 09:19:32 +04:00
|
|
|
{
|
2014-07-24 21:03:26 +04:00
|
|
|
MarkIntrinsicISizesDirty();
|
1998-04-30 21:57:09 +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
|
|
|
/* virtual */
|
1998-04-30 21:57:09 +04:00
|
|
|
BasicTableLayoutStrategy::~BasicTableLayoutStrategy()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/* virtual */ nscoord
|
2014-07-24 21:03:25 +04:00
|
|
|
BasicTableLayoutStrategy::GetMinISize(nsRenderingContext* aRenderingContext)
|
1998-04-30 21:57:09 +04:00
|
|
|
{
|
2015-06-16 17:45:46 +03:00
|
|
|
DISPLAY_MIN_WIDTH(mTableFrame, mMinISize);
|
|
|
|
if (mMinISize == NS_INTRINSIC_WIDTH_UNKNOWN) {
|
2014-07-24 21:03:26 +04:00
|
|
|
ComputeIntrinsicISizes(aRenderingContext);
|
2015-06-16 17:45:46 +03:00
|
|
|
}
|
|
|
|
return mMinISize;
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
1998-04-30 21:57:09 +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
|
|
|
/* virtual */ nscoord
|
2014-07-24 21:03:25 +04:00
|
|
|
BasicTableLayoutStrategy::GetPrefISize(nsRenderingContext* aRenderingContext,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aComputingSize)
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
2015-06-16 17:45:46 +03:00
|
|
|
DISPLAY_PREF_WIDTH(mTableFrame, mPrefISize);
|
|
|
|
NS_ASSERTION((mPrefISize == NS_INTRINSIC_WIDTH_UNKNOWN) ==
|
|
|
|
(mPrefISizePctExpand == NS_INTRINSIC_WIDTH_UNKNOWN),
|
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
|
|
|
"dirtyness out of sync");
|
2015-06-16 17:45:46 +03:00
|
|
|
if (mPrefISize == NS_INTRINSIC_WIDTH_UNKNOWN) {
|
2014-07-24 21:03:26 +04:00
|
|
|
ComputeIntrinsicISizes(aRenderingContext);
|
2015-06-16 17:45:46 +03:00
|
|
|
}
|
|
|
|
return aComputingSize ? mPrefISizePctExpand : mPrefISize;
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
1998-07-17 03:23:31 +04:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
struct CellISizeInfo {
|
|
|
|
CellISizeInfo(nscoord aMinCoord, nscoord aPrefCoord,
|
|
|
|
float aPrefPercent, bool aHasSpecifiedISize)
|
|
|
|
: hasSpecifiedISize(aHasSpecifiedISize)
|
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
|
|
|
, minCoord(aMinCoord)
|
|
|
|
, prefCoord(aPrefCoord)
|
|
|
|
, prefPercent(aPrefPercent)
|
|
|
|
{
|
2000-12-19 23:29:46 +03:00
|
|
|
}
|
1998-07-17 03:23:31 +04:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
bool hasSpecifiedISize;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nscoord minCoord;
|
|
|
|
nscoord prefCoord;
|
|
|
|
float prefPercent;
|
|
|
|
};
|
1999-12-14 01:56:31 +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
|
|
|
// Used for both column and cell calculations. The parts needed only
|
2008-12-04 19:09:52 +03:00
|
|
|
// for cells are skipped when aIsCell is false.
|
2015-06-16 17:45:46 +03:00
|
|
|
static CellISizeInfo
|
|
|
|
GetISizeInfo(nsRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame *aFrame, WritingMode aWM, bool aIsCell)
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
{
|
|
|
|
nscoord minCoord, prefCoord;
|
2013-02-17 01:51:02 +04:00
|
|
|
const nsStylePosition *stylePos = aFrame->StylePosition();
|
2012-08-03 11:05:01 +04:00
|
|
|
bool isQuirks = aFrame->PresContext()->CompatibilityMode() ==
|
|
|
|
eCompatibility_NavQuirks;
|
|
|
|
nscoord boxSizingToBorderEdge = 0;
|
2007-05-04 03:11:00 +04:00
|
|
|
if (aIsCell) {
|
2012-01-25 05:21:29 +04:00
|
|
|
// If aFrame is a container for font size inflation, then shrink
|
|
|
|
// wrapping inside of it should not apply font size inflation.
|
2012-05-21 09:18:27 +04:00
|
|
|
AutoMaybeDisableFontInflation an(aFrame);
|
2012-01-25 05:21:29 +04:00
|
|
|
|
2014-07-24 21:03:25 +04:00
|
|
|
minCoord = aFrame->GetMinISize(aRenderingContext);
|
|
|
|
prefCoord = aFrame->GetPrefISize(aRenderingContext);
|
2012-08-03 11:05:01 +04:00
|
|
|
// Until almost the end of this function, minCoord and prefCoord
|
2015-06-16 17:45:46 +03:00
|
|
|
// represent the box-sizing based isize values (which mean they
|
|
|
|
// should include inline padding and border width when
|
2012-08-03 11:05:01 +04:00
|
|
|
// box-sizing is set to border-box).
|
2015-06-16 17:45:46 +03:00
|
|
|
// Note that this function returns border-box isize, we add the
|
2012-08-03 11:05:01 +04:00
|
|
|
// outer edges near the end of this function.
|
|
|
|
|
|
|
|
// XXX Should we ignore percentage padding?
|
2015-06-16 17:45:46 +03:00
|
|
|
nsIFrame::IntrinsicISizeOffsetData offsets =
|
|
|
|
aFrame->IntrinsicISizeOffsets();
|
2012-08-03 11:05:01 +04:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
// In quirks mode, table cell isize should be content-box,
|
|
|
|
// but bsize should be border box.
|
2012-08-03 11:05:01 +04:00
|
|
|
// Because of this historic anomaly, we do not use quirk.css.
|
2015-06-16 17:45:46 +03:00
|
|
|
// (We can't specify one value of box-sizing for isize and another
|
|
|
|
// for bsize).
|
2012-08-03 11:05:01 +04:00
|
|
|
// For this reason, we also do not use box-sizing for just one of
|
|
|
|
// them, as this may be confusing.
|
2015-05-29 22:16:53 +03:00
|
|
|
if (isQuirks) {
|
2012-08-03 11:05:01 +04:00
|
|
|
boxSizingToBorderEdge = offsets.hPadding + offsets.hBorder;
|
|
|
|
}
|
|
|
|
else {
|
2015-05-29 22:16:53 +03:00
|
|
|
switch (stylePos->mBoxSizing) {
|
2015-11-20 05:09:29 +03:00
|
|
|
case StyleBoxSizing::Content:
|
2015-05-29 22:16:53 +03:00
|
|
|
boxSizingToBorderEdge = offsets.hPadding + offsets.hBorder;
|
|
|
|
break;
|
2015-11-20 05:09:29 +03:00
|
|
|
case StyleBoxSizing::Padding:
|
2015-05-29 22:16:53 +03:00
|
|
|
minCoord += offsets.hPadding;
|
|
|
|
prefCoord += offsets.hPadding;
|
|
|
|
boxSizingToBorderEdge = offsets.hBorder;
|
|
|
|
break;
|
2015-11-20 05:09:29 +03:00
|
|
|
case StyleBoxSizing::Border:
|
2015-05-29 22:16:53 +03:00
|
|
|
minCoord += offsets.hPadding + offsets.hBorder;
|
|
|
|
prefCoord += offsets.hPadding + offsets.hBorder;
|
|
|
|
break;
|
|
|
|
}
|
2012-08-03 11:05:01 +04:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
} else {
|
|
|
|
minCoord = 0;
|
|
|
|
prefCoord = 0;
|
|
|
|
}
|
|
|
|
float prefPercent = 0.0f;
|
2015-06-16 17:45:46 +03:00
|
|
|
bool hasSpecifiedISize = false;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
const nsStyleCoord& iSize = stylePos->ISize(aWM);
|
|
|
|
nsStyleUnit unit = iSize.GetUnit();
|
2012-11-21 20:19:37 +04:00
|
|
|
// NOTE: We're ignoring calc() units with percentages here, for lack of a
|
|
|
|
// sensible idea for what to do with them. This means calc() with
|
|
|
|
// percentages is basically handled like 'auto' for table cells and
|
|
|
|
// columns.
|
2015-06-16 17:45:46 +03:00
|
|
|
if (iSize.ConvertsToLength()) {
|
|
|
|
hasSpecifiedISize = true;
|
|
|
|
// Note: since ComputeISizeValue was designed to return content-box
|
|
|
|
// isize, it will (in some cases) subtract the box-sizing edges.
|
2012-08-03 11:05:01 +04:00
|
|
|
// We prevent this unwanted behavior by calling it with
|
|
|
|
// aContentEdgeToBoxSizing and aBoxSizingToMarginEdge set to 0.
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord c = nsLayoutUtils::ComputeISizeValue(aRenderingContext,
|
|
|
|
aFrame, 0, 0, 0, iSize);
|
2007-05-04 03:11:00 +04:00
|
|
|
// Quirk: A cell with "nowrap" set and a coord value for the
|
2015-06-16 17:45:46 +03:00
|
|
|
// isize which is bigger than the intrinsic minimum isize uses
|
|
|
|
// that coord value as the minimum isize.
|
2008-12-04 19:09:52 +03:00
|
|
|
// This is kept up-to-date with dynamic changes to nowrap by code in
|
2007-07-01 22:42:18 +04:00
|
|
|
// nsTableCellFrame::AttributeChanged
|
2015-06-16 17:45:46 +03:00
|
|
|
if (aIsCell && c > minCoord && isQuirks &&
|
2007-05-04 03:11:00 +04:00
|
|
|
aFrame->GetContent()->HasAttr(kNameSpaceID_None,
|
|
|
|
nsGkAtoms::nowrap)) {
|
2015-06-16 17:45:46 +03:00
|
|
|
minCoord = c;
|
2007-05-04 03:11:00 +04:00
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
prefCoord = std::max(c, minCoord);
|
2007-05-04 03:11:00 +04:00
|
|
|
} else if (unit == eStyleUnit_Percent) {
|
2015-06-16 17:45:46 +03:00
|
|
|
prefPercent = iSize.GetPercentValue();
|
2007-05-04 03:11:00 +04:00
|
|
|
} else if (unit == eStyleUnit_Enumerated && aIsCell) {
|
2015-06-16 17:45:46 +03:00
|
|
|
switch (iSize.GetIntValue()) {
|
2007-11-15 21:10:31 +03:00
|
|
|
case NS_STYLE_WIDTH_MAX_CONTENT:
|
2015-06-16 17:45:46 +03:00
|
|
|
// 'inline-size' only affects pref isize, not min
|
|
|
|
// isize, so don't change anything
|
2007-05-04 03:11:00 +04:00
|
|
|
break;
|
2007-11-15 21:10:31 +03:00
|
|
|
case NS_STYLE_WIDTH_MIN_CONTENT:
|
2007-05-04 03:11:00 +04:00
|
|
|
prefCoord = minCoord;
|
|
|
|
break;
|
2007-11-15 21:10:31 +03:00
|
|
|
case NS_STYLE_WIDTH_FIT_CONTENT:
|
|
|
|
case NS_STYLE_WIDTH_AVAILABLE:
|
2015-06-16 17:45:46 +03:00
|
|
|
// act just like 'inline-size: auto'
|
2007-05-04 03:11:00 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("unexpected enumerated value");
|
|
|
|
}
|
1999-07-28 12:09:02 +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-16 17:45:46 +03:00
|
|
|
nsStyleCoord maxISize(stylePos->MaxISize(aWM));
|
|
|
|
if (maxISize.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
if (!aIsCell || maxISize.GetIntValue() == NS_STYLE_WIDTH_AVAILABLE) {
|
|
|
|
maxISize.SetNoneValue();
|
|
|
|
} else if (maxISize.GetIntValue() == NS_STYLE_WIDTH_FIT_CONTENT) {
|
|
|
|
// for 'max-inline-size', '-moz-fit-content' is like
|
2007-11-15 21:10:31 +03:00
|
|
|
// '-moz-max-content'
|
2015-06-16 17:45:46 +03:00
|
|
|
maxISize.SetIntValue(NS_STYLE_WIDTH_MAX_CONTENT,
|
2007-05-04 03:11:00 +04:00
|
|
|
eStyleUnit_Enumerated);
|
2015-06-16 17:45:46 +03:00
|
|
|
}
|
2007-05-04 03:11:00 +04:00
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
unit = maxISize.GetUnit();
|
|
|
|
// XXX To really implement 'max-inline-size' well, we'd need to store
|
2007-05-04 03:11:00 +04:00
|
|
|
// it separately on the columns.
|
2015-06-16 17:45:46 +03:00
|
|
|
if (maxISize.ConvertsToLength() || unit == eStyleUnit_Enumerated) {
|
|
|
|
nscoord c =
|
|
|
|
nsLayoutUtils::ComputeISizeValue(aRenderingContext, aFrame,
|
|
|
|
0, 0, 0, maxISize);
|
|
|
|
minCoord = std::min(c, minCoord);
|
|
|
|
prefCoord = std::min(c, prefCoord);
|
2007-05-04 03:11:00 +04:00
|
|
|
} else if (unit == eStyleUnit_Percent) {
|
2015-06-16 17:45:46 +03:00
|
|
|
float p = stylePos->MaxISize(aWM).GetPercentValue();
|
|
|
|
if (p < prefPercent) {
|
2007-05-04 03:11:00 +04:00
|
|
|
prefPercent = p;
|
2015-06-16 17:45:46 +03:00
|
|
|
}
|
1998-06-24 03:23:21 +04:00
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
// treat calc() with percentages on max-inline-size just like 'none'.
|
|
|
|
|
|
|
|
nsStyleCoord minISize(stylePos->MinISize(aWM));
|
|
|
|
if (minISize.GetUnit() == eStyleUnit_Enumerated) {
|
|
|
|
if (!aIsCell || minISize.GetIntValue() == NS_STYLE_WIDTH_AVAILABLE) {
|
|
|
|
minISize.SetCoordValue(0);
|
|
|
|
} else if (minISize.GetIntValue() == NS_STYLE_WIDTH_FIT_CONTENT) {
|
|
|
|
// for 'min-inline-size', '-moz-fit-content' is like
|
2007-11-15 21:10:31 +03:00
|
|
|
// '-moz-min-content'
|
2015-06-16 17:45:46 +03:00
|
|
|
minISize.SetIntValue(NS_STYLE_WIDTH_MIN_CONTENT,
|
2007-05-04 03:11:00 +04:00
|
|
|
eStyleUnit_Enumerated);
|
2015-06-16 17:45:46 +03:00
|
|
|
}
|
2007-05-04 03:11:00 +04:00
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
unit = minISize.GetUnit();
|
|
|
|
if (minISize.ConvertsToLength() || unit == eStyleUnit_Enumerated) {
|
|
|
|
nscoord c =
|
|
|
|
nsLayoutUtils::ComputeISizeValue(aRenderingContext, aFrame,
|
|
|
|
0, 0, 0, minISize);
|
|
|
|
minCoord = std::max(c, minCoord);
|
|
|
|
prefCoord = std::max(c, prefCoord);
|
2007-05-04 03:11:00 +04:00
|
|
|
} else if (unit == eStyleUnit_Percent) {
|
2015-06-16 17:45:46 +03:00
|
|
|
float p = stylePos->MinISize(aWM).GetPercentValue();
|
|
|
|
if (p > prefPercent) {
|
2007-05-04 03:11:00 +04:00
|
|
|
prefPercent = p;
|
2015-06-16 17:45:46 +03:00
|
|
|
}
|
1998-07-13 22:11:12 +04:00
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
// treat calc() with percentages on min-inline-size just like '0'.
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
|
|
|
// XXX Should col frame have border/padding considered?
|
2007-05-04 03:11:00 +04:00
|
|
|
if (aIsCell) {
|
2012-08-03 11:05:01 +04:00
|
|
|
minCoord += boxSizingToBorderEdge;
|
|
|
|
prefCoord = NSCoordSaturatingAdd(prefCoord, boxSizingToBorderEdge);
|
1998-07-11 04:00:31 +04:00
|
|
|
}
|
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
return CellISizeInfo(minCoord, prefCoord, prefPercent, hasSpecifiedISize);
|
1998-04-30 21:57:09 +04:00
|
|
|
}
|
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
static inline CellISizeInfo
|
|
|
|
GetCellISizeInfo(nsRenderingContext *aRenderingContext,
|
|
|
|
nsTableCellFrame *aCellFrame, WritingMode aWM)
|
2000-12-19 23:29:46 +03:00
|
|
|
{
|
2015-06-16 17:45:46 +03:00
|
|
|
return GetISizeInfo(aRenderingContext, aCellFrame, aWM, true);
|
2000-12-19 23:29:46 +03:00
|
|
|
}
|
1998-04-30 21:57:09 +04:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
static inline CellISizeInfo
|
|
|
|
GetColISizeInfo(nsRenderingContext *aRenderingContext,
|
|
|
|
nsIFrame *aFrame, WritingMode aWM)
|
1998-04-30 21:57:09 +04:00
|
|
|
{
|
2015-06-16 17:45:46 +03:00
|
|
|
return GetISizeInfo(aRenderingContext, aFrame, aWM, false);
|
1999-07-28 12:09:02 +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
|
|
|
|
|
|
|
/**
|
|
|
|
* The algorithm in this function, in addition to meeting the
|
|
|
|
* requirements of Web-compatibility, is also invariant under reordering
|
|
|
|
* of the rows within a table (something that most, but not all, other
|
|
|
|
* browsers are).
|
|
|
|
*/
|
|
|
|
void
|
2014-07-24 21:03:26 +04:00
|
|
|
BasicTableLayoutStrategy::ComputeColumnIntrinsicISizes(nsRenderingContext* aRenderingContext)
|
1999-07-28 12:09:02 +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
|
|
|
nsTableFrame *tableFrame = mTableFrame;
|
|
|
|
nsTableCellMap *cellMap = tableFrame->GetCellMap();
|
2015-06-16 17:45:46 +03:00
|
|
|
WritingMode wm = tableFrame->GetWritingMode();
|
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-05-04 04:14:02 +04:00
|
|
|
mozilla::AutoStackArena arena;
|
2012-07-15 08:20:24 +04:00
|
|
|
SpanningCellSorter spanningCells;
|
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
|
|
|
|
|
|
|
// Loop over the columns to consider the columns and cells *without*
|
|
|
|
// a colspan.
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t col, col_end;
|
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 (col = 0, col_end = cellMap->GetColCount(); col < col_end; ++col) {
|
|
|
|
nsTableColFrame *colFrame = tableFrame->GetColFrame(col);
|
|
|
|
if (!colFrame) {
|
|
|
|
NS_ERROR("column frames out of sync with cell map");
|
|
|
|
continue;
|
2000-12-19 23:29:46 +03:00
|
|
|
}
|
2007-03-19 23:26:36 +03:00
|
|
|
colFrame->ResetIntrinsics();
|
|
|
|
colFrame->ResetSpanIntrinsics();
|
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-16 17:45:46 +03:00
|
|
|
// Consider the isizes on the column.
|
|
|
|
CellISizeInfo colInfo = GetColISizeInfo(aRenderingContext,
|
|
|
|
colFrame, wm);
|
2007-03-19 23:26:36 +03:00
|
|
|
colFrame->AddCoords(colInfo.minCoord, colInfo.prefCoord,
|
2015-06-16 17:45:46 +03:00
|
|
|
colInfo.hasSpecifiedISize);
|
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
|
|
|
colFrame->AddPrefPercent(colInfo.prefPercent);
|
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
// Consider the isizes on the column-group. Note that we follow
|
|
|
|
// what the HTML spec says here, and make the isize apply to
|
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
|
|
|
// each column in the group, not the group as a whole.
|
2009-08-01 19:53:40 +04:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
// If column has isize, column-group doesn't override isize.
|
2009-08-01 19:53:40 +04:00
|
|
|
if (colInfo.minCoord == 0 && colInfo.prefCoord == 0 &&
|
|
|
|
colInfo.prefPercent == 0.0f) {
|
|
|
|
NS_ASSERTION(colFrame->GetParent()->GetType() ==
|
|
|
|
nsGkAtoms::tableColGroupFrame,
|
|
|
|
"expected a column-group");
|
2015-06-16 17:45:46 +03:00
|
|
|
colInfo = GetColISizeInfo(aRenderingContext,
|
|
|
|
colFrame->GetParent(), wm);
|
2009-08-01 19:53:40 +04:00
|
|
|
colFrame->AddCoords(colInfo.minCoord, colInfo.prefCoord,
|
2015-06-16 17:45:46 +03:00
|
|
|
colInfo.hasSpecifiedISize);
|
2009-08-01 19:53:40 +04:00
|
|
|
colFrame->AddPrefPercent(colInfo.prefPercent);
|
|
|
|
}
|
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-16 17:45:46 +03:00
|
|
|
// Consider the contents of and the isizes on the cells without
|
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
|
|
|
// colspans.
|
2007-01-22 07:32:33 +03:00
|
|
|
nsCellMapColumnIterator columnIter(cellMap, col);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t row, colSpan;
|
2007-01-22 07:32:33 +03:00
|
|
|
nsTableCellFrame* cellFrame;
|
|
|
|
while ((cellFrame = columnIter.GetNextFrame(&row, &colSpan))) {
|
2007-01-13 04:04:56 +03:00
|
|
|
if (colSpan > 1) {
|
|
|
|
spanningCells.AddCell(colSpan, row, col);
|
|
|
|
continue;
|
|
|
|
}
|
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-16 17:45:46 +03:00
|
|
|
CellISizeInfo info = GetCellISizeInfo(aRenderingContext,
|
|
|
|
cellFrame, 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
|
|
|
|
2007-03-19 23:26:36 +03:00
|
|
|
colFrame->AddCoords(info.minCoord, info.prefCoord,
|
2015-06-16 17:45:46 +03:00
|
|
|
info.hasSpecifiedISize);
|
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
|
|
|
colFrame->AddPrefPercent(info.prefPercent);
|
1998-08-11 22:42:10 +04:00
|
|
|
}
|
2007-01-13 04:08:18 +03:00
|
|
|
#ifdef DEBUG_dbaron_off
|
|
|
|
printf("table %p col %d nonspan: min=%d pref=%d spec=%d pct=%f\n",
|
|
|
|
mTableFrame, col, colFrame->GetMinCoord(),
|
|
|
|
colFrame->GetPrefCoord(), colFrame->GetHasSpecifiedCoord(),
|
|
|
|
colFrame->GetPrefPercent());
|
|
|
|
#endif
|
1998-08-11 22:42:10 +04:00
|
|
|
}
|
2006-12-19 01:34:30 +03:00
|
|
|
#ifdef DEBUG_TABLE_STRATEGY
|
2014-07-24 21:03:26 +04:00
|
|
|
printf("ComputeColumnIntrinsicISizes single\n");
|
2011-10-17 18:59:28 +04:00
|
|
|
mTableFrame->Dump(false, true, false);
|
2006-12-19 01:34:30 +03:00
|
|
|
#endif
|
1999-07-28 12:09:02 +04:00
|
|
|
|
2007-01-13 04:04:56 +03:00
|
|
|
// Consider the cells with a colspan that we saved in the loop above
|
|
|
|
// into the spanning cell sorter. We consider these cells by seeing
|
2015-06-16 17:45:46 +03:00
|
|
|
// if they require adding to the isizes resulting only from cells
|
2007-01-13 04:04:56 +03:00
|
|
|
// with a smaller colspan, and therefore we must process them sorted
|
|
|
|
// in increasing order by colspan. For each colspan group, we
|
2007-03-19 23:26:36 +03:00
|
|
|
// accumulate new values to accumulate in the column frame's Span*
|
|
|
|
// members.
|
2007-01-13 04:04:56 +03:00
|
|
|
//
|
2015-06-16 17:45:46 +03:00
|
|
|
// Considering things only relative to the isizes resulting from
|
2007-01-13 04:04:56 +03:00
|
|
|
// cells with smaller colspans (rather than incrementally including
|
|
|
|
// the results from spanning cells, or doing spanning and
|
|
|
|
// non-spanning cells in a single pass) means that layout remains
|
2015-06-16 17:45:46 +03:00
|
|
|
// row-order-invariant and (except for percentage isizes that add to
|
2007-01-13 04:04:56 +03:00
|
|
|
// more than 100%) column-order invariant.
|
|
|
|
//
|
|
|
|
// Starting with smaller colspans makes it more likely that we
|
|
|
|
// satisfy all the constraints given and don't distribute space to
|
|
|
|
// columns where we don't need it.
|
|
|
|
SpanningCellSorter::Item *item;
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colSpan;
|
2007-01-13 04:04:56 +03:00
|
|
|
while ((item = spanningCells.GetNext(&colSpan))) {
|
|
|
|
NS_ASSERTION(colSpan > 1,
|
|
|
|
"cell should not have been put in spanning cell sorter");
|
|
|
|
do {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t row = item->row;
|
2007-01-13 04:04:56 +03:00
|
|
|
col = item->col;
|
|
|
|
CellData *cellData = cellMap->GetDataAt(row, col);
|
|
|
|
NS_ASSERTION(cellData && cellData->IsOrig(),
|
|
|
|
"bogus result from spanning cell sorter");
|
2007-01-24 23:18:04 +03:00
|
|
|
|
|
|
|
nsTableCellFrame *cellFrame = cellData->GetCellFrame();
|
2007-01-13 04:04:56 +03:00
|
|
|
NS_ASSERTION(cellFrame, "bogus result from spanning cell sorter");
|
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-16 17:45:46 +03:00
|
|
|
CellISizeInfo info =
|
|
|
|
GetCellISizeInfo(aRenderingContext, cellFrame, 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
|
|
|
|
2008-01-18 07:18:21 +03:00
|
|
|
if (info.prefPercent > 0.0f) {
|
2015-06-16 17:45:46 +03:00
|
|
|
DistributePctISizeToColumns(info.prefPercent,
|
2008-01-18 07:18:21 +03:00
|
|
|
col, colSpan);
|
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-16 17:45:46 +03:00
|
|
|
DistributeISizeToColumns(info.minCoord, col, colSpan,
|
|
|
|
BTLS_MIN_ISIZE, info.hasSpecifiedISize);
|
|
|
|
DistributeISizeToColumns(info.prefCoord, col, colSpan,
|
|
|
|
BTLS_PREF_ISIZE, info.hasSpecifiedISize);
|
2007-01-13 04:04:56 +03:00
|
|
|
} while ((item = item->next));
|
|
|
|
|
|
|
|
// Combine the results of the span analysis into the main results,
|
|
|
|
// for each increment of colspan.
|
|
|
|
|
|
|
|
for (col = 0, col_end = cellMap->GetColCount(); col < col_end; ++col) {
|
|
|
|
nsTableColFrame *colFrame = tableFrame->GetColFrame(col);
|
|
|
|
if (!colFrame) {
|
|
|
|
NS_ERROR("column frames out of sync with cell map");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-03-19 23:26:36 +03:00
|
|
|
colFrame->AccumulateSpanIntrinsics();
|
|
|
|
colFrame->ResetSpanIntrinsics();
|
2007-01-13 04:08:18 +03:00
|
|
|
|
|
|
|
#ifdef DEBUG_dbaron_off
|
|
|
|
printf("table %p col %d span %d: min=%d pref=%d spec=%d pct=%f\n",
|
|
|
|
mTableFrame, col, colSpan, colFrame->GetMinCoord(),
|
|
|
|
colFrame->GetPrefCoord(), colFrame->GetHasSpecifiedCoord(),
|
|
|
|
colFrame->GetPrefPercent());
|
|
|
|
#endif
|
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
|
|
|
}
|
2004-04-13 03:51:33 +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
|
|
|
// Prevent percentages from adding to more than 100% by (to be
|
|
|
|
// compatible with other browsers) treating any percentages that would
|
|
|
|
// increase the total percentage to more than 100% as the number that
|
|
|
|
// would increase it to only 100% (which is 0% if we've already hit
|
|
|
|
// 100%). This means layout depends on the order of columns.
|
|
|
|
float pct_used = 0.0f;
|
|
|
|
for (col = 0, col_end = cellMap->GetColCount(); col < col_end; ++col) {
|
|
|
|
nsTableColFrame *colFrame = tableFrame->GetColFrame(col);
|
|
|
|
if (!colFrame) {
|
|
|
|
NS_ERROR("column frames out of sync with cell map");
|
|
|
|
continue;
|
2000-09-09 05:46:44 +04:00
|
|
|
}
|
1999-11-06 01:36:59 +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
|
|
|
colFrame->AdjustPrefPercent(&pct_used);
|
1999-11-06 01:36:59 +03:00
|
|
|
}
|
2007-01-13 04:04:56 +03:00
|
|
|
|
2006-12-19 01:34:30 +03:00
|
|
|
#ifdef DEBUG_TABLE_STRATEGY
|
2014-07-24 21:03:26 +04:00
|
|
|
printf("ComputeColumnIntrinsicISizes spanning\n");
|
2011-10-17 18:59:28 +04:00
|
|
|
mTableFrame->Dump(false, true, false);
|
2006-12-19 01:34:30 +03:00
|
|
|
#endif
|
1999-11-06 01:36:59 +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
|
|
|
void
|
2014-07-24 21:03:26 +04:00
|
|
|
BasicTableLayoutStrategy::ComputeIntrinsicISizes(nsRenderingContext* aRenderingContext)
|
1999-11-06 01:36:59 +03:00
|
|
|
{
|
2014-07-24 21:03:26 +04:00
|
|
|
ComputeColumnIntrinsicISizes(aRenderingContext);
|
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
|
|
|
|
|
|
|
nsTableCellMap *cellMap = mTableFrame->GetCellMap();
|
|
|
|
nscoord min = 0, pref = 0, max_small_pct_pref = 0, nonpct_pref_total = 0;
|
|
|
|
float pct_total = 0.0f; // always from 0.0f - 1.0f
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colCount = cellMap->GetColCount();
|
2014-06-18 14:47:00 +04:00
|
|
|
// add a total of (colcount + 1) lots of cellSpacingX for columns where a
|
|
|
|
// cell originates
|
2015-03-20 07:16:00 +03:00
|
|
|
nscoord add = mTableFrame->GetColSpacing(colCount);
|
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-08-22 19:56:38 +04:00
|
|
|
for (int32_t col = 0; col < colCount; ++col) {
|
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
|
|
|
nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
|
|
|
|
if (!colFrame) {
|
|
|
|
NS_ERROR("column frames out of sync with cell map");
|
|
|
|
continue;
|
1999-11-06 01:36:59 +03:00
|
|
|
}
|
2008-09-24 21:14:35 +04:00
|
|
|
if (mTableFrame->ColumnHasCellSpacingBefore(col)) {
|
2015-03-20 07:16:00 +03:00
|
|
|
add += mTableFrame->GetColSpacing(col - 1);
|
2006-12-19 01:34:30 +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
|
|
|
min += colFrame->GetMinCoord();
|
2007-09-24 21:30:42 +04:00
|
|
|
pref = NSCoordSaturatingAdd(pref, colFrame->GetPrefCoord());
|
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
|
|
|
|
|
|
|
// Percentages are of the table, so we have to reverse them for
|
2015-06-16 17:45:46 +03:00
|
|
|
// intrinsic isizes.
|
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
|
|
|
float p = colFrame->GetPrefPercent();
|
|
|
|
if (p > 0.0f) {
|
2007-11-15 20:59:49 +03:00
|
|
|
nscoord colPref = colFrame->GetPrefCoord();
|
|
|
|
nscoord new_small_pct_expand =
|
|
|
|
(colPref == nscoord_MAX ?
|
|
|
|
nscoord_MAX : nscoord(float(colPref) / p));
|
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 (new_small_pct_expand > max_small_pct_pref) {
|
|
|
|
max_small_pct_pref = new_small_pct_expand;
|
2001-03-21 09:02:21 +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
|
|
|
pct_total += p;
|
|
|
|
} else {
|
2007-09-26 20:32:50 +04:00
|
|
|
nonpct_pref_total = NSCoordSaturatingAdd(nonpct_pref_total,
|
|
|
|
colFrame->GetPrefCoord());
|
2001-03-21 09:02:21 +03:00
|
|
|
}
|
1999-11-06 01:36:59 +03:00
|
|
|
}
|
2001-03-13 09:38:59 +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
|
|
|
nscoord pref_pct_expand = pref;
|
2000-02-12 04:55:40 +03:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
// Account for small percentages expanding the preferred isize of
|
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
|
|
|
// *other* columns.
|
|
|
|
if (max_small_pct_pref > pref_pct_expand) {
|
|
|
|
pref_pct_expand = max_small_pct_pref;
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
// Account for large percentages expanding the preferred isize of
|
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
|
|
|
// themselves. There's no need to iterate over the columns multiple
|
|
|
|
// times, since when there is such a need, the small percentage
|
|
|
|
// effect is bigger anyway. (I think!)
|
|
|
|
NS_ASSERTION(0.0f <= pct_total && pct_total <= 1.0f,
|
2015-06-16 17:45:46 +03:00
|
|
|
"column percentage inline-sizes not adjusted down to 100%");
|
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 (pct_total == 1.0f) {
|
|
|
|
if (nonpct_pref_total > 0) {
|
|
|
|
pref_pct_expand = nscoord_MAX;
|
|
|
|
// XXX Or should I use some smaller value? (Test this using
|
|
|
|
// nested tables!)
|
2005-10-29 17:45:38 +04:00
|
|
|
}
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
} else {
|
2007-11-15 21:04:16 +03:00
|
|
|
nscoord large_pct_pref =
|
|
|
|
(nonpct_pref_total == nscoord_MAX ?
|
|
|
|
nscoord_MAX :
|
|
|
|
nscoord(float(nonpct_pref_total) / (1.0f - pct_total)));
|
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 (large_pct_pref > pref_pct_expand)
|
|
|
|
pref_pct_expand = large_pct_pref;
|
1999-10-13 18:44:22 +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
|
|
|
// border-spacing isn't part of the basis for percentages
|
|
|
|
if (colCount > 0) {
|
|
|
|
min += add;
|
2007-09-24 21:30:42 +04:00
|
|
|
pref = NSCoordSaturatingAdd(pref, add);
|
|
|
|
pref_pct_expand = NSCoordSaturatingAdd(pref_pct_expand, add);
|
1998-08-11 22:42:10 +04:00
|
|
|
}
|
1998-04-30 21:57:09 +04:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
mMinISize = min;
|
|
|
|
mPrefISize = pref;
|
|
|
|
mPrefISizePctExpand = pref_pct_expand;
|
2001-02-07 07:31:38 +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
|
|
|
/* virtual */ void
|
2014-07-24 21:03:26 +04:00
|
|
|
BasicTableLayoutStrategy::MarkIntrinsicISizesDirty()
|
2001-03-13 09:38:59 +03:00
|
|
|
{
|
2015-06-16 17:45:46 +03:00
|
|
|
mMinISize = NS_INTRINSIC_WIDTH_UNKNOWN;
|
|
|
|
mPrefISize = NS_INTRINSIC_WIDTH_UNKNOWN;
|
|
|
|
mPrefISizePctExpand = NS_INTRINSIC_WIDTH_UNKNOWN;
|
|
|
|
mLastCalcISize = nscoord_MIN;
|
2001-03-13 09:38:59 +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
|
|
|
/* virtual */ void
|
2015-04-19 02:01:24 +03:00
|
|
|
BasicTableLayoutStrategy::ComputeColumnISizes(const nsHTMLReflowState& aReflowState)
|
1999-07-28 12:09:02 +04:00
|
|
|
{
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord iSize = aReflowState.ComputedISize();
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
if (mLastCalcISize == iSize) {
|
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;
|
2015-06-16 17:45:46 +03:00
|
|
|
}
|
|
|
|
mLastCalcISize = iSize;
|
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-16 17:45:46 +03:00
|
|
|
NS_ASSERTION((mMinISize == NS_INTRINSIC_WIDTH_UNKNOWN) ==
|
|
|
|
(mPrefISize == NS_INTRINSIC_WIDTH_UNKNOWN),
|
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
|
|
|
"dirtyness out of sync");
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION((mMinISize == NS_INTRINSIC_WIDTH_UNKNOWN) ==
|
|
|
|
(mPrefISizePctExpand == NS_INTRINSIC_WIDTH_UNKNOWN),
|
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
|
|
|
"dirtyness out of sync");
|
|
|
|
// XXX Is this needed?
|
2015-06-16 17:45:46 +03:00
|
|
|
if (mMinISize == NS_INTRINSIC_WIDTH_UNKNOWN) {
|
2014-07-24 21:03:26 +04:00
|
|
|
ComputeIntrinsicISizes(aReflowState.rendContext);
|
2015-06-16 17:45:46 +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
|
|
|
|
|
|
|
nsTableCellMap *cellMap = mTableFrame->GetCellMap();
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t colCount = cellMap->GetColCount();
|
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 (colCount <= 0)
|
|
|
|
return; // nothing to do
|
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
DistributeISizeToColumns(iSize, 0, colCount, BTLS_FINAL_ISIZE, false);
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2008-01-18 07:18:21 +03:00
|
|
|
#ifdef DEBUG_TABLE_STRATEGY
|
2015-04-19 02:01:24 +03:00
|
|
|
printf("ComputeColumnISizes final\n");
|
2011-10-17 18:59:28 +04:00
|
|
|
mTableFrame->Dump(false, true, false);
|
2008-01-18 07:18:21 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-16 17:45:46 +03:00
|
|
|
BasicTableLayoutStrategy::DistributePctISizeToColumns(float aSpanPrefPct,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aFirstCol,
|
|
|
|
int32_t aColCount)
|
2008-01-18 07:18:21 +03:00
|
|
|
{
|
|
|
|
// First loop to determine:
|
2015-06-16 17:45:46 +03:00
|
|
|
int32_t nonPctColCount = 0; // number of spanned columns without % isize
|
|
|
|
nscoord nonPctTotalPrefISize = 0; // total pref isize of those columns
|
|
|
|
// and to reduce aSpanPrefPct by columns that already have % isize
|
2008-01-18 07:18:21 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t scol, scol_end;
|
2013-01-03 07:58:05 +04:00
|
|
|
nsTableCellMap *cellMap = mTableFrame->GetCellMap();
|
2008-01-18 07:18:21 +03:00
|
|
|
for (scol = aFirstCol, scol_end = aFirstCol + aColCount;
|
|
|
|
scol < scol_end; ++scol) {
|
|
|
|
nsTableColFrame *scolFrame = mTableFrame->GetColFrame(scol);
|
|
|
|
if (!scolFrame) {
|
|
|
|
NS_ERROR("column frames out of sync with cell map");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
float scolPct = scolFrame->GetPrefPercent();
|
|
|
|
if (scolPct == 0.0f) {
|
2015-06-16 17:45:46 +03:00
|
|
|
nonPctTotalPrefISize += scolFrame->GetPrefCoord();
|
2013-01-03 07:58:05 +04:00
|
|
|
if (cellMap->GetNumCellsOriginatingInCol(scol) > 0) {
|
|
|
|
++nonPctColCount;
|
|
|
|
}
|
2008-01-18 07:18:21 +03:00
|
|
|
} else {
|
|
|
|
aSpanPrefPct -= scolPct;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aSpanPrefPct <= 0.0f || nonPctColCount == 0) {
|
2015-06-16 17:45:46 +03:00
|
|
|
// There's no %-isize on the colspan left over to distribute,
|
|
|
|
// or there are no columns to which we could distribute %-isize
|
2008-01-18 07:18:21 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Second loop, to distribute what remains of aSpanPrefPct
|
2015-06-16 17:45:46 +03:00
|
|
|
// between the non-percent-isize spanned columns
|
|
|
|
const bool spanHasNonPctPref = nonPctTotalPrefISize > 0; // Loop invariant
|
2008-01-18 07:18:21 +03:00
|
|
|
for (scol = aFirstCol, scol_end = aFirstCol + aColCount;
|
|
|
|
scol < scol_end; ++scol) {
|
|
|
|
nsTableColFrame *scolFrame = mTableFrame->GetColFrame(scol);
|
|
|
|
if (!scolFrame) {
|
|
|
|
NS_ERROR("column frames out of sync with cell map");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (scolFrame->GetPrefPercent() == 0.0f) {
|
|
|
|
NS_ASSERTION((!spanHasNonPctPref ||
|
2015-06-16 17:45:46 +03:00
|
|
|
nonPctTotalPrefISize != 0) &&
|
2008-01-18 07:18:21 +03:00
|
|
|
nonPctColCount != 0,
|
|
|
|
"should not be zero if we haven't allocated "
|
|
|
|
"all pref percent");
|
2008-02-22 20:15:27 +03:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
float allocatedPct; // % isize to be given to this column
|
2008-01-18 07:18:21 +03:00
|
|
|
if (spanHasNonPctPref) {
|
|
|
|
// Group so we're multiplying by 1.0f when we need
|
|
|
|
// to use up aSpanPrefPct.
|
|
|
|
allocatedPct = aSpanPrefPct *
|
|
|
|
(float(scolFrame->GetPrefCoord()) /
|
2015-06-16 17:45:46 +03:00
|
|
|
float(nonPctTotalPrefISize));
|
2013-01-03 07:58:05 +04:00
|
|
|
} else if (cellMap->GetNumCellsOriginatingInCol(scol) > 0) {
|
2015-06-16 17:45:46 +03:00
|
|
|
// distribute equally when all pref isizes are 0
|
2008-01-18 07:18:21 +03:00
|
|
|
allocatedPct = aSpanPrefPct / float(nonPctColCount);
|
2013-01-03 07:58:05 +04:00
|
|
|
} else {
|
|
|
|
allocatedPct = 0.0f;
|
2008-01-18 07:18:21 +03:00
|
|
|
}
|
|
|
|
// Allocate the percent
|
|
|
|
scolFrame->AddSpanPrefPercent(allocatedPct);
|
2013-01-03 07:58:05 +04:00
|
|
|
|
2008-01-18 07:18:21 +03:00
|
|
|
// To avoid accumulating rounding error from division,
|
|
|
|
// subtract this column's values from the totals.
|
|
|
|
aSpanPrefPct -= allocatedPct;
|
2015-06-16 17:45:46 +03:00
|
|
|
nonPctTotalPrefISize -= scolFrame->GetPrefCoord();
|
2013-01-03 07:58:05 +04:00
|
|
|
if (cellMap->GetNumCellsOriginatingInCol(scol) > 0) {
|
|
|
|
--nonPctColCount;
|
|
|
|
}
|
2008-02-22 20:15:27 +03:00
|
|
|
|
|
|
|
if (!aSpanPrefPct) {
|
2015-06-16 17:45:46 +03:00
|
|
|
// No more span-percent-isize to distribute --> we're done.
|
2008-02-22 20:15:27 +03:00
|
|
|
NS_ASSERTION(spanHasNonPctPref ?
|
2015-06-16 17:45:46 +03:00
|
|
|
nonPctTotalPrefISize == 0 :
|
2008-02-22 20:15:27 +03:00
|
|
|
nonPctColCount == 0,
|
2015-06-16 17:45:46 +03:00
|
|
|
"No more pct inline-size to distribute, "
|
|
|
|
"but there are still cols that need some.");
|
2008-02-22 20:15:27 +03:00
|
|
|
return;
|
|
|
|
}
|
2008-01-18 07:18:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-16 17:45:46 +03:00
|
|
|
BasicTableLayoutStrategy::DistributeISizeToColumns(nscoord aISize,
|
|
|
|
int32_t aFirstCol,
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t aColCount,
|
2015-06-16 17:45:46 +03:00
|
|
|
BtlsISizeType aISizeType,
|
|
|
|
bool aSpanHasSpecifiedISize)
|
2008-01-18 07:18:21 +03:00
|
|
|
{
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION(aISizeType != BTLS_FINAL_ISIZE ||
|
2008-01-18 07:18:21 +03:00
|
|
|
(aFirstCol == 0 &&
|
|
|
|
aColCount == mTableFrame->GetCellMap()->GetColCount()),
|
2015-06-16 17:45:46 +03:00
|
|
|
"Computing final column isizes, but didn't get full column range");
|
2014-06-18 14:47:00 +04:00
|
|
|
|
|
|
|
nscoord subtract = 0;
|
2015-06-16 17:45:46 +03:00
|
|
|
// aISize initially includes border-spacing for the boundaries in between
|
2008-01-18 07:18:21 +03:00
|
|
|
// each of the columns. We start at aFirstCol + 1 because the first
|
|
|
|
// in-between boundary would be at the left edge of column aFirstCol + 1
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t col = aFirstCol + 1; col < aFirstCol + aColCount; ++col) {
|
2008-09-24 21:14:35 +04:00
|
|
|
if (mTableFrame->ColumnHasCellSpacingBefore(col)) {
|
2014-06-18 14:47:00 +04:00
|
|
|
// border-spacing isn't part of the basis for percentages.
|
2015-03-20 07:16:00 +03:00
|
|
|
subtract += mTableFrame->GetColSpacing(col - 1);
|
2006-12-19 01:34:30 +03:00
|
|
|
}
|
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
if (aISizeType == BTLS_FINAL_ISIZE) {
|
|
|
|
// If we're computing final col-isize, then aISize initially includes
|
|
|
|
// border spacing on the table's far istart + far iend edge, too. Need
|
2008-01-18 07:18:21 +03:00
|
|
|
// to subtract those out, too.
|
2015-03-20 07:16:00 +03:00
|
|
|
subtract += (mTableFrame->GetColSpacing(-1) +
|
|
|
|
mTableFrame->GetColSpacing(aColCount));
|
2008-01-18 07:18:21 +03:00
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
aISize = NSCoordSaturatingSubtract(aISize, subtract, nscoord_MAX);
|
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-16 17:45:46 +03:00
|
|
|
* The goal of this function is to distribute |aISize| between the
|
|
|
|
* columns by making an appropriate AddSpanCoords or SetFinalISize
|
2008-01-18 07:18:21 +03:00
|
|
|
* call for each column. (We call AddSpanCoords if we're
|
2015-06-16 17:45:46 +03:00
|
|
|
* distributing a column-spanning cell's minimum or preferred isize
|
|
|
|
* to its spanned columns. We call SetFinalISize if we're
|
|
|
|
* distributing a table's final isize to its columns.)
|
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-16 17:45:46 +03:00
|
|
|
* The idea is to either assign one of the following sets of isizes
|
|
|
|
* or a weighted average of two adjacent sets of isizes. It is not
|
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
|
|
|
* possible to assign values smaller than the smallest set of
|
2015-06-16 17:45:46 +03:00
|
|
|
* isizes. However, see below for handling the case of assigning
|
|
|
|
* values larger than the largest set of isizes. From smallest to
|
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
|
|
|
* largest, these are:
|
|
|
|
*
|
2015-06-16 17:45:46 +03:00
|
|
|
* 1. [guess_min] Assign all columns their min isize.
|
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-16 17:45:46 +03:00
|
|
|
* 2. [guess_min_pct] Assign all columns with percentage isizes
|
|
|
|
* their percentage isize, and all other columns their min isize.
|
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-16 17:45:46 +03:00
|
|
|
* 3. [guess_min_spec] Assign all columns with percentage isizes
|
|
|
|
* their percentage isize, all columns with specified coordinate
|
|
|
|
* isizes their pref isize (since it doesn't matter whether it's the
|
|
|
|
* largest contributor to the pref isize that was the specified
|
|
|
|
* contributor), and all other columns their min isize.
|
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-16 17:45:46 +03:00
|
|
|
* 4. [guess_pref] Assign all columns with percentage isizes their
|
|
|
|
* specified isize, and all other columns their pref isize.
|
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-16 17:45:46 +03:00
|
|
|
* If |aISize| is *larger* than what we would assign in (4), then we
|
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
|
|
|
* expand the columns:
|
|
|
|
*
|
2015-06-16 17:45:46 +03:00
|
|
|
* a. if any columns without a specified coordinate isize or
|
|
|
|
* percent isize have nonzero pref isize, in proportion to pref
|
|
|
|
* isize [total_flex_pref]
|
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-09-08 02:57:06 +04:00
|
|
|
* b. otherwise, if any columns without a specified coordinate
|
2015-06-16 17:45:46 +03:00
|
|
|
* isize or percent isize, but with cells originating in them,
|
|
|
|
* have zero pref isize, equally between these
|
|
|
|
* [numNonSpecZeroISizeCols]
|
2008-02-22 06:25:56 +03:00
|
|
|
*
|
2015-06-16 17:45:46 +03:00
|
|
|
* c. otherwise, if any columns without percent isize have nonzero
|
|
|
|
* pref isize, in proportion to pref isize [total_fixed_pref]
|
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-16 17:45:46 +03:00
|
|
|
* d. otherwise, if any columns have nonzero percentage isizes, in
|
|
|
|
* proportion to the percentage isizes [total_pct]
|
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
|
|
|
*
|
2008-02-22 06:25:56 +03:00
|
|
|
* e. otherwise, equally.
|
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
|
|
|
*/
|
|
|
|
|
|
|
|
// Loop #1 over the columns, to figure out the four values above so
|
|
|
|
// we know which case we're dealing with.
|
|
|
|
|
|
|
|
nscoord guess_min = 0,
|
|
|
|
guess_min_pct = 0,
|
|
|
|
guess_min_spec = 0,
|
|
|
|
guess_pref = 0,
|
|
|
|
total_flex_pref = 0,
|
|
|
|
total_fixed_pref = 0;
|
|
|
|
float total_pct = 0.0f; // 0.0f to 1.0f
|
2015-06-16 17:45:46 +03:00
|
|
|
int32_t numInfiniteISizeCols = 0;
|
|
|
|
int32_t numNonSpecZeroISizeCols = 0;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t col;
|
2009-04-18 12:22:34 +04:00
|
|
|
nsTableCellMap *cellMap = mTableFrame->GetCellMap();
|
2008-01-18 07:18:21 +03:00
|
|
|
for (col = aFirstCol; col < aFirstCol + aColCount; ++col) {
|
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
|
|
|
nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
|
|
|
|
if (!colFrame) {
|
|
|
|
NS_ERROR("column frames out of sync with cell map");
|
1999-07-28 12:09:02 +04:00
|
|
|
continue;
|
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord min_iSize = colFrame->GetMinCoord();
|
|
|
|
guess_min += min_iSize;
|
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 (colFrame->GetPrefPercent() != 0.0f) {
|
|
|
|
float pct = colFrame->GetPrefPercent();
|
|
|
|
total_pct += pct;
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord val = nscoord(float(aISize) * pct);
|
|
|
|
if (val < min_iSize) {
|
|
|
|
val = min_iSize;
|
|
|
|
}
|
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
|
|
|
guess_min_pct += val;
|
2007-11-15 21:04:16 +03:00
|
|
|
guess_pref = NSCoordSaturatingAdd(guess_pref, val);
|
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-16 17:45:46 +03:00
|
|
|
nscoord pref_iSize = colFrame->GetPrefCoord();
|
|
|
|
if (pref_iSize == nscoord_MAX) {
|
|
|
|
++numInfiniteISizeCols;
|
2007-09-24 21:30:42 +04:00
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
guess_pref = NSCoordSaturatingAdd(guess_pref, pref_iSize);
|
|
|
|
guess_min_pct += min_iSize;
|
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 (colFrame->GetHasSpecifiedCoord()) {
|
|
|
|
// we'll add on the rest of guess_min_spec outside the
|
|
|
|
// loop
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord delta = NSCoordSaturatingSubtract(pref_iSize,
|
|
|
|
min_iSize, 0);
|
2007-09-24 21:30:42 +04:00
|
|
|
guess_min_spec = NSCoordSaturatingAdd(guess_min_spec, delta);
|
|
|
|
total_fixed_pref = NSCoordSaturatingAdd(total_fixed_pref,
|
2015-06-16 17:45:46 +03:00
|
|
|
pref_iSize);
|
|
|
|
} else if (pref_iSize == 0) {
|
2012-09-08 02:57:06 +04:00
|
|
|
if (cellMap->GetNumCellsOriginatingInCol(col) > 0) {
|
2015-06-16 17:45:46 +03:00
|
|
|
++numNonSpecZeroISizeCols;
|
2008-02-22 06:25:56 +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
|
|
|
} else {
|
2007-09-24 21:30:42 +04:00
|
|
|
total_flex_pref = NSCoordSaturatingAdd(total_flex_pref,
|
2015-06-16 17:45:46 +03:00
|
|
|
pref_iSize);
|
1998-06-06 02:50:03 +04:00
|
|
|
}
|
1998-05-27 02:03:16 +04:00
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
2007-09-24 21:30:42 +04:00
|
|
|
guess_min_spec = NSCoordSaturatingAdd(guess_min_spec, guess_min_pct);
|
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
|
|
|
|
|
|
|
// Determine what we're flexing:
|
|
|
|
enum Loop2Type {
|
|
|
|
FLEX_PCT_SMALL, // between (1) and (2) above
|
|
|
|
FLEX_FIXED_SMALL, // between (2) and (3) above
|
|
|
|
FLEX_FLEX_SMALL, // between (3) and (4) above
|
2008-01-18 07:18:21 +03:00
|
|
|
FLEX_FLEX_LARGE, // greater than (4) above, case (a)
|
2008-02-22 06:25:56 +03:00
|
|
|
FLEX_FLEX_LARGE_ZERO, // greater than (4) above, case (b)
|
|
|
|
FLEX_FIXED_LARGE, // greater than (4) above, case (c)
|
|
|
|
FLEX_PCT_LARGE, // greater than (4) above, case (d)
|
|
|
|
FLEX_ALL_LARGE // greater than (4) above, case (e)
|
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
|
|
|
};
|
|
|
|
|
|
|
|
Loop2Type l2t;
|
2007-02-18 22:49:50 +03:00
|
|
|
// These are constants (over columns) for each case's math. We use
|
|
|
|
// a pair of nscoords rather than a float so that we can subtract
|
|
|
|
// each column's allocation so we avoid accumulating rounding error.
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord space; // the amount of extra isize to allocate
|
2007-02-18 22:49:50 +03:00
|
|
|
union {
|
|
|
|
nscoord c;
|
|
|
|
float f;
|
|
|
|
} basis; // the sum of the statistic over columns to divide it
|
2015-06-16 17:45:46 +03:00
|
|
|
if (aISize < guess_pref) {
|
|
|
|
if (aISizeType != BTLS_FINAL_ISIZE && aISize <= guess_min) {
|
2008-01-18 07:18:21 +03:00
|
|
|
// Return early -- we don't have any extra space to distribute.
|
|
|
|
return;
|
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION(!(aISizeType == BTLS_FINAL_ISIZE && aISize < guess_min),
|
|
|
|
"Table inline-size is less than the "
|
|
|
|
"sum of its columns' min inline-sizes");
|
|
|
|
if (aISize < guess_min_pct) {
|
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
|
|
|
l2t = FLEX_PCT_SMALL;
|
2015-06-16 17:45:46 +03:00
|
|
|
space = aISize - guess_min;
|
2007-02-18 22:49:50 +03:00
|
|
|
basis.c = guess_min_pct - guess_min;
|
2015-06-16 17:45:46 +03:00
|
|
|
} else if (aISize < guess_min_spec) {
|
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
|
|
|
l2t = FLEX_FIXED_SMALL;
|
2015-06-16 17:45:46 +03:00
|
|
|
space = aISize - guess_min_pct;
|
2007-09-24 21:30:42 +04:00
|
|
|
basis.c = NSCoordSaturatingSubtract(guess_min_spec, guess_min_pct,
|
|
|
|
nscoord_MAX);
|
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 {
|
|
|
|
l2t = FLEX_FLEX_SMALL;
|
2015-06-16 17:45:46 +03:00
|
|
|
space = aISize - guess_min_spec;
|
2007-09-24 21:30:42 +04:00
|
|
|
basis.c = NSCoordSaturatingSubtract(guess_pref, guess_min_spec,
|
|
|
|
nscoord_MAX);
|
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-16 17:45:46 +03:00
|
|
|
space = NSCoordSaturatingSubtract(aISize, guess_pref, nscoord_MAX);
|
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 (total_flex_pref > 0) {
|
|
|
|
l2t = FLEX_FLEX_LARGE;
|
2007-02-18 22:49:50 +03:00
|
|
|
basis.c = total_flex_pref;
|
2015-06-16 17:45:46 +03:00
|
|
|
} else if (numNonSpecZeroISizeCols > 0) {
|
2008-02-22 06:25:56 +03:00
|
|
|
l2t = FLEX_FLEX_LARGE_ZERO;
|
2015-06-16 17:45:46 +03:00
|
|
|
basis.c = numNonSpecZeroISizeCols;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
} else if (total_fixed_pref > 0) {
|
|
|
|
l2t = FLEX_FIXED_LARGE;
|
2007-02-18 22:49:50 +03:00
|
|
|
basis.c = total_fixed_pref;
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
} else if (total_pct > 0.0f) {
|
|
|
|
l2t = FLEX_PCT_LARGE;
|
2007-02-18 22:49:50 +03:00
|
|
|
basis.f = total_pct;
|
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 {
|
|
|
|
l2t = FLEX_ALL_LARGE;
|
2008-01-18 07:18:21 +03:00
|
|
|
basis.c = aColCount;
|
1999-10-04 09:19:32 +04:00
|
|
|
}
|
2000-10-13 05:57:02 +04:00
|
|
|
}
|
1998-04-30 21:57:09 +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
|
|
|
#ifdef DEBUG_dbaron_off
|
2015-06-16 17:45:46 +03:00
|
|
|
printf("ComputeColumnISizes: %d columns in isize %d,\n"
|
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
|
|
|
" guesses=[%d,%d,%d,%d], totals=[%d,%d,%f],\n"
|
2007-02-18 22:49:50 +03:00
|
|
|
" l2t=%d, space=%d, basis.c=%d\n",
|
2015-06-16 17:45:46 +03:00
|
|
|
aColCount, aISize,
|
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
|
|
|
guess_min, guess_min_pct, guess_min_spec, guess_pref,
|
|
|
|
total_flex_pref, total_fixed_pref, total_pct,
|
2007-02-18 22:49:50 +03:00
|
|
|
l2t, space, basis.c);
|
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
|
|
|
#endif
|
1999-07-28 12:09:02 +04:00
|
|
|
|
2008-01-18 07:18:21 +03:00
|
|
|
for (col = aFirstCol; col < aFirstCol + aColCount; ++col) {
|
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
|
|
|
nsTableColFrame *colFrame = mTableFrame->GetColFrame(col);
|
|
|
|
if (!colFrame) {
|
|
|
|
NS_ERROR("column frames out of sync with cell map");
|
|
|
|
continue;
|
|
|
|
}
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord col_iSize;
|
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
|
|
|
|
|
|
|
float pct = colFrame->GetPrefPercent();
|
|
|
|
if (pct != 0.0f) {
|
2015-06-16 17:45:46 +03:00
|
|
|
col_iSize = nscoord(float(aISize) * pct);
|
2006-12-19 01:35:01 +03:00
|
|
|
nscoord col_min = colFrame->GetMinCoord();
|
2015-06-16 17:45:46 +03:00
|
|
|
if (col_iSize < col_min) {
|
|
|
|
col_iSize = col_min;
|
|
|
|
}
|
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-16 17:45:46 +03:00
|
|
|
col_iSize = colFrame->GetPrefCoord();
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
1999-05-27 02:22:23 +04:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord col_iSize_before_adjust = col_iSize;
|
2007-02-18 22:49:50 +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
|
|
|
switch (l2t) {
|
|
|
|
case FLEX_PCT_SMALL:
|
2015-06-16 17:45:46 +03:00
|
|
|
col_iSize = col_iSize_before_adjust = colFrame->GetMinCoord();
|
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 (pct != 0.0f) {
|
2007-02-18 22:49:50 +03:00
|
|
|
nscoord pct_minus_min =
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord(float(aISize) * pct) - col_iSize;
|
2007-02-18 22:49:50 +03:00
|
|
|
if (pct_minus_min > 0) {
|
|
|
|
float c = float(space) / float(basis.c);
|
|
|
|
basis.c -= pct_minus_min;
|
2015-06-16 17:45:46 +03:00
|
|
|
col_iSize += NSToCoordRound(float(pct_minus_min) * c);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FLEX_FIXED_SMALL:
|
|
|
|
if (pct == 0.0f) {
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION(col_iSize == colFrame->GetPrefCoord(),
|
|
|
|
"wrong inline-size assigned");
|
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 (colFrame->GetHasSpecifiedCoord()) {
|
|
|
|
nscoord col_min = colFrame->GetMinCoord();
|
2015-06-16 17:45:46 +03:00
|
|
|
nscoord pref_minus_min = col_iSize - col_min;
|
|
|
|
col_iSize = col_iSize_before_adjust = col_min;
|
2007-02-18 22:49:50 +03:00
|
|
|
if (pref_minus_min != 0) {
|
|
|
|
float c = float(space) / float(basis.c);
|
|
|
|
basis.c -= pref_minus_min;
|
2015-06-16 17:45:46 +03:00
|
|
|
col_iSize += NSToCoordRound(
|
2007-02-18 22:49:50 +03:00
|
|
|
float(pref_minus_min) * c);
|
|
|
|
}
|
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-16 17:45:46 +03:00
|
|
|
col_iSize = col_iSize_before_adjust =
|
2007-02-18 22:49:50 +03:00
|
|
|
colFrame->GetMinCoord();
|
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
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FLEX_FLEX_SMALL:
|
|
|
|
if (pct == 0.0f &&
|
|
|
|
!colFrame->GetHasSpecifiedCoord()) {
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION(col_iSize == colFrame->GetPrefCoord(),
|
|
|
|
"wrong inline-size assigned");
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
nscoord col_min = colFrame->GetMinCoord();
|
2007-09-24 21:30:42 +04:00
|
|
|
nscoord pref_minus_min =
|
2015-06-16 17:45:46 +03:00
|
|
|
NSCoordSaturatingSubtract(col_iSize, col_min, 0);
|
|
|
|
col_iSize = col_iSize_before_adjust = col_min;
|
2007-02-18 22:49:50 +03:00
|
|
|
if (pref_minus_min != 0) {
|
|
|
|
float c = float(space) / float(basis.c);
|
2015-06-16 17:45:46 +03:00
|
|
|
// If we have infinite-isize cols, then the standard
|
|
|
|
// adjustment to col_iSize using 'c' won't work,
|
2007-09-24 21:30:42 +04:00
|
|
|
// because basis.c and pref_minus_min are both
|
|
|
|
// nscoord_MAX and will cancel each other out in the
|
2015-06-16 17:45:46 +03:00
|
|
|
// col_iSize adjustment (making us assign all the
|
|
|
|
// space to the first inf-isize col). To correct for
|
|
|
|
// this, we'll also divide by numInfiniteISizeCols to
|
|
|
|
// spread the space equally among the inf-isize cols.
|
|
|
|
if (numInfiniteISizeCols) {
|
2007-09-24 21:30:42 +04:00
|
|
|
if (colFrame->GetPrefCoord() == nscoord_MAX) {
|
2015-06-16 17:45:46 +03:00
|
|
|
c = c / float(numInfiniteISizeCols);
|
|
|
|
--numInfiniteISizeCols;
|
2007-09-24 21:30:42 +04:00
|
|
|
} else {
|
|
|
|
c = 0.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
basis.c = NSCoordSaturatingSubtract(basis.c,
|
|
|
|
pref_minus_min,
|
|
|
|
nscoord_MAX);
|
2015-06-16 17:45:46 +03:00
|
|
|
col_iSize += NSToCoordRound(
|
2007-02-18 22:49:50 +03:00
|
|
|
float(pref_minus_min) * c);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FLEX_FLEX_LARGE:
|
|
|
|
if (pct == 0.0f &&
|
|
|
|
!colFrame->GetHasSpecifiedCoord()) {
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION(col_iSize == colFrame->GetPrefCoord(),
|
|
|
|
"wrong inline-size assigned");
|
|
|
|
if (col_iSize != 0) {
|
2008-01-18 07:18:21 +03:00
|
|
|
if (space == nscoord_MAX) {
|
2015-06-16 17:45:46 +03:00
|
|
|
basis.c -= col_iSize;
|
|
|
|
col_iSize = nscoord_MAX;
|
2008-01-18 07:18:21 +03:00
|
|
|
} else {
|
|
|
|
float c = float(space) / float(basis.c);
|
2015-06-16 17:45:46 +03:00
|
|
|
basis.c -= col_iSize;
|
|
|
|
col_iSize += NSToCoordRound(float(col_iSize) * c);
|
2008-01-18 07:18:21 +03:00
|
|
|
}
|
2007-02-18 22:49:50 +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
|
|
|
}
|
|
|
|
break;
|
2008-02-22 06:25:56 +03:00
|
|
|
case FLEX_FLEX_LARGE_ZERO:
|
|
|
|
if (pct == 0.0f &&
|
2008-04-08 23:07:16 +04:00
|
|
|
!colFrame->GetHasSpecifiedCoord() &&
|
2009-04-18 12:22:34 +04:00
|
|
|
cellMap->GetNumCellsOriginatingInCol(col) > 0) {
|
2008-02-22 06:25:56 +03:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION(col_iSize == 0 &&
|
2008-02-22 06:25:56 +03:00
|
|
|
colFrame->GetPrefCoord() == 0,
|
|
|
|
"Since we're in FLEX_FLEX_LARGE_ZERO case, "
|
2015-06-16 17:45:46 +03:00
|
|
|
"all auto-inline-size cols should have zero "
|
|
|
|
"pref inline-size.");
|
2008-02-22 06:25:56 +03:00
|
|
|
float c = float(space) / float(basis.c);
|
2015-06-16 17:45:46 +03:00
|
|
|
col_iSize += NSToCoordRound(c);
|
2008-02-22 06:25:56 +03:00
|
|
|
--basis.c;
|
|
|
|
}
|
|
|
|
break;
|
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
|
|
|
case FLEX_FIXED_LARGE:
|
|
|
|
if (pct == 0.0f) {
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION(col_iSize == colFrame->GetPrefCoord(),
|
|
|
|
"wrong inline-size assigned");
|
Bug 300030: Move intrinsic width computation out of nsIFrame::Reflow and into its own methods on nsIFrame. Replace reflow reasons, types, and commands with dirty bits/notifications. Thanks to bzbarsky for almost all of the HTML form controls (mozilla/layout/forms) changes, and many others for help testing and patching. For detailed commit logs, see REFLOW_YYYYMMDD_BRANCH, where YYYYMMDD is one of 20061031, 20060830, 20060603, 20060302, 20060119, 20051011, 20050804, 20050429, 20050315, 20050111, and 20041213.
2006-12-08 08:38:33 +03:00
|
|
|
NS_ASSERTION(colFrame->GetHasSpecifiedCoord() ||
|
|
|
|
colFrame->GetPrefCoord() == 0,
|
|
|
|
"wrong case");
|
2015-06-16 17:45:46 +03:00
|
|
|
if (col_iSize != 0) {
|
2007-02-18 22:49:50 +03:00
|
|
|
float c = float(space) / float(basis.c);
|
2015-06-16 17:45:46 +03:00
|
|
|
basis.c -= col_iSize;
|
|
|
|
col_iSize += NSToCoordRound(float(col_iSize) * c);
|
2007-02-18 22:49:50 +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
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FLEX_PCT_LARGE:
|
|
|
|
NS_ASSERTION(pct != 0.0f || colFrame->GetPrefCoord() == 0,
|
|
|
|
"wrong case");
|
2007-02-18 22:49:50 +03:00
|
|
|
if (pct != 0.0f) {
|
|
|
|
float c = float(space) / basis.f;
|
2015-06-16 17:45:46 +03:00
|
|
|
col_iSize += NSToCoordRound(pct * c);
|
2007-02-18 22:49:50 +03:00
|
|
|
basis.f -= pct;
|
|
|
|
}
|
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
|
|
|
break;
|
|
|
|
case FLEX_ALL_LARGE:
|
2007-02-18 22:49:50 +03:00
|
|
|
{
|
|
|
|
float c = float(space) / float(basis.c);
|
2015-06-16 17:45:46 +03:00
|
|
|
col_iSize += NSToCoordRound(c);
|
2007-02-18 22:49:50 +03:00
|
|
|
--basis.c;
|
|
|
|
}
|
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
|
|
|
break;
|
|
|
|
}
|
1999-05-27 02:22:23 +04:00
|
|
|
|
2008-01-18 07:18:21 +03:00
|
|
|
// Only subtract from space if it's a real number.
|
|
|
|
if (space != nscoord_MAX) {
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION(col_iSize != nscoord_MAX,
|
|
|
|
"How is col_iSize nscoord_MAX if space isn't?");
|
|
|
|
NS_ASSERTION(col_iSize_before_adjust != nscoord_MAX,
|
|
|
|
"How is col_iSize_before_adjust nscoord_MAX if space isn't?");
|
|
|
|
space -= col_iSize - col_iSize_before_adjust;
|
2008-01-18 07:18:21 +03:00
|
|
|
}
|
2007-02-18 22:49:50 +03:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
NS_ASSERTION(col_iSize >= colFrame->GetMinCoord(),
|
|
|
|
"assigned inline-size smaller than min");
|
2008-01-18 07:18:21 +03:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
// Apply the new isize
|
|
|
|
switch (aISizeType) {
|
|
|
|
case BTLS_MIN_ISIZE:
|
2008-01-18 07:18:21 +03:00
|
|
|
{
|
2015-06-16 17:45:46 +03:00
|
|
|
// Note: AddSpanCoords requires both a min and pref isize.
|
|
|
|
// For the pref isize, we'll just pass in our computed
|
|
|
|
// min isize, because the real pref isize will be at least
|
2008-01-18 07:18:21 +03:00
|
|
|
// as big
|
2015-06-16 17:45:46 +03:00
|
|
|
colFrame->AddSpanCoords(col_iSize, col_iSize,
|
|
|
|
aSpanHasSpecifiedISize);
|
2008-01-18 07:18:21 +03:00
|
|
|
}
|
|
|
|
break;
|
2015-06-16 17:45:46 +03:00
|
|
|
case BTLS_PREF_ISIZE:
|
2008-01-18 07:18:21 +03:00
|
|
|
{
|
2015-06-16 17:45:46 +03:00
|
|
|
// Note: AddSpanCoords requires both a min and pref isize.
|
|
|
|
// For the min isize, we'll just pass in 0, because
|
|
|
|
// the real min isize will be at least 0
|
|
|
|
colFrame->AddSpanCoords(0, col_iSize,
|
|
|
|
aSpanHasSpecifiedISize);
|
2008-01-18 07:18:21 +03:00
|
|
|
}
|
|
|
|
break;
|
2015-06-16 17:45:46 +03:00
|
|
|
case BTLS_FINAL_ISIZE:
|
2008-01-18 07:18:21 +03:00
|
|
|
{
|
2015-04-19 02:01:26 +03:00
|
|
|
nscoord old_final = colFrame->GetFinalISize();
|
2015-06-16 17:45:46 +03:00
|
|
|
colFrame->SetFinalISize(col_iSize);
|
2008-01-18 07:18:21 +03:00
|
|
|
|
2015-06-16 17:45:46 +03:00
|
|
|
if (old_final != col_iSize) {
|
2008-01-18 07:18:21 +03:00
|
|
|
mTableFrame->DidResizeColumns();
|
2015-06-16 17:45:46 +03:00
|
|
|
}
|
2008-01-18 07:18:21 +03:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
1999-07-28 12:09:02 +04:00
|
|
|
}
|
2008-01-18 07:18:21 +03:00
|
|
|
NS_ASSERTION((space == 0 || space == nscoord_MAX) &&
|
2007-02-18 22:49:50 +03:00
|
|
|
((l2t == FLEX_PCT_LARGE)
|
|
|
|
? (-0.001f < basis.f && basis.f < 0.001f)
|
2007-09-24 21:30:42 +04:00
|
|
|
: (basis.c == 0 || basis.c == nscoord_MAX)),
|
2007-02-18 22:49:50 +03:00
|
|
|
"didn't subtract all that we added");
|
1998-07-17 03:23:31 +04:00
|
|
|
}
|