Skip to content
Permalink
Browse files

Convert a method from &JSRef to JSRef

This also removes the unnecessary formation of a trait object.
  • Loading branch information
Cameron Zwarich
Cameron Zwarich committed Sep 30, 2014
1 parent 698b916 commit 3953456b619621983e1cb1af46beb80411981ffa
Showing with 4 additions and 5 deletions.
  1. +3 −3 components/script/dom/element.rs
  2. +1 −2 components/script/dom/node.rs
@@ -238,16 +238,16 @@ 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>;
fn is_void(self) -> bool;
}

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()
}

@@ -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()
}
}

5 comments on commit 3953456

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Oct 1, 2014

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Oct 1, 2014

merging zwarich/servo/more-jsref = 3953456 into auto

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Oct 1, 2014

zwarich/servo/more-jsref = 3953456 merged ok, testing candidate = 93e2592

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Oct 1, 2014

@bors-servo

This comment has been minimized.

Copy link
Contributor

@bors-servo bors-servo replied Oct 1, 2014

fast-forwarding master to auto = 93e2592

Please sign in to comment.
You can’t perform that action at this time.