From bc4e670c5ae2d0a5e281d05e03f5c1621219e4d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 30 Jun 2016 14:37:08 -0700 Subject: [PATCH] style: Add a temporary workaround for geckolib animations. With needs_borrow we will be able to remove this, though we'll have to implement clone_ and borrow_ methods for a bunch of properties. --- components/style/animation.rs | 5 +++++ components/style/properties/properties.mako.rs | 5 +++++ ports/geckolib/properties.mako.rs | 1 + 3 files changed, 11 insertions(+) diff --git a/components/style/animation.rs b/components/style/animation.rs index b2a64a5fa5e6..ba833937f6ba 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -422,6 +422,11 @@ pub fn maybe_start_animations(context: &SharedStyleContex { let mut had_animations = false; + // FIXME(emilio): Implement animations for geckolib. + if !new_style.is_servo() { + return false; + } + let box_style = new_style.as_servo().get_box(); for (i, name) in box_style.animation_name.0.iter().enumerate() { debug!("maybe_start_animations: name={}", name); diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index f73219afe0e0..bfdb6cd378f9 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1259,6 +1259,7 @@ pub trait ComputedValues : Debug + Clone + Send + Sync + 'static { // yet - panics for non-Servo implementations. // // Used only for animations. Don't use it in other places. + fn is_servo(&self) -> bool; fn as_servo<'a>(&'a self) -> &'a ServoComputedValues; fn as_servo_mut<'a>(&'a mut self) -> &'a mut ServoComputedValues; @@ -1310,7 +1311,11 @@ impl ComputedValues for ServoComputedValues { type Concrete${style_struct.trait_name} = style_structs::${style_struct.servo_struct_name}; % endfor + #[inline] + fn is_servo(&self) -> bool { true } + #[inline] fn as_servo<'a>(&'a self) -> &'a ServoComputedValues { self } + #[inline] fn as_servo_mut<'a>(&'a mut self) -> &'a mut ServoComputedValues { self } fn new(custom_properties: Option>, diff --git a/ports/geckolib/properties.mako.rs b/ports/geckolib/properties.mako.rs index 94e8f794a898..c66598fa0d33 100644 --- a/ports/geckolib/properties.mako.rs +++ b/ports/geckolib/properties.mako.rs @@ -74,6 +74,7 @@ impl ComputedValues for GeckoComputedValues { % endfor // These will go away, and we will never implement them. + fn is_servo(&self) -> bool { false } fn as_servo<'a>(&'a self) -> &'a ServoComputedValues { unimplemented!() } fn as_servo_mut<'a>(&'a mut self) -> &'a mut ServoComputedValues { unimplemented!() }