aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorRosemary Ajayi <okhuomonajayi54@gmail.com>2024-03-31 23:15:13 +0000
committerGitHub <noreply@github.com>2024-03-31 23:15:13 +0000
commit00c4d798c9619e068119db02910ed80ad9df937b (patch)
treeb14cd00919e48761f886e2d1096cee84621e740d /components/script/dom
parent9401102691db1388dfd2e4d7da5ffb69e8c28beb (diff)
downloadservo-00c4d798c9619e068119db02910ed80ad9df937b.tar.gz
servo-00c4d798c9619e068119db02910ed80ad9df937b.zip
clippy: Fix a few problems in `components/script/dom` (#31955)
* fixed various clippy warnings * fixed various clippy warnings * fixed various clippy warnings
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/filereader.rs2
-rw-r--r--components/script/dom/htmlscriptelement.rs4
-rw-r--r--components/script/dom/range.rs4
-rw-r--r--components/script/dom/testbinding.rs2
-rw-r--r--components/script/dom/vertexarrayobject.rs4
5 files changed, 7 insertions, 9 deletions
diff --git a/components/script/dom/filereader.rs b/components/script/dom/filereader.rs
index 2fe0ab948b2..713498c9d3a 100644
--- a/components/script/dom/filereader.rs
+++ b/components/script/dom/filereader.rs
@@ -90,7 +90,7 @@ pub struct FileReaderSharedFunctionality;
impl FileReaderSharedFunctionality {
pub fn dataurl_format(blob_contents: &[u8], blob_type: String) -> DOMString {
- let base64 = base64::engine::general_purpose::STANDARD.encode(&blob_contents);
+ let base64 = base64::engine::general_purpose::STANDARD.encode(blob_contents);
let dataurl = if blob_type.is_empty() {
format!("data:base64,{}", base64)
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index 2e157a896d9..3bc1d35b9b7 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -1186,9 +1186,7 @@ impl HTMLScriptElement {
(Some(ref ty), _) => {
debug!("script type={}", &***ty);
- if ty.to_ascii_lowercase().trim_matches(HTML_SPACE_CHARACTERS) ==
- String::from("module")
- {
+ if ty.to_ascii_lowercase().trim_matches(HTML_SPACE_CHARACTERS) == "module" {
return Some(ScriptType::Module);
}
diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs
index 72bd5350f6d..0cf64e264d0 100644
--- a/components/script/dom/range.rs
+++ b/components/script/dom/range.rs
@@ -296,11 +296,11 @@ impl Range {
}
fn start(&self) -> &BoundaryPoint {
- &self.abstract_range().start()
+ self.abstract_range().start()
}
fn end(&self) -> &BoundaryPoint {
- &self.abstract_range().end()
+ self.abstract_range().end()
}
pub fn start_container(&self) -> DomRoot<Node> {
diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs
index dea35a17e40..13ae19333b5 100644
--- a/components/script/dom/testbinding.rs
+++ b/components/script/dom/testbinding.rs
@@ -874,7 +874,7 @@ impl TestBindingMethods for TestBinding {
.get(pref_name.as_ref())
.as_str()
.map(DOMString::from)
- .unwrap_or_else(DOMString::new)
+ .unwrap_or_default()
}
fn PrefControlledAttributeDisabled(&self) -> bool {
false
diff --git a/components/script/dom/vertexarrayobject.rs b/components/script/dom/vertexarrayobject.rs
index 08ce5fb9854..b283a0b8f26 100644
--- a/components/script/dom/vertexarrayobject.rs
+++ b/components/script/dom/vertexarrayobject.rs
@@ -106,13 +106,13 @@ impl VertexArrayObject {
.get_mut(index as usize)
.ok_or(WebGLError::InvalidValue)?;
- if size < 1 || size > 4 {
+ if !(1..=4).contains(&size) {
return Err(WebGLError::InvalidValue);
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#BUFFER_OFFSET_AND_STRIDE
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#VERTEX_STRIDE
- if stride < 0 || stride > 255 || offset < 0 {
+ if !(0..=255).contains(&stride) || offset < 0 {
return Err(WebGLError::InvalidValue);
}