Skip to content

fix: scale CSS transform translate by viewport scale factor - #622

Closed
jerry4718 wants to merge 1 commit into
DioxusLabs:mainfrom
jerry4718:fix/transform-viewport-scale
Closed

fix: scale CSS transform translate by viewport scale factor#622
jerry4718 wants to merge 1 commit into
DioxusLabs:mainfrom
jerry4718:fix/transform-viewport-scale

Conversation

@jerry4718

@jerry4718 jerry4718 commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

CSS transform values (translate, transform-origin) are in CSS pixels and must be multiplied by the viewport scale factor (hidpi_scale * zoom) when rendering to device pixels. Previously only layout positions were scaled while transform matrices were not, causing misalignment between layout coordinates and transformed elements on hidpi screens.

Pass the viewport scale into resolve_2d_transform and multiply the translation components (translate property, transform function m41/m42, and transform-origin) by it. Scale factors and rotation angles are unitless and remain unchanged.

Test: transform_viewport_scale.rs verifies translate is scaled at hidpi_scale=2 while scale(0.5) is not.

WPT results

No changes in test results compared to main.

Generated by the WPT workflow.

CSS transform values (translate, transform-origin) are in CSS pixels and
must be multiplied by the viewport scale factor (hidpi_scale * zoom) when
rendering to device pixels. Previously only layout positions were scaled
while transform matrices were not, causing misalignment between layout
coordinates and transformed elements on hidpi screens.

Pass the viewport scale into resolve_2d_transform and multiply the
translation components (translate property, transform function m41/m42,
and transform-origin) by it. Scale factors and rotation angles are
unitless and remain unchanged.

Test: transform_viewport_scale.rs verifies translate is scaled at
hidpi_scale=2 while scale(0.5) is not.
@nicoburns

Copy link
Copy Markdown
Member

Thanks for the PR. AI review found issues with it, and generated #623 as an alternative which should fix your issues without introducing regressions. I've merged that instead.

@nicoburns nicoburns closed this Aug 7, 2026
@jerry4718
jerry4718 deleted the fix/transform-viewport-scale branch August 8, 2026 08:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants