Skip to content

Commit

Permalink
style: Avoid computing and storing change hints for text nodes.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Aug 22, 2016
1 parent 278bef4 commit 9feea76
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions components/style/matching.rs
Expand Up @@ -871,21 +871,29 @@ pub trait MatchMethods : TNode {
None => None,
};

let mut applicable_declarations_cache =
context.local_context().applicable_declarations_cache.borrow_mut();

let (damage, restyle_result) = if self.is_text_node() {
// In the case we're styling a text node, we don't need to compute the
// restyle damage, since it's a subset of the restyle damage of the
// parent.
//
// In Gecko, we're done, we don't need anything else from text nodes.
//
// In Servo, this is also true, since text nodes generate UnscannedText
// fragments, which aren't repairable by incremental layout.
if self.is_text_node() {
let mut data_ref = self.mutate_data().unwrap();
let mut data = &mut *data_ref;
let cloned_parent_style = ComputedValues::style_for_child_text_node(parent_style.unwrap());

let damage =
self.compute_restyle_damage(data.style.as_ref(), &cloned_parent_style, None);

data.style = Some(cloned_parent_style);

(damage, RestyleResult::Continue)
} else {
return RestyleResult::Continue;
}

let mut applicable_declarations_cache =
context.local_context().applicable_declarations_cache.borrow_mut();

let (damage, restyle_result) = {
let mut data_ref = self.mutate_data().unwrap();
let mut data = &mut *data_ref;
let final_style =
Expand Down

0 comments on commit 9feea76

Please sign in to comment.