| 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 244d9f4a9bbaf1b9e3fea1b14d39bb324cd1bc1c..2a158d9932dc24b29a57a2a8ba4d21f9dc79e100 100644
|
| --- a/third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp
|
| +++ b/third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp
|
| @@ -67,8 +67,8 @@ void TableLayoutAlgorithmAuto::recalcColumn(unsigned effCol)
|
|
|
| if (cell->maxPreferredLogicalWidth())
|
| columnLayout.emptyCellsOnly = false;
|
| -
|
| if (cell->colSpan() == 1) {
|
| +
|
| columnLayout.minLogicalWidth = std::max<int>(cell->minPreferredLogicalWidth(), columnLayout.minLogicalWidth);
|
| if (cell->maxPreferredLogicalWidth() > columnLayout.maxLogicalWidth) {
|
| columnLayout.maxLogicalWidth = cell->maxPreferredLogicalWidth();
|
| @@ -115,9 +115,6 @@ void TableLayoutAlgorithmAuto::recalcColumn(unsigned effCol)
|
| break;
|
| }
|
| } else if (!effCol || section->primaryCellAt(i, effCol - 1) != cell) {
|
| - // If a cell originates in this spanning column ensure we have a min/max width of at least 1px for it.
|
| - columnLayout.minLogicalWidth = std::max<int>(columnLayout.minLogicalWidth, cell->maxPreferredLogicalWidth() ? 1 : 0);
|
| -
|
| // This spanning cell originates in this column. Insert the cell into spanning cells list.
|
| insertSpanCell(cell);
|
| }
|
| @@ -312,6 +309,7 @@ int TableLayoutAlgorithmAuto::calcEffectiveLogicalWidth()
|
| bool haveAuto = false;
|
| bool spanHasEmptyCellsOnly = true;
|
| int fixedWidth = 0;
|
| + int numAuto = 0;
|
| while (lastCol < nEffCols && span > 0) {
|
| Layout& columnLayout = m_layoutStruct[lastCol];
|
| switch (columnLayout.logicalWidth.type()) {
|
| @@ -330,6 +328,8 @@ int TableLayoutAlgorithmAuto::calcEffectiveLogicalWidth()
|
| // fall through
|
| case Auto:
|
| haveAuto = true;
|
| + if (!columnLayout.columnHasNoCells)
|
| + numAuto++;
|
| // fall through
|
| default:
|
| // If the column is a percentage width, do not let the spanning cell overwrite the
|
| @@ -370,16 +370,17 @@ int TableLayoutAlgorithmAuto::calcEffectiveLogicalWidth()
|
| float percentMissing = cellLogicalWidth.percent() - totalPercent;
|
| int totalWidth = 0;
|
| for (unsigned pos = effCol; pos < lastCol; ++pos) {
|
| - if (!m_layoutStruct[pos].effectiveLogicalWidth.hasPercent())
|
| + if (!m_layoutStruct[pos].effectiveLogicalWidth.hasPercent() && (!m_layoutStruct[pos].emptyCellsOnly || spanHasEmptyCellsOnly))
|
| totalWidth += m_layoutStruct[pos].clampedEffectiveMaxLogicalWidth();
|
| }
|
|
|
| for (unsigned pos = effCol; pos < lastCol && totalWidth > 0; ++pos) {
|
| - if (!m_layoutStruct[pos].effectiveLogicalWidth.hasPercent()) {
|
| - float percent = percentMissing * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / totalWidth;
|
| + // Empty columns shouldn't get any share of a span's percent width.
|
| + if (!m_layoutStruct[pos].effectiveLogicalWidth.hasPercent() && (!m_layoutStruct[pos].emptyCellsOnly || spanHasEmptyCellsOnly)) {
|
| + float percent = percentMissing * static_cast<float>(m_layoutStruct[pos].clampedEffectiveMaxLogicalWidth()) / totalWidth;
|
| totalWidth -= m_layoutStruct[pos].clampedEffectiveMaxLogicalWidth();
|
| percentMissing -= percent;
|
| - if (percent > 0)
|
| + if (percent > 0 && !m_layoutStruct[pos].columnHasNoCells)
|
| m_layoutStruct[pos].effectiveLogicalWidth.setValue(Percent, percent);
|
| else
|
| m_layoutStruct[pos].effectiveLogicalWidth = Length();
|
| @@ -447,11 +448,14 @@ int TableLayoutAlgorithmAuto::calcEffectiveLogicalWidth()
|
| }
|
| if (!cellLogicalWidth.hasPercent()) {
|
| if (cellMaxLogicalWidth > spanMaxLogicalWidth) {
|
| + int widthAvailableToAuto = cellMaxLogicalWidth - fixedWidth;
|
| for (unsigned pos = effCol; spanMaxLogicalWidth >= 0 && pos < lastCol; ++pos) {
|
| int colMaxLogicalWidth = std::max(m_layoutStruct[pos].effectiveMaxLogicalWidth, static_cast<int>(spanMaxLogicalWidth ? cellMaxLogicalWidth * static_cast<float>(m_layoutStruct[pos].effectiveMaxLogicalWidth) / spanMaxLogicalWidth : cellMaxLogicalWidth));
|
| spanMaxLogicalWidth -= m_layoutStruct[pos].effectiveMaxLogicalWidth;
|
| cellMaxLogicalWidth -= colMaxLogicalWidth;
|
| m_layoutStruct[pos].effectiveMaxLogicalWidth = colMaxLogicalWidth;
|
| + if (m_layoutStruct[pos].logicalWidth.isAuto() && m_layoutStruct[pos].emptyCellsOnly && !m_layoutStruct[pos].columnHasNoCells && !spanHasEmptyCellsOnly)
|
| + m_layoutStruct[pos].effectiveMinLogicalWidth = widthAvailableToAuto / numAuto;
|
| }
|
| }
|
| } else {
|
| @@ -541,7 +545,8 @@ void TableLayoutAlgorithmAuto::layout()
|
| break;
|
| case Auto:
|
| if (m_layoutStruct[i].emptyCellsOnly) {
|
| - numAutoEmptyCellsOnly++;
|
| + if (!m_layoutStruct[i].columnHasNoCells)
|
| + numAutoEmptyCellsOnly++;
|
| } else {
|
| numAuto++;
|
| totalAuto += m_layoutStruct[i].clampedEffectiveMaxLogicalWidth();
|
|
|