Skip to content

Commit

Permalink
Remove ScriptThread::parsing_complete
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Jan 17, 2017
1 parent d297269 commit 70ed3e7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 37 deletions.
24 changes: 18 additions & 6 deletions components/script/dom/servoparser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use document_loader::{DocumentLoader, LoadType};
use dom::bindings::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::DocumentBinding::DocumentMethods;
use dom::bindings::codegen::Bindings::DocumentBinding::{DocumentMethods, DocumentReadyState};
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::Bindings::ServoParserBinding;
Expand All @@ -20,8 +20,9 @@ use dom::globalscope::GlobalScope;
use dom::htmlformelement::HTMLFormElement;
use dom::htmlimageelement::HTMLImageElement;
use dom::htmlscriptelement::{HTMLScriptElement, ScriptResult};
use dom::node::{Node, NodeSiblingIterator};
use dom::node::{Node, NodeDamage, NodeSiblingIterator};
use dom::text::Text;
use dom::window::ReflowReason;
use encoding::all::UTF_8;
use encoding::types::{DecoderTrap, Encoding};
use html5ever::tokenizer::buffer_queue::BufferQueue;
Expand All @@ -34,11 +35,13 @@ use net_traits::{FetchMetadata, FetchResponseListener, Metadata, NetworkError};
use network_listener::PreInvoke;
use profile_traits::time::{TimerMetadata, TimerMetadataFrameType};
use profile_traits::time::{TimerMetadataReflowType, ProfilerCategory, profile};
use script_layout_interface::message::ReflowQueryType;
use script_thread::ScriptThread;
use servo_config::resource_files::read_resource_file;
use servo_url::ServoUrl;
use std::cell::Cell;
use std::mem;
use style::context::ReflowGoal;

mod html;
mod xml;
Expand Down Expand Up @@ -333,19 +336,28 @@ impl ServoParser {
}
}

// https://html.spec.whatwg.org/multipage/#the-end
fn finish(&self) {
assert!(!self.suspended.get());
assert!(self.last_chunk_received.get());
assert!(self.script_input.borrow().is_empty());
assert!(self.network_input.borrow().is_empty());

// Step 2.
self.tokenizer.borrow_mut().end();
debug!("finished parsing");

self.document.set_current_parser(None);

if let Some(pipeline) = self.pipeline {
ScriptThread::parsing_complete(pipeline);
if self.pipeline.is_some() {
// Step 1.
self.document.set_ready_state(DocumentReadyState::Interactive);

self.document.disarm_reflow_timeout();
self.document.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
let window = self.document.window();
window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::FirstLoad);

// Step 3.
self.document.process_deferred_scripts();
}
}
}
Expand Down
31 changes: 0 additions & 31 deletions components/script/script_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,13 +583,6 @@ impl ScriptThread {
});
}

pub fn parsing_complete(id: PipelineId) {
SCRIPT_THREAD_ROOT.with(|root| {
let script_thread = unsafe { &*root.get().unwrap() };
script_thread.handle_parsing_complete(id);
});
}

pub fn process_event(msg: CommonScriptMsg) {
SCRIPT_THREAD_ROOT.with(|root| {
if let Some(script_thread) = root.get() {
Expand Down Expand Up @@ -2163,30 +2156,6 @@ impl ScriptThread {
context.process_response_eof(Ok(()));
}

fn handle_parsing_complete(&self, id: PipelineId) {
let document = match { self.documents.borrow().find_document(id) } {
Some(document) => document,
None => return,
};

let final_url = document.url();

// https://html.spec.whatwg.org/multipage/#the-end step 1
document.set_ready_state(DocumentReadyState::Interactive);

// TODO: Execute step 2 here.

// Kick off the initial reflow of the page.
debug!("kicking off initial reflow of {:?}", final_url);
document.disarm_reflow_timeout();
document.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
let window = window_from_node(&*document);
window.reflow(ReflowGoal::ForDisplay, ReflowQueryType::NoQuery, ReflowReason::FirstLoad);

// https://html.spec.whatwg.org/multipage/#the-end steps 3-4.
document.process_deferred_scripts();
}

fn handle_css_error_reporting(&self, pipeline_id: PipelineId, filename: String,
line: usize, column: usize, msg: String) {
let sender = match self.devtools_chan {
Expand Down

0 comments on commit 70ed3e7

Please sign in to comment.