mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
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:
parent
386a067c4b
commit
a34920b605
6 changed files with 16 additions and 15 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue