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

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: Removed extraneous blank lines 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..f899d31bedd1f76ee2b54d42a77911e2411b273f 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,17 @@ 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;
+ assert(_childCount > 0);
if (before == null) {
// append at the end (_lastChild)
child.parentData.previousSibling = _lastChild;
@@ -448,6 +452,8 @@ 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);
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