diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-12-15 22:12:10 +0100 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2019-12-16 14:23:56 +0100 |
commit | 7d30a7da750141bb0ca20b236271b41167ee225b (patch) | |
tree | 3b41496c0c91a2659123134f3d5e146bcbe3a773 | |
parent | c1c2b746c829a9d2266a181e35170300680e6636 (diff) | |
download | servo-7d30a7da750141bb0ca20b236271b41167ee225b.tar.gz servo-7d30a7da750141bb0ca20b236271b41167ee225b.zip |
Servo build fixes.
-rw-r--r-- | components/gfx/font.rs | 2 | ||||
-rw-r--r-- | components/gfx/font_context.rs | 2 | ||||
-rw-r--r-- | components/layout/block.rs | 22 | ||||
-rw-r--r-- | components/layout/display_list/background.rs | 4 | ||||
-rw-r--r-- | components/layout/display_list/border.rs | 20 | ||||
-rw-r--r-- | components/layout/display_list/builder.rs | 4 | ||||
-rw-r--r-- | components/layout/display_list/gradient.rs | 33 | ||||
-rw-r--r-- | components/layout/flex.rs | 18 | ||||
-rw-r--r-- | components/layout/flow.rs | 17 | ||||
-rw-r--r-- | components/layout/fragment.rs | 61 | ||||
-rw-r--r-- | components/layout/inline.rs | 6 | ||||
-rw-r--r-- | components/layout/lib.rs | 1 | ||||
-rw-r--r-- | components/layout/model.rs | 16 | ||||
-rw-r--r-- | components/layout/multicol.rs | 8 | ||||
-rw-r--r-- | components/layout/table_colgroup.rs | 2 | ||||
-rw-r--r-- | components/layout/table_row.rs | 12 | ||||
-rw-r--r-- | components/layout/text.rs | 2 | ||||
-rw-r--r-- | components/style/properties/longhands/border.mako.rs | 5 |
18 files changed, 118 insertions, 117 deletions
diff --git a/components/gfx/font.rs b/components/gfx/font.rs index 3dd5ac9f244..439784ba680 100644 --- a/components/gfx/font.rs +++ b/components/gfx/font.rs @@ -131,7 +131,7 @@ impl<'a> From<&'a FontStyleStruct> for FontDescriptor { FontDescriptor { template_descriptor: FontTemplateDescriptor::from(style), variant: style.font_variant_caps, - pt_size: style.font_size.size(), + pt_size: Au::from_f32_px(style.font_size.size().px()), } } } diff --git a/components/gfx/font_context.rs b/components/gfx/font_context.rs index 06755205935..113b384f84d 100644 --- a/components/gfx/font_context.rs +++ b/components/gfx/font_context.rs @@ -95,7 +95,7 @@ impl<S: FontSource> FontContext<S> { self.expire_font_caches_if_necessary(); let cache_key = FontGroupCacheKey { - size: style.font_size.size(), + size: Au::from_f32_px(style.font_size.size().px()), style, }; diff --git a/components/layout/block.rs b/components/layout/block.rs index 80c0fae2243..24413a31f4e 100644 --- a/components/layout/block.rs +++ b/components/layout/block.rs @@ -2029,7 +2029,7 @@ impl BlockFlow { // 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 // 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; } @@ -2548,8 +2548,8 @@ impl Flow for BlockFlow { .base .flags .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) && - self.fragment.style().logical_position().inline_start == LengthPercentageOrAuto::Auto && - self.fragment.style().logical_position().inline_end == LengthPercentageOrAuto::Auto + self.fragment.style().logical_position().inline_start.is_auto() && + self.fragment.style().logical_position().inline_end.is_auto() { self.base.position.start.i = inline_position } @@ -2560,8 +2560,8 @@ impl Flow for BlockFlow { .base .flags .contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) && - self.fragment.style().logical_position().block_start == LengthPercentageOrAuto::Auto && - self.fragment.style().logical_position().block_end == LengthPercentageOrAuto::Auto + self.fragment.style().logical_position().block_start.is_auto() && + self.fragment.style().logical_position().block_end.is_auto() { self.base.position.start.b = block_position } @@ -2848,16 +2848,18 @@ pub trait ISizeAndMarginsComputer { parent_flow_inline_size: Au, shared_context: &SharedStyleContext, ) -> MaybeAuto { + let inline_size = self.containing_block_inline_size( + block, + parent_flow_inline_size, + shared_context, + ); + MaybeAuto::from_option( block .fragment() .style() .content_inline_size() - .to_used_value(self.containing_block_inline_size( - block, - parent_flow_inline_size, - shared_context, - )), + .to_used_value(inline_size), ) } diff --git a/components/layout/display_list/background.rs b/components/layout/display_list/background.rs index 9d05cef9054..c08dcfe8598 100644 --- a/components/layout/display_list/background.rs +++ b/components/layout/display_list/background.rs @@ -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 /// image should be displayed on the background. fn compute_background_image_size( - bg_size: BackgroundSize, + bg_size: &BackgroundSize, bounds_size: Size2D<Au>, intrinsic_size: Option<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_y = get_cyclic(&bg.background_position_y.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( bg_clip, diff --git a/components/layout/display_list/border.rs b/components/layout/display_list/border.rs index 4970b2a34de..14ca2abe84f 100644 --- a/components/layout/display_list/border.rs +++ b/components/layout/display_list/border.rs @@ -25,7 +25,7 @@ use webrender_api::{BorderRadius, BorderSide, BorderStyle, ColorF, NormalBorder} /// /// [1]: https://drafts.csswg.org/css-backgrounds-3/#border-radius fn corner_radius( - radius: BorderCornerRadius, + radius: &BorderCornerRadius, containing_size: UntypedSize2D<Au>, ) -> UntypedSize2D<Au> { 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( abs_bounds.size.to_layout(), 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(), - 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(), - 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(), - 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(), }, ) @@ -161,7 +161,7 @@ pub fn image_outset( } fn side_image_width( - border_image_width: BorderImageSideWidth, + border_image_width: &BorderImageSideWidth, border_width: f32, total_length: Au, ) -> f32 { @@ -178,10 +178,10 @@ pub fn image_width( border_area: UntypedSize2D<Au>, ) -> LayoutSideOffsets { LayoutSideOffsets::new( - side_image_width(width.0, border.top, border_area.height), - side_image_width(width.1, border.right, border_area.width), - side_image_width(width.2, border.bottom, border_area.height), - side_image_width(width.3, border.left, border_area.width), + side_image_width(&width.0, border.top, border_area.height), + side_image_width(&width.1, border.right, border_area.width), + side_image_width(&width.2, border.bottom, border_area.height), + side_image_width(&width.3, border.left, border_area.width), ) } diff --git a/components/layout/display_list/builder.rs b/components/layout/display_list/builder.rs index 258c4f5490c..542ab95172a 100644 --- a/components/layout/display_list/builder.rs +++ b/components/layout/display_list/builder.rs @@ -995,7 +995,7 @@ impl Fragment { }; DisplayItem::Gradient(CommonDisplayItem::with_data(base, item, stops)) }, - GradientKind::Radial(shape, center) => { + GradientKind::Radial(ref shape, ref center) => { let (gradient, stops) = gradient::radial( style, placement.tile_size, @@ -1238,7 +1238,7 @@ impl Fragment { stops = linear_stops; NinePatchBorderSource::Gradient(wr_gradient) }, - GradientKind::Radial(shape, center) => { + GradientKind::Radial(ref shape, ref center) => { let (wr_gradient, radial_stops) = gradient::radial( style, border_image_area, diff --git a/components/layout/display_list/gradient.rs b/components/layout/display_list/gradient.rs index 3d7730e4fe6..454cd0be6db 100644 --- a/components/layout/display_list/gradient.rs +++ b/components/layout/display_list/gradient.rs @@ -91,9 +91,9 @@ fn convert_gradient_stops( color, position: None, }), - GradientItem::ComplexColorStop { color, position } => Some(ColorStop { + GradientItem::ComplexColorStop { color, ref position } => Some(ColorStop { color, - position: Some(position), + position: Some(position.clone()), }), _ => None, }) @@ -122,15 +122,18 @@ fn convert_gradient_stops( // Step 2: Move any stops placed before earlier stops to the // 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) { - if let Some(pos) = stop.position { - if position_to_offset(last_stop_position, total_length) > + if let Some(ref pos) = stop.position { + if position_to_offset(&last_stop_position, total_length) > position_to_offset(pos, total_length) { 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 // a stop run, which is always bounded by a length or percentage. 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 // a stop run, which is always bounded by a length or percentage. let (end_index, end_stop) = stop_items[(i + 1)..] @@ -153,7 +156,7 @@ fn convert_gradient_stops( .enumerate() .find(|&(_, ref stop)| stop.position.is_some()) .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 { start_offset, end_offset, @@ -168,7 +171,7 @@ fn convert_gradient_stops( stop_run_length * (i - stop_run.start_index) as f32 / ((2 + stop_run.stop_count) as f32) }, - Some(position) => { + Some(ref position) => { stop_run = None; position_to_offset(position, total_length) }, @@ -212,7 +215,7 @@ where 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) { return 0.0; } @@ -289,8 +292,8 @@ pub fn radial( style: &ComputedValues, size: Size2D<Au>, stops: &[GradientItem], - shape: EndingShape, - center: Position, + shape: &EndingShape, + center: &Position, repeating: bool, ) -> (RadialGradient, Vec<GradientStop>) { let center = Point2D::new( @@ -299,15 +302,15 @@ pub fn radial( ); let radius = match shape { EndingShape::Circle(Circle::Radius(length)) => { - let length = Au::from(length); + let length = Au::from(*length); Size2D::new(length, length) }, - EndingShape::Circle(Circle::Extent(extent)) => circle_size_keyword(extent, &size, ¢er), + EndingShape::Circle(Circle::Extent(extent)) => circle_size_keyword(*extent, &size, ¢er), EndingShape::Ellipse(Ellipse::Radii(x, y)) => { Size2D::new(x.to_used_value(size.width), y.to_used_value(size.height)) }, EndingShape::Ellipse(Ellipse::Extent(extent)) => { - ellipse_size_keyword(extent, &size, ¢er) + ellipse_size_keyword(*extent, &size, ¢er) }, }; diff --git a/components/layout/flex.rs b/components/layout/flex.rs index 8d2f7b98fe1..204e87f23fc 100644 --- a/components/layout/flex.rs +++ b/components/layout/flex.rs @@ -43,7 +43,7 @@ enum AxisSize { impl AxisSize { /// Generate a new available cross or main axis size from the specified size of the container, /// 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 { Size::Auto => AxisSize::MinMax(SizeConstraint::new(content_size, min, max, None)), 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 /// determining the flex base size and to indicate whether the main size of the item /// 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 { FlexBasis::Content => return MaybeAuto::Auto, - FlexBasis::Size(width) => width, + FlexBasis::Size(ref width) => width, }; let width = match width { @@ -135,7 +135,7 @@ impl FlexItem { // https://drafts.csswg.org/css-flexbox-1/#min-size-auto Direction::Inline => { 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(), containing_length, ); @@ -170,7 +170,7 @@ impl FlexItem { }, Direction::Block => { 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(), containing_length, ); @@ -452,7 +452,7 @@ impl FlexFlow { fn inline_mode_bubble_inline_sizes(&mut self) { // FIXME(emilio): This doesn't handle at all writing-modes. 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(); let mut computation = self.block_flow.fragment.compute_intrinsic_inline_sizes(); @@ -478,7 +478,7 @@ impl FlexFlow { // stripped out. fn block_mode_bubble_inline_sizes(&mut self) { 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(); 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 (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 { - (style.get_position().height, style.get_position().width) + (&style.get_position().height, &style.get_position().width) }; let available_inline_size = AxisSize::new( diff --git a/components/layout/flow.rs b/components/layout/flow.rs index 2d6e449766e..9ddfb274757 100644 --- a/components/layout/flow.rs +++ b/components/layout/flow.rs @@ -64,7 +64,6 @@ use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use style::properties::ComputedValues; use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage; -use style::values::computed::LengthPercentageOrAuto; use webrender_api::units::LayoutTransform; /// 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); let logical_position = style.logical_position(); - if logical_position.inline_start == LengthPercentageOrAuto::Auto && - logical_position.inline_end == LengthPercentageOrAuto::Auto + if logical_position.inline_start.is_auto() && + logical_position.inline_end.is_auto() { flags.insert(FlowFlags::INLINE_POSITION_IS_STATIC); } - if logical_position.block_start == LengthPercentageOrAuto::Auto && - logical_position.block_end == LengthPercentageOrAuto::Auto + if logical_position.block_start.is_auto() && + logical_position.block_end.is_auto() { flags.insert(FlowFlags::BLOCK_POSITION_IS_STATIC); } @@ -1113,13 +1112,13 @@ impl BaseFlow { let logical_position = style.logical_position(); self.flags.set( FlowFlags::INLINE_POSITION_IS_STATIC, - logical_position.inline_start == LengthPercentageOrAuto::Auto && - logical_position.inline_end == LengthPercentageOrAuto::Auto, + logical_position.inline_start.is_auto() && + logical_position.inline_end.is_auto() ); self.flags.set( FlowFlags::BLOCK_POSITION_IS_STATIC, - logical_position.block_start == LengthPercentageOrAuto::Auto && - logical_position.block_end == LengthPercentageOrAuto::Auto, + logical_position.block_start.is_auto() && + logical_position.block_end.is_auto() ); } } diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index f663dad744d..3eadf0a0ac8 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -61,10 +61,9 @@ use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage; use style::str::char_is_whitespace; 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::transform; -use style::Zero; use webrender_api; use webrender_api::units::LayoutTransform; @@ -1329,13 +1328,17 @@ impl Fragment { return; }, _ => { - let margin = self.style().logical_margin(); - self.margin.inline_start = - MaybeAuto::from_style(margin.inline_start, containing_block_inline_size) - .specified_or_zero(); - self.margin.inline_end = - MaybeAuto::from_style(margin.inline_end, containing_block_inline_size) - .specified_or_zero(); + let (inline_start, inline_end) = { + let margin = self.style().logical_margin(); + ( + MaybeAuto::from_style(margin.inline_start, containing_block_inline_size) + .specified_or_zero(), + MaybeAuto::from_style(margin.inline_end, containing_block_inline_size) + .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) // per CSS 2.1. - let margin = self.style().logical_margin(); - self.margin.block_start = - MaybeAuto::from_style(margin.block_start, containing_block_inline_size) - .specified_or_zero(); - self.margin.block_end = - MaybeAuto::from_style(margin.block_end, containing_block_inline_size) - .specified_or_zero(); + let (block_start, block_end) = { + let margin = self.style().logical_margin(); + ( + MaybeAuto::from_style(margin.block_start, containing_block_inline_size) + .specified_or_zero(), + MaybeAuto::from_style(margin.block_end, containing_block_inline_size) + .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> { fn from_style(style: &ComputedValues, container_size: &LogicalSize<Au>) -> LogicalSize<Au> { 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) .specified_or_zero() } else { -MaybeAuto::from_style(offsets.inline_end, container_size.inline) .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() } else { -MaybeAuto::from_style(offsets.block_end, container_size.block).specified_or_zero() @@ -2520,14 +2527,10 @@ impl Fragment { { continue; } - if inline_context_node.style.logical_margin().inline_end != - LengthPercentageOrAuto::zero() - { + if !inline_context_node.style.logical_margin().inline_end.is_definitely_zero() { return false; } - if inline_context_node.style.logical_padding().inline_end != - LengthPercentage::zero() - { + if !inline_context_node.style.logical_padding().inline_end.is_definitely_zero() { return false; } if inline_context_node.style.logical_border_width().inline_end != Au(0) { @@ -2546,14 +2549,10 @@ impl Fragment { { continue; } - if inline_context_node.style.logical_margin().inline_start != - LengthPercentageOrAuto::zero() - { + if !inline_context_node.style.logical_margin().inline_start.is_definitely_zero() { return false; } - if inline_context_node.style.logical_padding().inline_start != - LengthPercentage::zero() - { + if !inline_context_node.style.logical_padding().inline_start.is_definitely_zero() { return false; } if inline_context_node @@ -3193,7 +3192,7 @@ impl Fragment { ) -> Option<LayoutTransform> { match self.style().get_box().perspective { 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( perspective_origin .horizontal diff --git a/components/layout/inline.rs b/components/layout/inline.rs index 5ba82c1c95b..dfdb20e309b 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -1275,7 +1275,7 @@ impl InlineFlow { &mut line_metrics, &inline_metrics, style.get_box().display, - VerticalAlign::baseline(), + &VerticalAlign::baseline(), &mut largest_block_size_for_top_fragments, &mut largest_block_size_for_bottom_fragments, ); @@ -1296,7 +1296,7 @@ impl InlineFlow { &mut line_metrics, &inline_metrics, 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_bottom_fragments, ); @@ -1318,7 +1318,7 @@ impl InlineFlow { line_metrics: &mut LineMetrics, inline_metrics: &InlineMetrics, display_value: Display, - vertical_align_value: VerticalAlign, + vertical_align_value: &VerticalAlign, largest_block_size_for_top_fragments: &mut Au, largest_block_size_for_bottom_fragments: &mut Au, ) { diff --git a/components/layout/lib.rs b/components/layout/lib.rs index fdf3971fc3f..582a3e284d5 100644 --- a/components/layout/lib.rs +++ b/components/layout/lib.rs @@ -3,6 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] +#![feature(matches_macro)] #[macro_use] extern crate bitflags; diff --git a/components/layout/model.rs b/components/layout/model.rs index e6be75e45a4..08f916142e9 100644 --- a/components/layout/model.rs +++ b/components/layout/model.rs @@ -437,7 +437,7 @@ pub enum MaybeAuto { impl MaybeAuto { #[inline] - pub fn from_style(length: LengthPercentageOrAuto, containing_length: Au) -> MaybeAuto { + pub fn from_style(length: &LengthPercentageOrAuto, containing_length: Au) -> MaybeAuto { match length { LengthPercentageOrAuto::Auto => MaybeAuto::Auto, LengthPercentageOrAuto::LengthPercentage(ref lp) => { @@ -498,7 +498,7 @@ impl MaybeAuto { /// Receive an optional container size and return used value for width or height. /// /// `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 { Size::Auto => MaybeAuto::Auto, Size::LengthPercentage(ref lp) => { @@ -546,10 +546,10 @@ pub fn specified_margin_from_style( LogicalMargin::from_physical( writing_mode, SideOffsets2D::new( - 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_bottom, Au(0)).specified_or_zero(), - MaybeAuto::from_style(margin_style.margin_left, 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_bottom, 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. pub fn new( container_size: Option<Au>, - min_size: Size, - max_size: MaxSize, + min_size: &Size, + max_size: &MaxSize, border: Option<Au>, ) -> SizeConstraint { let mut min_size = match min_size { diff --git a/components/layout/multicol.rs b/components/layout/multicol.rs index 8890c08e189..4e1bfdf8d58 100644 --- a/components/layout/multicol.rs +++ b/components/layout/multicol.rs @@ -102,14 +102,14 @@ impl Flow for MulticolFlow { let column_width; { let style = &self.block_flow.fragment.style; - let column_gap = match style.get_position().column_gap { - NonNegativeLengthPercentageOrNormal::LengthPercentage(len) => { - len.0.to_pixel_length(content_inline_size).into() + let column_gap = Au::from(match style.get_position().column_gap { + NonNegativeLengthPercentageOrNormal::LengthPercentage(ref len) => { + len.0.to_pixel_length(content_inline_size) }, NonNegativeLengthPercentageOrNormal::Normal => { self.block_flow.fragment.style.get_font().font_size.size() }, - }; + }); let column_style = style.get_column(); let mut column_count; diff --git a/components/layout/table_colgroup.rs b/components/layout/table_colgroup.rs index b318dd95efd..ce097083f62 100644 --- a/components/layout/table_colgroup.rs +++ b/components/layout/table_colgroup.rs @@ -76,7 +76,7 @@ impl Flow for TableColGroupFlow { // Retrieve the specified value from the appropriate CSS property. let inline_size = fragment.style().content_inline_size(); for _ in 0..fragment.column_span() { - self.inline_sizes.push(inline_size) + self.inline_sizes.push(inline_size.clone()) } } } diff --git a/components/layout/table_row.rs b/components/layout/table_row.rs index ffaf720467b..58fb40bde3a 100644 --- a/components/layout/table_row.rs +++ b/components/layout/table_row.rs @@ -403,11 +403,6 @@ impl Flow for TableRowFlow { let child_row_span; { 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_row_span = child_table_cell.row_span; @@ -422,6 +417,13 @@ impl Flow for TableRowFlow { &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 diff --git a/components/layout/text.rs b/components/layout/text.rs index 199bd7e07f2..ef9515b0726 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -519,7 +519,7 @@ pub fn line_height_from_style(style: &ComputedValues, metrics: &FontMetrics) -> let font_size = style.get_font().font_size.size(); match style.get_inherited_text().line_height { 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), } } diff --git a/components/style/properties/longhands/border.mako.rs b/components/style/properties/longhands/border.mako.rs index 4d68c8bfc93..09cbea19a7f 100644 --- a/components/style/properties/longhands/border.mako.rs +++ b/components/style/properties/longhands/border.mako.rs @@ -108,7 +108,6 @@ ${helpers.predefined_type( "border-image-source", "ImageLayer", engines="gecko servo-2013 servo-2020", - servo_2020_pref="layout.2020.unimplemented", initial_value="computed::ImageLayer::none()", initial_specified_value="specified::ImageLayer::none()", spec="https://drafts.csswg.org/css-backgrounds/#the-background-image", @@ -122,7 +121,6 @@ ${helpers.predefined_type( "border-image-outset", "NonNegativeLengthOrNumberRect", engines="gecko servo-2013 servo-2020", - servo_2020_pref="layout.2020.unimplemented", initial_value="generics::rect::Rect::all(computed::NonNegativeLengthOrNumber::zero())", initial_specified_value="generics::rect::Rect::all(specified::NonNegativeLengthOrNumber::zero())", spec="https://drafts.csswg.org/css-backgrounds/#border-image-outset", @@ -135,7 +133,6 @@ ${helpers.predefined_type( "BorderImageRepeat", "computed::BorderImageRepeat::stretch()", engines="gecko servo-2013 servo-2020", - servo_2020_pref="layout.2020.unimplemented", initial_specified_value="specified::BorderImageRepeat::stretch()", animation_value_type="discrete", spec="https://drafts.csswg.org/css-backgrounds/#the-border-image-repeat", @@ -145,7 +142,6 @@ ${helpers.predefined_type( "border-image-width", "BorderImageWidth", engines="gecko servo-2013 servo-2020", - servo_2020_pref="layout.2020.unimplemented", initial_value="computed::BorderImageWidth::all(computed::BorderImageSideWidth::one())", initial_specified_value="specified::BorderImageWidth::all(specified::BorderImageSideWidth::one())", spec="https://drafts.csswg.org/css-backgrounds/#border-image-width", @@ -157,7 +153,6 @@ ${helpers.predefined_type( "border-image-slice", "BorderImageSlice", engines="gecko servo-2013 servo-2020", - servo_2020_pref="layout.2020.unimplemented", initial_value="computed::BorderImageSlice::hundred_percent()", initial_specified_value="specified::BorderImageSlice::hundred_percent()", spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice", |