mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Rip out the generic abstractions around ThreadLocalStyleContext.
MozReview-Commit-ID: 5WTLuk323Ac
This commit is contained in:
parent
296a215e54
commit
3330653dc8
7 changed files with 52 additions and 102 deletions
|
@ -5,7 +5,7 @@
|
|||
//! Traversing the DOM tree; the bloom filter.
|
||||
|
||||
use atomic_refcell::AtomicRefCell;
|
||||
use context::{ElementCascadeInputs, StyleContext, SharedStyleContext, ThreadLocalStyleContext};
|
||||
use context::{ElementCascadeInputs, StyleContext, SharedStyleContext};
|
||||
use data::{ElementData, ElementStyles};
|
||||
use dom::{DirtyDescendants, NodeInfo, OpaqueNode, TElement, TNode};
|
||||
use invalidation::element::restyle_hints::{RECASCADE_SELF, RECASCADE_DESCENDANTS, RestyleHint};
|
||||
|
@ -13,7 +13,6 @@ use matching::{ChildCascadeRequirement, MatchMethods};
|
|||
use sharing::{StyleSharingBehavior, StyleSharingTarget};
|
||||
#[cfg(feature = "servo")] use servo_config::opts;
|
||||
use smallvec::SmallVec;
|
||||
use std::borrow::BorrowMut;
|
||||
|
||||
/// A per-traversal-level chunk of data. This is sent down by the traversal, and
|
||||
/// currently only holds the dom depth for the bloom filter.
|
||||
|
@ -138,22 +137,17 @@ fn is_servo_nonincremental_layout() -> bool {
|
|||
/// A DOM Traversal trait, that is used to generically implement styling for
|
||||
/// Gecko and Servo.
|
||||
pub trait DomTraversal<E: TElement> : Sync {
|
||||
/// The thread-local context, used to store non-thread-safe stuff that needs
|
||||
/// to be used in the traversal, and of which we use one per worker, like
|
||||
/// the bloom filter, for example.
|
||||
type ThreadLocalContext: Send + BorrowMut<ThreadLocalStyleContext<E>>;
|
||||
|
||||
/// Process `node` on the way down, before its children have been processed.
|
||||
fn process_preorder(&self,
|
||||
data: &PerLevelTraversalData,
|
||||
thread_local: &mut Self::ThreadLocalContext,
|
||||
context: &mut StyleContext<E>,
|
||||
node: E::ConcreteNode);
|
||||
|
||||
/// Process `node` on the way up, after its children have been processed.
|
||||
///
|
||||
/// This is only executed if `needs_postorder_traversal` returns true.
|
||||
fn process_postorder(&self,
|
||||
thread_local: &mut Self::ThreadLocalContext,
|
||||
contect: &mut StyleContext<E>,
|
||||
node: E::ConcreteNode);
|
||||
|
||||
/// Boolean that specifies whether a bottom up traversal should be
|
||||
|
@ -177,7 +171,7 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
/// call durign the parallel traversal.
|
||||
fn handle_postorder_traversal(
|
||||
&self,
|
||||
thread_local: &mut Self::ThreadLocalContext,
|
||||
context: &mut StyleContext<E>,
|
||||
root: OpaqueNode,
|
||||
mut node: E::ConcreteNode,
|
||||
children_to_process: isize
|
||||
|
@ -190,7 +184,7 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
if children_to_process == 0 {
|
||||
// We are a leaf. Walk up the chain.
|
||||
loop {
|
||||
self.process_postorder(thread_local, node);
|
||||
self.process_postorder(context, node);
|
||||
if node.opaque() == root {
|
||||
break;
|
||||
}
|
||||
|
@ -404,7 +398,7 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
/// a parameter to keep the logs tidy.
|
||||
fn should_traverse_children(
|
||||
&self,
|
||||
thread_local: &mut ThreadLocalStyleContext<E>,
|
||||
context: &mut StyleContext<E>,
|
||||
parent: E,
|
||||
parent_data: &ElementData,
|
||||
log: LogBehavior
|
||||
|
@ -442,7 +436,7 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
// happens, we may just end up doing wasted work, since Gecko
|
||||
// recursively drops Servo ElementData when the XBL insertion parent of
|
||||
// an Element is changed.
|
||||
if cfg!(feature = "gecko") && thread_local.is_initial_style() &&
|
||||
if cfg!(feature = "gecko") && context.thread_local.is_initial_style() &&
|
||||
parent_data.styles.primary().has_moz_binding() {
|
||||
if log.allow() {
|
||||
debug!("Parent {:?} has XBL binding, deferring traversal",
|
||||
|
@ -458,23 +452,23 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
/// should be enqueued for processing.
|
||||
fn traverse_children<F>(
|
||||
&self,
|
||||
thread_local: &mut Self::ThreadLocalContext,
|
||||
context: &mut StyleContext<E>,
|
||||
parent: E,
|
||||
mut f: F
|
||||
)
|
||||
where
|
||||
F: FnMut(&mut Self::ThreadLocalContext, E::ConcreteNode)
|
||||
F: FnMut(&mut StyleContext<E>, E::ConcreteNode)
|
||||
{
|
||||
// Check if we're allowed to traverse past this element.
|
||||
let should_traverse =
|
||||
self.should_traverse_children(
|
||||
thread_local.borrow_mut(),
|
||||
context,
|
||||
parent,
|
||||
&parent.borrow_data().unwrap(),
|
||||
MayLog
|
||||
);
|
||||
|
||||
thread_local.borrow_mut().end_element(parent);
|
||||
context.thread_local.end_element(parent);
|
||||
if !should_traverse {
|
||||
return;
|
||||
}
|
||||
|
@ -495,7 +489,7 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
}
|
||||
}
|
||||
}
|
||||
f(thread_local, kid);
|
||||
f(context, kid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -517,9 +511,6 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
/// Return the shared style context common to all worker threads.
|
||||
fn shared_context(&self) -> &SharedStyleContext;
|
||||
|
||||
/// Creates a thread-local context.
|
||||
fn create_thread_local_context(&self) -> Self::ThreadLocalContext;
|
||||
|
||||
/// Whether we're performing a parallel traversal.
|
||||
///
|
||||
/// NB: We do this check on runtime. We could guarantee correctness in this
|
||||
|
@ -763,7 +754,7 @@ where
|
|||
// Preprocess children, propagating restyle hints and handling sibling
|
||||
// relationships.
|
||||
let should_traverse_children = traversal.should_traverse_children(
|
||||
&mut context.thread_local,
|
||||
context,
|
||||
element,
|
||||
&data,
|
||||
DontLog
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue