diff options
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 6205866f2dc..87f2d55f615 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -104,7 +104,7 @@ use time::{Tm, now}; use url::{Url, UrlParser}; use util::opts; use util::str::DOMString; -use util::task::spawn_named_with_send_on_failure; +use util::task; use util::task_state; use webdriver_handlers; @@ -232,8 +232,9 @@ pub enum ScriptTaskEventCategory { Resize, ScriptEvent, TimerEvent, - UpdateReplacedElement, SetViewport, + StylesheetLoad, + UpdateReplacedElement, WebSocketEvent, WorkerEvent, } @@ -396,7 +397,7 @@ pub struct ScriptTask { chan: MainThreadScriptChan, /// A channel to hand out to tasks that need to respond to a message from the script task. - control_chan: Sender<ConstellationControlMsg>, + control_chan: IpcSender<ConstellationControlMsg>, /// The port on which the constellation and layout tasks can communicate with the /// script task. @@ -438,6 +439,8 @@ pub struct ScriptTask { scheduler_chan: IpcSender<TimerEventRequest>, timer_event_chan: Sender<TimerEvent>, timer_event_port: Receiver<TimerEvent>, + + content_process_shutdown_chan: IpcSender<()>, } /// In the event of task failure, all data on the stack runs its destructor. However, there @@ -484,7 +487,8 @@ impl ScriptTaskFactory for ScriptTask { ScriptLayoutChan::new(chan, port) } - fn clone_layout_channel(_phantom: Option<&mut ScriptTask>, pair: &OpaqueScriptLayoutChannel) -> Box<Any + Send> { + fn clone_layout_channel(_phantom: Option<&mut ScriptTask>, pair: &OpaqueScriptLayoutChannel) + -> Box<Any + Send> { box pair.sender() as Box<Any + Send> } @@ -496,9 +500,10 @@ impl ScriptTaskFactory for ScriptTask { let (script_chan, script_port) = channel(); let layout_chan = LayoutChan(layout_chan.sender()); let failure_info = state.failure_info; - spawn_named_with_send_on_failure(format!("ScriptTask {:?}", state.id), task_state::SCRIPT, move || { + task::spawn_named_with_send_on_failure(format!("ScriptTask {:?}", state.id), + task_state::SCRIPT, + move || { PipelineNamespace::install(state.pipeline_namespace_id); - let roots = RootCollection::new(); let _stack_roots_tls = StackRootTLS::new(&roots); let chan = MainThreadScriptChan(script_chan); @@ -524,6 +529,7 @@ impl ScriptTaskFactory for ScriptTask { let reporter_name = format!("script-reporter-{}", id); mem_profiler_chan.run_with_memory_reporting(|| { script_task.start(); + let _ = script_task.content_process_shutdown_chan.send(()); }, reporter_name, channel_for_reporter, CommonScriptMsg::CollectReports); // This must always be the very last operation performed before the task completes @@ -636,6 +642,9 @@ impl ScriptTask { let (timer_event_chan, timer_event_port) = channel(); + // Ask the router to proxy IPC messages from the control port to us. + let control_port = ROUTER.route_ipc_receiver_to_new_mpsc_receiver(state.control_port); + ScriptTask { page: DOMRefCell::new(None), incomplete_loads: DOMRefCell::new(vec!()), @@ -650,7 +659,7 @@ impl ScriptTask { port: port, chan: chan, control_chan: state.control_chan, - control_port: state.control_port, + control_port: control_port, constellation_chan: state.constellation_chan, compositor: DOMRefCell::new(state.compositor), time_profiler_chan: state.time_profiler_chan, @@ -667,6 +676,8 @@ impl ScriptTask { scheduler_chan: state.scheduler_chan, timer_event_chan: timer_event_chan, timer_event_port: timer_event_port, + + content_process_shutdown_chan: state.content_process_shutdown_chan, } } @@ -939,7 +950,10 @@ impl ScriptTask { ScriptTaskEventCategory::NetworkEvent => ProfilerCategory::ScriptNetworkEvent, ScriptTaskEventCategory::Resize => ProfilerCategory::ScriptResize, ScriptTaskEventCategory::ScriptEvent => ProfilerCategory::ScriptEvent, - ScriptTaskEventCategory::UpdateReplacedElement => ProfilerCategory::ScriptUpdateReplacedElement, + ScriptTaskEventCategory::UpdateReplacedElement => { + ProfilerCategory::ScriptUpdateReplacedElement + } + ScriptTaskEventCategory::StylesheetLoad => ProfilerCategory::ScriptStylesheetLoad, ScriptTaskEventCategory::SetViewport => ProfilerCategory::ScriptSetViewport, ScriptTaskEventCategory::TimerEvent => ProfilerCategory::ScriptTimerEvent, ScriptTaskEventCategory::WebSocketEvent => ProfilerCategory::ScriptWebSocketEvent, @@ -1091,6 +1105,10 @@ impl ScriptTask { webdriver_handlers::handle_get_active_element(&page, pipeline_id, reply), WebDriverScriptCommand::GetElementTagName(node_id, reply) => webdriver_handlers::handle_get_name(&page, pipeline_id, node_id, reply), + WebDriverScriptCommand::GetElementAttribute(node_id, name, reply) => + webdriver_handlers::handle_get_attribute(&page, pipeline_id, node_id, name, reply), + WebDriverScriptCommand::GetElementCSS(node_id, name, reply) => + webdriver_handlers::handle_get_css(&page, pipeline_id, node_id, name, reply), WebDriverScriptCommand::GetElementText(node_id, reply) => webdriver_handlers::handle_get_text(&page, pipeline_id, node_id, reply), WebDriverScriptCommand::GetFrameId(frame_id, reply) => @@ -1182,6 +1200,7 @@ impl ScriptTask { failure, pipeline_port, layout_shutdown_chan, + content_process_shutdown_chan, } = new_layout_info; let layout_pair = ScriptTask::create_layout_channel(None::<&mut ScriptTask>); @@ -1201,6 +1220,7 @@ impl ScriptTask { script_chan: self.control_chan.clone(), image_cache_task: self.image_cache_task.clone(), layout_shutdown_chan: layout_shutdown_chan, + content_process_shutdown_chan: content_process_shutdown_chan, }; let page = self.root_page(); |