Auto merge of #25033 - servo:intrinsic, r=nox

Add support for inline-block and for computing min/max-content
This commit is contained in:
bors-servo 2019-12-04 16:23:33 -05:00 committed by GitHub
commit e70397d90a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 823 additions and 272 deletions

View file

@ -45,6 +45,9 @@ pub(crate) enum DisplayInside {
pub(crate) trait ComputedValuesExt {
fn writing_mode(&self) -> (WritingMode, Direction);
fn writing_mode_is_horizontal(&self) -> bool;
fn inline_size_is_auto(&self) -> bool;
fn inline_box_offsets_are_both_non_auto(&self) -> bool;
fn box_offsets(&self) -> flow_relative::Sides<LengthPercentageOrAuto>;
fn box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto>;
fn min_box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto>;
@ -62,6 +65,39 @@ impl ComputedValuesExt for ComputedValues {
(writing_mode, direction)
}
fn writing_mode_is_horizontal(&self) -> bool {
match self.get_inherited_box().writing_mode {
WritingMode::HorizontalTb => true,
WritingMode::VerticalLr | WritingMode::VerticalRl => false,
}
}
fn inline_size_is_auto(&self) -> bool {
let position = self.get_position();
let size = if self.writing_mode_is_horizontal() {
position.width
} else {
position.height
};
matches!(size, Size::Auto)
}
fn inline_box_offsets_are_both_non_auto(&self) -> bool {
let position = self.get_position();
let offsets = if self.writing_mode_is_horizontal() {
(position.left, position.right)
} else {
(position.top, position.bottom)
};
matches!(
offsets,
(
LengthPercentageOrAuto::LengthPercentage(_),
LengthPercentageOrAuto::LengthPercentage(_),
)
)
}
#[inline]
fn box_offsets(&self) -> flow_relative::Sides<LengthPercentageOrAuto> {
let position = self.get_position();