aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/document.rs16
-rw-r--r--components/script/dom/documentorshadowroot.rs2
-rw-r--r--components/script/dom/domtokenlist.rs2
-rw-r--r--components/script/dom/element.rs10
-rw-r--r--components/script/dom/eventtarget.rs8
5 files changed, 19 insertions, 19 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 3a51a5859a7..0d0592fa51e 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -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 {
diff --git a/components/script/dom/documentorshadowroot.rs b/components/script/dom/documentorshadowroot.rs
index 8b9da669fce..fec2b6372db 100644
--- a/components/script/dom/documentorshadowroot.rs
+++ b/components/script/dom/documentorshadowroot.rs
@@ -287,7 +287,7 @@ impl DocumentOrShadowRoot {
assert!(element.upcast::<Node>().is_connected());
assert!(!id.is_empty());
let mut id_map = id_map.borrow_mut();
- let elements = id_map.entry(id.clone()).or_insert(Vec::new());
+ let elements = id_map.entry(id.clone()).or_default();
elements.insert_pre_order(element, &root);
}
}
diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs
index 608795a40dc..fecacbcdb73 100644
--- a/components/script/dom/domtokenlist.rs
+++ b/components/script/dom/domtokenlist.rs
@@ -71,7 +71,7 @@ impl DOMTokenList {
// https://dom.spec.whatwg.org/#concept-dtl-update
fn perform_update_steps(&self, atoms: Vec<Atom>) {
// Step 1
- if !self.element.has_attribute(&self.local_name) && atoms.len() == 0 {
+ if !self.element.has_attribute(&self.local_name) && atoms.is_empty() {
return;
}
// step 2
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 033bc49e353..2cac691be0f 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -1217,7 +1217,7 @@ impl Element {
// "3. If its namespace is non-null and its namespace prefix is prefix, then return
// namespace."
if element.namespace() != &ns!() &&
- element.prefix().as_ref().map(|p| &**p) == prefix.as_ref().map(|p| &**p)
+ element.prefix().as_ref().map(|p| &**p) == prefix.as_deref()
{
return element.namespace().clone();
}
@@ -1548,7 +1548,7 @@ impl Element {
pub fn set_attribute(&self, name: &LocalName, value: AttrValue) {
assert!(name == &name.to_ascii_lowercase());
- assert!(!name.contains(":"));
+ assert!(!name.contains(':'));
self.set_first_matching_attribute(name.clone(), value, name.clone(), ns!(), None, |attr| {
attr.local_name() == name
@@ -1725,7 +1725,7 @@ impl Element {
pub fn get_tokenlist_attribute(&self, local_name: &LocalName) -> Vec<Atom> {
self.get_attribute(&ns!(), local_name)
.map(|attr| attr.value().as_tokens().to_vec())
- .unwrap_or(vec![])
+ .unwrap_or_default()
}
pub fn set_tokenlist_attribute(&self, local_name: &LocalName, value: DOMString) {
@@ -3066,7 +3066,7 @@ impl VirtualMethods for Element {
}
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);
}
@@ -3149,7 +3149,7 @@ impl VirtualMethods for Element {
}
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);
}
diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs
index 836be038b72..f44c60c0bd9 100644
--- a/components/script/dom/eventtarget.rs
+++ b/components/script/dom/eventtarget.rs
@@ -204,7 +204,7 @@ impl CompiledEventListener {
if let Ok(return_value) = return_value {
rooted!(in(*cx) let return_value = return_value);
if return_value.handle().is_boolean() &&
- return_value.handle().to_boolean() == true
+ return_value.handle().to_boolean()
{
event.upcast::<Event>().PreventDefault();
}
@@ -252,7 +252,7 @@ impl CompiledEventListener {
let value = value.handle();
//Step 5
- let should_cancel = value.is_boolean() && value.to_boolean() == false;
+ let should_cancel = value.is_boolean() && !value.to_boolean();
if should_cancel {
// FIXME: spec says to set the cancelled flag directly
@@ -342,7 +342,7 @@ impl EventListeners {
fn has_listeners(&self) -> bool {
// TODO: add, and take into account, a 'removed' field?
// https://dom.spec.whatwg.org/#event-listener-removed
- self.0.len() > 0
+ !self.0.is_empty()
}
}
@@ -417,7 +417,7 @@ impl EventTarget {
let idx = entries
.iter()
- .position(|ref entry| matches!(entry.listener, EventListenerType::Inline(_)));
+ .position(|entry| matches!(entry.listener, EventListenerType::Inline(_)));
match idx {
Some(idx) => match listener {