mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Remove HTMLDocument.
This commit is contained in:
parent
7190feb5e3
commit
e2617a6396
12 changed files with 10 additions and 81 deletions
|
@ -224,10 +224,6 @@ DOMInterfaces = {
|
||||||
{
|
{
|
||||||
}],
|
}],
|
||||||
|
|
||||||
'HTMLDocument': {
|
|
||||||
'customTrace': 'trace'
|
|
||||||
},
|
|
||||||
|
|
||||||
'HTMLOptionsCollection': [
|
'HTMLOptionsCollection': [
|
||||||
{
|
{
|
||||||
'nativeType': 'nsHTMLOptionCollection',
|
'nativeType': 'nsHTMLOptionCollection',
|
||||||
|
|
|
@ -3,14 +3,13 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use dom::bindings::codegen::DOMImplementationBinding;
|
use dom::bindings::codegen::DOMImplementationBinding;
|
||||||
use dom::bindings::codegen::InheritTypes::{NodeCast, DocumentCast};
|
use dom::bindings::codegen::InheritTypes::NodeCast;
|
||||||
use dom::bindings::js::JS;
|
use dom::bindings::js::JS;
|
||||||
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
||||||
use dom::bindings::utils::{Fallible, InvalidCharacter, NamespaceError};
|
use dom::bindings::utils::{Fallible, InvalidCharacter, NamespaceError};
|
||||||
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
|
use dom::bindings::utils::{QName, Name, InvalidXMLName, xml_name_type};
|
||||||
use dom::document::{Document, HTML, HTMLDocumentTypeId};
|
use dom::document::{Document, HTML, HTMLDocumentTypeId};
|
||||||
use dom::documenttype::DocumentType;
|
use dom::documenttype::DocumentType;
|
||||||
use dom::htmldocument::HTMLDocument;
|
|
||||||
use dom::htmlbodyelement::HTMLBodyElement;
|
use dom::htmlbodyelement::HTMLBodyElement;
|
||||||
use dom::htmlheadelement::HTMLHeadElement;
|
use dom::htmlheadelement::HTMLHeadElement;
|
||||||
use dom::htmlhtmlelement::HTMLHtmlElement;
|
use dom::htmlhtmlelement::HTMLHtmlElement;
|
||||||
|
@ -67,7 +66,7 @@ impl DOMImplementation {
|
||||||
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
||||||
pub fn CreateHTMLDocument(&self, title: Option<DOMString>) -> JS<Document> {
|
pub fn CreateHTMLDocument(&self, title: Option<DOMString>) -> JS<Document> {
|
||||||
// Step 1-2.
|
// Step 1-2.
|
||||||
let doc: JS<Document> = DocumentCast::from(&HTMLDocument::new(&self.owner, None));
|
let doc = Document::new(&self.owner, None, HTML, None);
|
||||||
assert!(doc.get().doctype == HTML);
|
assert!(doc.get().doctype == HTML);
|
||||||
|
|
||||||
let mut doc_node: JS<Node> = NodeCast::from(&doc);
|
let mut doc_node: JS<Node> = NodeCast::from(&doc);
|
||||||
|
|
|
@ -4,13 +4,11 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::DOMParserBinding;
|
use dom::bindings::codegen::DOMParserBinding;
|
||||||
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
|
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
|
||||||
use dom::bindings::codegen::InheritTypes::DocumentCast;
|
|
||||||
use dom::bindings::js::JS;
|
use dom::bindings::js::JS;
|
||||||
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
use dom::bindings::utils::{Reflector, Reflectable, reflect_dom_object};
|
||||||
use dom::bindings::utils::Fallible;
|
use dom::bindings::utils::Fallible;
|
||||||
use dom::bindings::utils::FailureUnknown;
|
use dom::bindings::utils::FailureUnknown;
|
||||||
use dom::document::Document;
|
use dom::document::{Document, HTML};
|
||||||
use dom::htmldocument::HTMLDocument;
|
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
|
@ -43,7 +41,7 @@ impl DOMParser {
|
||||||
-> Fallible<JS<Document>> {
|
-> Fallible<JS<Document>> {
|
||||||
match ty {
|
match ty {
|
||||||
Text_html => {
|
Text_html => {
|
||||||
Ok(DocumentCast::from(&HTMLDocument::new(&self.owner, None)))
|
Ok(Document::new(&self.owner, None, HTML, None))
|
||||||
}
|
}
|
||||||
Text_xml => {
|
Text_xml => {
|
||||||
Document::Constructor(&self.owner)
|
Document::Constructor(&self.owner)
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use dom::bindings::codegen::HTMLDocumentBinding;
|
|
||||||
use dom::bindings::codegen::InheritTypes::HTMLDocumentDerived;
|
|
||||||
use dom::bindings::js::JS;
|
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
|
||||||
use dom::document::{Document, HTML, HTMLDocumentTypeId};
|
|
||||||
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
|
||||||
use dom::node::DocumentNodeTypeId;
|
|
||||||
use dom::window::Window;
|
|
||||||
|
|
||||||
use extra::url::Url;
|
|
||||||
|
|
||||||
#[deriving(Encodable)]
|
|
||||||
pub struct HTMLDocument {
|
|
||||||
parent: Document
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HTMLDocumentDerived for EventTarget {
|
|
||||||
fn is_htmldocument(&self) -> bool {
|
|
||||||
match self.type_id {
|
|
||||||
NodeTargetTypeId(DocumentNodeTypeId(HTMLDocumentTypeId)) => true,
|
|
||||||
_ => false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl HTMLDocument {
|
|
||||||
pub fn new_inherited(window: JS<Window>, url: Option<Url>) -> HTMLDocument {
|
|
||||||
HTMLDocument {
|
|
||||||
parent: Document::new_inherited(window, url, HTML, None)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn new(window: &JS<Window>, url: Option<Url>) -> JS<HTMLDocument> {
|
|
||||||
let document = HTMLDocument::new_inherited(window.clone(), url);
|
|
||||||
Document::reflect_document(~document, window, HTMLDocumentBinding::Wrap)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Reflectable for HTMLDocument {
|
|
||||||
fn reflector<'a>(&'a self) -> &'a Reflector {
|
|
||||||
self.parent.reflector()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
|
|
||||||
self.parent.mut_reflector()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +0,0 @@
|
||||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
||||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* http://www.whatwg.org/specs/web-apps/current-work/#the-document-object */
|
|
||||||
interface HTMLDocument : Document {};
|
|
|
@ -81,7 +81,6 @@ pub mod dom {
|
||||||
pub mod htmldirectoryelement;
|
pub mod htmldirectoryelement;
|
||||||
pub mod htmldivelement;
|
pub mod htmldivelement;
|
||||||
pub mod htmldlistelement;
|
pub mod htmldlistelement;
|
||||||
pub mod htmldocument;
|
|
||||||
pub mod htmlelement;
|
pub mod htmlelement;
|
||||||
pub mod htmlembedelement;
|
pub mod htmlembedelement;
|
||||||
pub mod htmlfieldsetelement;
|
pub mod htmlfieldsetelement;
|
||||||
|
|
|
@ -6,15 +6,14 @@
|
||||||
//! and layout tasks.
|
//! and layout tasks.
|
||||||
|
|
||||||
use dom::bindings::codegen::RegisterBindings;
|
use dom::bindings::codegen::RegisterBindings;
|
||||||
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, DocumentCast, ElementCast};
|
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, ElementCast};
|
||||||
use dom::bindings::js::JS;
|
use dom::bindings::js::JS;
|
||||||
use dom::bindings::utils::{Reflectable, GlobalStaticData, with_gc_enabled};
|
use dom::bindings::utils::{Reflectable, GlobalStaticData, with_gc_enabled};
|
||||||
use dom::document::Document;
|
use dom::document::{Document, HTML};
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
||||||
use dom::event::Event;
|
use dom::event::Event;
|
||||||
use dom::eventtarget::EventTarget;
|
use dom::eventtarget::EventTarget;
|
||||||
use dom::htmldocument::HTMLDocument;
|
|
||||||
use dom::node::{Node, NodeHelpers};
|
use dom::node::{Node, NodeHelpers};
|
||||||
use dom::window::{TimerData, TimerHandle, Window};
|
use dom::window::{TimerData, TimerHandle, Window};
|
||||||
use html::hubbub_html_parser::HtmlParserResult;
|
use html::hubbub_html_parser::HtmlParserResult;
|
||||||
|
@ -718,7 +717,7 @@ impl ScriptTask {
|
||||||
// Parse HTML.
|
// Parse HTML.
|
||||||
//
|
//
|
||||||
// Note: We can parse the next document in parallel with any previous documents.
|
// Note: We can parse the next document in parallel with any previous documents.
|
||||||
let mut document = DocumentCast::from(&HTMLDocument::new(&window, Some(url.clone())));
|
let mut document = Document::new(&window, Some(url.clone()), HTML, None);
|
||||||
let html_parsing_result = hubbub_html_parser::parse_html(cx.ptr,
|
let html_parsing_result = hubbub_html_parser::parse_html(cx.ptr,
|
||||||
&mut document,
|
&mut document,
|
||||||
url.clone(),
|
url.clone(),
|
||||||
|
|
|
@ -6,7 +6,6 @@ is_a(window, Window);
|
||||||
is_a(document.documentElement, HTMLHtmlElement);
|
is_a(document.documentElement, HTMLHtmlElement);
|
||||||
is_a(document.documentElement.firstChild, HTMLHeadElement);
|
is_a(document.documentElement.firstChild, HTMLHeadElement);
|
||||||
is(document.documentElement.nextSibling, null);
|
is(document.documentElement.nextSibling, null);
|
||||||
is_a(document, HTMLDocument);
|
|
||||||
is_a(document, Document);
|
is_a(document, Document);
|
||||||
finish();
|
finish();
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -5,14 +5,14 @@
|
||||||
<script>
|
<script>
|
||||||
// test1: HTML document
|
// test1: HTML document
|
||||||
{
|
{
|
||||||
is_a(document, HTMLDocument, "test1-0, HTML document");
|
is_a(document, Document, "test1-0, HTML document");
|
||||||
is(document.contentType, "text/html", "test1-1, HTML document");
|
is(document.contentType, "text/html", "test1-1, HTML document");
|
||||||
}
|
}
|
||||||
|
|
||||||
// test2: XML document
|
// test2: XML document
|
||||||
{
|
{
|
||||||
var doc = new Document;
|
var doc = new Document;
|
||||||
is_not_a(doc, HTMLDocument, "test2-0, XML document");
|
is_a(doc, Document, "test2-0, XML document");
|
||||||
is(doc.contentType, "application/xml", "test2-1, XML document");
|
is(doc.contentType, "application/xml", "test2-1, XML document");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
var htmldoc = document.implementation.createHTMLDocument("example title");
|
var htmldoc = document.implementation.createHTMLDocument("example title");
|
||||||
isnot(htmldoc, null, "test3-0, createHTMLDocument");
|
isnot(htmldoc, null, "test3-0, createHTMLDocument");
|
||||||
is_a(htmldoc, Document, "test3-1, createHTMLDocument");
|
is_a(htmldoc, Document, "test3-1, createHTMLDocument");
|
||||||
is_a(htmldoc, HTMLDocument, "test3-2, createHTMLDocument");
|
|
||||||
is(htmldoc.childNodes.length, 2, "test3-3, createHTMLDocument");
|
is(htmldoc.childNodes.length, 2, "test3-3, createHTMLDocument");
|
||||||
|
|
||||||
is_a(htmldoc.doctype && htmldoc.doctype, DocumentType, "test3-4, createHTMLDocument");
|
is_a(htmldoc.doctype && htmldoc.doctype, DocumentType, "test3-4, createHTMLDocument");
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<body>
|
<body>
|
||||||
<div id="div1"></div>
|
<div id="div1"></div>
|
||||||
<script>
|
<script>
|
||||||
is_a(document.documentElement.parentNode, HTMLDocument);
|
is_a(document.documentElement.parentNode, Document);
|
||||||
is(document.documentElement.parentElement, null);
|
is(document.documentElement.parentElement, null);
|
||||||
|
|
||||||
var elem = document.createElement("p");
|
var elem = document.createElement("p");
|
||||||
|
|
|
@ -14,7 +14,6 @@ is_a(window.document.documentElement, Element);
|
||||||
is_a(window.document.documentElement, HTMLElement);
|
is_a(window.document.documentElement, HTMLElement);
|
||||||
is_a(window.document.documentElement, HTMLHtmlElement);
|
is_a(window.document.documentElement, HTMLHtmlElement);
|
||||||
is_a(window.document, Document);
|
is_a(window.document, Document);
|
||||||
is_a(window.document, HTMLDocument);
|
|
||||||
is(window.document.documentElement.tagName, "HTML");
|
is(window.document.documentElement.tagName, "HTML");
|
||||||
is_a(window.document.getElementsByTagName('foo-á')[0], HTMLUnknownElement);
|
is_a(window.document.getElementsByTagName('foo-á')[0], HTMLUnknownElement);
|
||||||
is(window.document.getElementsByTagName('foo-á')[0].tagName, "FOO-á");
|
is(window.document.getElementsByTagName('foo-á')[0].tagName, "FOO-á");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue