From 69e650ea6838942dc65d4cfb75fa77544ff4319e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 26 Jun 2017 15:30:13 -0700 Subject: [PATCH] style: Fix propagation of text-decoration lines. --- components/style/gecko/restyle_damage.rs | 7 +++-- components/style/matching.rs | 37 +++++++++++++++--------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/components/style/gecko/restyle_damage.rs b/components/style/gecko/restyle_damage.rs index 9d443b23baf..e9be48644ca 100644 --- a/components/style/gecko/restyle_damage.rs +++ b/components/style/gecko/restyle_damage.rs @@ -47,9 +47,10 @@ impl GeckoRestyleDamage { /// them, but Gecko has an interesting optimization when they mark accessed /// structs, so they effectively only diff structs that have ever been /// accessed from layout. - pub fn compute_style_difference(source: &nsStyleContext, - new_style: &Arc) - -> StyleDifference { + pub fn compute_style_difference( + source: &nsStyleContext, + new_style: &Arc + ) -> StyleDifference { // TODO(emilio): Const-ify this? let context = source as *const nsStyleContext as *mut nsStyleContext; let mut any_style_changed: bool = false; diff --git a/components/style/matching.rs b/components/style/matching.rs index ab51de215c4..3dd209c780a 100644 --- a/components/style/matching.rs +++ b/components/style/matching.rs @@ -98,15 +98,6 @@ pub enum ChildCascadeRequirement { MustCascadeDescendants, } -impl From for ChildCascadeRequirement { - fn from(change: StyleChange) -> ChildCascadeRequirement { - match change { - StyleChange::Unchanged => ChildCascadeRequirement::CanSkipCascade, - StyleChange::Changed => ChildCascadeRequirement::MustCascadeChildren, - } - } -} - bitflags! { /// Flags that represent the result of replace_rules. pub flags RulesChanged: u8 { @@ -778,6 +769,8 @@ trait PrivateMatchMethods: TElement { new_values: &Arc, pseudo: Option<&PseudoElement>) -> ChildCascadeRequirement { + use properties::computed_value_flags::*; + // Don't accumulate damage if we're in a restyle for reconstruction. if shared_context.traversal_flags.for_reconstruct() { return ChildCascadeRequirement::MustCascadeChildren; @@ -793,13 +786,26 @@ trait PrivateMatchMethods: TElement { let skip_applying_damage = restyle.reconstructed_self_or_ancestor(); - let difference = self.compute_style_difference(&old_values, - &new_values, - pseudo); + let difference = + self.compute_style_difference(&old_values, &new_values, pseudo); + if !skip_applying_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. @@ -813,7 +819,10 @@ trait PrivateMatchMethods: TElement { -> ChildCascadeRequirement { let difference = self.compute_style_difference(&old_values, &new_values, pseudo); restyle.damage |= difference.damage; - difference.change.into() + match difference.change { + StyleChange::Changed => ChildCascadeRequirement::MustCascadeChildren, + StyleChange::Unchanged => ChildCascadeRequirement::CanSkipCascade, + } } #[cfg(feature = "servo")]