Replace Root::deref() calls by Root::r() calls where possible.

This changes those calls that were already sound.
This commit is contained in:
Ms2ger 2015-01-01 12:20:52 +01:00
parent c9f26dfd59
commit 1dad710063
61 changed files with 479 additions and 471 deletions

View file

@ -175,11 +175,11 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
let (source, url) = match element.get_attribute(ns!(""), &atom!("src")).root() {
Some(src) => {
if src.deref().Value().is_empty() {
if src.r().Value().is_empty() {
// TODO: queue a task to fire a simple event named `error` at the element
return;
}
match UrlParser::new().base_url(&base_url).parse(src.deref().Value().as_slice()) {
match UrlParser::new().base_url(&base_url).parse(src.r().Value().as_slice()) {
Ok(url) => {
// TODO: Do a potentially CORS-enabled fetch with the mode being the current
// state of the element's `crossorigin` content attribute, the origin being
@ -192,14 +192,14 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
(source, metadata.final_url)
}
Err(_) => {
error!("error loading script {}", src.deref().Value());
error!("error loading script {}", src.r().Value());
return;
}
}
}
Err(_) => {
// TODO: queue a task to fire a simple event named `error` at the element
error!("error parsing URL for script {}", src.deref().Value());
error!("error parsing URL for script {}", src.r().Value());
return;
}
}
@ -207,20 +207,20 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
None => (text, base_url)
};
window.evaluate_script_with_result(source.as_slice(), url.serialize().as_slice());
window.r().evaluate_script_with_result(source.as_slice(), url.serialize().as_slice());
let event = Event::new(GlobalRef::Window(*window),
let event = Event::new(GlobalRef::Window(window.r()),
"load".into_string(),
EventBubbles::DoesNotBubble,
EventCancelable::NotCancelable).root();
event.set_trusted(true);
event.r().set_trusted(true);
let target: JSRef<EventTarget> = EventTargetCast::from_ref(self);
target.dispatch_event(*event);
target.dispatch_event(event.r());
}
fn is_javascript(self) -> bool {
let element: JSRef<Element> = ElementCast::from_ref(self);
match element.get_attribute(ns!(""), &atom!("type")).root().map(|s| s.Value()) {
match element.get_attribute(ns!(""), &atom!("type")).root().map(|s| s.r().Value()) {
Some(ref s) if s.is_empty() => {
// type attr exists, but empty means js
debug!("script type empty, inferring js");
@ -234,7 +234,7 @@ impl<'a> HTMLScriptElementHelpers for JSRef<'a, HTMLScriptElement> {
debug!("no script type");
match element.get_attribute(ns!(""), &atom!("language"))
.root()
.map(|s| s.Value()) {
.map(|s| s.r().Value()) {
Some(ref s) if s.is_empty() => {
debug!("script language empty, inferring js");
true