Convert various helper traits from &JSRef to JSRef

I converted them all with a few exceptions:

- Methods that were used by trait objects, since trait objects don't
  work with `self` methods.
- Methods that take an &'b JSRef<'a, T> and return an &'b. In reality,
  many (all?) could return an &'a instead, but this isn't allowed by the
  Deref trait.
- Methods that internally rely on the same issue with Deref.
- I left out the traits involved in layout entirely, even though not all
  of their methods suffer from one of the above problems.

There will probably be solutions to all of these problems in the future.
This commit is contained in:
Cameron Zwarich 2014-09-19 19:57:50 -07:00
parent 2c8d51a37c
commit d768ee77ad
17 changed files with 196 additions and 196 deletions

View file

@ -62,32 +62,32 @@ pub struct IFrameSize {
}
pub trait HTMLIFrameElementHelpers {
fn is_sandboxed(&self) -> bool;
fn get_url(&self) -> Option<Url>;
fn is_sandboxed(self) -> bool;
fn get_url(self) -> Option<Url>;
/// http://www.whatwg.org/html/#process-the-iframe-attributes
fn process_the_iframe_attributes(&self);
fn process_the_iframe_attributes(self);
}
impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
fn is_sandboxed(&self) -> bool {
fn is_sandboxed(self) -> bool {
self.sandbox.deref().get().is_some()
}
fn get_url(&self) -> Option<Url> {
let element: JSRef<Element> = ElementCast::from_ref(*self);
fn get_url(self) -> Option<Url> {
let element: JSRef<Element> = ElementCast::from_ref(self);
element.get_attribute(Null, "src").root().and_then(|src| {
let url = src.deref().value();
if url.as_slice().is_empty() {
None
} else {
let window = window_from_node(*self).root();
let window = window_from_node(self).root();
UrlParser::new().base_url(&window.deref().page().get_url())
.parse(url.as_slice()).ok()
}
})
}
fn process_the_iframe_attributes(&self) {
fn process_the_iframe_attributes(self) {
let url = match self.get_url() {
Some(url) => url.clone(),
None => Url::parse("about:blank").unwrap(),
@ -100,7 +100,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
};
// Subpage Id
let window = window_from_node(*self).root();
let window = window_from_node(self).root();
let page = window.deref().page();
let subpage_id = page.get_next_subpage_id();