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

View file

@ -3508,7 +3508,7 @@ pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool {
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn Servo_NoteExplicitHints( pub unsafe extern "C" fn Servo_NoteExplicitHints(
element: RawGeckoElementBorrowed, element: RawGeckoElementBorrowed,
restyle_hint: nsRestyleHint, restyle_hint: nsRestyleHint,
change_hint: nsChangeHint, change_hint: nsChangeHint,