From 5caa5d7ba2e3a5e2c53da0f0105b34ff5172bcab Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Tue, 1 Oct 2019 02:49:18 +0000 Subject: [PATCH] servo: Merge #16473 - Upgrade to rustc 1.18.0-nightly (5f13a3b54 2017-04-15) (from servo:rustup); r=emilio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This version enables [struct field reordering][1] which brings the size of the types for specified values of some CSS properties under the threshold such that they shouldn’t be boxed anymore, making unit tests fail. Simply unboxing them moves the test failure to Stylo’s unit tests, since the stable compiler used in that case does not do field re-ordering. Therefore, we manually reorder a couple fields to effectively bring this optimization to older compilers for a few specific types. [1]: https://github.com/rust-lang/rust/pull/40377 Source-Repo: https://github.com/servo/servo Source-Revision: c453e2ef89b32798dabbb23b22cfd5a72dddf6a5 UltraBlame original commit: 55519369af2b2a65f2a5c2275522a8b1dc014953 --- servo/components/script/dom/element.rs | 8 +-- .../style/properties/longhand/border.mako.rs | 2 +- .../style/properties/longhand/box.mako.rs | 1 - .../style/properties/longhand/column.mako.rs | 4 +- .../longhand/inherited_text.mako.rs | 6 +-- .../style/values/computed/length.rs | 2 +- .../style/values/specified/length.rs | 10 ++-- servo/ports/geckolib/glue.rs | 8 +-- servo/rust-commit-hash | 2 +- .../unit/style/properties/serialization.rs | 52 +++++++++---------- servo/tests/unit/style/properties/viewport.rs | 8 +-- 11 files changed, 50 insertions(+), 53 deletions(-) diff --git a/servo/components/script/dom/element.rs b/servo/components/script/dom/element.rs index 4adefe1dbb5f0..a6dd4f836f506 100644 --- a/servo/components/script/dom/element.rs +++ b/servo/components/script/dom/element.rs @@ -649,16 +649,16 @@ impl LayoutElementHelpers for LayoutJS { let width_value = specified::BorderWidth::from_length(specified::Length::from_px(border as f32)); hints.push(from_declaration( shared_lock, - PropertyDeclaration::BorderTopWidth(Box::new(width_value.clone())))); + PropertyDeclaration::BorderTopWidth(width_value.clone()))); hints.push(from_declaration( shared_lock, - PropertyDeclaration::BorderLeftWidth(Box::new(width_value.clone())))); + PropertyDeclaration::BorderLeftWidth(width_value.clone()))); hints.push(from_declaration( shared_lock, - PropertyDeclaration::BorderBottomWidth(Box::new(width_value.clone())))); + PropertyDeclaration::BorderBottomWidth(width_value.clone()))); hints.push(from_declaration( shared_lock, - PropertyDeclaration::BorderRightWidth(Box::new(width_value)))); + PropertyDeclaration::BorderRightWidth(width_value))); } } diff --git a/servo/components/style/properties/longhand/border.mako.rs b/servo/components/style/properties/longhand/border.mako.rs index 4e7a0b0b72f22..f19a9350c7eb3 100644 --- a/servo/components/style/properties/longhand/border.mako.rs +++ b/servo/components/style/properties/longhand/border.mako.rs @@ -36,7 +36,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style', "none solid double dotted dashed hidden groove ridge inset outset"), type="::values::specified::BorderStyle")} % for side in ALL_SIDES: - <%helpers:longhand name="border-${side[0]}-width" boxed="True" animation_type="normal" logical="${side[1]}" + <%helpers:longhand name="border-${side[0]}-width" animation_type="normal" logical="${side[1]}" alias="${maybe_moz_logical_alias(product, side, '-moz-border-%s-width')}" spec="${maybe_logical_spec(side, 'width')}"> use app_units::Au; diff --git a/servo/components/style/properties/longhand/box.mako.rs b/servo/components/style/properties/longhand/box.mako.rs index ec081b0588050..bac7a291e407e 100644 --- a/servo/components/style/properties/longhand/box.mako.rs +++ b/servo/components/style/properties/longhand/box.mako.rs @@ -1864,7 +1864,6 @@ ${helpers.predefined_type("perspective", gecko_ffi_name="mChildPerspective", spec="https://drafts.csswg.org/css-transforms/#perspective", extra_prefixes="moz webkit", - boxed=True, creates_stacking_context=True, fixpos_cb=True, animation_type="normal")} diff --git a/servo/components/style/properties/longhand/column.mako.rs b/servo/components/style/properties/longhand/column.mako.rs index a0c965a349d4a..314a270820225 100644 --- a/servo/components/style/properties/longhand/column.mako.rs +++ b/servo/components/style/properties/longhand/column.mako.rs @@ -13,7 +13,6 @@ ${helpers.predefined_type("column-width", initial_specified_value="Either::Second(Auto)", parse_method="parse_non_negative_length", extra_prefixes="moz", - boxed=True, animation_type="none", experimental=True, spec="https://drafts.csswg.org/css-multicol/#propdef-column-width")} @@ -36,7 +35,6 @@ ${helpers.predefined_type("column-gap", parse_method='parse_non_negative_length', extra_prefixes="moz", experimental=True, - boxed=True, animation_type="none", spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap")} @@ -45,7 +43,7 @@ ${helpers.single_keyword("column-fill", "balance auto", extra_prefixes="moz", spec="https://drafts.csswg.org/css-multicol/#propdef-column-fill")} // https://drafts.csswg.org/css-multicol-1/#propdef-column-rule-width -<%helpers:longhand name="column-rule-width" products="gecko" boxed="True" animation_type="normal" extra_prefixes="moz" +<%helpers:longhand name="column-rule-width" products="gecko" animation_type="normal" extra_prefixes="moz" spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width"> use app_units::Au; use std::fmt; diff --git a/servo/components/style/properties/longhand/inherited_text.mako.rs b/servo/components/style/properties/longhand/inherited_text.mako.rs index e6faab8d98ea2..ea324ca7546a0 100644 --- a/servo/components/style/properties/longhand/inherited_text.mako.rs +++ b/servo/components/style/properties/longhand/inherited_text.mako.rs @@ -406,7 +406,7 @@ ${helpers.single_keyword("text-align-last", % endif -<%helpers:longhand name="letter-spacing" boxed="True" animation_type="normal" +<%helpers:longhand name="letter-spacing" animation_type="normal" spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing"> use std::fmt; use style_traits::ToCss; @@ -1211,7 +1211,7 @@ ${helpers.predefined_type( "-moz-tab-size", "LengthOrNumber", "::values::Either::Second(8.0)", "parse_non_negative", - products="gecko", boxed=True, animation_type="none", + products="gecko", animation_type="none", spec="https://drafts.csswg.org/css-text-3/#tab-size-property")} @@ -1232,7 +1232,7 @@ ${helpers.predefined_type( complex_color=True, need_clone=True, spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")} -<%helpers:longhand products="gecko" name="-webkit-text-stroke-width" boxed="True" animation_type="none" +<%helpers:longhand products="gecko" name="-webkit-text-stroke-width" animation_type="none" spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width"> use app_units::Au; use std::fmt; diff --git a/servo/components/style/values/computed/length.rs b/servo/components/style/values/computed/length.rs index 24e709ace38f6..388ad949ed177 100644 --- a/servo/components/style/values/computed/length.rs +++ b/servo/components/style/values/computed/length.rs @@ -46,7 +46,7 @@ impl ToComputedValue for specified::Length { fn to_computed_value(&self, context: &Context) -> Au { match *self { specified::Length::NoCalc(l) => l.to_computed_value(context), - specified::Length::Calc(ref calc, range) => range.clamp(calc.to_computed_value(context).length()), + specified::Length::Calc(range, ref calc) => range.clamp(calc.to_computed_value(context).length()), } } diff --git a/servo/components/style/values/specified/length.rs b/servo/components/style/values/specified/length.rs index d4d052941297c..5390193e53b81 100644 --- a/servo/components/style/values/specified/length.rs +++ b/servo/components/style/values/specified/length.rs @@ -465,7 +465,7 @@ pub enum Length { - Calc(Box, AllowedLengthType), + Calc(AllowedLengthType, Box), } impl From for Length { @@ -479,7 +479,7 @@ impl HasViewportPercentage for Length { fn has_viewport_percentage(&self) -> bool { match *self { Length::NoCalc(ref inner) => inner.has_viewport_percentage(), - Length::Calc(ref calc, _) => calc.has_viewport_percentage(), + Length::Calc(_, ref calc) => calc.has_viewport_percentage(), } } } @@ -488,7 +488,7 @@ impl ToCss for Length { fn to_css(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { match *self { Length::NoCalc(ref inner) => inner.to_css(dest), - Length::Calc(ref calc, _) => calc.to_css(dest), + Length::Calc(_, ref calc) => calc.to_css(dest), } } } @@ -828,7 +828,7 @@ impl CalcLengthOrPercentage { input: &mut Parser, num_context: AllowedLengthType) -> Result { CalcLengthOrPercentage::parse(context, input, CalcUnit::Length).map(|calc| { - Length::Calc(Box::new(calc), num_context) + Length::Calc(num_context, Box::new(calc)) }) } @@ -1091,7 +1091,7 @@ impl From for LengthOrPercentage { fn from(len: Length) -> LengthOrPercentage { match len { Length::NoCalc(l) => LengthOrPercentage::Length(l), - Length::Calc(l, _) => LengthOrPercentage::Calc(l), + Length::Calc(_, l) => LengthOrPercentage::Calc(l), } } } diff --git a/servo/ports/geckolib/glue.rs b/servo/ports/geckolib/glue.rs index 2e839bfc55731..ea94dabcc89a1 100644 --- a/servo/ports/geckolib/glue.rs +++ b/servo/ports/geckolib/glue.rs @@ -1444,10 +1444,10 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations: let prop = match_wrap_declared! { long, Height => nocalc.into(), Width => nocalc.into(), - BorderTopWidth => Box::new(BorderWidth::Width(nocalc.into())), - BorderRightWidth => Box::new(BorderWidth::Width(nocalc.into())), - BorderBottomWidth => Box::new(BorderWidth::Width(nocalc.into())), - BorderLeftWidth => Box::new(BorderWidth::Width(nocalc.into())), + BorderTopWidth => BorderWidth::Width(nocalc.into()), + BorderRightWidth => BorderWidth::Width(nocalc.into()), + BorderBottomWidth => BorderWidth::Width(nocalc.into()), + BorderLeftWidth => BorderWidth::Width(nocalc.into()), MarginTop => nocalc.into(), MarginRight => nocalc.into(), MarginBottom => nocalc.into(), diff --git a/servo/rust-commit-hash b/servo/rust-commit-hash index c7e14fa626887..978afb0be45f8 100644 --- a/servo/rust-commit-hash +++ b/servo/rust-commit-hash @@ -1 +1 @@ -474f7a91eec8cba83b7eb7a578a7adb70614f877 +5f13a3b540ab6024665322d716e487c800645f24 diff --git a/servo/tests/unit/style/properties/serialization.rs b/servo/tests/unit/style/properties/serialization.rs index b6f56d78c3933..a86316c95944f 100644 --- a/servo/tests/unit/style/properties/serialization.rs +++ b/servo/tests/unit/style/properties/serialization.rs @@ -225,10 +225,10 @@ mod shorthand_serialization { let px_30 = BorderWidth::from_length(Length::from_px(30f32)); let px_10 = BorderWidth::from_length(Length::from_px(10f32)); - properties.push(PropertyDeclaration::BorderTopWidth(Box::new(px_30.clone()))); - properties.push(PropertyDeclaration::BorderRightWidth(Box::new(px_30.clone()))); - properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(px_30.clone()))); - properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(px_10.clone()))); + properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone())); + properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone())); + properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone())); + properties.push(PropertyDeclaration::BorderLeftWidth(px_10.clone())); let blue = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)), @@ -258,10 +258,10 @@ mod shorthand_serialization { let px_30 = BorderWidth::from_length(Length::from_px(30f32)); - properties.push(PropertyDeclaration::BorderTopWidth(Box::new(px_30.clone()))); - properties.push(PropertyDeclaration::BorderRightWidth(Box::new(px_30.clone()))); - properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(px_30.clone()))); - properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(px_30.clone()))); + properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone())); + properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone())); + properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone())); + properties.push(PropertyDeclaration::BorderLeftWidth(px_30.clone())); let blue = CSSColor { parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)), @@ -302,10 +302,10 @@ mod shorthand_serialization { let right_px = BorderWidth::from_length(Length::from_px(15f32)); let left_px = BorderWidth::from_length(Length::from_px(15f32)); - properties.push(PropertyDeclaration::BorderTopWidth(Box::new(top_px))); - properties.push(PropertyDeclaration::BorderRightWidth(Box::new(right_px))); - properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(bottom_px))); - properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(left_px))); + properties.push(PropertyDeclaration::BorderTopWidth(top_px)); + properties.push(PropertyDeclaration::BorderRightWidth(right_px)); + properties.push(PropertyDeclaration::BorderBottomWidth(bottom_px)); + properties.push(PropertyDeclaration::BorderLeftWidth(left_px)); let serialization = shorthand_properties_to_string(properties); assert_eq!(serialization, "border-width: 10px 15px;"); @@ -320,10 +320,10 @@ mod shorthand_serialization { let bottom_px = BorderWidth::Thick; let left_px = BorderWidth::from_length(Length::from_px(15f32)); - properties.push(PropertyDeclaration::BorderTopWidth(Box::new(top_px))); - properties.push(PropertyDeclaration::BorderRightWidth(Box::new(right_px))); - properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(bottom_px))); - properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(left_px))); + properties.push(PropertyDeclaration::BorderTopWidth(top_px)); + properties.push(PropertyDeclaration::BorderRightWidth(right_px)); + properties.push(PropertyDeclaration::BorderBottomWidth(bottom_px)); + properties.push(PropertyDeclaration::BorderLeftWidth(left_px)); let serialization = shorthand_properties_to_string(properties); assert_eq!(serialization, "border-width: thin medium thick 15px;"); @@ -411,7 +411,7 @@ mod shorthand_serialization { authored: None }; - properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width))); + properties.push(PropertyDeclaration::BorderTopWidth(width)); properties.push(PropertyDeclaration::BorderTopStyle(style)); properties.push(PropertyDeclaration::BorderTopColor(color)); @@ -429,7 +429,7 @@ mod shorthand_serialization { fn border_top_should_serialize_correctly() { let mut properties = Vec::new(); let (width, style, color) = get_border_property_values(); - properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width))); + properties.push(PropertyDeclaration::BorderTopWidth(width)); properties.push(PropertyDeclaration::BorderTopStyle(style)); properties.push(PropertyDeclaration::BorderTopColor(color)); @@ -441,7 +441,7 @@ mod shorthand_serialization { fn border_right_should_serialize_correctly() { let mut properties = Vec::new(); let (width, style, color) = get_border_property_values(); - properties.push(PropertyDeclaration::BorderRightWidth(Box::new(width))); + properties.push(PropertyDeclaration::BorderRightWidth(width)); properties.push(PropertyDeclaration::BorderRightStyle(style)); properties.push(PropertyDeclaration::BorderRightColor(color)); @@ -453,7 +453,7 @@ mod shorthand_serialization { fn border_bottom_should_serialize_correctly() { let mut properties = Vec::new(); let (width, style, color) = get_border_property_values(); - properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(width))); + properties.push(PropertyDeclaration::BorderBottomWidth(width)); properties.push(PropertyDeclaration::BorderBottomStyle(style)); properties.push(PropertyDeclaration::BorderBottomColor(color)); @@ -465,7 +465,7 @@ mod shorthand_serialization { fn border_left_should_serialize_correctly() { let mut properties = Vec::new(); let (width, style, color) = get_border_property_values(); - properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(width))); + properties.push(PropertyDeclaration::BorderLeftWidth(width)); properties.push(PropertyDeclaration::BorderLeftStyle(style)); properties.push(PropertyDeclaration::BorderLeftColor(color)); @@ -478,19 +478,19 @@ mod shorthand_serialization { let mut properties = Vec::new(); let (width, style, color) = get_border_property_values(); - properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width.clone()))); + properties.push(PropertyDeclaration::BorderTopWidth(width.clone())); properties.push(PropertyDeclaration::BorderTopStyle(style.clone())); properties.push(PropertyDeclaration::BorderTopColor(color.clone())); - properties.push(PropertyDeclaration::BorderRightWidth(Box::new(width.clone()))); + properties.push(PropertyDeclaration::BorderRightWidth(width.clone())); properties.push(PropertyDeclaration::BorderRightStyle(style.clone())); properties.push(PropertyDeclaration::BorderRightColor(color.clone())); - properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(width.clone()))); + properties.push(PropertyDeclaration::BorderBottomWidth(width.clone())); properties.push(PropertyDeclaration::BorderBottomStyle(style.clone())); properties.push(PropertyDeclaration::BorderBottomColor(color.clone())); - properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(width.clone()))); + properties.push(PropertyDeclaration::BorderLeftWidth(width.clone())); properties.push(PropertyDeclaration::BorderLeftStyle(style.clone())); properties.push(PropertyDeclaration::BorderLeftColor(color.clone())); @@ -575,7 +575,7 @@ mod shorthand_serialization { let width = Either::Second(Auto); let count = Either::Second(Auto); - properties.push(PropertyDeclaration::ColumnWidth(Box::new(width))); + properties.push(PropertyDeclaration::ColumnWidth(width)); properties.push(PropertyDeclaration::ColumnCount(count)); let serialization = shorthand_properties_to_string(properties); diff --git a/servo/tests/unit/style/properties/viewport.rs b/servo/tests/unit/style/properties/viewport.rs index c856d67e4358f..e63e9b8c80899 100644 --- a/servo/tests/unit/style/properties/viewport.rs +++ b/servo/tests/unit/style/properties/viewport.rs @@ -11,17 +11,17 @@ use style::values::specified::{AbsoluteLength, Length, NoCalcLength, ViewportPer #[test] fn has_viewport_percentage_for_specified_value() { - let pvw = PropertyDeclaration::BorderTopWidth(Box::new( + let pvw = PropertyDeclaration::BorderTopWidth( border_top_width::SpecifiedValue::from_length( Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.))) ) - )); + ); assert!(pvw.has_viewport_percentage()); - let pabs = PropertyDeclaration::BorderTopWidth(Box::new( + let pabs = PropertyDeclaration::BorderTopWidth( border_top_width::SpecifiedValue::from_length( Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(Au(100).to_f32_px()))) ) - )); + ); assert!(!pabs.has_viewport_percentage()); }