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

@ -307,7 +307,7 @@ fn broadcast_radio_checked(broadcaster: JSRef<HTMLInputElement>, group: Option<&
//TODO: if not in document, use root ancestor instead of document
let owner = broadcaster.form_owner().root();
let doc = document_from_node(broadcaster).root();
let doc_node: JSRef<Node> = NodeCast::from_ref(*doc);
let doc_node: JSRef<Node> = NodeCast::from_ref(doc.r());
// There is no DOM tree manipulation here, so this is safe
let mut iter = unsafe {
@ -342,7 +342,7 @@ impl<'a> HTMLInputElementHelpers for JSRef<'a, HTMLInputElement> {
fn force_relayout(self) {
let doc = document_from_node(self).root();
let node: JSRef<Node> = NodeCast::from_ref(self);
doc.content_changed(node, NodeDamage::OtherNodeDamage)
doc.r().content_changed(node, NodeDamage::OtherNodeDamage)
}
fn radio_group_updated(self, group: Option<&str>) {
@ -356,7 +356,7 @@ impl<'a> HTMLInputElementHelpers for JSRef<'a, HTMLInputElement> {
let elem: JSRef<Element> = ElementCast::from_ref(self);
elem.get_attribute(ns!(""), &atom!("name"))
.root()
.map(|name| name.Value())
.map(|name| name.r().Value())
}
fn update_checked_state(self, checked: bool, dirty: bool) {
@ -550,7 +550,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLInputElement> {
//TODO: set the editing position for text inputs
let doc = document_from_node(*self).root();
doc.request_focus(ElementCast::from_ref(*self));
doc.r().request_focus(ElementCast::from_ref(*self));
} else if "keydown" == event.Type().as_slice() && !event.DefaultPrevented() &&
(self.input_type.get() == InputType::InputText ||
self.input_type.get() == InputType::InputPassword) {
@ -631,7 +631,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
//TODO: if not in document, use root ancestor instead of document
let owner = self.form_owner().root();
let doc = document_from_node(*self).root();
let doc_node: JSRef<Node> = NodeCast::from_ref(*doc);
let doc_node: JSRef<Node> = NodeCast::from_ref(doc.r());
let group = self.get_radio_group_name();;
// Safe since we only manipulate the DOM tree after finding an element
@ -684,11 +684,11 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
Some(o) => {
// Avoiding iterating through the whole tree here, instead
// we can check if the conditions for radio group siblings apply
if name == o.get_radio_group_name() && // TODO should be compatibility caseless
self.form_owner() == o.form_owner() &&
if name == o.r().get_radio_group_name() && // TODO should be compatibility caseless
self.form_owner() == o.r().form_owner() &&
// TODO Both a and b are in the same home subtree
o.input_type.get() == InputType::InputRadio {
o.SetChecked(true);
o.r().input_type.get() == InputType::InputRadio {
o.r().SetChecked(true);
} else {
self.SetChecked(false);
}
@ -716,8 +716,8 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
if self.mutable() /* and document owner is fully active */ {
self.form_owner().map(|o| {
o.root().submit(SubmittedFrom::NotFromFormSubmitMethod,
FormSubmitter::InputElement(self.clone()))
o.root().r().submit(SubmittedFrom::NotFromFormSubmitMethod,
FormSubmitter::InputElement(self.clone()))
});
}
},
@ -726,7 +726,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
// FIXME (Manishearth): support document owners (needs ability to get parent browsing context)
if self.mutable() /* and document owner is fully active */ {
self.form_owner().map(|o| {
o.root().reset(ResetFrom::NotFromFormResetMethod)
o.root().r().reset(ResetFrom::NotFromFormResetMethod)
});
}
},
@ -735,21 +735,21 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
// https://html.spec.whatwg.org/multipage/forms.html#radio-button-state-(type=radio):activation-behavior
if self.mutable() {
let win = window_from_node(*self).root();
let event = Event::new(GlobalRef::Window(*win),
let event = Event::new(GlobalRef::Window(win.r()),
"input".into_string(),
EventBubbles::Bubbles,
EventCancelable::NotCancelable).root();
event.set_trusted(true);
event.r().set_trusted(true);
let target: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
target.DispatchEvent(*event).ok();
target.DispatchEvent(event.r()).ok();
let event = Event::new(GlobalRef::Window(*win),
let event = Event::new(GlobalRef::Window(win.r()),
"change".into_string(),
EventBubbles::Bubbles,
EventCancelable::NotCancelable).root();
event.set_trusted(true);
event.r().set_trusted(true);
let target: JSRef<EventTarget> = EventTargetCast::from_ref(*self);
target.DispatchEvent(*event).ok();
target.DispatchEvent(event.r()).ok();
}
},
_ => ()
@ -759,7 +759,7 @@ impl<'a> Activatable for JSRef<'a, HTMLInputElement> {
// https://html.spec.whatwg.org/multipage/forms.html#implicit-submission
fn implicit_submission(&self, ctrlKey: bool, shiftKey: bool, altKey: bool, metaKey: bool) {
let doc = document_from_node(*self).root();
let node: JSRef<Node> = NodeCast::from_ref(*doc);
let node: JSRef<Node> = NodeCast::from_ref(doc.r());
let owner = self.form_owner();
if owner.is_none() || ElementCast::from_ref(*self).click_in_progress() {
return;