mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #17655 - 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/17655) <!-- Reviewable:end -->
This commit is contained in:
commit
2ddbc92d90
37 changed files with 5836 additions and 4386 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"
|
||||
|
|
|
@ -219,9 +219,6 @@ pub struct LayoutThread {
|
|||
/// All the other elements of this struct are read-only.
|
||||
rw_data: Arc<Mutex<LayoutThreadData>>,
|
||||
|
||||
/// The CSS error reporter for all CSS loaded in this layout thread
|
||||
error_reporter: CSSErrorReporter,
|
||||
|
||||
webrender_image_cache: Arc<RwLock<FnvHashMap<(ServoUrl, UsePlaceholder),
|
||||
WebRenderImageInfo>>>,
|
||||
/// The executor for paint worklets.
|
||||
|
@ -532,10 +529,6 @@ impl LayoutThread {
|
|||
text_index_response: TextIndexResponse(None),
|
||||
nodes_from_point_response: vec![],
|
||||
})),
|
||||
error_reporter: CSSErrorReporter {
|
||||
pipelineid: id,
|
||||
script_chan: Arc::new(Mutex::new(script_chan)),
|
||||
},
|
||||
webrender_image_cache:
|
||||
Arc::new(RwLock::new(FnvHashMap::default())),
|
||||
timer:
|
||||
|
@ -580,7 +573,6 @@ impl LayoutThread {
|
|||
guards: guards,
|
||||
running_animations: self.running_animations.clone(),
|
||||
expired_animations: self.expired_animations.clone(),
|
||||
error_reporter: &self.error_reporter,
|
||||
local_context_creation_data: Mutex::new(thread_local_style_context_creation_data),
|
||||
timer: self.timer.clone(),
|
||||
quirks_mode: self.quirks_mode.unwrap(),
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -508,7 +508,6 @@ fn compute_style_for_animation_step(context: &SharedStyleContext,
|
|||
previous_style,
|
||||
/* cascade_info = */ None,
|
||||
/* visited_style = */ None,
|
||||
&*context.error_reporter,
|
||||
font_metrics_provider,
|
||||
CascadeFlags::empty(),
|
||||
context.quirks_mode);
|
||||
|
|
|
@ -12,7 +12,6 @@ use bloom::StyleBloom;
|
|||
use cache::LRUCache;
|
||||
use data::{EagerPseudoStyles, ElementData};
|
||||
use dom::{OpaqueNode, TNode, TElement, SendElement};
|
||||
use error_reporting::ParseErrorReporter;
|
||||
use euclid::Size2D;
|
||||
use fnv::FnvHashMap;
|
||||
use font_metrics::FontMetricsProvider;
|
||||
|
@ -122,9 +121,6 @@ pub struct SharedStyleContext<'a> {
|
|||
/// Guards for pre-acquired locks
|
||||
pub guards: StylesheetGuards<'a>,
|
||||
|
||||
///The CSS error reporter for all CSS loaded in this layout thread
|
||||
pub error_reporter: &'a ParseErrorReporter,
|
||||
|
||||
/// The current timer for transitions and animations. This is needed to test
|
||||
/// them.
|
||||
pub timer: Timer,
|
||||
|
|
|
@ -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"),
|
||||
|
@ -139,7 +139,7 @@ impl<'a> ContextualParseError<'a> {
|
|||
}
|
||||
|
||||
/// A generic trait for an error reporter.
|
||||
pub trait ParseErrorReporter : Sync {
|
||||
pub trait ParseErrorReporter {
|
||||
/// Called when the style engine detects an error.
|
||||
///
|
||||
/// Returns the current input being parsed, the source position it was
|
||||
|
@ -188,8 +188,3 @@ impl ParseErrorReporter for NullReporter {
|
|||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
/// Create an instance of the default error reporter.
|
||||
pub fn create_error_reporter() -> RustLogReporter {
|
||||
RustLogReporter
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -2262,7 +2264,8 @@ extern "C" {
|
|||
value: *const nsACString,
|
||||
data: *mut RawGeckoURLExtraData,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode: nsCompatibility)
|
||||
quirks_mode: nsCompatibility,
|
||||
loader: *mut Loader)
|
||||
-> RawServoDeclarationBlockStrong;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -2411,7 +2414,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" {
|
||||
|
@ -2480,8 +2484,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:
|
||||
|
@ -2493,7 +2497,8 @@ extern "C" {
|
|||
*mut RawGeckoURLExtraData,
|
||||
parsing_mode: ParsingMode,
|
||||
quirks_mode:
|
||||
nsCompatibility)
|
||||
nsCompatibility,
|
||||
loader: *mut Loader)
|
||||
-> bool;
|
||||
}
|
||||
extern "C" {
|
||||
|
@ -2891,3 +2896,23 @@ extern "C" {
|
|||
ServoComputedValuesBorrowedOrNull)
|
||||
-> *const nsStyleEffects;
|
||||
}
|
||||
extern "C" {
|
||||
pub fn Gecko_CreateCSSErrorReporter(sheet: *mut ServoStyleSheet,
|
||||
loader: *mut Loader, uri: *mut nsIURI)
|
||||
-> *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
|
@ -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 {
|
||||
|
|
|
@ -401,7 +401,6 @@ trait PrivateMatchMethods: TElement {
|
|||
layout_parent_style,
|
||||
visited_values_to_insert,
|
||||
Some(&mut cascade_info),
|
||||
&*shared_context.error_reporter,
|
||||
font_metrics_provider,
|
||||
cascade_flags,
|
||||
shared_context.quirks_mode));
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -314,8 +314,7 @@
|
|||
default_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
cacheable: &mut bool,
|
||||
cascade_info: &mut Option<<&mut CascadeInfo>,
|
||||
error_reporter: &ParseErrorReporter) {
|
||||
cascade_info: &mut Option<<&mut CascadeInfo>) {
|
||||
let declared_value = match *declaration {
|
||||
PropertyDeclaration::${property.camel_case}(ref value) => {
|
||||
DeclaredValue::Value(value)
|
||||
|
@ -424,15 +423,14 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}, error_reporter, quirks_mode);
|
||||
}, quirks_mode);
|
||||
}
|
||||
|
||||
% if property.custom_cascade:
|
||||
cascade_property_custom(declaration,
|
||||
inherited_style,
|
||||
context,
|
||||
cacheable,
|
||||
error_reporter);
|
||||
cacheable);
|
||||
% endif
|
||||
% else:
|
||||
// Do not allow stylesheets to set derived properties.
|
||||
|
|
|
@ -523,7 +523,6 @@ 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;
|
||||
use properties::LonghandId;
|
||||
use properties::DeclaredValue;
|
||||
|
||||
|
@ -587,7 +586,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:
|
||||
|
@ -612,7 +610,6 @@ impl AnimationValue {
|
|||
};
|
||||
result = AnimationValue::from_declaration(&declaration, context, initial);
|
||||
},
|
||||
&reporter,
|
||||
quirks_mode);
|
||||
result
|
||||
},
|
||||
|
|
|
@ -136,8 +136,7 @@
|
|||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||
_inherited_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
_cacheable: &mut bool,
|
||||
_error_reporter: &ParseErrorReporter) {
|
||||
_cacheable: &mut bool) {
|
||||
longhands::_servo_display_for_hypothetical_box::derive_from_display(context);
|
||||
longhands::_servo_text_decorations_in_effect::derive_from_display(context);
|
||||
longhands::_servo_under_display_none::derive_from_display(context);
|
||||
|
|
|
@ -261,8 +261,7 @@ ${helpers.single_keyword("unicode-bidi",
|
|||
fn cascade_property_custom(_declaration: &PropertyDeclaration,
|
||||
_inherited_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
_cacheable: &mut bool,
|
||||
_error_reporter: &ParseErrorReporter) {
|
||||
_cacheable: &mut bool) {
|
||||
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
|
||||
}
|
||||
% endif
|
||||
|
|
|
@ -21,10 +21,10 @@ use app_units::Au;
|
|||
#[cfg(feature = "servo")] use cssparser::RGBA;
|
||||
use cssparser::{Parser, TokenSerializationType, serialize_identifier};
|
||||
use cssparser::{ParserInput, CompactCowStr};
|
||||
use error_reporting::ParseErrorReporter;
|
||||
#[cfg(feature = "servo")] use euclid::SideOffsets2D;
|
||||
use computed_values;
|
||||
use context::QuirksMode;
|
||||
use error_reporting::NullReporter;
|
||||
use font_metrics::FontMetricsProvider;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::bindings;
|
||||
#[cfg(feature = "gecko")] use gecko_bindings::structs::{self, nsCSSPropertyID};
|
||||
|
@ -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;
|
||||
|
@ -377,7 +378,6 @@ impl PropertyDeclarationIdSet {
|
|||
% endif
|
||||
custom_properties: &Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
f: &mut F,
|
||||
error_reporter: &ParseErrorReporter,
|
||||
quirks_mode: QuirksMode)
|
||||
% if property.boxed:
|
||||
where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
|
||||
|
@ -392,7 +392,6 @@ impl PropertyDeclarationIdSet {
|
|||
with_variables.from_shorthand,
|
||||
custom_properties,
|
||||
f,
|
||||
error_reporter,
|
||||
quirks_mode);
|
||||
} else {
|
||||
f(value);
|
||||
|
@ -408,7 +407,6 @@ impl PropertyDeclarationIdSet {
|
|||
from_shorthand: Option<ShorthandId>,
|
||||
custom_properties: &Option<Arc<::custom_properties::CustomPropertiesMap>>,
|
||||
f: &mut F,
|
||||
error_reporter: &ParseErrorReporter,
|
||||
quirks_mode: QuirksMode)
|
||||
% if property.boxed:
|
||||
where F: FnMut(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
|
||||
|
@ -421,12 +419,10 @@ impl PropertyDeclarationIdSet {
|
|||
.ok()
|
||||
.and_then(|css| {
|
||||
// As of this writing, only the base URL is used for property values:
|
||||
//
|
||||
// FIXME(pcwalton): Cloning the error reporter is slow! But so are custom
|
||||
// properties, so whatever...
|
||||
let reporter = NullReporter;
|
||||
let context = ParserContext::new(Origin::Author,
|
||||
url_data,
|
||||
error_reporter,
|
||||
&reporter,
|
||||
None,
|
||||
PARSING_MODE_DEFAULT,
|
||||
quirks_mode);
|
||||
|
@ -1014,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()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1419,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));
|
||||
|
@ -1447,7 +1443,7 @@ impl PropertyDeclaration {
|
|||
declarations.push(value);
|
||||
Ok(())
|
||||
},
|
||||
Err(_) => Err(PropertyDeclarationParseError::InvalidValue),
|
||||
Err(_) => Err(PropertyDeclarationParseError::InvalidValue("${property.ident}".into())),
|
||||
}
|
||||
% else:
|
||||
Err(PropertyDeclarationParseError::UnknownProperty)
|
||||
|
@ -1487,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()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2514,8 +2510,7 @@ pub type CascadePropertyFn =
|
|||
default_style: &ComputedValues,
|
||||
context: &mut computed::Context,
|
||||
cacheable: &mut bool,
|
||||
cascade_info: &mut Option<<&mut CascadeInfo>,
|
||||
error_reporter: &ParseErrorReporter);
|
||||
cascade_info: &mut Option<<&mut CascadeInfo>);
|
||||
|
||||
/// A per-longhand array of functions to perform the CSS cascade on each of
|
||||
/// them, effectively doing virtual dispatch.
|
||||
|
@ -2577,7 +2572,6 @@ pub fn cascade(device: &Device,
|
|||
layout_parent_style: Option<<&ComputedValues>,
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
cascade_info: Option<<&mut CascadeInfo>,
|
||||
error_reporter: &ParseErrorReporter,
|
||||
font_metrics_provider: &FontMetricsProvider,
|
||||
flags: CascadeFlags,
|
||||
quirks_mode: QuirksMode)
|
||||
|
@ -2625,7 +2619,6 @@ pub fn cascade(device: &Device,
|
|||
layout_parent_style,
|
||||
visited_style,
|
||||
cascade_info,
|
||||
error_reporter,
|
||||
font_metrics_provider,
|
||||
flags,
|
||||
quirks_mode)
|
||||
|
@ -2641,7 +2634,6 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
|||
layout_parent_style: &ComputedValues,
|
||||
visited_style: Option<Arc<ComputedValues>>,
|
||||
mut cascade_info: Option<<&mut CascadeInfo>,
|
||||
error_reporter: &ParseErrorReporter,
|
||||
font_metrics_provider: &FontMetricsProvider,
|
||||
flags: CascadeFlags,
|
||||
quirks_mode: QuirksMode)
|
||||
|
@ -2795,8 +2787,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
|||
default_style,
|
||||
&mut context,
|
||||
&mut cacheable,
|
||||
&mut cascade_info,
|
||||
error_reporter);
|
||||
&mut cascade_info);
|
||||
}
|
||||
% if category_to_cascade_now == "early":
|
||||
let writing_mode = get_writing_mode(context.style.get_inheritedbox());
|
||||
|
@ -2869,8 +2860,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
|||
default_style,
|
||||
&mut context,
|
||||
&mut cacheable,
|
||||
&mut cascade_info,
|
||||
error_reporter);
|
||||
&mut cascade_info);
|
||||
% if product == "gecko":
|
||||
context.style.mutate_font().fixup_none_generic(context.device);
|
||||
% endif
|
||||
|
@ -2884,8 +2874,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
|||
default_style,
|
||||
&mut context,
|
||||
&mut cacheable,
|
||||
&mut cascade_info,
|
||||
error_reporter);
|
||||
&mut cascade_info);
|
||||
% if product == "gecko":
|
||||
// Font size must be explicitly inherited to handle lang changes and
|
||||
// scriptlevel changes.
|
||||
|
@ -2902,8 +2891,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
|||
default_style,
|
||||
&mut context,
|
||||
&mut cacheable,
|
||||
&mut cascade_info,
|
||||
error_reporter);
|
||||
&mut cascade_info);
|
||||
% endif
|
||||
}
|
||||
% endif
|
||||
|
|
|
@ -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,7 +10,6 @@ use bit_vec::BitVec;
|
|||
use context::{CascadeInputs, QuirksMode};
|
||||
use dom::TElement;
|
||||
use element_state::ElementState;
|
||||
use error_reporting::create_error_reporter;
|
||||
use font_metrics::FontMetricsProvider;
|
||||
#[cfg(feature = "gecko")]
|
||||
use gecko_bindings::structs::{nsIAtom, StyleRuleInclusion};
|
||||
|
@ -639,7 +638,6 @@ impl Stylist {
|
|||
parent.map(|p| &**p),
|
||||
None,
|
||||
None,
|
||||
&create_error_reporter(),
|
||||
font_metrics,
|
||||
cascade_flags,
|
||||
self.quirks_mode);
|
||||
|
@ -748,7 +746,6 @@ impl Stylist {
|
|||
Some(inherited_style),
|
||||
None,
|
||||
None,
|
||||
&create_error_reporter(),
|
||||
font_metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode);
|
||||
|
@ -780,7 +777,6 @@ impl Stylist {
|
|||
Some(parent_style),
|
||||
visited_values,
|
||||
None,
|
||||
&create_error_reporter(),
|
||||
font_metrics,
|
||||
CascadeFlags::empty(),
|
||||
self.quirks_mode);
|
||||
|
@ -1367,7 +1363,6 @@ impl Stylist {
|
|||
Some(parent_style),
|
||||
None,
|
||||
None,
|
||||
&create_error_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