servo: Merge #8971 - Add pipeline information to CSS error reporting (from jdm:expose-css-errors-1); r=jdm

Rebase of #8838.

Source-Repo: https://github.com/servo/servo
Source-Revision: d11f96e27074b0130760a02d39d2da4e003c820e
This commit is contained in:
GauriGNaik
2015-12-14 21:21:41 +05:00
parent 2d0ab8c0d7
commit f9f1c0b345
27 changed files with 103 additions and 29 deletions

View File

@@ -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<SubpageId>, metadata: Metadata)
-> Option<ParserRoot> {
@@ -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 {