Servo build fixes.

This commit is contained in:
Emilio Cobos Álvarez 2019-12-15 22:12:10 +01:00
parent c1c2b746c8
commit 7d30a7da75
18 changed files with 118 additions and 117 deletions

View file

@ -131,7 +131,7 @@ impl<'a> From<&'a FontStyleStruct> for FontDescriptor {
FontDescriptor { FontDescriptor {
template_descriptor: FontTemplateDescriptor::from(style), template_descriptor: FontTemplateDescriptor::from(style),
variant: style.font_variant_caps, variant: style.font_variant_caps,
pt_size: style.font_size.size(), pt_size: Au::from_f32_px(style.font_size.size().px()),
} }
} }
} }

View file

@ -95,7 +95,7 @@ impl<S: FontSource> FontContext<S> {
self.expire_font_caches_if_necessary(); self.expire_font_caches_if_necessary();
let cache_key = FontGroupCacheKey { let cache_key = FontGroupCacheKey {
size: style.font_size.size(), size: Au::from_f32_px(style.font_size.size().px()),
style, style,
}; };

View file

@ -2029,7 +2029,7 @@ impl BlockFlow {
// If `max-width` is set, then don't perform this speculation. We guess that the // If `max-width` is set, then don't perform this speculation. We guess that the
// page set `max-width` in order to avoid hitting floats. The search box on Google // page set `max-width` in order to avoid hitting floats. The search box on Google
// SERPs falls into this category. // SERPs falls into this category.
if self.fragment.style.max_inline_size() != MaxSize::None { if !matches!(self.fragment.style.max_inline_size(), MaxSize::None) {
return; return;
} }
@ -2548,8 +2548,8 @@ impl Flow for BlockFlow {
.base .base
.flags .flags
.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) && .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) &&
self.fragment.style().logical_position().inline_start == LengthPercentageOrAuto::Auto && self.fragment.style().logical_position().inline_start.is_auto() &&
self.fragment.style().logical_position().inline_end == LengthPercentageOrAuto::Auto self.fragment.style().logical_position().inline_end.is_auto()
{ {
self.base.position.start.i = inline_position self.base.position.start.i = inline_position
} }
@ -2560,8 +2560,8 @@ impl Flow for BlockFlow {
.base .base
.flags .flags
.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) && .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) &&
self.fragment.style().logical_position().block_start == LengthPercentageOrAuto::Auto && self.fragment.style().logical_position().block_start.is_auto() &&
self.fragment.style().logical_position().block_end == LengthPercentageOrAuto::Auto self.fragment.style().logical_position().block_end.is_auto()
{ {
self.base.position.start.b = block_position self.base.position.start.b = block_position
} }
@ -2848,16 +2848,18 @@ pub trait ISizeAndMarginsComputer {
parent_flow_inline_size: Au, parent_flow_inline_size: Au,
shared_context: &SharedStyleContext, shared_context: &SharedStyleContext,
) -> MaybeAuto { ) -> MaybeAuto {
let inline_size = self.containing_block_inline_size(
block,
parent_flow_inline_size,
shared_context,
);
MaybeAuto::from_option( MaybeAuto::from_option(
block block
.fragment() .fragment()
.style() .style()
.content_inline_size() .content_inline_size()
.to_used_value(self.containing_block_inline_size( .to_used_value(inline_size),
block,
parent_flow_inline_size,
shared_context,
)),
) )
} }

View file

@ -47,7 +47,7 @@ pub fn get_cyclic<T>(arr: &[T], index: usize) -> &T {
/// For a given area and an image compute how big the /// For a given area and an image compute how big the
/// image should be displayed on the background. /// image should be displayed on the background.
fn compute_background_image_size( fn compute_background_image_size(
bg_size: BackgroundSize, bg_size: &BackgroundSize,
bounds_size: Size2D<Au>, bounds_size: Size2D<Au>,
intrinsic_size: Option<Size2D<Au>>, intrinsic_size: Option<Size2D<Au>>,
) -> Size2D<Au> { ) -> Size2D<Au> {
@ -156,7 +156,7 @@ pub fn placement(
let bg_position_x = get_cyclic(&bg.background_position_x.0, index); let bg_position_x = get_cyclic(&bg.background_position_x.0, index);
let bg_position_y = get_cyclic(&bg.background_position_y.0, index); let bg_position_y = get_cyclic(&bg.background_position_y.0, index);
let bg_repeat = get_cyclic(&bg.background_repeat.0, index); let bg_repeat = get_cyclic(&bg.background_repeat.0, index);
let bg_size = *get_cyclic(&bg.background_size.0, index); let bg_size = get_cyclic(&bg.background_size.0, index);
let (clip_rect, clip_radii) = clip( let (clip_rect, clip_radii) = clip(
bg_clip, bg_clip,

View file

@ -25,7 +25,7 @@ use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF, NormalBorder}
/// ///
/// [1]: https://drafts.csswg.org/css-backgrounds-3/#border-radius /// [1]: https://drafts.csswg.org/css-backgrounds-3/#border-radius
fn corner_radius( fn corner_radius(
radius: BorderCornerRadius, radius: &BorderCornerRadius,
containing_size: UntypedSize2D<Au>, containing_size: UntypedSize2D<Au>,
) -> UntypedSize2D<Au> { ) -> UntypedSize2D<Au> {
let w = radius.0.width().to_used_value(containing_size.width); let w = radius.0.width().to_used_value(containing_size.width);
@ -91,13 +91,13 @@ pub fn radii(abs_bounds: Rect<Au>, border_style: &Border) -> BorderRadius {
overlapping_radii( overlapping_radii(
abs_bounds.size.to_layout(), abs_bounds.size.to_layout(),
BorderRadius { BorderRadius {
top_left: corner_radius(border_style.border_top_left_radius, abs_bounds.size) top_left: corner_radius(&border_style.border_top_left_radius, abs_bounds.size)
.to_layout(), .to_layout(),
top_right: corner_radius(border_style.border_top_right_radius, abs_bounds.size) top_right: corner_radius(&border_style.border_top_right_radius, abs_bounds.size)
.to_layout(), .to_layout(),
bottom_right: corner_radius(border_style.border_bottom_right_radius, abs_bounds.size) bottom_right: corner_radius(&border_style.border_bottom_right_radius, abs_bounds.size)
.to_layout(), .to_layout(),
bottom_left: corner_radius(border_style.border_bottom_left_radius, abs_bounds.size) bottom_left: corner_radius(&border_style.border_bottom_left_radius, abs_bounds.size)
.to_layout(), .to_layout(),
}, },
) )
@ -161,7 +161,7 @@ pub fn image_outset(
} }
fn side_image_width( fn side_image_width(
border_image_width: BorderImageSideWidth, border_image_width: &BorderImageSideWidth,
border_width: f32, border_width: f32,
total_length: Au, total_length: Au,
) -> f32 { ) -> f32 {
@ -178,10 +178,10 @@ pub fn image_width(
border_area: UntypedSize2D<Au>, border_area: UntypedSize2D<Au>,
) -> LayoutSideOffsets { ) -> LayoutSideOffsets {
LayoutSideOffsets::new( LayoutSideOffsets::new(
side_image_width(width.0, border.top, border_area.height), side_image_width(&width.0, border.top, border_area.height),
side_image_width(width.1, border.right, border_area.width), side_image_width(&width.1, border.right, border_area.width),
side_image_width(width.2, border.bottom, border_area.height), side_image_width(&width.2, border.bottom, border_area.height),
side_image_width(width.3, border.left, border_area.width), side_image_width(&width.3, border.left, border_area.width),
) )
} }

View file

@ -995,7 +995,7 @@ impl Fragment {
}; };
DisplayItem::Gradient(CommonDisplayItem::with_data(base, item, stops)) DisplayItem::Gradient(CommonDisplayItem::with_data(base, item, stops))
}, },
GradientKind::Radial(shape, center) => { GradientKind::Radial(ref shape, ref center) => {
let (gradient, stops) = gradient::radial( let (gradient, stops) = gradient::radial(
style, style,
placement.tile_size, placement.tile_size,
@ -1238,7 +1238,7 @@ impl Fragment {
stops = linear_stops; stops = linear_stops;
NinePatchBorderSource::Gradient(wr_gradient) NinePatchBorderSource::Gradient(wr_gradient)
}, },
GradientKind::Radial(shape, center) => { GradientKind::Radial(ref shape, ref center) => {
let (wr_gradient, radial_stops) = gradient::radial( let (wr_gradient, radial_stops) = gradient::radial(
style, style,
border_image_area, border_image_area,

View file

@ -91,9 +91,9 @@ fn convert_gradient_stops(
color, color,
position: None, position: None,
}), }),
GradientItem::ComplexColorStop { color, position } => Some(ColorStop { GradientItem::ComplexColorStop { color, ref position } => Some(ColorStop {
color, color,
position: Some(position), position: Some(position.clone()),
}), }),
_ => None, _ => None,
}) })
@ -122,15 +122,18 @@ fn convert_gradient_stops(
// Step 2: Move any stops placed before earlier stops to the // Step 2: Move any stops placed before earlier stops to the
// same position as the preceding stop. // same position as the preceding stop.
let mut last_stop_position = stop_items.first().unwrap().position.unwrap(); //
// FIXME(emilio): Once we know the offsets, it seems like converting the
// positions to absolute at once then process that would be cheaper.
let mut last_stop_position = stop_items.first().unwrap().position.as_ref().unwrap().clone();
for stop in stop_items.iter_mut().skip(1) { for stop in stop_items.iter_mut().skip(1) {
if let Some(pos) = stop.position { if let Some(ref pos) = stop.position {
if position_to_offset(last_stop_position, total_length) > if position_to_offset(&last_stop_position, total_length) >
position_to_offset(pos, total_length) position_to_offset(pos, total_length)
{ {
stop.position = Some(last_stop_position); stop.position = Some(last_stop_position);
} }
last_stop_position = stop.position.unwrap(); last_stop_position = stop.position.as_ref().unwrap().clone();
} }
} }
@ -145,7 +148,7 @@ fn convert_gradient_stops(
// `unwrap()` here should never fail because this is the beginning of // `unwrap()` here should never fail because this is the beginning of
// a stop run, which is always bounded by a length or percentage. // a stop run, which is always bounded by a length or percentage.
let start_offset = let start_offset =
position_to_offset(stop_items[i - 1].position.unwrap(), total_length); position_to_offset(stop_items[i - 1].position.as_ref().unwrap(), total_length);
// `unwrap()` here should never fail because this is the end of // `unwrap()` here should never fail because this is the end of
// a stop run, which is always bounded by a length or percentage. // a stop run, which is always bounded by a length or percentage.
let (end_index, end_stop) = stop_items[(i + 1)..] let (end_index, end_stop) = stop_items[(i + 1)..]
@ -153,7 +156,7 @@ fn convert_gradient_stops(
.enumerate() .enumerate()
.find(|&(_, ref stop)| stop.position.is_some()) .find(|&(_, ref stop)| stop.position.is_some())
.unwrap(); .unwrap();
let end_offset = position_to_offset(end_stop.position.unwrap(), total_length); let end_offset = position_to_offset(end_stop.position.as_ref().unwrap(), total_length);
stop_run = Some(StopRun { stop_run = Some(StopRun {
start_offset, start_offset,
end_offset, end_offset,
@ -168,7 +171,7 @@ fn convert_gradient_stops(
stop_run_length * (i - stop_run.start_index) as f32 / stop_run_length * (i - stop_run.start_index) as f32 /
((2 + stop_run.stop_count) as f32) ((2 + stop_run.stop_count) as f32)
}, },
Some(position) => { Some(ref position) => {
stop_run = None; stop_run = None;
position_to_offset(position, total_length) position_to_offset(position, total_length)
}, },
@ -212,7 +215,7 @@ where
Size2D::new(cmp(left_side, right_side), cmp(top_side, bottom_side)) Size2D::new(cmp(left_side, right_side), cmp(top_side, bottom_side))
} }
fn position_to_offset(position: LengthPercentage, total_length: Au) -> f32 { fn position_to_offset(position: &LengthPercentage, total_length: Au) -> f32 {
if total_length == Au(0) { if total_length == Au(0) {
return 0.0; return 0.0;
} }
@ -289,8 +292,8 @@ pub fn radial(
style: &ComputedValues, style: &ComputedValues,
size: Size2D<Au>, size: Size2D<Au>,
stops: &[GradientItem], stops: &[GradientItem],
shape: EndingShape, shape: &EndingShape,
center: Position, center: &Position,
repeating: bool, repeating: bool,
) -> (RadialGradient, Vec<GradientStop>) { ) -> (RadialGradient, Vec<GradientStop>) {
let center = Point2D::new( let center = Point2D::new(
@ -299,15 +302,15 @@ pub fn radial(
); );
let radius = match shape { let radius = match shape {
EndingShape::Circle(Circle::Radius(length)) => { EndingShape::Circle(Circle::Radius(length)) => {
let length = Au::from(length); let length = Au::from(*length);
Size2D::new(length, length) Size2D::new(length, length)
}, },
EndingShape::Circle(Circle::Extent(extent)) => circle_size_keyword(extent, &size, &center), EndingShape::Circle(Circle::Extent(extent)) => circle_size_keyword(*extent, &size, &center),
EndingShape::Ellipse(Ellipse::Radii(x, y)) => { EndingShape::Ellipse(Ellipse::Radii(x, y)) => {
Size2D::new(x.to_used_value(size.width), y.to_used_value(size.height)) Size2D::new(x.to_used_value(size.width), y.to_used_value(size.height))
}, },
EndingShape::Ellipse(Ellipse::Extent(extent)) => { EndingShape::Ellipse(Ellipse::Extent(extent)) => {
ellipse_size_keyword(extent, &size, &center) ellipse_size_keyword(*extent, &size, &center)
}, },
}; };

View file

@ -43,7 +43,7 @@ enum AxisSize {
impl AxisSize { impl AxisSize {
/// Generate a new available cross or main axis size from the specified size of the container, /// Generate a new available cross or main axis size from the specified size of the container,
/// containing block size, min constraint, and max constraint /// containing block size, min constraint, and max constraint
pub fn new(size: Size, content_size: Option<Au>, min: Size, max: MaxSize) -> AxisSize { pub fn new(size: &Size, content_size: Option<Au>, min: &Size, max: &MaxSize) -> AxisSize {
match size { match size {
Size::Auto => AxisSize::MinMax(SizeConstraint::new(content_size, min, max, None)), Size::Auto => AxisSize::MinMax(SizeConstraint::new(content_size, min, max, None)),
Size::LengthPercentage(ref lp) => match lp.maybe_to_used_value(content_size) { Size::LengthPercentage(ref lp) => match lp.maybe_to_used_value(content_size) {
@ -58,10 +58,10 @@ impl AxisSize {
/// and the container size, then return the used value of flex basis. it can be used to help /// and the container size, then return the used value of flex basis. it can be used to help
/// determining the flex base size and to indicate whether the main size of the item /// determining the flex base size and to indicate whether the main size of the item
/// is definite after flex size resolving. /// is definite after flex size resolving.
fn from_flex_basis(flex_basis: FlexBasis, main_length: Size, containing_length: Au) -> MaybeAuto { fn from_flex_basis(flex_basis: &FlexBasis, main_length: &Size, containing_length: Au) -> MaybeAuto {
let width = match flex_basis { let width = match flex_basis {
FlexBasis::Content => return MaybeAuto::Auto, FlexBasis::Content => return MaybeAuto::Auto,
FlexBasis::Size(width) => width, FlexBasis::Size(ref width) => width,
}; };
let width = match width { let width = match width {
@ -135,7 +135,7 @@ impl FlexItem {
// https://drafts.csswg.org/css-flexbox-1/#min-size-auto // https://drafts.csswg.org/css-flexbox-1/#min-size-auto
Direction::Inline => { Direction::Inline => {
let basis = from_flex_basis( let basis = from_flex_basis(
block.fragment.style.get_position().flex_basis, &block.fragment.style.get_position().flex_basis,
block.fragment.style.content_inline_size(), block.fragment.style.content_inline_size(),
containing_length, containing_length,
); );
@ -170,7 +170,7 @@ impl FlexItem {
}, },
Direction::Block => { Direction::Block => {
let basis = from_flex_basis( let basis = from_flex_basis(
block.fragment.style.get_position().flex_basis, &block.fragment.style.get_position().flex_basis,
block.fragment.style.content_block_size(), block.fragment.style.content_block_size(),
containing_length, containing_length,
); );
@ -452,7 +452,7 @@ impl FlexFlow {
fn inline_mode_bubble_inline_sizes(&mut self) { fn inline_mode_bubble_inline_sizes(&mut self) {
// FIXME(emilio): This doesn't handle at all writing-modes. // FIXME(emilio): This doesn't handle at all writing-modes.
let fixed_width = let fixed_width =
!model::style_length(self.block_flow.fragment.style().get_position().width, None) !model::style_length(&self.block_flow.fragment.style().get_position().width, None)
.is_auto(); .is_auto();
let mut computation = self.block_flow.fragment.compute_intrinsic_inline_sizes(); let mut computation = self.block_flow.fragment.compute_intrinsic_inline_sizes();
@ -478,7 +478,7 @@ impl FlexFlow {
// stripped out. // stripped out.
fn block_mode_bubble_inline_sizes(&mut self) { fn block_mode_bubble_inline_sizes(&mut self) {
let fixed_width = let fixed_width =
!model::style_length(self.block_flow.fragment.style().get_position().width, None) !model::style_length(&self.block_flow.fragment.style().get_position().width, None)
.is_auto(); .is_auto();
let mut computation = self.block_flow.fragment.compute_intrinsic_inline_sizes(); let mut computation = self.block_flow.fragment.compute_intrinsic_inline_sizes();
@ -960,9 +960,9 @@ impl Flow for FlexFlow {
let style = &self.block_flow.fragment.style; let style = &self.block_flow.fragment.style;
let (specified_block_size, specified_inline_size) = if style.writing_mode.is_vertical() let (specified_block_size, specified_inline_size) = if style.writing_mode.is_vertical()
{ {
(style.get_position().width, style.get_position().height) (&style.get_position().width, &style.get_position().height)
} else { } else {
(style.get_position().height, style.get_position().width) (&style.get_position().height, &style.get_position().width)
}; };
let available_inline_size = AxisSize::new( let available_inline_size = AxisSize::new(

View file

@ -64,7 +64,6 @@ use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage; use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::computed::LengthPercentageOrAuto;
use webrender_api::units::LayoutTransform; use webrender_api::units::LayoutTransform;
/// This marker trait indicates that a type is a struct with `#[repr(C)]` whose first field /// This marker trait indicates that a type is a struct with `#[repr(C)]` whose first field
@ -1020,13 +1019,13 @@ impl BaseFlow {
flags.insert(FlowFlags::IS_ABSOLUTELY_POSITIONED); flags.insert(FlowFlags::IS_ABSOLUTELY_POSITIONED);
let logical_position = style.logical_position(); let logical_position = style.logical_position();
if logical_position.inline_start == LengthPercentageOrAuto::Auto && if logical_position.inline_start.is_auto() &&
logical_position.inline_end == LengthPercentageOrAuto::Auto logical_position.inline_end.is_auto()
{ {
flags.insert(FlowFlags::INLINE_POSITION_IS_STATIC); flags.insert(FlowFlags::INLINE_POSITION_IS_STATIC);
} }
if logical_position.block_start == LengthPercentageOrAuto::Auto && if logical_position.block_start.is_auto() &&
logical_position.block_end == LengthPercentageOrAuto::Auto logical_position.block_end.is_auto()
{ {
flags.insert(FlowFlags::BLOCK_POSITION_IS_STATIC); flags.insert(FlowFlags::BLOCK_POSITION_IS_STATIC);
} }
@ -1113,13 +1112,13 @@ impl BaseFlow {
let logical_position = style.logical_position(); let logical_position = style.logical_position();
self.flags.set( self.flags.set(
FlowFlags::INLINE_POSITION_IS_STATIC, FlowFlags::INLINE_POSITION_IS_STATIC,
logical_position.inline_start == LengthPercentageOrAuto::Auto && logical_position.inline_start.is_auto() &&
logical_position.inline_end == LengthPercentageOrAuto::Auto, logical_position.inline_end.is_auto()
); );
self.flags.set( self.flags.set(
FlowFlags::BLOCK_POSITION_IS_STATIC, FlowFlags::BLOCK_POSITION_IS_STATIC,
logical_position.block_start == LengthPercentageOrAuto::Auto && logical_position.block_start.is_auto() &&
logical_position.block_end == LengthPercentageOrAuto::Auto, logical_position.block_end.is_auto()
); );
} }
} }

View file

@ -61,10 +61,9 @@ use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
use style::str::char_is_whitespace; use style::str::char_is_whitespace;
use style::values::computed::counters::ContentItem; use style::values::computed::counters::ContentItem;
use style::values::computed::{LengthPercentage, LengthPercentageOrAuto, Size, VerticalAlign}; use style::values::computed::{Size, VerticalAlign};
use style::values::generics::box_::{Perspective, VerticalAlignKeyword}; use style::values::generics::box_::{Perspective, VerticalAlignKeyword};
use style::values::generics::transform; use style::values::generics::transform;
use style::Zero;
use webrender_api; use webrender_api;
use webrender_api::units::LayoutTransform; use webrender_api::units::LayoutTransform;
@ -1329,13 +1328,17 @@ impl Fragment {
return; return;
}, },
_ => { _ => {
let (inline_start, inline_end) = {
let margin = self.style().logical_margin(); let margin = self.style().logical_margin();
self.margin.inline_start = (
MaybeAuto::from_style(margin.inline_start, containing_block_inline_size) MaybeAuto::from_style(margin.inline_start, containing_block_inline_size)
.specified_or_zero(); .specified_or_zero(),
self.margin.inline_end =
MaybeAuto::from_style(margin.inline_end, containing_block_inline_size) MaybeAuto::from_style(margin.inline_end, containing_block_inline_size)
.specified_or_zero(); .specified_or_zero(),
)
};
self.margin.inline_start = inline_start;
self.margin.inline_end = inline_end;
}, },
} }
@ -1384,13 +1387,17 @@ impl Fragment {
_ => { _ => {
// NB: Percentages are relative to containing block inline-size (not block-size) // NB: Percentages are relative to containing block inline-size (not block-size)
// per CSS 2.1. // per CSS 2.1.
let (block_start, block_end) = {
let margin = self.style().logical_margin(); let margin = self.style().logical_margin();
self.margin.block_start = (
MaybeAuto::from_style(margin.block_start, containing_block_inline_size) MaybeAuto::from_style(margin.block_start, containing_block_inline_size)
.specified_or_zero(); .specified_or_zero(),
self.margin.block_end =
MaybeAuto::from_style(margin.block_end, containing_block_inline_size) MaybeAuto::from_style(margin.block_end, containing_block_inline_size)
.specified_or_zero(); .specified_or_zero(),
)
};
self.margin.block_start = block_start;
self.margin.block_end = block_end;
}, },
} }
} }
@ -1458,14 +1465,14 @@ impl Fragment {
pub fn relative_position(&self, containing_block_size: &LogicalSize<Au>) -> LogicalSize<Au> { pub fn relative_position(&self, containing_block_size: &LogicalSize<Au>) -> LogicalSize<Au> {
fn from_style(style: &ComputedValues, container_size: &LogicalSize<Au>) -> LogicalSize<Au> { fn from_style(style: &ComputedValues, container_size: &LogicalSize<Au>) -> LogicalSize<Au> {
let offsets = style.logical_position(); let offsets = style.logical_position();
let offset_i = if offsets.inline_start != LengthPercentageOrAuto::Auto { let offset_i = if !offsets.inline_start.is_auto() {
MaybeAuto::from_style(offsets.inline_start, container_size.inline) MaybeAuto::from_style(offsets.inline_start, container_size.inline)
.specified_or_zero() .specified_or_zero()
} else { } else {
-MaybeAuto::from_style(offsets.inline_end, container_size.inline) -MaybeAuto::from_style(offsets.inline_end, container_size.inline)
.specified_or_zero() .specified_or_zero()
}; };
let offset_b = if offsets.block_start != LengthPercentageOrAuto::Auto { let offset_b = if !offsets.block_start.is_auto() {
MaybeAuto::from_style(offsets.block_start, container_size.block).specified_or_zero() MaybeAuto::from_style(offsets.block_start, container_size.block).specified_or_zero()
} else { } else {
-MaybeAuto::from_style(offsets.block_end, container_size.block).specified_or_zero() -MaybeAuto::from_style(offsets.block_end, container_size.block).specified_or_zero()
@ -2520,14 +2527,10 @@ impl Fragment {
{ {
continue; continue;
} }
if inline_context_node.style.logical_margin().inline_end != if !inline_context_node.style.logical_margin().inline_end.is_definitely_zero() {
LengthPercentageOrAuto::zero()
{
return false; return false;
} }
if inline_context_node.style.logical_padding().inline_end != if !inline_context_node.style.logical_padding().inline_end.is_definitely_zero() {
LengthPercentage::zero()
{
return false; return false;
} }
if inline_context_node.style.logical_border_width().inline_end != Au(0) { if inline_context_node.style.logical_border_width().inline_end != Au(0) {
@ -2546,14 +2549,10 @@ impl Fragment {
{ {
continue; continue;
} }
if inline_context_node.style.logical_margin().inline_start != if !inline_context_node.style.logical_margin().inline_start.is_definitely_zero() {
LengthPercentageOrAuto::zero()
{
return false; return false;
} }
if inline_context_node.style.logical_padding().inline_start != if !inline_context_node.style.logical_padding().inline_start.is_definitely_zero() {
LengthPercentage::zero()
{
return false; return false;
} }
if inline_context_node if inline_context_node
@ -3193,7 +3192,7 @@ impl Fragment {
) -> Option<LayoutTransform> { ) -> Option<LayoutTransform> {
match self.style().get_box().perspective { match self.style().get_box().perspective {
Perspective::Length(length) => { Perspective::Length(length) => {
let perspective_origin = self.style().get_box().perspective_origin; let perspective_origin = &self.style().get_box().perspective_origin;
let perspective_origin = Point2D::new( let perspective_origin = Point2D::new(
perspective_origin perspective_origin
.horizontal .horizontal

View file

@ -1275,7 +1275,7 @@ impl InlineFlow {
&mut line_metrics, &mut line_metrics,
&inline_metrics, &inline_metrics,
style.get_box().display, style.get_box().display,
VerticalAlign::baseline(), &VerticalAlign::baseline(),
&mut largest_block_size_for_top_fragments, &mut largest_block_size_for_top_fragments,
&mut largest_block_size_for_bottom_fragments, &mut largest_block_size_for_bottom_fragments,
); );
@ -1296,7 +1296,7 @@ impl InlineFlow {
&mut line_metrics, &mut line_metrics,
&inline_metrics, &inline_metrics,
node.style.get_box().display, node.style.get_box().display,
node.style.get_box().vertical_align, &node.style.get_box().vertical_align,
&mut largest_block_size_for_top_fragments, &mut largest_block_size_for_top_fragments,
&mut largest_block_size_for_bottom_fragments, &mut largest_block_size_for_bottom_fragments,
); );
@ -1318,7 +1318,7 @@ impl InlineFlow {
line_metrics: &mut LineMetrics, line_metrics: &mut LineMetrics,
inline_metrics: &InlineMetrics, inline_metrics: &InlineMetrics,
display_value: Display, display_value: Display,
vertical_align_value: VerticalAlign, vertical_align_value: &VerticalAlign,
largest_block_size_for_top_fragments: &mut Au, largest_block_size_for_top_fragments: &mut Au,
largest_block_size_for_bottom_fragments: &mut Au, largest_block_size_for_bottom_fragments: &mut Au,
) { ) {

View file

@ -3,6 +3,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#![deny(unsafe_code)] #![deny(unsafe_code)]
#![feature(matches_macro)]
#[macro_use] #[macro_use]
extern crate bitflags; extern crate bitflags;

View file

@ -437,7 +437,7 @@ pub enum MaybeAuto {
impl MaybeAuto { impl MaybeAuto {
#[inline] #[inline]
pub fn from_style(length: LengthPercentageOrAuto, containing_length: Au) -> MaybeAuto { pub fn from_style(length: &LengthPercentageOrAuto, containing_length: Au) -> MaybeAuto {
match length { match length {
LengthPercentageOrAuto::Auto => MaybeAuto::Auto, LengthPercentageOrAuto::Auto => MaybeAuto::Auto,
LengthPercentageOrAuto::LengthPercentage(ref lp) => { LengthPercentageOrAuto::LengthPercentage(ref lp) => {
@ -498,7 +498,7 @@ impl MaybeAuto {
/// Receive an optional container size and return used value for width or height. /// Receive an optional container size and return used value for width or height.
/// ///
/// `style_length`: content size as given in the CSS. /// `style_length`: content size as given in the CSS.
pub fn style_length(style_length: Size, container_size: Option<Au>) -> MaybeAuto { pub fn style_length(style_length: &Size, container_size: Option<Au>) -> MaybeAuto {
match style_length { match style_length {
Size::Auto => MaybeAuto::Auto, Size::Auto => MaybeAuto::Auto,
Size::LengthPercentage(ref lp) => { Size::LengthPercentage(ref lp) => {
@ -546,10 +546,10 @@ pub fn specified_margin_from_style(
LogicalMargin::from_physical( LogicalMargin::from_physical(
writing_mode, writing_mode,
SideOffsets2D::new( SideOffsets2D::new(
MaybeAuto::from_style(margin_style.margin_top, Au(0)).specified_or_zero(), MaybeAuto::from_style(&margin_style.margin_top, Au(0)).specified_or_zero(),
MaybeAuto::from_style(margin_style.margin_right, Au(0)).specified_or_zero(), MaybeAuto::from_style(&margin_style.margin_right, Au(0)).specified_or_zero(),
MaybeAuto::from_style(margin_style.margin_bottom, Au(0)).specified_or_zero(), MaybeAuto::from_style(&margin_style.margin_bottom, Au(0)).specified_or_zero(),
MaybeAuto::from_style(margin_style.margin_left, Au(0)).specified_or_zero(), MaybeAuto::from_style(&margin_style.margin_left, Au(0)).specified_or_zero(),
), ),
) )
} }
@ -568,8 +568,8 @@ impl SizeConstraint {
/// Create a `SizeConstraint` for an axis. /// Create a `SizeConstraint` for an axis.
pub fn new( pub fn new(
container_size: Option<Au>, container_size: Option<Au>,
min_size: Size, min_size: &Size,
max_size: MaxSize, max_size: &MaxSize,
border: Option<Au>, border: Option<Au>,
) -> SizeConstraint { ) -> SizeConstraint {
let mut min_size = match min_size { let mut min_size = match min_size {

View file

@ -102,14 +102,14 @@ impl Flow for MulticolFlow {
let column_width; let column_width;
{ {
let style = &self.block_flow.fragment.style; let style = &self.block_flow.fragment.style;
let column_gap = match style.get_position().column_gap { let column_gap = Au::from(match style.get_position().column_gap {
NonNegativeLengthPercentageOrNormal::LengthPercentage(len) => { NonNegativeLengthPercentageOrNormal::LengthPercentage(ref len) => {
len.0.to_pixel_length(content_inline_size).into() len.0.to_pixel_length(content_inline_size)
}, },
NonNegativeLengthPercentageOrNormal::Normal => { NonNegativeLengthPercentageOrNormal::Normal => {
self.block_flow.fragment.style.get_font().font_size.size() self.block_flow.fragment.style.get_font().font_size.size()
}, },
}; });
let column_style = style.get_column(); let column_style = style.get_column();
let mut column_count; let mut column_count;

View file

@ -76,7 +76,7 @@ impl Flow for TableColGroupFlow {
// Retrieve the specified value from the appropriate CSS property. // Retrieve the specified value from the appropriate CSS property.
let inline_size = fragment.style().content_inline_size(); let inline_size = fragment.style().content_inline_size();
for _ in 0..fragment.column_span() { for _ in 0..fragment.column_span() {
self.inline_sizes.push(inline_size) self.inline_sizes.push(inline_size.clone())
} }
} }
} }

View file

@ -403,11 +403,6 @@ impl Flow for TableRowFlow {
let child_row_span; let child_row_span;
{ {
let child_table_cell = kid.as_mut_table_cell(); let child_table_cell = kid.as_mut_table_cell();
child_specified_inline_size = child_table_cell
.block_flow
.fragment
.style
.content_inline_size();
child_column_span = child_table_cell.column_span; child_column_span = child_table_cell.column_span;
child_row_span = child_table_cell.row_span; child_row_span = child_table_cell.row_span;
@ -422,6 +417,13 @@ impl Flow for TableRowFlow {
&mut self.preliminary_collapsed_borders, &mut self.preliminary_collapsed_borders,
) )
} }
child_specified_inline_size = child_table_cell
.block_flow
.fragment
.style
.content_inline_size()
.clone();
} }
// Collect minimum and preferred inline-sizes of the cell for automatic table layout // Collect minimum and preferred inline-sizes of the cell for automatic table layout

View file

@ -519,7 +519,7 @@ pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) ->
let font_size = style.get_font().font_size.size(); let font_size = style.get_font().font_size.size();
match style.get_inherited_text().line_height { match style.get_inherited_text().line_height {
LineHeight::Normal => Au::from(metrics.line_gap), LineHeight::Normal => Au::from(metrics.line_gap),
LineHeight::Number(l) => font_size.scale_by(l.0), LineHeight::Number(l) => Au::from(font_size * l.0),
LineHeight::Length(l) => Au::from(l), LineHeight::Length(l) => Au::from(l),
} }
} }

View file

@ -108,7 +108,6 @@ ${helpers.predefined_type(
"border-image-source", "border-image-source",
"ImageLayer", "ImageLayer",
engines="gecko servo-2013 servo-2020", engines="gecko servo-2013 servo-2020",
servo_2020_pref="layout.2020.unimplemented",
initial_value="computed::ImageLayer::none()", initial_value="computed::ImageLayer::none()",
initial_specified_value="specified::ImageLayer::none()", initial_specified_value="specified::ImageLayer::none()",
spec="https://drafts.csswg.org/css-backgrounds/#the-background-image", spec="https://drafts.csswg.org/css-backgrounds/#the-background-image",
@ -122,7 +121,6 @@ ${helpers.predefined_type(
"border-image-outset", "border-image-outset",
"NonNegativeLengthOrNumberRect", "NonNegativeLengthOrNumberRect",
engines="gecko servo-2013 servo-2020", engines="gecko servo-2013 servo-2020",
servo_2020_pref="layout.2020.unimplemented",
initial_value="generics::rect::Rect::all(computed::NonNegativeLengthOrNumber::zero())", initial_value="generics::rect::Rect::all(computed::NonNegativeLengthOrNumber::zero())",
initial_specified_value="generics::rect::Rect::all(specified::NonNegativeLengthOrNumber::zero())", initial_specified_value="generics::rect::Rect::all(specified::NonNegativeLengthOrNumber::zero())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset", spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset",
@ -135,7 +133,6 @@ ${helpers.predefined_type(
"BorderImageRepeat", "BorderImageRepeat",
"computed::BorderImageRepeat::stretch()", "computed::BorderImageRepeat::stretch()",
engines="gecko servo-2013 servo-2020", engines="gecko servo-2013 servo-2020",
servo_2020_pref="layout.2020.unimplemented",
initial_specified_value="specified::BorderImageRepeat::stretch()", initial_specified_value="specified::BorderImageRepeat::stretch()",
animation_value_type="discrete", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat", spec="https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat",
@ -145,7 +142,6 @@ ${helpers.predefined_type(
"border-image-width", "border-image-width",
"BorderImageWidth", "BorderImageWidth",
engines="gecko servo-2013 servo-2020", engines="gecko servo-2013 servo-2020",
servo_2020_pref="layout.2020.unimplemented",
initial_value="computed::BorderImageWidth::all(computed::BorderImageSideWidth::one())", initial_value="computed::BorderImageWidth::all(computed::BorderImageSideWidth::one())",
initial_specified_value="specified::BorderImageWidth::all(specified::BorderImageSideWidth::one())", initial_specified_value="specified::BorderImageWidth::all(specified::BorderImageSideWidth::one())",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-width", spec="https://drafts.csswg.org/css-backgrounds/#border-image-width",
@ -157,7 +153,6 @@ ${helpers.predefined_type(
"border-image-slice", "border-image-slice",
"BorderImageSlice", "BorderImageSlice",
engines="gecko servo-2013 servo-2020", engines="gecko servo-2013 servo-2020",
servo_2020_pref="layout.2020.unimplemented",
initial_value="computed::BorderImageSlice::hundred_percent()", initial_value="computed::BorderImageSlice::hundred_percent()",
initial_specified_value="specified::BorderImageSlice::hundred_percent()", initial_specified_value="specified::BorderImageSlice::hundred_percent()",
spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice", spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice",