mirror of
https://github.com/servo/servo.git
synced 2025-08-12 17:05:33 +01:00
Clippy: Fixed clippy warnings in components/script/dom (#31801)
* fixed clippy warnings in htmlformelement.rs * Fixed clippy warnings * Fixed warnings related to matches! * made changes to compile "test-tidy" successfully
This commit is contained in:
parent
5c0199b568
commit
da3288dd00
6 changed files with 108 additions and 111 deletions
|
@ -120,24 +120,23 @@ impl InputType {
|
|||
// slightly differently, with placeholder characters shown rather
|
||||
// than the underlying value.
|
||||
fn is_textual(&self) -> bool {
|
||||
match *self {
|
||||
matches!(
|
||||
*self,
|
||||
InputType::Color |
|
||||
InputType::Date |
|
||||
InputType::DatetimeLocal |
|
||||
InputType::Email |
|
||||
InputType::Hidden |
|
||||
InputType::Month |
|
||||
InputType::Number |
|
||||
InputType::Range |
|
||||
InputType::Search |
|
||||
InputType::Tel |
|
||||
InputType::Text |
|
||||
InputType::Time |
|
||||
InputType::Url |
|
||||
InputType::Week => true,
|
||||
|
||||
_ => false,
|
||||
}
|
||||
InputType::Date |
|
||||
InputType::DatetimeLocal |
|
||||
InputType::Email |
|
||||
InputType::Hidden |
|
||||
InputType::Month |
|
||||
InputType::Number |
|
||||
InputType::Range |
|
||||
InputType::Search |
|
||||
InputType::Tel |
|
||||
InputType::Text |
|
||||
InputType::Time |
|
||||
InputType::Url |
|
||||
InputType::Week
|
||||
)
|
||||
}
|
||||
|
||||
fn is_textual_or_password(&self) -> bool {
|
||||
|
@ -428,45 +427,45 @@ impl HTMLInputElement {
|
|||
}
|
||||
|
||||
fn does_readonly_apply(&self) -> bool {
|
||||
match self.input_type() {
|
||||
matches!(
|
||||
self.input_type(),
|
||||
InputType::Text |
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Email |
|
||||
InputType::Password |
|
||||
InputType::Date |
|
||||
InputType::Month |
|
||||
InputType::Week |
|
||||
InputType::Time |
|
||||
InputType::DatetimeLocal |
|
||||
InputType::Number => true,
|
||||
_ => false,
|
||||
}
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Email |
|
||||
InputType::Password |
|
||||
InputType::Date |
|
||||
InputType::Month |
|
||||
InputType::Week |
|
||||
InputType::Time |
|
||||
InputType::DatetimeLocal |
|
||||
InputType::Number
|
||||
)
|
||||
}
|
||||
|
||||
fn does_minmaxlength_apply(&self) -> bool {
|
||||
match self.input_type() {
|
||||
matches!(
|
||||
self.input_type(),
|
||||
InputType::Text |
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Email |
|
||||
InputType::Password => true,
|
||||
_ => false,
|
||||
}
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Email |
|
||||
InputType::Password
|
||||
)
|
||||
}
|
||||
|
||||
fn does_pattern_apply(&self) -> bool {
|
||||
match self.input_type() {
|
||||
matches!(
|
||||
self.input_type(),
|
||||
InputType::Text |
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Email |
|
||||
InputType::Password => true,
|
||||
_ => false,
|
||||
}
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Email |
|
||||
InputType::Password
|
||||
)
|
||||
}
|
||||
|
||||
fn does_multiple_apply(&self) -> bool {
|
||||
|
@ -476,24 +475,23 @@ impl HTMLInputElement {
|
|||
// valueAsNumber, step, min, and max all share the same set of
|
||||
// input types they apply to
|
||||
fn does_value_as_number_apply(&self) -> bool {
|
||||
match self.input_type() {
|
||||
matches!(
|
||||
self.input_type(),
|
||||
InputType::Date |
|
||||
InputType::Month |
|
||||
InputType::Week |
|
||||
InputType::Time |
|
||||
InputType::DatetimeLocal |
|
||||
InputType::Number |
|
||||
InputType::Range => true,
|
||||
_ => false,
|
||||
}
|
||||
InputType::Month |
|
||||
InputType::Week |
|
||||
InputType::Time |
|
||||
InputType::DatetimeLocal |
|
||||
InputType::Number |
|
||||
InputType::Range
|
||||
)
|
||||
}
|
||||
|
||||
fn does_value_as_date_apply(&self) -> bool {
|
||||
match self.input_type() {
|
||||
InputType::Date | InputType::Month | InputType::Week | InputType::Time => true,
|
||||
// surprisingly, spec says false for DateTimeLocal!
|
||||
_ => false,
|
||||
}
|
||||
matches!(
|
||||
self.input_type(),
|
||||
InputType::Date | InputType::Month | InputType::Week | InputType::Time
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage#concept-input-step
|
||||
|
@ -1102,15 +1100,14 @@ impl<'dom> LayoutHTMLInputElementHelpers<'dom> for LayoutDom<'dom, HTMLInputElem
|
|||
impl TextControlElement for HTMLInputElement {
|
||||
// https://html.spec.whatwg.org/multipage/#concept-input-apply
|
||||
fn selection_api_applies(&self) -> bool {
|
||||
match self.input_type() {
|
||||
matches!(
|
||||
self.input_type(),
|
||||
InputType::Text |
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Password => true,
|
||||
|
||||
_ => false,
|
||||
}
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Password
|
||||
)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#concept-input-apply
|
||||
|
@ -2108,21 +2105,21 @@ impl HTMLInputElement {
|
|||
.filter_map(DomRoot::downcast::<HTMLInputElement>)
|
||||
.filter(|input| {
|
||||
input.form_owner() == owner &&
|
||||
match input.input_type() {
|
||||
matches!(
|
||||
input.input_type(),
|
||||
InputType::Text |
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Email |
|
||||
InputType::Password |
|
||||
InputType::Date |
|
||||
InputType::Month |
|
||||
InputType::Week |
|
||||
InputType::Time |
|
||||
InputType::DatetimeLocal |
|
||||
InputType::Number => true,
|
||||
_ => false,
|
||||
}
|
||||
InputType::Search |
|
||||
InputType::Url |
|
||||
InputType::Tel |
|
||||
InputType::Email |
|
||||
InputType::Password |
|
||||
InputType::Date |
|
||||
InputType::Month |
|
||||
InputType::Week |
|
||||
InputType::Time |
|
||||
InputType::DatetimeLocal |
|
||||
InputType::Number
|
||||
)
|
||||
});
|
||||
|
||||
if inputs.skip(1).next().is_some() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue