Skip to content
Permalink
Browse files

Make HTMLFormElementHelpers::submit take an enumerated argument inste…

…ad of a boolean

Fixes #3677
  • Loading branch information...
gilles-leblanc committed Oct 17, 2014
1 parent 6ab8f46 commit a31849df1142fd51f0fd48034bcf08f053b4a56f
Showing with 10 additions and 5 deletions.
  1. +8 −3 components/script/dom/htmlformelement.rs
  2. +2 −2 components/script/dom/htmlinputelement.rs
@@ -116,19 +116,24 @@ impl<'a> HTMLFormElementMethods for JSRef<'a, HTMLFormElement> {

// https://html.spec.whatwg.org/multipage/forms.html#the-form-element:concept-form-submit
fn Submit(self) {
self.submit(true, FormElement(self));
self.submit(FromFormSubmitMethod, FormElement(self));
}
}

pub enum SubmittedFrom {
FromFormSubmitMethod,
NotFromFormSubmitMethod
}

pub trait HTMLFormElementHelpers {
// https://html.spec.whatwg.org/multipage/forms.html#concept-form-submit
fn submit(self, from_submit_method: bool, submitter: FormSubmitter);
fn submit(self, submit_method_flag: SubmittedFrom, submitter: FormSubmitter);
// https://html.spec.whatwg.org/multipage/forms.html#constructing-the-form-data-set
fn get_form_dataset(self, submitter: Option<FormSubmitter>) -> Vec<FormDatum>;
}

impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
fn submit(self, _from_submit_method: bool, submitter: FormSubmitter) {
fn submit(self, _submit_method_flag: SubmittedFrom, submitter: FormSubmitter) {
// Step 1
let doc = document_from_node(self).root();
let win = window_from_node(self).root();
@@ -19,7 +19,7 @@ use dom::element::{AttributeHandlers, Element, HTMLInputElementTypeId};
use dom::event::Event;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::htmlelement::HTMLElement;
use dom::htmlformelement::{InputElement, FormOwner, HTMLFormElement, HTMLFormElementHelpers};
use dom::htmlformelement::{InputElement, FormOwner, HTMLFormElement, HTMLFormElementHelpers, NotFromFormSubmitMethod};
use dom::node::{DisabledStateHelpers, Node, NodeHelpers, ElementNodeTypeId, document_from_node, window_from_node};
use dom::virtualmethods::VirtualMethods;

@@ -397,7 +397,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
InputRadio => self.SetChecked(true),
InputButton(Some(DEFAULT_SUBMIT_VALUE)) => {
self.form_owner().map(|o| {
o.root().submit(false, InputElement(self.clone()))
o.root().submit(NotFromFormSubmitMethod, InputElement(self.clone()))
});
}
_ => {}

5 comments on commit a31849d

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Oct 17, 2014

saw approval from jdm
at gilles-leblanc@a31849d

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Oct 17, 2014

merging gilles-leblanc/servo/issue-3677 = a31849d into auto

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Oct 17, 2014

gilles-leblanc/servo/issue-3677 = a31849d merged ok, testing candidate = de2178b

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Oct 17, 2014

@bors-servo

This comment has been minimized.

Copy link
Contributor

bors-servo replied Oct 17, 2014

fast-forwarding master to auto = de2178b

Please sign in to comment.
You can’t perform that action at this time.