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

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

Issue 1190793002: Rename UINode to Widget. (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 | « sky/sdk/lib/widgets/ui_node.dart ('k') | sky/tests/framework/stocks.dart » ('j') | 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/ui_node.dart b/sky/sdk/lib/widgets/widget.dart
similarity index 89%
rename from sky/sdk/lib/widgets/ui_node.dart
rename to sky/sdk/lib/widgets/widget.dart
index 08ff047a69f8931dc32c34073e6388c30883bb0f..670227933f071124cb98cc0990a134e62d825ab5 100644
--- a/sky/sdk/lib/widgets/ui_node.dart
+++ b/sky/sdk/lib/widgets/widget.dart
@@ -17,28 +17,28 @@ export '../rendering/object.dart' show Point, Size, Rect, Color, Paint, Path;
final bool _shouldLogRenderDuration = false;
-// All Effen nodes derive from UINode. All nodes have a _parent, a _key and
+// All Effen nodes derive from Widget. All nodes have a _parent, a _key and
// can be sync'd.
-abstract class UINode {
+abstract class Widget {
- UINode({ String key }) {
+ Widget({ String key }) {
_key = key == null ? "$runtimeType" : "$runtimeType-$key";
- assert(this is AbstractUINodeRoot || _inRenderDirtyComponents); // you should not build the UI tree ahead of time, build it only during build()
+ assert(this is AbstractWidgetRoot || _inRenderDirtyComponents); // you should not build the UI tree ahead of time, build it only during build()
}
String _key;
String get key => _key;
- UINode _parent;
- UINode get parent => _parent;
+ Widget _parent;
+ Widget get parent => _parent;
bool _mounted = false;
bool _wasMounted = false;
bool get mounted => _mounted;
static bool _notifyingMountStatus = false;
- static Set<UINode> _mountedChanged = new HashSet<UINode>();
+ static Set<Widget> _mountedChanged = new HashSet<Widget>();
- void setParent(UINode newParent) {
+ void setParent(Widget newParent) {
assert(!_notifyingMountStatus);
_parent = newParent;
if (newParent == null) {
@@ -58,7 +58,7 @@ abstract class UINode {
static void _notifyMountStatusChanged() {
try {
_notifyingMountStatus = true;
- for (UINode node in _mountedChanged) {
+ for (Widget node in _mountedChanged) {
if (node._wasMounted != node._mounted) {
if (node._mounted)
node.didMount();
@@ -82,11 +82,11 @@ abstract class UINode {
// if the |old| node has become stateful and should be retained.
// This is called immediately before _sync().
// Component._retainStatefulNodeIfPossible() calls syncFields().
- bool _retainStatefulNodeIfPossible(UINode old) => false;
+ bool _retainStatefulNodeIfPossible(Widget old) => false;
bool get interchangeable => false; // if true, then keys can be duplicated
- void _sync(UINode old, dynamic slot);
+ void _sync(Widget old, dynamic slot);
// 'slot' is the identifier that the parent RenderObjectWrapper uses to know
// where to put this descendant
@@ -95,19 +95,19 @@ abstract class UINode {
setParent(null);
}
- UINode findAncestor(Type targetType) {
+ Widget findAncestor(Type targetType) {
var ancestor = _parent;
while (ancestor != null && !reflectClass(ancestor.runtimeType).isSubtypeOf(reflectClass(targetType)))
ancestor = ancestor._parent;
return ancestor;
}
- void removeChild(UINode node) {
+ void removeChild(Widget node) {
node.remove();
}
// Returns the child which should be retained as the child of this node.
- UINode syncChild(UINode node, UINode oldNode, dynamic slot) {
+ Widget syncChild(Widget node, Widget oldNode, dynamic slot) {
assert(oldNode is! Component || !oldNode._disqualifiedFromEverAppearingAgain);
@@ -150,15 +150,15 @@ abstract class UINode {
// Descendants of TagNode provide a way to tag RenderObjectWrapper and
// Component nodes with annotations, such as event listeners,
// stylistic information, etc.
-abstract class TagNode extends UINode {
+abstract class TagNode extends Widget {
- TagNode(UINode content, { String key })
+ TagNode(Widget content, { String key })
: this.content = content, super(key: key);
- UINode content;
+ Widget content;
- void _sync(UINode old, dynamic slot) {
- UINode oldContent = old == null ? null : (old as TagNode).content;
+ void _sync(Widget old, dynamic slot) {
+ Widget oldContent = old == null ? null : (old as TagNode).content;
content = syncChild(content, oldContent, slot);
assert(content.root != null);
_root = content.root;
@@ -174,7 +174,7 @@ abstract class TagNode extends UINode {
}
class ParentDataNode extends TagNode {
- ParentDataNode(UINode content, this.parentData, { String key })
+ ParentDataNode(Widget content, this.parentData, { String key })
: super(content, key: key);
final ParentData parentData;
}
@@ -185,7 +185,7 @@ typedef void EventListener(sky.Event e);
class EventListenerNode extends TagNode {
- EventListenerNode(UINode content, {
+ EventListenerNode(Widget content, {
EventListener onWheel,
GestureEventListener onGestureFlingCancel,
GestureEventListener onGestureFlingStart,
@@ -270,7 +270,7 @@ class EventListenerNode extends TagNode {
}
-abstract class Component extends UINode {
+abstract class Component extends Widget {
Component({ String key, bool stateful })
: _stateful = stateful != null ? stateful : false,
@@ -284,7 +284,7 @@ abstract class Component extends UINode {
bool _dirty = true;
bool _disqualifiedFromEverAppearingAgain = false;
- UINode _built;
+ Widget _built;
dynamic _slot; // cached slot from the last time we were synced
void didMount() {
@@ -300,7 +300,7 @@ abstract class Component extends UINode {
super.remove();
}
- bool _retainStatefulNodeIfPossible(UINode old) {
+ bool _retainStatefulNodeIfPossible(Widget old) {
assert(!_disqualifiedFromEverAppearingAgain);
Component oldComponent = old as Component;
@@ -342,7 +342,7 @@ abstract class Component extends UINode {
// assert(_built != null && old == null)
// 3) Syncing against an old version
// assert(_built == null && old != null)
- void _sync(UINode old, dynamic slot) {
+ void _sync(Widget old, dynamic slot) {
assert(_built == null || old == null);
assert(!_disqualifiedFromEverAppearingAgain);
@@ -398,7 +398,7 @@ abstract class Component extends UINode {
_scheduleComponentForRender(this);
}
- UINode build();
+ Widget build();
}
@@ -428,7 +428,7 @@ void _buildDirtyComponents() {
_inRenderDirtyComponents = false;
}
- UINode._notifyMountStatusChanged();
+ Widget._notifyMountStatusChanged();
if (_shouldLogRenderDuration) {
sw.stop();
@@ -450,11 +450,11 @@ void _scheduleComponentForRender(Component c) {
// RenderObjectWrappers correspond to a desired state of a RenderObject.
-// They are fully immutable, with one exception: A UINode which is a
+// They are fully immutable, with one exception: A Widget which is a
// Component which lives within an MultiChildRenderObjectWrapper's
// children list, may be replaced with the "old" instance if it has
// become stateful.
-abstract class RenderObjectWrapper extends UINode {
+abstract class RenderObjectWrapper extends Widget {
RenderObjectWrapper({ String key }) : super(key: key);
@@ -467,7 +467,7 @@ abstract class RenderObjectWrapper extends UINode {
static RenderObjectWrapper _getMounted(RenderObject node) => _nodeMap[node];
- void _sync(UINode old, dynamic slot) {
+ void _sync(Widget old, dynamic slot) {
assert(parent != null);
if (old == null) {
_root = createNode();
@@ -486,7 +486,7 @@ abstract class RenderObjectWrapper extends UINode {
void syncRenderObject(RenderObjectWrapper old) {
ParentData parentData = null;
- UINode ancestor = parent;
+ Widget ancestor = parent;
while (ancestor != null && ancestor is! RenderObjectWrapper) {
if (ancestor is ParentDataNode && ancestor.parentData != null) {
if (parentData != null)
@@ -513,15 +513,15 @@ abstract class RenderObjectWrapper extends UINode {
abstract class OneChildRenderObjectWrapper extends RenderObjectWrapper {
- OneChildRenderObjectWrapper({ UINode child, String key })
+ OneChildRenderObjectWrapper({ Widget child, String key })
: _child = child, super(key: key);
- UINode _child;
- UINode get child => _child;
+ Widget _child;
+ Widget get child => _child;
void syncRenderObject(RenderObjectWrapper old) {
super.syncRenderObject(old);
- UINode oldChild = old == null ? null : (old as OneChildRenderObjectWrapper).child;
+ Widget oldChild = old == null ? null : (old as OneChildRenderObjectWrapper).child;
_child = syncChild(child, oldChild, null);
}
@@ -533,7 +533,7 @@ abstract class OneChildRenderObjectWrapper extends RenderObjectWrapper {
assert(root == this.root); // TODO(ianh): Remove this once the analyzer is cleverer
}
- void removeChild(UINode node) {
+ void removeChild(Widget node) {
final root = this.root; // TODO(ianh): Remove this once the analyzer is cleverer
assert(root is RenderObjectWithChildMixin);
root.child = null;
@@ -554,13 +554,13 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
// In MultiChildRenderObjectWrapper subclasses, slots are RenderObject nodes
// to use as the "insert before" sibling in ContainerRenderObjectMixin.add() calls
- MultiChildRenderObjectWrapper({ String key, List<UINode> children })
+ MultiChildRenderObjectWrapper({ String key, List<Widget> children })
: this.children = children == null ? const [] : children,
super(key: key) {
assert(!_debugHasDuplicateIds());
}
- final List<UINode> children;
+ final List<Widget> children;
void insert(RenderObjectWrapper child, dynamic slot) {
final root = this.root; // TODO(ianh): Remove this once the analyzer is cleverer
@@ -570,7 +570,7 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
assert(root == this.root); // TODO(ianh): Remove this once the analyzer is cleverer
}
- void removeChild(UINode node) {
+ void removeChild(Widget node) {
final root = this.root; // TODO(ianh): Remove this once the analyzer is cleverer
assert(root is ContainerRenderObjectMixin);
assert(node.root.parent == root);
@@ -619,8 +619,8 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
var oldEndIndex = oldChildren.length;
RenderObject nextSibling = null;
- UINode currentNode = null;
- UINode oldNode = null;
+ Widget currentNode = null;
+ Widget oldNode = null;
void sync(int atIndex) {
children[atIndex] = syncChild(currentNode, oldNode, nextSibling);
@@ -642,7 +642,7 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
sync(endIndex);
}
- HashMap<String, UINode> oldNodeIdMap = null;
+ HashMap<String, Widget> oldNodeIdMap = null;
bool oldNodeReordered(String key) {
return oldNodeIdMap != null &&
@@ -662,7 +662,7 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
if (oldNodeIdMap != null)
return;
- oldNodeIdMap = new HashMap<String, UINode>();
+ oldNodeIdMap = new HashMap<String, Widget>();
for (int i = oldStartIndex; i < oldEndIndex; i++) {
var node = oldChildren[i];
if (!node.interchangeable)
@@ -732,25 +732,25 @@ abstract class MultiChildRenderObjectWrapper extends RenderObjectWrapper {
}
-class UINodeAppView extends AppView {
+class WidgetAppView extends AppView {
- UINodeAppView({ RenderView renderViewOverride: null })
+ WidgetAppView({ RenderView renderViewOverride: null })
: super(renderViewOverride: renderViewOverride) {
assert(_appView == null);
}
- static UINodeAppView _appView;
+ static WidgetAppView _appView;
static AppView get appView => _appView;
- static void initUINodeAppView({ RenderView renderViewOverride: null }) {
+ static void initWidgetAppView({ RenderView renderViewOverride: null }) {
if (_appView == null)
- _appView = new UINodeAppView(renderViewOverride: renderViewOverride);
+ _appView = new WidgetAppView(renderViewOverride: renderViewOverride);
}
void dispatchEvent(sky.Event event, HitTestResult result) {
assert(_appView == this);
super.dispatchEvent(event, result);
for (HitTestEntry entry in result.path.reversed) {
- UINode target = RenderObjectWrapper._getMounted(entry.target);
+ Widget target = RenderObjectWrapper._getMounted(entry.target);
if (target == null)
continue;
RenderObject targetRoot = target.root;
@@ -764,15 +764,15 @@ class UINodeAppView extends AppView {
}
-abstract class AbstractUINodeRoot extends Component {
+abstract class AbstractWidgetRoot extends Component {
- AbstractUINodeRoot({ RenderView renderViewOverride }) : super(stateful: true) {
- UINodeAppView.initUINodeAppView(renderViewOverride: renderViewOverride);
+ AbstractWidgetRoot({ RenderView renderViewOverride }) : super(stateful: true) {
+ WidgetAppView.initWidgetAppView(renderViewOverride: renderViewOverride);
_mounted = true;
_scheduleComponentForRender(this);
}
- void syncFields(AbstractUINodeRoot source) {
+ void syncFields(AbstractWidgetRoot source) {
assert(false);
// if we get here, it implies that we have a parent
}
@@ -786,7 +786,7 @@ abstract class AbstractUINodeRoot extends Component {
}
-abstract class App extends AbstractUINodeRoot {
+abstract class App extends AbstractWidgetRoot {
App({ RenderView renderViewOverride }) : super(renderViewOverride: renderViewOverride);
@@ -795,18 +795,18 @@ abstract class App extends AbstractUINodeRoot {
if (root.parent == null) {
// we haven't attached it yet
- UINodeAppView._appView.root = root;
+ WidgetAppView._appView.root = root;
}
assert(root.parent is RenderView);
}
}
-typedef UINode Builder();
+typedef Widget Builder();
-class RenderBoxToUINodeAdapter extends AbstractUINodeRoot {
+class RenderBoxToWidgetAdapter extends AbstractWidgetRoot {
- RenderBoxToUINodeAdapter(
+ RenderBoxToWidgetAdapter(
RenderObjectWithChildMixin<RenderBox> container,
this.builder
) : _container = container, super() {
@@ -842,5 +842,5 @@ class RenderBoxToUINodeAdapter extends AbstractUINodeRoot {
assert(root.parent == _container);
}
- UINode build() => builder();
+ Widget build() => builder();
}
« no previous file with comments | « sky/sdk/lib/widgets/ui_node.dart ('k') | sky/tests/framework/stocks.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698