Bug 194815

Summary: SVG Image intrinsic size should be used if css style size is 'auto'
Product: WebKit Reporter: Frédéric Wang (:fredw) <fred.wang>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: ahmad.saleem792, bfulgham, krit, rwlbuis, simon.fraser, webkit-bug-importer, zimmermann
Priority: P2 Keywords: BlinkMergeCandidate, BrowserCompat, InRadar, WPTImpact
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: http://wpt.live/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto.html
See Also: https://bugs.chromium.org/p/chromium/issues/detail?id=493681
https://github.com/web-platform-tests/wpt/pull/15464
https://bugs.webkit.org/show_bug.cgi?id=250412
Attachments:
Description Flags
Tentative Patch none

Description Frédéric Wang (:fredw) 2019-02-19 02:37:14 PST
"The CSS width and height properties are used for sizing some SVG elements. Specifically, they are used to size ‘rect’, ‘svg’, ‘image’ and ‘foreignObject’. All of these elements have ‘width’ and ‘height’ presentation attributes. The properties are also used for laying out embedded elements from the HTML namespace. "
"The value auto for width and height on the ‘image’ element is calculated from the referenced image's intrinsic dimensions and aspect ratio, according to the CSS default sizing algorithm."
(https://www.w3.org/TR/SVG2/geometry.html#Sizing)

" A value of zero for either width or height disables rendering of the element and its embedded content. The 'auto' value for width or height is used to size the corresponding element automatically based on the intrinsic dimensions or intrinsic aspect ratio of the referenced resource. Computation of automatically-sized values follows the Default Sizing Algorithm defined for replaced elements in CSS layout [css-images-3]. In particular, when the referenced resource does not have an intrinsic size (such as an ‘iframe’ or an image types with no defined dimensions), it is assumed to have a width of 300px and a height of 150px."
(https://www.w3.org/TR/SVG2/embedded.html#Placement)

Essentially we should port Chromium's change:
https://codereview.chromium.org/2230963002
https://bugs.chromium.org/p/chromium/issues/detail?id=493681
Comment 2 Frédéric Wang (:fredw) 2019-02-21 07:15:16 PST
Created attachment 362604 [details]
Tentative Patch

Just trying to import https://chromium.googlesource.com/chromium/src.git/+/3c1a3822848d986337573cfaf2817c8a69417791 and align with Chromium. https://w3c-test.org/svg/geometry/svg-image-intrinsic-size-with-cssstyle-auto.html already times out without the patch applies, so there might be something wrong in WebKit's implementation.
Comment 3 Radar WebKit Bug Importer 2024-02-08 15:15:36 PST
<rdar://problem/122586485>