Remove workarounds that avoided 'super' in mixins
Dart supports this properly now.
This commit is contained in:
parent
57cc25a3aa
commit
dfc7f00a88
@ -631,7 +631,8 @@ abstract class RenderBox extends RenderObject {
|
|||||||
String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(prefix)}${prefix}size: ${size}\n';
|
String debugDescribeSettings(String prefix) => '${super.debugDescribeSettings(prefix)}${prefix}size: ${size}\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A mixin that provides useful default behaviors for boxes with children managed by the [ContainerRenderObjectMixin] mixin
|
/// A mixin that provides useful default behaviors for boxes with children
|
||||||
|
/// managed by the [ContainerRenderObjectMixin] mixin.
|
||||||
///
|
///
|
||||||
/// By convention, this class doesn't override any members of the superclass.
|
/// By convention, this class doesn't override any members of the superclass.
|
||||||
/// Instead, it provides helpful functions that subclasses can call as
|
/// Instead, it provides helpful functions that subclasses can call as
|
||||||
|
@ -68,32 +68,20 @@ class AbstractNode {
|
|||||||
|
|
||||||
/// Mark this node as attached.
|
/// Mark this node as attached.
|
||||||
///
|
///
|
||||||
/// Typically called only from overrides of [attachChildren] and to mark the
|
/// Typically called only from the parent's attach(), and to mark the root of
|
||||||
/// root of a tree attached.
|
/// a tree attached.
|
||||||
void attach() {
|
void attach() {
|
||||||
_attached = true;
|
_attached = true;
|
||||||
attachChildren();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Override this function in subclasses with child to call attach() for each
|
|
||||||
/// child. Do not call directly.
|
|
||||||
attachChildren() { }
|
|
||||||
|
|
||||||
/// Mark this node as detached.
|
/// Mark this node as detached.
|
||||||
///
|
///
|
||||||
/// Typically called only from overrides for [detachChildren] and to mark the
|
/// Typically called only from the parent's detach(), and to mark the root of
|
||||||
/// root of a tree detached.
|
/// a tree detached.
|
||||||
void detach() {
|
void detach() {
|
||||||
_attached = false;
|
_attached = false;
|
||||||
detachChildren();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Override this function in subclasses with child to call detach() for each
|
|
||||||
/// child. Do not call directly.
|
|
||||||
detachChildren() { }
|
|
||||||
|
|
||||||
// TODO(ianh): remove attachChildren()/detachChildren() workaround once mixins can use super.
|
|
||||||
|
|
||||||
AbstractNode _parent;
|
AbstractNode _parent;
|
||||||
/// The parent of this node in the tree.
|
/// The parent of this node in the tree.
|
||||||
AbstractNode get parent => _parent;
|
AbstractNode get parent => _parent;
|
||||||
|
@ -25,15 +25,15 @@ typedef sky.Shader ShaderCallback(Rect bounds);
|
|||||||
/// input parameters to the parent's layout algorithm or their position relative
|
/// input parameters to the parent's layout algorithm or their position relative
|
||||||
/// to other children.
|
/// to other children.
|
||||||
class ParentData {
|
class ParentData {
|
||||||
void detach() {
|
/// Called when the RenderObject is removed from the tree.
|
||||||
detachSiblings();
|
void detach() { }
|
||||||
}
|
|
||||||
void detachSiblings() { } // workaround for lack of inter-class mixins in Dart
|
|
||||||
|
|
||||||
/// Override this function in subclasses to merge in data from other instance into this instance
|
/// Override this function in subclasses to merge in data from other instance
|
||||||
|
/// into this instance.
|
||||||
void merge(ParentData other) {
|
void merge(ParentData other) {
|
||||||
assert(other.runtimeType == this.runtimeType);
|
assert(other.runtimeType == this.runtimeType);
|
||||||
}
|
}
|
||||||
|
|
||||||
String toString() => '<none>';
|
String toString() => '<none>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1158,11 +1158,13 @@ abstract class RenderObjectWithChildMixin<ChildType extends RenderObject> implem
|
|||||||
if (_child != null)
|
if (_child != null)
|
||||||
adoptChild(_child);
|
adoptChild(_child);
|
||||||
}
|
}
|
||||||
void attachChildren() {
|
void attach() {
|
||||||
|
super.attach();
|
||||||
if (_child != null)
|
if (_child != null)
|
||||||
_child.attach();
|
_child.attach();
|
||||||
}
|
}
|
||||||
void detachChildren() {
|
void detach() {
|
||||||
|
super.detach();
|
||||||
if (_child != null)
|
if (_child != null)
|
||||||
_child.detach();
|
_child.detach();
|
||||||
}
|
}
|
||||||
@ -1178,14 +1180,15 @@ abstract class RenderObjectWithChildMixin<ChildType extends RenderObject> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parent data to support a doubly-linked list of children
|
/// Parent data to support a doubly-linked list of children
|
||||||
abstract class ContainerParentDataMixin<ChildType extends RenderObject> {
|
abstract class ContainerParentDataMixin<ChildType extends RenderObject> implements ParentData {
|
||||||
/// The previous sibling in the parent's child list
|
/// The previous sibling in the parent's child list
|
||||||
ChildType previousSibling;
|
ChildType previousSibling;
|
||||||
/// The next sibling in the parent's child list
|
/// The next sibling in the parent's child list
|
||||||
ChildType nextSibling;
|
ChildType nextSibling;
|
||||||
|
|
||||||
/// Clear the sibling pointers.
|
/// Clear the sibling pointers.
|
||||||
void detachSiblings() {
|
void detach() {
|
||||||
|
super.detach();
|
||||||
if (previousSibling != null) {
|
if (previousSibling != null) {
|
||||||
assert(previousSibling.parentData is ContainerParentDataMixin<ChildType>);
|
assert(previousSibling.parentData is ContainerParentDataMixin<ChildType>);
|
||||||
assert(previousSibling != this);
|
assert(previousSibling != this);
|
||||||
@ -1362,6 +1365,27 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
|
|||||||
_removeFromChildList(child);
|
_removeFromChildList(child);
|
||||||
_addToChildList(child, before: before);
|
_addToChildList(child, before: before);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void attach() {
|
||||||
|
super.attach();
|
||||||
|
ChildType child = _firstChild;
|
||||||
|
while (child != null) {
|
||||||
|
child.attach();
|
||||||
|
assert(child.parentData is ParentDataType);
|
||||||
|
child = child.parentData.nextSibling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void detach() {
|
||||||
|
super.detach();
|
||||||
|
ChildType child = _firstChild;
|
||||||
|
while (child != null) {
|
||||||
|
child.detach();
|
||||||
|
assert(child.parentData is ParentDataType);
|
||||||
|
child = child.parentData.nextSibling;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void redepthChildren() {
|
void redepthChildren() {
|
||||||
ChildType child = _firstChild;
|
ChildType child = _firstChild;
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
@ -1370,22 +1394,7 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
|
|||||||
child = child.parentData.nextSibling;
|
child = child.parentData.nextSibling;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void attachChildren() {
|
|
||||||
ChildType child = _firstChild;
|
|
||||||
while (child != null) {
|
|
||||||
child.attach();
|
|
||||||
assert(child.parentData is ParentDataType);
|
|
||||||
child = child.parentData.nextSibling;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void detachChildren() {
|
|
||||||
ChildType child = _firstChild;
|
|
||||||
while (child != null) {
|
|
||||||
child.detach();
|
|
||||||
assert(child.parentData is ParentDataType);
|
|
||||||
child = child.parentData.nextSibling;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void visitChildren(RenderObjectVisitor visitor) {
|
void visitChildren(RenderObjectVisitor visitor) {
|
||||||
ChildType child = _firstChild;
|
ChildType child = _firstChild;
|
||||||
while (child != null) {
|
while (child != null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user