style: Move root font size handling outside of the cascade.
draft
style: Move root font size handling outside of the cascade.
And merge it with the rest of the code handling root font-size changes.
MozReview-Commit-ID: 3rW1C3mXiMd
--- a/servo/components/style/matching.rs
+++ b/servo/components/style/matching.rs
@@ -336,17 +336,16 @@ trait PrivateMatchMethods: TElement {
cascade_flags.insert(SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP)
}
if cascade_visited.visited_dependent_only() {
cascade_flags.insert(VISITED_DEPENDENT_ONLY);
}
if self.is_native_anonymous() || cascade_target == CascadeTarget::EagerPseudo {
cascade_flags.insert(PROHIBIT_DISPLAY_CONTENTS);
} else if self.is_root() {
- debug_assert!(self.owner_doc_matches_for_testing(shared_context.stylist.device()));
cascade_flags.insert(IS_ROOT_ELEMENT);
}
// Grab the inherited values.
let parent_el;
let element_and_style; // So parent_el and style_to_inherit_from are known live.
let style_to_inherit_from = match cascade_target {
CascadeTarget::Normal => {
@@ -558,19 +557,24 @@ trait PrivateMatchMethods: TElement {
// The new root font-size has already been updated on the Device
// in properties::apply_declarations.
let device = context.shared.stylist.device();
let new_font_size = new_values.get_font().clone_font_size();
// If the root font-size changed since last time, and something
// in the document did use rem units, ensure we recascade the
// entire tree.
- if old_values.map_or(false, |v| v.get_font().clone_font_size() != new_font_size) &&
- device.used_root_font_size() {
- child_cascade_requirement = ChildCascadeRequirement::MustCascadeDescendants;
+ if old_values.map_or(true, |v| v.get_font().clone_font_size() != new_font_size) {
+ // FIXME(emilio): This can fire when called from a document
+ // from the bfcache (bug 1376897).
+ debug_assert!(self.owner_doc_matches_for_testing(device));
+ device.set_root_font_size(new_font_size);
+ if device.used_root_font_size() {
+ child_cascade_requirement = ChildCascadeRequirement::MustCascadeDescendants;
+ }
}
}
}
// Set the new computed values.
let primary_inputs = context.cascade_inputs_mut().primary_mut();
cascade_visited.set_primary_values(&mut data.styles,
primary_inputs,
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -2896,21 +2896,16 @@ pub fn apply_declarations<'a, F, I>(devi
inherited_style,
default_style,
&mut context,
&mut cacheable,
&mut cascade_info,
error_reporter);
% endif
}
-
- if context.is_root_element {
- let s = context.style.get_font().clone_font_size();
- context.device.set_root_font_size(s);
- }
% endif
% endfor
let mut style = context.style;
{
StyleAdjuster::new(&mut style)
.adjust(context.layout_parent_style, flags);
@@ -2933,17 +2928,16 @@ pub fn apply_declarations<'a, F, I>(devi
seen.contains(LonghandId::FontFamily) {
style.mutate_font().compute_font_hash();
}
% endif
style.build()
}
-
/// See StyleAdjuster::adjust_for_border_width.
pub fn adjust_border_width(style: &mut StyleBuilder) {
% for side in ["top", "right", "bottom", "left"]:
// Like calling to_computed_value, which wouldn't type check.
if style.get_border().clone_border_${side}_style().none_or_hidden() &&
style.get_border().border_${side}_has_nonzero_width() {
style.mutate_border().set_border_${side}_width(Au(0));
}