diff options
Diffstat (limited to 'components/style/context.rs')
-rw-r--r-- | components/style/context.rs | 59 |
1 files changed, 30 insertions, 29 deletions
diff --git a/components/style/context.rs b/components/style/context.rs index 6785d752478..f649f64afbf 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -6,12 +6,12 @@ use animation::Animation; use app_units::Au; -use dom::OpaqueNode; +use bloom::StyleBloom; +use dom::{OpaqueNode, TElement}; use error_reporting::ParseErrorReporter; use euclid::Size2D; use matching::StyleSharingCandidateCache; use parking_lot::RwLock; -use std::cell::RefCell; use std::collections::HashMap; use std::sync::{Arc, Mutex}; use std::sync::mpsc::Sender; @@ -19,18 +19,26 @@ use stylist::Stylist; use timer::Timer; /// This structure is used to create a local style context from a shared one. -pub struct LocalStyleContextCreationInfo { +pub struct ThreadLocalStyleContextCreationInfo { new_animations_sender: Sender<Animation>, } -impl LocalStyleContextCreationInfo { +impl ThreadLocalStyleContextCreationInfo { pub fn new(animations_sender: Sender<Animation>) -> Self { - LocalStyleContextCreationInfo { + ThreadLocalStyleContextCreationInfo { new_animations_sender: animations_sender, } } } +#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)] +#[cfg_attr(feature = "servo", derive(HeapSizeOf))] +pub enum QuirksMode { + Quirks, + LimitedQuirks, + NoQuirks, +} + pub struct SharedStyleContext { /// The current viewport size. pub viewport_size: Size2D<Au>, @@ -38,21 +46,9 @@ pub struct SharedStyleContext { /// Screen sized changed? pub screen_size_changed: bool, - /// Skip the root during traversal? - /// - /// This is used in Gecko to style newly-appended children without restyling - /// the parent. It would be cleaner to add an API to allow us to enqueue the - /// children directly from glue.rs. - #[cfg(feature = "gecko")] - pub skip_root: bool, - /// The CSS selector stylist. pub stylist: Arc<Stylist>, - /// Starts at zero, and increased by one every time a layout completes. - /// This can be used to easily check for invalid stale data. - pub generation: u32, - /// Why is this reflow occurring pub goal: ReflowGoal, @@ -65,33 +61,38 @@ pub struct SharedStyleContext { ///The CSS error reporter for all CSS loaded in this layout thread pub error_reporter: Box<ParseErrorReporter + Sync>, - /// Data needed to create the local style context from the shared one. - pub local_context_creation_data: Mutex<LocalStyleContextCreationInfo>, + /// Data needed to create the thread-local style context from the shared one. + pub local_context_creation_data: Mutex<ThreadLocalStyleContextCreationInfo>, /// The current timer for transitions and animations. This is needed to test /// them. pub timer: Timer, + + /// The QuirksMode state which the document needs to be rendered with + pub quirks_mode: QuirksMode, } -pub struct LocalStyleContext { - pub style_sharing_candidate_cache: RefCell<StyleSharingCandidateCache>, +pub struct ThreadLocalStyleContext<E: TElement> { + pub style_sharing_candidate_cache: StyleSharingCandidateCache<E>, + pub bloom_filter: StyleBloom<E>, /// A channel on which new animations that have been triggered by style /// recalculation can be sent. pub new_animations_sender: Sender<Animation>, } -impl LocalStyleContext { - pub fn new(local_context_creation_data: &LocalStyleContextCreationInfo) -> Self { - LocalStyleContext { - style_sharing_candidate_cache: RefCell::new(StyleSharingCandidateCache::new()), - new_animations_sender: local_context_creation_data.new_animations_sender.clone(), +impl<E: TElement> ThreadLocalStyleContext<E> { + pub fn new(shared: &SharedStyleContext) -> Self { + ThreadLocalStyleContext { + style_sharing_candidate_cache: StyleSharingCandidateCache::new(), + bloom_filter: StyleBloom::new(), + new_animations_sender: shared.local_context_creation_data.lock().unwrap().new_animations_sender.clone(), } } } -pub trait StyleContext<'a> { - fn shared_context(&self) -> &'a SharedStyleContext; - fn local_context(&self) -> &LocalStyleContext; +pub struct StyleContext<'a, E: TElement + 'a> { + pub shared: &'a SharedStyleContext, + pub thread_local: &'a mut ThreadLocalStyleContext<E>, } /// Why we're doing reflow. |