| OLD | NEW |
| 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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 _currentOrder = _order; | 608 _currentOrder = _order; |
| 609 _currentlyRendering = this; | 609 _currentlyRendering = this; |
| 610 _rendered = render(); | 610 _rendered = render(); |
| 611 _currentlyRendering = null; | 611 _currentlyRendering = null; |
| 612 _currentOrder = lastOrder; | 612 _currentOrder = lastOrder; |
| 613 | 613 |
| 614 _rendered.events.addAll(events); | 614 _rendered.events.addAll(events); |
| 615 | 615 |
| 616 _dirty = false; | 616 _dirty = false; |
| 617 | 617 |
| 618 if (oldRendered != null && _rendered.runtimeType != oldRendered.runtimeType) | 618 // TODO(rafaelw): This eagerly removes the old DOM. It may be that a |
| 619 // new component was rendered that could re-use some of it. Consider |
| 620 // syncing the new VDOM against the old one. |
| 621 if (oldRendered != null && |
| 622 _rendered.runtimeType != oldRendered.runtimeType) { |
| 623 oldRendered._remove(); |
| 619 oldRendered = null; | 624 oldRendered = null; |
| 625 } |
| 620 | 626 |
| 621 if (_rendered._sync(oldRendered, host, insertBefore)) { | 627 if (_rendered._sync(oldRendered, host, insertBefore)) { |
| 622 _rendered = oldRendered; // retain stateful component | 628 _rendered = oldRendered; // retain stateful component |
| 623 } | 629 } |
| 624 _root = _rendered._root; | 630 _root = _rendered._root; |
| 625 assert(_rendered._root is sky.Node); | 631 assert(_rendered._root is sky.Node); |
| 626 | 632 |
| 627 if (mounting) { | 633 if (mounting) { |
| 628 didMount(); | 634 didMount(); |
| 629 } | 635 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 | 672 |
| 667 _sync(null, _host, null); | 673 _sync(null, _host, null); |
| 668 assert(_root is sky.Node); | 674 assert(_root is sky.Node); |
| 669 | 675 |
| 670 sw.stop(); | 676 sw.stop(); |
| 671 if (_shouldLogRenderDuration) | 677 if (_shouldLogRenderDuration) |
| 672 print("Initial render: ${sw.elapsedMicroseconds} microseconds"); | 678 print("Initial render: ${sw.elapsedMicroseconds} microseconds"); |
| 673 }); | 679 }); |
| 674 } | 680 } |
| 675 } | 681 } |
| OLD | NEW |