diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/script/dom/bindings/codegen/Bindings.conf | 5 | ||||
-rw-r--r-- | src/components/script/dom/bindings/codegen/CodegenRust.py | 2 | ||||
-rw-r--r-- | src/components/script/dom/bindings/codegen/HTMLButtonElement.webidl | 50 | ||||
-rw-r--r-- | src/components/script/dom/bindings/codegen/ValidityState.webidl | 25 | ||||
-rw-r--r-- | src/components/script/dom/bindings/node.rs | 4 | ||||
-rw-r--r-- | src/components/script/dom/element.rs | 5 | ||||
-rw-r--r-- | src/components/script/dom/htmlbuttonelement.rs | 116 | ||||
-rw-r--r-- | src/components/script/dom/validitystate.rs | 77 | ||||
-rw-r--r-- | src/components/script/html/hubbub_html_parser.rs | 6 | ||||
-rw-r--r-- | src/components/script/script.rc | 4 |
10 files changed, 291 insertions, 3 deletions
diff --git a/src/components/script/dom/bindings/codegen/Bindings.conf b/src/components/script/dom/bindings/codegen/Bindings.conf index e78a55ecbd1..360fa647e94 100644 --- a/src/components/script/dom/bindings/codegen/Bindings.conf +++ b/src/components/script/dom/bindings/codegen/Bindings.conf @@ -370,6 +370,9 @@ DOMInterfaces = { 'UIEvent': { }, +'ValidityState': { +}, + 'WebGLRenderingContext': { 'nativeType': 'mozilla::WebGLContext', 'headerFile': 'WebGLContext.h', @@ -548,6 +551,7 @@ def addHTMLElement(element): addHTMLElement('HTMLAnchorElement') addHTMLElement('HTMLAppletElement') addHTMLElement('HTMLAreaElement') +addHTMLElement('HTMLButtonElement') addHTMLElement('HTMLBaseElement') addHTMLElement('HTMLBodyElement') addHTMLElement('HTMLBRElement') @@ -556,6 +560,7 @@ addHTMLElement('HTMLDataElement') addHTMLElement('HTMLDivElement') addHTMLElement('HTMLDListElement') addHTMLElement('HTMLElement') +addHTMLElement('HTMLFormElement') addHTMLElement('HTMLHeadElement') addHTMLElement('HTMLHtmlElement') addHTMLElement('HTMLHRElement') diff --git a/src/components/script/dom/bindings/codegen/CodegenRust.py b/src/components/script/dom/bindings/codegen/CodegenRust.py index acf677d6b7d..f036c872b3d 100644 --- a/src/components/script/dom/bindings/codegen/CodegenRust.py +++ b/src/components/script/dom/bindings/codegen/CodegenRust.py @@ -4623,6 +4623,7 @@ class CGBindingRoot(CGThing): 'dom::htmlbaseelement::HTMLBaseElement', #XXXjune0cho 'dom::htmlbodyelement::HTMLBodyElement', #XXXjune0cho 'dom::htmlbrelement::HTMLBRElement', #XXXrecrack + 'dom::htmlbuttonelement::HTMLButtonElement', #XXXjdm 'dom::htmlcanvaselement::HTMLCanvasElement', 'dom::htmldataelement::HTMLDataElement', #XXXjune0cho 'dom::htmldlistelement::HTMLDListElement', @@ -4664,6 +4665,7 @@ class CGBindingRoot(CGThing): 'dom::formdata::*', #XXXjdm 'dom::mouseevent::*', #XXXjdm 'dom::uievent::*', #XXXjdm + 'dom::validitystate::*', #XXXjdm 'dom::windowproxy::*', #XXXjdm 'dom::window::Window', #XXXjdm 'dom::bindings::codegen::*', #XXXjdm diff --git a/src/components/script/dom/bindings/codegen/HTMLButtonElement.webidl b/src/components/script/dom/bindings/codegen/HTMLButtonElement.webidl new file mode 100644 index 00000000000..2160e7595be --- /dev/null +++ b/src/components/script/dom/bindings/codegen/HTMLButtonElement.webidl @@ -0,0 +1,50 @@ +/* -*- 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/#the-button-element + * © 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. + */ + +interface HTMLFormElement; + +// http://www.whatwg.org/specs/web-apps/current-work/#the-button-element +interface HTMLButtonElement : HTMLElement { + [SetterThrows, Pure] + attribute boolean autofocus; + [SetterThrows, Pure] + attribute boolean disabled; + [Pure] + readonly attribute HTMLFormElement? form; + [SetterThrows, Pure] + attribute DOMString formAction; + [SetterThrows, Pure] + attribute DOMString formEnctype; + [SetterThrows, Pure] + attribute DOMString formMethod; + [SetterThrows, Pure] + attribute boolean formNoValidate; + [SetterThrows, Pure] + attribute DOMString formTarget; + [SetterThrows, Pure] + attribute DOMString name; + [SetterThrows, Pure] + attribute DOMString type; + [SetterThrows, Pure] + attribute DOMString value; +// Not yet implemented: +// attribute HTMLMenuElement? menu; + + readonly attribute boolean willValidate; + readonly attribute ValidityState validity; + readonly attribute DOMString validationMessage; + boolean checkValidity(); + void setCustomValidity(DOMString error); + +// Not yet implemented: +// readonly attribute NodeList labels; +}; diff --git a/src/components/script/dom/bindings/codegen/ValidityState.webidl b/src/components/script/dom/bindings/codegen/ValidityState.webidl new file mode 100644 index 00000000000..d8d1d1bccd8 --- /dev/null +++ b/src/components/script/dom/bindings/codegen/ValidityState.webidl @@ -0,0 +1,25 @@ +/* -*- 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/#validitystate + * © 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. + */ + +interface ValidityState { + readonly attribute boolean valueMissing; + readonly attribute boolean typeMismatch; + readonly attribute boolean patternMismatch; + readonly attribute boolean tooLong; + readonly attribute boolean rangeUnderflow; + readonly attribute boolean rangeOverflow; + readonly attribute boolean stepMismatch; +// readonly attribute boolean badInput; + readonly attribute boolean customError; + readonly attribute boolean valid; +}; + diff --git a/src/components/script/dom/bindings/node.rs b/src/components/script/dom/bindings/node.rs index f69fd1f2225..6400230df6b 100644 --- a/src/components/script/dom/bindings/node.rs +++ b/src/components/script/dom/bindings/node.rs @@ -9,7 +9,7 @@ use dom::bindings::utils::{CacheableWrapper, WrapperCache, DerivedWrapper}; use dom::element::{HTMLElementTypeId, HTMLAnchorElementTypeId, HTMLAppletElementTypeId, HTMLAreaElementTypeId, HTMLBaseElementTypeId, - HTMLBodyElementTypeId, HTMLBRElementTypeId, + HTMLBodyElementTypeId, HTMLBRElementTypeId, HTMLButtonElementTypeId, HTMLCanvasElementTypeId, HTMLDataElementTypeId, HTMLDivElementTypeId, HTMLHeadElementTypeId, HTMLHRElementTypeId, HTMLHtmlElementTypeId, HTMLIframeElementTypeId, HTMLImageElementTypeId, @@ -30,6 +30,7 @@ use dom::htmlappletelement::HTMLAppletElement; use dom::htmlareaelement::HTMLAreaElement; use dom::htmlbaseelement::HTMLBaseElement; use dom::htmlbodyelement::HTMLBodyElement; +use dom::htmlbuttonelement::HTMLButtonElement; use dom::htmlhrelement::HTMLHRElement; use dom::htmlbrelement::HTMLBRElement; use dom::htmlcanvaselement::HTMLCanvasElement; @@ -128,6 +129,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject ElementNodeTypeId(HTMLBaseElementTypeId) => generate_element!(HTMLBaseElement), ElementNodeTypeId(HTMLBodyElementTypeId) => generate_element!(HTMLBodyElement), ElementNodeTypeId(HTMLBRElementTypeId) => generate_element!(HTMLBRElement), + ElementNodeTypeId(HTMLButtonElementTypeId) => generate_element!(HTMLButtonElement), ElementNodeTypeId(HTMLCanvasElementTypeId) => generate_element!(HTMLCanvasElement), ElementNodeTypeId(HTMLDataElementTypeId) => generate_element!(HTMLDataElement), ElementNodeTypeId(HTMLDListElementTypeId) => generate_element!(HTMLDListElement), diff --git a/src/components/script/dom/element.rs b/src/components/script/dom/element.rs index d6217d0ce54..fd6e49d1006 100644 --- a/src/components/script/dom/element.rs +++ b/src/components/script/dom/element.rs @@ -7,6 +7,7 @@ use dom::bindings::codegen::{HTMLAnchorElementBinding, HTMLAppletElementBinding, HTMLAreaElementBinding, HTMLBaseElementBinding, HTMLBodyElementBinding, HTMLBRElementBinding, + HTMLButtonElementBinding, HTMLCanvasElementBinding, HTMLDataElementBinding, HTMLDListElementBinding, HTMLDivElementBinding, HTMLHeadElementBinding, HTMLHRElementBinding, @@ -32,6 +33,7 @@ use dom::htmlareaelement::HTMLAreaElement; use dom::htmlbaseelement::HTMLBaseElement; use dom::htmlbodyelement::HTMLBodyElement; use dom::htmlbrelement::HTMLBRElement; +use dom::htmlbuttonelement::HTMLButtonElement; use dom::htmlcanvaselement::HTMLCanvasElement; use dom::htmlcollection::HTMLCollection; use dom::htmldataelement::HTMLDataElement; @@ -104,6 +106,7 @@ pub enum ElementTypeId { HTMLBaseElementTypeId, HTMLBRElementTypeId, HTMLBodyElementTypeId, + HTMLButtonElementTypeId, HTMLCanvasElementTypeId, HTMLDataElementTypeId, HTMLDListElementTypeId, @@ -224,6 +227,8 @@ generate_cacheable_wrapper!(HTMLBaseElement, HTMLBaseElementBinding::Wrap) generate_binding_object!(HTMLBaseElement) generate_cacheable_wrapper!(HTMLBodyElement, HTMLBodyElementBinding::Wrap) generate_binding_object!(HTMLBodyElement) +generate_cacheable_wrapper!(HTMLButtonElement, HTMLButtonElementBinding::Wrap) +generate_binding_object!(HTMLButtonElement) generate_cacheable_wrapper!(HTMLCanvasElement, HTMLCanvasElementBinding::Wrap) generate_binding_object!(HTMLCanvasElement) generate_cacheable_wrapper!(HTMLDListElement, HTMLDListElementBinding::Wrap) diff --git a/src/components/script/dom/htmlbuttonelement.rs b/src/components/script/dom/htmlbuttonelement.rs new file mode 100644 index 00000000000..fa831c67fd3 --- /dev/null +++ b/src/components/script/dom/htmlbuttonelement.rs @@ -0,0 +1,116 @@ +/* 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::utils::{DOMString, null_string, ErrorResult}; +use dom::htmlelement::HTMLElement; +use dom::node::{AbstractNode, ScriptView}; +use dom::validitystate::ValidityState; + +pub struct HTMLButtonElement { + parent: HTMLElement +} + +impl HTMLButtonElement { + pub fn Autofocus(&self) -> bool { + false + } + + pub fn SetAutofocus(&mut self, _autofocus: bool, _rv: &mut ErrorResult) { + } + + pub fn Disabled(&self) -> bool { + false + } + + pub fn SetDisabled(&mut self, _disabled: bool, _rv: &mut ErrorResult) { + } + + pub fn GetForm(&self) -> Option<AbstractNode<ScriptView>> { + None + } + + pub fn FormAction(&self) -> DOMString { + null_string + } + + pub fn SetFormAction(&mut self, _formaction: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn FormEnctype(&self) -> DOMString { + null_string + } + + pub fn SetFormEnctype(&mut self, _formenctype: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn FormMethod(&self) -> DOMString { + null_string + } + + pub fn SetFormMethod(&mut self, _formmethod: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn FormNoValidate(&self) -> bool { + false + } + + pub fn SetFormNoValidate(&mut self, _novalidate: bool, _rv: &mut ErrorResult) { + } + + pub fn FormTarget(&self) -> DOMString { + null_string + } + + pub fn SetFormTarget(&mut self, _formtarget: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn Name(&self) -> DOMString { + null_string + } + + pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn Type(&self) -> DOMString { + null_string + } + + pub fn SetType(&mut self, _type: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn Value(&self) -> DOMString { + null_string + } + + pub fn SetValue(&mut self, _value: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn WillValidate(&self) -> bool { + false + } + + pub fn SetWillValidate(&mut self, _will_validate: bool) { + } + + pub fn Validity(&self) -> @mut ValidityState { + @mut ValidityState::valid() + } + + pub fn SetValidity(&mut self, _validity: @mut ValidityState) { + } + + pub fn ValidationMessage(&self) -> DOMString { + null_string + } + + pub fn SetValidationMessage(&mut self, _message: &DOMString, _rv: &mut ErrorResult) { + } + + pub fn CheckValidity(&self) -> bool { + true + } + + pub fn SetCustomValidity(&mut self, _error: &DOMString) { + } +}
\ No newline at end of file diff --git a/src/components/script/dom/validitystate.rs b/src/components/script/dom/validitystate.rs new file mode 100644 index 00000000000..9bf415d64de --- /dev/null +++ b/src/components/script/dom/validitystate.rs @@ -0,0 +1,77 @@ +/* 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::utils::{WrapperCache, BindingObject, CacheableWrapper}; +use dom::bindings::codegen::ValidityStateBinding; +use js::jsapi::{JSContext, JSObject}; +use std::cast; + +pub struct ValidityState { + wrapper: WrapperCache, + state: u8 +} + +impl ValidityState { + pub fn valid() -> ValidityState { + ValidityState { + wrapper: WrapperCache::new(), + state: 0 + } + } +} + +impl ValidityState { + pub fn ValueMissing(&self) -> bool { + false + } + + pub fn TypeMismatch(&self) -> bool { + false + } + + pub fn PatternMismatch(&self) -> bool { + false + } + + pub fn TooLong(&self) -> bool { + false + } + + pub fn RangeUnderflow(&self) -> bool { + false + } + + pub fn RangeOverflow(&self) -> bool { + false + } + + pub fn StepMismatch(&self) -> bool { + false + } + + pub fn CustomError(&self) -> bool { + false + } + + pub fn Valid(&self) -> bool { + true + } +} + +impl CacheableWrapper for ValidityState { + fn get_wrappercache(&mut self) -> &mut WrapperCache { + unsafe { cast::transmute(&self.wrapper) } + } + + fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject { + let mut unused = false; + ValidityStateBinding::Wrap(cx, scope, self, &mut unused) + } +} + +impl BindingObject for ValidityState { + fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut CacheableWrapper> { + None + } +} diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index 8ed87121667..69ae559ef57 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -5,8 +5,8 @@ use dom::element::{HTMLElementTypeId, HTMLAnchorElementTypeId, HTMLAppletElementTypeId, HTMLAreaElementTypeId, HTMLBaseElementTypeId, HTMLBodyElementTypeId, - HTMLBRElementTypeId, HTMLCanvasElementTypeId, HTMLDataElementTypeId, - HTMLDivElementTypeId, HTMLDListElementTypeId, + HTMLBRElementTypeId, HTMLButtonElementTypeId, HTMLCanvasElementTypeId, + HTMLDataElementTypeId, HTMLDivElementTypeId, HTMLDListElementTypeId, HTMLFontElementTypeId, HTMLFormElementTypeId, HTMLHRElementTypeId, HTMLHeadElementTypeId, HTMLHtmlElementTypeId, HTMLImageElementTypeId, HTMLIframeElementTypeId, HTMLInputElementTypeId, @@ -34,6 +34,7 @@ use dom::htmlappletelement::HTMLAppletElement; use dom::htmlareaelement::HTMLAreaElement; use dom::htmlbaseelement::HTMLBaseElement; use dom::htmlbodyelement::HTMLBodyElement; +use dom::htmlbuttonelement::HTMLButtonElement; use dom::htmlcanvaselement::HTMLCanvasElement; use dom::htmldataelement::HTMLDataElement; use dom::htmldlistelement::HTMLDListElement; @@ -246,6 +247,7 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView> handle_element!(cx, tag, "base", HTMLBaseElementTypeId, HTMLBaseElement, []); handle_element!(cx, tag, "br", HTMLBRElementTypeId, HTMLBRElement, []); handle_element!(cx, tag, "body", HTMLBodyElementTypeId, HTMLBodyElement, []); + handle_element!(cx, tag, "button", HTMLButtonElementTypeId, HTMLButtonElement, []); handle_element!(cx, tag, "canvas", HTMLCanvasElementTypeId, HTMLCanvasElement, []); handle_element!(cx, tag, "data", HTMLDataElementTypeId, HTMLDataElement, []); handle_element!(cx, tag, "div", HTMLDivElementTypeId, HTMLDivElement, []); diff --git a/src/components/script/script.rc b/src/components/script/script.rc index 037ba1aef63..efee8a7e67a 100644 --- a/src/components/script/script.rc +++ b/src/components/script/script.rc @@ -48,6 +48,7 @@ pub mod dom { pub mod HTMLBaseElementBinding; pub mod HTMLBodyElementBinding; pub mod HTMLBRElementBinding; + pub mod HTMLButtonElementBinding; pub mod HTMLCanvasElementBinding; pub mod HTMLCollectionBinding; pub mod HTMLDataElementBinding; @@ -88,6 +89,7 @@ pub mod dom { pub mod RegisterBindings; pub mod TextBinding; pub mod UIEventBinding; + pub mod ValidityStateBinding; pub mod WindowBinding; pub mod WindowProxyBinding; } @@ -108,6 +110,7 @@ pub mod dom { pub mod htmlbaseelement; pub mod htmlbodyelement; pub mod htmlbrelement; + pub mod htmlbuttonelement; pub mod htmlcanvaselement; pub mod htmlcollection; pub mod htmldataelement; @@ -140,6 +143,7 @@ pub mod dom { pub mod mouseevent; pub mod node; pub mod uievent; + pub mod validitystate; pub mod window; pub mod windowproxy; } |