mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
[clippy] Rename enum FormSubmitter and its elements (#32791)
* [clippy] Renames enum FormSubmitter and its elements Signed-off-by: Danila Matveev <usurname.r@gmail.com> * fmt Signed-off-by: Danila Matveev <usurname.r@gmail.com> --------- Signed-off-by: Danila Matveev <usurname.r@gmail.com>
This commit is contained in:
parent
882a855b8c
commit
e4ad1d3ab9
3 changed files with 44 additions and 44 deletions
|
@ -23,7 +23,7 @@ use crate::dom::eventtarget::EventTarget;
|
|||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::htmlfieldsetelement::HTMLFieldSetElement;
|
||||
use crate::dom::htmlformelement::{
|
||||
FormControl, FormDatum, FormDatumValue, FormSubmitter, HTMLFormElement, ResetFrom,
|
||||
FormControl, FormDatum, FormDatumValue, FormSubmitterElement, HTMLFormElement, ResetFrom,
|
||||
SubmittedFrom,
|
||||
};
|
||||
use crate::dom::node::{window_from_node, BindContext, Node, UnbindContext};
|
||||
|
@ -192,11 +192,11 @@ impl HTMLButtonElementMethods for HTMLButtonElement {
|
|||
impl HTMLButtonElement {
|
||||
/// <https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set>
|
||||
/// Steps range from 3.1 to 3.7 (specific to HTMLButtonElement)
|
||||
pub fn form_datum(&self, submitter: Option<FormSubmitter>) -> Option<FormDatum> {
|
||||
pub fn form_datum(&self, submitter: Option<FormSubmitterElement>) -> Option<FormDatum> {
|
||||
// Step 3.1: disabled state check is in get_unclean_dataset
|
||||
|
||||
// Step 3.1: only run steps if this is the submitter
|
||||
if let Some(FormSubmitter::ButtonElement(submitter)) = submitter {
|
||||
if let Some(FormSubmitterElement::Button(submitter)) = submitter {
|
||||
if submitter != self {
|
||||
return None;
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ impl Activatable for HTMLButtonElement {
|
|||
if let Some(owner) = self.form_owner() {
|
||||
owner.submit(
|
||||
SubmittedFrom::NotFromForm,
|
||||
FormSubmitter::ButtonElement(self),
|
||||
FormSubmitterElement::Button(self),
|
||||
);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -260,12 +260,12 @@ impl HTMLFormElementMethods for HTMLFormElement {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#the-form-element:concept-form-submit
|
||||
fn Submit(&self) {
|
||||
self.submit(SubmittedFrom::FromForm, FormSubmitter::FormElement(self));
|
||||
self.submit(SubmittedFrom::FromForm, FormSubmitterElement::Form(self));
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-form-requestsubmit
|
||||
fn RequestSubmit(&self, submitter: Option<&HTMLElement>) -> Fallible<()> {
|
||||
let submitter: FormSubmitter = match submitter {
|
||||
let submitter: FormSubmitterElement = match submitter {
|
||||
Some(submitter_element) => {
|
||||
// Step 1.1
|
||||
let error_not_a_submit_button =
|
||||
|
@ -279,12 +279,12 @@ impl HTMLFormElementMethods for HTMLFormElement {
|
|||
};
|
||||
|
||||
let submit_button = match element {
|
||||
HTMLElementTypeId::HTMLInputElement => FormSubmitter::InputElement(
|
||||
HTMLElementTypeId::HTMLInputElement => FormSubmitterElement::Input(
|
||||
submitter_element
|
||||
.downcast::<HTMLInputElement>()
|
||||
.expect("Failed to downcast submitter elem to HTMLInputElement."),
|
||||
),
|
||||
HTMLElementTypeId::HTMLButtonElement => FormSubmitter::ButtonElement(
|
||||
HTMLElementTypeId::HTMLButtonElement => FormSubmitterElement::Button(
|
||||
submitter_element
|
||||
.downcast::<HTMLButtonElement>()
|
||||
.expect("Failed to downcast submitter elem to HTMLButtonElement."),
|
||||
|
@ -316,7 +316,7 @@ impl HTMLFormElementMethods for HTMLFormElement {
|
|||
},
|
||||
None => {
|
||||
// Step 2
|
||||
FormSubmitter::FormElement(self)
|
||||
FormSubmitterElement::Form(self)
|
||||
},
|
||||
};
|
||||
// Step 3
|
||||
|
@ -691,7 +691,7 @@ impl HTMLFormElement {
|
|||
}
|
||||
|
||||
/// [Form submission](https://html.spec.whatwg.org/multipage/#concept-form-submit)
|
||||
pub fn submit(&self, submit_method_flag: SubmittedFrom, submitter: FormSubmitter) {
|
||||
pub fn submit(&self, submit_method_flag: SubmittedFrom, submitter: FormSubmitterElement) {
|
||||
// Step 1
|
||||
if self.upcast::<Element>().cannot_navigate() {
|
||||
return;
|
||||
|
@ -722,15 +722,15 @@ impl HTMLFormElement {
|
|||
// spec calls this "submitterButton" but it doesn't have to be a button,
|
||||
// just not be the form itself
|
||||
let submitter_button = match submitter {
|
||||
FormSubmitter::FormElement(f) => {
|
||||
FormSubmitterElement::Form(f) => {
|
||||
if f == self {
|
||||
None
|
||||
} else {
|
||||
Some(f.upcast::<HTMLElement>())
|
||||
}
|
||||
},
|
||||
FormSubmitter::InputElement(i) => Some(i.upcast::<HTMLElement>()),
|
||||
FormSubmitter::ButtonElement(b) => Some(b.upcast::<HTMLElement>()),
|
||||
FormSubmitterElement::Input(i) => Some(i.upcast::<HTMLElement>()),
|
||||
FormSubmitterElement::Button(b) => Some(b.upcast::<HTMLElement>()),
|
||||
};
|
||||
|
||||
// Step 6.5
|
||||
|
@ -1081,7 +1081,7 @@ impl HTMLFormElement {
|
|||
/// 5.x substeps are mostly handled inside element-specific methods
|
||||
fn get_unclean_dataset(
|
||||
&self,
|
||||
submitter: Option<FormSubmitter>,
|
||||
submitter: Option<FormSubmitterElement>,
|
||||
encoding: Option<&'static Encoding>,
|
||||
) -> Vec<FormDatum> {
|
||||
let controls = self.controls.borrow();
|
||||
|
@ -1171,7 +1171,7 @@ impl HTMLFormElement {
|
|||
/// <https://html.spec.whatwg.org/multipage/#constructing-the-form-data-set>
|
||||
pub fn get_form_dataset(
|
||||
&self,
|
||||
submitter: Option<FormSubmitter>,
|
||||
submitter: Option<FormSubmitterElement>,
|
||||
encoding: Option<&'static Encoding>,
|
||||
) -> Option<Vec<FormDatum>> {
|
||||
fn clean_crlf(s: &str) -> DOMString {
|
||||
|
@ -1380,24 +1380,24 @@ pub enum FormMethod {
|
|||
|
||||
/// <https://html.spec.whatwg.org/multipage/#form-associated-element>
|
||||
#[derive(Clone, Copy, MallocSizeOf)]
|
||||
pub enum FormSubmitter<'a> {
|
||||
FormElement(&'a HTMLFormElement),
|
||||
InputElement(&'a HTMLInputElement),
|
||||
ButtonElement(&'a HTMLButtonElement),
|
||||
pub enum FormSubmitterElement<'a> {
|
||||
Form(&'a HTMLFormElement),
|
||||
Input(&'a HTMLInputElement),
|
||||
Button(&'a HTMLButtonElement),
|
||||
// TODO: implement other types of form associated elements
|
||||
// (including custom elements) that can be passed as submitter.
|
||||
}
|
||||
|
||||
impl<'a> FormSubmitter<'a> {
|
||||
impl<'a> FormSubmitterElement<'a> {
|
||||
fn action(&self) -> DOMString {
|
||||
match *self {
|
||||
FormSubmitter::FormElement(form) => form.Action(),
|
||||
FormSubmitter::InputElement(input_element) => input_element.get_form_attribute(
|
||||
FormSubmitterElement::Form(form) => form.Action(),
|
||||
FormSubmitterElement::Input(input_element) => input_element.get_form_attribute(
|
||||
&local_name!("formaction"),
|
||||
|i| i.FormAction(),
|
||||
|f| f.Action(),
|
||||
),
|
||||
FormSubmitter::ButtonElement(button_element) => button_element.get_form_attribute(
|
||||
FormSubmitterElement::Button(button_element) => button_element.get_form_attribute(
|
||||
&local_name!("formaction"),
|
||||
|i| i.FormAction(),
|
||||
|f| f.Action(),
|
||||
|
@ -1407,13 +1407,13 @@ impl<'a> FormSubmitter<'a> {
|
|||
|
||||
fn enctype(&self) -> FormEncType {
|
||||
let attr = match *self {
|
||||
FormSubmitter::FormElement(form) => form.Enctype(),
|
||||
FormSubmitter::InputElement(input_element) => input_element.get_form_attribute(
|
||||
FormSubmitterElement::Form(form) => form.Enctype(),
|
||||
FormSubmitterElement::Input(input_element) => input_element.get_form_attribute(
|
||||
&local_name!("formenctype"),
|
||||
|i| i.FormEnctype(),
|
||||
|f| f.Enctype(),
|
||||
),
|
||||
FormSubmitter::ButtonElement(button_element) => button_element.get_form_attribute(
|
||||
FormSubmitterElement::Button(button_element) => button_element.get_form_attribute(
|
||||
&local_name!("formenctype"),
|
||||
|i| i.FormEnctype(),
|
||||
|f| f.Enctype(),
|
||||
|
@ -1430,13 +1430,13 @@ impl<'a> FormSubmitter<'a> {
|
|||
|
||||
fn method(&self) -> FormMethod {
|
||||
let attr = match *self {
|
||||
FormSubmitter::FormElement(form) => form.Method(),
|
||||
FormSubmitter::InputElement(input_element) => input_element.get_form_attribute(
|
||||
FormSubmitterElement::Form(form) => form.Method(),
|
||||
FormSubmitterElement::Input(input_element) => input_element.get_form_attribute(
|
||||
&local_name!("formmethod"),
|
||||
|i| i.FormMethod(),
|
||||
|f| f.Method(),
|
||||
),
|
||||
FormSubmitter::ButtonElement(button_element) => button_element.get_form_attribute(
|
||||
FormSubmitterElement::Button(button_element) => button_element.get_form_attribute(
|
||||
&local_name!("formmethod"),
|
||||
|i| i.FormMethod(),
|
||||
|f| f.Method(),
|
||||
|
@ -1451,13 +1451,13 @@ impl<'a> FormSubmitter<'a> {
|
|||
|
||||
fn target(&self) -> DOMString {
|
||||
match *self {
|
||||
FormSubmitter::FormElement(form) => form.Target(),
|
||||
FormSubmitter::InputElement(input_element) => input_element.get_form_attribute(
|
||||
FormSubmitterElement::Form(form) => form.Target(),
|
||||
FormSubmitterElement::Input(input_element) => input_element.get_form_attribute(
|
||||
&local_name!("formtarget"),
|
||||
|i| i.FormTarget(),
|
||||
|f| f.Target(),
|
||||
),
|
||||
FormSubmitter::ButtonElement(button_element) => button_element.get_form_attribute(
|
||||
FormSubmitterElement::Button(button_element) => button_element.get_form_attribute(
|
||||
&local_name!("formtarget"),
|
||||
|i| i.FormTarget(),
|
||||
|f| f.Target(),
|
||||
|
@ -1467,13 +1467,13 @@ impl<'a> FormSubmitter<'a> {
|
|||
|
||||
fn no_validate(&self, _form_owner: &HTMLFormElement) -> bool {
|
||||
match *self {
|
||||
FormSubmitter::FormElement(form) => form.NoValidate(),
|
||||
FormSubmitter::InputElement(input_element) => input_element.get_form_boolean_attribute(
|
||||
FormSubmitterElement::Form(form) => form.NoValidate(),
|
||||
FormSubmitterElement::Input(input_element) => input_element.get_form_boolean_attribute(
|
||||
&local_name!("formnovalidate"),
|
||||
|i| i.FormNoValidate(),
|
||||
|f| f.NoValidate(),
|
||||
),
|
||||
FormSubmitter::ButtonElement(button_element) => button_element
|
||||
FormSubmitterElement::Button(button_element) => button_element
|
||||
.get_form_boolean_attribute(
|
||||
&local_name!("formnovalidate"),
|
||||
|i| i.FormNoValidate(),
|
||||
|
@ -1487,9 +1487,9 @@ impl<'a> FormSubmitter<'a> {
|
|||
match *self {
|
||||
// https://html.spec.whatwg.org/multipage/#image-button-state-(type=image)
|
||||
// https://html.spec.whatwg.org/multipage/#submit-button-state-(type=submit)
|
||||
FormSubmitter::InputElement(input_element) => input_element.is_submit_button(),
|
||||
FormSubmitterElement::Input(input_element) => input_element.is_submit_button(),
|
||||
// https://html.spec.whatwg.org/multipage/#attr-button-type-submit-state
|
||||
FormSubmitter::ButtonElement(button_element) => button_element.is_submit_button(),
|
||||
FormSubmitterElement::Button(button_element) => button_element.is_submit_button(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -1497,8 +1497,8 @@ impl<'a> FormSubmitter<'a> {
|
|||
// https://html.spec.whatwg.org/multipage/#form-owner
|
||||
fn form_owner(&self) -> Option<DomRoot<HTMLFormElement>> {
|
||||
match *self {
|
||||
FormSubmitter::ButtonElement(button_el) => button_el.form_owner(),
|
||||
FormSubmitter::InputElement(input_el) => input_el.form_owner(),
|
||||
FormSubmitterElement::Button(button_el) => button_el.form_owner(),
|
||||
FormSubmitterElement::Input(input_el) => input_el.form_owner(),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ use crate::dom::htmldatalistelement::HTMLDataListElement;
|
|||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::htmlfieldsetelement::HTMLFieldSetElement;
|
||||
use crate::dom::htmlformelement::{
|
||||
FormControl, FormDatum, FormDatumValue, FormSubmitter, HTMLFormElement, ResetFrom,
|
||||
FormControl, FormDatum, FormDatumValue, FormSubmitterElement, HTMLFormElement, ResetFrom,
|
||||
SubmittedFrom,
|
||||
};
|
||||
use crate::dom::keyboardevent::KeyboardEvent;
|
||||
|
@ -1679,7 +1679,7 @@ impl HTMLInputElement {
|
|||
/// Steps range from 5.1 to 5.10 (specific to HTMLInputElement)
|
||||
pub fn form_datums(
|
||||
&self,
|
||||
submitter: Option<FormSubmitter>,
|
||||
submitter: Option<FormSubmitterElement>,
|
||||
encoding: Option<&'static Encoding>,
|
||||
) -> Vec<FormDatum> {
|
||||
// 3.1: disabled state check is in get_unclean_dataset
|
||||
|
@ -1690,7 +1690,7 @@ impl HTMLInputElement {
|
|||
// Step 5.4
|
||||
let name = self.Name();
|
||||
let is_submitter = match submitter {
|
||||
Some(FormSubmitter::InputElement(s)) => self == s,
|
||||
Some(FormSubmitterElement::Input(s)) => self == s,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
@ -2107,7 +2107,7 @@ impl HTMLInputElement {
|
|||
// lazily test for > 1 submission-blocking inputs
|
||||
return;
|
||||
}
|
||||
form.submit(SubmittedFrom::NotFromForm, FormSubmitter::FormElement(form));
|
||||
form.submit(SubmittedFrom::NotFromForm, FormSubmitterElement::Form(form));
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -2821,7 +2821,7 @@ impl Activatable for HTMLInputElement {
|
|||
if let Some(o) = self.form_owner() {
|
||||
o.submit(
|
||||
SubmittedFrom::NotFromForm,
|
||||
FormSubmitter::InputElement(self),
|
||||
FormSubmitterElement::Input(self),
|
||||
)
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue