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

Unified Diff: third_party/pkg/angular/lib/core_dom/view.dart

Issue 257423008: Update all Angular libs (run update_all.sh). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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
Index: third_party/pkg/angular/lib/core_dom/view.dart
diff --git a/third_party/pkg/angular/lib/core_dom/view.dart b/third_party/pkg/angular/lib/core_dom/view.dart
new file mode 100644
index 0000000000000000000000000000000000000000..c53309f7de3c35bfb4bf658441120284f5f7ff53
--- /dev/null
+++ b/third_party/pkg/angular/lib/core_dom/view.dart
@@ -0,0 +1,67 @@
+part of angular.core.dom_internal;
+
+/**
+ * A View is a fundamental building block of DOM. It is a chunk of DOM which
+ * can not be structurally changed. A View can have [ViewPort] placeholders
+ * embedded in its DOM. A [ViewPort] can contain other [View]s and it is the
+ * only way in which DOM structure can be modified.
+ *
+ * A [View] is a collection of DOM nodes
+
+ * A [View] can be created from [ViewFactory].
+ *
+ */
+class View {
+ final List<dom.Node> nodes;
+ final EventHandler eventHandler;
+
+ View(this.nodes, this.eventHandler);
+
+ void registerEvent(String eventName) {
+ eventHandler.register(eventName);
+ }
+}
+
+/**
+ * A ViewPort maintains an ordered list of [View]'s. It contains a
+ * [placeholder] node that is used as the insertion point for view nodes.
+ */
+class ViewPort {
+ final dom.Node placeholder;
+ final Animate _animate;
+ final _views = <View>[];
+
+ ViewPort(this.placeholder, this._animate);
+
+ void insert(View view, { View insertAfter }) {
+ dom.Node previousNode = _lastNode(insertAfter);
+ _viewsInsertAfter(view, insertAfter);
+
+ _animate.insert(view.nodes, placeholder.parentNode,
+ insertBefore: previousNode.nextNode);
+ }
+
+ void remove(View view) {
+ _views.remove(view);
+ _animate.remove(view.nodes);
+ }
+
+ void move(View view, { View moveAfter }) {
+ dom.Node previousNode = _lastNode(moveAfter);
+ _views.remove(view);
+ _viewsInsertAfter(view, moveAfter);
+
+ _animate.move(view.nodes, placeholder.parentNode,
+ insertBefore: previousNode.nextNode);
+ }
+
+ void _viewsInsertAfter(View view, View insertAfter) {
+ int index = insertAfter == null ? 0 : _views.indexOf(insertAfter) + 1;
+ _views.insert(index, view);
+ }
+
+ dom.Node _lastNode(View insertAfter) =>
+ insertAfter == null
+ ? placeholder
+ : insertAfter.nodes.last;
+}
« no previous file with comments | « third_party/pkg/angular/lib/core_dom/tree_sanitizer.dart ('k') | third_party/pkg/angular/lib/core_dom/view_factory.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698