| Index: third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp
|
| diff --git a/third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp b/third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp
|
| index 0ff2aad54ee239d5a6080cad371f6bc07eecb043..79132d7c0f879718b368c6ff048a6f2fcafc4c9d 100644
|
| --- a/third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp
|
| @@ -33,6 +33,7 @@ TableLayoutAlgorithmAuto::TableLayoutAlgorithmAuto(LayoutTable* table)
|
| : TableLayoutAlgorithm(table)
|
| , m_hasPercent(false)
|
| , m_effectiveLogicalWidthDirty(true)
|
| + , m_scaledWidthFromPercentColumns()
|
| {
|
| }
|
|
|
| @@ -177,9 +178,27 @@ void TableLayoutAlgorithmAuto::fullRecalc()
|
| recalcColumn(i);
|
| }
|
|
|
| +static bool shouldScaleColumnsForParent(LayoutTable* table)
|
| +{
|
| + LayoutBlock* cb = table->containingBlock();
|
| + while (!cb->isLayoutView()) {
|
| + // It doesn't matter if our table is auto or fixed: auto means we don't
|
| + // scale. Fixed doesn't care if we do or not because it doesn't depend
|
| + // on the cell contents' preferred widths.
|
| + if (cb->isTableCell())
|
| + return false;
|
| + cb = cb->containingBlock();
|
| + }
|
| + return true;
|
| +}
|
| +
|
| // FIXME: This needs to be adapted for vertical writing modes.
|
| -static bool shouldScaleColumns(LayoutTable* table)
|
| +static bool shouldScaleColumnsForSelf(LayoutTable* table)
|
| {
|
| + // Normally, scale all columns to satisfy this from CSS2.2:
|
| + // "A percentage value for a column width is relative to the table width.
|
| + // If the table has 'width: auto', a percentage represents a constraint on the column's width"
|
| +
|
| // A special case. If this table is not fixed width and contained inside
|
| // a cell, then don't bloat the maxwidth by examining percentage growth.
|
| while (true) {
|
| @@ -217,7 +236,7 @@ void TableLayoutAlgorithmAuto::computeIntrinsicLogicalWidths(LayoutUnit& minWidt
|
| maxWidth = LayoutUnit();
|
| float maxPercent = 0;
|
| float maxNonPercent = 0;
|
| - bool scaleColumns = shouldScaleColumns(m_table);
|
| + bool scaleColumnsForSelf = shouldScaleColumnsForSelf(m_table);
|
|
|
| // We substitute 0 percent by (epsilon / percentScaleFactor) percent in two places below to avoid division by zero.
|
| // FIXME: Handle the 0% cases properly.
|
| @@ -227,7 +246,7 @@ void TableLayoutAlgorithmAuto::computeIntrinsicLogicalWidths(LayoutUnit& minWidt
|
| for (size_t i = 0; i < m_layoutStruct.size(); ++i) {
|
| minWidth += m_layoutStruct[i].effectiveMinLogicalWidth;
|
| maxWidth += m_layoutStruct[i].effectiveMaxLogicalWidth;
|
| - if (scaleColumns) {
|
| + if (scaleColumnsForSelf) {
|
| if (m_layoutStruct[i].effectiveLogicalWidth.hasPercent()) {
|
| float percent = std::min(static_cast<float>(m_layoutStruct[i].effectiveLogicalWidth.percent()), remainingPercent);
|
| float logicalWidth = static_cast<float>(m_layoutStruct[i].effectiveMaxLogicalWidth) * 100 / std::max(percent, epsilon);
|
| @@ -239,10 +258,12 @@ void TableLayoutAlgorithmAuto::computeIntrinsicLogicalWidths(LayoutUnit& minWidt
|
| }
|
| }
|
|
|
| - if (scaleColumns) {
|
| + if (scaleColumnsForSelf) {
|
| maxNonPercent = maxNonPercent * 100 / std::max(remainingPercent, epsilon);
|
| - maxWidth = std::max(maxWidth, LayoutUnit(std::min(maxNonPercent, static_cast<float>(tableMaxWidth))));
|
| - maxWidth = std::max(maxWidth, LayoutUnit(std::min(maxPercent, static_cast<float>(tableMaxWidth))));
|
| + m_scaledWidthFromPercentColumns = LayoutUnit(std::min(maxNonPercent, static_cast<float>(tableMaxWidth)));
|
| + m_scaledWidthFromPercentColumns = std::max(m_scaledWidthFromPercentColumns, LayoutUnit(std::min(maxPercent, static_cast<float>(tableMaxWidth))));
|
| + if (m_scaledWidthFromPercentColumns > maxWidth && shouldScaleColumnsForParent(m_table))
|
| + maxWidth = m_scaledWidthFromPercentColumns;
|
| }
|
|
|
| maxWidth = LayoutUnit(std::max(maxWidth.floor(), spanMaxLogicalWidth));
|
|
|