aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/window.rs9
-rw-r--r--components/script/reporter.rs23
-rw-r--r--components/script/script_thread.rs11
3 files changed, 32 insertions, 11 deletions
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index c8ea1d9f0f8..cf449c3e26f 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -56,6 +56,7 @@ use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64};
use script_thread::{DOMManipulationThreadSource, UserInteractionThreadSource, NetworkingThreadSource};
use script_thread::{HistoryTraversalThreadSource, FileReadingThreadSource, SendableMainThreadScriptChan};
use script_thread::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
+use script_traits::ConstellationControlMsg;
use script_traits::{DocumentState, MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId};
use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg, TimerEventRequest, TimerSource};
use std::ascii::AsciiExt;
@@ -66,10 +67,10 @@ use std::default::Default;
use std::ffi::CString;
use std::io::{Write, stderr, stdout};
use std::rc::Rc;
-use std::sync::Arc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
use std::sync::mpsc::{Sender, channel};
+use std::sync::{Arc, Mutex};
use string_cache::Atom;
use style::context::ReflowGoal;
use style::error_reporting::ParseErrorReporter;
@@ -1304,6 +1305,7 @@ impl Window {
mem_profiler_chan: mem::ProfilerChan,
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
constellation_chan: ConstellationChan<ConstellationMsg>,
+ control_chan: IpcSender<ConstellationControlMsg>,
scheduler_chan: IpcSender<TimerEventRequest>,
timer_event_chan: IpcSender<TimerEvent>,
layout_chan: LayoutChan,
@@ -1317,7 +1319,10 @@ impl Window {
lchan.send(Msg::GetRPC(rpc_send)).unwrap();
rpc_recv.recv().unwrap()
};
- let error_reporter = CSSErrorReporter { pipelineid: id };
+ let error_reporter = CSSErrorReporter {
+ pipelineid: id,
+ script_chan: Arc::new(Mutex::new(control_chan)),
+ };
let win = box Window {
eventtarget: EventTarget::new_inherited(),
script_chan: script_chan,
diff --git a/components/script/reporter.rs b/components/script/reporter.rs
index 95b036933d3..39b9e81d333 100644
--- a/components/script/reporter.rs
+++ b/components/script/reporter.rs
@@ -3,25 +3,42 @@
* 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(JSTraceable, 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) {
- let location = input.source_location(position);
- // TODO eventually this will got into a "web console" or something.
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, }
+ box CSSErrorReporter {
+ pipelineid: self.pipelineid,
+ script_chan: self.script_chan.clone(),
+ }
}
}
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 83e60a50549..2230f254320 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -1785,6 +1785,7 @@ impl ScriptThread {
self.mem_profiler_chan.clone(),
self.devtools_chan.clone(),
self.constellation_chan.clone(),
+ self.control_chan.clone(),
self.scheduler_chan.clone(),
ipc_timer_event_chan,
incomplete.layout_chan,
@@ -1840,6 +1841,9 @@ impl ScriptThread {
let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(ConstellationMsg::ActivateDocument(incomplete.pipeline_id)).unwrap();
+ // Notify devtools that a new script global exists.
+ self.notify_devtools(document.Title(), final_url.clone(), (page.pipeline(), None));
+
let is_javascript = incomplete.url.scheme == "javascript";
let parse_input = if is_javascript {
use url::percent_encoding::percent_decode_to;
@@ -2199,15 +2203,10 @@ impl ScriptThread {
document.process_deferred_scripts();
window.set_fragment_name(final_url.fragment.clone());
-
- // Notify devtools that a new script global exists.
- //TODO: should this happen as soon as the global is created, or at least once the first
- // script runs?
- self.notify_devtools(document.Title(), (*final_url).clone(), (id, None));
}
fn handle_css_error_reporting(&self, pipeline_id: PipelineId, filename: String,
- line: u32, column: u32, msg: String) {
+ line: usize, column: usize, msg: String) {
let parent_page = self.root_page();
let page = match parent_page.find(pipeline_id) {
Some(page) => page,