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

Side by Side Diff: sky/sdk/lib/widgets/widget.dart

Issue 1187023005: Rename insert() to insertChildRoot() so it's consistent with detachChildRoot(). (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 unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/widgets/scaffold.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:mirrors'; 7 import 'dart:mirrors';
8 import 'dart:sky' as sky; 8 import 'dart:sky' as sky;
9 9
10 import '../app/view.dart'; 10 import '../app/view.dart';
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
484 484
485 RenderObjectWrapper({ String key }) : super(key: key); 485 RenderObjectWrapper({ String key }) : super(key: key);
486 486
487 RenderObject createNode(); 487 RenderObject createNode();
488 488
489 static final Map<RenderObject, RenderObjectWrapper> _nodeMap = 489 static final Map<RenderObject, RenderObjectWrapper> _nodeMap =
490 new HashMap<RenderObject, RenderObjectWrapper>(); 490 new HashMap<RenderObject, RenderObjectWrapper>();
491 static RenderObjectWrapper _getMounted(RenderObject node) => _nodeMap[node]; 491 static RenderObjectWrapper _getMounted(RenderObject node) => _nodeMap[node];
492 492
493 RenderObjectWrapper _ancestor; 493 RenderObjectWrapper _ancestor;
494 void insert(RenderObjectWrapper child, dynamic slot); 494 void insertChildRoot(RenderObjectWrapper child, dynamic slot);
495 void detachChildRoot(RenderObjectWrapper child); 495 void detachChildRoot(RenderObjectWrapper child);
496 496
497 void _sync(Widget old, dynamic slot) { 497 void _sync(Widget old, dynamic slot) {
498 // TODO(abarth): We should split RenderObjectWrapper into two pieces so that 498 // TODO(abarth): We should split RenderObjectWrapper into two pieces so that
499 // RenderViewObject doesn't need to inherit all this code it 499 // RenderViewObject doesn't need to inherit all this code it
500 // doesn't need. 500 // doesn't need.
501 assert(parent != null || this is RenderViewWrapper); 501 assert(parent != null || this is RenderViewWrapper);
502 if (old == null) { 502 if (old == null) {
503 _root = createNode(); 503 _root = createNode();
504 _ancestor = findAncestor(RenderObjectWrapper); 504 _ancestor = findAncestor(RenderObjectWrapper);
505 if (_ancestor is RenderObjectWrapper) 505 if (_ancestor is RenderObjectWrapper)
506 _ancestor.insert(this, slot); 506 _ancestor.insertChildRoot(this, slot);
507 } else { 507 } else {
508 _root = old.root; 508 _root = old.root;
509 _ancestor = old._ancestor; 509 _ancestor = old._ancestor;
510 } 510 }
511 assert(_root == root); // in case a subclass reintroduces it 511 assert(_root == root); // in case a subclass reintroduces it
512 assert(root != null); 512 assert(root != null);
513 assert(mounted); 513 assert(mounted);
514 _nodeMap[root] = this; 514 _nodeMap[root] = this;
515 syncRenderObject(old); 515 syncRenderObject(old);
516 } 516 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 556
557 Widget _child; 557 Widget _child;
558 Widget get child => _child; 558 Widget get child => _child;
559 559
560 void syncRenderObject(RenderObjectWrapper old) { 560 void syncRenderObject(RenderObjectWrapper old) {
561 super.syncRenderObject(old); 561 super.syncRenderObject(old);
562 Widget oldChild = old == null ? null : (old as OneChildRenderObjectWrapper). child; 562 Widget oldChild = old == null ? null : (old as OneChildRenderObjectWrapper). child;
563 _child = syncChild(child, oldChild, null); 563 _child = syncChild(child, oldChild, null);
564 } 564 }
565 565
566 void insert(RenderObjectWrapper child, dynamic slot) { 566 void insertChildRoot(RenderObjectWrapper child, dynamic slot) {
567 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer 567 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer
568 assert(root is RenderObjectWithChildMixin); 568 assert(root is RenderObjectWithChildMixin);
569 assert(slot == null); 569 assert(slot == null);
570 root.child = child.root; 570 root.child = child.root;
571 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer 571 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer
572 } 572 }
573 573
574 void detachChildRoot(RenderObjectWrapper child) { 574 void detachChildRoot(RenderObjectWrapper child) {
575 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer 575 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer
576 assert(root is RenderObjectWithChildMixin); 576 assert(root is RenderObjectWithChildMixin);
(...skipping 16 matching lines...) Expand all
593 // to use as the "insert before" sibling in ContainerRenderObjectMixin.add() c alls 593 // to use as the "insert before" sibling in ContainerRenderObjectMixin.add() c alls
594 594
595 MultiChildRenderObjectWrapper({ String key, List<Widget> children }) 595 MultiChildRenderObjectWrapper({ String key, List<Widget> children })
596 : this.children = children == null ? const [] : children, 596 : this.children = children == null ? const [] : children,
597 super(key: key) { 597 super(key: key) {
598 assert(!_debugHasDuplicateIds()); 598 assert(!_debugHasDuplicateIds());
599 } 599 }
600 600
601 final List<Widget> children; 601 final List<Widget> children;
602 602
603 void insert(RenderObjectWrapper child, dynamic slot) { 603 void insertChildRoot(RenderObjectWrapper child, dynamic slot) {
604 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer 604 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer
605 assert(slot == null || slot is RenderObject); 605 assert(slot == null || slot is RenderObject);
606 assert(root is ContainerRenderObjectMixin); 606 assert(root is ContainerRenderObjectMixin);
607 root.add(child.root, before: slot); 607 root.add(child.root, before: slot);
608 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer 608 assert(root == this.root); // TODO(ianh): Remove this once the analyzer is c leverer
609 } 609 }
610 610
611 void detachChildRoot(RenderObjectWrapper child) { 611 void detachChildRoot(RenderObjectWrapper child) {
612 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer 612 final root = this.root; // TODO(ianh): Remove this once the analyzer is clev erer
613 assert(root is ContainerRenderObjectMixin); 613 assert(root is ContainerRenderObjectMixin);
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 if (root.parent == null) { 880 if (root.parent == null) {
881 // we haven't attached it yet 881 // we haven't attached it yet
882 assert(_container.child == null); 882 assert(_container.child == null);
883 _container.child = root; 883 _container.child = root;
884 } 884 }
885 assert(root.parent == _container); 885 assert(root.parent == _container);
886 } 886 }
887 887
888 Widget build() => builder(); 888 Widget build() => builder();
889 } 889 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/widgets/scaffold.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698