Skip to content

Commit

Permalink
Add basic HTMLDialogElement interface
Browse files Browse the repository at this point in the history
  • Loading branch information
dhodder committed Apr 4, 2015
1 parent 4ffeb81 commit 78de6b2
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/script/dom/create.rs
Expand Up @@ -18,6 +18,7 @@ use dom::htmlbuttonelement::HTMLButtonElement;
use dom::htmlcanvaselement::HTMLCanvasElement;
use dom::htmldataelement::HTMLDataElement;
use dom::htmldatalistelement::HTMLDataListElement;
use dom::htmldialogelement::HTMLDialogElement;
use dom::htmldirectoryelement::HTMLDirectoryElement;
use dom::htmldivelement::HTMLDivElement;
use dom::htmldlistelement::HTMLDListElement;
Expand Down Expand Up @@ -134,6 +135,7 @@ pub fn create_element(name: QualName, prefix: Option<DOMString>,
atom!("del") => make!(HTMLModElement),
atom!("details") => make!(HTMLElement),
atom!("dfn") => make!(HTMLElement),
atom!("dialog") => make!(HTMLDialogElement),
atom!("dir") => make!(HTMLDirectoryElement),
atom!("div") => make!(HTMLDivElement),
atom!("dl") => make!(HTMLDListElement),
Expand Down
39 changes: 39 additions & 0 deletions components/script/dom/htmldialogelement.rs
@@ -0,0 +1,39 @@
/* 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::Bindings::HTMLDialogElementBinding;
use dom::bindings::codegen::InheritTypes::HTMLDialogElementDerived;
use dom::bindings::js::{JSRef, Temporary};
use dom::document::Document;
use dom::element::ElementTypeId;
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::node::{Node, NodeTypeId};
use util::str::DOMString;

#[dom_struct]
pub struct HTMLDialogElement {
htmlelement: HTMLElement,
}

impl HTMLDialogElementDerived for EventTarget {
fn is_htmldialogelement(&self) -> bool {
*self.type_id() == EventTargetTypeId::Node(NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLDialogElement)))
}
}

impl HTMLDialogElement {
fn new_inherited(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> HTMLDialogElement {
HTMLDialogElement {
htmlelement: HTMLElement::new_inherited(HTMLElementTypeId::HTMLDialogElement, localName, prefix, document)
}
}

#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, prefix: Option<DOMString>, document: JSRef<Document>) -> Temporary<HTMLDialogElement> {
let element = HTMLDialogElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLDialogElementBinding::Wrap)
}
}

1 change: 1 addition & 0 deletions components/script/dom/htmlelement.rs
Expand Up @@ -225,6 +225,7 @@ pub enum HTMLElementTypeId {
HTMLCanvasElement,
HTMLDataElement,
HTMLDataListElement,
HTMLDialogElement,
HTMLDirectoryElement,
HTMLDListElement,
HTMLDivElement,
Expand Down
1 change: 1 addition & 0 deletions components/script/dom/mod.rs
Expand Up @@ -236,6 +236,7 @@ pub mod htmlcanvaselement;
pub mod htmlcollection;
pub mod htmldataelement;
pub mod htmldatalistelement;
pub mod htmldialogelement;
pub mod htmldirectoryelement;
pub mod htmldivelement;
pub mod htmldlistelement;
Expand Down
13 changes: 13 additions & 0 deletions components/script/dom/webidls/HTMLDialogElement.webidl
@@ -0,0 +1,13 @@
/* -*- 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/html/#htmldialogelement
interface HTMLDialogElement : HTMLElement {
//attribute boolean open;
//attribute DOMString returnValue;
//void show(optional (MouseEvent or Element) anchor);
//void showModal(optional (MouseEvent or Element) anchor);
//void close(optional DOMString returnValue);
};
2 changes: 2 additions & 0 deletions tests/content/test_collections.html
Expand Up @@ -51,6 +51,7 @@
<time datetime="2014-02-14">Valentines day</time>
<area></area>
<data></data>
<dialog></dialog>
<template></template>
<pre>pre</pre>
<audio>
Expand Down Expand Up @@ -111,6 +112,7 @@
check_tag("area", 1, [HTMLAreaElement]);
check_tag("base", 1, [HTMLBaseElement]);
check_tag("data", 1, [HTMLDataElement]);
check_tag("dialog", 1, [HTMLDialogElement]);
check_tag("ol", 1, [HTMLOListElement]);
check_tag("canvas", 1, [HTMLCanvasElement]);
check_tag("source", 2, [HTMLSourceElement]);
Expand Down
1 change: 1 addition & 0 deletions tests/content/test_node_cloneNode.html
Expand Up @@ -45,6 +45,7 @@
create_element_and_check("colgroup", HTMLTableColElement);
create_element_and_check("data", HTMLDataElement);
create_element_and_check("datalist", HTMLDataListElement);
create_element_and_check("dialog", HTMLDialogElement);
create_element_and_check("dd", HTMLElement);
create_element_and_check("del", HTMLModElement);
create_element_and_check("details", HTMLElement);
Expand Down

4 comments on commit 78de6b2

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging dhodder/servo/master = 78de6b2 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dhodder/servo/master = 78de6b2 merged ok, testing candidate = 05371a8

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.