Convert a method from &JSRef to JSRef

This also removes the unnecessary formation of a trait object.
This commit is contained in:
Cameron Zwarich 2014-09-27 20:43:39 -07:00
parent 698b916c09
commit 3953456b61
2 changed files with 4 additions and 5 deletions

View file

@ -238,7 +238,7 @@ impl LayoutElementHelpers for JS<Element> {
}
pub trait ElementHelpers {
fn html_element_in_html_document(&self) -> bool;
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<AttrInfo>;
@ -246,8 +246,8 @@ pub trait ElementHelpers {
}
impl<'a> ElementHelpers for JSRef<'a, Element> {
fn html_element_in_html_document(&self) -> bool {
let node: JSRef<Node> = NodeCast::from_ref(*self);
fn html_element_in_html_document(self) -> bool {
let node: JSRef<Node> = NodeCast::from_ref(self);
self.namespace == ns!(HTML) && node.is_in_html_doc()
}

View file

@ -2086,8 +2086,7 @@ impl<'a> style::TNode<'a, JSRef<'a, Element>> for JSRef<'a, Node> {
fn is_html_element_in_html_document(&self) -> bool {
let elem: Option<JSRef<'a, Element>> = ElementCast::to_ref(*self);
assert!(elem.is_some());
let elem: &ElementHelpers = &elem.unwrap() as &ElementHelpers;
elem.html_element_in_html_document()
elem.unwrap().html_element_in_html_document()
}
}