mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Generate bindings for HTMLTextAreaElement.
This commit is contained in:
parent
d0e0a16ee6
commit
c1f9f43808
11 changed files with 281 additions and 3 deletions
|
@ -564,6 +564,7 @@ addHTMLElement('HTMLStyleElement')
|
|||
addHTMLElement('HTMLTableElement')
|
||||
addHTMLElement('HTMLTableRowElement')
|
||||
addHTMLElement('HTMLTableSectionElement')
|
||||
addHTMLElement('HTMLTextAreaElement')
|
||||
|
||||
# If you add one of these, you need to make sure nsDOMQS.h has the relevant
|
||||
# macros added for it
|
||||
|
|
|
@ -4632,6 +4632,7 @@ class CGBindingRoot(CGThing):
|
|||
'dom::htmltableelement::HTMLTableElement',
|
||||
'dom::htmltablerowelement::HTMLTableRowElement',
|
||||
'dom::htmltablesectionelement::HTMLTableSectionElement',
|
||||
'dom::htmltextareaelement::HTMLTextAreaElement',
|
||||
'dom::bindings::utils::*',
|
||||
'dom::bindings::conversions::*',
|
||||
'dom::blob::*', #XXXjdm
|
||||
|
|
|
@ -0,0 +1,101 @@
|
|||
/* -*- 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-textarea-element
|
||||
* http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
|
||||
* © 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 nsIEditor;
|
||||
interface MozControllers;
|
||||
*/
|
||||
interface HTMLTextAreaElement : HTMLElement {
|
||||
// attribute DOMString autocomplete;
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean autofocus;
|
||||
[SetterThrows, Pure]
|
||||
attribute unsigned long cols;
|
||||
// attribute DOMString dirName;
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean disabled;
|
||||
/*
|
||||
[Pure]
|
||||
readonly attribute HTMLFormElement? form;
|
||||
*/
|
||||
// attribute DOMString inputMode;
|
||||
[SetterThrows, Pure]
|
||||
attribute long maxLength;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString name;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString placeholder;
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean readOnly;
|
||||
[SetterThrows, Pure]
|
||||
attribute boolean required;
|
||||
[SetterThrows, Pure]
|
||||
attribute unsigned long rows;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString wrap;
|
||||
|
||||
[Constant]
|
||||
readonly attribute DOMString type;
|
||||
[SetterThrows, Pure]
|
||||
attribute DOMString defaultValue;
|
||||
[TreatNullAs=EmptyString] attribute DOMString value;
|
||||
readonly attribute unsigned long textLength;
|
||||
|
||||
readonly attribute boolean willValidate;
|
||||
/*
|
||||
readonly attribute ValidityState validity;
|
||||
*/
|
||||
readonly attribute DOMString validationMessage;
|
||||
boolean checkValidity();
|
||||
void setCustomValidity(DOMString error);
|
||||
/*
|
||||
readonly attribute NodeList labels;
|
||||
*/
|
||||
void select();
|
||||
[Throws]
|
||||
attribute unsigned long selectionStart;
|
||||
[Throws]
|
||||
attribute unsigned long selectionEnd;
|
||||
[Throws]
|
||||
attribute DOMString selectionDirection;
|
||||
void setRangeText(DOMString replacement);
|
||||
/*
|
||||
void setRangeText(DOMString replacement, unsigned long start, unsigned long end, optional SelectionMode selectionMode);
|
||||
|
||||
[Throws]
|
||||
void setSelectionRange(unsigned long start, unsigned long end, optional DOMString direction);
|
||||
*/
|
||||
};
|
||||
/*
|
||||
partial interface HTMLTextAreaElement {
|
||||
// Mirrored chrome-only Mozilla extensions to nsIDOMHTMLTextAreaElement.
|
||||
// Please make sure to update this list of nsIDOMHTMLTextAreaElement changes.
|
||||
|
||||
[Throws, ChromeOnly]
|
||||
readonly attribute MozControllers controllers;
|
||||
};
|
||||
|
||||
partial interface HTMLTextAreaElement {
|
||||
// Mirrored chrome-only nsIDOMNSEditableElement methods. Please make sure
|
||||
// to update this list if nsIDOMNSEditableElement changes.
|
||||
|
||||
[ChromeOnly]
|
||||
readonly attribute nsIEditor? editor;
|
||||
|
||||
// This is similar to set .value on nsIDOMInput/TextAreaElements, but
|
||||
// handling of the value change is closer to the normal user input, so
|
||||
// 'change' event for example will be dispatched when focusing out the
|
||||
// element.
|
||||
[ChromeOnly]
|
||||
void setUserInput(DOMString input);
|
||||
};
|
||||
*/
|
|
@ -14,6 +14,7 @@ use dom::element::{HTMLBRElementTypeId};
|
|||
use dom::element::{HTMLParagraphElementTypeId, HTMLScriptElementTypeId, HTMLMetaElementTypeId};
|
||||
use dom::element::{HTMLOListElementTypeId, HTMLStyleElementTypeId, HTMLTableElementTypeId};
|
||||
use dom::element::{HTMLTableRowElementTypeId, HTMLTableSectionElementTypeId};
|
||||
use dom::element::{HTMLTextAreaElementTypeId};
|
||||
use dom::element::{HTMLHeadElement, HTMLHtmlElement, HTMLDivElement, HTMLSpanElement};
|
||||
use dom::element::{HTMLParagraphElement};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
|
@ -30,6 +31,7 @@ use dom::htmlstyleelement::HTMLStyleElement;
|
|||
use dom::htmltableelement::HTMLTableElement;
|
||||
use dom::htmltablerowelement::HTMLTableRowElement;
|
||||
use dom::htmltablesectionelement::HTMLTableSectionElement;
|
||||
use dom::htmltextareaelement::HTMLTextAreaElement;
|
||||
use dom::node::{AbstractNode, Node, ElementNodeTypeId, TextNodeTypeId, CommentNodeTypeId};
|
||||
use dom::node::{DoctypeNodeTypeId, ScriptView, Text};
|
||||
|
||||
|
@ -114,6 +116,7 @@ pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> *JSObject
|
|||
ElementNodeTypeId(HTMLTableElementTypeId) => generate_element!(HTMLTableElement),
|
||||
ElementNodeTypeId(HTMLTableRowElementTypeId) => generate_element!(HTMLTableRowElement),
|
||||
ElementNodeTypeId(HTMLTableSectionElementTypeId) => generate_element!(HTMLTableSectionElement),
|
||||
ElementNodeTypeId(HTMLTextAreaElementTypeId) => generate_element!(HTMLTextAreaElement),
|
||||
ElementNodeTypeId(_) => element::create(cx, node).ptr,
|
||||
CommentNodeTypeId |
|
||||
DoctypeNodeTypeId => text::create(cx, node).ptr,
|
||||
|
|
|
@ -617,7 +617,7 @@ pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: uint, _vp: *JSVal) ->
|
|||
}
|
||||
|
||||
pub fn initialize_global(global: *JSObject) {
|
||||
let protoArray = @mut ([0 as *JSObject, ..48]);
|
||||
let protoArray = @mut ([0 as *JSObject, ..49]);
|
||||
assert!(protoArray.len() == PrototypeList::id::_ID_Count as uint);
|
||||
unsafe {
|
||||
//XXXjdm we should be storing the box pointer instead of the inner
|
||||
|
|
|
@ -12,7 +12,7 @@ use dom::bindings::codegen::{HTMLParagraphElementBinding, HTMLScriptElementBindi
|
|||
use dom::bindings::codegen::{HTMLImageElementBinding, HTMLOListElementBinding};
|
||||
use dom::bindings::codegen::{HTMLMetaElementBinding, HTMLStyleElementBinding};
|
||||
use dom::bindings::codegen::{HTMLTableElementBinding, HTMLTableRowElementBinding};
|
||||
use dom::bindings::codegen::{HTMLTableSectionElementBinding};
|
||||
use dom::bindings::codegen::{HTMLTableSectionElementBinding, HTMLTextAreaElementBinding};
|
||||
use dom::bindings::utils::{null_string, str};
|
||||
use dom::bindings::utils::{BindingObject, CacheableWrapper, DOMString, ErrorResult, WrapperCache};
|
||||
use dom::clientrect::ClientRect;
|
||||
|
@ -32,6 +32,7 @@ use dom::htmlstyleelement::HTMLStyleElement;
|
|||
use dom::htmltableelement::HTMLTableElement;
|
||||
use dom::htmltablerowelement::HTMLTableRowElement;
|
||||
use dom::htmltablesectionelement::HTMLTableSectionElement;
|
||||
use dom::htmltextareaelement::HTMLTextAreaElement;
|
||||
use dom::node::{ElementNodeTypeId, Node, ScriptView, AbstractNode};
|
||||
use layout_interface::{ContentBoxQuery, ContentBoxResponse, ContentBoxesQuery};
|
||||
use layout_interface::{ContentBoxesResponse};
|
||||
|
@ -97,6 +98,7 @@ pub enum ElementTypeId {
|
|||
HTMLTableCellElementTypeId,
|
||||
HTMLTableElementTypeId,
|
||||
HTMLTableRowElementTypeId,
|
||||
HTMLTextAreaElementTypeId,
|
||||
HTMLTitleElementTypeId,
|
||||
HTMLUListElementTypeId,
|
||||
UnknownElementTypeId,
|
||||
|
@ -212,6 +214,8 @@ generate_cacheable_wrapper!(HTMLTableRowElement, HTMLTableRowElementBinding::Wra
|
|||
generate_binding_object!(HTMLTableRowElement)
|
||||
generate_cacheable_wrapper!(HTMLTableSectionElement, HTMLTableSectionElementBinding::Wrap)
|
||||
generate_binding_object!(HTMLTableSectionElement)
|
||||
generate_cacheable_wrapper!(HTMLTextAreaElement, HTMLTextAreaElementBinding::Wrap)
|
||||
generate_binding_object!(HTMLTextAreaElement)
|
||||
|
||||
//
|
||||
// Fancier elements
|
||||
|
|
155
src/components/script/dom/htmltextareaelement.rs
Normal file
155
src/components/script/dom/htmltextareaelement.rs
Normal file
|
@ -0,0 +1,155 @@
|
|||
/* 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;
|
||||
|
||||
pub struct HTMLTextAreaElement {
|
||||
parent: HTMLElement,
|
||||
}
|
||||
|
||||
impl HTMLTextAreaElement {
|
||||
pub fn Autofocus(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn SetAutofocus(&mut self, _autofocus: bool, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Cols(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn SetCols(&self, _cols: u32, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Disabled(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn SetDisabled(&mut self, _disabled: bool, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn MaxLength(&self) -> i32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn SetMaxLength(&self, _max_length: i32, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Name(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetName(&mut self, _name: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Placeholder(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetPlaceholder(&mut self, _placeholder: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn ReadOnly(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn SetReadOnly(&mut self, _read_only: bool, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Required(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn SetRequired(&mut self, _required: bool, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Rows(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn SetRows(&self, _rows: u32, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Wrap(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetWrap(&mut self, _wrap: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Type(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetType(&mut self, _type: &DOMString) {
|
||||
}
|
||||
|
||||
pub fn DefaultValue(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetDefaultValue(&mut self, _default_value: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn Value(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetValue(&mut self, _value: &DOMString) {
|
||||
}
|
||||
|
||||
pub fn TextLength(&self) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn SetTextLength(&self, _text_length: u32, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn WillValidate(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn SetWillValidate(&mut self, _will_validate: bool, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn ValidationMessage(&self) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn CheckValidity(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
pub fn SetCustomValidity(&self, _error: &DOMString) {
|
||||
}
|
||||
|
||||
pub fn Select(&self) {
|
||||
}
|
||||
|
||||
pub fn GetSelectionStart(&self, _rv: &mut ErrorResult) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn SetSelectionStart(&self, _selection_start: u32, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn GetSelectionEnd(&self, _rv: &mut ErrorResult) -> u32 {
|
||||
0
|
||||
}
|
||||
|
||||
pub fn SetSelectionEnd(&self, _selection_end: u32, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn GetSelectionDirection(&self, _rv: &mut ErrorResult) -> DOMString {
|
||||
null_string
|
||||
}
|
||||
|
||||
pub fn SetSelectionDirection(&self, _selection_direction: &DOMString, _rv: &mut ErrorResult) {
|
||||
}
|
||||
|
||||
pub fn SetRangeText(&self, _replacement: &DOMString) {
|
||||
}
|
||||
}
|
|
@ -14,7 +14,8 @@ use dom::element::{HTMLElementTypeId,
|
|||
HTMLSelectElementTypeId, HTMLSmallElementTypeId,
|
||||
HTMLSpanElementTypeId, HTMLStyleElementTypeId, HTMLTableSectionElementTypeId,
|
||||
HTMLTableCellElementTypeId, HTMLTableElementTypeId,
|
||||
HTMLTableRowElementTypeId, HTMLTitleElementTypeId, HTMLUListElementTypeId,
|
||||
HTMLTableRowElementTypeId, HTMLTextAreaElementTypeId,
|
||||
HTMLTitleElementTypeId, HTMLUListElementTypeId,
|
||||
UnknownElementTypeId};
|
||||
use dom::element::{HTMLDivElement, HTMLFontElement, HTMLFormElement,
|
||||
HTMLHeadElement, HTMLHeadingElement, HTMLHtmlElement,
|
||||
|
@ -39,6 +40,7 @@ use dom::htmlstyleelement::HTMLStyleElement;
|
|||
use dom::htmltableelement::HTMLTableElement;
|
||||
use dom::htmltablerowelement::HTMLTableRowElement;
|
||||
use dom::htmltablesectionelement::HTMLTableSectionElement;
|
||||
use dom::htmltextareaelement::HTMLTextAreaElement;
|
||||
use dom::element::{Element, Attr};
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{AbstractNode, Comment, Doctype, ElementNodeTypeId, Node, ScriptView};
|
||||
|
@ -237,6 +239,7 @@ fn build_element_from_tag(cx: *JSContext, tag: &str) -> AbstractNode<ScriptView>
|
|||
handle_element!(cx, tag, "tbody", HTMLTableSectionElementTypeId, HTMLTableSectionElement, []);
|
||||
handle_element!(cx, tag, "td", HTMLTableCellElementTypeId, HTMLTableCellElement, []);
|
||||
handle_element!(cx, tag, "table", HTMLTableElementTypeId, HTMLTableElement, []);
|
||||
handle_element!(cx, tag, "textarea",HTMLTextAreaElementTypeId, HTMLTextAreaElement, []);
|
||||
handle_element!(cx, tag, "tr", HTMLTableRowElementTypeId, HTMLTableRowElement, []);
|
||||
handle_element!(cx, tag, "title", HTMLTitleElementTypeId, HTMLTitleElement, []);
|
||||
handle_element!(cx, tag, "ul", HTMLUListElementTypeId, HTMLUListElement, []);
|
||||
|
|
|
@ -63,6 +63,7 @@ pub mod dom {
|
|||
pub mod HTMLTableElementBinding;
|
||||
pub mod HTMLTableRowElementBinding;
|
||||
pub mod HTMLTableSectionElementBinding;
|
||||
pub mod HTMLTextAreaElementBinding;
|
||||
pub mod MouseEventBinding;
|
||||
pub mod NodeBinding;
|
||||
pub mod PrototypeList;
|
||||
|
@ -99,6 +100,7 @@ pub mod dom {
|
|||
pub mod htmltableelement;
|
||||
pub mod htmltablerowelement;
|
||||
pub mod htmltablesectionelement;
|
||||
pub mod htmltextareaelement;
|
||||
pub mod mouseevent;
|
||||
pub mod node;
|
||||
pub mod uievent;
|
||||
|
|
|
@ -29,5 +29,6 @@
|
|||
<aside>aside</aside>
|
||||
<b>b</b>
|
||||
<i>i</i>
|
||||
<textarea>textarea</textarea>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -151,6 +151,13 @@ for (let i = 0, l = tagList.length; i < l; ++i) {
|
|||
window.alert(tags[0] instanceof HTMLElement);
|
||||
}
|
||||
|
||||
window.alert("HTMLTextAreaElement:");
|
||||
let tags = document.getElementsByTagName("textarea");
|
||||
window.alert(tags);
|
||||
window.alert(tags.length);
|
||||
window.alert(tags[0].tagName);
|
||||
window.alert(tags[0] instanceof HTMLTextAreaElement);
|
||||
|
||||
//TODO: Doesn't work until we throw proper exceptions instead of returning 0 on
|
||||
// unwrap failure.
|
||||
/*try {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue