diff options
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r-- | components/script/script_thread.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 764a7c87a4f..8319ad3cba3 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -256,6 +256,9 @@ pub enum MainThreadScriptMsg { DOMManipulation(DOMManipulationTask), /// Tasks that originate from the user interaction task source UserInteraction(UserInteractionTask), + /// Notifies the script thread that a new worklet has been loaded, and thus the page should be + /// reflowed. + WorkletLoaded(PipelineId), } impl OpaqueSender<CommonScriptMsg> for Box<ScriptChan + Send> { @@ -724,6 +727,7 @@ impl ScriptThread { devtools_chan: script_thread.devtools_chan.clone(), constellation_chan: script_thread.constellation_chan.clone(), scheduler_chan: script_thread.scheduler_chan.clone(), + image_cache: script_thread.image_cache.clone(), }; Rc::new(WorkletThreadPool::spawn(chan, init)) }).clone() @@ -828,6 +832,7 @@ impl ScriptThread { debug!("Starting script thread."); while self.handle_msgs() { // Go on... + debug!("Running script thread."); } debug!("Stopped script thread."); } @@ -856,6 +861,7 @@ impl ScriptThread { let mut sequential = vec![]; // Receive at least one message so we don't spinloop. + debug!("Waiting for event."); let mut event = { let sel = Select::new(); let mut script_port = sel.handle(&self.port); @@ -887,6 +893,7 @@ impl ScriptThread { panic!("unexpected select result") } }; + debug!("Got event."); // Squash any pending resize, reflow, animation tick, and mouse-move events in the queue. let mut mouse_move_event_index = None; @@ -983,6 +990,7 @@ impl ScriptThread { } // Process the gathered events. + debug!("Processing events."); for msg in sequential { debug!("Processing event {:?}.", msg); let category = self.categorize_msg(&msg); @@ -1025,6 +1033,7 @@ impl ScriptThread { // Issue batched reflows on any pages that require it (e.g. if images loaded) // TODO(gw): In the future we could probably batch other types of reflows // into this loop too, but for now it's only images. + debug!("Issuing batched reflows."); for (_, document) in self.documents.borrow().iter() { let window = document.window(); let pending_reflows = window.get_pending_reflow_count(); @@ -1189,11 +1198,16 @@ impl ScriptThread { // The category of the runnable is ignored by the pattern, however // it is still respected by profiling (see categorize_msg). if !runnable.is_cancelled() { + debug!("Running runnable."); runnable.main_thread_handler(self) + } else { + debug!("Not running cancelled runnable."); } } MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(reports_chan)) => self.collect_reports(reports_chan), + MainThreadScriptMsg::WorkletLoaded(pipeline_id) => + self.handle_worklet_loaded(pipeline_id), MainThreadScriptMsg::DOMManipulation(task) => task.handle_task(self), MainThreadScriptMsg::UserInteraction(task) => @@ -1759,6 +1773,14 @@ impl ScriptThread { } } + /// Handles a worklet being loaded. Does nothing if the page no longer exists. + fn handle_worklet_loaded(&self, pipeline_id: PipelineId) { + let document = self.documents.borrow().find_document(pipeline_id); + if let Some(document) = document { + self.rebuild_and_force_reflow(&document, ReflowReason::WorkletLoaded); + } + } + /// Notify a window of a storage event fn handle_storage_event(&self, pipeline_id: PipelineId, storage_type: StorageType, url: ServoUrl, key: Option<String>, old_value: Option<String>, new_value: Option<String>) { |