servo: Merge #17057 - Don't set root font size when styling NAC (from Manishearth:nonac); r=emilio
authorManish Goregaokar <manishearth@gmail.com>
Sat, 27 May 2017 00:18:01 -0500
changeset 409092 e85390404ed2cdb84b7cabaa5ce426d886cb4c24
parent 409063 1c1bf54915bbf8cda82dbf7985e87b1c0ff30e4c
child 409093 3de27eb37023c2513eee0c20774f92e70a3c6cf5
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
servo: Merge #17057 - Don't set root font size when styling NAC (from Manishearth:nonac); r=emilio try at https://treeherder.mozilla.org/#/jobs?repo=try&revision=ad4acc4941dd91d10e3646ecd7fa03576fc75342 Source-Repo: https://github.com/servo/servo Source-Revision: 6706c818371c18e23e75de59aebc7327be67ead8
servo/components/style/matching.rs
servo/components/style/properties/properties.mako.rs
--- a/servo/components/style/matching.rs
+++ b/servo/components/style/matching.rs
@@ -8,18 +8,19 @@
 #![deny(missing_docs)]
 
 use cascade_info::CascadeInfo;
 use context::{SelectorFlagsMap, SharedStyleContext, StyleContext};
 use data::{ComputedStyle, ElementData, RestyleData};
 use dom::{TElement, TNode};
 use font_metrics::FontMetricsProvider;
 use log::LogLevel::Trace;
+use properties::{ALLOW_SET_ROOT_FONT_SIZE, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP};
 use properties::{AnimationRules, CascadeFlags, ComputedValues};
-use properties::{SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP, VISITED_DEPENDENT_ONLY, cascade};
+use properties::{VISITED_DEPENDENT_ONLY, cascade};
 use properties::longhands::display::computed_value as display;
 use restyle_hints::{RESTYLE_CSS_ANIMATIONS, RESTYLE_CSS_TRANSITIONS, RestyleReplacements};
 use restyle_hints::{RESTYLE_STYLE_ATTRIBUTE, RESTYLE_SMIL};
 use rule_tree::{CascadeLevel, StrongRuleNode};
 use selector_parser::{PseudoElement, RestyleDamage, SelectorImpl};
 use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode, StyleRelations};
 use selectors::matching::{VisitedHandlingMode, AFFECTED_BY_PSEUDO_ELEMENTS};
 use sharing::{StyleSharingBehavior, StyleSharingResult};
@@ -251,16 +252,19 @@ trait PrivateMatchMethods: TElement {
         let mut cascade_info = CascadeInfo::new();
         let mut cascade_flags = CascadeFlags::empty();
         if self.skip_root_and_item_based_display_fixup() {
             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_flags.insert(ALLOW_SET_ROOT_FONT_SIZE);
+        }
 
         // Grab the inherited values.
         let parent_el;
         let parent_data;
         let style_to_inherit_from = match inherit_mode {
             InheritMode::Normal => {
                 parent_el = self.inheritance_parent();
                 parent_data = parent_el.as_ref().and_then(|e| e.borrow_data());
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -2478,16 +2478,25 @@ bitflags! {
         /// Whether to inherit all styles from the parent. If this flag is not
         /// present, non-inherited styles are reset to their initial values.
         const INHERIT_ALL = 0x01,
         /// Whether to skip any root element and flex/grid item display style
         /// fixup.
         const SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP = 0x02,
         /// Whether to only cascade properties that are visited dependent.
         const VISITED_DEPENDENT_ONLY = 0x04,
+        /// Should we modify the device's root font size
+        /// when computing the root?
+        ///
+        /// Not set for native anonymous content since some NAC
+        /// form their own root, but share the device.
+        ///
+        /// ::backdrop and all NAC will resolve rem units against
+        /// the toplevel root element now.
+        const ALLOW_SET_ROOT_FONT_SIZE = 0x08,
     }
 }
 
 /// Performs the CSS cascade, computing new styles for an element from its parent style.
 ///
 /// The arguments are:
 ///
 ///   * `device`: Used to get the initial viewport and other external state.
@@ -2768,17 +2777,17 @@ pub fn apply_declarations<'a, F, I>(devi
                                                  default_style,
                                                  &mut context,
                                                  &mut cacheable,
                                                  &mut cascade_info,
                                                  error_reporter);
             % endif
             }
 
-            if is_root_element {
+            if is_root_element && flags.contains(ALLOW_SET_ROOT_FONT_SIZE) {
                 let s = context.style.get_font().clone_font_size();
                 context.device.set_root_font_size(s);
             }
         % endif
     % endfor
 
     let mut style = context.style;