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

Unified Diff: Source/core/rendering/RenderTable.cpp

Issue 14141004: Fix table sizing when 'max-width' is used (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated the test to use Ahem for consistency across platforms Created 7 years, 8 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 | « LayoutTests/fast/table/html-table-width-max-width-constrained-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderTable.cpp
diff --git a/Source/core/rendering/RenderTable.cpp b/Source/core/rendering/RenderTable.cpp
index db2c65c451260bebfb9f549c6059ce81ab752246..0f5d565e8b96d550a3b0975cb86a73992623bcae 100644
--- a/Source/core/rendering/RenderTable.cpp
+++ b/Source/core/rendering/RenderTable.cpp
@@ -272,10 +272,6 @@ void RenderTable::updateLogicalWidth()
setLogicalWidth(min<int>(availableContentLogicalWidth, maxPreferredLogicalWidth()));
}
- // Ensure we aren't smaller than our min preferred width.
- setLogicalWidth(max<int>(logicalWidth(), minPreferredLogicalWidth()));
-
-
// Ensure we aren't bigger than our max-width style.
Length styleMaxLogicalWidth = style()->logicalMaxWidth();
if ((styleMaxLogicalWidth.isSpecified() && !styleMaxLogicalWidth.isNegative()) || styleMaxLogicalWidth.isIntrinsic()) {
@@ -283,7 +279,11 @@ void RenderTable::updateLogicalWidth()
setLogicalWidth(min<int>(logicalWidth(), computedMaxLogicalWidth));
}
- // Ensure we aren't smaller than our min-width style.
+ // Ensure we aren't smaller than our min preferred width. This MUST be done after 'max-width' as
+ // we ignore it if it means we wouldn't accomodate our content.
+ setLogicalWidth(max<int>(logicalWidth(), minPreferredLogicalWidth()));
+
+ // Ensure we aren't smaller than our min-width style.
Length styleMinLogicalWidth = style()->logicalMinWidth();
if ((styleMinLogicalWidth.isSpecified() && !styleMinLogicalWidth.isNegative()) || styleMinLogicalWidth.isIntrinsic()) {
LayoutUnit computedMinLogicalWidth = convertStyleLogicalWidthToComputedWidth(styleMinLogicalWidth, availableLogicalWidth);
@@ -308,6 +308,10 @@ void RenderTable::updateLogicalWidth()
setMarginStart(minimumValueForLength(style()->marginStart(), availableLogicalWidth, renderView));
setMarginEnd(minimumValueForLength(style()->marginEnd(), availableLogicalWidth, renderView));
}
+
+ // We should NEVER shrink the table below the min-content logical width, or else the table can't accomodate
+ // its own content which doesn't match CSS nor what authors expect.
+ ASSERT(logicalWidth() >= minPreferredLogicalWidth());
}
// This method takes a RenderStyle's logical width, min-width, or max-width length and computes its actual value.
@@ -768,8 +772,9 @@ void RenderTable::computePreferredLogicalWidths()
// FIXME: This should probably be checking for isSpecified since you should be able to use percentage, calc or viewport relative values for maxWidth.
if (styleToUse->logicalMaxWidth().isFixed()) {
+ // We don't constrain m_minPreferredLogicalWidth as the table should be at least the size of its min-content, regardless of 'max-width'.
m_maxPreferredLogicalWidth = std::min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
- m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(styleToUse->logicalMaxWidth().value()));
+ m_maxPreferredLogicalWidth = std::max(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
}
// FIXME: We should be adding borderAndPaddingLogicalWidth here, but m_tableLayout->computePreferredLogicalWidths already does,
« no previous file with comments | « LayoutTests/fast/table/html-table-width-max-width-constrained-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698