From 43731c5757f5d91179beab9eae19dd0511b4ae42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Naz=C4=B1m=20Can=20Alt=C4=B1nova?= Date: Thu, 9 Feb 2017 01:05:44 +0300 Subject: [PATCH] Box custom property --- components/style/custom_properties.rs | 13 +++++++------ components/style/properties/properties.mako.rs | 5 +++-- tests/unit/style/size_of.rs | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/components/style/custom_properties.rs b/components/style/custom_properties.rs index 8c6c3675c02..fcd319a290c 100644 --- a/components/style/custom_properties.rs +++ b/components/style/custom_properties.rs @@ -8,7 +8,7 @@ use Atom; use cssparser::{Delimiter, Parser, SourcePosition, Token, TokenSerializationType}; -use parser::{Parse, ParserContext}; +use parser::ParserContext; use properties::DeclaredValue; use std::ascii::AsciiExt; use std::borrow::Cow; @@ -129,16 +129,17 @@ impl ComputedValue { } } -impl Parse for SpecifiedValue { - fn parse(_context: &ParserContext, input: &mut Parser) -> Result { +impl SpecifiedValue { + /// Parse a custom property SpecifiedValue. + pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result, ()> { let mut references = Some(HashSet::new()); let (first, css, last) = try!(parse_self_contained_declaration_value(input, &mut references)); - Ok(SpecifiedValue { + Ok(Box::new(SpecifiedValue { css: css.into_owned(), first_token_type: first, last_token_type: last, references: references.unwrap(), - }) + })) } } @@ -328,7 +329,7 @@ pub fn cascade<'a>(custom_properties: &mut Option>>, seen: &mut HashSet<&'a Name>, name: &'a Name, - specified_value: &'a DeclaredValue) { + specified_value: &'a DeclaredValue>) { let was_already_present = !seen.insert(name); if was_already_present { return; diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index d8b7586a799..6440deab04b 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -850,7 +850,7 @@ pub enum PropertyDeclaration { % endfor /// A custom property declaration, with the property name and the declared /// value. - Custom(::custom_properties::Name, DeclaredValue<::custom_properties::SpecifiedValue>), + Custom(::custom_properties::Name, DeclaredValue>), } impl HasViewportPercentage for PropertyDeclaration { @@ -1029,7 +1029,8 @@ impl PropertyDeclaration { Err(()) => return PropertyDeclarationParseResult::InvalidValue, } }; - result_list.push((PropertyDeclaration::Custom(name, value), Importance::Normal)); + result_list.push((PropertyDeclaration::Custom(name, value), + Importance::Normal)); return PropertyDeclarationParseResult::ValidOrIgnoredDeclaration; } PropertyId::Longhand(id) => match id { diff --git a/tests/unit/style/size_of.rs b/tests/unit/style/size_of.rs index 00005485175..86f43fa7b51 100644 --- a/tests/unit/style/size_of.rs +++ b/tests/unit/style/size_of.rs @@ -7,7 +7,7 @@ use style::properties::{PropertyDeclaration, specified_value_sizes}; #[test] fn size_of_property_declaration() { - let old = 96; + let old = 72; let new = size_of::(); if new < old { panic!("Your changes have decreased the stack size of PropertyDeclaration enum from {} to {}. \