Bug 257615

Summary: Fix getBBox() returning (0,0) bug when width or height is zero
Product: WebKit Reporter: Ahmad Saleem <ahmad.saleem792>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: karlcow, sabouhallawa, simon.fraser, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=93290

Description Ahmad Saleem 2023-06-01 12:33:09 PDT
Hi Team,

While going through Blink commit, I came across another failing test case:

Test Case: https://bug-93290-attachments.webkit.org/attachment.cgi?id=156745

^ From our own bug 93290.

*** Safari Technology Preview 171 & Firefox Nightly 115 ***

bbox size is: 0 by 0

*** Chrome Canary 116 ***

bbox size is: 0 by 100

___________________


Although, we fixed it in bug 93290 but the code is not today as was changed in the bug. (Might be reverted).

Blink Commit: https://src.chromium.org/viewvc/blink?view=revision&revision=170097

^ I did local testing and now we match 'Chrome'.

___________________

FAIL - https://jsfiddle.net/9wdL6xjf/show & https://jsfiddle.net/f2m7kh69/show etc.

_____________________

Bounding Box Spec: https://svgwg.org/svg2-draft/coords.html#BoundingBoxes & https://svgwg.org/svg2-draft/types.html#__svg__SVGGraphicsElement__getBBox

________________________

Thanks!
Comment 1 Alexey Proskuryakov 2023-06-02 10:54:32 PDT
git log for tests added with that fix shows an explanation from Said, see https://commits.webkit.org/217223@main:

    These tests were added in r169522. They succeed in Safari and Chrome but
    they fail in FireFox. The issue of calculating getBBox was discussed in:
    https://lists.w3.org/Archives/Public/www-svg/2012Aug/0014.html. But no
    resolution was reached.

So looks like we've intentionally undone this change.
Comment 2 Karl Dubost 2023-06-04 22:16:18 PDT
In addition to what Alex mentioned
there are a number of issues around
https://wpt.fyi/results/svg/types/scripted?label=master&label=experimental&aligned&q=getbbox

Also 
https://bugs.webkit.org/buglist.cgi?quicksearch=getbbox

Probably it would be worth to open an issue on 
https://github.com/w3c/svgwg/issues?q=is%3Aissue+is%3Aopen+getbbox

with a pointer to the thread Alex found.
https://lists.w3.org/Archives/Public/www-svg/2012Aug/thread.html#msg14

Gecko/WebKit at the time were aligned on ignoring the shape and consider it as a display: none.

The state of implementations was described in 
https://lists.w3.org/Archives/Public/www-svg/2012Aug/0043.html


On SVG 2 current Editor Draft
https://svgwg.org/svg2-draft/types.html#__svg__SVGGraphicsElement__getBBox


> The getBBox method is used to compute the bounding box of 
> the current element. When the getBBox(options) method is 
> called, the bounding box algorithm is invoked for the 
> current element, with fill, stroke, markers and clipped 
> members of the options dictionary argument used to control 
> which parts of the element are included in the bounding 
> box, using the element's user coordinate system as the 
> coordinate system to return the bounding box in. A newly 
> created DOMRect object that defines the computed bounding 
> box is returned. 

And the paragraph ends with:

> If getBBox gets called on a non-rendered element, and 
> the UA is not able to compute the geometry of the element, 
> then throw an InvalidStateError.

So at least it should throw an InvalidStateError.


(If I understood correctly.)
Comment 3 Radar WebKit Bug Importer 2023-06-08 12:34:15 PDT
<rdar://problem/110480937>