Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ae1b93917e553b9b4f1257317e5057625e17fb7d
      
https://github.com/WebKit/WebKit/commit/ae1b93917e553b9b4f1257317e5057625e17fb7d
  Author: Karl Dubost <[email protected]>
  Date:   2026-09-29 (Tue, 29 Sep 2026)

  Changed paths:
    A 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-fill-stroke-hittest-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-fill-stroke-hittest.html
    A 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-getBoundingClientRect-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-getBoundingClientRect.html
    M 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/w3c-import.log
    A 
LayoutTests/platform/mac-tahoe-wk2-lbse-text/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-fill-stroke-hittest-expected.txt
    M LayoutTests/tests-options.json
    M Source/WebCore/rendering/svg/RenderSVGEllipse.cpp
    M Source/WebCore/rendering/svg/RenderSVGPath.cpp
    M Source/WebCore/rendering/svg/RenderSVGRect.cpp
    M Source/WebCore/rendering/svg/RenderSVGShape.cpp
    M Source/WebCore/rendering/svg/RenderSVGShape.h
    M Source/WebCore/rendering/svg/SVGRenderSupport.cpp
    M Source/WebCore/rendering/svg/SVGRenderSupport.h
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGEllipse.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGPath.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRect.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGShape.cpp
    M Source/WebCore/rendering/svg/legacy/LegacyRenderSVGShape.h

  Log Message:
  -----------
  [SVG] pointer-events=stroke, visibleStroke, visible and all miss the stroke 
area when stroke is none
https://bugs.webkit.org/show_bug.cgi?id=325149
rdar://188285211

Reviewed by Simon Fraser.

With pointer-events set to stroke, visibleStroke, visible or all, the
stroke area of a shape hit-tests even when stroke is none:

    The value of the stroke property does not affect event processing.
    https://w3c.github.io/svgwg/svg2-draft/interact.html#PointerEventsProperty

strokeContains() first checks the point against
approximateStrokeBoundingBox(), and runs the exact stroke test only if
the point is inside it. That box is also the repaint rect, so it
includes the stroke area only when the stroke is painted. With stroke
none, a point on the stroke but outside the fill was rejected by that
first check.

Add hitTestStrokeBoundingBox(). With stroke none, it computes the box
as if the stroke were painted. Markers are left out, as they are not
hit-tested as part of the shape, and so is the stroke drawn for
zero-length subpaths with a round or square stroke-linecap, which is
only recorded when the stroke is painted.
approximateStrokeBoundingBox() itself is unchanged.

The new box is cached and cleared in updateShapeFromElement(), like
the approximate stroke bounding box. Without the cache, a shape with
vector-effect=non-scaling-stroke transformed a copy of its path on
every hit test.

Measured with https://bugs.webkit.org/attachment.cgi?id=481589: 400
shapes with stroke none and pointer-events=stroke, 2500
elementFromPoint() calls, MiniBrowser release build. With LBSE, 373 ms
without the cache and 88 ms with it, against 87 ms for the same shapes
with stroke=transparent. With the legacy engine and the cache, 49 ms
against 52 ms.

Safari failed 72 subtests of pointer-events-fill-stroke-hittest.html,
all of them stroke-related. They now pass. LBSE still fails 24 of them,
because RenderSVGContainer rejects the point before reaching the shape.
See https://webkit.org/b/325231

Tests: 
imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-fill-stroke-hittest.html
       
imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-getBoundingClientRect.html

* 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-fill-stroke-hittest-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-fill-stroke-hittest.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-getBoundingClientRect-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-getBoundingClientRect.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/svg/interact/scripted/w3c-import.log:
* 
LayoutTests/platform/mac-tahoe-wk2-lbse-text/imported/w3c/web-platform-tests/svg/interact/scripted/pointer-events-fill-stroke-hittest-expected.txt:
 Added.
* LayoutTests/tests-options.json:
* Source/WebCore/rendering/svg/RenderSVGEllipse.cpp:
(WebCore::RenderSVGEllipse::updateShapeFromElement):
* Source/WebCore/rendering/svg/RenderSVGPath.cpp:
(WebCore::RenderSVGPath::updateShapeFromElement):
* Source/WebCore/rendering/svg/RenderSVGRect.cpp:
(WebCore::RenderSVGRect::updateShapeFromElement):
* Source/WebCore/rendering/svg/RenderSVGShape.cpp:
(WebCore::RenderSVGShape::strokeContains):
(WebCore::RenderSVGShape::hitTestStrokeBoundingBox const):
* Source/WebCore/rendering/svg/RenderSVGShape.h:
* Source/WebCore/rendering/svg/SVGRenderSupport.cpp:
(WebCore::SVGRenderSupport::calculateApproximateStrokeBoundingBox):
* Source/WebCore/rendering/svg/SVGRenderSupport.h:
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGEllipse.cpp:
(WebCore::LegacyRenderSVGEllipse::updateShapeFromElement):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGPath.cpp:
(WebCore::LegacyRenderSVGPath::updateShapeFromElement):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGRect.cpp:
(WebCore::LegacyRenderSVGRect::updateShapeFromElement):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGShape.cpp:
(WebCore::LegacyRenderSVGShape::strokeContains):
(WebCore::LegacyRenderSVGShape::hitTestStrokeBoundingBox const):
* Source/WebCore/rendering/svg/legacy/LegacyRenderSVGShape.h:

Canonical link: https://commits.webkit.org/322143@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to