diff options
author | Ms2ger <ms2ger@gmail.com> | 2015-04-18 18:50:11 +0200 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2015-04-27 13:18:56 +0200 |
commit | 5fd753fda2c1af33bb5aea45a3f0e17532af5308 (patch) | |
tree | 6cdfb9135df4177ba0f8a195e8330ea9240abdaa /components/script/script_task.rs | |
parent | b0ddd8149b04db6bceba0c0b8de852acc1086838 (diff) | |
download | servo-5fd753fda2c1af33bb5aea45a3f0e17532af5308.tar.gz servo-5fd753fda2c1af33bb5aea45a3f0e17532af5308.zip |
Factor out a handle_parsing_complete function from ScriptTask::Load.
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r-- | components/script/script_task.rs | 80 |
1 files changed, 46 insertions, 34 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 6de72745163..f1f469212aa 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -1164,40 +1164,7 @@ impl ScriptTask { }; parse_html(document.r(), parse_input, &final_url, None); - - document.r().set_ready_state(DocumentReadyState::Interactive); - self.compositor.borrow_mut().set_ready_state(incomplete.pipeline_id, PerformingLayout); - - // Kick off the initial reflow of the page. - debug!("kicking off initial reflow of {:?}", final_url); - document.r().content_changed(NodeCast::from_ref(document.r()), - NodeDamage::OtherNodeDamage); - window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::FirstLoad); - - // No more reflow required - page.set_reflow_status(false); - - // https://html.spec.whatwg.org/multipage/#the-end step 4 - let addr: Trusted<Document> = Trusted::new(self.get_cx(), document.r(), self.chan.clone()); - let handler = box DocumentProgressHandler::new(addr.clone(), DocumentProgressTask::DOMContentLoaded); - self.chan.send(ScriptMsg::RunnableMsg(handler)).unwrap(); - - // We have no concept of a document loader right now, so just dispatch the - // "load" event as soon as we've finished executing all scripts parsed during - // the initial load. - - // https://html.spec.whatwg.org/multipage/#the-end step 7 - let handler = box DocumentProgressHandler::new(addr, DocumentProgressTask::Load); - self.chan.send(ScriptMsg::RunnableMsg(handler)).unwrap(); - - window.r().set_fragment_name(final_url.fragment.clone()); - - let ConstellationChan(ref chan) = self.constellation_chan; - chan.send(ConstellationMsg::LoadComplete).unwrap(); - - // Notify devtools that a new script global exists. - self.notify_devtools(document.r().Title(), final_url, (incomplete.pipeline_id, None)); - + self.handle_parsing_complete(incomplete.pipeline_id); page_remover.neuter(); } @@ -1413,6 +1380,51 @@ impl ScriptTask { self.devtools_markers.borrow_mut().clear(); *self.devtools_marker_sender.borrow_mut() = None; } + + fn handle_parsing_complete(&self, id: PipelineId) { + let parent_page = self.root_page(); + let page = match parent_page.find(id) { + Some(page) => page, + None => return, + }; + + let document = page.document().root(); + let final_url = document.r().url(); + + document.r().set_ready_state(DocumentReadyState::Interactive); + self.compositor.borrow_mut().set_ready_state(id, PerformingLayout); + + // Kick off the initial reflow of the page. + debug!("kicking off initial reflow of {:?}", final_url); + document.r().content_changed(NodeCast::from_ref(document.r()), + NodeDamage::OtherNodeDamage); + let window = window_from_node(document.r()).root(); + window.r().reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::FirstLoad); + + // No more reflow required + page.set_reflow_status(false); + + // https://html.spec.whatwg.org/multipage/#the-end step 4 + let addr: Trusted<Document> = Trusted::new(self.get_cx(), document.r(), self.chan.clone()); + let handler = box DocumentProgressHandler::new(addr.clone(), DocumentProgressTask::DOMContentLoaded); + self.chan.send(ScriptMsg::RunnableMsg(handler)).unwrap(); + + // We have no concept of a document loader right now, so just dispatch the + // "load" event as soon as we've finished executing all scripts parsed during + // the initial load. + + // https://html.spec.whatwg.org/multipage/#the-end step 7 + let handler = box DocumentProgressHandler::new(addr, DocumentProgressTask::Load); + self.chan.send(ScriptMsg::RunnableMsg(handler)).unwrap(); + + window.r().set_fragment_name(final_url.fragment.clone()); + + let ConstellationChan(ref chan) = self.constellation_chan; + chan.send(ConstellationMsg::LoadComplete).unwrap(); + + // Notify devtools that a new script global exists. + self.notify_devtools(document.r().Title(), final_url, (id, None)); + } } impl Drop for ScriptTask { |