mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
layout: Make surrounding_intrinsic_inline_size
report border/padding
and margin separately. This makes correct table layout easier.
This commit is contained in:
parent
b659753555
commit
179547b68f
3 changed files with 16 additions and 11 deletions
|
@ -1585,12 +1585,12 @@ impl BlockFlow {
|
|||
/// used for calculating shrink-to-fit width. Assumes that intrinsic sizes have already been
|
||||
/// computed for this flow.
|
||||
fn content_intrinsic_inline_sizes(&self) -> IntrinsicISizes {
|
||||
let surrounding_inline_size = self.fragment.surrounding_intrinsic_inline_size();
|
||||
let (border_padding, margin) = self.fragment.surrounding_intrinsic_inline_size();
|
||||
IntrinsicISizes {
|
||||
minimum_inline_size: self.base.intrinsic_inline_sizes.minimum_inline_size -
|
||||
surrounding_inline_size,
|
||||
border_padding - margin,
|
||||
preferred_inline_size: self.base.intrinsic_inline_sizes.preferred_inline_size -
|
||||
surrounding_inline_size,
|
||||
border_padding - margin,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,8 +172,10 @@ impl FlexItem {
|
|||
block.fragment.compute_inline_direction_margins(containing_length);
|
||||
block.fragment.compute_block_direction_margins(containing_length);
|
||||
|
||||
let (border_padding, margin) = block.fragment.surrounding_intrinsic_inline_size();
|
||||
let content_size = block.base.intrinsic_inline_sizes.preferred_inline_size
|
||||
- block.fragment.surrounding_intrinsic_inline_size()
|
||||
- border_padding
|
||||
- margin
|
||||
+ block.fragment.box_sizing_boundary(direction);
|
||||
self.base_size = basis.specified_or_default(content_size);
|
||||
self.max_size = specified_or_none(self.style.max_inline_size(), containing_length)
|
||||
|
|
|
@ -1091,11 +1091,11 @@ impl Fragment {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns the portion of the intrinsic inline-size that consists of borders, padding, and/or
|
||||
/// margins.
|
||||
/// Returns the portion of the intrinsic inline-size that consists of borders/padding and
|
||||
/// margins, respectively.
|
||||
///
|
||||
/// FIXME(#2261, pcwalton): This won't work well for inlines: is this OK?
|
||||
pub fn surrounding_intrinsic_inline_size(&self) -> Au {
|
||||
pub fn surrounding_intrinsic_inline_size(&self) -> (Au, Au) {
|
||||
let flags = self.quantities_included_in_intrinsic_inline_size();
|
||||
let style = self.style();
|
||||
|
||||
|
@ -1127,16 +1127,19 @@ impl Fragment {
|
|||
Au(0)
|
||||
};
|
||||
|
||||
margin + padding + border
|
||||
(border + padding, margin)
|
||||
}
|
||||
|
||||
/// Uses the style only to estimate the intrinsic inline-sizes. These may be modified for text
|
||||
/// or replaced elements.
|
||||
fn style_specified_intrinsic_inline_size(&self) -> IntrinsicISizesContribution {
|
||||
pub fn style_specified_intrinsic_inline_size(&self) -> IntrinsicISizesContribution {
|
||||
let flags = self.quantities_included_in_intrinsic_inline_size();
|
||||
let style = self.style();
|
||||
let mut specified = Au(0);
|
||||
|
||||
// FIXME(#2261, pcwalton): This won't work well for inlines: is this OK?
|
||||
let (border_padding, margin) = self.surrounding_intrinsic_inline_size();
|
||||
|
||||
let mut specified = Au(0);
|
||||
if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED) {
|
||||
specified = MaybeAuto::from_style(style.content_inline_size(),
|
||||
Au(0)).specified_or_zero();
|
||||
|
@ -1154,7 +1157,7 @@ impl Fragment {
|
|||
minimum_inline_size: specified,
|
||||
preferred_inline_size: specified,
|
||||
},
|
||||
surrounding_size: surrounding_inline_size,
|
||||
surrounding_size: border_padding + margin,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue