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..2f7eef1b9ebb38a1d5b14b4de8f70bea6e4c4204 100644 |
--- a/third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp |
+++ b/third_party/WebKit/Source/core/layout/TableLayoutAlgorithmAuto.cpp |
@@ -215,9 +215,25 @@ void TableLayoutAlgorithmAuto::computeIntrinsicLogicalWidths(LayoutUnit& minWidt |
int spanMaxLogicalWidth = calcEffectiveLogicalWidth(); |
minWidth = LayoutUnit(); |
maxWidth = LayoutUnit(); |
+ |
+ for (size_t i = 0; i < m_layoutStruct.size(); ++i) { |
+ minWidth += m_layoutStruct[i].effectiveMinLogicalWidth; |
+ maxWidth += m_layoutStruct[i].effectiveMaxLogicalWidth; |
+ } |
+ |
+ maxWidth = LayoutUnit(std::max(maxWidth.floor(), spanMaxLogicalWidth)); |
+} |
+ |
+LayoutUnit TableLayoutAlgorithmAuto::scaledWidthFromPercentColumns() |
+{ |
+ // 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" |
+ if (!shouldScaleColumns(m_table)) |
+ return LayoutUnit(0); |
+ |
float maxPercent = 0; |
float maxNonPercent = 0; |
- bool scaleColumns = shouldScaleColumns(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. |
@@ -225,27 +241,19 @@ void TableLayoutAlgorithmAuto::computeIntrinsicLogicalWidths(LayoutUnit& minWidt |
float remainingPercent = 100; |
for (size_t i = 0; i < m_layoutStruct.size(); ++i) { |
- minWidth += m_layoutStruct[i].effectiveMinLogicalWidth; |
dgrogan
2016/04/27 03:14:05
Your excerpt was instrumental in my understanding
|
- maxWidth += m_layoutStruct[i].effectiveMaxLogicalWidth; |
- if (scaleColumns) { |
- 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); |
- maxPercent = std::max(logicalWidth, maxPercent); |
- remainingPercent -= percent; |
- } else { |
- maxNonPercent += m_layoutStruct[i].effectiveMaxLogicalWidth; |
- } |
+ 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); |
+ maxPercent = std::max(logicalWidth, maxPercent); |
+ remainingPercent -= percent; |
+ } else { |
+ maxNonPercent += m_layoutStruct[i].effectiveMaxLogicalWidth; |
} |
} |
- if (scaleColumns) { |
- 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)))); |
- } |
- |
- maxWidth = LayoutUnit(std::max(maxWidth.floor(), spanMaxLogicalWidth)); |
+ maxNonPercent = maxNonPercent * 100 / std::max(remainingPercent, epsilon); |
+ LayoutUnit maxWidth = LayoutUnit(std::min(maxNonPercent, static_cast<float>(tableMaxWidth))); |
+ return std::max(maxWidth, LayoutUnit(std::min(maxPercent, static_cast<float>(tableMaxWidth)))); |
} |
void TableLayoutAlgorithmAuto::applyPreferredLogicalWidthQuirks(LayoutUnit& minWidth, LayoutUnit& maxWidth) const |