mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clipping: Fix some warnings in components/script/dom
(#31799)
* fix clippy websocket errors * fix clippy window errors * fix clippy window errors * fix clippy window errors
This commit is contained in:
parent
4b408a3724
commit
ce0d456469
2 changed files with 16 additions and 22 deletions
|
@ -368,7 +368,7 @@ impl WebSocketMethods for WebSocket {
|
|||
let send_data = self.send_impl(data_byte_len)?;
|
||||
|
||||
if send_data {
|
||||
let bytes = blob.get_bytes().unwrap_or(vec![]);
|
||||
let bytes = blob.get_bytes().unwrap_or_default();
|
||||
let _ = self
|
||||
.sender
|
||||
.send(WebSocketDomAction::SendMessage(MessageData::Binary(bytes)));
|
||||
|
@ -409,7 +409,7 @@ impl WebSocketMethods for WebSocket {
|
|||
fn Close(&self, code: Option<u16>, reason: Option<USVString>) -> ErrorResult {
|
||||
if let Some(code) = code {
|
||||
//Fail if the supplied code isn't normal and isn't reserved for libraries, frameworks, and applications
|
||||
if code != close_code::NORMAL && (code < 3000 || code > 4999) {
|
||||
if code != close_code::NORMAL && !(3000..=4999).contains(&code) {
|
||||
return Err(Error::InvalidAccess);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use std::ptr::NonNull;
|
|||
use std::rc::Rc;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{cmp, env, mem};
|
||||
use std::{cmp, env};
|
||||
|
||||
use app_units::Au;
|
||||
use backtrace::Backtrace;
|
||||
|
@ -404,9 +404,7 @@ impl Window {
|
|||
pub fn ignore_all_tasks(&self) {
|
||||
let mut ignore_flags = self.task_manager.task_cancellers.borrow_mut();
|
||||
for task_source_name in TaskSourceName::all() {
|
||||
let flag = ignore_flags
|
||||
.entry(task_source_name)
|
||||
.or_insert(Default::default());
|
||||
let flag = ignore_flags.entry(task_source_name).or_default();
|
||||
flag.store(true, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
@ -595,7 +593,7 @@ pub fn base64_atob(input: DOMString) -> Fallible<DOMString> {
|
|||
if input.len() % 4 == 0 {
|
||||
if input.ends_with("==") {
|
||||
input = &input[..input.len() - 2]
|
||||
} else if input.ends_with("=") {
|
||||
} else if input.ends_with('=') {
|
||||
input = &input[..input.len() - 1]
|
||||
}
|
||||
}
|
||||
|
@ -1096,7 +1094,7 @@ impl WindowMethods for Window {
|
|||
let rust_stack = Backtrace::new();
|
||||
println!(
|
||||
"Current JS stack:\n{}\nCurrent Rust stack:\n{:?}",
|
||||
js_stack.unwrap_or(String::new()),
|
||||
js_stack.unwrap_or_default(),
|
||||
rust_stack
|
||||
);
|
||||
}
|
||||
|
@ -1500,7 +1498,7 @@ impl WindowMethods for Window {
|
|||
|
||||
let document = self.Document();
|
||||
let name_map = document.name_map();
|
||||
for (name, elements) in &(*name_map).0 {
|
||||
for (name, elements) in &name_map.0 {
|
||||
if name.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
@ -1512,7 +1510,7 @@ impl WindowMethods for Window {
|
|||
}
|
||||
}
|
||||
let id_map = document.id_map();
|
||||
for (id, elements) in &(*id_map).0 {
|
||||
for (id, elements) in &id_map.0 {
|
||||
if id.is_empty() {
|
||||
continue;
|
||||
}
|
||||
|
@ -1573,7 +1571,7 @@ impl Window {
|
|||
.borrow()
|
||||
.as_ref()
|
||||
.map(|e| DomRoot::from_ref(&**e));
|
||||
*self.current_event.borrow_mut() = event.map(|e| Dom::from_ref(e));
|
||||
*self.current_event.borrow_mut() = event.map(Dom::from_ref);
|
||||
current
|
||||
}
|
||||
|
||||
|
@ -1601,7 +1599,7 @@ impl Window {
|
|||
};
|
||||
|
||||
// Step 9.
|
||||
self.post_message(target_origin, source_origin, &*source.window_proxy(), data);
|
||||
self.post_message(target_origin, source_origin, &source.window_proxy(), data);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -1625,10 +1623,8 @@ impl Window {
|
|||
pub fn cancel_all_tasks(&self) {
|
||||
let mut ignore_flags = self.task_manager.task_cancellers.borrow_mut();
|
||||
for task_source_name in TaskSourceName::all() {
|
||||
let flag = ignore_flags
|
||||
.entry(task_source_name)
|
||||
.or_insert(Default::default());
|
||||
let cancelled = mem::replace(&mut *flag, Default::default());
|
||||
let flag = ignore_flags.entry(task_source_name).or_default();
|
||||
let cancelled = std::mem::take(&mut *flag);
|
||||
cancelled.store(true, Ordering::SeqCst);
|
||||
}
|
||||
}
|
||||
|
@ -1638,10 +1634,8 @@ impl Window {
|
|||
/// `true` and replaces it with a brand new one for future tasks.
|
||||
pub fn cancel_all_tasks_from_source(&self, task_source_name: TaskSourceName) {
|
||||
let mut ignore_flags = self.task_manager.task_cancellers.borrow_mut();
|
||||
let flag = ignore_flags
|
||||
.entry(task_source_name)
|
||||
.or_insert(Default::default());
|
||||
let cancelled = mem::replace(&mut *flag, Default::default());
|
||||
let flag = ignore_flags.entry(task_source_name).or_default();
|
||||
let cancelled = std::mem::take(&mut *flag);
|
||||
cancelled.store(true, Ordering::SeqCst);
|
||||
}
|
||||
|
||||
|
@ -1914,11 +1908,11 @@ impl Window {
|
|||
let node = unsafe { from_untrusted_node_address(image.node) };
|
||||
|
||||
if let PendingImageState::Unrequested(ref url) = image.state {
|
||||
fetch_image_for_layout(url.clone(), &*node, id, self.image_cache.clone());
|
||||
fetch_image_for_layout(url.clone(), &node, id, self.image_cache.clone());
|
||||
}
|
||||
|
||||
let mut images = self.pending_layout_images.borrow_mut();
|
||||
let nodes = images.entry(id).or_insert(vec![]);
|
||||
let nodes = images.entry(id).or_default();
|
||||
if nodes
|
||||
.iter()
|
||||
.find(|n| &***n as *const _ == &*node as *const _)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue