Bug 1418867 - Fall back to re-resolve style if the parent element has no style data for the given pseudo element. r?emilio draft
authorHiroyuki Ikezoe <hikezoe@mozilla.com>
Tue, 21 Nov 2017 18:08:03 +0900
changeset 701147 2e8f56c3f43cdf67fc01beb542c27de1d4670727
parent 701146 efde9a0014d1110844c2e9dee46d481169ec0495
child 701148 941cbe63bbcba4ab8ebb23093d105eb70369b93a
push id90087
push userhikezoe@mozilla.com
push dateTue, 21 Nov 2017 09:09:46 +0000
reviewersemilio
bugs1418867
milestone59.0a1
Bug 1418867 - Fall back to re-resolve style if the parent element has no style data for the given pseudo element. r?emilio MozReview-Commit-ID: DkyMwdz2DhE
servo/ports/geckolib/glue.rs
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -803,28 +803,23 @@ pub extern "C" fn Servo_StyleSet_GetBase
     if without_animations_rules == *rules {
         return computed_values.clone_arc().into();
     }
 
     let element = GeckoElement(element);
 
     if let Some(pseudo) = element.implemented_pseudo_element() {
         let parent_element = element.inheritance_parent();
-        let parent_data = match parent_element.as_ref().and_then(|e| e.borrow_data()) {
-            Some(data) => data,
-            None => return computed_values.clone_arc().into(),
-        };
-
-        let styles = &parent_data.styles;
-        // This style already doesn't have animations.
-        return styles
-            .pseudos
-            .get(&pseudo)
-            .expect("GetBaseComputedValuesForElement for an unexisting pseudo?")
-            .clone().into();
+        let parent_data = parent_element.as_ref().and_then(|e| e.borrow_data());
+        if let Some(parent_data) = parent_data {
+            // If there is the style for the pseudo, it already doesn't have animations.
+            if let Some(pseudo_style) = parent_data.styles.pseudos.get(&pseudo) {
+                return pseudo_style.clone().into();
+            }
+        }
     }
 
     let global_style_data = &*GLOBAL_STYLE_DATA;
     let guard = global_style_data.shared_lock.read();
     let shared = create_shared_context(&global_style_data,
                                        &guard,
                                        &doc_data,
                                        TraversalFlags::empty(),