mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
clippy: Fix needless_borrow warnings in components/script (#31928)
This commit is contained in:
parent
2d5a1cd02e
commit
c4739675d8
19 changed files with 32 additions and 32 deletions
|
@ -584,7 +584,7 @@ impl CanvasState {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mark_as_dirty(&self, canvas: Option<&HTMLCanvasElement>) {
|
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);
|
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,
|
// Whenever "currentColor" is used as a color in the PaintRenderingContext2D API,
|
||||||
// it is treated as opaque black.
|
// it is treated as opaque black.
|
||||||
None => AbsoluteColor::BLACK,
|
None => AbsoluteColor::BLACK,
|
||||||
Some(ref canvas) => {
|
Some(canvas) => {
|
||||||
let canvas_element = canvas.upcast::<Element>();
|
let canvas_element = canvas.upcast::<Element>();
|
||||||
match canvas_element.style() {
|
match canvas_element.style() {
|
||||||
Some(ref s) if canvas_element.has_css_layout_box() => {
|
Some(ref s) if canvas_element.has_css_layout_box() => {
|
||||||
|
|
|
@ -102,10 +102,10 @@ impl AsyncBluetoothListener for BluetoothPermissionResult {
|
||||||
self.set_state(PermissionState::Granted);
|
self.set_state(PermissionState::Granted);
|
||||||
let bluetooth = self.get_bluetooth();
|
let bluetooth = self.get_bluetooth();
|
||||||
let mut device_instance_map = bluetooth.get_device_map().borrow_mut();
|
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
|
// https://webbluetoothcg.github.io/web-bluetooth/#request-the-bluetooth-permission
|
||||||
// Step 3.
|
// 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
|
// https://w3c.github.io/permissions/#dom-permissions-request
|
||||||
// Step 8.
|
// Step 8.
|
||||||
|
|
|
@ -3529,7 +3529,7 @@ impl Document {
|
||||||
self.id_map
|
self.id_map
|
||||||
.borrow()
|
.borrow()
|
||||||
.get(id)
|
.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> {
|
pub fn ensure_pending_restyle(&self, el: &Element) -> RefMut<PendingRestyle> {
|
||||||
|
|
|
@ -82,7 +82,7 @@ impl DocumentFragmentMethods for DocumentFragment {
|
||||||
self.id_map
|
self.id_map
|
||||||
.borrow()
|
.borrow()
|
||||||
.get(&id)
|
.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
|
// https://dom.spec.whatwg.org/#dom-parentnode-firstelementchild
|
||||||
|
|
|
@ -3246,7 +3246,7 @@ impl<'a> SelectorsElement for DomRoot<Element> {
|
||||||
operation: &AttrSelectorOperation<&AtomString>,
|
operation: &AttrSelectorOperation<&AtomString>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match *ns {
|
match *ns {
|
||||||
NamespaceConstraint::Specific(ref ns) => self
|
NamespaceConstraint::Specific(ns) => self
|
||||||
.get_attribute(ns, local_name)
|
.get_attribute(ns, local_name)
|
||||||
.map_or(false, |attr| attr.value().eval_selector(operation)),
|
.map_or(false, |attr| attr.value().eval_selector(operation)),
|
||||||
NamespaceConstraint::Any => self.attrs.borrow().iter().any(|attr| {
|
NamespaceConstraint::Any => self.attrs.borrow().iter().any(|attr| {
|
||||||
|
|
|
@ -1209,7 +1209,7 @@ impl GlobalScope {
|
||||||
if let Some(channels) = channels.get(&channel_name) {
|
if let Some(channels) = channels.get(&channel_name) {
|
||||||
channels
|
channels
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|ref channel| {
|
.filter(|channel| {
|
||||||
// Step 8.
|
// Step 8.
|
||||||
// Filter out the sender.
|
// Filter out the sender.
|
||||||
if let Some(id) = channel_id {
|
if let Some(id) = channel_id {
|
||||||
|
@ -1355,7 +1355,7 @@ impl GlobalScope {
|
||||||
{
|
{
|
||||||
let to_be_removed: Vec<MessagePortId> = message_ports
|
let to_be_removed: Vec<MessagePortId> = message_ports
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(id, ref managed_port)| {
|
.filter_map(|(id, managed_port)| {
|
||||||
if managed_port.closed {
|
if managed_port.closed {
|
||||||
// Let the constellation know to drop this port and the one it is entangled with,
|
// 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.
|
// 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()
|
&mut *self.broadcast_channel_state.borrow_mut()
|
||||||
{
|
{
|
||||||
channels.retain(|name, ref mut channels| {
|
channels.retain(|name, ref mut channels| {
|
||||||
channels.retain(|ref chan| !chan.closed());
|
channels.retain(|chan| !chan.closed());
|
||||||
if channels.is_empty() {
|
if channels.is_empty() {
|
||||||
let _ = self.script_to_constellation_chan().send(
|
let _ = self.script_to_constellation_chan().send(
|
||||||
ScriptMsg::RemoveBroadcastChannelNameInRouter(
|
ScriptMsg::RemoveBroadcastChannelNameInRouter(
|
||||||
|
|
|
@ -2483,7 +2483,7 @@ impl VirtualMethods for HTMLInputElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, context: &BindContext) {
|
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);
|
s.bind_to_tree(context);
|
||||||
}
|
}
|
||||||
self.upcast::<Element>()
|
self.upcast::<Element>()
|
||||||
|
@ -2620,7 +2620,7 @@ impl VirtualMethods for HTMLInputElement {
|
||||||
maybe_doc: Option<&Document>,
|
maybe_doc: Option<&Document>,
|
||||||
clone_children: CloneChildrenFlag,
|
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);
|
s.cloning_steps(copy, maybe_doc, clone_children);
|
||||||
}
|
}
|
||||||
let elem = copy.downcast::<HTMLInputElement>().unwrap();
|
let elem = copy.downcast::<HTMLInputElement>().unwrap();
|
||||||
|
|
|
@ -59,7 +59,7 @@ impl VirtualMethods for HTMLLegendElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, context: &BindContext) {
|
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);
|
s.bind_to_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ impl VirtualMethods for HTMLLinkElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, context: &BindContext) {
|
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);
|
s.bind_to_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ impl VirtualMethods for HTMLLinkElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from_tree(&self, context: &UnbindContext) {
|
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);
|
s.unbind_from_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ impl VirtualMethods for HTMLMetaElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, context: &BindContext) {
|
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);
|
s.bind_to_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ impl VirtualMethods for HTMLMetaElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from_tree(&self, context: &UnbindContext) {
|
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);
|
s.unbind_from_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ impl VirtualMethods for HTMLOptGroupElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, context: &BindContext) {
|
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);
|
s.bind_to_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -336,7 +336,7 @@ impl VirtualMethods for HTMLOptionElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, context: &BindContext) {
|
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);
|
s.bind_to_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1254,7 +1254,7 @@ impl VirtualMethods for HTMLScriptElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn children_changed(&self, mutation: &ChildrenMutation) {
|
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);
|
s.children_changed(mutation);
|
||||||
}
|
}
|
||||||
if !self.parser_inserted.get() && self.upcast::<Node>().is_connected() {
|
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) {
|
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);
|
s.bind_to_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1281,7 +1281,7 @@ impl VirtualMethods for HTMLScriptElement {
|
||||||
maybe_doc: Option<&Document>,
|
maybe_doc: Option<&Document>,
|
||||||
clone_children: CloneChildrenFlag,
|
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);
|
s.cloning_steps(copy, maybe_doc, clone_children);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -447,7 +447,7 @@ impl VirtualMethods for HTMLSelectElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bind_to_tree(&self, context: &BindContext) {
|
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);
|
s.bind_to_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -225,7 +225,7 @@ impl VirtualMethods for HTMLStyleElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unbind_from_tree(&self, context: &UnbindContext) {
|
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);
|
s.unbind_from_tree(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ impl CollectionFilter for TableRowFilter {
|
||||||
(root.is_parent_of(elem.upcast()) ||
|
(root.is_parent_of(elem.upcast()) ||
|
||||||
self.sections
|
self.sections
|
||||||
.iter()
|
.iter()
|
||||||
.any(|ref section| section.is_parent_of(elem.upcast())))
|
.any(|section| section.is_parent_of(elem.upcast())))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,12 +232,12 @@ impl Node {
|
||||||
assert!(new_child.prev_sibling.get().is_none());
|
assert!(new_child.prev_sibling.get().is_none());
|
||||||
assert!(new_child.next_sibling.get().is_none());
|
assert!(new_child.next_sibling.get().is_none());
|
||||||
match before {
|
match before {
|
||||||
Some(ref before) => {
|
Some(before) => {
|
||||||
assert!(before.parent_node.get().as_deref() == Some(self));
|
assert!(before.parent_node.get().as_deref() == Some(self));
|
||||||
let prev_sibling = before.GetPreviousSibling();
|
let prev_sibling = before.GetPreviousSibling();
|
||||||
match prev_sibling {
|
match prev_sibling {
|
||||||
None => {
|
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));
|
self.first_child.set(Some(new_child));
|
||||||
},
|
},
|
||||||
Some(ref prev_sibling) => {
|
Some(ref prev_sibling) => {
|
||||||
|
|
|
@ -206,7 +206,7 @@ impl RTCPeerConnection {
|
||||||
let signaller = this.make_signaller();
|
let signaller = this.make_signaller();
|
||||||
*this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller));
|
*this.controller.borrow_mut() = Some(ServoMedia::get().unwrap().create_webrtc(signaller));
|
||||||
if let Some(ref servers) = config.iceServers {
|
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 {
|
let server = match server.urls {
|
||||||
StringOrStringSequence::String(ref s) => Some(s.clone()),
|
StringOrStringSequence::String(ref s) => Some(s.clone()),
|
||||||
StringOrStringSequence::StringSequence(ref s) => s.get(0).cloned(),
|
StringOrStringSequence::StringSequence(ref s) => s.get(0).cloned(),
|
||||||
|
|
|
@ -255,8 +255,8 @@ impl<'dom, LayoutDataType: LayoutDataTrait> style::dom::TElement
|
||||||
where
|
where
|
||||||
F: FnMut(&AtomIdent),
|
F: FnMut(&AtomIdent),
|
||||||
{
|
{
|
||||||
if let Some(ref classes) = self.element.get_classes_for_layout() {
|
if let Some(classes) = self.element.get_classes_for_layout() {
|
||||||
for class in *classes {
|
for class in classes {
|
||||||
callback(AtomIdent::cast(class))
|
callback(AtomIdent::cast(class))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,7 +520,7 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
|
||||||
operation: &AttrSelectorOperation<&AtomString>,
|
operation: &AttrSelectorOperation<&AtomString>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match *ns {
|
match *ns {
|
||||||
NamespaceConstraint::Specific(ref ns) => self
|
NamespaceConstraint::Specific(ns) => self
|
||||||
.get_attr_enum(ns, local_name)
|
.get_attr_enum(ns, local_name)
|
||||||
.map_or(false, |value| value.eval_selector(operation)),
|
.map_or(false, |value| value.eval_selector(operation)),
|
||||||
NamespaceConstraint::Any => self
|
NamespaceConstraint::Any => self
|
||||||
|
@ -875,7 +875,7 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
|
||||||
operation: &AttrSelectorOperation<&AtomString>,
|
operation: &AttrSelectorOperation<&AtomString>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
match *ns {
|
match *ns {
|
||||||
NamespaceConstraint::Specific(ref ns) => self
|
NamespaceConstraint::Specific(ns) => self
|
||||||
.get_attr_enum(ns, local_name)
|
.get_attr_enum(ns, local_name)
|
||||||
.map_or(false, |value| value.eval_selector(operation)),
|
.map_or(false, |value| value.eval_selector(operation)),
|
||||||
NamespaceConstraint::Any => self
|
NamespaceConstraint::Any => self
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue