Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook up Stylo error reporter to Firefox devtools #17655

Merged
merged 2 commits into from Jul 11, 2017
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

stylo: Update rust-cssparser; extract more specific error types when …

…reporting (bug 1352669).
  • Loading branch information
jdm committed Jul 11, 2017
commit 0b43d0072ce8112b661daef2a9b52fc95143308c

Some generated files are not rendered by default. Learn more.

@@ -12,7 +12,7 @@ path = "lib.rs"
[dependencies]
azure = {git = "https://github.com/servo/rust-azure"}
canvas_traits = {path = "../canvas_traits"}
cssparser = "0.16.1"
cssparser = "0.17.0"
euclid = "0.15"
gleam = "0.4"
ipc-channel = "0.8"
@@ -10,7 +10,7 @@ name = "canvas_traits"
path = "lib.rs"

[dependencies]
cssparser = "0.16.1"
cssparser = "0.17.0"
euclid = "0.15"
heapsize = "0.4"
heapsize_derive = "0.1"
@@ -35,7 +35,7 @@ byteorder = "1.0"
canvas_traits = {path = "../canvas_traits"}
caseless = "0.1.0"
cookie = "0.6"
cssparser = "0.16.1"
cssparser = "0.17.0"
deny_public_fields = {path = "../deny_public_fields"}
devtools_traits = {path = "../devtools_traits"}
dom_struct = {path = "../dom_struct"}
@@ -13,7 +13,7 @@ path = "lib.rs"
app_units = "0.5"
atomic_refcell = "0.1"
canvas_traits = {path = "../canvas_traits"}
cssparser = "0.16.1"
cssparser = "0.17.0"
euclid = "0.15"
gfx_traits = {path = "../gfx_traits"}
heapsize = "0.4"
@@ -25,7 +25,7 @@ unstable = []
[dependencies]
bitflags = "0.7"
matches = "0.1"
cssparser = "0.16.1"
cssparser = "0.17.0"
log = "0.3"
fnv = "1.0"
phf = "0.7.18"
@@ -59,7 +59,7 @@ pub enum SelectorParseError<'i, T> {
PseudoElementExpectedIdent,
UnsupportedPseudoClass,
UnexpectedIdent(CompactCowStr<'i>),
ExpectedNamespace,
ExpectedNamespace(CompactCowStr<'i>),
Custom(T),
}

@@ -1105,9 +1105,10 @@ fn parse_qualified_name<'i, 't, P, E, Impl>
let position = input.position();
match input.next_including_whitespace() {
Ok(Token::Delim('|')) => {
let prefix = from_cow_str(value.into());
let prefix = from_cow_str(value.clone().into());
let result = parser.namespace_for_prefix(&prefix);
let url = result.ok_or(ParseError::Custom(SelectorParseError::ExpectedNamespace))?;
let url = result.ok_or(ParseError::Custom(
SelectorParseError::ExpectedNamespace(value.into())))?;
explicit_namespace(input, QNamePrefix::ExplicitNamespace(prefix, url))
},
_ => {
@@ -38,7 +38,7 @@ bitflags = "0.7"
bit-vec = "0.4.3"
byteorder = "1.0"
cfg-if = "0.1.0"
cssparser = "0.16.1"
cssparser = "0.17.0"
encoding = {version = "0.2", optional = true}
euclid = "0.15"
fnv = "1.0"
@@ -280,10 +280,10 @@ fn parse_declaration_value_block<'i, 't>
}
token.serialization_type()
}
Token::BadUrl =>
return Err(StyleParseError::BadUrlInDeclarationValueBlock.into()),
Token::BadString =>
return Err(StyleParseError::BadStringInDeclarationValueBlock.into()),
Token::BadUrl(u) =>
return Err(StyleParseError::BadUrlInDeclarationValueBlock(u).into()),
Token::BadString(s) =>
return Err(StyleParseError::BadStringInDeclarationValueBlock(s).into()),
Token::CloseParenthesis =>
return Err(StyleParseError::UnbalancedCloseParenthesisInDeclarationValueBlock.into()),
Token::CloseSquareBracket =>
@@ -76,8 +76,8 @@ impl<'a> ContextualParseError<'a> {
Token::ParenthesisBlock => format!("parenthesis ("),
Token::SquareBracketBlock => format!("square bracket ["),
Token::CurlyBracketBlock => format!("curly bracket {{"),
Token::BadUrl => format!("bad url parse error"),
Token::BadString => format!("bad string parse error"),
Token::BadUrl(ref _u) => format!("bad url parse error"),
Token::BadString(ref _s) => format!("bad string parse error"),
Token::CloseParenthesis => format!("unmatched close parenthesis"),
Token::CloseSquareBracket => format!("unmatched close square bracket"),
Token::CloseCurlyBracket => format!("unmatched close curly bracket"),
@@ -88,11 +88,11 @@ impl<'a> ContextualParseError<'a> {
match *err {
CssParseError::Basic(BasicParseError::UnexpectedToken(ref t)) =>
format!("found unexpected {}", token_to_str(t)),
CssParseError::Basic(BasicParseError::ExpectedToken(ref t)) =>
format!("expected {}", token_to_str(t)),
CssParseError::Basic(BasicParseError::EndOfInput) =>
format!("unexpected end of input"),
CssParseError::Basic(BasicParseError::AtRuleInvalid) =>
CssParseError::Basic(BasicParseError::AtRuleInvalid(ref i)) =>
format!("@ rule invalid: {}", i),
CssParseError::Basic(BasicParseError::AtRuleBodyInvalid) =>
format!("@ rule invalid"),
CssParseError::Basic(BasicParseError::QualifiedRuleInvalid) =>
format!("qualified rule invalid"),
@@ -908,10 +908,17 @@ pub fn parse_one_declaration_into(declarations: &mut SourcePropertyDeclaration,
parsing_mode,
quirks_mode);
let mut input = ParserInput::new(input);
Parser::new(&mut input).parse_entirely(|parser| {
let mut parser = Parser::new(&mut input);
let start = parser.position();
parser.parse_entirely(|parser| {
PropertyDeclaration::parse_into(declarations, id, &context, parser)
.map_err(|e| e.into())
}).map_err(|_| ())
}).map_err(|err| {
let end = parser.position();
let error = ContextualParseError::UnsupportedPropertyDeclaration(
parser.slice(start..end), err);
log_css_error(&mut parser, start, error, &context);
})
}

/// A struct to parse property declarations.
@@ -37,7 +37,8 @@ use properties::animated_properties::AnimatableLonghand;
use selectors::parser::SelectorParseError;
#[cfg(feature = "servo")] use servo_config::prefs::PREFS;
use shared_lock::StylesheetGuards;
use style_traits::{PARSING_MODE_DEFAULT, HasViewportPercentage, ToCss, ParseError, PropertyDeclarationParseError};
use style_traits::{PARSING_MODE_DEFAULT, HasViewportPercentage, ToCss, ParseError};
use style_traits::{PropertyDeclarationParseError, StyleParseError};
use stylesheets::{CssRuleType, MallocSizeOf, MallocSizeOfFn, Origin, UrlExtraData};
#[cfg(feature = "servo")] use values::Either;
use values::generics::text::LineHeight;
@@ -1009,7 +1010,7 @@ impl PropertyId {
match static_id(&property_name) {
Some(&StaticId::Longhand(id)) => Ok(PropertyId::Longhand(id)),
Some(&StaticId::Shorthand(id)) => Ok(PropertyId::Shorthand(id)),
None => Err(SelectorParseError::UnexpectedIdent(property_name).into()),
None => Err(StyleParseError::UnknownProperty(property_name).into()),
}
}

@@ -1414,7 +1415,7 @@ impl PropertyDeclaration {
Ok(keyword) => DeclaredValueOwned::CSSWideKeyword(keyword),
Err(_) => match ::custom_properties::SpecifiedValue::parse(context, input) {
Ok(value) => DeclaredValueOwned::Value(value),
Err(_) => return Err(PropertyDeclarationParseError::InvalidValue),
Err(_) => return Err(PropertyDeclarationParseError::InvalidValue(name.to_string())),
}
};
declarations.push(PropertyDeclaration::Custom(name, value));
@@ -1442,7 +1443,7 @@ impl PropertyDeclaration {
declarations.push(value);
Ok(())
},
Err(_) => Err(PropertyDeclarationParseError::InvalidValue),
Err(_) => Err(PropertyDeclarationParseError::InvalidValue("${property.ident}".into())),
}
% else:
Err(PropertyDeclarationParseError::UnknownProperty)
@@ -1482,7 +1483,7 @@ impl PropertyDeclaration {
},
Err(_) => {
shorthands::${shorthand.ident}::parse_into(declarations, context, input)
.map_err(|_| PropertyDeclarationParseError::InvalidValue)
.map_err(|_| PropertyDeclarationParseError::InvalidValue("${shorthand.ident}".into()))
}
}
}
@@ -7,7 +7,7 @@
use {Namespace, Prefix};
use counter_style::{parse_counter_style_body, parse_counter_style_name};
use cssparser::{AtRuleParser, AtRuleType, Parser, QualifiedRuleParser, RuleListParser};
use cssparser::{CompactCowStr, SourceLocation};
use cssparser::{CompactCowStr, SourceLocation, BasicParseError};
use error_reporting::ContextualParseError;
use font_face::parse_font_face_block;
use media_queries::{parse_media_query_list, MediaList};
@@ -184,7 +184,13 @@ impl<'a, 'i> AtRuleParser<'i> for TopLevelRuleParser<'a> {
self.state = State::Namespaces;

let prefix_result = input.try(|input| input.expect_ident());
let url = Namespace::from(Cow::from(input.expect_url_or_string()?));
let maybe_namespace = match input.expect_url_or_string() {
Ok(url_or_string) => url_or_string,
Err(BasicParseError::UnexpectedToken(t)) =>
return Err(StyleParseError::UnexpectedTokenWithinNamespace(t).into()),
Err(e) => return Err(e.into()),
};
let url = Namespace::from(Cow::from(maybe_namespace));

let id = register_namespace(&url)
.map_err(|()| StyleParseError::UnspecifiedError)?;
@@ -509,7 +515,7 @@ fn get_location_with_offset(
offset: u64
) -> SourceLocation {
SourceLocation {
line: location.line + offset as u32 - 1,
line: location.line + offset as u32,
column: location.column,
}
}
@@ -16,7 +16,7 @@ gecko = []
[dependencies]
app_units = "0.5"
bitflags = "0.7"
cssparser = "0.16.1"
cssparser = "0.17.0"
euclid = "0.15"
heapsize = {version = "0.4", optional = true}
heapsize_derive = {version = "0.1", optional = true}
@@ -22,7 +22,7 @@ extern crate euclid;
extern crate selectors;
#[cfg(feature = "servo")] #[macro_use] extern crate serde;

use cssparser::CompactCowStr;
use cssparser::{CompactCowStr, Token};
use selectors::parser::SelectorParseError;

/// Opaque type stored in type-unsafe work queues for parallel layout.
@@ -81,9 +81,9 @@ pub type ParseError<'i> = cssparser::ParseError<'i, SelectorParseError<'i, Style
/// Errors that can be encountered while parsing CSS values.
pub enum StyleParseError<'i> {
/// A bad URL token in a DVB.
BadUrlInDeclarationValueBlock,
BadUrlInDeclarationValueBlock(CompactCowStr<'i>),
/// A bad string token in a DVB.
BadStringInDeclarationValueBlock,
BadStringInDeclarationValueBlock(CompactCowStr<'i>),
/// Unexpected closing parenthesis in a DVB.
UnbalancedCloseParenthesisInDeclarationValueBlock,
/// Unexpected closing bracket in a DVB.
@@ -110,17 +110,21 @@ pub enum StyleParseError<'i> {
UnsupportedAtRule(CompactCowStr<'i>),
/// A placeholder for many sources of errors that require more specific variants.
UnspecifiedError,
/// An unexpected token was found within a namespace rule.
UnexpectedTokenWithinNamespace(Token<'i>),
/// An unknown CSS property was encountered.
UnknownProperty(CompactCowStr<'i>),
}

/// The result of parsing a property declaration.
#[derive(Eq, PartialEq, Copy, Clone, Debug)]
#[derive(Eq, PartialEq, Clone, Debug)]
pub enum PropertyDeclarationParseError {
/// The property declaration was for an unknown property.
UnknownProperty,
/// The property declaration was for a disabled experimental property.
ExperimentalProperty,
/// The property declaration contained an invalid value.
InvalidValue,
InvalidValue(String),
/// The declaration contained an animation property, and we were parsing
/// this as a keyframe block (so that property should be ignored).
///
@@ -16,7 +16,7 @@ gecko_debug = ["style/gecko_debug"]

[dependencies]
atomic_refcell = "0.1"
cssparser = "0.16.1"
cssparser = "0.17.0"
env_logger = {version = "0.4", default-features = false} # disable `regex` to reduce code size
libc = "0.2"
log = {version = "0.3.5", features = ["release_max_level_info"]}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.