style: Cleanup GeckoElement::note_explicit_hints.

What it's doing is not so complicated.
This commit is contained in:
Emilio Cobos Álvarez 2018-02-16 18:59:00 +01:00
parent 36e6d57aee
commit 2c03609dc1
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 23 additions and 27 deletions

View file

@ -699,7 +699,7 @@ impl<'le> GeckoElement<'le> {
/// animation.
///
/// Also this function schedules style flush.
pub fn note_explicit_hints(
pub unsafe fn note_explicit_hints(
&self,
restyle_hint: nsRestyleHint,
change_hint: nsChangeHint,
@ -716,32 +716,25 @@ impl<'le> GeckoElement<'le> {
restyle_hint.has_non_animation_hint()),
"Animation restyle hints should not appear with non-animation restyle hints");
let mut maybe_data = self.mutate_data();
let should_restyle = maybe_data.as_mut().map_or(false, |d| unsafe {
if !d.has_styles() {
return false;
let mut data = match self.mutate_data() {
Some(d) => d,
None => {
debug!("(Element not styled, discarding hints)");
return;
}
};
// Propagate the bit up the chain.
if restyle_hint.has_animation_hint() {
bindings::Gecko_NoteAnimationOnlyDirtyElement(self.0);
} else {
bindings::Gecko_NoteDirtyElement(self.0);
}
debug_assert!(data.has_styles(), "how?");
true
});
if should_restyle {
maybe_data
.as_mut()
.unwrap()
.hint
.insert(restyle_hint.into());
maybe_data.as_mut().unwrap().damage |= damage;
// Propagate the bit up the chain.
if restyle_hint.has_animation_hint() {
bindings::Gecko_NoteAnimationOnlyDirtyElement(self.0);
} else {
debug!("(Element not styled, discarding hints)");
bindings::Gecko_NoteDirtyElement(self.0);
}
data.hint.insert(restyle_hint);
data.damage |= damage;
}
/// This logic is duplicated in Gecko's nsIContent::IsRootOfAnonymousSubtree.
@ -1313,8 +1306,7 @@ impl<'le> TElement for GeckoElement<'le> {
}
/// Process various tasks that are a result of animation-only restyle.
fn process_post_animation(&self,
tasks: PostAnimationTasks) {
fn process_post_animation(&self, tasks: PostAnimationTasks) {
use gecko_bindings::structs::nsChangeHint_nsChangeHint_Empty;
use gecko_bindings::structs::nsRestyleHint_eRestyle_Subtree;
@ -1329,8 +1321,12 @@ impl<'le> TElement for GeckoElement<'le> {
.map_or(true, |p| !p.is_before_or_after()),
"display property animation shouldn't run on pseudo elements \
since it's only for SMIL");
self.note_explicit_hints(nsRestyleHint_eRestyle_Subtree,
nsChangeHint_nsChangeHint_Empty);
unsafe {
self.note_explicit_hints(
nsRestyleHint_eRestyle_Subtree,
nsChangeHint_nsChangeHint_Empty,
);
}
}
}