servo: Merge #16981 - Bug 1366427: Make backdrop not inherit from the parent element. r=heycam (from emilio:backdrop); r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 23 May 2017 02:25:07 -0500
changeset 360151 73f9c356e3673b52870bc768cae0eb7f49d140af
parent 360150 46704306beac283ab27d233378d8f20f12218320
child 360152 8cc336b9806d0d16a0ae19d81fed5b2372ac7ea1
push id31871
push userryanvm@gmail.com
push dateTue, 23 May 2017 22:02:07 +0000
treeherdermozilla-central@545ffce30eac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, heycam
bugs1366427
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #16981 - Bug 1366427: Make backdrop not inherit from the parent element. r=heycam (from emilio:backdrop); r=heycam Source-Repo: https://github.com/servo/servo Source-Revision: 17069f4876670d5a4f310e449f8bc78bbb45c827
servo/components/style/gecko/pseudo_element.rs
servo/components/style/stylist.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/gecko/pseudo_element.rs
+++ b/servo/components/style/gecko/pseudo_element.rs
@@ -44,16 +44,25 @@ impl PseudoElement {
 
         if self.is_anon_box() {
             return PseudoElementCascadeType::Precomputed
         }
 
         PseudoElementCascadeType::Lazy
     }
 
+    /// Whether the pseudo-element should inherit from the default computed
+    /// values instead of from the parent element.
+    ///
+    /// This is not the common thing, but there are some pseudos (namely:
+    /// ::backdrop), that shouldn't inherit from the parent element.
+    pub fn inherits_from_default_values(&self) -> bool {
+        !matches!(*self, PseudoElement::Backdrop)
+    }
+
     /// Gets the canonical index of this eagerly-cascaded pseudo-element.
     #[inline]
     pub fn eager_index(&self) -> usize {
         EAGER_PSEUDOS.iter().position(|p| p == self)
             .expect("Not an eager pseudo")
     }
 
     /// Creates a pseudo-element from an eager index.
--- a/servo/components/style/stylist.rs
+++ b/servo/components/style/stylist.rs
@@ -623,17 +623,17 @@ impl Stylist {
     /// :selection.
     ///
     /// Check the documentation on lazy pseudo-elements in
     /// docs/components/style.md
     pub fn lazily_compute_pseudo_element_style<E>(&self,
                                                   guards: &StylesheetGuards,
                                                   element: &E,
                                                   pseudo: &PseudoElement,
-                                                  parent: &Arc<ComputedValues>,
+                                                  parent_style: &ComputedValues,
                                                   font_metrics: &FontMetricsProvider)
                                                   -> Option<ComputedStyle>
         where E: TElement,
     {
         let rule_node =
             match self.lazy_pseudo_rules(guards, element, pseudo) {
                 Some(rule_node) => rule_node,
                 None => return None
@@ -642,18 +642,18 @@ impl Stylist {
         // Read the comment on `precomputed_values_for_pseudo` to see why it's
         // difficult to assert that display: contents nodes never arrive here
         // (tl;dr: It doesn't apply for replaced elements and such, but the
         // computed value is still "contents").
         let computed =
             properties::cascade(&self.device,
                                 &rule_node,
                                 guards,
-                                Some(&**parent),
-                                Some(&**parent),
+                                Some(parent_style),
+                                Some(parent_style),
                                 None,
                                 &RustLogReporter,
                                 font_metrics,
                                 CascadeFlags::empty(),
                                 self.quirks_mode);
 
         Some(ComputedStyle::new(rule_node, Arc::new(computed)))
     }
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1198,17 +1198,21 @@ fn get_pseudo_style(guard: &SharedRwLock
                     doc_data: &PerDocumentStyleData)
                     -> Option<Arc<ComputedValues>>
 {
     match pseudo.cascade_type() {
         PseudoElementCascadeType::Eager => styles.pseudos.get(&pseudo).map(|s| s.values().clone()),
         PseudoElementCascadeType::Precomputed => unreachable!("No anonymous boxes"),
         PseudoElementCascadeType::Lazy => {
             let d = doc_data.borrow_mut();
-            let base = styles.primary.values();
+            let base = if pseudo.inherits_from_default_values() {
+                d.default_computed_values()
+            } else {
+                styles.primary.values()
+            };
             let guards = StylesheetGuards::same(guard);
             let metrics = get_metrics_provider_for_product();
             d.stylist.lazily_compute_pseudo_element_style(&guards,
                                                           &element,
                                                           &pseudo,
                                                           base,
                                                           &metrics)
                      .map(|s| s.values().clone())