Rename Root<T> to DomRoot<T>

In a later PR, DomRoot<T> will become a type alias of Root<Dom<T>>,
where Root<T> will be able to handle all the things that need to be
rooted that have a stable traceable address that doesn't move for the
whole lifetime of the root. Stay tuned.
This commit is contained in:
Anthony Ramine 2017-09-26 01:53:40 +02:00
parent 577370746e
commit f87c2a8d76
291 changed files with 1774 additions and 1770 deletions

View file

@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::NamedNodeMapBinding;
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
use dom::bindings::error::{Error, Fallible};
use dom::bindings::reflector::{Reflector, reflect_dom_object};
use dom::bindings::root::{Dom, Root};
use dom::bindings::root::{Dom, DomRoot};
use dom::bindings::str::DOMString;
use dom::bindings::xmlname::namespace_from_domstring;
use dom::element::Element;
@ -31,7 +31,7 @@ impl NamedNodeMap {
}
}
pub fn new(window: &Window, elem: &Element) -> Root<NamedNodeMap> {
pub fn new(window: &Window, elem: &Element) -> DomRoot<NamedNodeMap> {
reflect_dom_object(box NamedNodeMap::new_inherited(elem),
window, NamedNodeMapBinding::Wrap)
}
@ -44,53 +44,53 @@ impl NamedNodeMapMethods for NamedNodeMap {
}
// https://dom.spec.whatwg.org/#dom-namednodemap-item
fn Item(&self, index: u32) -> Option<Root<Attr>> {
self.owner.attrs().get(index as usize).map(|js| Root::from_ref(&**js))
fn Item(&self, index: u32) -> Option<DomRoot<Attr>> {
self.owner.attrs().get(index as usize).map(|js| DomRoot::from_ref(&**js))
}
// https://dom.spec.whatwg.org/#dom-namednodemap-getnameditem
fn GetNamedItem(&self, name: DOMString) -> Option<Root<Attr>> {
fn GetNamedItem(&self, name: DOMString) -> Option<DomRoot<Attr>> {
self.owner.get_attribute_by_name(name)
}
// https://dom.spec.whatwg.org/#dom-namednodemap-getnameditemns
fn GetNamedItemNS(&self, namespace: Option<DOMString>, local_name: DOMString)
-> Option<Root<Attr>> {
-> Option<DomRoot<Attr>> {
let ns = namespace_from_domstring(namespace);
self.owner.get_attribute(&ns, &LocalName::from(local_name))
}
// https://dom.spec.whatwg.org/#dom-namednodemap-setnameditem
fn SetNamedItem(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> {
fn SetNamedItem(&self, attr: &Attr) -> Fallible<Option<DomRoot<Attr>>> {
self.owner.SetAttributeNode(attr)
}
// https://dom.spec.whatwg.org/#dom-namednodemap-setnameditemns
fn SetNamedItemNS(&self, attr: &Attr) -> Fallible<Option<Root<Attr>>> {
fn SetNamedItemNS(&self, attr: &Attr) -> Fallible<Option<DomRoot<Attr>>> {
self.SetNamedItem(attr)
}
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditem
fn RemoveNamedItem(&self, name: DOMString) -> Fallible<Root<Attr>> {
fn RemoveNamedItem(&self, name: DOMString) -> Fallible<DomRoot<Attr>> {
let name = self.owner.parsed_name(name);
self.owner.remove_attribute_by_name(&name).ok_or(Error::NotFound)
}
// https://dom.spec.whatwg.org/#dom-namednodemap-removenameditemns
fn RemoveNamedItemNS(&self, namespace: Option<DOMString>, local_name: DOMString)
-> Fallible<Root<Attr>> {
-> Fallible<DomRoot<Attr>> {
let ns = namespace_from_domstring(namespace);
self.owner.remove_attribute(&ns, &LocalName::from(local_name))
.ok_or(Error::NotFound)
}
// https://dom.spec.whatwg.org/#dom-namednodemap-item
fn IndexedGetter(&self, index: u32) -> Option<Root<Attr>> {
fn IndexedGetter(&self, index: u32) -> Option<DomRoot<Attr>> {
self.Item(index)
}
// check-tidy: no specs after this line
fn NamedGetter(&self, name: DOMString) -> Option<Root<Attr>> {
fn NamedGetter(&self, name: DOMString) -> Option<DomRoot<Attr>> {
self.GetNamedItem(name)
}