diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-26 01:53:40 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2017-09-26 09:49:10 +0200 |
commit | f87c2a8d7616112ca924e30292db2d244cf87eec (patch) | |
tree | 7344afe7ec0ec1ac7d1d13f5385111ee9c4be332 /components/script/dom/nodelist.rs | |
parent | 577370746e2ce3da7fa25a20b8e1bbeed319df65 (diff) | |
download | servo-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/nodelist.rs')
-rw-r--r-- | components/script/dom/nodelist.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/components/script/dom/nodelist.rs b/components/script/dom/nodelist.rs index 191cc1f30cd..d6c0a394c93 100644 --- a/components/script/dom/nodelist.rs +++ b/components/script/dom/nodelist.rs @@ -6,7 +6,7 @@ use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods; use dom::bindings::codegen::Bindings::NodeListBinding; use dom::bindings::codegen::Bindings::NodeListBinding::NodeListMethods; use dom::bindings::reflector::{Reflector, reflect_dom_object}; -use dom::bindings::root::{Dom, MutNullableDom, Root, RootedReference}; +use dom::bindings::root::{Dom, DomRoot, MutNullableDom, RootedReference}; use dom::node::{ChildrenMutation, Node}; use dom::window::Window; use dom_struct::dom_struct; @@ -36,26 +36,26 @@ impl NodeList { } #[allow(unrooted_must_root)] - pub fn new(window: &Window, list_type: NodeListType) -> Root<NodeList> { + pub fn new(window: &Window, list_type: NodeListType) -> DomRoot<NodeList> { reflect_dom_object(box NodeList::new_inherited(list_type), window, NodeListBinding::Wrap) } - pub fn new_simple_list<T>(window: &Window, iter: T) -> Root<NodeList> - where T: Iterator<Item=Root<Node>> { + pub fn new_simple_list<T>(window: &Window, iter: T) -> DomRoot<NodeList> + where T: Iterator<Item=DomRoot<Node>> { NodeList::new(window, NodeListType::Simple(iter.map(|r| Dom::from_ref(&*r)).collect())) } - pub fn new_simple_list_slice(window: &Window, slice: &[&Node]) -> Root<NodeList> { + pub fn new_simple_list_slice(window: &Window, slice: &[&Node]) -> DomRoot<NodeList> { NodeList::new(window, NodeListType::Simple(slice.iter().map(|r| Dom::from_ref(*r)).collect())) } - pub fn new_child_list(window: &Window, node: &Node) -> Root<NodeList> { + pub fn new_child_list(window: &Window, node: &Node) -> DomRoot<NodeList> { NodeList::new(window, NodeListType::Children(ChildrenList::new(node))) } - pub fn empty(window: &Window) -> Root<NodeList> { + pub fn empty(window: &Window) -> DomRoot<NodeList> { NodeList::new(window, NodeListType::Simple(vec![])) } } @@ -70,17 +70,17 @@ impl NodeListMethods for NodeList { } // https://dom.spec.whatwg.org/#dom-nodelist-item - fn Item(&self, index: u32) -> Option<Root<Node>> { + fn Item(&self, index: u32) -> Option<DomRoot<Node>> { match self.list_type { NodeListType::Simple(ref elems) => { - elems.get(index as usize).map(|node| Root::from_ref(&**node)) + elems.get(index as usize).map(|node| DomRoot::from_ref(&**node)) }, NodeListType::Children(ref list) => list.item(index), } } // https://dom.spec.whatwg.org/#dom-nodelist-item - fn IndexedGetter(&self, index: u32) -> Option<Root<Node>> { + fn IndexedGetter(&self, index: u32) -> Option<DomRoot<Node>> { self.Item(index) } } @@ -103,7 +103,7 @@ impl NodeList { } } - pub fn iter<'a>(&'a self) -> impl Iterator<Item=Root<Node>> + 'a { + pub fn iter<'a>(&'a self) -> impl Iterator<Item=DomRoot<Node>> + 'a { let len = self.Length(); (0..len).flat_map(move |i| self.Item(i)) } @@ -132,7 +132,7 @@ impl ChildrenList { self.node.children_count() } - pub fn item(&self, index: u32) -> Option<Root<Node>> { + pub fn item(&self, index: u32) -> Option<DomRoot<Node>> { // This always start traversing the children from the closest element // among parent's first and last children and the last visited one. let len = self.len() as u32; |