Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: Sync changes from mozilla-central. #25299

Merged
merged 28 commits into from Dec 17, 2019
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
519a0e7
style: convert NS_STYLE_TOP_LAYER_* to an enum class in nsStyleConsts.h
jeffin143 Dec 1, 2019
5cc4394
style: convert NS_STYLE_RUBY_ALIGN_* to an enum class in nsStyleConsts.h
jeffin143 Dec 1, 2019
24f21f3
style: convert NS_STYLE_TEXT_SIZE_ADJUST_* to an enum class in nsStyl…
jeffin143 Dec 2, 2019
7e3e8e1
style: convert NS_STYLE_RUBY_POSITION_* to an enum class in nsStyleCo…
jeffin143 Dec 2, 2019
3bd62cf
style: Check for border-image-* initial specified values when seriali…
nordzilla Dec 3, 2019
51c1dfe
style: Add support for parsing of the CSS text-underline-position pro…
jfkthame Dec 4, 2019
5e7d429
style: Refactor InvalidationMap flags to use bitflags.
nordzilla Dec 5, 2019
f89c311
style: Remove layout.css.xul-box-display-values.survive-blockificatio…
emilio Dec 5, 2019
80ac4d2
style: Avoid writing into the empty array header.
emilio Dec 16, 2019
baa9ac1
style: Update derive_more.
emilio Dec 5, 2019
e944962
style: convert NS_STYLE_ISOLATION_* to an enum class in nsStyleConsts.h.
jeffin143 Dec 6, 2019
6973317
style: Correctly style dark scrollbars in tree components.
heycam Dec 9, 2019
7cd59da
style: Invalidate shadow part pseudo-class styles correctly.
emilio Dec 9, 2019
d954f51
style: Fix serialization of @namespace rule.
emilio Nov 25, 2019
e8a3a71
style: convert NS_STYLE_POINTER_EVENTS_* to an enum class in nsStyleC…
jeffin143 Dec 12, 2019
02c30bc
style: Preserve CSS input exactly during sanitization.
emilio Dec 12, 2019
4b62e9f
style: convert NS_STYLE_VISIBILITY_* to an enum class in nsStyleConsts.h
jeffin143 Dec 13, 2019
4cd8813
style: Remove full-screen-api.unprefix.enabled.
emilio Dec 13, 2019
a541046
style: Use less Au in font code.
emilio Dec 15, 2019
789ddd9
style: Make LengthPercentage not copy.
emilio Dec 15, 2019
ad61cae
style: Update smallvec to 1.0.
emilio Dec 15, 2019
c1c2b74
Update Cargo.lock.
emilio Dec 15, 2019
7d30a7d
Servo build fixes.
emilio Dec 15, 2019
e885ccb
layout-2020: build fixes.
emilio Dec 15, 2019
ef16c58
Rustfmt recent changes.
emilio Dec 15, 2019
75a05f0
Appease tidy.
emilio Dec 15, 2019
f7c5df5
Update WPT expectations.
emilio Dec 16, 2019
7513bc2
Cherry-pick some parts of the cssparser update.
emilio Dec 16, 2019
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Servo build fixes.

  • Loading branch information
emilio committed Dec 16, 2019
commit 7d30a7da750141bb0ca20b236271b41167ee225b
@@ -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()),
}
}
}
@@ -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,
};

@@ -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),
)
}

@@ -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,
@@ -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),
)
}

@@ -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,
@@ -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,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,
@@ -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, &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)
},
};

@@ -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(
@@ -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()
);
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.