Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: e33f42cd046adc916beddbf75157f692f6f22ad7
      
https://github.com/WebKit/WebKit/commit/e33f42cd046adc916beddbf75157f692f6f22ad7
  Author: Antoine Quint <[email protected]>
  Date:   2024-07-16 (Tue, 16 Jul 2024)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/svg/animations/spaces-at-end-of-path-data-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/svg/path/property/d-none-expected.svg
    A 
LayoutTests/imported/w3c/web-platform-tests/svg/path/property/d-none-ref.svg
    A LayoutTests/imported/w3c/web-platform-tests/svg/path/property/d-none.svg
    M Source/WebCore/dom/StyledElement.cpp
    M Source/WebCore/dom/StyledElement.h
    M Source/WebCore/html/HTMLImageElement.h
    M Source/WebCore/svg/SVGPathByteStream.h
    M Source/WebCore/svg/SVGPathElement.cpp
    M Source/WebCore/svg/SVGPathElement.h

  Log Message:
  -----------
  [svg] setting `d: none` on a `<path>` does not override the `d` SVG attribute
https://bugs.webkit.org/show_bug.cgi?id=276653

Reviewed by Nikolas Zimmermann.

If the `d` CSS property is set to `none`, the resulting `SVGRenderStyle::d()` 
value is `nullptr`.
We must account for this in `SVGPathElement::path()` and 
`SVGPathElement::pathByteStream()` and
return an empty path in the case that we don't have a `BasicShapePath` set on 
the style. In fact,
at long as the `d` CSS property is enabled, we should never return the SVG 
attribute value.

Making this code change alone yielded two test regressions:

    - svg/custom/svg-curve-with-relative-coordinates.html
    - svg/animations/path-animation.svg

Indeed, neither of those two tests explicitly sets the `d` SVG attribute, 
relying instead on `<animate>` or
the `pathSegList` DOM API to set the path data. The lack of a `d` SVG attribute 
means the traditional mechanism
to compile a list of presentation attributes for a `<path>` attribute will not 
pick up the `d` property.

So we add a new method to collect additional presentational hints as was 
already done for the HTML `<img>`
element, promoting the `collectExtraStyleForPresentationalHints()` method from 
`HTMLImageElement` to a virtual
method on `StyledElement` and making `SVGPathElement` override it. Using this 
method, we can collect the `d`
presentational hint if it hasn't already been picked up.

Finally, since the lack of accounting for `d: none` when rendering wasn't 
caught by existing tests, we add
a new WPT reftest.

* 
LayoutTests/imported/w3c/web-platform-tests/svg/animations/spaces-at-end-of-path-data-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/svg/path/property/d-none-expected.svg:
 Added.
* LayoutTests/imported/w3c/web-platform-tests/svg/path/property/d-none-ref.svg: 
Added.
* LayoutTests/imported/w3c/web-platform-tests/svg/path/property/d-none.svg: 
Added.
* Source/WebCore/dom/StyledElement.cpp:
(WebCore::StyledElement::rebuildPresentationalHintStyle):
* Source/WebCore/dom/StyledElement.h:
(WebCore::StyledElement::collectExtraStyleForPresentationalHints):
* Source/WebCore/html/HTMLImageElement.h:
* Source/WebCore/svg/SVGPathByteStream.h:
* Source/WebCore/svg/SVGPathElement.cpp:
(WebCore::SVGPathElement::pathByteStream const):
(WebCore::SVGPathElement::path const):
(WebCore::SVGPathElement::collectPresentationalHintsForAttribute):
(WebCore::SVGPathElement::collectExtraStyleForPresentationalHints):
(WebCore::SVGPathElement::collectDPresentationalHint):
* Source/WebCore/svg/SVGPathElement.h:

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to