aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/style/keyframes.rs10
-rw-r--r--components/style/properties/declaration_block.rs10
-rw-r--r--components/style/properties/properties.mako.rs34
-rw-r--r--components/style/supports.rs10
-rw-r--r--ports/geckolib/glue.rs11
5 files changed, 30 insertions, 45 deletions
diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs
index 87bebc308d2..40d8ef60b09 100644
--- a/components/style/keyframes.rs
+++ b/components/style/keyframes.rs
@@ -13,7 +13,6 @@ use parser::{ParserContext, ParserContextExtraData, log_css_error};
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, PropertyId};
use properties::{PropertyDeclarationId, LonghandId, DeclaredValue};
use properties::LonghandIdSet;
-use properties::PropertyDeclarationParseResult;
use properties::animated_properties::TransitionProperty;
use properties::longhands::transition_timing_function::single_value::SpecifiedValue as SpecifiedTimingFunction;
use std::fmt;
@@ -407,12 +406,9 @@ impl<'a, 'b> DeclarationParser for KeyframeDeclarationParser<'a, 'b> {
fn parse_value(&mut self, name: &str, input: &mut Parser) -> Result<(), ()> {
let id = try!(PropertyId::parse(name.into()));
let old_len = self.declarations.len();
- match PropertyDeclaration::parse(id, self.context, input, &mut self.declarations, true) {
- PropertyDeclarationParseResult::ValidOrIgnoredDeclaration => {}
- _ => {
- self.declarations.truncate(old_len);
- return Err(());
- }
+ if PropertyDeclaration::parse(id, self.context, input, &mut self.declarations, true).is_err() {
+ self.declarations.truncate(old_len);
+ return Err(())
}
// 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 ac618dcbf72..b21fa79e3ec 100644
--- a/components/style/properties/declaration_block.rs
+++ b/components/style/properties/declaration_block.rs
@@ -561,8 +561,8 @@ pub fn parse_one_declaration(id: PropertyId,
Parser::new(input).parse_entirely(|parser| {
let mut results = vec![];
match PropertyDeclaration::parse(id, &context, parser, &mut results, false) {
- PropertyDeclarationParseResult::ValidOrIgnoredDeclaration => Ok(results),
- _ => Err(())
+ Ok(()) => Ok(results),
+ Err(_) => Err(())
}
})
}
@@ -592,10 +592,8 @@ impl<'a, 'b> DeclarationParser for PropertyDeclarationParser<'a, 'b> {
let id = try!(PropertyId::parse(name.into()));
let old_len = self.declarations.len();
let parse_result = input.parse_until_before(Delimiter::Bang, |input| {
- match PropertyDeclaration::parse(id, self.context, input, &mut self.declarations, false) {
- PropertyDeclarationParseResult::ValidOrIgnoredDeclaration => Ok(()),
- _ => Err(())
- }
+ PropertyDeclaration::parse(id, self.context, input, &mut self.declarations, false)
+ .map_err(|_| ())
});
if let Err(_) = parse_result {
// rollback
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index f0969ac1eea..642b56ff851 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -886,7 +886,7 @@ impl HasViewportPercentage for PropertyDeclaration {
/// The result of parsing a property declaration.
#[derive(Eq, PartialEq, Copy, Clone)]
-pub enum PropertyDeclarationParseResult {
+pub enum PropertyDeclarationParseError {
/// The property declaration was for an unknown property.
UnknownProperty,
/// The property declaration was for a disabled experimental property.
@@ -898,8 +898,6 @@ pub enum PropertyDeclarationParseResult {
///
/// See: https://drafts.csswg.org/css-animations/#keyframes
AnimationPropertyInKeyframeBlock,
- /// The declaration was either valid or ignored.
- ValidOrIgnoredDeclaration,
}
impl fmt::Debug for PropertyDeclaration {
@@ -933,7 +931,7 @@ impl ToCss for PropertyDeclaration {
% if property.experimental and product == "servo":
if !PREFS.get("${property.experimental}")
.as_boolean().unwrap_or(false) {
- return PropertyDeclarationParseResult::ExperimentalProperty
+ return Err(PropertyDeclarationParseError::ExperimentalProperty)
}
% endif
% if product == "gecko":
@@ -950,7 +948,7 @@ impl ToCss for PropertyDeclaration {
let id = structs::${helpers.to_nscsspropertyid(property.ident)};
let enabled = unsafe { bindings::Gecko_PropertyId_IsPrefEnabled(id) };
if !enabled {
- return PropertyDeclarationParseResult::ExperimentalProperty
+ return Err(PropertyDeclarationParseError::ExperimentalProperty)
}
}
% endif
@@ -1060,19 +1058,19 @@ impl PropertyDeclaration {
pub fn parse(id: PropertyId, context: &ParserContext, input: &mut Parser,
result_list: &mut Vec<(PropertyDeclaration, Importance)>,
in_keyframe_block: bool)
- -> PropertyDeclarationParseResult {
+ -> Result<(), 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 PropertyDeclarationParseResult::InvalidValue,
+ Err(()) => return Err(PropertyDeclarationParseError::InvalidValue),
}
};
result_list.push((PropertyDeclaration::Custom(name, value),
Importance::Normal));
- return PropertyDeclarationParseResult::ValidOrIgnoredDeclaration;
+ return Ok(());
}
PropertyId::Longhand(id) => match id {
% for property in data.longhands:
@@ -1080,12 +1078,12 @@ impl PropertyDeclaration {
% if not property.derived_from:
% if not property.allowed_in_keyframe_block:
if in_keyframe_block {
- return PropertyDeclarationParseResult::AnimationPropertyInKeyframeBlock
+ return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
}
% endif
% if property.internal:
if context.stylesheet_origin != Origin::UserAgent {
- return PropertyDeclarationParseResult::UnknownProperty
+ return Err(PropertyDeclarationParseError::UnknownProperty)
}
% endif
@@ -1095,12 +1093,12 @@ impl PropertyDeclaration {
Ok(value) => {
result_list.push((PropertyDeclaration::${property.camel_case}(value),
Importance::Normal));
- PropertyDeclarationParseResult::ValidOrIgnoredDeclaration
+ Ok(())
},
- Err(()) => PropertyDeclarationParseResult::InvalidValue,
+ Err(()) => Err(PropertyDeclarationParseError::InvalidValue),
}
% else:
- PropertyDeclarationParseResult::UnknownProperty
+ Err(PropertyDeclarationParseError::UnknownProperty)
% endif
}
% endfor
@@ -1110,12 +1108,12 @@ impl PropertyDeclaration {
ShorthandId::${shorthand.camel_case} => {
% if not shorthand.allowed_in_keyframe_block:
if in_keyframe_block {
- return PropertyDeclarationParseResult::AnimationPropertyInKeyframeBlock
+ return Err(PropertyDeclarationParseError::AnimationPropertyInKeyframeBlock)
}
% endif
% if shorthand.internal:
if context.stylesheet_origin != Origin::UserAgent {
- return PropertyDeclarationParseResult::UnknownProperty
+ return Err(PropertyDeclarationParseError::UnknownProperty)
}
% endif
@@ -1128,16 +1126,16 @@ impl PropertyDeclaration {
PropertyDeclaration::${sub_property.camel_case}(
DeclaredValue::CSSWideKeyword(keyword)), Importance::Normal));
% endfor
- PropertyDeclarationParseResult::ValidOrIgnoredDeclaration
+ Ok(())
},
Err(()) => match shorthands::${shorthand.ident}::parse(context, input) {
Ok(parsed) => {
parsed.expand(|declaration| {
result_list.push((declaration, Importance::Normal))
});
- PropertyDeclarationParseResult::ValidOrIgnoredDeclaration
+ Ok(())
}
- Err(()) => PropertyDeclarationParseResult::InvalidValue,
+ Err(()) => Err(PropertyDeclarationParseError::InvalidValue),
}
}
}
diff --git a/components/style/supports.rs b/components/style/supports.rs
index 0451204eb1e..170d874801e 100644
--- a/components/style/supports.rs
+++ b/components/style/supports.rs
@@ -205,7 +205,6 @@ impl Declaration {
///
/// https://drafts.csswg.org/css-conditional-3/#support-definition
pub fn eval(&self, cx: &ParserContext) -> bool {
- use properties::PropertyDeclarationParseResult::*;
let id = if let Ok(id) = PropertyId::parse((&*self.prop).into()) {
id
} else {
@@ -219,13 +218,6 @@ impl Declaration {
if !input.is_exhausted() {
return false;
}
- match res {
- UnknownProperty => false,
- ExperimentalProperty => false, // only happens for experimental props
- // that haven't been enabled
- InvalidValue => false,
- AnimationPropertyInKeyframeBlock => unreachable!(),
- ValidOrIgnoredDeclaration => true,
- }
+ res.is_ok()
}
}
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index 4dccb916c72..3047b727293 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -68,7 +68,7 @@ use style::keyframes::KeyframesStepValue;
use style::parallel;
use style::parser::{ParserContext, ParserContextExtraData};
use style::properties::{ComputedValues, Importance, PropertyDeclaration};
-use style::properties::{PropertyDeclarationParseResult, PropertyDeclarationBlock, PropertyId};
+use style::properties::{PropertyDeclarationBlock, PropertyId};
use style::properties::animated_properties::{AnimationValue, Interpolate, TransitionProperty};
use style::properties::parse_one_declaration;
use style::restyle_hints::{self, RestyleHint};
@@ -714,10 +714,11 @@ pub extern "C" fn Servo_ParseProperty(property: *const nsACString, value: *const
extra_data);
let mut results = vec![];
- match PropertyDeclaration::parse(id, &context, &mut Parser::new(value),
- &mut results, false) {
- PropertyDeclarationParseResult::ValidOrIgnoredDeclaration => {},
- _ => return RawServoDeclarationBlockStrong::null(),
+ let result = PropertyDeclaration::parse(
+ id, &context, &mut Parser::new(value), &mut results, false
+ );
+ if result.is_err() {
+ return RawServoDeclarationBlockStrong::null()
}
Arc::new(RwLock::new(PropertyDeclarationBlock {