Bug 252903

Summary: [Resize-observer] The `getBoundingBox` of a non-empty SVG element is 0x0
Product: WebKit Reporter: cathiechen <cathiechen>
Component: CSSAssignee: cathiechen <cathiechen>
Status: RESOLVED FIXED    
Severity: Normal CC: cathiechen, rbuis, sabouhallawa, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
test-case none

Description cathiechen 2023-02-24 07:30:40 PST
Created attachment 465152 [details]
test-case

In ResizeObservation::computeObservedSizes(), it calls `downcast<SVGElement>(*m_target).getBoundingBox()` which returns 0x0 when the layout size of SVG is not empty.
See the attached test.
Comment 1 cathiechen 2023-02-24 08:50:12 PST
According to [1],

> Web content can also contain SVG elements. SVG elements that do not have associated CSS layout boxes define bounding box instead of a content box. Content rect for the SVGGraphicsElements without CSS layout boxes is a rect whose:
> width is bounding box width
> height is bounding box height

So from ResizeObserver size, it is correct to call `downcast<SVGElement>(*m_target).getBoundingBox()` in `ResizeObservation::computeObservedSizes()`.

I'll leave this bug to an SVG Expert.

[1] https://drafts.csswg.org/resize-observer/
Comment 2 cathiechen 2023-03-02 13:28:54 PST
Pull request: https://github.com/WebKit/WebKit/pull/10955
Comment 3 Radar WebKit Bug Importer 2023-03-03 07:31:14 PST
<rdar://problem/106194536>
Comment 4 EWS 2023-03-27 06:24:00 PDT
Committed 262145@main (afa718b1cfd9): <https://commits.webkit.org/262145@main>

Reviewed commits have been landed. Closing PR #10955 and removing active labels.