servo: Merge #19661 - style: Simplify ::-moz-fieldset-content special-casing (from emilio:simplify-fieldset-contents); r=upsuper
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 30 Dec 2017 15:12:23 -0600
changeset 449293 ad608b710884837c08dd3082268c88cc0f61c231
parent 449285 e02699fd3129bef049f848e2f71189182eabe555
child 449294 dda1c7951937e13941162cfbe7a89ac6fdb81972
push id8527
push userCallek@gmail.com
push dateThu, 11 Jan 2018 21:05:50 +0000
treeherdermozilla-beta@95342d212a7a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersupsuper
milestone59.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 #19661 - style: Simplify ::-moz-fieldset-content special-casing (from emilio:simplify-fieldset-contents); r=upsuper The style adjuster knows about the pseudo, so there's no reason to thread that info down. There are more simplifications that can be done in followups, cleaning a bit the cascade flags too, those will come later. Source-Repo: https://github.com/servo/servo Source-Revision: fb569f9c159627a058b902bfe820f55c2657e590
servo/components/style/properties/properties.mako.rs
servo/components/style/style_adjuster.rs
servo/ports/geckolib/glue.rs
--- a/servo/components/style/properties/properties.mako.rs
+++ b/servo/components/style/properties/properties.mako.rs
@@ -3079,19 +3079,16 @@ bitflags! {
         /// that it may affect global state, like the Device's root font-size.
         const IS_ROOT_ELEMENT = 1 << 3;
 
         /// Whether to convert display:contents into display:inline.  This
         /// is used by Gecko to prevent display:contents on generated
         /// content.
         const PROHIBIT_DISPLAY_CONTENTS = 1 << 4;
 
-        /// Whether we're styling the ::-moz-fieldset-content anonymous box.
-        const IS_FIELDSET_CONTENT = 1 << 5;
-
         /// Whether we're computing the style of a link, either visited or
         /// unvisited.
         const IS_LINK = 1 << 6;
 
         /// Whether we're computing the style of a link element that happens to
         /// be visited.
         const IS_VISITED_LINK = 1 << 7;
     }
--- a/servo/components/style/style_adjuster.rs
+++ b/servo/components/style/style_adjuster.rs
@@ -338,22 +338,22 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
     ///
     /// NOTE(emilio): We don't need to handle the display change for this case
     /// in matching.rs because anonymous box restyling works separately to the
     /// normal cascading process.
     #[cfg(feature = "gecko")]
     fn adjust_for_fieldset_content(
         &mut self,
         layout_parent_style: &ComputedValues,
-        flags: CascadeFlags,
     ) {
-        use properties::CascadeFlags;
-        if !flags.contains(CascadeFlags::IS_FIELDSET_CONTENT) {
-            return;
+        match self.style.pseudo {
+            Some(ref p) if p.is_fieldset_content() => {},
+            _ => return,
         }
+
         debug_assert_eq!(self.style.get_box().clone_display(), Display::Block);
         // TODO We actually want style from parent rather than layout
         // parent, so that this fixup doesn't happen incorrectly when
         // when <fieldset> has "display: contents".
         let parent_display = layout_parent_style.get_box().clone_display();
         let new_display = match parent_display {
             Display::Flex |
             Display::InlineFlex => Some(Display::Flex),
@@ -565,17 +565,17 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
         if flags.contains(CascadeFlags::VISITED_DEPENDENT_ONLY) {
             return;
         }
 
         self.adjust_for_visited(flags);
         #[cfg(feature = "gecko")]
         {
             self.adjust_for_prohibited_display_contents(flags);
-            self.adjust_for_fieldset_content(layout_parent_style, flags);
+            self.adjust_for_fieldset_content(layout_parent_style);
         }
         self.adjust_for_top_layer();
         self.blockify_if_necessary(layout_parent_style, flags);
         self.adjust_for_position();
         self.adjust_for_overflow();
         #[cfg(feature = "gecko")]
         {
             self.adjust_for_table_text_align();
--- a/servo/ports/geckolib/glue.rs
+++ b/servo/ports/geckolib/glue.rs
@@ -1982,20 +1982,16 @@ pub extern "C" fn Servo_ComputedValues_G
     let global_style_data = &*GLOBAL_STYLE_DATA;
     let guard = global_style_data.shared_lock.read();
     let guards = StylesheetGuards::same(&guard);
     let data = PerDocumentStyleData::from_ffi(raw_data).borrow_mut();
     let atom = Atom::from(pseudo_tag);
     let pseudo = PseudoElement::from_anon_box_atom(&atom)
         .expect("Not an anon box pseudo?");
 
-    let mut cascade_flags = CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
-    if pseudo.is_fieldset_content() {
-        cascade_flags.insert(CascadeFlags::IS_FIELDSET_CONTENT);
-    }
     let metrics = get_metrics_provider_for_product();
 
     // If the pseudo element is PageContent, we should append the precomputed
     // pseudo element declerations with specified page rules.
     let page_decls = match pseudo {
         PseudoElement::PageContent => {
             let mut declarations = vec![];
             let iter = data.stylist.iter_extra_data_origins_rev();
@@ -2018,16 +2014,17 @@ pub extern "C" fn Servo_ComputedValues_G
     };
 
     let rule_node = data.stylist.rule_node_for_precomputed_pseudo(
         &guards,
         &pseudo,
         page_decls,
     );
 
+    let cascade_flags = CascadeFlags::SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP;
     data.stylist.precomputed_values_for_pseudo_with_rule_node(
         &guards,
         &pseudo,
         parent_style_or_null.map(|x| &*x),
         cascade_flags,
         &metrics,
         rule_node
     ).into()
@@ -3634,21 +3631,18 @@ pub extern "C" fn Servo_ReparentStyle(
                 cascade_flags.insert(CascadeFlags::IS_VISITED_LINK);
             }
         };
 
         if element.is_native_anonymous() {
             cascade_flags.insert(CascadeFlags::PROHIBIT_DISPLAY_CONTENTS);
         }
     }
-    if let Some(pseudo) = pseudo.as_ref() {
+    if pseudo.is_some() {
         cascade_flags.insert(CascadeFlags::PROHIBIT_DISPLAY_CONTENTS);
-        if pseudo.is_fieldset_content() {
-            cascade_flags.insert(CascadeFlags::IS_FIELDSET_CONTENT);
-        }
     }
 
     doc_data.stylist.compute_style_with_inputs(
         &inputs,
         pseudo.as_ref(),
         &StylesheetGuards::same(&guard),
         Some(parent_style),
         Some(parent_style_ignoring_first_line),