diff options
Diffstat (limited to 'components/layout')
-rw-r--r-- | components/layout/animation.rs | 6 | ||||
-rw-r--r-- | components/layout/context.rs | 3 | ||||
-rw-r--r-- | components/layout/css/matching.rs | 10 | ||||
-rw-r--r-- | components/layout/layout_task.rs | 2 |
4 files changed, 10 insertions, 11 deletions
diff --git a/components/layout/animation.rs b/components/layout/animation.rs index 27bf118bfda..7b58e435681 100644 --- a/components/layout/animation.rs +++ b/components/layout/animation.rs @@ -14,14 +14,14 @@ use script::layout_interface::Animation; use script_traits::ConstellationControlMsg; use std::collections::HashMap; use std::collections::hash_map::Entry; -use std::sync::Arc; use std::sync::mpsc::Sender; +use std::sync::{Arc, Mutex}; use style::animation::{GetMod, PropertyAnimation}; use style::properties::ComputedValues; /// Inserts transitions into the queue of running animations as applicable for the given style /// difference. This is called from the layout worker threads. -pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation>, +pub fn start_transitions_if_applicable(new_animations_sender: &Mutex<Sender<Animation>>, node: OpaqueNode, old_style: &ComputedValues, new_style: &mut ComputedValues) { @@ -37,7 +37,7 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Sender<Animation> let animation_style = new_style.get_animation(); let start_time = now + (animation_style.transition_delay.0.get_mod(i).seconds() as f64); - new_animations_sender.send(Animation { + new_animations_sender.lock().unwrap().send(Animation { node: node.id(), property_animation: property_animation, start_time: start_time, diff --git a/components/layout/context.rs b/components/layout/context.rs index 5a7bbdfed8f..eb5c19cc596 100644 --- a/components/layout/context.rs +++ b/components/layout/context.rs @@ -105,7 +105,7 @@ pub struct SharedLayoutContext { /// A channel on which new animations that have been triggered by style recalculation can be /// sent. - pub new_animations_sender: Sender<Animation>, + pub new_animations_sender: Mutex<Sender<Animation>>, /// A channel to send canvas renderers to paint task, in order to correctly paint the layers pub canvas_layers_sender: Sender<(LayerId, IpcSender<CanvasMsg>)>, @@ -123,7 +123,6 @@ pub struct SharedLayoutContext { // FIXME(#6569) This implementations is unsound: // XXX UNSOUND!!! for image_cache_task // XXX UNSOUND!!! for stylist -// XXX UNSOUND!!! for new_animations_sender // XXX UNSOUND!!! for canvas_layers_sender #[allow(unsafe_code)] unsafe impl Sync for SharedLayoutContext {} diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs index 456f8cbe88f..d0260fa5c98 100644 --- a/components/layout/css/matching.rs +++ b/components/layout/css/matching.rs @@ -21,8 +21,8 @@ use smallvec::SmallVec; use std::borrow::ToOwned; use std::hash::{Hash, Hasher}; use std::slice::Iter; -use std::sync::Arc; use std::sync::mpsc::Sender; +use std::sync::{Arc, Mutex}; use string_cache::{Atom, Namespace}; use style::node::TElementAttributes; use style::properties::{ComputedValues, PropertyDeclaration, cascade}; @@ -406,7 +406,7 @@ pub trait MatchMethods { parent: Option<LayoutNode>, applicable_declarations: &ApplicableDeclarations, applicable_declarations_cache: &mut ApplicableDeclarationsCache, - new_animations_sender: &Sender<Animation>); + new_animations_sender: &Mutex<Sender<Animation>>); } trait PrivateMatchMethods { @@ -417,7 +417,7 @@ trait PrivateMatchMethods { style: &mut Option<Arc<ComputedValues>>, applicable_declarations_cache: &mut ApplicableDeclarationsCache, - new_animations_sender: &Sender<Animation>, + new_animations_sender: &Mutex<Sender<Animation>>, shareable: bool, animate_properties: bool) -> RestyleDamage; @@ -438,7 +438,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> { style: &mut Option<Arc<ComputedValues>>, applicable_declarations_cache: &mut ApplicableDeclarationsCache, - new_animations_sender: &Sender<Animation>, + new_animations_sender: &Mutex<Sender<Animation>>, shareable: bool, animate_properties: bool) -> RestyleDamage { @@ -655,7 +655,7 @@ impl<'ln> MatchMethods for LayoutNode<'ln> { parent: Option<LayoutNode>, applicable_declarations: &ApplicableDeclarations, applicable_declarations_cache: &mut ApplicableDeclarationsCache, - new_animations_sender: &Sender<Animation>) { + new_animations_sender: &Mutex<Sender<Animation>>) { // Get our parent's style. This must be unsafe so that we don't touch the parent's // borrow flags. // diff --git a/components/layout/layout_task.rs b/components/layout/layout_task.rs index edf408cf937..604a0743d34 100644 --- a/components/layout/layout_task.rs +++ b/components/layout/layout_task.rs @@ -461,7 +461,7 @@ impl LayoutTask { url: (*url).clone(), visible_rects: rw_data.visible_rects.clone(), generation: rw_data.generation, - new_animations_sender: rw_data.new_animations_sender.clone(), + new_animations_sender: Mutex::new(rw_data.new_animations_sender.clone()), goal: goal, running_animations: rw_data.running_animations.clone(), } |