diff --git a/components/script/dom/servohtmlparser.rs b/components/script/dom/servohtmlparser.rs index eed6efb4b20..ec01187e2b4 100644 --- a/components/script/dom/servohtmlparser.rs +++ b/components/script/dom/servohtmlparser.rs @@ -53,9 +53,6 @@ pub struct ServoHTMLParser { tokenizer: DOMRefCell, /// True if this parser should avoid passing any further data to the tokenizer. suspended: Cell, - /// The pipeline associated with this parse, unavailable if this parse does not - /// correspond to a page load. - pipeline: Option, } 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) diff --git a/components/script/dom/servoparser.rs b/components/script/dom/servoparser.rs index c5611a6364d..4a2bc0de400 100644 --- a/components/script/dom/servoparser.rs +++ b/components/script/dom/servoparser.rs @@ -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, + /// The pipeline associated with this parse, unavailable if this parse + /// does not correspond to a page load. + pipeline: Option, /// Input chunks received but not yet passed to the parser. pending_input: DOMRefCell>, /// 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, + 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 { + self.pipeline + } + pub fn has_pending_input(&self) -> bool { !self.pending_input.borrow().is_empty() } diff --git a/components/script/dom/servoxmlparser.rs b/components/script/dom/servoxmlparser.rs index 4dc9b942b7b..119dd8f4b47 100644 --- a/components/script/dom/servoxmlparser.rs +++ b/components/script/dom/servoxmlparser.rs @@ -38,9 +38,6 @@ pub struct ServoXMLParser { tokenizer: DOMRefCell, /// True if this parser should avoid passing any further data to the tokenizer. suspended: Cell, - /// The pipeline associated with this parse, unavailable if this parse does not - /// correspond to a page load. - pipeline: Option, } 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)