Add inline_size_is_auto

This commit is contained in:
Simon Sapin 2019-12-02 23:49:39 +01:00
parent 6a5b8337a1
commit 2c124b9d0b
2 changed files with 20 additions and 0 deletions

View file

@ -4,6 +4,7 @@
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]
#![feature(matches_macro)]
pub mod context; pub mod context;
pub mod data; pub mod data;

View file

@ -43,6 +43,8 @@ pub(crate) enum DisplayInside {
pub(crate) trait ComputedValuesExt { pub(crate) trait ComputedValuesExt {
fn writing_mode(&self) -> (WritingMode, Direction); fn writing_mode(&self) -> (WritingMode, Direction);
fn writing_mode_is_horizontal(&self) -> bool;
fn inline_size_is_auto(&self) -> bool;
fn box_offsets(&self) -> flow_relative::Sides<LengthPercentageOrAuto>; fn box_offsets(&self) -> flow_relative::Sides<LengthPercentageOrAuto>;
fn box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto>; fn box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto>;
fn padding(&self) -> flow_relative::Sides<LengthPercentage>; fn padding(&self) -> flow_relative::Sides<LengthPercentage>;
@ -58,6 +60,23 @@ impl ComputedValuesExt for ComputedValues {
(writing_mode, direction) (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)
}
#[inline] #[inline]
fn box_offsets(&self) -> flow_relative::Sides<LengthPercentageOrAuto> { fn box_offsets(&self) -> flow_relative::Sides<LengthPercentageOrAuto> {
let position = self.get_position(); let position = self.get_position();