Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up the parsers into a single interface #13675

Merged
merged 9 commits into from Oct 11, 2016
Prev

Merge script::parse and script::dom::servoparser

  • Loading branch information
nox committed Oct 11, 2016
commit 4b813e0bdc4c7e908a9ce3f145cf453c4778e2b9
@@ -18,9 +18,9 @@ use dom::bindings::str::DOMString;
use dom::document::{Document, IsHTMLDocument};
use dom::document::DocumentSource;
use dom::globalscope::GlobalScope;
use dom::servoparser::html::{ParseContext, parse_html};
use dom::servoparser::xml::{self, parse_xml};
use dom::window::Window;
use parse::html::{ParseContext, parse_html};
use parse::xml::{self, parse_xml};

#[dom_struct]
pub struct DOMParser {
@@ -47,6 +47,7 @@ use dom::htmltextareaelement::{HTMLTextAreaElement, LayoutHTMLTextAreaElementHel
use dom::nodelist::NodeList;
use dom::processinginstruction::ProcessingInstruction;
use dom::range::WeakRangeVec;
use dom::servoparser::html::parse_html_fragment;
use dom::svgsvgelement::{SVGSVGElement, LayoutSVGSVGElementHelpers};
use dom::text::Text;
use dom::virtualmethods::{VirtualMethods, vtable_for};
@@ -59,7 +60,6 @@ use html5ever::tree_builder::QuirksMode;
use js::jsapi::{JSContext, JSObject, JSRuntime};
use libc::{self, c_void, uintptr_t};
use msg::constellation_msg::PipelineId;
use parse::html::parse_html_fragment;
use ref_slice::ref_slice;
use script_layout_interface::{HTMLCanvasData, OpaqueStyleAndLayoutData, SVGSVGData};
use script_layout_interface::{LayoutElementType, LayoutNodeType, TrustedNodeAddress};
@@ -23,7 +23,6 @@ use dom::htmltemplateelement::HTMLTemplateElement;
use dom::node::{document_from_node, window_from_node};
use dom::node::Node;
use dom::processinginstruction::ProcessingInstruction;
use dom::servoparser::{ServoParser, Tokenizer};
use dom::text::Text;
use html5ever::Attribute;
use html5ever::serialize::{AttrRef, Serializable, Serializer};
@@ -34,10 +33,10 @@ use html5ever::tokenizer::{Tokenizer as HtmlTokenizer, TokenizerOpts};
use html5ever::tree_builder::{NextParserState, NodeOrText, QuirksMode};
use html5ever::tree_builder::{TreeBuilder, TreeBuilderOpts, TreeSink};
use msg::constellation_msg::PipelineId;
use parse::Sink;
use std::borrow::Cow;
use std::io::{self, Write};
use string_cache::QualName;
use super::{LastChunkState, ServoParser, Sink, Tokenizer};
use url::Url;

fn insert(parent: &Node, reference_child: Option<&Node>, child: NodeOrText<JS<Node>>) {
@@ -279,7 +278,8 @@ pub fn parse_html(document: &Document,
let tb = TreeBuilder::new(sink, options);
let tok = HtmlTokenizer::new(tb, Default::default());

ServoParser::new(document, owner, Tokenizer::HTML(tok), false)
ServoParser::new(
document, owner, Tokenizer::HTML(tok), LastChunkState::NotReceived)
},
ParseContext::Fragment(fc) => {
let tb = TreeBuilder::new_for_fragment(
@@ -294,7 +294,8 @@ pub fn parse_html(document: &Document,
};
let tok = HtmlTokenizer::new(tb, tok_options);

ServoParser::new(document, None, Tokenizer::HTML(tok), true)
ServoParser::new(
document, None, Tokenizer::HTML(tok), LastChunkState::Received)
}
};
parser.parse_chunk(String::from(input));
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.