clippy: Fix needless_borrow warnings in components/script (#31928)

This commit is contained in:
Azhar Ismagulova 2024-03-29 08:58:22 +00:00 committed by GitHub
parent 2d5a1cd02e
commit c4739675d8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 32 additions and 32 deletions

View file

@ -584,7 +584,7 @@ impl CanvasState {
}
pub fn mark_as_dirty(&self, canvas: Option<&HTMLCanvasElement>) {
if let Some(ref canvas) = canvas {
if let Some(canvas) = canvas {
canvas.upcast::<Node>().dirty(NodeDamage::OtherNodeDamage);
}
}
@ -1705,7 +1705,7 @@ pub fn parse_color(canvas: Option<&HTMLCanvasElement>, string: &str) -> Result<R
// Whenever "currentColor" is used as a color in the PaintRenderingContext2D API,
// it is treated as opaque black.
None => AbsoluteColor::BLACK,
Some(ref canvas) => {
Some(canvas) => {
let canvas_element = canvas.upcast::<Element>();
match canvas_element.style() {
Some(ref s) if canvas_element.has_css_layout_box() => {

View file

@ -102,10 +102,10 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
self.set_state(PermissionState::Granted);
let bluetooth = self.get_bluetooth();
let mut device_instance_map = bluetooth.get_device_map().borrow_mut();
if let Some(ref existing_device) = device_instance_map.get(&device.id) {
if let Some(existing_device) = device_instance_map.get(&device.id) {
// https://webbluetoothcg.github.io/web-bluetooth/#request-the-bluetooth-permission
// Step 3.
self.set_devices(vec![Dom::from_ref(*existing_device)]);
self.set_devices(vec![Dom::from_ref(existing_device)]);
// https://w3c.github.io/permissions/#dom-permissions-request
// Step 8.

View file

@ -3529,7 +3529,7 @@ impl Document {
self.id_map
.borrow()
.get(id)
.map(|ref elements| DomRoot::from_ref(&*(*elements)[0]))
.map(|elements| DomRoot::from_ref(&*elements[0]))
}
pub fn ensure_pending_restyle(&self, el: &Element) -> RefMut<PendingRestyle> {

View file

@ -82,7 +82,7 @@ impl DocumentFragmentMethods for DocumentFragment {
self.id_map
.borrow()
.get(&id)
.map(|ref elements| DomRoot::from_ref(&*(*elements)[0]))
.map(|elements| DomRoot::from_ref(&*elements[0]))
}
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild

View file

@ -3246,7 +3246,7 @@ impl<'a> SelectorsElement for DomRoot<Element> {
operation: &AttrSelectorOperation<&AtomString>,
) -> bool {
match *ns {
NamespaceConstraint::Specific(ref ns) => self
NamespaceConstraint::Specific(ns) => self
.get_attribute(ns, local_name)
.map_or(false, |attr| attr.value().eval_selector(operation)),
NamespaceConstraint::Any => self.attrs.borrow().iter().any(|attr| {

View file

@ -1209,7 +1209,7 @@ impl GlobalScope {
if let Some(channels) = channels.get(&channel_name) {
channels
.iter()
.filter(|ref channel| {
.filter(|channel| {
// Step 8.
// Filter out the sender.
if let Some(id) = channel_id {
@ -1355,7 +1355,7 @@ impl GlobalScope {
{
let to_be_removed: Vec<MessagePortId> = message_ports
.iter()
.filter_map(|(id, ref managed_port)| {
.filter_map(|(id, managed_port)| {
if managed_port.closed {
// Let the constellation know to drop this port and the one it is entangled with,
// and to forward this message to the script-process where the entangled is found.
@ -1388,7 +1388,7 @@ impl GlobalScope {
&mut *self.broadcast_channel_state.borrow_mut()
{
channels.retain(|name, ref mut channels| {
channels.retain(|ref chan| !chan.closed());
channels.retain(|chan| !chan.closed());
if channels.is_empty() {
let _ = self.script_to_constellation_chan().send(
ScriptMsg::RemoveBroadcastChannelNameInRouter(

View file

@ -2483,7 +2483,7 @@ impl VirtualMethods for HTMLInputElement {
}
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);
}
self.upcast::<Element>()
@ -2620,7 +2620,7 @@ impl VirtualMethods for HTMLInputElement {
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 elem = copy.downcast::<HTMLInputElement>().unwrap();

View file

@ -59,7 +59,7 @@ impl VirtualMethods for HTMLLegendElement {
}
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);
}

View file

@ -239,7 +239,7 @@ impl VirtualMethods for HTMLLinkElement {
}
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);
}
@ -263,7 +263,7 @@ impl VirtualMethods for HTMLLinkElement {
}
fn unbind_from_tree(&self, context: &UnbindContext) {
if let Some(ref s) = self.super_type() {
if let Some(s) = self.super_type() {
s.unbind_from_tree(context);
}

View file

@ -227,7 +227,7 @@ impl VirtualMethods for HTMLMetaElement {
}
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);
}
@ -245,7 +245,7 @@ impl VirtualMethods for HTMLMetaElement {
}
fn unbind_from_tree(&self, context: &UnbindContext) {
if let Some(ref s) = self.super_type() {
if let Some(s) = self.super_type() {
s.unbind_from_tree(context);
}

View file

@ -123,7 +123,7 @@ impl VirtualMethods for HTMLOptGroupElement {
}
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);
}

View file

@ -336,7 +336,7 @@ impl VirtualMethods for HTMLOptionElement {
}
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);
}

View file

@ -1254,7 +1254,7 @@ impl VirtualMethods for HTMLScriptElement {
}
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.parser_inserted.get() && self.upcast::<Node>().is_connected() {
@ -1263,7 +1263,7 @@ impl VirtualMethods for HTMLScriptElement {
}
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);
}
@ -1281,7 +1281,7 @@ impl VirtualMethods for HTMLScriptElement {
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);
}

View file

@ -447,7 +447,7 @@ impl VirtualMethods for HTMLSelectElement {
}
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);
}

View file

@ -225,7 +225,7 @@ impl VirtualMethods for HTMLStyleElement {
}
fn unbind_from_tree(&self, context: &UnbindContext) {
if let Some(ref s) = self.super_type() {
if let Some(s) = self.super_type() {
s.unbind_from_tree(context);
}

View file

@ -50,7 +50,7 @@ impl CollectionFilter for TableRowFilter {
(root.is_parent_of(elem.upcast()) ||
self.sections
.iter()
.any(|ref section| section.is_parent_of(elem.upcast())))
.any(|section| section.is_parent_of(elem.upcast())))
}
}

View file

@ -232,12 +232,12 @@ impl Node {
assert!(new_child.prev_sibling.get().is_none());
assert!(new_child.next_sibling.get().is_none());
match before {
Some(ref before) => {
Some(before) => {
assert!(before.parent_node.get().as_deref() == Some(self));
let prev_sibling = before.GetPreviousSibling();
match prev_sibling {
None => {
assert!(self.first_child.get().as_deref() == Some(*before));
assert!(self.first_child.get().as_deref() == Some(before));
self.first_child.set(Some(new_child));
},
Some(ref prev_sibling) => {

View file

@ -206,7 +206,7 @@ impl RTCPeerConnection {
let signaller = this.make_signaller();
*this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller));
if let Some(ref servers) = config.iceServers {
if let Some(ref server) = servers.get(0) {
if let Some(server) = servers.get(0) {
let server = match server.urls {
StringOrStringSequence::String(ref s) => Some(s.clone()),
StringOrStringSequence::StringSequence(ref s) => s.get(0).cloned(),

View file

@ -255,8 +255,8 @@ impl<'dom, LayoutDataType: LayoutDataTrait> style::dom::TElement
where
F: FnMut(&AtomIdent),
{
if let Some(ref classes) = self.element.get_classes_for_layout() {
for class in *classes {
if let Some(classes) = self.element.get_classes_for_layout() {
for class in classes {
callback(AtomIdent::cast(class))
}
}
@ -520,7 +520,7 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
operation: &AttrSelectorOperation<&AtomString>,
) -> bool {
match *ns {
NamespaceConstraint::Specific(ref ns) => self
NamespaceConstraint::Specific(ns) => self
.get_attr_enum(ns, local_name)
.map_or(false, |value| value.eval_selector(operation)),
NamespaceConstraint::Any => self
@ -875,7 +875,7 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
operation: &AttrSelectorOperation<&AtomString>,
) -> bool {
match *ns {
NamespaceConstraint::Specific(ref ns) => self
NamespaceConstraint::Specific(ns) => self
.get_attr_enum(ns, local_name)
.map_or(false, |value| value.eval_selector(operation)),
NamespaceConstraint::Any => self