| OLD | NEW |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 1 part of fn; | 5 part of fn; |
| 2 | 6 |
| 3 List<Component> _dirtyComponents = new List<Component>(); | 7 List<Component> _dirtyComponents = new List<Component>(); |
| 4 bool _renderScheduled = false; | 8 bool _renderScheduled = false; |
| 5 | 9 |
| 6 void _renderDirtyComponents() { | 10 void _renderDirtyComponents() { |
| 7 Stopwatch sw = new Stopwatch()..start(); | 11 Stopwatch sw = new Stopwatch()..start(); |
| 8 | 12 |
| 9 _dirtyComponents.sort((a, b) => a._order - b._order); | 13 _dirtyComponents.sort((a, b) => a._order - b._order); |
| 10 for (var comp in _dirtyComponents) { | 14 for (var comp in _dirtyComponents) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 if (!_renderScheduled) { | 27 if (!_renderScheduled) { |
| 24 _renderScheduled = true; | 28 _renderScheduled = true; |
| 25 new Future.microtask(_renderDirtyComponents); | 29 new Future.microtask(_renderDirtyComponents); |
| 26 } | 30 } |
| 27 } | 31 } |
| 28 | 32 |
| 29 abstract class Component extends Node { | 33 abstract class Component extends Node { |
| 30 bool _dirty = true; // components begin dirty because they haven't rendered. | 34 bool _dirty = true; // components begin dirty because they haven't rendered. |
| 31 Node _rendered = null; | 35 Node _rendered = null; |
| 32 bool _removed = false; | 36 bool _removed = false; |
| 33 int _order; | 37 final int _order; |
| 34 static int _currentOrder = 0; | 38 static int _currentOrder = 0; |
| 35 bool _stateful; | 39 bool _stateful; |
| 36 static Component _currentlyRendering; | 40 static Component _currentlyRendering; |
| 37 | 41 |
| 38 Component({ Object key, bool stateful }) | 42 Component({ Object key, bool stateful }) |
| 39 : _stateful = stateful != null ? stateful : false, | 43 : _stateful = stateful != null ? stateful : false, |
| 40 _order = _currentOrder + 1, | 44 _order = _currentOrder + 1, |
| 41 super(key:key); | 45 super(key:key); |
| 42 | 46 |
| 43 void willUnmount() {} | 47 void willUnmount() {} |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 153 |
| 150 new Future.microtask(() { | 154 new Future.microtask(() { |
| 151 Stopwatch sw = new Stopwatch()..start(); | 155 Stopwatch sw = new Stopwatch()..start(); |
| 152 _sync(null, _host, null); | 156 _sync(null, _host, null); |
| 153 assert(_root is sky.Node); | 157 assert(_root is sky.Node); |
| 154 sw.stop(); | 158 sw.stop(); |
| 155 print("Initial render: ${sw.elapsedMicroseconds} microseconds"); | 159 print("Initial render: ${sw.elapsedMicroseconds} microseconds"); |
| 156 }); | 160 }); |
| 157 } | 161 } |
| 158 } | 162 } |
| OLD | NEW |