mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Kill ServoParser::pipeline
This commit is contained in:
parent
90839305ae
commit
d8238646a0
5 changed files with 20 additions and 48 deletions
|
@ -530,11 +530,6 @@ impl Document {
|
||||||
self.reflow_timeout.set(Some(timeout))
|
self.reflow_timeout.set(Some(timeout))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disables any pending reflow timeouts.
|
|
||||||
pub fn disarm_reflow_timeout(&self) {
|
|
||||||
self.reflow_timeout.set(None)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Remove any existing association between the provided id and any elements in this document.
|
/// Remove any existing association between the provided id and any elements in this document.
|
||||||
pub fn unregister_named_element(&self, to_unregister: &Element, id: Atom) {
|
pub fn unregister_named_element(&self, to_unregister: &Element, id: Atom) {
|
||||||
debug!("Removing named element from document {:p}: {:p} id={}",
|
debug!("Removing named element from document {:p}: {:p} id={}",
|
||||||
|
@ -1556,6 +1551,15 @@ impl Document {
|
||||||
self.process_deferred_scripts();
|
self.process_deferred_scripts();
|
||||||
},
|
},
|
||||||
LoadType::PageSource(_) => {
|
LoadType::PageSource(_) => {
|
||||||
|
if self.browsing_context.is_some() {
|
||||||
|
// Disarm the reflow timer and trigger the initial reflow.
|
||||||
|
self.reflow_timeout.set(None);
|
||||||
|
self.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
|
||||||
|
self.window.reflow(ReflowGoal::ForDisplay,
|
||||||
|
ReflowQueryType::NoQuery,
|
||||||
|
ReflowReason::FirstLoad);
|
||||||
|
}
|
||||||
|
|
||||||
// Deferred scripts have to wait for page to finish loading,
|
// Deferred scripts have to wait for page to finish loading,
|
||||||
// this is the first opportunity to process them.
|
// this is the first opportunity to process them.
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl DOMParserMethods for DOMParser {
|
||||||
loader,
|
loader,
|
||||||
None,
|
None,
|
||||||
None);
|
None);
|
||||||
ServoParser::parse_html_document(&document, s, url, None);
|
ServoParser::parse_html_document(&document, s, url);
|
||||||
document.set_ready_state(DocumentReadyState::Complete);
|
document.set_ready_state(DocumentReadyState::Complete);
|
||||||
Ok(document)
|
Ok(document)
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ impl DOMParserMethods for DOMParser {
|
||||||
loader,
|
loader,
|
||||||
None,
|
None,
|
||||||
None);
|
None);
|
||||||
ServoParser::parse_xml_document(&document, s, url, None);
|
ServoParser::parse_xml_document(&document, s, url);
|
||||||
Ok(document)
|
Ok(document)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,9 +20,8 @@ use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlformelement::HTMLFormElement;
|
use dom::htmlformelement::HTMLFormElement;
|
||||||
use dom::htmlimageelement::HTMLImageElement;
|
use dom::htmlimageelement::HTMLImageElement;
|
||||||
use dom::htmlscriptelement::{HTMLScriptElement, ScriptResult};
|
use dom::htmlscriptelement::{HTMLScriptElement, ScriptResult};
|
||||||
use dom::node::{Node, NodeDamage, NodeSiblingIterator};
|
use dom::node::{Node, NodeSiblingIterator};
|
||||||
use dom::text::Text;
|
use dom::text::Text;
|
||||||
use dom::window::ReflowReason;
|
|
||||||
use encoding::all::UTF_8;
|
use encoding::all::UTF_8;
|
||||||
use encoding::types::{DecoderTrap, Encoding};
|
use encoding::types::{DecoderTrap, Encoding};
|
||||||
use html5ever::tokenizer::buffer_queue::BufferQueue;
|
use html5ever::tokenizer::buffer_queue::BufferQueue;
|
||||||
|
@ -35,13 +34,11 @@ use net_traits::{FetchMetadata, FetchResponseListener, Metadata, NetworkError};
|
||||||
use network_listener::PreInvoke;
|
use network_listener::PreInvoke;
|
||||||
use profile_traits::time::{TimerMetadata, TimerMetadataFrameType};
|
use profile_traits::time::{TimerMetadata, TimerMetadataFrameType};
|
||||||
use profile_traits::time::{TimerMetadataReflowType, ProfilerCategory, profile};
|
use profile_traits::time::{TimerMetadataReflowType, ProfilerCategory, profile};
|
||||||
use script_layout_interface::message::ReflowQueryType;
|
|
||||||
use script_thread::ScriptThread;
|
use script_thread::ScriptThread;
|
||||||
use servo_config::resource_files::read_resource_file;
|
use servo_config::resource_files::read_resource_file;
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use style::context::ReflowGoal;
|
|
||||||
|
|
||||||
mod html;
|
mod html;
|
||||||
mod xml;
|
mod xml;
|
||||||
|
@ -63,9 +60,6 @@ pub struct ServoParser {
|
||||||
reflector: Reflector,
|
reflector: Reflector,
|
||||||
/// The document associated with this parser.
|
/// The document associated with this parser.
|
||||||
document: JS<Document>,
|
document: JS<Document>,
|
||||||
/// The pipeline associated with this parse, unavailable if this parse
|
|
||||||
/// does not correspond to a page load.
|
|
||||||
pipeline: Option<PipelineId>,
|
|
||||||
/// Input received from network.
|
/// Input received from network.
|
||||||
#[ignore_heap_size_of = "Defined in html5ever"]
|
#[ignore_heap_size_of = "Defined in html5ever"]
|
||||||
network_input: DOMRefCell<BufferQueue>,
|
network_input: DOMRefCell<BufferQueue>,
|
||||||
|
@ -89,9 +83,8 @@ enum LastChunkState {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ServoParser {
|
impl ServoParser {
|
||||||
pub fn parse_html_document(document: &Document, input: DOMString, url: ServoUrl, owner: Option<PipelineId>) {
|
pub fn parse_html_document(document: &Document, input: DOMString, url: ServoUrl) {
|
||||||
let parser = ServoParser::new(document,
|
let parser = ServoParser::new(document,
|
||||||
owner,
|
|
||||||
Tokenizer::Html(self::html::Tokenizer::new(document, url, None)),
|
Tokenizer::Html(self::html::Tokenizer::new(document, url, None)),
|
||||||
LastChunkState::NotReceived);
|
LastChunkState::NotReceived);
|
||||||
parser.parse_chunk(String::from(input));
|
parser.parse_chunk(String::from(input));
|
||||||
|
@ -131,7 +124,6 @@ impl ServoParser {
|
||||||
};
|
};
|
||||||
|
|
||||||
let parser = ServoParser::new(&document,
|
let parser = ServoParser::new(&document,
|
||||||
None,
|
|
||||||
Tokenizer::Html(self::html::Tokenizer::new(&document,
|
Tokenizer::Html(self::html::Tokenizer::new(&document,
|
||||||
url.clone(),
|
url.clone(),
|
||||||
Some(fragment_context))),
|
Some(fragment_context))),
|
||||||
|
@ -145,9 +137,8 @@ impl ServoParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_xml_document(document: &Document, input: DOMString, url: ServoUrl, owner: Option<PipelineId>) {
|
pub fn parse_xml_document(document: &Document, input: DOMString, url: ServoUrl) {
|
||||||
let parser = ServoParser::new(document,
|
let parser = ServoParser::new(document,
|
||||||
owner,
|
|
||||||
Tokenizer::Xml(self::xml::Tokenizer::new(document, url)),
|
Tokenizer::Xml(self::xml::Tokenizer::new(document, url)),
|
||||||
LastChunkState::NotReceived);
|
LastChunkState::NotReceived);
|
||||||
parser.parse_chunk(String::from(input));
|
parser.parse_chunk(String::from(input));
|
||||||
|
@ -234,14 +225,12 @@ impl ServoParser {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
fn new_inherited(document: &Document,
|
fn new_inherited(document: &Document,
|
||||||
pipeline: Option<PipelineId>,
|
|
||||||
tokenizer: Tokenizer,
|
tokenizer: Tokenizer,
|
||||||
last_chunk_state: LastChunkState)
|
last_chunk_state: LastChunkState)
|
||||||
-> Self {
|
-> Self {
|
||||||
ServoParser {
|
ServoParser {
|
||||||
reflector: Reflector::new(),
|
reflector: Reflector::new(),
|
||||||
document: JS::from_ref(document),
|
document: JS::from_ref(document),
|
||||||
pipeline: pipeline,
|
|
||||||
network_input: DOMRefCell::new(BufferQueue::new()),
|
network_input: DOMRefCell::new(BufferQueue::new()),
|
||||||
script_input: DOMRefCell::new(BufferQueue::new()),
|
script_input: DOMRefCell::new(BufferQueue::new()),
|
||||||
tokenizer: DOMRefCell::new(tokenizer),
|
tokenizer: DOMRefCell::new(tokenizer),
|
||||||
|
@ -253,11 +242,10 @@ impl ServoParser {
|
||||||
|
|
||||||
#[allow(unrooted_must_root)]
|
#[allow(unrooted_must_root)]
|
||||||
fn new(document: &Document,
|
fn new(document: &Document,
|
||||||
pipeline: Option<PipelineId>,
|
|
||||||
tokenizer: Tokenizer,
|
tokenizer: Tokenizer,
|
||||||
last_chunk_state: LastChunkState)
|
last_chunk_state: LastChunkState)
|
||||||
-> Root<Self> {
|
-> Root<Self> {
|
||||||
reflect_dom_object(box ServoParser::new_inherited(document, pipeline, tokenizer, last_chunk_state),
|
reflect_dom_object(box ServoParser::new_inherited(document, tokenizer, last_chunk_state),
|
||||||
document.window(),
|
document.window(),
|
||||||
ServoParserBinding::Wrap)
|
ServoParserBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
@ -345,16 +333,6 @@ impl ServoParser {
|
||||||
self.tokenizer.borrow_mut().end();
|
self.tokenizer.borrow_mut().end();
|
||||||
self.document.set_current_parser(None);
|
self.document.set_current_parser(None);
|
||||||
|
|
||||||
if self.pipeline.is_some() {
|
|
||||||
// Initial reflow.
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Steps 3-12 are in another castle, namely finish_load.
|
// Steps 3-12 are in another castle, namely finish_load.
|
||||||
let url = self.tokenizer.borrow().url().clone();
|
let url = self.tokenizer.borrow().url().clone();
|
||||||
self.document.finish_load(LoadType::PageSource(url));
|
self.document.finish_load(LoadType::PageSource(url));
|
||||||
|
|
|
@ -1181,7 +1181,7 @@ impl XMLHttpRequest {
|
||||||
self.response_json.get()
|
self.response_json.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn document_text_html(&self) -> Root<Document>{
|
fn document_text_html(&self) -> Root<Document> {
|
||||||
let charset = self.final_charset().unwrap_or(UTF_8);
|
let charset = self.final_charset().unwrap_or(UTF_8);
|
||||||
let wr = self.global();
|
let wr = self.global();
|
||||||
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
|
let decoded = charset.decode(&self.response.borrow(), DecoderTrap::Replace).unwrap();
|
||||||
|
@ -1190,8 +1190,7 @@ impl XMLHttpRequest {
|
||||||
ServoParser::parse_html_document(
|
ServoParser::parse_html_document(
|
||||||
&document,
|
&document,
|
||||||
DOMString::from(decoded),
|
DOMString::from(decoded),
|
||||||
wr.get_url(),
|
wr.get_url());
|
||||||
Some(wr.pipeline_id()));
|
|
||||||
document
|
document
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1204,8 +1203,7 @@ impl XMLHttpRequest {
|
||||||
ServoParser::parse_xml_document(
|
ServoParser::parse_xml_document(
|
||||||
&document,
|
&document,
|
||||||
DOMString::from(decoded),
|
DOMString::from(decoded),
|
||||||
wr.get_url(),
|
wr.get_url());
|
||||||
Some(wr.pipeline_id()));
|
|
||||||
document
|
document
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1849,17 +1849,9 @@ impl ScriptThread {
|
||||||
document.set_https_state(metadata.https_state);
|
document.set_https_state(metadata.https_state);
|
||||||
|
|
||||||
if is_html_document == IsHTMLDocument::NonHTMLDocument {
|
if is_html_document == IsHTMLDocument::NonHTMLDocument {
|
||||||
ServoParser::parse_xml_document(
|
ServoParser::parse_xml_document(&document, parse_input, final_url);
|
||||||
&document,
|
|
||||||
parse_input,
|
|
||||||
final_url,
|
|
||||||
Some(incomplete.pipeline_id));
|
|
||||||
} else {
|
} else {
|
||||||
ServoParser::parse_html_document(
|
ServoParser::parse_html_document(&document, parse_input, final_url);
|
||||||
&document,
|
|
||||||
parse_input,
|
|
||||||
final_url,
|
|
||||||
Some(incomplete.pipeline_id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if incomplete.is_frozen {
|
if incomplete.is_frozen {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue