aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/flexbox
diff options
context:
space:
mode:
authorOriol Brufau <obrufau@igalia.com>2025-01-16 08:54:47 -0800
committerGitHub <noreply@github.com>2025-01-16 16:54:47 +0000
commit60dc3b26fb01ac3730475113033c270e95276a69 (patch)
tree848bb5034c0197d6446b648475307bb3d99517b6 /components/layout_2020/flexbox
parent7e7792dfbdf5af7d447f9d99b915a8b7f4a6e7e9 (diff)
downloadservo-60dc3b26fb01ac3730475113033c270e95276a69.tar.gz
servo-60dc3b26fb01ac3730475113033c270e95276a69.zip
layout: Allow layouts to customize their used style (#35012)
Some layouts like table need some style overrides. We were handling this in `ComputedValuesExt`, but it was messy, unreliable and too limited. For example, we were assuming that a style with `display: table` would belong to a table wrapper box or table grid box. However, certain HTML elements can ignore their `display` value and generate a different kind of box. I think we aren't doing that yet, but we will need this. Also, resolving the used border of a table needs layout information, which we don't have in `ComputedValuesExt`. This patch will allow to improve border collapsing in a follow-up. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Diffstat (limited to 'components/layout_2020/flexbox')
-rw-r--r--components/layout_2020/flexbox/layout.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/components/layout_2020/flexbox/layout.rs b/components/layout_2020/flexbox/layout.rs
index 9fd038b2be4..8501398b5d4 100644
--- a/components/layout_2020/flexbox/layout.rs
+++ b/components/layout_2020/flexbox/layout.rs
@@ -42,7 +42,8 @@ use crate::sizing::{
ComputeInlineContentSizes, ContentSizes, InlineContentSizesResult, IntrinsicSizingMode,
};
use crate::style_ext::{
- AspectRatio, Clamp, ComputedValuesExt, ContentBoxSizesAndPBMDeprecated, PaddingBorderMargin,
+ AspectRatio, Clamp, ComputedValuesExt, ContentBoxSizesAndPBMDeprecated, LayoutStyle,
+ PaddingBorderMargin,
};
use crate::{
ConstraintSpace, ContainingBlock, ContainingBlockSize, IndefiniteContainingBlock,
@@ -1052,7 +1053,7 @@ impl FlexContainer {
containing_block_for_container: &ContainingBlock,
) -> (FlexRelativeVec2<Au>, FlexRelativeVec2<Option<Au>>, bool) {
let sizes: ContentBoxSizesAndPBMDeprecated = self
- .style
+ .layout_style()
.content_box_sizes_and_padding_border_margin(&containing_block_for_container.into())
.into();
@@ -1071,6 +1072,11 @@ impl FlexContainer {
sizes.depends_on_block_constraints,
)
}
+
+ #[inline]
+ pub(crate) fn layout_style(&self) -> LayoutStyle {
+ LayoutStyle::Default(&self.style)
+ }
}
/// Align all flex lines per `align-content` according to
@@ -1141,7 +1147,8 @@ impl<'a> FlexItem<'a> {
pbm,
depends_on_block_constraints,
} = box_
- .style()
+ .independent_formatting_context
+ .layout_style()
.content_box_sizes_and_padding_border_margin(&containing_block.into())
.into();
@@ -2281,7 +2288,9 @@ impl FlexItemBox {
content_max_box_size,
pbm,
..
- } = style
+ } = self
+ .independent_formatting_context
+ .layout_style()
.content_box_sizes_and_padding_border_margin(containing_block)
.into();
let preferred_aspect_ratio = self