Changeset 218648 in webkit


Ignore:
Timestamp:
Jun 21, 2017, 2:13:58 PM (8 years ago)
Author:
Simon Fraser
Message:

svgPath.getTotalLength() freezes webkit
https://bugs.webkit.org/show_bug.cgi?id=173566
<rdar://problem/32866731>

Reviewed by Dean Jackson.

Source/WebCore:

Ensure that curveLength() progresses by making split() return a bool indicating
whether either of the resulting curves are the same as the original. This can happen
when midPoint() on two close points returns a point that is the same as one of the
arguments because of floating-point precision limitations.

Test: svg/custom/path-getTotalLength-hang.html

  • platform/graphics/PathTraversalState.cpp:

(WebCore::QuadraticBezier::operator ==):
(WebCore::QuadraticBezier::split):
(WebCore::CubicBezier::operator ==):
(WebCore::CubicBezier::split):
(WebCore::curveLength):

LayoutTests:

  • svg/custom/path-getTotalLength-hang.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r218636 r218648  
     12017-06-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        svgPath.getTotalLength() freezes webkit
     4        https://bugs.webkit.org/show_bug.cgi?id=173566
     5        <rdar://problem/32866731>
     6
     7        Reviewed by Dean Jackson.
     8
     9        * svg/custom/path-getTotalLength-hang.html: Added.
     10
    1112017-06-21  Claudio Saavedra  <csaavedra@igalia.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r218647 r218648  
     12017-06-20  Simon Fraser  <simon.fraser@apple.com>
     2
     3        svgPath.getTotalLength() freezes webkit
     4        https://bugs.webkit.org/show_bug.cgi?id=173566
     5        <rdar://problem/32866731>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Ensure that curveLength() progresses by making split() return a bool indicating
     10        whether either of the resulting curves are the same as the original. This can happen
     11        when midPoint() on two close points returns a point that is the same as one of the
     12        arguments because of floating-point precision limitations.
     13
     14        Test: svg/custom/path-getTotalLength-hang.html
     15
     16        * platform/graphics/PathTraversalState.cpp:
     17        (WebCore::QuadraticBezier::operator ==):
     18        (WebCore::QuadraticBezier::split):
     19        (WebCore::CubicBezier::operator ==):
     20        (WebCore::CubicBezier::split):
     21        (WebCore::curveLength):
     22
    1232017-06-21  Youenn Fablet  <youenn@apple.com>
    224
  • trunk/Source/WebCore/platform/graphics/PathTraversalState.cpp

    r182828 r218648  
    4949    {
    5050    }
     51
     52    bool operator==(const QuadraticBezier& rhs) const
     53    {
     54        return start == rhs.start
     55            && control == rhs.control
     56            && end == rhs.end;
     57    }
    5158   
    5259    float approximateDistance() const
     
    5562    }
    5663   
    57     void split(QuadraticBezier& left, QuadraticBezier& right) const
     64    bool split(QuadraticBezier& left, QuadraticBezier& right) const
    5865    {
    5966        left.control = midPoint(start, control);
     
    6673        left.start = start;
    6774        right.end = end;
     75
     76        return !(left == *this) && !(right == *this);
    6877    }
    6978   
     
    8291    {
    8392    }
    84    
     93
     94    bool operator==(const CubicBezier& rhs) const
     95    {
     96        return start == rhs.start
     97            && control1 == rhs.control1
     98            && control2 == rhs.control2
     99            && end == rhs.end;
     100    }
     101
    85102    float approximateDistance() const
    86103    {
     
    88105    }
    89106       
    90     void split(CubicBezier& left, CubicBezier& right) const
     107    bool split(CubicBezier& left, CubicBezier& right) const
    91108    {   
    92109        FloatPoint startToControl1 = midPoint(control1, control2);
     
    103120        left.end = leftControl2ToRightControl1;
    104121        right.start = leftControl2ToRightControl1;
     122
     123        return !(left == *this) && !(right == *this);
    105124    }
    106125   
     
    128147        float length = curve.approximateDistance();
    129148
    130         if ((length - distanceLine(curve.start, curve.end)) > kPathSegmentLengthTolerance && curveStack.size() < curveStackDepthLimit) {
    131             CurveType leftCurve;
    132             CurveType rightCurve;
    133             curve.split(leftCurve, rightCurve);
     149        CurveType leftCurve;
     150        CurveType rightCurve;
     151
     152        if ((length - distanceLine(curve.start, curve.end)) > kPathSegmentLengthTolerance && curveStack.size() < curveStackDepthLimit && curve.split(leftCurve, rightCurve)) {
    134153            curve = leftCurve;
    135154            curveStack.append(rightCurve);
Note: See TracChangeset for help on using the changeset viewer.