Skip to content

Commit

Permalink
style: Inline maybe_restyle, since it only has one caller.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Feb 16, 2018
1 parent a6113af commit 36e6d57
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions components/style/gecko/wrapper.rs
Expand Up @@ -692,32 +692,13 @@ impl<'le> GeckoElement<'le> {
unsafe { Gecko_GetDocumentLWTheme(node.owner_doc().0) }
}

/// Only safe to call on the main thread, with exclusive access to the element and
/// its ancestors.
/// This function is also called after display property changed for SMIL animation.
/// Only safe to call on the main thread, with exclusive access to the
/// element and its ancestors.
///
/// This function is also called after display property changed for SMIL
/// animation.
///
/// Also this function schedules style flush.
unsafe fn maybe_restyle<'a>(
&self,
data: &'a mut ElementData,
animation_only: bool,
) -> bool {
if !data.has_styles() {
return false;
}

// Propagate the bit up the chain.
if animation_only {
bindings::Gecko_NoteAnimationOnlyDirtyElement(self.0);
} else {
bindings::Gecko_NoteDirtyElement(self.0);
}

// Ensure and return the RestyleData.
true
}

/// Set restyle and change hints to the element data.
pub fn note_explicit_hints(
&self,
restyle_hint: nsRestyleHint,
Expand All @@ -737,8 +718,20 @@ impl<'le> GeckoElement<'le> {

let mut maybe_data = self.mutate_data();
let should_restyle = maybe_data.as_mut().map_or(false, |d| unsafe {
self.maybe_restyle(d, restyle_hint.has_animation_hint())
if !d.has_styles() {
return false;
}

// Propagate the bit up the chain.
if restyle_hint.has_animation_hint() {
bindings::Gecko_NoteAnimationOnlyDirtyElement(self.0);
} else {
bindings::Gecko_NoteDirtyElement(self.0);
}

true
});

if should_restyle {
maybe_data
.as_mut()
Expand Down

0 comments on commit 36e6d57

Please sign in to comment.