aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2019-01-10 14:35:43 +0100
committerAnthony Ramine <n.oxyde@gmail.com>2019-01-14 10:26:26 +0100
commit64755705fbdeb0aaf257bbdd39577646f2718f28 (patch)
tree8972808dd0e08b1af78b02b0532795d2c7bb1487 /components/script
parent17ee21bf9d4200ea53d5a924c139f6c9add8b2b7 (diff)
downloadservo-64755705fbdeb0aaf257bbdd39577646f2718f28.tar.gz
servo-64755705fbdeb0aaf257bbdd39577646f2718f28.zip
Move CSSReporter from script_layout_interface to script
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/bindings/trace.rs2
-rw-r--r--components/script/dom/window.rs43
2 files changed, 40 insertions, 5 deletions
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index e645fb181d5..2ea4de3d340 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -85,7 +85,6 @@ use net_traits::{Metadata, NetworkError, ReferrerPolicy, ResourceFetchTiming, Re
use offscreen_gl_context::GLLimits;
use profile_traits::mem::ProfilerChan as MemProfilerChan;
use profile_traits::time::ProfilerChan as TimeProfilerChan;
-use script_layout_interface::reporter::CSSErrorReporter;
use script_layout_interface::rpc::LayoutRPC;
use script_layout_interface::OpaqueStyleAndLayoutData;
use script_traits::DrawAPaintImageResult;
@@ -455,7 +454,6 @@ unsafe_no_jsmanaged_fields!(Instant);
unsafe_no_jsmanaged_fields!(RelativePos);
unsafe_no_jsmanaged_fields!(OpaqueStyleAndLayoutData);
unsafe_no_jsmanaged_fields!(PathBuf);
-unsafe_no_jsmanaged_fields!(CSSErrorReporter);
unsafe_no_jsmanaged_fields!(DrawAPaintImageResult);
unsafe_no_jsmanaged_fields!(DocumentId);
unsafe_no_jsmanaged_fields!(ImageKey);
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 3f702cbeabd..f8669ccd858 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -69,7 +69,7 @@ use base64;
use bluetooth_traits::BluetoothRequest;
use canvas_traits::webgl::WebGLChan;
use crossbeam_channel::{unbounded, Sender, TryRecvError};
-use cssparser::{Parser, ParserInput};
+use cssparser::{Parser, ParserInput, SourceLocation};
use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType};
use dom_struct::dom_struct;
use embedder_traits::EmbedderMsg;
@@ -94,7 +94,6 @@ use profile_traits::ipc as ProfiledIpc;
use profile_traits::mem::ProfilerChan as MemProfilerChan;
use profile_traits::time::ProfilerChan as TimeProfilerChan;
use script_layout_interface::message::{Msg, QueryMsg, Reflow, ReflowGoal, ScriptReflow};
-use script_layout_interface::reporter::CSSErrorReporter;
use script_layout_interface::rpc::{ContentBoxResponse, ContentBoxesResponse, LayoutRPC};
use script_layout_interface::rpc::{
NodeScrollIdResponse, ResolvedStyleResponse, TextIndexResponse,
@@ -120,7 +119,7 @@ use std::mem;
use std::rc::Rc;
use std::sync::atomic::Ordering;
use std::sync::{Arc, Mutex};
-use style::error_reporting::ParseErrorReporter;
+use style::error_reporting::{ContextualParseError, ParseErrorReporter};
use style::media_queries;
use style::parser::ParserContext as CssParserContext;
use style::properties::{ComputedValues, PropertyId};
@@ -2242,3 +2241,41 @@ impl Window {
));
}
}
+
+#[derive(Clone, MallocSizeOf)]
+pub struct CSSErrorReporter {
+ pub pipelineid: PipelineId,
+ // Arc+Mutex combo is necessary to make this struct Sync,
+ // which is necessary to fulfill the bounds required by the
+ // uses of the ParseErrorReporter trait.
+ #[ignore_malloc_size_of = "Arc is defined in libstd"]
+ pub script_chan: Arc<Mutex<IpcSender<ConstellationControlMsg>>>,
+}
+unsafe_no_jsmanaged_fields!(CSSErrorReporter);
+
+impl ParseErrorReporter for CSSErrorReporter {
+ fn report_error(&self, url: &ServoUrl, location: SourceLocation, error: ContextualParseError) {
+ if log_enabled!(log::Level::Info) {
+ info!(
+ "Url:\t{}\n{}:{} {}",
+ url.as_str(),
+ location.line,
+ location.column,
+ error
+ )
+ }
+
+ //TODO: report a real filename
+ let _ = self
+ .script_chan
+ .lock()
+ .unwrap()
+ .send(ConstellationControlMsg::ReportCSSError(
+ self.pipelineid,
+ "".to_owned(),
+ location.line,
+ location.column,
+ error.to_string(),
+ ));
+ }
+}