aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlinputelement.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-02-03 10:40:01 -0700
committerbors-servo <metajack+bors@gmail.com>2015-02-03 10:40:01 -0700
commit2bfe5cfecdf00bb8bc0fbde957984d75fb1d1229 (patch)
tree48b64adf461f09ae8ec38ad023244a6a0586f0a9 /components/script/dom/htmlinputelement.rs
parent45ebcf1df7b2b320502136731ae429eb5498fa43 (diff)
parent67ff27293aca7d33ba4aa72bfacee1e3dbec7853 (diff)
downloadservo-2bfe5cfecdf00bb8bc0fbde957984d75fb1d1229.tar.gz
servo-2bfe5cfecdf00bb8bc0fbde957984d75fb1d1229.zip
auto merge of #4729 : yodalee/servo/issue4534-form-submission-for-button-elements, r=jdm
Sorry for the late PR for the issue #4534. This issue is more complicated than I thought, I have to un-comment the Form-related attribute in Button element. In the beginning, I modify the files in `bindings` directory, and it's ... generated files. Hope I don't make something wrong.
Diffstat (limited to 'components/script/dom/htmlinputelement.rs')
-rw-r--r--components/script/dom/htmlinputelement.rs49
1 files changed, 25 insertions, 24 deletions
diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index ede6ee71fb0..a6622cd87f1 100644
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -303,6 +303,8 @@ pub trait HTMLInputElementHelpers {
fn update_checked_state(self, checked: bool, dirty: bool);
fn get_size(&self) -> u32;
fn get_indeterminate_state(self) -> bool;
+ fn mutable(self) -> bool;
+ fn reset(self);
}
#[allow(unsafe_blocks)]
@@ -392,6 +394,29 @@ impl<'a> HTMLInputElementHelpers for JSRef<'a, HTMLInputElement> {
fn get_indeterminate_state(self) -> bool {
self.indeterminate.get()
}
+
+ // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-mutable
+ fn mutable(self) -> bool {
+ // https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-fe-mutable
+ // https://html.spec.whatwg.org/multipage/forms.html#the-readonly-attribute:concept-fe-mutable
+ let node: JSRef<Node> = NodeCast::from_ref(self);
+ !(node.get_disabled_state() || self.ReadOnly())
+ }
+
+ // https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-form-reset-control
+ fn reset(self) {
+ match self.input_type.get() {
+ InputType::InputRadio | InputType::InputCheckbox => {
+ self.update_checked_state(self.DefaultChecked(), false);
+ self.checked_changed.set(false);
+ },
+ InputType::InputImage => (),
+ _ => ()
+ }
+
+ self.SetValue(self.DefaultValue());
+ self.value_changed.set(false);
+ }
}
impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
@@ -583,32 +608,8 @@ impl<'a> FormControl<'a> for JSRef<'a, HTMLInputElement> {
fn to_element(self) -> JSRef<'a, Element> {
ElementCast::from_ref(self)
}
-
- // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-mutable
- fn mutable(self) -> bool {
- // https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-fe-mutable
- // https://html.spec.whatwg.org/multipage/forms.html#the-readonly-attribute:concept-fe-mutable
- let node: JSRef<Node> = NodeCast::from_ref(self);
- !(node.get_disabled_state() || self.ReadOnly())
- }
-
- // https://html.spec.whatwg.org/multipage/forms.html#the-input-element:concept-form-reset-control
- fn reset(self) {
- match self.input_type.get() {
- InputType::InputRadio | InputType::InputCheckbox => {
- self.update_checked_state(self.DefaultChecked(), false);
- self.checked_changed.set(false);
- },
- InputType::InputImage => (),
- _ => ()
- }
-
- self.SetValue(self.DefaultValue());
- self.value_changed.set(false);
- }
}
-
impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
fn as_element(&self) -> Temporary<Element> {
Temporary::from_rooted(ElementCast::from_ref(*self))