mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Expose the traversal kind to the style system.
This way we'll be able to take different paths for the sequential and parallel traversals in some concrete cases. This is a preliminar patch to fix bug 1332525.
This commit is contained in:
parent
7e2329ea4e
commit
f00b628c3a
7 changed files with 64 additions and 13 deletions
|
@ -62,6 +62,23 @@ impl LogBehavior {
|
|||
fn allow(&self) -> bool { matches!(*self, MayLog) }
|
||||
}
|
||||
|
||||
/// The kind of traversals we could perform.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub enum TraversalDriver {
|
||||
/// A potentially parallel traversal.
|
||||
Parallel,
|
||||
/// A sequential traversal.
|
||||
Sequential,
|
||||
}
|
||||
|
||||
impl TraversalDriver {
|
||||
/// Returns whether this represents a parallel traversal or not.
|
||||
#[inline]
|
||||
pub fn is_parallel(&self) -> bool {
|
||||
matches!(*self, TraversalDriver::Parallel)
|
||||
}
|
||||
}
|
||||
|
||||
/// A DOM Traversal trait, that is used to generically implement styling for
|
||||
/// Gecko and Servo.
|
||||
pub trait DomTraversal<E: TElement> : Sync {
|
||||
|
@ -284,6 +301,14 @@ pub trait DomTraversal<E: TElement> : Sync {
|
|||
|
||||
/// 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
|
||||
/// regard via the type system via a `TraversalDriver` trait for this trait,
|
||||
/// that could be one of two concrete types. It's not clear whether the
|
||||
/// potential code size impact of that is worth it.
|
||||
fn is_parallel(&self) -> bool;
|
||||
}
|
||||
|
||||
/// Helper for the function below.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue