mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +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
|
@ -30,7 +30,7 @@ use crate::dom::NodeExt;
|
|||
use crate::fragment_tree::{BaseFragmentInfo, Fragment, IFrameFragment, ImageFragment};
|
||||
use crate::geom::{LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSize};
|
||||
use crate::sizing::InlineContentSizesResult;
|
||||
use crate::style_ext::{AspectRatio, Clamp, ComputedValuesExt, PaddingBorderMargin};
|
||||
use crate::style_ext::{AspectRatio, Clamp, ComputedValuesExt, ContentBoxSizesAndPBMDeprecated};
|
||||
use crate::{AuOrAuto, ContainingBlock, IndefiniteContainingBlock};
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
|
@ -430,24 +430,22 @@ impl ReplacedContent {
|
|||
&self,
|
||||
containing_block: &ContainingBlock,
|
||||
style: &ComputedValues,
|
||||
pbm: &PaddingBorderMargin,
|
||||
content_box_sizes_and_pbm: &ContentBoxSizesAndPBMDeprecated,
|
||||
) -> LogicalVec2<Au> {
|
||||
let box_size = style
|
||||
.content_box_size_deprecated(containing_block, pbm)
|
||||
// We need to clamp to zero here to obtain the proper aspect
|
||||
// ratio when box-sizing is border-box and the inner box size
|
||||
// would otherwise be negative.
|
||||
// We need to clamp to zero here to obtain the proper aspect ratio when box-sizing
|
||||
// is border-box and the inner box size would otherwise be negative.
|
||||
let content_box_size = content_box_sizes_and_pbm
|
||||
.content_box_size
|
||||
.map(|value| value.map(|value| value.max(Au::zero())));
|
||||
let min_box_size = style
|
||||
.content_min_box_size_deprecated(containing_block, pbm)
|
||||
let content_min_box_size = content_box_sizes_and_pbm
|
||||
.content_min_box_size
|
||||
.auto_is(Au::zero);
|
||||
let max_box_size = style.content_max_box_size_deprecated(containing_block, pbm);
|
||||
self.used_size_as_if_inline_element_from_content_box_sizes(
|
||||
containing_block,
|
||||
style,
|
||||
box_size,
|
||||
min_box_size,
|
||||
max_box_size,
|
||||
content_box_size,
|
||||
content_min_box_size,
|
||||
content_box_sizes_and_pbm.content_max_box_size,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue