Address review comments; add docs

This commit is contained in:
Manish Goregaokar 2015-07-22 18:28:02 +05:30
parent 521d8bc32e
commit a9f651cfa1
2 changed files with 9 additions and 5 deletions

View file

@ -26,6 +26,10 @@ declare_lint!(UNROOTED_MUST_ROOT, Deny,
/// ///
/// This helps catch most situations where pointers like `JS<T>` are used in a way that they can be invalidated by a /// This helps catch most situations where pointers like `JS<T>` are used in a way that they can be invalidated by a
/// GC pass. /// GC pass.
///
/// Structs which have their own mechanism of rooting their unrooted contents (e.g. `ScriptTask`)
/// can be marked as `#[allow(unrooted_must_root)]`. Smart pointers which root their interior type
/// can be marked as `#[allow_unrooted_interior]`
pub struct UnrootedPass { pub struct UnrootedPass {
in_new_function: bool in_new_function: bool
} }

View file

@ -328,7 +328,7 @@ impl<'a> PrivateNodeHelpers for &'a Node {
match before { match before {
Some(ref before) => { Some(ref before) => {
assert!(before.parent_node.get().map(Root::from_rooted).r() == Some(self)); assert!(before.parent_node.get().map(Root::from_rooted).r() == Some(self));
let prev_sibling = before.prev_sibling.get_rooted(); let prev_sibling = before.GetPreviousSibling();
match prev_sibling { match prev_sibling {
None => { None => {
assert!(Some(*before) == self.first_child.get().map(Root::from_rooted).r()); assert!(Some(*before) == self.first_child.get().map(Root::from_rooted).r());
@ -343,7 +343,7 @@ impl<'a> PrivateNodeHelpers for &'a Node {
new_child.next_sibling.set(Some(JS::from_ref(before))); new_child.next_sibling.set(Some(JS::from_ref(before)));
}, },
None => { None => {
let last_child = self.last_child.get_rooted(); let last_child = self.GetLastChild();
match last_child { match last_child {
None => self.first_child.set(Some(JS::from_ref(new_child))), None => self.first_child.set(Some(JS::from_ref(new_child))),
Some(ref last_child) => { Some(ref last_child) => {
@ -365,7 +365,7 @@ impl<'a> PrivateNodeHelpers for &'a Node {
/// Fails unless `child` is a child of this node. /// Fails unless `child` is a child of this node.
fn remove_child(self, child: &Node) { fn remove_child(self, child: &Node) {
assert!(child.parent_node.get().map(Root::from_rooted).r() == Some(self)); assert!(child.parent_node.get().map(Root::from_rooted).r() == Some(self));
let prev_sibling = child.prev_sibling.get_rooted(); let prev_sibling = child.GetPreviousSibling();
match prev_sibling { match prev_sibling {
None => { None => {
self.first_child.set(child.next_sibling.get()); self.first_child.set(child.next_sibling.get());
@ -374,7 +374,7 @@ impl<'a> PrivateNodeHelpers for &'a Node {
prev_sibling.next_sibling.set(child.next_sibling.get()); prev_sibling.next_sibling.set(child.next_sibling.get());
} }
} }
let next_sibling = child.next_sibling.get_rooted(); let next_sibling = child.GetNextSibling();
match next_sibling { match next_sibling {
None => { None => {
self.last_child.set(child.prev_sibling.get()); self.last_child.set(child.prev_sibling.get());
@ -1476,7 +1476,7 @@ impl Node {
// https://dom.spec.whatwg.org/#concept-node-adopt // https://dom.spec.whatwg.org/#concept-node-adopt
pub fn adopt(node: &Node, document: &Document) { pub fn adopt(node: &Node, document: &Document) {
// Step 1. // Step 1.
let parent_node = node.parent_node.get_rooted(); let parent_node = node.GetParentNode();
match parent_node { match parent_node {
Some(ref parent) => { Some(ref parent) => {
Node::remove(node, parent, SuppressObserver::Unsuppressed); Node::remove(node, parent, SuppressObserver::Unsuppressed);