clippy: Fix another set of clippy problems in components/script/dom (#31909)

* a reference to a reference

* length comparison to zero

* length comparison to zero

* length comparison to zero
This commit is contained in:
Rosemary Ajayi 2024-03-28 12:33:29 +01:00 committed by GitHub
parent af358f51db
commit 18054d0737
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 19 additions and 19 deletions

View file

@ -933,7 +933,7 @@ impl Document {
pub fn register_form_id_listener<T: ?Sized + FormControl>(&self, id: DOMString, listener: &T) {
let mut map = self.form_id_listener_map.borrow_mut();
let listener = listener.to_element();
let set = map.entry(Atom::from(id)).or_insert(HashSet::new());
let set = map.entry(Atom::from(id)).or_default();
set.insert(Dom::from_ref(listener));
}
@ -1075,7 +1075,7 @@ impl Document {
/// <https://html.spec.whatwg.org/multipage/#focus-fixup-rule>
pub(crate) fn perform_focus_fixup_rule(&self, not_focusable: &Element) {
if Some(not_focusable) != self.focused.get().as_ref().map(|e| &**e) {
if Some(not_focusable) != self.focused.get().as_deref() {
return;
}
self.request_focus(
@ -1114,7 +1114,7 @@ impl Document {
},
};
*self.focus_transaction.borrow_mut() = FocusTransaction::NotInTransaction;
if self.focused == possibly_focused.as_ref().map(|e| &**e) {
if self.focused == possibly_focused.as_deref() {
return;
}
if let Some(ref elem) = self.focused.get() {
@ -1129,7 +1129,7 @@ impl Document {
}
}
self.focused.set(possibly_focused.as_ref().map(|e| &**e));
self.focused.set(possibly_focused.as_deref());
if let Some(ref elem) = self.focused.get() {
elem.set_focus_state(true);
@ -1152,7 +1152,7 @@ impl Document {
let (text, multiline) = if let Some(input) = elem.downcast::<HTMLInputElement>() {
(
Some((
(&input.Value()).to_string(),
input.Value().to_string(),
input.GetSelectionEnd().unwrap_or(0) as i32,
)),
false,
@ -1160,7 +1160,7 @@ impl Document {
} else if let Some(textarea) = elem.downcast::<HTMLTextAreaElement>() {
(
Some((
(&textarea.Value()).to_string(),
textarea.Value().to_string(),
textarea.GetSelectionEnd().unwrap_or(0) as i32,
)),
true,
@ -1188,7 +1188,7 @@ impl Document {
title.clone(),
));
let global = self.window.upcast::<GlobalScope>();
if let Some(ref chan) = global.devtools_chan() {
if let Some(chan) = global.devtools_chan() {
let _ = chan.send(ScriptToDevtoolsControlMsg::TitleChanged(
global.pipeline_id(),
title,
@ -3031,7 +3031,7 @@ fn get_registrable_domain_suffix_of_or_is_equal_to(
let index = original_host.len().checked_sub(host.len())?;
let (prefix, suffix) = original_host.split_at(index);
if !prefix.ends_with(".") {
if !prefix.ends_with('.') {
return None;
}
if suffix != host {