mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
layout: Generalize ContainingBlock
's block size to a SizeConstraint
(#34946)
It used to be an `AuOrAuto`, turning it into a `SizeConstraint` allows passing the information about the min and max constraints when the containing block doesn't have a definite block size. This will be useful for table layout. Note that in most cases we were already constructing the containing block from a `SizeConstraint`, but we were calling `to_auto_or()` to turn it into an `AuOrAuto`. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
parent
de780dcde4
commit
f66cd172d6
11 changed files with 71 additions and 69 deletions
|
@ -24,7 +24,7 @@ use crate::cell::ArcRefCell;
|
|||
use crate::fragment_tree::{
|
||||
BaseFragmentInfo, BoxFragment, CollapsedBlockMargins, Fragment, TextFragment,
|
||||
};
|
||||
use crate::geom::{AuOrAuto, LogicalRect, LogicalVec2, PhysicalRect, ToLogical};
|
||||
use crate::geom::{LogicalRect, LogicalVec2, PhysicalRect, ToLogical};
|
||||
use crate::positioned::{
|
||||
relative_adjustement, AbsolutelyPositionedBox, PositioningContext, PositioningContextLength,
|
||||
};
|
||||
|
@ -427,7 +427,7 @@ impl LineItemLayout<'_, '_> {
|
|||
let inline_box_containing_block = ContainingBlock {
|
||||
size: ContainingBlockSize {
|
||||
inline: content_rect.size.inline,
|
||||
block: AuOrAuto::Auto,
|
||||
block: Default::default(),
|
||||
},
|
||||
style: self.layout.containing_block.style,
|
||||
};
|
||||
|
|
|
@ -145,7 +145,7 @@ impl BlockLevelBox {
|
|||
|
||||
let available_inline_size =
|
||||
containing_block.size.inline - pbm.padding_border_sums.inline - margin.inline_sum();
|
||||
let available_block_size = containing_block.size.block.non_auto().map(|block_size| {
|
||||
let available_block_size = containing_block.size.block.to_definite().map(|block_size| {
|
||||
Au::zero().max(block_size - pbm.padding_border_sums.block - margin.block_sum())
|
||||
});
|
||||
|
||||
|
@ -174,7 +174,7 @@ impl BlockLevelBox {
|
|||
let containing_block_for_children = ContainingBlock {
|
||||
size: ContainingBlockSize {
|
||||
inline: inline_size,
|
||||
block: tentative_block_size.to_auto_or(),
|
||||
block: tentative_block_size,
|
||||
},
|
||||
style,
|
||||
};
|
||||
|
@ -269,7 +269,7 @@ impl OutsideMarker {
|
|||
let containing_block_for_children = ContainingBlock {
|
||||
size: ContainingBlockSize {
|
||||
inline: content_sizes.sizes.max_content,
|
||||
block: AuOrAuto::auto(),
|
||||
block: SizeConstraint::default(),
|
||||
},
|
||||
style: &self.marker_style,
|
||||
};
|
||||
|
@ -1202,7 +1202,7 @@ impl IndependentNonReplacedContents {
|
|||
let available_block_size = containing_block
|
||||
.size
|
||||
.block
|
||||
.non_auto()
|
||||
.to_definite()
|
||||
.map(|block_size| Au::zero().max(block_size - pbm_sums.block_sum()));
|
||||
let (preferred_block_size, min_block_size, max_block_size) = content_box_sizes
|
||||
.block
|
||||
|
@ -1265,7 +1265,7 @@ impl IndependentNonReplacedContents {
|
|||
&ContainingBlock {
|
||||
size: ContainingBlockSize {
|
||||
inline: inline_size,
|
||||
block: tentative_block_size.to_auto_or(),
|
||||
block: tentative_block_size,
|
||||
},
|
||||
style,
|
||||
},
|
||||
|
@ -1335,7 +1335,7 @@ impl IndependentNonReplacedContents {
|
|||
&ContainingBlock {
|
||||
size: ContainingBlockSize {
|
||||
inline: proposed_inline_size,
|
||||
block: tentative_block_size.to_auto_or(),
|
||||
block: tentative_block_size,
|
||||
},
|
||||
style,
|
||||
},
|
||||
|
@ -1662,7 +1662,7 @@ fn solve_containing_block_padding_and_border_for_in_flow_box<'a>(
|
|||
let available_block_size = containing_block
|
||||
.size
|
||||
.block
|
||||
.non_auto()
|
||||
.to_definite()
|
||||
.map(|block_size| Au::zero().max(block_size - pbm_sums.block_sum()));
|
||||
|
||||
// https://drafts.csswg.org/css2/#the-height-property
|
||||
|
@ -1698,7 +1698,7 @@ fn solve_containing_block_padding_and_border_for_in_flow_box<'a>(
|
|||
let containing_block_for_children = ContainingBlock {
|
||||
size: ContainingBlockSize {
|
||||
inline: inline_size,
|
||||
block: tentative_block_size.to_auto_or(),
|
||||
block: tentative_block_size,
|
||||
},
|
||||
style,
|
||||
};
|
||||
|
@ -2102,7 +2102,7 @@ fn block_size_is_zero_or_intrinsic(size: &StyleSize, containing_block: &Containi
|
|||
StyleSize::LengthPercentage(ref lp) => {
|
||||
// TODO: Should this resolve definite percentages? Blink does it, Gecko and WebKit don't.
|
||||
lp.is_definitely_zero() ||
|
||||
(lp.0.has_percentage() && containing_block.size.block.is_auto())
|
||||
(lp.0.has_percentage() && !containing_block.size.block.is_definite())
|
||||
},
|
||||
StyleSize::AnchorSizeFunction(_) => unreachable!("anchor-size() should be disabled"),
|
||||
}
|
||||
|
@ -2171,7 +2171,7 @@ impl IndependentFormattingContext {
|
|||
let available_block_size = containing_block
|
||||
.size
|
||||
.block
|
||||
.non_auto()
|
||||
.to_definite()
|
||||
.map(|block_size| (block_size - pbm_sums.block_sum()).max(Au::zero()));
|
||||
let tentative_block_size = content_box_sizes_and_pbm
|
||||
.content_box_sizes
|
||||
|
@ -2198,7 +2198,7 @@ impl IndependentFormattingContext {
|
|||
let containing_block_for_children = ContainingBlock {
|
||||
size: ContainingBlockSize {
|
||||
inline: inline_size,
|
||||
block: tentative_block_size.to_auto_or(),
|
||||
block: tentative_block_size,
|
||||
},
|
||||
style: self.style(),
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue