aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/parse
diff options
context:
space:
mode:
authorConnor Brewster <brewsterc@my.caspercollege.edu>2016-04-14 14:56:38 -0600
committerConnor Brewster <brewsterc@my.caspercollege.edu>2016-04-27 08:44:13 -0600
commit3389c497c0ca740dbcd4fd56a4fc8d490f7a8592 (patch)
tree86aebd6dafad16ac7c54ebd0a366226b5ebc8836 /components/script/parse
parent2729864af73d62719ea0fd55cef417c43bdd951e (diff)
downloadservo-3389c497c0ca740dbcd4fd56a4fc8d490f7a8592.tar.gz
servo-3389c497c0ca740dbcd4fd56a4fc8d490f7a8592.zip
Finish hooking up XML parser
added script integration with xml5ever Updated test expectations Removed timeout test expectation Refactors application/xhtml+xml is treated as HTML Updated xml5ever Updated Text Expectations
Diffstat (limited to 'components/script/parse')
-rw-r--r--components/script/parse/xml.rs23
1 files changed, 21 insertions, 2 deletions
diff --git a/components/script/parse/xml.rs b/components/script/parse/xml.rs
index 6c82e5af358..74741af8806 100644
--- a/components/script/parse/xml.rs
+++ b/components/script/parse/xml.rs
@@ -11,11 +11,13 @@ use dom::comment::Comment;
use dom::document::Document;
use dom::documenttype::DocumentType;
use dom::element::{Element, ElementCreator};
+use dom::htmlscriptelement::HTMLScriptElement;
use dom::node::Node;
use dom::processinginstruction::ProcessingInstruction;
use dom::servoxmlparser;
use dom::servoxmlparser::ServoXMLParser;
use dom::text::Text;
+use html5ever;
use msg::constellation_msg::PipelineId;
use parse::Parser;
use std::borrow::Cow;
@@ -24,7 +26,7 @@ use url::Url;
use util::str::DOMString;
use xml5ever::tendril::StrTendril;
use xml5ever::tokenizer::{Attribute, QName};
-use xml5ever::tree_builder::{NodeOrText, TreeSink};
+use xml5ever::tree_builder::{NextParserState, NodeOrText, TreeSink};
impl<'a> TreeSink for servoxmlparser::Sink {
type Handle = JS<Node>;
@@ -101,6 +103,24 @@ impl<'a> TreeSink for servoxmlparser::Sink {
doc);
JS::from_ref(pi.upcast())
}
+
+ fn mark_script_already_started(&mut self, node: Self::Handle) {
+ let script = node.downcast::<HTMLScriptElement>();
+ if let Some(script) = script {
+ script.mark_already_started();
+ }
+ }
+
+ fn complete_script(&mut self, node: Self::Handle) -> NextParserState {
+ let script = node.downcast::<HTMLScriptElement>();
+ if let Some(script) = script {
+ return match script.prepare() {
+ html5ever::tree_builder::NextParserState::Continue => NextParserState::Continue,
+ html5ever::tree_builder::NextParserState::Suspend => NextParserState::Suspend
+ };
+ }
+ NextParserState::Continue
+ }
}
@@ -119,4 +139,3 @@ pub fn parse_xml(document: &Document,
};
parser.parse_chunk(String::from(input));
}
-