Bug 199236

Summary: Safari is not scaling SVGs with Command+/- zoom when font-size: is used
Product: WebKit Reporter: Tom <apple>
Component: SVGAssignee: Fujii Hironori <Hironori.Fujii>
Status: REOPENED    
Severity: Normal CC: ahmad.saleem792, commit-queue, decademoon.bugzilla, dino, Hironori.Fujii, mmaxfield, sabouhallawa, simon.fraser, timothy, webkit-bug-importer, zbbjornson, zimmermann
Priority: P2 Keywords: BrowserCompat, InRadar, LayerBasedSVGEngine
Version: Safari 12   
Hardware: All   
OS: Unspecified   
URL: https://jsfiddle.net/winzig/3k6x91ha/1/
See Also: https://bugs.webkit.org/show_bug.cgi?id=118818
https://bugs.webkit.org/show_bug.cgi?id=279041
https://bugs.webkit.org/show_bug.cgi?id=281478
https://bugs.webkit.org/show_bug.cgi?id=281561
Bug Depends on: 283990    
Bug Blocks:    
Attachments:
Description Flags
test case
none
WIP patch
none
test of foreignObject
none
PerformanceTestsResults (Needs to adjust localPath) none

Tom
Reported 2019-06-26 15:08:36 PDT
I've found that SVGs don't scale in Safari the way they do in the other modern browsers when font-size is specified. It's as if Safari treats font-size on SVGs as an absolute size that cannot be changed. Other browsers don't behave this way, so I assume it's a bug? Where this becomes a big problem is with things like Font Awesome, which now offers SVG instead of fonts for it's icon sets. Here is a demonstration: https://jsfiddle.net/winzig/3k6x91ha/1/ If you use Command+ and Command- to zoom in and out, the text scales as appropriate, the third home icon does as well (an SVG without font-size set) but the first two SVG icons don't scale no matter what. If you load the same page in Chrome/Firefox/Edge, it works as expected. I opened a bug report with Apple a while back (October) that is now in the new feedback system as FB5992037.
Attachments
test case (209 bytes, text/html)
2024-09-01 21:45 PDT, Fujii Hironori
no flags
WIP patch (810 bytes, patch)
2024-09-01 21:45 PDT, Fujii Hironori
no flags
test of foreignObject (289 bytes, text/xml)
2024-09-02 00:44 PDT, Fujii Hironori
no flags
PerformanceTestsResults (Needs to adjust localPath) (8.20 MB, text/html)
2024-09-25 22:10 PDT, Fujii Hironori
no flags
Tom
Comment 1 2019-06-26 15:09:17 PDT
Note: I've seen this issue on Safari 11, 12 and the latest technology preview.
Radar WebKit Bug Importer
Comment 2 2019-07-01 11:19:31 PDT
Dean Jackson
Comment 3 2019-11-13 12:52:58 PST
It seems that RenderBox::computeReplacedLogicalHeightUsing gets a logical height that reflects the inherited font-size, not the one calculated after applying the page zoom.
Dean Jackson
Comment 4 2019-11-13 12:55:08 PST
StyleBoxData has different values for m_height in the element with font-size inherit vs nothing.
Dean Jackson
Comment 5 2019-11-13 13:13:57 PST
When we're calculating the font-size, we go through BuilderState::setFontSize, which looks at useSVGZoomRules() // SVG handles zooming in a different way compared to CSS. The whole document is scaled instead // of each individual length value in the render style / tree. CSSPrimitiveValue::computeLength*() // multiplies each resolved length with the zoom multiplier - so for SVG we need to disable that. // Though all CSS values that can be applied to outermost <svg> elements (width/height/border/padding...) // need to respect the scaling. RenderBox (the parent class of RenderSVGRoot) grabs values like // width/height/border/padding/... from the RenderStyle -> for SVG these values would never scale, // if we'd pass a 1.0 zoom factor everyhwere. So we only pass a zoom factor of 1.0 for specific // properties that are NOT allowed to scale within a zoomed SVG document (letter/word-spacing/font-size). bool BuilderState::useSVGZoomRules() const { return is<SVGElement>(element()); }
Tom
Comment 6 2020-06-28 10:46:39 PDT
Still happening in Safari 14...
decademoon.bugzilla
Comment 7 2023-04-22 20:04:34 PDT
This is still happening in Safari 16.4 A workaround is to wrap the <svg> in a <span> and apply the font-size style to the span and the width/height 1em style to the svg.
Fujii Hironori
Comment 8 2024-09-01 21:45:21 PDT
Created attachment 472399 [details] test case
Fujii Hironori
Comment 9 2024-09-01 21:45:34 PDT
Created attachment 472400 [details] WIP patch
Fujii Hironori
Comment 10 2024-09-01 22:14:48 PDT
Fujii Hironori
Comment 11 2024-09-02 00:44:46 PDT
Created attachment 472402 [details] test of foreignObject
Fujii Hironori
Comment 12 2024-09-25 22:10:24 PDT
Created attachment 472690 [details] PerformanceTestsResults (Needs to adjust localPath) This is a result of "run-perf-tests --release --repeat=3". base: daf9470 patched: 9294b29 There is no performance regressions.
EWS
Comment 13 2024-09-26 13:27:06 PDT
Committed 284310@main (4e612c4d529b): <https://commits.webkit.org/284310@main> Reviewed commits have been landed. Closing PR #33020 and removing active labels.
Fujii Hironori
Comment 14 2024-09-30 21:51:18 PDT
*** Bug 279041 has been marked as a duplicate of this bug. ***
WebKit Commit Bot
Comment 15 2024-12-03 12:28:56 PST
Re-opened since this is blocked by bug 283990
Tom
Comment 16 2025-02-14 15:42:50 PST
What's the status of this issue in terms of getting the fix shipped? Back in September it appears that the commit landed, but then December 3 it says it was re-opened due to 283990 blocked it, but that bug appears to be closed/resolved now, so what is holding this patch up? Thanks!
Fujii Hironori
Comment 17 2025-02-14 16:24:29 PST
Yes, 287302@main reverted the fix. No one is actively working on this bug.
Note You need to log in before you can comment on or make changes to this bug.