Commit 2db1f59c authored by Adam Barth's avatar Adam Barth

Remove Widget.removeChild

This function just calls remove(). Also, have Widget do the recursive remove
walk by calling walkChildren.
parent 62e67957
......@@ -117,14 +117,6 @@ class BlockViewport extends RenderObjectWrapper {
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
}
void remove() {
for (Widget child in layoutState._childrenByKey.values) {
assert(child != null);
removeChild(child);
}
super.remove();
}
void didMount() {
renderObject.callback = layout;
super.didMount();
......
......@@ -295,21 +295,11 @@ abstract class Widget {
}
void remove() {
walkChildren((Widget child) => child.remove());
_renderObject = null;
setParent(null);
}
void removeChild(Widget node) {
// Call this when we no longer have a child equivalent to node.
// For example, when our child has changed type, or has been set to null.
// Do not call this when our child has been replaced by an equivalent but
// newer instance that will sync() with the old one, since in that case
// the subtree starting from the old node, as well as the render tree that
// belonged to the old node, continue to live on in the replacement node.
node.remove();
assert(node.parent == null);
}
void detachRenderObject();
// Returns the child which should be retained as the child of this node.
......@@ -328,7 +318,7 @@ abstract class Widget {
// the child in this slot has gone away
assert(oldNode.mounted);
oldNode.detachRenderObject();
removeChild(oldNode);
oldNode.remove();
assert(!oldNode.mounted);
return null;
}
......@@ -348,7 +338,7 @@ abstract class Widget {
} else {
assert(oldNode.mounted);
oldNode.detachRenderObject();
removeChild(oldNode);
oldNode.remove();
oldNode = null;
}
}
......@@ -441,12 +431,6 @@ abstract class TagNode extends Widget {
child.updateSlot(newSlot);
}
void remove() {
if (child != null)
removeChild(child);
super.remove();
}
void detachRenderObject() {
if (child != null)
child.detachRenderObject();
......@@ -618,9 +602,8 @@ abstract class Component extends Widget {
void remove() {
assert(_built != null);
assert(renderObject != null);
removeChild(_built);
_built = null;
super.remove();
_built = null;
}
void detachRenderObject() {
......@@ -1020,12 +1003,6 @@ abstract class OneChildRenderObjectWrapper extends RenderObjectWrapper {
renderObject.child = null;
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
}
void remove() {
if (child != null)
removeChild(child);
super.remove();
}
}
abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
......@@ -1062,15 +1039,6 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
}
void remove() {
assert(children != null);
for (var child in children) {
assert(child != null);
removeChild(child);
}
super.remove();
}
bool _debugHasDuplicateIds() {
var idSet = new HashSet<Key>();
for (var child in children) {
......
......@@ -219,11 +219,6 @@ class Scaffold extends RenderObjectWrapper {
assert(renderObject == this.renderObject); // TODO(ianh): Remove this once the analyzer is cleverer
}
void remove() {
walkChildren((Widget child) => removeChild(child));
super.remove();
}
void syncRenderObject(Widget old) {
super.syncRenderObject(old);
for (ScaffoldSlots slot in ScaffoldSlots.values) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment