Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 | |
| 400 _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.
| |
| 401 assert(_childCount > 0); | |
| 402 | |
| 397 if (before == null) { | 403 if (before == null) { |
| 398 // append at the end (_lastChild) | 404 // append at the end (_lastChild) |
| 399 child.parentData.previousSibling = _lastChild; | 405 child.parentData.previousSibling = _lastChild; |
| 400 if (_lastChild != null) { | 406 if (_lastChild != null) { |
| 401 assert(_lastChild.parentData is ParentDataType); | 407 assert(_lastChild.parentData is ParentDataType); |
| 402 _lastChild.parentData.nextSibling = child; | 408 _lastChild.parentData.nextSibling = child; |
| 403 } | 409 } |
| 404 _lastChild = child; | 410 _lastChild = child; |
| 405 if (_firstChild == null) | 411 if (_firstChild == null) |
| 406 _firstChild = child; | 412 _firstChild = child; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 } | 447 } |
| 442 void addAll(List<ChildType> children) { | 448 void addAll(List<ChildType> children) { |
| 443 if (children != null) | 449 if (children != null) |
| 444 for (ChildType child in children) | 450 for (ChildType child in children) |
| 445 add(child); | 451 add(child); |
| 446 } | 452 } |
| 447 void _removeFromChildList(ChildType child) { | 453 void _removeFromChildList(ChildType child) { |
| 448 assert(child.parentData is ParentDataType); | 454 assert(child.parentData is ParentDataType); |
| 449 assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild)); | 455 assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild)); |
| 450 assert(_debugUltimateNextSiblingOf(child, equals: _lastChild)); | 456 assert(_debugUltimateNextSiblingOf(child, equals: _lastChild)); |
| 457 | |
| 458 _childCount -= 1; | |
| 459 assert(_childCount > 0); | |
| 460 | |
|
Hixie
2015/06/26 18:04:33
ditto here
hansmuller
2015/06/26 18:16:10
Done.
| |
| 451 if (child.parentData.previousSibling == null) { | 461 if (child.parentData.previousSibling == null) { |
| 452 assert(_firstChild == child); | 462 assert(_firstChild == child); |
| 453 _firstChild = child.parentData.nextSibling; | 463 _firstChild = child.parentData.nextSibling; |
| 454 } else { | 464 } else { |
| 455 assert(child.parentData.previousSibling.parentData is ParentDataType); | 465 assert(child.parentData.previousSibling.parentData is ParentDataType); |
| 456 child.parentData.previousSibling.parentData.nextSibling = child.parentData .nextSibling; | 466 child.parentData.previousSibling.parentData.nextSibling = child.parentData .nextSibling; |
| 457 } | 467 } |
| 458 if (child.parentData.nextSibling == null) { | 468 if (child.parentData.nextSibling == null) { |
| 459 assert(_lastChild == child); | 469 assert(_lastChild == child); |
| 460 _lastChild = child.parentData.previousSibling; | 470 _lastChild = child.parentData.previousSibling; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 525 int count = 1; | 535 int count = 1; |
| 526 ChildType child = _firstChild; | 536 ChildType child = _firstChild; |
| 527 while (child != null) { | 537 while (child != null) { |
| 528 result += '${prefix}child ${count}: ${child.toString(prefix)}'; | 538 result += '${prefix}child ${count}: ${child.toString(prefix)}'; |
| 529 count += 1; | 539 count += 1; |
| 530 child = child.parentData.nextSibling; | 540 child = child.parentData.nextSibling; |
| 531 } | 541 } |
| 532 return result; | 542 return result; |
| 533 } | 543 } |
| 534 } | 544 } |
| OLD | NEW |