Skip to content

Commit

Permalink
Convert a method from &JSRef to JSRef
Browse files Browse the repository at this point in the history
This also removes the unnecessary formation of a trait object.
  • Loading branch information
Cameron Zwarich committed Sep 30, 2014
1 parent 698b916 commit 3953456
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions components/script/dom/element.rs
Expand Up @@ -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()
}

Expand Down
3 changes: 1 addition & 2 deletions components/script/dom/node.rs
Expand Up @@ -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()
}
}

Expand Down

5 comments on commit 3953456

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 93e2592

Please sign in to comment.