Fixup for align-self and tests

This is a fixup for `align-self`, the computed value of which should now
properly inherit `align-items` value of its parent. Additional passed
tests is also removed from ini folder. Fixup for geckolib errors.
This commit is contained in:
Pu Xingyu 2016-05-27 09:04:37 +08:00
parent a7733b38d4
commit f4b8f9766c
10 changed files with 54 additions and 27 deletions

View file

@ -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">

View file

@ -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<C: ComputedValues>(
}
}
{
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.

View file

@ -17,7 +17,7 @@ body {
var passed =
getComputedStyle(body).getPropertyValue("align-self") ==
"auto";
"stretch";
body.textContent = body.className = passed ? "PASS" : "FAIL";
</script>
</body></html>

View file

@ -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",

View file

@ -1,3 +0,0 @@
[flexbox_computedstyle_flex-flow-nowrap.htm]
type: reftest
expected: PASS

View file

@ -1,3 +0,0 @@
[flexbox_computedstyle_flex-flow-row-nowrap.htm]
type: reftest
expected: PASS

View file

@ -1,3 +0,0 @@
[flexbox_computedstyle_flex-flow-row.htm]
type: reftest
expected: PASS

View file

@ -1,3 +0,0 @@
[flexbox_computedstyle_flex-shorthand-0-auto.htm]
type: reftest
expected: PASS

View file

@ -1,3 +0,0 @@
[flexbox_computedstyle_flex-shorthand-initial.htm]
type: reftest
expected: PASS

View file

@ -1,3 +0,0 @@
[flexbox_computedstyle_flex-shorthand-invalid.htm]
type: reftest
expected: PASS