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

Side by Side Diff: sky/framework/fn.dart

Issue 983973005: Add an assert that we don't schedule a render during render (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Don't die in production Created 5 years, 9 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 library fn; 5 library fn;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:sky' as sky; 9 import 'dart:sky' as sky;
10 import 'reflect.dart' as reflect; 10 import 'reflect.dart' as reflect;
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 496
497 sky.HTMLAnchorElement skyAnchor = _root as sky.HTMLAnchorElement; 497 sky.HTMLAnchorElement skyAnchor = _root as sky.HTMLAnchorElement;
498 if (href != oldAnchor.href) { 498 if (href != oldAnchor.href) {
499 skyAnchor.href = href; 499 skyAnchor.href = href;
500 } 500 }
501 } 501 }
502 } 502 }
503 503
504 List<Component> _dirtyComponents = new List<Component>(); 504 List<Component> _dirtyComponents = new List<Component>();
505 bool _renderScheduled = false; 505 bool _renderScheduled = false;
506 bool _inRenderDirtyComponents = false;
506 507
507 void _renderDirtyComponents() { 508 void _renderDirtyComponents() {
508 Stopwatch sw = new Stopwatch()..start(); 509 try {
510 _inRenderDirtyComponents = true;
511 Stopwatch sw = new Stopwatch()..start();
509 512
510 _dirtyComponents.sort((a, b) => a._order - b._order); 513 _dirtyComponents.sort((a, b) => a._order - b._order);
511 for (var comp in _dirtyComponents) { 514 for (var comp in _dirtyComponents) {
512 comp._renderIfDirty(); 515 comp._renderIfDirty();
516 }
517
518 _dirtyComponents.clear();
519 _renderScheduled = false;
520
521 sw.stop();
522 if (_shouldLogRenderDuration)
523 print("Render took ${sw.elapsedMicroseconds} microseconds");
524 } finally {
525 _inRenderDirtyComponents = false;
513 } 526 }
514
515 _dirtyComponents.clear();
516 _renderScheduled = false;
517
518 sw.stop();
519 if (_shouldLogRenderDuration)
520 print("Render took ${sw.elapsedMicroseconds} microseconds");
521 } 527 }
522 528
523 void _scheduleComponentForRender(Component c) { 529 void _scheduleComponentForRender(Component c) {
530 assert(!_inRenderDirtyComponents);
531 if (_inRenderDirtyComponents)
532 return;
533
524 _dirtyComponents.add(c); 534 _dirtyComponents.add(c);
525 535
526 if (!_renderScheduled) { 536 if (!_renderScheduled) {
527 _renderScheduled = true; 537 _renderScheduled = true;
528 new Future.microtask(_renderDirtyComponents); 538 new Future.microtask(_renderDirtyComponents);
529 } 539 }
530 } 540 }
531 541
532 abstract class Component extends Node { 542 abstract class Component extends Node {
533 bool _dirty = true; // components begin dirty because they haven't rendered. 543 bool _dirty = true; // components begin dirty because they haven't rendered.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 663
654 _sync(null, _host, null); 664 _sync(null, _host, null);
655 assert(_root is sky.Node); 665 assert(_root is sky.Node);
656 666
657 sw.stop(); 667 sw.stop();
658 if (_shouldLogRenderDuration) 668 if (_shouldLogRenderDuration)
659 print("Initial render: ${sw.elapsedMicroseconds} microseconds"); 669 print("Initial render: ${sw.elapsedMicroseconds} microseconds");
660 }); 670 });
661 } 671 }
662 } 672 }
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