fix(clippy): Clippy suggestions in components/script/dom/* (#33072)

Signed-off-by: Jose T. Monagas <josetmonagas@proton.me>
Co-authored-by: Jose T. Monagas <josetmonagas@proton.me>
This commit is contained in:
Jose Monagas 2024-08-15 22:31:30 +03:00 committed by GitHub
parent 386a067c4b
commit a34920b605
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 16 additions and 15 deletions

View file

@ -147,7 +147,7 @@ impl InputType {
*self == InputType::Time
}
fn to_str(&self) -> &str {
fn as_str(&self) -> &str {
match *self {
InputType::Button => "button",
InputType::Checkbox => "checkbox",
@ -1203,7 +1203,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
// https://html.spec.whatwg.org/multipage/#dom-input-type
fn Type(&self) -> DOMString {
DOMString::from(self.input_type().to_str())
DOMString::from(self.input_type().as_str())
}
// https://html.spec.whatwg.org/multipage/#dom-input-type
@ -1356,7 +1356,7 @@ impl HTMLInputElementMethods for HTMLInputElement {
// https://html.spec.whatwg.org/multipage/#dom-input-valueasnumber
fn ValueAsNumber(&self) -> f64 {
self.convert_string_to_number(&self.Value())
.unwrap_or(std::f64::NAN)
.unwrap_or(f64::NAN)
}
// https://html.spec.whatwg.org/multipage/#dom-input-valueasnumber

View file

@ -604,6 +604,11 @@ impl Node {
}
}
pub fn is_empty(&self) -> bool {
// A node is considered empty if its length is 0.
return self.len() == 0;
}
/// <https://dom.spec.whatwg.org/#concept-tree-index>
pub fn index(&self) -> u32 {
self.preceding_siblings().count() as u32

View file

@ -29,19 +29,12 @@ impl Iterable for TestBindingPairIterable {
self.map.borrow().len() as u32
}
fn get_value_at_index(&self, index: u32) -> u32 {
*self
.map
.borrow()
.iter()
.nth(index as usize)
.map(|a| &a.1)
.unwrap()
*self.map.borrow().get(index as usize).map(|a| &a.1).unwrap()
}
fn get_key_at_index(&self, index: u32) -> DOMString {
self.map
.borrow()
.iter()
.nth(index as usize)
.get(index as usize)
.map(|a| &a.0)
.unwrap()
.clone()

View file

@ -46,7 +46,7 @@ impl<'a, E: TextControlElement> TextControlSelection<'a, E> {
}
// Step 2
self.set_range(Some(0), Some(u32::max_value()), None, None);
self.set_range(Some(0), Some(u32::MAX), None, None);
}
// https://html.spec.whatwg.org/multipage/#dom-textarea/input-selectionstart

View file

@ -66,6 +66,10 @@ impl TimeRangesContainer {
self.ranges.len() as u32
}
pub fn is_empty(&self) -> bool {
self.ranges.is_empty()
}
pub fn start(&self, index: u32) -> Result<f64, TimeRangesError> {
self.ranges
.get(index as usize)

View file

@ -103,8 +103,7 @@ impl XRInputSource {
.iter()
.enumerate()
.for_each(|(i, value)| {
self.gamepad
.map_and_normalize_buttons(i as usize, *value as f64);
self.gamepad.map_and_normalize_buttons(i, *value as f64);
});
frame.axis_values.iter().enumerate().for_each(|(i, value)| {
self.gamepad.map_and_normalize_axes(i, *value as f64);