style: Recascade the document when rem units are used and the root font-size changes.

This commit is contained in:
Cameron McCormack 2017-06-03 13:18:43 +08:00
parent 7b61d55421
commit 19b61dfc08
6 changed files with 76 additions and 21 deletions

View file

@ -9,7 +9,8 @@ use context::{SharedStyleContext, StyleContext, ThreadLocalStyleContext};
use data::{ElementData, ElementStyles, StoredRestyleHint};
use dom::{DirtyDescendants, NodeInfo, OpaqueNode, TElement, TNode};
use matching::{ChildCascadeRequirement, MatchMethods};
use restyle_hints::{HintComputationContext, RestyleHint};
use restyle_hints::{CascadeHint, HintComputationContext, RECASCADE_SELF};
use restyle_hints::{RECASCADE_DESCENDANTS, RestyleHint};
use selector_parser::RestyleDamage;
use sharing::{StyleSharingBehavior, StyleSharingTarget};
#[cfg(feature = "servo")] use servo_config::opts;
@ -672,7 +673,7 @@ pub fn recalc_style_at<E, D>(traversal: &D,
}), "Should've computed the final hint and handled later_siblings already");
let compute_self = !element.has_current_styles(data);
let mut inherited_style_changed = false;
let mut cascade_hint = CascadeHint::empty();
debug!("recalc_style_at: {:?} (compute_self={:?}, dirty_descendants={:?}, data={:?})",
element, compute_self, element.has_dirty_descendants(), data);
@ -680,8 +681,11 @@ pub fn recalc_style_at<E, D>(traversal: &D,
// Compute style for this element if necessary.
if compute_self {
match compute_style(traversal, traversal_data, context, element, data) {
ChildCascadeRequirement::MustCascade => {
inherited_style_changed = true;
ChildCascadeRequirement::MustCascadeChildren => {
cascade_hint |= RECASCADE_SELF;
}
ChildCascadeRequirement::MustCascadeDescendants => {
cascade_hint |= RECASCADE_SELF | RECASCADE_DESCENDANTS;
}
ChildCascadeRequirement::CanSkipCascade => {}
};
@ -708,15 +712,13 @@ pub fn recalc_style_at<E, D>(traversal: &D,
},
};
if inherited_style_changed {
// FIXME(bholley): Need to handle explicitly-inherited reset properties
// somewhere.
propagated_hint.insert(StoredRestyleHint::recascade_self());
}
// FIXME(bholley): Need to handle explicitly-inherited reset properties
// somewhere.
propagated_hint.insert_cascade_hint(cascade_hint);
trace!("propagated_hint={:?}, inherited_style_changed={:?}, \
trace!("propagated_hint={:?}, cascade_hint={:?}, \
is_display_none={:?}, implementing_pseudo={:?}",
propagated_hint, inherited_style_changed,
propagated_hint, cascade_hint,
data.styles().is_display_none(),
element.implemented_pseudo_element());
debug_assert!(element.has_current_styles(data) ||