From fc81276c8ef755a7b5c5b21ce5a58c4824efdd90 Mon Sep 17 00:00:00 2001 From: GauriGNaik Date: Fri, 4 Dec 2015 19:19:21 -0500 Subject: Add pipeline information to CSS error reporting. --- components/script/script_task.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'components/script/script_task.rs') diff --git a/components/script/script_task.rs b/components/script/script_task.rs index c4efab48169..3c54259fc3e 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -592,6 +592,14 @@ pub unsafe extern "C" fn shadow_check_callback(_cx: *mut JSContext, DOMProxyShadowsResult::ShadowCheckFailed } +#[derive(JSTraceable, HeapSizeOf)] +pub struct CSSError { + filename: String, + line: usize, + column: usize, + msg: String +} + impl ScriptTask { pub fn page_fetch_complete(id: PipelineId, subpage: Option, metadata: Metadata) -> Option { @@ -1009,7 +1017,9 @@ impl ScriptTask { ConstellationControlMsg::GetCurrentState(sender, pipeline_id) => { let state = self.handle_get_current_state(pipeline_id); sender.send(state).unwrap(); - } + }, + ConstellationControlMsg::ReportCSSError(pipeline_id, filename, line, column, msg) => + self.handle_css_error_reporting(pipeline_id, filename, line, column, msg), } } @@ -2054,6 +2064,24 @@ impl ScriptTask { // script runs? self.notify_devtools(document.Title(), (*final_url).clone(), (id, None)); } + + fn handle_css_error_reporting(&self, pipeline_id: PipelineId, filename: String, + line: usize, column: usize, msg: String) { + let parent_page = self.root_page(); + let page = match parent_page.find(pipeline_id) { + Some(page) => page, + None => return, + }; + + let document = page.document(); + let css_error = CSSError { + filename: filename, + line: line, + column: column, + msg: msg + }; + document.report_css_error(css_error); + } } impl Drop for ScriptTask { -- cgit v1.2.3