Convert TNode / TElement to use self methods rather than &self

This commit is contained in:
Cameron Zwarich 2014-09-30 21:00:07 -07:00
parent 63314208c0
commit 79b4ec99b4
4 changed files with 69 additions and 69 deletions

View file

@ -948,14 +948,14 @@ impl<'a> VirtualMethods for JSRef<'a, Element> {
}
impl<'a> style::TElement<'a> for JSRef<'a, Element> {
fn get_attr(&self, namespace: &Namespace, attr: &str) -> Option<&'a str> {
fn get_attr(self, namespace: &Namespace, attr: &str) -> Option<&'a str> {
self.get_attribute(namespace.clone(), attr).root().map(|attr| {
unsafe { mem::transmute(attr.deref().value().as_slice()) }
})
}
fn get_link(&self) -> Option<&'a str> {
fn get_link(self) -> Option<&'a str> {
// FIXME: This is HTML only.
let node: JSRef<Node> = NodeCast::from_ref(*self);
let node: JSRef<Node> = NodeCast::from_ref(self);
match node.type_id() {
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#
// selector-link
@ -965,29 +965,29 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
_ => None,
}
}
fn get_local_name(&self) -> &'a Atom {
fn get_local_name(self) -> &'a Atom {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn get_local_name<'a, T: ElementHelpers<'a>>(this: T) -> &'a Atom {
this.get_local_name()
}
get_local_name(*self)
get_local_name(self)
}
fn get_namespace(&self) -> &'a Namespace {
fn get_namespace(self) -> &'a Namespace {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn get_namespace<'a, T: ElementHelpers<'a>>(this: T) -> &'a Namespace {
this.get_namespace()
}
get_namespace(*self)
get_namespace(self)
}
fn get_hover_state(&self) -> bool {
let node: JSRef<Node> = NodeCast::from_ref(*self);
fn get_hover_state(self) -> bool {
let node: JSRef<Node> = NodeCast::from_ref(self);
node.get_hover_state()
}
fn get_id<'a>(&self) -> Option<Atom> {
fn get_id<'a>(self) -> Option<Atom> {
self.get_attribute(ns!(""), "id").map(|attr| {
let attr = attr.root();
match *attr.value() {
@ -996,21 +996,21 @@ impl<'a> style::TElement<'a> for JSRef<'a, Element> {
}
})
}
fn get_disabled_state(&self) -> bool {
let node: JSRef<Node> = NodeCast::from_ref(*self);
fn get_disabled_state(self) -> bool {
let node: JSRef<Node> = NodeCast::from_ref(self);
node.get_disabled_state()
}
fn get_enabled_state(&self) -> bool {
let node: JSRef<Node> = NodeCast::from_ref(*self);
fn get_enabled_state(self) -> bool {
let node: JSRef<Node> = NodeCast::from_ref(self);
node.get_enabled_state()
}
fn has_class(&self, name: &str) -> bool {
fn has_class(self, name: &str) -> bool {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn has_class<T: AttributeHandlers>(this: T, name: &str) -> bool {
this.has_class(name)
}
has_class(*self, name)
has_class(self, name)
}
}