mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #15943 - hiikezoe:animation-on-pseudo, r=heycam
Use computed styles of the pseudo and its parent when calling Gecko_U… …pdateAnimations to update CSS Animations on pseudo-elements. <!-- Please describe your changes on the following line: --> This is a PR of https://bugzilla.mozilla.org/show_bug.cgi?id=1346408 . --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors <!-- Either: --> - [X] These changes do not require tests because it's for stylo <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- 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/15943) <!-- Reviewable:end -->
This commit is contained in:
commit
5a8f3ef1d5
1 changed files with 11 additions and 4 deletions
|
@ -506,24 +506,31 @@ impl<'le> TElement for GeckoElement<'le> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_animations(&self, pseudo: Option<&PseudoElement>) {
|
fn update_animations(&self, pseudo: Option<&PseudoElement>) {
|
||||||
let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo);
|
|
||||||
|
|
||||||
// We have to update animations even if the element has no computed style
|
// We have to update animations even if the element has no computed style
|
||||||
// since it means the element is in a display:none subtree, we should destroy
|
// since it means the element is in a display:none subtree, we should destroy
|
||||||
// all CSS animations in display:none subtree.
|
// all CSS animations in display:none subtree.
|
||||||
let computed_data = self.borrow_data();
|
let computed_data = self.borrow_data();
|
||||||
let computed_values = computed_data.as_ref().map(|d| d.styles().primary.values());
|
let computed_values =
|
||||||
|
computed_data.as_ref().map(|d|
|
||||||
|
pseudo.map_or_else(|| d.styles().primary.values(),
|
||||||
|
|p| d.styles().pseudos.get(p).unwrap().values())
|
||||||
|
);
|
||||||
let computed_values_opt = computed_values.map(|v|
|
let computed_values_opt = computed_values.map(|v|
|
||||||
*HasArcFFI::arc_as_borrowed(v)
|
*HasArcFFI::arc_as_borrowed(v)
|
||||||
);
|
);
|
||||||
|
|
||||||
let parent_element = self.parent_element();
|
let parent_element = if pseudo.is_some() {
|
||||||
|
self.parent_element()
|
||||||
|
} else {
|
||||||
|
Some(*self)
|
||||||
|
};
|
||||||
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
|
||||||
let parent_values = parent_data.as_ref().map(|d| d.styles().primary.values());
|
let parent_values = parent_data.as_ref().map(|d| d.styles().primary.values());
|
||||||
let parent_values_opt = parent_values.map(|v|
|
let parent_values_opt = parent_values.map(|v|
|
||||||
*HasArcFFI::arc_as_borrowed(v)
|
*HasArcFFI::arc_as_borrowed(v)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo);
|
||||||
unsafe {
|
unsafe {
|
||||||
Gecko_UpdateAnimations(self.0, atom_ptr,
|
Gecko_UpdateAnimations(self.0, atom_ptr,
|
||||||
computed_values_opt,
|
computed_values_opt,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue