mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Introduce ServoParser::pipeline
This commit is contained in:
parent
02162a8bda
commit
1f23810a34
3 changed files with 19 additions and 15 deletions
|
@ -53,9 +53,6 @@ pub struct ServoHTMLParser {
|
|||
tokenizer: DOMRefCell<Tokenizer>,
|
||||
/// True if this parser should avoid passing any further data to the tokenizer.
|
||||
suspended: Cell<bool>,
|
||||
/// The pipeline associated with this parse, unavailable if this parse does not
|
||||
/// correspond to a page load.
|
||||
pipeline: Option<PipelineId>,
|
||||
}
|
||||
|
||||
impl<'a> Parser for &'a ServoHTMLParser {
|
||||
|
@ -76,7 +73,7 @@ impl<'a> Parser for &'a ServoHTMLParser {
|
|||
|
||||
self.upcast().document().set_current_parser(None);
|
||||
|
||||
if let Some(pipeline) = self.pipeline {
|
||||
if let Some(pipeline) = self.upcast().pipeline() {
|
||||
ScriptThread::parsing_complete(pipeline);
|
||||
}
|
||||
}
|
||||
|
@ -99,10 +96,9 @@ impl ServoHTMLParser {
|
|||
let tok = tokenizer::Tokenizer::new(tb, Default::default());
|
||||
|
||||
let parser = ServoHTMLParser {
|
||||
servoparser: ServoParser::new_inherited(document, false),
|
||||
servoparser: ServoParser::new_inherited(document, pipeline, false),
|
||||
tokenizer: DOMRefCell::new(tok),
|
||||
suspended: Cell::new(false),
|
||||
pipeline: pipeline,
|
||||
};
|
||||
|
||||
reflect_dom_object(box parser, document.window(), ServoHTMLParserBinding::Wrap)
|
||||
|
@ -132,10 +128,9 @@ impl ServoHTMLParser {
|
|||
let tok = tokenizer::Tokenizer::new(tb, tok_opts);
|
||||
|
||||
let parser = ServoHTMLParser {
|
||||
servoparser: ServoParser::new_inherited(document, true),
|
||||
servoparser: ServoParser::new_inherited(document, None, true),
|
||||
tokenizer: DOMRefCell::new(tok),
|
||||
suspended: Cell::new(false),
|
||||
pipeline: None,
|
||||
};
|
||||
|
||||
reflect_dom_object(box parser, document.window(), ServoHTMLParserBinding::Wrap)
|
||||
|
|
|
@ -6,6 +6,7 @@ use dom::bindings::cell::DOMRefCell;
|
|||
use dom::bindings::reflector::Reflector;
|
||||
use dom::bindings::js::JS;
|
||||
use dom::document::Document;
|
||||
use msg::constellation_msg::PipelineId;
|
||||
use std::cell::Cell;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -13,6 +14,9 @@ pub struct ServoParser {
|
|||
reflector: Reflector,
|
||||
/// The document associated with this parser.
|
||||
document: JS<Document>,
|
||||
/// The pipeline associated with this parse, unavailable if this parse
|
||||
/// does not correspond to a page load.
|
||||
pipeline: Option<PipelineId>,
|
||||
/// Input chunks received but not yet passed to the parser.
|
||||
pending_input: DOMRefCell<Vec<String>>,
|
||||
/// Whether to expect any further input from the associated network request.
|
||||
|
@ -20,10 +24,15 @@ pub struct ServoParser {
|
|||
}
|
||||
|
||||
impl ServoParser {
|
||||
pub fn new_inherited(document: &Document, last_chunk_received: bool) -> Self {
|
||||
pub fn new_inherited(
|
||||
document: &Document,
|
||||
pipeline: Option<PipelineId>,
|
||||
last_chunk_received: bool)
|
||||
-> Self {
|
||||
ServoParser {
|
||||
reflector: Reflector::new(),
|
||||
document: JS::from_ref(document),
|
||||
pipeline: pipeline,
|
||||
pending_input: DOMRefCell::new(vec![]),
|
||||
last_chunk_received: Cell::new(last_chunk_received),
|
||||
}
|
||||
|
@ -33,6 +42,10 @@ impl ServoParser {
|
|||
&self.document
|
||||
}
|
||||
|
||||
pub fn pipeline(&self) -> Option<PipelineId> {
|
||||
self.pipeline
|
||||
}
|
||||
|
||||
pub fn has_pending_input(&self) -> bool {
|
||||
!self.pending_input.borrow().is_empty()
|
||||
}
|
||||
|
|
|
@ -38,9 +38,6 @@ pub struct ServoXMLParser {
|
|||
tokenizer: DOMRefCell<Tokenizer>,
|
||||
/// True if this parser should avoid passing any further data to the tokenizer.
|
||||
suspended: Cell<bool>,
|
||||
/// The pipeline associated with this parse, unavailable if this parse does not
|
||||
/// correspond to a page load.
|
||||
pipeline: Option<PipelineId>,
|
||||
}
|
||||
|
||||
impl<'a> Parser for &'a ServoXMLParser {
|
||||
|
@ -61,7 +58,7 @@ impl<'a> Parser for &'a ServoXMLParser {
|
|||
|
||||
self.upcast().document().set_current_parser(None);
|
||||
|
||||
if let Some(pipeline) = self.pipeline {
|
||||
if let Some(pipeline) = self.upcast().pipeline() {
|
||||
ScriptThread::parsing_complete(pipeline);
|
||||
}
|
||||
}
|
||||
|
@ -81,10 +78,9 @@ impl ServoXMLParser {
|
|||
let tok = tokenizer::XmlTokenizer::new(tb, Default::default());
|
||||
|
||||
let parser = ServoXMLParser {
|
||||
servoparser: ServoParser::new_inherited(document, false),
|
||||
servoparser: ServoParser::new_inherited(document, pipeline, false),
|
||||
tokenizer: DOMRefCell::new(tok),
|
||||
suspended: Cell::new(false),
|
||||
pipeline: pipeline,
|
||||
};
|
||||
|
||||
reflect_dom_object(box parser, document.window(), ServoXMLParserBinding::Wrap)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue