aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/taffy/layout.rs
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2024-12-18 16:52:18 -0800
committerGitHub <noreply@github.com>2024-12-19 00:52:18 +0000
commite2a0ac07ff2aeece5485f491210e77ebc2af127c (patch)
treec25df0f0f89a7ef23920017d508cb970e7a2aec7 /components/layout_2020/taffy/layout.rs
parent28e330c9b6bf4edfdb42172968268fba85ceecf5 (diff)
downloadservo-e2a0ac07ff2aeece5485f491210e77ebc2af127c.tar.gz
servo-e2a0ac07ff2aeece5485f491210e77ebc2af127c.zip
Refactor box size computation (#34671)
in each layout logic, in order to correctly resolve sizing keywords. This patch adds a new `Sizes` struct which holds the preferred, min and max sizing values for one axis, and unifies the logic to resolve the final size into there. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components/layout_2020/taffy/layout.rs')
-rw-r--r--components/layout_2020/taffy/layout.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/components/layout_2020/taffy/layout.rs b/components/layout_2020/taffy/layout.rs
index 4ed13aa008b..3cdf162899e 100644
--- a/components/layout_2020/taffy/layout.rs
+++ b/components/layout_2020/taffy/layout.rs
@@ -22,7 +22,7 @@ use crate::formatting_contexts::{
use crate::fragment_tree::{BoxFragment, CollapsedBlockMargins, Fragment};
use crate::geom::{
LogicalSides, LogicalVec2, PhysicalPoint, PhysicalRect, PhysicalSides, PhysicalSize, Size,
- SizeConstraint,
+ SizeConstraint, Sizes,
};
use crate::positioned::{AbsolutelyPositionedBox, PositioningContext, PositioningContextLength};
use crate::sizing::{ComputeInlineContentSizes, ContentSizes, InlineContentSizesResult};
@@ -155,18 +155,16 @@ impl taffy::LayoutPartialTree for TaffyContainerContext<'_> {
style,
independent_context
.preferred_aspect_ratio(&pbm.padding_border_sums),
- LogicalVec2 {
- inline: option_f32_to_size(content_box_known_dimensions.width),
- block: option_f32_to_size(content_box_known_dimensions.height),
- },
- LogicalVec2 {
- inline: Size::Numeric(Au::zero()),
- block: Size::Numeric(Au::zero()),
- },
- LogicalVec2 {
- inline: Size::Initial,
- block: Size::Initial,
- },
+ &Sizes::new(
+ option_f32_to_size(content_box_known_dimensions.height),
+ Size::Initial,
+ Size::Initial,
+ ),
+ &Sizes::new(
+ option_f32_to_size(content_box_known_dimensions.width),
+ Size::Initial,
+ Size::Initial,
+ ),
pbm.padding_border_sums + pbm.margin.auto_is(Au::zero).sum(),
)
.to_physical_size(self.style.writing_mode);