Changeset 249090 in webkit


Ignore:
Timestamp:
Aug 24, 2019 2:42:42 PM (5 years ago)
Author:
Simon Fraser
Message:

Page crashes under CGPathAddUnevenCornersRoundedRect
https://bugs.webkit.org/show_bug.cgi?id=201117

Reviewed by Dean Jackson.
Source/WebCore:

Fix crash on https://onehtmlpagechallenge.com/entries/pure-css-still-life-water-lemon.html
We were passing CG radius values where the sum of two radii was greater than the height or
width, caused by rounding when converting from floats to doubles.

Test: fast/borders/renderable-uneven-rounded-rects.html

  • platform/graphics/cg/PathCG.cpp:

(WebCore::Path::platformAddPathForRoundedRect):

LayoutTests:

  • fast/borders/renderable-uneven-rounded-rects-expected.txt: Added.
  • fast/borders/renderable-uneven-rounded-rects.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r249089 r249090  
     12019-08-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Page crashes under CGPathAddUnevenCornersRoundedRect
     4        https://bugs.webkit.org/show_bug.cgi?id=201117
     5
     6        Reviewed by Dean Jackson.
     7
     8        * fast/borders/renderable-uneven-rounded-rects-expected.txt: Added.
     9        * fast/borders/renderable-uneven-rounded-rects.html: Added.
     10
    1112019-08-24  Devin Rousso  <drousso@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r249088 r249090  
     12019-08-24  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Page crashes under CGPathAddUnevenCornersRoundedRect
     4        https://bugs.webkit.org/show_bug.cgi?id=201117
     5
     6        Reviewed by Dean Jackson.
     7       
     8        Fix crash on https://onehtmlpagechallenge.com/entries/pure-css-still-life-water-lemon.html
     9        We were passing CG radius values where the sum of two radii was greater than the height or
     10        width, caused by rounding when converting from floats to doubles.
     11
     12        Test: fast/borders/renderable-uneven-rounded-rects.html
     13
     14        * platform/graphics/cg/PathCG.cpp:
     15        (WebCore::Path::platformAddPathForRoundedRect):
     16
    1172019-08-23  Simon Fraser  <simon.fraser@apple.com>
    218
  • trunk/Source/WebCore/platform/graphics/cg/PathCG.cpp

    r238501 r249090  
    308308        CGFloat rectWidth = CGRectGetWidth(rectToDraw);
    309309        CGFloat rectHeight = CGRectGetHeight(rectToDraw);
    310         if (rectWidth < 2 * radiusWidth)
     310        if (2 * radiusWidth > rectWidth)
    311311            radiusWidth = rectWidth / 2 - std::numeric_limits<CGFloat>::epsilon();
    312         if (rectHeight < 2 * radiusHeight)
     312        if (2 * radiusHeight > rectHeight)
    313313            radiusHeight = rectHeight / 2 - std::numeric_limits<CGFloat>::epsilon();
    314314        CGPathAddRoundedRect(ensurePlatformPath(), nullptr, rectToDraw, radiusWidth, radiusHeight);
     
    318318#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101400) || (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000)
    319319    CGRect rectToDraw = rect;
     320   
     321    enum Corners {
     322        BottomLeft,
     323        BottomRight,
     324        TopRight,
     325        TopLeft
     326    };
    320327    CGSize corners[4] = { bottomLeftRadius, bottomRightRadius, topRightRadius, topLeftRadius };
     328
     329    CGFloat rectWidth = CGRectGetWidth(rectToDraw);
     330    CGFloat rectHeight = CGRectGetHeight(rectToDraw);
     331   
     332    // Clamp the radii after conversion to CGFloats.
     333    corners[TopRight].width = std::min(corners[TopRight].width, rectWidth - corners[TopLeft].width);
     334    corners[BottomRight].width = std::min(corners[BottomRight].width, rectWidth - corners[BottomLeft].width);
     335    corners[BottomLeft].height = std::min(corners[BottomLeft].height, rectHeight - corners[TopLeft].height);
     336    corners[BottomRight].height = std::min(corners[BottomRight].height, rectHeight - corners[TopRight].height);
     337
    321338    CGPathAddUnevenCornersRoundedRect(ensurePlatformPath(), nullptr, rectToDraw, corners);
    322339    return;
Note: See TracChangeset for help on using the changeset viewer.