diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs
index 45385e786e7..21e05340cb4 100755
--- a/components/script/dom/htmlinputelement.rs
+++ b/components/script/dom/htmlinputelement.rs
@@ -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
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 316f63ce191..d99da9bd97e 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -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;
+ }
+
///
pub fn index(&self) -> u32 {
self.preceding_siblings().count() as u32
diff --git a/components/script/dom/testbindingpairiterable.rs b/components/script/dom/testbindingpairiterable.rs
index 6496f3c9a07..aaed63bf715 100644
--- a/components/script/dom/testbindingpairiterable.rs
+++ b/components/script/dom/testbindingpairiterable.rs
@@ -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()
diff --git a/components/script/dom/textcontrol.rs b/components/script/dom/textcontrol.rs
index 7f0fc3dc11e..73a23f59dc8 100644
--- a/components/script/dom/textcontrol.rs
+++ b/components/script/dom/textcontrol.rs
@@ -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
diff --git a/components/script/dom/timeranges.rs b/components/script/dom/timeranges.rs
index 4f02330478d..496f7ee8090 100644
--- a/components/script/dom/timeranges.rs
+++ b/components/script/dom/timeranges.rs
@@ -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 {
self.ranges
.get(index as usize)
diff --git a/components/script/dom/xrinputsource.rs b/components/script/dom/xrinputsource.rs
index dd1bef7c77a..f0954905e7a 100644
--- a/components/script/dom/xrinputsource.rs
+++ b/components/script/dom/xrinputsource.rs
@@ -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);