mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Manage side effects when redoing layout for align-self: stretch
flex item
This commit is contained in:
parent
25469bdcd1
commit
22b60d8b82
3 changed files with 21 additions and 12 deletions
|
@ -78,6 +78,7 @@ struct FlexLine<'a> {
|
||||||
struct FlexItemLayoutResult {
|
struct FlexItemLayoutResult {
|
||||||
hypothetical_cross_size: Length,
|
hypothetical_cross_size: Length,
|
||||||
fragments: Vec<Fragment>,
|
fragments: Vec<Fragment>,
|
||||||
|
positioning_context: PositioningContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return type of `FlexLine::layout`
|
/// Return type of `FlexLine::layout`
|
||||||
|
@ -629,7 +630,7 @@ impl FlexLine<'_> {
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.zip(item_layout_results)
|
.zip(item_layout_results)
|
||||||
.zip(&item_used_main_sizes)
|
.zip(&item_used_main_sizes)
|
||||||
.map(|((item, item_result), &used_main_size)| {
|
.map(|((item, mut item_result), &used_main_size)| {
|
||||||
let has_stretch_auto = true; // FIXME: use the property
|
let has_stretch_auto = true; // FIXME: use the property
|
||||||
let cross_size = if has_stretch_auto &&
|
let cross_size = if has_stretch_auto &&
|
||||||
item.content_box_size.cross.is_auto() &&
|
item.content_box_size.cross.is_auto() &&
|
||||||
|
@ -642,13 +643,16 @@ impl FlexLine<'_> {
|
||||||
} else {
|
} else {
|
||||||
item_result.hypothetical_cross_size
|
item_result.hypothetical_cross_size
|
||||||
};
|
};
|
||||||
let fragments = if has_stretch_auto {
|
if has_stretch_auto {
|
||||||
item.layout(used_main_size, flex_context, Some(cross_size))
|
// “If the flex item has `align-self: stretch`, redo layout for its contents,
|
||||||
.fragments
|
// treating this used size as its definite cross size
|
||||||
} else {
|
// so that percentage-sized children can be resolved.”
|
||||||
item_result.fragments
|
item_result = item.layout(used_main_size, flex_context, Some(cross_size));
|
||||||
};
|
}
|
||||||
(cross_size, fragments)
|
flex_context
|
||||||
|
.positioning_context
|
||||||
|
.append(item_result.positioning_context);
|
||||||
|
(cross_size, item_result.fragments)
|
||||||
})
|
})
|
||||||
.unzip();
|
.unzip();
|
||||||
|
|
||||||
|
@ -895,6 +899,11 @@ impl<'a> FlexItem<'a> {
|
||||||
flex_context: &mut FlexContext,
|
flex_context: &mut FlexContext,
|
||||||
used_cross_size_override: Option<Length>,
|
used_cross_size_override: Option<Length>,
|
||||||
) -> FlexItemLayoutResult {
|
) -> FlexItemLayoutResult {
|
||||||
|
let mut positioning_context = PositioningContext::new_for_rayon(
|
||||||
|
flex_context
|
||||||
|
.positioning_context
|
||||||
|
.collects_for_nearest_positioned_ancestor(),
|
||||||
|
);
|
||||||
match flex_context.flex_axis {
|
match flex_context.flex_axis {
|
||||||
FlexAxis::Row => {
|
FlexAxis::Row => {
|
||||||
// The main axis is the container’s inline axis
|
// The main axis is the container’s inline axis
|
||||||
|
@ -922,6 +931,7 @@ impl<'a> FlexItem<'a> {
|
||||||
FlexItemLayoutResult {
|
FlexItemLayoutResult {
|
||||||
hypothetical_cross_size: cross_size,
|
hypothetical_cross_size: cross_size,
|
||||||
fragments,
|
fragments,
|
||||||
|
positioning_context,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
IndependentFormattingContext::NonReplaced(non_replaced) => {
|
IndependentFormattingContext::NonReplaced(non_replaced) => {
|
||||||
|
@ -939,13 +949,14 @@ impl<'a> FlexItem<'a> {
|
||||||
content_block_size,
|
content_block_size,
|
||||||
} = non_replaced.layout(
|
} = non_replaced.layout(
|
||||||
flex_context.layout_context,
|
flex_context.layout_context,
|
||||||
flex_context.positioning_context,
|
&mut positioning_context,
|
||||||
&item_as_containing_block,
|
&item_as_containing_block,
|
||||||
self.tree_rank,
|
self.tree_rank,
|
||||||
);
|
);
|
||||||
FlexItemLayoutResult {
|
FlexItemLayoutResult {
|
||||||
hypothetical_cross_size: content_block_size,
|
hypothetical_cross_size: content_block_size,
|
||||||
fragments,
|
fragments,
|
||||||
|
positioning_context,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
[dynamic-change-simplified-layout.html]
|
[dynamic-change-simplified-layout.html]
|
||||||
expected: CRASH
|
expected: FAIL
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
[layout-with-inline-svg-001.html]
|
|
||||||
expected: CRASH
|
|
Loading…
Add table
Add a link
Reference in a new issue