style: Don't use rule cache for property-restricted pseudo-elements.

This commit is contained in:
Cameron McCormack 2017-09-13 16:15:21 +08:00
parent a7dd19cfb1
commit 30982b92c8
3 changed files with 21 additions and 3 deletions

View file

@ -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,