From 67f43e2b677a223ad67039d66d433b85a87c2889 Mon Sep 17 00:00:00 2001 From: Adenilson Cavalcanti Date: Tue, 22 Jul 2014 14:05:35 -0700 Subject: [PATCH] Move Parser creation to its own function (issue #849). This is the first step to implement innerHTML, as we need a way create and initialize a parser object while setting the received DOMString (which may be either text/html/whatever). --- src/components/script/html/hubbub_html_parser.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index fba020bf7af..a53acea4115 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -328,13 +328,9 @@ pub fn parse_html(page: &Page, *page.mut_url() = Some((base_url.clone(), true)); } - let mut parser = hubbub::Parser("UTF-8", false); + let mut parser = build_parser(unsafe { document.to_hubbub_node() }); debug!("created parser"); - parser.set_document_node(unsafe { document.to_hubbub_node() }); - parser.enable_scripting(true); - parser.enable_styling(true); - let (css_chan2, js_chan2) = (css_chan.clone(), js_chan.clone()); let doc_cell = RefCell::new(document); @@ -557,3 +553,11 @@ pub fn parse_html(page: &Page, } } +fn build_parser(node: hubbub::NodeDataPtr) -> hubbub::Parser { + let mut parser = hubbub::Parser("UTF-8", false); + parser.set_document_node(node); + parser.enable_scripting(true); + parser.enable_styling(true); + parser +} +