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

Side by Side 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, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | sky/sdk/lib/widgets/tabs.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'dart:math' as math; 5 import 'dart:math' as math;
6 import 'dart:sky' as sky; 6 import 'dart:sky' as sky;
7 import 'dart:sky' show Point, Size, Rect, Color, Paint, Path; 7 import 'dart:sky' show Point, Size, Rect, Color, Paint, Path;
8 8
9 import '../base/hit_test.dart'; 9 import '../base/hit_test.dart';
10 import '../base/node.dart'; 10 import '../base/node.dart';
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 assert(nextSibling != this); 360 assert(nextSibling != this);
361 assert(nextSibling.parentData.previousSibling == this); 361 assert(nextSibling.parentData.previousSibling == this);
362 nextSibling.parentData.previousSibling = previousSibling; 362 nextSibling.parentData.previousSibling = previousSibling;
363 } 363 }
364 previousSibling = null; 364 previousSibling = null;
365 nextSibling = null; 365 nextSibling = null;
366 } 366 }
367 } 367 }
368 368
369 abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent DataType extends ContainerParentDataMixin<ChildType>> implements RenderObject { 369 abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent DataType extends ContainerParentDataMixin<ChildType>> implements RenderObject {
370 // abstract class that has only InlineNode children
371 370
372 bool _debugUltimatePreviousSiblingOf(ChildType child, { ChildType equals }) { 371 bool _debugUltimatePreviousSiblingOf(ChildType child, { ChildType equals }) {
373 assert(child.parentData is ParentDataType); 372 assert(child.parentData is ParentDataType);
374 while (child.parentData.previousSibling != null) { 373 while (child.parentData.previousSibling != null) {
375 assert(child.parentData.previousSibling != child); 374 assert(child.parentData.previousSibling != child);
376 child = child.parentData.previousSibling; 375 child = child.parentData.previousSibling;
377 assert(child.parentData is ParentDataType); 376 assert(child.parentData is ParentDataType);
378 } 377 }
379 return child == equals; 378 return child == equals;
380 } 379 }
381 bool _debugUltimateNextSiblingOf(ChildType child, { ChildType equals }) { 380 bool _debugUltimateNextSiblingOf(ChildType child, { ChildType equals }) {
382 assert(child.parentData is ParentDataType); 381 assert(child.parentData is ParentDataType);
383 while (child.parentData.nextSibling != null) { 382 while (child.parentData.nextSibling != null) {
384 assert(child.parentData.nextSibling != child); 383 assert(child.parentData.nextSibling != child);
385 child = child.parentData.nextSibling; 384 child = child.parentData.nextSibling;
386 assert(child.parentData is ParentDataType); 385 assert(child.parentData is ParentDataType);
387 } 386 }
388 return child == equals; 387 return child == equals;
389 } 388 }
390 389
390 int _childCount = 0;
391 int get childCount => _childCount;
392
391 ChildType _firstChild; 393 ChildType _firstChild;
392 ChildType _lastChild; 394 ChildType _lastChild;
393 void _addToChildList(ChildType child, { ChildType before }) { 395 void _addToChildList(ChildType child, { ChildType before }) {
394 assert(child.parentData is ParentDataType); 396 assert(child.parentData is ParentDataType);
395 assert(child.parentData.nextSibling == null); 397 assert(child.parentData.nextSibling == null);
396 assert(child.parentData.previousSibling == null); 398 assert(child.parentData.previousSibling == null);
399 _childCount += 1;
400 assert(_childCount > 0);
397 if (before == null) { 401 if (before == null) {
398 // append at the end (_lastChild) 402 // append at the end (_lastChild)
399 child.parentData.previousSibling = _lastChild; 403 child.parentData.previousSibling = _lastChild;
400 if (_lastChild != null) { 404 if (_lastChild != null) {
401 assert(_lastChild.parentData is ParentDataType); 405 assert(_lastChild.parentData is ParentDataType);
402 _lastChild.parentData.nextSibling = child; 406 _lastChild.parentData.nextSibling = child;
403 } 407 }
404 _lastChild = child; 408 _lastChild = child;
405 if (_firstChild == null) 409 if (_firstChild == null)
406 _firstChild = child; 410 _firstChild = child;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 } 445 }
442 void addAll(List<ChildType> children) { 446 void addAll(List<ChildType> children) {
443 if (children != null) 447 if (children != null)
444 for (ChildType child in children) 448 for (ChildType child in children)
445 add(child); 449 add(child);
446 } 450 }
447 void _removeFromChildList(ChildType child) { 451 void _removeFromChildList(ChildType child) {
448 assert(child.parentData is ParentDataType); 452 assert(child.parentData is ParentDataType);
449 assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild)); 453 assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
450 assert(_debugUltimateNextSiblingOf(child, equals: _lastChild)); 454 assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
455 _childCount -= 1;
456 assert(_childCount > 0);
451 if (child.parentData.previousSibling == null) { 457 if (child.parentData.previousSibling == null) {
452 assert(_firstChild == child); 458 assert(_firstChild == child);
453 _firstChild = child.parentData.nextSibling; 459 _firstChild = child.parentData.nextSibling;
454 } else { 460 } else {
455 assert(child.parentData.previousSibling.parentData is ParentDataType); 461 assert(child.parentData.previousSibling.parentData is ParentDataType);
456 child.parentData.previousSibling.parentData.nextSibling = child.parentData .nextSibling; 462 child.parentData.previousSibling.parentData.nextSibling = child.parentData .nextSibling;
457 } 463 }
458 if (child.parentData.nextSibling == null) { 464 if (child.parentData.nextSibling == null) {
459 assert(_lastChild == child); 465 assert(_lastChild == child);
460 _lastChild = child.parentData.previousSibling; 466 _lastChild = child.parentData.previousSibling;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 int count = 1; 531 int count = 1;
526 ChildType child = _firstChild; 532 ChildType child = _firstChild;
527 while (child != null) { 533 while (child != null) {
528 result += '${prefix}child ${count}: ${child.toString(prefix)}'; 534 result += '${prefix}child ${count}: ${child.toString(prefix)}';
529 count += 1; 535 count += 1;
530 child = child.parentData.nextSibling; 536 child = child.parentData.nextSibling;
531 } 537 }
532 return result; 538 return result;
533 } 539 }
534 } 540 }
OLDNEW
« 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