mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Implements some HTMLTextAreaElement attributes
These attributes all reflect their own related content values, with the exception of defaultValue, which acts as an alias for its IDL textContent attribute. Many of these do have default values and constraints which are currently unimplemented.
This commit is contained in:
parent
c6aadc5bcc
commit
fd65b5f438
2 changed files with 59 additions and 7 deletions
|
@ -7,6 +7,7 @@ use dom::attr::AttrHelpers;
|
||||||
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding;
|
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding;
|
||||||
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
|
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
|
||||||
|
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementDerived, HTMLFieldSetElementDerived};
|
use dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementDerived, HTMLFieldSetElementDerived};
|
||||||
use dom::bindings::js::{JSRef, Temporary};
|
use dom::bindings::js::{JSRef, Temporary};
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
|
@ -46,16 +47,67 @@ impl HTMLTextAreaElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> HTMLTextAreaElementMethods for JSRef<'a, HTMLTextAreaElement> {
|
impl<'a> HTMLTextAreaElementMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
|
// TODO A few of these attributes have default values and additional
|
||||||
|
// constraints
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-cols
|
||||||
|
make_uint_getter!(Cols)
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-cols
|
||||||
|
make_uint_setter!(SetCols, "cols")
|
||||||
|
|
||||||
// http://www.whatwg.org/html/#dom-fe-disabled
|
// http://www.whatwg.org/html/#dom-fe-disabled
|
||||||
make_bool_getter!(Disabled)
|
make_bool_getter!(Disabled)
|
||||||
|
|
||||||
// http://www.whatwg.org/html/#dom-fe-disabled
|
// http://www.whatwg.org/html/#dom-fe-disabled
|
||||||
make_bool_setter!(SetDisabled, "disabled")
|
make_bool_setter!(SetDisabled, "disabled")
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#attr-fe-name
|
||||||
|
make_getter!(Name)
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#attr-fe-name
|
||||||
|
make_setter!(SetName, "name")
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-placeholder
|
||||||
|
make_getter!(Placeholder)
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-placeholder
|
||||||
|
make_setter!(SetPlaceholder, "placeholder")
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-required
|
||||||
|
make_bool_getter!(Required)
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-required
|
||||||
|
make_bool_setter!(SetRequired, "required")
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-rows
|
||||||
|
make_uint_getter!(Rows)
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-rows
|
||||||
|
make_uint_setter!(SetRows, "rows")
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-wrap
|
||||||
|
make_getter!(Wrap)
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-wrap
|
||||||
|
make_setter!(SetWrap, "wrap")
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-type
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-type
|
||||||
fn Type(self) -> DOMString {
|
fn Type(self) -> DOMString {
|
||||||
"textarea".to_string()
|
"textarea".to_string()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-defaultvalue
|
||||||
|
fn DefaultValue(self) -> DOMString {
|
||||||
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
|
node.GetTextContent().unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://html.spec.whatwg.org/multipage/forms.html#dom-textarea-defaultvalue
|
||||||
|
fn SetDefaultValue(self, value: DOMString) {
|
||||||
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
|
node.SetTextContent(Some(value))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
||||||
|
|
|
@ -7,22 +7,22 @@
|
||||||
interface HTMLTextAreaElement : HTMLElement {
|
interface HTMLTextAreaElement : HTMLElement {
|
||||||
// attribute DOMString autocomplete;
|
// attribute DOMString autocomplete;
|
||||||
// attribute boolean autofocus;
|
// attribute boolean autofocus;
|
||||||
// attribute unsigned long cols;
|
attribute unsigned long cols;
|
||||||
// attribute DOMString dirName;
|
// attribute DOMString dirName;
|
||||||
attribute boolean disabled;
|
attribute boolean disabled;
|
||||||
//readonly attribute HTMLFormElement? form;
|
//readonly attribute HTMLFormElement? form;
|
||||||
// attribute DOMString inputMode;
|
// attribute DOMString inputMode;
|
||||||
// attribute long maxLength;
|
// attribute long maxLength;
|
||||||
// attribute long minLength;
|
// attribute long minLength;
|
||||||
// attribute DOMString name;
|
attribute DOMString name;
|
||||||
// attribute DOMString placeholder;
|
attribute DOMString placeholder;
|
||||||
// attribute boolean readOnly;
|
// attribute boolean readOnly;
|
||||||
// attribute boolean required;
|
attribute boolean required;
|
||||||
// attribute unsigned long rows;
|
attribute unsigned long rows;
|
||||||
// attribute DOMString wrap;
|
attribute DOMString wrap;
|
||||||
|
|
||||||
readonly attribute DOMString type;
|
readonly attribute DOMString type;
|
||||||
// attribute DOMString defaultValue;
|
attribute DOMString defaultValue;
|
||||||
//[TreatNullAs=EmptyString] attribute DOMString value;
|
//[TreatNullAs=EmptyString] attribute DOMString value;
|
||||||
//readonly attribute unsigned long textLength;
|
//readonly attribute unsigned long textLength;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue