mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Box custom property
This commit is contained in:
parent
78afe2b8d1
commit
43731c5757
3 changed files with 11 additions and 9 deletions
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
use Atom;
|
use Atom;
|
||||||
use cssparser::{Delimiter, Parser, SourcePosition, Token, TokenSerializationType};
|
use cssparser::{Delimiter, Parser, SourcePosition, Token, TokenSerializationType};
|
||||||
use parser::{Parse, ParserContext};
|
use parser::ParserContext;
|
||||||
use properties::DeclaredValue;
|
use properties::DeclaredValue;
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
@ -129,16 +129,17 @@ impl ComputedValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Parse for SpecifiedValue {
|
impl SpecifiedValue {
|
||||||
fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
/// Parse a custom property SpecifiedValue.
|
||||||
|
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<Box<Self>, ()> {
|
||||||
let mut references = Some(HashSet::new());
|
let mut references = Some(HashSet::new());
|
||||||
let (first, css, last) = try!(parse_self_contained_declaration_value(input, &mut references));
|
let (first, css, last) = try!(parse_self_contained_declaration_value(input, &mut references));
|
||||||
Ok(SpecifiedValue {
|
Ok(Box::new(SpecifiedValue {
|
||||||
css: css.into_owned(),
|
css: css.into_owned(),
|
||||||
first_token_type: first,
|
first_token_type: first,
|
||||||
last_token_type: last,
|
last_token_type: last,
|
||||||
references: references.unwrap(),
|
references: references.unwrap(),
|
||||||
})
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +329,7 @@ pub fn cascade<'a>(custom_properties: &mut Option<HashMap<&'a Name, BorrowedSpec
|
||||||
inherited: &'a Option<Arc<HashMap<Name, ComputedValue>>>,
|
inherited: &'a Option<Arc<HashMap<Name, ComputedValue>>>,
|
||||||
seen: &mut HashSet<&'a Name>,
|
seen: &mut HashSet<&'a Name>,
|
||||||
name: &'a Name,
|
name: &'a Name,
|
||||||
specified_value: &'a DeclaredValue<SpecifiedValue>) {
|
specified_value: &'a DeclaredValue<Box<SpecifiedValue>>) {
|
||||||
let was_already_present = !seen.insert(name);
|
let was_already_present = !seen.insert(name);
|
||||||
if was_already_present {
|
if was_already_present {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -850,7 +850,7 @@ pub enum PropertyDeclaration {
|
||||||
% endfor
|
% endfor
|
||||||
/// A custom property declaration, with the property name and the declared
|
/// A custom property declaration, with the property name and the declared
|
||||||
/// value.
|
/// value.
|
||||||
Custom(::custom_properties::Name, DeclaredValue<::custom_properties::SpecifiedValue>),
|
Custom(::custom_properties::Name, DeclaredValue<Box<::custom_properties::SpecifiedValue>>),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HasViewportPercentage for PropertyDeclaration {
|
impl HasViewportPercentage for PropertyDeclaration {
|
||||||
|
@ -1029,7 +1029,8 @@ impl PropertyDeclaration {
|
||||||
Err(()) => return PropertyDeclarationParseResult::InvalidValue,
|
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;
|
return PropertyDeclarationParseResult::ValidOrIgnoredDeclaration;
|
||||||
}
|
}
|
||||||
PropertyId::Longhand(id) => match id {
|
PropertyId::Longhand(id) => match id {
|
||||||
|
|
|
@ -7,7 +7,7 @@ use style::properties::{PropertyDeclaration, specified_value_sizes};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn size_of_property_declaration() {
|
fn size_of_property_declaration() {
|
||||||
let old = 96;
|
let old = 72;
|
||||||
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 {}. \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue