mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Report CSS errors to script task for further processing.
This commit is contained in:
parent
3703e6d4f6
commit
e6d906dbbf
7 changed files with 41 additions and 15 deletions
|
@ -89,8 +89,8 @@ struct ConsoleMsg {
|
||||||
timeStamp: u64,
|
timeStamp: u64,
|
||||||
arguments: Vec<String>,
|
arguments: Vec<String>,
|
||||||
filename: String,
|
filename: String,
|
||||||
lineNumber: u32,
|
lineNumber: usize,
|
||||||
columnNumber: u32,
|
columnNumber: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(RustcEncodable)]
|
#[derive(RustcEncodable)]
|
||||||
|
|
|
@ -49,8 +49,8 @@ pub struct DevtoolsPageInfo {
|
||||||
#[derive(Deserialize, HeapSizeOf, Serialize, Clone)]
|
#[derive(Deserialize, HeapSizeOf, Serialize, Clone)]
|
||||||
pub struct CSSError {
|
pub struct CSSError {
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub line: u32,
|
pub line: usize,
|
||||||
pub column: u32,
|
pub column: usize,
|
||||||
pub msg: String
|
pub msg: String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,8 +223,8 @@ pub struct ConsoleMessage {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub logLevel: LogLevel,
|
pub logLevel: LogLevel,
|
||||||
pub filename: String,
|
pub filename: String,
|
||||||
pub lineNumber: u32,
|
pub lineNumber: usize,
|
||||||
pub columnNumber: u32,
|
pub columnNumber: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
|
|
|
@ -410,7 +410,7 @@ impl LayoutThread {
|
||||||
is_iframe: is_iframe,
|
is_iframe: is_iframe,
|
||||||
port: port,
|
port: port,
|
||||||
pipeline_port: pipeline_receiver,
|
pipeline_port: pipeline_receiver,
|
||||||
script_chan: script_chan,
|
script_chan: script_chan.clone(),
|
||||||
constellation_chan: constellation_chan.clone(),
|
constellation_chan: constellation_chan.clone(),
|
||||||
paint_chan: paint_chan,
|
paint_chan: paint_chan,
|
||||||
time_profiler_chan: time_profiler_chan,
|
time_profiler_chan: time_profiler_chan,
|
||||||
|
@ -446,7 +446,10 @@ impl LayoutThread {
|
||||||
resolved_style_response: None,
|
resolved_style_response: None,
|
||||||
offset_parent_response: OffsetParentResponse::empty(),
|
offset_parent_response: OffsetParentResponse::empty(),
|
||||||
})),
|
})),
|
||||||
error_reporter: CSSErrorReporter { pipelineid: id },
|
error_reporter: CSSErrorReporter {
|
||||||
|
pipelineid: id,
|
||||||
|
script_chan: Arc::new(Mutex::new(script_chan)),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ use rustc_serialize::base64::{FromBase64, STANDARD, ToBase64};
|
||||||
use script_thread::{DOMManipulationThreadSource, UserInteractionThreadSource, NetworkingThreadSource};
|
use script_thread::{DOMManipulationThreadSource, UserInteractionThreadSource, NetworkingThreadSource};
|
||||||
use script_thread::{HistoryTraversalThreadSource, FileReadingThreadSource, SendableMainThreadScriptChan};
|
use script_thread::{HistoryTraversalThreadSource, FileReadingThreadSource, SendableMainThreadScriptChan};
|
||||||
use script_thread::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
|
use script_thread::{ScriptChan, ScriptPort, MainThreadScriptChan, MainThreadScriptMsg, RunnableWrapper};
|
||||||
|
use script_traits::ConstellationControlMsg;
|
||||||
use script_traits::{DocumentState, MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId};
|
use script_traits::{DocumentState, MsDuration, ScriptToCompositorMsg, TimerEvent, TimerEventId};
|
||||||
use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg, TimerEventRequest, TimerSource};
|
use script_traits::{MozBrowserEvent, ScriptMsg as ConstellationMsg, TimerEventRequest, TimerSource};
|
||||||
use std::ascii::AsciiExt;
|
use std::ascii::AsciiExt;
|
||||||
|
@ -66,10 +67,10 @@ use std::default::Default;
|
||||||
use std::ffi::CString;
|
use std::ffi::CString;
|
||||||
use std::io::{Write, stderr, stdout};
|
use std::io::{Write, stderr, stdout};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::Arc;
|
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
|
use std::sync::mpsc::TryRecvError::{Disconnected, Empty};
|
||||||
use std::sync::mpsc::{Sender, channel};
|
use std::sync::mpsc::{Sender, channel};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
use string_cache::Atom;
|
use string_cache::Atom;
|
||||||
use style::context::ReflowGoal;
|
use style::context::ReflowGoal;
|
||||||
use style::error_reporting::ParseErrorReporter;
|
use style::error_reporting::ParseErrorReporter;
|
||||||
|
@ -1304,6 +1305,7 @@ impl Window {
|
||||||
mem_profiler_chan: mem::ProfilerChan,
|
mem_profiler_chan: mem::ProfilerChan,
|
||||||
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
devtools_chan: Option<IpcSender<ScriptToDevtoolsControlMsg>>,
|
||||||
constellation_chan: ConstellationChan<ConstellationMsg>,
|
constellation_chan: ConstellationChan<ConstellationMsg>,
|
||||||
|
control_chan: IpcSender<ConstellationControlMsg>,
|
||||||
scheduler_chan: IpcSender<TimerEventRequest>,
|
scheduler_chan: IpcSender<TimerEventRequest>,
|
||||||
timer_event_chan: IpcSender<TimerEvent>,
|
timer_event_chan: IpcSender<TimerEvent>,
|
||||||
layout_chan: LayoutChan,
|
layout_chan: LayoutChan,
|
||||||
|
@ -1317,7 +1319,10 @@ impl Window {
|
||||||
lchan.send(Msg::GetRPC(rpc_send)).unwrap();
|
lchan.send(Msg::GetRPC(rpc_send)).unwrap();
|
||||||
rpc_recv.recv().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 {
|
let win = box Window {
|
||||||
eventtarget: EventTarget::new_inherited(),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
script_chan: script_chan,
|
script_chan: script_chan,
|
||||||
|
|
|
@ -3,25 +3,42 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use cssparser::{Parser, SourcePosition};
|
use cssparser::{Parser, SourcePosition};
|
||||||
|
use ipc_channel::ipc::IpcSender;
|
||||||
use log;
|
use log;
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
|
use script_traits::ConstellationControlMsg;
|
||||||
|
use std::sync::{Mutex, Arc};
|
||||||
use style::error_reporting::ParseErrorReporter;
|
use style::error_reporting::ParseErrorReporter;
|
||||||
|
|
||||||
#[derive(JSTraceable, HeapSizeOf)]
|
#[derive(JSTraceable, HeapSizeOf)]
|
||||||
pub struct CSSErrorReporter {
|
pub struct CSSErrorReporter {
|
||||||
pub pipelineid: PipelineId,
|
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 {
|
impl ParseErrorReporter for CSSErrorReporter {
|
||||||
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
|
fn report_error(&self, input: &mut Parser, position: SourcePosition, message: &str) {
|
||||||
if log_enabled!(log::LogLevel::Info) {
|
|
||||||
let location = input.source_location(position);
|
let location = input.source_location(position);
|
||||||
// TODO eventually this will got into a "web console" or something.
|
if log_enabled!(log::LogLevel::Info) {
|
||||||
info!("{}:{} {}", location.line, location.column, message)
|
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> {
|
fn clone(&self) -> Box<ParseErrorReporter + Send + Sync> {
|
||||||
box CSSErrorReporter { pipelineid: self.pipelineid, }
|
box CSSErrorReporter {
|
||||||
|
pipelineid: self.pipelineid,
|
||||||
|
script_chan: self.script_chan.clone(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1785,6 +1785,7 @@ impl ScriptThread {
|
||||||
self.mem_profiler_chan.clone(),
|
self.mem_profiler_chan.clone(),
|
||||||
self.devtools_chan.clone(),
|
self.devtools_chan.clone(),
|
||||||
self.constellation_chan.clone(),
|
self.constellation_chan.clone(),
|
||||||
|
self.control_chan.clone(),
|
||||||
self.scheduler_chan.clone(),
|
self.scheduler_chan.clone(),
|
||||||
ipc_timer_event_chan,
|
ipc_timer_event_chan,
|
||||||
incomplete.layout_chan,
|
incomplete.layout_chan,
|
||||||
|
@ -2207,7 +2208,7 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_css_error_reporting(&self, pipeline_id: PipelineId, filename: String,
|
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 parent_page = self.root_page();
|
||||||
let page = match parent_page.find(pipeline_id) {
|
let page = match parent_page.find(pipeline_id) {
|
||||||
Some(page) => page,
|
Some(page) => page,
|
||||||
|
|
|
@ -147,7 +147,7 @@ pub enum ConstellationControlMsg {
|
||||||
/// Notifies a parent frame that one of its child frames is now active.
|
/// Notifies a parent frame that one of its child frames is now active.
|
||||||
FramedContentChanged(PipelineId, SubpageId),
|
FramedContentChanged(PipelineId, SubpageId),
|
||||||
/// Report an error from a CSS parser for the given pipeline
|
/// Report an error from a CSS parser for the given pipeline
|
||||||
ReportCSSError(PipelineId, String, u32, u32, String),
|
ReportCSSError(PipelineId, String, usize, usize, String),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Used to determine if a script has any pending asynchronous activity.
|
/// Used to determine if a script has any pending asynchronous activity.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue