From 2c8d51a37c84fb5de531d00c45de9c0020930b11 Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Fri, 19 Sep 2014 01:32:30 -0700 Subject: [PATCH 1/3] More progress in the &JSRef -> JSRef conversion Change all of the Methods traits to take `self` instead of `&self`. --- components/script/dom/attr.rs | 15 +- .../dom/bindings/codegen/CodegenRust.py | 4 +- .../script/dom/canvasrenderingcontext2d.rs | 8 +- components/script/dom/characterdata.rs | 20 +- components/script/dom/console.rs | 12 +- components/script/dom/customevent.rs | 6 +- .../script/dom/dedicatedworkerglobalscope.rs | 10 +- components/script/dom/document.rs | 156 +++--- components/script/dom/documentfragment.rs | 15 +- components/script/dom/documenttype.rs | 10 +- components/script/dom/domexception.rs | 6 +- components/script/dom/domimplementation.rs | 6 +- components/script/dom/domparser.rs | 2 +- components/script/dom/domrect.rs | 12 +- components/script/dom/domrectlist.rs | 6 +- components/script/dom/domtokenlist.rs | 8 +- components/script/dom/element.rs | 108 ++-- components/script/dom/event.rs | 26 +- components/script/dom/eventtarget.rs | 6 +- components/script/dom/file.rs | 4 +- components/script/dom/formdata.rs | 14 +- components/script/dom/htmlanchorelement.rs | 8 +- components/script/dom/htmlbodyelement.rs | 8 +- components/script/dom/htmlbuttonelement.rs | 8 +- components/script/dom/htmlcanvaselement.rs | 18 +- components/script/dom/htmlcollection.rs | 10 +- components/script/dom/htmldatalistelement.rs | 4 +- components/script/dom/htmlelement.rs | 16 +- components/script/dom/htmlfieldsetelement.rs | 12 +- components/script/dom/htmliframeelement.rs | 20 +- components/script/dom/htmlimageelement.rs | 56 +-- components/script/dom/htmlinputelement.rs | 4 +- components/script/dom/htmlobjectelement.rs | 4 +- components/script/dom/htmloptgroupelement.rs | 4 +- components/script/dom/htmloptionelement.rs | 4 +- components/script/dom/htmloutputelement.rs | 4 +- components/script/dom/htmlscriptelement.rs | 12 +- components/script/dom/htmlselectelement.rs | 10 +- components/script/dom/htmltableelement.rs | 9 +- components/script/dom/htmltextareaelement.rs | 4 +- components/script/dom/htmltitleelement.rs | 8 +- components/script/dom/location.rs | 6 +- components/script/dom/macros.rs | 12 +- components/script/dom/messageevent.rs | 6 +- components/script/dom/mouseevent.rs | 24 +- components/script/dom/namednodemap.rs | 6 +- components/script/dom/navigator.rs | 10 +- components/script/dom/node.rs | 100 ++-- components/script/dom/nodelist.rs | 6 +- components/script/dom/performance.rs | 4 +- components/script/dom/performancetiming.rs | 2 +- .../script/dom/processinginstruction.rs | 2 +- components/script/dom/progressevent.rs | 6 +- components/script/dom/range.rs | 2 +- components/script/dom/screen.rs | 4 +- components/script/dom/testbinding.rs | 474 +++++++++--------- components/script/dom/treewalker.rs | 24 +- components/script/dom/uievent.rs | 8 +- components/script/dom/urlsearchparams.rs | 10 +- components/script/dom/window.rs | 84 ++-- components/script/dom/worker.rs | 10 +- components/script/dom/workerglobalscope.rs | 22 +- components/script/dom/workerlocation.rs | 6 +- components/script/dom/workernavigator.rs | 10 +- components/script/dom/xmlhttprequest.rs | 56 +-- .../script/dom/xmlhttprequesteventtarget.rs | 56 +-- 66 files changed, 812 insertions(+), 815 deletions(-) diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index 00d42d22b49..bf6880d1026 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -116,33 +116,32 @@ impl Attr { } impl<'a> AttrMethods for JSRef<'a, Attr> { - fn LocalName(&self) -> DOMString { + fn LocalName(self) -> DOMString { self.local_name().as_slice().to_string() } - fn Value(&self) -> DOMString { + fn Value(self) -> DOMString { self.value().as_slice().to_string() } - fn SetValue(&self, value: DOMString) { + fn SetValue(self, value: DOMString) { let owner = self.owner.root(); - let value = owner.deref().parse_attribute( - &self.namespace, self.local_name(), value); + let value = owner.deref().parse_attribute(&self.namespace, self.local_name(), value); self.set_value(ReplacedAttr, value); } - fn Name(&self) -> DOMString { + fn Name(self) -> DOMString { self.name.as_slice().to_string() } - fn GetNamespaceURI(&self) -> Option { + fn GetNamespaceURI(self) -> Option { match self.namespace.to_str() { "" => None, url => Some(url.to_string()), } } - fn GetPrefix(&self) -> Option { + fn GetPrefix(self) -> Option { self.prefix.clone() } } diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index dd39ff61563..8ec5f24ccdd 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -2186,7 +2186,7 @@ class CGCallGenerator(CGThing): if static: call = CGWrapper(call, pre="%s::" % descriptorProvider.interface.identifier.name) else: - call = CGWrapper(call, pre="(*%s)." % object) + call = CGWrapper(call, pre="%s." % object) call = CGList([call, CGWrapper(args, pre="(", post=")")]) self.cgRoot.append(CGList([ @@ -4064,7 +4064,7 @@ class CGInterfaceTrait(CGThing): return "".join(", %s: %s" % argument for argument in arguments) methods = CGList([ - CGGeneric("fn %s(&self%s) -> %s;\n" % (name, fmt(arguments), rettype)) + CGGeneric("fn %s(self%s) -> %s;\n" % (name, fmt(arguments), rettype)) for name, arguments, rettype in members() ], "") self.cgRoot = CGWrapper(CGIndenter(methods), diff --git a/components/script/dom/canvasrenderingcontext2d.rs b/components/script/dom/canvasrenderingcontext2d.rs index c96b63eae7c..84553ee2a93 100644 --- a/components/script/dom/canvasrenderingcontext2d.rs +++ b/components/script/dom/canvasrenderingcontext2d.rs @@ -46,21 +46,21 @@ impl CanvasRenderingContext2D { } impl<'a> CanvasRenderingContext2DMethods for JSRef<'a, CanvasRenderingContext2D> { - fn Canvas(&self) -> Temporary { + fn Canvas(self) -> Temporary { Temporary::new(self.canvas) } - fn FillRect(&self, x: f64, y: f64, width: f64, height: f64) { + fn FillRect(self, x: f64, y: f64, width: f64, height: f64) { let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32)); self.renderer.deref().send(FillRect(rect)); } - fn ClearRect(&self, x: f64, y: f64, width: f64, height: f64) { + fn ClearRect(self, x: f64, y: f64, width: f64, height: f64) { let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32)); self.renderer.deref().send(ClearRect(rect)); } - fn StrokeRect(&self, x: f64, y: f64, width: f64, height: f64) { + fn StrokeRect(self, x: f64, y: f64, width: f64, height: f64) { let rect = Rect(Point2D(x as f32, y as f32), Size2D(width as f32, height as f32)); self.renderer.deref().send(StrokeRect(rect)); } diff --git a/components/script/dom/characterdata.rs b/components/script/dom/characterdata.rs index a7ac4a2d631..14c1123f1bd 100644 --- a/components/script/dom/characterdata.rs +++ b/components/script/dom/characterdata.rs @@ -45,37 +45,37 @@ impl CharacterData { } impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> { - fn Data(&self) -> DOMString { + fn Data(self) -> DOMString { self.data.deref().borrow().clone() } - fn SetData(&self, arg: DOMString) -> ErrorResult { + fn SetData(self, arg: DOMString) -> ErrorResult { *self.data.deref().borrow_mut() = arg; Ok(()) } - fn Length(&self) -> u32 { + fn Length(self) -> u32 { self.data.deref().borrow().len() as u32 } - fn SubstringData(&self, offset: u32, count: u32) -> Fallible { + fn SubstringData(self, offset: u32, count: u32) -> Fallible { Ok(self.data.deref().borrow().as_slice().slice(offset as uint, count as uint).to_string()) } - fn AppendData(&self, arg: DOMString) -> ErrorResult { + fn AppendData(self, arg: DOMString) -> ErrorResult { self.data.deref().borrow_mut().push_str(arg.as_slice()); Ok(()) } - fn InsertData(&self, offset: u32, arg: DOMString) -> ErrorResult { + fn InsertData(self, offset: u32, arg: DOMString) -> ErrorResult { self.ReplaceData(offset, 0, arg) } - fn DeleteData(&self, offset: u32, count: u32) -> ErrorResult { + fn DeleteData(self, offset: u32, count: u32) -> ErrorResult { self.ReplaceData(offset, count, "".to_string()) } - fn ReplaceData(&self, offset: u32, count: u32, arg: DOMString) -> ErrorResult { + fn ReplaceData(self, offset: u32, count: u32, arg: DOMString) -> ErrorResult { let length = self.data.deref().borrow().len() as u32; if offset > length { return Err(IndexSize); @@ -94,8 +94,8 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> { } // http://dom.spec.whatwg.org/#dom-childnode-remove - fn Remove(&self) { - let node: JSRef = NodeCast::from_ref(*self); + fn Remove(self) { + let node: JSRef = NodeCast::from_ref(self); node.remove_self(); } } diff --git a/components/script/dom/console.rs b/components/script/dom/console.rs index d761252eaef..d8757b3eb81 100644 --- a/components/script/dom/console.rs +++ b/components/script/dom/console.rs @@ -28,27 +28,27 @@ impl Console { } impl<'a> ConsoleMethods for JSRef<'a, Console> { - fn Log(&self, message: DOMString) { + fn Log(self, message: DOMString) { println!("{:s}", message); } - fn Debug(&self, message: DOMString) { + fn Debug(self, message: DOMString) { println!("{:s}", message); } - fn Info(&self, message: DOMString) { + fn Info(self, message: DOMString) { println!("{:s}", message); } - fn Warn(&self, message: DOMString) { + fn Warn(self, message: DOMString) { println!("{:s}", message); } - fn Error(&self, message: DOMString) { + fn Error(self, message: DOMString) { println!("{:s}", message); } - fn Assert(&self, condition: bool, message: Option) { + fn Assert(self, condition: bool, message: Option) { if !condition { let message = match message { Some(ref message) => message.as_slice(), diff --git a/components/script/dom/customevent.rs b/components/script/dom/customevent.rs index 71dfb9c89f5..7549176d2ee 100644 --- a/components/script/dom/customevent.rs +++ b/components/script/dom/customevent.rs @@ -57,18 +57,18 @@ impl CustomEvent { } impl<'a> CustomEventMethods for JSRef<'a, CustomEvent> { - fn Detail(&self, _cx: *mut JSContext) -> JSVal { + fn Detail(self, _cx: *mut JSContext) -> JSVal { *self.detail.deref().get() } - fn InitCustomEvent(&self, + fn InitCustomEvent(self, _cx: *mut JSContext, type_: DOMString, can_bubble: bool, cancelable: bool, detail: JSVal) { self.detail.deref().set(Traceable::new(detail)); - let event: JSRef = EventCast::from_ref(*self); + let event: JSRef = EventCast::from_ref(self); event.InitEvent(type_, can_bubble, cancelable); } } diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index a17cd511990..f707f6f8d55 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -151,7 +151,7 @@ impl DedicatedWorkerGlobalScope { } impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalScope> { - fn PostMessage(&self, cx: *mut JSContext, message: JSVal) { + fn PostMessage(self, cx: *mut JSContext, message: JSVal) { let mut data = ptr::mut_null(); let mut nbytes = 0; unsafe { @@ -163,13 +163,13 @@ impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalSc sender.send(WorkerPostMessage(*self.worker, data, nbytes)); } - fn GetOnmessage(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnmessage(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("message") } - fn SetOnmessage(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnmessage(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("message", listener) } } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 69f1dd25d3e..e9f16bc60e2 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -367,25 +367,25 @@ impl<'a> PrivateDocumentHelpers for JSRef<'a, Document> { impl<'a> DocumentMethods for JSRef<'a, Document> { // http://dom.spec.whatwg.org/#dom-document-implementation - fn Implementation(&self) -> Temporary { + fn Implementation(self) -> Temporary { if self.implementation.get().is_none() { - self.implementation.assign(Some(DOMImplementation::new(*self))); + self.implementation.assign(Some(DOMImplementation::new(self))); } Temporary::new(self.implementation.get().get_ref().clone()) } // http://dom.spec.whatwg.org/#dom-document-url - fn URL(&self) -> DOMString { + fn URL(self) -> DOMString { self.url().serialize() } // http://dom.spec.whatwg.org/#dom-document-documenturi - fn DocumentURI(&self) -> DOMString { + fn DocumentURI(self) -> DOMString { self.URL() } // http://dom.spec.whatwg.org/#dom-document-compatmode - fn CompatMode(&self) -> DOMString { + fn CompatMode(self) -> DOMString { match self.quirks_mode.deref().get() { LimitedQuirks | NoQuirks => "CSS1Compat".to_string(), FullQuirks => "BackCompat".to_string() @@ -393,18 +393,18 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://dom.spec.whatwg.org/#dom-document-characterset - fn CharacterSet(&self) -> DOMString { + fn CharacterSet(self) -> DOMString { self.encoding_name.deref().borrow().as_slice().to_ascii_lower() } // http://dom.spec.whatwg.org/#dom-document-content_type - fn ContentType(&self) -> DOMString { + fn ContentType(self) -> DOMString { self.content_type.clone() } // http://dom.spec.whatwg.org/#dom-document-doctype - fn GetDoctype(&self) -> Option> { - let node: JSRef = NodeCast::from_ref(*self); + fn GetDoctype(self) -> Option> { + let node: JSRef = NodeCast::from_ref(self); node.children().find(|child| { child.is_doctype() }).map(|node| { @@ -414,32 +414,32 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://dom.spec.whatwg.org/#dom-document-documentelement - fn GetDocumentElement(&self) -> Option> { - let node: JSRef = NodeCast::from_ref(*self); + fn GetDocumentElement(self) -> Option> { + let node: JSRef = NodeCast::from_ref(self); node.child_elements().next().map(|elem| Temporary::from_rooted(elem)) } // http://dom.spec.whatwg.org/#dom-document-getelementsbytagname - fn GetElementsByTagName(&self, tag_name: DOMString) -> Temporary { + fn GetElementsByTagName(self, tag_name: DOMString) -> Temporary { let window = self.window.root(); - HTMLCollection::by_tag_name(*window, NodeCast::from_ref(*self), tag_name) + HTMLCollection::by_tag_name(*window, NodeCast::from_ref(self), tag_name) } // http://dom.spec.whatwg.org/#dom-document-getelementsbytagnamens - fn GetElementsByTagNameNS(&self, maybe_ns: Option, tag_name: DOMString) -> Temporary { + fn GetElementsByTagNameNS(self, maybe_ns: Option, tag_name: DOMString) -> Temporary { let window = self.window.root(); - HTMLCollection::by_tag_name_ns(*window, NodeCast::from_ref(*self), tag_name, maybe_ns) + HTMLCollection::by_tag_name_ns(*window, NodeCast::from_ref(self), tag_name, maybe_ns) } // http://dom.spec.whatwg.org/#dom-document-getelementsbyclassname - fn GetElementsByClassName(&self, classes: DOMString) -> Temporary { + fn GetElementsByClassName(self, classes: DOMString) -> Temporary { let window = self.window.root(); - HTMLCollection::by_class_name(*window, NodeCast::from_ref(*self), classes) + HTMLCollection::by_class_name(*window, NodeCast::from_ref(self), classes) } // http://dom.spec.whatwg.org/#dom-nonelementparentnode-getelementbyid - fn GetElementById(&self, id: DOMString) -> Option> { + fn GetElementById(self, id: DOMString) -> Option> { match self.idmap.deref().borrow().find_equiv(&id) { None => None, Some(ref elements) => Some(Temporary::new((*elements)[0].clone())), @@ -447,17 +447,17 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://dom.spec.whatwg.org/#dom-document-createelement - fn CreateElement(&self, local_name: DOMString) -> Fallible> { + fn CreateElement(self, local_name: DOMString) -> Fallible> { if xml_name_type(local_name.as_slice()) == InvalidXMLName { debug!("Not a valid element name"); return Err(InvalidCharacter); } let local_name = local_name.as_slice().to_ascii_lower(); - Ok(build_element_from_tag(local_name, namespace::HTML, *self)) + Ok(build_element_from_tag(local_name, namespace::HTML, self)) } // http://dom.spec.whatwg.org/#dom-document-createelementns - fn CreateElementNS(&self, + fn CreateElementNS(self, namespace: Option, qualified_name: DOMString) -> Fallible> { let ns = Namespace::from_str(null_str_as_empty_ref(&namespace)); @@ -497,31 +497,31 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } if ns == namespace::HTML { - Ok(build_element_from_tag(local_name_from_qname.to_string(), ns, *self)) + Ok(build_element_from_tag(local_name_from_qname.to_string(), ns, self)) } else { Ok(Element::new(local_name_from_qname.to_string(), ns, - prefix_from_qname.map(|s| s.to_string()), *self)) + prefix_from_qname.map(|s| s.to_string()), self)) } } // http://dom.spec.whatwg.org/#dom-document-createdocumentfragment - fn CreateDocumentFragment(&self) -> Temporary { - DocumentFragment::new(*self) + fn CreateDocumentFragment(self) -> Temporary { + DocumentFragment::new(self) } // http://dom.spec.whatwg.org/#dom-document-createtextnode - fn CreateTextNode(&self, data: DOMString) + fn CreateTextNode(self, data: DOMString) -> Temporary { - Text::new(data, *self) + Text::new(data, self) } // http://dom.spec.whatwg.org/#dom-document-createcomment - fn CreateComment(&self, data: DOMString) -> Temporary { - Comment::new(data, *self) + fn CreateComment(self, data: DOMString) -> Temporary { + Comment::new(data, self) } // http://dom.spec.whatwg.org/#dom-document-createprocessinginstruction - fn CreateProcessingInstruction(&self, target: DOMString, + fn CreateProcessingInstruction(self, target: DOMString, data: DOMString) -> Fallible> { // Step 1. if xml_name_type(target.as_slice()) == InvalidXMLName { @@ -534,11 +534,11 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // Step 3. - Ok(ProcessingInstruction::new(target, data, *self)) + Ok(ProcessingInstruction::new(target, data, self)) } // http://dom.spec.whatwg.org/#dom-document-importnode - fn ImportNode(&self, node: JSRef, deep: bool) -> Fallible> { + fn ImportNode(self, node: JSRef, deep: bool) -> Fallible> { // Step 1. if node.is_document() { return Err(NotSupported); @@ -550,25 +550,25 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { false => DoNotCloneChildren }; - Ok(Node::clone(node, Some(*self), clone_children)) + Ok(Node::clone(node, Some(self), clone_children)) } // http://dom.spec.whatwg.org/#dom-document-adoptnode - fn AdoptNode(&self, node: JSRef) -> Fallible> { + fn AdoptNode(self, node: JSRef) -> Fallible> { // Step 1. if node.is_document() { return Err(NotSupported); } // Step 2. - Node::adopt(node, *self); + Node::adopt(node, self); // Step 3. Ok(Temporary::from_rooted(node)) } // http://dom.spec.whatwg.org/#dom-document-createevent - fn CreateEvent(&self, interface: DOMString) -> Fallible> { + fn CreateEvent(self, interface: DOMString) -> Fallible> { let window = self.window.root(); match interface.as_slice().to_ascii_lower().as_slice() { @@ -581,7 +581,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://www.whatwg.org/html/#dom-document-lastmodified - fn LastModified(&self) -> DOMString { + fn LastModified(self) -> DOMString { match *self.last_modified.borrow() { Some(ref t) => t.clone(), None => time::now().strftime("%m/%d/%Y %H:%M:%S"), @@ -589,18 +589,18 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://dom.spec.whatwg.org/#dom-document-createrange - fn CreateRange(&self) -> Temporary { - Range::new(*self) + fn CreateRange(self) -> Temporary { + Range::new(self) } // http://dom.spec.whatwg.org/#dom-document-createtreewalker - fn CreateTreeWalker(&self, root: JSRef, whatToShow: u32, filter: Option) + fn CreateTreeWalker(self, root: JSRef, whatToShow: u32, filter: Option) -> Temporary { - TreeWalker::new(*self, root, whatToShow, filter) + TreeWalker::new(self, root, whatToShow, filter) } // http://www.whatwg.org/specs/web-apps/current-work/#document.title - fn Title(&self) -> DOMString { + fn Title(self) -> DOMString { let mut title = String::new(); self.GetDocumentElement().root().map(|root| { let root: JSRef = NodeCast::from_ref(*root); @@ -620,7 +620,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://www.whatwg.org/specs/web-apps/current-work/#document.title - fn SetTitle(&self, title: DOMString) -> ErrorResult { + fn SetTitle(self, title: DOMString) -> ErrorResult { self.GetDocumentElement().root().map(|root| { let root: JSRef = NodeCast::from_ref(*root); let head_node = root.traverse_preorder().find(|child| { @@ -642,7 +642,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } }, None => { - let new_title = HTMLTitleElement::new("title".to_string(), *self).root(); + let new_title = HTMLTitleElement::new("title".to_string(), self).root(); let new_title: JSRef = NodeCast::from_ref(*new_title); if !title.is_empty() { @@ -658,7 +658,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-head - fn GetHead(&self) -> Option> { + fn GetHead(self) -> Option> { self.get_html_element().and_then(|root| { let root = root.root(); let node: JSRef = NodeCast::from_ref(*root); @@ -671,7 +671,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body - fn GetBody(&self) -> Option> { + fn GetBody(self) -> Option> { self.get_html_element().and_then(|root| { let root = root.root(); let node: JSRef = NodeCast::from_ref(*root); @@ -688,7 +688,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-body - fn SetBody(&self, new_body: Option>) -> ErrorResult { + fn SetBody(self, new_body: Option>) -> ErrorResult { // Step 1. match new_body { Some(ref htmlelem) => { @@ -731,7 +731,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { } // http://www.whatwg.org/specs/web-apps/current-work/#dom-document-getelementsbyname - fn GetElementsByName(&self, name: DOMString) -> Temporary { + fn GetElementsByName(self, name: DOMString) -> Temporary { self.createNodeList(|node| { if !node.is_element() { return false; @@ -744,121 +744,121 @@ impl<'a> DocumentMethods for JSRef<'a, Document> { }) } - fn Images(&self) -> Temporary { + fn Images(self) -> Temporary { if self.images.get().is_none() { let window = self.window.root(); - let root = NodeCast::from_ref(*self); + let root = NodeCast::from_ref(self); let filter = box ImagesFilter; self.images.assign(Some(HTMLCollection::create(*window, root, filter))); } Temporary::new(self.images.get().get_ref().clone()) } - fn Embeds(&self) -> Temporary { + fn Embeds(self) -> Temporary { if self.embeds.get().is_none() { let window = self.window.root(); - let root = NodeCast::from_ref(*self); + let root = NodeCast::from_ref(self); let filter = box EmbedsFilter; self.embeds.assign(Some(HTMLCollection::create(*window, root, filter))); } Temporary::new(self.embeds.get().get_ref().clone()) } - fn Plugins(&self) -> Temporary { + fn Plugins(self) -> Temporary { self.Embeds() } - fn Links(&self) -> Temporary { + fn Links(self) -> Temporary { if self.links.get().is_none() { let window = self.window.root(); - let root = NodeCast::from_ref(*self); + let root = NodeCast::from_ref(self); let filter = box LinksFilter; self.links.assign(Some(HTMLCollection::create(*window, root, filter))); } Temporary::new(self.links.get().get_ref().clone()) } - fn Forms(&self) -> Temporary { + fn Forms(self) -> Temporary { if self.forms.get().is_none() { let window = self.window.root(); - let root = NodeCast::from_ref(*self); + let root = NodeCast::from_ref(self); let filter = box FormsFilter; self.forms.assign(Some(HTMLCollection::create(*window, root, filter))); } Temporary::new(self.forms.get().get_ref().clone()) } - fn Scripts(&self) -> Temporary { + fn Scripts(self) -> Temporary { if self.scripts.get().is_none() { let window = self.window.root(); - let root = NodeCast::from_ref(*self); + let root = NodeCast::from_ref(self); let filter = box ScriptsFilter; self.scripts.assign(Some(HTMLCollection::create(*window, root, filter))); } Temporary::new(self.scripts.get().get_ref().clone()) } - fn Anchors(&self) -> Temporary { + fn Anchors(self) -> Temporary { if self.anchors.get().is_none() { let window = self.window.root(); - let root = NodeCast::from_ref(*self); + let root = NodeCast::from_ref(self); let filter = box AnchorsFilter; self.anchors.assign(Some(HTMLCollection::create(*window, root, filter))); } Temporary::new(self.anchors.get().get_ref().clone()) } - fn Applets(&self) -> Temporary { + fn Applets(self) -> Temporary { // FIXME: This should be return OBJECT elements containing applets. if self.applets.get().is_none() { let window = self.window.root(); - let root = NodeCast::from_ref(*self); + let root = NodeCast::from_ref(self); let filter = box AppletsFilter; self.applets.assign(Some(HTMLCollection::create(*window, root, filter))); } Temporary::new(self.applets.get().get_ref().clone()) } - fn Location(&self) -> Temporary { + fn Location(self) -> Temporary { let window = self.window.root(); window.Location() } // http://dom.spec.whatwg.org/#dom-parentnode-children - fn Children(&self) -> Temporary { + fn Children(self) -> Temporary { let window = self.window.root(); - HTMLCollection::children(*window, NodeCast::from_ref(*self)) + HTMLCollection::children(*window, NodeCast::from_ref(self)) } // http://dom.spec.whatwg.org/#dom-parentnode-queryselector - fn QuerySelector(&self, selectors: DOMString) -> Fallible>> { - let root: JSRef = NodeCast::from_ref(*self); + fn QuerySelector(self, selectors: DOMString) -> Fallible>> { + let root: JSRef = NodeCast::from_ref(self); root.query_selector(selectors) } // http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall - fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible> { - let root: JSRef = NodeCast::from_ref(*self); + fn QuerySelectorAll(self, selectors: DOMString) -> Fallible> { + let root: JSRef = NodeCast::from_ref(self); root.query_selector_all(selectors) } - fn GetOnclick(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnclick(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("click") } - fn SetOnclick(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnclick(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("click", listener) } - fn GetOnload(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnload(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("load") } - fn SetOnload(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnload(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("load", listener) } } diff --git a/components/script/dom/documentfragment.rs b/components/script/dom/documentfragment.rs index 916a3550264..3a2a04c299e 100644 --- a/components/script/dom/documentfragment.rs +++ b/components/script/dom/documentfragment.rs @@ -53,23 +53,22 @@ impl DocumentFragment { impl<'a> DocumentFragmentMethods for JSRef<'a, DocumentFragment> { // http://dom.spec.whatwg.org/#dom-parentnode-children - fn Children(&self) -> Temporary { - let window = window_from_node(*self).root(); - HTMLCollection::children(*window, NodeCast::from_ref(*self)) + fn Children(self) -> Temporary { + let window = window_from_node(self).root(); + HTMLCollection::children(*window, NodeCast::from_ref(self)) } // http://dom.spec.whatwg.org/#dom-parentnode-queryselector - fn QuerySelector(&self, selectors: DOMString) -> Fallible>> { - let root: JSRef = NodeCast::from_ref(*self); + fn QuerySelector(self, selectors: DOMString) -> Fallible>> { + let root: JSRef = NodeCast::from_ref(self); root.query_selector(selectors) } // http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall - fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible> { - let root: JSRef = NodeCast::from_ref(*self); + fn QuerySelectorAll(self, selectors: DOMString) -> Fallible> { + let root: JSRef = NodeCast::from_ref(self); root.query_selector_all(selectors) } - } impl Reflectable for DocumentFragment { diff --git a/components/script/dom/documenttype.rs b/components/script/dom/documenttype.rs index 5c438b276ab..8bbf0185a48 100644 --- a/components/script/dom/documenttype.rs +++ b/components/script/dom/documenttype.rs @@ -56,21 +56,21 @@ impl DocumentType { } impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> { - fn Name(&self) -> DOMString { + fn Name(self) -> DOMString { self.name.clone() } - fn PublicId(&self) -> DOMString { + fn PublicId(self) -> DOMString { self.public_id.clone() } - fn SystemId(&self) -> DOMString { + fn SystemId(self) -> DOMString { self.system_id.clone() } // http://dom.spec.whatwg.org/#dom-childnode-remove - fn Remove(&self) { - let node: JSRef = NodeCast::from_ref(*self); + fn Remove(self) { + let node: JSRef = NodeCast::from_ref(self); node.remove_self(); } } diff --git a/components/script/dom/domexception.rs b/components/script/dom/domexception.rs index 633eaa452f0..ff2993baac8 100644 --- a/components/script/dom/domexception.rs +++ b/components/script/dom/domexception.rs @@ -91,7 +91,7 @@ impl Reflectable for DOMException { impl<'a> DOMExceptionMethods for JSRef<'a, DOMException> { // http://dom.spec.whatwg.org/#dom-domexception-code - fn Code(&self) -> u16 { + fn Code(self) -> u16 { match self.code { // http://dom.spec.whatwg.org/#concept-throw EncodingError => 0, @@ -100,12 +100,12 @@ impl<'a> DOMExceptionMethods for JSRef<'a, DOMException> { } // http://dom.spec.whatwg.org/#error-names-0 - fn Name(&self) -> DOMString { + fn Name(self) -> DOMString { self.code.to_string() } // http://dom.spec.whatwg.org/#error-names-0 - fn Message(&self) -> DOMString { + fn Message(self) -> DOMString { match self.code { IndexSizeError => "The index is not in the allowed range.".to_string(), HierarchyRequestError => "The operation would yield an incorrect node tree.".to_string(), diff --git a/components/script/dom/domimplementation.rs b/components/script/dom/domimplementation.rs index 1c5c3cd55cf..5ce1706b78f 100644 --- a/components/script/dom/domimplementation.rs +++ b/components/script/dom/domimplementation.rs @@ -54,7 +54,7 @@ impl Reflectable for DOMImplementation { // http://dom.spec.whatwg.org/#domimplementation impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> { // http://dom.spec.whatwg.org/#dom-domimplementation-createdocumenttype - fn CreateDocumentType(&self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible> { + fn CreateDocumentType(self, qname: DOMString, pubid: DOMString, sysid: DOMString) -> Fallible> { match xml_name_type(qname.as_slice()) { // Step 1. InvalidXMLName => Err(InvalidCharacter), @@ -69,7 +69,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> { } // http://dom.spec.whatwg.org/#dom-domimplementation-createdocument - fn CreateDocument(&self, namespace: Option, qname: DOMString, + fn CreateDocument(self, namespace: Option, qname: DOMString, maybe_doctype: Option>) -> Fallible> { let doc = self.document.root(); let win = doc.window.root(); @@ -115,7 +115,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> { } // http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument - fn CreateHTMLDocument(&self, title: Option) -> Temporary { + fn CreateHTMLDocument(self, title: Option) -> Temporary { let document = self.document.root(); let win = document.window.root(); diff --git a/components/script/dom/domparser.rs b/components/script/dom/domparser.rs index a75e6e13444..a467fd1812d 100644 --- a/components/script/dom/domparser.rs +++ b/components/script/dom/domparser.rs @@ -39,7 +39,7 @@ impl DOMParser { } impl<'a> DOMParserMethods for JSRef<'a, DOMParser> { - fn ParseFromString(&self, + fn ParseFromString(self, _s: DOMString, ty: DOMParserBinding::SupportedType) -> Fallible> { diff --git a/components/script/dom/domrect.rs b/components/script/dom/domrect.rs index f9fdf9b79cd..53ca08ba482 100644 --- a/components/script/dom/domrect.rs +++ b/components/script/dom/domrect.rs @@ -41,27 +41,27 @@ impl DOMRect { } impl<'a> DOMRectMethods for JSRef<'a, DOMRect> { - fn Top(&self) -> f32 { + fn Top(self) -> f32 { self.top } - fn Bottom(&self) -> f32 { + fn Bottom(self) -> f32 { self.bottom } - fn Left(&self) -> f32 { + fn Left(self) -> f32 { self.left } - fn Right(&self) -> f32 { + fn Right(self) -> f32 { self.right } - fn Width(&self) -> f32 { + fn Width(self) -> f32 { (self.right - self.left).abs() } - fn Height(&self) -> f32 { + fn Height(self) -> f32 { (self.bottom - self.top).abs() } } diff --git a/components/script/dom/domrectlist.rs b/components/script/dom/domrectlist.rs index bf2d277d6bf..5520002afe3 100644 --- a/components/script/dom/domrectlist.rs +++ b/components/script/dom/domrectlist.rs @@ -37,11 +37,11 @@ impl DOMRectList { } impl<'a> DOMRectListMethods for JSRef<'a, DOMRectList> { - fn Length(&self) -> u32 { + fn Length(self) -> u32 { self.rects.len() as u32 } - fn Item(&self, index: u32) -> Option> { + fn Item(self, index: u32) -> Option> { let rects = &self.rects; if index < rects.len() as u32 { Some(Temporary::new(rects[index as uint].clone())) @@ -50,7 +50,7 @@ impl<'a> DOMRectListMethods for JSRef<'a, DOMRectList> { } } - fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + fn IndexedGetter(self, index: u32, found: &mut bool) -> Option> { *found = index < self.rects.len() as u32; self.Item(index) } diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index 18633658943..fc4fefb3ec0 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -71,27 +71,27 @@ impl<'a> PrivateDOMTokenListHelpers for JSRef<'a, DOMTokenList> { // http://dom.spec.whatwg.org/#domtokenlist impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> { // http://dom.spec.whatwg.org/#dom-domtokenlist-length - fn Length(&self) -> u32 { + fn Length(self) -> u32 { self.attribute().root().map(|attr| { attr.value().tokens().map(|tokens| tokens.len()).unwrap_or(0) }).unwrap_or(0) as u32 } // http://dom.spec.whatwg.org/#dom-domtokenlist-item - fn Item(&self, index: u32) -> Option { + fn Item(self, index: u32) -> Option { self.attribute().root().and_then(|attr| attr.value().tokens().and_then(|mut tokens| { tokens.idx(index as uint).map(|token| token.as_slice().to_string()) })) } - fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option { + fn IndexedGetter(self, index: u32, found: &mut bool) -> Option { let item = self.Item(index); *found = item.is_some(); item } // http://dom.spec.whatwg.org/#dom-domtokenlist-contains - fn Contains(&self, token: DOMString) -> Fallible { + fn Contains(self, token: DOMString) -> Fallible { self.check_token_exceptions(token.as_slice()).map(|slice| { self.attribute().root().and_then(|attr| attr.value().tokens().map(|mut tokens| { let atom = Atom::from_slice(slice); diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 143f025fc72..4101c7e074e 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -271,7 +271,7 @@ impl<'a> ElementHelpers for JSRef<'a, Element> { summarized } - fn is_void(&self) -> bool { + fn is_void(self) -> bool { if self.namespace != namespace::HTML { return false } @@ -506,24 +506,24 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { impl<'a> ElementMethods for JSRef<'a, Element> { // http://dom.spec.whatwg.org/#dom-element-namespaceuri - fn GetNamespaceURI(&self) -> Option { + fn GetNamespaceURI(self) -> Option { match self.namespace { Null => None, ref ns => Some(ns.to_str().to_string()) } } - fn LocalName(&self) -> DOMString { + fn LocalName(self) -> DOMString { self.local_name.as_slice().to_string() } // http://dom.spec.whatwg.org/#dom-element-prefix - fn GetPrefix(&self) -> Option { + fn GetPrefix(self) -> Option { self.prefix.clone() } // http://dom.spec.whatwg.org/#dom-element-tagname - fn TagName(&self) -> DOMString { + fn TagName(self) -> DOMString { let qualified_name = match self.prefix { Some(ref prefix) => format!("{}:{}", prefix, self.local_name).into_maybe_owned(), None => self.local_name.as_slice().into_maybe_owned() @@ -536,31 +536,31 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } // http://dom.spec.whatwg.org/#dom-element-id - fn Id(&self) -> DOMString { + fn Id(self) -> DOMString { self.get_string_attribute("id") } // http://dom.spec.whatwg.org/#dom-element-id - fn SetId(&self, id: DOMString) { + fn SetId(self, id: DOMString) { self.set_atomic_attribute("id", id); } // http://dom.spec.whatwg.org/#dom-element-classname - fn ClassName(&self) -> DOMString { + fn ClassName(self) -> DOMString { self.get_string_attribute("class") } // http://dom.spec.whatwg.org/#dom-element-classname - fn SetClassName(&self, class: DOMString) { + fn SetClassName(self, class: DOMString) { self.set_tokenlist_attribute("class", class); } // http://dom.spec.whatwg.org/#dom-element-classlist - fn ClassList(&self) -> Temporary { + fn ClassList(self) -> Temporary { match self.class_list.get() { Some(class_list) => Temporary::new(class_list), None => { - let class_list = DOMTokenList::new(*self, "class").root(); + let class_list = DOMTokenList::new(self, "class").root(); self.class_list.assign(Some(class_list.deref().clone())); Temporary::from_rooted(*class_list) } @@ -568,24 +568,24 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } // http://dom.spec.whatwg.org/#dom-element-attributes - fn Attributes(&self) -> Temporary { + fn Attributes(self) -> Temporary { match self.attr_list.get() { None => (), Some(ref list) => return Temporary::new(list.clone()), } let doc = { - let node: JSRef = NodeCast::from_ref(*self); + let node: JSRef = NodeCast::from_ref(self); node.owner_doc().root() }; let window = doc.deref().window.root(); - let list = NamedNodeMap::new(*window, *self); + let list = NamedNodeMap::new(*window, self); self.attr_list.assign(Some(list)); Temporary::new(self.attr_list.get().get_ref().clone()) } // http://dom.spec.whatwg.org/#dom-element-getattribute - fn GetAttribute(&self, name: DOMString) -> Option { + fn GetAttribute(self, name: DOMString) -> Option { let name = if self.html_element_in_html_document() { name.as_slice().to_ascii_lower() } else { @@ -596,7 +596,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } // http://dom.spec.whatwg.org/#dom-element-getattributens - fn GetAttributeNS(&self, + fn GetAttributeNS(self, namespace: Option, local_name: DOMString) -> Option { let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace)); @@ -605,11 +605,11 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } // http://dom.spec.whatwg.org/#dom-element-setattribute - fn SetAttribute(&self, + fn SetAttribute(self, name: DOMString, value: DOMString) -> ErrorResult { { - let node: JSRef = NodeCast::from_ref(*self); + let node: JSRef = NodeCast::from_ref(self); node.wait_until_safe_to_modify_dom(); } @@ -636,12 +636,12 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } // http://dom.spec.whatwg.org/#dom-element-setattributens - fn SetAttributeNS(&self, + fn SetAttributeNS(self, namespace_url: Option, name: DOMString, value: DOMString) -> ErrorResult { { - let node: JSRef = NodeCast::from_ref(*self); + let node: JSRef = NodeCast::from_ref(self); node.wait_until_safe_to_modify_dom(); } @@ -705,7 +705,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } // http://dom.spec.whatwg.org/#dom-element-removeattribute - fn RemoveAttribute(&self, name: DOMString) { + fn RemoveAttribute(self, name: DOMString) { let name = if self.html_element_in_html_document() { name.as_slice().to_ascii_lower() } else { @@ -715,7 +715,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } // http://dom.spec.whatwg.org/#dom-element-removeattributens - fn RemoveAttributeNS(&self, + fn RemoveAttributeNS(self, namespace: Option, localname: DOMString) { let namespace = Namespace::from_str(null_str_as_empty_ref(&namespace)); @@ -723,38 +723,38 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } // http://dom.spec.whatwg.org/#dom-element-hasattribute - fn HasAttribute(&self, + fn HasAttribute(self, name: DOMString) -> bool { self.has_attribute(name.as_slice()) } // http://dom.spec.whatwg.org/#dom-element-hasattributens - fn HasAttributeNS(&self, + fn HasAttributeNS(self, namespace: Option, local_name: DOMString) -> bool { self.GetAttributeNS(namespace, local_name).is_some() } - fn GetElementsByTagName(&self, localname: DOMString) -> Temporary { - let window = window_from_node(*self).root(); - HTMLCollection::by_tag_name(*window, NodeCast::from_ref(*self), localname) + fn GetElementsByTagName(self, localname: DOMString) -> Temporary { + let window = window_from_node(self).root(); + HTMLCollection::by_tag_name(*window, NodeCast::from_ref(self), localname) } - fn GetElementsByTagNameNS(&self, maybe_ns: Option, + fn GetElementsByTagNameNS(self, maybe_ns: Option, localname: DOMString) -> Temporary { - let window = window_from_node(*self).root(); - HTMLCollection::by_tag_name_ns(*window, NodeCast::from_ref(*self), localname, maybe_ns) + let window = window_from_node(self).root(); + HTMLCollection::by_tag_name_ns(*window, NodeCast::from_ref(self), localname, maybe_ns) } - fn GetElementsByClassName(&self, classes: DOMString) -> Temporary { - let window = window_from_node(*self).root(); - HTMLCollection::by_class_name(*window, NodeCast::from_ref(*self), classes) + fn GetElementsByClassName(self, classes: DOMString) -> Temporary { + let window = window_from_node(self).root(); + HTMLCollection::by_class_name(*window, NodeCast::from_ref(self), classes) } // http://dev.w3.org/csswg/cssom-view/#dom-element-getclientrects - fn GetClientRects(&self) -> Temporary { - let win = window_from_node(*self).root(); - let node: JSRef = NodeCast::from_ref(*self); + fn GetClientRects(self) -> Temporary { + let win = window_from_node(self).root(); + let node: JSRef = NodeCast::from_ref(self); let rects = node.get_content_boxes(); let rects: Vec> = rects.iter().map(|r| { DOMRect::new( @@ -769,9 +769,9 @@ impl<'a> ElementMethods for JSRef<'a, Element> { } // http://dev.w3.org/csswg/cssom-view/#dom-element-getboundingclientrect - fn GetBoundingClientRect(&self) -> Temporary { - let win = window_from_node(*self).root(); - let node: JSRef = NodeCast::from_ref(*self); + fn GetBoundingClientRect(self) -> Temporary { + let win = window_from_node(self).root(); + let node: JSRef = NodeCast::from_ref(self); let rect = node.get_bounding_content_box(); DOMRect::new( *win, @@ -781,45 +781,45 @@ impl<'a> ElementMethods for JSRef<'a, Element> { rect.origin.x + rect.size.width) } - fn GetInnerHTML(&self) -> Fallible { + fn GetInnerHTML(self) -> Fallible { //XXX TODO: XML case - Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(*self), false, false))) + Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(self), false, false))) } - fn GetOuterHTML(&self) -> Fallible { - Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(*self), true, false))) + fn GetOuterHTML(self) -> Fallible { + Ok(serialize(&mut NodeIterator::new(NodeCast::from_ref(self), true, false))) } // http://dom.spec.whatwg.org/#dom-parentnode-children - fn Children(&self) -> Temporary { - let window = window_from_node(*self).root(); - HTMLCollection::children(*window, NodeCast::from_ref(*self)) + fn Children(self) -> Temporary { + let window = window_from_node(self).root(); + HTMLCollection::children(*window, NodeCast::from_ref(self)) } // http://dom.spec.whatwg.org/#dom-parentnode-queryselector - fn QuerySelector(&self, selectors: DOMString) -> Fallible>> { - let root: JSRef = NodeCast::from_ref(*self); + fn QuerySelector(self, selectors: DOMString) -> Fallible>> { + let root: JSRef = NodeCast::from_ref(self); root.query_selector(selectors) } // http://dom.spec.whatwg.org/#dom-parentnode-queryselectorall - fn QuerySelectorAll(&self, selectors: DOMString) -> Fallible> { - let root: JSRef = NodeCast::from_ref(*self); + fn QuerySelectorAll(self, selectors: DOMString) -> Fallible> { + let root: JSRef = NodeCast::from_ref(self); root.query_selector_all(selectors) } // http://dom.spec.whatwg.org/#dom-childnode-remove - fn Remove(&self) { - let node: JSRef = NodeCast::from_ref(*self); + fn Remove(self) { + let node: JSRef = NodeCast::from_ref(self); node.remove_self(); } // http://dom.spec.whatwg.org/#dom-element-matches - fn Matches(&self, selectors: DOMString) -> Fallible { + fn Matches(self, selectors: DOMString) -> Fallible { match parse_selector_list_from_str(selectors.as_slice()) { Err(()) => Err(Syntax), Ok(ref selectors) => { - let root: JSRef = NodeCast::from_ref(*self); + let root: JSRef = NodeCast::from_ref(self); Ok(matches(selectors, &root, &mut None)) } } diff --git a/components/script/dom/event.rs b/components/script/dom/event.rs index e50acecb0e3..88270fde8eb 100644 --- a/components/script/dom/event.rs +++ b/components/script/dom/event.rs @@ -98,54 +98,54 @@ impl Event { } impl<'a> EventMethods for JSRef<'a, Event> { - fn EventPhase(&self) -> u16 { + fn EventPhase(self) -> u16 { self.phase.deref().get() as u16 } - fn Type(&self) -> DOMString { + fn Type(self) -> DOMString { self.type_.deref().borrow().clone() } - fn GetTarget(&self) -> Option> { + fn GetTarget(self) -> Option> { self.target.get().as_ref().map(|target| Temporary::new(target.clone())) } - fn GetCurrentTarget(&self) -> Option> { + fn GetCurrentTarget(self) -> Option> { self.current_target.get().as_ref().map(|target| Temporary::new(target.clone())) } - fn DefaultPrevented(&self) -> bool { + fn DefaultPrevented(self) -> bool { self.canceled.deref().get() } - fn PreventDefault(&self) { + fn PreventDefault(self) { if self.cancelable.deref().get() { self.canceled.deref().set(true) } } - fn StopPropagation(&self) { + fn StopPropagation(self) { self.stop_propagation.deref().set(true); } - fn StopImmediatePropagation(&self) { + fn StopImmediatePropagation(self) { self.stop_immediate.deref().set(true); self.stop_propagation.deref().set(true); } - fn Bubbles(&self) -> bool { + fn Bubbles(self) -> bool { self.bubbles.deref().get() } - fn Cancelable(&self) -> bool { + fn Cancelable(self) -> bool { self.cancelable.deref().get() } - fn TimeStamp(&self) -> u64 { + fn TimeStamp(self) -> u64 { self.timestamp } - fn InitEvent(&self, + fn InitEvent(self, type_: DOMString, bubbles: bool, cancelable: bool) { @@ -163,7 +163,7 @@ impl<'a> EventMethods for JSRef<'a, Event> { self.cancelable.deref().set(cancelable); } - fn IsTrusted(&self) -> bool { + fn IsTrusted(self) -> bool { self.trusted.deref().get() } } diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index 57c7fabd2d1..d2c2dcb7585 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -225,7 +225,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> { } impl<'a> EventTargetMethods for JSRef<'a, EventTarget> { - fn AddEventListener(&self, + fn AddEventListener(self, ty: DOMString, listener: Option, capture: bool) { @@ -246,7 +246,7 @@ impl<'a> EventTargetMethods for JSRef<'a, EventTarget> { } } - fn RemoveEventListener(&self, + fn RemoveEventListener(self, ty: DOMString, listener: Option, capture: bool) { @@ -270,7 +270,7 @@ impl<'a> EventTargetMethods for JSRef<'a, EventTarget> { } } - fn DispatchEvent(&self, event: JSRef) -> Fallible { + fn DispatchEvent(self, event: JSRef) -> Fallible { self.dispatch_event_with_target(None, event) } } diff --git a/components/script/dom/file.rs b/components/script/dom/file.rs index 151db9132b0..52ea7feff74 100644 --- a/components/script/dom/file.rs +++ b/components/script/dom/file.rs @@ -36,8 +36,8 @@ impl File { } } -impl FileMethods for File { - fn Name(&self) -> DOMString { +impl<'a> FileMethods for JSRef<'a, File> { + fn Name(self) -> DOMString { self.name.clone() } } diff --git a/components/script/dom/formdata.rs b/components/script/dom/formdata.rs index 7e5f22845de..4374a55067e 100644 --- a/components/script/dom/formdata.rs +++ b/components/script/dom/formdata.rs @@ -56,22 +56,22 @@ impl FormData { impl<'a> FormDataMethods for JSRef<'a, FormData> { #[allow(unrooted_must_root)] - fn Append(&self, name: DOMString, value: JSRef, filename: Option) { + fn Append(self, name: DOMString, value: JSRef, filename: Option) { let file = FileData(JS::from_rooted(self.get_file_from_blob(value, filename))); self.data.deref().borrow_mut().insert_or_update_with(name.clone(), vec!(file.clone()), |_k, v| {v.push(file.clone());}); } - fn Append_(&self, name: DOMString, value: DOMString) { + fn Append_(self, name: DOMString, value: DOMString) { self.data.deref().borrow_mut().insert_or_update_with(name, vec!(StringData(value.clone())), |_k, v| {v.push(StringData(value.clone()));}); } - fn Delete(&self, name: DOMString) { + fn Delete(self, name: DOMString) { self.data.deref().borrow_mut().remove(&name); } - fn Get(&self, name: DOMString) -> Option { + fn Get(self, name: DOMString) -> Option { if self.data.deref().borrow().contains_key_equiv(&name) { match self.data.deref().borrow().get(&name)[0].clone() { StringData(ref s) => Some(eString(s.clone())), @@ -84,16 +84,16 @@ impl<'a> FormDataMethods for JSRef<'a, FormData> { } } - fn Has(&self, name: DOMString) -> bool { + fn Has(self, name: DOMString) -> bool { self.data.deref().borrow().contains_key_equiv(&name) } #[allow(unrooted_must_root)] - fn Set(&self, name: DOMString, value: JSRef, filename: Option) { + fn Set(self, name: DOMString, value: JSRef, filename: Option) { let file = FileData(JS::from_rooted(self.get_file_from_blob(value, filename))); self.data.deref().borrow_mut().insert(name, vec!(file)); } - fn Set_(&self, name: DOMString, value: DOMString) { + fn Set_(self, name: DOMString, value: DOMString) { self.data.deref().borrow_mut().insert(name, vec!(StringData(value))); } } diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 1860f685d9a..728b9c07fb6 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -122,13 +122,13 @@ impl Reflectable for HTMLAnchorElement { } impl<'a> HTMLAnchorElementMethods for JSRef<'a, HTMLAnchorElement> { - fn Text(&self) -> DOMString { - let node: JSRef = NodeCast::from_ref(*self); + fn Text(self) -> DOMString { + let node: JSRef = NodeCast::from_ref(self); node.GetTextContent().unwrap() } - fn SetText(&self, value: DOMString) { - let node: JSRef = NodeCast::from_ref(*self); + fn SetText(self, value: DOMString) { + let node: JSRef = NodeCast::from_ref(self); node.SetTextContent(Some(value)) } } diff --git a/components/script/dom/htmlbodyelement.rs b/components/script/dom/htmlbodyelement.rs index 96728eaa3f6..efdf4065145 100644 --- a/components/script/dom/htmlbodyelement.rs +++ b/components/script/dom/htmlbodyelement.rs @@ -47,13 +47,13 @@ impl HTMLBodyElement { } impl<'a> HTMLBodyElementMethods for JSRef<'a, HTMLBodyElement> { - fn GetOnunload(&self) -> Option { - let win = window_from_node(*self).root(); + fn GetOnunload(self) -> Option { + let win = window_from_node(self).root(); win.deref().GetOnunload() } - fn SetOnunload(&self, listener: Option) { - let win = window_from_node(*self).root(); + fn SetOnunload(self, listener: Option) { + let win = window_from_node(self).root(); win.deref().SetOnunload(listener) } } diff --git a/components/script/dom/htmlbuttonelement.rs b/components/script/dom/htmlbuttonelement.rs index 9de41db4423..c3b0b0e50f8 100644 --- a/components/script/dom/htmlbuttonelement.rs +++ b/components/script/dom/htmlbuttonelement.rs @@ -46,8 +46,8 @@ impl HTMLButtonElement { } impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> { - fn Validity(&self) -> Temporary { - let window = window_from_node(*self).root(); + fn Validity(self) -> Temporary { + let window = window_from_node(self).root(); ValidityState::new(*window) } @@ -55,8 +55,8 @@ impl<'a> HTMLButtonElementMethods for JSRef<'a, HTMLButtonElement> { make_bool_getter!(Disabled) // http://www.whatwg.org/html/#dom-fe-disabled - fn SetDisabled(&self, disabled: bool) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetDisabled(self, disabled: bool) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_bool_attribute("disabled", disabled) } } diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs index 501e905ef55..be12b3042ef 100644 --- a/components/script/dom/htmlcanvaselement.rs +++ b/components/script/dom/htmlcanvaselement.rs @@ -61,33 +61,33 @@ impl HTMLCanvasElement { } impl<'a> HTMLCanvasElementMethods for JSRef<'a, HTMLCanvasElement> { - fn Width(&self) -> u32 { + fn Width(self) -> u32 { self.width.get() } - fn SetWidth(&self, width: u32) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetWidth(self, width: u32) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_uint_attribute("width", width) } - fn Height(&self) -> u32 { + fn Height(self) -> u32 { self.height.get() } - fn SetHeight(&self, height: u32) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetHeight(self, height: u32) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_uint_attribute("height", height) } - fn GetContext(&self, id: DOMString) -> Option> { + fn GetContext(self, id: DOMString) -> Option> { if id.as_slice() != "2d" { return None; } if self.context.get().is_none() { - let window = window_from_node(*self).root(); + let window = window_from_node(self).root(); let (w, h) = (self.width.get() as i32, self.height.get() as i32); - let context = CanvasRenderingContext2D::new(&Window(*window), *self, Size2D(w, h)); + let context = CanvasRenderingContext2D::new(&Window(*window), self, Size2D(w, h)); self.context.assign(Some(context)); } self.context.get().map(|context| Temporary::new(context)) diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs index d5de946acdd..6a4baf3f5dc 100644 --- a/components/script/dom/htmlcollection.rs +++ b/components/script/dom/htmlcollection.rs @@ -172,7 +172,7 @@ impl HTMLCollection { impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> { // http://dom.spec.whatwg.org/#dom-htmlcollection-length - fn Length(&self) -> u32 { + fn Length(self) -> u32 { match self.collection { Static(ref elems) => elems.len() as u32, Live(ref root, ref filter) => { @@ -187,7 +187,7 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> { } // http://dom.spec.whatwg.org/#dom-htmlcollection-item - fn Item(&self, index: u32) -> Option> { + fn Item(self, index: u32) -> Option> { match self.collection { Static(ref elems) => elems .as_slice() @@ -209,7 +209,7 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> { } // http://dom.spec.whatwg.org/#dom-htmlcollection-nameditem - fn NamedItem(&self, key: DOMString) -> Option> { + fn NamedItem(self, key: DOMString) -> Option> { // Step 1. if key.is_empty() { return None; @@ -239,13 +239,13 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> { } } - fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + fn IndexedGetter(self, index: u32, found: &mut bool) -> Option> { let maybe_elem = self.Item(index); *found = maybe_elem.is_some(); maybe_elem } - fn NamedGetter(&self, name: DOMString, found: &mut bool) -> Option> { + fn NamedGetter(self, name: DOMString, found: &mut bool) -> Option> { let maybe_elem = self.NamedItem(name); *found = maybe_elem.is_some(); maybe_elem diff --git a/components/script/dom/htmldatalistelement.rs b/components/script/dom/htmldatalistelement.rs index cd82390a9a4..6ca6cb7fe3d 100644 --- a/components/script/dom/htmldatalistelement.rs +++ b/components/script/dom/htmldatalistelement.rs @@ -43,14 +43,14 @@ impl HTMLDataListElement { } impl<'a> HTMLDataListElementMethods for JSRef<'a, HTMLDataListElement> { - fn Options(&self) -> Temporary { + fn Options(self) -> Temporary { struct HTMLDataListOptionsFilter; impl CollectionFilter for HTMLDataListOptionsFilter { fn filter(&self, elem: JSRef, _root: JSRef) -> bool { elem.is_htmloptionelement() } } - let node: JSRef = NodeCast::from_ref(*self); + let node: JSRef = NodeCast::from_ref(self); let filter = box HTMLDataListOptionsFilter; let window = window_from_node(node).root(); HTMLCollection::create(*window, node, filter) diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 42744ba32a0..4d9dccab7c9 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -63,28 +63,28 @@ impl<'a> PrivateHTMLElementHelpers for JSRef<'a, HTMLElement> { } impl<'a> HTMLElementMethods for JSRef<'a, HTMLElement> { - fn GetOnclick(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnclick(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("click") } - fn SetOnclick(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnclick(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("click", listener) } - fn GetOnload(&self) -> Option { + fn GetOnload(self) -> Option { if self.is_body_or_frameset() { - let win = window_from_node(*self).root(); + let win = window_from_node(self).root(); win.deref().GetOnload() } else { None } } - fn SetOnload(&self, listener: Option) { + fn SetOnload(self, listener: Option) { if self.is_body_or_frameset() { - let win = window_from_node(*self).root(); + let win = window_from_node(self).root(); win.deref().SetOnload(listener) } } diff --git a/components/script/dom/htmlfieldsetelement.rs b/components/script/dom/htmlfieldsetelement.rs index 103c8a60332..4f5b1bb7fde 100644 --- a/components/script/dom/htmlfieldsetelement.rs +++ b/components/script/dom/htmlfieldsetelement.rs @@ -49,7 +49,7 @@ impl HTMLFieldSetElement { impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> { // http://www.whatwg.org/html/#dom-fieldset-elements - fn Elements(&self) -> Temporary { + fn Elements(self) -> Temporary { struct ElementsFilter; impl CollectionFilter for ElementsFilter { fn filter(&self, elem: JSRef, root: JSRef) -> bool { @@ -59,14 +59,14 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> { elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.deref().local_name.as_slice()) } } - let node: JSRef = NodeCast::from_ref(*self); + let node: JSRef = NodeCast::from_ref(self); let filter = box ElementsFilter; let window = window_from_node(node).root(); HTMLCollection::create(*window, node, filter) } - fn Validity(&self) -> Temporary { - let window = window_from_node(*self).root(); + fn Validity(self) -> Temporary { + let window = window_from_node(self).root(); ValidityState::new(*window) } @@ -74,8 +74,8 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> { make_bool_getter!(Disabled) // http://www.whatwg.org/html/#dom-fieldset-disabled - fn SetDisabled(&self, disabled: bool) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetDisabled(self, disabled: bool) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_bool_attribute("disabled", disabled) } } diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index f8cf746bce2..0c2e5d4d6b4 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -131,29 +131,29 @@ impl HTMLIFrameElement { } impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> { - fn Src(&self) -> DOMString { - let element: JSRef = ElementCast::from_ref(*self); + fn Src(self) -> DOMString { + let element: JSRef = ElementCast::from_ref(self); element.get_string_attribute("src") } - fn SetSrc(&self, src: DOMString) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetSrc(self, src: DOMString) { + let element: JSRef = ElementCast::from_ref(self); element.set_url_attribute("src", src) } - fn Sandbox(&self) -> DOMString { - let element: JSRef = ElementCast::from_ref(*self); + fn Sandbox(self) -> DOMString { + let element: JSRef = ElementCast::from_ref(self); element.get_string_attribute("sandbox") } - fn SetSandbox(&self, sandbox: DOMString) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetSandbox(self, sandbox: DOMString) { + let element: JSRef = ElementCast::from_ref(self); element.set_string_attribute("sandbox", sandbox); } - fn GetContentWindow(&self) -> Option> { + fn GetContentWindow(self) -> Option> { self.size.deref().get().and_then(|size| { - let window = window_from_node(*self).root(); + let window = window_from_node(self).root(); let children = &*window.deref().page.children.deref().borrow(); let child = children.iter().find(|child| { child.subpage_id.unwrap() == size.subpage_id diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index f534182a53c..faac2c8d037 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -99,93 +99,93 @@ impl LayoutHTMLImageElementHelpers for JS { impl<'a> HTMLImageElementMethods for JSRef<'a, HTMLImageElement> { make_getter!(Alt) - fn SetAlt(&self, alt: DOMString) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetAlt(self, alt: DOMString) { + let element: JSRef = ElementCast::from_ref(self); element.set_string_attribute("alt", alt) } make_getter!(Src) - fn SetSrc(&self, src: DOMString) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetSrc(self, src: DOMString) { + let element: JSRef = ElementCast::from_ref(self); element.set_url_attribute("src", src) } make_getter!(UseMap) - fn SetUseMap(&self, use_map: DOMString) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetUseMap(self, use_map: DOMString) { + let element: JSRef = ElementCast::from_ref(self); element.set_string_attribute("usemap", use_map) } make_bool_getter!(IsMap) - fn SetIsMap(&self, is_map: bool) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetIsMap(self, is_map: bool) { + let element: JSRef = ElementCast::from_ref(self); element.set_string_attribute("ismap", is_map.to_string()) } - fn Width(&self) -> u32 { - let node: JSRef = NodeCast::from_ref(*self); + fn Width(self) -> u32 { + let node: JSRef = NodeCast::from_ref(self); let rect = node.get_bounding_content_box(); to_px(rect.size.width) as u32 } - fn SetWidth(&self, width: u32) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetWidth(self, width: u32) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_uint_attribute("width", width) } - fn Height(&self) -> u32 { - let node: JSRef = NodeCast::from_ref(*self); + fn Height(self) -> u32 { + let node: JSRef = NodeCast::from_ref(self); let rect = node.get_bounding_content_box(); to_px(rect.size.height) as u32 } - fn SetHeight(&self, height: u32) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetHeight(self, height: u32) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_uint_attribute("height", height) } make_getter!(Name) - fn SetName(&self, name: DOMString) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetName(self, name: DOMString) { + let element: JSRef = ElementCast::from_ref(self); element.set_string_attribute("name", name) } make_getter!(Align) - fn SetAlign(&self, align: DOMString) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetAlign(self, align: DOMString) { + let element: JSRef = ElementCast::from_ref(self); element.set_string_attribute("align", align) } make_uint_getter!(Hspace) - fn SetHspace(&self, hspace: u32) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetHspace(self, hspace: u32) { + let element: JSRef = ElementCast::from_ref(self); element.set_uint_attribute("hspace", hspace) } make_uint_getter!(Vspace) - fn SetVspace(&self, vspace: u32) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetVspace(self, vspace: u32) { + let element: JSRef = ElementCast::from_ref(self); element.set_uint_attribute("vspace", vspace) } make_getter!(LongDesc) - fn SetLongDesc(&self, longdesc: DOMString) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetLongDesc(self, longdesc: DOMString) { + let element: JSRef = ElementCast::from_ref(self); element.set_string_attribute("longdesc", longdesc) } make_getter!(Border) - fn SetBorder(&self, border: DOMString) { - let element: JSRef = ElementCast::from_ref(*self); + fn SetBorder(self, border: DOMString) { + let element: JSRef = ElementCast::from_ref(self); element.set_string_attribute("border", border) } } diff --git a/components/script/dom/htmlinputelement.rs b/components/script/dom/htmlinputelement.rs index 6b6484b0d45..256bea5b710 100644 --- a/components/script/dom/htmlinputelement.rs +++ b/components/script/dom/htmlinputelement.rs @@ -49,8 +49,8 @@ impl<'a> HTMLInputElementMethods for JSRef<'a, HTMLInputElement> { make_bool_getter!(Disabled) // http://www.whatwg.org/html/#dom-fe-disabled - fn SetDisabled(&self, disabled: bool) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetDisabled(self, disabled: bool) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_bool_attribute("disabled", disabled) } } diff --git a/components/script/dom/htmlobjectelement.rs b/components/script/dom/htmlobjectelement.rs index d8ed9116559..98d5dc25e00 100644 --- a/components/script/dom/htmlobjectelement.rs +++ b/components/script/dom/htmlobjectelement.rs @@ -83,8 +83,8 @@ pub fn is_image_data(uri: &str) -> bool { } impl<'a> HTMLObjectElementMethods for JSRef<'a, HTMLObjectElement> { - fn Validity(&self) -> Temporary { - let window = window_from_node(*self).root(); + fn Validity(self) -> Temporary { + let window = window_from_node(self).root(); ValidityState::new(*window) } } diff --git a/components/script/dom/htmloptgroupelement.rs b/components/script/dom/htmloptgroupelement.rs index cd7649e0048..b7bdfe4c93b 100644 --- a/components/script/dom/htmloptgroupelement.rs +++ b/components/script/dom/htmloptgroupelement.rs @@ -49,8 +49,8 @@ impl<'a> HTMLOptGroupElementMethods for JSRef<'a, HTMLOptGroupElement> { make_bool_getter!(Disabled) // http://www.whatwg.org/html#dom-optgroup-disabled - fn SetDisabled(&self, disabled: bool) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetDisabled(self, disabled: bool) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_bool_attribute("disabled", disabled) } } diff --git a/components/script/dom/htmloptionelement.rs b/components/script/dom/htmloptionelement.rs index bb40b4c5b7c..fd0740ba172 100644 --- a/components/script/dom/htmloptionelement.rs +++ b/components/script/dom/htmloptionelement.rs @@ -49,8 +49,8 @@ impl<'a> HTMLOptionElementMethods for JSRef<'a, HTMLOptionElement> { make_bool_getter!(Disabled) // http://www.whatwg.org/html/#dom-option-disabled - fn SetDisabled(&self, disabled: bool) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetDisabled(self, disabled: bool) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_bool_attribute("disabled", disabled) } } diff --git a/components/script/dom/htmloutputelement.rs b/components/script/dom/htmloutputelement.rs index 219a8ed227a..452ab89d8ed 100644 --- a/components/script/dom/htmloutputelement.rs +++ b/components/script/dom/htmloutputelement.rs @@ -42,8 +42,8 @@ impl HTMLOutputElement { } impl<'a> HTMLOutputElementMethods for JSRef<'a, HTMLOutputElement> { - fn Validity(&self) -> Temporary { - let window = window_from_node(*self).root(); + fn Validity(self) -> Temporary { + let window = window_from_node(self).root(); ValidityState::new(*window) } } diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 43ba78176d1..d16fc56d72f 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -107,20 +107,20 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> { } impl<'a> HTMLScriptElementMethods for JSRef<'a, HTMLScriptElement> { - fn Src(&self) -> DOMString { - let element: JSRef = ElementCast::from_ref(*self); + fn Src(self) -> DOMString { + let element: JSRef = ElementCast::from_ref(self); element.get_url_attribute("src") } // http://www.whatwg.org/html/#dom-script-text - fn Text(&self) -> DOMString { - let node: JSRef = NodeCast::from_ref(*self); + fn Text(self) -> DOMString { + let node: JSRef = NodeCast::from_ref(self); Node::collect_text_contents(node.children()) } // http://www.whatwg.org/html/#dom-script-text - fn SetText(&self, value: DOMString) { - let node: JSRef = NodeCast::from_ref(*self); + fn SetText(self, value: DOMString) { + let node: JSRef = NodeCast::from_ref(self); node.SetTextContent(Some(value)) } } diff --git a/components/script/dom/htmlselectelement.rs b/components/script/dom/htmlselectelement.rs index 1d720ca8eb7..0a96b1ef82c 100644 --- a/components/script/dom/htmlselectelement.rs +++ b/components/script/dom/htmlselectelement.rs @@ -48,21 +48,21 @@ impl HTMLSelectElement { } impl<'a> HTMLSelectElementMethods for JSRef<'a, HTMLSelectElement> { - fn Validity(&self) -> Temporary { - let window = window_from_node(*self).root(); + fn Validity(self) -> Temporary { + let window = window_from_node(self).root(); ValidityState::new(*window) } // Note: this function currently only exists for test_union.html. - fn Add(&self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option) { + fn Add(self, _element: HTMLOptionElementOrHTMLOptGroupElement, _before: Option) { } // http://www.whatwg.org/html/#dom-fe-disabled make_bool_getter!(Disabled) // http://www.whatwg.org/html/#dom-fe-disabled - fn SetDisabled(&self, disabled: bool) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetDisabled(self, disabled: bool) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_bool_attribute("disabled", disabled) } } diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index 09c0bf8c886..c54be9fedb5 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -50,10 +50,9 @@ impl Reflectable for HTMLTableElement { } impl<'a> HTMLTableElementMethods for JSRef<'a, HTMLTableElement> { - // http://www.whatwg.org/html/#dom-table-caption - fn GetCaption(&self) -> Option> { - let node: JSRef = NodeCast::from_ref(*self); + fn GetCaption(self) -> Option> { + let node: JSRef = NodeCast::from_ref(self); node.children().find(|child| { child.type_id() == ElementNodeTypeId(HTMLTableCaptionElementTypeId) }).map(|node| { @@ -62,8 +61,8 @@ impl<'a> HTMLTableElementMethods for JSRef<'a, HTMLTableElement> { } // http://www.whatwg.org/html/#dom-table-caption - fn SetCaption(&self, new_caption: Option>) { - let node: JSRef = NodeCast::from_ref(*self); + fn SetCaption(self, new_caption: Option>) { + let node: JSRef = NodeCast::from_ref(self); let old_caption = self.GetCaption(); match old_caption { diff --git a/components/script/dom/htmltextareaelement.rs b/components/script/dom/htmltextareaelement.rs index 47d4b2c0e4b..39d28967f5f 100644 --- a/components/script/dom/htmltextareaelement.rs +++ b/components/script/dom/htmltextareaelement.rs @@ -49,8 +49,8 @@ impl<'a> HTMLTextAreaElementMethods for JSRef<'a, HTMLTextAreaElement> { make_bool_getter!(Disabled) // http://www.whatwg.org/html/#dom-fe-disabled - fn SetDisabled(&self, disabled: bool) { - let elem: JSRef = ElementCast::from_ref(*self); + fn SetDisabled(self, disabled: bool) { + let elem: JSRef = ElementCast::from_ref(self); elem.set_bool_attribute("disabled", disabled) } } diff --git a/components/script/dom/htmltitleelement.rs b/components/script/dom/htmltitleelement.rs index 7f4a3bbeda6..c10566ff032 100644 --- a/components/script/dom/htmltitleelement.rs +++ b/components/script/dom/htmltitleelement.rs @@ -44,8 +44,8 @@ impl HTMLTitleElement { impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> { // http://www.whatwg.org/html/#dom-title-text - fn Text(&self) -> DOMString { - let node: JSRef = NodeCast::from_ref(*self); + fn Text(self) -> DOMString { + let node: JSRef = NodeCast::from_ref(self); let mut content = String::new(); for child in node.children() { let text: Option> = TextCast::to_ref(child); @@ -58,8 +58,8 @@ impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> { } // http://www.whatwg.org/html/#dom-title-text - fn SetText(&self, value: DOMString) { - let node: JSRef = NodeCast::from_ref(*self); + fn SetText(self, value: DOMString) { + let node: JSRef = NodeCast::from_ref(self); node.SetTextContent(Some(value)) } } diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs index 8217c91e4f6..0b13916aaea 100644 --- a/components/script/dom/location.rs +++ b/components/script/dom/location.rs @@ -38,15 +38,15 @@ impl Location { } impl<'a> LocationMethods for JSRef<'a, Location> { - fn Href(&self) -> DOMString { + fn Href(self) -> DOMString { UrlHelper::Href(&self.page.get_url()) } - fn Search(&self) -> DOMString { + fn Search(self) -> DOMString { UrlHelper::Search(&self.page.get_url()) } - fn Hash(&self) -> DOMString { + fn Hash(self) -> DOMString { UrlHelper::Hash(&self.page.get_url()) } } diff --git a/components/script/dom/macros.rs b/components/script/dom/macros.rs index 20eb2afea16..c9d7550b7ea 100644 --- a/components/script/dom/macros.rs +++ b/components/script/dom/macros.rs @@ -7,11 +7,11 @@ #[macro_export] macro_rules! make_getter( ( $attr:ident ) => ( - fn $attr(&self) -> DOMString { + fn $attr(self) -> DOMString { use dom::element::{Element, AttributeHandlers}; use dom::bindings::codegen::InheritTypes::ElementCast; use std::ascii::StrAsciiExt; - let element: JSRef = ElementCast::from_ref(*self); + let element: JSRef = ElementCast::from_ref(self); element.get_string_attribute(stringify!($attr).to_ascii_lower().as_slice()) } ); @@ -20,11 +20,11 @@ macro_rules! make_getter( #[macro_export] macro_rules! make_bool_getter( ( $attr:ident ) => ( - fn $attr(&self) -> bool { + fn $attr(self) -> bool { use dom::element::{Element, AttributeHandlers}; use dom::bindings::codegen::InheritTypes::ElementCast; use std::ascii::StrAsciiExt; - let element: JSRef = ElementCast::from_ref(*self); + let element: JSRef = ElementCast::from_ref(self); element.has_attribute(stringify!($attr).to_ascii_lower().as_slice()) } ); @@ -33,11 +33,11 @@ macro_rules! make_bool_getter( #[macro_export] macro_rules! make_uint_getter( ( $attr:ident ) => ( - fn $attr(&self) -> u32 { + fn $attr(self) -> u32 { use dom::element::{Element, AttributeHandlers}; use dom::bindings::codegen::InheritTypes::ElementCast; use std::ascii::StrAsciiExt; - let element: JSRef = ElementCast::from_ref(*self); + let element: JSRef = ElementCast::from_ref(self); element.get_uint_attribute(stringify!($attr).to_ascii_lower().as_slice()) } ); diff --git a/components/script/dom/messageevent.rs b/components/script/dom/messageevent.rs index 50115176f60..ed716b68f59 100644 --- a/components/script/dom/messageevent.rs +++ b/components/script/dom/messageevent.rs @@ -80,15 +80,15 @@ impl MessageEvent { } impl<'a> MessageEventMethods for JSRef<'a, MessageEvent> { - fn Data(&self, _cx: *mut JSContext) -> JSVal { + fn Data(self, _cx: *mut JSContext) -> JSVal { *self.data } - fn Origin(&self) -> DOMString { + fn Origin(self) -> DOMString { self.origin.clone() } - fn LastEventId(&self) -> DOMString { + fn LastEventId(self) -> DOMString { self.lastEventId.clone() } } diff --git a/components/script/dom/mouseevent.rs b/components/script/dom/mouseevent.rs index ba6253e028d..da9377a5718 100644 --- a/components/script/dom/mouseevent.rs +++ b/components/script/dom/mouseevent.rs @@ -104,47 +104,47 @@ impl MouseEvent { } impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> { - fn ScreenX(&self) -> i32 { + fn ScreenX(self) -> i32 { self.screen_x.deref().get() } - fn ScreenY(&self) -> i32 { + fn ScreenY(self) -> i32 { self.screen_y.deref().get() } - fn ClientX(&self) -> i32 { + fn ClientX(self) -> i32 { self.client_x.deref().get() } - fn ClientY(&self) -> i32 { + fn ClientY(self) -> i32 { self.client_y.deref().get() } - fn CtrlKey(&self) -> bool { + fn CtrlKey(self) -> bool { self.ctrl_key.deref().get() } - fn ShiftKey(&self) -> bool { + fn ShiftKey(self) -> bool { self.shift_key.deref().get() } - fn AltKey(&self) -> bool { + fn AltKey(self) -> bool { self.alt_key.deref().get() } - fn MetaKey(&self) -> bool { + fn MetaKey(self) -> bool { self.meta_key.deref().get() } - fn Button(&self) -> i16 { + fn Button(self) -> i16 { self.button.deref().get() } - fn GetRelatedTarget(&self) -> Option> { + fn GetRelatedTarget(self) -> Option> { self.related_target.get().clone().map(|target| Temporary::new(target)) } - fn InitMouseEvent(&self, + fn InitMouseEvent(self, typeArg: DOMString, canBubbleArg: bool, cancelableArg: bool, @@ -160,7 +160,7 @@ impl<'a> MouseEventMethods for JSRef<'a, MouseEvent> { metaKeyArg: bool, buttonArg: i16, relatedTargetArg: Option>) { - let uievent: JSRef = UIEventCast::from_ref(*self); + let uievent: JSRef = UIEventCast::from_ref(self); uievent.InitUIEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg); self.screen_x.deref().set(screenXArg); self.screen_y.deref().set(screenYArg); diff --git a/components/script/dom/namednodemap.rs b/components/script/dom/namednodemap.rs index d6b3c4f9e59..bd4ae4f1008 100644 --- a/components/script/dom/namednodemap.rs +++ b/components/script/dom/namednodemap.rs @@ -33,15 +33,15 @@ impl NamedNodeMap { } impl<'a> NamedNodeMapMethods for JSRef<'a, NamedNodeMap> { - fn Length(&self) -> u32 { + fn Length(self) -> u32 { self.owner.root().attrs.borrow().len() as u32 } - fn Item(&self, index: u32) -> Option> { + fn Item(self, index: u32) -> Option> { self.owner.root().attrs.borrow().as_slice().get(index as uint).map(|x| Temporary::new(x.clone())) } - fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + fn IndexedGetter(self, index: u32, found: &mut bool) -> Option> { let item = self.Item(index); *found = item.is_some(); item diff --git a/components/script/dom/navigator.rs b/components/script/dom/navigator.rs index 06b6c90f57b..ba01be87ff0 100644 --- a/components/script/dom/navigator.rs +++ b/components/script/dom/navigator.rs @@ -32,23 +32,23 @@ impl Navigator { } impl<'a> NavigatorMethods for JSRef<'a, Navigator> { - fn Product(&self) -> DOMString { + fn Product(self) -> DOMString { NavigatorInfo::Product() } - fn TaintEnabled(&self) -> bool { + fn TaintEnabled(self) -> bool { NavigatorInfo::TaintEnabled() } - fn AppName(&self) -> DOMString { + fn AppName(self) -> DOMString { NavigatorInfo::AppName() } - fn AppCodeName(&self) -> DOMString { + fn AppCodeName(self) -> DOMString { NavigatorInfo::AppCodeName() } - fn Platform(&self) -> DOMString { + fn Platform(self) -> DOMString { NavigatorInfo::Platform() } } diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index a95123d0bc7..786445bf628 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1485,7 +1485,7 @@ impl Node { impl<'a> NodeMethods for JSRef<'a, Node> { // http://dom.spec.whatwg.org/#dom-node-nodetype - fn NodeType(&self) -> u16 { + fn NodeType(self) -> u16 { match self.type_id { ElementNodeTypeId(_) => NodeConstants::ELEMENT_NODE, TextNodeTypeId => NodeConstants::TEXT_NODE, @@ -1498,21 +1498,21 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-nodename - fn NodeName(&self) -> DOMString { + fn NodeName(self) -> DOMString { match self.type_id { ElementNodeTypeId(..) => { - let elem: JSRef = ElementCast::to_ref(*self).unwrap(); + let elem: JSRef = ElementCast::to_ref(self).unwrap(); elem.TagName() } TextNodeTypeId => "#text".to_string(), ProcessingInstructionNodeTypeId => { let processing_instruction: JSRef = - ProcessingInstructionCast::to_ref(*self).unwrap(); + ProcessingInstructionCast::to_ref(self).unwrap(); processing_instruction.Target() } CommentNodeTypeId => "#comment".to_string(), DoctypeNodeTypeId => { - let doctype: JSRef = DocumentTypeCast::to_ref(*self).unwrap(); + let doctype: JSRef = DocumentTypeCast::to_ref(self).unwrap(); doctype.deref().name.clone() }, DocumentFragmentNodeTypeId => "#document-fragment".to_string(), @@ -1521,13 +1521,13 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-baseuri - fn GetBaseURI(&self) -> Option { + fn GetBaseURI(self) -> Option { // FIXME (#1824) implement. None } // http://dom.spec.whatwg.org/#dom-node-ownerdocument - fn GetOwnerDocument(&self) -> Option> { + fn GetOwnerDocument(self) -> Option> { match self.type_id { ElementNodeTypeId(..) | CommentNodeTypeId | @@ -1540,12 +1540,12 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-parentnode - fn GetParentNode(&self) -> Option> { + fn GetParentNode(self) -> Option> { self.parent_node.get().map(|node| Temporary::new(node)) } // http://dom.spec.whatwg.org/#dom-node-parentelement - fn GetParentElement(&self) -> Option> { + fn GetParentElement(self) -> Option> { self.parent_node.get() .and_then(|parent| { let parent = parent.root(); @@ -1556,12 +1556,12 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-haschildnodes - fn HasChildNodes(&self) -> bool { + fn HasChildNodes(self) -> bool { self.first_child.get().is_some() } // http://dom.spec.whatwg.org/#dom-node-childnodes - fn ChildNodes(&self) -> Temporary { + fn ChildNodes(self) -> Temporary { match self.child_list.get() { None => (), Some(ref list) => return Temporary::new(list.clone()), @@ -1569,38 +1569,38 @@ impl<'a> NodeMethods for JSRef<'a, Node> { let doc = self.owner_doc().root(); let window = doc.deref().window.root(); - let child_list = NodeList::new_child_list(*window, *self); + let child_list = NodeList::new_child_list(*window, self); self.child_list.assign(Some(child_list)); Temporary::new(self.child_list.get().get_ref().clone()) } // http://dom.spec.whatwg.org/#dom-node-firstchild - fn GetFirstChild(&self) -> Option> { + fn GetFirstChild(self) -> Option> { self.first_child.get().map(|node| Temporary::new(node)) } // http://dom.spec.whatwg.org/#dom-node-lastchild - fn GetLastChild(&self) -> Option> { + fn GetLastChild(self) -> Option> { self.last_child.get().map(|node| Temporary::new(node)) } // http://dom.spec.whatwg.org/#dom-node-previoussibling - fn GetPreviousSibling(&self) -> Option> { + fn GetPreviousSibling(self) -> Option> { self.prev_sibling.get().map(|node| Temporary::new(node)) } // http://dom.spec.whatwg.org/#dom-node-nextsibling - fn GetNextSibling(&self) -> Option> { + fn GetNextSibling(self) -> Option> { self.next_sibling.get().map(|node| Temporary::new(node)) } // http://dom.spec.whatwg.org/#dom-node-nodevalue - fn GetNodeValue(&self) -> Option { + fn GetNodeValue(self) -> Option { match self.type_id { CommentNodeTypeId | TextNodeTypeId | ProcessingInstructionNodeTypeId => { - let chardata: JSRef = CharacterDataCast::to_ref(*self).unwrap(); + let chardata: JSRef = CharacterDataCast::to_ref(self).unwrap(); Some(chardata.Data()) } _ => { @@ -1610,7 +1610,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-nodevalue - fn SetNodeValue(&self, val: Option) { + fn SetNodeValue(self, val: Option) { match self.type_id { CommentNodeTypeId | TextNodeTypeId | @@ -1622,7 +1622,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-textcontent - fn GetTextContent(&self) -> Option { + fn GetTextContent(self) -> Option { match self.type_id { DocumentFragmentNodeTypeId | ElementNodeTypeId(..) => { @@ -1632,7 +1632,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { CommentNodeTypeId | TextNodeTypeId | ProcessingInstructionNodeTypeId => { - let characterdata: JSRef = CharacterDataCast::to_ref(*self).unwrap(); + let characterdata: JSRef = CharacterDataCast::to_ref(self).unwrap(); Some(characterdata.Data()) } DoctypeNodeTypeId | @@ -1643,7 +1643,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-textcontent - fn SetTextContent(&self, value: Option) { + fn SetTextContent(self, value: Option) { let value = null_str_as_empty(&value); match self.type_id { DocumentFragmentNodeTypeId | @@ -1657,14 +1657,14 @@ impl<'a> NodeMethods for JSRef<'a, Node> { }.root(); // Step 3. - Node::replace_all(node.root_ref(), *self); + Node::replace_all(node.root_ref(), self); } CommentNodeTypeId | TextNodeTypeId | ProcessingInstructionNodeTypeId => { self.wait_until_safe_to_modify_dom(); - let characterdata: JSRef = CharacterDataCast::to_ref(*self).unwrap(); + let characterdata: JSRef = CharacterDataCast::to_ref(self).unwrap(); *characterdata.data.deref().borrow_mut() = value; // Notify the document that the content of this node is different @@ -1677,17 +1677,17 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-insertbefore - fn InsertBefore(&self, node: JSRef, child: Option>) -> Fallible> { - Node::pre_insert(node, *self, child) + fn InsertBefore(self, node: JSRef, child: Option>) -> Fallible> { + Node::pre_insert(node, self, child) } // http://dom.spec.whatwg.org/#dom-node-appendchild - fn AppendChild(&self, node: JSRef) -> Fallible> { - Node::pre_insert(node, *self, None) + fn AppendChild(self, node: JSRef) -> Fallible> { + Node::pre_insert(node, self, None) } // http://dom.spec.whatwg.org/#concept-node-replace - fn ReplaceChild(&self, node: JSRef, child: JSRef) -> Fallible> { + fn ReplaceChild(self, node: JSRef, child: JSRef) -> Fallible> { // Step 1. match self.type_id { @@ -1698,7 +1698,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // Step 2. - if node.is_inclusive_ancestor_of(*self) { + if node.is_inclusive_ancestor_of(self) { return Err(HierarchyRequest); } @@ -1789,15 +1789,15 @@ impl<'a> NodeMethods for JSRef<'a, Node> { }; // Step 9. - let document = document_from_node(*self).root(); + let document = document_from_node(self).root(); Node::adopt(node, *document); { // Step 10. - Node::remove(child, *self, Suppressed); + Node::remove(child, self, Suppressed); // Step 11. - Node::insert(node, *self, reference_child, Suppressed); + Node::insert(node, self, reference_child, Suppressed); } // Step 12-14. @@ -1816,13 +1816,13 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-removechild - fn RemoveChild(&self, node: JSRef) + fn RemoveChild(self, node: JSRef) -> Fallible> { - Node::pre_remove(node, *self) + Node::pre_remove(node, self) } // http://dom.spec.whatwg.org/#dom-node-normalize - fn Normalize(&self) { + fn Normalize(self) { let mut prev_text = None; for child in self.children() { if child.is_text() { @@ -1848,15 +1848,15 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-clonenode - fn CloneNode(&self, deep: bool) -> Temporary { + fn CloneNode(self, deep: bool) -> Temporary { match deep { - true => Node::clone(*self, None, CloneChildren), - false => Node::clone(*self, None, DoNotCloneChildren) + true => Node::clone(self, None, CloneChildren), + false => Node::clone(self, None, DoNotCloneChildren) } } // http://dom.spec.whatwg.org/#dom-node-isequalnode - fn IsEqualNode(&self, maybe_node: Option>) -> bool { + fn IsEqualNode(self, maybe_node: Option>) -> bool { fn is_equal_doctype(node: JSRef, other: JSRef) -> bool { let doctype: JSRef = DocumentTypeCast::to_ref(node).unwrap(); let other_doctype: JSRef = DocumentTypeCast::to_ref(other).unwrap(); @@ -1931,13 +1931,13 @@ impl<'a> NodeMethods for JSRef<'a, Node> { // Step 1. None => false, // Step 2-6. - Some(node) => is_equal_node(*self, node) + Some(node) => is_equal_node(self, node) } } // http://dom.spec.whatwg.org/#dom-node-comparedocumentposition - fn CompareDocumentPosition(&self, other: JSRef) -> u16 { - if *self == other { + fn CompareDocumentPosition(self, other: JSRef) -> u16 { + if self == other { // step 2. 0 } else { @@ -1952,7 +1952,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { lastself = ancestor.clone(); } for ancestor in other.ancestors() { - if ancestor == *self { + if ancestor == self { // step 5. return NodeConstants::DOCUMENT_POSITION_CONTAINED_BY + NodeConstants::DOCUMENT_POSITION_FOLLOWING; @@ -1961,7 +1961,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } if lastself != lastother { - let abstract_uint: uintptr_t = as_uintptr(&*self); + let abstract_uint: uintptr_t = as_uintptr(&self); let other_uint: uintptr_t = as_uintptr(&*other); let random = if abstract_uint < other_uint { @@ -1980,7 +1980,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { // step 6. return NodeConstants::DOCUMENT_POSITION_PRECEDING; } - if child == *self { + if child == self { // step 7. return NodeConstants::DOCUMENT_POSITION_FOLLOWING; } @@ -1990,7 +1990,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-contains - fn Contains(&self, maybe_other: Option>) -> bool { + fn Contains(self, maybe_other: Option>) -> bool { match maybe_other { None => false, Some(other) => self.is_inclusive_ancestor_of(other) @@ -1998,19 +1998,19 @@ impl<'a> NodeMethods for JSRef<'a, Node> { } // http://dom.spec.whatwg.org/#dom-node-lookupprefix - fn LookupPrefix(&self, _prefix: Option) -> Option { + fn LookupPrefix(self, _prefix: Option) -> Option { // FIXME (#1826) implement. None } // http://dom.spec.whatwg.org/#dom-node-lookupnamespaceuri - fn LookupNamespaceURI(&self, _namespace: Option) -> Option { + fn LookupNamespaceURI(self, _namespace: Option) -> Option { // FIXME (#1826) implement. None } // http://dom.spec.whatwg.org/#dom-node-isdefaultnamespace - fn IsDefaultNamespace(&self, _namespace: Option) -> bool { + fn IsDefaultNamespace(self, _namespace: Option) -> bool { // FIXME (#1826) implement. false } diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index 0fbc6d47b79..1691a4cbd0f 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -48,7 +48,7 @@ impl NodeList { } impl<'a> NodeListMethods for JSRef<'a, NodeList> { - fn Length(&self) -> u32 { + fn Length(self) -> u32 { match self.list_type { Simple(ref elems) => elems.len() as u32, Children(ref node) => { @@ -58,7 +58,7 @@ impl<'a> NodeListMethods for JSRef<'a, NodeList> { } } - fn Item(&self, index: u32) -> Option> { + fn Item(self, index: u32) -> Option> { match self.list_type { _ if index >= self.Length() => None, Simple(ref elems) => Some(Temporary::new(elems[index as uint].clone())), @@ -70,7 +70,7 @@ impl<'a> NodeListMethods for JSRef<'a, NodeList> { } } - fn IndexedGetter(&self, index: u32, found: &mut bool) -> Option> { + fn IndexedGetter(self, index: u32, found: &mut bool) -> Option> { let item = self.Item(index); *found = item.is_some(); item diff --git a/components/script/dom/performance.rs b/components/script/dom/performance.rs index 7aafb604a9a..1916e86db4c 100644 --- a/components/script/dom/performance.rs +++ b/components/script/dom/performance.rs @@ -36,11 +36,11 @@ impl Performance { } impl<'a> PerformanceMethods for JSRef<'a, Performance> { - fn Timing(&self) -> Temporary { + fn Timing(self) -> Temporary { Temporary::new(self.timing.clone()) } - fn Now(&self) -> DOMHighResTimeStamp { + fn Now(self) -> DOMHighResTimeStamp { let navStart = self.timing.root().NavigationStartPrecise() as f64; (time::precise_time_s() - navStart) as DOMHighResTimeStamp } diff --git a/components/script/dom/performancetiming.rs b/components/script/dom/performancetiming.rs index 99ed766073c..299c6eb6b16 100644 --- a/components/script/dom/performancetiming.rs +++ b/components/script/dom/performancetiming.rs @@ -37,7 +37,7 @@ impl PerformanceTiming { } impl<'a> PerformanceTimingMethods for JSRef<'a, PerformanceTiming> { - fn NavigationStart(&self) -> u64 { + fn NavigationStart(self) -> u64 { self.navigationStart } } diff --git a/components/script/dom/processinginstruction.rs b/components/script/dom/processinginstruction.rs index a22261dbca1..b15bc9c4ef0 100644 --- a/components/script/dom/processinginstruction.rs +++ b/components/script/dom/processinginstruction.rs @@ -42,7 +42,7 @@ impl ProcessingInstruction { } impl<'a> ProcessingInstructionMethods for JSRef<'a, ProcessingInstruction> { - fn Target(&self) -> DOMString { + fn Target(self) -> DOMString { self.target.clone() } } diff --git a/components/script/dom/progressevent.rs b/components/script/dom/progressevent.rs index 3a775bc6f04..d9012f99efe 100644 --- a/components/script/dom/progressevent.rs +++ b/components/script/dom/progressevent.rs @@ -58,13 +58,13 @@ impl ProgressEvent { } impl<'a> ProgressEventMethods for JSRef<'a, ProgressEvent> { - fn LengthComputable(&self) -> bool { + fn LengthComputable(self) -> bool { self.length_computable } - fn Loaded(&self) -> u64{ + fn Loaded(self) -> u64{ self.loaded } - fn Total(&self) -> u64 { + fn Total(self) -> u64 { self.total } } diff --git a/components/script/dom/range.rs b/components/script/dom/range.rs index 9c3bfc1cadc..98a33f8ca59 100644 --- a/components/script/dom/range.rs +++ b/components/script/dom/range.rs @@ -39,7 +39,7 @@ impl Range { impl<'a> RangeMethods for JSRef<'a, Range> { /// http://dom.spec.whatwg.org/#dom-range-detach - fn Detach(&self) { + fn Detach(self) { // This method intentionally left blank. } } diff --git a/components/script/dom/screen.rs b/components/script/dom/screen.rs index 464ee905b14..019436d77fb 100644 --- a/components/script/dom/screen.rs +++ b/components/script/dom/screen.rs @@ -30,11 +30,11 @@ impl Screen { } impl<'a> ScreenMethods for JSRef<'a, Screen> { - fn ColorDepth(&self) -> u32 { + fn ColorDepth(self) -> u32 { 24 } - fn PixelDepth(&self) -> u32 { + fn PixelDepth(self) -> u32 { 24 } } diff --git a/components/script/dom/testbinding.rs b/components/script/dom/testbinding.rs index 9f3e9de384c..057897807d2 100644 --- a/components/script/dom/testbinding.rs +++ b/components/script/dom/testbinding.rs @@ -26,265 +26,265 @@ pub struct TestBinding { } impl<'a> TestBindingMethods for JSRef<'a, TestBinding> { - fn BooleanAttribute(&self) -> bool { false } - fn SetBooleanAttribute(&self, _: bool) {} - fn ByteAttribute(&self) -> i8 { 0 } - fn SetByteAttribute(&self, _: i8) {} - fn OctetAttribute(&self) -> u8 { 0 } - fn SetOctetAttribute(&self, _: u8) {} - fn ShortAttribute(&self) -> i16 { 0 } - fn SetShortAttribute(&self, _: i16) {} - fn UnsignedShortAttribute(&self) -> u16 { 0 } - fn SetUnsignedShortAttribute(&self, _: u16) {} - fn LongAttribute(&self) -> i32 { 0 } - fn SetLongAttribute(&self, _: i32) {} - fn UnsignedLongAttribute(&self) -> u32 { 0 } - fn SetUnsignedLongAttribute(&self, _: u32) {} - fn LongLongAttribute(&self) -> i64 { 0 } - fn SetLongLongAttribute(&self, _: i64) {} - fn UnsignedLongLongAttribute(&self) -> u64 { 0 } - fn SetUnsignedLongLongAttribute(&self, _: u64) {} - fn FloatAttribute(&self) -> f32 { 0. } - fn SetFloatAttribute(&self, _: f32) {} - fn DoubleAttribute(&self) -> f64 { 0. } - fn SetDoubleAttribute(&self, _: f64) {} - fn StringAttribute(&self) -> DOMString { "".to_string() } - fn SetStringAttribute(&self, _: DOMString) {} - fn ByteStringAttribute(&self) -> ByteString { ByteString::new(vec!()) } - fn SetByteStringAttribute(&self, _: ByteString) {} - fn EnumAttribute(&self) -> TestEnum { _empty } - fn SetEnumAttribute(&self, _: TestEnum) {} - fn InterfaceAttribute(&self) -> Temporary { + fn BooleanAttribute(self) -> bool { false } + fn SetBooleanAttribute(self, _: bool) {} + fn ByteAttribute(self) -> i8 { 0 } + fn SetByteAttribute(self, _: i8) {} + fn OctetAttribute(self) -> u8 { 0 } + fn SetOctetAttribute(self, _: u8) {} + fn ShortAttribute(self) -> i16 { 0 } + fn SetShortAttribute(self, _: i16) {} + fn UnsignedShortAttribute(self) -> u16 { 0 } + fn SetUnsignedShortAttribute(self, _: u16) {} + fn LongAttribute(self) -> i32 { 0 } + fn SetLongAttribute(self, _: i32) {} + fn UnsignedLongAttribute(self) -> u32 { 0 } + fn SetUnsignedLongAttribute(self, _: u32) {} + fn LongLongAttribute(self) -> i64 { 0 } + fn SetLongLongAttribute(self, _: i64) {} + fn UnsignedLongLongAttribute(self) -> u64 { 0 } + fn SetUnsignedLongLongAttribute(self, _: u64) {} + fn FloatAttribute(self) -> f32 { 0. } + fn SetFloatAttribute(self, _: f32) {} + fn DoubleAttribute(self) -> f64 { 0. } + fn SetDoubleAttribute(self, _: f64) {} + fn StringAttribute(self) -> DOMString { "".to_string() } + fn SetStringAttribute(self, _: DOMString) {} + fn ByteStringAttribute(self) -> ByteString { ByteString::new(vec!()) } + fn SetByteStringAttribute(self, _: ByteString) {} + fn EnumAttribute(self) -> TestEnum { _empty } + fn SetEnumAttribute(self, _: TestEnum) {} + fn InterfaceAttribute(self) -> Temporary { let global = self.global.root(); Blob::new(&global.root_ref()) } - fn SetInterfaceAttribute(&self, _: JSRef) {} - fn UnionAttribute(&self) -> HTMLElementOrLong { eLong(0) } - fn SetUnionAttribute(&self, _: HTMLElementOrLong) {} - fn Union2Attribute(&self) -> EventOrString { eString("".to_string()) } - fn SetUnion2Attribute(&self, _: EventOrString) {} - fn AnyAttribute(&self, _: *mut JSContext) -> JSVal { NullValue() } - fn SetAnyAttribute(&self, _: *mut JSContext, _: JSVal) {} + fn SetInterfaceAttribute(self, _: JSRef) {} + fn UnionAttribute(self) -> HTMLElementOrLong { eLong(0) } + fn SetUnionAttribute(self, _: HTMLElementOrLong) {} + fn Union2Attribute(self) -> EventOrString { eString("".to_string()) } + fn SetUnion2Attribute(self, _: EventOrString) {} + fn AnyAttribute(self, _: *mut JSContext) -> JSVal { NullValue() } + fn SetAnyAttribute(self, _: *mut JSContext, _: JSVal) {} - fn GetBooleanAttributeNullable(&self) -> Option { Some(false) } - fn SetBooleanAttributeNullable(&self, _: Option) {} - fn GetByteAttributeNullable(&self) -> Option { Some(0) } - fn SetByteAttributeNullable(&self, _: Option) {} - fn GetOctetAttributeNullable(&self) -> Option { Some(0) } - fn SetOctetAttributeNullable(&self, _: Option) {} - fn GetShortAttributeNullable(&self) -> Option { Some(0) } - fn SetShortAttributeNullable(&self, _: Option) {} - fn GetUnsignedShortAttributeNullable(&self) -> Option { Some(0) } - fn SetUnsignedShortAttributeNullable(&self, _: Option) {} - fn GetLongAttributeNullable(&self) -> Option { Some(0) } - fn SetLongAttributeNullable(&self, _: Option) {} - fn GetUnsignedLongAttributeNullable(&self) -> Option { Some(0) } - fn SetUnsignedLongAttributeNullable(&self, _: Option) {} - fn GetLongLongAttributeNullable(&self) -> Option { Some(0) } - fn SetLongLongAttributeNullable(&self, _: Option) {} - fn GetUnsignedLongLongAttributeNullable(&self) -> Option { Some(0) } - fn SetUnsignedLongLongAttributeNullable(&self, _: Option) {} - fn GetFloatAttributeNullable(&self) -> Option { Some(0.) } - fn SetFloatAttributeNullable(&self, _: Option) {} - fn GetDoubleAttributeNullable(&self) -> Option { Some(0.) } - fn SetDoubleAttributeNullable(&self, _: Option) {} - fn GetByteStringAttributeNullable(&self) -> Option { Some(ByteString::new(vec!())) } - fn SetByteStringAttributeNullable(&self, _: Option) {} - fn GetStringAttributeNullable(&self) -> Option { Some("".to_string()) } - fn SetStringAttributeNullable(&self, _: Option) {} - fn GetEnumAttributeNullable(&self) -> Option { Some(_empty) } - fn GetInterfaceAttributeNullable(&self) -> Option> { + fn GetBooleanAttributeNullable(self) -> Option { Some(false) } + fn SetBooleanAttributeNullable(self, _: Option) {} + fn GetByteAttributeNullable(self) -> Option { Some(0) } + fn SetByteAttributeNullable(self, _: Option) {} + fn GetOctetAttributeNullable(self) -> Option { Some(0) } + fn SetOctetAttributeNullable(self, _: Option) {} + fn GetShortAttributeNullable(self) -> Option { Some(0) } + fn SetShortAttributeNullable(self, _: Option) {} + fn GetUnsignedShortAttributeNullable(self) -> Option { Some(0) } + fn SetUnsignedShortAttributeNullable(self, _: Option) {} + fn GetLongAttributeNullable(self) -> Option { Some(0) } + fn SetLongAttributeNullable(self, _: Option) {} + fn GetUnsignedLongAttributeNullable(self) -> Option { Some(0) } + fn SetUnsignedLongAttributeNullable(self, _: Option) {} + fn GetLongLongAttributeNullable(self) -> Option { Some(0) } + fn SetLongLongAttributeNullable(self, _: Option) {} + fn GetUnsignedLongLongAttributeNullable(self) -> Option { Some(0) } + fn SetUnsignedLongLongAttributeNullable(self, _: Option) {} + fn GetFloatAttributeNullable(self) -> Option { Some(0.) } + fn SetFloatAttributeNullable(self, _: Option) {} + fn GetDoubleAttributeNullable(self) -> Option { Some(0.) } + fn SetDoubleAttributeNullable(self, _: Option) {} + fn GetByteStringAttributeNullable(self) -> Option { Some(ByteString::new(vec!())) } + fn SetByteStringAttributeNullable(self, _: Option) {} + fn GetStringAttributeNullable(self) -> Option { Some("".to_string()) } + fn SetStringAttributeNullable(self, _: Option) {} + fn GetEnumAttributeNullable(self) -> Option { Some(_empty) } + fn GetInterfaceAttributeNullable(self) -> Option> { let global = self.global.root(); Some(Blob::new(&global.root_ref())) } - fn SetInterfaceAttributeNullable(&self, _: Option>) {} - fn GetUnionAttributeNullable(&self) -> Option { Some(eLong(0)) } - fn SetUnionAttributeNullable(&self, _: Option) {} - fn GetUnion2AttributeNullable(&self) -> Option { Some(eString("".to_string())) } - fn SetUnion2AttributeNullable(&self, _: Option) {} - fn ReceiveVoid(&self) -> () {} - fn ReceiveBoolean(&self) -> bool { false } - fn ReceiveByte(&self) -> i8 { 0 } - fn ReceiveOctet(&self) -> u8 { 0 } - fn ReceiveShort(&self) -> i16 { 0 } - fn ReceiveUnsignedShort(&self) -> u16 { 0 } - fn ReceiveLong(&self) -> i32 { 0 } - fn ReceiveUnsignedLong(&self) -> u32 { 0 } - fn ReceiveLongLong(&self) -> i64 { 0 } - fn ReceiveUnsignedLongLong(&self) -> u64 { 0 } - fn ReceiveFloat(&self) -> f32 { 0. } - fn ReceiveDouble(&self) -> f64 { 0. } - fn ReceiveString(&self) -> DOMString { "".to_string() } - fn ReceiveByteString(&self) -> ByteString { ByteString::new(vec!()) } - fn ReceiveEnum(&self) -> TestEnum { _empty } - fn ReceiveInterface(&self) -> Temporary { + fn SetInterfaceAttributeNullable(self, _: Option>) {} + fn GetUnionAttributeNullable(self) -> Option { Some(eLong(0)) } + fn SetUnionAttributeNullable(self, _: Option) {} + fn GetUnion2AttributeNullable(self) -> Option { Some(eString("".to_string())) } + fn SetUnion2AttributeNullable(self, _: Option) {} + fn ReceiveVoid(self) -> () {} + fn ReceiveBoolean(self) -> bool { false } + fn ReceiveByte(self) -> i8 { 0 } + fn ReceiveOctet(self) -> u8 { 0 } + fn ReceiveShort(self) -> i16 { 0 } + fn ReceiveUnsignedShort(self) -> u16 { 0 } + fn ReceiveLong(self) -> i32 { 0 } + fn ReceiveUnsignedLong(self) -> u32 { 0 } + fn ReceiveLongLong(self) -> i64 { 0 } + fn ReceiveUnsignedLongLong(self) -> u64 { 0 } + fn ReceiveFloat(self) -> f32 { 0. } + fn ReceiveDouble(self) -> f64 { 0. } + fn ReceiveString(self) -> DOMString { "".to_string() } + fn ReceiveByteString(self) -> ByteString { ByteString::new(vec!()) } + fn ReceiveEnum(self) -> TestEnum { _empty } + fn ReceiveInterface(self) -> Temporary { let global = self.global.root(); Blob::new(&global.root_ref()) } - fn ReceiveAny(&self, _: *mut JSContext) -> JSVal { NullValue() } - fn ReceiveUnion(&self) -> HTMLElementOrLong { eLong(0) } - fn ReceiveUnion2(&self) -> EventOrString { eString("".to_string()) } + fn ReceiveAny(self, _: *mut JSContext) -> JSVal { NullValue() } + fn ReceiveUnion(self) -> HTMLElementOrLong { eLong(0) } + fn ReceiveUnion2(self) -> EventOrString { eString("".to_string()) } - fn ReceiveNullableBoolean(&self) -> Option { Some(false) } - fn ReceiveNullableByte(&self) -> Option { Some(0) } - fn ReceiveNullableOctet(&self) -> Option { Some(0) } - fn ReceiveNullableShort(&self) -> Option { Some(0) } - fn ReceiveNullableUnsignedShort(&self) -> Option { Some(0) } - fn ReceiveNullableLong(&self) -> Option { Some(0) } - fn ReceiveNullableUnsignedLong(&self) -> Option { Some(0) } - fn ReceiveNullableLongLong(&self) -> Option { Some(0) } - fn ReceiveNullableUnsignedLongLong(&self) -> Option { Some(0) } - fn ReceiveNullableFloat(&self) -> Option { Some(0.) } - fn ReceiveNullableDouble(&self) -> Option { Some(0.) } - fn ReceiveNullableString(&self) -> Option { Some("".to_string()) } - fn ReceiveNullableByteString(&self) -> Option { Some(ByteString::new(vec!())) } - fn ReceiveNullableEnum(&self) -> Option { Some(_empty) } - fn ReceiveNullableInterface(&self) -> Option> { + fn ReceiveNullableBoolean(self) -> Option { Some(false) } + fn ReceiveNullableByte(self) -> Option { Some(0) } + fn ReceiveNullableOctet(self) -> Option { Some(0) } + fn ReceiveNullableShort(self) -> Option { Some(0) } + fn ReceiveNullableUnsignedShort(self) -> Option { Some(0) } + fn ReceiveNullableLong(self) -> Option { Some(0) } + fn ReceiveNullableUnsignedLong(self) -> Option { Some(0) } + fn ReceiveNullableLongLong(self) -> Option { Some(0) } + fn ReceiveNullableUnsignedLongLong(self) -> Option { Some(0) } + fn ReceiveNullableFloat(self) -> Option { Some(0.) } + fn ReceiveNullableDouble(self) -> Option { Some(0.) } + fn ReceiveNullableString(self) -> Option { Some("".to_string()) } + fn ReceiveNullableByteString(self) -> Option { Some(ByteString::new(vec!())) } + fn ReceiveNullableEnum(self) -> Option { Some(_empty) } + fn ReceiveNullableInterface(self) -> Option> { let global = self.global.root(); Some(Blob::new(&global.root_ref())) } - fn ReceiveNullableUnion(&self) -> Option { Some(eLong(0)) } - fn ReceiveNullableUnion2(&self) -> Option { Some(eString("".to_string())) } + fn ReceiveNullableUnion(self) -> Option { Some(eLong(0)) } + fn ReceiveNullableUnion2(self) -> Option { Some(eString("".to_string())) } - fn PassBoolean(&self, _: bool) {} - fn PassByte(&self, _: i8) {} - fn PassOctet(&self, _: u8) {} - fn PassShort(&self, _: i16) {} - fn PassUnsignedShort(&self, _: u16) {} - fn PassLong(&self, _: i32) {} - fn PassUnsignedLong(&self, _: u32) {} - fn PassLongLong(&self, _: i64) {} - fn PassUnsignedLongLong(&self, _: u64) {} - fn PassFloat(&self, _: f32) {} - fn PassDouble(&self, _: f64) {} - fn PassString(&self, _: DOMString) {} - fn PassByteString(&self, _: ByteString) {} - fn PassEnum(&self, _: TestEnum) {} - fn PassInterface(&self, _: JSRef) {} - fn PassUnion(&self, _: HTMLElementOrLong) {} - fn PassUnion2(&self, _: EventOrString) {} - fn PassUnion3(&self, _: BlobOrString) {} - fn PassAny(&self, _: *mut JSContext, _: JSVal) {} + fn PassBoolean(self, _: bool) {} + fn PassByte(self, _: i8) {} + fn PassOctet(self, _: u8) {} + fn PassShort(self, _: i16) {} + fn PassUnsignedShort(self, _: u16) {} + fn PassLong(self, _: i32) {} + fn PassUnsignedLong(self, _: u32) {} + fn PassLongLong(self, _: i64) {} + fn PassUnsignedLongLong(self, _: u64) {} + fn PassFloat(self, _: f32) {} + fn PassDouble(self, _: f64) {} + fn PassString(self, _: DOMString) {} + fn PassByteString(self, _: ByteString) {} + fn PassEnum(self, _: TestEnum) {} + fn PassInterface(self, _: JSRef) {} + fn PassUnion(self, _: HTMLElementOrLong) {} + fn PassUnion2(self, _: EventOrString) {} + fn PassUnion3(self, _: BlobOrString) {} + fn PassAny(self, _: *mut JSContext, _: JSVal) {} - fn PassNullableBoolean(&self, _: Option) {} - fn PassNullableByte(&self, _: Option) {} - fn PassNullableOctet(&self, _: Option) {} - fn PassNullableShort(&self, _: Option) {} - fn PassNullableUnsignedShort(&self, _: Option) {} - fn PassNullableLong(&self, _: Option) {} - fn PassNullableUnsignedLong(&self, _: Option) {} - fn PassNullableLongLong(&self, _: Option) {} - fn PassNullableUnsignedLongLong(&self, _: Option) {} - fn PassNullableFloat(&self, _: Option) {} - fn PassNullableDouble(&self, _: Option) {} - fn PassNullableString(&self, _: Option) {} - fn PassNullableByteString(&self, _: Option) {} - // fn PassNullableEnum(&self, _: Option) {} - fn PassNullableInterface(&self, _: Option>) {} - fn PassNullableUnion(&self, _: Option) {} - fn PassNullableUnion2(&self, _: Option) {} + fn PassNullableBoolean(self, _: Option) {} + fn PassNullableByte(self, _: Option) {} + fn PassNullableOctet(self, _: Option) {} + fn PassNullableShort(self, _: Option) {} + fn PassNullableUnsignedShort(self, _: Option) {} + fn PassNullableLong(self, _: Option) {} + fn PassNullableUnsignedLong(self, _: Option) {} + fn PassNullableLongLong(self, _: Option) {} + fn PassNullableUnsignedLongLong(self, _: Option) {} + fn PassNullableFloat(self, _: Option) {} + fn PassNullableDouble(self, _: Option) {} + fn PassNullableString(self, _: Option) {} + fn PassNullableByteString(self, _: Option) {} + // fn PassNullableEnum(self, _: Option) {} + fn PassNullableInterface(self, _: Option>) {} + fn PassNullableUnion(self, _: Option) {} + fn PassNullableUnion2(self, _: Option) {} - fn PassOptionalBoolean(&self, _: Option) {} - fn PassOptionalByte(&self, _: Option) {} - fn PassOptionalOctet(&self, _: Option) {} - fn PassOptionalShort(&self, _: Option) {} - fn PassOptionalUnsignedShort(&self, _: Option) {} - fn PassOptionalLong(&self, _: Option) {} - fn PassOptionalUnsignedLong(&self, _: Option) {} - fn PassOptionalLongLong(&self, _: Option) {} - fn PassOptionalUnsignedLongLong(&self, _: Option) {} - fn PassOptionalFloat(&self, _: Option) {} - fn PassOptionalDouble(&self, _: Option) {} - fn PassOptionalString(&self, _: Option) {} - fn PassOptionalByteString(&self, _: Option) {} - fn PassOptionalEnum(&self, _: Option) {} - fn PassOptionalInterface(&self, _: Option>) {} - fn PassOptionalUnion(&self, _: Option) {} - fn PassOptionalUnion2(&self, _: Option) {} - fn PassOptionalAny(&self, _: *mut JSContext, _: JSVal) {} + fn PassOptionalBoolean(self, _: Option) {} + fn PassOptionalByte(self, _: Option) {} + fn PassOptionalOctet(self, _: Option) {} + fn PassOptionalShort(self, _: Option) {} + fn PassOptionalUnsignedShort(self, _: Option) {} + fn PassOptionalLong(self, _: Option) {} + fn PassOptionalUnsignedLong(self, _: Option) {} + fn PassOptionalLongLong(self, _: Option) {} + fn PassOptionalUnsignedLongLong(self, _: Option) {} + fn PassOptionalFloat(self, _: Option) {} + fn PassOptionalDouble(self, _: Option) {} + fn PassOptionalString(self, _: Option) {} + fn PassOptionalByteString(self, _: Option) {} + fn PassOptionalEnum(self, _: Option) {} + fn PassOptionalInterface(self, _: Option>) {} + fn PassOptionalUnion(self, _: Option) {} + fn PassOptionalUnion2(self, _: Option) {} + fn PassOptionalAny(self, _: *mut JSContext, _: JSVal) {} - fn PassOptionalNullableBoolean(&self, _: Option>) {} - fn PassOptionalNullableByte(&self, _: Option>) {} - fn PassOptionalNullableOctet(&self, _: Option>) {} - fn PassOptionalNullableShort(&self, _: Option>) {} - fn PassOptionalNullableUnsignedShort(&self, _: Option>) {} - fn PassOptionalNullableLong(&self, _: Option>) {} - fn PassOptionalNullableUnsignedLong(&self, _: Option>) {} - fn PassOptionalNullableLongLong(&self, _: Option>) {} - fn PassOptionalNullableUnsignedLongLong(&self, _: Option>) {} - fn PassOptionalNullableFloat(&self, _: Option>) {} - fn PassOptionalNullableDouble(&self, _: Option>) {} - fn PassOptionalNullableString(&self, _: Option>) {} - fn PassOptionalNullableByteString(&self, _: Option>) {} - // fn PassOptionalNullableEnum(&self, _: Option>) {} - fn PassOptionalNullableInterface(&self, _: Option>>) {} - fn PassOptionalNullableUnion(&self, _: Option>) {} - fn PassOptionalNullableUnion2(&self, _: Option>) {} + fn PassOptionalNullableBoolean(self, _: Option>) {} + fn PassOptionalNullableByte(self, _: Option>) {} + fn PassOptionalNullableOctet(self, _: Option>) {} + fn PassOptionalNullableShort(self, _: Option>) {} + fn PassOptionalNullableUnsignedShort(self, _: Option>) {} + fn PassOptionalNullableLong(self, _: Option>) {} + fn PassOptionalNullableUnsignedLong(self, _: Option>) {} + fn PassOptionalNullableLongLong(self, _: Option>) {} + fn PassOptionalNullableUnsignedLongLong(self, _: Option>) {} + fn PassOptionalNullableFloat(self, _: Option>) {} + fn PassOptionalNullableDouble(self, _: Option>) {} + fn PassOptionalNullableString(self, _: Option>) {} + fn PassOptionalNullableByteString(self, _: Option>) {} + // fn PassOptionalNullableEnum(self, _: Option>) {} + fn PassOptionalNullableInterface(self, _: Option>>) {} + fn PassOptionalNullableUnion(self, _: Option>) {} + fn PassOptionalNullableUnion2(self, _: Option>) {} - fn PassOptionalBooleanWithDefault(&self, _: bool) {} - fn PassOptionalByteWithDefault(&self, _: i8) {} - fn PassOptionalOctetWithDefault(&self, _: u8) {} - fn PassOptionalShortWithDefault(&self, _: i16) {} - fn PassOptionalUnsignedShortWithDefault(&self, _: u16) {} - fn PassOptionalLongWithDefault(&self, _: i32) {} - fn PassOptionalUnsignedLongWithDefault(&self, _: u32) {} - fn PassOptionalLongLongWithDefault(&self, _: i64) {} - fn PassOptionalUnsignedLongLongWithDefault(&self, _: u64) {} - fn PassOptionalStringWithDefault(&self, _: DOMString) {} - fn PassOptionalEnumWithDefault(&self, _: TestEnum) {} + fn PassOptionalBooleanWithDefault(self, _: bool) {} + fn PassOptionalByteWithDefault(self, _: i8) {} + fn PassOptionalOctetWithDefault(self, _: u8) {} + fn PassOptionalShortWithDefault(self, _: i16) {} + fn PassOptionalUnsignedShortWithDefault(self, _: u16) {} + fn PassOptionalLongWithDefault(self, _: i32) {} + fn PassOptionalUnsignedLongWithDefault(self, _: u32) {} + fn PassOptionalLongLongWithDefault(self, _: i64) {} + fn PassOptionalUnsignedLongLongWithDefault(self, _: u64) {} + fn PassOptionalStringWithDefault(self, _: DOMString) {} + fn PassOptionalEnumWithDefault(self, _: TestEnum) {} - fn PassOptionalNullableBooleanWithDefault(&self, _: Option) {} - fn PassOptionalNullableByteWithDefault(&self, _: Option) {} - fn PassOptionalNullableOctetWithDefault(&self, _: Option) {} - fn PassOptionalNullableShortWithDefault(&self, _: Option) {} - fn PassOptionalNullableUnsignedShortWithDefault(&self, _: Option) {} - fn PassOptionalNullableLongWithDefault(&self, _: Option) {} - fn PassOptionalNullableUnsignedLongWithDefault(&self, _: Option) {} - fn PassOptionalNullableLongLongWithDefault(&self, _: Option) {} - fn PassOptionalNullableUnsignedLongLongWithDefault(&self, _: Option) {} - // fn PassOptionalNullableFloatWithDefault(&self, _: Option) {} - // fn PassOptionalNullableDoubleWithDefault(&self, _: Option) {} - fn PassOptionalNullableStringWithDefault(&self, _: Option) {} - fn PassOptionalNullableByteStringWithDefault(&self, _: Option) {} - // fn PassOptionalNullableEnumWithDefault(&self, _: Option) {} - fn PassOptionalNullableInterfaceWithDefault(&self, _: Option>) {} - fn PassOptionalNullableUnionWithDefault(&self, _: Option) {} - fn PassOptionalNullableUnion2WithDefault(&self, _: Option) {} - fn PassOptionalAnyWithDefault(&self, _: *mut JSContext, _: JSVal) {} + fn PassOptionalNullableBooleanWithDefault(self, _: Option) {} + fn PassOptionalNullableByteWithDefault(self, _: Option) {} + fn PassOptionalNullableOctetWithDefault(self, _: Option) {} + fn PassOptionalNullableShortWithDefault(self, _: Option) {} + fn PassOptionalNullableUnsignedShortWithDefault(self, _: Option) {} + fn PassOptionalNullableLongWithDefault(self, _: Option) {} + fn PassOptionalNullableUnsignedLongWithDefault(self, _: Option) {} + fn PassOptionalNullableLongLongWithDefault(self, _: Option) {} + fn PassOptionalNullableUnsignedLongLongWithDefault(self, _: Option) {} + // fn PassOptionalNullableFloatWithDefault(self, _: Option) {} + // fn PassOptionalNullableDoubleWithDefault(self, _: Option) {} + fn PassOptionalNullableStringWithDefault(self, _: Option) {} + fn PassOptionalNullableByteStringWithDefault(self, _: Option) {} + // fn PassOptionalNullableEnumWithDefault(self, _: Option) {} + fn PassOptionalNullableInterfaceWithDefault(self, _: Option>) {} + fn PassOptionalNullableUnionWithDefault(self, _: Option) {} + fn PassOptionalNullableUnion2WithDefault(self, _: Option) {} + fn PassOptionalAnyWithDefault(self, _: *mut JSContext, _: JSVal) {} - fn PassOptionalNullableBooleanWithNonNullDefault(&self, _: Option) {} - fn PassOptionalNullableByteWithNonNullDefault(&self, _: Option) {} - fn PassOptionalNullableOctetWithNonNullDefault(&self, _: Option) {} - fn PassOptionalNullableShortWithNonNullDefault(&self, _: Option) {} - fn PassOptionalNullableUnsignedShortWithNonNullDefault(&self, _: Option) {} - fn PassOptionalNullableLongWithNonNullDefault(&self, _: Option) {} - fn PassOptionalNullableUnsignedLongWithNonNullDefault(&self, _: Option) {} - fn PassOptionalNullableLongLongWithNonNullDefault(&self, _: Option) {} - fn PassOptionalNullableUnsignedLongLongWithNonNullDefault(&self, _: Option) {} - // fn PassOptionalNullableFloatWithNonNullDefault(&self, _: Option) {} - // fn PassOptionalNullableDoubleWithNonNullDefault(&self, _: Option) {} - fn PassOptionalNullableStringWithNonNullDefault(&self, _: Option) {} - // fn PassOptionalNullableEnumWithNonNullDefault(&self, _: Option) {} + fn PassOptionalNullableBooleanWithNonNullDefault(self, _: Option) {} + fn PassOptionalNullableByteWithNonNullDefault(self, _: Option) {} + fn PassOptionalNullableOctetWithNonNullDefault(self, _: Option) {} + fn PassOptionalNullableShortWithNonNullDefault(self, _: Option) {} + fn PassOptionalNullableUnsignedShortWithNonNullDefault(self, _: Option) {} + fn PassOptionalNullableLongWithNonNullDefault(self, _: Option) {} + fn PassOptionalNullableUnsignedLongWithNonNullDefault(self, _: Option) {} + fn PassOptionalNullableLongLongWithNonNullDefault(self, _: Option) {} + fn PassOptionalNullableUnsignedLongLongWithNonNullDefault(self, _: Option) {} + // fn PassOptionalNullableFloatWithNonNullDefault(self, _: Option) {} + // fn PassOptionalNullableDoubleWithNonNullDefault(self, _: Option) {} + fn PassOptionalNullableStringWithNonNullDefault(self, _: Option) {} + // fn PassOptionalNullableEnumWithNonNullDefault(self, _: Option) {} - fn PassVariadicBoolean(&self, _: Vec) {} - fn PassVariadicByte(&self, _: Vec) {} - fn PassVariadicOctet(&self, _: Vec) {} - fn PassVariadicShort(&self, _: Vec) {} - fn PassVariadicUnsignedShort(&self, _: Vec) {} - fn PassVariadicLong(&self, _: Vec) {} - fn PassVariadicUnsignedLong(&self, _: Vec) {} - fn PassVariadicLongLong(&self, _: Vec) {} - fn PassVariadicUnsignedLongLong(&self, _: Vec) {} - fn PassVariadicFloat(&self, _: Vec) {} - fn PassVariadicDouble(&self, _: Vec) {} - fn PassVariadicString(&self, _: Vec) {} - fn PassVariadicByteString(&self, _: Vec) {} - fn PassVariadicEnum(&self, _: Vec) {} - // fn PassVariadicInterface(&self, _: Vec>) {} - fn PassVariadicUnion(&self, _: Vec) {} - fn PassVariadicUnion2(&self, _: Vec) {} - fn PassVariadicUnion3(&self, _: Vec) {} - fn PassVariadicAny(&self, _: *mut JSContext, _: Vec) {} + fn PassVariadicBoolean(self, _: Vec) {} + fn PassVariadicByte(self, _: Vec) {} + fn PassVariadicOctet(self, _: Vec) {} + fn PassVariadicShort(self, _: Vec) {} + fn PassVariadicUnsignedShort(self, _: Vec) {} + fn PassVariadicLong(self, _: Vec) {} + fn PassVariadicUnsignedLong(self, _: Vec) {} + fn PassVariadicLongLong(self, _: Vec) {} + fn PassVariadicUnsignedLongLong(self, _: Vec) {} + fn PassVariadicFloat(self, _: Vec) {} + fn PassVariadicDouble(self, _: Vec) {} + fn PassVariadicString(self, _: Vec) {} + fn PassVariadicByteString(self, _: Vec) {} + fn PassVariadicEnum(self, _: Vec) {} + // fn PassVariadicInterface(self, _: Vec>) {} + fn PassVariadicUnion(self, _: Vec) {} + fn PassVariadicUnion2(self, _: Vec) {} + fn PassVariadicUnion3(self, _: Vec) {} + fn PassVariadicAny(self, _: *mut JSContext, _: Vec) {} } impl TestBinding { diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index aa09af45c7c..e1d49be408f 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -69,15 +69,15 @@ impl TreeWalker { } impl<'a> TreeWalkerMethods for JSRef<'a, TreeWalker> { - fn Root(&self) -> Temporary { + fn Root(self) -> Temporary { Temporary::new(self.root_node) } - fn WhatToShow(&self) -> u32 { + fn WhatToShow(self) -> u32 { self.what_to_show } - fn GetFilter(&self) -> Option { + fn GetFilter(self) -> Option { match self.filter { FilterNone => None, FilterJS(nf) => Some(nf), @@ -85,41 +85,41 @@ impl<'a> TreeWalkerMethods for JSRef<'a, TreeWalker> { } } - fn CurrentNode(&self) -> Temporary { + fn CurrentNode(self) -> Temporary { Temporary::new(self.current_node.get()) } - fn SetCurrentNode(&self, node: JSRef) -> ErrorResult { + fn SetCurrentNode(self, node: JSRef) -> ErrorResult { // XXX Future: check_same_origin(root_node, node) (throws) self.current_node.set(JS::from_rooted(node)); Ok(()) } - fn ParentNode(&self) -> Fallible>> { + fn ParentNode(self) -> Fallible>> { self.parent_node() } - fn FirstChild(&self) -> Fallible>> { + fn FirstChild(self) -> Fallible>> { self.first_child() } - fn LastChild(&self) -> Fallible>> { + fn LastChild(self) -> Fallible>> { self.last_child() } - fn PreviousSibling(&self) -> Fallible>> { + fn PreviousSibling(self) -> Fallible>> { self.prev_sibling() } - fn NextSibling(&self) -> Fallible>> { + fn NextSibling(self) -> Fallible>> { self.next_sibling() } - fn PreviousNode(&self) -> Fallible>> { + fn PreviousNode(self) -> Fallible>> { self.prev_node() } - fn NextNode(&self) -> Fallible>> { + fn NextNode(self) -> Fallible>> { self.next_node() } } diff --git a/components/script/dom/uievent.rs b/components/script/dom/uievent.rs index f8f7b59094d..6d51347e000 100644 --- a/components/script/dom/uievent.rs +++ b/components/script/dom/uievent.rs @@ -68,21 +68,21 @@ impl UIEvent { } impl<'a> UIEventMethods for JSRef<'a, UIEvent> { - fn GetView(&self) -> Option> { + fn GetView(self) -> Option> { self.view.get().map(|view| Temporary::new(view)) } - fn Detail(&self) -> i32 { + fn Detail(self) -> i32 { self.detail.deref().get() } - fn InitUIEvent(&self, + fn InitUIEvent(self, type_: DOMString, can_bubble: bool, cancelable: bool, view: Option>, detail: i32) { - let event: JSRef = EventCast::from_ref(*self); + let event: JSRef = EventCast::from_ref(self); event.InitEvent(type_, can_bubble, cancelable); self.view.assign(view); self.detail.deref().set(detail); diff --git a/components/script/dom/urlsearchparams.rs b/components/script/dom/urlsearchparams.rs index 7ac6067862e..ea8d7da7002 100644 --- a/components/script/dom/urlsearchparams.rs +++ b/components/script/dom/urlsearchparams.rs @@ -61,26 +61,26 @@ impl URLSearchParams { } impl<'a> URLSearchParamsMethods for JSRef<'a, URLSearchParams> { - fn Append(&self, name: DOMString, value: DOMString) { + fn Append(self, name: DOMString, value: DOMString) { self.data.deref().borrow_mut().insert_or_update_with(name, vec!(value.clone()), |_k, v| v.push(value.clone())); self.update_steps(); } - fn Delete(&self, name: DOMString) { + fn Delete(self, name: DOMString) { self.data.deref().borrow_mut().remove(&name); self.update_steps(); } - fn Get(&self, name: DOMString) -> Option { + fn Get(self, name: DOMString) -> Option { self.data.deref().borrow().find_equiv(&name).map(|v| v[0].clone()) } - fn Has(&self, name: DOMString) -> bool { + fn Has(self, name: DOMString) -> bool { self.data.deref().borrow().contains_key_equiv(&name) } - fn Set(&self, name: DOMString, value: DOMString) { + fn Set(self, name: DOMString, value: DOMString) { self.data.deref().borrow_mut().insert(name, vec!(value)); self.update_steps(); } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 3c3f79d3da3..fd147aaefdf 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -202,51 +202,51 @@ pub fn base64_atob(atob: DOMString) -> Fallible { impl<'a> WindowMethods for JSRef<'a, Window> { - fn Alert(&self, s: DOMString) { + fn Alert(self, s: DOMString) { // Right now, just print to the console println!("ALERT: {:s}", s); } - fn Close(&self) { + fn Close(self) { let ScriptChan(ref chan) = self.script_chan; chan.send(ExitWindowMsg(self.page.id.clone())); } - fn Document(&self) -> Temporary { + fn Document(self) -> Temporary { let frame = self.page().frame(); Temporary::new(frame.get_ref().document.clone()) } - fn Location(&self) -> Temporary { + fn Location(self) -> Temporary { if self.location.get().is_none() { let page = self.deref().page.clone(); - let location = Location::new(*self, page); + let location = Location::new(self, page); self.location.assign(Some(location)); } Temporary::new(self.location.get().get_ref().clone()) } - fn Console(&self) -> Temporary { + fn Console(self) -> Temporary { if self.console.get().is_none() { - let console = Console::new(&global::Window(*self)); + let console = Console::new(&global::Window(self)); self.console.assign(Some(console)); } Temporary::new(self.console.get().get_ref().clone()) } - fn Navigator(&self) -> Temporary { + fn Navigator(self) -> Temporary { if self.navigator.get().is_none() { - let navigator = Navigator::new(*self); + let navigator = Navigator::new(self); self.navigator.assign(Some(navigator)); } Temporary::new(self.navigator.get().get_ref().clone()) } - fn SetTimeout(&self, _cx: *mut JSContext, callback: JSVal, timeout: i32) -> i32 { + fn SetTimeout(self, _cx: *mut JSContext, callback: JSVal, timeout: i32) -> i32 { self.set_timeout_or_interval(callback, timeout, false) } - fn ClearTimeout(&self, handle: i32) { + fn ClearTimeout(self, handle: i32) { let mut timers = self.active_timers.deref().borrow_mut(); let mut timer_handle = timers.pop(&TimerId(handle)); match timer_handle { @@ -256,103 +256,103 @@ impl<'a> WindowMethods for JSRef<'a, Window> { timers.remove(&TimerId(handle)); } - fn SetInterval(&self, _cx: *mut JSContext, callback: JSVal, timeout: i32) -> i32 { + fn SetInterval(self, _cx: *mut JSContext, callback: JSVal, timeout: i32) -> i32 { self.set_timeout_or_interval(callback, timeout, true) } - fn ClearInterval(&self, handle: i32) { + fn ClearInterval(self, handle: i32) { self.ClearTimeout(handle); } - fn Window(&self) -> Temporary { - Temporary::from_rooted(*self) + fn Window(self) -> Temporary { + Temporary::from_rooted(self) } - fn Self(&self) -> Temporary { + fn Self(self) -> Temporary { self.Window() } // http://www.whatwg.org/html/#dom-frames - fn Frames(&self) -> Temporary { + fn Frames(self) -> Temporary { self.Window() } - fn Parent(&self) -> Temporary { + fn Parent(self) -> Temporary { //TODO - Once we support iframes correctly this needs to return the parent frame self.Window() } - fn Performance(&self) -> Temporary { + fn Performance(self) -> Temporary { if self.performance.get().is_none() { - let performance = Performance::new(*self); + let performance = Performance::new(self); self.performance.assign(Some(performance)); } Temporary::new(self.performance.get().get_ref().clone()) } - fn GetOnclick(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnclick(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("click") } - fn SetOnclick(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnclick(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("click", listener) } - fn GetOnload(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnload(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("load") } - fn SetOnload(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnload(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("load", listener) } - fn GetOnunload(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnunload(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("unload") } - fn SetOnunload(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnunload(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("unload", listener) } - fn GetOnerror(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnerror(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("error") } - fn SetOnerror(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnerror(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("error", listener) } - fn Screen(&self) -> Temporary { + fn Screen(self) -> Temporary { if self.screen.get().is_none() { - let screen = Screen::new(*self); + let screen = Screen::new(self); self.screen.assign(Some(screen)); } Temporary::new(self.screen.get().get_ref().clone()) } - fn Debug(&self, message: DOMString) { + fn Debug(self, message: DOMString) { debug!("{:s}", message); } - fn Gc(&self) { + fn Gc(self) { unsafe { JS_GC(JS_GetRuntime(self.get_cx())); } } - fn Btoa(&self, btoa: DOMString) -> Fallible { + fn Btoa(self, btoa: DOMString) -> Fallible { base64_btoa(btoa) } - fn Atob(&self, atob: DOMString) -> Fallible { + fn Atob(self, atob: DOMString) -> Fallible { base64_atob(atob) } } diff --git a/components/script/dom/worker.rs b/components/script/dom/worker.rs index be7a8ffb34d..af7302a1671 100644 --- a/components/script/dom/worker.rs +++ b/components/script/dom/worker.rs @@ -130,7 +130,7 @@ impl Worker { } impl<'a> WorkerMethods for JSRef<'a, Worker> { - fn PostMessage(&self, cx: *mut JSContext, message: JSVal) { + fn PostMessage(self, cx: *mut JSContext, message: JSVal) { let mut data = ptr::mut_null(); let mut nbytes = 0; unsafe { @@ -143,13 +143,13 @@ impl<'a> WorkerMethods for JSRef<'a, Worker> { sender.send(DOMMessage(data, nbytes)); } - fn GetOnmessage(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnmessage(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("message") } - fn SetOnmessage(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnmessage(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("message", listener) } } diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index b4aa3603ef4..b0df64f0b11 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -79,19 +79,19 @@ impl WorkerGlobalScope { } impl<'a> WorkerGlobalScopeMethods for JSRef<'a, WorkerGlobalScope> { - fn Self(&self) -> Temporary { - Temporary::from_rooted(*self) + fn Self(self) -> Temporary { + Temporary::from_rooted(self) } - fn Location(&self) -> Temporary { + fn Location(self) -> Temporary { if self.location.get().is_none() { - let location = WorkerLocation::new(*self, self.worker_url.deref().clone()); + let location = WorkerLocation::new(self, self.worker_url.deref().clone()); self.location.assign(Some(location)); } Temporary::new(self.location.get().get_ref().clone()) } - fn ImportScripts(&self, url_strings: Vec) -> ErrorResult { + fn ImportScripts(self, url_strings: Vec) -> ErrorResult { let mut urls = Vec::with_capacity(url_strings.len()); for url in url_strings.move_iter() { let url = UrlParser::new().base_url(&*self.worker_url) @@ -123,27 +123,27 @@ impl<'a> WorkerGlobalScopeMethods for JSRef<'a, WorkerGlobalScope> { Ok(()) } - fn Navigator(&self) -> Temporary { + fn Navigator(self) -> Temporary { if self.navigator.get().is_none() { - let navigator = WorkerNavigator::new(*self); + let navigator = WorkerNavigator::new(self); self.navigator.assign(Some(navigator)); } Temporary::new(self.navigator.get().get_ref().clone()) } - fn Console(&self) -> Temporary { + fn Console(self) -> Temporary { if self.console.get().is_none() { - let console = Console::new(&global::Worker(*self)); + let console = Console::new(&global::Worker(self)); self.console.assign(Some(console)); } Temporary::new(self.console.get().get_ref().clone()) } - fn Btoa(&self, btoa: DOMString) -> Fallible { + fn Btoa(self, btoa: DOMString) -> Fallible { base64_btoa(btoa) } - fn Atob(&self, atob: DOMString) -> Fallible { + fn Atob(self, atob: DOMString) -> Fallible { base64_atob(atob) } } diff --git a/components/script/dom/workerlocation.rs b/components/script/dom/workerlocation.rs index f8732a0f7ac..57334953e3d 100644 --- a/components/script/dom/workerlocation.rs +++ b/components/script/dom/workerlocation.rs @@ -38,15 +38,15 @@ impl WorkerLocation { } impl<'a> WorkerLocationMethods for JSRef<'a, WorkerLocation> { - fn Href(&self) -> DOMString { + fn Href(self) -> DOMString { UrlHelper::Href(self.url.deref()) } - fn Search(&self) -> DOMString { + fn Search(self) -> DOMString { UrlHelper::Search(self.url.deref()) } - fn Hash(&self) -> DOMString { + fn Hash(self) -> DOMString { UrlHelper::Hash(self.url.deref()) } } diff --git a/components/script/dom/workernavigator.rs b/components/script/dom/workernavigator.rs index 37de1b91e65..e99e93991b1 100644 --- a/components/script/dom/workernavigator.rs +++ b/components/script/dom/workernavigator.rs @@ -32,23 +32,23 @@ impl WorkerNavigator { } impl<'a> WorkerNavigatorMethods for JSRef<'a, WorkerNavigator> { - fn Product(&self) -> DOMString { + fn Product(self) -> DOMString { NavigatorInfo::Product() } - fn TaintEnabled(&self) -> bool { + fn TaintEnabled(self) -> bool { NavigatorInfo::TaintEnabled() } - fn AppName(&self) -> DOMString { + fn AppName(self) -> DOMString { NavigatorInfo::AppName() } - fn AppCodeName(&self) -> DOMString { + fn AppCodeName(self) -> DOMString { NavigatorInfo::AppCodeName() } - fn Platform(&self) -> DOMString { + fn Platform(self) -> DOMString { NavigatorInfo::Platform() } } diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 3f3be18a4ed..3afbe1ecb72 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -91,8 +91,8 @@ pub enum XHRProgress { TimeoutMsg } -enum SyncOrAsync<'a, 'b> { - Sync(&'b JSRef<'a, XMLHttpRequest>), +enum SyncOrAsync<'a> { + Sync(JSRef<'a, XMLHttpRequest>), Async(TrustedXHRAddress, ScriptChan) } @@ -186,7 +186,7 @@ impl XMLHttpRequest { cors_request: Result,()>) -> ErrorResult { fn notify_partial_progress(fetch_type: &SyncOrAsync, msg: XHRProgress) { match *fetch_type { - Sync(ref xhr) => { + Sync(xhr) => { xhr.process_partial_response(msg); }, Async(addr, ref script_chan) => { @@ -259,21 +259,21 @@ impl XMLHttpRequest { } impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { - fn GetOnreadystatechange(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnreadystatechange(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("readystatechange") } - fn SetOnreadystatechange(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnreadystatechange(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("readystatechange", listener) } - fn ReadyState(&self) -> u16 { + fn ReadyState(self) -> u16 { self.ready_state.deref().get() as u16 } - fn Open(&self, method: ByteString, url: DOMString) -> ErrorResult { + fn Open(self, method: ByteString, url: DOMString) -> ErrorResult { // Clean up from previous requests, if any: self.cancel_timeout(); let uppercase_method = method.as_str().map(|s| { @@ -334,12 +334,12 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { _ => Err(Syntax), // Step 3 } } - fn Open_(&self, method: ByteString, url: DOMString, async: bool, + fn Open_(self, method: ByteString, url: DOMString, async: bool, _username: Option, _password: Option) -> ErrorResult { self.sync.deref().set(!async); self.Open(method, url) } - fn SetRequestHeader(&self, name: ByteString, mut value: ByteString) -> ErrorResult { + fn SetRequestHeader(self, name: ByteString, mut value: ByteString) -> ErrorResult { if self.ready_state.deref().get() != Opened || self.send_flag.deref().get() { return Err(InvalidState); // Step 1, 2 } @@ -403,10 +403,10 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { None => Err(Syntax) } } - fn Timeout(&self) -> u32 { + fn Timeout(self) -> u32 { self.timeout.deref().get() } - fn SetTimeout(&self, timeout: u32) -> ErrorResult { + fn SetTimeout(self, timeout: u32) -> ErrorResult { if self.sync.deref().get() { // FIXME: Not valid for a worker environment Err(InvalidState) @@ -428,16 +428,16 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { Ok(()) } } - fn WithCredentials(&self) -> bool { + fn WithCredentials(self) -> bool { self.with_credentials.deref().get() } - fn SetWithCredentials(&self, with_credentials: bool) { + fn SetWithCredentials(self, with_credentials: bool) { self.with_credentials.deref().set(with_credentials); } - fn Upload(&self) -> Temporary { + fn Upload(self) -> Temporary { Temporary::new(self.upload) } - fn Send(&self, data: Option) -> ErrorResult { + fn Send(self, data: Option) -> ErrorResult { if self.ready_state.deref().get() != Opened || self.send_flag.deref().get() { return Err(InvalidState); // Step 1, 2 } @@ -566,7 +566,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { } Ok(()) } - fn Abort(&self) { + fn Abort(self) { self.terminate_sender.deref().borrow().as_ref().map(|s| s.send_opt(Abort)); match self.ready_state.deref().get() { Opened if self.send_flag.deref().get() => self.process_partial_response(ErroredMsg(Some(Abort))), @@ -575,16 +575,16 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { }; self.ready_state.deref().set(Unsent); } - fn ResponseURL(&self) -> DOMString { + fn ResponseURL(self) -> DOMString { self.response_url.clone() } - fn Status(&self) -> u16 { + fn Status(self) -> u16 { self.status.deref().get() } - fn StatusText(&self) -> ByteString { + fn StatusText(self) -> ByteString { self.status_text.deref().borrow().clone() } - fn GetResponseHeader(&self, name: ByteString) -> Option { + fn GetResponseHeader(self, name: ByteString) -> Option { self.filter_response_headers().iter().find(|h| { name.eq_ignore_case(&FromStr::from_str(h.header_name().as_slice()).unwrap()) }).map(|h| { @@ -592,7 +592,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { ByteString::new(h.header_value().as_slice().chars().map(|c| { assert!(c <= '\u00FF'); c as u8 }).collect()) }) } - fn GetAllResponseHeaders(&self) -> ByteString { + fn GetAllResponseHeaders(self) -> ByteString { let mut writer = MemWriter::new(); self.filter_response_headers().write_all(&mut writer).ok().expect("Writing response headers failed"); let mut vec = writer.unwrap(); @@ -603,10 +603,10 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { ByteString::new(vec) } - fn ResponseType(&self) -> XMLHttpRequestResponseType { + fn ResponseType(self) -> XMLHttpRequestResponseType { self.response_type.deref().get() } - fn SetResponseType(&self, response_type: XMLHttpRequestResponseType) -> ErrorResult { + fn SetResponseType(self, response_type: XMLHttpRequestResponseType) -> ErrorResult { match self.global { WorkerField(_) if response_type == Document => return Ok(()), _ => {} @@ -620,7 +620,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { } } } - fn Response(&self, cx: *mut JSContext) -> JSVal { + fn Response(self, cx: *mut JSContext) -> JSVal { match self.response_type.deref().get() { _empty | Text => { let ready_state = self.ready_state.deref().get(); @@ -649,7 +649,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { } } } - fn GetResponseText(&self) -> Fallible { + fn GetResponseText(self) -> Fallible { match self.response_type.deref().get() { _empty | Text => { match self.ready_state.deref().get() { @@ -660,7 +660,7 @@ impl<'a> XMLHttpRequestMethods for JSRef<'a, XMLHttpRequest> { _ => Err(InvalidState) } } - fn GetResponseXML(&self) -> Option> { + fn GetResponseXML(self) -> Option> { self.response_xml.get().map(|response| Temporary::new(response)) } } diff --git a/components/script/dom/xmlhttprequesteventtarget.rs b/components/script/dom/xmlhttprequesteventtarget.rs index 805cceebc96..66fdf2d77f0 100644 --- a/components/script/dom/xmlhttprequesteventtarget.rs +++ b/components/script/dom/xmlhttprequesteventtarget.rs @@ -41,73 +41,73 @@ impl Reflectable for XMLHttpRequestEventTarget { } impl<'a> XMLHttpRequestEventTargetMethods for JSRef<'a, XMLHttpRequestEventTarget> { - fn GetOnloadstart(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnloadstart(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("loadstart") } - fn SetOnloadstart(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnloadstart(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("loadstart", listener) } - fn GetOnprogress(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnprogress(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("progress") } - fn SetOnprogress(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnprogress(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("progress", listener) } - fn GetOnabort(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnabort(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("abort") } - fn SetOnabort(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnabort(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("abort", listener) } - fn GetOnerror(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnerror(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("error") } - fn SetOnerror(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnerror(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("error", listener) } - fn GetOnload(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnload(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("load") } - fn SetOnload(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnload(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("load", listener) } - fn GetOntimeout(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOntimeout(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("timeout") } - fn SetOntimeout(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOntimeout(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("timeout", listener) } - fn GetOnloadend(&self) -> Option { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn GetOnloadend(self) -> Option { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.get_event_handler_common("loadend") } - fn SetOnloadend(&self, listener: Option) { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn SetOnloadend(self, listener: Option) { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.set_event_handler_common("loadend", listener) } } From d768ee77adab5e5f53b7fb978c07ddbb798e8954 Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Fri, 19 Sep 2014 19:57:50 -0700 Subject: [PATCH 2/3] Convert various helper traits from &JSRef to JSRef I converted them all with a few exceptions: - Methods that were used by trait objects, since trait objects don't work with `self` methods. - Methods that take an &'b JSRef<'a, T> and return an &'b. In reality, many (all?) could return an &'a instead, but this isn't allowed by the Deref trait. - Methods that internally rely on the same issue with Deref. - I left out the traits involved in layout entirely, even though not all of their methods suffer from one of the above problems. There will probably be solutions to all of these problems in the future. --- components/script/dom/attr.rs | 8 +- .../script/dom/dedicatedworkerglobalscope.rs | 4 +- components/script/dom/document.rs | 48 +++++----- components/script/dom/domtokenlist.rs | 8 +- components/script/dom/element.rs | 88 +++++++++---------- components/script/dom/eventtarget.rs | 38 ++++---- components/script/dom/htmlanchorelement.rs | 8 +- components/script/dom/htmlelement.rs | 6 +- components/script/dom/htmliframeelement.rs | 18 ++-- components/script/dom/htmlimageelement.rs | 6 +- components/script/dom/htmllinkelement.rs | 6 +- components/script/dom/htmlscriptelement.rs | 6 +- components/script/dom/htmlstyleelement.rs | 6 +- components/script/dom/performancetiming.rs | 4 +- components/script/dom/treewalker.rs | 54 ++++++------ components/script/dom/window.rs | 32 +++---- components/script/dom/xmlhttprequest.rs | 52 +++++------ 17 files changed, 196 insertions(+), 196 deletions(-) diff --git a/components/script/dom/attr.rs b/components/script/dom/attr.rs index bf6880d1026..2da30a8c58c 100644 --- a/components/script/dom/attr.rs +++ b/components/script/dom/attr.rs @@ -147,14 +147,14 @@ impl<'a> AttrMethods for JSRef<'a, Attr> { } pub trait AttrHelpers { - fn set_value(&self, set_type: AttrSettingType, value: AttrValue); + fn set_value(self, set_type: AttrSettingType, value: AttrValue); fn value<'a>(&'a self) -> Ref<'a, AttrValue>; fn local_name<'a>(&'a self) -> &'a Atom; - fn summarize(&self) -> AttrInfo; + fn summarize(self) -> AttrInfo; } impl<'a> AttrHelpers for JSRef<'a, Attr> { - fn set_value(&self, set_type: AttrSettingType, value: AttrValue) { + fn set_value(self, set_type: AttrSettingType, value: AttrValue) { let owner = self.owner.root(); let node: JSRef = NodeCast::from_ref(*owner); let namespace_is_null = self.namespace == namespace::Null; @@ -187,7 +187,7 @@ impl<'a> AttrHelpers for JSRef<'a, Attr> { &self.local_name } - fn summarize(&self) -> AttrInfo { + fn summarize(self) -> AttrInfo { AttrInfo { namespace: self.namespace.to_str().to_string(), name: self.Name(), diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index f707f6f8d55..4050e157dad 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -175,11 +175,11 @@ impl<'a> DedicatedWorkerGlobalScopeMethods for JSRef<'a, DedicatedWorkerGlobalSc } trait PrivateDedicatedWorkerGlobalScopeHelpers { - fn delayed_release_worker(&self); + fn delayed_release_worker(self); } impl<'a> PrivateDedicatedWorkerGlobalScopeHelpers for JSRef<'a, DedicatedWorkerGlobalScope> { - fn delayed_release_worker(&self) { + fn delayed_release_worker(self) { let ScriptChan(ref sender) = self.parent_sender; sender.send(WorkerRelease(*self.worker)); } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index e9f16bc60e2..601a4c6162c 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -150,16 +150,16 @@ impl CollectionFilter for AppletsFilter { pub trait DocumentHelpers { fn url<'a>(&'a self) -> &'a Url; - fn quirks_mode(&self) -> QuirksMode; - fn set_quirks_mode(&self, mode: QuirksMode); - fn set_last_modified(&self, value: DOMString); - fn set_encoding_name(&self, name: DOMString); - fn content_changed(&self); - fn damage_and_reflow(&self, damage: DocumentDamageLevel); - fn wait_until_safe_to_modify_dom(&self); - fn unregister_named_element(&self, to_unregister: JSRef, id: DOMString); - fn register_named_element(&self, element: JSRef, id: DOMString); - fn load_anchor_href(&self, href: DOMString); + fn quirks_mode(self) -> QuirksMode; + fn set_quirks_mode(self, mode: QuirksMode); + fn set_last_modified(self, value: DOMString); + fn set_encoding_name(self, name: DOMString); + fn content_changed(self); + fn damage_and_reflow(self, damage: DocumentDamageLevel); + fn wait_until_safe_to_modify_dom(self); + fn unregister_named_element(self, to_unregister: JSRef, id: DOMString); + fn register_named_element(self, element: JSRef, id: DOMString); + fn load_anchor_href(self, href: DOMString); } impl<'a> DocumentHelpers for JSRef<'a, Document> { @@ -167,37 +167,37 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> { &*self.url } - fn quirks_mode(&self) -> QuirksMode { + fn quirks_mode(self) -> QuirksMode { self.quirks_mode.deref().get() } - fn set_quirks_mode(&self, mode: QuirksMode) { + fn set_quirks_mode(self, mode: QuirksMode) { self.quirks_mode.deref().set(mode); } - fn set_last_modified(&self, value: DOMString) { + fn set_last_modified(self, value: DOMString) { *self.last_modified.deref().borrow_mut() = Some(value); } - fn set_encoding_name(&self, name: DOMString) { + fn set_encoding_name(self, name: DOMString) { *self.encoding_name.deref().borrow_mut() = name; } - fn content_changed(&self) { + fn content_changed(self) { self.damage_and_reflow(ContentChangedDocumentDamage); } - fn damage_and_reflow(&self, damage: DocumentDamageLevel) { + fn damage_and_reflow(self, damage: DocumentDamageLevel) { self.window.root().damage_and_reflow(damage); } - fn wait_until_safe_to_modify_dom(&self) { + fn wait_until_safe_to_modify_dom(self) { self.window.root().wait_until_safe_to_modify_dom(); } /// Remove any existing association between the provided id and any elements in this document. - fn unregister_named_element(&self, + fn unregister_named_element(self, to_unregister: JSRef, id: DOMString) { let mut idmap = self.idmap.deref().borrow_mut(); @@ -218,7 +218,7 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> { } /// Associate an element present in this document with the provided id. - fn register_named_element(&self, + fn register_named_element(self, element: JSRef, id: DOMString) { assert!({ @@ -261,7 +261,7 @@ impl<'a> DocumentHelpers for JSRef<'a, Document> { idmap.insert(id, elements); } - fn load_anchor_href(&self, href: DOMString) { + fn load_anchor_href(self, href: DOMString) { let window = self.window.root(); window.load_url(href); } @@ -329,12 +329,12 @@ impl Reflectable for Document { } trait PrivateDocumentHelpers { - fn createNodeList(&self, callback: |node: JSRef| -> bool) -> Temporary; - fn get_html_element(&self) -> Option>; + fn createNodeList(self, callback: |node: JSRef| -> bool) -> Temporary; + fn get_html_element(self) -> Option>; } impl<'a> PrivateDocumentHelpers for JSRef<'a, Document> { - fn createNodeList(&self, callback: |node: JSRef| -> bool) -> Temporary { + fn createNodeList(self, callback: |node: JSRef| -> bool) -> Temporary { let window = self.window.root(); match self.GetDocumentElement().root() { @@ -355,7 +355,7 @@ impl<'a> PrivateDocumentHelpers for JSRef<'a, Document> { } - fn get_html_element(&self) -> Option> { + fn get_html_element(self) -> Option> { self.GetDocumentElement().root().filtered(|root| { let root: JSRef = NodeCast::from_ref(**root); root.type_id() == ElementNodeTypeId(HTMLHtmlElementTypeId) diff --git a/components/script/dom/domtokenlist.rs b/components/script/dom/domtokenlist.rs index fc4fefb3ec0..8e44de023b9 100644 --- a/components/script/dom/domtokenlist.rs +++ b/components/script/dom/domtokenlist.rs @@ -49,17 +49,17 @@ impl Reflectable for DOMTokenList { } trait PrivateDOMTokenListHelpers { - fn attribute(&self) -> Option>; - fn check_token_exceptions<'a>(&self, token: &'a str) -> Fallible<&'a str>; + fn attribute(self) -> Option>; + fn check_token_exceptions<'a>(self, token: &'a str) -> Fallible<&'a str>; } impl<'a> PrivateDOMTokenListHelpers for JSRef<'a, DOMTokenList> { - fn attribute(&self) -> Option> { + fn attribute(self) -> Option> { let element = self.element.root(); element.deref().get_attribute(Null, self.local_name) } - fn check_token_exceptions<'a>(&self, token: &'a str) -> Fallible<&'a str> { + fn check_token_exceptions<'a>(self, token: &'a str) -> Fallible<&'a str> { match token { "" => Err(Syntax), token if token.find(HTML_SPACE_CHARACTERS).is_some() => Err(InvalidCharacter), diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 4101c7e074e..612188f7be1 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -241,8 +241,8 @@ pub trait ElementHelpers { fn html_element_in_html_document(&self) -> bool; fn get_local_name<'a>(&'a self) -> &'a Atom; fn get_namespace<'a>(&'a self) -> &'a Namespace; - fn summarize(&self) -> Vec; - fn is_void(&self) -> bool; + fn summarize(self) -> Vec; + fn is_void(self) -> bool; } impl<'a> ElementHelpers for JSRef<'a, Element> { @@ -259,7 +259,7 @@ impl<'a> ElementHelpers for JSRef<'a, Element> { &self.deref().namespace } - fn summarize(&self) -> Vec { + fn summarize(self) -> Vec { let attrs = self.Attributes().root(); let mut i = 0; let mut summarized = vec!(); @@ -289,45 +289,45 @@ impl<'a> ElementHelpers for JSRef<'a, Element> { pub trait AttributeHandlers { /// Returns the attribute with given namespace and case-sensitive local /// name, if any. - fn get_attribute(&self, namespace: Namespace, local_name: &str) + fn get_attribute(self, namespace: Namespace, local_name: &str) -> Option>; - fn set_attribute_from_parser(&self, local_name: Atom, + fn set_attribute_from_parser(self, local_name: Atom, value: DOMString, namespace: Namespace, prefix: Option); - fn set_attribute(&self, name: &str, value: AttrValue); - fn do_set_attribute(&self, local_name: Atom, value: AttrValue, + fn set_attribute(self, name: &str, value: AttrValue); + fn do_set_attribute(self, local_name: Atom, value: AttrValue, name: Atom, namespace: Namespace, prefix: Option, cb: |JSRef| -> bool); - fn parse_attribute(&self, namespace: &Namespace, local_name: &Atom, + fn parse_attribute(self, namespace: &Namespace, local_name: &Atom, value: DOMString) -> AttrValue; - fn remove_attribute(&self, namespace: Namespace, name: &str); - fn notify_attribute_changed(&self, local_name: &Atom); + fn remove_attribute(self, namespace: Namespace, name: &str); + fn notify_attribute_changed(self, local_name: &Atom); fn has_class(&self, name: &str) -> bool; - fn set_atomic_attribute(&self, name: &str, value: DOMString); + fn set_atomic_attribute(self, name: &str, value: DOMString); // http://www.whatwg.org/html/#reflecting-content-attributes-in-idl-attributes - fn has_attribute(&self, name: &str) -> bool; - fn set_bool_attribute(&self, name: &str, value: bool); - fn get_url_attribute(&self, name: &str) -> DOMString; - fn set_url_attribute(&self, name: &str, value: DOMString); - fn get_string_attribute(&self, name: &str) -> DOMString; - fn set_string_attribute(&self, name: &str, value: DOMString); - fn set_tokenlist_attribute(&self, name: &str, value: DOMString); - fn get_uint_attribute(&self, name: &str) -> u32; - fn set_uint_attribute(&self, name: &str, value: u32); + fn has_attribute(self, name: &str) -> bool; + fn set_bool_attribute(self, name: &str, value: bool); + fn get_url_attribute(self, name: &str) -> DOMString; + fn set_url_attribute(self, name: &str, value: DOMString); + fn get_string_attribute(self, name: &str) -> DOMString; + fn set_string_attribute(self, name: &str, value: DOMString); + fn set_tokenlist_attribute(self, name: &str, value: DOMString); + fn get_uint_attribute(self, name: &str) -> u32; + fn set_uint_attribute(self, name: &str, value: u32); } impl<'a> AttributeHandlers for JSRef<'a, Element> { - fn get_attribute(&self, namespace: Namespace, local_name: &str) -> Option> { + fn get_attribute(self, namespace: Namespace, local_name: &str) -> Option> { let local_name = Atom::from_slice(local_name); self.attrs.borrow().iter().map(|attr| attr.root()).find(|attr| { *attr.local_name() == local_name && attr.namespace == namespace }).map(|x| Temporary::from_rooted(*x)) } - fn set_attribute_from_parser(&self, local_name: Atom, + fn set_attribute_from_parser(self, local_name: Atom, value: DOMString, namespace: Namespace, prefix: Option) { let name = match prefix { @@ -341,11 +341,11 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { self.do_set_attribute(local_name, value, name, namespace, prefix, |_| false) } - fn set_attribute(&self, name: &str, value: AttrValue) { + fn set_attribute(self, name: &str, value: AttrValue) { assert!(name == name.to_ascii_lower().as_slice()); assert!(!name.contains(":")); - let node: JSRef = NodeCast::from_ref(*self); + let node: JSRef = NodeCast::from_ref(self); node.wait_until_safe_to_modify_dom(); let name = Atom::from_slice(name); @@ -353,7 +353,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { namespace::Null, None, |attr| *attr.local_name() == name); } - fn do_set_attribute(&self, local_name: Atom, value: AttrValue, + fn do_set_attribute(self, local_name: Atom, value: AttrValue, name: Atom, namespace: Namespace, prefix: Option, cb: |JSRef| -> bool) { let idx = self.deref().attrs.borrow().iter() @@ -362,9 +362,9 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { let (idx, set_type) = match idx { Some(idx) => (idx, ReplacedAttr), None => { - let window = window_from_node(*self).root(); + let window = window_from_node(self).root(); let attr = Attr::new(*window, local_name, value.clone(), - name, namespace.clone(), prefix, *self); + name, namespace.clone(), prefix, self); self.deref().attrs.borrow_mut().push_unrooted(&attr); (self.deref().attrs.borrow().len() - 1, FirstSetAttr) } @@ -373,17 +373,17 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { (*self.deref().attrs.borrow())[idx].root().set_value(set_type, value); } - fn parse_attribute(&self, namespace: &Namespace, local_name: &Atom, + fn parse_attribute(self, namespace: &Namespace, local_name: &Atom, value: DOMString) -> AttrValue { if *namespace == namespace::Null { - vtable_for(&NodeCast::from_ref(*self)) + vtable_for(&NodeCast::from_ref(self)) .parse_plain_attribute(local_name.as_slice(), value) } else { StringAttrValue(value) } } - fn remove_attribute(&self, namespace: Namespace, name: &str) { + fn remove_attribute(self, namespace: Namespace, name: &str) { let (_, local_name) = get_attribute_parts(name); let local_name = Atom::from_slice(local_name); @@ -395,13 +395,13 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { None => (), Some(idx) => { { - let node: JSRef = NodeCast::from_ref(*self); + let node: JSRef = NodeCast::from_ref(self); node.wait_until_safe_to_modify_dom(); } if namespace == namespace::Null { let removed_raw_value = (*self.deref().attrs.borrow())[idx].root().Value(); - vtable_for(&NodeCast::from_ref(*self)) + vtable_for(&NodeCast::from_ref(self)) .before_remove_attr(&local_name, removed_raw_value); } @@ -411,8 +411,8 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { }; } - fn notify_attribute_changed(&self, local_name: &Atom) { - let node: JSRef = NodeCast::from_ref(*self); + fn notify_attribute_changed(self, local_name: &Atom) { + let node: JSRef = NodeCast::from_ref(self); if node.is_in_doc() { let damage = match local_name.as_slice() { "style" | "id" | "class" => MatchSelectorsDocumentDamage, @@ -431,13 +431,13 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { }).unwrap_or(false) } - fn set_atomic_attribute(&self, name: &str, value: DOMString) { + fn set_atomic_attribute(self, name: &str, value: DOMString) { assert!(name == name.to_ascii_lower().as_slice()); let value = AttrValue::from_atomic(value); self.set_attribute(name, value); } - fn has_attribute(&self, name: &str) -> bool { + fn has_attribute(self, name: &str) -> bool { let name = match self.html_element_in_html_document() { true => Atom::from_slice(name.to_ascii_lower().as_slice()), false => Atom::from_slice(name) @@ -447,7 +447,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { }) } - fn set_bool_attribute(&self, name: &str, value: bool) { + fn set_bool_attribute(self, name: &str, value: bool) { if self.has_attribute(name) == value { return; } if value { self.set_string_attribute(name, String::new()); @@ -456,16 +456,16 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { } } - fn get_url_attribute(&self, name: &str) -> DOMString { + fn get_url_attribute(self, name: &str) -> DOMString { assert!(name == name.to_ascii_lower().as_slice()); // XXX Resolve URL. self.get_string_attribute(name) } - fn set_url_attribute(&self, name: &str, value: DOMString) { + fn set_url_attribute(self, name: &str, value: DOMString) { self.set_string_attribute(name, value); } - fn get_string_attribute(&self, name: &str) -> DOMString { + fn get_string_attribute(self, name: &str) -> DOMString { assert!(name == name.to_ascii_lower().as_slice()); match self.get_attribute(Null, name) { Some(x) => { @@ -475,17 +475,17 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { None => "".to_string() } } - fn set_string_attribute(&self, name: &str, value: DOMString) { + fn set_string_attribute(self, name: &str, value: DOMString) { assert!(name == name.to_ascii_lower().as_slice()); self.set_attribute(name, StringAttrValue(value)); } - fn set_tokenlist_attribute(&self, name: &str, value: DOMString) { + fn set_tokenlist_attribute(self, name: &str, value: DOMString) { assert!(name == name.to_ascii_lower().as_slice()); self.set_attribute(name, AttrValue::from_tokenlist(value)); } - fn get_uint_attribute(&self, name: &str) -> u32 { + fn get_uint_attribute(self, name: &str) -> u32 { assert!(name == name.to_ascii_lower().as_slice()); let attribute = self.get_attribute(Null, name).root(); match attribute { @@ -498,7 +498,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> { None => 0, } } - fn set_uint_attribute(&self, name: &str, value: u32) { + fn set_uint_attribute(self, name: &str, value: u32) { assert!(name == name.to_ascii_lower().as_slice()); self.set_attribute(name, UIntAttrValue(value.to_string(), value)); } diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs index d2c2dcb7585..ebe904bc476 100644 --- a/components/script/dom/eventtarget.rs +++ b/components/script/dom/eventtarget.rs @@ -94,37 +94,37 @@ impl EventTarget { } pub trait EventTargetHelpers { - fn dispatch_event_with_target<'a>(&self, - target: Option>, - event: JSRef) -> Fallible; - fn set_inline_event_listener(&self, + fn dispatch_event_with_target(self, + target: Option>, + event: JSRef) -> Fallible; + fn set_inline_event_listener(self, ty: DOMString, listener: Option); - fn get_inline_event_listener(&self, ty: DOMString) -> Option; - fn set_event_handler_uncompiled(&self, + fn get_inline_event_listener(self, ty: DOMString) -> Option; + fn set_event_handler_uncompiled(self, cx: *mut JSContext, url: Url, scope: *mut JSObject, ty: &str, source: DOMString); - fn set_event_handler_common(&self, ty: &str, + fn set_event_handler_common(self, ty: &str, listener: Option); - fn get_event_handler_common(&self, ty: &str) -> Option; + fn get_event_handler_common(self, ty: &str) -> Option; - fn has_handlers(&self) -> bool; + fn has_handlers(self) -> bool; } impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> { - fn dispatch_event_with_target<'b>(&self, - target: Option>, - event: JSRef) -> Fallible { + fn dispatch_event_with_target(self, + target: Option>, + event: JSRef) -> Fallible { if event.deref().dispatching.deref().get() || !event.deref().initialized.deref().get() { return Err(InvalidState); } - Ok(dispatch_event(*self, target, event)) + Ok(dispatch_event(self, target, event)) } - fn set_inline_event_listener(&self, + fn set_inline_event_listener(self, ty: DOMString, listener: Option) { let mut handlers = self.handlers.deref().borrow_mut(); @@ -156,7 +156,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> { } } - fn get_inline_event_listener(&self, ty: DOMString) -> Option { + fn get_inline_event_listener(self, ty: DOMString) -> Option { let handlers = self.handlers.deref().borrow(); let entries = handlers.find(&ty); entries.and_then(|entries| entries.iter().find(|entry| { @@ -167,7 +167,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> { }).map(|entry| entry.listener.get_listener())) } - fn set_event_handler_uncompiled(&self, + fn set_event_handler_uncompiled(self, cx: *mut JSContext, url: Url, scope: *mut JSObject, @@ -207,19 +207,19 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> { } fn set_event_handler_common( - &self, ty: &str, listener: Option) + self, ty: &str, listener: Option) { let event_listener = listener.map(|listener| EventListener::new(listener.callback())); self.set_inline_event_listener(ty.to_string(), event_listener); } - fn get_event_handler_common(&self, ty: &str) -> Option { + fn get_event_handler_common(self, ty: &str) -> Option { let listener = self.get_inline_event_listener(ty.to_string()); listener.map(|listener| CallbackContainer::new(listener.parent.callback())) } - fn has_handlers(&self) -> bool { + fn has_handlers(self) -> bool { !self.handlers.deref().borrow().is_empty() } } diff --git a/components/script/dom/htmlanchorelement.rs b/components/script/dom/htmlanchorelement.rs index 728b9c07fb6..6414c7d0c3c 100644 --- a/components/script/dom/htmlanchorelement.rs +++ b/components/script/dom/htmlanchorelement.rs @@ -50,19 +50,19 @@ impl HTMLAnchorElement { } trait PrivateHTMLAnchorElementHelpers { - fn handle_event_impl(&self, event: JSRef); + fn handle_event_impl(self, event: JSRef); } impl<'a> PrivateHTMLAnchorElementHelpers for JSRef<'a, HTMLAnchorElement> { - fn handle_event_impl(&self, event: JSRef) { + fn handle_event_impl(self, event: JSRef) { if "click" == event.Type().as_slice() && !event.DefaultPrevented() { - let element: JSRef = ElementCast::from_ref(*self); + let element: JSRef = ElementCast::from_ref(self); let attr = element.get_attribute(Null, "href").root(); match attr { Some(ref href) => { let value = href.Value(); debug!("clicked on link to {:s}", value); - let node: JSRef = NodeCast::from_ref(*self); + let node: JSRef = NodeCast::from_ref(self); let doc = node.owner_doc().root(); doc.load_anchor_href(value); } diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 4d9dccab7c9..1ae99e4367e 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -52,12 +52,12 @@ impl HTMLElement { } trait PrivateHTMLElementHelpers { - fn is_body_or_frameset(&self) -> bool; + fn is_body_or_frameset(self) -> bool; } impl<'a> PrivateHTMLElementHelpers for JSRef<'a, HTMLElement> { - fn is_body_or_frameset(&self) -> bool { - let eventtarget: JSRef = EventTargetCast::from_ref(*self); + fn is_body_or_frameset(self) -> bool { + let eventtarget: JSRef = EventTargetCast::from_ref(self); eventtarget.is_htmlbodyelement() || eventtarget.is_htmlframesetelement() } } diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 0c2e5d4d6b4..0079f51fb30 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -62,32 +62,32 @@ pub struct IFrameSize { } pub trait HTMLIFrameElementHelpers { - fn is_sandboxed(&self) -> bool; - fn get_url(&self) -> Option; + fn is_sandboxed(self) -> bool; + fn get_url(self) -> Option; /// http://www.whatwg.org/html/#process-the-iframe-attributes - fn process_the_iframe_attributes(&self); + fn process_the_iframe_attributes(self); } impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> { - fn is_sandboxed(&self) -> bool { + fn is_sandboxed(self) -> bool { self.sandbox.deref().get().is_some() } - fn get_url(&self) -> Option { - let element: JSRef = ElementCast::from_ref(*self); + fn get_url(self) -> Option { + let element: JSRef = ElementCast::from_ref(self); element.get_attribute(Null, "src").root().and_then(|src| { let url = src.deref().value(); if url.as_slice().is_empty() { None } else { - let window = window_from_node(*self).root(); + let window = window_from_node(self).root(); UrlParser::new().base_url(&window.deref().page().get_url()) .parse(url.as_slice()).ok() } }) } - fn process_the_iframe_attributes(&self) { + fn process_the_iframe_attributes(self) { let url = match self.get_url() { Some(url) => url.clone(), None => Url::parse("about:blank").unwrap(), @@ -100,7 +100,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> { }; // Subpage Id - let window = window_from_node(*self).root(); + let window = window_from_node(self).root(); let page = window.deref().page(); let subpage_id = page.get_next_subpage_id(); diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index faac2c8d037..91fcad5603c 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -39,14 +39,14 @@ impl HTMLImageElementDerived for EventTarget { } trait PrivateHTMLImageElementHelpers { - fn update_image(&self, value: Option<(DOMString, &Url)>); + fn update_image(self, value: Option<(DOMString, &Url)>); } impl<'a> PrivateHTMLImageElementHelpers for JSRef<'a, HTMLImageElement> { /// Makes the local `image` member match the status of the `src` attribute and starts /// prefetching the image. This method must be called after `src` is changed. - fn update_image(&self, value: Option<(DOMString, &Url)>) { - let node: JSRef = NodeCast::from_ref(*self); + fn update_image(self, value: Option<(DOMString, &Url)>) { + let node: JSRef = NodeCast::from_ref(self); let document = node.owner_doc().root(); let window = document.deref().window.root(); let image_cache = &window.image_cache_task; diff --git a/components/script/dom/htmllinkelement.rs b/components/script/dom/htmllinkelement.rs index 6b88948fe02..46050c8ca82 100644 --- a/components/script/dom/htmllinkelement.rs +++ b/components/script/dom/htmllinkelement.rs @@ -114,12 +114,12 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLLinkElement> { } trait PrivateHTMLLinkElementHelpers { - fn handle_stylesheet_url(&self, href: &str); + fn handle_stylesheet_url(self, href: &str); } impl<'a> PrivateHTMLLinkElementHelpers for JSRef<'a, HTMLLinkElement> { - fn handle_stylesheet_url(&self, href: &str) { - let window = window_from_node(*self).root(); + fn handle_stylesheet_url(self, href: &str) { + let window = window_from_node(self).root(); match UrlParser::new().base_url(&window.deref().page().get_url()).parse(href) { Ok(url) => { let LayoutChan(ref layout_chan) = *window.deref().page().layout_chan; diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index d16fc56d72f..d733cbb45ea 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -48,7 +48,7 @@ impl HTMLScriptElement { pub trait HTMLScriptElementHelpers { /// Prepare a script (), /// steps 6 and 7. - fn is_javascript(&self) -> bool; + fn is_javascript(self) -> bool; } /// Supported script types as defined by @@ -73,8 +73,8 @@ static SCRIPT_JS_MIMES: StaticStringVec = &[ ]; impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> { - fn is_javascript(&self) -> bool { - let element: JSRef = ElementCast::from_ref(*self); + fn is_javascript(self) -> bool { + let element: JSRef = ElementCast::from_ref(self); match element.get_attribute(Null, "type").root().map(|s| s.Value()) { Some(ref s) if s.is_empty() => { // type attr exists, but empty means js diff --git a/components/script/dom/htmlstyleelement.rs b/components/script/dom/htmlstyleelement.rs index 52ccfde5488..3dea1745240 100644 --- a/components/script/dom/htmlstyleelement.rs +++ b/components/script/dom/htmlstyleelement.rs @@ -44,12 +44,12 @@ impl HTMLStyleElement { } pub trait StyleElementHelpers { - fn parse_own_css(&self); + fn parse_own_css(self); } impl<'a> StyleElementHelpers for JSRef<'a, HTMLStyleElement> { - fn parse_own_css(&self) { - let node: JSRef = NodeCast::from_ref(*self); + fn parse_own_css(self) { + let node: JSRef = NodeCast::from_ref(self); assert!(node.is_in_doc()); let win = window_from_node(node).root(); diff --git a/components/script/dom/performancetiming.rs b/components/script/dom/performancetiming.rs index 299c6eb6b16..25773ac42c9 100644 --- a/components/script/dom/performancetiming.rs +++ b/components/script/dom/performancetiming.rs @@ -43,11 +43,11 @@ impl<'a> PerformanceTimingMethods for JSRef<'a, PerformanceTiming> { } pub trait PerformanceTimingHelpers { - fn NavigationStartPrecise(&self) -> f64; + fn NavigationStartPrecise(self) -> f64; } impl<'a> PerformanceTimingHelpers for JSRef<'a, PerformanceTiming> { - fn NavigationStartPrecise(&self) -> f64 { + fn NavigationStartPrecise(self) -> f64 { self.navigationStartPrecise } } diff --git a/components/script/dom/treewalker.rs b/components/script/dom/treewalker.rs index e1d49be408f..cac3776e0ac 100644 --- a/components/script/dom/treewalker.rs +++ b/components/script/dom/treewalker.rs @@ -133,24 +133,24 @@ impl Reflectable for TreeWalker { type NodeAdvancer<'a, 'b> = |node: JSRef<'a, Node>|: 'b -> Option>; trait PrivateTreeWalkerHelpers<'a, 'b> { - fn traverse_children(&self, + fn traverse_children(self, next_child: NodeAdvancer<'a, 'b>, next_sibling: NodeAdvancer<'a, 'b>) -> Fallible>>; - fn traverse_siblings(&self, + fn traverse_siblings(self, next_child: NodeAdvancer<'a, 'b>, next_sibling: NodeAdvancer<'a, 'b>) -> Fallible>>; - fn is_root_node(&self, node: JSRef<'a, Node>) -> bool; - fn is_current_node(&self, node: JSRef<'a, Node>) -> bool; - fn first_following_node_not_following_root(&self, node: JSRef<'a, Node>) + fn is_root_node(self, node: JSRef<'a, Node>) -> bool; + fn is_current_node(self, node: JSRef<'a, Node>) -> bool; + fn first_following_node_not_following_root(self, node: JSRef<'a, Node>) -> Option>; - fn accept_node(&self, node: JSRef<'a, Node>) -> Fallible; + fn accept_node(self, node: JSRef<'a, Node>) -> Fallible; } impl<'a, 'b> PrivateTreeWalkerHelpers<'a, 'b> for JSRef<'a, TreeWalker> { // http://dom.spec.whatwg.org/#concept-traverse-children - fn traverse_children(&self, + fn traverse_children(self, next_child: NodeAdvancer<'a, 'b>, next_sibling: NodeAdvancer<'a, 'b>) -> Fallible>> { @@ -229,7 +229,7 @@ impl<'a, 'b> PrivateTreeWalkerHelpers<'a, 'b> for JSRef<'a, TreeWalker> { } // http://dom.spec.whatwg.org/#concept-traverse-siblings - fn traverse_siblings(&self, + fn traverse_siblings(self, next_child: NodeAdvancer<'a, 'b>, next_sibling: NodeAdvancer<'a, 'b>) -> Fallible>> { @@ -293,7 +293,7 @@ impl<'a, 'b> PrivateTreeWalkerHelpers<'a, 'b> for JSRef<'a, TreeWalker> { } // http://dom.spec.whatwg.org/#concept-tree-following - fn first_following_node_not_following_root(&self, node: JSRef<'a, Node>) + fn first_following_node_not_following_root(self, node: JSRef<'a, Node>) -> Option> { // "An object A is following an object B if A and B are in the same tree // and A comes after B in tree order." @@ -320,7 +320,7 @@ impl<'a, 'b> PrivateTreeWalkerHelpers<'a, 'b> for JSRef<'a, TreeWalker> { } // http://dom.spec.whatwg.org/#concept-node-filter - fn accept_node(&self, node: JSRef<'a, Node>) -> Fallible { + fn accept_node(self, node: JSRef<'a, Node>) -> Fallible { // "To filter node run these steps:" // "1. Let n be node's nodeType attribute value minus 1." let n: uint = node.NodeType() as uint - 1; @@ -336,32 +336,32 @@ impl<'a, 'b> PrivateTreeWalkerHelpers<'a, 'b> for JSRef<'a, TreeWalker> { match self.filter { FilterNone => Ok(NodeFilterConstants::FILTER_ACCEPT), FilterNative(f) => Ok((*f)(node)), - FilterJS(callback) => callback.AcceptNode_(*self, node, RethrowExceptions) + FilterJS(callback) => callback.AcceptNode_(self, node, RethrowExceptions) } } - fn is_root_node(&self, node: JSRef<'a, Node>) -> bool { + fn is_root_node(self, node: JSRef<'a, Node>) -> bool { JS::from_rooted(node) == self.root_node } - fn is_current_node(&self, node: JSRef<'a, Node>) -> bool { + fn is_current_node(self, node: JSRef<'a, Node>) -> bool { JS::from_rooted(node) == self.current_node.get() } } pub trait TreeWalkerHelpers<'a> { - fn parent_node(&self) -> Fallible>>; - fn first_child(&self) -> Fallible>>; - fn last_child(&self) -> Fallible>>; - fn next_sibling(&self) -> Fallible>>; - fn prev_sibling(&self) -> Fallible>>; - fn next_node(&self) -> Fallible>>; - fn prev_node(&self) -> Fallible>>; + fn parent_node(self) -> Fallible>>; + fn first_child(self) -> Fallible>>; + fn last_child(self) -> Fallible>>; + fn next_sibling(self) -> Fallible>>; + fn prev_sibling(self) -> Fallible>>; + fn next_node(self) -> Fallible>>; + fn prev_node(self) -> Fallible>>; } impl<'a> TreeWalkerHelpers<'a> for JSRef<'a, TreeWalker> { // http://dom.spec.whatwg.org/#dom-treewalker-parentnode - fn parent_node(&self) -> Fallible>> { + fn parent_node(self) -> Fallible>> { // "1. Let node be the value of the currentNode attribute." let mut node = self.current_node.get().root().clone(); // "2. While node is not null and is not root, run these substeps:" @@ -389,35 +389,35 @@ impl<'a> TreeWalkerHelpers<'a> for JSRef<'a, TreeWalker> { } // http://dom.spec.whatwg.org/#dom-treewalker-firstchild - fn first_child(&self) -> Fallible>> { + fn first_child(self) -> Fallible>> { // "The firstChild() method must traverse children of type first." self.traverse_children(|node| node.first_child(), |node| node.next_sibling()) } // http://dom.spec.whatwg.org/#dom-treewalker-lastchild - fn last_child(&self) -> Fallible>> { + fn last_child(self) -> Fallible>> { // "The lastChild() method must traverse children of type last." self.traverse_children(|node| node.last_child(), |node| node.prev_sibling()) } // http://dom.spec.whatwg.org/#dom-treewalker-nextsibling - fn next_sibling(&self) -> Fallible>> { + fn next_sibling(self) -> Fallible>> { // "The nextSibling() method must traverse siblings of type next." self.traverse_siblings(|node| node.first_child(), |node| node.next_sibling()) } // http://dom.spec.whatwg.org/#dom-treewalker-previoussibling - fn prev_sibling(&self) -> Fallible>> { + fn prev_sibling(self) -> Fallible>> { // "The previousSibling() method must traverse siblings of type previous." self.traverse_siblings(|node| node.last_child(), |node| node.prev_sibling()) } // http://dom.spec.whatwg.org/#dom-treewalker-previousnode - fn prev_node(&self) -> Fallible>> { + fn prev_node(self) -> Fallible>> { // "1. Let node be the value of the currentNode attribute." let mut node = self.current_node.get().root().clone(); // "2. While node is not root, run these substeps:" @@ -478,7 +478,7 @@ impl<'a> TreeWalkerHelpers<'a> for JSRef<'a, TreeWalker> { } // http://dom.spec.whatwg.org/#dom-treewalker-nextnode - fn next_node(&self) -> Fallible>> { + fn next_node(self) -> Fallible>> { // "1. Let node be the value of the currentNode attribute." let mut node = self.current_node.get().root().clone(); // "2. Let result be FILTER_ACCEPT." diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index fd147aaefdf..631dfbec858 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -364,21 +364,21 @@ impl Reflectable for Window { } pub trait WindowHelpers { - fn damage_and_reflow(&self, damage: DocumentDamageLevel); - fn flush_layout(&self, goal: ReflowGoal); - fn wait_until_safe_to_modify_dom(&self); - fn init_browser_context(&self, doc: JSRef); - fn load_url(&self, href: DOMString); - fn handle_fire_timer(&self, timer_id: TimerId, cx: *mut JSContext); - fn evaluate_js_with_result(&self, code: &str) -> JSVal; + fn damage_and_reflow(self, damage: DocumentDamageLevel); + fn flush_layout(self, goal: ReflowGoal); + fn wait_until_safe_to_modify_dom(self); + fn init_browser_context(self, doc: JSRef); + fn load_url(self, href: DOMString); + fn handle_fire_timer(self, timer_id: TimerId, cx: *mut JSContext); + fn evaluate_js_with_result(self, code: &str) -> JSVal; } trait PrivateWindowHelpers { - fn set_timeout_or_interval(&self, callback: JSVal, timeout: i32, is_interval: bool) -> i32; + fn set_timeout_or_interval(self, callback: JSVal, timeout: i32, is_interval: bool) -> i32; } impl<'a> WindowHelpers for JSRef<'a, Window> { - fn evaluate_js_with_result(&self, code: &str) -> JSVal { + fn evaluate_js_with_result(self, code: &str) -> JSVal { let global = self.reflector().get_jsobject(); let code: Vec = code.as_slice().utf16_units().collect(); let mut rval = UndefinedValue(); @@ -397,27 +397,27 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { }) } - fn damage_and_reflow(&self, damage: DocumentDamageLevel) { + fn damage_and_reflow(self, damage: DocumentDamageLevel) { self.page().damage(damage); self.page().avoided_reflows.set(self.page().avoided_reflows.get() + 1); } - fn flush_layout(&self, goal: ReflowGoal) { + fn flush_layout(self, goal: ReflowGoal) { self.page().flush_layout(goal); } - fn wait_until_safe_to_modify_dom(&self) { + fn wait_until_safe_to_modify_dom(self) { // FIXME: This disables concurrent layout while we are modifying the DOM, since // our current architecture is entirely unsafe in the presence of races. self.page().join_layout(); } - fn init_browser_context(&self, doc: JSRef) { + fn init_browser_context(self, doc: JSRef) { *self.browser_context.deref().borrow_mut() = Some(BrowserContext::new(doc)); } /// Commence a new URL load which will either replace this window or scroll to a fragment. - fn load_url(&self, href: DOMString) { + fn load_url(self, href: DOMString) { let base_url = self.page().get_url(); debug!("current page url is {:?}", base_url); let url = UrlParser::new().base_url(&base_url).parse(href.as_slice()); @@ -431,7 +431,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { } } - fn handle_fire_timer(&self, timer_id: TimerId, cx: *mut JSContext) { + fn handle_fire_timer(self, timer_id: TimerId, cx: *mut JSContext) { let this_value = self.reflector().get_jsobject(); let data = match self.active_timers.deref().borrow().find(&timer_id) { @@ -455,7 +455,7 @@ impl<'a> WindowHelpers for JSRef<'a, Window> { } impl<'a> PrivateWindowHelpers for JSRef<'a, Window> { - fn set_timeout_or_interval(&self, callback: JSVal, timeout: i32, is_interval: bool) -> i32 { + fn set_timeout_or_interval(self, callback: JSVal, timeout: i32, is_interval: bool) -> i32 { let timeout = cmp::max(0, timeout) as u64; let handle = self.next_timer_handle.deref().get(); self.next_timer_handle.deref().set(handle + 1); diff --git a/components/script/dom/xmlhttprequest.rs b/components/script/dom/xmlhttprequest.rs index 3afbe1ecb72..42ff2f483cb 100644 --- a/components/script/dom/xmlhttprequest.rs +++ b/components/script/dom/xmlhttprequest.rs @@ -692,23 +692,23 @@ impl TrustedXHRAddress { trait PrivateXMLHttpRequestHelpers { - unsafe fn to_trusted(&self) -> TrustedXHRAddress; - fn release_once(&self); - fn change_ready_state(&self, XMLHttpRequestState); - fn process_partial_response(&self, progress: XHRProgress); - fn insert_trusted_header(&self, name: String, value: String); - fn dispatch_progress_event(&self, upload: bool, type_: DOMString, loaded: u64, total: Option); - fn dispatch_upload_progress_event(&self, type_: DOMString, partial_load: Option); - fn dispatch_response_progress_event(&self, type_: DOMString); - fn text_response(&self) -> DOMString; - fn set_timeout(&self, timeout:u32); - fn cancel_timeout(&self); - fn filter_response_headers(&self) -> ResponseHeaderCollection; + unsafe fn to_trusted(self) -> TrustedXHRAddress; + fn release_once(self); + fn change_ready_state(self, XMLHttpRequestState); + fn process_partial_response(self, progress: XHRProgress); + fn insert_trusted_header(self, name: String, value: String); + fn dispatch_progress_event(self, upload: bool, type_: DOMString, loaded: u64, total: Option); + fn dispatch_upload_progress_event(self, type_: DOMString, partial_load: Option); + fn dispatch_response_progress_event(self, type_: DOMString); + fn text_response(self) -> DOMString; + fn set_timeout(self, timeout:u32); + fn cancel_timeout(self); + fn filter_response_headers(self) -> ResponseHeaderCollection; } impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { // Creates a trusted address to the object, and roots it. Always pair this with a release() - unsafe fn to_trusted(&self) -> TrustedXHRAddress { + unsafe fn to_trusted(self) -> TrustedXHRAddress { if self.pinned_count.deref().get() == 0 { JS_AddObjectRoot(self.global.root().root_ref().get_cx(), self.reflector().rootable()); } @@ -717,7 +717,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { TrustedXHRAddress(self.deref() as *const XMLHttpRequest as *const libc::c_void) } - fn release_once(&self) { + fn release_once(self) { if self.sync.deref().get() { // Lets us call this at various termination cases without having to // check self.sync every time, since the pinning mechanism only is @@ -734,18 +734,18 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { } } - fn change_ready_state(&self, rs: XMLHttpRequestState) { + fn change_ready_state(self, rs: XMLHttpRequestState) { assert!(self.ready_state.deref().get() != rs) self.ready_state.deref().set(rs); let global = self.global.root(); let event = Event::new(&global.root_ref(), "readystatechange".to_string(), false, true).root(); - let target: JSRef = EventTargetCast::from_ref(*self); + let target: JSRef = EventTargetCast::from_ref(self); target.dispatch_event_with_target(None, *event).ok(); } - fn process_partial_response(&self, progress: XHRProgress) { + fn process_partial_response(self, progress: XHRProgress) { match progress { HeadersReceivedMsg(headers, status) => { // For synchronous requests, this should not fire any events, and just store data @@ -845,7 +845,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { } } - fn insert_trusted_header(&self, name: String, value: String) { + fn insert_trusted_header(self, name: String, value: String) { // Insert a header without checking spec-compliance // Use for hardcoded headers let mut collection = self.request_headers.deref().borrow_mut(); @@ -857,7 +857,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { collection.insert(maybe_header.unwrap()); } - fn dispatch_progress_event(&self, upload: bool, type_: DOMString, loaded: u64, total: Option) { + fn dispatch_progress_event(self, upload: bool, type_: DOMString, loaded: u64, total: Option) { let global = self.global.root(); let upload_target = *self.upload.root(); let progressevent = ProgressEvent::new(&global.root_ref(), @@ -867,25 +867,25 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { let target: JSRef = if upload { EventTargetCast::from_ref(upload_target) } else { - EventTargetCast::from_ref(*self) + EventTargetCast::from_ref(self) }; let event: JSRef = EventCast::from_ref(*progressevent); target.dispatch_event_with_target(None, event).ok(); } - fn dispatch_upload_progress_event(&self, type_: DOMString, partial_load: Option) { + fn dispatch_upload_progress_event(self, type_: DOMString, partial_load: Option) { // If partial_load is None, loading has completed and we can just use the value from the request body let total = self.request_body_len.get() as u64; self.dispatch_progress_event(true, type_, partial_load.unwrap_or(total), Some(total)); } - fn dispatch_response_progress_event(&self, type_: DOMString) { + fn dispatch_response_progress_event(self, type_: DOMString) { let len = self.response.deref().borrow().len() as u64; let total = self.response_headers.deref().borrow().content_length.map(|x| {x as u64}); self.dispatch_progress_event(false, type_, len, total); } - fn set_timeout(&self, timeout: u32) { + fn set_timeout(self, timeout: u32) { // Sets up the object to timeout in a given number of milliseconds // This will cancel all previous timeouts let oneshot = self.timer.deref().borrow_mut().oneshot(timeout as u64); @@ -916,7 +916,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { } ); } - fn cancel_timeout(&self) { + fn cancel_timeout(self) { // Cancels timeouts on the object, if any if self.timeout_pinned.deref().get() { self.timeout_pinned.deref().set(false); @@ -925,7 +925,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { // oneshot() closes the previous channel, canceling the timeout self.timer.deref().borrow_mut().oneshot(0); } - fn text_response(&self) -> DOMString { + fn text_response(self) -> DOMString { let mut encoding = UTF_8 as EncodingRef; match self.response_headers.deref().borrow().content_type { Some(ref x) => { @@ -941,7 +941,7 @@ impl<'a> PrivateXMLHttpRequestHelpers for JSRef<'a, XMLHttpRequest> { // the result should be fine. XXXManishearth have a closer look at this later encoding.decode(self.response.deref().borrow().as_slice(), DecodeReplace).unwrap().to_string() } - fn filter_response_headers(&self) -> ResponseHeaderCollection { + fn filter_response_headers(self) -> ResponseHeaderCollection { // http://fetch.spec.whatwg.org/#concept-response-header-list let mut headers = ResponseHeaderCollection::new(); for header in self.response_headers.deref().borrow().iter() { From 8aec08074c1535d2c8c9d3bb2208c6f83b82114e Mon Sep 17 00:00:00 2001 From: Cameron Zwarich Date: Fri, 19 Sep 2014 21:32:02 -0700 Subject: [PATCH 3/3] Remove some extraneous &* pairs --- components/script/dom/comment.rs | 2 +- components/script/dom/document.rs | 4 ++-- components/script/dom/htmliframeelement.rs | 2 +- components/script/dom/htmltableelement.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/script/dom/comment.rs b/components/script/dom/comment.rs index 86b82e0646c..aa0718390ed 100644 --- a/components/script/dom/comment.rs +++ b/components/script/dom/comment.rs @@ -42,7 +42,7 @@ impl Comment { pub fn Constructor(global: &GlobalRef, data: DOMString) -> Fallible> { let document = global.as_window().Document().root(); - Ok(Comment::new(data, *&*document)) + Ok(Comment::new(data, *document)) } } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 601a4c6162c..b6971f5dd14 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -317,8 +317,8 @@ impl Document { DocumentBinding::Wrap).root(); let node: JSRef = NodeCast::from_ref(*document); - node.set_owner_doc(*&*document); - Temporary::from_rooted(*&*document) + node.set_owner_doc(*document); + Temporary::from_rooted(*document) } } diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs index 0079f51fb30..e6ba1bd73c1 100644 --- a/components/script/dom/htmliframeelement.rs +++ b/components/script/dom/htmliframeelement.rs @@ -154,7 +154,7 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> { fn GetContentWindow(self) -> Option> { self.size.deref().get().and_then(|size| { let window = window_from_node(self).root(); - let children = &*window.deref().page.children.deref().borrow(); + let children = window.deref().page.children.deref().borrow(); let child = children.iter().find(|child| { child.subpage_id.unwrap() == size.subpage_id }); diff --git a/components/script/dom/htmltableelement.rs b/components/script/dom/htmltableelement.rs index c54be9fedb5..f8b3a043a1f 100644 --- a/components/script/dom/htmltableelement.rs +++ b/components/script/dom/htmltableelement.rs @@ -67,8 +67,8 @@ impl<'a> HTMLTableElementMethods for JSRef<'a, HTMLTableElement> { match old_caption { Some(htmlelem) => { - let htmlelem_jsref = &*htmlelem.root(); - let old_caption_node: JSRef = NodeCast::from_ref(*htmlelem_jsref); + let htmlelem_root = htmlelem.root(); + let old_caption_node: JSRef = NodeCast::from_ref(*htmlelem_root); assert!(node.RemoveChild(old_caption_node).is_ok()); } None => ()