mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Wrap SharedLayoutContext::new_animations_sender in a Mutex.
This commit is contained in:
parent
552a03fde6
commit
8fc75704c9
4 changed files with 10 additions and 11 deletions
|
@ -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,
|
||||
|
|
|
@ -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 {}
|
||||
|
|
|
@ -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.
|
||||
//
|
||||
|
|
|
@ -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(),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue