mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Use html5ever for HTML parsing
This commit is contained in:
parent
3fbb25cc43
commit
9da7679367
13 changed files with 749 additions and 119 deletions
|
@ -52,12 +52,12 @@ use dom::range::Range;
|
|||
use dom::treewalker::TreeWalker;
|
||||
use dom::uievent::UIEvent;
|
||||
use dom::window::{Window, WindowHelpers};
|
||||
use html::hubbub_html_parser::build_element_from_tag;
|
||||
use hubbub::hubbub::{QuirksMode, NoQuirks, LimitedQuirks, FullQuirks};
|
||||
use parse::html::build_element_from_tag;
|
||||
use servo_util::namespace;
|
||||
use servo_util::str::{DOMString, split_html_space_chars};
|
||||
|
||||
use string_cache::Atom;
|
||||
use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
|
||||
use string_cache::{Atom, QualName};
|
||||
use url::Url;
|
||||
|
||||
use std::collections::hashmap::HashMap;
|
||||
|
@ -426,7 +426,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
fn CompatMode(self) -> DOMString {
|
||||
match self.quirks_mode.get() {
|
||||
LimitedQuirks | NoQuirks => "CSS1Compat".to_string(),
|
||||
FullQuirks => "BackCompat".to_string()
|
||||
Quirks => "BackCompat".to_string()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -492,7 +492,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
return Err(InvalidCharacter);
|
||||
}
|
||||
let local_name = local_name.as_slice().to_ascii_lower();
|
||||
Ok(build_element_from_tag(local_name, ns!(HTML), None, self))
|
||||
let name = QualName::new(ns!(HTML), Atom::from_slice(local_name.as_slice()));
|
||||
Ok(build_element_from_tag(name, None, self))
|
||||
}
|
||||
|
||||
// http://dom.spec.whatwg.org/#dom-document-createelementns
|
||||
|
@ -512,9 +513,9 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
QName => {}
|
||||
}
|
||||
|
||||
let (prefix_from_qname,
|
||||
local_name_from_qname) = get_attribute_parts(qualified_name.as_slice());
|
||||
match (&ns, prefix_from_qname.clone(), local_name_from_qname.as_slice()) {
|
||||
let (prefix_from_qname, local_name_from_qname)
|
||||
= get_attribute_parts(qualified_name.as_slice());
|
||||
match (&ns, prefix_from_qname, local_name_from_qname) {
|
||||
// throw if prefix is not null and namespace is null
|
||||
(&ns!(""), Some(_), _) => {
|
||||
debug!("Namespace can't be null with a non-null prefix");
|
||||
|
@ -536,8 +537,8 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
|||
}
|
||||
|
||||
if ns == ns!(HTML) {
|
||||
Ok(build_element_from_tag(local_name_from_qname.to_string(), ns,
|
||||
prefix_from_qname.map(|s| s.to_string()), self))
|
||||
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))
|
||||
} else {
|
||||
Ok(Element::new(local_name_from_qname.to_string(), ns,
|
||||
prefix_from_qname.map(|s| s.to_string()), self))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue