Skip to content

script: Make iframe resizes immediately observable in child. - #46587

Merged
jschwe merged 2 commits into
servo:mainfrom
jschwe:issue-45888-iframe-resize
Jul 18, 2026
Merged

jschwe merged 2 commits into
servo:mainfrom
jschwe:issue-45888-iframe-resize

Conversation

@jschwe

@jschwe jschwe commented Jul 17, 2026 •

Copy link
Copy Markdown
Member

When an iframe is resized, the new size should be
observable immediately, but before this commit observability was delayed.

To fix this add_resize_event now immediately applies the new viewport size. The resize event itself is processed as before during "run the resize steps".

Layout queries flush the layout of parents, if it is out of date,
this is however a best effort approach (as in other engines too). If we can't flush parents layout synchronously, then we accept potentially outdated sizes.

The viewport size can now be updated many times between reflows, hence we move dirty_all_nodes to the reflow restyle phase, since dirtying everything synchronously would probably be bad for performance. The new location should be equivalent, since it's the only consumer.

Testing: Many new wpt-tests pass, element-ready-check-containing-iframe.html changes from FAIL to timeout. mach try
Fixes: #45888

@jschwe jschwe changed the title script: Make iframe resizes immediatly observable in child. script: Make iframe resizes immediately observable in child. Jul 17, 2026
@jschwe
jschwe force-pushed the issue-45888-iframe-resize branch from c7233ab to f5db44c Compare July 17, 2026 11:49
When an iframe is resized, the new size should be
observable immediatly, but before this commit observability
was delayed.

To fix this `add_resize_event` now immediatly applies the new
viewport size. The resize event itself is processed as before
during "run the resize steps".
This is however a best effort approach (as in other engines too).
If we can't flush parents layout synchronously, then we accept
potentially outdated sizes.

Layout queries flush the layout of parents, if it is out of
date

The viewport size can now be updated many times between reflows,
we move the `dirty_all_nodes` to the reflow restyle phase, since
dirtying everything synchronously would probably be bad for performance.
The new location should be equivalent, since it's the only consumer.

Signed-off-by: Jonathan Schwender <[email protected]>
@jschwe
jschwe force-pushed the issue-45888-iframe-resize branch from f5db44c to c8ee6a3 Compare July 17, 2026 12:28
@jschwe
jschwe marked this pull request as ready for review July 17, 2026 12:49
@jschwe
jschwe requested a review from gterzian as a code owner July 17, 2026 12:49
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 17, 2026

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very nice! I'd like to file a followup issue on removing the early return, because a situation where parent layouts are unsafe but child layouts are safe sounds wrong to me.

Comment thread components/script/dom/window/window.rs Resolved
Comment on lines +2879 to +2880
// If we can't run layout we need to abort, otherwise we'd run into the same check but as an assert
// later.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm interested in understanding when this happens. Do you have testcases that trigger this assertion?

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.

It triggered crashes in a couple wpt tests. One of them was dom/nodes/Node-isConnected.html

Comment thread components/script/dom/window/window.rs Resolved
@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Jul 17, 2026
Co-authored-by: Josh Matthews <[email protected]>
Signed-off-by: Jonathan Schwender <[email protected]>
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Jul 17, 2026
@jschwe
jschwe added this pull request to the merge queue Jul 18, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 18, 2026
Merged via the queue into servo:main with commit af8c181 Jul 18, 2026
34 checks passed
@jschwe
jschwe deleted the issue-45888-iframe-resize branch July 18, 2026 15:04
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Jul 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale size evaluation of child iframe

3 participants