Introduce a closure to replace rule nodes.

We need a scope to restore rule_node_changed that were borrowed by the closure.
This closure function will be used for animation-only restyles as well.
This commit is contained in:
Hiroyuki Ikezoe 2017-03-26 18:46:22 +09:00
parent 749189bad5
commit 6d5ee2e361

View file

@ -954,30 +954,32 @@ pub trait MatchMethods : TElement {
context: &StyleContext<Self>, context: &StyleContext<Self>,
data: &mut AtomicRefMut<ElementData>) data: &mut AtomicRefMut<ElementData>)
-> bool { -> bool {
use properties::PropertyDeclarationBlock;
use shared_lock::Locked;
let primary_rules = &mut data.styles_mut().primary.rules; let primary_rules = &mut data.styles_mut().primary.rules;
let mut rule_node_changed = false; let mut rule_node_changed = false;
if hint.contains(RESTYLE_STYLE_ATTRIBUTE) { {
let style_attribute = self.style_attribute(); let mut replace_rule_node = |level: CascadeLevel,
pdb: Option<&Arc<Locked<PropertyDeclarationBlock>>>,
path: &mut StrongRuleNode| {
let new_node = context.shared.stylist.rule_tree
.update_rule_at_level(level, pdb, path, &context.shared.guards);
if let Some(n) = new_node {
*path = n;
rule_node_changed = true;
}
};
let new_node = context.shared.stylist.rule_tree if hint.contains(RESTYLE_STYLE_ATTRIBUTE) {
.update_rule_at_level(CascadeLevel::StyleAttributeNormal, let style_attribute = self.style_attribute();
style_attribute, replace_rule_node(CascadeLevel::StyleAttributeNormal,
primary_rules, style_attribute,
&context.shared.guards); primary_rules);
if let Some(n) = new_node { replace_rule_node(CascadeLevel::StyleAttributeImportant,
*primary_rules = n; style_attribute,
rule_node_changed = true; primary_rules);
}
let new_node = context.shared.stylist.rule_tree
.update_rule_at_level(CascadeLevel::StyleAttributeImportant,
style_attribute,
primary_rules,
&context.shared.guards);
if let Some(n) = new_node {
*primary_rules = n;
rule_node_changed = true;
} }
} }