aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2017-03-07 17:17:54 +0100
committerSimon Sapin <simon.sapin@exyr.org>2017-03-07 23:37:29 +0100
commit4b4a873c3ec0b024ef63fbcc02e8fbff0dc75d6a (patch)
tree955706dc375a24d853ce482e612a047eb48572dc
parent9d663ea7af3771531e87669d8323916e9f106075 (diff)
downloadservo-4b4a873c3ec0b024ef63fbcc02e8fbff0dc75d6a.tar.gz
servo-4b4a873c3ec0b024ef63fbcc02e8fbff0dc75d6a.zip
Move parse method of PropertyDeclaration to ParsedDeclaration
This is what it now returns.
-rw-r--r--components/style/keyframes.rs2
-rw-r--r--components/style/properties/declaration_block.rs4
-rw-r--r--components/style/properties/properties.mako.rs172
-rw-r--r--components/style/supports.rs4
-rw-r--r--ports/geckolib/glue.rs4
5 files changed, 93 insertions, 93 deletions
diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs
index e48e8c4e909..0fde0c64284 100644
--- a/components/style/keyframes.rs
+++ b/components/style/keyframes.rs
@@ -401,7 +401,7 @@ impl<'a, 'b> DeclarationParser for KeyframeDeclarationParser<'a, 'b> {
fn parse_value(&mut self, name: &str, input: &mut Parser) -> Result<ParsedDeclaration, ()> {
let id = try!(PropertyId::parse(name.into()));
- match PropertyDeclaration::parse(id, self.context, input, true) {
+ match ParsedDeclaration::parse(id, self.context, input, true) {
Ok(parsed) => {
// In case there is still unparsed text in the declaration, we should roll back.
if !input.is_exhausted() {
diff --git a/components/style/properties/declaration_block.rs b/components/style/properties/declaration_block.rs
index cb63c97f50c..ff6047289a6 100644
--- a/components/style/properties/declaration_block.rs
+++ b/components/style/properties/declaration_block.rs
@@ -557,7 +557,7 @@ pub fn parse_one_declaration(id: PropertyId,
-> Result<ParsedDeclaration, ()> {
let context = ParserContext::new_with_extra_data(Origin::Author, base_url, error_reporter, extra_data);
Parser::new(input).parse_entirely(|parser| {
- PropertyDeclaration::parse(id, &context, parser, false)
+ ParsedDeclaration::parse(id, &context, parser, false)
.map_err(|_| ())
})
}
@@ -582,7 +582,7 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> {
-> Result<(ParsedDeclaration, Importance), ()> {
let id = try!(PropertyId::parse(name.into()));
let parsed = input.parse_until_before(Delimiter::Bang, |input| {
- PropertyDeclaration::parse(id, self.context, input, false)
+ ParsedDeclaration::parse(id, self.context, input, false)
.map_err(|_| ())
})?;
let importance = match input.try(parse_important) {
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index 8730680db9b..74b28d25d95 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -857,6 +857,92 @@ impl ParsedDeclaration {
ParsedDeclaration::LonghandOrCustom(declaration) => f(declaration),
}
}
+
+ /// The `in_keyframe_block` parameter controls this:
+ ///
+ /// https://drafts.csswg.org/css-animations/#keyframes
+ /// > The <declaration-list> inside of <keyframe-block> accepts any CSS property
+ /// > except those defined in this specification,
+ /// > but does accept the `animation-play-state` property and interprets it specially.
+ ///
+ /// This will not actually parse Importance values, and will always set things
+ /// to Importance::Normal. Parsing Importance values is the job of PropertyDeclarationParser,
+ /// we only set them here so that we don't have to reallocate
+ pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser,
+ in_keyframe_block: bool)
+ -> Result<ParsedDeclaration, PropertyDeclarationParseError> {
+ match id {
+ PropertyId::Custom(name) => {
+ let value = match input.try(|i| CSSWideKeyword::parse(context, i)) {
+ Ok(keyword) => DeclaredValue::CSSWideKeyword(keyword),
+ Err(()) => match ::custom_properties::SpecifiedValue::parse(context, input) {
+ Ok(value) => DeclaredValue::Value(value),
+ Err(()) => return Err(PropertyDeclarationParseError::InvalidValue),
+ }
+ };
+ Ok(ParsedDeclaration::LonghandOrCustom(PropertyDeclaration::Custom(name, value)))
+ }
+ PropertyId::Longhand(id) => match id {
+ % for property in data.longhands:
+ LonghandId::${property.camel_case} => {
+ % if not property.derived_from:
+ % if not property.allowed_in_keyframe_block:
+ if in_keyframe_block {
+ return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
+ }
+ % endif
+ % if property.internal:
+ if context.stylesheet_origin != Origin::UserAgent {
+ return Err(PropertyDeclarationParseError::UnknownProperty)
+ }
+ % endif
+
+ ${property_pref_check(property)}
+
+ match longhands::${property.ident}::parse_declared(context, input) {
+ Ok(value) => {
+ Ok(ParsedDeclaration::LonghandOrCustom(
+ PropertyDeclaration::${property.camel_case}(value)
+ ))
+ },
+ Err(()) => Err(PropertyDeclarationParseError::InvalidValue),
+ }
+ % else:
+ Err(PropertyDeclarationParseError::UnknownProperty)
+ % endif
+ }
+ % endfor
+ },
+ PropertyId::Shorthand(id) => match id {
+ % for shorthand in data.shorthands:
+ ShorthandId::${shorthand.camel_case} => {
+ % if not shorthand.allowed_in_keyframe_block:
+ if in_keyframe_block {
+ return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
+ }
+ % endif
+ % if shorthand.internal:
+ if context.stylesheet_origin != Origin::UserAgent {
+ return Err(PropertyDeclarationParseError::UnknownProperty)
+ }
+ % endif
+
+ ${property_pref_check(shorthand)}
+
+ match input.try(|i| CSSWideKeyword::parse(context, i)) {
+ Ok(keyword) => {
+ Ok(ParsedDeclaration::${shorthand.camel_case}CSSWideKeyword(keyword))
+ },
+ Err(()) => {
+ shorthands::${shorthand.ident}::parse(context, input)
+ .map_err(|()| PropertyDeclarationParseError::InvalidValue)
+ }
+ }
+ }
+ % endfor
+ }
+ }
+ }
}
/// Servo's representation for a property declaration.
@@ -1051,92 +1137,6 @@ impl PropertyDeclaration {
}
}
- /// The `in_keyframe_block` parameter controls this:
- ///
- /// https://drafts.csswg.org/css-animations/#keyframes
- /// > The <declaration-list> inside of <keyframe-block> accepts any CSS property
- /// > except those defined in this specification,
- /// > but does accept the `animation-play-state` property and interprets it specially.
- ///
- /// This will not actually parse Importance values, and will always set things
- /// to Importance::Normal. Parsing Importance values is the job of PropertyDeclarationParser,
- /// we only set them here so that we don't have to reallocate
- pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser,
- in_keyframe_block: bool)
- -> Result<ParsedDeclaration, PropertyDeclarationParseError> {
- match id {
- PropertyId::Custom(name) => {
- let value = match input.try(|i| CSSWideKeyword::parse(context, i)) {
- Ok(keyword) => DeclaredValue::CSSWideKeyword(keyword),
- Err(()) => match ::custom_properties::SpecifiedValue::parse(context, input) {
- Ok(value) => DeclaredValue::Value(value),
- Err(()) => return Err(PropertyDeclarationParseError::InvalidValue),
- }
- };
- Ok(ParsedDeclaration::LonghandOrCustom(PropertyDeclaration::Custom(name, value)))
- }
- PropertyId::Longhand(id) => match id {
- % for property in data.longhands:
- LonghandId::${property.camel_case} => {
- % if not property.derived_from:
- % if not property.allowed_in_keyframe_block:
- if in_keyframe_block {
- return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
- }
- % endif
- % if property.internal:
- if context.stylesheet_origin != Origin::UserAgent {
- return Err(PropertyDeclarationParseError::UnknownProperty)
- }
- % endif
-
- ${property_pref_check(property)}
-
- match longhands::${property.ident}::parse_declared(context, input) {
- Ok(value) => {
- Ok(ParsedDeclaration::LonghandOrCustom(
- PropertyDeclaration::${property.camel_case}(value)
- ))
- },
- Err(()) => Err(PropertyDeclarationParseError::InvalidValue),
- }
- % else:
- Err(PropertyDeclarationParseError::UnknownProperty)
- % endif
- }
- % endfor
- },
- PropertyId::Shorthand(id) => match id {
- % for shorthand in data.shorthands:
- ShorthandId::${shorthand.camel_case} => {
- % if not shorthand.allowed_in_keyframe_block:
- if in_keyframe_block {
- return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
- }
- % endif
- % if shorthand.internal:
- if context.stylesheet_origin != Origin::UserAgent {
- return Err(PropertyDeclarationParseError::UnknownProperty)
- }
- % endif
-
- ${property_pref_check(shorthand)}
-
- match input.try(|i| CSSWideKeyword::parse(context, i)) {
- Ok(keyword) => {
- Ok(ParsedDeclaration::${shorthand.camel_case}CSSWideKeyword(keyword))
- },
- Err(()) => {
- shorthands::${shorthand.ident}::parse(context, input)
- .map_err(|()| PropertyDeclarationParseError::InvalidValue)
- }
- }
- }
- % endfor
- }
- }
- }
-
/// The shorthands that this longhand is part of.
pub fn shorthands(&self) -> &'static [ShorthandId] {
// first generate longhand to shorthands lookup map
diff --git a/components/style/supports.rs b/components/style/supports.rs
index ccdde3231bb..96c4bd3b5dc 100644
--- a/components/style/supports.rs
+++ b/components/style/supports.rs
@@ -6,7 +6,7 @@
use cssparser::{parse_important, Parser, Token};
use parser::ParserContext;
-use properties::{PropertyDeclaration, PropertyId};
+use properties::{PropertyId, ParsedDeclaration};
use std::fmt;
use style_traits::ToCss;
@@ -211,7 +211,7 @@ impl Declaration {
return false
};
let mut input = Parser::new(&self.val);
- let res = PropertyDeclaration::parse(id, cx, &mut input, /* in_keyframe */ false);
+ let res = ParsedDeclaration::parse(id, cx, &mut input, /* in_keyframe */ false);
let _ = input.try(parse_important);
res.is_ok() && input.is_exhausted()
}
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index c8b5d7013b6..d331293e530 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -67,7 +67,7 @@ use style::gecko_properties::{self, style_structs};
use style::keyframes::KeyframesStepValue;
use style::parallel;
use style::parser::{ParserContext, ParserContextExtraData};
-use style::properties::{ComputedValues, Importance, PropertyDeclaration};
+use style::properties::{ComputedValues, Importance, ParsedDeclaration};
use style::properties::{PropertyDeclarationBlock, PropertyId};
use style::properties::animated_properties::{AnimationValue, Interpolate, TransitionProperty};
use style::properties::parse_one_declaration;
@@ -713,7 +713,7 @@ pub extern "C" fn Servo_ParseProperty(property: *const nsACString, value: *const
Box::new(StdoutErrorReporter),
extra_data);
- match PropertyDeclaration::parse(id, &context, &mut Parser::new(value), false) {
+ match ParsedDeclaration::parse(id, &context, &mut Parser::new(value), false) {
Ok(parsed) => {
let mut declarations = Vec::new();
parsed.expand(|d| declarations.push((d, Importance::Normal)));