mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Make Restyle tracking more granular.
The primary idea of this patch is to ditch the rigid enum of Previous/Current styles, and replace it with a series of indicators for the various types of work that needs to be performed (expanding snapshots, rematching, recascading, and damage processing). This loses us a little bit of sanity checking (since the up-to-date-ness of our style is no longer baked into the type system), but gives us a lot more flexibility that we'll need going forward (especially when we separate matching from cascading). We also eliminate get_styling_mode in favor of a method on the traversal. This patch does a few other things as ridealongs: * Temporarily eliminates the handling for transfering ownership of styles to the frame. We'll need this again at some point, but for now it's causing too much complexity for a half-implemented feature. * Ditches TRestyleDamage, which is no longer necessary post-crate-merge, and is a constant source of compilation failures from either needing to be imported or being unnecessarily imported (which varies between gecko and servo). * Expands Snapshots for the traversal root, which was missing before. * Fixes up the skip_root stuff to avoid visiting the skipped root. * Unifies parallel traversal and avoids spawning for a single work item. * Adds an explicit pre_traverse step do any pre-processing and determine whether we need to traverse at all. MozReview-Commit-ID: IKhLAkAigXE
This commit is contained in:
parent
4cb3404c09
commit
80460cc549
27 changed files with 502 additions and 474 deletions
|
@ -106,7 +106,7 @@ use std::sync::mpsc::{Receiver, Sender, channel};
|
|||
use style::animation::Animation;
|
||||
use style::context::{LocalStyleContextCreationInfo, ReflowGoal, SharedStyleContext};
|
||||
use style::data::StoredRestyleHint;
|
||||
use style::dom::{StylingMode, TElement, TNode};
|
||||
use style::dom::{TElement, TNode};
|
||||
use style::error_reporting::{ParseErrorReporter, StdoutErrorReporter};
|
||||
use style::logical_geometry::LogicalPoint;
|
||||
use style::media_queries::{Device, MediaType};
|
||||
|
@ -116,6 +116,7 @@ use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
|
|||
use style::stylist::Stylist;
|
||||
use style::thread_state;
|
||||
use style::timer::Timer;
|
||||
use style::traversal::DomTraversalContext;
|
||||
use util::geometry::max_rect;
|
||||
use util::opts;
|
||||
use util::prefs::PREFS;
|
||||
|
@ -1122,7 +1123,7 @@ impl LayoutThread {
|
|||
None => continue,
|
||||
};
|
||||
let mut style_data = &mut data.base.style_data;
|
||||
debug_assert!(!style_data.is_restyle());
|
||||
debug_assert!(style_data.has_current_styles());
|
||||
let mut restyle_data = match style_data.restyle() {
|
||||
Some(d) => d,
|
||||
None => continue,
|
||||
|
@ -1131,7 +1132,9 @@ impl LayoutThread {
|
|||
// Stash the data on the element for processing by the style system.
|
||||
restyle_data.hint = restyle.hint.into();
|
||||
restyle_data.damage = restyle.damage;
|
||||
restyle_data.snapshot = restyle.snapshot;
|
||||
if let Some(s) = restyle.snapshot {
|
||||
restyle_data.snapshot.ensure(move || s);
|
||||
}
|
||||
debug!("Noting restyle for {:?}: {:?}", el, restyle_data);
|
||||
}
|
||||
}
|
||||
|
@ -1142,7 +1145,9 @@ impl LayoutThread {
|
|||
data.reflow_info.goal);
|
||||
|
||||
let dom_depth = Some(0); // This is always the root node.
|
||||
if element.styling_mode() != StylingMode::Stop {
|
||||
let token = <RecalcStyleAndConstructFlows as DomTraversalContext<ServoLayoutNode>>
|
||||
::pre_traverse(element, &shared_layout_context.style_context.stylist, /* skip_root = */ false);
|
||||
if token.should_traverse() {
|
||||
// Recalculate CSS styles and rebuild flows and fragments.
|
||||
profile(time::ProfilerCategory::LayoutStyleRecalc,
|
||||
self.profiler_metadata(),
|
||||
|
@ -1152,11 +1157,11 @@ impl LayoutThread {
|
|||
if let (true, Some(traversal)) = (self.parallel_flag, self.parallel_traversal.as_mut()) {
|
||||
// Parallel mode
|
||||
parallel::traverse_dom::<ServoLayoutNode, RecalcStyleAndConstructFlows>(
|
||||
element.as_node(), dom_depth, &shared_layout_context, traversal);
|
||||
element, dom_depth, &shared_layout_context, token, traversal);
|
||||
} else {
|
||||
// Sequential mode
|
||||
sequential::traverse_dom::<ServoLayoutNode, RecalcStyleAndConstructFlows>(
|
||||
element.as_node(), &shared_layout_context);
|
||||
element, &shared_layout_context, token);
|
||||
}
|
||||
});
|
||||
// TODO(pcwalton): Measure energy usage of text shaping, perhaps?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue