mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Introduce and use Scoped TLS.
It turns out that it's problematic to embed ThreadLocalStyleContext within LayoutContext, because parameterizing the former on TElement (which we do in the next patch) infects all the traversal stuff with the trait parameters, which we don't really want. In general, it probably makes sense to use separate scoped TLS types for the separate DOM and Flow tree passes, so we can add a different ScopedTLS type for the Flow pass if we ever need it. We also reorder the |scope| and |shared| parameters in parallel.rs, because it aligns more with the order in style/parallel.rs. I did this when I was adding a TLS parameter to all these functions, which I realized we don't need for now.
This commit is contained in:
parent
8f7f62f810
commit
c5f01fe3b8
16 changed files with 212 additions and 205 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
use atomic_refcell::{AtomicRefCell, AtomicRefMut};
|
||||
use bloom::StyleBloom;
|
||||
use context::{SharedStyleContext, StyleContext, ThreadLocalStyleContext};
|
||||
use context::{SharedStyleContext, StyleContext};
|
||||
use data::{ElementData, StoredRestyleHint};
|
||||
use dom::{OpaqueNode, TElement, TNode};
|
||||
use matching::{MatchMethods, StyleSharingResult};
|
||||
|
@ -15,10 +15,8 @@ use selector_parser::RestyleDamage;
|
|||
use selectors::Element;
|
||||
use selectors::matching::StyleRelations;
|
||||
use servo_config::opts;
|
||||
use std::borrow::Borrow;
|
||||
use std::cell::RefCell;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
|
||||
use stylist::Stylist;
|
||||
|
||||
|
@ -128,15 +126,16 @@ impl LogBehavior {
|
|||
}
|
||||
|
||||
pub trait DomTraversal<N: TNode> : Sync {
|
||||
type ThreadLocalContext: Borrow<ThreadLocalStyleContext>;
|
||||
type ThreadLocalContext: Send;
|
||||
|
||||
/// Process `node` on the way down, before its children have been processed.
|
||||
fn process_preorder(&self, node: N, data: &mut PerLevelTraversalData);
|
||||
fn process_preorder(&self, data: &mut PerLevelTraversalData,
|
||||
thread_local: &mut Self::ThreadLocalContext, node: N);
|
||||
|
||||
/// 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, node: N);
|
||||
fn process_postorder(&self, thread_local: &mut Self::ThreadLocalContext, node: N);
|
||||
|
||||
/// Boolean that specifies whether a bottom up traversal should be
|
||||
/// performed.
|
||||
|
@ -321,7 +320,7 @@ pub trait DomTraversal<N: TNode> : Sync {
|
|||
|
||||
fn shared_context(&self) -> &SharedStyleContext;
|
||||
|
||||
fn create_or_get_thread_local_context(&self) -> Rc<Self::ThreadLocalContext>;
|
||||
fn create_thread_local_context(&self) -> Self::ThreadLocalContext;
|
||||
}
|
||||
|
||||
/// Determines the amount of relations where we're going to share style.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue