Diff
Modified: trunk/LayoutTests/ChangeLog (145423 => 145424)
--- trunk/LayoutTests/ChangeLog 2013-03-11 23:18:44 UTC (rev 145423)
+++ trunk/LayoutTests/ChangeLog 2013-03-11 23:20:56 UTC (rev 145424)
@@ -1,3 +1,15 @@
+2013-03-05 Ojan Vafai <o...@chromium.org>
+
+ Intrinsic width keyword values don't work for tables
+ https://bugs.webkit.org/show_bug.cgi?id=111515
+
+ Reviewed by Julien Chaffraix.
+
+ * fast/css-intrinsic-dimensions/css-tables-expected.txt: Added.
+ * fast/css-intrinsic-dimensions/css-tables.html: Added.
+ * fast/css-intrinsic-dimensions/tables-expected.txt: Added.
+ * fast/css-intrinsic-dimensions/tables.html: Added.
+
2013-03-11 Stephen Chenney <schen...@chromium.org>
HTMLInputElement can delete an ImageLoader while it's still needed
Added: trunk/LayoutTests/fast/css-intrinsic-dimensions/css-tables-expected.txt (0 => 145424)
--- trunk/LayoutTests/fast/css-intrinsic-dimensions/css-tables-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css-intrinsic-dimensions/css-tables-expected.txt 2013-03-11 23:20:56 UTC (rev 145424)
@@ -0,0 +1,25 @@
+
+PASS
+ PASS
+
+PASS
+
+PASS
+
+PASS
+ PASS
+
+PASS
+
+PASS
+ PASS
+
+PASS
+
+PASS
+
+PASS
+ PASS
+
+PASS
+
Added: trunk/LayoutTests/fast/css-intrinsic-dimensions/css-tables.html (0 => 145424)
--- trunk/LayoutTests/fast/css-intrinsic-dimensions/css-tables.html (rev 0)
+++ trunk/LayoutTests/fast/css-intrinsic-dimensions/css-tables.html 2013-03-11 23:20:56 UTC (rev 145424)
@@ -0,0 +1,136 @@
+<!DOCTYPE html>
+<style>
+.table {
+ display: table;
+ border: 5px solid salmon;
+ padding: 5px;
+}
+.td {
+ display: table-cell;
+ border: 5px solid orange;
+}
+.child {
+ display: inline-block;
+ width: 50px;
+ height: 20px;
+ background-color: pink;
+}
+.collapse {
+ border-collapse: collapse;
+}
+</style>
+
+<div class="table" data-expected-width=134>
+ <div class="td" data-expected-width=114>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+</div>
+
+<div class="table" style="width: -webkit-min-content" data-expected-width=80>
+ <div class="td" data-expected-width=60>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+</div>
+
+<div class="table" style="width: -webkit-max-content" data-expected-width=134>
+ <div class="td" data-expected-width=114>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+</div>
+
+<div class="table" style="width: -webkit-fit-content" data-expected-width=134>
+ <div class="td" data-expected-width=114>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+</div>
+
+<div style="width: 134px">
+ <div class="table" style="width: -webkit-fit-content" data-expected-width=134>
+ <div class="td" data-expected-width=114>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+ </div>
+</div>
+
+<div style="width: 133px">
+ <div class="table" style="width: -webkit-fit-content" data-expected-width=133>
+ <div class="td" data-expected-width=113>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+ </div>
+</div>
+
+<div style="width: 400px">
+ <div class="table" style="width: -webkit-fill-available" data-expected-width=400>
+ <div class="td" data-expected-width=380>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+ </div>
+<div>
+
+<div class="table collapse" data-expected-width=114>
+ <div class="td" data-expected-width=109>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+</div>
+
+<div class="table collapse" style="width: -webkit-min-content" data-expected-width=60>
+ <div class="td" data-expected-width=55>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+</div>
+
+<div class="table collapse" style="width: -webkit-max-content" data-expected-width=114>
+ <div class="td" data-expected-width=109>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+</div>
+
+<div class="table collapse" style="width: -webkit-fit-content" data-expected-width=114>
+ <div class="td" data-expected-width=109>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+</div>
+
+<div style="width: 114px">
+ <div class="table collapse" style="width: -webkit-fit-content" data-expected-width=114>
+ <div class="td" data-expected-width=109>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+ </div>
+</div>
+
+<div style="width: 113px">
+ <div class="table collapse" style="width: -webkit-fit-content" data-expected-width=113>
+ <div class="td" data-expected-width=108>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+ </div>
+</div>
+
+<div style="width: 400px">
+ <div class="table collapse" style="width: -webkit-fill-available" data-expected-width=400>
+ <div class="td" data-expected-width=395>
+ <div class="child"></div>
+ <div class="child"></div>
+ </div>
+ </div>
+<div>
+
+<script src=""
+<script>
+checkLayout('.table');
+</script>
\ No newline at end of file
Added: trunk/LayoutTests/fast/css-intrinsic-dimensions/tables-expected.txt (0 => 145424)
--- trunk/LayoutTests/fast/css-intrinsic-dimensions/tables-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css-intrinsic-dimensions/tables-expected.txt 2013-03-11 23:20:56 UTC (rev 145424)
@@ -0,0 +1,25 @@
+
+PASS
+ PASS
+
+PASS
+
+PASS
+
+PASS
+ PASS
+
+PASS
+
+PASS
+ PASS
+
+PASS
+
+PASS
+
+PASS
+ PASS
+
+PASS
+
Added: trunk/LayoutTests/fast/css-intrinsic-dimensions/tables.html (0 => 145424)
--- trunk/LayoutTests/fast/css-intrinsic-dimensions/tables.html (rev 0)
+++ trunk/LayoutTests/fast/css-intrinsic-dimensions/tables.html 2013-03-11 23:20:56 UTC (rev 145424)
@@ -0,0 +1,134 @@
+<!DOCTYPE html>
+<style>
+table {
+ border: 5px solid salmon;
+ padding: 5px;
+}
+td {
+ border: 5px solid orange;
+}
+.child {
+ display: inline-block;
+ width: 50px;
+ height: 20px;
+ background-color: pink;
+}
+.collapse {
+ border-collapse: collapse;
+}
+</style>
+
+<table data-expected-width=140>
+ <td data-expected-width=116>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+</table>
+
+<table style="width: -webkit-min-content" data-expected-width=86>
+ <td data-expected-width=62>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+</table>
+
+<table style="width: -webkit-max-content" data-expected-width=140>
+ <td data-expected-width=116>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+</table>
+
+<table style="width: -webkit-fit-content" data-expected-width=140>
+ <td data-expected-width=116>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+</table>
+
+<div style="width: 140px">
+ <table style="width: -webkit-fit-content" data-expected-width=140>
+ <td data-expected-width=116>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+ </table>
+</div>
+
+<div style="width: 139px">
+ <table style="width: -webkit-fit-content" data-expected-width=139>
+ <td data-expected-width=115>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+ </table>
+</div>
+
+<div style="width: 400px">
+ <table style="width: -webkit-fill-available" data-expected-width=400>
+ <td data-expected-width=376>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+ </table>
+<div>
+
+<table class="collapse" data-expected-width=116>
+ <td data-expected-width=111>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+</table>
+
+<table class="collapse" style="width: -webkit-min-content" data-expected-width=62>
+ <td data-expected-width=57>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+</table>
+
+<table class="collapse" style="width: -webkit-max-content" data-expected-width=116>
+ <td data-expected-width=111>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+</table>
+
+<table class="collapse" style="width: -webkit-fit-content" data-expected-width=116>
+ <td data-expected-width=111>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+</table>
+
+<div style="width: 116px">
+ <table class="collapse" style="width: -webkit-fit-content" data-expected-width=116>
+ <td data-expected-width=111>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+ </table>
+</div>
+
+<div style="width: 115px">
+ <table class="collapse" style="width: -webkit-fit-content" data-expected-width=115>
+ <td data-expected-width=110>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+ </table>
+</div>
+
+<div style="width: 400px">
+ <table class="collapse" style="width: -webkit-fill-available" data-expected-width=400>
+ <td data-expected-width=395>
+ <div class="child"></div>
+ <div class="child"></div>
+ </td>
+ </table>
+<div>
+
+<script src=""
+<script>
+checkLayout('table');
+</script>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (145423 => 145424)
--- trunk/Source/WebCore/ChangeLog 2013-03-11 23:18:44 UTC (rev 145423)
+++ trunk/Source/WebCore/ChangeLog 2013-03-11 23:20:56 UTC (rev 145424)
@@ -1,3 +1,40 @@
+2013-03-05 Ojan Vafai <o...@chromium.org>
+
+ Intrinsic width keyword values don't work for tables
+ https://bugs.webkit.org/show_bug.cgi?id=111515
+
+ Reviewed by Julien Chaffraix.
+
+ Tests: fast/css-intrinsic-dimensions/css-tables.html
+ fast/css-intrinsic-dimensions/tables.html
+
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::computeIntrinsicLogicalWidthUsing):
+ (WebCore::RenderBox::computeLogicalWidthInRegionUsing):
+ (WebCore::RenderBox::computeReplacedLogicalWidthUsing):
+ (WebCore::RenderBox::computePositionedLogicalWidthUsing):
+ * rendering/RenderBox.h:
+ Pass in the border and padding as an argument since RenderTable needs
+ to pass in a different value. Unfortunately, the math doesn't work out right
+ in the positioned/replaced cases if we just pass 0. We need to pass in the correct
+ border and padding and then subtract it from the result.
+
+ * rendering/RenderTable.cpp:
+ (WebCore::RenderTable::updateLogicalWidth):
+ Compute intrinsic widths as well as specified ones. Down the road
+ we may want to consider having intrinsic width values return true for
+ isSpecified.
+
+ (WebCore::RenderTable::convertStyleLogicalWidthToComputedWidth):
+ Compute intrinsic widths as well.
+
+ (WebCore::RenderTable::computeIntrinsicLogicalWidths):
+ Implement this method so that the RenderBox::computeIntrinsicLogicalWidthUsing
+ gets the right intrinsic values instead of the preferred values.
+
+ (WebCore::RenderTable::computePreferredLogicalWidths):
+ * rendering/RenderTable.h:
+
2013-03-11 Stephen Chenney <schen...@chromium.org>
HTMLInputElement can delete an ImageLoader while it's still needed
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (145423 => 145424)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2013-03-11 23:18:44 UTC (rev 145423)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2013-03-11 23:20:56 UTC (rev 145424)
@@ -2025,7 +2025,7 @@
return availableLogicalWidth - marginStart - marginEnd;
}
-LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth) const
+LayoutUnit RenderBox::computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const
{
if (logicalWidthLength.type() == FillAvailable)
return fillAvailableMeasure(availableLogicalWidth);
@@ -2034,8 +2034,6 @@
LayoutUnit maxLogicalWidth = 0;
computeIntrinsicLogicalWidths(minLogicalWidth, maxLogicalWidth);
- LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth();
-
if (logicalWidthLength.type() == MinContent)
return minLogicalWidth + borderAndPadding;
@@ -2075,7 +2073,7 @@
}
if (logicalWidth.isIntrinsic())
- return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalWidth);
+ return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalWidth, borderAndPaddingLogicalWidth());
LayoutUnit marginStart = 0;
LayoutUnit marginEnd = 0;
@@ -2580,7 +2578,7 @@
case MaxContent: {
// MinContent/MaxContent don't need the availableLogicalWidth argument.
LayoutUnit availableLogicalWidth = 0;
- return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalWidth) - borderAndPaddingLogicalWidth();
+ return computeIntrinsicLogicalWidthUsing(logicalWidth, availableLogicalWidth, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth();
}
case ViewportPercentageWidth:
case ViewportPercentageHeight:
@@ -2599,7 +2597,7 @@
// FIXME: Handle cases when containing block width is calculated or viewport percent.
// https://bugs.webkit.org/show_bug.cgi?id=91071
if (logicalWidth.isIntrinsic())
- return computeIntrinsicLogicalWidthUsing(logicalWidth, cw) - borderAndPaddingLogicalWidth();
+ return computeIntrinsicLogicalWidthUsing(logicalWidth, cw, borderAndPaddingLogicalWidth()) - borderAndPaddingLogicalWidth();
if (cw > 0 || (!cw && (containerLogicalWidth.isFixed() || containerLogicalWidth.isPercent())))
return adjustContentBoxLogicalWidthForBoxSizing(minimumValueForLength(logicalWidth, cw));
}
@@ -3070,7 +3068,7 @@
if (widthSizeType == MinSize && logicalWidth.isAuto())
logicalWidth = Length(0, Fixed);
else if (logicalWidth.isIntrinsic())
- logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, containerLogicalWidth) - bordersPlusPadding, Fixed);
+ logicalWidth = Length(computeIntrinsicLogicalWidthUsing(logicalWidth, containerLogicalWidth, bordersPlusPadding) - bordersPlusPadding, Fixed);
// 'left' and 'right' cannot both be 'auto' because one would of been
// converted to the static position already
Modified: trunk/Source/WebCore/rendering/RenderBox.h (145423 => 145424)
--- trunk/Source/WebCore/rendering/RenderBox.h 2013-03-11 23:18:44 UTC (rev 145423)
+++ trunk/Source/WebCore/rendering/RenderBox.h 2013-03-11 23:20:56 UTC (rev 145424)
@@ -607,6 +607,8 @@
#endif
void computePositionedLogicalWidth(LogicalExtentComputedValues&, RenderRegion* = 0, LayoutUnit offsetFromLogicalTopOfFirstPage = 0) const;
+
+ LayoutUnit computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth, LayoutUnit borderAndPadding) const;
virtual bool shouldComputeSizeAsReplaced() const { return isReplaced() && !isInlineBlockOrInlineTable(); }
@@ -655,8 +657,6 @@
LayoutUnit fillAvailableMeasure(LayoutUnit availableLogicalWidth) const;
LayoutUnit fillAvailableMeasure(LayoutUnit availableLogicalWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const;
- LayoutUnit computeIntrinsicLogicalWidthUsing(Length logicalWidthLength, LayoutUnit availableLogicalWidth) const;
-
virtual void computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const;
// This function calculates the minimum and maximum preferred widths for an object.
Modified: trunk/Source/WebCore/rendering/RenderTable.cpp (145423 => 145424)
--- trunk/Source/WebCore/rendering/RenderTable.cpp 2013-03-11 23:18:44 UTC (rev 145423)
+++ trunk/Source/WebCore/rendering/RenderTable.cpp 2013-03-11 23:20:56 UTC (rev 145424)
@@ -253,7 +253,7 @@
LayoutUnit containerWidthInInlineDirection = hasPerpendicularContainingBlock ? perpendicularContainingBlockLogicalHeight() : availableLogicalWidth;
Length styleLogicalWidth = style()->logicalWidth();
- if (styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive())
+ if ((styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive()) || styleLogicalWidth.isIntrinsic())
setLogicalWidth(convertStyleLogicalWidthToComputedWidth(styleLogicalWidth, containerWidthInInlineDirection));
else {
// Subtract out any fixed margins from our available width for auto width tables.
@@ -278,14 +278,14 @@
// Ensure we aren't bigger than our max-width style.
Length styleMaxLogicalWidth = style()->logicalMaxWidth();
- if (styleMaxLogicalWidth.isSpecified() && !styleMaxLogicalWidth.isNegative()) {
+ if ((styleMaxLogicalWidth.isSpecified() && !styleMaxLogicalWidth.isNegative()) || styleMaxLogicalWidth.isIntrinsic()) {
LayoutUnit computedMaxLogicalWidth = convertStyleLogicalWidthToComputedWidth(styleMaxLogicalWidth, availableLogicalWidth);
setLogicalWidth(min<int>(logicalWidth(), computedMaxLogicalWidth));
}
// Ensure we aren't smaller than our min-width style.
Length styleMinLogicalWidth = style()->logicalMinWidth();
- if (styleMinLogicalWidth.isSpecified() && !styleMinLogicalWidth.isNegative()) {
+ if ((styleMinLogicalWidth.isSpecified() && !styleMinLogicalWidth.isNegative()) || styleMinLogicalWidth.isIntrinsic()) {
LayoutUnit computedMinLogicalWidth = convertStyleLogicalWidthToComputedWidth(styleMinLogicalWidth, availableLogicalWidth);
setLogicalWidth(max<int>(logicalWidth(), computedMinLogicalWidth));
}
@@ -313,11 +313,14 @@
// This method takes a RenderStyle's logical width, min-width, or max-width length and computes its actual value.
LayoutUnit RenderTable::convertStyleLogicalWidthToComputedWidth(const Length& styleLogicalWidth, LayoutUnit availableWidth)
{
+ if (styleLogicalWidth.isIntrinsic())
+ return computeIntrinsicLogicalWidthUsing(styleLogicalWidth, availableWidth, bordersPaddingAndSpacingInRowDirection());
+
// HTML tables' width styles already include borders and paddings, but CSS tables' width styles do not.
LayoutUnit borders = 0;
bool isCSSTable = !node() || !node()->hasTagName(tableTag);
if (isCSSTable && styleLogicalWidth.isSpecified() && styleLogicalWidth.isPositive() && style()->boxSizing() == CONTENT_BOX)
- borders = borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit() : paddingStart() + paddingEnd());
+ borders = borderStart() + borderEnd() + (collapseBorders() ? LayoutUnit() : paddingStart() + paddingEnd());
return minimumValueForLength(styleLogicalWidth, availableWidth, view()) + borders;
}
@@ -717,15 +720,25 @@
paintMaskImages(paintInfo, rect);
}
+void RenderTable::computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) const
+{
+ recalcSectionsIfNeeded();
+ // FIXME: Do the recalc in borderStart/borderEnd and make those const_cast this call.
+ // Then m_borderStart/m_borderEnd will be transparent a cache and it removes the possibility
+ // of reading out stale values.
+ const_cast<RenderTable*>(this)->recalcBordersInRowDirection();
+ // FIXME: Restructure the table layout code so that we can make this method const.
+ const_cast<RenderTable*>(this)->m_tableLayout->computeIntrinsicLogicalWidths(minWidth, maxWidth);
+
+ // FIXME: We should include captions widths here like we do in computePreferredLogicalWidths.
+}
+
void RenderTable::computePreferredLogicalWidths()
{
ASSERT(preferredLogicalWidthsDirty());
- recalcSectionsIfNeeded();
- recalcBordersInRowDirection();
+ computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
- m_tableLayout->computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
-
int bordersPaddingAndSpacing = bordersPaddingAndSpacingInRowDirection();
m_minPreferredLogicalWidth += bordersPaddingAndSpacing;
m_maxPreferredLogicalWidth += bordersPaddingAndSpacing;
Modified: trunk/Source/WebCore/rendering/RenderTable.h (145423 => 145424)
--- trunk/Source/WebCore/rendering/RenderTable.h 2013-03-11 23:18:44 UTC (rev 145423)
+++ trunk/Source/WebCore/rendering/RenderTable.h 2013-03-11 23:20:56 UTC (rev 145424)
@@ -277,7 +277,8 @@
virtual void paintBoxDecorations(PaintInfo&, const LayoutPoint&);
virtual void paintMask(PaintInfo&, const LayoutPoint&);
virtual void layout();
- virtual void computePreferredLogicalWidths();
+ virtual void computeIntrinsicLogicalWidths(LayoutUnit& minWidth, LayoutUnit& maxWidth) const OVERRIDE;
+ virtual void computePreferredLogicalWidths() OVERRIDE;
virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTestLocation& locationInContainer, const LayoutPoint& accumulatedOffset, HitTestAction) OVERRIDE;
virtual int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const OVERRIDE;