aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authoryodalee <lc85301@gmail.com>2015-01-28 03:36:09 +0800
committeryodalee <lc85301@gmail.com>2015-02-03 20:37:06 +0800
commit0f2b1c4856036b477480a282d1246bbeefd70cdb (patch)
tree9d5368ba944b3c2252bb0ead1a6fc854dd818c19 /components/script/dom
parent15231db7d325007cdd2a20236830f04478fff50d (diff)
downloadservo-0f2b1c4856036b477480a282d1246bbeefd70cdb.tar.gz
servo-0f2b1c4856036b477480a282d1246bbeefd70cdb.zip
activation behavior for Button type Submit
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/htmlbuttonelement.rs10
-rw-r--r--components/script/dom/htmlformelement.rs27
2 files changed, 34 insertions, 3 deletions
diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs
index 7c2ff444fbe..52ee5bf56d8 100644
--- a/components/script/dom/htmlbuttonelement.rs
+++ b/components/script/dom/htmlbuttonelement.rs
@@ -15,7 +15,8 @@ use dom::element::{AttributeHandlers, Element, ElementTypeId};
use dom::element::ActivationElementHelpers;
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
-use dom::htmlformelement::{FormControl};
+use dom::htmlformelement::{FormSubmitter, FormControl, HTMLFormElementHelpers};
+use dom::htmlformelement::{SubmittedFrom};
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node};
use dom::validitystate::ValidityState;
use dom::virtualmethods::VirtualMethods;
@@ -205,6 +206,13 @@ impl<'a> Activatable for JSRef<'a, HTMLButtonElement> {
fn activation_behavior(&self) {
let ty = self.button_type.get();
match ty {
+ //https://html.spec.whatwg.org/multipage/forms.html#attr-button-type-submit-state
+ ButtonType::ButtonSubmit => {
+ self.form_owner().map(|o| {
+ o.root().r().submit(SubmittedFrom::NotFromFormSubmitMethod,
+ FormSubmitter::ButtonElement(self.clone()))
+ });
+ }
_ => ()
}
}
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index bf6fe0d1c5f..be296d04c15 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -8,6 +8,7 @@ use dom::bindings::codegen::Bindings::EventTargetBinding::EventTargetMethods;
use dom::bindings::codegen::Bindings::HTMLFormElementBinding;
use dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMethods;
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
+use dom::bindings::codegen::Bindings::HTMLButtonElementBinding::HTMLButtonElementMethods;
use dom::bindings::codegen::InheritTypes::{EventTargetCast, HTMLFormElementDerived, NodeCast};
use dom::bindings::codegen::InheritTypes::{HTMLInputElementCast, HTMLTextAreaElementCast, HTMLFormElementCast};
use dom::bindings::global::GlobalRef;
@@ -19,6 +20,7 @@ use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::element::ElementTypeId;
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
use dom::htmlinputelement::{HTMLInputElement, HTMLInputElementHelpers};
+use dom::htmlbuttonelement::{HTMLButtonElement};
use dom::htmltextareaelement::{HTMLTextAreaElement, HTMLTextAreaElementHelpers};
use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node};
use hyper::method::Method;
@@ -416,8 +418,9 @@ pub enum FormMethod {
#[derive(Copy)]
pub enum FormSubmitter<'a> {
FormElement(JSRef<'a, HTMLFormElement>),
- InputElement(JSRef<'a, HTMLInputElement>)
- // TODO: Submit buttons, image submit, etc etc
+ InputElement(JSRef<'a, HTMLInputElement>),
+ ButtonElement(JSRef<'a, HTMLButtonElement>)
+ // TODO: image submit, etc etc
}
impl<'a> FormSubmitter<'a> {
@@ -429,6 +432,11 @@ impl<'a> FormSubmitter<'a> {
input_element.get_form_attribute(&Atom::from_slice("formaction"),
|i| i.FormAction(),
|f| f.Action())
+ },
+ FormSubmitter::ButtonElement(button_element) => {
+ button_element.get_form_attribute(&Atom::from_slice("formaction"),
+ |i| i.FormAction(),
+ |f| f.Action())
}
}
}
@@ -441,6 +449,11 @@ impl<'a> FormSubmitter<'a> {
input_element.get_form_attribute(&Atom::from_slice("formenctype"),
|i| i.FormEnctype(),
|f| f.Enctype())
+ },
+ FormSubmitter::ButtonElement(button_element) => {
+ button_element.get_form_attribute(&Atom::from_slice("formenctype"),
+ |i| i.FormAction(),
+ |f| f.Action())
}
};
match attr.as_slice() {
@@ -460,6 +473,11 @@ impl<'a> FormSubmitter<'a> {
input_element.get_form_attribute(&Atom::from_slice("formmethod"),
|i| i.FormMethod(),
|f| f.Method())
+ },
+ FormSubmitter::ButtonElement(button_element) => {
+ button_element.get_form_attribute(&Atom::from_slice("formmethod"),
+ |i| i.FormAction(),
+ |f| f.Action())
}
};
match attr.as_slice() {
@@ -477,6 +495,11 @@ impl<'a> FormSubmitter<'a> {
input_element.get_form_attribute(&Atom::from_slice("formtarget"),
|i| i.FormTarget(),
|f| f.Target())
+ },
+ FormSubmitter::ButtonElement(button_element) => {
+ button_element.get_form_attribute(&Atom::from_slice("formtarget"),
+ |i| i.FormAction(),
+ |f| f.Action())
}
}
}