Skip to content

Improve transform tracking. - #1811

Merged
xStrom merged 1 commit into
linebender:mainfrom
xStrom:transform-refactor
Jun 2, 2026
Merged

xStrom merged 1 commit into
linebender:mainfrom
xStrom:transform-refactor

Conversation

@xStrom

@xStrom xStrom commented May 25, 2026 •

Copy link
Copy Markdown
Member

The old transform_changed was busted. It was internally documented as tracking transform and scroll_translation, but in practice it was also tracking origin, but then exposed in MutateCtx::transform_has_changed with the claim that it only tracks transform -- and then Xilem was using it with that assumption.

This PR cleans that up by removing MutateCtx::transform_has_changed and properly documenting transform_changed as tracking everything which affects the full transform that the compose pass calculates. Currently that is transform, scroll_translation, and origin.

What's more, the transform_changed flag isn't even merged up the tree, yet the compose pass checks it to decide whether to traverse into a branch. Thus, the compose pass was implicitly depending on unrelated code paths to set the needs_compose flag.

This PR sets the needs_compose flag explicitly, to ensure things remain working even when that flag isn't being set elsewhere.

The composing logic was duplicated in both the compose and accessibility passes. Yet it is critical for correct accessibility behavior for that to stay in sync with the compose results.

This PR introduces WidgetState::compose_local_transform as a helper method, which will calculate the correct local transform. This will help this logic stay in sync. This is especially relevant as the logic gets more fragile, i.e. with the pixel snapping of #1803.

Finally, this PR adds a new test which makes sure that scroll translation doesn't trigger a layout, is respected by hit testing, and that the regular and accessibility bounds are the same.

@xStrom xStrom added masonry Issues relating to the Masonry widget layer needs review Needs review before proceeding. labels May 25, 2026
@PoignardAzur

Copy link
Copy Markdown
Collaborator

I'm not certain about this PR. It seems to add complexity (you now have to remember the difference between mark_compose_transform_changed and mark_transform_changed) to Masonry for the sake of papering over one of Xilem's idiosyncrasies.

Could we instead use something like ViewCtx::prop_has_changed

let prop_has_changed = ctx.prop_has_changed::<P>(element.id());

and remove MutateCtx::transform_changed entirely?

@xStrom

xStrom commented May 29, 2026

Copy link
Copy Markdown
Member Author

Yes, it's significant complexity cost for a minor Xilem quirk. I created #1820 which moves the tracking to Xilem and would allow us to greatly reduce the complexity of Masonry's tracking.

@xStrom xStrom added blocked Progress is blocked by some other task. and removed needs review Needs review before proceeding. labels May 29, 2026
@PoignardAzur

Copy link
Copy Markdown
Collaborator

Should we close this, then?

@xStrom
xStrom force-pushed the transform-refactor branch from fab2ab8 to 8dbf0b4 Compare May 30, 2026 16:05
@xStrom
xStrom force-pushed the transform-refactor branch from f262be0 to e6d5e15 Compare May 30, 2026 16:12
@xStrom xStrom added needs review Needs review before proceeding. and removed blocked Progress is blocked by some other task. labels May 30, 2026
@xStrom

xStrom commented May 30, 2026

Copy link
Copy Markdown
Member Author

No, this PR is still valid. It is now simplified and no longer splits the transform dirty tracking.

@PoignardAzur PoignardAzur left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment on lines +125 to +131
assert!(
!records.iter().any(|record| matches!(
record,
Record::PointerEvent(_) | Record::Update(Update::HoveredChanged(true))
)),
"pointer should not reach the child before scroll translation"
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like assert_all would give more info in case of an error.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, but it requires a new dependency, right? Doesn't seem important enough to add a whole new dep.

@PoignardAzur PoignardAzur Jun 3, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean the helper function we define in masonry_testing.

@xStrom xStrom removed the needs review Needs review before proceeding. label Jun 2, 2026
@xStrom
xStrom added this pull request to the merge queue Jun 2, 2026
Merged via the queue into linebender:main with commit 5d72ad4 Jun 2, 2026
31 of 34 checks passed
@xStrom
xStrom deleted the transform-refactor branch June 2, 2026 07:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

masonry Issues relating to the Masonry widget layer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants