aboutsummaryrefslogtreecommitdiffstats
path: root/ports
diff options
context:
space:
mode:
authorCameron McCormack <cam@mcc.id.au>2017-12-04 12:52:39 +0800
committerCameron McCormack <cam@mcc.id.au>2017-12-05 13:22:22 +0800
commit7015d5b22e8157450677cf0e01d83e8afc8c0d1d (patch)
treee759a0b29972151ea4baf74a3e8e79e1572f2054 /ports
parent7940061c9a76ce41acf13b227233860b983642c9 (diff)
downloadservo-7015d5b22e8157450677cf0e01d83e8afc8c0d1d.tar.gz
servo-7015d5b22e8157450677cf0e01d83e8afc8c0d1d.zip
style: Add a new CSS error type for lone value parsing errors.
This allows us to report errors in functions that want to just parse a single CSS value, rather than a value for a particular property declaration. The one value type that we need to support for now is <color> value parsing errors, so just add formatting/support for that.
Diffstat (limited to 'ports')
-rw-r--r--ports/geckolib/error_reporter.rs25
1 files changed, 23 insertions, 2 deletions
diff --git a/ports/geckolib/error_reporter.rs b/ports/geckolib/error_reporter.rs
index efca5b55ede..e3e3cdf49c3 100644
--- a/ports/geckolib/error_reporter.rs
+++ b/ports/geckolib/error_reporter.rs
@@ -17,7 +17,7 @@ use style::gecko_bindings::structs::{Loader, ServoStyleSheet, nsIURI};
use style::gecko_bindings::structs::ErrorReporter as GeckoErrorReporter;
use style::gecko_bindings::structs::URLExtraData as RawUrlExtraData;
use style::stylesheets::UrlExtraData;
-use style_traits::StyleParseErrorKind;
+use style_traits::{StyleParseErrorKind, ValueParseErrorKind};
pub type ErrorKind<'i> = ParseErrorKind<'i, StyleParseErrorKind<'i>>;
@@ -139,6 +139,9 @@ fn extract_error_params<'a>(err: ErrorKind<'a>) -> Option<ErrorParams<'a>> {
ParseErrorKind::Custom(
StyleParseErrorKind::ExpectedIdentifier(token)
+ ) |
+ ParseErrorKind::Custom(
+ StyleParseErrorKind::ValueError(ValueParseErrorKind::InvalidColor(token))
) => {
(Some(ErrorString::UnexpectedToken(token)), None)
}
@@ -198,7 +201,8 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
ContextualParseError::UnsupportedRule(s, err) |
ContextualParseError::UnsupportedViewportDescriptorDeclaration(s, err) |
ContextualParseError::UnsupportedCounterStyleDescriptorDeclaration(s, err) |
- ContextualParseError::InvalidMediaRule(s, err) => {
+ ContextualParseError::InvalidMediaRule(s, err) |
+ ContextualParseError::UnsupportedValue(s, err) => {
(s.into(), err.kind)
}
ContextualParseError::InvalidCounterStyleWithoutSymbols(s) |
@@ -360,6 +364,23 @@ impl<'a> ErrorHelpers<'a> for ContextualParseError<'a> {
ContextualParseError::UnsupportedFontFeatureValuesDescriptor(..) |
ContextualParseError::InvalidFontFeatureValuesRule(..) =>
(b"PEUnknownAtRule\0", Action::Skip),
+ ContextualParseError::UnsupportedValue(_, ParseError { ref kind, .. }) => {
+ match *kind {
+ ParseErrorKind::Custom(
+ StyleParseErrorKind::ValueError(
+ ValueParseErrorKind::InvalidColor(..)
+ )
+ ) => (b"PEColorNotColor", Action::Nothing),
+ _ => {
+ // Not the best error message, since we weren't parsing
+ // a declaration, just a value. But we don't produce
+ // UnsupportedValue errors other than InvalidColors
+ // currently.
+ debug_assert!(false, "should use a more specific error message");
+ (b"PEDeclDropped", Action::Nothing)
+ }
+ }
+ }
};
(None, msg, action)
}