⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 278271 in webkit


Ignore:
Timestamp:
May 30, 2021, 11:39:50 PM (5 years ago)
Author:
Wenson Hsieh
Message:

REGRESSION (r258118): SVG paths that contain a single move command incorrect client bounding rects
https://bugs.webkit.org/show_bug.cgi?id=226447
rdar://72112744

Reviewed by Alan Bujtas.

Source/WebCore:

r258118 introduced a fast path for computing the bounding rect of a WebCore::Path without having to
materialize a platform path object (e.g. CGPathRef on platforms that use CoreGraphics). To do this, we
introduce InlinePathData -- a variant capable of representing several types of simple Path objects without
allocating a platform path.

However, in the case where a Path only consists of a single moveTo command, this fast path for computing the
bounding rect currently returns the zero rect (an empty rect at the origin), rather than an empty rect at the
location we've moved to. This causes the offset of the bounding rect of an SVG path element that contains only a
single M drawing command to be incorrect.

Simply fix this by returning an empty rect that is offset by the moveTo location, rather than the origin.

Test: fast/svg/bounding-rect-for-path-with-only-move-command.html

  • platform/graphics/Path.cpp:

(WebCore::Path::boundingRectFromInlineData const):

LayoutTests:

Add a layout test to exercise the bug.

  • fast/svg/bounding-rect-for-path-with-only-move-command-expected.txt: Added.
  • fast/svg/bounding-rect-for-path-with-only-move-command.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r278268 r278271  
     12021-05-30  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        REGRESSION (r258118): SVG paths that contain a single move command incorrect client bounding rects
     4        https://bugs.webkit.org/show_bug.cgi?id=226447
     5        rdar://72112744
     6
     7        Reviewed by Alan Bujtas.
     8
     9        Add a layout test to exercise the bug.
     10
     11        * fast/svg/bounding-rect-for-path-with-only-move-command-expected.txt: Added.
     12        * fast/svg/bounding-rect-for-path-with-only-move-command.html: Added.
     13
    1142021-05-30  Sam Weinig  <weinig@apple.com>
    215
  • trunk/Source/WebCore/ChangeLog

    r278270 r278271  
     12021-05-30  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        REGRESSION (r258118): SVG paths that contain a single move command incorrect client bounding rects
     4        https://bugs.webkit.org/show_bug.cgi?id=226447
     5        rdar://72112744
     6
     7        Reviewed by Alan Bujtas.
     8
     9        r258118 introduced a fast path for computing the bounding rect of a `WebCore::Path` without having to
     10        materialize a platform path object (e.g. `CGPathRef` on platforms that use CoreGraphics). To do this, we
     11        introduce `InlinePathData` -- a variant capable of representing several types of simple `Path` objects without
     12        allocating a platform path.
     13
     14        However, in the case where a `Path` only consists of a single `moveTo` command, this fast path for computing the
     15        bounding rect currently returns the zero rect (an empty rect at the origin), rather than an empty rect at the
     16        location we've moved to. This causes the offset of the bounding rect of an SVG path element that contains only a
     17        single `M` drawing command to be incorrect.
     18
     19        Simply fix this by returning an empty rect that is offset by the `moveTo` location, rather than the origin.
     20
     21        Test: fast/svg/bounding-rect-for-path-with-only-move-command.html
     22
     23        * platform/graphics/Path.cpp:
     24        (WebCore::Path::boundingRectFromInlineData const):
     25
    1262021-05-30  Youenn Fablet  <youenn@apple.com>
    227
  • trunk/Source/WebCore/platform/graphics/Path.cpp

    r278253 r278271  
    491491
    492492    if (hasInlineData<MoveData>())
    493         return FloatRect { };
     493        return {{ inlineData<MoveData>().location, FloatSize { } }};
    494494
    495495    if (hasInlineData<LineData>()) {
Note: See TracChangeset for help on using the changeset viewer.