Bug 1459436: Implement Debug for KeyframeAnimationStyle by hand. r=emilio
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 05 May 2018 17:39:12 +0200
changeset 473168 6403b7b81a8cd6675327fabce4c35a995f52faa8
parent 473167 22420d6434d4ad2049edb8c2030add30d32a7f61
child 473169 fa28f84b96b717664e205dd126d7e27c9844f6ba
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1459436
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1459436: Implement Debug for KeyframeAnimationStyle by hand. r=emilio The ComputedValues format is huge and unneeded. Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io> MozReview-Commit-ID: 44OuCMWJPLk
servo/components/style/animation.rs
--- a/servo/components/style/animation.rs
+++ b/servo/components/style/animation.rs
@@ -11,16 +11,17 @@ use context::SharedStyleContext;
 use dom::{OpaqueNode, TElement};
 use font_metrics::FontMetricsProvider;
 use properties::{self, CascadeFlags, ComputedValues, LonghandId};
 use properties::animated_properties::{AnimatedProperty, TransitionProperty};
 use properties::longhands::animation_direction::computed_value::single_value::T as AnimationDirection;
 use properties::longhands::animation_play_state::computed_value::single_value::T as AnimationPlayState;
 use rule_tree::CascadeLevel;
 use servo_arc::Arc;
+use std::fmt;
 use std::sync::mpsc::Sender;
 use stylesheets::keyframes_rule::{KeyframesAnimation, KeyframesStep, KeyframesStepValue};
 use timer::Timer;
 use values::computed::Time;
 use values::computed::transform::TimingFunction;
 use values::generics::box_::AnimationIterationCount;
 use values::generics::transform::{StepPosition, TimingFunction as GenericTimingFunction};
 
@@ -47,17 +48,17 @@ pub enum KeyframesRunningState {
     /// This animation is actually running.
     Running,
 }
 
 /// This structure represents the current keyframe animation state, i.e., the
 /// duration, the current and maximum iteration count, and the state (either
 /// playing or paused).
 // TODO: unify the use of f32/f64 in this file.
-#[derive(Clone, Debug)]
+#[derive(Clone)]
 pub struct KeyframesAnimationState {
     /// The time this animation started at.
     pub started_at: f64,
     /// The duration of this animation.
     pub duration: f64,
     /// The delay of the animation.
     pub delay: f64,
     /// The current iteration state for the animation.
@@ -178,16 +179,32 @@ impl KeyframesAnimationState {
     fn is_paused(&self) -> bool {
         match self.running_state {
             KeyframesRunningState::Paused(..) => true,
             KeyframesRunningState::Running => false,
         }
     }
 }
 
+impl fmt::Debug for KeyframesAnimationState {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        f.debug_struct("KeyframesAnimationState")
+            .field("started_at", &self.started_at)
+            .field("duration", &self.duration)
+            .field("delay", &self.delay)
+            .field("iteration_state", &self.iteration_state)
+            .field("running_state", &self.running_state)
+            .field("direction", &self.direction)
+            .field("current_direction", &self.current_direction)
+            .field("expired", &self.expired)
+            .field("cascade_style", &())
+            .finish()
+    }
+}
+
 /// State relating to an animation.
 #[derive(Clone, Debug)]
 pub enum Animation {
     /// A transition is just a single frame triggered at a time, with a reflow.
     ///
     /// the f64 field is the start time as returned by `time::precise_time_s()`.
     ///
     /// The `bool` field is werther this animation should no longer run.