author | Emilio Cobos Álvarez <emilio@crisal.io> |
Thu, 18 Jun 2020 18:14:29 +0000 | |
changeset 536378 | 206011a5cc20c369785442fb03a8d377125e4675 |
parent 536377 | a3dfa01e1721a81bcf5a4dfd6fa67c0b16809afb |
child 536379 | ef8485a16d099e24f4832178664c5a93a28396ec |
push id | 119420 |
push user | ealvarez@mozilla.com |
push date | Thu, 18 Jun 2020 18:18:12 +0000 |
treeherder | autoland@206011a5cc20 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1646811 |
milestone | 79.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
|
--- a/servo/components/style/animation.rs +++ b/servo/components/style/animation.rs @@ -884,17 +884,18 @@ impl ElementAnimationSet { for transition in self.transitions.iter_mut() { if transition.state != AnimationState::Finished { self.dirty = true; transition.state = AnimationState::Canceled; } } } - pub(crate) fn apply_active_animations( + /// Apply all active animations. + pub fn apply_active_animations( &self, context: &SharedStyleContext, style: &mut Arc<ComputedValues>, ) { let now = context.current_time_for_animations; let mutable_style = Arc::make_mut(style); if let Some(map) = self.get_value_map_for_active_animations(now) { for value in map.values() { @@ -1232,17 +1233,17 @@ impl DocumentAnimationSet { .map(|map| { let block = PropertyDeclarationBlock::from_animation_value_map(&map); Arc::new(shared_lock.wrap(block)) }) } /// 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, shared_lock: &SharedRwLock, ) -> AnimationDeclarations { let sets = self.sets.read(); let set = match sets.get(key) { Some(set) => set, @@ -1259,17 +1260,17 @@ impl DocumentAnimationSet { }); AnimationDeclarations { animations, transitions, } } /// 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(); } } } /// Kick off any new transitions for this node and return all of the properties that are /// transitioning. This is at the end of calculating style for a single node.
--- a/servo/components/style/dom.rs +++ b/servo/components/style/dom.rs @@ -879,28 +879,16 @@ 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 /// passed the same parameters. #[cfg(feature = "gecko")] fn needs_transitions_update( &self, before_change_style: &ComputedValues,
--- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -562,16 +562,22 @@ impl<'le> fmt::Debug for GeckoElement<'l impl<'le> GeckoElement<'le> { /// Gets the raw `ElementData` refcell for the element. #[inline(always)] pub fn get_data(&self) -> Option<&AtomicRefCell<ElementData>> { 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 { let attrs = match self.0.mAttrs.mImpl.mPtr.as_ref() { Some(attrs) => attrs, None => return &[], }; @@ -1230,21 +1236,21 @@ impl<'le> TElement for GeckoElement<'le> Locked::<PropertyDeclarationBlock>::as_arc( &*(&raw as *const &structs::RawServoDeclarationBlock), ) .borrow_arc(), ) } } - fn animation_rule(&self) -> Option<Arc<Locked<PropertyDeclarationBlock>>> { + fn animation_rule(&self, _: &SharedStyleContext) -> Option<Arc<Locked<PropertyDeclarationBlock>>> { get_animation_rule(self, CascadeLevel::Animations) } - fn transition_rule(&self) -> Option<Arc<Locked<PropertyDeclarationBlock>>> { + fn transition_rule(&self, _: &SharedStyleContext) -> Option<Arc<Locked<PropertyDeclarationBlock>>> { get_animation_rule(self, CascadeLevel::Transitions) } #[inline] fn state(&self) -> ElementState { ElementState::from_bits_truncate(self.state_internal()) } @@ -1511,50 +1517,46 @@ impl<'le> TElement for GeckoElement<'le> self.0, before_change_values, computed_values_opt, tasks.bits(), ); } } - 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<PseudoElement>) -> bool { self.may_have_animations() && unsafe { Gecko_ElementHasCSSAnimations(self.0) } } fn has_css_transitions(&self, _: &SharedStyleContext, _: Option<PseudoElement>) -> bool { self.may_have_animations() && unsafe { Gecko_ElementHasCSSTransitions(self.0) } } // 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 // (nsTransitionManager::DoUpdateTransitions) where we actually perform the // update. // // https://drafts.csswg.org/css-transitions/#starting fn needs_transitions_update( &self, before_change_style: &ComputedValues, after_change_style: &ComputedValues, ) -> 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(); for transition_property in after_change_style.transition_properties() { let physical_longhand = transition_property .longhand_id .to_physical(after_change_style.writing_mode); transitions_to_keep.insert(physical_longhand);
--- a/servo/components/style/matching.rs +++ b/servo/components/style/matching.rs @@ -386,16 +386,17 @@ trait PrivateMatchMethods: TElement { old_styles: &mut ElementStyles, new_styles: &mut ResolvedElementStyles, restyle_hint: RestyleHint, important_rules_changed: bool, ) { 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, old_values.as_ref().map(|v| &**v), new_values, restyle_hint, ); return; @@ -415,17 +416,17 @@ trait PrivateMatchMethods: TElement { } let before_change_style = if self.might_need_transitions_update( context, old_values.as_ref().map(|s| &**s), 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 }; // In order to avoid creating a SequentialTask for transitions which // may not be updated, we check it per property to make sure Gecko // side will really update transition. @@ -448,17 +449,17 @@ trait PrivateMatchMethods: TElement { old_values.clone() } else { None } } else { 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); } if new_values.is_display_property_changed_from_none(old_values.as_ref().map(|s| &**s)) { tasks.insert(UpdateAnimationsTasks::DISPLAY_CHANGED_FROM_NONE); } }
--- a/servo/components/style/properties/declaration_block.rs +++ b/servo/components/style/properties/declaration_block.rs @@ -34,17 +34,17 @@ pub struct AnimationDeclarations { /// Declarations for animations. pub animations: Option<Arc<Locked<PropertyDeclarationBlock>>>, /// Declarations for transitions. pub transitions: Option<Arc<Locked<PropertyDeclarationBlock>>>, } 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() } } /// An enum describes how a declaration should update /// the declaration block. #[derive(Clone, Copy, Debug, Eq, PartialEq)]
--- a/servo/components/style/style_resolver.rs +++ b/servo/components/style/style_resolver.rs @@ -302,17 +302,17 @@ where parent_style, layout_parent_style, /* pseudo = */ None, ) }) } /// 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, primary_style: &PrimaryStyle, ) -> ResolvedStyle { with_default_parent_styles(self.element, |_, layout_parent_style| { let layout_parent_style_for_pseudo = layout_parent_style_for_pseudo(primary_style, layout_parent_style);
--- a/servo/components/style/values/specified/box.rs +++ b/servo/components/style/values/specified/box.rs @@ -30,24 +30,25 @@ fn moz_display_values_enabled(context: & #[cfg(feature = "gecko")] fn moz_box_display_values_enabled(context: &ParserContext) -> bool { context.in_ua_or_chrome_sheet() || static_prefs::pref!("layout.css.xul-box-display-values.content.enabled") } 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 /// the two basic qualities of how an element generates boxes /// <https://drafts.csswg.org/css-display/#propdef-display> #[allow(missing_docs)] #[derive(Clone, Copy, Debug, Eq, FromPrimitive, Hash, MallocSizeOf, PartialEq, ToCss, ToShmem)] #[repr(u8)]
--- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -5490,17 +5490,17 @@ fn create_context_for_animation<'a>( font_metrics_provider: &'a dyn FontMetricsProvider, style: &'a ComputedValues, parent_style: Option<&'a ComputedValues>, for_smil_animation: bool, rule_cache_conditions: &'a mut RuleCacheConditions, ) -> Context<'a> { Context { builder: StyleBuilder::for_animation(per_doc_data.stylist.device(), style, parent_style), - font_metrics_provider: font_metrics_provider, + font_metrics_provider, cached_system_font: None, in_media_query: false, quirks_mode: per_doc_data.stylist.quirks_mode(), for_smil_animation, for_non_inherited_property: None, rule_cache_conditions: RefCell::new(rule_cache_conditions), } } @@ -6354,17 +6354,17 @@ pub extern "C" fn Servo_ProcessInvalidat #[no_mangle] pub extern "C" fn Servo_HasPendingRestyleAncestor( element: &RawGeckoElement, may_need_to_flush_layout: bool, ) -> bool { let mut has_yet_to_be_styled = false; let mut element = Some(GeckoElement(element)); while let Some(e) = element { - if e.has_animations() { + if e.has_any_animation() { return true; } // If the element needs a frame, it means that we haven't styled it yet // after it got inserted in the document, and thus we may need to do // that for transitions and animations to trigger. // // This is a fast path in the common case, but `has_yet_to_be_styled` is