style: Fix gecko build.

This commit is contained in:
Emilio Cobos Álvarez 2020-06-18 20:03:04 +02:00
parent 059a50bba0
commit 97f29c893f
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
7 changed files with 27 additions and 34 deletions

View file

@ -889,7 +889,8 @@ impl ElementAnimationSet {
} }
} }
pub(crate) fn apply_active_animations( /// Apply all active animations.
pub fn apply_active_animations(
&self, &self,
context: &SharedStyleContext, context: &SharedStyleContext,
style: &mut Arc<ComputedValues>, style: &mut Arc<ComputedValues>,
@ -1237,7 +1238,7 @@ impl DocumentAnimationSet {
/// Get all the animation declarations for the given key, returning an empty /// Get all the animation declarations for the given key, returning an empty
/// `AnimationDeclarations` if there are no animations. /// `AnimationDeclarations` if there are no animations.
pub(crate) fn get_all_declarations( pub fn get_all_declarations(
&self, &self,
key: &AnimationSetKey, key: &AnimationSetKey,
time: f64, time: f64,
@ -1264,7 +1265,7 @@ impl DocumentAnimationSet {
} }
/// Cancel all animations for set at the given key. /// 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) { if let Some(set) = self.sets.write().get_mut(key) {
set.cancel_all_animations(); set.cancel_all_animations();
} }

View file

@ -884,18 +884,6 @@ pub trait TElement:
doc_rules_apply 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 /// 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. /// 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 /// This method should only be called if might_needs_transitions_update returns true when

View file

@ -567,6 +567,12 @@ impl<'le> GeckoElement<'le> {
unsafe { self.0.mServoData.get().as_ref() } 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)] #[inline(always)]
fn attrs(&self) -> &[structs::AttrArray_InternalAttr] { fn attrs(&self) -> &[structs::AttrArray_InternalAttr] {
unsafe { unsafe {
@ -1235,11 +1241,11 @@ impl<'le> TElement for GeckoElement<'le> {
} }
} }
fn animation_rule(&self) -> Option<Arc<Locked<PropertyDeclarationBlock>>> { fn animation_rule(&self, _: &SharedStyleContext) -> Option<Arc<Locked<PropertyDeclarationBlock>>> {
get_animation_rule(self, CascadeLevel::Animations) 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) get_animation_rule(self, CascadeLevel::Transitions)
} }
@ -1516,8 +1522,9 @@ impl<'le> TElement for GeckoElement<'le> {
} }
} }
fn has_animations(&self) -> bool { #[inline]
self.may_have_animations() && unsafe { Gecko_ElementHasAnimations(self.0) } fn has_animations(&self, _: &SharedStyleContext) -> bool {
self.has_any_animation()
} }
fn has_css_animations(&self, _: &SharedStyleContext, _: Option<PseudoElement>) -> bool { fn has_css_animations(&self, _: &SharedStyleContext, _: Option<PseudoElement>) -> bool {
@ -1529,7 +1536,8 @@ impl<'le> TElement for GeckoElement<'le> {
} }
// Detect if there are any changes that require us to update transitions. // 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. // might_need_transitions_update check.
// //
// The following logic shadows the logic used on the Gecko side // The following logic shadows the logic used on the Gecko side
@ -1544,12 +1552,6 @@ impl<'le> TElement for GeckoElement<'le> {
) -> bool { ) -> bool {
use crate::properties::LonghandIdSet; 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 after_change_box_style = after_change_style.get_box();
let existing_transitions = self.css_transitions_info(); let existing_transitions = self.css_transitions_info();
let mut transitions_to_keep = LonghandIdSet::new(); let mut transitions_to_keep = LonghandIdSet::new();

View file

@ -391,6 +391,7 @@ trait PrivateMatchMethods: TElement {
use crate::context::UpdateAnimationsTasks; use crate::context::UpdateAnimationsTasks;
let new_values = new_styles.primary_style_mut(); let new_values = new_styles.primary_style_mut();
let old_values = &old_styles.primary;
if context.shared.traversal_flags.for_animation_only() { if context.shared.traversal_flags.for_animation_only() {
self.handle_display_change_for_smil_if_needed( self.handle_display_change_for_smil_if_needed(
context, context,
@ -420,7 +421,7 @@ trait PrivateMatchMethods: TElement {
new_values, new_values,
/* pseudo_element = */ None, /* 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) self.after_change_style(context, new_values)
} else { } else {
None None
@ -453,7 +454,7 @@ trait PrivateMatchMethods: TElement {
None None
}; };
if self.has_animations() { if self.has_animations(&context.shared) {
tasks.insert(UpdateAnimationsTasks::EFFECT_PROPERTIES); tasks.insert(UpdateAnimationsTasks::EFFECT_PROPERTIES);
if important_rules_changed { if important_rules_changed {
tasks.insert(UpdateAnimationsTasks::CASCADE_RESULTS); tasks.insert(UpdateAnimationsTasks::CASCADE_RESULTS);

View file

@ -39,7 +39,7 @@ pub struct AnimationDeclarations {
impl AnimationDeclarations { impl AnimationDeclarations {
/// Whether or not this `AnimationDeclarations` is empty. /// 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() self.animations.is_none() && self.transitions.is_none()
} }
} }

View file

@ -307,7 +307,7 @@ where
} }
/// Cascade a set of rules for pseudo element, using the default parent for inheritance. /// 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, &mut self,
inputs: CascadeInputs, inputs: CascadeInputs,
pseudo: &PseudoElement, pseudo: &PseudoElement,

View file

@ -35,14 +35,15 @@ fn moz_box_display_values_enabled(context: &ParserContext) -> bool {
} }
fn flexbox_enabled() -> bool { fn flexbox_enabled() -> bool {
if cfg!(feature = "servo-layout-2020") { #[cfg(feature = "servo-layout-2020")]
servo_config::prefs::pref_map() {
return servo_config::prefs::pref_map()
.get("layout.flexbox.enabled") .get("layout.flexbox.enabled")
.as_bool() .as_bool()
.unwrap_or(false) .unwrap_or(false)
} else {
true
} }
true
} }
/// Defines an elements display type, which consists of /// Defines an elements display type, which consists of