aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/audionode.rs9
-rw-r--r--components/script/dom/bindings/str.rs11
-rwxr-xr-xcomponents/script/dom/htmlobjectelement.rs13
-rw-r--r--components/script/dom/node.rs49
-rw-r--r--components/script/dom/rtcdatachannel.rs19
-rw-r--r--components/script/dom/xmlhttprequest.rs105
-rw-r--r--components/script/script_thread.rs46
7 files changed, 117 insertions, 135 deletions
diff --git a/components/script/dom/audionode.rs b/components/script/dom/audionode.rs
index 65d1973ebab..bdf864d0981 100644
--- a/components/script/dom/audionode.rs
+++ b/components/script/dom/audionode.rs
@@ -354,11 +354,10 @@ impl AudioNodeMethods for AudioNode {
return Ok(());
}
- match self.upcast::<EventTarget>().type_id() {
- EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) => {
- return Err(Error::InvalidState);
- },
- _ => (),
+ if let EventTargetTypeId::AudioNode(AudioNodeTypeId::ChannelSplitterNode) =
+ self.upcast::<EventTarget>().type_id()
+ {
+ return Err(Error::InvalidState);
};
self.channel_interpretation.set(value);
diff --git a/components/script/dom/bindings/str.rs b/components/script/dom/bindings/str.rs
index ae0e1f585a7..c7568f2c351 100644
--- a/components/script/dom/bindings/str.rs
+++ b/components/script/dom/bindings/str.rs
@@ -741,13 +741,10 @@ fn parse_time_component(value: &str) -> Option<(u32, u32, f64)> {
if second_iterator.next()?.len() != 2 {
return None;
}
- match second_iterator.next() {
- Some(second_last) => {
- if second_last.len() > 3 {
- return None;
- }
- },
- None => {},
+ if let Some(second_last) = second_iterator.next() {
+ if second_last.len() > 3 {
+ return None;
+ }
}
second.parse::<f64>().ok()?
diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs
index 75d84484e40..007b4950b62 100755
--- a/components/script/dom/htmlobjectelement.rs
+++ b/components/script/dom/htmlobjectelement.rs
@@ -74,17 +74,14 @@ impl<'a> ProcessDataURL for &'a HTMLObjectElement {
// 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.
fn process_data_url(&self) {
- let elem = self.upcast::<Element>();
+ let element = self.upcast::<Element>();
// TODO: support other values
- match (
- elem.get_attribute(&ns!(), &local_name!("type")),
- elem.get_attribute(&ns!(), &local_name!("data")),
+ if let (None, Some(_uri)) = (
+ element.get_attribute(&ns!(), &local_name!("type")),
+ element.get_attribute(&ns!(), &local_name!("data")),
) {
- (None, Some(_uri)) => {
- // TODO(gw): Prefetch the image here.
- },
- _ => {},
+ // TODO(gw): Prefetch the image here.
}
}
}
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 7f2d4105abd..bbeb7fe1489 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -2981,33 +2981,30 @@ impl NodeMethods for Node {
// same owner element.
if let Some(node2) = node2 {
if Some(node2) == node1 {
- match (attr1, attr2) {
- (Some(a1), Some(a2)) => {
- let attrs = node2.downcast::<Element>().unwrap().attrs();
- // go through the attrs in order to see if self
- // or other is first; spec is clear that we
- // want value-equality, not reference-equality
- for attr in attrs.iter() {
- if (*attr.namespace() == *a1.namespace()) &&
- (attr.local_name() == a1.local_name()) &&
- (**attr.value() == **a1.value())
- {
- return NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
- 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;
- }
+ if let (Some(a1), Some(a2)) = (attr1, attr2) {
+ let attrs = node2.downcast::<Element>().unwrap().attrs();
+ // go through the attrs in order to see if self
+ // or other is first; spec is clear that we
+ // want value-equality, not reference-equality
+ for attr in attrs.iter() {
+ if (*attr.namespace() == *a1.namespace()) &&
+ (attr.local_name() == a1.local_name()) &&
+ (**attr.value() == **a1.value())
+ {
+ return NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC +
+ NodeConstants::DOCUMENT_POSITION_PRECEDING;
}
- // both attrs have node2 as their owner element, so
- // we can't have left the loop without seeing them
- unreachable!();
- },
- (_, _) => {},
+ 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
+ // we can't have left the loop without seeing them
+ unreachable!();
}
}
}
diff --git a/components/script/dom/rtcdatachannel.rs b/components/script/dom/rtcdatachannel.rs
index 87429be677c..36c1cab92db 100644
--- a/components/script/dom/rtcdatachannel.rs
+++ b/components/script/dom/rtcdatachannel.rs
@@ -200,17 +200,14 @@ impl RTCDataChannel {
}
pub fn on_state_change(&self, state: DataChannelState) {
- match state {
- DataChannelState::Closing => {
- let event = Event::new(
- &self.global(),
- atom!("closing"),
- EventBubbles::DoesNotBubble,
- EventCancelable::NotCancelable,
- );
- event.upcast::<Event>().fire(self.upcast());
- },
- _ => {},
+ if let DataChannelState::Closing = state {
+ let event = Event::new(
+ &self.global(),
+ atom!("closing"),
+ EventBubbles::DoesNotBubble,
+ EventCancelable::NotCancelable,
+ );
+ event.upcast::<Event>().fire(self.upcast());
};
self.ready_state.set(state.into());
}
diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs
index f019bc60f31..dd0a31ef266 100644
--- a/components/script/dom/xmlhttprequest.rs
+++ b/components/script/dom/xmlhttprequest.rs
@@ -724,65 +724,62 @@ impl XMLHttpRequestMethods for XMLHttpRequest {
.pipeline_id(Some(self.global().pipeline_id()));
// step 4 (second half)
- match content_type {
- Some(content_type) => {
- let encoding = match data {
- Some(DocumentOrXMLHttpRequestBodyInit::String(_)) |
- Some(DocumentOrXMLHttpRequestBodyInit::Document(_)) =>
- // 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
- // using content types provided by Hyper.
- {
- Some("UTF-8")
- },
- _ => None,
- };
-
- let mut content_type_set = false;
- if !request.headers.contains_key(header::CONTENT_TYPE) {
- request.headers.insert(
- header::CONTENT_TYPE,
- HeaderValue::from_str(&content_type).unwrap(),
- );
- content_type_set = true;
- }
+ if let Some(content_type) = content_type {
+ let encoding = match data {
+ Some(DocumentOrXMLHttpRequestBodyInit::String(_)) |
+ Some(DocumentOrXMLHttpRequestBodyInit::Document(_)) =>
+ // 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
+ // using content types provided by Hyper.
+ {
+ Some("UTF-8")
+ },
+ _ => None,
+ };
+
+ let mut content_type_set = false;
+ if !request.headers.contains_key(header::CONTENT_TYPE) {
+ request.headers.insert(
+ header::CONTENT_TYPE,
+ HeaderValue::from_str(&content_type).unwrap(),
+ );
+ content_type_set = true;
+ }
- if !content_type_set {
- let ct = request.headers.typed_get::<ContentType>();
- if let Some(ct) = ct {
- if let Some(encoding) = encoding {
- let mime: Mime = ct.into();
- for param in mime.params() {
- if param.0 == mime::CHARSET &&
- !param.1.as_ref().eq_ignore_ascii_case(encoding)
- {
- let new_params: Vec<(Name, Name)> = mime
- .params()
- .filter(|p| p.0 != mime::CHARSET)
- .map(|p| (p.0, p.1))
- .collect();
-
- let new_mime = format!(
- "{}/{}; charset={}{}{}",
- mime.type_().as_ref(),
- mime.subtype().as_ref(),
- encoding,
- if new_params.is_empty() { "" } else { "; " },
- new_params
- .iter()
- .map(|p| format!("{}={}", p.0, p.1))
- .collect::<Vec<String>>()
- .join("; ")
- );
- let new_mime: Mime = new_mime.parse().unwrap();
- request.headers.typed_insert(ContentType::from(new_mime))
- }
+ if !content_type_set {
+ let ct = request.headers.typed_get::<ContentType>();
+ if let Some(ct) = ct {
+ if let Some(encoding) = encoding {
+ let mime: Mime = ct.into();
+ for param in mime.params() {
+ if param.0 == mime::CHARSET &&
+ !param.1.as_ref().eq_ignore_ascii_case(encoding)
+ {
+ let new_params: Vec<(Name, Name)> = mime
+ .params()
+ .filter(|p| p.0 != mime::CHARSET)
+ .map(|p| (p.0, p.1))
+ .collect();
+
+ let new_mime = format!(
+ "{}/{}; charset={}{}{}",
+ mime.type_().as_ref(),
+ mime.subtype().as_ref(),
+ encoding,
+ if new_params.is_empty() { "" } else { "; " },
+ new_params
+ .iter()
+ .map(|p| format!("{}={}", p.0, p.1))
+ .collect::<Vec<String>>()
+ .join("; ")
+ );
+ let new_mime: Mime = new_mime.parse().unwrap();
+ request.headers.typed_insert(ContentType::from(new_mime))
}
}
}
}
- },
- _ => (),
+ }
}
self.fetch_time.set(time::now().to_timespec().sec);
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 004aca8f8f3..960eb8a2e01 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -2778,31 +2778,29 @@ impl ScriptThread {
Some(idx) => {
// https://html.spec.whatwg.org/multipage/#process-a-navigate-response
// 2. If response's status is 204 or 205, then abort these steps.
- match metadata {
- Some(Metadata {
- status: Some((204..=205, _)),
- ..
- }) => {
- // If we have an existing window that is being navigated:
- if let Some(window) = self.documents.borrow().find_window(*id) {
- let window_proxy = window.window_proxy();
- // https://html.spec.whatwg.org/multipage/
- // #navigating-across-documents:delaying-load-events-mode-2
- if window_proxy.parent().is_some() {
- // The user agent must take this nested browsing context
- // out of the delaying load events mode
- // when this navigation algorithm later matures,
- // or when it terminates (whether due to having run all the steps,
- // or being canceled, or being aborted), whichever happens first.
- window_proxy.stop_delaying_load_events_mode();
- }
+ if let Some(Metadata {
+ status: Some((204..=205, _)),
+ ..
+ }) = metadata
+ {
+ // If we have an existing window that is being navigated:
+ if let Some(window) = self.documents.borrow().find_window(*id) {
+ let window_proxy = window.window_proxy();
+ // https://html.spec.whatwg.org/multipage/
+ // #navigating-across-documents:delaying-load-events-mode-2
+ if window_proxy.parent().is_some() {
+ // The user agent must take this nested browsing context
+ // out of the delaying load events mode
+ // when this navigation algorithm later matures,
+ // or when it terminates (whether due to having run all the steps,
+ // or being canceled, or being aborted), whichever happens first.
+ window_proxy.stop_delaying_load_events_mode();
}
- self.script_sender
- .send((*id, ScriptMsg::AbortLoadUrl))
- .unwrap();
- return None;
- },
- _ => (),
+ }
+ self.script_sender
+ .send((*id, ScriptMsg::AbortLoadUrl))
+ .unwrap();
+ return None;
};
let load = self.incomplete_loads.borrow_mut().remove(idx);