mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Fixed some clippy warnings by replacing 'match' with 'if' (#32007)
This commit is contained in:
parent
05f1bbf0a9
commit
e0e3408650
5 changed files with 57 additions and 71 deletions
|
@ -2767,15 +2767,12 @@ impl FetchResponseListener for HTMLMediaElementFetchListener {
|
||||||
// restart the download later from where we left, we cancel
|
// restart the download later from where we left, we cancel
|
||||||
// the current request. Otherwise, we continue the request
|
// the current request. Otherwise, we continue the request
|
||||||
// assuming that we may drop some frames.
|
// assuming that we may drop some frames.
|
||||||
match e {
|
if e == PlayerError::EnoughData {
|
||||||
PlayerError::EnoughData => {
|
if let Some(ref mut current_fetch_context) =
|
||||||
if let Some(ref mut current_fetch_context) =
|
*elem.current_fetch_context.borrow_mut()
|
||||||
*elem.current_fetch_context.borrow_mut()
|
{
|
||||||
{
|
current_fetch_context.cancel(CancelReason::Backoff);
|
||||||
current_fetch_context.cancel(CancelReason::Backoff);
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
warn!("Could not push input data to player {:?}", e);
|
warn!("Could not push input data to player {:?}", e);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -87,38 +87,35 @@ impl VirtualMethods for HTMLOptGroupElement {
|
||||||
|
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
match attr.local_name() {
|
if attr.local_name() == &local_name!("disabled") {
|
||||||
&local_name!("disabled") => {
|
let disabled_state = match mutation {
|
||||||
let disabled_state = match mutation {
|
AttributeMutation::Set(None) => true,
|
||||||
AttributeMutation::Set(None) => true,
|
AttributeMutation::Set(Some(_)) => {
|
||||||
AttributeMutation::Set(Some(_)) => {
|
// Option group was already disabled.
|
||||||
// Option group was already disabled.
|
return;
|
||||||
return;
|
},
|
||||||
},
|
AttributeMutation::Removed => false,
|
||||||
AttributeMutation::Removed => false,
|
};
|
||||||
};
|
let el = self.upcast::<Element>();
|
||||||
let el = self.upcast::<Element>();
|
el.set_disabled_state(disabled_state);
|
||||||
el.set_disabled_state(disabled_state);
|
el.set_enabled_state(!disabled_state);
|
||||||
el.set_enabled_state(!disabled_state);
|
let options = el
|
||||||
let options = el
|
.upcast::<Node>()
|
||||||
.upcast::<Node>()
|
.children()
|
||||||
.children()
|
.filter(|child| child.is::<HTMLOptionElement>())
|
||||||
.filter(|child| child.is::<HTMLOptionElement>())
|
.map(|child| DomRoot::from_ref(child.downcast::<HTMLOptionElement>().unwrap()));
|
||||||
.map(|child| DomRoot::from_ref(child.downcast::<HTMLOptionElement>().unwrap()));
|
if disabled_state {
|
||||||
if disabled_state {
|
for option in options {
|
||||||
for option in options {
|
let el = option.upcast::<Element>();
|
||||||
let el = option.upcast::<Element>();
|
el.set_disabled_state(true);
|
||||||
el.set_disabled_state(true);
|
el.set_enabled_state(false);
|
||||||
el.set_enabled_state(false);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for option in options {
|
|
||||||
let el = option.upcast::<Element>();
|
|
||||||
el.check_disabled_attribute();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
} else {
|
||||||
_ => {},
|
for option in options {
|
||||||
|
let el = option.upcast::<Element>();
|
||||||
|
el.check_disabled_attribute();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -158,11 +158,8 @@ impl VirtualMethods for HTMLOutputElement {
|
||||||
|
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
match attr.local_name() {
|
if attr.local_name() == &local_name!("form") {
|
||||||
&local_name!("form") => {
|
self.form_attribute_mutated(mutation);
|
||||||
self.form_attribute_mutated(mutation);
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -657,21 +657,20 @@ impl HTMLScriptElement {
|
||||||
if script_type == ScriptType::Classic {
|
if script_type == ScriptType::Classic {
|
||||||
let for_attribute = element.get_attribute(&ns!(), &local_name!("for"));
|
let for_attribute = element.get_attribute(&ns!(), &local_name!("for"));
|
||||||
let event_attribute = element.get_attribute(&ns!(), &local_name!("event"));
|
let event_attribute = element.get_attribute(&ns!(), &local_name!("event"));
|
||||||
match (for_attribute, event_attribute) {
|
if let (Some(ref for_attribute), Some(ref event_attribute)) =
|
||||||
(Some(ref for_attribute), Some(ref event_attribute)) => {
|
(for_attribute, event_attribute)
|
||||||
let for_value = for_attribute.value().to_ascii_lowercase();
|
{
|
||||||
let for_value = for_value.trim_matches(HTML_SPACE_CHARACTERS);
|
let for_value = for_attribute.value().to_ascii_lowercase();
|
||||||
if for_value != "window" {
|
let for_value = for_value.trim_matches(HTML_SPACE_CHARACTERS);
|
||||||
return;
|
if for_value != "window" {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let event_value = event_attribute.value().to_ascii_lowercase();
|
let event_value = event_attribute.value().to_ascii_lowercase();
|
||||||
let event_value = event_value.trim_matches(HTML_SPACE_CHARACTERS);
|
let event_value = event_value.trim_matches(HTML_SPACE_CHARACTERS);
|
||||||
if event_value != "onload" && event_value != "onload()" {
|
if event_value != "onload" && event_value != "onload()" {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
(_, _) => (),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1239,15 +1238,12 @@ impl VirtualMethods for HTMLScriptElement {
|
||||||
|
|
||||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||||
match *attr.local_name() {
|
if *attr.local_name() == local_name!("src") {
|
||||||
local_name!("src") => {
|
if let AttributeMutation::Set(_) = mutation {
|
||||||
if let AttributeMutation::Set(_) = mutation {
|
if !self.parser_inserted.get() && self.upcast::<Node>().is_connected() {
|
||||||
if !self.parser_inserted.get() && self.upcast::<Node>().is_connected() {
|
self.prepare();
|
||||||
self.prepare();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => {},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -288,10 +288,9 @@ impl FetchResponseListener for FetchContext {
|
||||||
|
|
||||||
fn submit_resource_timing(&mut self) {
|
fn submit_resource_timing(&mut self) {
|
||||||
// navigation submission is handled in servoparser/mod.rs
|
// navigation submission is handled in servoparser/mod.rs
|
||||||
match self.resource_timing.timing_type {
|
if self.resource_timing.timing_type == ResourceTimingType::Resource {
|
||||||
ResourceTimingType::Resource => network_listener::submit_timing(self),
|
network_listener::submit_timing(self)
|
||||||
_ => {},
|
}
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue