Skip to content

script: Always dirty nodes when changing node state#39102

Merged
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:hover-state-should-dirty-node
Sep 3, 2025
Merged

script: Always dirty nodes when changing node state#39102
mrobinson merged 1 commit intoservo:mainfrom
mrobinson:hover-state-should-dirty-node

Conversation

@mrobinson
Copy link
Copy Markdown
Member

With incremental layout adding a restyle to a node isn't enough to force
its layout to update. We also need to explicitly mark the node as dirty
so that its contents are updated when layout is run. This change makes
this consistent for all node state changes. This might be a bit too
conservative as all node state may not affect layout, but should catch
issues in the future.

Testing: This is very hard to test as it requires moving the mouse over the
WebView, and the moving it away, and then testing the rendered contents. This
kind of coordination would be difficult to manage with unit tests.
Fixes: #38989.

With incremental layout adding a restyle to a node isn't enough to force
its layout to update. We also need to explicitly mark the node as dirty
so that its contents are updated when layout is run. This change makes
this consistent for all node state changes. This might be a bit too
conservative as all node state may not affect layout, but should catch
issues in the future.

Signed-off-by: Martin Robinson <[email protected]>
@mrobinson mrobinson requested a review from gterzian as a code owner September 3, 2025 07:07
@mrobinson mrobinson added this pull request to the merge queue Sep 3, 2025
Merged via the queue into servo:main with commit 6b20812 Sep 3, 2025
22 checks passed
@mrobinson mrobinson deleted the hover-state-should-dirty-node branch September 3, 2025 09:48
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Nov 26, 2025
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in servo#39102 in order to fix servo#38989, but it's no longer
needed.

Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Nov 28, 2025
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in servo#39102 in order to fix servo#38989, but it's no longer
needed.

Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Nov 28, 2025
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in servo#39102 in order to fix servo#38989, but it's no longer
needed.

Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Nov 28, 2025
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in servo#39102 in order to fix servo#38989, but it's no longer
needed.

Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Dec 1, 2025
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in servo#39102 in order to fix servo#38989, but it's no longer
needed.

Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Dec 1, 2025
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in servo#39102 in order to fix servo#38989, but it's no longer
needed.

Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Dec 1, 2025
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in servo#39102 in order to fix servo#38989, but it's no longer
needed.

Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
Loirooriol added a commit to Loirooriol/servo that referenced this pull request Dec 2, 2025
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in servo#39102 in order to fix servo#38989, but it's no longer
needed.

Co-authored-by: Martin Robinson <[email protected]>
Signed-off-by: Oriol Brufau <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request Dec 2, 2025
…#40902)

When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in #39102 in order to fix #38989, but for the most part
it's no longer needed.

However, we will now dirty when a `<textarea>` or `<input>` which can be
selected gets or loses focus. This is to ensure that the caret or
selections get correctly updated.

Testing: Manually tested that #38989 is not regressing

Signed-off-by: Oriol Brufau <[email protected]>
Co-authored-by: Martin Robinson <[email protected]>
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.

Element hover state no longer cleared correctly on cursor left

2 participants