aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Sapin <simon.sapin@exyr.org>2013-10-24 17:43:48 +0200
committerSimon Sapin <simon.sapin@exyr.org>2013-11-01 00:30:20 +0000
commitabb1bdefee24ff56c16e933190a9c113c6e20ba4 (patch)
tree1c211b126515076ca0696a6b5c60cd6de558cf14 /src
parent352acbb8335fcf78f2d62dc781fa9d86b9368f9c (diff)
downloadservo-abb1bdefee24ff56c16e933190a9c113c6e20ba4.tar.gz
servo-abb1bdefee24ff56c16e933190a9c113c6e20ba4.zip
Log CSS errors on stderr, with serialized bits of CSS.
Diffstat (limited to 'src')
-rw-r--r--src/components/style/errors.rs2
-rw-r--r--src/components/style/properties.rs.mako25
-rw-r--r--src/components/style/stylesheets.rs5
3 files changed, 23 insertions, 9 deletions
diff --git a/src/components/style/errors.rs b/src/components/style/errors.rs
index fdbf1c5167b..d899054393c 100644
--- a/src/components/style/errors.rs
+++ b/src/components/style/errors.rs
@@ -22,5 +22,5 @@ impl<T, I: Iterator<Result<T, SyntaxError>>> Iterator<T> for ErrorLoggerIterator
pub fn log_css_error(location: SourceLocation, message: &str) {
// TODO eventually this will got into a "web console" or something.
- info!("{:u}:{:u} {:s}", location.line, location.column, message)
+ error!("{:u}:{:u} {:s}", location.line, location.column, message)
}
diff --git a/src/components/style/properties.rs.mako b/src/components/style/properties.rs.mako
index 01bbb2f556f..8036a54e3f0 100644
--- a/src/components/style/properties.rs.mako
+++ b/src/components/style/properties.rs.mako
@@ -861,8 +861,12 @@ pub fn parse_property_declaration_list<I: Iterator<Node>>(input: I) -> PropertyD
Declaration(Declaration{ location: l, name: n, value: v, important: i}) => {
// TODO: only keep the last valid declaration for a given name.
let list = if i { &mut important } else { &mut normal };
- if !PropertyDeclaration::parse(n, v, list) {
- log_css_error(l, "Invalid property declaration")
+ match PropertyDeclaration::parse(n, v, list) {
+ UnknownProperty => log_css_error(l, format!(
+ "Unsupported property: {}:{}", n, v.iter().to_css())),
+ InvalidValue => log_css_error(l, format!(
+ "Invalid value: {}:{}", n, v.iter().to_css())),
+ ValidDeclaration => (),
}
}
}
@@ -909,15 +913,22 @@ pub enum PropertyDeclaration {
% endfor
}
+
+enum PropertyDeclarationParseResult {
+ UnknownProperty,
+ InvalidValue,
+ ValidDeclaration,
+}
+
impl PropertyDeclaration {
pub fn parse(name: &str, value: &[ComponentValue],
- result_list: &mut ~[PropertyDeclaration]) -> bool {
+ result_list: &mut ~[PropertyDeclaration]) -> PropertyDeclarationParseResult {
match name.to_ascii_lower().as_slice() {
% for property in LONGHANDS:
"${property.name}" => result_list.push(${property.ident}_declaration(
match longhands::${property.ident}::parse_declared(value) {
Some(value) => value,
- None => return false,
+ None => return InvalidValue,
}
)),
% endfor
@@ -949,13 +960,13 @@ impl PropertyDeclaration {
));
% endfor
},
- None => return false,
+ None => return InvalidValue,
}
},
% endfor
- _ => return false, // Unknown property
+ _ => return UnknownProperty,
}
- true
+ ValidDeclaration
}
}
diff --git a/src/components/style/stylesheets.rs b/src/components/style/stylesheets.rs
index 424d1c5b0d7..b97a9897d43 100644
--- a/src/components/style/stylesheets.rs
+++ b/src/components/style/stylesheets.rs
@@ -112,12 +112,15 @@ impl Stylesheet {
pub fn parse_style_rule(rule: QualifiedRule, parent_rules: &mut ~[CSSRule],
namespaces: &NamespaceMap) {
let QualifiedRule{location: location, prelude: prelude, block: block} = rule;
+ // FIXME: avoid doing this for valid selectors
+ let serialized = prelude.iter().to_css();
match selectors::parse_selector_list(prelude, namespaces) {
Some(selectors) => parent_rules.push(CSSStyleRule(StyleRule{
selectors: selectors,
declarations: properties::parse_property_declaration_list(block.move_iter())
})),
- None => log_css_error(location, "Unsupported CSS selector."),
+ None => log_css_error(location, format!(
+ "Invalid/unsupported selector: {}", serialized)),
}
}