| 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 'app.dart'; | 7 import 'app.dart'; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 import 'dart:collection'; | 9 import 'dart:collection'; |
| 10 import 'dart:mirrors'; | 10 import 'dart:mirrors'; |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 static void _notifyMountStatusChanged() { | 67 static void _notifyMountStatusChanged() { |
| 68 try { | 68 try { |
| 69 _notifyingMountStatus = true; | 69 _notifyingMountStatus = true; |
| 70 for (UINode node in _mountedChanged) { | 70 for (UINode node in _mountedChanged) { |
| 71 if (node._wasMounted != node._mounted) { | 71 if (node._wasMounted != node._mounted) { |
| 72 if (node._mounted) | 72 if (node._mounted) |
| 73 node._didMount(); | 73 node.didMount(); |
| 74 else | 74 else |
| 75 node._didUnmount(); | 75 node.didUnmount(); |
| 76 node._wasMounted = node._mounted; | 76 node._wasMounted = node._mounted; |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 _mountedChanged.clear(); | 79 _mountedChanged.clear(); |
| 80 } finally { | 80 } finally { |
| 81 _notifyingMountStatus = false; | 81 _notifyingMountStatus = false; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 void _didMount() { } | 84 void didMount() { } |
| 85 void _didUnmount() { } | 85 void didUnmount() { } |
| 86 | 86 |
| 87 RenderObject root; | 87 RenderObject root; |
| 88 | 88 |
| 89 // Subclasses which implements Nodes that become stateful may return true | 89 // Subclasses which implements Nodes that become stateful may return true |
| 90 // if the |old| node has become stateful and should be retained. | 90 // if the |old| node has become stateful and should be retained. |
| 91 // This is called immediately before _sync(). | 91 // This is called immediately before _sync(). |
| 92 // Component._retainStatefulNodeIfPossible() calls syncFields(). | 92 // Component._retainStatefulNodeIfPossible() calls syncFields(). |
| 93 bool _retainStatefulNodeIfPossible(UINode old) => false; | 93 bool _retainStatefulNodeIfPossible(UINode old) => false; |
| 94 | 94 |
| 95 bool get interchangeable => false; // if true, then keys can be duplicated | 95 bool get interchangeable => false; // if true, then keys can be duplicated |
| (...skipping 783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 879 static Component _currentlyBuilding; | 879 static Component _currentlyBuilding; |
| 880 bool get _isBuilding => _currentlyBuilding == this; | 880 bool get _isBuilding => _currentlyBuilding == this; |
| 881 | 881 |
| 882 bool _stateful; | 882 bool _stateful; |
| 883 bool _dirty = true; | 883 bool _dirty = true; |
| 884 bool _disqualifiedFromEverAppearingAgain = false; | 884 bool _disqualifiedFromEverAppearingAgain = false; |
| 885 | 885 |
| 886 UINode _built; | 886 UINode _built; |
| 887 dynamic _slot; // cached slot from the last time we were synced | 887 dynamic _slot; // cached slot from the last time we were synced |
| 888 | 888 |
| 889 List<Function> _mountCallbacks; | 889 void didMount() { |
| 890 List<Function> _unmountCallbacks; | |
| 891 | |
| 892 void onDidMount(Function fn) { | |
| 893 if (_mountCallbacks == null) | |
| 894 _mountCallbacks = new List<Function>(); | |
| 895 | |
| 896 _mountCallbacks.add(fn); | |
| 897 } | |
| 898 | |
| 899 void onDidUnmount(Function fn) { | |
| 900 if (_unmountCallbacks == null) | |
| 901 _unmountCallbacks = new List<Function>(); | |
| 902 | |
| 903 _unmountCallbacks.add(fn); | |
| 904 } | |
| 905 | |
| 906 void _didMount() { | |
| 907 assert(!_disqualifiedFromEverAppearingAgain); | 890 assert(!_disqualifiedFromEverAppearingAgain); |
| 908 super._didMount(); | 891 super.didMount(); |
| 909 if (_mountCallbacks != null) | |
| 910 for (Function fn in _mountCallbacks) | |
| 911 fn(); | |
| 912 } | |
| 913 | |
| 914 void _didUnmount() { | |
| 915 super._didUnmount(); | |
| 916 if (_unmountCallbacks != null) | |
| 917 for (Function fn in _unmountCallbacks) | |
| 918 fn(); | |
| 919 } | 892 } |
| 920 | 893 |
| 921 void remove() { | 894 void remove() { |
| 922 assert(_built != null); | 895 assert(_built != null); |
| 923 assert(root != null); | 896 assert(root != null); |
| 924 removeChild(_built); | 897 removeChild(_built); |
| 925 _built = null; | 898 _built = null; |
| 926 super.remove(); | 899 super.remove(); |
| 927 } | 900 } |
| 928 | 901 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 } | 1095 } |
| 1123 | 1096 |
| 1124 } | 1097 } |
| 1125 | 1098 |
| 1126 class Text extends Component { | 1099 class Text extends Component { |
| 1127 Text(this.data) : super(key: '*text*'); | 1100 Text(this.data) : super(key: '*text*'); |
| 1128 final String data; | 1101 final String data; |
| 1129 bool get interchangeable => true; | 1102 bool get interchangeable => true; |
| 1130 UINode build() => new Paragraph(text: data); | 1103 UINode build() => new Paragraph(text: data); |
| 1131 } | 1104 } |
| OLD | NEW |