WebKit icon indicating copy to clipboard operation
WebKit copied to clipboard

Account for zoom when computing SVG font size

Open Ahmad-S792 opened this issue 2 years ago โ€ข 17 comments

Account for zoom when computing SVG font size

https://bugs.webkit.org/show_bug.cgi?id=118818

Reviewed by NOBODY (OOPS!).

Merge - https://chromium.googlesource.com/chromium/blink/+/5624c6e475af92d541edc8a3394602e320d00323 & https://src.chromium.org/viewvc/blink?view=revision&revision=180995

Previously, text that was zoomed appeared larger than geometry under the same zoom value. This was caused by two bugs:
1) When setting the computed font size, we incorrectly referenced the computedTextSize instead of the specified size.
2) Text with GeometricPrecision did not set a computed size but instead relied on the text size being correct.

Further, it also fixes an issue about optimization in RenderSVGInlineText::computeNewScaledFontForStyle would skip updating the font size on lowdpi devices while zooming. The computed font size calculation depends on zoom and the font scaling factor depends on the device's scaling factor. Previously, we would skip updating the font when the scaling factor was 1 which would fail to account for zoom. This patch updates the optimization to only be used when both the scaling factor and zoom are 1.

This change addresses both of these issues and adds a test to prove correctness.

* Source/WebCore/rendering/svg/RenderSVGInlineText.cpp:
(RenderSVGInlineText::computedNewScaledFontForStyle) - Updated Scaling factor to be accounted into two buckets: 1) GeometricPrecision 2) computedTextSize being referred 3) Use DoNotUseSmartMinimumForFontSize 4) Also fix low DPI issue
* LayoutTests/svg/zoom/text/zoom-text-geometry.html: Added Test Case
* LayoutTests/svg/zoom/text/zoom-text-geometry-expected.html: Added Test Case Expectations
* LayoutTests/svg/zoom/text/lowdpi-zoom-text.html: Added Test Case
* LayoutTests/svg/texst/lowdpi-zoom-text-expected.txt: Added Test Case Expectations

https://github.com/WebKit/WebKit/commit/2dbdf5c9a40dde630ab89f1654f351af86bfdbc0

Misc iOS, tvOS & watchOS macOS Linux Windows
โœ… ๐Ÿงช style โœ… ๐Ÿ›  ios โœ… ๐Ÿ›  mac โœ… ๐Ÿ›  wpe โŒ ๐Ÿ›  ๐Ÿงช win
โœ… ๐Ÿงช bindings โœ… ๐Ÿ›  ios-sim โœ… ๐Ÿ›  mac-debug โœ… ๐Ÿ›  gtk โœ… ๐Ÿ›  wincairo
โœ… ๐Ÿงช webkitperl โœ… ๐Ÿงช ios-wk2 โœ… ๐Ÿ›  mac-AS-debug โœ… ๐Ÿงช gtk-wk2
โœ… ๐Ÿงช api-ios โœ… ๐Ÿงช api-mac โœ… ๐Ÿงช api-gtk
โœ… ๐Ÿ›  tv โŒ ๐Ÿงช mac-wk1
โœ… ๐Ÿ›  tv-sim โŒ ๐Ÿงช mac-wk2
โœ… ๐Ÿ›  watch โŒ ๐Ÿงช mac-AS-debug-wk2
โœ… ๐Ÿ›  watch-sim โœ… ๐Ÿงช mac-wk2-stress

Ahmad-S792 avatar Sep 04 '22 21:09 Ahmad-S792

@smfr & @nikolaszimmermann - Can you guide or suggest on how to fix this 'ios-wk2' failure (svg/text/font-small-enlarged-minimum-larger.svg)?

Ahmad-S792 avatar Sep 09 '22 08:09 Ahmad-S792

Sorry for not responding at all - I'm pretty busy these days...

nikolaszimmermann avatar Sep 16 '22 19:09 nikolaszimmermann

Thanks for tackling this -- not ready though, the LayoutTests changes seem fishy.

Replied above and would appreciate your guidance because I am able to pass all changes by adding 'font-size: 80' but only fails in iOS-wk2 and have asked for input from Simon and he referred that it might be iOS device scaling factor and I should look into hidpi test cases.

Ahmad-S792 avatar Sep 17 '22 07:09 Ahmad-S792

That looks good - let's wait for EWS results. If ok, I'll r+ it. Thanks @Ahmad-S792 for your patience.

No worries - I should appreciate you to deal with noob like me. :-)

I am just learning day by day and have day job so some time response take some time. :-)

Ahmad-S792 avatar Sep 21 '22 19:09 Ahmad-S792

As discussed with @nikolaszimmermann over Slack, there is another change, which we require prior to landing this. So I will work on it and then have similar to this another PR to land this in future hoping that EWS does not reflect same failures.

Ahmad-S792 avatar Oct 17 '22 08:10 Ahmad-S792