style: Avoid cloning all over the error reporter.

This commit is contained in:
Emilio Cobos Álvarez 2017-03-14 00:12:38 +01:00
parent eaf27ccfa0
commit b4de69e3eb
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
36 changed files with 186 additions and 154 deletions

View file

@ -63,7 +63,7 @@ fn test_parse_stylesheet() {
let url = ServoUrl::parse("about::test").unwrap();
let stylesheet = Stylesheet::from_str(css, url.clone(), Origin::UserAgent, Default::default(),
None,
Box::new(CSSErrorReporterTest),
&CSSErrorReporterTest,
ParserContextExtraData::default());
let mut namespaces = Namespaces::default();
namespaces.default = Some(ns!(html));
@ -289,13 +289,15 @@ impl CSSInvalidErrorReporterTest {
}
impl ParseErrorReporter for CSSInvalidErrorReporterTest {
fn report_error(&self, input: &mut CssParser, position: SourcePosition, message: &str,
url: &ServoUrl) {
fn report_error(&self,
input: &mut CssParser,
position: SourcePosition,
message: &str,
url: &ServoUrl) {
let location = input.source_location(position);
let errors = self.errors.clone();
let mut errors = errors.lock().unwrap();
let mut errors = self.errors.lock().unwrap();
errors.push(
CSSError{
@ -306,14 +308,6 @@ impl ParseErrorReporter for CSSInvalidErrorReporterTest {
}
);
}
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
return Box::new(
CSSInvalidErrorReporterTest{
errors: self.errors.clone()
}
);
}
}
@ -327,13 +321,13 @@ fn test_report_error_stylesheet() {
}
";
let url = ServoUrl::parse("about::test").unwrap();
let error_reporter = Box::new(CSSInvalidErrorReporterTest::new());
let error_reporter = CSSInvalidErrorReporterTest::new();
let errors = error_reporter.errors.clone();
Stylesheet::from_str(css, url.clone(), Origin::UserAgent, Default::default(),
None,
error_reporter,
&error_reporter,
ParserContextExtraData::default());
let mut errors = errors.lock().unwrap();