mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #20065 - emilio:note-stuff, r=nox
style: Cleanup GeckoElement::note_explicit_hints What it's doing is not so complicated. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/20065) <!-- Reviewable:end -->
This commit is contained in:
commit
d423e54d58
2 changed files with 31 additions and 42 deletions
|
@ -692,33 +692,14 @@ impl<'le> GeckoElement<'le> {
|
||||||
unsafe { Gecko_GetDocumentLWTheme(node.owner_doc().0) }
|
unsafe { Gecko_GetDocumentLWTheme(node.owner_doc().0) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Only safe to call on the main thread, with exclusive access to the element and
|
/// Only safe to call on the main thread, with exclusive access to the
|
||||||
/// its ancestors.
|
/// element and its ancestors.
|
||||||
/// This function is also called after display property changed for SMIL animation.
|
///
|
||||||
|
/// This function is also called after display property changed for SMIL
|
||||||
|
/// animation.
|
||||||
///
|
///
|
||||||
/// Also this function schedules style flush.
|
/// Also this function schedules style flush.
|
||||||
unsafe fn maybe_restyle<'a>(
|
pub unsafe fn note_explicit_hints(
|
||||||
&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,
|
&self,
|
||||||
restyle_hint: nsRestyleHint,
|
restyle_hint: nsRestyleHint,
|
||||||
change_hint: nsChangeHint,
|
change_hint: nsChangeHint,
|
||||||
|
@ -735,20 +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,
|
||||||
self.maybe_restyle(d, restyle_hint.has_animation_hint())
|
None => {
|
||||||
});
|
debug!("(Element not styled, discarding hints)");
|
||||||
if should_restyle {
|
return;
|
||||||
maybe_data
|
}
|
||||||
.as_mut()
|
};
|
||||||
.unwrap()
|
|
||||||
.hint
|
debug_assert!(data.has_styles(), "how?");
|
||||||
.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 {
|
} 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.
|
||||||
|
@ -1320,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;
|
||||||
|
|
||||||
|
@ -1336,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,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3565,7 +3565,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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue