layout-2020: build fixes.

This commit is contained in:
Emilio Cobos Álvarez 2019-12-15 22:29:59 +01:00
parent 7d30a7da75
commit e885ccb7ae
5 changed files with 48 additions and 56 deletions

View file

@ -175,13 +175,14 @@ impl flow_relative::Vec2<MaxSize<LengthPercentage>> {
containing_block: &ContainingBlock, containing_block: &ContainingBlock,
) -> flow_relative::Vec2<Option<Length>> { ) -> flow_relative::Vec2<Option<Length>> {
flow_relative::Vec2 { flow_relative::Vec2 {
inline: self inline: match self.inline {
.inline MaxSize::None => None,
.to_option() MaxSize::LengthPercentage(ref lp) => Some(lp.percentage_relative_to(containing_block.inline_size)),
.map(|lp| lp.percentage_relative_to(containing_block.inline_size)), },
block: self.block.to_option().and_then(|olp| { block: match self.block {
olp.maybe_percentage_relative_to(containing_block.block_size.non_auto()) MaxSize::None => None,
}), MaxSize::LengthPercentage(ref lp) => lp.maybe_percentage_relative_to(containing_block.block_size.non_auto()),
},
} }
} }
} }

View file

@ -40,7 +40,7 @@ pub(crate) struct HoistedAbsolutelyPositionedBox<'box_tree> {
box_offsets: Vec2<AbsoluteBoxOffsets>, box_offsets: Vec2<AbsoluteBoxOffsets>,
} }
#[derive(Clone, Copy, Debug)] #[derive(Clone, Debug)]
pub(crate) enum AbsoluteBoxOffsets { pub(crate) enum AbsoluteBoxOffsets {
StaticStart { StaticStart {
start: Length, start: Length,
@ -113,13 +113,13 @@ impl AbsolutelyPositionedBox {
box_offsets: Vec2 { box_offsets: Vec2 {
inline: absolute_box_offsets( inline: absolute_box_offsets(
initial_start_corner.inline, initial_start_corner.inline,
box_offsets.inline_start, box_offsets.inline_start.clone(),
box_offsets.inline_end, box_offsets.inline_end.clone(),
), ),
block: absolute_box_offsets( block: absolute_box_offsets(
initial_start_corner.block, initial_start_corner.block,
box_offsets.block_start, box_offsets.block_start.clone(),
box_offsets.block_end, box_offsets.block_end.clone(),
), ),
}, },
} }
@ -372,20 +372,20 @@ impl<'box_tree> HoistedAbsolutelyPositionedBox<'box_tree> {
let inline_axis = solve_axis( let inline_axis = solve_axis(
cbis, cbis,
pb.inline_sum(), pb.inline_sum(),
computed_margin.inline_start, computed_margin.inline_start.clone(),
computed_margin.inline_end, computed_margin.inline_end.clone(),
/* avoid_negative_margin_start */ true, /* avoid_negative_margin_start */ true,
self.box_offsets.inline, self.box_offsets.inline.clone(),
size.inline, size.inline,
); );
let block_axis = solve_axis( let block_axis = solve_axis(
cbis, cbis,
pb.block_sum(), pb.block_sum(),
computed_margin.block_start, computed_margin.block_start.clone(),
computed_margin.block_end, computed_margin.block_end.clone(),
/* avoid_negative_margin_start */ false, /* avoid_negative_margin_start */ false,
self.box_offsets.block, self.box_offsets.block.clone(),
size.block, size.block,
); );

View file

@ -7,6 +7,7 @@
use crate::style_ext::ComputedValuesExt; use crate::style_ext::ComputedValuesExt;
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::values::computed::{Length, LengthPercentage, Percentage}; use style::values::computed::{Length, LengthPercentage, Percentage};
use style::values::generics::length::MaxSize;
use style::Zero; use style::Zero;
/// Which min/max-content values should be computed during box construction /// Which min/max-content values should be computed during box construction
@ -114,11 +115,10 @@ impl BoxContentSizes {
.inline .inline
.percentage_relative_to(Length::zero()) .percentage_relative_to(Length::zero())
.auto_is(Length::zero); .auto_is(Length::zero);
let max_inline_size = style let max_inline_size = match style.max_box_size().inline {
.max_box_size() MaxSize::None => None,
.inline MaxSize::LengthPercentage(ref lp) => lp.as_length(),
.to_option() };
.and_then(|lp| lp.as_length());
let clamp = |l: Length| l.clamp_between_extremums(min_inline_size, max_inline_size); let clamp = |l: Length| l.clamp_between_extremums(min_inline_size, max_inline_size);
// Percentages for 'width' are treated as 'auto' // Percentages for 'width' are treated as 'auto'

View file

@ -55,9 +55,9 @@ impl ComputedValuesExt for ComputedValues {
fn inline_size_is_length(&self) -> bool { fn inline_size_is_length(&self) -> bool {
let position = self.get_position(); let position = self.get_position();
let size = if self.writing_mode.is_horizontal() { let size = if self.writing_mode.is_horizontal() {
position.width &position.width
} else { } else {
position.height &position.height
}; };
matches!(size, Size::LengthPercentage(lp) if lp.0.as_length().is_some()) matches!(size, Size::LengthPercentage(lp) if lp.0.as_length().is_some())
} }
@ -65,21 +65,21 @@ impl ComputedValuesExt for ComputedValues {
fn inline_box_offsets_are_both_non_auto(&self) -> bool { fn inline_box_offsets_are_both_non_auto(&self) -> bool {
let position = self.get_position(); let position = self.get_position();
let (a, b) = if self.writing_mode.is_horizontal() { let (a, b) = if self.writing_mode.is_horizontal() {
(position.left, position.right) (&position.left, &position.right)
} else { } else {
(position.top, position.bottom) (&position.top, &position.bottom)
}; };
a != LengthPercentageOrAuto::Auto && b != LengthPercentageOrAuto::Auto !a.is_auto() && !b.is_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();
physical::Sides { physical::Sides {
top: position.top, top: position.top.clone(),
left: position.left, left: position.left.clone(),
bottom: position.bottom, bottom: position.bottom.clone(),
right: position.right, right: position.right.clone(),
} }
.to_flow_relative(self.writing_mode) .to_flow_relative(self.writing_mode)
} }
@ -88,8 +88,8 @@ impl ComputedValuesExt for ComputedValues {
fn box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto> { fn box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto> {
let position = self.get_position(); let position = self.get_position();
physical::Vec2 { physical::Vec2 {
x: size_to_length(position.width), x: size_to_length(position.width.clone()),
y: size_to_length(position.height), y: size_to_length(position.height.clone()),
} }
.size_to_flow_relative(self.writing_mode) .size_to_flow_relative(self.writing_mode)
} }
@ -98,8 +98,8 @@ impl ComputedValuesExt for ComputedValues {
fn min_box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto> { fn min_box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto> {
let position = self.get_position(); let position = self.get_position();
physical::Vec2 { physical::Vec2 {
x: size_to_length(position.min_width), x: size_to_length(position.min_width.clone()),
y: size_to_length(position.min_height), y: size_to_length(position.min_height.clone()),
} }
.size_to_flow_relative(self.writing_mode) .size_to_flow_relative(self.writing_mode)
} }
@ -112,8 +112,8 @@ impl ComputedValuesExt for ComputedValues {
}; };
let position = self.get_position(); let position = self.get_position();
physical::Vec2 { physical::Vec2 {
x: unwrap(position.max_width), x: unwrap(position.max_width.clone()),
y: unwrap(position.max_height), y: unwrap(position.max_height.clone()),
} }
.size_to_flow_relative(self.writing_mode) .size_to_flow_relative(self.writing_mode)
} }
@ -122,10 +122,10 @@ impl ComputedValuesExt for ComputedValues {
fn padding(&self) -> flow_relative::Sides<LengthPercentage> { fn padding(&self) -> flow_relative::Sides<LengthPercentage> {
let padding = self.get_padding(); let padding = self.get_padding();
physical::Sides { physical::Sides {
top: padding.padding_top.0, top: padding.padding_top.0.clone(),
left: padding.padding_left.0, left: padding.padding_left.0.clone(),
bottom: padding.padding_bottom.0, bottom: padding.padding_bottom.0.clone(),
right: padding.padding_right.0, right: padding.padding_right.0.clone(),
} }
.to_flow_relative(self.writing_mode) .to_flow_relative(self.writing_mode)
} }
@ -144,10 +144,10 @@ impl ComputedValuesExt for ComputedValues {
fn margin(&self) -> flow_relative::Sides<LengthPercentageOrAuto> { fn margin(&self) -> flow_relative::Sides<LengthPercentageOrAuto> {
let margin = self.get_margin(); let margin = self.get_margin();
physical::Sides { physical::Sides {
top: margin.margin_top, top: margin.margin_top.clone(),
left: margin.margin_left, left: margin.margin_left.clone(),
bottom: margin.margin_bottom, bottom: margin.margin_bottom.clone(),
right: margin.margin_right, right: margin.margin_right.clone(),
} }
.to_flow_relative(self.writing_mode) .to_flow_relative(self.writing_mode)
} }
@ -180,7 +180,7 @@ impl From<stylo::Display> for Display {
fn size_to_length(size: Size) -> LengthPercentageOrAuto { fn size_to_length(size: Size) -> LengthPercentageOrAuto {
match size { match size {
Size::LengthPercentage(length) => LengthPercentageOrAuto::LengthPercentage(length.0), Size::LengthPercentage(length) => LengthPercentageOrAuto::LengthPercentage(length.0.clone()),
Size::Auto => LengthPercentageOrAuto::Auto, Size::Auto => LengthPercentageOrAuto::Auto,
} }
} }

View file

@ -207,15 +207,6 @@ impl<LengthPercentage> MaxSize<LengthPercentage> {
pub fn none() -> Self { pub fn none() -> Self {
MaxSize::None MaxSize::None
} }
/// Convert
#[cfg(not(feature = "gecko"))]
pub fn to_option(self) -> Option<LengthPercentage> {
match self {
Self::LengthPercentage(lp) => Some(lp),
Self::None => None,
}
}
} }
/// A generic `<length>` | `<number>` value for the `-moz-tab-size` property. /// A generic `<length>` | `<number>` value for the `-moz-tab-size` property.