mirror of
https://github.com/servo/servo.git
synced 2025-06-24 17:14:33 +01:00
Use parse_html
in DOMParser.
This commit is contained in:
parent
fbf42c951b
commit
96f73d67d4
2 changed files with 12 additions and 10 deletions
|
@ -14,9 +14,8 @@ use dom::bindings::js::{JS, JSRef, Temporary};
|
|||
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
||||
use dom::document::{Document, DocumentHelpers, IsHTMLDocument};
|
||||
use dom::document::DocumentSource;
|
||||
use dom::servohtmlparser::ServoHTMLParser;
|
||||
use dom::window::Window;
|
||||
use parse::Parser;
|
||||
use parse::html::{HTMLInput, parse_html};
|
||||
use servo_util::str::DOMString;
|
||||
|
||||
#[dom_struct]
|
||||
|
@ -50,23 +49,21 @@ impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
|
|||
ty: DOMParserBinding::SupportedType)
|
||||
-> Fallible<Temporary<Document>> {
|
||||
let window = self.window.root().clone();
|
||||
let url = Some(window.get_url());
|
||||
let url = window.get_url();
|
||||
let content_type = DOMParserBinding::SupportedTypeValues::strings[ty as uint].to_string();
|
||||
match ty {
|
||||
Text_html => {
|
||||
let document = Document::new(window, url.clone(),
|
||||
let document = Document::new(window, Some(url.clone()),
|
||||
IsHTMLDocument::HTMLDocument,
|
||||
Some(content_type),
|
||||
DocumentSource::FromParser).root().clone();
|
||||
let parser = ServoHTMLParser::new(url.clone(), document).root().clone();
|
||||
parser.parse_chunk(s);
|
||||
parser.finish();
|
||||
parse_html(document, HTMLInput::InputString(s), &url);
|
||||
document.set_ready_state(DocumentReadyState::Complete);
|
||||
Ok(Temporary::from_rooted(document))
|
||||
}
|
||||
Text_xml => {
|
||||
//FIXME: this should probably be FromParser when we actually parse the string (#3756).
|
||||
Ok(Document::new(window, url.clone(),
|
||||
Ok(Document::new(window, Some(url.clone()),
|
||||
IsHTMLDocument::NonHTMLDocument,
|
||||
Some(content_type),
|
||||
DocumentSource::NotFromParser))
|
||||
|
|
|
@ -168,7 +168,10 @@ pub fn parse_html(document: JSRef<Document>,
|
|||
let parser = ServoHTMLParser::new(Some(url.clone()), document).root();
|
||||
let parser: JSRef<ServoHTMLParser> = *parser;
|
||||
|
||||
task_state::enter(IN_HTML_PARSER);
|
||||
let nested_parse = task_state::get().contains(task_state::IN_HTML_PARSER);
|
||||
if !nested_parse {
|
||||
task_state::enter(IN_HTML_PARSER);
|
||||
}
|
||||
|
||||
match input {
|
||||
HTMLInput::InputString(s) => {
|
||||
|
@ -201,7 +204,9 @@ pub fn parse_html(document: JSRef<Document>,
|
|||
|
||||
parser.finish();
|
||||
|
||||
task_state::exit(IN_HTML_PARSER);
|
||||
if !nested_parse {
|
||||
task_state::exit(IN_HTML_PARSER);
|
||||
}
|
||||
|
||||
debug!("finished parsing");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue