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

Side by Side Diff: pkg/template_binding/lib/src/instance_binding_map.dart

Issue 50203004: port TemplateBinding to ed3266266e751b5ab1f75f8e0509d0d5f0ef35d8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 part of template_binding;
6
7 class _InstanceBindingMap {
8 final List bindings;
9 final List<_InstanceBindingMap> children;
10 final Node templateRef;
11 final bool hasSubTemplate;
12
13 _InstanceBindingMap._(this.bindings, this.children, this.templateRef,
14 this.hasSubTemplate);
15
16 factory _InstanceBindingMap(Node node, BindingDelegate delegate) {
17 var bindings = _getBindings(node, delegate);
18
19 bool hasSubTemplate = false;
20 Node templateRef = null;
21
22 if (isSemanticTemplate(node)) {
23 templateRef = node;
24 hasSubTemplate = true;
25 }
26
27 List children = null;
28 for (var c = node.firstChild, i = 0; c != null; c = c.nextNode, i++) {
29 var childMap = new _InstanceBindingMap(c, delegate);
30 if (childMap == null) continue;
31
32 if (children == null) children = new List(node.nodes.length);
33 children[i] = childMap;
34 if (childMap.hasSubTemplate) {
35 hasSubTemplate = true;
36 }
37 }
38
39 return new _InstanceBindingMap._(bindings, children, templateRef,
40 hasSubTemplate);
41 }
42 }
43
44
45 void _addMapBindings(Node node, _InstanceBindingMap map, model,
46 BindingDelegate delegate, List bound) {
47 if (map == null) return;
48
49 if (map.templateRef != null) {
50 TemplateBindExtension.decorate(node, map.templateRef);
51 if (delegate != null) {
52 templateBindFallback(node)._bindingDelegate = delegate;
53 }
54 }
55
56 if (map.bindings != null) {
57 _processBindings(map.bindings, node, model, bound);
58 }
59
60 if (map.children == null) return;
61
62 int i = 0;
63 for (var c = node.firstChild; c != null; c = c.nextNode) {
64 _addMapBindings(c, map.children[i++], model, delegate, bound);
65 }
66 }
OLDNEW
« no previous file with comments | « pkg/template_binding/lib/src/input_bindings.dart ('k') | pkg/template_binding/lib/src/list_diff.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698