mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
stylo: Implement align-items and justify-items
This commit is contained in:
parent
11396b4dd3
commit
0a0dd11f50
5 changed files with 183 additions and 13 deletions
|
@ -864,7 +864,8 @@ fn static_assert() {
|
|||
<% skip_position_longhands = " ".join(x.ident for x in SIDES + GRID_LINES) %>
|
||||
<%self:impl_trait style_struct_name="Position"
|
||||
skip_longhands="${skip_position_longhands} z-index box-sizing order align-content
|
||||
justify-content align-self justify-self">
|
||||
justify-content align-self justify-self align-items
|
||||
justify-items">
|
||||
% for side in SIDES:
|
||||
<% impl_split_style_coord("%s" % side.ident,
|
||||
"mOffset",
|
||||
|
@ -926,6 +927,24 @@ fn static_assert() {
|
|||
|
||||
${impl_simple_copy('justify_self', 'mJustifySelf')}
|
||||
|
||||
pub fn set_align_items(&mut self, v: longhands::align_items::computed_value::T) {
|
||||
self.gecko.mAlignItems = v.0.bits()
|
||||
}
|
||||
|
||||
${impl_simple_copy('align_items', 'mAlignItems')}
|
||||
|
||||
pub fn set_justify_items(&mut self, v: longhands::justify_items::computed_value::T) {
|
||||
self.gecko.mJustifyItems = v.0.bits()
|
||||
}
|
||||
|
||||
${impl_simple_copy('justify_items', 'mJustifyItems')}
|
||||
|
||||
pub fn clone_justify_items(&self) -> longhands::justify_items::computed_value::T {
|
||||
use values::specified::align::{AlignFlags, JustifyItems};
|
||||
JustifyItems(AlignFlags::from_bits(self.gecko.mJustifyItems)
|
||||
.expect("mJustifyItems contains valid flags"))
|
||||
}
|
||||
|
||||
pub fn set_box_sizing(&mut self, v: longhands::box_sizing::computed_value::T) {
|
||||
use computed_values::box_sizing::T;
|
||||
use gecko_bindings::structs::StyleBoxSizing;
|
||||
|
|
|
@ -99,22 +99,19 @@ ${helpers.single_keyword("flex-wrap", "nowrap wrap wrap-reverse",
|
|||
animatable=False)}
|
||||
% endif
|
||||
|
||||
// https://drafts.csswg.org/css-flexbox/#propdef-align-items
|
||||
// FIXME: This is a workaround for 'normal' value. We don't support the Gecko initial value 'normal' yet.
|
||||
${helpers.single_keyword("align-items", "stretch flex-start flex-end center baseline" if product == "servo"
|
||||
else "normal stretch flex-start flex-end center baseline",
|
||||
need_clone=True,
|
||||
extra_prefixes="webkit",
|
||||
gecko_constant_prefix="NS_STYLE_ALIGN",
|
||||
spec="https://drafts.csswg.org/css-flexbox/#align-items-property",
|
||||
animatable=False)}
|
||||
|
||||
% if product == "servo":
|
||||
// FIXME: Update Servo to support the same Syntax as Gecko.
|
||||
${helpers.single_keyword("align-content", "stretch flex-start flex-end center space-between space-around",
|
||||
extra_prefixes="webkit",
|
||||
spec="https://drafts.csswg.org/css-flexbox/#align-content-property",
|
||||
animatable=False)}
|
||||
|
||||
${helpers.single_keyword("align-items",
|
||||
"stretch flex-start flex-end center baseline",
|
||||
need_clone=True,
|
||||
extra_prefixes="webkit",
|
||||
spec="https://drafts.csswg.org/css-flexbox/#align-items-property",
|
||||
animatable=False)}
|
||||
% else:
|
||||
${helpers.predefined_type(name="align-content",
|
||||
type="AlignJustifyContent",
|
||||
|
@ -122,6 +119,19 @@ ${helpers.single_keyword("align-items", "stretch flex-start flex-end center base
|
|||
spec="https://drafts.csswg.org/css-flexbox/#align-content-property",
|
||||
extra_prefixes="webkit",
|
||||
animatable=False)}
|
||||
|
||||
${helpers.predefined_type(name="align-items",
|
||||
type="AlignItems",
|
||||
initial_value="specified::AlignItems::normal()",
|
||||
spec="https://drafts.csswg.org/css-align/#propdef-align-items",
|
||||
extra_prefixes="webkit",
|
||||
animatable=False)}
|
||||
|
||||
${helpers.predefined_type(name="justify-items",
|
||||
type="JustifyItems",
|
||||
initial_value="specified::JustifyItems::auto()",
|
||||
spec="https://drafts.csswg.org/css-align/#propdef-justify-items",
|
||||
animatable=False)}
|
||||
% endif
|
||||
|
||||
// Flex item properties
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue