script: Remove 'pending reflow' concept and some explicit reflows (#34558)

The `pending reflow` concept isn't necessary now that *update the
rendering* is taking care of triggering reflows at the correct time.
`Window::reflow` already avoids reflows if the page is not dirty, so
pending reflows is now just an extraneous check as long as *update the
rendering* runs properly.

This change also removes some explicit reflows, which now wait until the
appropriate moment during *update the rendering*. This should remove
some extra reflows that are not necessary.

Servo needs some way to track that resizing the web view needs to
re-layout due to the initial containing block changing. Move handling
of `Document::needs_paint` to the script thread and use this, expanding
the rustdoc to explain what it is for a bit more clearly.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2024-12-11 13:58:37 +01:00 committed by GitHub
parent bc741bdc0b
commit 3f85a27097
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 43 additions and 122 deletions

View file

@ -47,7 +47,7 @@ use profile_traits::time::{
self as profile_time, TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType,
};
use profile_traits::{path, time_profile};
use script::layout_dom::{ServoLayoutDocument, ServoLayoutElement, ServoLayoutNode};
use script::layout_dom::{ServoLayoutElement, ServoLayoutNode};
use script_layout_interface::{
Layout, LayoutConfig, LayoutFactory, NodesFromPointQueryType, OffsetParentResponse,
ReflowComplete, ReflowGoal, ScriptReflow, TrustedNodeAddress,
@ -899,7 +899,6 @@ impl LayoutThread {
self.perform_post_style_recalc_layout_passes(
root.clone(),
&data.reflow_goal,
Some(&document),
&mut layout_context,
);
}
@ -929,7 +928,6 @@ impl LayoutThread {
&self,
fragment_tree: Arc<FragmentTree>,
reflow_goal: &ReflowGoal,
document: Option<&ServoLayoutDocument>,
context: &mut LayoutContext,
) {
Self::cancel_animations_for_nodes_not_in_fragment_tree(
@ -944,20 +942,9 @@ impl LayoutThread {
}
if !reflow_goal.needs_display_list() {
// Defer the paint step until the next ForDisplay.
//
// We need to tell the document about this so it doesn't
// incorrectly suppress reflows. See #13131.
document
.expect("No document in a non-display reflow?")
.needs_paint_from_layout();
return;
}
if let Some(document) = document {
document.will_paint();
}
let mut epoch = self.epoch.get();
epoch.next();
self.epoch.set(epoch);