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

Side by Side Diff: sky/sdk/lib/framework/rendering/node.dart

Issue 1151573020: Fix the crash when the drawer is hidden. (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 | « sky/sdk/lib/framework/fn2.dart ('k') | 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 '../node.dart'; 5 import '../node.dart';
6 import '../scheduler.dart' as scheduler; 6 import '../scheduler.dart' as scheduler;
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 import 'dart:sky' as sky; 8 import 'dart:sky' as sky;
9 9
10 class ParentData { 10 class ParentData {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 // override this to setup .parentData correctly for your class 48 // override this to setup .parentData correctly for your class
49 if (child.parentData is! ParentData) 49 if (child.parentData is! ParentData)
50 child.parentData = new ParentData(); 50 child.parentData = new ParentData();
51 } 51 }
52 52
53 void adoptChild(RenderNode child) { // only for use by subclasses 53 void adoptChild(RenderNode child) { // only for use by subclasses
54 // call this whenever you decide a node is a child 54 // call this whenever you decide a node is a child
55 assert(child != null); 55 assert(child != null);
56 setParentData(child); 56 setParentData(child);
57 super.adoptChild(child); 57 super.adoptChild(child);
58 markNeedsLayout();
58 } 59 }
59 void dropChild(RenderNode child) { // only for use by subclasses 60 void dropChild(RenderNode child) { // only for use by subclasses
60 assert(child != null); 61 assert(child != null);
61 assert(child.parentData != null); 62 assert(child.parentData != null);
62 child.parentData.detach(); 63 child.parentData.detach();
64 if (child._relayoutSubtreeRoot != child) {
65 child._relayoutSubtreeRoot = null;
66 child._needsLayout = true;
67 }
63 super.dropChild(child); 68 super.dropChild(child);
69 markNeedsLayout();
64 } 70 }
65 71
66 static List<RenderNode> _nodesNeedingLayout = new List<RenderNode>(); 72 static List<RenderNode> _nodesNeedingLayout = new List<RenderNode>();
67 static bool _debugDoingLayout = false; 73 static bool _debugDoingLayout = false;
68 bool _needsLayout = true; 74 bool _needsLayout = true;
69 bool get needsLayout => _needsLayout; 75 bool get needsLayout => _needsLayout;
70 RenderNode _relayoutSubtreeRoot; 76 RenderNode _relayoutSubtreeRoot;
71 dynamic _constraints; 77 dynamic _constraints;
72 dynamic get constraints => _constraints; 78 dynamic get constraints => _constraints;
73 bool debugAncestorsAlreadyMarkedNeedsLayout() { 79 bool debugAncestorsAlreadyMarkedNeedsLayout() {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 230
225 abstract class RenderNodeWithChildMixin<ChildType extends RenderNode> { 231 abstract class RenderNodeWithChildMixin<ChildType extends RenderNode> {
226 ChildType _child; 232 ChildType _child;
227 ChildType get child => _child; 233 ChildType get child => _child;
228 void set child (ChildType value) { 234 void set child (ChildType value) {
229 if (_child != null) 235 if (_child != null)
230 dropChild(_child); 236 dropChild(_child);
231 _child = value; 237 _child = value;
232 if (_child != null) 238 if (_child != null)
233 adoptChild(_child); 239 adoptChild(_child);
234 markNeedsLayout();
235 } 240 }
236 void attachChildren() { 241 void attachChildren() {
237 if (_child != null) 242 if (_child != null)
238 _child.attach(); 243 _child.attach();
239 } 244 }
240 void detachChildren() { 245 void detachChildren() {
241 if (_child != null) 246 if (_child != null)
242 _child.detach(); 247 _child.detach();
243 } 248 }
244 } 249 }
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 child.parentData.previousSibling = before.parentData.previousSibling; 334 child.parentData.previousSibling = before.parentData.previousSibling;
330 child.parentData.nextSibling = before; 335 child.parentData.nextSibling = before;
331 // set up links from siblings to child 336 // set up links from siblings to child
332 assert(child.parentData.previousSibling.parentData is ParentDataType); 337 assert(child.parentData.previousSibling.parentData is ParentDataType);
333 assert(child.parentData.nextSibling.parentData is ParentDataType); 338 assert(child.parentData.nextSibling.parentData is ParentDataType);
334 child.parentData.previousSibling.parentData.nextSibling = child; 339 child.parentData.previousSibling.parentData.nextSibling = child;
335 child.parentData.nextSibling.parentData.previousSibling = child; 340 child.parentData.nextSibling.parentData.previousSibling = child;
336 assert(before.parentData.previousSibling == child); 341 assert(before.parentData.previousSibling == child);
337 } 342 }
338 } 343 }
339 markNeedsLayout();
340 } 344 }
341 void remove(ChildType child) { 345 void remove(ChildType child) {
342 assert(child.parentData is ParentDataType); 346 assert(child.parentData is ParentDataType);
343 assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild)); 347 assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
344 assert(_debugUltimateNextSiblingOf(child, equals: _lastChild)); 348 assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
345 if (child.parentData.previousSibling == null) { 349 if (child.parentData.previousSibling == null) {
346 assert(_firstChild == child); 350 assert(_firstChild == child);
347 _firstChild = child.parentData.nextSibling; 351 _firstChild = child.parentData.nextSibling;
348 } else { 352 } else {
349 assert(child.parentData.previousSibling.parentData is ParentDataType); 353 assert(child.parentData.previousSibling.parentData is ParentDataType);
350 child.parentData.previousSibling.parentData.nextSibling = child.parentData .nextSibling; 354 child.parentData.previousSibling.parentData.nextSibling = child.parentData .nextSibling;
351 } 355 }
352 if (child.parentData.nextSibling == null) { 356 if (child.parentData.nextSibling == null) {
353 assert(_lastChild == child); 357 assert(_lastChild == child);
354 _lastChild = child.parentData.previousSibling; 358 _lastChild = child.parentData.previousSibling;
355 } else { 359 } else {
356 assert(child.parentData.nextSibling.parentData is ParentDataType); 360 assert(child.parentData.nextSibling.parentData is ParentDataType);
357 child.parentData.nextSibling.parentData.previousSibling = child.parentData .previousSibling; 361 child.parentData.nextSibling.parentData.previousSibling = child.parentData .previousSibling;
358 } 362 }
359 child.parentData.previousSibling = null; 363 child.parentData.previousSibling = null;
360 child.parentData.nextSibling = null; 364 child.parentData.nextSibling = null;
361 dropChild(child); 365 dropChild(child);
362 markNeedsLayout();
363 } 366 }
364 void redepthChildren() { 367 void redepthChildren() {
365 ChildType child = _firstChild; 368 ChildType child = _firstChild;
366 while (child != null) { 369 while (child != null) {
367 redepthChild(child); 370 redepthChild(child);
368 assert(child.parentData is ParentDataType); 371 assert(child.parentData is ParentDataType);
369 child = child.parentData.nextSibling; 372 child = child.parentData.nextSibling;
370 } 373 }
371 } 374 }
372 void attachChildren() { 375 void attachChildren() {
(...skipping 13 matching lines...) Expand all
386 } 389 }
387 } 390 }
388 391
389 ChildType get firstChild => _firstChild; 392 ChildType get firstChild => _firstChild;
390 ChildType get lastChild => _lastChild; 393 ChildType get lastChild => _lastChild;
391 ChildType childAfter(ChildType child) { 394 ChildType childAfter(ChildType child) {
392 assert(child.parentData is ParentDataType); 395 assert(child.parentData is ParentDataType);
393 return child.parentData.nextSibling; 396 return child.parentData.nextSibling;
394 } 397 }
395 } 398 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/fn2.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698