Skip to content

Commit ef53845

Browse files
committed
Upgrade to rustc 1.18.0-nightly (5f13a3b54 2017-04-15)
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 test unit fail. Simly unboxing them moves the test failure to Stylo’s unit test, 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]: rust-lang/rust#40377
1 parent 7ae9c96 commit ef53845

File tree

10 files changed

+46
-49
lines changed

10 files changed

+46
-49
lines changed

components/style/properties/longhand/border.mako.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
3636
"none solid double dotted dashed hidden groove ridge inset outset"),
3737
type="::values::specified::BorderStyle")}
3838
% for side in ALL_SIDES:
39-
<%helpers:longhand name="border-${side[0]}-width" boxed="True" animation_type="normal" logical="${side[1]}"
39+
<%helpers:longhand name="border-${side[0]}-width" animation_type="normal" logical="${side[1]}"
4040
alias="${maybe_moz_logical_alias(product, side, '-moz-border-%s-width')}"
4141
spec="${maybe_logical_spec(side, 'width')}">
4242
use app_units::Au;

components/style/properties/longhand/box.mako.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1864,7 +1864,6 @@ ${helpers.predefined_type("perspective",
18641864
gecko_ffi_name="mChildPerspective",
18651865
spec="https://drafts.csswg.org/css-transforms/#perspective",
18661866
extra_prefixes="moz webkit",
1867-
boxed=True,
18681867
creates_stacking_context=True,
18691868
fixpos_cb=True,
18701869
animation_type="normal")}

components/style/properties/longhand/column.mako.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ ${helpers.predefined_type("column-width",
1313
initial_specified_value="Either::Second(Auto)",
1414
parse_method="parse_non_negative_length",
1515
extra_prefixes="moz",
16-
boxed=True,
1716
animation_type="none",
1817
experimental=True,
1918
spec="https://drafts.csswg.org/css-multicol/#propdef-column-width")}
@@ -36,7 +35,6 @@ ${helpers.predefined_type("column-gap",
3635
parse_method='parse_non_negative_length',
3736
extra_prefixes="moz",
3837
experimental=True,
39-
boxed=True,
4038
animation_type="none",
4139
spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap")}
4240

@@ -45,7 +43,7 @@ ${helpers.single_keyword("column-fill", "balance auto", extra_prefixes="moz",
4543
spec="https://drafts.csswg.org/css-multicol/#propdef-column-fill")}
4644

4745
// https://drafts.csswg.org/css-multicol-1/#propdef-column-rule-width
48-
<%helpers:longhand name="column-rule-width" products="gecko" boxed="True" animation_type="normal" extra_prefixes="moz"
46+
<%helpers:longhand name="column-rule-width" products="gecko" animation_type="normal" extra_prefixes="moz"
4947
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width">
5048
use app_units::Au;
5149
use std::fmt;

components/style/properties/longhand/inherited_text.mako.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ ${helpers.single_keyword("text-align-last",
406406
% endif
407407
</%helpers:longhand>
408408

409-
<%helpers:longhand name="letter-spacing" boxed="True" animation_type="normal"
409+
<%helpers:longhand name="letter-spacing" animation_type="normal"
410410
spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing">
411411
use std::fmt;
412412
use style_traits::ToCss;
@@ -1211,7 +1211,7 @@ ${helpers.predefined_type(
12111211
"-moz-tab-size", "LengthOrNumber",
12121212
"::values::Either::Second(8.0)",
12131213
"parse_non_negative",
1214-
products="gecko", boxed=True, animation_type="none",
1214+
products="gecko", animation_type="none",
12151215
spec="https://drafts.csswg.org/css-text-3/#tab-size-property")}
12161216

12171217

@@ -1232,7 +1232,7 @@ ${helpers.predefined_type(
12321232
complex_color=True, need_clone=True,
12331233
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")}
12341234

1235-
<%helpers:longhand products="gecko" name="-webkit-text-stroke-width" boxed="True" animation_type="none"
1235+
<%helpers:longhand products="gecko" name="-webkit-text-stroke-width" animation_type="none"
12361236
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width">
12371237
use app_units::Au;
12381238
use std::fmt;

components/style/values/computed/length.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl ToComputedValue for specified::Length {
4646
fn to_computed_value(&self, context: &Context) -> Au {
4747
match *self {
4848
specified::Length::NoCalc(l) => l.to_computed_value(context),
49-
specified::Length::Calc(ref calc, range) => range.clamp(calc.to_computed_value(context).length()),
49+
specified::Length::Calc(range, ref calc) => range.clamp(calc.to_computed_value(context).length()),
5050
}
5151
}
5252

components/style/values/specified/length.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ pub enum Length {
465465
/// A calc expression.
466466
///
467467
/// https://drafts.csswg.org/css-values/#calc-notation
468-
Calc(Box<CalcLengthOrPercentage>, AllowedLengthType),
468+
Calc(AllowedLengthType, Box<CalcLengthOrPercentage>),
469469
}
470470

471471
impl From<NoCalcLength> for Length {
@@ -479,7 +479,7 @@ impl HasViewportPercentage for Length {
479479
fn has_viewport_percentage(&self) -> bool {
480480
match *self {
481481
Length::NoCalc(ref inner) => inner.has_viewport_percentage(),
482-
Length::Calc(ref calc, _) => calc.has_viewport_percentage(),
482+
Length::Calc(_, ref calc) => calc.has_viewport_percentage(),
483483
}
484484
}
485485
}
@@ -488,7 +488,7 @@ impl ToCss for Length {
488488
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
489489
match *self {
490490
Length::NoCalc(ref inner) => inner.to_css(dest),
491-
Length::Calc(ref calc, _) => calc.to_css(dest),
491+
Length::Calc(_, ref calc) => calc.to_css(dest),
492492
}
493493
}
494494
}
@@ -850,7 +850,7 @@ impl CalcLengthOrPercentage {
850850
input: &mut Parser,
851851
num_context: AllowedLengthType) -> Result<Length, ()> {
852852
CalcLengthOrPercentage::parse(context, input, CalcUnit::Length).map(|calc| {
853-
Length::Calc(Box::new(calc), num_context)
853+
Length::Calc(num_context, Box::new(calc))
854854
})
855855
}
856856

@@ -1113,7 +1113,7 @@ impl From<Length> for LengthOrPercentage {
11131113
fn from(len: Length) -> LengthOrPercentage {
11141114
match len {
11151115
Length::NoCalc(l) => LengthOrPercentage::Length(l),
1116-
Length::Calc(l, _) => LengthOrPercentage::Calc(l),
1116+
Length::Calc(_, l) => LengthOrPercentage::Calc(l),
11171117
}
11181118
}
11191119
}

ports/geckolib/glue.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,10 +1439,10 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations:
14391439
let prop = match_wrap_declared! { long,
14401440
Height => nocalc.into(),
14411441
Width => nocalc.into(),
1442-
BorderTopWidth => Box::new(BorderWidth::Width(nocalc.into())),
1443-
BorderRightWidth => Box::new(BorderWidth::Width(nocalc.into())),
1444-
BorderBottomWidth => Box::new(BorderWidth::Width(nocalc.into())),
1445-
BorderLeftWidth => Box::new(BorderWidth::Width(nocalc.into())),
1442+
BorderTopWidth => BorderWidth::Width(nocalc.into()),
1443+
BorderRightWidth => BorderWidth::Width(nocalc.into()),
1444+
BorderBottomWidth => BorderWidth::Width(nocalc.into()),
1445+
BorderLeftWidth => BorderWidth::Width(nocalc.into()),
14461446
MarginTop => nocalc.into(),
14471447
MarginRight => nocalc.into(),
14481448
MarginBottom => nocalc.into(),

rust-commit-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
474f7a91eec8cba83b7eb7a578a7adb70614f877
1+
5f13a3b540ab6024665322d716e487c800645f24

tests/unit/style/properties/serialization.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,10 @@ mod shorthand_serialization {
225225
let px_30 = BorderWidth::from_length(Length::from_px(30f32));
226226
let px_10 = BorderWidth::from_length(Length::from_px(10f32));
227227

228-
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(px_30.clone())));
229-
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(px_30.clone())));
230-
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(px_30.clone())));
231-
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(px_10.clone())));
228+
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone()));
229+
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
230+
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone()));
231+
properties.push(PropertyDeclaration::BorderLeftWidth(px_10.clone()));
232232

233233
let blue = CSSColor {
234234
parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
@@ -258,10 +258,10 @@ mod shorthand_serialization {
258258

259259
let px_30 = BorderWidth::from_length(Length::from_px(30f32));
260260

261-
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(px_30.clone())));
262-
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(px_30.clone())));
263-
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(px_30.clone())));
264-
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(px_30.clone())));
261+
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone()));
262+
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
263+
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone()));
264+
properties.push(PropertyDeclaration::BorderLeftWidth(px_30.clone()));
265265

266266
let blue = CSSColor {
267267
parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
@@ -302,10 +302,10 @@ mod shorthand_serialization {
302302
let right_px = BorderWidth::from_length(Length::from_px(15f32));
303303
let left_px = BorderWidth::from_length(Length::from_px(15f32));
304304

305-
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(top_px)));
306-
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(right_px)));
307-
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(bottom_px)));
308-
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(left_px)));
305+
properties.push(PropertyDeclaration::BorderTopWidth(top_px));
306+
properties.push(PropertyDeclaration::BorderRightWidth(right_px));
307+
properties.push(PropertyDeclaration::BorderBottomWidth(bottom_px));
308+
properties.push(PropertyDeclaration::BorderLeftWidth(left_px));
309309

310310
let serialization = shorthand_properties_to_string(properties);
311311
assert_eq!(serialization, "border-width: 10px 15px;");
@@ -320,10 +320,10 @@ mod shorthand_serialization {
320320
let bottom_px = BorderWidth::Thick;
321321
let left_px = BorderWidth::from_length(Length::from_px(15f32));
322322

323-
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(top_px)));
324-
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(right_px)));
325-
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(bottom_px)));
326-
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(left_px)));
323+
properties.push(PropertyDeclaration::BorderTopWidth(top_px));
324+
properties.push(PropertyDeclaration::BorderRightWidth(right_px));
325+
properties.push(PropertyDeclaration::BorderBottomWidth(bottom_px));
326+
properties.push(PropertyDeclaration::BorderLeftWidth(left_px));
327327

328328
let serialization = shorthand_properties_to_string(properties);
329329
assert_eq!(serialization, "border-width: thin medium thick 15px;");
@@ -411,7 +411,7 @@ mod shorthand_serialization {
411411
authored: None
412412
};
413413

414-
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width)));
414+
properties.push(PropertyDeclaration::BorderTopWidth(width));
415415
properties.push(PropertyDeclaration::BorderTopStyle(style));
416416
properties.push(PropertyDeclaration::BorderTopColor(color));
417417

@@ -429,7 +429,7 @@ mod shorthand_serialization {
429429
fn border_top_should_serialize_correctly() {
430430
let mut properties = Vec::new();
431431
let (width, style, color) = get_border_property_values();
432-
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width)));
432+
properties.push(PropertyDeclaration::BorderTopWidth(width));
433433
properties.push(PropertyDeclaration::BorderTopStyle(style));
434434
properties.push(PropertyDeclaration::BorderTopColor(color));
435435

@@ -441,7 +441,7 @@ mod shorthand_serialization {
441441
fn border_right_should_serialize_correctly() {
442442
let mut properties = Vec::new();
443443
let (width, style, color) = get_border_property_values();
444-
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(width)));
444+
properties.push(PropertyDeclaration::BorderRightWidth(width));
445445
properties.push(PropertyDeclaration::BorderRightStyle(style));
446446
properties.push(PropertyDeclaration::BorderRightColor(color));
447447

@@ -453,7 +453,7 @@ mod shorthand_serialization {
453453
fn border_bottom_should_serialize_correctly() {
454454
let mut properties = Vec::new();
455455
let (width, style, color) = get_border_property_values();
456-
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(width)));
456+
properties.push(PropertyDeclaration::BorderBottomWidth(width));
457457
properties.push(PropertyDeclaration::BorderBottomStyle(style));
458458
properties.push(PropertyDeclaration::BorderBottomColor(color));
459459

@@ -465,7 +465,7 @@ mod shorthand_serialization {
465465
fn border_left_should_serialize_correctly() {
466466
let mut properties = Vec::new();
467467
let (width, style, color) = get_border_property_values();
468-
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(width)));
468+
properties.push(PropertyDeclaration::BorderLeftWidth(width));
469469
properties.push(PropertyDeclaration::BorderLeftStyle(style));
470470
properties.push(PropertyDeclaration::BorderLeftColor(color));
471471

@@ -478,19 +478,19 @@ mod shorthand_serialization {
478478
let mut properties = Vec::new();
479479
let (width, style, color) = get_border_property_values();
480480

481-
properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width.clone())));
481+
properties.push(PropertyDeclaration::BorderTopWidth(width.clone()));
482482
properties.push(PropertyDeclaration::BorderTopStyle(style.clone()));
483483
properties.push(PropertyDeclaration::BorderTopColor(color.clone()));
484484

485-
properties.push(PropertyDeclaration::BorderRightWidth(Box::new(width.clone())));
485+
properties.push(PropertyDeclaration::BorderRightWidth(width.clone()));
486486
properties.push(PropertyDeclaration::BorderRightStyle(style.clone()));
487487
properties.push(PropertyDeclaration::BorderRightColor(color.clone()));
488488

489-
properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(width.clone())));
489+
properties.push(PropertyDeclaration::BorderBottomWidth(width.clone()));
490490
properties.push(PropertyDeclaration::BorderBottomStyle(style.clone()));
491491
properties.push(PropertyDeclaration::BorderBottomColor(color.clone()));
492492

493-
properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(width.clone())));
493+
properties.push(PropertyDeclaration::BorderLeftWidth(width.clone()));
494494
properties.push(PropertyDeclaration::BorderLeftStyle(style.clone()));
495495
properties.push(PropertyDeclaration::BorderLeftColor(color.clone()));
496496

@@ -575,7 +575,7 @@ mod shorthand_serialization {
575575
let width = Either::Second(Auto);
576576
let count = Either::Second(Auto);
577577

578-
properties.push(PropertyDeclaration::ColumnWidth(Box::new(width)));
578+
properties.push(PropertyDeclaration::ColumnWidth(width));
579579
properties.push(PropertyDeclaration::ColumnCount(count));
580580

581581
let serialization = shorthand_properties_to_string(properties);

tests/unit/style/properties/viewport.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ use style::values::specified::{AbsoluteLength, Length, NoCalcLength, ViewportPer
1111
#[test]
1212
fn has_viewport_percentage_for_specified_value() {
1313
//TODO: test all specified value with a HasViewportPercentage impl
14-
let pvw = PropertyDeclaration::BorderTopWidth(Box::new(
14+
let pvw = PropertyDeclaration::BorderTopWidth(
1515
border_top_width::SpecifiedValue::from_length(
1616
Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.)))
1717
)
18-
));
18+
);
1919
assert!(pvw.has_viewport_percentage());
2020

21-
let pabs = PropertyDeclaration::BorderTopWidth(Box::new(
21+
let pabs = PropertyDeclaration::BorderTopWidth(
2222
border_top_width::SpecifiedValue::from_length(
2323
Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(Au(100).to_f32_px())))
2424
)
25-
));
25+
);
2626
assert!(!pabs.has_viewport_percentage());
2727
}

0 commit comments

Comments
 (0)