Skip to content

Commit

Permalink
style: Fix gecko build.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Jun 18, 2020
1 parent 059a50b commit 97f29c8
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 34 deletions.
7 changes: 4 additions & 3 deletions components/style/animation.rs
Expand Up @@ -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<ComputedValues>,
Expand Down Expand Up @@ -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,
Expand All @@ -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();
}
Expand Down
12 changes: 0 additions & 12 deletions components/style/dom.rs
Expand Up @@ -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
Expand Down
24 changes: 13 additions & 11 deletions components/style/gecko/wrapper.rs
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

fn transition_rule(&self) -> Option<Arc<Locked<PropertyDeclarationBlock>>> {
fn transition_rule(&self, _: &SharedStyleContext) -> Option<Arc<Locked<PropertyDeclarationBlock>>> {
get_animation_rule(self, CascadeLevel::Transitions)
}

Expand Down Expand Up @@ -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<PseudoElement>) -> bool {
Expand All @@ -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
Expand All @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions components/style/matching.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion components/style/properties/declaration_block.rs
Expand Up @@ -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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/style/style_resolver.rs
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions components/style/values/specified/box.rs
Expand Up @@ -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
Expand Down

0 comments on commit 97f29c8

Please sign in to comment.