From 97f29c893f19eb0edb890ba2a57e6bdb164d258b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 18 Jun 2020 20:03:04 +0200 Subject: [PATCH] style: Fix gecko build. --- components/style/animation.rs | 7 +++--- components/style/dom.rs | 12 ---------- components/style/gecko/wrapper.rs | 24 ++++++++++--------- components/style/matching.rs | 5 ++-- .../style/properties/declaration_block.rs | 2 +- components/style/style_resolver.rs | 2 +- components/style/values/specified/box.rs | 9 +++---- 7 files changed, 27 insertions(+), 34 deletions(-) diff --git a/components/style/animation.rs b/components/style/animation.rs index 78b15d22cfb..197ba5be0cf 100644 --- a/components/style/animation.rs +++ b/components/style/animation.rs @@ -889,7 +889,8 @@ impl ElementAnimationSet { } } - pub(crate) fn apply_active_animations( + /// Apply all active animations. + pub fn apply_active_animations( &self, context: &SharedStyleContext, style: &mut Arc, @@ -1237,7 +1238,7 @@ impl DocumentAnimationSet { /// Get all the animation declarations for the given key, returning an empty /// `AnimationDeclarations` if there are no animations. - pub(crate) fn get_all_declarations( + pub fn get_all_declarations( &self, key: &AnimationSetKey, time: f64, @@ -1264,7 +1265,7 @@ impl DocumentAnimationSet { } /// Cancel all animations for set at the given key. - pub(crate) fn cancel_all_animations_for_key(&self, key: &AnimationSetKey) { + pub fn cancel_all_animations_for_key(&self, key: &AnimationSetKey) { if let Some(set) = self.sets.write().get_mut(key) { set.cancel_all_animations(); } diff --git a/components/style/dom.rs b/components/style/dom.rs index a61739b920e..60e1be054d6 100644 --- a/components/style/dom.rs +++ b/components/style/dom.rs @@ -884,18 +884,6 @@ pub trait TElement: doc_rules_apply } - /// Does a rough (and cheap) check for whether or not transitions might need to be updated that - /// will quickly return false for the common case of no transitions specified or running. If - /// this returns false, we definitely don't need to update transitions but if it returns true - /// we can perform the more thoroughgoing check, needs_transitions_update, to further - /// reduce the possibility of false positives. - #[cfg(feature = "gecko")] - fn might_need_transitions_update( - &self, - old_values: Option<&ComputedValues>, - new_values: &ComputedValues, - ) -> bool; - /// Returns true if one of the transitions needs to be updated on this element. We check all /// the transition properties to make sure that updating transitions is necessary. /// This method should only be called if might_needs_transitions_update returns true when diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs index e301bdd1107..9d63be36cd4 100644 --- a/components/style/gecko/wrapper.rs +++ b/components/style/gecko/wrapper.rs @@ -567,6 +567,12 @@ impl<'le> GeckoElement<'le> { unsafe { self.0.mServoData.get().as_ref() } } + /// Returns whether any animation applies to this element. + #[inline] + pub fn has_any_animation(&self) -> bool { + self.may_have_animations() && unsafe { Gecko_ElementHasAnimations(self.0) } + } + #[inline(always)] fn attrs(&self) -> &[structs::AttrArray_InternalAttr] { unsafe { @@ -1235,11 +1241,11 @@ impl<'le> TElement for GeckoElement<'le> { } } - fn animation_rule(&self) -> Option>> { + fn animation_rule(&self, _: &SharedStyleContext) -> Option>> { get_animation_rule(self, CascadeLevel::Animations) } - fn transition_rule(&self) -> Option>> { + fn transition_rule(&self, _: &SharedStyleContext) -> Option>> { get_animation_rule(self, CascadeLevel::Transitions) } @@ -1516,8 +1522,9 @@ impl<'le> TElement for GeckoElement<'le> { } } - fn has_animations(&self) -> bool { - self.may_have_animations() && unsafe { Gecko_ElementHasAnimations(self.0) } + #[inline] + fn has_animations(&self, _: &SharedStyleContext) -> bool { + self.has_any_animation() } fn has_css_animations(&self, _: &SharedStyleContext, _: Option) -> bool { @@ -1529,7 +1536,8 @@ impl<'le> TElement for GeckoElement<'le> { } // Detect if there are any changes that require us to update transitions. - // This is used as a more thoroughgoing check than the, cheaper + // + // This is used as a more thoroughgoing check than the cheaper // might_need_transitions_update check. // // The following logic shadows the logic used on the Gecko side @@ -1544,12 +1552,6 @@ impl<'le> TElement for GeckoElement<'le> { ) -> bool { use crate::properties::LonghandIdSet; - debug_assert!( - self.might_need_transitions_update(Some(before_change_style), after_change_style), - "We should only call needs_transitions_update if \ - might_need_transitions_update returns true" - ); - let after_change_box_style = after_change_style.get_box(); let existing_transitions = self.css_transitions_info(); let mut transitions_to_keep = LonghandIdSet::new(); diff --git a/components/style/matching.rs b/components/style/matching.rs index 31ba54a37e0..8e4398bc8c2 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -391,6 +391,7 @@ trait PrivateMatchMethods: TElement { use crate::context::UpdateAnimationsTasks; let new_values = new_styles.primary_style_mut(); + let old_values = &old_styles.primary; if context.shared.traversal_flags.for_animation_only() { self.handle_display_change_for_smil_if_needed( context, @@ -420,7 +421,7 @@ trait PrivateMatchMethods: TElement { new_values, /* pseudo_element = */ None, ) { - let after_change_style = if self.has_css_transitions(context.shared) { + let after_change_style = if self.has_css_transitions(context.shared, /* pseudo_element = */ None) { self.after_change_style(context, new_values) } else { None @@ -453,7 +454,7 @@ trait PrivateMatchMethods: TElement { None }; - if self.has_animations() { + if self.has_animations(&context.shared) { tasks.insert(UpdateAnimationsTasks::EFFECT_PROPERTIES); if important_rules_changed { tasks.insert(UpdateAnimationsTasks::CASCADE_RESULTS); diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs index 2bb7a8c7442..fe52e6059c7 100644 --- a/components/style/properties/declaration_block.rs +++ b/components/style/properties/declaration_block.rs @@ -39,7 +39,7 @@ pub struct AnimationDeclarations { impl AnimationDeclarations { /// Whether or not this `AnimationDeclarations` is empty. - pub(crate) fn is_empty(&self) -> bool { + pub fn is_empty(&self) -> bool { self.animations.is_none() && self.transitions.is_none() } } diff --git a/components/style/style_resolver.rs b/components/style/style_resolver.rs index c1f20ee0c27..8caf3cec4c3 100644 --- a/components/style/style_resolver.rs +++ b/components/style/style_resolver.rs @@ -307,7 +307,7 @@ where } /// Cascade a set of rules for pseudo element, using the default parent for inheritance. - pub(crate) fn cascade_style_and_visited_for_pseudo_with_default_parents( + pub fn cascade_style_and_visited_for_pseudo_with_default_parents( &mut self, inputs: CascadeInputs, pseudo: &PseudoElement, diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index 676262500f0..6fc86b48678 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -35,14 +35,15 @@ fn moz_box_display_values_enabled(context: &ParserContext) -> bool { } fn flexbox_enabled() -> bool { - if cfg!(feature = "servo-layout-2020") { - servo_config::prefs::pref_map() + #[cfg(feature = "servo-layout-2020")] + { + return servo_config::prefs::pref_map() .get("layout.flexbox.enabled") .as_bool() .unwrap_or(false) - } else { - true } + + true } /// Defines an element’s display type, which consists of