| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 } | 310 } |
| 311 if (parentData != null) { | 311 if (parentData != null) { |
| 312 assert(root.parentData != null); | 312 assert(root.parentData != null); |
| 313 root.parentData.merge(parentData); // this will throw if the types aren't
approriate | 313 root.parentData.merge(parentData); // this will throw if the types aren't
approriate |
| 314 assert(parent != null); | 314 assert(parent != null); |
| 315 assert(parent.root != null); | 315 assert(parent.root != null); |
| 316 parent.root.markNeedsLayout(); | 316 parent.root.markNeedsLayout(); |
| 317 } | 317 } |
| 318 } | 318 } |
| 319 | 319 |
| 320 void removeChild(UINode node) { | |
| 321 root.remove(node.root); | |
| 322 super.removeChild(node); | |
| 323 } | |
| 324 | |
| 325 void _remove() { | 320 void _remove() { |
| 326 assert(root != null); | 321 assert(root != null); |
| 327 _nodeMap.remove(root); | 322 _nodeMap.remove(root); |
| 328 super._remove(); | 323 super._remove(); |
| 329 } | 324 } |
| 330 } | 325 } |
| 331 | 326 |
| 332 abstract class OneChildRenderNodeWrapper extends RenderNodeWrapper { | 327 abstract class OneChildRenderNodeWrapper extends RenderNodeWrapper { |
| 333 final UINode child; | 328 final UINode child; |
| 334 | 329 |
| 335 OneChildRenderNodeWrapper({ this.child, Object key }) : super(key: key); | 330 OneChildRenderNodeWrapper({ this.child, Object key }) : super(key: key); |
| 336 | 331 |
| 337 void insert(RenderNodeWrapper child, dynamic slot) { | |
| 338 assert(slot == null); | |
| 339 root.child = child.root; | |
| 340 } | |
| 341 | |
| 342 void syncRenderNode(RenderNodeWrapper old) { | 332 void syncRenderNode(RenderNodeWrapper old) { |
| 343 super.syncRenderNode(old); | 333 super.syncRenderNode(old); |
| 344 UINode oldChild = old == null ? null : (old as OneChildRenderNodeWrapper).ch
ild; | 334 UINode oldChild = old == null ? null : (old as OneChildRenderNodeWrapper).ch
ild; |
| 345 syncChild(child, oldChild, null); | 335 syncChild(child, oldChild, null); |
| 346 } | 336 } |
| 347 | 337 |
| 338 void insert(RenderNodeWrapper child, dynamic slot) { |
| 339 assert(slot == null); |
| 340 root.child = child.root; |
| 341 } |
| 342 |
| 343 void removeChild(UINode node) { |
| 344 root.child = null; |
| 345 super.removeChild(node); |
| 346 } |
| 347 |
| 348 void _remove() { | 348 void _remove() { |
| 349 assert(child != null); | 349 if (child != null) |
| 350 removeChild(child); | 350 removeChild(child); |
| 351 super._remove(); | 351 super._remove(); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 class Padding extends OneChildRenderNodeWrapper { | 355 class Padding extends OneChildRenderNodeWrapper { |
| 356 RenderPadding root; | 356 RenderPadding root; |
| 357 final EdgeDims padding; | 357 final EdgeDims padding; |
| 358 | 358 |
| 359 Padding({ this.padding, UINode child, Object key }) | 359 Padding({ this.padding, UINode child, Object key }) |
| 360 : super(child: child, key: key); | 360 : super(child: child, key: key); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 key: key | 429 key: key |
| 430 ) { | 430 ) { |
| 431 assert(!_debugHasDuplicateIds()); | 431 assert(!_debugHasDuplicateIds()); |
| 432 } | 432 } |
| 433 | 433 |
| 434 void insert(RenderNodeWrapper child, dynamic slot) { | 434 void insert(RenderNodeWrapper child, dynamic slot) { |
| 435 assert(slot == null || slot is RenderNode); | 435 assert(slot == null || slot is RenderNode); |
| 436 root.add(child.root, before: slot); | 436 root.add(child.root, before: slot); |
| 437 } | 437 } |
| 438 | 438 |
| 439 void removeChild(UINode node) { |
| 440 assert(root is ContainerRenderNodeMixin); |
| 441 root.remove(node.root); |
| 442 super.removeChild(node); |
| 443 } |
| 444 |
| 439 void _remove() { | 445 void _remove() { |
| 440 assert(children != null); | 446 assert(children != null); |
| 441 for (var child in children) { | 447 for (var child in children) { |
| 442 assert(child != null); | 448 assert(child != null); |
| 443 removeChild(child); | 449 removeChild(child); |
| 444 } | 450 } |
| 445 super._remove(); | 451 super._remove(); |
| 446 } | 452 } |
| 447 | 453 |
| 448 bool _debugHasDuplicateIds() { | 454 bool _debugHasDuplicateIds() { |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 948 assert(root.parent is RenderView); | 954 assert(root.parent is RenderView); |
| 949 } | 955 } |
| 950 } | 956 } |
| 951 | 957 |
| 952 class Text extends Component { | 958 class Text extends Component { |
| 953 Text(this.data) : super(key: '*text*'); | 959 Text(this.data) : super(key: '*text*'); |
| 954 final String data; | 960 final String data; |
| 955 bool get interchangeable => true; | 961 bool get interchangeable => true; |
| 956 UINode build() => new Paragraph(text: data); | 962 UINode build() => new Paragraph(text: data); |
| 957 } | 963 } |
| OLD | NEW |