aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_layout_interface
diff options
context:
space:
mode:
Diffstat (limited to 'components/script_layout_interface')
-rw-r--r--components/script_layout_interface/Cargo.toml2
-rw-r--r--components/script_layout_interface/lib.rs5
-rw-r--r--components/script_layout_interface/reporter.rs44
3 files changed, 51 insertions, 0 deletions
diff --git a/components/script_layout_interface/Cargo.toml b/components/script_layout_interface/Cargo.toml
index 226df50f386..287c72ee2c0 100644
--- a/components/script_layout_interface/Cargo.toml
+++ b/components/script_layout_interface/Cargo.toml
@@ -12,12 +12,14 @@ path = "lib.rs"
app_units = {version = "0.2.3", features = ["plugins"]}
bitflags = "0.7"
canvas_traits = {path = "../canvas_traits"}
+cssparser = {version = "0.5.4", features = ["heap_size", "serde-serialization"]}
euclid = {version = "0.6.4", features = ["plugins"]}
gfx_traits = {path = "../gfx_traits"}
heapsize = "0.3.0"
heapsize_plugin = "0.1.2"
ipc-channel = {git = "https://github.com/servo/ipc-channel"}
libc = "0.2"
+log = "0.3.5"
msg = {path = "../msg"}
net_traits = {path = "../net_traits"}
profile_traits = {path = "../profile_traits"}
diff --git a/components/script_layout_interface/lib.rs b/components/script_layout_interface/lib.rs
index 929730f3909..c2e06e3dcf7 100644
--- a/components/script_layout_interface/lib.rs
+++ b/components/script_layout_interface/lib.rs
@@ -7,6 +7,7 @@
//! to depend on script.
#![deny(unsafe_code)]
+#![feature(box_syntax)]
#![feature(custom_attribute)]
#![feature(custom_derive)]
#![feature(nonzero)]
@@ -20,11 +21,14 @@ extern crate app_units;
extern crate bitflags;
extern crate canvas_traits;
extern crate core;
+extern crate cssparser;
extern crate euclid;
extern crate gfx_traits;
extern crate heapsize;
extern crate ipc_channel;
extern crate libc;
+#[macro_use]
+extern crate log;
extern crate msg;
extern crate net_traits;
extern crate profile_traits;
@@ -38,6 +42,7 @@ extern crate url;
extern crate util;
pub mod message;
+pub mod reporter;
pub mod restyle_damage;
pub mod rpc;
pub mod wrapper_traits;
diff --git a/components/script_layout_interface/reporter.rs b/components/script_layout_interface/reporter.rs
new file mode 100644
index 00000000000..4561f2d63ca
--- /dev/null
+++ b/components/script_layout_interface/reporter.rs
@@ -0,0 +1,44 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+use cssparser::{Parser, SourcePosition};
+use ipc_channel::ipc::IpcSender;
+use log;
+use msg::constellation_msg::PipelineId;
+use script_traits::ConstellationControlMsg;
+use std::sync::{Mutex, Arc};
+use style::error_reporting::ParseErrorReporter;
+
+#[derive(HeapSizeOf)]
+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_heap_size_of = "Arc is defined in libstd"]
+ pub script_chan: Arc<Mutex<IpcSender<ConstellationControlMsg>>>,
+}
+
+impl ParseErrorReporter for CSSErrorReporter {
+ fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
+ let location = input.source_location(position);
+ if log_enabled!(log::LogLevel::Info) {
+ info!("{}:{} {}", location.line, location.column, message)
+ }
+ //TODO: report a real filename
+ let _ = self.script_chan.lock().unwrap().send(
+ ConstellationControlMsg::ReportCSSError(self.pipelineid,
+ "".to_owned(),
+ location.line,
+ location.column,
+ message.to_owned()));
+ }
+
+ fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
+ box CSSErrorReporter {
+ pipelineid: self.pipelineid,
+ script_chan: self.script_chan.clone(),
+ }
+ }
+}