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 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:collection'; | 6 import 'dart:collection'; |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'dart:sky' as sky; | 8 import 'dart:sky' as sky; |
9 | 9 |
10 import '../app.dart'; | 10 import '../app.dart'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 final bool _shouldLogRenderDuration = false; | 21 final bool _shouldLogRenderDuration = false; |
22 | 22 |
23 /* | 23 /* |
24 * All Effen nodes derive from UINode. All nodes have a _parent, a _key and | 24 * All Effen nodes derive from UINode. All nodes have a _parent, a _key and |
25 * can be sync'd. | 25 * can be sync'd. |
26 */ | 26 */ |
27 abstract class UINode { | 27 abstract class UINode { |
28 | 28 |
29 UINode({ Object key }) { | 29 UINode({ Object key }) { |
30 _key = key == null ? "$runtimeType" : "$runtimeType-$key"; | 30 _key = key == null ? "$runtimeType" : "$runtimeType-$key"; |
31 assert(this is App || _inRenderDirtyComponents); // you should not build the
UI tree ahead of time, build it only during build() | 31 assert(this is AbstractUINodeRoot || _inRenderDirtyComponents); // you shoul
d not build the UI tree ahead of time, build it only during build() |
32 } | 32 } |
33 | 33 |
34 String _key; | 34 String _key; |
35 String get key => _key; | 35 String get key => _key; |
36 | 36 |
37 UINode _parent; | 37 UINode _parent; |
38 UINode get parent => _parent; | 38 UINode get parent => _parent; |
39 | 39 |
40 bool _mounted = false; | 40 bool _mounted = false; |
41 bool _wasMounted = false; | 41 bool _wasMounted = false; |
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 } | 745 } |
746 | 746 |
747 | 747 |
748 class UINodeAppView extends AppView { | 748 class UINodeAppView extends AppView { |
749 | 749 |
750 UINodeAppView() { | 750 UINodeAppView() { |
751 assert(_appView == null); | 751 assert(_appView == null); |
752 } | 752 } |
753 | 753 |
754 static UINodeAppView _appView; | 754 static UINodeAppView _appView; |
| 755 static AppView get appView => _appView; |
755 static void initUINodeAppView() { | 756 static void initUINodeAppView() { |
756 if (_appView == null) | 757 if (_appView == null) |
757 _appView = new UINodeAppView(); | 758 _appView = new UINodeAppView(); |
758 } | 759 } |
759 | 760 |
760 void dispatchEvent(sky.Event event, HitTestResult result) { | 761 void dispatchEvent(sky.Event event, HitTestResult result) { |
761 assert(_appView == this); | 762 assert(_appView == this); |
762 super.dispatchEvent(event, result); | 763 super.dispatchEvent(event, result); |
763 for (HitTestEntry entry in result.path.reversed) { | 764 for (HitTestEntry entry in result.path.reversed) { |
764 UINode target = RenderObjectWrapper._getMounted(entry.target); | 765 UINode target = RenderObjectWrapper._getMounted(entry.target); |
(...skipping 29 matching lines...) Expand all Loading... |
794 assert(parent == null); | 795 assert(parent == null); |
795 _sync(null, null); | 796 _sync(null, null); |
796 } | 797 } |
797 | 798 |
798 } | 799 } |
799 | 800 |
800 abstract class App extends AbstractUINodeRoot { | 801 abstract class App extends AbstractUINodeRoot { |
801 | 802 |
802 App(); | 803 App(); |
803 | 804 |
804 AppView get appView => UINodeAppView._appView; | |
805 | |
806 void _buildIfDirty() { | 805 void _buildIfDirty() { |
807 super._buildIfDirty(); | 806 super._buildIfDirty(); |
808 | 807 |
809 if (root.parent == null) { | 808 if (root.parent == null) { |
810 // we haven't attached it yet | 809 // we haven't attached it yet |
811 UINodeAppView._appView.root = root; | 810 UINodeAppView._appView.root = root; |
812 } | 811 } |
813 assert(root.parent is RenderView); | 812 assert(root.parent is RenderView); |
814 } | 813 } |
815 | 814 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 // we haven't attached it yet | 850 // we haven't attached it yet |
852 assert(_container.child == null); | 851 assert(_container.child == null); |
853 _container.child = root; | 852 _container.child = root; |
854 } | 853 } |
855 assert(root.parent == _container); | 854 assert(root.parent == _container); |
856 } | 855 } |
857 | 856 |
858 UINode build() => builder(); | 857 UINode build() => builder(); |
859 | 858 |
860 } | 859 } |
OLD | NEW |