Skip to content
Permalink
Browse files

layout-2020: build fixes.

  • Loading branch information
emilio committed Dec 15, 2019
1 parent 7d30a7d commit e885ccb7aede1289c2cbb03f696c4ebe700b6919
@@ -175,13 +175,14 @@ impl flow_relative::Vec2<MaxSize<LengthPercentage>> {
containing_block: &ContainingBlock,
) -> flow_relative::Vec2<Option<Length>> {
flow_relative::Vec2 {
inline: self
.inline
.to_option()
.map(|lp| lp.percentage_relative_to(containing_block.inline_size)),
block: self.block.to_option().and_then(|olp| {
olp.maybe_percentage_relative_to(containing_block.block_size.non_auto())
}),
inline: match self.inline {
MaxSize::None => None,
MaxSize::LengthPercentage(ref lp) => Some(lp.percentage_relative_to(containing_block.inline_size)),
},
block: match self.block {
MaxSize::None => None,
MaxSize::LengthPercentage(ref lp) => lp.maybe_percentage_relative_to(containing_block.block_size.non_auto()),
},
}
}
}
@@ -40,7 +40,7 @@ pub(crate) struct HoistedAbsolutelyPositionedBox<'box_tree> {
box_offsets: Vec2<AbsoluteBoxOffsets>,
}

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

let block_axis = solve_axis(
cbis,
pb.block_sum(),
computed_margin.block_start,
computed_margin.block_end,
computed_margin.block_start.clone(),
computed_margin.block_end.clone(),
/* avoid_negative_margin_start */ false,
self.box_offsets.block,
self.box_offsets.block.clone(),
size.block,
);

@@ -7,6 +7,7 @@
use crate::style_ext::ComputedValuesExt;
use style::properties::ComputedValues;
use style::values::computed::{Length, LengthPercentage, Percentage};
use style::values::generics::length::MaxSize;
use style::Zero;

/// Which min/max-content values should be computed during box construction
@@ -114,11 +115,10 @@ impl BoxContentSizes {
.inline
.percentage_relative_to(Length::zero())
.auto_is(Length::zero);
let max_inline_size = style
.max_box_size()
.inline
.to_option()
.and_then(|lp| lp.as_length());
let max_inline_size = match style.max_box_size().inline {
MaxSize::None => None,
MaxSize::LengthPercentage(ref lp) => lp.as_length(),
};
let clamp = |l: Length| l.clamp_between_extremums(min_inline_size, max_inline_size);

// Percentages for 'width' are treated as 'auto'
@@ -55,31 +55,31 @@ impl ComputedValuesExt for ComputedValues {
fn inline_size_is_length(&self) -> bool {
let position = self.get_position();
let size = if self.writing_mode.is_horizontal() {
position.width
&position.width
} else {
position.height
&position.height
};
matches!(size, Size::LengthPercentage(lp) if lp.0.as_length().is_some())
}

fn inline_box_offsets_are_both_non_auto(&self) -> bool {
let position = self.get_position();
let (a, b) = if self.writing_mode.is_horizontal() {
(position.left, position.right)
(&position.left, &position.right)
} else {
(position.top, position.bottom)
(&position.top, &position.bottom)
};
a != LengthPercentageOrAuto::Auto && b != LengthPercentageOrAuto::Auto
!a.is_auto() && !b.is_auto()
}

#[inline]
fn box_offsets(&self) -> flow_relative::Sides<LengthPercentageOrAuto> {
let position = self.get_position();
physical::Sides {
top: position.top,
left: position.left,
bottom: position.bottom,
right: position.right,
top: position.top.clone(),
left: position.left.clone(),
bottom: position.bottom.clone(),
right: position.right.clone(),
}
.to_flow_relative(self.writing_mode)
}
@@ -88,8 +88,8 @@ impl ComputedValuesExt for ComputedValues {
fn box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto> {
let position = self.get_position();
physical::Vec2 {
x: size_to_length(position.width),
y: size_to_length(position.height),
x: size_to_length(position.width.clone()),
y: size_to_length(position.height.clone()),
}
.size_to_flow_relative(self.writing_mode)
}
@@ -98,8 +98,8 @@ impl ComputedValuesExt for ComputedValues {
fn min_box_size(&self) -> flow_relative::Vec2<LengthPercentageOrAuto> {
let position = self.get_position();
physical::Vec2 {
x: size_to_length(position.min_width),
y: size_to_length(position.min_height),
x: size_to_length(position.min_width.clone()),
y: size_to_length(position.min_height.clone()),
}
.size_to_flow_relative(self.writing_mode)
}
@@ -112,8 +112,8 @@ impl ComputedValuesExt for ComputedValues {
};
let position = self.get_position();
physical::Vec2 {
x: unwrap(position.max_width),
y: unwrap(position.max_height),
x: unwrap(position.max_width.clone()),
y: unwrap(position.max_height.clone()),
}
.size_to_flow_relative(self.writing_mode)
}
@@ -122,10 +122,10 @@ impl ComputedValuesExt for ComputedValues {
fn padding(&self) -> flow_relative::Sides<LengthPercentage> {
let padding = self.get_padding();
physical::Sides {
top: padding.padding_top.0,
left: padding.padding_left.0,
bottom: padding.padding_bottom.0,
right: padding.padding_right.0,
top: padding.padding_top.0.clone(),
left: padding.padding_left.0.clone(),
bottom: padding.padding_bottom.0.clone(),
right: padding.padding_right.0.clone(),
}
.to_flow_relative(self.writing_mode)
}
@@ -144,10 +144,10 @@ impl ComputedValuesExt for ComputedValues {
fn margin(&self) -> flow_relative::Sides<LengthPercentageOrAuto> {
let margin = self.get_margin();
physical::Sides {
top: margin.margin_top,
left: margin.margin_left,
bottom: margin.margin_bottom,
right: margin.margin_right,
top: margin.margin_top.clone(),
left: margin.margin_left.clone(),
bottom: margin.margin_bottom.clone(),
right: margin.margin_right.clone(),
}
.to_flow_relative(self.writing_mode)
}
@@ -180,7 +180,7 @@ impl From<stylo::Display> for Display {

fn size_to_length(size: Size) -> LengthPercentageOrAuto {
match size {
Size::LengthPercentage(length) => LengthPercentageOrAuto::LengthPercentage(length.0),
Size::LengthPercentage(length) => LengthPercentageOrAuto::LengthPercentage(length.0.clone()),
Size::Auto => LengthPercentageOrAuto::Auto,
}
}
@@ -207,15 +207,6 @@ impl<LengthPercentage> MaxSize<LengthPercentage> {
pub fn none() -> Self {
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.

0 comments on commit e885ccb

Please sign in to comment.
You can’t perform that action at this time.