Skip to content

Commit

Permalink
Factor out a new function to check display property is changed from '…
Browse files Browse the repository at this point in the history
…none' to other
  • Loading branch information
Hiroyuki Ikezoe committed Feb 21, 2018
1 parent f90e98d commit 5ba2e87
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
9 changes: 1 addition & 8 deletions components/style/matching.rs
Expand Up @@ -176,14 +176,7 @@ trait PrivateMatchMethods: TElement {
return;
}

let display_changed_from_none = old_values.map_or(false, |old| {
let old_display_style = old.get_box().clone_display();
let new_display_style = new_values.get_box().clone_display();
old_display_style == Display::None &&
new_display_style != Display::None
});

if display_changed_from_none {
if new_values.is_display_property_changed_from_none(old_values) {
// When display value is changed from none to other, we need to
// traverse descendant elements in a subsequent normal
// traversal (we can't traverse them in this animation-only restyle
Expand Down
16 changes: 16 additions & 0 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -144,6 +144,22 @@ impl ComputedValues {
return our_type == CSSPseudoElementType_InheritingAnonBox ||
our_type == CSSPseudoElementType::NonInheritingAnonBox;
}

/// Returns true if the display property is changed from 'none' to others.
pub fn is_display_property_changed_from_none(
&self,
old_values: Option<<&ComputedValues>
) -> bool {
use properties::longhands::display::computed_value::T as Display;

old_values.map_or(false, |old| {
let old_display_style = old.get_box().clone_display();
let new_display_style = self.get_box().clone_display();
old_display_style == Display::None &&
new_display_style != Display::None
})
}

}

impl Drop for ComputedValues {
Expand Down

0 comments on commit 5ba2e87

Please sign in to comment.