mirror of
https://github.com/servo/servo.git
synced 2025-07-06 06:53:38 +01:00
script|layout: Do not force restyle when doing script queries (#37677)
Instead of doing a restyle whenever layout is requested, only do one if script believes that the `Document` has changed in a way that needs a restyle. In addition, track the different reasons this might be the case. This will be used later to provide better debugging output. In layout, when a restyle isn't requested, provide: - an early return if layout is up-to-date enough for the reflow goal. - skipping restyle and reflow if it isn't necessary. Testing: This should not change observable behavior, and thus is covered by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
f9880637e9
commit
3e1cdacd07
8 changed files with 168 additions and 127 deletions
|
@ -68,7 +68,7 @@ use js::jsapi::{
|
|||
};
|
||||
use js::jsval::UndefinedValue;
|
||||
use js::rust::ParentRuntime;
|
||||
use layout_api::{LayoutConfig, LayoutFactory, ScriptThreadFactory};
|
||||
use layout_api::{LayoutConfig, LayoutFactory, RestyleReason, ScriptThreadFactory};
|
||||
use media::WindowGLContext;
|
||||
use metrics::MAX_TASK_NS;
|
||||
use net_traits::image_cache::{ImageCache, ImageCacheResponseMessage};
|
||||
|
@ -1374,7 +1374,7 @@ impl ScriptThread {
|
|||
let Some((_, document)) = self.documents.borrow().iter().find(|(_, document)| {
|
||||
document.is_fully_active() &&
|
||||
!document.window().layout_blocked() &&
|
||||
document.needs_reflow().is_some()
|
||||
!document.restyle_reason().is_empty()
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
|
@ -3132,7 +3132,7 @@ impl ScriptThread {
|
|||
/// page no longer exists.
|
||||
fn handle_worklet_loaded(&self, pipeline_id: PipelineId) {
|
||||
if let Some(document) = self.documents.borrow().find_document(pipeline_id) {
|
||||
document.set_needs_paint(true)
|
||||
document.add_restyle_reason(RestyleReason::PaintWorkletLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue