Bug 1459436: Fix servo build. r=emilio

MozReview-Commit-ID: Ex5RKgPgd8x
This commit is contained in:
Emilio Cobos Álvarez 2018-05-05 17:19:06 +02:00
Родитель 68affa51a4
Коммит 6ee6a58a0f
5 изменённых файлов: 32 добавлений и 32 удалений

Просмотреть файл

@ -39,14 +39,14 @@ where
let mut new_running_animations = vec![];
while let Ok(animation) = new_animations_receiver.try_recv() {
let mut should_push = true;
if let Animation::Keyframes(ref node, ref name, ref state) = animation {
if let Animation::Keyframes(ref node, _, ref name, ref state) = animation {
// If the animation was already present in the list for the
// node, just update its state, else push the new animation to
// run.
if let Some(ref mut animations) = running_animations.get_mut(node) {
// TODO: This being linear is probably not optimal.
for anim in animations.iter_mut() {
if let Animation::Keyframes(_, ref anim_name, ref mut anim_state) = *anim {
if let Animation::Keyframes(_, _, ref anim_name, ref mut anim_state) = *anim {
if *name == *anim_name {
debug!("update_animation_state: Found other animation {}", name);
anim_state.update_from_other(&state, timer);
@ -83,7 +83,7 @@ where
Animation::Transition(_, started_at, ref frame, _expired) => {
now < started_at + frame.duration
}
Animation::Keyframes(_, _, ref mut state) => {
Animation::Keyframes(_, _, _, ref mut state) => {
// This animation is still running, or we need to keep
// iterating.
now < state.started_at + state.duration || state.tick()

Просмотреть файл

@ -272,27 +272,27 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
}
self.traversal.list_item.truncate_to_level(self.level);
for &(ref counter_name, value) in &*fragment.style().get_counters().counter_reset {
let counter_name = &*counter_name.0;
for pair in &*fragment.style().get_counters().counter_reset {
let counter_name = &*pair.name.0;
if let Some(ref mut counter) = self.traversal.counters.get_mut(counter_name) {
counter.reset(self.level, value);
counter.reset(self.level, pair.value);
continue
}
let mut counter = Counter::new();
counter.reset(self.level, value);
counter.reset(self.level, pair.value);
self.traversal.counters.insert(counter_name.to_owned(), counter);
}
for &(ref counter_name, value) in &*fragment.style().get_counters().counter_increment {
let counter_name = &*counter_name.0;
for pair in &*fragment.style().get_counters().counter_increment {
let counter_name = &*pair.name.0;
if let Some(ref mut counter) = self.traversal.counters.get_mut(counter_name) {
counter.increment(self.level, value);
counter.increment(self.level, pair.value);
continue
}
let mut counter = Counter::new();
counter.increment(self.level, value);
counter.increment(self.level, pair.value);
self.traversal.counters.insert(counter_name.to_owned(), counter);
}

Просмотреть файл

@ -17,7 +17,7 @@ use properties::longhands::animation_play_state::computed_value::single_value::T
use rule_tree::CascadeLevel;
use servo_arc::Arc;
use std::sync::mpsc::Sender;
use stylesheets::keyframes_rule::{KeyframesStep, KeyframesStepValue};
use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
use timer::Timer;
use values::computed::Time;
use values::computed::transform::TimingFunction;
@ -194,7 +194,9 @@ pub enum Animation {
Transition(OpaqueNode, f64, AnimationFrame, bool),
/// A keyframes animation is identified by a name, and can have a
/// node-dependent state (i.e. iteration count, etc.).
Keyframes(OpaqueNode, Atom, KeyframesAnimationState),
///
/// TODO(emilio): The animation object could be refcounted.
Keyframes(OpaqueNode, KeyframesAnimation, Atom, KeyframesAnimationState),
}
impl Animation {
@ -204,7 +206,7 @@ impl Animation {
debug_assert!(!self.is_expired());
match *self {
Animation::Transition(_, _, _, ref mut expired) => *expired = true,
Animation::Keyframes(_, _, ref mut state) => state.expired = true,
Animation::Keyframes(_, _, _, ref mut state) => state.expired = true,
}
}
@ -213,7 +215,7 @@ impl Animation {
pub fn is_expired(&self) -> bool {
match *self {
Animation::Transition(_, _, _, expired) => expired,
Animation::Keyframes(_, _, ref state) => state.expired,
Animation::Keyframes(_, _, _, ref state) => state.expired,
}
}
@ -222,7 +224,7 @@ impl Animation {
pub fn node(&self) -> &OpaqueNode {
match *self {
Animation::Transition(ref node, _, _, _) => node,
Animation::Keyframes(ref node, _, _) => node,
Animation::Keyframes(ref node, _, _, _) => node,
}
}
@ -231,7 +233,7 @@ impl Animation {
pub fn is_paused(&self) -> bool {
match *self {
Animation::Transition(..) => false,
Animation::Keyframes(_, _, ref state) => state.is_paused(),
Animation::Keyframes(_, _, _, ref state) => state.is_paused(),
}
}
@ -500,12 +502,16 @@ where
/// Triggers animations for a given node looking at the animation property
/// values.
pub fn maybe_start_animations(
pub fn maybe_start_animations<E>(
element: E,
context: &SharedStyleContext,
new_animations_sender: &Sender<Animation>,
node: OpaqueNode,
new_style: &Arc<ComputedValues>,
) -> bool {
) -> bool
where
E: TElement,
{
let mut had_animations = false;
let box_style = new_style.get_box();
@ -522,7 +528,7 @@ pub fn maybe_start_animations(
continue;
}
if let Some(ref anim) = context.stylist.get_animation(name) {
if let Some(anim) = context.stylist.get_animation(name, element) {
debug!("maybe_start_animations: animation {} found", name);
// If this animation doesn't have any keyframe, we can just continue
@ -561,6 +567,7 @@ pub fn maybe_start_animations(
new_animations_sender
.send(Animation::Keyframes(
node,
anim.clone(),
name.clone(),
KeyframesAnimationState {
started_at: animation_start,
@ -628,7 +635,7 @@ pub fn update_style_for_animation<E>(
*style = new_style
}
},
Animation::Keyframes(_, ref name, ref state) => {
Animation::Keyframes(_, ref animation, ref name, ref state) => {
debug!(
"update_style_for_animation: animation found: \"{}\", {:?}",
name, state
@ -641,14 +648,6 @@ pub fn update_style_for_animation<E>(
KeyframesRunningState::Paused(progress) => started_at + duration * progress,
};
let animation = match context.stylist.get_animation(name) {
None => {
warn!("update_style_for_animation: Animation {:?} not found", name);
return;
},
Some(animation) => animation,
};
debug_assert!(!animation.steps.is_empty());
let maybe_index = style

Просмотреть файл

@ -425,6 +425,7 @@ trait PrivateMatchMethods: TElement {
let this_opaque = self.as_node().opaque();
// Trigger any present animations if necessary.
animation::maybe_start_animations(
*self,
&shared_context,
new_animations_sender,
this_opaque,

Просмотреть файл

@ -259,7 +259,7 @@ impl DeepCloneWithLock for Keyframe {
/// declarations to apply.
///
/// TODO: Find a better name for this?
#[derive(Debug, MallocSizeOf)]
#[derive(Clone, Debug, MallocSizeOf)]
pub enum KeyframesStepValue {
/// A step formed by a declaration block specified by the CSS.
Declarations {
@ -275,7 +275,7 @@ pub enum KeyframesStepValue {
}
/// A single step from a keyframe animation.
#[derive(Debug, MallocSizeOf)]
#[derive(Clone, Debug, MallocSizeOf)]
pub struct KeyframesStep {
/// The percentage of the animation duration when this step starts.
pub start_percentage: KeyframePercentage,
@ -352,7 +352,7 @@ impl KeyframesStep {
/// of keyframes, in order.
///
/// It only takes into account animable properties.
#[derive(Debug, MallocSizeOf)]
#[derive(Clone, Debug, MallocSizeOf)]
pub struct KeyframesAnimation {
/// The difference steps of the animation.
pub steps: Vec<KeyframesStep>,