mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
layout: Fix depends_on_block_constraints
logic (#38318)
The logic was wrong, sometimes we weren't setting it to true on flex containers that needed it, and then as a workaround we were setting it to to true on flex items that didn't need it. For example, this testcase had 5 cache misses when stretching the items, now we will avoid laying them out again: ```html <div style="display: flex"> <div></div> <div></div> <div></div> <div></div> <div></div> </div> ``` Also, the workaround wasn't always working, e.g. it failed to stretch the green element here: ```html <div style="display: flex; min-height: 200px"> <div> <div style="display: flex; height: 100%; background-color: red"> <div style="width: 200px; background-color: green;"></div> </div> </div> </div> ``` Testing: Adding new test Fixes: #38023 Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
a5d4c49ec6
commit
3d2f0d1be5
10 changed files with 50 additions and 36 deletions
|
@ -254,7 +254,6 @@ impl IndependentFormattingContext {
|
|||
containing_block_for_children: &ContainingBlock,
|
||||
containing_block: &ContainingBlock,
|
||||
preferred_aspect_ratio: Option<AspectRatio>,
|
||||
depends_on_block_constraints: bool,
|
||||
lazy_block_size: &LazySize,
|
||||
) -> CacheableLayoutResult {
|
||||
match &self.contents {
|
||||
|
@ -263,20 +262,17 @@ impl IndependentFormattingContext {
|
|||
containing_block_for_children,
|
||||
preferred_aspect_ratio,
|
||||
&self.base,
|
||||
depends_on_block_constraints,
|
||||
lazy_block_size,
|
||||
),
|
||||
IndependentFormattingContextContents::Flow(bfc) => bfc.layout(
|
||||
layout_context,
|
||||
positioning_context,
|
||||
containing_block_for_children,
|
||||
depends_on_block_constraints,
|
||||
),
|
||||
IndependentFormattingContextContents::Flex(fc) => fc.layout(
|
||||
layout_context,
|
||||
positioning_context,
|
||||
containing_block_for_children,
|
||||
depends_on_block_constraints,
|
||||
lazy_block_size,
|
||||
),
|
||||
IndependentFormattingContextContents::Grid(fc) => fc.layout(
|
||||
|
@ -290,7 +286,6 @@ impl IndependentFormattingContext {
|
|||
positioning_context,
|
||||
containing_block_for_children,
|
||||
containing_block,
|
||||
depends_on_block_constraints,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -307,7 +302,6 @@ impl IndependentFormattingContext {
|
|||
containing_block_for_children: &ContainingBlock,
|
||||
containing_block: &ContainingBlock,
|
||||
preferred_aspect_ratio: Option<AspectRatio>,
|
||||
depends_on_block_constraints: bool,
|
||||
lazy_block_size: &LazySize,
|
||||
) -> CacheableLayoutResult {
|
||||
if let Some(cache) = self.base.cached_layout_result.borrow().as_ref() {
|
||||
|
@ -316,8 +310,7 @@ impl IndependentFormattingContext {
|
|||
containing_block_for_children.size.inline &&
|
||||
(cache.containing_block_for_children_size.block ==
|
||||
containing_block_for_children.size.block ||
|
||||
!(cache.result.depends_on_block_constraints ||
|
||||
depends_on_block_constraints))
|
||||
!cache.result.depends_on_block_constraints)
|
||||
{
|
||||
positioning_context.append(cache.positioning_context.clone());
|
||||
return cache.result.clone();
|
||||
|
@ -337,7 +330,6 @@ impl IndependentFormattingContext {
|
|||
containing_block_for_children,
|
||||
containing_block,
|
||||
preferred_aspect_ratio,
|
||||
depends_on_block_constraints,
|
||||
lazy_block_size,
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue