OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
1 class AbstractNode { | 5 class AbstractNode { |
2 | 6 |
3 // AbstractNode represents a node in a tree. | 7 // AbstractNode represents a node in a tree. |
4 // The AbstractNode protocol is as follows: | 8 // The AbstractNode protocol is as follows: |
5 // - When a subclass is changing the parent of a child, it should | 9 // - When a subclass is changing the parent of a child, it should |
6 // call either parent.adoptChild(child) or parent.dropChild(child) | 10 // call either parent.adoptChild(child) or parent.dropChild(child) |
7 // as appropriate. Subclasses should expose an API for | 11 // as appropriate. Subclasses should expose an API for |
8 // manipulating the tree if you want to (e.g. a setter for a | 12 // manipulating the tree if you want to (e.g. a setter for a |
9 // 'child' property, or an 'add()' method to manipulate a list). | 13 // 'child' property, or an 'add()' method to manipulate a list). |
10 // - You can see the current parent by querying 'parent'. | 14 // - You can see the current parent by querying 'parent'. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 void dropChild(AbstractNode child) { // only for use by subclasses | 77 void dropChild(AbstractNode child) { // only for use by subclasses |
74 assert(child != null); | 78 assert(child != null); |
75 assert(child._parent == this); | 79 assert(child._parent == this); |
76 assert(child.attached == attached); | 80 assert(child.attached == attached); |
77 child._parent = null; | 81 child._parent = null; |
78 if (attached) | 82 if (attached) |
79 child.detach(); | 83 child.detach(); |
80 } | 84 } |
81 | 85 |
82 } | 86 } |
OLD | NEW |