aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlcollection.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-09-26 01:53:40 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-09-26 09:49:10 +0200
commitf87c2a8d7616112ca924e30292db2d244cf87eec (patch)
tree7344afe7ec0ec1ac7d1d13f5385111ee9c4be332 /components/script/dom/htmlcollection.rs
parent577370746e2ce3da7fa25a20b8e1bbeed319df65 (diff)
downloadservo-f87c2a8d7616112ca924e30292db2d244cf87eec.tar.gz
servo-f87c2a8d7616112ca924e30292db2d244cf87eec.zip
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.
Diffstat (limited to 'components/script/dom/htmlcollection.rs')
-rw-r--r--components/script/dom/htmlcollection.rs46
1 files changed, 23 insertions, 23 deletions
diff --git a/components/script/dom/htmlcollection.rs b/components/script/dom/htmlcollection.rs
index dd8a62617db..cefa1407413 100644
--- a/components/script/dom/htmlcollection.rs
+++ b/components/script/dom/htmlcollection.rs
@@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::HTMLCollectionBinding;
use dom::bindings::codegen::Bindings::HTMLCollectionBinding::HTMLCollectionMethods;
use dom::bindings::inheritance::Castable;
use dom::bindings::reflector::{Reflector, reflect_dom_object};
-use dom::bindings::root::{Dom, Root, MutNullableDom};
+use dom::bindings::root::{Dom, DomRoot, MutNullableDom};
use dom::bindings::str::DOMString;
use dom::bindings::trace::JSTraceable;
use dom::bindings::xmlname::namespace_from_domstring;
@@ -81,13 +81,13 @@ impl HTMLCollection {
}
#[allow(unrooted_must_root)]
- pub fn new(window: &Window, root: &Node, filter: Box<CollectionFilter + 'static>) -> Root<HTMLCollection> {
+ pub fn new(window: &Window, root: &Node, filter: Box<CollectionFilter + 'static>) -> DomRoot<HTMLCollection> {
reflect_dom_object(box HTMLCollection::new_inherited(root, filter),
window, HTMLCollectionBinding::Wrap)
}
pub fn create(window: &Window, root: &Node,
- filter: Box<CollectionFilter + 'static>) -> Root<HTMLCollection> {
+ filter: Box<CollectionFilter + 'static>) -> DomRoot<HTMLCollection> {
HTMLCollection::new(window, root, filter)
}
@@ -104,7 +104,7 @@ impl HTMLCollection {
}
}
- fn set_cached_cursor(&self, index: u32, element: Option<Root<Element>>) -> Option<Root<Element>> {
+ fn set_cached_cursor(&self, index: u32, element: Option<DomRoot<Element>>) -> Option<DomRoot<Element>> {
if let Some(element) = element {
self.cached_cursor_index.set(OptionU32::some(index));
self.cached_cursor_element.set(Some(&element));
@@ -116,7 +116,7 @@ impl HTMLCollection {
// https://dom.spec.whatwg.org/#concept-getelementsbytagname
pub fn by_qualified_name(window: &Window, root: &Node, qualified_name: LocalName)
- -> Root<HTMLCollection> {
+ -> DomRoot<HTMLCollection> {
// case 1
if qualified_name == local_name!("*") {
#[derive(HeapSizeOf, JSTraceable)]
@@ -161,14 +161,14 @@ impl HTMLCollection {
}
pub fn by_tag_name_ns(window: &Window, root: &Node, tag: DOMString,
- maybe_ns: Option<DOMString>) -> Root<HTMLCollection> {
+ maybe_ns: Option<DOMString>) -> DomRoot<HTMLCollection> {
let local = LocalName::from(tag);
let ns = namespace_from_domstring(maybe_ns);
let qname = QualName::new(None, ns, local);
HTMLCollection::by_qual_tag_name(window, root, qname)
}
- pub fn by_qual_tag_name(window: &Window, root: &Node, qname: QualName) -> Root<HTMLCollection> {
+ pub fn by_qual_tag_name(window: &Window, root: &Node, qname: QualName) -> DomRoot<HTMLCollection> {
#[derive(HeapSizeOf, JSTraceable)]
struct TagNameNSFilter {
qname: QualName
@@ -186,13 +186,13 @@ impl HTMLCollection {
}
pub fn by_class_name(window: &Window, root: &Node, classes: DOMString)
- -> Root<HTMLCollection> {
+ -> DomRoot<HTMLCollection> {
let class_atoms = split_html_space_chars(&classes).map(Atom::from).collect();
HTMLCollection::by_atomic_class_name(window, root, class_atoms)
}
pub fn by_atomic_class_name(window: &Window, root: &Node, classes: Vec<Atom>)
- -> Root<HTMLCollection> {
+ -> DomRoot<HTMLCollection> {
#[derive(HeapSizeOf, JSTraceable)]
struct ClassNameFilter {
classes: Vec<Atom>
@@ -211,7 +211,7 @@ impl HTMLCollection {
HTMLCollection::create(window, root, box filter)
}
- pub fn children(window: &Window, root: &Node) -> Root<HTMLCollection> {
+ pub fn children(window: &Window, root: &Node) -> DomRoot<HTMLCollection> {
#[derive(HeapSizeOf, JSTraceable)]
struct ElementChildFilter;
impl CollectionFilter for ElementChildFilter {
@@ -222,27 +222,27 @@ impl HTMLCollection {
HTMLCollection::create(window, root, box ElementChildFilter)
}
- pub fn elements_iter_after<'a>(&'a self, after: &'a Node) -> impl Iterator<Item=Root<Element>> + 'a {
+ pub fn elements_iter_after<'a>(&'a self, after: &'a Node) -> impl Iterator<Item=DomRoot<Element>> + 'a {
// Iterate forwards from a node.
after.following_nodes(&self.root)
- .filter_map(Root::downcast)
+ .filter_map(DomRoot::downcast)
.filter(move |element| self.filter.filter(&element, &self.root))
}
- pub fn elements_iter<'a>(&'a self) -> impl Iterator<Item=Root<Element>> + 'a {
+ pub fn elements_iter<'a>(&'a self) -> impl Iterator<Item=DomRoot<Element>> + 'a {
// Iterate forwards from the root.
self.elements_iter_after(&*self.root)
}
- pub fn elements_iter_before<'a>(&'a self, before: &'a Node) -> impl Iterator<Item=Root<Element>> + 'a {
+ pub fn elements_iter_before<'a>(&'a self, before: &'a Node) -> impl Iterator<Item=DomRoot<Element>> + 'a {
// Iterate backwards from a node.
before.preceding_nodes(&self.root)
- .filter_map(Root::downcast)
+ .filter_map(DomRoot::downcast)
.filter(move |element| self.filter.filter(&element, &self.root))
}
- pub fn root_node(&self) -> Root<Node> {
- Root::from_ref(&self.root)
+ pub fn root_node(&self) -> DomRoot<Node> {
+ DomRoot::from_ref(&self.root)
}
}
@@ -263,7 +263,7 @@ impl HTMLCollectionMethods for HTMLCollection {
}
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
- fn Item(&self, index: u32) -> Option<Root<Element>> {
+ fn Item(&self, index: u32) -> Option<DomRoot<Element>> {
self.validate_cache();
if let Some(element) = self.cached_cursor_element.get() {
@@ -276,14 +276,14 @@ impl HTMLCollectionMethods for HTMLCollection {
// The cursor is before the element we're looking for
// Iterate forwards, starting at the cursor.
let offset = index - (cached_index + 1);
- let node: Root<Node> = Root::upcast(element);
+ let node: DomRoot<Node> = DomRoot::upcast(element);
let mut iter = self.elements_iter_after(&node);
self.set_cached_cursor(index, iter.nth(offset as usize))
} else {
// The cursor is after the element we're looking for
// Iterate backwards, starting at the cursor.
let offset = cached_index - (index + 1);
- let node: Root<Node> = Root::upcast(element);
+ let node: DomRoot<Node> = DomRoot::upcast(element);
let mut iter = self.elements_iter_before(&node);
self.set_cached_cursor(index, iter.nth(offset as usize))
}
@@ -300,7 +300,7 @@ impl HTMLCollectionMethods for HTMLCollection {
}
// https://dom.spec.whatwg.org/#dom-htmlcollection-nameditem
- fn NamedItem(&self, key: DOMString) -> Option<Root<Element>> {
+ fn NamedItem(&self, key: DOMString) -> Option<DomRoot<Element>> {
// Step 1.
if key.is_empty() {
return None;
@@ -314,12 +314,12 @@ impl HTMLCollectionMethods for HTMLCollection {
}
// https://dom.spec.whatwg.org/#dom-htmlcollection-item
- fn IndexedGetter(&self, index: u32) -> Option<Root<Element>> {
+ fn IndexedGetter(&self, index: u32) -> Option<DomRoot<Element>> {
self.Item(index)
}
// check-tidy: no specs after this line
- fn NamedGetter(&self, name: DOMString) -> Option<Root<Element>> {
+ fn NamedGetter(&self, name: DOMString) -> Option<DomRoot<Element>> {
self.NamedItem(name)
}