Bug 1366427: Make backdrop not inherit from the parent element. r?heycam
MozReview-Commit-ID: EnnmvDsgbdx
--- a/servo/components/style/gecko/pseudo_element.rs
+++ b/servo/components/style/gecko/pseudo_element.rs
@@ -44,16 +44,24 @@ impl PseudoElement {
if self.is_anon_box() {
return PseudoElementCascadeType::Precomputed
}
PseudoElementCascadeType::Lazy
}
+ /// Whether the pseudo-element should inherit from the parent element.
+ ///
+ /// This is the common thing, but there are some pseudos (namely:
+ /// ::backdrop), that shouldn't inherit from the parent element.
+ pub fn inherits_from_parent(&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
@@ -627,17 +627,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
@@ -646,18 +646,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
@@ -1177,17 +1177,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_parent() {
+ styles.primary.values()
+ } else {
+ d.default_computed_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())