mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +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) {
|
pub(crate) fn cancel_animations_for_node(&self, node: &Node) {
|
||||||
let mut animations = self.sets.sets.write();
|
let mut animations = self.sets.sets.write();
|
||||||
let mut cancel_animations_for = |key| {
|
let mut cancel_animations_for = |key| {
|
||||||
animations.get_mut(&key).map(|set| {
|
if let Some(set) = animations.get_mut(&key) {
|
||||||
set.cancel_all_animations();
|
set.cancel_all_animations();
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let opaque_node = node.to_opaque();
|
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 impl<T: JSTraceable> CustomTraceable for OnceCell<T> {
|
||||||
unsafe fn trace(&self, tracer: *mut JSTracer) {
|
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) {
|
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) => {
|
RulesSource::Rules(ref css_rules) => {
|
||||||
css_rules.write_with(&mut guard).remove_rule(index)?;
|
css_rules.write_with(&mut guard).remove_rule(index)?;
|
||||||
let mut dom_rules = self.dom_rules.borrow_mut();
|
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);
|
dom_rules.remove(index);
|
||||||
Ok(())
|
Ok(())
|
||||||
},
|
},
|
||||||
RulesSource::Keyframes(ref kf) => {
|
RulesSource::Keyframes(ref kf) => {
|
||||||
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-deleterule
|
// https://drafts.csswg.org/css-animations/#dom-csskeyframesrule-deleterule
|
||||||
let mut dom_rules = self.dom_rules.borrow_mut();
|
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);
|
dom_rules.remove(index);
|
||||||
kf.write_with(&mut guard).keyframes.remove(index);
|
kf.write_with(&mut guard).keyframes.remove(index);
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -162,7 +166,9 @@ impl CSSRuleList {
|
||||||
// Remove parent stylesheets from all children
|
// Remove parent stylesheets from all children
|
||||||
pub fn deparent_all(&self) {
|
pub fn deparent_all(&self) {
|
||||||
for rule in self.dom_rules.borrow().iter() {
|
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
|
// 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)
|
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
|
||||||
// Check if document owner is fully active
|
// Check if document owner is fully active
|
||||||
self.form_owner().map(|o| {
|
if let Some(o) = self.form_owner() {
|
||||||
o.submit(
|
o.submit(
|
||||||
SubmittedFrom::NotFromForm,
|
SubmittedFrom::NotFromForm,
|
||||||
FormSubmitter::InputElement(self),
|
FormSubmitter::InputElement(self),
|
||||||
)
|
)
|
||||||
});
|
}
|
||||||
},
|
},
|
||||||
InputType::Reset => {
|
InputType::Reset => {
|
||||||
// https://html.spec.whatwg.org/multipage/#reset-button-state-(type=reset):activation-behavior
|
// 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)
|
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
|
||||||
// Check if document owner is fully active
|
// 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 => {
|
InputType::Checkbox | InputType::Radio => {
|
||||||
// https://html.spec.whatwg.org/multipage/#checkbox-state-(type=checkbox):activation-behavior
|
// https://html.spec.whatwg.org/multipage/#checkbox-state-(type=checkbox):activation-behavior
|
||||||
|
|
|
@ -1432,23 +1432,21 @@ impl HTMLMediaElement {
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
GLPlayerMsgForward::Lock(sender) => {
|
GLPlayerMsgForward::Lock(sender) => {
|
||||||
video_renderer
|
if let Some(holder) = video_renderer
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_frame_holder
|
.current_frame_holder
|
||||||
.as_mut()
|
.as_mut() {
|
||||||
.map(|holder| {
|
|
||||||
holder.lock();
|
holder.lock();
|
||||||
sender.send(holder.get()).unwrap();
|
sender.send(holder.get()).unwrap();
|
||||||
});
|
};
|
||||||
},
|
},
|
||||||
GLPlayerMsgForward::Unlock() => {
|
GLPlayerMsgForward::Unlock() => {
|
||||||
video_renderer
|
if let Some(holder) = video_renderer
|
||||||
.lock()
|
.lock()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.current_frame_holder
|
.current_frame_holder
|
||||||
.as_mut()
|
.as_mut() { holder.unlock() }
|
||||||
.map(|holder| holder.unlock());
|
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
|
@ -485,7 +485,9 @@ impl Tokenizer {
|
||||||
},
|
},
|
||||||
ParseOperation::MarkScriptAlreadyStarted { node } => {
|
ParseOperation::MarkScriptAlreadyStarted { node } => {
|
||||||
let script = self.get_node(&node).downcast::<HTMLScriptElement>();
|
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 } => {
|
ParseOperation::ReparentChildren { parent, new_parent } => {
|
||||||
let parent = self.get_node(&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>) {
|
fn mark_script_already_started(&mut self, node: &Dom<Node>) {
|
||||||
let script = node.downcast::<HTMLScriptElement>();
|
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 {
|
fn complete_script(&mut self, node: &Dom<Node>) -> NextParserState {
|
||||||
|
|
|
@ -267,10 +267,9 @@ impl WorkerMethods for Worker {
|
||||||
self.terminated.set(true);
|
self.terminated.set(true);
|
||||||
|
|
||||||
// Step 3
|
// Step 3
|
||||||
self.context_for_interrupt
|
if let Some(cx) = self.context_for_interrupt.borrow().as_ref() {
|
||||||
.borrow()
|
cx.request_interrupt()
|
||||||
.as_ref()
|
}
|
||||||
.map(|cx| cx.request_interrupt());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://html.spec.whatwg.org/multipage/#handler-worker-onmessage
|
// https://html.spec.whatwg.org/multipage/#handler-worker-onmessage
|
||||||
|
|
|
@ -70,9 +70,9 @@ struct DroppableField {
|
||||||
impl Drop for DroppableField {
|
impl Drop for DroppableField {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let worklet_id = self.worklet_id;
|
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);
|
thread_pool.exit_worklet(worklet_id);
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1127,13 +1127,13 @@ impl XMLHttpRequest {
|
||||||
// Part of step 13, send() (processing response)
|
// Part of step 13, send() (processing response)
|
||||||
// XXXManishearth handle errors, if any (substep 1)
|
// XXXManishearth handle errors, if any (substep 1)
|
||||||
// Substep 2
|
// Substep 2
|
||||||
status.map(|(code, reason)| {
|
if let Some((code, reason)) = status {
|
||||||
self.status.set(code);
|
self.status.set(code);
|
||||||
*self.status_text.borrow_mut() = ByteString::new(reason);
|
*self.status_text.borrow_mut() = ByteString::new(reason);
|
||||||
});
|
}
|
||||||
headers
|
if let Some(h) = headers.as_ref() {
|
||||||
.as_ref()
|
*self.response_headers.borrow_mut() = h.clone();
|
||||||
.map(|h| *self.response_headers.borrow_mut() = h.clone());
|
}
|
||||||
{
|
{
|
||||||
let len = headers.and_then(|h| h.typed_get::<ContentLength>());
|
let len = headers.and_then(|h| h.typed_get::<ContentLength>());
|
||||||
let mut response = self.response.borrow_mut();
|
let mut response = self.response.borrow_mut();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue