Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1331)

Unified Diff: Source/core/layout/TableLayoutAlgorithmAuto.cpp

Issue 1177653002: Revert "Don't add artifical 1 pixel width to empty tables" (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/layout/TableLayoutAlgorithmAuto.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/TableLayoutAlgorithmAuto.cpp
diff --git a/Source/core/layout/TableLayoutAlgorithmAuto.cpp b/Source/core/layout/TableLayoutAlgorithmAuto.cpp
index b5e824c41e190ade6ef7935bfe08b77e1d7198d1..e10454b8856993ff9d37065bb189fd7f1ab060a0 100644
--- a/Source/core/layout/TableLayoutAlgorithmAuto.cpp
+++ b/Source/core/layout/TableLayoutAlgorithmAuto.cpp
@@ -63,15 +63,15 @@ void TableLayoutAlgorithmAuto::recalcColumn(unsigned effCol)
if (current.inColSpan || !cell)
continue;
- columnLayout.columnHasNoCells = false;
- bool cellHasContent = cell->minPreferredLogicalWidth();
+ bool cellHasContent = cell->children()->firstChild() || cell->style()->hasBorder() || cell->style()->hasPadding() || cell->style()->hasBackground();
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 +373,13 @@ int TableLayoutAlgorithmAuto::calcEffectiveLogicalWidth()
int totalWidth = 0;
for (unsigned pos = effCol; pos < lastCol; ++pos) {
if (!m_layoutStruct[pos].effectiveLogicalWidth.hasPercent())
- totalWidth += m_layoutStruct[pos].clampedEffectiveMaxLogicalWidth();
+ totalWidth += m_layoutStruct[pos].effectiveMaxLogicalWidth;
}
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].clampedEffectiveMaxLogicalWidth();
+ totalWidth -= m_layoutStruct[pos].effectiveMaxLogicalWidth;
percentMissing -= percent;
if (percent > 0)
m_layoutStruct[pos].effectiveLogicalWidth.setValue(Percent, percent);
@@ -538,7 +538,7 @@ void TableLayoutAlgorithmAuto::layout()
break;
case Fixed:
numFixed++;
- totalFixed += m_layoutStruct[i].clampedEffectiveMaxLogicalWidth();
+ totalFixed += m_layoutStruct[i].effectiveMaxLogicalWidth;
// fall through
break;
case Auto:
@@ -546,7 +546,7 @@ void TableLayoutAlgorithmAuto::layout()
numAutoEmptyCellsOnly++;
} else {
numAuto++;
- totalAuto += m_layoutStruct[i].clampedEffectiveMaxLogicalWidth();
+ totalAuto += m_layoutStruct[i].effectiveMaxLogicalWidth;
allocAuto += cellLogicalWidth;
}
break;
@@ -594,17 +594,13 @@ void TableLayoutAlgorithmAuto::layout()
}
}
- // Give each auto width column its share of the available width, non-empty columns then empty columns.
+ // Give each auto width column its share of the available width.
if (available > 0 && numAuto) {
available += allocAuto;
distributeWidthToColumns<float, Auto, NonEmptyCells, InitialWidth, StartToEnd>(available, totalAuto);
}
- if (available > 0 && numAutoEmptyCellsOnly) {
- 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 and non-empty auto width columns, in that order.
if (available > 0 && numFixed)
distributeWidthToColumns<float, Fixed, AllCells, ExtraWidth, StartToEnd>(available, totalFixed);
@@ -645,10 +641,6 @@ 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.
- if (cellsToProcess == EmptyCells && logicalWidth.isAuto() && (!m_layoutStruct[i].emptyCellsOnly || m_layoutStruct[i].columnHasNoCells))
- continue;
if (distributionMode != LeftoverWidth && logicalWidth.type() != lengthType)
continue;
@@ -657,7 +649,7 @@ void TableLayoutAlgorithmAuto::distributeWidthToColumns(int& available, Total to
if (lengthType == Percent)
factor = logicalWidth.percent();
else if (lengthType == Auto || lengthType == Fixed)
- factor = m_layoutStruct[i].clampedEffectiveMaxLogicalWidth();
+ factor = m_layoutStruct[i].effectiveMaxLogicalWidth;
}
int newWidth = available * factor / total;
« no previous file with comments | « Source/core/layout/TableLayoutAlgorithmAuto.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698