Changeset 129914 in webkit


Ignore:
Timestamp:
Sep 28, 2012 10:14:43 AM (12 years ago)
Author:
tony@chromium.org
Message:

flexbox assert fails with auto-sized item with padding
https://bugs.webkit.org/show_bug.cgi?id=97606

Reviewed by Ojan Vafai.

Source/WebCore:

Depending on the denominator of FractionalLayoutUnit, we can lose precision when
converting to a float. This would cause a rounding error in flex-shrink to trigger an ASSERT.
To avoid this problem in the future, switch to using doubles for flex-shrink and flex-grow
at layout time. The CSS values themselves are still floats.

Test: css3/flexbox/negative-flex-rounding-assert.html

  • rendering/RenderFlexibleBox.cpp:

(WebCore::RenderFlexibleBox::layoutFlexItems): Use doubles for local variables.
(WebCore::RenderFlexibleBox::computeNextFlexLine): Pass in doubles.
(WebCore::RenderFlexibleBox::freezeViolations): Pass in doubles.
(WebCore::RenderFlexibleBox::resolveFlexibleLengths): Pass in doubles.

  • rendering/RenderFlexibleBox.h:

LayoutTests:

Add a test that hits an ASSERT when FractionalLayoutUnit denominator is 60.

  • css3/flexbox/negative-flex-rounding-assert-expected.txt: Added.
  • css3/flexbox/negative-flex-rounding-assert.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r129908 r129914  
     12012-09-27  Tony Chang  <tony@chromium.org>
     2
     3        flexbox assert fails with auto-sized item with padding
     4        https://bugs.webkit.org/show_bug.cgi?id=97606
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Add a test that hits an ASSERT when FractionalLayoutUnit denominator is 60.
     9
     10        * css3/flexbox/negative-flex-rounding-assert-expected.txt: Added.
     11        * css3/flexbox/negative-flex-rounding-assert.html: Added.
     12
    1132012-09-28  Harald Tveit Alvestrand  <harald@alvestrand.no>
    214       
  • trunk/Source/WebCore/ChangeLog

    r129913 r129914  
     12012-09-27  Tony Chang  <tony@chromium.org>
     2
     3        flexbox assert fails with auto-sized item with padding
     4        https://bugs.webkit.org/show_bug.cgi?id=97606
     5
     6        Reviewed by Ojan Vafai.
     7
     8        Depending on the denominator of FractionalLayoutUnit, we can lose precision when
     9        converting to a float.  This would cause a rounding error in flex-shrink to trigger an ASSERT.
     10        To avoid this problem in the future, switch to using doubles for flex-shrink and flex-grow
     11        at layout time.  The CSS values themselves are still floats.
     12
     13        Test: css3/flexbox/negative-flex-rounding-assert.html
     14
     15        * rendering/RenderFlexibleBox.cpp:
     16        (WebCore::RenderFlexibleBox::layoutFlexItems): Use doubles for local variables.
     17        (WebCore::RenderFlexibleBox::computeNextFlexLine): Pass in doubles.
     18        (WebCore::RenderFlexibleBox::freezeViolations): Pass in doubles.
     19        (WebCore::RenderFlexibleBox::resolveFlexibleLengths): Pass in doubles.
     20        * rendering/RenderFlexibleBox.h:
     21
    1222012-09-28  Sheriff Bot  <webkit.review.bot@gmail.com>
    223
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.cpp

    r129154 r129914  
    616616    OrderedFlexItemList orderedChildren;
    617617    LayoutUnit preferredMainAxisExtent;
    618     float totalFlexGrow;
    619     float totalWeightedFlexShrink;
     618    double totalFlexGrow;
     619    double totalWeightedFlexShrink;
    620620    LayoutUnit minMaxAppliedMainAxisExtent;
    621621
     
    798798}
    799799
    800 bool RenderFlexibleBox::computeNextFlexLine(OrderIterator& iterator, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, float& totalFlexGrow, float& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent)
     800bool RenderFlexibleBox::computeNextFlexLine(OrderIterator& iterator, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent)
    801801{
    802802    orderedChildren.clear();
     
    833833}
    834834
    835 void RenderFlexibleBox::freezeViolations(const WTF::Vector<Violation>& violations, LayoutUnit& availableFreeSpace, float& totalFlexGrow, float& totalWeightedFlexShrink, InflexibleFlexItemSize& inflexibleItems)
     835void RenderFlexibleBox::freezeViolations(const WTF::Vector<Violation>& violations, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSize& inflexibleItems)
    836836{
    837837    for (size_t i = 0; i < violations.size(); ++i) {
     
    847847
    848848// Returns true if we successfully ran the algorithm and sized the flex items.
    849 bool RenderFlexibleBox::resolveFlexibleLengths(FlexSign flexSign, const OrderedFlexItemList& children, LayoutUnit& availableFreeSpace, float& totalFlexGrow, float& totalWeightedFlexShrink, InflexibleFlexItemSize& inflexibleItems, WTF::Vector<LayoutUnit>& childSizes)
     849bool RenderFlexibleBox::resolveFlexibleLengths(FlexSign flexSign, const OrderedFlexItemList& children, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSize& inflexibleItems, WTF::Vector<LayoutUnit>& childSizes)
    850850{
    851851    childSizes.clear();
  • trunk/Source/WebCore/rendering/RenderFlexibleBox.h

    r129154 r129914  
    124124    void computeMainAxisPreferredSizes(bool relayoutChildren, OrderHashSet&);
    125125    LayoutUnit adjustChildSizeForMinAndMax(RenderBox*, LayoutUnit childSize);
    126     bool computeNextFlexLine(OrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, float& totalFlexGrow, float& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent);
     126    bool computeNextFlexLine(OrderIterator&, OrderedFlexItemList& orderedChildren, LayoutUnit& preferredMainAxisExtent, double& totalFlexGrow, double& totalWeightedFlexShrink, LayoutUnit& minMaxAppliedMainAxisExtent);
    127127
    128     bool resolveFlexibleLengths(FlexSign, const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, float& totalFlexGrow, float& totalWeightedFlexShrink, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
    129     void freezeViolations(const WTF::Vector<Violation>&, LayoutUnit& availableFreeSpace, float& totalFlexGrow, float& totalWeightedFlexShrink, InflexibleFlexItemSize&);
     128    bool resolveFlexibleLengths(FlexSign, const OrderedFlexItemList&, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSize&, WTF::Vector<LayoutUnit>& childSizes);
     129    void freezeViolations(const WTF::Vector<Violation>&, LayoutUnit& availableFreeSpace, double& totalFlexGrow, double& totalWeightedFlexShrink, InflexibleFlexItemSize&);
    130130
    131131    void setLogicalOverrideSize(RenderBox* child, LayoutUnit childPreferredSize);
Note: See TracChangeset for help on using the changeset viewer.