Index: Source/core/rendering/RenderBox.cpp |
diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp |
index 84f11e672d2eb3c9686e9e5df2477c6fd974017a..f1b1af12aac9694dacd1953fb488e9ddf537b6f4 100644 |
--- a/Source/core/rendering/RenderBox.cpp |
+++ b/Source/core/rendering/RenderBox.cpp |
@@ -2347,8 +2347,7 @@ bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const |
// stretching column flexbox. |
// FIXME: Think about block-flow here. |
// https://bugs.webkit.org/show_bug.cgi?id=46473 |
- if (logicalWidth.type() == Auto && !isStretchingColumnFlexItem(this) && node() && (node()->hasTagName(inputTag) |
- || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) || isHTMLTextAreaElement(node()) || node()->hasTagName(legendTag))) |
+ if (logicalWidth.type() == Auto && !isStretchingColumnFlexItem(this) && isElementWithIntrinsicWidth()) |
return true; |
if (isHorizontalWritingMode() != containingBlock()->isHorizontalWritingMode()) |
@@ -2357,6 +2356,15 @@ bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const |
return false; |
} |
+bool RenderBox::isElementWithIntrinsicWidth() const |
+{ |
+ if (node() && (node()->hasTagName(inputTag) || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) |
+ || isHTMLTextAreaElement(node()) || node()->hasTagName(legendTag))) |
+ return true; |
+ |
+ return false; |
+} |
+ |
void RenderBox::computeInlineDirectionMargins(RenderBlock* containingBlock, LayoutUnit containerWidth, LayoutUnit childWidth, LayoutUnit& marginStart, LayoutUnit& marginEnd) const |
{ |
const RenderStyle* containingBlockStyle = containingBlock->style(); |
@@ -3479,7 +3487,16 @@ void RenderBox::computePositionedLogicalWidthUsing(Length logicalWidth, const Re |
} else if (!logicalLeftIsAuto && logicalWidthIsAuto && !logicalRightIsAuto) { |
// RULE 5: (solve for width) |
logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView); |
- computedValues.m_extent = availableSpace - (logicalLeftValue + valueForLength(logicalRight, containerLogicalWidth, renderView)); |
+ // Use shrink-to-fit for width for Button, input, select, textarea, and legend treat width value of |
+ // 'auto' as 'intrinsic'. |
+ if (isElementWithIntrinsicWidth()) { |
+ LayoutUnit preferredWidth = maxPreferredLogicalWidth() - bordersPlusPadding; |
+ LayoutUnit preferredMinWidth = minPreferredLogicalWidth() - bordersPlusPadding; |
+ LayoutUnit availableWidth = availableSpace - logicalLeftValue; |
+ computedValues.m_extent = min(max(preferredMinWidth, availableWidth), preferredWidth); |
cbiesinger
2013/10/09 17:13:38
Is there a reasonable way to share this code with
pals
2013/10/10 05:30:54
Done.
|
+ } else { |
+ computedValues.m_extent = availableSpace - (logicalLeftValue + valueForLength(logicalRight, containerLogicalWidth, renderView)); |
+ } |
} else if (!logicalLeftIsAuto && !logicalWidthIsAuto && logicalRightIsAuto) { |
// RULE 6: (no need solve for right) |
logicalLeftValue = valueForLength(logicalLeft, containerLogicalWidth, renderView); |