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

Unified Diff: sky/sdk/lib/widgets/widget.dart

Issue 1217473007: Remove all the caching of Theme data, since perf data suggests it wasn't helping. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/widget.dart
diff --git a/sky/sdk/lib/widgets/widget.dart b/sky/sdk/lib/widgets/widget.dart
index ebecd821318de476cf42d006966052b2b5443d97..f1371fe3a9dcf3de255ba7066953ee7db149cdde 100644
--- a/sky/sdk/lib/widgets/widget.dart
+++ b/sky/sdk/lib/widgets/widget.dart
@@ -222,54 +222,8 @@ class ParentDataNode extends TagNode {
final ParentData parentData;
}
-abstract class _Heir implements Widget {
- Map<Type, Inherited> _traits;
- Inherited inheritedOfType(Type type) => _traits == null ? null : _traits[type];
-
- static _Heir _getHeirAncestor(Widget widget) {
- Widget ancestor = widget;
- while (ancestor != null && !(ancestor is _Heir)) {
- ancestor = ancestor.parent;
- }
- return ancestor as _Heir;
- }
-
- void _updateTraitsFromParent(Widget parent) {
- _Heir ancestor = _getHeirAncestor(parent);
- if (ancestor == null || ancestor._traits == null) return;
- _updateTraits(ancestor._traits);
- }
-
- void _updateTraitsRecursively(Widget widget) {
- if (widget is _Heir)
- widget._updateTraits(_traits);
- else
- widget.walkChildren(_updateTraitsRecursively);
- }
-
- void _updateTraits(Map<Type, Inherited> newTraits) {
- if (newTraits != _traits) {
- _traits = newTraits;
- walkChildren(_updateTraitsRecursively);
- }
- }
-}
-
-abstract class Inherited extends TagNode with _Heir {
- Inherited({ String key, Widget child }) : super._withKey(child, key) {
- _traits = new Map<Type, Inherited>();
- }
-
- void set _traits(Map<Type, Inherited> value) {
- super._traits = new Map<Type, Inherited>.from(value)
- ..[runtimeType] = this;
- }
-
- // TODO(jackson): When Dart supports super in mixins we can move to _Heir
- void setParent(Widget parent) {
- _updateTraitsFromParent(parent);
- super.setParent(parent);
- }
+abstract class Inherited extends TagNode {
+ Inherited({ String key, Widget child }) : super._withKey(child, key);
}
typedef void GestureEventListener(sky.GestureEvent e);
@@ -363,7 +317,7 @@ class Listener extends TagNode {
}
-abstract class Component extends Widget with _Heir {
+abstract class Component extends Widget {
Component({ String key, bool stateful })
: _stateful = stateful != null ? stateful : false,
@@ -385,12 +339,6 @@ abstract class Component extends Widget with _Heir {
super.didMount();
}
- // TODO(jackson): When Dart supports super in mixins we can move to _Heir
- void setParent(Widget parent) {
- _updateTraitsFromParent(parent);
- super.setParent(parent);
- }
-
void remove() {
assert(_built != null);
assert(root != null);
@@ -405,6 +353,13 @@ abstract class Component extends Widget with _Heir {
_built.detachRoot();
}
+ Inherited inheritedOfType(Type targetType) {
+ Widget ancestor = parent;
+ while (ancestor != null && ancestor.runtimeType != targetType)
+ ancestor = ancestor.parent;
+ return ancestor;
+ }
+
bool _retainStatefulNodeIfPossible(Widget old) {
assert(!_disqualifiedFromEverAppearingAgain);
« 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