Commit aa1b9b2
SVGLength percentage resolution fails for elements inside non-instanced <symbol> or when viewportElement() returns nullptr
https://bugs.webkit.org/show_bug.cgi?id=303127
rdar://165431008
Reviewed by Simon Fraser.
SVGLength.value was throwing `NotSupportedError` when resolving percentage
values for elements inside non-instanced <symbol> elements or display:none
containers. According to the SVG specification [1], either an <svg> element
or a <symbol> element that is instanced by a <use> element establishes a
new viewport. For non-instanced <symbol> elements, the nearest ancestor
<svg> should provide the viewport for percentage resolution.
Fix viewport calculation by extending viewportElement() with a
ViewportElementType enum that allows callers to specify whether they want
any viewport element (including <symbol>) or specifically an <svg> element.
This eliminates the need for manual ancestor walks in computeViewportSize()
while preserving the original behavior for normal viewport elements.
When ViewportElementType::SVGSVGOnly is specified, viewportElement() now
walks up the ancestor tree to find the nearest <svg> element, skipping
<symbol> elements. This matches other browser engines (Blink / Chromium
and Gecko / Firefox).
[1] https://svgwg.org/svg2-draft/coords.html#EstablishingANewSVGViewport
NOTE: We still don't progress WPT due to floating point issue with height
in WPT test but it progress for width.
* Source/WebCore/svg/SVGElement.cpp:
(WebCore::SVGElement::viewportElement const):
* Source/WebCore/svg/SVGElement.h:
* Source/WebCore/svg/SVGLengthContext.cpp:
(WebCore::SVGLengthContext::computeViewportSize const):
* LayoutTests/imported/w3c/web-platform-tests/svg/geometry/svg-baseval-in-display-none-expected.txt: Partial Progression
Canonical link: https://commits.webkit.org/304197@main1 parent bd18128 commit aa1b9b2
File tree
4 files changed
+20
-8
lines changed- LayoutTests/imported/w3c/web-platform-tests/svg/geometry
- Source/WebCore/svg
4 files changed
+20
-8
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
233 | | - | |
| 233 | + | |
234 | 234 | | |
235 | 235 | | |
236 | | - | |
| 236 | + | |
237 | 237 | | |
238 | 238 | | |
239 | | - | |
240 | | - | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
241 | 244 | | |
242 | 245 | | |
243 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
74 | 80 | | |
75 | 81 | | |
76 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
36 | 37 | | |
37 | 38 | | |
38 | 39 | | |
| |||
421 | 422 | | |
422 | 423 | | |
423 | 424 | | |
| 425 | + | |
| 426 | + | |
424 | 427 | | |
425 | 428 | | |
426 | 429 | | |
| |||
432 | 435 | | |
433 | 436 | | |
434 | 437 | | |
435 | | - | |
436 | | - | |
| 438 | + | |
| 439 | + | |
437 | 440 | | |
438 | 441 | | |
439 | 442 | | |
| |||
0 commit comments