aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/components/main/layout/construct.rs4
-rw-r--r--src/components/script/dom/document.rs27
-rw-r--r--src/components/script/dom/domimplementation.rs7
-rw-r--r--src/components/script/dom/domparser.rs4
-rw-r--r--src/components/script/dom/element.rs8
-rw-r--r--src/components/script/dom/htmlserializer.rs2
-rw-r--r--src/components/script/dom/node.rs34
-rw-r--r--src/components/script/script_task.rs4
8 files changed, 46 insertions, 44 deletions
diff --git a/src/components/main/layout/construct.rs b/src/components/main/layout/construct.rs
index 7ca32d95f64..66192647bcd 100644
--- a/src/components/main/layout/construct.rs
+++ b/src/components/main/layout/construct.rs
@@ -644,7 +644,7 @@ impl<'a> PostorderNodeMutTraversal for FlowConstructor<'a> {
CommentNodeTypeId |
DoctypeNodeTypeId |
DocumentFragmentNodeTypeId |
- DocumentNodeTypeId(_) |
+ DocumentNodeTypeId |
ProcessingInstructionNodeTypeId => (display::none, float::none, position::static_),
};
@@ -717,7 +717,7 @@ impl<'ln> NodeUtils for ThreadSafeLayoutNode<'ln> {
CommentNodeTypeId |
DoctypeNodeTypeId |
DocumentFragmentNodeTypeId |
- DocumentNodeTypeId(_) |
+ DocumentNodeTypeId |
ElementNodeTypeId(HTMLImageElementTypeId) => true,
ElementNodeTypeId(HTMLObjectElementTypeId) => self.has_object_data(),
ElementNodeTypeId(_) => false,
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs
index 055a4dcad6d..e839e4aa233 100644
--- a/src/components/script/dom/document.rs
+++ b/src/components/script/dom/document.rs
@@ -45,9 +45,9 @@ use std::hashmap::HashMap;
use extra::serialize::{Encoder, Encodable};
#[deriving(Eq,Encodable)]
-pub enum DocumentTypeId {
- PlainDocumentTypeId,
- HTMLDocumentTypeId
+pub enum IsHTMLDocument {
+ HTMLDocument,
+ NonHTMLDocument,
}
#[deriving(Encodable)]
@@ -59,6 +59,7 @@ pub struct Document {
implementation: Option<JS<DOMImplementation>>,
content_type: DOMString,
encoding_name: DOMString,
+ is_html_document: bool,
extra: Untraceable,
}
@@ -75,7 +76,7 @@ impl<S: Encoder> Encodable<S> for Untraceable {
impl DocumentDerived for EventTarget {
fn is_document(&self) -> bool {
match self.type_id {
- NodeTargetTypeId(DocumentNodeTypeId(_)) => true,
+ NodeTargetTypeId(DocumentNodeTypeId) => true,
_ => false
}
}
@@ -97,20 +98,23 @@ impl Document {
raw_doc
}
- pub fn new_inherited(window: JS<Window>, url: Option<Url>, doctype: DocumentTypeId, content_type: Option<DOMString>) -> Document {
+ pub fn new_inherited(window: JS<Window>,
+ url: Option<Url>,
+ is_html_document: IsHTMLDocument,
+ content_type: Option<DOMString>) -> Document {
Document {
- node: Node::new_without_doc(DocumentNodeTypeId(doctype)),
+ node: Node::new_without_doc(DocumentNodeTypeId),
reflector_: Reflector::new(),
window: window,
idmap: HashMap::new(),
implementation: None,
content_type: match content_type {
Some(string) => string.clone(),
- None => match doctype {
+ None => match is_html_document {
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
- HTMLDocumentTypeId => ~"text/html",
+ HTMLDocument => ~"text/html",
// http://dom.spec.whatwg.org/#concept-document-content-type
- PlainDocumentTypeId => ~"application/xml"
+ NonHTMLDocument => ~"application/xml"
}
},
extra: Untraceable {
@@ -123,10 +127,11 @@ impl Document {
},
// http://dom.spec.whatwg.org/#concept-document-encoding
encoding_name: ~"utf-8",
+ is_html_document: is_html_document == HTMLDocument,
}
}
- pub fn new(window: &JS<Window>, url: Option<Url>, doctype: DocumentTypeId, content_type: Option<DOMString>) -> JS<Document> {
+ pub fn new(window: &JS<Window>, url: Option<Url>, doctype: IsHTMLDocument, content_type: Option<DOMString>) -> JS<Document> {
let document = Document::new_inherited(window.clone(), url, doctype, content_type);
Document::reflect_document(~document, window, DocumentBinding::Wrap)
}
@@ -135,7 +140,7 @@ impl Document {
impl Document {
// http://dom.spec.whatwg.org/#dom-document
pub fn Constructor(owner: &JS<Window>) -> Fallible<JS<Document>> {
- Ok(Document::new(owner, None, PlainDocumentTypeId, None))
+ Ok(Document::new(owner, None, NonHTMLDocument, None))
}
}
diff --git a/src/components/script/dom/domimplementation.rs b/src/components/script/dom/domimplementation.rs
index ee9af6206c9..86968680741 100644
--- a/src/components/script/dom/domimplementation.rs
+++ b/src/components/script/dom/domimplementation.rs
@@ -8,13 +8,13 @@ use dom::bindings::js::JS;
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
use dom::bindings::utils::{Fallible, InvalidCharacter, NamespaceError};
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
-use dom::document::{Document, HTMLDocumentTypeId};
+use dom::document::{Document, HTMLDocument};
use dom::documenttype::DocumentType;
use dom::htmlbodyelement::HTMLBodyElement;
use dom::htmlheadelement::HTMLHeadElement;
use dom::htmlhtmlelement::HTMLHtmlElement;
use dom::htmltitleelement::HTMLTitleElement;
-use dom::node::{Node, DocumentNodeTypeId, NodeHelpers, INode};
+use dom::node::{Node, INode};
use dom::text::Text;
use dom::window::Window;
use servo_util::str::DOMString;
@@ -66,9 +66,8 @@ impl DOMImplementation {
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
pub fn CreateHTMLDocument(&self, title: Option<DOMString>) -> JS<Document> {
// Step 1-2.
- let doc = Document::new(&self.owner, None, HTMLDocumentTypeId, None);
+ let doc = Document::new(&self.owner, None, HTMLDocument, None);
let mut doc_node: JS<Node> = NodeCast::from(&doc);
- assert!(doc_node.type_id() == DocumentNodeTypeId(HTMLDocumentTypeId));
{
// Step 3.
diff --git a/src/components/script/dom/domparser.rs b/src/components/script/dom/domparser.rs
index f95a8e853e5..f66e737a5f8 100644
--- a/src/components/script/dom/domparser.rs
+++ b/src/components/script/dom/domparser.rs
@@ -8,7 +8,7 @@ use dom::bindings::js::JS;
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
use dom::bindings::utils::Fallible;
use dom::bindings::utils::FailureUnknown;
-use dom::document::{Document, HTMLDocumentTypeId};
+use dom::document::{Document, HTMLDocument};
use dom::window::Window;
use servo_util::str::DOMString;
@@ -41,7 +41,7 @@ impl DOMParser {
-> Fallible<JS<Document>> {
match ty {
Text_html => {
- Ok(Document::new(&self.owner, None, HTMLDocumentTypeId, None))
+ Ok(Document::new(&self.owner, None, HTMLDocument, None))
}
Text_xml => {
Document::Constructor(&self.owner)
diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs
index 44a4a401e74..d7bbaa065a6 100644
--- a/src/components/script/dom/element.rs
+++ b/src/components/script/dom/element.rs
@@ -16,12 +16,12 @@ use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
use dom::htmlcollection::HTMLCollection;
use dom::clientrect::ClientRect;
use dom::clientrectlist::ClientRectList;
-use dom::document::{Document, HTMLDocumentTypeId};
+use dom::document::Document;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlimageelement::HTMLImageElement;
use dom::htmliframeelement::HTMLIFrameElement;
use dom::htmlobjectelement::HTMLObjectElement;
-use dom::node::{DocumentNodeTypeId, ElementNodeTypeId, Node, NodeHelpers, NodeIterator};
+use dom::node::{ElementNodeTypeId, Node, NodeHelpers, NodeIterator};
use dom::htmlserializer::serialize;
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
use layout_interface::{ContentBoxesResponse, ContentChangedDocumentDamage};
@@ -152,10 +152,8 @@ impl Element {
}
pub fn html_element_in_html_document(&self) -> bool {
- let owner = self.node.owner_doc();
self.namespace == namespace::HTML &&
- // FIXME: check that this matches what the spec calls "is in an HTML document"
- owner.get().node.type_id == DocumentNodeTypeId(HTMLDocumentTypeId)
+ self.node.owner_doc().get().is_html_document
}
pub fn get_attribute(&self,
diff --git a/src/components/script/dom/htmlserializer.rs b/src/components/script/dom/htmlserializer.rs
index 17e1b099b41..482c724666b 100644
--- a/src/components/script/dom/htmlserializer.rs
+++ b/src/components/script/dom/htmlserializer.rs
@@ -52,7 +52,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> ~str {
DocumentFragmentNodeTypeId => {
~""
}
- DocumentNodeTypeId(_) => {
+ DocumentNodeTypeId => {
fail!("It shouldn't be possible to serialize a document node")
}
}
diff --git a/src/components/script/dom/node.rs b/src/components/script/dom/node.rs
index 4526b45dd8b..a0357c92ab4 100644
--- a/src/components/script/dom/node.rs
+++ b/src/components/script/dom/node.rs
@@ -12,7 +12,7 @@ use dom::bindings::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::utils::{ErrorResult, Fallible, NotFound, HierarchyRequest};
use dom::bindings::utils;
use dom::characterdata::CharacterData;
-use dom::document::{Document, DocumentTypeId};
+use dom::document::Document;
use dom::documenttype::DocumentType;
use dom::element::{Element, ElementTypeId, HTMLAnchorElementTypeId};
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@@ -101,7 +101,7 @@ impl NodeFlags {
pub fn new(type_id: NodeTypeId) -> NodeFlags {
let mut flags = NodeFlags(0);
match type_id {
- DocumentNodeTypeId(_) => { flags.set_is_in_doc(true); }
+ DocumentNodeTypeId => { flags.set_is_in_doc(true); }
_ => {}
}
flags
@@ -208,7 +208,7 @@ pub enum NodeTypeId {
DoctypeNodeTypeId,
DocumentFragmentNodeTypeId,
CommentNodeTypeId,
- DocumentNodeTypeId(DocumentTypeId),
+ DocumentNodeTypeId,
ElementNodeTypeId(ElementTypeId),
TextNodeTypeId,
ProcessingInstructionNodeTypeId,
@@ -362,7 +362,7 @@ impl NodeHelpers for JS<Node> {
#[inline]
fn is_document(&self) -> bool {
match self.type_id() {
- DocumentNodeTypeId(..) => true,
+ DocumentNodeTypeId => true,
_ => false
}
}
@@ -804,7 +804,7 @@ impl Node {
TextNodeTypeId => 3,
ProcessingInstructionNodeTypeId => 7,
CommentNodeTypeId => 8,
- DocumentNodeTypeId(_) => 9,
+ DocumentNodeTypeId => 9,
DoctypeNodeTypeId => 10,
DocumentFragmentNodeTypeId => 11,
}
@@ -829,7 +829,7 @@ impl Node {
doctype.get().name.clone()
},
DocumentFragmentNodeTypeId => ~"#document-fragment",
- DocumentNodeTypeId(_) => ~"#document"
+ DocumentNodeTypeId => ~"#document"
}
}
@@ -847,7 +847,7 @@ impl Node {
ProcessingInstructionNodeTypeId |
DoctypeNodeTypeId |
DocumentFragmentNodeTypeId => Some(self.owner_doc()),
- DocumentNodeTypeId(_) => None
+ DocumentNodeTypeId => None
}
}
@@ -931,7 +931,7 @@ impl Node {
Some(characterdata.get().Data())
}
DoctypeNodeTypeId |
- DocumentNodeTypeId(_) => {
+ DocumentNodeTypeId => {
None
}
}
@@ -975,7 +975,7 @@ impl Node {
-> Fallible<JS<Node>> {
// Step 1.
match parent.type_id() {
- DocumentNodeTypeId(..) |
+ DocumentNodeTypeId |
DocumentFragmentNodeTypeId |
ElementNodeTypeId(..) => (),
_ => return Err(HierarchyRequest)
@@ -1010,12 +1010,12 @@ impl Node {
ElementNodeTypeId(_) |
ProcessingInstructionNodeTypeId |
CommentNodeTypeId => (),
- DocumentNodeTypeId(..) => return Err(HierarchyRequest)
+ DocumentNodeTypeId => return Err(HierarchyRequest)
}
// Step 6.
match parent.type_id() {
- DocumentNodeTypeId(_) => {
+ DocumentNodeTypeId => {
match node.type_id() {
// Step 6.1
DocumentFragmentNodeTypeId => {
@@ -1084,7 +1084,7 @@ impl Node {
TextNodeTypeId |
ProcessingInstructionNodeTypeId |
CommentNodeTypeId => (),
- DocumentNodeTypeId(_) => unreachable!(),
+ DocumentNodeTypeId => unreachable!(),
}
},
_ => (),
@@ -1252,7 +1252,7 @@ impl Node {
document.get().content_changed();
}
DoctypeNodeTypeId |
- DocumentNodeTypeId(_) => {}
+ DocumentNodeTypeId => {}
}
Ok(())
}
@@ -1279,7 +1279,7 @@ impl Node {
-> Fallible<JS<Node>> {
// Step 1.
match parent.type_id() {
- DocumentNodeTypeId(..) |
+ DocumentNodeTypeId |
DocumentFragmentNodeTypeId |
ElementNodeTypeId(..) => (),
_ => return Err(HierarchyRequest)
@@ -1305,12 +1305,12 @@ impl Node {
TextNodeTypeId |
ProcessingInstructionNodeTypeId |
CommentNodeTypeId => (),
- DocumentNodeTypeId(..) => return Err(HierarchyRequest)
+ DocumentNodeTypeId => return Err(HierarchyRequest)
}
// Step 6.
match parent.type_id() {
- DocumentNodeTypeId(..) => {
+ DocumentNodeTypeId => {
match node.type_id() {
// Step 6.1
DocumentFragmentNodeTypeId => {
@@ -1358,7 +1358,7 @@ impl Node {
TextNodeTypeId |
ProcessingInstructionNodeTypeId |
CommentNodeTypeId => (),
- DocumentNodeTypeId(..) => unreachable!()
+ DocumentNodeTypeId => unreachable!()
}
},
_ => ()
diff --git a/src/components/script/script_task.rs b/src/components/script/script_task.rs
index 971fa215da8..a9a284ad21f 100644
--- a/src/components/script/script_task.rs
+++ b/src/components/script/script_task.rs
@@ -9,7 +9,7 @@ use dom::bindings::codegen::RegisterBindings;
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, ElementCast};
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable, GlobalStaticData, with_gc_enabled};
-use dom::document::{Document, HTMLDocumentTypeId};
+use dom::document::{Document, HTMLDocument};
use dom::element::Element;
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
use dom::event::Event;
@@ -717,7 +717,7 @@ impl ScriptTask {
// Parse HTML.
//
// Note: We can parse the next document in parallel with any previous documents.
- let mut document = Document::new(&window, Some(url.clone()), HTMLDocumentTypeId, None);
+ let mut document = Document::new(&window, Some(url.clone()), HTMLDocument, None);
let html_parsing_result = hubbub_html_parser::parse_html(cx.ptr,
&mut document,
url.clone(),