Index: Source/core/layout/TableLayoutAlgorithmAuto.cpp |
diff --git a/Source/core/layout/TableLayoutAlgorithmAuto.cpp b/Source/core/layout/TableLayoutAlgorithmAuto.cpp |
index b0a11f06aa0570e29c76d901469ac9a9c1098d14..fbd120cb1473575a27b7972fb543838f338cb16a 100644 |
--- a/Source/core/layout/TableLayoutAlgorithmAuto.cpp |
+++ b/Source/core/layout/TableLayoutAlgorithmAuto.cpp |
@@ -26,6 +26,7 @@ |
#include "core/layout/LayoutTableCell.h" |
#include "core/layout/LayoutTableCol.h" |
#include "core/layout/LayoutTableSection.h" |
+#include "core/layout/LayoutText.h" |
#include "core/layout/TextAutosizer.h" |
namespace blink { |
@@ -63,15 +64,15 @@ void TableLayoutAlgorithmAuto::recalcColumn(unsigned effCol) |
if (current.inColSpan || !cell) |
continue; |
+ columnLayout.columnHasNoCells = false; |
- bool cellHasContent = cell->children()->firstChild() || cell->style()->hasBorder() || cell->style()->hasPadding() || cell->style()->hasBackground(); |
+ bool cellHasContent = cell->minPreferredLogicalWidth(); |
if (cellHasContent) |
columnLayout.emptyCellsOnly = false; |
// A cell originates in this column. Ensure we have |
// a min/max width of at least 1px for this column now. |
columnLayout.minLogicalWidth = std::max<int>(columnLayout.minLogicalWidth, cellHasContent ? 1 : 0); |
- columnLayout.maxLogicalWidth = std::max<int>(columnLayout.maxLogicalWidth, 1); |
if (cell->colSpan() == 1) { |
columnLayout.minLogicalWidth = std::max<int>(cell->minPreferredLogicalWidth(), columnLayout.minLogicalWidth); |
@@ -373,13 +374,13 @@ int TableLayoutAlgorithmAuto::calcEffectiveLogicalWidth() |
int totalWidth = 0; |
for (unsigned pos = effCol; pos < lastCol; ++pos) { |
if (!m_layoutStruct[pos].effectiveLogicalWidth.hasPercent()) |
- totalWidth += m_layoutStruct[pos].effectiveMaxLogicalWidth; |
+ 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; |
- totalWidth -= m_layoutStruct[pos].effectiveMaxLogicalWidth; |
+ totalWidth -= m_layoutStruct[pos].clampedEffectiveMaxLogicalWidth(); |
percentMissing -= percent; |
if (percent > 0) |
m_layoutStruct[pos].effectiveLogicalWidth.setValue(Percent, percent); |
@@ -538,7 +539,7 @@ void TableLayoutAlgorithmAuto::layout() |
break; |
case Fixed: |
numFixed++; |
- totalFixed += m_layoutStruct[i].effectiveMaxLogicalWidth; |
+ totalFixed += m_layoutStruct[i].clampedEffectiveMaxLogicalWidth(); |
// fall through |
break; |
case Auto: |
@@ -546,7 +547,7 @@ void TableLayoutAlgorithmAuto::layout() |
numAutoEmptyCellsOnly++; |
} else { |
numAuto++; |
- totalAuto += m_layoutStruct[i].effectiveMaxLogicalWidth; |
+ totalAuto += m_layoutStruct[i].clampedEffectiveMaxLogicalWidth(); |
allocAuto += cellLogicalWidth; |
} |
break; |
@@ -599,8 +600,12 @@ void TableLayoutAlgorithmAuto::layout() |
available += allocAuto; |
distributeWidthToColumns<float, Auto, NonEmptyCells, InitialWidth, StartToEnd>(available, totalAuto); |
} |
+ if (available > 0 && numAutoEmptyCellsOnly) { |
mstensho (USE GERRIT)
2015/05/20 09:34:22
A comment in front of this would be nice.
|
+ unsigned total = numAutoEmptyCellsOnly; |
+ distributeWidthToColumns<float, Auto, EmptyCells, InitialWidth, StartToEnd>(available, total); |
+ } |
- // Any remaining available width expands fixed width, percent width and non-empty auto width columns, in that order. |
+ // Any remaining available width expands fixed width, percent width, non-empty auto width columns and empty auto width columns, in that order. |
mstensho (USE GERRIT)
2015/05/20 09:34:22
Should you put the following inside a large else b
|
if (available > 0 && numFixed) |
distributeWidthToColumns<float, Fixed, AllCells, ExtraWidth, StartToEnd>(available, totalFixed); |
@@ -613,6 +618,11 @@ void TableLayoutAlgorithmAuto::layout() |
distributeWidthToColumns<unsigned, Auto, NonEmptyCells, LeftoverWidth, EndToStart>(available, total); |
} |
+ if (available > 0) { |
+ unsigned total = numAutoEmptyCellsOnly; |
+ distributeWidthToColumns<unsigned, Auto, EmptyCells, LeftoverWidth, EndToStart>(available, total); |
+ } |
+ |
// If we have overallocated, reduce every cell according to the difference between desired width and minwidth |
// this seems to produce to the pixel exact results with IE. Wonder is some of this also holds for width distributing. |
// This is basically the reverse of how we grew the cells. |
@@ -641,6 +651,9 @@ void TableLayoutAlgorithmAuto::distributeWidthToColumns(int& available, Total to |
const Length& logicalWidth = m_layoutStruct[i].effectiveLogicalWidth; |
if (cellsToProcess == NonEmptyCells && logicalWidth.isAuto() && m_layoutStruct[i].emptyCellsOnly) |
continue; |
+ // When allocating width to columns with nothing but empty cells we avoid columns that exist only to flesh out a colspan and have no actual cells. |
mstensho (USE GERRIT)
2015/05/20 09:34:22
Could you break this comment into two lines?
|
+ if (cellsToProcess == EmptyCells && logicalWidth.isAuto() && (!m_layoutStruct[i].emptyCellsOnly || m_layoutStruct[i].columnHasNoCells)) |
+ continue; |
if (distributionMode != LeftoverWidth && logicalWidth.type() != lengthType) |
continue; |
@@ -649,7 +662,7 @@ void TableLayoutAlgorithmAuto::distributeWidthToColumns(int& available, Total to |
if (lengthType == Percent) |
factor = logicalWidth.percent(); |
else if (lengthType == Auto || lengthType == Fixed) |
- factor = m_layoutStruct[i].effectiveMaxLogicalWidth; |
+ factor = m_layoutStruct[i].clampedEffectiveMaxLogicalWidth(); |
} |
int newWidth = available * factor / total; |