diff --git a/components/style/error_reporting.rs b/components/style/error_reporting.rs index fb41a777e31..9ad89a54cc5 100644 --- a/components/style/error_reporting.rs +++ b/components/style/error_reporting.rs @@ -42,3 +42,17 @@ impl ParseErrorReporter for StdoutErrorReporter { } } } + +/// Error reporter which silently forgets errors +pub struct NullReporter; + +impl ParseErrorReporter for NullReporter { + fn report_error(&self, + _: &mut Parser, + _: SourcePosition, + _: &str, + _: &UrlExtraData, + _: u64) { + // do nothing + } +} diff --git a/components/style/keyframes.rs b/components/style/keyframes.rs index 542481b287c..d7e3485fc7d 100644 --- a/components/style/keyframes.rs +++ b/components/style/keyframes.rs @@ -8,6 +8,7 @@ use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, RuleListParser}; use cssparser::{DeclarationListParser, DeclarationParser, parse_one_rule}; +use error_reporting::NullReporter; use parser::{LengthParsingMode, ParserContext, log_css_error}; use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, PropertyId}; use properties::{PropertyDeclarationId, LonghandId, ParsedDeclaration}; @@ -18,7 +19,7 @@ use shared_lock::{SharedRwLock, SharedRwLockReadGuard, Locked, ToCssWithGuard}; use std::fmt; use std::sync::Arc; use style_traits::ToCss; -use stylesheets::{CssRuleType, MemoryHoleReporter, Stylesheet, VendorPrefix}; +use stylesheets::{CssRuleType, Stylesheet, VendorPrefix}; /// A number from 0 to 1, indicating the percentage of the animation when this /// keyframe should run. @@ -125,7 +126,7 @@ impl Keyframe { /// Parse a CSS keyframe. pub fn parse(css: &str, parent_stylesheet: &Stylesheet) -> Result>, ()> { - let error_reporter = MemoryHoleReporter; + let error_reporter = NullReporter; let context = ParserContext::new(parent_stylesheet.origin, &parent_stylesheet.url_data, &error_reporter, diff --git a/components/style/stylesheets.rs b/components/style/stylesheets.rs index 8d2c59744b5..bb08dd247d1 100644 --- a/components/style/stylesheets.rs +++ b/components/style/stylesheets.rs @@ -10,7 +10,7 @@ use {Atom, Prefix, Namespace}; use cssparser::{AtRuleParser, Parser, QualifiedRuleParser}; use cssparser::{AtRuleType, RuleListParser, SourcePosition, Token, parse_one_rule}; use cssparser::ToCss as ParserToCss; -use error_reporting::ParseErrorReporter; +use error_reporting::{ParseErrorReporter, NullReporter}; #[cfg(feature = "servo")] use font_face::FontFaceRuleData; use font_face::parse_font_face_block; @@ -321,20 +321,6 @@ pub enum CssRuleType { Viewport = 15, } -/// Error reporter which silently forgets errors -pub struct MemoryHoleReporter; - -impl ParseErrorReporter for MemoryHoleReporter { - fn report_error(&self, - _: &mut Parser, - _: SourcePosition, - _: &str, - _: &UrlExtraData, - _: u64) { - // do nothing - } -} - #[allow(missing_docs)] pub enum SingleRuleParseError { Syntax, @@ -418,7 +404,7 @@ impl CssRule { state: Option, loader: Option<&StylesheetLoader>) -> Result<(Self, State), SingleRuleParseError> { - let error_reporter = MemoryHoleReporter; + let error_reporter = NullReporter; let mut namespaces = parent_stylesheet.namespaces.write(); let context = ParserContext::new(parent_stylesheet.origin, &parent_stylesheet.url_data,