Skip to content

Commit

Permalink
Encapsulate CSS error reporter creation for stylo.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdm committed Jun 9, 2017
1 parent fd6e54d commit 3773a4d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
12 changes: 12 additions & 0 deletions components/style/error_reporting.rs
Expand Up @@ -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
}
4 changes: 2 additions & 2 deletions components/style/gecko/wrapper.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
Expand Up @@ -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;

Expand Down Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions components/style/stylist.rs
Expand Up @@ -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};
Expand Down Expand Up @@ -595,7 +595,7 @@ impl Stylist {
parent.map(|p| &**p),
None,
None,
&RustLogReporter,
&create_error_reporter(),
font_metrics,
cascade_flags,
self.quirks_mode);
Expand Down Expand Up @@ -676,7 +676,7 @@ impl Stylist {
Some(parent_style),
None,
None,
&RustLogReporter,
&create_error_reporter(),
font_metrics,
CascadeFlags::empty(),
self.quirks_mode);
Expand Down Expand Up @@ -1216,7 +1216,7 @@ impl Stylist {
Some(parent_style),
None,
None,
&RustLogReporter,
&create_error_reporter(),
&metrics,
CascadeFlags::empty(),
self.quirks_mode))
Expand Down

0 comments on commit 3773a4d

Please sign in to comment.