mirror of
https://github.com/servo/servo.git
synced 2025-06-08 00:23:30 +00:00
clippy: Fix option_map_unit_fn warnings (#31906)
This commit is contained in:
parent
a5bcae212a
commit
da76ebabe9
11 changed files with 43 additions and 30 deletions
|
@ -126,9 +126,9 @@ impl Animations {
|
|||
pub(crate) fn cancel_animations_for_node(&self, node: &Node) {
|
||||
let mut animations = self.sets.sets.write();
|
||||
let mut cancel_animations_for = |key| {
|
||||
animations.get_mut(&key).map(|set| {
|
||||
if let Some(set) = animations.get_mut(&key) {
|
||||
set.cancel_all_animations();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let opaque_node = node.to_opaque();
|
||||
|
|
|
@ -92,7 +92,9 @@ unsafe impl<T: CustomTraceable> CustomTraceable for DomRefCell<T> {
|
|||
|
||||
unsafe impl<T: JSTraceable> CustomTraceable for OnceCell<T> {
|
||||
unsafe fn trace(&self, tracer: *mut JSTracer) {
|
||||
self.get().map(|value| value.trace(tracer));
|
||||
if let Some(value) = self.get() {
|
||||
value.trace(tracer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -159,6 +159,8 @@ impl SpecificCSSRule for CSSKeyframesRule {
|
|||
}
|
||||
|
||||
fn deparent_children(&self) {
|
||||
self.rulelist.get().map(|list| list.deparent_all());
|
||||
if let Some(list) = self.rulelist.get() {
|
||||
list.deparent_all()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,14 +144,18 @@ impl CSSRuleList {
|
|||
RulesSource::Rules(ref css_rules) => {
|
||||
css_rules.write_with(&mut guard).remove_rule(index)?;
|
||||
let mut dom_rules = self.dom_rules.borrow_mut();
|
||||
dom_rules[index].get().map(|r| r.detach());
|
||||
if let Some(r) = dom_rules[index].get() {
|
||||
r.detach()
|
||||
}
|
||||
dom_rules.remove(index);
|
||||
Ok(())
|
||||
},
|
||||
RulesSource::Keyframes(ref kf) => {
|
||||
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-deleterule
|
||||
let mut dom_rules = self.dom_rules.borrow_mut();
|
||||
dom_rules[index].get().map(|r| r.detach());
|
||||
if let Some(r) = dom_rules[index].get() {
|
||||
r.detach()
|
||||
}
|
||||
dom_rules.remove(index);
|
||||
kf.write_with(&mut guard).keyframes.remove(index);
|
||||
Ok(())
|
||||
|
@ -162,7 +166,9 @@ impl CSSRuleList {
|
|||
// Remove parent stylesheets from all children
|
||||
pub fn deparent_all(&self) {
|
||||
for rule in self.dom_rules.borrow().iter() {
|
||||
rule.get().map(|r| DomRoot::upcast(r).deparent());
|
||||
if let Some(r) = rule.get() {
|
||||
DomRoot::upcast(r).deparent()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2832,18 +2832,20 @@ impl Activatable for HTMLInputElement {
|
|||
// https://html.spec.whatwg.org/multipage/#submit-button-state-(type=submit):activation-behavior
|
||||
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
|
||||
// Check if document owner is fully active
|
||||
self.form_owner().map(|o| {
|
||||
if let Some(o) = self.form_owner() {
|
||||
o.submit(
|
||||
SubmittedFrom::NotFromForm,
|
||||
FormSubmitter::InputElement(self),
|
||||
)
|
||||
});
|
||||
}
|
||||
},
|
||||
InputType::Reset => {
|
||||
// https://html.spec.whatwg.org/multipage/#reset-button-state-(type=reset):activation-behavior
|
||||
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
|
||||
// Check if document owner is fully active
|
||||
self.form_owner().map(|o| o.reset(ResetFrom::NotFromForm));
|
||||
if let Some(o) = self.form_owner() {
|
||||
o.reset(ResetFrom::NotFromForm)
|
||||
}
|
||||
},
|
||||
InputType::Checkbox | InputType::Radio => {
|
||||
// https://html.spec.whatwg.org/multipage/#checkbox-state-(type=checkbox):activation-behavior
|
||||
|
|
|
@ -1432,23 +1432,21 @@ impl HTMLMediaElement {
|
|||
|
||||
match msg {
|
||||
GLPlayerMsgForward::Lock(sender) => {
|
||||
video_renderer
|
||||
if let Some(holder) = video_renderer
|
||||
.lock()
|
||||
.unwrap()
|
||||
.current_frame_holder
|
||||
.as_mut()
|
||||
.map(|holder| {
|
||||
.as_mut() {
|
||||
holder.lock();
|
||||
sender.send(holder.get()).unwrap();
|
||||
});
|
||||
};
|
||||
},
|
||||
GLPlayerMsgForward::Unlock() => {
|
||||
video_renderer
|
||||
if let Some(holder) = video_renderer
|
||||
.lock()
|
||||
.unwrap()
|
||||
.current_frame_holder
|
||||
.as_mut()
|
||||
.map(|holder| holder.unlock());
|
||||
.as_mut() { holder.unlock() }
|
||||
},
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
@ -485,7 +485,9 @@ impl Tokenizer {
|
|||
},
|
||||
ParseOperation::MarkScriptAlreadyStarted { node } => {
|
||||
let script = self.get_node(&node).downcast::<HTMLScriptElement>();
|
||||
script.map(|script| script.set_already_started(true));
|
||||
if let Some(script) = script {
|
||||
script.set_already_started(true)
|
||||
}
|
||||
},
|
||||
ParseOperation::ReparentChildren { parent, new_parent } => {
|
||||
let parent = self.get_node(&parent);
|
||||
|
|
|
@ -1259,7 +1259,9 @@ impl TreeSink for Sink {
|
|||
|
||||
fn mark_script_already_started(&mut self, node: &Dom<Node>) {
|
||||
let script = node.downcast::<HTMLScriptElement>();
|
||||
script.map(|script| script.set_already_started(true));
|
||||
if let Some(script) = script {
|
||||
script.set_already_started(true)
|
||||
}
|
||||
}
|
||||
|
||||
fn complete_script(&mut self, node: &Dom<Node>) -> NextParserState {
|
||||
|
|
|
@ -267,10 +267,9 @@ impl WorkerMethods for Worker {
|
|||
self.terminated.set(true);
|
||||
|
||||
// Step 3
|
||||
self.context_for_interrupt
|
||||
.borrow()
|
||||
.as_ref()
|
||||
.map(|cx| cx.request_interrupt());
|
||||
if let Some(cx) = self.context_for_interrupt.borrow().as_ref() {
|
||||
cx.request_interrupt()
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#handler-worker-onmessage
|
||||
|
|
|
@ -70,9 +70,9 @@ struct DroppableField {
|
|||
impl Drop for DroppableField {
|
||||
fn drop(&mut self) {
|
||||
let worklet_id = self.worklet_id;
|
||||
self.thread_pool.get_mut().map(|thread_pool| {
|
||||
if let Some(thread_pool) = self.thread_pool.get_mut() {
|
||||
thread_pool.exit_worklet(worklet_id);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1127,13 +1127,13 @@ impl XMLHttpRequest {
|
|||
// Part of step 13, send() (processing response)
|
||||
// XXXManishearth handle errors, if any (substep 1)
|
||||
// Substep 2
|
||||
status.map(|(code, reason)| {
|
||||
if let Some((code, reason)) = status {
|
||||
self.status.set(code);
|
||||
*self.status_text.borrow_mut() = ByteString::new(reason);
|
||||
});
|
||||
headers
|
||||
.as_ref()
|
||||
.map(|h| *self.response_headers.borrow_mut() = h.clone());
|
||||
}
|
||||
if let Some(h) = headers.as_ref() {
|
||||
*self.response_headers.borrow_mut() = h.clone();
|
||||
}
|
||||
{
|
||||
let len = headers.and_then(|h| h.typed_get::<ContentLength>());
|
||||
let mut response = self.response.borrow_mut();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue