mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clippy: fixed some warnings in components/script (#31888)
This commit is contained in:
parent
8dece05980
commit
92b557867c
11 changed files with 39 additions and 40 deletions
|
@ -123,7 +123,7 @@ pub fn handle_get_children(
|
|||
reply: IpcSender<Option<Vec<NodeInfo>>>,
|
||||
) {
|
||||
match find_node_by_unique_id(documents, pipeline, &node_id) {
|
||||
None => return reply.send(None).unwrap(),
|
||||
None => reply.send(None).unwrap(),
|
||||
Some(parent) => {
|
||||
let children = parent.children().map(|child| child.summarize()).collect();
|
||||
|
||||
|
|
|
@ -164,10 +164,9 @@ impl DocumentLoader {
|
|||
}
|
||||
|
||||
pub fn is_only_blocked_by_iframes(&self) -> bool {
|
||||
self.blocking_loads.iter().all(|load| match *load {
|
||||
LoadType::Subframe(_) => true,
|
||||
_ => false,
|
||||
})
|
||||
self.blocking_loads
|
||||
.iter()
|
||||
.all(|load| matches!(*load, LoadType::Subframe(_)))
|
||||
}
|
||||
|
||||
pub fn inhibit_events(&mut self) {
|
||||
|
|
|
@ -142,7 +142,7 @@ impl PartialEq for BoundaryPoint {
|
|||
|
||||
/// <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> {
|
||||
if a_node as *const Node == b_node as *const Node {
|
||||
if std::ptr::eq(a_node, b_node) {
|
||||
// Step 1.
|
||||
return Some(a_offset.cmp(&b_offset));
|
||||
}
|
||||
|
|
|
@ -1035,7 +1035,7 @@ pub fn is_valid_custom_element_name(name: &str) -> bool {
|
|||
// PotentialCustomElementName ::= [a-z] (PCENChar)* '-' (PCENChar)*
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -1078,19 +1078,19 @@ fn is_potential_custom_element_char(c: char) -> bool {
|
|||
c == '.' ||
|
||||
c == '_' ||
|
||||
c == '\u{B7}' ||
|
||||
(c >= '0' && c <= '9') ||
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= '\u{C0}' && c <= '\u{D6}') ||
|
||||
(c >= '\u{D8}' && c <= '\u{F6}') ||
|
||||
(c >= '\u{F8}' && c <= '\u{37D}') ||
|
||||
(c >= '\u{37F}' && c <= '\u{1FFF}') ||
|
||||
(c >= '\u{200C}' && c <= '\u{200D}') ||
|
||||
(c >= '\u{203F}' && c <= '\u{2040}') ||
|
||||
(c >= '\u{2070}' && c <= '\u{2FEF}') ||
|
||||
(c >= '\u{3001}' && c <= '\u{D7FF}') ||
|
||||
(c >= '\u{F900}' && c <= '\u{FDCF}') ||
|
||||
(c >= '\u{FDF0}' && c <= '\u{FFFD}') ||
|
||||
(c >= '\u{10000}' && c <= '\u{EFFFF}')
|
||||
('0'..='9').contains(&c) ||
|
||||
('a'..='z').contains(&c) ||
|
||||
('\u{C0}'..='\u{D6}').contains(&c) ||
|
||||
('\u{D8}'..='\u{F6}').contains(&c) ||
|
||||
('\u{F8}'..='\u{37D}').contains(&c) ||
|
||||
('\u{37F}'..='\u{1FFF}').contains(&c) ||
|
||||
('\u{200C}'..='\u{200D}').contains(&c) ||
|
||||
('\u{203F}'..='\u{2040}').contains(&c) ||
|
||||
('\u{2070}'..='\u{2FEF}').contains(&c) ||
|
||||
('\u{3001}'..='\u{D7FF}').contains(&c) ||
|
||||
('\u{F900}'..='\u{FDCF}').contains(&c) ||
|
||||
('\u{FDF0}'..='\u{FFFD}').contains(&c) ||
|
||||
('\u{10000}'..='\u{EFFFF}').contains(&c)
|
||||
}
|
||||
|
||||
fn is_extendable_element_interface(element: &str) -> bool {
|
||||
|
|
|
@ -741,7 +741,7 @@ fn inner_invoke(
|
|||
|
||||
// Step 2.12
|
||||
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
|
||||
|
|
|
@ -414,7 +414,7 @@ impl FetchResponseListener for EventSourceContext {
|
|||
}
|
||||
|
||||
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.reestablish_the_connection();
|
||||
|
|
|
@ -117,7 +117,7 @@ impl FakeXRInputControllerMethods for FakeXRInputController {
|
|||
XRHandedness::Left => Handedness::Left,
|
||||
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>
|
||||
|
@ -127,12 +127,12 @@ impl FakeXRInputControllerMethods for FakeXRInputController {
|
|||
XRTargetRayMode::Tracked_pointer => TargetRayMode::TrackedPointer,
|
||||
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>
|
||||
fn SetProfiles(&self, profiles: Vec<DOMString>) {
|
||||
let t = profiles.into_iter().map(String::from).collect();
|
||||
let _ = self.send_message(MockInputMsg::SetProfiles(t));
|
||||
self.send_message(MockInputMsg::SetProfiles(t));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -105,13 +105,13 @@ impl File {
|
|||
Err(_) => return Err(Error::InvalidCharacter),
|
||||
};
|
||||
|
||||
let ref blobPropertyBag = filePropertyBag.parent;
|
||||
let blobPropertyBag = &filePropertyBag.parent;
|
||||
|
||||
let modified = filePropertyBag.lastModified;
|
||||
// NOTE: Following behaviour might be removed in future,
|
||||
// see https://github.com/w3c/FileAPI/issues/41
|
||||
let replaced_filename = DOMString::from_string(filename.replace("/", ":"));
|
||||
let type_string = normalize_type_string(&blobPropertyBag.type_.to_string());
|
||||
let replaced_filename = DOMString::from_string(filename.replace('/', ":"));
|
||||
let type_string = normalize_type_string(blobPropertyBag.type_.as_ref());
|
||||
Ok(File::new_with_proto(
|
||||
global,
|
||||
proto,
|
||||
|
|
|
@ -110,7 +110,7 @@ impl FormDataMethods for FormData {
|
|||
fn Delete(&self, name: USVString) {
|
||||
self.data
|
||||
.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
|
||||
|
@ -118,7 +118,7 @@ impl FormDataMethods for FormData {
|
|||
self.data
|
||||
.borrow()
|
||||
.iter()
|
||||
.filter(|(datum_name, _)| datum_name.0 == LocalName::from(name.0.clone()))
|
||||
.filter(|(datum_name, _)| datum_name.0 == name.0)
|
||||
.next()
|
||||
.map(|(_, datum)| match &datum.value {
|
||||
FormDatumValue::String(ref s) => {
|
||||
|
@ -134,7 +134,7 @@ impl FormDataMethods for FormData {
|
|||
.borrow()
|
||||
.iter()
|
||||
.filter_map(|(datum_name, datum)| {
|
||||
if datum_name.0 != LocalName::from(name.0.clone()) {
|
||||
if datum_name.0 != name.0 {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -153,7 +153,7 @@ impl FormDataMethods for FormData {
|
|||
self.data
|
||||
.borrow()
|
||||
.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
|
||||
|
@ -211,7 +211,7 @@ impl FormData {
|
|||
},
|
||||
};
|
||||
|
||||
let bytes = blob.get_bytes().unwrap_or(vec![]);
|
||||
let bytes = blob.get_bytes().unwrap_or_default();
|
||||
|
||||
File::new(
|
||||
&self.global(),
|
||||
|
|
|
@ -100,7 +100,7 @@ impl LayoutHTMLTextAreaElementHelpers for LayoutDom<'_, HTMLTextAreaElement> {
|
|||
// placeholder is single line, but that's an unimportant detail.
|
||||
self.placeholder()
|
||||
.replace("\r\n", "\n")
|
||||
.replace("\r", "\n")
|
||||
.replace('\r', "\n")
|
||||
.into()
|
||||
} else {
|
||||
text.into()
|
||||
|
@ -545,7 +545,7 @@ impl VirtualMethods for HTMLTextAreaElement {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -599,7 +599,7 @@ impl VirtualMethods for HTMLTextAreaElement {
|
|||
maybe_doc: Option<&Document>,
|
||||
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);
|
||||
}
|
||||
let el = copy.downcast::<HTMLTextAreaElement>().unwrap();
|
||||
|
@ -613,7 +613,7 @@ impl VirtualMethods for HTMLTextAreaElement {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
if !self.value_dirty.get() {
|
||||
|
@ -702,7 +702,7 @@ impl FormControl for HTMLTextAreaElement {
|
|||
self.form_owner.set(form);
|
||||
}
|
||||
|
||||
fn to_element<'a>(&'a self) -> &'a Element {
|
||||
fn to_element(&self) -> &Element {
|
||||
self.upcast::<Element>()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ impl VirtualMethods for HTMLTitleElement {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
let node = self.upcast::<Node>();
|
||||
|
@ -77,7 +77,7 @@ impl VirtualMethods for HTMLTitleElement {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
let node = self.upcast::<Node>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue