Skip to content

Commit

Permalink
Generate bindings for HTMLFormElement.
Browse files Browse the repository at this point in the history
  • Loading branch information
sonwow committed Aug 29, 2013
1 parent 65c6435 commit c9f9d29
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/script/dom/bindings/codegen/Bindings.conf
Expand Up @@ -570,7 +570,7 @@ addHTMLElement('HTMLElement')
addHTMLElement('HTMLEmbedElement')
addHTMLElement('HTMLFieldSetElement')
addHTMLElement('HTMLFontElement')
#addHTMLElement('HTMLFormElement')
addHTMLElement('HTMLFormElement')
addHTMLElement('HTMLFrameElement')
addHTMLElement('HTMLFrameSetElement')
addHTMLElement('HTMLHeadElement')
Expand Down
Expand Up @@ -10,7 +10,8 @@
* and create derivative works of this document.
*/

interface HTMLFormElement;
// FIXME: servo#707
//interface HTMLFormElement;

// http://www.whatwg.org/specs/web-apps/current-work/#the-button-element
interface HTMLButtonElement : HTMLElement {
Expand Down
48 changes: 48 additions & 0 deletions src/components/script/dom/bindings/codegen/HTMLFormElement.webidl
@@ -0,0 +1,48 @@
/* -*- 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/.
*
* The origin of this IDL file is
* http://www.whatwg.org/specs/web-apps/current-work/#htmlformelement
*
* ⓒ Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/

[OverrideBuiltins]
interface HTMLFormElement : HTMLElement {
[Pure, SetterThrows]
attribute DOMString acceptCharset;
[Pure, SetterThrows]
attribute DOMString action;
[Pure, SetterThrows]
attribute DOMString autocomplete;
[Pure, SetterThrows]
attribute DOMString enctype;
[Pure, SetterThrows]
attribute DOMString encoding;
[Pure, SetterThrows]
attribute DOMString method;
[Pure, SetterThrows]
attribute DOMString name;
[Pure, SetterThrows]
attribute boolean noValidate;
[Pure, SetterThrows]
attribute DOMString target;

[Constant]
readonly attribute HTMLCollection elements;
[Pure]
readonly attribute long length;

getter Element (unsigned long index);
// TODO this should be: getter (RadioNodeList or HTMLInputElement or HTMLImageElement) (DOMString name);
// getter nsISupports (DOMString name);

[Throws]
void submit();
void reset();
boolean checkValidity();
};
2 changes: 2 additions & 0 deletions src/components/script/dom/bindings/element.rs
Expand Up @@ -361,6 +361,8 @@ generate_cacheable_wrapper!(HTMLDataListElement, HTMLDataListElementBinding::Wra
generate_binding_object!(HTMLDataListElement)
generate_cacheable_wrapper!(HTMLDListElement, HTMLDListElementBinding::Wrap)
generate_binding_object!(HTMLDListElement)
generate_cacheable_wrapper!(HTMLFormElement, HTMLFormElementBinding::Wrap)
generate_binding_object!(HTMLFormElement)
generate_cacheable_wrapper!(HTMLFrameElement, HTMLFrameElementBinding::Wrap)
generate_binding_object!(HTMLFrameElement)
generate_cacheable_wrapper!(HTMLFrameSetElement, HTMLFrameSetElementBinding::Wrap)
Expand Down
1 change: 1 addition & 0 deletions src/components/script/dom/bindings/node.rs
Expand Up @@ -88,6 +88,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject
ElementNodeTypeId(HTMLEmbedElementTypeId) => generate_element!(HTMLEmbedElement),
ElementNodeTypeId(HTMLFieldSetElementTypeId) => generate_element!(HTMLFieldSetElement),
ElementNodeTypeId(HTMLFontElementTypeId) => generate_element!(HTMLFontElement),
ElementNodeTypeId(HTMLFormElementTypeId) => generate_element!(HTMLFormElement),
ElementNodeTypeId(HTMLFrameElementTypeId) => generate_element!(HTMLFrameElement),
ElementNodeTypeId(HTMLFrameSetElementTypeId) => generate_element!(HTMLFrameSetElement),
ElementNodeTypeId(HTMLHeadElementTypeId) => generate_element!(HTMLHeadElement),
Expand Down
106 changes: 106 additions & 0 deletions src/components/script/dom/htmlformelement.rs
Expand Up @@ -2,8 +2,114 @@
* 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::utils::{CacheableWrapper, DOMString, ErrorResult, null_string};
use dom::element::HTMLFormElementTypeId;
use dom::htmlcollection::HTMLCollection;
use dom::htmlelement::HTMLElement;
use dom::node::{AbstractNode, ElementNodeTypeId, Node, ScriptView};

use js::jsapi::{JSObject, JSContext};

pub struct HTMLFormElement {
parent: HTMLElement
}

impl HTMLFormElement {
fn get_scope_and_cx(&self) -> (*JSObject, *JSContext) {
let doc = self.parent.parent.parent.owner_doc.unwrap();
let win = doc.with_base(|doc| doc.window.unwrap());
let cx = unsafe {(*win.page).js_info.get_ref().js_compartment.cx.ptr};
let cache = win.get_wrappercache();
let scope = cache.get_wrapper();
(scope, cx)
}

pub fn AcceptCharset(&self) -> DOMString {
null_string
}

pub fn SetAcceptCharset(&mut self, _accept_charset: &DOMString, _rv: &mut ErrorResult) {
}

pub fn Action(&self) -> DOMString {
null_string
}

pub fn SetAction(&mut self, _action: &DOMString, _rv: &mut ErrorResult) {
}

pub fn Autocomplete(&self) -> DOMString {
null_string
}

pub fn SetAutocomplete(&mut self, _autocomplete: &DOMString, _rv: &mut ErrorResult) {
}

pub fn Enctype(&self) -> DOMString {
null_string
}

pub fn SetEnctype(&mut self, _enctype: &DOMString, _rv: &mut ErrorResult) {
}

pub fn Encoding(&self) -> DOMString {
null_string
}

pub fn SetEncoding(&mut self, _encoding: &DOMString, _rv: &mut ErrorResult) {
}

pub fn Method(&self) -> DOMString {
null_string
}

pub fn SetMethod(&mut self, _method: &DOMString, _rv: &mut ErrorResult) {
}

pub fn Name(&self) -> DOMString {
null_string
}

pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) {
}

pub fn NoValidate(&self) -> bool {
false
}

pub fn SetNoValidate(&mut self, _no_validate: bool, _rv: &mut ErrorResult) {
}

pub fn Target(&self) -> DOMString {
null_string
}

pub fn SetTarget(&mut self, _target: &DOMString, _rv: &mut ErrorResult) {
}

pub fn Elements(&self) -> @mut HTMLCollection {
let (scope, cx) = self.get_scope_and_cx();
HTMLCollection::new(~[], cx, scope)
}

pub fn Length(&self) -> i32 {
0
}

pub fn Submit(&self, _rv: &mut ErrorResult) {
}

pub fn Reset(&self) {
}

pub fn CheckValidity(&self) -> bool {
false
}

pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> AbstractNode<ScriptView> {
let (_scope, cx) = self.get_scope_and_cx();
// FIXME: This should be replaced with a proper value according to the index
let node = @Node::new(ElementNodeTypeId(HTMLFormElementTypeId));
unsafe { return Node::as_abstract_node(cx, node) }
}
}

5 comments on commit c9f9d29

@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.

saw approval from jdm
at sonwow@c9f9d29

@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 sonwow/servo/bindings = c9f9d29 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.

sonwow/servo/bindings = c9f9d29 merged ok, testing candidate = bc3cd8c

@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.

fast-forwarding master to auto = bc3cd8c

Please sign in to comment.