aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPu Xingyu <pu.stshine@gmail.com>2016-07-09 22:51:07 +0800
committerPu Xingyu <pu.stshine@gmail.com>2016-07-12 07:17:31 +0800
commitd40e6c573822ca86ebc60a04ef12cac2cfed7d81 (patch)
treeccdb6cabeea7eb9d4930a0d2259bde039addf795
parentc2a22bd05e0c8282175422df26e188ef63bcc452 (diff)
downloadservo-d40e6c573822ca86ebc60a04ef12cac2cfed7d81.tar.gz
servo-d40e6c573822ca86ebc60a04ef12cac2cfed7d81.zip
Clear non-inherited properties on anonymous block
Add a modify_style_for_anonymous_flow() function to use initial values for non-inherited properties and parent values for inherited properties as the block style. It also set border and outline to zero and set the display property from the parameter.
-rw-r--r--components/layout/flow.rs3
-rw-r--r--components/style/properties/properties.mako.rs41
-rw-r--r--tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_generated-flex.htm.ini3
3 files changed, 44 insertions, 3 deletions
diff --git a/components/layout/flow.rs b/components/layout/flow.rs
index 1c53740c402..092d29bf0ac 100644
--- a/components/layout/flow.rs
+++ b/components/layout/flow.rs
@@ -1304,6 +1304,9 @@ impl<'a> ImmutableFlowUtils for &'a Flow {
Arc::new(TableCellFlow::from_node_fragment_and_visibility_flag(node, fragment, !hide))
},
FlowClass::Flex => {
+ properties::modify_style_for_anonymous_flow(
+ &mut style,
+ display::T::block);
let fragment =
Fragment::from_opaque_node_and_style(node.opaque(),
PseudoElementType::Normal,
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index 9bb65979f4e..e4da7a18c6d 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -1972,6 +1972,47 @@ pub fn cascade<C: ComputedValues>(
(style, cacheable)
}
+pub fn modify_style_for_anonymous_flow(style: &mut Arc<ServoComputedValues>,
+ new_display_value: longhands::display::computed_value::T) {
+ // The 'align-self' property needs some special treatment since
+ // its value depends on the 'align-items' value of its parent.
+ % if "align-items" in data.longhands_by_name:
+ use computed_values::align_self::T as align_self;
+ use computed_values::align_items::T as align_items;
+ let self_align =
+ match style.position.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,
+ };
+ % endif
+ let inital_values = &*INITIAL_SERVO_VALUES;
+ let mut style = Arc::make_mut(style);
+ % for style_struct in data.active_style_structs():
+ % if not style_struct.inherited:
+ style.${style_struct.ident} = inital_values.clone_${style_struct.trait_name_lower}();
+ % endif
+ % endfor
+ % if "align-items" in data.longhands_by_name:
+ let position = Arc::make_mut(&mut style.position);
+ position.align_self = self_align;
+ % endif
+ if new_display_value != longhands::display::computed_value::T::inline {
+ let new_box = Arc::make_mut(&mut style.box_);
+ new_box.display = new_display_value;
+ }
+ let border = Arc::make_mut(&mut style.border);
+ % for side in ["top", "right", "bottom", "left"]:
+ // Like calling to_computed_value, which wouldn't type check.
+ border.border_${side}_width = Au(0);
+ % endfor
+ // Initial value of outline-style is always none for anonymous box.
+ let outline = Arc::make_mut(&mut style.outline);
+ outline.outline_width = Au(0);
+}
+
/// Alters the given style to accommodate replaced content. This is called in flow construction. It
/// handles cases like `<div style="position: absolute">foo bar baz</div>` (in which `foo`, `bar`,
/// and `baz` must not be absolutely-positioned) and cases like `<sup>Foo</sup>` (in which the
diff --git a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_generated-flex.htm.ini b/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_generated-flex.htm.ini
deleted file mode 100644
index f286c4eb197..00000000000
--- a/tests/wpt/metadata-css/css-flexbox-1_dev/html/flexbox_generated-flex.htm.ini
+++ /dev/null
@@ -1,3 +0,0 @@
-[flexbox_generated-flex.htm]
- type: reftest
- expected: FAIL