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

Side by Side Diff: sky/sdk/lib/rendering/object.dart

Issue 1186123009: Clean the relayout subtree root deeply when removing a child, otherwise the tree ends up in an inco… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | 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 '../app/scheduler.dart' as scheduler; 9 import '../app/scheduler.dart' as scheduler;
10 import '../framework/node.dart'; 10 import '../framework/node.dart';
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 setParentData(child); 58 setParentData(child);
59 super.adoptChild(child); 59 super.adoptChild(child);
60 markNeedsLayout(); 60 markNeedsLayout();
61 } 61 }
62 void dropChild(RenderObject child) { // only for use by subclasses 62 void dropChild(RenderObject child) { // only for use by subclasses
63 assert(!debugDoingLayout); 63 assert(!debugDoingLayout);
64 assert(!debugDoingPaint); 64 assert(!debugDoingPaint);
65 assert(child != null); 65 assert(child != null);
66 assert(child.parentData != null); 66 assert(child.parentData != null);
67 child.parentData.detach(); 67 child.parentData.detach();
68 if (child._relayoutSubtreeRoot != child) { 68 child._cleanRelayoutSubtreeRoot();
69 child._relayoutSubtreeRoot = null;
70 child._needsLayout = true;
71 }
72 super.dropChild(child); 69 super.dropChild(child);
73 markNeedsLayout(); 70 markNeedsLayout();
74 } 71 }
75 72
76 static List<RenderObject> _nodesNeedingLayout = new List<RenderObject>(); 73 static List<RenderObject> _nodesNeedingLayout = new List<RenderObject>();
77 static bool _debugDoingLayout = false; 74 static bool _debugDoingLayout = false;
78 static bool get debugDoingLayout => _debugDoingLayout; 75 static bool get debugDoingLayout => _debugDoingLayout;
79 bool _needsLayout = true; 76 bool _needsLayout = true;
80 bool get needsLayout => _needsLayout; 77 bool get needsLayout => _needsLayout;
81 RenderObject _relayoutSubtreeRoot; 78 RenderObject _relayoutSubtreeRoot;
(...skipping 25 matching lines...) Expand all
107 if (_relayoutSubtreeRoot != this) { 104 if (_relayoutSubtreeRoot != this) {
108 final parent = this.parent; // TODO(ianh): Remove this once the analyzer i s cleverer 105 final parent = this.parent; // TODO(ianh): Remove this once the analyzer i s cleverer
109 assert(parent is RenderObject); 106 assert(parent is RenderObject);
110 parent.markNeedsLayout(); 107 parent.markNeedsLayout();
111 assert(parent == this.parent); // TODO(ianh): Remove this once the analyze r is cleverer 108 assert(parent == this.parent); // TODO(ianh): Remove this once the analyze r is cleverer
112 } else { 109 } else {
113 _nodesNeedingLayout.add(this); 110 _nodesNeedingLayout.add(this);
114 scheduler.ensureVisualUpdate(); 111 scheduler.ensureVisualUpdate();
115 } 112 }
116 } 113 }
114 void _cleanRelayoutSubtreeRoot() {
115 if (_relayoutSubtreeRoot != this) {
116 _relayoutSubtreeRoot = null;
117 _needsLayout = true;
118 _cleanRelayoutSubtreeRootChildren();
119 }
120 }
121 void _cleanRelayoutSubtreeRootChildren() { } // workaround for lack of inter-c lass mixins in Dart
117 void scheduleInitialLayout() { 122 void scheduleInitialLayout() {
118 assert(attached); 123 assert(attached);
119 assert(parent == null); 124 assert(parent == null);
120 assert(_relayoutSubtreeRoot == null); 125 assert(_relayoutSubtreeRoot == null);
121 _relayoutSubtreeRoot = this; 126 _relayoutSubtreeRoot = this;
122 _nodesNeedingLayout.add(this); 127 _nodesNeedingLayout.add(this);
123 scheduler.ensureVisualUpdate(); 128 scheduler.ensureVisualUpdate();
124 } 129 }
125 static void flushLayout() { 130 static void flushLayout() {
126 _debugDoingLayout = true; 131 _debugDoingLayout = true;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 adoptChild(_child); 295 adoptChild(_child);
291 } 296 }
292 void attachChildren() { 297 void attachChildren() {
293 if (_child != null) 298 if (_child != null)
294 _child.attach(); 299 _child.attach();
295 } 300 }
296 void detachChildren() { 301 void detachChildren() {
297 if (_child != null) 302 if (_child != null)
298 _child.detach(); 303 _child.detach();
299 } 304 }
305 void _cleanRelayoutSubtreeRootChildren() {
306 if (_child != null)
307 _child._cleanRelayoutSubtreeRoot();
308 }
300 String debugDescribeChildren(String prefix) { 309 String debugDescribeChildren(String prefix) {
301 if (child != null) 310 if (child != null)
302 return '${prefix}child: ${child.toString(prefix)}'; 311 return '${prefix}child: ${child.toString(prefix)}';
303 return ''; 312 return '';
304 } 313 }
305 } 314 }
306 315
307 316
308 // GENERIC MIXIN FOR RENDER NODES WITH A LIST OF CHILDREN 317 // GENERIC MIXIN FOR RENDER NODES WITH A LIST OF CHILDREN
309 318
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 446 }
438 } 447 }
439 void detachChildren() { 448 void detachChildren() {
440 ChildType child = _firstChild; 449 ChildType child = _firstChild;
441 while (child != null) { 450 while (child != null) {
442 child.detach(); 451 child.detach();
443 assert(child.parentData is ParentDataType); 452 assert(child.parentData is ParentDataType);
444 child = child.parentData.nextSibling; 453 child = child.parentData.nextSibling;
445 } 454 }
446 } 455 }
456 void _cleanRelayoutSubtreeRootChildren() {
457 ChildType child = _firstChild;
458 while (child != null) {
459 child._cleanRelayoutSubtreeRoot();
460 assert(child.parentData is ParentDataType);
461 child = child.parentData.nextSibling;
462 }
463 }
447 464
448 ChildType get firstChild => _firstChild; 465 ChildType get firstChild => _firstChild;
449 ChildType get lastChild => _lastChild; 466 ChildType get lastChild => _lastChild;
450 ChildType childAfter(ChildType child) { 467 ChildType childAfter(ChildType child) {
451 assert(child.parentData is ParentDataType); 468 assert(child.parentData is ParentDataType);
452 return child.parentData.nextSibling; 469 return child.parentData.nextSibling;
453 } 470 }
454 471
455 String debugDescribeChildren(String prefix) { 472 String debugDescribeChildren(String prefix) {
456 String result = ''; 473 String result = '';
457 int count = 1; 474 int count = 1;
458 ChildType child = _firstChild; 475 ChildType child = _firstChild;
459 while (child != null) { 476 while (child != null) {
460 result += '${prefix}child ${count}: ${child.toString(prefix)}'; 477 result += '${prefix}child ${count}: ${child.toString(prefix)}';
461 count += 1; 478 count += 1;
462 child = child.parentData.nextSibling; 479 child = child.parentData.nextSibling;
463 } 480 }
464 return result; 481 return result;
465 } 482 }
466 } 483 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698