mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Auto merge of #17624 - jdm:stylo-error-reporter, r=emilio
Hook up Stylo error reporter to Firefox devtools Reviewed by @emilio in https://bugzilla.mozilla.org/show_bug.cgi?id=1352669. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] There are tests for these changes <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17624) <!-- Reviewable:end -->
This commit is contained in:
commit
585468da9a
30 changed files with 6011 additions and 4423 deletions
|
@ -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"
|
||||
|
|
|
@ -415,7 +415,8 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
|||
&style_pseudo,
|
||||
Some(data.styles.primary()),
|
||||
CascadeFlags::empty(),
|
||||
&ServoMetricsProvider)
|
||||
&ServoMetricsProvider,
|
||||
context.error_reporter)
|
||||
.clone()
|
||||
}
|
||||
PseudoElementCascadeType::Lazy => {
|
||||
|
@ -427,7 +428,8 @@ pub trait ThreadSafeLayoutElement: Clone + Copy + Sized + Debug +
|
|||
RuleInclusion::All,
|
||||
data.styles.primary(),
|
||||
/* is_probe = */ false,
|
||||
&ServoMetricsProvider)
|
||||
&ServoMetricsProvider,
|
||||
context.error_reporter)
|
||||
.unwrap()
|
||||
.clone()
|
||||
}
|
||||
|
|
|
@ -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 =>
|
||||
|
|
|
@ -8,6 +8,9 @@
|
|||
|
||||
use cssparser::{Parser, SourcePosition, BasicParseError, Token};
|
||||
use cssparser::ParseError as CssParseError;
|
||||
#[cfg(feature = "gecko")] use gecko::error_reporter::ErrorReporter;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::Loader;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::ServoStyleSheet;
|
||||
use log;
|
||||
use style_traits::ParseError;
|
||||
use stylesheets::UrlExtraData;
|
||||
|
@ -76,8 +79,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 +91,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"),
|
||||
|
@ -190,6 +193,15 @@ impl ParseErrorReporter for NullReporter {
|
|||
}
|
||||
|
||||
/// Create an instance of the default error reporter.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn create_error_reporter() -> RustLogReporter {
|
||||
RustLogReporter
|
||||
}
|
||||
|
||||
/// Create an instance of the default error reporter for Stylo.
|
||||
#[cfg(feature = "gecko")]
|
||||
pub fn create_error_reporter(sheet: *mut ServoStyleSheet,
|
||||
loader: *mut Loader)
|
||||
-> ErrorReporter {
|
||||
ErrorReporter::new(loader, sheet)
|
||||
}
|
||||
|
|
306
components/style/gecko/error_reporter.rs
Normal file
306
components/style/gecko/error_reporter.rs
Normal file
|
@ -0,0 +1,306 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Wrapper around Gecko's CSS error reporting mechanism.
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use cssparser::{Parser, SourcePosition, ParseError as CssParseError, Token, BasicParseError};
|
||||
use cssparser::CompactCowStr;
|
||||
use error_reporting::{ParseErrorReporter, ContextualParseError};
|
||||
use gecko_bindings::bindings::{Gecko_CreateCSSErrorReporter, Gecko_DestroyCSSErrorReporter};
|
||||
use gecko_bindings::bindings::Gecko_ReportUnexpectedCSSError;
|
||||
use gecko_bindings::structs::{Loader, ServoStyleSheet, nsIURI};
|
||||
use gecko_bindings::structs::ErrorReporter as GeckoErrorReporter;
|
||||
use selectors::parser::SelectorParseError;
|
||||
use style_traits::{ParseError, StyleParseError, PropertyDeclarationParseError};
|
||||
use stylesheets::UrlExtraData;
|
||||
|
||||
/// Wrapper around an instance of Gecko's CSS error reporter.
|
||||
pub struct ErrorReporter(*mut GeckoErrorReporter);
|
||||
unsafe impl Sync for ErrorReporter {}
|
||||
|
||||
impl ErrorReporter {
|
||||
/// Create a new instance of the Gecko error reporter.
|
||||
pub fn new(loader: *mut Loader,
|
||||
sheet: *mut ServoStyleSheet) -> ErrorReporter {
|
||||
unsafe {
|
||||
ErrorReporter(Gecko_CreateCSSErrorReporter(sheet, loader))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ErrorReporter {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
Gecko_DestroyCSSErrorReporter(self.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum ErrorString<'a> {
|
||||
Snippet(CompactCowStr<'a>),
|
||||
Ident(CompactCowStr<'a>),
|
||||
UnexpectedToken(Token<'a>),
|
||||
}
|
||||
|
||||
impl<'a> ErrorString<'a> {
|
||||
fn into_str(self) -> String {
|
||||
match self {
|
||||
ErrorString::Snippet(s) => s.into_owned(),
|
||||
ErrorString::Ident(i) => escape_css_ident(&i),
|
||||
ErrorString::UnexpectedToken(t) => token_to_str(t),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This is identical to the behaviour of cssparser::serialize_identifier, except that
|
||||
// it uses numerical escapes for a larger set of characters.
|
||||
fn escape_css_ident(ident: &str) -> String {
|
||||
// The relevant parts of the CSS grammar are:
|
||||
// ident ([-]?{nmstart}|[-][-]){nmchar}*
|
||||
// nmstart [_a-z]|{nonascii}|{escape}
|
||||
// nmchar [_a-z0-9-]|{nonascii}|{escape}
|
||||
// nonascii [^\0-\177]
|
||||
// escape {unicode}|\\[^\n\r\f0-9a-f]
|
||||
// unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
|
||||
// from http://www.w3.org/TR/CSS21/syndata.html#tokenization but
|
||||
// modified for idents by
|
||||
// http://dev.w3.org/csswg/cssom/#serialize-an-identifier and
|
||||
// http://dev.w3.org/csswg/css-syntax/#would-start-an-identifier
|
||||
if ident.is_empty() {
|
||||
return ident.into()
|
||||
}
|
||||
|
||||
let mut escaped = String::new();
|
||||
|
||||
// A leading dash does not need to be escaped as long as it is not the
|
||||
// *only* character in the identifier.
|
||||
let mut iter = ident.chars().peekable();
|
||||
if iter.peek() == Some(&'-') {
|
||||
if ident.len() == 1 {
|
||||
return "\\-".into();
|
||||
}
|
||||
|
||||
escaped.push('-');
|
||||
// Skip the first character.
|
||||
let _ = iter.next();
|
||||
}
|
||||
|
||||
// Escape a digit at the start (including after a dash),
|
||||
// numerically. If we didn't escape it numerically, it would get
|
||||
// interpreted as a numeric escape for the wrong character.
|
||||
if iter.peek().map_or(false, |&c| '0' <= c && c <= '9') {
|
||||
let ch = iter.next().unwrap();
|
||||
escaped.push_str(&format!("\\{:x} ", ch as u32));
|
||||
}
|
||||
|
||||
while let Some(ch) = iter.next() {
|
||||
if ch == '\0' {
|
||||
escaped.push_str("\u{FFFD}");
|
||||
} else if ch < (0x20 as char) || (0x7f as char <= ch && ch < (0xA0 as char)) {
|
||||
// Escape U+0000 through U+001F and U+007F through U+009F numerically.
|
||||
escaped.push_str(&format!("\\{:x} ", ch as u32));
|
||||
} else {
|
||||
// Escape ASCII non-identifier printables as a backslash plus
|
||||
// the character.
|
||||
if (ch < (0x7F as char)) &&
|
||||
ch != '_' && ch != '-' &&
|
||||
(ch < '0' || '9' < ch) &&
|
||||
(ch < 'A' || 'Z' < ch) &&
|
||||
(ch < 'a' || 'z' < ch)
|
||||
{
|
||||
escaped.push('\\');
|
||||
}
|
||||
escaped.push(ch);
|
||||
}
|
||||
}
|
||||
|
||||
escaped
|
||||
}
|
||||
|
||||
// This is identical to the behaviour of cssparser::CssStringWriter, except that
|
||||
// the characters between 0x7F and 0xA0 as numerically escaped as well.
|
||||
fn escape_css_string(s: &str) -> String {
|
||||
let mut escaped = String::new();
|
||||
for ch in s.chars() {
|
||||
if ch < ' ' || (ch >= (0x7F as char) && ch < (0xA0 as char)) {
|
||||
escaped.push_str(&format!("\\{:x} ", ch as u32));
|
||||
} else {
|
||||
if ch == '"' || ch == '\'' || ch == '\\' {
|
||||
// Escape backslash and quote characters symbolically.
|
||||
// It's not technically necessary to escape the quote
|
||||
// character that isn't being used to delimit the string,
|
||||
// but we do it anyway because that makes testing simpler.
|
||||
escaped.push('\\');
|
||||
}
|
||||
escaped.push(ch);
|
||||
}
|
||||
}
|
||||
escaped
|
||||
}
|
||||
|
||||
fn token_to_str<'a>(t: Token<'a>) -> String {
|
||||
match t {
|
||||
Token::Ident(i) => escape_css_ident(&i),
|
||||
Token::AtKeyword(kw) => format!("@{}", escape_css_ident(&kw)),
|
||||
Token::Hash(h) | Token::IDHash(h) => format!("#{}", escape_css_ident(&h)),
|
||||
Token::QuotedString(s) => format!("'{}'", escape_css_string(&s)),
|
||||
Token::UnquotedUrl(u) => format!("'{}'", escape_css_string(&u)),
|
||||
Token::Delim(d) => d.to_string(),
|
||||
Token::Number { int_value: Some(i), .. } => i.to_string(),
|
||||
Token::Number { value, .. } => value.to_string(),
|
||||
Token::Percentage { int_value: Some(i), .. } => i.to_string(),
|
||||
Token::Percentage { unit_value, .. } => unit_value.to_string(),
|
||||
Token::Dimension { int_value: Some(i), ref unit, .. } =>
|
||||
format!("{}{}", i.to_string(), escape_css_ident(&unit.to_string())),
|
||||
Token::Dimension { value, ref unit, .. } =>
|
||||
format!("{}{}", value.to_string(), escape_css_ident(&unit.to_string())),
|
||||
Token::WhiteSpace(_) => "whitespace".into(),
|
||||
Token::Comment(_) => "comment".into(),
|
||||
Token::Colon => ":".into(),
|
||||
Token::Semicolon => ";".into(),
|
||||
Token::Comma => ",".into(),
|
||||
Token::IncludeMatch => "~=".into(),
|
||||
Token::DashMatch => "|=".into(),
|
||||
Token::PrefixMatch => "^=".into(),
|
||||
Token::SuffixMatch => "$=".into(),
|
||||
Token::SubstringMatch => "*=".into(),
|
||||
Token::Column => "||".into(),
|
||||
Token::CDO => "<!--".into(),
|
||||
Token::CDC => "-->".into(),
|
||||
Token::Function(f) => format!("{}(", escape_css_ident(&f)),
|
||||
Token::ParenthesisBlock => "(".into(),
|
||||
Token::SquareBracketBlock => "[".into(),
|
||||
Token::CurlyBracketBlock => "{".into(),
|
||||
Token::BadUrl(url) => format!("url('{}", escape_css_string(&url)).into(),
|
||||
Token::BadString(s) => format!("'{}", escape_css_string(&s)).into(),
|
||||
Token::CloseParenthesis => "unmatched close parenthesis".into(),
|
||||
Token::CloseSquareBracket => "unmatched close square bracket".into(),
|
||||
Token::CloseCurlyBracket => "unmatched close curly bracket".into(),
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ContextualParseError<'a> {
|
||||
fn error_data(self) -> (CompactCowStr<'a>, ParseError<'a>) {
|
||||
match self {
|
||||
ContextualParseError::UnsupportedPropertyDeclaration(s, err) |
|
||||
ContextualParseError::UnsupportedFontFaceDescriptor(s, err) |
|
||||
ContextualParseError::InvalidKeyframeRule(s, err) |
|
||||
ContextualParseError::UnsupportedKeyframePropertyDeclaration(s, err) |
|
||||
ContextualParseError::InvalidRule(s, err) |
|
||||
ContextualParseError::UnsupportedRule(s, err) |
|
||||
ContextualParseError::UnsupportedViewportDescriptorDeclaration(s, err) |
|
||||
ContextualParseError::UnsupportedCounterStyleDescriptorDeclaration(s, err) =>
|
||||
(s.into(), err),
|
||||
ContextualParseError::InvalidCounterStyleWithoutSymbols(s) |
|
||||
ContextualParseError::InvalidCounterStyleNotEnoughSymbols(s) =>
|
||||
(s.into(), StyleParseError::UnspecifiedError.into()),
|
||||
ContextualParseError::InvalidCounterStyleWithoutAdditiveSymbols |
|
||||
ContextualParseError::InvalidCounterStyleExtendsWithSymbols |
|
||||
ContextualParseError::InvalidCounterStyleExtendsWithAdditiveSymbols =>
|
||||
("".into(), StyleParseError::UnspecifiedError.into())
|
||||
}
|
||||
}
|
||||
|
||||
fn error_param(self) -> ErrorString<'a> {
|
||||
match self.error_data() {
|
||||
(_, CssParseError::Basic(BasicParseError::UnexpectedToken(t))) =>
|
||||
ErrorString::UnexpectedToken(t),
|
||||
|
||||
(_, CssParseError::Basic(BasicParseError::AtRuleInvalid(i))) =>
|
||||
ErrorString::Snippet(format!("@{}", escape_css_ident(&i)).into()),
|
||||
|
||||
(_, CssParseError::Custom(SelectorParseError::Custom(
|
||||
StyleParseError::PropertyDeclaration(
|
||||
PropertyDeclarationParseError::InvalidValue(property))))) =>
|
||||
ErrorString::Snippet(property.into()),
|
||||
|
||||
(_, CssParseError::Custom(SelectorParseError::UnexpectedIdent(ident))) =>
|
||||
ErrorString::Ident(ident),
|
||||
|
||||
(_, CssParseError::Custom(SelectorParseError::ExpectedNamespace(namespace))) =>
|
||||
ErrorString::Ident(namespace),
|
||||
|
||||
(_, CssParseError::Custom(SelectorParseError::Custom(
|
||||
StyleParseError::UnknownProperty(property)))) =>
|
||||
ErrorString::Ident(property),
|
||||
|
||||
(_, CssParseError::Custom(SelectorParseError::Custom(
|
||||
StyleParseError::UnexpectedTokenWithinNamespace(token)))) =>
|
||||
ErrorString::UnexpectedToken(token),
|
||||
|
||||
(s, _) => ErrorString::Snippet(s)
|
||||
}
|
||||
}
|
||||
|
||||
fn to_gecko_message(&self) -> &'static [u8] {
|
||||
match *self {
|
||||
ContextualParseError::UnsupportedPropertyDeclaration(
|
||||
_, CssParseError::Basic(BasicParseError::UnexpectedToken(_))) |
|
||||
ContextualParseError::UnsupportedPropertyDeclaration(
|
||||
_, CssParseError::Basic(BasicParseError::AtRuleInvalid(_))) =>
|
||||
b"PEParseDeclarationDeclExpected\0",
|
||||
ContextualParseError::UnsupportedPropertyDeclaration(
|
||||
_, CssParseError::Custom(SelectorParseError::Custom(
|
||||
StyleParseError::PropertyDeclaration(
|
||||
PropertyDeclarationParseError::InvalidValue(_))))) =>
|
||||
b"PEValueParsingError\0",
|
||||
ContextualParseError::UnsupportedPropertyDeclaration(..) =>
|
||||
b"PEUnknownProperty\0",
|
||||
ContextualParseError::UnsupportedFontFaceDescriptor(..) =>
|
||||
b"PEUnknwnFontDesc\0",
|
||||
ContextualParseError::InvalidKeyframeRule(..) =>
|
||||
b"PEKeyframeBadName\0",
|
||||
ContextualParseError::UnsupportedKeyframePropertyDeclaration(..) =>
|
||||
b"PEBadSelectorKeyframeRuleIgnored\0",
|
||||
ContextualParseError::InvalidRule(
|
||||
_, CssParseError::Custom(SelectorParseError::ExpectedNamespace(_))) =>
|
||||
b"PEUnknownNamespacePrefix\0",
|
||||
ContextualParseError::InvalidRule(
|
||||
_, CssParseError::Custom(SelectorParseError::Custom(
|
||||
StyleParseError::UnexpectedTokenWithinNamespace(_)))) =>
|
||||
b"PEAtNSUnexpected\0",
|
||||
ContextualParseError::InvalidRule(..) =>
|
||||
b"PEBadSelectorRSIgnored\0",
|
||||
ContextualParseError::UnsupportedRule(..) =>
|
||||
b"PEDeclDropped\0",
|
||||
ContextualParseError::UnsupportedViewportDescriptorDeclaration(..) |
|
||||
ContextualParseError::UnsupportedCounterStyleDescriptorDeclaration(..) |
|
||||
ContextualParseError::InvalidCounterStyleWithoutSymbols(..) |
|
||||
ContextualParseError::InvalidCounterStyleNotEnoughSymbols(..) |
|
||||
ContextualParseError::InvalidCounterStyleWithoutAdditiveSymbols |
|
||||
ContextualParseError::InvalidCounterStyleExtendsWithSymbols |
|
||||
ContextualParseError::InvalidCounterStyleExtendsWithAdditiveSymbols =>
|
||||
b"PEUnknownAtRule\0",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ParseErrorReporter for ErrorReporter {
|
||||
fn report_error<'a>(&self,
|
||||
input: &mut Parser,
|
||||
position: SourcePosition,
|
||||
error: ContextualParseError<'a>,
|
||||
url: &UrlExtraData,
|
||||
line_number_offset: u64) {
|
||||
let location = input.source_location(position);
|
||||
let line_number = location.line + line_number_offset as u32;
|
||||
|
||||
let name = error.to_gecko_message();
|
||||
let param = error.error_param().into_str();
|
||||
let source = input.current_line();
|
||||
unsafe {
|
||||
Gecko_ReportUnexpectedCSSError(self.0,
|
||||
name.as_ptr() as *const _,
|
||||
param.as_ptr() as *const _,
|
||||
param.len() as u32,
|
||||
source.as_ptr() as *const _,
|
||||
source.len() as u32,
|
||||
line_number as u32,
|
||||
location.column as u32,
|
||||
url.mBaseURI.raw::<nsIURI>());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@ use gecko_bindings::structs::nsTArray;
|
|||
type nsACString_internal = nsACString;
|
||||
type nsAString_internal = nsAString;
|
||||
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
|
||||
use gecko_bindings::structs::mozilla::css::ErrorReporter;
|
||||
use gecko_bindings::structs::mozilla::css::ImageValue;
|
||||
use gecko_bindings::structs::mozilla::css::URLValue;
|
||||
use gecko_bindings::structs::mozilla::css::URLValueData;
|
||||
|
@ -71,6 +72,7 @@ use gecko_bindings::structs::nsChangeHint;
|
|||
use gecko_bindings::structs::nsCursorImage;
|
||||
use gecko_bindings::structs::nsFont;
|
||||
use gecko_bindings::structs::nsIAtom;
|
||||
use gecko_bindings::structs::nsIURI;
|
||||
use gecko_bindings::structs::nsCompatibility;
|
||||
use gecko_bindings::structs::nsMediaFeature;
|
||||
use gecko_bindings::structs::nsRestyleHint;
|
||||
|
@ -591,6 +593,10 @@ extern "C" {
|
|||
pub fn Gecko_GetDocumentLWTheme(aDocument: *const nsIDocument)
|
||||
-> nsIDocument_DocumentTheme;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_GetDocumentLoader(aPresCtx: RawGeckoPresContextBorrowed)
|
||||
-> *mut Loader;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_AtomAttrValue(element: RawGeckoElementBorrowed,
|
||||
attribute: *mut nsIAtom) -> *mut nsIAtom;
|
||||
|
@ -1956,7 +1962,8 @@ extern "C" {
|
|||
parent_style:
|
||||
ServoComputedValuesBorrowedOrNull,
|
||||
declarations:
|
||||
RawServoDeclarationBlockBorrowed)
|
||||
RawServoDeclarationBlockBorrowed,
|
||||
loader: *mut Loader)
|
||||
-> ServoComputedValuesStrong;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -2161,6 +2168,16 @@ extern "C" {
|
|||
pub fn Servo_StyleRule_GetSelectorCount(rule: RawServoStyleRuleBorrowed,
|
||||
count: *mut u32);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_StyleRule_SelectorMatchesElement(arg1:
|
||||
RawServoStyleRuleBorrowed,
|
||||
arg2:
|
||||
RawGeckoElementBorrowed,
|
||||
index: u32,
|
||||
pseudo_type:
|
||||
CSSPseudoElementType)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed,
|
||||
result: *mut nsAString);
|
||||
|
@ -2254,7 +2271,8 @@ extern "C" {
|
|||
value: *const nsACString,
|
||||
data: *mut RawGeckoURLExtraData,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: nsCompatibility)
|
||||
quirks_mode: nsCompatibility,
|
||||
loader: *mut Loader)
|
||||
-> RawServoDeclarationBlockStrong;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -2403,7 +2421,8 @@ extern "C" {
|
|||
extern "C" {
|
||||
pub fn Servo_ParseStyleAttribute(data: *const nsACString,
|
||||
extra_data: *mut RawGeckoURLExtraData,
|
||||
quirks_mode: nsCompatibility)
|
||||
quirks_mode: nsCompatibility,
|
||||
loader: *mut Loader)
|
||||
-> RawServoDeclarationBlockStrong;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -2472,8 +2491,8 @@ extern "C" {
|
|||
is_important: bool,
|
||||
data: *mut RawGeckoURLExtraData,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: nsCompatibility)
|
||||
-> bool;
|
||||
quirks_mode: nsCompatibility,
|
||||
loader: *mut Loader) -> bool;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Servo_DeclarationBlock_SetPropertyById(declarations:
|
||||
|
@ -2485,7 +2504,8 @@ extern "C" {
|
|||
*mut RawGeckoURLExtraData,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode:
|
||||
nsCompatibility)
|
||||
nsCompatibility,
|
||||
loader: *mut Loader)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -2882,3 +2902,23 @@ extern "C" {
|
|||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleEffects;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CreateCSSErrorReporter(sheet: *mut ServoStyleSheet,
|
||||
loader: *mut Loader)
|
||||
-> *mut ErrorReporter;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_DestroyCSSErrorReporter(reporter: *mut ErrorReporter);
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_ReportUnexpectedCSSError(reporter: *mut ErrorReporter,
|
||||
message:
|
||||
*const ::std::os::raw::c_char,
|
||||
param:
|
||||
*const ::std::os::raw::c_char,
|
||||
paramLen: u32,
|
||||
source:
|
||||
*const ::std::os::raw::c_char,
|
||||
sourceLen: u32, lineNumber: u32,
|
||||
colNumber: u32, aURI: *mut nsIURI);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -10,6 +10,7 @@ mod non_ts_pseudo_class_list;
|
|||
pub mod arc_types;
|
||||
pub mod conversions;
|
||||
pub mod data;
|
||||
pub mod error_reporter;
|
||||
pub mod global_style_data;
|
||||
pub mod media_queries;
|
||||
pub mod pseudo_element;
|
||||
|
|
|
@ -23,7 +23,7 @@ use data::ElementData;
|
|||
use dom::{self, DescendantsBit, LayoutIterator, NodeInfo, TElement, TNode, UnsafeNode};
|
||||
use dom::{OpaqueNode, PresentationalHintsSynthesizer};
|
||||
use element_state::{ElementState, DocumentState, NS_DOCUMENT_STATE_WINDOW_INACTIVE};
|
||||
use error_reporting::create_error_reporter;
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
|
||||
use gecko::data::PerDocumentStyleData;
|
||||
use gecko::global_style_data::GLOBAL_STYLE_DATA;
|
||||
|
@ -478,8 +478,9 @@ impl<'le> GeckoElement<'le> {
|
|||
/// Parse the style attribute of an element.
|
||||
pub fn parse_style_attribute(value: &str,
|
||||
url_data: &UrlExtraData,
|
||||
quirks_mode: QuirksMode) -> PropertyDeclarationBlock {
|
||||
parse_style_attribute(value, url_data, &create_error_reporter(), quirks_mode)
|
||||
quirks_mode: QuirksMode,
|
||||
reporter: &ParseErrorReporter) -> PropertyDeclarationBlock {
|
||||
parse_style_attribute(value, url_data, reporter, quirks_mode)
|
||||
}
|
||||
|
||||
fn flags(&self) -> u32 {
|
||||
|
|
|
@ -111,16 +111,19 @@ pub struct AnimationValueIterator<'a, 'cx, 'cx_a:'cx> {
|
|||
iter: Iter<'a, (PropertyDeclaration, Importance)>,
|
||||
context: &'cx mut Context<'cx_a>,
|
||||
default_values: &'a Arc<ComputedValues>,
|
||||
reporter: &'a ParseErrorReporter,
|
||||
}
|
||||
|
||||
impl<'a, 'cx, 'cx_a:'cx> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
fn new(declarations: &'a PropertyDeclarationBlock,
|
||||
context: &'cx mut Context<'cx_a>,
|
||||
default_values: &'a Arc<ComputedValues>) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
default_values: &'a Arc<ComputedValues>,
|
||||
reporter: &'a ParseErrorReporter) -> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
AnimationValueIterator {
|
||||
iter: declarations.declarations().iter(),
|
||||
context: context,
|
||||
default_values: default_values,
|
||||
reporter: reporter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +141,8 @@ impl<'a, 'cx, 'cx_a:'cx> Iterator for AnimationValueIterator<'a, 'cx, 'cx_a> {
|
|||
if importance == Importance::Normal {
|
||||
let property = AnimatableLonghand::from_declaration(decl);
|
||||
let animation = AnimationValue::from_declaration(decl, &mut self.context,
|
||||
self.default_values);
|
||||
self.default_values,
|
||||
self.reporter);
|
||||
debug_assert!(property.is_none() == animation.is_none(),
|
||||
"The failure condition of AnimatableLonghand::from_declaration \
|
||||
and AnimationValue::from_declaration should be the same");
|
||||
|
@ -204,9 +208,10 @@ impl PropertyDeclarationBlock {
|
|||
/// Return an iterator of (AnimatableLonghand, AnimationValue).
|
||||
pub fn to_animation_value_iter<'a, 'cx, 'cx_a:'cx>(&'a self,
|
||||
context: &'cx mut Context<'cx_a>,
|
||||
default_values: &'a Arc<ComputedValues>)
|
||||
default_values: &'a Arc<ComputedValues>,
|
||||
reporter: &'a ParseErrorReporter)
|
||||
-> AnimationValueIterator<'a, 'cx, 'cx_a> {
|
||||
AnimationValueIterator::new(self, context, default_values)
|
||||
AnimationValueIterator::new(self, context, default_values, reporter)
|
||||
}
|
||||
|
||||
/// Returns whether this block contains any declaration with `!important`.
|
||||
|
@ -908,10 +913,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.
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
use app_units::Au;
|
||||
use cssparser::{Parser, RGBA};
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use euclid::{Point2D, Size2D};
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::bindings::RawServoAnimationValueMap;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::RawGeckoGfxMatrix4x4;
|
||||
|
@ -522,8 +523,8 @@ impl AnimationValue {
|
|||
|
||||
/// Construct an AnimationValue from a property declaration
|
||||
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
|
||||
initial: &ComputedValues) -> Option<Self> {
|
||||
use error_reporting::create_error_reporter;
|
||||
initial: &ComputedValues,
|
||||
reporter: &ParseErrorReporter) -> Option<Self> {
|
||||
use properties::LonghandId;
|
||||
use properties::DeclaredValue;
|
||||
|
||||
|
@ -587,7 +588,6 @@ impl AnimationValue {
|
|||
},
|
||||
PropertyDeclaration::WithVariables(id, ref variables) => {
|
||||
let custom_props = context.style().custom_properties();
|
||||
let reporter = create_error_reporter();
|
||||
match id {
|
||||
% for prop in data.longhands:
|
||||
% if prop.animatable:
|
||||
|
@ -610,9 +610,13 @@ impl AnimationValue {
|
|||
},
|
||||
DeclaredValue::WithVariables(_) => unreachable!(),
|
||||
};
|
||||
result = AnimationValue::from_declaration(&declaration, context, initial);
|
||||
result = AnimationValue::from_declaration(
|
||||
&declaration,
|
||||
context,
|
||||
initial,
|
||||
reporter);
|
||||
},
|
||||
&reporter,
|
||||
reporter,
|
||||
quirks_mode);
|
||||
result
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
|
@ -1014,7 +1015,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()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1419,7 +1420,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));
|
||||
|
@ -1447,7 +1448,7 @@ impl PropertyDeclaration {
|
|||
declarations.push(value);
|
||||
Ok(())
|
||||
},
|
||||
Err(_) => Err(PropertyDeclarationParseError::InvalidValue),
|
||||
Err(_) => Err(PropertyDeclarationParseError::InvalidValue("${property.ident}".into())),
|
||||
}
|
||||
% else:
|
||||
Err(PropertyDeclarationParseError::UnknownProperty)
|
||||
|
@ -1487,7 +1488,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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ use bit_vec::BitVec;
|
|||
use context::{CascadeInputs, QuirksMode};
|
||||
use dom::TElement;
|
||||
use element_state::ElementState;
|
||||
use error_reporting::ParseErrorReporter;
|
||||
#[cfg(feature = "servo")]
|
||||
use error_reporting::create_error_reporter;
|
||||
use font_metrics::FontMetricsProvider;
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -597,12 +599,15 @@ impl Stylist {
|
|||
/// parent; otherwise, non-inherited properties are reset to their initial
|
||||
/// values. The flow constructor uses this flag when constructing anonymous
|
||||
/// flows.
|
||||
///
|
||||
/// The error reporter is only needed when processing custom variables.
|
||||
pub fn precomputed_values_for_pseudo(&self,
|
||||
guards: &StylesheetGuards,
|
||||
pseudo: &PseudoElement,
|
||||
parent: Option<&Arc<ComputedValues>>,
|
||||
cascade_flags: CascadeFlags,
|
||||
font_metrics: &FontMetricsProvider)
|
||||
font_metrics: &FontMetricsProvider,
|
||||
reporter: &ParseErrorReporter)
|
||||
-> Arc<ComputedValues> {
|
||||
debug_assert!(pseudo.is_precomputed());
|
||||
|
||||
|
@ -639,7 +644,7 @@ impl Stylist {
|
|||
parent.map(|p| &**p),
|
||||
None,
|
||||
None,
|
||||
&create_error_reporter(),
|
||||
reporter,
|
||||
font_metrics,
|
||||
cascade_flags,
|
||||
self.quirks_mode);
|
||||
|
@ -680,7 +685,7 @@ impl Stylist {
|
|||
cascade_flags.insert(INHERIT_ALL);
|
||||
}
|
||||
self.precomputed_values_for_pseudo(guards, &pseudo, Some(parent_style), cascade_flags,
|
||||
&ServoMetricsProvider)
|
||||
&ServoMetricsProvider, &create_error_reporter())
|
||||
}
|
||||
|
||||
/// Computes a pseudo-element style lazily during layout.
|
||||
|
@ -690,6 +695,8 @@ impl Stylist {
|
|||
///
|
||||
/// Check the documentation on lazy pseudo-elements in
|
||||
/// docs/components/style.md
|
||||
///
|
||||
/// The error reporter is only required for processing custom variables.
|
||||
pub fn lazily_compute_pseudo_element_style<E>(&self,
|
||||
guards: &StylesheetGuards,
|
||||
element: &E,
|
||||
|
@ -697,7 +704,8 @@ impl Stylist {
|
|||
rule_inclusion: RuleInclusion,
|
||||
parent_style: &Arc<ComputedValues>,
|
||||
is_probe: bool,
|
||||
font_metrics: &FontMetricsProvider)
|
||||
font_metrics: &FontMetricsProvider,
|
||||
reporter: &ParseErrorReporter)
|
||||
-> Option<Arc<ComputedValues>>
|
||||
where E: TElement,
|
||||
{
|
||||
|
@ -706,18 +714,22 @@ impl Stylist {
|
|||
self.compute_pseudo_element_style_with_inputs(&cascade_inputs,
|
||||
guards,
|
||||
parent_style,
|
||||
font_metrics)
|
||||
font_metrics,
|
||||
reporter)
|
||||
}
|
||||
|
||||
/// Computes a pseudo-element style lazily using the given CascadeInputs.
|
||||
/// This can be used for truly lazy pseudo-elements or to avoid redoing
|
||||
/// selector matching for eager pseudo-elements when we need to recompute
|
||||
/// their style with a new parent style.
|
||||
///
|
||||
/// The error reporter is only required for processing custom variables.
|
||||
pub fn compute_pseudo_element_style_with_inputs(&self,
|
||||
inputs: &CascadeInputs,
|
||||
guards: &StylesheetGuards,
|
||||
parent_style: &Arc<ComputedValues>,
|
||||
font_metrics: &FontMetricsProvider)
|
||||
font_metrics: &FontMetricsProvider,
|
||||
reporter: &ParseErrorReporter)
|
||||
-> Option<Arc<ComputedValues>>
|
||||
{
|
||||
// We may have only visited rules in cases when we are actually
|
||||
|
@ -748,7 +760,7 @@ impl Stylist {
|
|||
Some(inherited_style),
|
||||
None,
|
||||
None,
|
||||
&create_error_reporter(),
|
||||
reporter,
|
||||
font_metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode);
|
||||
|
@ -780,7 +792,7 @@ impl Stylist {
|
|||
Some(parent_style),
|
||||
visited_values,
|
||||
None,
|
||||
&create_error_reporter(),
|
||||
reporter,
|
||||
font_metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode);
|
||||
|
@ -1342,10 +1354,12 @@ impl Stylist {
|
|||
}
|
||||
|
||||
/// Computes styles for a given declaration with parent_style.
|
||||
/// The error reporter is only used for processing custom variables.
|
||||
pub fn compute_for_declarations(&self,
|
||||
guards: &StylesheetGuards,
|
||||
parent_style: &Arc<ComputedValues>,
|
||||
declarations: Arc<Locked<PropertyDeclarationBlock>>)
|
||||
declarations: Arc<Locked<PropertyDeclarationBlock>>,
|
||||
reporter: &ParseErrorReporter)
|
||||
-> Arc<ComputedValues> {
|
||||
use font_metrics::get_metrics_provider_for_product;
|
||||
|
||||
|
@ -1367,7 +1381,7 @@ impl Stylist {
|
|||
Some(parent_style),
|
||||
None,
|
||||
None,
|
||||
&create_error_reporter(),
|
||||
reporter,
|
||||
&metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode))
|
||||
|
|
|
@ -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).
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue