Skip to content

Commit

Permalink
Servo build fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Dec 16, 2019
1 parent c1c2b74 commit 7d30a7d
Show file tree
Hide file tree
Showing 18 changed files with 118 additions and 117 deletions.
2 changes: 1 addition & 1 deletion components/gfx/font.rs
Expand Up @@ -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()),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion components/gfx/font_context.rs
Expand Up @@ -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,
};

Expand Down
22 changes: 12 additions & 10 deletions components/layout/block.rs
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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),
)
}

Expand Down
4 changes: 2 additions & 2 deletions components/layout/display_list/background.rs
Expand Up @@ -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> {
Expand Down Expand Up @@ -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,
Expand Down
20 changes: 10 additions & 10 deletions components/layout/display_list/border.rs
Expand Up @@ -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);
Expand Down Expand Up @@ -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(),
},
)
Expand Down Expand Up @@ -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 {
Expand All @@ -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),
)
}

Expand Down
4 changes: 2 additions & 2 deletions components/layout/display_list/builder.rs
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
33 changes: 18 additions & 15 deletions components/layout/display_list/gradient.rs
Expand Up @@ -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,
})
Expand Down Expand Up @@ -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();
}
}

Expand All @@ -145,15 +148,15 @@ 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)..]
.iter()
.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,
Expand All @@ -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)
},
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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(
Expand All @@ -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, &center),
EndingShape::Circle(Circle::Extent(extent)) => circle_size_keyword(*extent, &size, &center),
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, &center)
ellipse_size_keyword(*extent, &size, &center)
},
};

Expand Down
18 changes: 9 additions & 9 deletions components/layout/flex.rs
Expand Up @@ -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) {
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -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,
);
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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(
Expand Down
17 changes: 8 additions & 9 deletions components/layout/flow.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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()
);
}
}
Expand Down

0 comments on commit 7d30a7d

Please sign in to comment.