Changeset 131481 in webkit


Ignore:
Timestamp:
Oct 16, 2012 11:44:37 AM (12 years ago)
Author:
tony@chromium.org
Message:

in a column flexbox, input overflows the box when stretched
https://bugs.webkit.org/show_bug.cgi?id=99273

Reviewed by Ojan Vafai.

Source/WebCore:

Fix a bug where we didn't properly subtract padding and border when overriding the child size.
We didn't see this because of a performance optimization in RenderBox where we stretch children.
Also apply this performance optimization in new flexbox for form controls.

Test: css3/flexbox/stretch-input-in-column.html

  • rendering/RenderBox.cpp:

(WebCore::flexboxChildHasStretchAlignment):
(WebCore::isStretchingVerticalFlexboxChild):
(WebCore::RenderBox::sizesLogicalWidthToFitContent): Apply performance optimization to form controls in new flexbox.

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::applyStretchAlignmentToChild): Properly subtract border and padding.

LayoutTests:

Add a ref test since we're testing form rendering. Make sure that we get the
right behavior without the performance optimization (e.g., in multiline flexbox).

  • css3/flexbox/stretch-input-in-column-expected.html: Added.
  • css3/flexbox/stretch-input-in-column.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r131480 r131481  
     12012-10-16  Tony Chang  <tony@chromium.org>
     2
     3        in a column flexbox, input overflows the box when stretched
     4        https://bugs.webkit.org/show_bug.cgi?id=99273
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Add a ref test since we're testing form rendering. Make sure that we get the
     9        right behavior without the performance optimization (e.g., in multiline flexbox).
     10
     11        * css3/flexbox/stretch-input-in-column-expected.html: Added.
     12        * css3/flexbox/stretch-input-in-column.html: Added.
     13
    1142012-10-16  Csaba Osztrogonác  <ossy@webkit.org>
    215
  • trunk/Source/WebCore/ChangeLog

    r131479 r131481  
     12012-10-16  Tony Chang  <tony@chromium.org>
     2
     3        in a column flexbox, input overflows the box when stretched
     4        https://bugs.webkit.org/show_bug.cgi?id=99273
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Fix a bug where we didn't properly subtract padding and border when overriding the child size.
     9        We didn't see this because of a performance optimization in RenderBox where we stretch children.
     10        Also apply this performance optimization in new flexbox for form controls.
     11
     12        Test: css3/flexbox/stretch-input-in-column.html
     13
     14        * rendering/RenderBox.cpp:
     15        (WebCore::flexboxChildHasStretchAlignment):
     16        (WebCore::isStretchingVerticalFlexboxChild):
     17        (WebCore::RenderBox::sizesLogicalWidthToFitContent): Apply performance optimization to form controls in new flexbox.
     18        * rendering/RenderFlexibleBox.cpp:
     19        (WebCore::RenderFlexibleBox::applyStretchAlignmentToChild): Properly subtract border and padding.
     20
    1212012-10-16  Simon Fraser  <simon.fraser@apple.com>
    222
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r131348 r131481  
    17731773}
    17741774
     1775static bool flexItemHasStretchAlignment(const RenderObject* flexitem)
     1776{
     1777    RenderObject* parent = flexitem->parent();
     1778    return flexitem->style()->alignSelf() == AlignStretch || (flexitem->style()->alignSelf() == AlignAuto && parent->style()->alignItems() == AlignStretch);
     1779}
     1780
     1781static bool isStretchingColumnFlexItem(const RenderObject* flexitem)
     1782{
     1783    RenderObject* parent = flexitem->parent();
     1784    if (parent->isDeprecatedFlexibleBox() && parent->style()->boxOrient() == VERTICAL && parent->style()->boxAlign() == BSTRETCH)
     1785        return true;
     1786
     1787    // We don't stretch multiline flexboxes because they need to apply line spacing (align-content) first.
     1788    if (parent->isFlexibleBox() && parent->style()->flexWrap() == FlexWrapNone && parent->style()->isColumnFlexDirection() && flexItemHasStretchAlignment(flexitem))
     1789        return true;
     1790    return false;
     1791}
     1792
    17751793bool RenderBox::sizesLogicalWidthToFitContent(SizeType widthType) const
    17761794{
     
    18011819    // stretched size to avoid an extra layout when applying alignment.
    18021820    if (parent()->isFlexibleBox()) {
    1803         // For multiline columns, we need to apply the flex-line-pack first, so we can't stretch now.
     1821        // For multiline columns, we need to apply align-content first, so we can't stretch now.
    18041822        if (!parent()->style()->isColumnFlexDirection() || parent()->style()->flexWrap() != FlexWrapNone)
    18051823            return true;
    1806         EAlignItems itemAlign = style()->alignSelf();
    1807         if (itemAlign != AlignStretch && (itemAlign != AlignAuto || parent()->style()->alignItems() != AlignStretch))
     1824        if (!flexItemHasStretchAlignment(this))
    18081825            return true;
    18091826    }
     
    18131830    // FIXME: Think about block-flow here.
    18141831    // https://bugs.webkit.org/show_bug.cgi?id=46473
    1815     if (parent()->isDeprecatedFlexibleBox()
    1816             && (parent()->style()->boxOrient() == HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH))
     1832    if (parent()->isDeprecatedFlexibleBox() && (parent()->style()->boxOrient() == HORIZONTAL || parent()->style()->boxAlign() != BSTRETCH))
    18171833        return true;
    18181834
    1819     // Button, input, select, textarea, and legend treat
    1820     // width value of 'auto' as 'intrinsic' unless it's in a
    1821     // stretching vertical flexbox.
     1835    // Button, input, select, textarea, and legend treat width value of 'auto' as 'intrinsic' unless it's in a
     1836    // stretching column flexbox.
    18221837    // FIXME: Think about block-flow here.
    18231838    // https://bugs.webkit.org/show_bug.cgi?id=46473
    1824     if (logicalWidth.type() == Auto && !(parent()->isDeprecatedFlexibleBox() && parent()->style()->boxOrient() == VERTICAL && parent()->style()->boxAlign() == BSTRETCH) && node() && (node()->hasTagName(inputTag) || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) || node()->hasTagName(textareaTag) || node()->hasTagName(legendTag)))
     1839    if (logicalWidth.type() == Auto && !isStretchingColumnFlexItem(this) && node() && (node()->hasTagName(inputTag) || node()->hasTagName(selectTag) || node()->hasTagName(buttonTag) || node()->hasTagName(textareaTag) || node()->hasTagName(legendTag)))
    18251840        return true;
    18261841
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r130714 r131481  
    13041304
    13051305            if (childWidth != child->logicalWidth()) {
    1306                 child->setOverrideLogicalContentWidth(childWidth);
     1306                child->setOverrideLogicalContentWidth(childWidth - child->borderAndPaddingLogicalWidth());
    13071307                child->setChildNeedsLayout(true, MarkOnlyThis);
    13081308                child->layoutIfNeeded();
Note: See TracChangeset for help on using the changeset viewer.