First steps of &JSRef -> JSRef conversion

Replace &JSRef with JSRef in the bulk of the generated code. This will
remove a level of indirection throughout all DOM code.

This patch doesn't change methods implemented on JSRef<T> to take `self`
rather than `&self`, and it leaves a few other uses of &JSRef, but those
changes can be made incrementally.
This commit is contained in:
Cameron Zwarich 2014-09-18 13:43:15 -07:00
parent b8f34bbc51
commit 4fa8725111
126 changed files with 994 additions and 992 deletions

View file

@ -29,14 +29,14 @@ impl HTMLTitleElementDerived for EventTarget {
}
impl HTMLTitleElement {
pub fn new_inherited(localName: DOMString, document: &JSRef<Document>) -> HTMLTitleElement {
pub fn new_inherited(localName: DOMString, document: JSRef<Document>) -> HTMLTitleElement {
HTMLTitleElement {
htmlelement: HTMLElement::new_inherited(HTMLTitleElementTypeId, localName, document)
}
}
#[allow(unrooted_must_root)]
pub fn new(localName: DOMString, document: &JSRef<Document>) -> Temporary<HTMLTitleElement> {
pub fn new(localName: DOMString, document: JSRef<Document>) -> Temporary<HTMLTitleElement> {
let element = HTMLTitleElement::new_inherited(localName, document);
Node::reflect_node(box element, document, HTMLTitleElementBinding::Wrap)
}
@ -45,10 +45,10 @@ impl HTMLTitleElement {
impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> {
// http://www.whatwg.org/html/#dom-title-text
fn Text(&self) -> DOMString {
let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JSRef<Node> = NodeCast::from_ref(*self);
let mut content = String::new();
for child in node.children() {
let text: Option<&JSRef<Text>> = TextCast::to_ref(&child);
let text: Option<JSRef<Text>> = TextCast::to_ref(child);
match text {
Some(text) => content.push_str(text.characterdata.data.borrow().as_slice()),
None => (),
@ -59,7 +59,7 @@ impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> {
// http://www.whatwg.org/html/#dom-title-text
fn SetText(&self, value: DOMString) {
let node: &JSRef<Node> = NodeCast::from_ref(self);
let node: JSRef<Node> = NodeCast::from_ref(*self);
node.SetTextContent(Some(value))
}
}