mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
style: Don't use rule cache for property-restricted pseudo-elements.
This commit is contained in:
parent
a7dd19cfb1
commit
30982b92c8
3 changed files with 21 additions and 3 deletions
|
@ -2600,7 +2600,7 @@ pub struct StyleBuilder<'a> {
|
|||
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
|
||||
/// The pseudo-element this style will represent.
|
||||
pseudo: Option<<&'a PseudoElement>,
|
||||
pub pseudo: Option<<&'a PseudoElement>,
|
||||
|
||||
/// Whether we have mutated any reset structs since the the last time
|
||||
/// `clear_modified_reset` was called. This is used to tell whether the
|
||||
|
|
|
@ -9,6 +9,7 @@ use fnv::FnvHashMap;
|
|||
use logical_geometry::WritingMode;
|
||||
use properties::{ComputedValues, StyleBuilder};
|
||||
use rule_tree::StrongRuleNode;
|
||||
use selector_parser::PseudoElement;
|
||||
use servo_arc::Arc;
|
||||
use smallvec::SmallVec;
|
||||
use values::computed::NonNegativeLength;
|
||||
|
@ -93,6 +94,14 @@ impl RuleCache {
|
|||
return None;
|
||||
}
|
||||
|
||||
// A pseudo-element with property restrictions can result in different
|
||||
// computed values if it's also used for a non-pseudo.
|
||||
if builder_with_early_props.pseudo
|
||||
.and_then(|p| p.property_restriction())
|
||||
.is_some() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let rules = match builder_with_early_props.rules {
|
||||
Some(ref rules) => rules,
|
||||
None => return None,
|
||||
|
@ -115,6 +124,7 @@ impl RuleCache {
|
|||
pub fn insert_if_possible(
|
||||
&mut self,
|
||||
style: &Arc<ComputedValues>,
|
||||
pseudo: Option<&PseudoElement>,
|
||||
conditions: &RuleCacheConditions,
|
||||
) -> bool {
|
||||
if !conditions.cacheable() {
|
||||
|
@ -126,6 +136,12 @@ impl RuleCache {
|
|||
return false;
|
||||
}
|
||||
|
||||
// A pseudo-element with property restrictions can result in different
|
||||
// computed values if it's also used for a non-pseudo.
|
||||
if pseudo.and_then(|p| p.property_restriction()).is_some() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let rules = match style.rules {
|
||||
Some(ref r) => r.clone(),
|
||||
None => return false,
|
||||
|
|
|
@ -574,11 +574,13 @@ where
|
|||
}
|
||||
|
||||
let implemented_pseudo = self.element.implemented_pseudo_element();
|
||||
let pseudo = pseudo.or(implemented_pseudo.as_ref());
|
||||
|
||||
let mut conditions = Default::default();
|
||||
let values =
|
||||
cascade(
|
||||
self.context.shared.stylist.device(),
|
||||
pseudo.or(implemented_pseudo.as_ref()),
|
||||
pseudo,
|
||||
rules.unwrap_or(self.context.shared.stylist.rule_tree().root()),
|
||||
&self.context.shared.guards,
|
||||
parent_style,
|
||||
|
@ -595,7 +597,7 @@ where
|
|||
self.context
|
||||
.thread_local
|
||||
.rule_cache
|
||||
.insert_if_possible(&values, &conditions);
|
||||
.insert_if_possible(&values, pseudo, &conditions);
|
||||
|
||||
values
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue