diff --git a/components/style/properties/longhand/position.mako.rs b/components/style/properties/longhand/position.mako.rs index b91e79e384d..bc93a6614e5 100644 --- a/components/style/properties/longhand/position.mako.rs +++ b/components/style/properties/longhand/position.mako.rs @@ -61,22 +61,36 @@ // http://www.w3.org/TR/css3-flexbox/ // Flex container properties -${helpers.single_keyword("flex-direction", "row row-reverse column column-reverse")} +${helpers.single_keyword("flex-direction", "row row-reverse column column-reverse", experimental=True)} -${helpers.single_keyword("flex-wrap", "nowrap wrap wrap-reverse")} +${helpers.single_keyword("flex-wrap", "nowrap wrap wrap-reverse", experimental=True)} -${helpers.single_keyword("justify-content", "flex-start flex-end center space-between space-around")} +// FIXME(stshine): The type of 'justify-content' and 'align-content' is uint16_t in gecko +// FIXME(stshine): Its higher bytes are used to store fallback value. Disable them in geckolib for now +${helpers.single_keyword("justify-content", "flex-start flex-end center space-between space-around", + experimental=True, + gecko_constant_prefix="NS_STYLE_JUSTIFY", + products="servo")} -${helpers.single_keyword("align-items", "stretch flex-start flex-end center baseline")} +${helpers.single_keyword("align-items", "stretch flex-start flex-end center baseline", + experimental=True, + need_clone=True, + gecko_constant_prefix="NS_STYLE_ALIGN")} -${helpers.single_keyword("align-content", "stretch flex-start flex-end center space-between space-around")} +${helpers.single_keyword("align-content", "stretch flex-start flex-end center space-between space-around", + experimental=True, + gecko_constant_prefix="NS_STYLE_ALIGN", + products="servo")} // Flex item properties -${helpers.predefined_type("flex-grow", "Number", "0.0", "parse_non_negative")} +${helpers.predefined_type("flex-grow", "Number", "0.0", "parse_non_negative", experimental=True)} -${helpers.predefined_type("flex-shrink", "Number", "1.0", "parse_non_negative")} +${helpers.predefined_type("flex-shrink", "Number", "1.0", "parse_non_negative", experimental=True)} -${helpers.single_keyword("align-self", "auto stretch flex-start flex-end center baseline")} +${helpers.single_keyword("align-self", "auto stretch flex-start flex-end center baseline", + experimental=True, + need_clone=True, + gecko_constant_prefix="NS_STYLE_ALIGN")} // https://drafts.csswg.org/css-flexbox/#propdef-order <%helpers:longhand name="order"> diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index de31ea761c6..cfa9df84237 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -1165,6 +1165,13 @@ pub mod style_structs { fn outline_has_nonzero_width(&self) -> bool { self.outline_width != ::app_units::Au(0) } + % elif style_struct.trait_name == "Position": + fn clone_align_items(&self) -> longhands::align_items::computed_value::T { + self.align_items.clone() + } + fn clone_align_self(&self) -> longhands::align_self::computed_value::T { + self.align_self.clone() + } % elif style_struct.trait_name == "Text": fn has_underline(&self) -> bool { self.text_decoration.underline @@ -1890,6 +1897,23 @@ pub fn cascade( } } + { + use self::style_struct_traits::Position; + use computed_values::align_self::T as align_self; + use computed_values::align_items::T as align_items; + if style.get_position().clone_align_self() == computed_values::align_self::T::auto && !positioned { + let self_align = + match context.inherited_style.get_position().clone_align_items() { + align_items::stretch => align_self::stretch, + align_items::baseline => align_self::baseline, + align_items::flex_start => align_self::flex_start, + align_items::flex_end => align_self::flex_end, + align_items::center => align_self::center, + }; + style.mutate_position().set_align_self(self_align); + } + } + // The initial value of border-*-width may be changed at computed value time. % for side in ["top", "right", "bottom", "left"]: // Like calling to_computed_value, which wouldn't type check. diff --git a/tests/wpt/css-tests/css-flexbox-1_dev/html/flexbox_computedstyle_align-self-invalid.htm b/tests/wpt/css-tests/css-flexbox-1_dev/html/flexbox_computedstyle_align-self-invalid.htm index 00355e87526..8f6a0c7f228 100644 --- a/tests/wpt/css-tests/css-flexbox-1_dev/html/flexbox_computedstyle_align-self-invalid.htm +++ b/tests/wpt/css-tests/css-flexbox-1_dev/html/flexbox_computedstyle_align-self-invalid.htm @@ -17,7 +17,7 @@ body { var passed = getComputedStyle(body).getPropertyValue("align-self") == - "auto"; + "stretch"; body.textContent = body.className = passed ? "PASS" : "FAIL"; diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/__dir__.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/__dir__.ini index a2bf1be1b98..c69efaf3cab 100644 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/__dir__.ini +++ b/tests/wpt/metadata-css/css-flexbox-1_dev/__dir__.ini @@ -1,5 +1,12 @@ prefs: ["layout.flex.enabled:true", "layout.flex-direction.enabled:true", + "layout.flex-wrap.enabled:true", + "layout.flex-grow.enabled:true", + "layout.flex-shrink.enabled:true", + "layout.justify-content.enabled:true", + "layout.align-items.enabled:true", + "layout.align-self.enabled:true", + "layout.align-content.enabled:true", "layout.columns.enabled:true", "layout.column-width.enabled:true", "layout.column-count.enabled:true", diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-flow-nowrap.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-flow-nowrap.htm.ini deleted file mode 100644 index 6c474597fe1..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-flow-nowrap.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flexbox_computedstyle_flex-flow-nowrap.htm] - type: reftest - expected: PASS diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-flow-row-nowrap.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-flow-row-nowrap.htm.ini deleted file mode 100644 index 5bc9fbdc549..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-flow-row-nowrap.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flexbox_computedstyle_flex-flow-row-nowrap.htm] - type: reftest - expected: PASS diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-flow-row.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-flow-row.htm.ini deleted file mode 100644 index 91714705571..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-flow-row.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flexbox_computedstyle_flex-flow-row.htm] - type: reftest - expected: PASS diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-shorthand-0-auto.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-shorthand-0-auto.htm.ini deleted file mode 100644 index 1b8df9ab6b4..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-shorthand-0-auto.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flexbox_computedstyle_flex-shorthand-0-auto.htm] - type: reftest - expected: PASS diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-shorthand-initial.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-shorthand-initial.htm.ini deleted file mode 100644 index f69e6bb81ea..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-shorthand-initial.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flexbox_computedstyle_flex-shorthand-initial.htm] - type: reftest - expected: PASS diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-shorthand-invalid.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-shorthand-invalid.htm.ini deleted file mode 100644 index 22ca5bbe49f..00000000000 --- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_computedstyle_flex-shorthand-invalid.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[flexbox_computedstyle_flex-shorthand-invalid.htm] - type: reftest - expected: PASS