Navigation Menu

Skip to content

Commit

Permalink
Make HTMLFormElementHelpers::submit take an enumerated argument inste…
Browse files Browse the repository at this point in the history
…ad of a boolean

Fixes #3677
  • Loading branch information
gilles-leblanc committed Oct 17, 2014
1 parent 6ab8f46 commit a31849d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions components/script/dom/htmlformelement.rs
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/htmlinputelement.rs
Expand Up @@ -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;

Expand Down Expand Up @@ -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()))
});
}
_ => {}
Expand Down

5 comments on commit a31849d

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at gilles-leblanc@a31849d

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = de2178b

Please sign in to comment.