Adjust display value for ;-moz-fieldset-content when parent is flex\grid. r?emilio draft
authorXidorn Quan <me@upsuper.org>
Thu, 13 Jul 2017 11:45:50 +1000
changeset 607979 e9ab8b28f02f0d1673c939d91594f6d6639fb226
parent 607976 4eb4a8ca42f1bcb0ca756866a0303c8b8830ba4a
child 607980 4a06f65f0528db9efeba22d0e1fb25b85b66090f
push id68150
push userxquan@mozilla.com
push dateThu, 13 Jul 2017 02:06:32 +0000
reviewersemilio
milestone56.0a1
Adjust display value for ;-moz-fieldset-content when parent is flex\grid. r?emilio MozReview-Commit-ID: 7r2OaUZbQdg
servo/components/style/properties/longhand/box.mako.rs
--- a/servo/components/style/properties/longhand/box.mako.rs
+++ b/servo/components/style/properties/longhand/box.mako.rs
@@ -8,17 +8,17 @@
 <% data.new_style_struct("Box",
                          inherited=False,
                          gecko_name="Display") %>
 
 // TODO(SimonSapin): don't parse `inline-table`, since we don't support it
 <%helpers:longhand name="display"
                    need_clone="True"
                    animation_value_type="discrete"
-                   custom_cascade="${product == 'servo'}"
+                   custom_cascade="True"
                    spec="https://drafts.csswg.org/css-display/#propdef-display">
     <%
         values = """inline block inline-block
             table inline-table table-row-group table-header-group table-footer-group
             table-row table-column-group table-column table-cell table-caption
             list-item none
         """.split()
         webkit_prefixed_values = "flex inline-flex".split()
@@ -136,16 +136,40 @@
         fn cascade_property_custom(_declaration: &PropertyDeclaration,
                                    _inherited_style: &ComputedValues,
                                    context: &mut computed::Context,
                                    _cacheable: &mut bool) {
             longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
             longhands::_servo_text_decorations_in_effect::derive_from_display(context);
             longhands::_servo_under_display_none::derive_from_display(context);
         }
+    % else:
+        fn cascade_property_custom(_declaration: &PropertyDeclaration,
+                                   inherited_style: &ComputedValues,
+                                   context: &mut computed::Context,
+                                   cacheable: &mut bool) {
+            use self::computed_value::T;
+            if let Some(pseudo) = context.pseudo {
+                use selector_parser::PseudoElement;
+                // Inherit a <fieldset> grid/flex display type into its
+                // anonymous content box.
+                if *pseudo == PseudoElement::FieldsetContent {
+                    let parent_display = inherited_style.get_box().clone_display();
+                    let new_display = match parent_display {
+                        T::grid | T::inline_grid => Some(T::grid),
+                        T::flex | T::inline_flex => Some(T::flex),
+                        _ => None,
+                    };
+                    if let Some(new_display) = new_display {
+                        context.mutate_style().mutate_box().set_display(new_display);
+                        *cacheable = false;
+                    }
+                }
+            }
+        }
     % endif
 
     ${helpers.gecko_keyword_conversion(Keyword('display', ' '.join(values),
                                                gecko_enum_prefix='StyleDisplay',
                                                gecko_strip_moz_prefix=False))}
 
 </%helpers:longhand>