clippy: fixed some warnings in components/script (#31888)

This commit is contained in:
Ekta Siwach 2024-03-27 02:55:42 +05:30 committed by GitHub
parent 8dece05980
commit 92b557867c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 39 additions and 40 deletions

View file

@ -123,7 +123,7 @@ pub fn handle_get_children(
reply: IpcSender<Option<Vec<NodeInfo>>>, reply: IpcSender<Option<Vec<NodeInfo>>>,
) { ) {
match find_node_by_unique_id(documents, pipeline, &node_id) { match find_node_by_unique_id(documents, pipeline, &node_id) {
None => return reply.send(None).unwrap(), None => reply.send(None).unwrap(),
Some(parent) => { Some(parent) => {
let children = parent.children().map(|child| child.summarize()).collect(); let children = parent.children().map(|child| child.summarize()).collect();

View file

@ -164,10 +164,9 @@ impl DocumentLoader {
} }
pub fn is_only_blocked_by_iframes(&self) -> bool { pub fn is_only_blocked_by_iframes(&self) -> bool {
self.blocking_loads.iter().all(|load| match *load { self.blocking_loads
LoadType::Subframe(_) => true, .iter()
_ => false, .all(|load| matches!(*load, LoadType::Subframe(_)))
})
} }
pub fn inhibit_events(&mut self) { pub fn inhibit_events(&mut self) {

View file

@ -142,7 +142,7 @@ impl PartialEq for BoundaryPoint {
/// <https://dom.spec.whatwg.org/#concept-range-bp-position> /// <https://dom.spec.whatwg.org/#concept-range-bp-position>
pub fn bp_position(a_node: &Node, a_offset: u32, b_node: &Node, b_offset: u32) -> Option<Ordering> { pub fn bp_position(a_node: &Node, a_offset: u32, b_node: &Node, b_offset: u32) -> Option<Ordering> {
if a_node as *const Node == b_node as *const Node { if std::ptr::eq(a_node, b_node) {
// Step 1. // Step 1.
return Some(a_offset.cmp(&b_offset)); return Some(a_offset.cmp(&b_offset));
} }

View file

@ -1035,7 +1035,7 @@ pub fn is_valid_custom_element_name(name: &str) -> bool {
// PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)* // PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)*
let mut chars = name.chars(); let mut chars = name.chars();
if !chars.next().map_or(false, |c| c >= 'a' && c <= 'z') { if !chars.next().map_or(false, |c| ('a'..='z').contains(&c)) {
return false; return false;
} }
@ -1078,19 +1078,19 @@ fn is_potential_custom_element_char(c: char) -> bool {
c == '.' || c == '.' ||
c == '_' || c == '_' ||
c == '\u{B7}' || c == '\u{B7}' ||
(c >= '0' && c <= '9') || ('0'..='9').contains(&c) ||
(c >= 'a' && c <= 'z') || ('a'..='z').contains(&c) ||
(c >= '\u{C0}' && c <= '\u{D6}') || ('\u{C0}'..='\u{D6}').contains(&c) ||
(c >= '\u{D8}' && c <= '\u{F6}') || ('\u{D8}'..='\u{F6}').contains(&c) ||
(c >= '\u{F8}' && c <= '\u{37D}') || ('\u{F8}'..='\u{37D}').contains(&c) ||
(c >= '\u{37F}' && c <= '\u{1FFF}') || ('\u{37F}'..='\u{1FFF}').contains(&c) ||
(c >= '\u{200C}' && c <= '\u{200D}') || ('\u{200C}'..='\u{200D}').contains(&c) ||
(c >= '\u{203F}' && c <= '\u{2040}') || ('\u{203F}'..='\u{2040}').contains(&c) ||
(c >= '\u{2070}' && c <= '\u{2FEF}') || ('\u{2070}'..='\u{2FEF}').contains(&c) ||
(c >= '\u{3001}' && c <= '\u{D7FF}') || ('\u{3001}'..='\u{D7FF}').contains(&c) ||
(c >= '\u{F900}' && c <= '\u{FDCF}') || ('\u{F900}'..='\u{FDCF}').contains(&c) ||
(c >= '\u{FDF0}' && c <= '\u{FFFD}') || ('\u{FDF0}'..='\u{FFFD}').contains(&c) ||
(c >= '\u{10000}' && c <= '\u{EFFFF}') ('\u{10000}'..='\u{EFFFF}').contains(&c)
} }
fn is_extendable_element_interface(element: &str) -> bool { fn is_extendable_element_interface(element: &str) -> bool {

View file

@ -741,7 +741,7 @@ fn inner_invoke(
// Step 2.12 // Step 2.12
if let Some(window) = global.downcast::<Window>() { if let Some(window) = global.downcast::<Window>() {
window.set_current_event(current_event.as_ref().map(|e| &**e)); window.set_current_event(current_event.as_deref());
} }
// Step 2.13: short-circuit instead of going to next listener // Step 2.13: short-circuit instead of going to next listener

View file

@ -414,7 +414,7 @@ impl FetchResponseListener for EventSourceContext {
} }
fn process_response_eof(&mut self, _response: Result<ResourceFetchTiming, NetworkError>) { fn process_response_eof(&mut self, _response: Result<ResourceFetchTiming, NetworkError>) {
if let Some(_) = self.incomplete_utf8.take() { if self.incomplete_utf8.take().is_some() {
self.parse("\u{FFFD}".chars()); self.parse("\u{FFFD}".chars());
} }
self.reestablish_the_connection(); self.reestablish_the_connection();

View file

@ -117,7 +117,7 @@ impl FakeXRInputControllerMethods for FakeXRInputController {
XRHandedness::Left => Handedness::Left, XRHandedness::Left => Handedness::Left,
XRHandedness::Right => Handedness::Right, XRHandedness::Right => Handedness::Right,
}; };
let _ = self.send_message(MockInputMsg::SetHandedness(h)); self.send_message(MockInputMsg::SetHandedness(h));
} }
/// <https://immersive-web.github.io/webxr-test-api/#dom-fakexrinputcontroller-settargetraymode> /// <https://immersive-web.github.io/webxr-test-api/#dom-fakexrinputcontroller-settargetraymode>
@ -127,12 +127,12 @@ impl FakeXRInputControllerMethods for FakeXRInputController {
XRTargetRayMode::Tracked_pointer => TargetRayMode::TrackedPointer, XRTargetRayMode::Tracked_pointer => TargetRayMode::TrackedPointer,
XRTargetRayMode::Screen => TargetRayMode::Screen, XRTargetRayMode::Screen => TargetRayMode::Screen,
}; };
let _ = self.send_message(MockInputMsg::SetTargetRayMode(t)); self.send_message(MockInputMsg::SetTargetRayMode(t));
} }
/// <https://immersive-web.github.io/webxr-test-api/#dom-fakexrinputcontroller-setprofiles> /// <https://immersive-web.github.io/webxr-test-api/#dom-fakexrinputcontroller-setprofiles>
fn SetProfiles(&self, profiles: Vec<DOMString>) { fn SetProfiles(&self, profiles: Vec<DOMString>) {
let t = profiles.into_iter().map(String::from).collect(); let t = profiles.into_iter().map(String::from).collect();
let _ = self.send_message(MockInputMsg::SetProfiles(t)); self.send_message(MockInputMsg::SetProfiles(t));
} }
} }

View file

@ -105,13 +105,13 @@ impl File {
Err(_) => return Err(Error::InvalidCharacter), Err(_) => return Err(Error::InvalidCharacter),
}; };
let ref blobPropertyBag = filePropertyBag.parent; let blobPropertyBag = &filePropertyBag.parent;
let modified = filePropertyBag.lastModified; let modified = filePropertyBag.lastModified;
// NOTE: Following behaviour might be removed in future, // NOTE: Following behaviour might be removed in future,
// see https://github.com/w3c/FileAPI/issues/41 // see https://github.com/w3c/FileAPI/issues/41
let replaced_filename = DOMString::from_string(filename.replace("/", ":")); let replaced_filename = DOMString::from_string(filename.replace('/', ":"));
let type_string = normalize_type_string(&blobPropertyBag.type_.to_string()); let type_string = normalize_type_string(blobPropertyBag.type_.as_ref());
Ok(File::new_with_proto( Ok(File::new_with_proto(
global, global,
proto, proto,

View file

@ -110,7 +110,7 @@ impl FormDataMethods for FormData {
fn Delete(&self, name: USVString) { fn Delete(&self, name: USVString) {
self.data self.data
.borrow_mut() .borrow_mut()
.retain(|(datum_name, _)| datum_name.0 != LocalName::from(name.0.clone())); .retain(|(datum_name, _)| datum_name.0 != name.0);
} }
// https://xhr.spec.whatwg.org/#dom-formdata-get // https://xhr.spec.whatwg.org/#dom-formdata-get
@ -118,7 +118,7 @@ impl FormDataMethods for FormData {
self.data self.data
.borrow() .borrow()
.iter() .iter()
.filter(|(datum_name, _)| datum_name.0 == LocalName::from(name.0.clone())) .filter(|(datum_name, _)| datum_name.0 == name.0)
.next() .next()
.map(|(_, datum)| match &datum.value { .map(|(_, datum)| match &datum.value {
FormDatumValue::String(ref s) => { FormDatumValue::String(ref s) => {
@ -134,7 +134,7 @@ impl FormDataMethods for FormData {
.borrow() .borrow()
.iter() .iter()
.filter_map(|(datum_name, datum)| { .filter_map(|(datum_name, datum)| {
if datum_name.0 != LocalName::from(name.0.clone()) { if datum_name.0 != name.0 {
return None; return None;
} }
@ -153,7 +153,7 @@ impl FormDataMethods for FormData {
self.data self.data
.borrow() .borrow()
.iter() .iter()
.any(|(datum_name, _0)| datum_name.0 == LocalName::from(name.0.clone())) .any(|(datum_name, _0)| datum_name.0 == name.0)
} }
// https://xhr.spec.whatwg.org/#dom-formdata-set // https://xhr.spec.whatwg.org/#dom-formdata-set
@ -211,7 +211,7 @@ impl FormData {
}, },
}; };
let bytes = blob.get_bytes().unwrap_or(vec![]); let bytes = blob.get_bytes().unwrap_or_default();
File::new( File::new(
&self.global(), &self.global(),

View file

@ -100,7 +100,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
// placeholder is single line, but that's an unimportant detail. // placeholder is single line, but that's an unimportant detail.
self.placeholder() self.placeholder()
.replace("\r\n", "\n") .replace("\r\n", "\n")
.replace("\r", "\n") .replace('\r', "\n")
.into() .into()
} else { } else {
text.into() text.into()
@ -545,7 +545,7 @@ impl VirtualMethods for HTMLTextAreaElement {
} }
fn bind_to_tree(&self, context: &BindContext) { fn bind_to_tree(&self, context: &BindContext) {
if let Some(ref s) = self.super_type() { if let Some(s) = self.super_type() {
s.bind_to_tree(context); s.bind_to_tree(context);
} }
@ -599,7 +599,7 @@ impl VirtualMethods for HTMLTextAreaElement {
maybe_doc: Option<&Document>, maybe_doc: Option<&Document>,
clone_children: CloneChildrenFlag, clone_children: CloneChildrenFlag,
) { ) {
if let Some(ref s) = self.super_type() { if let Some(s) = self.super_type() {
s.cloning_steps(copy, maybe_doc, clone_children); s.cloning_steps(copy, maybe_doc, clone_children);
} }
let el = copy.downcast::<HTMLTextAreaElement>().unwrap(); let el = copy.downcast::<HTMLTextAreaElement>().unwrap();
@ -613,7 +613,7 @@ impl VirtualMethods for HTMLTextAreaElement {
} }
fn children_changed(&self, mutation: &ChildrenMutation) { fn children_changed(&self, mutation: &ChildrenMutation) {
if let Some(ref s) = self.super_type() { if let Some(s) = self.super_type() {
s.children_changed(mutation); s.children_changed(mutation);
} }
if !self.value_dirty.get() { if !self.value_dirty.get() {
@ -702,7 +702,7 @@ impl FormControl for HTMLTextAreaElement {
self.form_owner.set(form); self.form_owner.set(form);
} }
fn to_element<'a>(&'a self) -> &'a Element { fn to_element(&self) -> &Element {
self.upcast::<Element>() self.upcast::<Element>()
} }
} }

View file

@ -67,7 +67,7 @@ impl VirtualMethods for HTMLTitleElement {
} }
fn children_changed(&self, mutation: &ChildrenMutation) { fn children_changed(&self, mutation: &ChildrenMutation) {
if let Some(ref s) = self.super_type() { if let Some(s) = self.super_type() {
s.children_changed(mutation); s.children_changed(mutation);
} }
let node = self.upcast::<Node>(); let node = self.upcast::<Node>();
@ -77,7 +77,7 @@ impl VirtualMethods for HTMLTitleElement {
} }
fn bind_to_tree(&self, context: &BindContext) { fn bind_to_tree(&self, context: &BindContext) {
if let Some(ref s) = self.super_type() { if let Some(s) = self.super_type() {
s.bind_to_tree(context); s.bind_to_tree(context);
} }
let node = self.upcast::<Node>(); let node = self.upcast::<Node>();