Skip to content

Commit

Permalink
clippy: Fix dereferenced warnings (#31770)
Browse files Browse the repository at this point in the history
  • Loading branch information
oluwatobiss committed Mar 20, 2024
1 parent 0cf2cab commit 02a0cdd
Show file tree
Hide file tree
Showing 43 changed files with 92 additions and 96 deletions.
2 changes: 1 addition & 1 deletion components/script/canvas_state.rs
Expand Up @@ -1039,7 +1039,7 @@ impl CanvasState {
};
let node = canvas.upcast::<Node>();
let window = window_from_node(&*canvas);
let resolved_font_style = match window.resolved_font_style_query(&node, value.to_string()) {
let resolved_font_style = match window.resolved_font_style_query(node, value.to_string()) {
Some(value) => value,
None => return, // syntax error
};
Expand Down
25 changes: 11 additions & 14 deletions components/script/dom/htmlinputelement.rs
Expand Up @@ -810,12 +810,12 @@ impl HTMLInputElement {

match self.input_type() {
// https://html.spec.whatwg.org/multipage/#url-state-(type%3Durl)%3Asuffering-from-a-type-mismatch
InputType::Url => Url::parse(&value).is_err(),
InputType::Url => Url::parse(value).is_err(),
// https://html.spec.whatwg.org/multipage/#e-mail-state-(type%3Demail)%3Asuffering-from-a-type-mismatch
// https://html.spec.whatwg.org/multipage/#e-mail-state-(type%3Demail)%3Asuffering-from-a-type-mismatch-2
InputType::Email => {
if self.Multiple() {
!split_commas(&value).all(|s| {
!split_commas(value).all(|s| {
DOMString::from_string(s.to_string()).is_valid_email_address_string()
})
} else {
Expand Down Expand Up @@ -843,10 +843,10 @@ impl HTMLInputElement {

if compile_pattern(cx, &pattern_str, pattern.handle_mut()) {
if self.Multiple() && self.does_multiple_apply() {
!split_commas(&value)
!split_commas(value)
.all(|s| matches_js_regex(cx, pattern.handle(), s).unwrap_or(true))
} else {
!matches_js_regex(cx, pattern.handle(), &value).unwrap_or(true)
!matches_js_regex(cx, pattern.handle(), value).unwrap_or(true)
}
} else {
// Element doesn't suffer from pattern mismatch if pattern is invalid.
Expand Down Expand Up @@ -926,7 +926,7 @@ impl HTMLInputElement {
return ValidationFlags::empty();
}

let value_as_number = match self.convert_string_to_number(&value) {
let value_as_number = match self.convert_string_to_number(value) {
Ok(num) => num,
Err(()) => return ValidationFlags::empty(),
};
Expand Down Expand Up @@ -1645,7 +1645,7 @@ fn radio_group_iter<'a>(
// If group is None, in_same_group always fails, but we need to always return elem.
root.traverse_preorder(ShadowIncluding::No)
.filter_map(|r| DomRoot::downcast::<HTMLInputElement>(r))
.filter(move |r| &**r == elem || in_same_group(&r, owner.as_deref(), group, None))
.filter(move |r| &**r == elem || in_same_group(r, owner.as_deref(), group, None))
}

fn broadcast_radio_checked(broadcaster: &HTMLInputElement, group: Option<&Atom>) {
Expand Down Expand Up @@ -1740,7 +1740,7 @@ impl HTMLInputElement {
datums.push(FormDatum {
ty: ty.clone(),
name: name.clone(),
value: FormDatumValue::File(DomRoot::from_ref(&f)),
value: FormDatumValue::File(DomRoot::from_ref(f)),
});
}
},
Expand Down Expand Up @@ -2068,7 +2068,7 @@ impl HTMLInputElement {

#[allow(crown::unrooted_must_root)]
fn selection(&self) -> TextControlSelection<Self> {
TextControlSelection::new(&self, &self.textinput)
TextControlSelection::new(self, &self.textinput)
}

// https://html.spec.whatwg.org/multipage/#implicit-submission
Expand Down Expand Up @@ -2129,10 +2129,7 @@ impl HTMLInputElement {
// lazily test for > 1 submission-blocking inputs
return;
}
form.submit(
SubmittedFrom::NotFromForm,
FormSubmitter::FormElement(&form),
);
form.submit(SubmittedFrom::NotFromForm, FormSubmitter::FormElement(form));
},
}
}
Expand Down Expand Up @@ -2607,7 +2604,7 @@ impl VirtualMethods for HTMLInputElement {
.task_manager()
.user_interaction_task_source()
.queue_event(
&self.upcast(),
self.upcast(),
atom!("input"),
EventBubbles::Bubbles,
EventCancelable::NotCancelable,
Expand Down Expand Up @@ -2828,7 +2825,7 @@ impl Activatable for HTMLInputElement {
// Avoiding iterating through the whole tree here, instead
// we can check if the conditions for radio group siblings apply
if in_same_group(
&o,
o,
self.form_owner().as_deref(),
self.radio_group_name().as_ref(),
Some(&*tree_root),
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/htmllinkelement.rs
Expand Up @@ -308,7 +308,7 @@ impl HTMLLinkElement {
None => "",
};

let mut input = ParserInput::new(&mq_str);
let mut input = ParserInput::new(mq_str);
let mut css_parser = CssParser::new(&mut input);
let document_url_data = &UrlExtraData(document.url().get_arc());
let window = document.window();
Expand All @@ -317,7 +317,7 @@ impl HTMLLinkElement {
// much sense.
let context = CssParserContext::new(
Origin::Author,
&document_url_data,
document_url_data,
Some(CssRuleType::Media),
ParsingMode::DEFAULT,
document.quirks_mode(),
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/htmlmediaelement.rs
Expand Up @@ -1952,7 +1952,7 @@ impl HTMLMediaElement {
let global = self.global();
let media_session = global.as_window().Navigator().MediaSession();

media_session.register_media_instance(&self);
media_session.register_media_instance(self);

media_session.send_event(event);
}
Expand Down
20 changes: 10 additions & 10 deletions components/script/dom/htmlscriptelement.rs
Expand Up @@ -300,7 +300,7 @@ impl ScriptOrigin {

pub fn text(&self) -> Rc<DOMString> {
match &self.code {
SourceCode::Text(text) => Rc::clone(&text),
SourceCode::Text(text) => Rc::clone(text),
SourceCode::Compiled(compiled_script) => Rc::clone(&compiled_script.original_text),
}
}
Expand All @@ -319,11 +319,11 @@ fn finish_fetching_a_classic_script(
let document = document_from_node(&*elem);

match script_kind {
ExternalScriptKind::Asap => document.asap_script_loaded(&elem, load),
ExternalScriptKind::AsapInOrder => document.asap_in_order_script_loaded(&elem, load),
ExternalScriptKind::Deferred => document.deferred_script_loaded(&elem, load),
ExternalScriptKind::Asap => document.asap_script_loaded(elem, load),
ExternalScriptKind::AsapInOrder => document.asap_in_order_script_loaded(elem, load),
ExternalScriptKind::Deferred => document.deferred_script_loaded(elem, load),
ExternalScriptKind::ParsingBlocking => {
document.pending_parsing_blocking_script_loaded(&elem, load)
document.pending_parsing_blocking_script_loaded(elem, load)
},
}

Expand Down Expand Up @@ -645,7 +645,7 @@ impl HTMLScriptElement {
// Step 15.
if !element.has_attribute(&local_name!("src")) &&
doc.should_elements_inline_type_behavior_be_blocked(
&element,
element,
csp::InlineCheckType::Script,
&text,
) == csp::CheckResult::Blocked
Expand Down Expand Up @@ -1085,7 +1085,7 @@ impl HTMLScriptElement {
// Step 4
let window = window_from_node(self);
let global = window.upcast::<GlobalScope>();
let _aes = AutoEntryScript::new(&global);
let _aes = AutoEntryScript::new(global);

let tree = if script.external {
global.get_module_map().borrow().get(&script.url).cloned()
Expand All @@ -1103,7 +1103,7 @@ impl HTMLScriptElement {
let module_error = module_tree.get_rethrow_error().borrow();
let network_error = module_tree.get_network_error().borrow();
if module_error.is_some() && network_error.is_none() {
module_tree.report_error(&global);
module_tree.report_error(global);
return;
}
}
Expand All @@ -1117,11 +1117,11 @@ impl HTMLScriptElement {
if let Some(record) = record {
rooted!(in(*GlobalScope::get_cx()) let mut rval = UndefinedValue());
let evaluated =
module_tree.execute_module(&global, record, rval.handle_mut().into());
module_tree.execute_module(global, record, rval.handle_mut().into());

if let Err(exception) = evaluated {
module_tree.set_rethrow_error(exception);
module_tree.report_error(&global);
module_tree.report_error(global);
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/htmltextareaelement.rs
Expand Up @@ -456,7 +456,7 @@ impl HTMLTextAreaElement {

#[allow(crown::unrooted_must_root)]
fn selection(&self) -> TextControlSelection<Self> {
TextControlSelection::new(&self, &self.textinput)
TextControlSelection::new(self, &self.textinput)
}
}

Expand Down Expand Up @@ -656,7 +656,7 @@ impl VirtualMethods for HTMLTextAreaElement {
.task_manager()
.user_interaction_task_source()
.queue_event(
&self.upcast(),
self.upcast(),
atom!("input"),
EventBubbles::Bubbles,
EventCancelable::NotCancelable,
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/htmltrackelement.rs
Expand Up @@ -45,7 +45,7 @@ impl HTMLTrackElement {
HTMLTrackElement {
htmlelement: HTMLElement::new_inherited(local_name, prefix, document),
ready_state: ReadyState::None,
track: Dom::from_ref(&track),
track: Dom::from_ref(track),
}
}

Expand All @@ -56,7 +56,7 @@ impl HTMLTrackElement {
proto: Option<HandleObject>,
) -> DomRoot<HTMLTrackElement> {
let track = TextTrack::new(
&document.window(),
document.window(),
Default::default(),
Default::default(),
Default::default(),
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/htmlvideoelement.rs
Expand Up @@ -148,7 +148,7 @@ impl HTMLVideoElement {
}

// Step 3.
let poster_url = match document_from_node(self).url().join(&poster_url) {
let poster_url = match document_from_node(self).url().join(poster_url) {
Ok(url) => url,
Err(_) => return,
};
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/mediametadata.rs
Expand Up @@ -65,7 +65,7 @@ impl MediaMetadata {
}

pub fn set_session(&self, session: &MediaSession) {
self.session.set(Some(&session));
self.session.set(Some(session));
}
}

Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/mediasession.rs
Expand Up @@ -133,7 +133,7 @@ impl MediaSessionMethods for MediaSession {
init.artist = DOMString::from_string(metadata.artist.clone());
init.album = DOMString::from_string(metadata.album.clone());
let global = self.global();
Some(MediaMetadata::new(&global.as_window(), &init))
Some(MediaMetadata::new(global.as_window(), &init))
} else {
None
}
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/mediastream.rs
Expand Up @@ -154,7 +154,7 @@ impl MediaStream {
fn clone_with_proto(&self, proto: Option<HandleObject>) -> DomRoot<MediaStream> {
let new = MediaStream::new_with_proto(&self.global(), proto);
for track in &*self.tracks.borrow() {
new.add_track(&track)
new.add_track(track)
}
new
}
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/mediastreamaudiodestinationnode.rs
Expand Up @@ -43,7 +43,7 @@ impl MediaStreamAudioDestinationNode {
);
let node = AudioNode::new_inherited(
AudioNodeInit::MediaStreamDestinationNode(socket),
&context.upcast(),
context.upcast(),
node_options,
1, // inputs
0, // outputs
Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/mediastreamaudiosourcenode.rs
Expand Up @@ -39,14 +39,14 @@ impl MediaStreamAudioSourceNode {
.id();
let node = AudioNode::new_inherited(
AudioNodeInit::MediaStreamSourceNode(track),
&context.upcast(),
context.upcast(),
Default::default(),
0, // inputs
1, // outputs
)?;
Ok(MediaStreamAudioSourceNode {
node,
stream: Dom::from_ref(&stream),
stream: Dom::from_ref(stream),
})
}

Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/mediastreamtrackaudiosourcenode.rs
Expand Up @@ -30,14 +30,14 @@ impl MediaStreamTrackAudioSourceNode {
) -> Fallible<MediaStreamTrackAudioSourceNode> {
let node = AudioNode::new_inherited(
AudioNodeInit::MediaStreamSourceNode(track.id()),
&context.upcast(),
context.upcast(),
Default::default(),
0, // inputs
1, // outputs
)?;
Ok(MediaStreamTrackAudioSourceNode {
node,
track: Dom::from_ref(&track),
track: Dom::from_ref(track),
})
}

Expand Down
4 changes: 2 additions & 2 deletions components/script/dom/messagechannel.rs
Expand Up @@ -31,10 +31,10 @@ impl MessageChannel {
/// <https://html.spec.whatwg.org/multipage/#dom-messagechannel>
fn new(incumbent: &GlobalScope, proto: Option<HandleObject>) -> DomRoot<MessageChannel> {
// Step 1
let port1 = MessagePort::new(&incumbent);
let port1 = MessagePort::new(incumbent);

// Step 2
let port2 = MessagePort::new(&incumbent);
let port2 = MessagePort::new(incumbent);

incumbent.track_message_port(&*port1, None);
incumbent.track_message_port(&*port2, None);
Expand Down
3 changes: 1 addition & 2 deletions components/script/dom/navigator.rs
Expand Up @@ -214,8 +214,7 @@ impl NavigatorMethods for Navigator {

/// <https://immersive-web.github.io/webxr/#dom-navigator-xr>
fn Xr(&self) -> DomRoot<XRSystem> {
self.xr
.or_init(|| XRSystem::new(&self.global().as_window()))
self.xr.or_init(|| XRSystem::new(self.global().as_window()))
}

/// <https://w3c.github.io/mediacapture-main/#dom-navigator-mediadevices>
Expand Down

0 comments on commit 02a0cdd

Please sign in to comment.