diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 73bf9b1036a..2279b8f2058 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -520,6 +520,7 @@ impl LayoutThread { local_context_creation_data: Mutex::new(thread_local_style_context_creation_data), timer: self.timer.clone(), quirks_mode: self.quirks_mode.unwrap(), + animation_only_restyle: false, }, image_cache_thread: Mutex::new(self.image_cache_thread.clone()), font_cache_thread: Mutex::new(self.font_cache_thread.clone()), diff --git a/components/style/context.rs b/components/style/context.rs index 3a2926672ac..27943243ddf 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -87,6 +87,9 @@ pub struct SharedStyleContext<'a> { /// The QuirksMode state which the document needs to be rendered with pub quirks_mode: QuirksMode, + + /// True if the traversal is processing only animation restyles. + pub animation_only_restyle: bool, } impl<'a> SharedStyleContext<'a> { diff --git a/components/style/dom.rs b/components/style/dom.rs index a0c83c88b3f..cf64e2da6b8 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -372,6 +372,16 @@ pub trait TElement : PartialEq + Debug + Sized + Copy + Clone + ElementExt + Pre /// Returns true if the element has a CSS animation. fn has_css_animations(&self, _pseudo: Option<&PseudoElement>) -> bool; + + /// Returns true if the element has animation restyle hints. + fn has_animation_restyle_hints(&self) -> bool { + let data = match self.borrow_data() { + Some(d) => d, + None => return false, + }; + return data.get_restyle() + .map_or(false, |r| r.hint.has_animation_hint()); + } } /// TNode and TElement aren't Send because we want to be careful and explicit diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 81bab36febc..b1555cc7693 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -125,7 +125,8 @@ pub extern "C" fn Servo_Shutdown() { } fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard, - per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyleContext<'a> { + per_doc_data: &PerDocumentStyleDataImpl, + animation_only: bool) -> SharedStyleContext<'a> { let local_context_data = ThreadLocalStyleContextCreationInfo::new(per_doc_data.new_animations_sender.clone()); @@ -140,6 +141,7 @@ fn create_shared_context<'a>(guard: &'a SharedRwLockReadGuard, timer: Timer::new(), // FIXME Find the real QuirksMode information for this document quirks_mode: QuirksMode::NoQuirks, + animation_only_restyle: animation_only, } } @@ -166,7 +168,8 @@ fn traverse_subtree(element: GeckoElement, raw_data: RawServoStyleSetBorrowed, let global_style_data = &*GLOBAL_STYLE_DATA; let guard = global_style_data.shared_lock.read(); - let shared_style_context = create_shared_context(&guard, &per_doc_data); + let shared_style_context = create_shared_context(&guard, &per_doc_data, + traversal_flags.for_animation_only()); let traversal_driver = if global_style_data.style_thread_pool.is_none() { TraversalDriver::Sequential @@ -1509,7 +1512,7 @@ pub extern "C" fn Servo_ResolveStyleLazily(element: RawGeckoElementBorrowed, } // We don't have the style ready. Go ahead and compute it as necessary. - let shared = create_shared_context(&guard, &mut doc_data.borrow_mut()); + let shared = create_shared_context(&guard, &mut doc_data.borrow_mut(), false); let mut tlc = ThreadLocalStyleContext::new(&shared); let mut context = StyleContext { shared: &shared,