aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Matthews <josh@joshmatthews.net>2017-04-18 19:10:21 +1000
committerJosh Matthews <josh@joshmatthews.net>2017-06-09 13:16:38 -0400
commit3773a4d49942a6fbe7bcfe92ed7a033bec21f3da (patch)
tree89d22f40f91dcb5e139b82be49817bc71499cb04
parentfd6e54d9e37cb31ad5a1e3a55dfbc91aee0a4e4e (diff)
downloadservo-3773a4d49942a6fbe7bcfe92ed7a033bec21f3da.tar.gz
servo-3773a4d49942a6fbe7bcfe92ed7a033bec21f3da.zip
Encapsulate CSS error reporter creation for stylo.
-rw-r--r--components/style/error_reporting.rs12
-rw-r--r--components/style/gecko/wrapper.rs4
-rw-r--r--components/style/properties/helpers/animated_properties.mako.rs4
-rw-r--r--components/style/stylist.rs8
4 files changed, 20 insertions, 8 deletions
diff --git a/components/style/error_reporting.rs b/components/style/error_reporting.rs
index a3bbf57d88f..1191c2b3ebb 100644
--- a/components/style/error_reporting.rs
+++ b/components/style/error_reporting.rs
@@ -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
+}
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index 6c70013d481..2ac03135421 100644
--- a/components/style/gecko/wrapper.rs
+++ b/components/style/gecko/wrapper.rs
@@ -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 {
diff --git a/components/style/properties/helpers/animated_properties.mako.rs b/components/style/properties/helpers/animated_properties.mako.rs
index eea69199f6b..60be81aa92a 100644
--- a/components/style/properties/helpers/animated_properties.mako.rs
+++ b/components/style/properties/helpers/animated_properties.mako.rs
@@ -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:
diff --git a/components/style/stylist.rs b/components/style/stylist.rs
index 6374737f157..7f91855c4fc 100644
--- a/components/style/stylist.rs
+++ b/components/style/stylist.rs
@@ -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))