Bug 1346408 - Pass pseudo computed style and its parent style of the pseudo element. r?heycam draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 14 Mar 2017 06:45:12 +0900
changeset 497826 2bc4dd3761fecb3785af372f914903389767f4de
parent 497813 727412152afc7cf3530ce0fd9f2199aa84aa33a0
child 497827 0b1a50e47e13e06d00775e854f172077aba690e0
push id49020
push userhikezoe@mozilla.com
push dateMon, 13 Mar 2017 22:01:01 +0000
reviewersheycam
bugs1346408
milestone55.0a1
Bug 1346408 - Pass pseudo computed style and its parent style of the pseudo element. r?heycam MozReview-Commit-ID: EpSM6Tf5GbM
servo/components/style/gecko/wrapper.rs
--- a/servo/components/style/gecko/wrapper.rs
+++ b/servo/components/style/gecko/wrapper.rs
@@ -501,34 +501,41 @@ impl<'le> TElement for GeckoElement<'le>
     }
 
     fn has_selector_flags(&self, flags: ElementSelectorFlags) -> bool {
         let node_flags = selector_flags_to_node_flags(flags);
         (self.flags() & node_flags) == node_flags
     }
 
     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
         // since it means the element is in a display:none subtree, we should destroy
         // all CSS animations in display:none subtree.
         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|
             *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_values = parent_data.as_ref().map(|d| d.styles().primary.values());
         let parent_values_opt = parent_values.map(|v|
             *HasArcFFI::arc_as_borrowed(v)
         );
 
+        let atom_ptr = PseudoElement::ns_atom_or_null_from_opt(pseudo);
         unsafe {
             Gecko_UpdateAnimations(self.0, atom_ptr,
                                    computed_values_opt,
                                    parent_values_opt);
         }
     }
 
     fn has_css_animations(&self, pseudo: Option<&PseudoElement>) -> bool {