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

Side by Side Diff: sky/sdk/lib/framework/layout2.dart

Issue 1149843003: Rename setupPos to setParentData (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 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/framework/layout.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 library layout; 1 library layout;
2 2
3 // This version of layout.dart is an update to the other one, this one using new APIs. 3 // This version of layout.dart is an update to the other one, this one using new APIs.
4 // It will not work in a stock Sky setup currently. 4 // It will not work in a stock Sky setup currently.
5 5
6 import 'node.dart'; 6 import 'node.dart';
7 7
8 import 'dart:sky' as sky; 8 import 'dart:sky' as sky;
9 9
10 // ABSTRACT LAYOUT 10 // ABSTRACT LAYOUT
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 abstract class RenderNode extends AbstractNode { 43 abstract class RenderNode extends AbstractNode {
44 44
45 // LAYOUT 45 // LAYOUT
46 46
47 // parentData is only for use by the RenderNode that actually lays this 47 // parentData is only for use by the RenderNode that actually lays this
48 // node out, and any other nodes who happen to know exactly what 48 // node out, and any other nodes who happen to know exactly what
49 // kind of node that is. 49 // kind of node that is.
50 ParentData parentData; 50 ParentData parentData;
51 void setupPos(RenderNode child) { 51 void setParentData(RenderNode child) {
52 // override this to setup .parentData correctly for your class 52 // override this to setup .parentData correctly for your class
53 if (child.parentData is! ParentData) 53 if (child.parentData is! ParentData)
54 child.parentData = new ParentData(); 54 child.parentData = new ParentData();
55 } 55 }
56 56
57 void adoptChild(RenderNode child) { // only for use by subclasses 57 void adoptChild(RenderNode child) { // only for use by subclasses
58 // call this whenever you decide a node is a child 58 // call this whenever you decide a node is a child
59 assert(child != null); 59 assert(child != null);
60 setupPos(child); 60 setParentData(child);
61 super.adoptChild(child); 61 super.adoptChild(child);
62 } 62 }
63 void dropChild(RenderNode child) { // only for use by subclasses 63 void dropChild(RenderNode child) { // only for use by subclasses
64 assert(child != null); 64 assert(child != null);
65 assert(child.parentData != null); 65 assert(child.parentData != null);
66 child.parentData.detach(); 66 child.parentData.detach();
67 super.dropChild(child); 67 super.dropChild(child);
68 } 68 }
69 69
70 static List<RenderNode> _nodesNeedingLayout = new List<RenderNode>(); 70 static List<RenderNode> _nodesNeedingLayout = new List<RenderNode>();
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 final double height; 397 final double height;
398 } 398 }
399 399
400 class BoxParentData extends ParentData { 400 class BoxParentData extends ParentData {
401 double x = 0.0; 401 double x = 0.0;
402 double y = 0.0; 402 double y = 0.0;
403 } 403 }
404 404
405 abstract class RenderBox extends RenderNode { 405 abstract class RenderBox extends RenderNode {
406 406
407 void setupPos(RenderNode child) { 407 void setParentData(RenderNode child) {
408 if (child.parentData is! BoxParentData) 408 if (child.parentData is! BoxParentData)
409 child.parentData = new BoxParentData(); 409 child.parentData = new BoxParentData();
410 } 410 }
411 411
412 // override this to report what dimensions you would have if you 412 // override this to report what dimensions you would have if you
413 // were laid out with the given constraints this can walk the tree 413 // were laid out with the given constraints this can walk the tree
414 // if it must, but it should be as cheap as possible; just get the 414 // if it must, but it should be as cheap as possible; just get the
415 // dimensions and nothing else (e.g. don't calculate hypothetical 415 // dimensions and nothing else (e.g. don't calculate hypothetical
416 // child positions if they're not needed to determine dimensions) 416 // child positions if they're not needed to determine dimensions)
417 BoxDimensions getIntrinsicDimensions({ 417 BoxDimensions getIntrinsicDimensions({
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 EdgeDims _padding; 561 EdgeDims _padding;
562 EdgeDims get padding => _padding; 562 EdgeDims get padding => _padding;
563 void set padding(EdgeDims value) { 563 void set padding(EdgeDims value) {
564 assert(value != null); 564 assert(value != null);
565 if (_padding != value) { 565 if (_padding != value) {
566 _padding = value; 566 _padding = value;
567 markNeedsLayout(); 567 markNeedsLayout();
568 } 568 }
569 } 569 }
570 570
571 void setupPos(RenderBox child) { 571 void setParentData(RenderBox child) {
572 if (child.parentData is! BlockParentData) 572 if (child.parentData is! BlockParentData)
573 child.parentData = new BlockParentData(); 573 child.parentData = new BlockParentData();
574 } 574 }
575 575
576 // override this to report what dimensions you would have if you 576 // override this to report what dimensions you would have if you
577 // were laid out with the given constraints this can walk the tree 577 // were laid out with the given constraints this can walk the tree
578 // if it must, but it should be as cheap as possible; just get the 578 // if it must, but it should be as cheap as possible; just get the
579 // dimensions and nothing else (e.g. don't calculate hypothetical 579 // dimensions and nothing else (e.g. don't calculate hypothetical
580 // child positions if they're not needed to determine dimensions) 580 // child positions if they're not needed to determine dimensions)
581 BoxDimensions getIntrinsicDimensions({ 581 BoxDimensions getIntrinsicDimensions({
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
748 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parentDa ta as BoxParentData).y); 748 canvas.paintChild(body, (body.parentData as BoxParentData).x, (body.parentDa ta as BoxParentData).y);
749 if (statusbar != null) 749 if (statusbar != null)
750 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s tatusbar.parentData as BoxParentData).y); 750 canvas.paintChild(statusbar, (statusbar.parentData as BoxParentData).x, (s tatusbar.parentData as BoxParentData).y);
751 if (toolbar != null) 751 if (toolbar != null)
752 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb ar.parentData as BoxParentData).y); 752 canvas.paintChild(toolbar, (toolbar.parentData as BoxParentData).x, (toolb ar.parentData as BoxParentData).y);
753 if (drawer != null) 753 if (drawer != null)
754 canvas.paintChild(drawer, (drawer.parentData as BoxParentData).x, (drawer. parentData as BoxParentData).y); 754 canvas.paintChild(drawer, (drawer.parentData as BoxParentData).x, (drawer. parentData as BoxParentData).y);
755 } 755 }
756 756
757 } 757 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/layout.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698