LibWeb: Implement SVGGeometryElement.getTotalLength() - #11006
Conversation
This was stubbed but now returns the correct value
Use the element's own computed values rather than the layout node's. This method can be called when there is no layout node for the element (for instance `SVGGeometryElement::getTotalLength` when the element is `display: none`).
📝 WalkthroughWalkthroughSVG geometry elements now calculate total path length after layout and style updates. SVG percentage values use element-specific viewport resolution. Circle path generation reads computed geometry values directly. WPT coverage was added for hidden rectangles, circles, and paths. ChangesSVG geometry length
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant SVGGeometryElement
participant Document
participant SVGElement
participant SVGPath
SVGGeometryElement->>Document: Update layout and element style
SVGGeometryElement->>SVGElement: Resolve viewport dimensions
SVGGeometryElement->>SVGPath: Generate path and measure total length
SVGGeometryElement-->>SVGGeometryElement: Return ExceptionOr<float>
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Libraries/LibWeb/SVG/SVGElement.cpp`:
- Around line 424-432: Update viewport_size_for_percentage_resolution() to
obtain the viewport through viewport_element() instead of owner_svg_element().
Preserve the existing null check, active_view_box handling, and
viewport_size_from_layout fallback so percentage geometry in <use>-instantiated
<symbol> contents resolves against the symbol’s viewport.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 266cbf4b-b93c-4bde-812f-ffd57e821dc3
⛔ Files ignored due to path filters (1)
Tests/LibWeb/Text/input/wpt-import/svg/types/scripted/SVGGeometryElement.getTotalLength-01.svgis excluded by!**/*.svg
📒 Files selected for processing (12)
Libraries/LibWeb/DOM/Document.hLibraries/LibWeb/SVG/SVGCircleElement.cppLibraries/LibWeb/SVG/SVGElement.cppLibraries/LibWeb/SVG/SVGElement.hLibraries/LibWeb/SVG/SVGGeometryElement.cppLibraries/LibWeb/SVG/SVGGeometryElement.hLibraries/LibWeb/SVG/SVGLength.cppTests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGGeometryElement.getTotalLength-01.txtTests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGGeometryElement.getTotalLength-02.txtTests/LibWeb/Text/expected/wpt-import/svg/types/scripted/SVGPathElement.getTotalLength-01.txtTests/LibWeb/Text/input/wpt-import/svg/types/scripted/SVGGeometryElement.getTotalLength-02.htmlTests/LibWeb/Text/input/wpt-import/svg/types/scripted/SVGPathElement.getTotalLength-01.html
This was stubbed but now returns the correct value