mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
flex 2020: Handle positioning flex item based on align-self
This commit is contained in:
parent
d1b92b68c7
commit
ba9448e682
1 changed files with 23 additions and 5 deletions
|
@ -715,7 +715,10 @@ impl FlexLine<'_> {
|
||||||
.items
|
.items
|
||||||
.iter()
|
.iter()
|
||||||
.zip(&item_margins)
|
.zip(&item_margins)
|
||||||
.map(|(item, margin)| item.align_along_cross_axis(margin));
|
.zip(&item_used_cross_sizes)
|
||||||
|
.map(|((item, margin), size)| {
|
||||||
|
item.align_along_cross_axis(margin, size, line_cross_size)
|
||||||
|
});
|
||||||
|
|
||||||
let item_fragments = self
|
let item_fragments = self
|
||||||
.items
|
.items
|
||||||
|
@ -1149,14 +1152,29 @@ impl FlexItem<'_> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the coordinate of the cross-start side of the content area
|
/// Return the coordinate of the cross-start side of the content area
|
||||||
fn align_along_cross_axis(&self, margin: &FlexRelativeSides<Length>) -> Length {
|
fn align_along_cross_axis(
|
||||||
|
&self,
|
||||||
|
margin: &FlexRelativeSides<Length>,
|
||||||
|
content_size: &Length,
|
||||||
|
line_cross_size: Length,
|
||||||
|
) -> Length {
|
||||||
let outer_cross_start =
|
let outer_cross_start =
|
||||||
if self.margin.cross_start.is_auto() || self.margin.cross_end.is_auto() {
|
if self.margin.cross_start.is_auto() || self.margin.cross_end.is_auto() {
|
||||||
Length::zero()
|
Length::zero()
|
||||||
} else {
|
} else {
|
||||||
// FIXME: “Align all flex items along the cross-axis per `align-self`”
|
match self.align_self {
|
||||||
// For now we hard-code the behavior of `stretch`:
|
AlignItems::Stretch | AlignItems::FlexStart => Length::zero(),
|
||||||
Length::zero()
|
AlignItems::FlexEnd => {
|
||||||
|
let margin_box_cross = *content_size + self.pbm_auto_is_zero.cross;
|
||||||
|
line_cross_size - margin_box_cross
|
||||||
|
},
|
||||||
|
AlignItems::Center => {
|
||||||
|
let margin_box_cross = *content_size + self.pbm_auto_is_zero.cross;
|
||||||
|
(line_cross_size - margin_box_cross) / 2.
|
||||||
|
},
|
||||||
|
// FIXME: handle baseline alignment
|
||||||
|
AlignItems::Baseline => Length::zero(),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
outer_cross_start + margin.cross_start + self.border.cross_start + self.padding.cross_start
|
outer_cross_start + margin.cross_start + self.border.cross_start + self.padding.cross_start
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue