Bug 284341
| Summary: | WebKit returns 300x150 for naturalHeight/naturalWidth for SVG-as-an-image with unspecified, percent-valued, or 0 size | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Daniel Holbert <dholbert> |
| Component: | SVG | Assignee: | Karl Dubost <karlcow> |
| Status: | NEW | ||
| Severity: | Normal | CC: | ahmad.saleem792, emilio, heycam, karlcow, sabouhallawa, webkit-bug-importer, zimmermann |
| Priority: | P2 | Keywords: | BrowserCompat, InRadar, WPTImpact |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: | https://bugs.webkit.org/show_bug.cgi?id=291655 | ||
Daniel Holbert
Steps to repro:
1. Visit https://bug1935269.bmoattachments.org/attachment.cgi?id=9442538
EXPECTED RESULTS:
The second line of text at the top should say
img naturalWidth x naturalHeight: 0 x 0"
ACTUAL RESULTS:
The second line of text at the top says:
naturalWidth x naturalHeight: 300 x 150
Firefox gives expected-results.
Chrome gives partly-expected results; they report 0 x 150. Their narrower version of this bug is https://issues.chromium.org/issues/41357911 .
There's a more comprehensive test here:
https://bug1935269.bmoattachments.org/attachment.cgi?id=9442584
WebKit fails 60 of the subtests there. Chrome fails 24. Firefox passes all of them.
See more analysis over on https://bugzilla.mozilla.org/show_bug.cgi?id=1935269 (which I filed in Mozilla's bug tracker but is really tracking a case where Firefox is correct and other browsers are incorrect). The 3rd and 4th comments there have spec quotes that make it pretty-clear that Firefox is correct.
heycam also looked at this 5 years ago over in https://bugzilla.mozilla.org/show_bug.cgi?id=1607081#c4 and concluded that it was correct to return 0x0 for this case.
I posted some analysis of the relevant WebKit code in https://bugzilla.mozilla.org/show_bug.cgi?id=1935269#c6 -- https://searchfox.org/wubkat/rev/48c752dce43162935898b93cefa254a21a5e84c5/Source/WebCore/svg/graphics/SVGImage.cpp#148-149,172-180 is the main issue where it explicitly sets 300x150 if the size is empty (i.e. if either dimension happens to be 0).
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/141196049>
Karl Dubost
Pull request: https://github.com/WebKit/WebKit/pull/37685
Karl Dubost
When this behavior is fixed, it will create a breakage for iCloud.
See https://bugzilla.mozilla.org/show_bug.cgi?id=1923304
So it might need a Quirk at the same time that this is fixed.
Ahmad Saleem
Test Case on WPT (Already imported in repo) - https://wpt.fyi/results/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight.html?label=master&label=experimental&aligned&q=the-img-element%2F
Karl Dubost
see the new tests https://wpt.fyi/results/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-unavailable.tentative.html
and the spec change:
Spec text for naturalWidth and naturalHeight behavior isn't web-compatible, for cases where attributes are missing
https://github.com/whatwg/html/issues/11287#issuecomment-2923467541
Daniel Holbert
(In reply to Karl Dubost from comment #5)
> see the new tests
> https://wpt.fyi/results/html/semantics/embedded-content/the-img-element/
> naturalWidth-naturalHeight-unavailable.tentative.html
Update: I actually renamed the test in the past few days (since I broadened it to cover .width and .height APIs and not-just-"unavailable"-cases) - it's now here:
https://wpt.fyi/results/html/semantics/embedded-content/the-img-element/naturalWidth-naturalHeight-width-height.tentative.html
Ahmad Saleem
(In reply to Daniel Holbert from comment #6)
> (In reply to Karl Dubost from comment #5)
> > see the new tests
> > https://wpt.fyi/results/html/semantics/embedded-content/the-img-element/
> > naturalWidth-naturalHeight-unavailable.tentative.html
>
> Update: I actually renamed the test in the past few days (since I broadened
> it to cover .width and .height APIs and not-just-"unavailable"-cases) - it's
> now here:
> https://wpt.fyi/results/html/semantics/embedded-content/the-img-element/
> naturalWidth-naturalHeight-width-height.tentative.html
Thanks Daniel, I am syncing new tests here including this one - https://github.com/WebKit/WebKit/pull/46237