Box more specified values to bring SpecifiedValue/PropertyDeclaration sizes down to 24/32 bytes.

MozReview-Commit-ID: xstAfjVQqi
This commit is contained in:
Bobby Holley 2017-03-17 16:37:43 -07:00
parent 8f3f8098c3
commit 97dd3a1b08
12 changed files with 58 additions and 50 deletions

View file

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

View file

@ -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" 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')}"
spec="${maybe_logical_spec(side, 'width')}">
use app_units::Au;
@ -69,6 +69,7 @@ ${helpers.gecko_keyword_conversion(Keyword('border-style',
"computed::BorderRadiusSize::zero()",
"parse", extra_prefixes="webkit",
spec="https://drafts.csswg.org/css-backgrounds/#border-%s-radius" % corner,
boxed=True,
animatable=True)}
% endfor
@ -556,7 +557,7 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box",
}
</%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">
use std::fmt;
use style_traits::ToCss;

View file

@ -1709,10 +1709,11 @@ ${helpers.predefined_type("perspective",
gecko_ffi_name="mChildPerspective",
spec="https://drafts.csswg.org/css-transforms/#perspective",
extra_prefixes="moz webkit",
boxed=True,
animatable=True)}
// 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">
use std::fmt;
use style_traits::ToCss;

View file

@ -13,6 +13,7 @@ ${helpers.predefined_type("column-width",
initial_specified_value="Either::Second(Auto)",
parse_method="parse_non_negative_length",
extra_prefixes="moz",
boxed=True,
animatable=False,
experimental=True,
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',
extra_prefixes="moz",
experimental=True,
boxed=True,
animatable=False,
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")}
// 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">
use app_units::Au;
use std::fmt;

View file

@ -6,7 +6,8 @@
<% 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 std::ascii::AsciiExt;
use values::computed::ComputedValueAsSpecified;

View file

@ -308,7 +308,7 @@ ${helpers.single_keyword("text-align-last",
</%helpers:longhand>
// 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">
use std::fmt;
use style_traits::ToCss;
@ -811,7 +811,7 @@ ${helpers.single_keyword("text-align-last",
}
</%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">
use computed_values::writing_mode::T as writing_mode;
use std::fmt;
@ -1081,7 +1081,7 @@ ${helpers.predefined_type(
"-moz-tab-size", "LengthOrNumber",
"::values::Either::Second(8.0)",
"parse_non_negative",
products="gecko", animatable=False,
products="gecko", boxed=True, animatable=False,
spec="https://drafts.csswg.org/css-text-3/#tab-size-property")}
@ -1102,7 +1102,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" 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">
use app_units::Au;
use std::fmt;

View file

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

View file

@ -6,7 +6,8 @@
<% 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;
use values::HasViewportPercentage;
use values::computed::ComputedValueAsSpecified;
@ -176,4 +177,5 @@ ${helpers.predefined_type("caret-color",
"Either::Second(Auto)",
spec="https://drafts.csswg.org/css-ui/#caret-color",
animatable="True",
boxed=True,
products="gecko")}

View file

@ -2451,7 +2451,7 @@ macro_rules! longhand_properties_idents {
pub fn test_size_of_property_declaration() {
use std::mem::size_of;
let old = 40;
let old = 32;
let new = size_of::<PropertyDeclaration>();
if new < old {
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")]
pub fn test_size_of_specified_values() {
use std::mem::size_of;
let threshold = 32;
let threshold = 24;
let mut longhands = vec![];
% for property in data.longhands: