servo: Merge #16015 - Box more specified values to bring SpecifiedValue/PropertyDeclaration sizes down to 24/32 bytes (from bholley:box_more_properties); r=Manishearth

I think these properties are generally rare enough that they're not worth adding 8 bytes of memmove overhead on every PropertyDeclaration. There are a _lot_ of 24-byte properties though, so I think that's probably a good sustainable level.

Source-Repo: https://github.com/servo/servo
Source-Revision: ae1a7cc7b8079491c2140d694467113dcc1f44a6

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : a3eaac5f9529174d13151a1cc1f52d5015f81560
This commit is contained in:
Bobby Holley 2017-03-17 22:19:51 -07:00
Родитель 06caf786e0
Коммит 4d61095fe0
12 изменённых файлов: 58 добавлений и 50 удалений

Просмотреть файл

@ -623,13 +623,13 @@ impl LayoutElementHelpers for LayoutJS<Element> {
if let Some(border) = border { if let Some(border) = border {
let width_value = specified::BorderWidth::from_length(specified::Length::from_px(border as f32)); let width_value = specified::BorderWidth::from_length(specified::Length::from_px(border as f32));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderTopWidth(width_value.clone()))); PropertyDeclaration::BorderTopWidth(Box::new(width_value.clone()))));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderLeftWidth(width_value.clone()))); PropertyDeclaration::BorderLeftWidth(Box::new(width_value.clone()))));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderBottomWidth(width_value.clone()))); PropertyDeclaration::BorderBottomWidth(Box::new(width_value.clone()))));
hints.push(from_declaration( hints.push(from_declaration(
PropertyDeclaration::BorderRightWidth(width_value))); PropertyDeclaration::BorderRightWidth(Box::new(width_value))));
} }
} }

Просмотреть файл

@ -36,7 +36,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
"none solid double dotted dashed hidden groove ridge inset outset"), "none solid double dotted dashed hidden groove ridge inset outset"),
type="::values::specified::BorderStyle")} type="::values::specified::BorderStyle")}
% for side in ALL_SIDES: % for side in ALL_SIDES:
<%helpers:longhand name="border-${side[0]}-width" animatable="True" logical="${side[1]}" <%helpers:longhand name="border-${side[0]}-width" boxed="True" animatable="True" logical="${side[1]}"
alias="${maybe_moz_logical_alias(product, side, '-moz-border-%s-width')}" alias="${maybe_moz_logical_alias(product, side, '-moz-border-%s-width')}"
spec="${maybe_logical_spec(side, 'width')}"> spec="${maybe_logical_spec(side, 'width')}">
use app_units::Au; use app_units::Au;
@ -69,6 +69,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
"computed::BorderRadiusSize::zero()", "computed::BorderRadiusSize::zero()",
"parse", extra_prefixes="webkit", "parse", extra_prefixes="webkit",
spec="https://drafts.csswg.org/css-backgrounds/#border-%s-radius" % corner, spec="https://drafts.csswg.org/css-backgrounds/#border-%s-radius" % corner,
boxed=True,
animatable=True)} animatable=True)}
% endfor % endfor
@ -556,7 +557,7 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box",
} }
</%helpers:longhand> </%helpers:longhand>
<%helpers:longhand name="border-image-slice" animatable="False" <%helpers:longhand name="border-image-slice" boxed="True" animatable="False"
spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice"> spec="https://drafts.csswg.org/css-backgrounds/#border-image-slice">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;

Просмотреть файл

@ -1709,10 +1709,11 @@ ${helpers.predefined_type("perspective",
gecko_ffi_name="mChildPerspective", gecko_ffi_name="mChildPerspective",
spec="https://drafts.csswg.org/css-transforms/#perspective", spec="https://drafts.csswg.org/css-transforms/#perspective",
extra_prefixes="moz webkit", extra_prefixes="moz webkit",
boxed=True,
animatable=True)} animatable=True)}
// FIXME: This prop should be animatable // FIXME: This prop should be animatable
<%helpers:longhand name="perspective-origin" animatable="False" extra_prefixes="moz webkit" <%helpers:longhand name="perspective-origin" boxed="True" animatable="False" extra_prefixes="moz webkit"
spec="https://drafts.csswg.org/css-transforms/#perspective-origin-property"> spec="https://drafts.csswg.org/css-transforms/#perspective-origin-property">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;

Просмотреть файл

@ -13,6 +13,7 @@ ${helpers.predefined_type("column-width",
initial_specified_value="Either::Second(Auto)", initial_specified_value="Either::Second(Auto)",
parse_method="parse_non_negative_length", parse_method="parse_non_negative_length",
extra_prefixes="moz", extra_prefixes="moz",
boxed=True,
animatable=False, animatable=False,
experimental=True, experimental=True,
spec="https://drafts.csswg.org/css-multicol/#propdef-column-width")} spec="https://drafts.csswg.org/css-multicol/#propdef-column-width")}
@ -35,6 +36,7 @@ ${helpers.predefined_type("column-gap",
parse_method='parse_non_negative_length', parse_method='parse_non_negative_length',
extra_prefixes="moz", extra_prefixes="moz",
experimental=True, experimental=True,
boxed=True,
animatable=False, animatable=False,
spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap")} spec="https://drafts.csswg.org/css-multicol/#propdef-column-gap")}
@ -43,7 +45,7 @@ ${helpers.single_keyword("column-fill", "balance auto", extra_prefixes="moz",
spec="https://drafts.csswg.org/css-multicol/#propdef-column-fill")} spec="https://drafts.csswg.org/css-multicol/#propdef-column-fill")}
// https://drafts.csswg.org/css-multicol-1/#propdef-column-rule-width // https://drafts.csswg.org/css-multicol-1/#propdef-column-rule-width
<%helpers:longhand name="column-rule-width" products="gecko" animatable="True" extra_prefixes="moz" <%helpers:longhand name="column-rule-width" products="gecko" boxed="True" animatable="True" extra_prefixes="moz"
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width"> spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width">
use app_units::Au; use app_units::Au;
use std::fmt; use std::fmt;

Просмотреть файл

@ -6,7 +6,8 @@
<% data.new_style_struct("Counters", inherited=False, gecko_name="Content") %> <% data.new_style_struct("Counters", inherited=False, gecko_name="Content") %>
<%helpers:longhand name="content" animatable="False" spec="https://drafts.csswg.org/css-content/#propdef-content"> <%helpers:longhand name="content" boxed="True" animatable="False"
spec="https://drafts.csswg.org/css-content/#propdef-content">
use cssparser::Token; use cssparser::Token;
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;

Просмотреть файл

@ -308,7 +308,7 @@ ${helpers.single_keyword("text-align-last",
</%helpers:longhand> </%helpers:longhand>
// FIXME: This prop should be animatable. // FIXME: This prop should be animatable.
<%helpers:longhand name="letter-spacing" animatable="False" <%helpers:longhand name="letter-spacing" boxed="True" animatable="False"
spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing"> spec="https://drafts.csswg.org/css-text/#propdef-letter-spacing">
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
@ -811,7 +811,7 @@ ${helpers.single_keyword("text-align-last",
} }
</%helpers:longhand> </%helpers:longhand>
<%helpers:longhand name="text-emphasis-style" products="gecko" need_clone="True" animatable="False" <%helpers:longhand name="text-emphasis-style" products="gecko" need_clone="True" boxed="True" animatable="False"
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-style"> spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-style">
use computed_values::writing_mode::T as writing_mode; use computed_values::writing_mode::T as writing_mode;
use std::fmt; use std::fmt;
@ -1081,7 +1081,7 @@ ${helpers.predefined_type(
"-moz-tab-size", "LengthOrNumber", "-moz-tab-size", "LengthOrNumber",
"::values::Either::Second(8.0)", "::values::Either::Second(8.0)",
"parse_non_negative", "parse_non_negative",
products="gecko", animatable=False, products="gecko", boxed=True, animatable=False,
spec="https://drafts.csswg.org/css-text-3/#tab-size-property")} spec="https://drafts.csswg.org/css-text-3/#tab-size-property")}
@ -1102,7 +1102,7 @@ ${helpers.predefined_type(
complex_color=True, need_clone=True, complex_color=True, need_clone=True,
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")} spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")}
<%helpers:longhand products="gecko" name="-webkit-text-stroke-width" animatable="False" <%helpers:longhand products="gecko" name="-webkit-text-stroke-width" boxed="True" animatable="False"
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width"> spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width">
use app_units::Au; use app_units::Au;
use std::fmt; use std::fmt;

Просмотреть файл

@ -122,6 +122,7 @@ ${helpers.predefined_type("outline-color", "CSSColor", "computed::CSSColor::Curr
${helpers.predefined_type("-moz-outline-radius-" + corner, "BorderRadiusSize", ${helpers.predefined_type("-moz-outline-radius-" + corner, "BorderRadiusSize",
"computed::BorderRadiusSize::zero()", "computed::BorderRadiusSize::zero()",
"parse", products="gecko", "parse", products="gecko",
boxed=True,
animatable=False, animatable=False,
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-outline-radius)")} spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-outline-radius)")}
% endfor % endfor

Просмотреть файл

@ -6,7 +6,8 @@
<% data.new_style_struct("Pointing", inherited=True, gecko_name="UserInterface") %> <% data.new_style_struct("Pointing", inherited=True, gecko_name="UserInterface") %>
<%helpers:longhand name="cursor" animatable="False" spec="https://drafts.csswg.org/css-ui/#cursor"> <%helpers:longhand name="cursor" boxed="${product == 'gecko'}" animatable="False"
spec="https://drafts.csswg.org/css-ui/#cursor">
pub use self::computed_value::T as SpecifiedValue; pub use self::computed_value::T as SpecifiedValue;
use values::HasViewportPercentage; use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified; use values::computed::ComputedValueAsSpecified;
@ -176,4 +177,5 @@ ${helpers.predefined_type("caret-color",
"Either::Second(Auto)", "Either::Second(Auto)",
spec="https://drafts.csswg.org/css-ui/#caret-color", spec="https://drafts.csswg.org/css-ui/#caret-color",
animatable="True", animatable="True",
boxed=True,
products="gecko")} products="gecko")}

Просмотреть файл

@ -2451,7 +2451,7 @@ macro_rules! longhand_properties_idents {
pub fn test_size_of_property_declaration() { pub fn test_size_of_property_declaration() {
use std::mem::size_of; use std::mem::size_of;
let old = 40; let old = 32;
let new = size_of::<PropertyDeclaration>(); let new = size_of::<PropertyDeclaration>();
if new < old { if new < old {
panic!("Your changes have decreased the stack size of PropertyDeclaration enum from {} to {}. \ panic!("Your changes have decreased the stack size of PropertyDeclaration enum from {} to {}. \
@ -2471,7 +2471,7 @@ pub fn test_size_of_property_declaration() {
#[cfg(feature = "testing")] #[cfg(feature = "testing")]
pub fn test_size_of_specified_values() { pub fn test_size_of_specified_values() {
use std::mem::size_of; use std::mem::size_of;
let threshold = 32; let threshold = 24;
let mut longhands = vec![]; let mut longhands = vec![];
% for property in data.longhands: % for property in data.longhands:

Просмотреть файл

@ -1114,10 +1114,10 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations:
let prop = match_wrap_declared! { long, let prop = match_wrap_declared! { long,
Height => nocalc.into(), Height => nocalc.into(),
Width => nocalc.into(), Width => nocalc.into(),
BorderTopWidth => BorderWidth::Width(nocalc.into()), BorderTopWidth => Box::new(BorderWidth::Width(nocalc.into())),
BorderRightWidth => BorderWidth::Width(nocalc.into()), BorderRightWidth => Box::new(BorderWidth::Width(nocalc.into())),
BorderBottomWidth => BorderWidth::Width(nocalc.into()), BorderBottomWidth => Box::new(BorderWidth::Width(nocalc.into())),
BorderLeftWidth => BorderWidth::Width(nocalc.into()), BorderLeftWidth => Box::new(BorderWidth::Width(nocalc.into())),
MarginTop => nocalc.into(), MarginTop => nocalc.into(),
MarginRight => nocalc.into(), MarginRight => nocalc.into(),
MarginBottom => nocalc.into(), MarginBottom => nocalc.into(),

Просмотреть файл

@ -237,10 +237,10 @@ mod shorthand_serialization {
let px_30 = BorderWidth::from_length(Length::from_px(30f32)); let px_30 = BorderWidth::from_length(Length::from_px(30f32));
let px_10 = BorderWidth::from_length(Length::from_px(10f32)); let px_10 = BorderWidth::from_length(Length::from_px(10f32));
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderTopWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderRightWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderLeftWidth(px_10.clone())); properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(px_10.clone())));
let blue = CSSColor { let blue = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)), parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
@ -270,10 +270,10 @@ mod shorthand_serialization {
let px_30 = BorderWidth::from_length(Length::from_px(30f32)); let px_30 = BorderWidth::from_length(Length::from_px(30f32));
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderTopWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderRightWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderBottomWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(px_30.clone())));
properties.push(PropertyDeclaration::BorderLeftWidth(px_30.clone())); properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(px_30.clone())));
let blue = CSSColor { let blue = CSSColor {
parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)), parsed: ComputedColor::RGBA(RGBA::new(0, 0, 255, 255)),
@ -314,10 +314,10 @@ mod shorthand_serialization {
let right_px = BorderWidth::from_length(Length::from_px(15f32)); let right_px = BorderWidth::from_length(Length::from_px(15f32));
let left_px = BorderWidth::from_length(Length::from_px(15f32)); let left_px = BorderWidth::from_length(Length::from_px(15f32));
properties.push(PropertyDeclaration::BorderTopWidth(top_px)); properties.push(PropertyDeclaration::BorderTopWidth(Box::new(top_px)));
properties.push(PropertyDeclaration::BorderRightWidth(right_px)); properties.push(PropertyDeclaration::BorderRightWidth(Box::new(right_px)));
properties.push(PropertyDeclaration::BorderBottomWidth(bottom_px)); properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(bottom_px)));
properties.push(PropertyDeclaration::BorderLeftWidth(left_px)); properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(left_px)));
let serialization = shorthand_properties_to_string(properties); let serialization = shorthand_properties_to_string(properties);
assert_eq!(serialization, "border-width: 10px 15px;"); assert_eq!(serialization, "border-width: 10px 15px;");
@ -332,10 +332,10 @@ mod shorthand_serialization {
let bottom_px = BorderWidth::Thick; let bottom_px = BorderWidth::Thick;
let left_px = BorderWidth::from_length(Length::from_px(15f32)); let left_px = BorderWidth::from_length(Length::from_px(15f32));
properties.push(PropertyDeclaration::BorderTopWidth(top_px)); properties.push(PropertyDeclaration::BorderTopWidth(Box::new(top_px)));
properties.push(PropertyDeclaration::BorderRightWidth(right_px)); properties.push(PropertyDeclaration::BorderRightWidth(Box::new(right_px)));
properties.push(PropertyDeclaration::BorderBottomWidth(bottom_px)); properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(bottom_px)));
properties.push(PropertyDeclaration::BorderLeftWidth(left_px)); properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(left_px)));
let serialization = shorthand_properties_to_string(properties); let serialization = shorthand_properties_to_string(properties);
assert_eq!(serialization, "border-width: thin medium thick 15px;"); assert_eq!(serialization, "border-width: thin medium thick 15px;");
@ -400,7 +400,7 @@ mod shorthand_serialization {
authored: None authored: None
}; };
properties.push(PropertyDeclaration::BorderTopWidth(width)); properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderTopStyle(style)); properties.push(PropertyDeclaration::BorderTopStyle(style));
properties.push(PropertyDeclaration::BorderTopColor(color)); properties.push(PropertyDeclaration::BorderTopColor(color));
@ -418,7 +418,7 @@ mod shorthand_serialization {
fn border_top_should_serialize_correctly() { fn border_top_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let (width, style, color) = get_border_property_values(); let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderTopWidth(width)); properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderTopStyle(style)); properties.push(PropertyDeclaration::BorderTopStyle(style));
properties.push(PropertyDeclaration::BorderTopColor(color)); properties.push(PropertyDeclaration::BorderTopColor(color));
@ -430,7 +430,7 @@ mod shorthand_serialization {
fn border_right_should_serialize_correctly() { fn border_right_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let (width, style, color) = get_border_property_values(); let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderRightWidth(width)); properties.push(PropertyDeclaration::BorderRightWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderRightStyle(style)); properties.push(PropertyDeclaration::BorderRightStyle(style));
properties.push(PropertyDeclaration::BorderRightColor(color)); properties.push(PropertyDeclaration::BorderRightColor(color));
@ -442,7 +442,7 @@ mod shorthand_serialization {
fn border_bottom_should_serialize_correctly() { fn border_bottom_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let (width, style, color) = get_border_property_values(); let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderBottomWidth(width)); properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderBottomStyle(style)); properties.push(PropertyDeclaration::BorderBottomStyle(style));
properties.push(PropertyDeclaration::BorderBottomColor(color)); properties.push(PropertyDeclaration::BorderBottomColor(color));
@ -454,7 +454,7 @@ mod shorthand_serialization {
fn border_left_should_serialize_correctly() { fn border_left_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let (width, style, color) = get_border_property_values(); let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderLeftWidth(width)); properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(width)));
properties.push(PropertyDeclaration::BorderLeftStyle(style)); properties.push(PropertyDeclaration::BorderLeftStyle(style));
properties.push(PropertyDeclaration::BorderLeftColor(color)); properties.push(PropertyDeclaration::BorderLeftColor(color));
@ -467,19 +467,19 @@ mod shorthand_serialization {
let mut properties = Vec::new(); let mut properties = Vec::new();
let (width, style, color) = get_border_property_values(); let (width, style, color) = get_border_property_values();
properties.push(PropertyDeclaration::BorderTopWidth(width.clone())); properties.push(PropertyDeclaration::BorderTopWidth(Box::new(width.clone())));
properties.push(PropertyDeclaration::BorderTopStyle(style.clone())); properties.push(PropertyDeclaration::BorderTopStyle(style.clone()));
properties.push(PropertyDeclaration::BorderTopColor(color.clone())); properties.push(PropertyDeclaration::BorderTopColor(color.clone()));
properties.push(PropertyDeclaration::BorderRightWidth(width.clone())); properties.push(PropertyDeclaration::BorderRightWidth(Box::new(width.clone())));
properties.push(PropertyDeclaration::BorderRightStyle(style.clone())); properties.push(PropertyDeclaration::BorderRightStyle(style.clone()));
properties.push(PropertyDeclaration::BorderRightColor(color.clone())); properties.push(PropertyDeclaration::BorderRightColor(color.clone()));
properties.push(PropertyDeclaration::BorderBottomWidth(width.clone())); properties.push(PropertyDeclaration::BorderBottomWidth(Box::new(width.clone())));
properties.push(PropertyDeclaration::BorderBottomStyle(style.clone())); properties.push(PropertyDeclaration::BorderBottomStyle(style.clone()));
properties.push(PropertyDeclaration::BorderBottomColor(color.clone())); properties.push(PropertyDeclaration::BorderBottomColor(color.clone()));
properties.push(PropertyDeclaration::BorderLeftWidth(width.clone())); properties.push(PropertyDeclaration::BorderLeftWidth(Box::new(width.clone())));
properties.push(PropertyDeclaration::BorderLeftStyle(style.clone())); properties.push(PropertyDeclaration::BorderLeftStyle(style.clone()));
properties.push(PropertyDeclaration::BorderLeftColor(color.clone())); properties.push(PropertyDeclaration::BorderLeftColor(color.clone()));
@ -564,7 +564,7 @@ mod shorthand_serialization {
let width = Either::Second(Auto); let width = Either::Second(Auto);
let count = Either::Second(Auto); let count = Either::Second(Auto);
properties.push(PropertyDeclaration::ColumnWidth(width)); properties.push(PropertyDeclaration::ColumnWidth(Box::new(width)));
properties.push(PropertyDeclaration::ColumnCount(count)); properties.push(PropertyDeclaration::ColumnCount(count));
let serialization = shorthand_properties_to_string(properties); let serialization = shorthand_properties_to_string(properties);

Просмотреть файл

@ -11,17 +11,17 @@ use style::values::specified::{Length, NoCalcLength, ViewportPercentageLength};
#[test] #[test]
fn has_viewport_percentage_for_specified_value() { fn has_viewport_percentage_for_specified_value() {
//TODO: test all specified value with a HasViewportPercentage impl //TODO: test all specified value with a HasViewportPercentage impl
let pvw = PropertyDeclaration::BorderTopWidth( let pvw = PropertyDeclaration::BorderTopWidth(Box::new(
border_top_width::SpecifiedValue::from_length( border_top_width::SpecifiedValue::from_length(
Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.))) Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.)))
) )
); ));
assert!(pvw.has_viewport_percentage()); assert!(pvw.has_viewport_percentage());
let pabs = PropertyDeclaration::BorderTopWidth( let pabs = PropertyDeclaration::BorderTopWidth(Box::new(
border_top_width::SpecifiedValue::from_length( border_top_width::SpecifiedValue::from_length(
Length::NoCalc(NoCalcLength::Absolute(Au(100))) Length::NoCalc(NoCalcLength::Absolute(Au(100)))
) )
); ));
assert!(!pabs.has_viewport_percentage()); assert!(!pabs.has_viewport_percentage());
} }