Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: sky/sdk/lib/rendering/object.dart

Issue 1217533002: Add RenderObject.childCount (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Moved childCount to ContainerRenderObjectMixin Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/tabs.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/rendering/object.dart
diff --git a/sky/sdk/lib/rendering/object.dart b/sky/sdk/lib/rendering/object.dart
index a21db01421615485521d0d36a5e7c7a53cb57c5e..3e92d3d9204a073fd766e0f86c0b7593cd186a84 100644
--- a/sky/sdk/lib/rendering/object.dart
+++ b/sky/sdk/lib/rendering/object.dart
@@ -367,7 +367,6 @@ abstract class ContainerParentDataMixin<ChildType extends RenderObject> {
}
abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, ParentDataType extends ContainerParentDataMixin<ChildType>> implements RenderObject {
- // abstract class that has only InlineNode children
bool _debugUltimatePreviousSiblingOf(ChildType child, { ChildType equals }) {
assert(child.parentData is ParentDataType);
@@ -388,12 +387,19 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
return child == equals;
}
+ int _childCount = 0;
+ int get childCount => _childCount;
+
ChildType _firstChild;
ChildType _lastChild;
void _addToChildList(ChildType child, { ChildType before }) {
assert(child.parentData is ParentDataType);
assert(child.parentData.nextSibling == null);
assert(child.parentData.previousSibling == null);
+
+ _childCount += 1;
Hixie 2015/06/26 18:04:33 Since the rest of this function doesn't have parag
hansmuller 2015/06/26 18:16:10 Done.
+ assert(_childCount > 0);
+
if (before == null) {
// append at the end (_lastChild)
child.parentData.previousSibling = _lastChild;
@@ -448,6 +454,10 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
assert(child.parentData is ParentDataType);
assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
+
+ _childCount -= 1;
+ assert(_childCount > 0);
+
Hixie 2015/06/26 18:04:33 ditto here
hansmuller 2015/06/26 18:16:10 Done.
if (child.parentData.previousSibling == null) {
assert(_firstChild == child);
_firstChild = child.parentData.nextSibling;
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/tabs.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698