mirror of
https://github.com/servo/servo.git
synced 2025-07-31 11:10:22 +01:00
Make replace_rules_internal return true only if important rules changed.
This commit is contained in:
parent
7651cebcd0
commit
07421a8e9c
2 changed files with 14 additions and 8 deletions
|
@ -703,15 +703,17 @@ pub trait MatchMethods : TElement {
|
||||||
let replace_rule_node = |level: CascadeLevel,
|
let replace_rule_node = |level: CascadeLevel,
|
||||||
pdb: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
|
pdb: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
|
||||||
path: &mut StrongRuleNode| -> bool {
|
path: &mut StrongRuleNode| -> bool {
|
||||||
|
let mut important_rules_changed = false;
|
||||||
let new_node = stylist.rule_tree()
|
let new_node = stylist.rule_tree()
|
||||||
.update_rule_at_level(level, pdb, path, guards);
|
.update_rule_at_level(level,
|
||||||
match new_node {
|
pdb,
|
||||||
Some(n) => {
|
path,
|
||||||
*path = n;
|
guards,
|
||||||
level.is_important()
|
&mut important_rules_changed);
|
||||||
},
|
if let Some(n) = new_node {
|
||||||
None => false,
|
*path = n;
|
||||||
}
|
}
|
||||||
|
important_rules_changed
|
||||||
};
|
};
|
||||||
|
|
||||||
if !context.shared.traversal_flags.for_animation_only() {
|
if !context.shared.traversal_flags.for_animation_only() {
|
||||||
|
|
|
@ -310,12 +310,14 @@ impl RuleTree {
|
||||||
level: CascadeLevel,
|
level: CascadeLevel,
|
||||||
pdb: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
|
pdb: Option<ArcBorrow<Locked<PropertyDeclarationBlock>>>,
|
||||||
path: &StrongRuleNode,
|
path: &StrongRuleNode,
|
||||||
guards: &StylesheetGuards)
|
guards: &StylesheetGuards,
|
||||||
|
important_rules_changed: &mut bool)
|
||||||
-> Option<StrongRuleNode> {
|
-> Option<StrongRuleNode> {
|
||||||
debug_assert!(level.is_unique_per_element());
|
debug_assert!(level.is_unique_per_element());
|
||||||
// TODO(emilio): Being smarter with lifetimes we could avoid a bit of
|
// TODO(emilio): Being smarter with lifetimes we could avoid a bit of
|
||||||
// the refcount churn.
|
// the refcount churn.
|
||||||
let mut current = path.clone();
|
let mut current = path.clone();
|
||||||
|
*important_rules_changed = false;
|
||||||
|
|
||||||
// First walk up until the first less-or-equally specific rule.
|
// First walk up until the first less-or-equally specific rule.
|
||||||
let mut children = SmallVec::<[_; 10]>::new();
|
let mut children = SmallVec::<[_; 10]>::new();
|
||||||
|
@ -335,6 +337,8 @@ impl RuleTree {
|
||||||
// special cases, and replacing them for a `while` loop, avoiding the
|
// special cases, and replacing them for a `while` loop, avoiding the
|
||||||
// optimizations).
|
// optimizations).
|
||||||
if current.get().level == level {
|
if current.get().level == level {
|
||||||
|
*important_rules_changed |= level.is_important();
|
||||||
|
|
||||||
if let Some(pdb) = pdb {
|
if let Some(pdb) = pdb {
|
||||||
// If the only rule at the level we're replacing is exactly the
|
// If the only rule at the level we're replacing is exactly the
|
||||||
// same as `pdb`, we're done, and `path` is still valid.
|
// same as `pdb`, we're done, and `path` is still valid.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue