Rename MemoryHoleReporter to NullReporter

This commit is contained in:
Simon Sapin 2017-04-24 07:56:50 +02:00
parent 733820583e
commit de1fe51dc6
3 changed files with 19 additions and 18 deletions

View file

@ -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
}
}

View file

@ -8,6 +8,7 @@
use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, RuleListParser}; use cssparser::{AtRuleParser, Parser, QualifiedRuleParser, RuleListParser};
use cssparser::{DeclarationListParser, DeclarationParser, parse_one_rule}; use cssparser::{DeclarationListParser, DeclarationParser, parse_one_rule};
use error_reporting::NullReporter;
use parser::{LengthParsingMode, ParserContext, log_css_error}; use parser::{LengthParsingMode, ParserContext, log_css_error};
use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, PropertyId}; use properties::{Importance, PropertyDeclaration, PropertyDeclarationBlock, PropertyId};
use properties::{PropertyDeclarationId, LonghandId, ParsedDeclaration}; use properties::{PropertyDeclarationId, LonghandId, ParsedDeclaration};
@ -18,7 +19,7 @@ use shared_lock::{SharedRwLock, SharedRwLockReadGuard, Locked, ToCssWithGuard};
use std::fmt; use std::fmt;
use std::sync::Arc; use std::sync::Arc;
use style_traits::ToCss; 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 /// A number from 0 to 1, indicating the percentage of the animation when this
/// keyframe should run. /// keyframe should run.
@ -125,7 +126,7 @@ impl Keyframe {
/// Parse a CSS keyframe. /// Parse a CSS keyframe.
pub fn parse(css: &str, parent_stylesheet: &Stylesheet) pub fn parse(css: &str, parent_stylesheet: &Stylesheet)
-> Result<Arc<Locked<Self>>, ()> { -> Result<Arc<Locked<Self>>, ()> {
let error_reporter = MemoryHoleReporter; let error_reporter = NullReporter;
let context = ParserContext::new(parent_stylesheet.origin, let context = ParserContext::new(parent_stylesheet.origin,
&parent_stylesheet.url_data, &parent_stylesheet.url_data,
&error_reporter, &error_reporter,

View file

@ -10,7 +10,7 @@ use {Atom, Prefix, Namespace};
use cssparser::{AtRuleParser, Parser, QualifiedRuleParser}; use cssparser::{AtRuleParser, Parser, QualifiedRuleParser};
use cssparser::{AtRuleType, RuleListParser, SourcePosition, Token, parse_one_rule}; use cssparser::{AtRuleType, RuleListParser, SourcePosition, Token, parse_one_rule};
use cssparser::ToCss as ParserToCss; use cssparser::ToCss as ParserToCss;
use error_reporting::ParseErrorReporter; use error_reporting::{ParseErrorReporter, NullReporter};
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
use font_face::FontFaceRuleData; use font_face::FontFaceRuleData;
use font_face::parse_font_face_block; use font_face::parse_font_face_block;
@ -321,20 +321,6 @@ pub enum CssRuleType {
Viewport = 15, 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)] #[allow(missing_docs)]
pub enum SingleRuleParseError { pub enum SingleRuleParseError {
Syntax, Syntax,
@ -418,7 +404,7 @@ impl CssRule {
state: Option<State>, state: Option<State>,
loader: Option<&StylesheetLoader>) loader: Option<&StylesheetLoader>)
-> Result<(Self, State), SingleRuleParseError> { -> Result<(Self, State), SingleRuleParseError> {
let error_reporter = MemoryHoleReporter; let error_reporter = NullReporter;
let mut namespaces = parent_stylesheet.namespaces.write(); let mut namespaces = parent_stylesheet.namespaces.write();
let context = ParserContext::new(parent_stylesheet.origin, let context = ParserContext::new(parent_stylesheet.origin,
&parent_stylesheet.url_data, &parent_stylesheet.url_data,