From 71dbc6c023320d29ae591e6010ece33b6e9c8d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sat, 20 May 2017 11:56:48 +0200 Subject: [PATCH] Bug 1366427: Make backdrop not inherit from the parent element. r=heycam MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MozReview-Commit-ID: EnnmvDsgbdx Signed-off-by: Emilio Cobos Álvarez --- components/style/gecko/pseudo_element.rs | 9 +++++++++ components/style/stylist.rs | 6 +++--- ports/geckolib/glue.rs | 6 +++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/components/style/gecko/pseudo_element.rs b/components/style/gecko/pseudo_element.rs index b15e17e6f38..93da2b589d0 100644 --- a/components/style/gecko/pseudo_element.rs +++ b/components/style/gecko/pseudo_element.rs @@ -49,6 +49,15 @@ impl PseudoElement { 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 { diff --git a/components/style/stylist.rs b/components/style/stylist.rs index a2f358b3f22..f1c541b8ef1 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -630,7 +630,7 @@ impl Stylist { guards: &StylesheetGuards, element: &E, pseudo: &PseudoElement, - parent: &Arc, + parent_style: &ComputedValues, font_metrics: &FontMetricsProvider) -> Option where E: TElement, @@ -649,8 +649,8 @@ impl Stylist { properties::cascade(&self.device, &rule_node, guards, - Some(&**parent), - Some(&**parent), + Some(parent_style), + Some(parent_style), None, &RustLogReporter, font_metrics, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 55c031351c8..362c5804427 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -1205,7 +1205,11 @@ fn get_pseudo_style(guard: &SharedRwLockReadGuard, 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,