aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorMatthew Rasmus <mattr@zzntd.com>2014-11-29 13:24:29 -0800
committerMatthew Rasmus <mattr@zzntd.com>2014-12-05 12:21:31 -0800
commitfd65b5f43826e526eb1dced4c93b0a63b8f49121 (patch)
tree4fd9415f1ccb8b1a236a9fa0f79fdc95c5667760 /components/script/dom
parentc6aadc5bcc8fccf8a6d4bc41d2b48279fa47c4e5 (diff)
downloadservo-fd65b5f43826e526eb1dced4c93b0a63b8f49121.tar.gz
servo-fd65b5f43826e526eb1dced4c93b0a63b8f49121.zip
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.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/htmltextareaelement.rs52
-rw-r--r--components/script/dom/webidls/HTMLTextAreaElement.webidl14
2 files changed, 59 insertions, 7 deletions
diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs
index 80aad8c136c..8888178df5f 100644
--- a/components/script/dom/htmltextareaelement.rs
+++ b/components/script/dom/htmltextareaelement.rs
@@ -7,6 +7,7 @@ use dom::attr::AttrHelpers;
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding;
use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods;
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, NodeCast};
+use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
use dom::bindings::codegen::InheritTypes::{HTMLTextAreaElementDerived, HTMLFieldSetElementDerived};
use dom::bindings::js::{JSRef, Temporary};
use dom::bindings::utils::{Reflectable, Reflector};
@@ -46,16 +47,67 @@ impl 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
make_bool_getter!(Disabled)
// http://www.whatwg.org/html/#dom-fe-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
fn Type(self) -> DOMString {
"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> {
diff --git a/components/script/dom/webidls/HTMLTextAreaElement.webidl b/components/script/dom/webidls/HTMLTextAreaElement.webidl
index f3fb5b3cf40..124de2015f1 100644
--- a/components/script/dom/webidls/HTMLTextAreaElement.webidl
+++ b/components/script/dom/webidls/HTMLTextAreaElement.webidl
@@ -7,22 +7,22 @@
interface HTMLTextAreaElement : HTMLElement {
// attribute DOMString autocomplete;
// attribute boolean autofocus;
- // attribute unsigned long cols;
+ attribute unsigned long cols;
// attribute DOMString dirName;
attribute boolean disabled;
//readonly attribute HTMLFormElement? form;
// attribute DOMString inputMode;
// attribute long maxLength;
// attribute long minLength;
- // attribute DOMString name;
- // attribute DOMString placeholder;
+ attribute DOMString name;
+ attribute DOMString placeholder;
// attribute boolean readOnly;
- // attribute boolean required;
- // attribute unsigned long rows;
- // attribute DOMString wrap;
+ attribute boolean required;
+ attribute unsigned long rows;
+ attribute DOMString wrap;
readonly attribute DOMString type;
- // attribute DOMString defaultValue;
+ attribute DOMString defaultValue;
//[TreatNullAs=EmptyString] attribute DOMString value;
//readonly attribute unsigned long textLength;