Encapsulate CSS error reporter creation for stylo.

This commit is contained in:
Josh Matthews 2017-04-18 19:10:21 +10:00
parent fd6e54d9e3
commit 3773a4d499
4 changed files with 20 additions and 8 deletions

View file

@ -124,3 +124,15 @@ impl ParseErrorReporter for NullReporter {
// do nothing
}
}
/// Create an instance of the default error reporter for Servo.
#[cfg(feature = "servo")]
pub fn create_error_reporter() -> RustLogReporter {
RustLogReporter
}
/// Create an instance of the default error reporter for Stylo.
#[cfg(feature = "gecko")]
pub fn create_error_reporter() -> RustLogReporter {
RustLogReporter
}

View file

@ -21,7 +21,7 @@ use data::ElementData;
use dom::{self, DescendantsBit, LayoutIterator, NodeInfo, TElement, TNode, UnsafeNode};
use dom::{OpaqueNode, PresentationalHintsSynthesizer};
use element_state::ElementState;
use error_reporting::RustLogReporter;
use error_reporting::create_error_reporter;
use font_metrics::{FontMetrics, FontMetricsProvider, FontMetricsQueryResult};
use gecko::data::PerDocumentStyleData;
use gecko::global_style_data::GLOBAL_STYLE_DATA;
@ -416,7 +416,7 @@ impl<'le> GeckoElement<'le> {
pub fn parse_style_attribute(value: &str,
url_data: &UrlExtraData,
quirks_mode: QuirksMode) -> PropertyDeclarationBlock {
parse_style_attribute(value, url_data, &RustLogReporter, quirks_mode)
parse_style_attribute(value, url_data, &create_error_reporter(), quirks_mode)
}
fn flags(&self) -> u32 {

View file

@ -476,7 +476,7 @@ impl AnimationValue {
/// Construct an AnimationValue from a property declaration
pub fn from_declaration(decl: &PropertyDeclaration, context: &mut Context,
initial: &ComputedValues) -> Option<Self> {
use error_reporting::RustLogReporter;
use error_reporting::create_error_reporter;
use properties::LonghandId;
use properties::DeclaredValue;
@ -539,7 +539,7 @@ impl AnimationValue {
},
PropertyDeclaration::WithVariables(id, ref variables) => {
let custom_props = context.style().custom_properties();
let reporter = RustLogReporter;
let reporter = create_error_reporter();
match id {
% for prop in data.longhands:
% if prop.animatable:

View file

@ -10,7 +10,7 @@ use context::{QuirksMode, SharedStyleContext};
use data::ComputedStyle;
use dom::TElement;
use element_state::ElementState;
use error_reporting::RustLogReporter;
use error_reporting::create_error_reporter;
use font_metrics::FontMetricsProvider;
#[cfg(feature = "gecko")]
use gecko_bindings::structs::{nsIAtom, StyleRuleInclusion};
@ -595,7 +595,7 @@ impl Stylist {
parent.map(|p| &**p),
None,
None,
&RustLogReporter,
&create_error_reporter(),
font_metrics,
cascade_flags,
self.quirks_mode);
@ -676,7 +676,7 @@ impl Stylist {
Some(parent_style),
None,
None,
&RustLogReporter,
&create_error_reporter(),
font_metrics,
CascadeFlags::empty(),
self.quirks_mode);
@ -1216,7 +1216,7 @@ impl Stylist {
Some(parent_style),
None,
None,
&RustLogReporter,
&create_error_reporter(),
&metrics,
CascadeFlags::empty(),
self.quirks_mode))