mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +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>>,
|
custom_properties: Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||||
|
|
||||||
/// The pseudo-element this style will represent.
|
/// 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
|
/// Whether we have mutated any reset structs since the the last time
|
||||||
/// `clear_modified_reset` was called. This is used to tell whether the
|
/// `clear_modified_reset` was called. This is used to tell whether the
|
||||||
|
|
|
@ -9,6 +9,7 @@ use fnv::FnvHashMap;
|
||||||
use logical_geometry::WritingMode;
|
use logical_geometry::WritingMode;
|
||||||
use properties::{ComputedValues, StyleBuilder};
|
use properties::{ComputedValues, StyleBuilder};
|
||||||
use rule_tree::StrongRuleNode;
|
use rule_tree::StrongRuleNode;
|
||||||
|
use selector_parser::PseudoElement;
|
||||||
use servo_arc::Arc;
|
use servo_arc::Arc;
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use values::computed::NonNegativeLength;
|
use values::computed::NonNegativeLength;
|
||||||
|
@ -93,6 +94,14 @@ impl RuleCache {
|
||||||
return None;
|
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 {
|
let rules = match builder_with_early_props.rules {
|
||||||
Some(ref rules) => rules,
|
Some(ref rules) => rules,
|
||||||
None => return None,
|
None => return None,
|
||||||
|
@ -115,6 +124,7 @@ impl RuleCache {
|
||||||
pub fn insert_if_possible(
|
pub fn insert_if_possible(
|
||||||
&mut self,
|
&mut self,
|
||||||
style: &Arc<ComputedValues>,
|
style: &Arc<ComputedValues>,
|
||||||
|
pseudo: Option<&PseudoElement>,
|
||||||
conditions: &RuleCacheConditions,
|
conditions: &RuleCacheConditions,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if !conditions.cacheable() {
|
if !conditions.cacheable() {
|
||||||
|
@ -126,6 +136,12 @@ impl RuleCache {
|
||||||
return false;
|
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 {
|
let rules = match style.rules {
|
||||||
Some(ref r) => r.clone(),
|
Some(ref r) => r.clone(),
|
||||||
None => return false,
|
None => return false,
|
||||||
|
|
|
@ -574,11 +574,13 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let implemented_pseudo = self.element.implemented_pseudo_element();
|
let implemented_pseudo = self.element.implemented_pseudo_element();
|
||||||
|
let pseudo = pseudo.or(implemented_pseudo.as_ref());
|
||||||
|
|
||||||
let mut conditions = Default::default();
|
let mut conditions = Default::default();
|
||||||
let values =
|
let values =
|
||||||
cascade(
|
cascade(
|
||||||
self.context.shared.stylist.device(),
|
self.context.shared.stylist.device(),
|
||||||
pseudo.or(implemented_pseudo.as_ref()),
|
pseudo,
|
||||||
rules.unwrap_or(self.context.shared.stylist.rule_tree().root()),
|
rules.unwrap_or(self.context.shared.stylist.rule_tree().root()),
|
||||||
&self.context.shared.guards,
|
&self.context.shared.guards,
|
||||||
parent_style,
|
parent_style,
|
||||||
|
@ -595,7 +597,7 @@ where
|
||||||
self.context
|
self.context
|
||||||
.thread_local
|
.thread_local
|
||||||
.rule_cache
|
.rule_cache
|
||||||
.insert_if_possible(&values, &conditions);
|
.insert_if_possible(&values, pseudo, &conditions);
|
||||||
|
|
||||||
values
|
values
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue