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

@ -11,7 +11,6 @@ use cssparser::{Parser, AtRuleParser, DeclarationParser, Delimiter};
use error_reporting::ParseErrorReporter;
use parser::{ParserContext, ParserContextExtraData, log_css_error};
use servo_url::ServoUrl;
use std::boxed::Box as StdBox;
use std::fmt;
use style_traits::ToCss;
use stylesheets::Origin;
@ -570,10 +569,13 @@ pub fn append_serialization<'a, W, I, N>(dest: &mut W,
/// shared between Servo and Gecko.
pub fn parse_style_attribute(input: &str,
base_url: &ServoUrl,
error_reporter: StdBox<ParseErrorReporter + Send>,
error_reporter: &ParseErrorReporter,
extra_data: ParserContextExtraData)
-> PropertyDeclarationBlock {
let context = ParserContext::new_with_extra_data(Origin::Author, base_url, error_reporter, extra_data);
let context = ParserContext::new_with_extra_data(Origin::Author,
base_url,
error_reporter,
extra_data);
parse_property_declaration_list(&context, &mut Parser::new(input))
}
@ -585,10 +587,13 @@ pub fn parse_style_attribute(input: &str,
pub fn parse_one_declaration(id: PropertyId,
input: &str,
base_url: &ServoUrl,
error_reporter: StdBox<ParseErrorReporter + Send>,
error_reporter: &ParseErrorReporter,
extra_data: ParserContextExtraData)
-> Result<ParsedDeclaration, ()> {
let context = ParserContext::new_with_extra_data(Origin::Author, base_url, error_reporter, extra_data);
let context = ParserContext::new_with_extra_data(Origin::Author,
base_url,
error_reporter,
extra_data);
Parser::new(input).parse_entirely(|parser| {
ParsedDeclaration::parse(id, &context, parser, false)
.map_err(|_| ())

View file

@ -233,7 +233,7 @@
context: &mut computed::Context,
cacheable: &mut bool,
cascade_info: &mut Option<<&mut CascadeInfo>,
error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
error_reporter: &ParseErrorReporter) {
let declared_value = match *declaration {
PropertyDeclaration::${property.camel_case}(ref declared_value) => {
declared_value

View file

@ -85,7 +85,7 @@
_inherited_style: &ComputedValues,
context: &mut computed::Context,
_cacheable: &mut bool,
_error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
_error_reporter: &ParseErrorReporter) {
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);

View file

@ -210,7 +210,7 @@ ${helpers.single_keyword("unicode-bidi",
_inherited_style: &ComputedValues,
context: &mut computed::Context,
_cacheable: &mut bool,
_error_reporter: &mut StdBox<ParseErrorReporter + Send>) {
_error_reporter: &ParseErrorReporter) {
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
}
% endif

View file

@ -11,7 +11,6 @@
<%namespace name="helpers" file="/helpers.mako.rs" />
use std::borrow::Cow;
use std::boxed::Box as StdBox;
use std::collections::HashSet;
use std::fmt;
use std::sync::Arc;
@ -288,7 +287,7 @@ impl PropertyDeclarationIdSet {
% endif
custom_properties: &Option<Arc<::custom_properties::ComputedValuesMap>>,
f: F,
error_reporter: &mut StdBox<ParseErrorReporter + Send>)
error_reporter: &ParseErrorReporter)
% if property.boxed:
where F: FnOnce(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
% else:
@ -322,7 +321,7 @@ impl PropertyDeclarationIdSet {
from_shorthand: Option<ShorthandId>,
custom_properties: &Option<Arc<::custom_properties::ComputedValuesMap>>,
f: F,
error_reporter: &mut StdBox<ParseErrorReporter + Send>,
error_reporter: &ParseErrorReporter,
extra_data: ParserContextExtraData)
% if property.boxed:
where F: FnOnce(&DeclaredValue<Box<longhands::${property.ident}::SpecifiedValue>>)
@ -338,7 +337,7 @@ impl PropertyDeclarationIdSet {
// FIXME(pcwalton): Cloning the error reporter is slow! But so are custom
// properties, so whatever...
let context = ParserContext::new_with_extra_data(
::stylesheets::Origin::Author, base_url, (*error_reporter).clone(),
::stylesheets::Origin::Author, base_url, error_reporter,
extra_data);
Parser::new(&css).parse_entirely(|input| {
match from_shorthand {
@ -1764,7 +1763,7 @@ pub type CascadePropertyFn =
context: &mut computed::Context,
cacheable: &mut bool,
cascade_info: &mut Option<<&mut CascadeInfo>,
error_reporter: &mut StdBox<ParseErrorReporter + Send>);
error_reporter: &ParseErrorReporter);
/// A per-longhand array of functions to perform the CSS cascade on each of
/// them, effectively doing virtual dispatch.
@ -1808,7 +1807,7 @@ pub fn cascade(device: &Device,
parent_style: Option<<&ComputedValues>,
layout_parent_style: Option<<&ComputedValues>,
cascade_info: Option<<&mut CascadeInfo>,
error_reporter: StdBox<ParseErrorReporter + Send>,
error_reporter: &ParseErrorReporter,
flags: CascadeFlags)
-> ComputedValues {
debug_assert_eq!(parent_style.is_some(), layout_parent_style.is_some());
@ -1863,7 +1862,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
inherited_style: &ComputedValues,
layout_parent_style: &ComputedValues,
mut cascade_info: Option<<&mut CascadeInfo>,
mut error_reporter: StdBox<ParseErrorReporter + Send>,
error_reporter: &ParseErrorReporter,
font_metrics_provider: Option<<&FontMetricsProvider>,
flags: CascadeFlags)
-> ComputedValues
@ -1991,7 +1990,7 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
&mut context,
&mut cacheable,
&mut cascade_info,
&mut error_reporter);
error_reporter);
}
% if category_to_cascade_now == "early":
let writing_mode = get_writing_mode(context.style.get_inheritedbox());