mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #14922 - heycam:pseudo-inherit, r=emilio
Don't inherit all properties for eagerly computed pseudos if there are no matching rules. <!-- Please describe your changes on the following line: --> When we resolve style for an eagerly computed pseudo-element, such as an anonymous box, if there are no matching rules we currently just clone the parent's style. We should only do that if `inherit_all` is true, otherwise we should inherit only the inherited properties from the parent. I was going to use `.unwrap_or_default()` on the result of looking up `precomputed_pseudo_element_decls`, but that didn't seem to work since that map lookup returns a reference and not a `Vec` itself. r? @emilio --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1329121 <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14922) <!-- Reviewable:end -->
This commit is contained in:
commit
ebd4a8b3ee
3 changed files with 27 additions and 27 deletions
|
@ -394,7 +394,7 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
||||||
&context.default_computed_values,
|
&context.default_computed_values,
|
||||||
false);
|
false);
|
||||||
data.styles_mut().pseudos
|
data.styles_mut().pseudos
|
||||||
.insert(style_pseudo.clone(), new_style.unwrap());
|
.insert(style_pseudo.clone(), new_style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PseudoElementCascadeType::Lazy => {
|
PseudoElementCascadeType::Lazy => {
|
||||||
|
|
|
@ -276,32 +276,33 @@ impl Stylist {
|
||||||
parent: Option<&Arc<ComputedValues>>,
|
parent: Option<&Arc<ComputedValues>>,
|
||||||
default: &Arc<ComputedValues>,
|
default: &Arc<ComputedValues>,
|
||||||
inherit_all: bool)
|
inherit_all: bool)
|
||||||
-> Option<ComputedStyle> {
|
-> ComputedStyle {
|
||||||
debug_assert!(SelectorImpl::pseudo_element_cascade_type(pseudo).is_precomputed());
|
debug_assert!(SelectorImpl::pseudo_element_cascade_type(pseudo).is_precomputed());
|
||||||
if let Some(declarations) = self.precomputed_pseudo_element_decls.get(pseudo) {
|
|
||||||
// FIXME(emilio): When we've taken rid of the cascade we can just
|
let rule_node = match self.precomputed_pseudo_element_decls.get(pseudo) {
|
||||||
// use into_iter.
|
Some(declarations) => {
|
||||||
let rule_node =
|
// FIXME(emilio): When we've taken rid of the cascade we can just
|
||||||
|
// use into_iter.
|
||||||
self.rule_tree.insert_ordered_rules(
|
self.rule_tree.insert_ordered_rules(
|
||||||
declarations.into_iter().map(|a| (a.source.clone(), a.importance)));
|
declarations.into_iter().map(|a| (a.source.clone(), a.importance)))
|
||||||
|
|
||||||
let mut flags = CascadeFlags::empty();
|
|
||||||
if inherit_all {
|
|
||||||
flags.insert(INHERIT_ALL)
|
|
||||||
}
|
}
|
||||||
|
None => self.rule_tree.root(),
|
||||||
|
};
|
||||||
|
|
||||||
let computed =
|
let mut flags = CascadeFlags::empty();
|
||||||
properties::cascade(self.device.au_viewport_size(),
|
if inherit_all {
|
||||||
&rule_node,
|
flags.insert(INHERIT_ALL)
|
||||||
parent.map(|p| &**p),
|
|
||||||
default,
|
|
||||||
None,
|
|
||||||
Box::new(StdoutErrorReporter),
|
|
||||||
flags);
|
|
||||||
Some(ComputedStyle::new(rule_node, Arc::new(computed)))
|
|
||||||
} else {
|
|
||||||
parent.map(|p| ComputedStyle::new(self.rule_tree.root(), p.clone()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let computed =
|
||||||
|
properties::cascade(self.device.au_viewport_size(),
|
||||||
|
&rule_node,
|
||||||
|
parent.map(|p| &**p),
|
||||||
|
default,
|
||||||
|
None,
|
||||||
|
Box::new(StdoutErrorReporter),
|
||||||
|
flags);
|
||||||
|
ComputedStyle::new(rule_node, Arc::new(computed))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the style for an anonymous box of the given type.
|
/// Returns the style for an anonymous box of the given type.
|
||||||
|
@ -329,7 +330,6 @@ impl Stylist {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.precomputed_values_for_pseudo(&pseudo, Some(parent_style), default_style, inherit_all)
|
self.precomputed_values_for_pseudo(&pseudo, Some(parent_style), default_style, inherit_all)
|
||||||
.expect("style_for_anonymous_box(): No precomputed values for that pseudo!")
|
|
||||||
.values
|
.values
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -521,10 +521,10 @@ pub extern "C" fn Servo_ComputedValues_GetForAnonymousBox(parent_style_or_null:
|
||||||
|
|
||||||
|
|
||||||
let maybe_parent = ComputedValues::arc_from_borrowed(&parent_style_or_null);
|
let maybe_parent = ComputedValues::arc_from_borrowed(&parent_style_or_null);
|
||||||
let new_computed = data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent,
|
data.stylist.precomputed_values_for_pseudo(&pseudo, maybe_parent,
|
||||||
&data.default_computed_values, false)
|
&data.default_computed_values, false)
|
||||||
.map(|styles| styles.values);
|
.values
|
||||||
new_computed.map_or(Strong::null(), |c| c.into_strong())
|
.into_strong()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue