diff options
author | Ms2ger <Ms2ger@gmail.com> | 2015-12-30 14:59:11 +0100 |
---|---|---|
committer | Ms2ger <Ms2ger@gmail.com> | 2015-12-30 15:13:08 +0100 |
commit | 828392b41cc4cfc21ebc59702fad1778bede1fa9 (patch) | |
tree | 2a1ea316b7fdd2d7b5eb94bda717d51572037e75 /components | |
parent | 3f407ea3d620e381b3adf6352cc09f9912db26b3 (diff) | |
download | servo-828392b41cc4cfc21ebc59702fad1778bede1fa9.tar.gz servo-828392b41cc4cfc21ebc59702fad1778bede1fa9.zip |
Don't copy the list of stylesheets in LayoutTask::handle_reflow.
It would be nice to avoid exposing the fact that these are stored in an Arc
to the selector matching code.
Diffstat (limited to 'components')
-rw-r--r-- | components/layout/layout_task.rs | 8 | ||||
-rw-r--r-- | components/style/selector_matching.rs | 5 |
2 files changed, 6 insertions, 7 deletions
diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index 87f34ce2a8c..da3b7518f3f 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -954,9 +954,6 @@ impl LayoutTask { node.dump(); } - let stylesheets: Vec<&Stylesheet> = data.document_stylesheets.iter().map(|entry| &**entry) - .collect(); - let stylesheets_changed = data.stylesheets_changed; let initial_viewport = data.window_size.initial_viewport; let old_viewport_size = self.viewport_size; let current_screen_size = Size2D::new(Au::from_f32_px(initial_viewport.width.get()), @@ -964,7 +961,7 @@ impl LayoutTask { // Calculate the actual viewport as per DEVICE-ADAPT § 6 let device = Device::new(MediaType::Screen, initial_viewport); - rw_data.stylist.set_device(device, &stylesheets); + rw_data.stylist.set_device(device, &data.document_stylesheets); let constraints = rw_data.stylist.viewport_constraints().clone(); self.viewport_size = match constraints { @@ -990,7 +987,8 @@ impl LayoutTask { } // If the entire flow tree is invalid, then it will be reflowed anyhow. - let needs_dirtying = rw_data.stylist.update(&stylesheets, stylesheets_changed); + let needs_dirtying = rw_data.stylist.update(&data.document_stylesheets, + data.stylesheets_changed); let needs_reflow = viewport_size_changed && !needs_dirtying; unsafe { if needs_dirtying { diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs index dd99a3f26b4..a2fd14ff249 100644 --- a/components/style/selector_matching.rs +++ b/components/style/selector_matching.rs @@ -18,6 +18,7 @@ use selectors::parser::PseudoElement; use selectors::states::*; use smallvec::VecLike; use std::process; +use std::sync::Arc; use style_traits::viewport::ViewportConstraints; use stylesheets::{CSSRuleIteratorExt, Origin, Stylesheet}; use url::Url; @@ -141,7 +142,7 @@ impl Stylist { stylist } - pub fn update(&mut self, doc_stylesheets: &[&Stylesheet], + pub fn update(&mut self, doc_stylesheets: &[Arc<Stylesheet>], stylesheets_changed: bool) -> bool { if !(self.is_device_dirty || stylesheets_changed) { return false; @@ -239,7 +240,7 @@ impl Stylist { self.state_deps.compute_hint(element, snapshot, current_state) } - pub fn set_device(&mut self, mut device: Device, stylesheets: &[&Stylesheet]) { + pub fn set_device(&mut self, mut device: Device, stylesheets: &[Arc<Stylesheet>]) { let cascaded_rule = stylesheets.iter() .flat_map(|s| s.effective_rules(&self.device).viewport()) .cascade(); |