mirror of
https://github.com/servo/servo.git
synced 2025-06-13 02:44:29 +00:00
script: No longer do explicit reflows for display (#34599)
These all happen now in *update the rendering*, typically after the message that triggered this code is processed, though in two cases reflow needs to be triggered explicitly. This makes `ReflowReason` redundant though perhaps `ReflowCondition` can be expanded later to give more insight into why the page is dirty. - Handling of the "reflow timer" concept has been explained a bit more via data structures and rustdoc comments. - Theme changes are cleaned up a little to simplify what happens during reflow and to avoid unecessary reflows when the theme doesn't change. Notably, layout queries and scrolling still trigger normal reflows and don't update the rendering. This needs more investigation as it's unclear to me currently whether or not they should update the rendering and simply delay event dispatch or only reflow. In general, this is a simplfication of the code. Fixes #31871. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
682eba9f74
commit
471d3572b7
9 changed files with 179 additions and 191 deletions
|
@ -137,7 +137,7 @@ use crate::dom::serviceworker::TrustedServiceWorkerAddress;
|
|||
use crate::dom::servoparser::{ParserContext, ServoParser};
|
||||
#[cfg(feature = "webgpu")]
|
||||
use crate::dom::webgpu::identityhub::IdentityHub;
|
||||
use crate::dom::window::{ReflowReason, Window};
|
||||
use crate::dom::window::Window;
|
||||
use crate::dom::windowproxy::{CreatorBrowsingContextInfo, WindowProxy};
|
||||
use crate::dom::worker::TrustedWorkerAddress;
|
||||
use crate::dom::worklet::WorkletThreadPool;
|
||||
|
@ -1625,7 +1625,7 @@ impl ScriptThread {
|
|||
// > doc and its node navigable to reflect the current state.
|
||||
let window = document.window();
|
||||
if document.is_fully_active() {
|
||||
window.reflow(ReflowGoal::Full, ReflowReason::UpdateTheRendering, can_gc);
|
||||
window.reflow(ReflowGoal::UpdateTheRendering, can_gc);
|
||||
}
|
||||
|
||||
// TODO: Process top layer removals according to
|
||||
|
@ -1660,7 +1660,7 @@ impl ScriptThread {
|
|||
}
|
||||
|
||||
let Some((_, document)) = self.documents.borrow().iter().find(|(_, document)| {
|
||||
!document.window().reflows_suppressed() && document.needs_reflow().is_some()
|
||||
!document.window().layout_blocked() && document.needs_reflow().is_some()
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
|
@ -2254,7 +2254,7 @@ impl ScriptThread {
|
|||
self.handle_resize_inactive_msg(id, new_size)
|
||||
},
|
||||
ConstellationControlMsg::ThemeChange(_, theme) => {
|
||||
self.handle_theme_change(theme);
|
||||
self.handle_theme_change_msg(theme);
|
||||
},
|
||||
ConstellationControlMsg::GetTitle(pipeline_id) => {
|
||||
self.handle_get_title_msg(pipeline_id)
|
||||
|
@ -2846,12 +2846,10 @@ impl ScriptThread {
|
|||
})
|
||||
}
|
||||
|
||||
fn handle_theme_change(&self, theme: Theme) {
|
||||
let docs = self.documents.borrow();
|
||||
for (_, document) in docs.iter() {
|
||||
let window = document.window();
|
||||
window.set_theme(theme);
|
||||
window.force_reflow(ReflowGoal::Full, ReflowReason::ThemeChange, None);
|
||||
/// Handle changes to the theme, triggering reflow if the theme actually changed.
|
||||
fn handle_theme_change_msg(&self, theme: Theme) {
|
||||
for (_, document) in self.documents.borrow().iter() {
|
||||
document.window().handle_theme_change(theme);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2972,7 +2970,7 @@ impl ScriptThread {
|
|||
);
|
||||
let document = self.documents.borrow().find_document(id);
|
||||
if let Some(document) = document {
|
||||
document.set_activity(activity, CanGc::note());
|
||||
document.set_activity(activity);
|
||||
return;
|
||||
}
|
||||
let mut loads = self.incomplete_loads.borrow_mut();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue