Move build_element_from_tag out of the HTML parser.

This function is not particular to the parser, so should live in the DOM.
This commit is contained in:
Ms2ger 2014-10-29 23:36:24 +01:00
parent f9b84fd870
commit 82216fd5c0
7 changed files with 248 additions and 166 deletions

View file

@ -33,7 +33,7 @@ use dom::customevent::CustomEvent;
use dom::documentfragment::DocumentFragment;
use dom::documenttype::DocumentType;
use dom::domimplementation::DOMImplementation;
use dom::element::{Element, AttributeHandlers, get_attribute_parts};
use dom::element::{Element, ScriptCreated, AttributeHandlers, get_attribute_parts};
use dom::element::{HTMLHeadElementTypeId, HTMLTitleElementTypeId};
use dom::element::{HTMLBodyElementTypeId, HTMLFrameSetElementTypeId};
use dom::event::{Event, DoesNotBubble, NotCancelable};
@ -55,7 +55,6 @@ use dom::range::Range;
use dom::treewalker::TreeWalker;
use dom::uievent::UIEvent;
use dom::window::{Window, WindowHelpers};
use parse::html::{build_element_from_tag, ScriptCreated};
use servo_util::namespace;
use servo_util::str::{DOMString, split_html_space_chars};
@ -529,7 +528,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
}
let local_name = local_name.as_slice().to_ascii_lower();
let name = QualName::new(ns!(HTML), Atom::from_slice(local_name.as_slice()));
Ok(build_element_from_tag(name, None, self, ScriptCreated))
Ok(Element::create(name, None, self, ScriptCreated))
}
// http://dom.spec.whatwg.org/#dom-document-createelementns
@ -574,8 +573,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
if ns == ns!(HTML) {
let name = QualName::new(ns!(HTML), Atom::from_slice(local_name_from_qname));
Ok(build_element_from_tag(name, prefix_from_qname.map(|s| s.to_string()), self,
ScriptCreated))
Ok(Element::create(name, prefix_from_qname.map(|s| s.to_string()), self,
ScriptCreated))
} else {
Ok(Element::new(local_name_from_qname.to_string(), ns,
prefix_from_qname.map(|s| s.to_string()), self))