Scale CSS transform translation by viewport scale without double-scaling percentages - #623
Conversation
…le-scaling percentages
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Tested hidpi transform rendering headlessly at the rendered-pixel level (CPU image renderer, no window). A test page with 100×100 boxes using Result: all boxes' rendered bboxes at scale 2 are exactly 2× their scale-1 bboxes (0px error). Percentage translates and the default
Measured bounding boxes (device px)
The transformed red box's scale-2 x-range (240–440) coincides exactly with the untransformed cyan control laid out at the same CSS x-coords, confirming transforms track layout.
|
Summary
Fixes absolute-length transform translations being unscaled at hidpi (e.g.
translate(100px)athidpi_scale=2moved only 100 device px = 50 CSS px), without introducing the percentage double-scaling that #622 does.The stored
node.transform()is treated as a device-pixel-space matrix everywhere (hit testing inverts it on device-px points;blitz-paintcomposes it afterbox_position * scale). Previouslyset_transformpassed a reference box already scaled to device px, which made percentage translates/origins resolve correctly but left absolute lengths unscaled.The fix resolves the transform entirely in CSS pixels (unscaled reference box), then conjugates it into device space —
S · T · S⁻¹— which scales only the translation components:resolve_2d_transformitself is unchanged and stays pure CSS-px (ascaleparam was previously removed in 0e359fe because in-function scaling caused exactly this class of double-scaling bug).Alternative to #622, which multiplies by
scaleafter resolving percentages against the already-scaled reference box, double-scalingtranslate: 50%,translate(50%, 50%), and the defaulttransform-origin: 50% 50%(displacing every rotate/scale transform at hidpi).Tests (
transform_viewport_scale.rs) cover px and percentage translates (property and function forms), unitless scale factors, and default/absolute transform-origins at scale 1 and 2.Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/1d6103743b204723b3b711924b665735
Requested by: @nicoburns
WPT results
No changes in test results compared to
main.Generated by the WPT workflow.