style: Fix propagation of text-decoration lines.

This commit is contained in:
Emilio Cobos Álvarez 2017-06-26 15:30:13 -07:00
parent 1c2fcb16ca
commit 69e650ea68
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 27 additions and 17 deletions

View file

@ -47,9 +47,10 @@ impl GeckoRestyleDamage {
/// them, but Gecko has an interesting optimization when they mark accessed /// them, but Gecko has an interesting optimization when they mark accessed
/// structs, so they effectively only diff structs that have ever been /// structs, so they effectively only diff structs that have ever been
/// accessed from layout. /// accessed from layout.
pub fn compute_style_difference(source: &nsStyleContext, pub fn compute_style_difference(
new_style: &Arc<ComputedValues>) source: &nsStyleContext,
-> StyleDifference { new_style: &Arc<ComputedValues>
) -> StyleDifference {
// TODO(emilio): Const-ify this? // TODO(emilio): Const-ify this?
let context = source as *const nsStyleContext as *mut nsStyleContext; let context = source as *const nsStyleContext as *mut nsStyleContext;
let mut any_style_changed: bool = false; let mut any_style_changed: bool = false;

View file

@ -98,15 +98,6 @@ pub enum ChildCascadeRequirement {
MustCascadeDescendants, MustCascadeDescendants,
} }
impl From<StyleChange> for ChildCascadeRequirement {
fn from(change: StyleChange) -> ChildCascadeRequirement {
match change {
StyleChange::Unchanged => ChildCascadeRequirement::CanSkipCascade,
StyleChange::Changed => ChildCascadeRequirement::MustCascadeChildren,
}
}
}
bitflags! { bitflags! {
/// Flags that represent the result of replace_rules. /// Flags that represent the result of replace_rules.
pub flags RulesChanged: u8 { pub flags RulesChanged: u8 {
@ -778,6 +769,8 @@ trait PrivateMatchMethods: TElement {
new_values: &Arc<ComputedValues>, new_values: &Arc<ComputedValues>,
pseudo: Option<&PseudoElement>) pseudo: Option<&PseudoElement>)
-> ChildCascadeRequirement { -> ChildCascadeRequirement {
use properties::computed_value_flags::*;
// Don't accumulate damage if we're in a restyle for reconstruction. // Don't accumulate damage if we're in a restyle for reconstruction.
if shared_context.traversal_flags.for_reconstruct() { if shared_context.traversal_flags.for_reconstruct() {
return ChildCascadeRequirement::MustCascadeChildren; return ChildCascadeRequirement::MustCascadeChildren;
@ -793,13 +786,26 @@ trait PrivateMatchMethods: TElement {
let skip_applying_damage = let skip_applying_damage =
restyle.reconstructed_self_or_ancestor(); restyle.reconstructed_self_or_ancestor();
let difference = self.compute_style_difference(&old_values, let difference =
&new_values, self.compute_style_difference(&old_values, &new_values, pseudo);
pseudo);
if !skip_applying_damage { if !skip_applying_damage {
restyle.damage |= difference.damage; restyle.damage |= difference.damage;
} }
difference.change.into()
match difference.change {
StyleChange::Unchanged => {
// We need to cascade the children in order to ensure the
// correct propagation of text-decoration-line, which is a reset
// property.
if old_values.flags.contains(HAS_TEXT_DECORATION_LINE) !=
new_values.flags.contains(HAS_TEXT_DECORATION_LINE) {
return ChildCascadeRequirement::MustCascadeChildren;
}
ChildCascadeRequirement::CanSkipCascade
},
StyleChange::Changed => ChildCascadeRequirement::MustCascadeChildren,
}
} }
/// Computes and applies restyle damage unless we've already maxed it out. /// Computes and applies restyle damage unless we've already maxed it out.
@ -813,7 +819,10 @@ trait PrivateMatchMethods: TElement {
-> ChildCascadeRequirement { -> ChildCascadeRequirement {
let difference = self.compute_style_difference(&old_values, &new_values, pseudo); let difference = self.compute_style_difference(&old_values, &new_values, pseudo);
restyle.damage |= difference.damage; restyle.damage |= difference.damage;
difference.change.into() match difference.change {
StyleChange::Changed => ChildCascadeRequirement::MustCascadeChildren,
StyleChange::Unchanged => ChildCascadeRequirement::CanSkipCascade,
}
} }
#[cfg(feature = "servo")] #[cfg(feature = "servo")]