mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Fix servo build.
This commit is contained in:
parent
39169ad92e
commit
33b593d32e
5 changed files with 32 additions and 32 deletions
|
@ -39,14 +39,14 @@ where
|
||||||
let mut new_running_animations = vec![];
|
let mut new_running_animations = vec![];
|
||||||
while let Ok(animation) = new_animations_receiver.try_recv() {
|
while let Ok(animation) = new_animations_receiver.try_recv() {
|
||||||
let mut should_push = true;
|
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
|
// If the animation was already present in the list for the
|
||||||
// node, just update its state, else push the new animation to
|
// node, just update its state, else push the new animation to
|
||||||
// run.
|
// run.
|
||||||
if let Some(ref mut animations) = running_animations.get_mut(node) {
|
if let Some(ref mut animations) = running_animations.get_mut(node) {
|
||||||
// TODO: This being linear is probably not optimal.
|
// TODO: This being linear is probably not optimal.
|
||||||
for anim in animations.iter_mut() {
|
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 {
|
if *name == *anim_name {
|
||||||
debug!("update_animation_state: Found other animation {}", name);
|
debug!("update_animation_state: Found other animation {}", name);
|
||||||
anim_state.update_from_other(&state, timer);
|
anim_state.update_from_other(&state, timer);
|
||||||
|
@ -83,7 +83,7 @@ where
|
||||||
Animation::Transition(_, started_at, ref frame, _expired) => {
|
Animation::Transition(_, started_at, ref frame, _expired) => {
|
||||||
now < started_at + frame.duration
|
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
|
// This animation is still running, or we need to keep
|
||||||
// iterating.
|
// iterating.
|
||||||
now < state.started_at + state.duration || state.tick()
|
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);
|
self.traversal.list_item.truncate_to_level(self.level);
|
||||||
|
|
||||||
for &(ref counter_name, value) in &*fragment.style().get_counters().counter_reset {
|
for pair in &*fragment.style().get_counters().counter_reset {
|
||||||
let counter_name = &*counter_name.0;
|
let counter_name = &*pair.name.0;
|
||||||
if let Some(ref mut counter) = self.traversal.counters.get_mut(counter_name) {
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut counter = Counter::new();
|
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);
|
self.traversal.counters.insert(counter_name.to_owned(), counter);
|
||||||
}
|
}
|
||||||
|
|
||||||
for &(ref counter_name, value) in &*fragment.style().get_counters().counter_increment {
|
for pair in &*fragment.style().get_counters().counter_increment {
|
||||||
let counter_name = &*counter_name.0;
|
let counter_name = &*pair.name.0;
|
||||||
if let Some(ref mut counter) = self.traversal.counters.get_mut(counter_name) {
|
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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut counter = Counter::new();
|
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);
|
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 rule_tree::CascadeLevel;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use std::sync::mpsc::Sender;
|
use std::sync::mpsc::Sender;
|
||||||
use stylesheets::keyframes_rule::{KeyframesStep, KeyframesStepValue};
|
use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
|
||||||
use timer::Timer;
|
use timer::Timer;
|
||||||
use values::computed::Time;
|
use values::computed::Time;
|
||||||
use values::computed::transform::TimingFunction;
|
use values::computed::transform::TimingFunction;
|
||||||
|
@ -194,7 +194,9 @@ pub enum Animation {
|
||||||
Transition(OpaqueNode, f64, AnimationFrame, bool),
|
Transition(OpaqueNode, f64, AnimationFrame, bool),
|
||||||
/// A keyframes animation is identified by a name, and can have a
|
/// A keyframes animation is identified by a name, and can have a
|
||||||
/// node-dependent state (i.e. iteration count, etc.).
|
/// 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 {
|
impl Animation {
|
||||||
|
@ -204,7 +206,7 @@ impl Animation {
|
||||||
debug_assert!(!self.is_expired());
|
debug_assert!(!self.is_expired());
|
||||||
match *self {
|
match *self {
|
||||||
Animation::Transition(_, _, _, ref mut expired) => *expired = true,
|
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 {
|
pub fn is_expired(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
Animation::Transition(_, _, _, expired) => expired,
|
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 {
|
pub fn node(&self) -> &OpaqueNode {
|
||||||
match *self {
|
match *self {
|
||||||
Animation::Transition(ref node, _, _, _) => node,
|
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 {
|
pub fn is_paused(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
Animation::Transition(..) => false,
|
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
|
/// Triggers animations for a given node looking at the animation property
|
||||||
/// values.
|
/// values.
|
||||||
pub fn maybe_start_animations(
|
pub fn maybe_start_animations<E>(
|
||||||
|
element: E,
|
||||||
context: &SharedStyleContext,
|
context: &SharedStyleContext,
|
||||||
new_animations_sender: &Sender<Animation>,
|
new_animations_sender: &Sender<Animation>,
|
||||||
node: OpaqueNode,
|
node: OpaqueNode,
|
||||||
new_style: &Arc<ComputedValues>,
|
new_style: &Arc<ComputedValues>,
|
||||||
) -> bool {
|
) -> bool
|
||||||
|
where
|
||||||
|
E: TElement,
|
||||||
|
{
|
||||||
let mut had_animations = false;
|
let mut had_animations = false;
|
||||||
|
|
||||||
let box_style = new_style.get_box();
|
let box_style = new_style.get_box();
|
||||||
|
@ -522,7 +528,7 @@ pub fn maybe_start_animations(
|
||||||
continue;
|
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);
|
debug!("maybe_start_animations: animation {} found", name);
|
||||||
|
|
||||||
// If this animation doesn't have any keyframe, we can just continue
|
// If this animation doesn't have any keyframe, we can just continue
|
||||||
|
@ -561,6 +567,7 @@ pub fn maybe_start_animations(
|
||||||
new_animations_sender
|
new_animations_sender
|
||||||
.send(Animation::Keyframes(
|
.send(Animation::Keyframes(
|
||||||
node,
|
node,
|
||||||
|
anim.clone(),
|
||||||
name.clone(),
|
name.clone(),
|
||||||
KeyframesAnimationState {
|
KeyframesAnimationState {
|
||||||
started_at: animation_start,
|
started_at: animation_start,
|
||||||
|
@ -628,7 +635,7 @@ pub fn update_style_for_animation<E>(
|
||||||
*style = new_style
|
*style = new_style
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Animation::Keyframes(_, ref name, ref state) => {
|
Animation::Keyframes(_, ref animation, ref name, ref state) => {
|
||||||
debug!(
|
debug!(
|
||||||
"update_style_for_animation: animation found: \"{}\", {:?}",
|
"update_style_for_animation: animation found: \"{}\", {:?}",
|
||||||
name, state
|
name, state
|
||||||
|
@ -641,14 +648,6 @@ pub fn update_style_for_animation<E>(
|
||||||
KeyframesRunningState::Paused(progress) => started_at + duration * progress,
|
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());
|
debug_assert!(!animation.steps.is_empty());
|
||||||
|
|
||||||
let maybe_index = style
|
let maybe_index = style
|
||||||
|
|
|
@ -425,6 +425,7 @@ trait PrivateMatchMethods: TElement {
|
||||||
let this_opaque = self.as_node().opaque();
|
let this_opaque = self.as_node().opaque();
|
||||||
// Trigger any present animations if necessary.
|
// Trigger any present animations if necessary.
|
||||||
animation::maybe_start_animations(
|
animation::maybe_start_animations(
|
||||||
|
*self,
|
||||||
&shared_context,
|
&shared_context,
|
||||||
new_animations_sender,
|
new_animations_sender,
|
||||||
this_opaque,
|
this_opaque,
|
||||||
|
|
|
@ -259,7 +259,7 @@ impl DeepCloneWithLock for Keyframe {
|
||||||
/// declarations to apply.
|
/// declarations to apply.
|
||||||
///
|
///
|
||||||
/// TODO: Find a better name for this?
|
/// TODO: Find a better name for this?
|
||||||
#[derive(Debug, MallocSizeOf)]
|
#[derive(Clone, Debug, MallocSizeOf)]
|
||||||
pub enum KeyframesStepValue {
|
pub enum KeyframesStepValue {
|
||||||
/// A step formed by a declaration block specified by the CSS.
|
/// A step formed by a declaration block specified by the CSS.
|
||||||
Declarations {
|
Declarations {
|
||||||
|
@ -275,7 +275,7 @@ pub enum KeyframesStepValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A single step from a keyframe animation.
|
/// A single step from a keyframe animation.
|
||||||
#[derive(Debug, MallocSizeOf)]
|
#[derive(Clone, Debug, MallocSizeOf)]
|
||||||
pub struct KeyframesStep {
|
pub struct KeyframesStep {
|
||||||
/// The percentage of the animation duration when this step starts.
|
/// The percentage of the animation duration when this step starts.
|
||||||
pub start_percentage: KeyframePercentage,
|
pub start_percentage: KeyframePercentage,
|
||||||
|
@ -352,7 +352,7 @@ impl KeyframesStep {
|
||||||
/// of keyframes, in order.
|
/// of keyframes, in order.
|
||||||
///
|
///
|
||||||
/// It only takes into account animable properties.
|
/// It only takes into account animable properties.
|
||||||
#[derive(Debug, MallocSizeOf)]
|
#[derive(Clone, Debug, MallocSizeOf)]
|
||||||
pub struct KeyframesAnimation {
|
pub struct KeyframesAnimation {
|
||||||
/// The difference steps of the animation.
|
/// The difference steps of the animation.
|
||||||
pub steps: Vec<KeyframesStep>,
|
pub steps: Vec<KeyframesStep>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue