mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
style: Avoid cloning all over the error reporter.
This commit is contained in:
parent
eaf27ccfa0
commit
b4de69e3eb
36 changed files with 186 additions and 154 deletions
|
@ -12,7 +12,7 @@ use error_reporting::ParseErrorReporter;
|
|||
use gecko_bindings::sugar::refptr::{GeckoArcPrincipal, GeckoArcURI};
|
||||
use servo_url::ServoUrl;
|
||||
use style_traits::OneOrMoreCommaSeparated;
|
||||
use stylesheets::{MemoryHoleReporter, Origin};
|
||||
use stylesheets::Origin;
|
||||
|
||||
/// Extra data that the style backend may need to parse stylesheets.
|
||||
#[cfg(not(feature = "gecko"))]
|
||||
|
@ -67,7 +67,7 @@ pub struct ParserContext<'a> {
|
|||
/// The base url we're parsing this stylesheet as.
|
||||
pub base_url: &'a ServoUrl,
|
||||
/// An error reporter to report syntax errors.
|
||||
pub error_reporter: Box<ParseErrorReporter + Send>,
|
||||
pub error_reporter: &'a ParseErrorReporter,
|
||||
/// Implementation-dependent extra data.
|
||||
pub extra_data: ParserContextExtraData,
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ impl<'a> ParserContext<'a> {
|
|||
/// Create a `ParserContext` with extra data.
|
||||
pub fn new_with_extra_data(stylesheet_origin: Origin,
|
||||
base_url: &'a ServoUrl,
|
||||
error_reporter: Box<ParseErrorReporter + Send>,
|
||||
error_reporter: &'a ParseErrorReporter,
|
||||
extra_data: ParserContextExtraData)
|
||||
-> ParserContext<'a> {
|
||||
ParserContext {
|
||||
|
@ -90,22 +90,27 @@ impl<'a> ParserContext<'a> {
|
|||
/// Create a parser context with the default extra data.
|
||||
pub fn new(stylesheet_origin: Origin,
|
||||
base_url: &'a ServoUrl,
|
||||
error_reporter: Box<ParseErrorReporter + Send>)
|
||||
error_reporter: &'a ParseErrorReporter)
|
||||
-> ParserContext<'a> {
|
||||
let extra_data = ParserContextExtraData::default();
|
||||
Self::new_with_extra_data(stylesheet_origin, base_url, error_reporter, extra_data)
|
||||
}
|
||||
|
||||
/// Create a parser context for on-the-fly parsing in CSSOM
|
||||
pub fn new_for_cssom(base_url: &'a ServoUrl) -> ParserContext<'a> {
|
||||
Self::new(Origin::User, base_url, Box::new(MemoryHoleReporter))
|
||||
pub fn new_for_cssom(base_url: &'a ServoUrl,
|
||||
error_reporter: &'a ParseErrorReporter)
|
||||
-> ParserContext<'a> {
|
||||
Self::new(Origin::User, base_url, error_reporter)
|
||||
}
|
||||
}
|
||||
|
||||
/// Defaults to a no-op.
|
||||
/// Set a `RUST_LOG=style::errors` environment variable
|
||||
/// to log CSS parse errors to stderr.
|
||||
pub fn log_css_error(input: &mut Parser, position: SourcePosition, message: &str, parsercontext: &ParserContext) {
|
||||
pub fn log_css_error(input: &mut Parser,
|
||||
position: SourcePosition,
|
||||
message: &str,
|
||||
parsercontext: &ParserContext) {
|
||||
let servo_url = parsercontext.base_url;
|
||||
parsercontext.error_reporter.report_error(input, position, message, servo_url);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue