Commit 9e7e2778 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Rename "detachChild" to "forgetChild" (#6845)

...to avoid confusion with "detachRenderObject" which is basically
unrelated.
parent 856fef87
...@@ -495,7 +495,7 @@ class RenderObjectToWidgetElement<T extends RenderObject> extends RootRenderObje ...@@ -495,7 +495,7 @@ class RenderObjectToWidgetElement<T extends RenderObject> extends RootRenderObje
} }
@override @override
void detachChild(Element child) { void forgetChild(Element child) {
assert(child == _child); assert(child == _child);
_child = null; _child = null;
} }
......
...@@ -70,7 +70,7 @@ class _LayoutBuilderElement extends RenderObjectElement { ...@@ -70,7 +70,7 @@ class _LayoutBuilderElement extends RenderObjectElement {
} }
@override @override
void detachChild(Element child) { void forgetChild(Element child) {
assert(child == _child); assert(child == _child);
_child = null; _child = null;
} }
......
...@@ -514,9 +514,9 @@ class _LazyBlockElement extends RenderObjectElement { ...@@ -514,9 +514,9 @@ class _LazyBlockElement extends RenderObjectElement {
} }
@override @override
void detachChild(Element child) { void forgetChild(Element child) {
assert(() { assert(() {
// TODO(ianh): implement detachChild for LazyBlock // TODO(ianh): implement forgetChild for LazyBlock
throw new FlutterError( throw new FlutterError(
'LazyBlock does not yet support GlobalKey reparenting of its children.\n' 'LazyBlock does not yet support GlobalKey reparenting of its children.\n'
'As a temporary workaround, wrap the child with the GlobalKey in a ' 'As a temporary workaround, wrap the child with the GlobalKey in a '
......
...@@ -418,7 +418,7 @@ class _TheatreElement extends RenderObjectElement { ...@@ -418,7 +418,7 @@ class _TheatreElement extends RenderObjectElement {
static final Object _onstageSlot = new Object(); static final Object _onstageSlot = new Object();
List<Element> _offstage; List<Element> _offstage;
final Set<Element> _detachedOffstageChildren = new HashSet<Element>(); final Set<Element> _forgottenOffstageChildren = new HashSet<Element>();
@override @override
void insertChildRenderObject(RenderBox child, dynamic slot) { void insertChildRenderObject(RenderBox child, dynamic slot) {
...@@ -462,7 +462,7 @@ class _TheatreElement extends RenderObjectElement { ...@@ -462,7 +462,7 @@ class _TheatreElement extends RenderObjectElement {
if (_onstage != null) if (_onstage != null)
visitor(_onstage); visitor(_onstage);
for (Element child in _offstage) { for (Element child in _offstage) {
if (!_detachedOffstageChildren.contains(child)) if (!_forgottenOffstageChildren.contains(child))
visitor(child); visitor(child);
} }
} }
...@@ -474,13 +474,13 @@ class _TheatreElement extends RenderObjectElement { ...@@ -474,13 +474,13 @@ class _TheatreElement extends RenderObjectElement {
} }
@override @override
bool detachChild(Element child) { bool forgetChild(Element child) {
if (child == _onstage) { if (child == _onstage) {
_onstage = null; _onstage = null;
} else { } else {
assert(_offstage.contains(child)); assert(_offstage.contains(child));
assert(!_detachedOffstageChildren.contains(child)); assert(!_forgottenOffstageChildren.contains(child));
_detachedOffstageChildren.add(child); _forgottenOffstageChildren.add(child);
} }
return true; return true;
} }
...@@ -503,8 +503,8 @@ class _TheatreElement extends RenderObjectElement { ...@@ -503,8 +503,8 @@ class _TheatreElement extends RenderObjectElement {
super.update(newWidget); super.update(newWidget);
assert(widget == newWidget); assert(widget == newWidget);
_onstage = updateChild(_onstage, widget.onstage, _onstageSlot); _onstage = updateChild(_onstage, widget.onstage, _onstageSlot);
_offstage = updateChildren(_offstage, widget.offstage, detachedChildren: _detachedOffstageChildren); _offstage = updateChildren(_offstage, widget.offstage, forgottenChildren: _forgottenOffstageChildren);
_detachedOffstageChildren.clear(); _forgottenOffstageChildren.clear();
} }
} }
......
...@@ -274,7 +274,7 @@ class _TableElement extends RenderObjectElement { ...@@ -274,7 +274,7 @@ class _TableElement extends RenderObjectElement {
renderObject.setChild(childParentData.x, childParentData.y, null); renderObject.setChild(childParentData.x, childParentData.y, null);
} }
final Set<Element> _detachedChildren = new HashSet<Element>(); final Set<Element> _forgottenChildren = new HashSet<Element>();
@override @override
void update(Table newWidget) { void update(Table newWidget) {
...@@ -300,17 +300,17 @@ class _TableElement extends RenderObjectElement { ...@@ -300,17 +300,17 @@ class _TableElement extends RenderObjectElement {
} }
newChildren.add(new _TableElementRow( newChildren.add(new _TableElementRow(
key: row.key, key: row.key,
children: updateChildren(oldChildren, row.children, detachedChildren: _detachedChildren) children: updateChildren(oldChildren, row.children, forgottenChildren: _forgottenChildren)
)); ));
} }
while (oldUnkeyedRows.moveNext()) while (oldUnkeyedRows.moveNext())
updateChildren(oldUnkeyedRows.current.children, const <Widget>[], detachedChildren: _detachedChildren); updateChildren(oldUnkeyedRows.current.children, const <Widget>[], forgottenChildren: _forgottenChildren);
for (List<Element> oldChildren in oldKeyedRows.values.where((List<Element> list) => !taken.contains(list))) for (List<Element> oldChildren in oldKeyedRows.values.where((List<Element> list) => !taken.contains(list)))
updateChildren(oldChildren, const <Widget>[], detachedChildren: _detachedChildren); updateChildren(oldChildren, const <Widget>[], forgottenChildren: _forgottenChildren);
assert(() { _debugWillReattachChildren = false; return true; }); assert(() { _debugWillReattachChildren = false; return true; });
_children = newChildren; _children = newChildren;
_updateRenderObjectChildren(); _updateRenderObjectChildren();
_detachedChildren.clear(); _forgottenChildren.clear();
super.update(newWidget); super.update(newWidget);
assert(widget == newWidget); assert(widget == newWidget);
} }
...@@ -326,14 +326,14 @@ class _TableElement extends RenderObjectElement { ...@@ -326,14 +326,14 @@ class _TableElement extends RenderObjectElement {
@override @override
void visitChildren(ElementVisitor visitor) { void visitChildren(ElementVisitor visitor) {
for (Element child in _children.expand((_TableElementRow row) => row.children)) { for (Element child in _children.expand((_TableElementRow row) => row.children)) {
if (!_detachedChildren.contains(child)) if (!_forgottenChildren.contains(child))
visitor(child); visitor(child);
} }
} }
@override @override
bool detachChild(Element child) { bool forgetChild(Element child) {
_detachedChildren.add(child); _forgottenChildren.add(child);
return true; return true;
} }
} }
......
...@@ -104,9 +104,9 @@ abstract class VirtualViewportElement extends RenderObjectElement { ...@@ -104,9 +104,9 @@ abstract class VirtualViewportElement extends RenderObjectElement {
} }
@override @override
void detachChild(Element child) { void forgetChild(Element child) {
assert(() { assert(() {
// TODO(ianh): implement detachChild for VirtualViewport // TODO(ianh): implement forgetChild for VirtualViewport
throw new FlutterError( throw new FlutterError(
'$runtimeType does not yet support GlobalKey reparenting of its children.\n' '$runtimeType does not yet support GlobalKey reparenting of its children.\n'
'As a temporary workaround, wrap the child with the GlobalKey in a ' 'As a temporary workaround, wrap the child with the GlobalKey in a '
......
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