diff options
Diffstat (limited to 'components/script')
-rw-r--r-- | components/script/dom/node.rs | 31 | ||||
-rw-r--r-- | components/script/dom/nodeiterator.rs | 4 | ||||
-rw-r--r-- | components/script/dom/range.rs | 18 | ||||
-rw-r--r-- | components/script/dom/servohtmlparser.rs | 2 | ||||
-rw-r--r-- | components/script/dom/textencoder.rs | 4 | ||||
-rw-r--r-- | components/script/dom/treewalker.rs | 56 | ||||
-rw-r--r-- | components/script/dom/url.rs | 2 | ||||
-rw-r--r-- | components/script/dom/urlhelper.rs | 2 | ||||
-rw-r--r-- | components/script/dom/virtualmethods.rs | 2 | ||||
-rw-r--r-- | components/script/dom/webglrenderingcontext.rs | 14 | ||||
-rw-r--r-- | components/script/dom/websocket.rs | 2 | ||||
-rw-r--r-- | components/script/dom/window.rs | 8 | ||||
-rw-r--r-- | components/script/dom/workerglobalscope.rs | 4 | ||||
-rw-r--r-- | components/script/dom/xmlhttprequest.rs | 20 | ||||
-rw-r--r-- | components/script/dom/xmlhttprequesteventtarget.rs | 2 | ||||
-rw-r--r-- | components/script/script_task.rs | 10 | ||||
-rw-r--r-- | components/script/textinput.rs | 7 | ||||
-rw-r--r-- | components/script/timers.rs | 4 |
18 files changed, 78 insertions, 114 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 72855380540..6ca62f181e3 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -264,7 +264,7 @@ impl LayoutDataRef { /// Borrows the layout data immutably. This function is *not* thread-safe. #[inline] - pub fn borrow<'a>(&'a self) -> Ref<'a, Option<LayoutData>> { + pub fn borrow(&self) -> Ref<Option<LayoutData>> { debug_assert!(task_state::get().is_layout()); self.data_cell.borrow() } @@ -275,7 +275,7 @@ impl LayoutDataRef { /// prevent CSS selector matching from mutably accessing nodes it's not supposed to and racing /// on it. This has already resulted in one bug! #[inline] - pub fn borrow_mut<'a>(&'a self) -> RefMut<'a, Option<LayoutData>> { + pub fn borrow_mut(&self) -> RefMut<Option<LayoutData>> { debug_assert!(task_state::get().is_layout()); self.data_cell.borrow_mut() } @@ -908,7 +908,7 @@ impl<'a> NodeHelpers for &'a Node { // Step 1. match parse_author_origin_selector_list_from_str(&selectors) { // Step 2. - Err(()) => return Err(Syntax), + Err(()) => Err(Syntax), // Step 3. Ok(ref selectors) => { let root = self.ancestors().last(); @@ -1326,7 +1326,7 @@ impl Iterator for FollowingNodeIterator { } } self.current = None; - return None + None } } @@ -1372,7 +1372,7 @@ impl Iterator for PrecedingNodeIterator { } self.current = None; - return None + None } } @@ -1663,7 +1663,7 @@ impl Node { Node::insert(node, parent, reference_child, SuppressObserver::Unsuppressed); // Step 6. - return Ok(Root::from_ref(node)) + Ok(Root::from_ref(node)) } // https://dom.spec.whatwg.org/#concept-node-insert @@ -2088,24 +2088,13 @@ impl<'a> NodeMethods for &'a Node { // https://dom.spec.whatwg.org/#dom-node-nodevalue fn GetNodeValue(self) -> Option<DOMString> { - match self.type_id { - NodeTypeId::CharacterData(..) => { - let chardata: &CharacterData = CharacterDataCast::to_ref(self).unwrap(); - Some(chardata.Data()) - } - _ => { - None - } - } + CharacterDataCast::to_ref(self).map(|c| c.Data()) } // https://dom.spec.whatwg.org/#dom-node-nodevalue fn SetNodeValue(self, val: Option<DOMString>) { - match self.type_id { - NodeTypeId::CharacterData(..) => { - self.SetTextContent(val) - } - _ => {} + if let NodeTypeId::CharacterData(..) = self.type_id { + self.SetTextContent(val) } } @@ -2565,7 +2554,7 @@ pub fn window_from_node<T: NodeBase + Reflectable>(derived: &T) -> Root<Window> } impl<'a> VirtualMethods for &'a Node { - fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> { + fn super_type(&self) -> Option<&VirtualMethods> { let eventtarget: &&EventTarget = EventTargetCast::from_borrowed_ref(self); Some(eventtarget as &VirtualMethods) } diff --git a/components/script/dom/nodeiterator.rs b/components/script/dom/nodeiterator.rs index 7e641c83cfd..0958bfca992 100644 --- a/components/script/dom/nodeiterator.rs +++ b/components/script/dom/nodeiterator.rs @@ -138,7 +138,7 @@ impl<'a> NodeIteratorMethods for &'a NodeIterator { } } - return Ok(None); + Ok(None) } // https://dom.spec.whatwg.org/#dom-nodeiterator-previousnode @@ -183,7 +183,7 @@ impl<'a> NodeIteratorMethods for &'a NodeIterator { } } - return Ok(None); + Ok(None) } // https://dom.spec.whatwg.org/#dom-nodeiterator-detach diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index b67ce2d60c8..78af618eff5 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -122,7 +122,7 @@ impl Range { return Err(HierarchyRequest); } - return Ok((first_contained_child, last_contained_child, contained_children)); + Ok((first_contained_child, last_contained_child, contained_children)) } } @@ -338,17 +338,11 @@ impl<'a> RangeMethods for &'a Range { let end = &inner.end; let end_node = end.node(); let end_offset = end.offset; - match (bp_position(parent.r(), offset + 1, start_node.r(), start_offset).unwrap(), - bp_position(parent.r(), offset, end_node.r(), end_offset).unwrap()) { - (Ordering::Greater, Ordering::Less) => { - // Step 5. - true - }, - _ => { - // Step 6. - false - } - } + // Step 5. + Ordering::Greater == bp_position(parent.r(), offset + 1, + start_node.r(), start_offset).unwrap() && + Ordering::Less == bp_position(parent.r(), offset, + end_node.r(), end_offset).unwrap() } // https://dom.spec.whatwg.org/#dom-range-clonecontents diff --git a/components/script/dom/servohtmlparser.rs b/components/script/dom/servohtmlparser.rs index e979e3f6610..b9ccd50632f 100644 --- a/components/script/dom/servohtmlparser.rs +++ b/components/script/dom/servohtmlparser.rs @@ -268,7 +268,7 @@ impl ServoHTMLParser { } #[inline] - pub fn tokenizer<'a>(&'a self) -> &'a DOMRefCell<Tokenizer> { + pub fn tokenizer(&self) -> &DOMRefCell<Tokenizer> { &self.tokenizer } } diff --git a/components/script/dom/textencoder.rs b/components/script/dom/textencoder.rs index 29a715a8ed1..1b76de05d0d 100644 --- a/components/script/dom/textencoder.rs +++ b/components/script/dom/textencoder.rs @@ -65,7 +65,7 @@ impl TextEncoder { } _ => { debug!("Encoding Not UTF"); - return Err(Range("The encoding must be utf-8, utf-16le, or utf-16be.".to_owned())) + Err(Range("The encoding must be utf-8, utf-16le, or utf-16be.".to_owned())) } } } @@ -87,7 +87,7 @@ impl<'a> TextEncoderMethods for &'a TextEncoder { let js_object_data: *mut uint8_t = JS_GetUint8ArrayData(js_object, ptr::null()); ptr::copy_nonoverlapping(encoded.as_ptr(), js_object_data, length as usize); - return js_object; + js_object } } } diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index b859a2f0277..b8271909505 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -104,12 +104,9 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { node = n; // "2. If node is not null and filtering node returns FILTER_ACCEPT, // then set the currentNode attribute to node, return node." - match try!(self.accept_node(node.r())) { - NodeFilterConstants::FILTER_ACCEPT => { - self.current_node.set(JS::from_rooted(&node)); - return Ok(Some(node)) - }, - _ => {} + if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(node.r())) { + self.current_node.set(JS::from_rooted(&node)); + return Ok(Some(node)) } }, None => break, @@ -195,12 +192,9 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { } // "5. Filter node and if the return value is FILTER_ACCEPT, then // set the currentNode attribute to node and return node." - match try!(self.accept_node(node.r())) { - NodeFilterConstants::FILTER_ACCEPT => { - self.current_node.set(JS::from_rooted(&node)); - return Ok(Some(node)) - }, - _ => {} + if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(node.r())) { + self.current_node.set(JS::from_rooted(&node)); + return Ok(Some(node)) } } // "6. Return null." @@ -217,9 +211,8 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { loop { // "1. While result is not FILTER_REJECT and node has a child, run these subsubsteps:" loop { - match result { - NodeFilterConstants::FILTER_REJECT => break, - _ => {} + if NodeFilterConstants::FILTER_REJECT == result { + break; } match node.r().GetFirstChild() { None => break, @@ -230,12 +223,9 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { result = try!(self.accept_node(node.r())); // "3. If result is FILTER_ACCEPT, then // set the currentNode attribute to node and return node." - match result { - NodeFilterConstants::FILTER_ACCEPT => { - self.current_node.set(JS::from_rooted(&node)); - return Ok(Some(node)) - }, - _ => {} + if NodeFilterConstants::FILTER_ACCEPT == result { + self.current_node.set(JS::from_rooted(&node)); + return Ok(Some(node)) } } } @@ -251,12 +241,9 @@ impl<'a> TreeWalkerMethods for &'a TreeWalker { result = try!(self.accept_node(node.r())); // "4. If result is FILTER_ACCEPT, then // set the currentNode attribute to node and return node." - match result { - NodeFilterConstants::FILTER_ACCEPT => { - self.current_node.set(JS::from_rooted(&node)); - return Ok(Some(node)) - }, - _ => {} + if NodeFilterConstants::FILTER_ACCEPT == result { + self.current_node.set(JS::from_rooted(&node)); + return Ok(Some(node)) } } } @@ -391,13 +378,11 @@ impl<'a> PrivateTreeWalkerHelpers for &'a TreeWalker { let result = try!(self.accept_node(node.r())); // "3. If result is FILTER_ACCEPT, then set the currentNode // attribute to node and return node." - match result { - NodeFilterConstants::FILTER_ACCEPT => { - self.current_node.set(JS::from_rooted(&node)); - return Ok(Some(node)) - }, - _ => {} + if NodeFilterConstants::FILTER_ACCEPT == result { + self.current_node.set(JS::from_rooted(&node)); + return Ok(Some(node)) } + // "4. Set sibling to node's first child if type is next, // and node's last child if type is previous." sibling_op = next_child(node.r()); @@ -418,9 +403,8 @@ impl<'a> PrivateTreeWalkerHelpers for &'a TreeWalker { // "5. Filter node and if the return value is FILTER_ACCEPT, then return null." Some(n) => { node = n; - match try!(self.accept_node(node.r())) { - NodeFilterConstants::FILTER_ACCEPT => return Ok(None), - _ => {} + if NodeFilterConstants::FILTER_ACCEPT == try!(self.accept_node(node.r())) { + return Ok(None) } } } diff --git a/components/script/dom/url.rs b/components/script/dom/url.rs index 9bbd0f1b5fc..d4a8b5a23ff 100644 --- a/components/script/dom/url.rs +++ b/components/script/dom/url.rs @@ -142,7 +142,7 @@ impl<'a> URLMethods for &'a URL { } } -fn parser_with_base<'a>(base: Option<&'a Url>) -> UrlParser<'a> { +fn parser_with_base(base: Option<&Url>) -> UrlParser { let mut parser = UrlParser::new(); if let Some(base) = base { parser.base_url(base); diff --git a/components/script/dom/urlhelper.rs b/components/script/dom/urlhelper.rs index cff468574b2..4376a85e390 100644 --- a/components/script/dom/urlhelper.rs +++ b/components/script/dom/urlhelper.rs @@ -84,7 +84,7 @@ impl UrlHelper { if urlA.port() != urlB.port() { return false } - return true + true } // https://url.spec.whatwg.org/#dom-urlutils-search diff --git a/components/script/dom/virtualmethods.rs b/components/script/dom/virtualmethods.rs index b67cbb69d4f..437f39422c6 100644 --- a/components/script/dom/virtualmethods.rs +++ b/components/script/dom/virtualmethods.rs @@ -48,7 +48,7 @@ use string_cache::Atom; pub trait VirtualMethods { /// Returns self as the superclass of the implementation for this trait, /// if any. - fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods>; + fn super_type(&self) -> Option<&VirtualMethods>; /// Called when changing or adding attributes, after the attribute's value /// has been updated. diff --git a/components/script/dom/webglrenderingcontext.rs b/components/script/dom/webglrenderingcontext.rs index 0b6fa7b3869..4acf36256c8 100644 --- a/components/script/dom/webglrenderingcontext.rs +++ b/components/script/dom/webglrenderingcontext.rs @@ -514,15 +514,13 @@ impl<'a> WebGLRenderingContextMethods for &'a WebGLRenderingContext { // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.10 fn VertexAttribPointer(self, attrib_id: u32, size: i32, data_type: u32, normalized: bool, stride: i32, offset: i64) { - match data_type { - constants::FLOAT => { - let msg = CanvasMsg::WebGL( - CanvasWebGLMsg::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset)); - self.ipc_renderer.send(msg).unwrap() - } - _ => panic!("VertexAttribPointer: Data Type not supported") + if let constants::FLOAT = data_type { + let msg = CanvasMsg::WebGL( + CanvasWebGLMsg::VertexAttribPointer2f(attrib_id, size, normalized, stride, offset)); + self.ipc_renderer.send(msg).unwrap() + } else { + panic!("VertexAttribPointer: Data Type not supported") } - } // https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.4 diff --git a/components/script/dom/websocket.rs b/components/script/dom/websocket.rs index 7855c3e453b..1e00a9e507a 100644 --- a/components/script/dom/websocket.rs +++ b/components/script/dom/websocket.rs @@ -277,7 +277,7 @@ impl<'a> WebSocketMethods for &'a WebSocket { let mut other_sender = self.sender.borrow_mut(); let my_sender = other_sender.as_mut().unwrap(); let _ = my_sender.lock().unwrap().send_message(Message::Text(data.unwrap().0)); - return Ok(()) + Ok(()) } // https://html.spec.whatwg.org/multipage/#dom-websocket-close diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 43e4ca6e642..82e3247dc8e 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -269,19 +269,19 @@ impl Window { (box SendableMainThreadScriptChan(tx), box rx) } - pub fn image_cache_task<'a>(&'a self) -> &'a ImageCacheTask { + pub fn image_cache_task(&self) -> &ImageCacheTask { &self.image_cache_task } - pub fn compositor<'a>(&'a self) -> &'a IpcSender<ScriptToCompositorMsg> { + pub fn compositor(&self) -> &IpcSender<ScriptToCompositorMsg> { &self.compositor } - pub fn browsing_context<'a>(&'a self) -> Ref<'a, Option<BrowsingContext>> { + pub fn browsing_context(&self) -> Ref<Option<BrowsingContext>> { self.browsing_context.borrow() } - pub fn page<'a>(&'a self) -> &'a Page { + pub fn page(&self) -> &Page { &*self.page } diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index 70477846627..468de091271 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -143,11 +143,11 @@ impl WorkerGlobalScope { self.runtime.cx() } - pub fn resource_task<'a>(&'a self) -> &'a ResourceTask { + pub fn resource_task(&self) -> &ResourceTask { &self.resource_task } - pub fn get_url<'a>(&'a self) -> &'a Url { + pub fn get_url(&self) -> &Url { &self.worker_url } diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index e28482e3f16..577416fe700 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -784,19 +784,17 @@ impl<'a> PrivateXMLHttpRequestHelpers for &'a XMLHttpRequest { fn process_headers_available(self, cors_request: Option<CORSRequest>, gen_id: GenerationId, metadata: Metadata) -> Result<(), Error> { - match cors_request { - Some(ref req) => { - match metadata.headers { - Some(ref h) if allow_cross_origin_request(req, h) => {}, - _ => { - self.process_partial_response(XHRProgress::Errored(gen_id, Network)); - return Err(Network); - } + + if let Some(ref req) = cors_request { + match metadata.headers { + Some(ref h) if allow_cross_origin_request(req, h) => {}, + _ => { + self.process_partial_response(XHRProgress::Errored(gen_id, Network)); + return Err(Network); } - }, + } + } - _ => {} - }; // XXXManishearth Clear cache entries in case of a network error self.process_partial_response(XHRProgress::HeadersReceived(gen_id, metadata.headers, diff --git a/components/script/dom/xmlhttprequesteventtarget.rs b/components/script/dom/xmlhttprequesteventtarget.rs index d93746fed0f..3bf1aa408b0 100644 --- a/components/script/dom/xmlhttprequesteventtarget.rs +++ b/components/script/dom/xmlhttprequesteventtarget.rs @@ -28,7 +28,7 @@ impl XMLHttpRequestEventTarget { } #[inline] - pub fn eventtarget<'a>(&'a self) -> &'a EventTarget { + pub fn eventtarget(&self) -> &EventTarget { &self.eventtarget } } diff --git a/components/script/script_task.rs b/components/script/script_task.rs index 60d8887484c..8d342a9eaf5 100644 --- a/components/script/script_task.rs +++ b/components/script/script_task.rs @@ -267,7 +267,7 @@ pub struct SendableMainThreadScriptChan(pub Sender<CommonScriptMsg>); impl ScriptChan for SendableMainThreadScriptChan { fn send(&self, msg: CommonScriptMsg) -> Result<(), ()> { let SendableMainThreadScriptChan(ref chan) = *self; - return chan.send(msg).map_err(|_| ()); + chan.send(msg).map_err(|_| ()) } fn clone(&self) -> Box<ScriptChan + Send> { @@ -550,7 +550,7 @@ unsafe extern "C" fn debug_gc_callback(_rt: *mut JSRuntime, status: JSGCStatus, unsafe extern "C" fn shadow_check_callback(_cx: *mut JSContext, _object: HandleObject, _id: HandleId) -> DOMProxyShadowsResult { // XXX implement me - return DOMProxyShadowsResult::ShadowCheckFailed; + DOMProxyShadowsResult::ShadowCheckFailed } impl ScriptTask { @@ -1062,7 +1062,7 @@ impl ScriptTask { return ScriptState::DocumentLoading; } - return ScriptState::DocumentLoaded; + ScriptState::DocumentLoaded } fn handle_new_layout(&self, new_layout_info: NewLayoutInfo) { @@ -1406,7 +1406,7 @@ impl ScriptTask { if let Some(ref mut child_page) = page.remove(id) { shut_down_layout(&*child_page, exit_type); } - return false; + false } /// Handles when layout task finishes all animation in one tick @@ -1550,7 +1550,7 @@ impl ScriptTask { DocumentSource::FromParser, loader); - let frame_element = frame_element.r().map(|elem| ElementCast::from_ref(elem)); + let frame_element = frame_element.r().map(ElementCast::from_ref); window.r().init_browsing_context(document.r(), frame_element); // Create the root frame diff --git a/components/script/textinput.rs b/components/script/textinput.rs index 31fc7dc2e25..5ecf6a4f312 100644 --- a/components/script/textinput.rs +++ b/components/script/textinput.rs @@ -292,10 +292,11 @@ impl<T: ClipboardProvider> TextInput<T> { /// Deal with a newline input. pub fn handle_return(&mut self) -> KeyReaction { if !self.multiline { - return KeyReaction::TriggerDefaultAction; + KeyReaction::TriggerDefaultAction + } else { + self.insert_char('\n'); + KeyReaction::DispatchInput } - self.insert_char('\n'); - return KeyReaction::DispatchInput; } /// Select all text in the input control. diff --git a/components/script/timers.rs b/components/script/timers.rs index 579c0d9a2c3..8cc317f83ac 100644 --- a/components/script/timers.rs +++ b/components/script/timers.rs @@ -222,8 +222,8 @@ impl TimerManager { for _ in 0..arguments.len() { timer.data.args.push(Heap::default()); } - for i in 0..arguments.len() { - timer.data.args.get_mut(i).unwrap().set(arguments[i].get()); + for (i, item) in arguments.iter().enumerate() { + timer.data.args.get_mut(i).unwrap().set(item.get()); } handle } |