Attachment #8822390: part 5. Store a ComputedValues on SharedStyleContext for bug #1298588

View | Details | Raw Unified | Return to bug 1298588
Collapse All | Expand All

(-)a/servo/components/layout_thread/lib.rs (+6 lines)
Line     Link Here 
 Lines 119-134   use style::logical_geometry::LogicalPoin Link Here 
119
use style::media_queries::{Device, MediaType};
119
use style::media_queries::{Device, MediaType};
120
use style::parser::ParserContextExtraData;
120
use style::parser::ParserContextExtraData;
121
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
121
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW, REPAINT, REPOSITION, STORE_OVERFLOW};
122
use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
122
use style::stylesheets::{Origin, Stylesheet, UserAgentStylesheets};
123
use style::stylist::Stylist;
123
use style::stylist::Stylist;
124
use style::thread_state;
124
use style::thread_state;
125
use style::timer::Timer;
125
use style::timer::Timer;
126
use style::traversal::DomTraversal;
126
use style::traversal::DomTraversal;
127
use style::properties::ComputedValues;
127
128
128
/// Information needed by the layout thread.
129
/// Information needed by the layout thread.
129
pub struct LayoutThread {
130
pub struct LayoutThread {
130
    /// The ID of the pipeline that we belong to.
131
    /// The ID of the pipeline that we belong to.
131
    id: PipelineId,
132
    id: PipelineId,
132
133
133
    /// The URL of the pipeline that we belong to.
134
    /// The URL of the pipeline that we belong to.
134
    url: ServoUrl,
135
    url: ServoUrl,
 Lines 522-537   impl LayoutThread { Link Here 
522
                stylist: rw_data.stylist.clone(),
523
                stylist: rw_data.stylist.clone(),
523
                goal: goal,
524
                goal: goal,
524
                running_animations: self.running_animations.clone(),
525
                running_animations: self.running_animations.clone(),
525
                expired_animations: self.expired_animations.clone(),
526
                expired_animations: self.expired_animations.clone(),
526
                error_reporter: self.error_reporter.clone(),
527
                error_reporter: self.error_reporter.clone(),
527
                local_context_creation_data: Mutex::new(thread_local_style_context_creation_data),
528
                local_context_creation_data: Mutex::new(thread_local_style_context_creation_data),
528
                timer: self.timer.clone(),
529
                timer: self.timer.clone(),
529
                quirks_mode: self.quirks_mode.unwrap(),
530
                quirks_mode: self.quirks_mode.unwrap(),
531
                // FIXME(bz): This isn't really right, but it's no more wrong
532
                // than what we used to do.  See
533
                // https://github.com/servo/servo/issues/14773 for fixing it
534
                // properly.
535
                default_computed_values: Arc::new(ComputedValues::initial_values().clone()),
530
            },
536
            },
531
            image_cache_thread: Mutex::new(self.image_cache_thread.clone()),
537
            image_cache_thread: Mutex::new(self.image_cache_thread.clone()),
532
            image_cache_sender: Mutex::new(self.image_cache_sender.clone()),
538
            image_cache_sender: Mutex::new(self.image_cache_sender.clone()),
533
            font_cache_thread: Mutex::new(self.font_cache_thread.clone()),
539
            font_cache_thread: Mutex::new(self.font_cache_thread.clone()),
534
            webrender_image_cache: self.webrender_image_cache.clone(),
540
            webrender_image_cache: self.webrender_image_cache.clone(),
535
        }
541
        }
536
    }
542
    }
537
543
(-)a/servo/components/style/context.rs (+5 lines)
Line     Link Here 
 Lines 12-27   use error_reporting::ParseErrorReporter; Link Here 
12
use euclid::Size2D;
12
use euclid::Size2D;
13
use matching::StyleSharingCandidateCache;
13
use matching::StyleSharingCandidateCache;
14
use parking_lot::RwLock;
14
use parking_lot::RwLock;
15
use std::collections::HashMap;
15
use std::collections::HashMap;
16
use std::sync::{Arc, Mutex};
16
use std::sync::{Arc, Mutex};
17
use std::sync::mpsc::Sender;
17
use std::sync::mpsc::Sender;
18
use stylist::Stylist;
18
use stylist::Stylist;
19
use timer::Timer;
19
use timer::Timer;
20
use properties::ComputedValues;
20
21
21
/// This structure is used to create a local style context from a shared one.
22
/// This structure is used to create a local style context from a shared one.
22
pub struct ThreadLocalStyleContextCreationInfo {
23
pub struct ThreadLocalStyleContextCreationInfo {
23
    new_animations_sender: Sender<Animation>,
24
    new_animations_sender: Sender<Animation>,
24
}
25
}
25
26
26
impl ThreadLocalStyleContextCreationInfo {
27
impl ThreadLocalStyleContextCreationInfo {
27
    pub fn new(animations_sender: Sender<Animation>) -> Self {
28
    pub fn new(animations_sender: Sender<Animation>) -> Self {
 Lines 65-80   pub struct SharedStyleContext { Link Here 
65
    pub local_context_creation_data: Mutex<ThreadLocalStyleContextCreationInfo>,
66
    pub local_context_creation_data: Mutex<ThreadLocalStyleContextCreationInfo>,
66
67
67
    /// The current timer for transitions and animations. This is needed to test
68
    /// The current timer for transitions and animations. This is needed to test
68
    /// them.
69
    /// them.
69
    pub timer: Timer,
70
    pub timer: Timer,
70
71
71
    /// The QuirksMode state which the document needs to be rendered with
72
    /// The QuirksMode state which the document needs to be rendered with
72
    pub quirks_mode: QuirksMode,
73
    pub quirks_mode: QuirksMode,
74
75
    /// The default computed values to use for elements with no rules
76
    /// applying to them.
77
    pub default_computed_values: Arc<ComputedValues>,
73
}
78
}
74
79
75
pub struct ThreadLocalStyleContext<E: TElement> {
80
pub struct ThreadLocalStyleContext<E: TElement> {
76
    pub style_sharing_candidate_cache: StyleSharingCandidateCache<E>,
81
    pub style_sharing_candidate_cache: StyleSharingCandidateCache<E>,
77
    pub bloom_filter: StyleBloom<E>,
82
    pub bloom_filter: StyleBloom<E>,
78
    /// A channel on which new animations that have been triggered by style
83
    /// A channel on which new animations that have been triggered by style
79
    /// recalculation can be sent.
84
    /// recalculation can be sent.
80
    pub new_animations_sender: Sender<Animation>,
85
    pub new_animations_sender: Sender<Animation>,
(-)a/servo/ports/geckolib/glue.rs (+1 lines)
Line     Link Here 
 Lines 103-118   fn create_shared_context(per_doc_data: & Link Here 
103
        stylist: per_doc_data.stylist.clone(),
103
        stylist: per_doc_data.stylist.clone(),
104
        running_animations: per_doc_data.running_animations.clone(),
104
        running_animations: per_doc_data.running_animations.clone(),
105
        expired_animations: per_doc_data.expired_animations.clone(),
105
        expired_animations: per_doc_data.expired_animations.clone(),
106
        error_reporter: Box::new(StdoutErrorReporter),
106
        error_reporter: Box::new(StdoutErrorReporter),
107
        local_context_creation_data: Mutex::new(local_context_data),
107
        local_context_creation_data: Mutex::new(local_context_data),
108
        timer: Timer::new(),
108
        timer: Timer::new(),
109
        // FIXME Find the real QuirksMode information for this document
109
        // FIXME Find the real QuirksMode information for this document
110
        quirks_mode: QuirksMode::NoQuirks,
110
        quirks_mode: QuirksMode::NoQuirks,
111
        default_computed_values: per_doc_data.default_computed_values.clone(),
111
    }
112
    }
112
}
113
}
113
114
114
fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
115
fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed,
115
                    unstyled_children_only: bool) {
116
                    unstyled_children_only: bool) {
116
    // Force the creation of our lazily-constructed initial computed values on
117
    // Force the creation of our lazily-constructed initial computed values on
117
    // the main thread, since it's not safe to call elsewhere.
118
    // the main thread, since it's not safe to call elsewhere.
118
    //
119
    //

Return to bug 1298588