Move new_animations_receiver from LayoutTaskData to LayoutTask.

This commit is contained in:
Ms2ger 2015-11-06 15:10:08 +01:00
parent 604d1e8400
commit 5e4039d328
2 changed files with 12 additions and 8 deletions

View file

@ -14,7 +14,7 @@ use script::layout_interface::Animation;
use script_traits::ConstellationControlMsg;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
use std::sync::mpsc::Sender;
use std::sync::mpsc::{Sender, Receiver};
use std::sync::{Arc, Mutex};
use style::animation::{GetMod, PropertyAnimation};
use style::properties::ComputedValues;
@ -50,9 +50,11 @@ pub fn start_transitions_if_applicable(new_animations_sender: &Mutex<Sender<Anim
/// Processes any new animations that were discovered after style recalculation.
/// Also expire any old animations that have completed.
pub fn update_animation_state(rw_data: &mut LayoutTaskData, pipeline_id: PipelineId) {
pub fn update_animation_state(rw_data: &mut LayoutTaskData,
new_animations_receiver: &Receiver<Animation>,
pipeline_id: PipelineId) {
let mut new_running_animations = Vec::new();
while let Ok(animation) = rw_data.new_animations_receiver.try_recv() {
while let Ok(animation) = new_animations_receiver.try_recv() {
new_running_animations.push(animation)
}

View file

@ -128,9 +128,6 @@ pub struct LayoutTaskData {
/// The list of currently-running animations.
pub running_animations: Arc<HashMap<OpaqueNode, Vec<Animation>>>,
/// Receives newly-discovered animations.
pub new_animations_receiver: Receiver<Animation>,
/// A counter for epoch messages
epoch: Epoch,
@ -222,6 +219,9 @@ pub struct LayoutTask {
/// sent.
new_animations_sender: Sender<Animation>,
/// Receives newly-discovered animations.
new_animations_receiver: Receiver<Animation>,
/// A mutex to allow for fast, read-only RPC of layout's internal data
/// structures, while still letting the LayoutTask modify them.
///
@ -434,6 +434,7 @@ impl LayoutTask {
parallel_traversal: parallel_traversal,
generation: 0,
new_animations_sender: new_animations_sender,
new_animations_receiver: new_animations_receiver,
rw_data: Arc::new(Mutex::new(
LayoutTaskData {
root_flow: None,
@ -448,7 +449,6 @@ impl LayoutTask {
running_animations: Arc::new(HashMap::new()),
offset_parent_response: OffsetParentResponse::empty(),
visible_rects: Arc::new(HashMap::with_hash_state(Default::default())),
new_animations_receiver: new_animations_receiver,
epoch: Epoch(0),
outstanding_web_fonts: outstanding_web_fonts_counter,
})),
@ -1340,7 +1340,9 @@ impl LayoutTask {
layout_context: &mut SharedLayoutContext) {
if let Some(mut root_flow) = rw_data.layout_root() {
// Kick off animations if any were triggered, expire completed ones.
animation::update_animation_state(&mut *rw_data, self.id);
animation::update_animation_state(&mut *rw_data,
&self.new_animations_receiver,
self.id);
profile(time::ProfilerCategory::LayoutRestyleDamagePropagation,
self.profiler_metadata(),