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

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

Issue 1195113002: Improve stocks2 performance (Closed) Base URL: git@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/rendering/box.dart ('k') | sky/sdk/lib/rendering/paragraph.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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 void _cleanRelayoutSubtreeRootChildren() { } // workaround for lack of inter-c lass mixins in Dart 124 void _cleanRelayoutSubtreeRootChildren() { } // workaround for lack of inter-c lass mixins in Dart
125 void scheduleInitialLayout() { 125 void scheduleInitialLayout() {
126 assert(attached); 126 assert(attached);
127 assert(parent == null); 127 assert(parent == null);
128 assert(_relayoutSubtreeRoot == null); 128 assert(_relayoutSubtreeRoot == null);
129 _relayoutSubtreeRoot = this; 129 _relayoutSubtreeRoot = this;
130 _nodesNeedingLayout.add(this); 130 _nodesNeedingLayout.add(this);
131 scheduler.ensureVisualUpdate(); 131 scheduler.ensureVisualUpdate();
132 } 132 }
133 static void flushLayout() { 133 static void flushLayout() {
134 sky.tracing.begin('RenderObject.flushLayout');
134 _debugDoingLayout = true; 135 _debugDoingLayout = true;
135 List<RenderObject> dirtyNodes = _nodesNeedingLayout; 136 try {
136 _nodesNeedingLayout = new List<RenderObject>(); 137 List<RenderObject> dirtyNodes = _nodesNeedingLayout;
137 dirtyNodes..sort((a, b) => a.depth - b.depth)..forEach((node) { 138 _nodesNeedingLayout = new List<RenderObject>();
138 if (node._needsLayout && node.attached) 139 dirtyNodes..sort((a, b) => a.depth - b.depth)..forEach((node) {
139 node.layoutWithoutResize(); 140 if (node._needsLayout && node.attached)
140 }); 141 node.layoutWithoutResize();
141 _debugDoingLayout = false; 142 });
143 } finally {
144 _debugDoingLayout = false;
145 sky.tracing.end('RenderObject.flushLayout');
146 }
142 } 147 }
143 void layoutWithoutResize() { 148 void layoutWithoutResize() {
144 try { 149 try {
145 assert(_relayoutSubtreeRoot == this); 150 assert(_relayoutSubtreeRoot == this);
146 performLayout(); 151 performLayout();
147 } catch (e, stack) { 152 } catch (e, stack) {
148 print('Exception raised during layout of ${this}: ${e}'); 153 print('Exception raised during layout of ${this}: ${e}');
149 print(stack); 154 print(stack);
150 return; 155 return;
151 } 156 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 while (child.parentData.nextSibling != null) { 348 while (child.parentData.nextSibling != null) {
344 assert(child.parentData.nextSibling != child); 349 assert(child.parentData.nextSibling != child);
345 child = child.parentData.nextSibling; 350 child = child.parentData.nextSibling;
346 assert(child.parentData is ParentDataType); 351 assert(child.parentData is ParentDataType);
347 } 352 }
348 return child == equals; 353 return child == equals;
349 } 354 }
350 355
351 ChildType _firstChild; 356 ChildType _firstChild;
352 ChildType _lastChild; 357 ChildType _lastChild;
353 void add(ChildType child, { ChildType before }) { 358 void _addToChildList(ChildType child, { ChildType before }) {
354 assert(child != this);
355 assert(before != this);
356 assert(child != before);
357 assert(child != _firstChild);
358 assert(child != _lastChild);
359 adoptChild(child);
360 assert(child.parentData is ParentDataType); 359 assert(child.parentData is ParentDataType);
361 assert(child.parentData.nextSibling == null); 360 assert(child.parentData.nextSibling == null);
362 assert(child.parentData.previousSibling == null); 361 assert(child.parentData.previousSibling == null);
363 if (before == null) { 362 if (before == null) {
364 // append at the end (_lastChild) 363 // append at the end (_lastChild)
365 child.parentData.previousSibling = _lastChild; 364 child.parentData.previousSibling = _lastChild;
366 if (_lastChild != null) { 365 if (_lastChild != null) {
367 assert(_lastChild.parentData is ParentDataType); 366 assert(_lastChild.parentData is ParentDataType);
368 _lastChild.parentData.nextSibling = child; 367 _lastChild.parentData.nextSibling = child;
369 } 368 }
(...skipping 19 matching lines...) Expand all
389 child.parentData.nextSibling = before; 388 child.parentData.nextSibling = before;
390 // set up links from siblings to child 389 // set up links from siblings to child
391 assert(child.parentData.previousSibling.parentData is ParentDataType); 390 assert(child.parentData.previousSibling.parentData is ParentDataType);
392 assert(child.parentData.nextSibling.parentData is ParentDataType); 391 assert(child.parentData.nextSibling.parentData is ParentDataType);
393 child.parentData.previousSibling.parentData.nextSibling = child; 392 child.parentData.previousSibling.parentData.nextSibling = child;
394 child.parentData.nextSibling.parentData.previousSibling = child; 393 child.parentData.nextSibling.parentData.previousSibling = child;
395 assert(before.parentData.previousSibling == child); 394 assert(before.parentData.previousSibling == child);
396 } 395 }
397 } 396 }
398 } 397 }
399 void remove(ChildType child) { 398 void add(ChildType child, { ChildType before }) {
399 assert(child != this);
400 assert(before != this);
401 assert(child != before);
402 assert(child != _firstChild);
403 assert(child != _lastChild);
404 adoptChild(child);
405 _addToChildList(child, before: before);
406 }
407 void _removeFromChildList(ChildType child) {
400 assert(child.parentData is ParentDataType); 408 assert(child.parentData is ParentDataType);
401 assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild)); 409 assert(_debugUltimatePreviousSiblingOf(child, equals: _firstChild));
402 assert(_debugUltimateNextSiblingOf(child, equals: _lastChild)); 410 assert(_debugUltimateNextSiblingOf(child, equals: _lastChild));
403 if (child.parentData.previousSibling == null) { 411 if (child.parentData.previousSibling == null) {
404 assert(_firstChild == child); 412 assert(_firstChild == child);
405 _firstChild = child.parentData.nextSibling; 413 _firstChild = child.parentData.nextSibling;
406 } else { 414 } else {
407 assert(child.parentData.previousSibling.parentData is ParentDataType); 415 assert(child.parentData.previousSibling.parentData is ParentDataType);
408 child.parentData.previousSibling.parentData.nextSibling = child.parentData .nextSibling; 416 child.parentData.previousSibling.parentData.nextSibling = child.parentData .nextSibling;
409 } 417 }
410 if (child.parentData.nextSibling == null) { 418 if (child.parentData.nextSibling == null) {
411 assert(_lastChild == child); 419 assert(_lastChild == child);
412 _lastChild = child.parentData.previousSibling; 420 _lastChild = child.parentData.previousSibling;
413 } else { 421 } else {
414 assert(child.parentData.nextSibling.parentData is ParentDataType); 422 assert(child.parentData.nextSibling.parentData is ParentDataType);
415 child.parentData.nextSibling.parentData.previousSibling = child.parentData .previousSibling; 423 child.parentData.nextSibling.parentData.previousSibling = child.parentData .previousSibling;
416 } 424 }
417 child.parentData.previousSibling = null; 425 child.parentData.previousSibling = null;
418 child.parentData.nextSibling = null; 426 child.parentData.nextSibling = null;
427 }
428 void remove(ChildType child) {
429 _removeFromChildList(child);
419 dropChild(child); 430 dropChild(child);
420 } 431 }
432 void move(ChildType child, { ChildType before }) {
433 assert(child != this);
434 assert(before != this);
435 assert(child != before);
436 assert(child.parent == this);
437 assert(child.parentData is ParentDataType);
438 if (child.parentData.nextSibling == before)
439 return;
440 _removeFromChildList(child);
441 _addToChildList(child, before: before);
442 }
421 void redepthChildren() { 443 void redepthChildren() {
422 ChildType child = _firstChild; 444 ChildType child = _firstChild;
423 while (child != null) { 445 while (child != null) {
424 redepthChild(child); 446 redepthChild(child);
425 assert(child.parentData is ParentDataType); 447 assert(child.parentData is ParentDataType);
426 child = child.parentData.nextSibling; 448 child = child.parentData.nextSibling;
427 } 449 }
428 } 450 }
429 void attachChildren() { 451 void attachChildren() {
430 ChildType child = _firstChild; 452 ChildType child = _firstChild;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 int count = 1; 485 int count = 1;
464 ChildType child = _firstChild; 486 ChildType child = _firstChild;
465 while (child != null) { 487 while (child != null) {
466 result += '${prefix}child ${count}: ${child.toString(prefix)}'; 488 result += '${prefix}child ${count}: ${child.toString(prefix)}';
467 count += 1; 489 count += 1;
468 child = child.parentData.nextSibling; 490 child = child.parentData.nextSibling;
469 } 491 }
470 return result; 492 return result;
471 } 493 }
472 } 494 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/rendering/box.dart ('k') | sky/sdk/lib/rendering/paragraph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698