mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
clippy: Fix single_match warnings (#31876)
This commit is contained in:
parent
d16f259e1d
commit
b71de92569
7 changed files with 115 additions and 133 deletions
|
@ -354,11 +354,10 @@ impl AudioNodeMethods for AudioNode {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
match self.upcast::<EventTarget>().type_id() {
|
if let EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) =
|
||||||
EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) => {
|
self.upcast::<EventTarget>().type_id()
|
||||||
return Err(Error::InvalidState);
|
{
|
||||||
},
|
return Err(Error::InvalidState);
|
||||||
_ => (),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.channel_interpretation.set(value);
|
self.channel_interpretation.set(value);
|
||||||
|
|
|
@ -741,13 +741,10 @@ fn parse_time_component(value: &str) -> Option<(u32, u32, f64)> {
|
||||||
if second_iterator.next()?.len() != 2 {
|
if second_iterator.next()?.len() != 2 {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
match second_iterator.next() {
|
if let Some(second_last) = second_iterator.next() {
|
||||||
Some(second_last) => {
|
if second_last.len() > 3 {
|
||||||
if second_last.len() > 3 {
|
return None;
|
||||||
return None;
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
None => {},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
second.parse::<f64>().ok()?
|
second.parse::<f64>().ok()?
|
||||||
|
|
|
@ -74,17 +74,14 @@ impl<'a> ProcessDataURL for &'a HTMLObjectElement {
|
||||||
// Makes the local `data` member match the status of the `data` attribute and starts
|
// Makes the local `data` member match the status of the `data` attribute and starts
|
||||||
/// prefetching the image. This method must be called after `data` is changed.
|
/// prefetching the image. This method must be called after `data` is changed.
|
||||||
fn process_data_url(&self) {
|
fn process_data_url(&self) {
|
||||||
let elem = self.upcast::<Element>();
|
let element = self.upcast::<Element>();
|
||||||
|
|
||||||
// TODO: support other values
|
// TODO: support other values
|
||||||
match (
|
if let (None, Some(_uri)) = (
|
||||||
elem.get_attribute(&ns!(), &local_name!("type")),
|
element.get_attribute(&ns!(), &local_name!("type")),
|
||||||
elem.get_attribute(&ns!(), &local_name!("data")),
|
element.get_attribute(&ns!(), &local_name!("data")),
|
||||||
) {
|
) {
|
||||||
(None, Some(_uri)) => {
|
// TODO(gw): Prefetch the image here.
|
||||||
// TODO(gw): Prefetch the image here.
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2981,33 +2981,30 @@ impl NodeMethods for Node {
|
||||||
// same owner element.
|
// same owner element.
|
||||||
if let Some(node2) = node2 {
|
if let Some(node2) = node2 {
|
||||||
if Some(node2) == node1 {
|
if Some(node2) == node1 {
|
||||||
match (attr1, attr2) {
|
if let (Some(a1), Some(a2)) = (attr1, attr2) {
|
||||||
(Some(a1), Some(a2)) => {
|
let attrs = node2.downcast::<Element>().unwrap().attrs();
|
||||||
let attrs = node2.downcast::<Element>().unwrap().attrs();
|
// go through the attrs in order to see if self
|
||||||
// go through the attrs in order to see if self
|
// or other is first; spec is clear that we
|
||||||
// or other is first; spec is clear that we
|
// want value-equality, not reference-equality
|
||||||
// want value-equality, not reference-equality
|
for attr in attrs.iter() {
|
||||||
for attr in attrs.iter() {
|
if (*attr.namespace() == *a1.namespace()) &&
|
||||||
if (*attr.namespace() == *a1.namespace()) &&
|
(attr.local_name() == a1.local_name()) &&
|
||||||
(attr.local_name() == a1.local_name()) &&
|
(**attr.value() == **a1.value())
|
||||||
(**attr.value() == **a1.value())
|
{
|
||||||
{
|
return NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
|
||||||
return NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
|
NodeConstants::DOCUMENT_POSITION_PRECEDING;
|
||||||
NodeConstants::DOCUMENT_POSITION_PRECEDING;
|
|
||||||
}
|
|
||||||
if (*attr.namespace() == *a2.namespace()) &&
|
|
||||||
(attr.local_name() == a2.local_name()) &&
|
|
||||||
(**attr.value() == **a2.value())
|
|
||||||
{
|
|
||||||
return NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
|
|
||||||
NodeConstants::DOCUMENT_POSITION_FOLLOWING;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// both attrs have node2 as their owner element, so
|
if (*attr.namespace() == *a2.namespace()) &&
|
||||||
// we can't have left the loop without seeing them
|
(attr.local_name() == a2.local_name()) &&
|
||||||
unreachable!();
|
(**attr.value() == **a2.value())
|
||||||
},
|
{
|
||||||
(_, _) => {},
|
return NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
|
||||||
|
NodeConstants::DOCUMENT_POSITION_FOLLOWING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// both attrs have node2 as their owner element, so
|
||||||
|
// we can't have left the loop without seeing them
|
||||||
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -200,17 +200,14 @@ impl RTCDataChannel {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn on_state_change(&self, state: DataChannelState) {
|
pub fn on_state_change(&self, state: DataChannelState) {
|
||||||
match state {
|
if let DataChannelState::Closing = state {
|
||||||
DataChannelState::Closing => {
|
let event = Event::new(
|
||||||
let event = Event::new(
|
&self.global(),
|
||||||
&self.global(),
|
atom!("closing"),
|
||||||
atom!("closing"),
|
EventBubbles::DoesNotBubble,
|
||||||
EventBubbles::DoesNotBubble,
|
EventCancelable::NotCancelable,
|
||||||
EventCancelable::NotCancelable,
|
);
|
||||||
);
|
event.upcast::<Event>().fire(self.upcast());
|
||||||
event.upcast::<Event>().fire(self.upcast());
|
|
||||||
},
|
|
||||||
_ => {},
|
|
||||||
};
|
};
|
||||||
self.ready_state.set(state.into());
|
self.ready_state.set(state.into());
|
||||||
}
|
}
|
||||||
|
|
|
@ -724,65 +724,62 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
|
||||||
.pipeline_id(Some(self.global().pipeline_id()));
|
.pipeline_id(Some(self.global().pipeline_id()));
|
||||||
|
|
||||||
// step 4 (second half)
|
// step 4 (second half)
|
||||||
match content_type {
|
if let Some(content_type) = content_type {
|
||||||
Some(content_type) => {
|
let encoding = match data {
|
||||||
let encoding = match data {
|
Some(DocumentOrXMLHttpRequestBodyInit::String(_)) |
|
||||||
Some(DocumentOrXMLHttpRequestBodyInit::String(_)) |
|
Some(DocumentOrXMLHttpRequestBodyInit::Document(_)) =>
|
||||||
Some(DocumentOrXMLHttpRequestBodyInit::Document(_)) =>
|
// XHR spec differs from http, and says UTF-8 should be in capitals,
|
||||||
// XHR spec differs from http, and says UTF-8 should be in capitals,
|
// instead of "utf-8", which is what Hyper defaults to. So not
|
||||||
// instead of "utf-8", which is what Hyper defaults to. So not
|
// using content types provided by Hyper.
|
||||||
// using content types provided by Hyper.
|
{
|
||||||
{
|
Some("UTF-8")
|
||||||
Some("UTF-8")
|
},
|
||||||
},
|
_ => None,
|
||||||
_ => None,
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let mut content_type_set = false;
|
let mut content_type_set = false;
|
||||||
if !request.headers.contains_key(header::CONTENT_TYPE) {
|
if !request.headers.contains_key(header::CONTENT_TYPE) {
|
||||||
request.headers.insert(
|
request.headers.insert(
|
||||||
header::CONTENT_TYPE,
|
header::CONTENT_TYPE,
|
||||||
HeaderValue::from_str(&content_type).unwrap(),
|
HeaderValue::from_str(&content_type).unwrap(),
|
||||||
);
|
);
|
||||||
content_type_set = true;
|
content_type_set = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !content_type_set {
|
if !content_type_set {
|
||||||
let ct = request.headers.typed_get::<ContentType>();
|
let ct = request.headers.typed_get::<ContentType>();
|
||||||
if let Some(ct) = ct {
|
if let Some(ct) = ct {
|
||||||
if let Some(encoding) = encoding {
|
if let Some(encoding) = encoding {
|
||||||
let mime: Mime = ct.into();
|
let mime: Mime = ct.into();
|
||||||
for param in mime.params() {
|
for param in mime.params() {
|
||||||
if param.0 == mime::CHARSET &&
|
if param.0 == mime::CHARSET &&
|
||||||
!param.1.as_ref().eq_ignore_ascii_case(encoding)
|
!param.1.as_ref().eq_ignore_ascii_case(encoding)
|
||||||
{
|
{
|
||||||
let new_params: Vec<(Name, Name)> = mime
|
let new_params: Vec<(Name, Name)> = mime
|
||||||
.params()
|
.params()
|
||||||
.filter(|p| p.0 != mime::CHARSET)
|
.filter(|p| p.0 != mime::CHARSET)
|
||||||
.map(|p| (p.0, p.1))
|
.map(|p| (p.0, p.1))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let new_mime = format!(
|
let new_mime = format!(
|
||||||
"{}/{}; charset={}{}{}",
|
"{}/{}; charset={}{}{}",
|
||||||
mime.type_().as_ref(),
|
mime.type_().as_ref(),
|
||||||
mime.subtype().as_ref(),
|
mime.subtype().as_ref(),
|
||||||
encoding,
|
encoding,
|
||||||
if new_params.is_empty() { "" } else { "; " },
|
if new_params.is_empty() { "" } else { "; " },
|
||||||
new_params
|
new_params
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| format!("{}={}", p.0, p.1))
|
.map(|p| format!("{}={}", p.0, p.1))
|
||||||
.collect::<Vec<String>>()
|
.collect::<Vec<String>>()
|
||||||
.join("; ")
|
.join("; ")
|
||||||
);
|
);
|
||||||
let new_mime: Mime = new_mime.parse().unwrap();
|
let new_mime: Mime = new_mime.parse().unwrap();
|
||||||
request.headers.typed_insert(ContentType::from(new_mime))
|
request.headers.typed_insert(ContentType::from(new_mime))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
_ => (),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.fetch_time.set(time::now().to_timespec().sec);
|
self.fetch_time.set(time::now().to_timespec().sec);
|
||||||
|
|
|
@ -2778,31 +2778,29 @@ impl ScriptThread {
|
||||||
Some(idx) => {
|
Some(idx) => {
|
||||||
// https://html.spec.whatwg.org/multipage/#process-a-navigate-response
|
// https://html.spec.whatwg.org/multipage/#process-a-navigate-response
|
||||||
// 2. If response's status is 204 or 205, then abort these steps.
|
// 2. If response's status is 204 or 205, then abort these steps.
|
||||||
match metadata {
|
if let Some(Metadata {
|
||||||
Some(Metadata {
|
status: Some((204..=205, _)),
|
||||||
status: Some((204..=205, _)),
|
..
|
||||||
..
|
}) = metadata
|
||||||
}) => {
|
{
|
||||||
// If we have an existing window that is being navigated:
|
// If we have an existing window that is being navigated:
|
||||||
if let Some(window) = self.documents.borrow().find_window(*id) {
|
if let Some(window) = self.documents.borrow().find_window(*id) {
|
||||||
let window_proxy = window.window_proxy();
|
let window_proxy = window.window_proxy();
|
||||||
// https://html.spec.whatwg.org/multipage/
|
// https://html.spec.whatwg.org/multipage/
|
||||||
// #navigating-across-documents:delaying-load-events-mode-2
|
// #navigating-across-documents:delaying-load-events-mode-2
|
||||||
if window_proxy.parent().is_some() {
|
if window_proxy.parent().is_some() {
|
||||||
// The user agent must take this nested browsing context
|
// The user agent must take this nested browsing context
|
||||||
// out of the delaying load events mode
|
// out of the delaying load events mode
|
||||||
// when this navigation algorithm later matures,
|
// when this navigation algorithm later matures,
|
||||||
// or when it terminates (whether due to having run all the steps,
|
// or when it terminates (whether due to having run all the steps,
|
||||||
// or being canceled, or being aborted), whichever happens first.
|
// or being canceled, or being aborted), whichever happens first.
|
||||||
window_proxy.stop_delaying_load_events_mode();
|
window_proxy.stop_delaying_load_events_mode();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
self.script_sender
|
}
|
||||||
.send((*id, ScriptMsg::AbortLoadUrl))
|
self.script_sender
|
||||||
.unwrap();
|
.send((*id, ScriptMsg::AbortLoadUrl))
|
||||||
return None;
|
.unwrap();
|
||||||
},
|
return None;
|
||||||
_ => (),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let load = self.incomplete_loads.borrow_mut().remove(idx);
|
let load = self.incomplete_loads.borrow_mut().remove(idx);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue