Commit a9ad84a8 authored by Ian Hickson's avatar Ian Hickson

Merge pull request #1241 from Hixie/ancestorOfType

Move findAncestorRenderObjectWrapper to RenderObjectWrapper
parents 93ebc9e4 c363a9a2
...@@ -354,13 +354,6 @@ abstract class Widget { ...@@ -354,13 +354,6 @@ abstract class Widget {
// where to put this descendant. If you just defer to a child, then make sure // where to put this descendant. If you just defer to a child, then make sure
// to pass them the slot. // to pass them the slot.
Widget findAncestorRenderObjectWrapper() {
var ancestor = _parent;
while (ancestor != null && ancestor is! RenderObjectWrapper)
ancestor = ancestor._parent;
return ancestor;
}
Set<Type> _dependencies; Set<Type> _dependencies;
Inherited inheritedOfType(Type targetType) { Inherited inheritedOfType(Type targetType) {
if (_dependencies == null) if (_dependencies == null)
...@@ -1103,6 +1096,13 @@ abstract class RenderObjectWrapper extends Widget { ...@@ -1103,6 +1096,13 @@ abstract class RenderObjectWrapper extends Widget {
newNode._ancestor = _ancestor; newNode._ancestor = _ancestor;
} }
RenderObjectWrapper findAncestorRenderObjectWrapper() {
Widget ancestor = parent;
while (ancestor != null && ancestor is! RenderObjectWrapper)
ancestor = ancestor.parent;
return ancestor;
}
void _sync(RenderObjectWrapper old, dynamic slot) { void _sync(RenderObjectWrapper old, dynamic slot) {
// TODO(abarth): We should split RenderObjectWrapper into two pieces so that // TODO(abarth): We should split RenderObjectWrapper into two pieces so that
// RenderViewObject doesn't need to inherit all this code it // RenderViewObject doesn't need to inherit all this code it
...@@ -1113,7 +1113,7 @@ abstract class RenderObjectWrapper extends Widget { ...@@ -1113,7 +1113,7 @@ abstract class RenderObjectWrapper extends Widget {
_renderObject = createNode(); _renderObject = createNode();
assert(_renderObject != null); assert(_renderObject != null);
_ancestor = findAncestorRenderObjectWrapper(); _ancestor = findAncestorRenderObjectWrapper();
if (_ancestor is RenderObjectWrapper) if (_ancestor != null)
_ancestor.insertChildRenderObject(this, slot); _ancestor.insertChildRenderObject(this, slot);
} else { } else {
_renderObject = old.renderObject; _renderObject = old.renderObject;
......
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