[zoom] Adjust line-height and width when the effective zoom changes
Based on CL:53027603 by chrishtr@. In Blink, lengths are stored on the ComputedStyle with "premultiplied zoom", meaning that for e.g. width:20px;zoom:200%, the width is stored as "40". Currently, we do not account for this during inheritance: we inherit that "40" as-is, even if the effective zoom of the element we're inheriting into is not the same. Issue 9397 [1] clarified that this is not correct, and therefore we need to adjust our zoomed values when inheriting. This CL solves this problem by using our existing code paths for creating the computed CSSValue (which already does unzooming) and for applying that CSSValue onto a ComputedStyle (which already does zooming). We need two things for this to work: 1. Special behavior in Longhand::ApplyInherit, which detects if the effective zoom changed, and if so, inherits via the computed CSSValue path instead of the regular ComputedStyle-to-ComputedStyle path. However, Longhand::ApplyInherit is only reached if an explicit inherit/unset exists in the cascade, but we also need to make the adjustment for *inherited* properties (e.g. line-height). Therefore: 2. During cascade expansion, if the effective zoom changes vs. the parent zoom, we insert explicit 'unset' values at the bottom of the cascade. This ensures that we always reach ApplyInherit for affected properties. This CL only enables the zoom adjustment for one inherited property (line-height), and one non-inherited property (width) to establish the pattern. Future CLs will incrementally add the 'affected_by_zoom' flag to the relevant properties. Bug: 40946858 [1] https://github.com/w3c/csswg-drafts/issues/9397 Change-Id: Iab4dd978143e56264a5c78377055ecbb0363b276 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5323090 Commit-Queue: Chris Harrelson <chrishtr@chromium.org> Reviewed-by:Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1267277}
Loading
Please register or sign in to comment