style: Compute damage for text nodes.

They have styles just like elements do.

Allows a dynamic change of `display: none` to `display: inline` to work.

Closes #9868.
This commit is contained in:
Patrick Walton 2016-03-14 19:14:21 -07:00
parent aea8d8959d
commit d59dee0c65
5 changed files with 52 additions and 6 deletions

View file

@ -655,6 +655,7 @@ pub trait MatchMethods : TNode {
}
};
let damage;
if self.is_text_node() {
// Text nodes get a copy of the parent style. This ensures
// that during fragment construction any non-inherited
@ -663,9 +664,11 @@ pub trait MatchMethods : TNode {
let mut data_ref = self.mutate_data().unwrap();
let mut data = &mut *data_ref;
let cloned_parent_style = parent_style.unwrap().clone();
damage = Self::ConcreteRestyleDamage::compute(data.style.as_ref(),
&*cloned_parent_style);
data.style = Some(cloned_parent_style);
} else {
let damage = {
damage = {
let mut data_ref = self.mutate_data().unwrap();
let mut data = &mut *data_ref;
let (mut damage, final_style) = self.cascade_node_pseudo_element(
@ -706,13 +709,15 @@ pub trait MatchMethods : TNode {
// This method needs to borrow the data as mutable, so make sure data_ref goes out of
// scope first.
self.set_restyle_damage(damage);
self.set_can_be_fragmented(parent.map_or(false, |p| {
p.can_be_fragmented() ||
parent_style.as_ref().unwrap().is_multicol()
}));
}
// This method needs to borrow the data as mutable, so make sure data_ref goes out of
// scope first.
self.set_restyle_damage(damage);
}
}