mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
layout: Avoid layout sometimes when stretching (#33967)
This is the second flexbox caching change. It seeks to detect when a relayout can be avoided in the case of a stretching flex item. This heuristic can be combined, because currently we still do relayout sometimes when we do not need to. For instance currently we always relayout when a flex child is itself a column flex. This only needs to happen when the grandchildren themselves grow or shrink. That optimization is perhaps a lower priority as `flex-grow: 0 / flex-shrink: 1` is the default behavior for flex. Since this change means we more consistenly zero out the percentage part of `calc` expressions when they have circular dependencies, this causes one test to start failing (`/css/css-values/calc-min-height-block-1.html`). This is related to w3c/csswg-drafts#10969, which is pending on further discussion in the working group. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
638b520186
commit
52db185568
12 changed files with 490 additions and 257 deletions
|
@ -627,6 +627,10 @@ pub(super) struct InlineFormattingContextLayout<'layout_data> {
|
|||
/// Whether or not this InlineFormattingContext has processed any in flow content at all.
|
||||
had_inflow_content: bool,
|
||||
|
||||
/// Whether or not the layout of this InlineFormattingContext depends on the block size
|
||||
/// of its container for the purposes of flexbox layout.
|
||||
depends_on_block_constraints: bool,
|
||||
|
||||
/// The currently white-space-collapse setting of this line. This is stored on the
|
||||
/// [`InlineFormattingContextLayout`] because when a soft wrap opportunity is defined
|
||||
/// by the boundary between two characters, the white-space-collapse property of their
|
||||
|
@ -701,6 +705,12 @@ impl<'layout_dta> InlineFormattingContextLayout<'layout_dta> {
|
|||
.map(|index| &self.ifc.font_metrics[index].metrics),
|
||||
);
|
||||
|
||||
self.depends_on_block_constraints |= inline_box
|
||||
.style
|
||||
.depends_on_block_constraints_due_to_relative_positioning(
|
||||
self.containing_block.style.writing_mode,
|
||||
);
|
||||
|
||||
// If we are starting a `<br>` element prepare to clear after its deferred linebreak has been
|
||||
// processed. Note that a `<br>` is composed of the element itself and the inner pseudo-element
|
||||
// with the actual linebreak. Both will have this `FragmentFlag`; that's why this code only
|
||||
|
@ -1631,6 +1641,7 @@ impl InlineFormattingContext {
|
|||
deferred_br_clear: Clear::None,
|
||||
have_deferred_soft_wrap_opportunity: false,
|
||||
had_inflow_content: false,
|
||||
depends_on_block_constraints: false,
|
||||
white_space_collapse: style_text.white_space_collapse,
|
||||
text_wrap_mode: style_text.text_wrap_mode,
|
||||
baselines: Baselines::default(),
|
||||
|
@ -1692,6 +1703,7 @@ impl InlineFormattingContext {
|
|||
content_block_size,
|
||||
collapsible_margins_in_children,
|
||||
baselines: layout.baselines,
|
||||
depends_on_block_constraints: layout.depends_on_block_constraints,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1921,6 +1933,12 @@ impl IndependentFormattingContext {
|
|||
layout.containing_block,
|
||||
);
|
||||
|
||||
// If this Fragment's layout depends on the block size of the containing block,
|
||||
// then the entire layout of the inline formatting context does as well.
|
||||
layout.depends_on_block_constraints |= fragment.base.flags.contains(
|
||||
FragmentFlags::SIZE_DEPENDS_ON_BLOCK_CONSTRAINTS_AND_CAN_BE_CHILD_OF_FLEX_ITEM,
|
||||
);
|
||||
|
||||
// Offset the content rectangle by the physical offset of the padding, border, and margin.
|
||||
let container_writing_mode = layout.containing_block.style.writing_mode;
|
||||
let pbm_physical_offset = pbm_sums
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue