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

Side by Side Diff: sky/sdk/lib/framework/rendering/object.dart

Issue 1157993005: Give RenderObject a useful toString(). (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
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 '../node.dart'; 5 import '../node.dart';
6 import '../scheduler.dart' as scheduler; 6 import '../scheduler.dart' as scheduler;
7 import 'dart:math' as math; 7 import 'dart:math' as math;
8 import 'dart:sky' as sky; 8 import 'dart:sky' as sky;
9 9
10 class ParentData { 10 class ParentData {
11 void detach() { 11 void detach() {
12 detachSiblings(); 12 detachSiblings();
13 } 13 }
14 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart 14 void detachSiblings() { } // workaround for lack of inter-class mixins in Dart
15 void merge(ParentData other) { 15 void merge(ParentData other) {
16 // override this in subclasses to merge in data from other into this 16 // override this in subclasses to merge in data from other into this
17 assert(other.runtimeType == this.runtimeType); 17 assert(other.runtimeType == this.runtimeType);
18 } 18 }
19 String toString() => '<none>';
19 } 20 }
20 21
21 const kLayoutDirections = 4; 22 const kLayoutDirections = 4;
22 23
23 double clamp({double min: 0.0, double value: 0.0, double max: double.INFINITY}) { 24 double clamp({double min: 0.0, double value: 0.0, double max: double.INFINITY}) {
24 assert(min != null); 25 assert(min != null);
25 assert(value != null); 26 assert(value != null);
26 assert(max != null); 27 assert(max != null);
27 return math.max(min, math.min(max, value)); 28 return math.max(min, math.min(max, value));
28 } 29 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // // irregular shape, e.g. if you have a hole.) 213 // // irregular shape, e.g. if you have a hole.)
213 // // Otherwise: 214 // // Otherwise:
214 // // For each child that intersects x,y, in z-order starting from the top, 215 // // For each child that intersects x,y, in z-order starting from the top,
215 // // call hitTest() for that child, passing it /result/, and the coordinate s 216 // // call hitTest() for that child, passing it /result/, and the coordinate s
216 // // converted to the child's coordinate origin, and stop at the first chil d 217 // // converted to the child's coordinate origin, and stop at the first chil d
217 // // that returns true. 218 // // that returns true.
218 // // Then, add yourself to /result/, and return true. 219 // // Then, add yourself to /result/, and return true.
219 // } 220 // }
220 // You must not add yourself to /result/ if you return false. 221 // You must not add yourself to /result/ if you return false.
221 222
223
224 String toString([String prefix = '']) {
225 String header = '${runtimeType}\n';
226 prefix += ' ';
227 String settings = '${debugDescribeSettings(prefix)}';
228 if (settings != '')
229 settings += '\n';
230 return '${header}${settings}${debugDescribeChildren(prefix)}';
231 }
232 String debugDescribeSettings(String prefix) => '${prefix}parentData: ${parentD ata}';
233 String debugDescribeChildren(String prefix) => '';
234
222 } 235 }
223 236
224 class HitTestResult { 237 class HitTestResult {
225 final List<RenderObject> path = new List<RenderObject>(); 238 final List<RenderObject> path = new List<RenderObject>();
226 239
227 RenderObject get result => path.first; 240 RenderObject get result => path.first;
228 241
229 void add(RenderObject node) { 242 void add(RenderObject node) {
230 path.add(node); 243 path.add(node);
231 } 244 }
(...skipping 13 matching lines...) Expand all
245 adoptChild(_child); 258 adoptChild(_child);
246 } 259 }
247 void attachChildren() { 260 void attachChildren() {
248 if (_child != null) 261 if (_child != null)
249 _child.attach(); 262 _child.attach();
250 } 263 }
251 void detachChildren() { 264 void detachChildren() {
252 if (_child != null) 265 if (_child != null)
253 _child.detach(); 266 _child.detach();
254 } 267 }
268 String debugDescribeChildren(String prefix) => '${prefix}child: ${child.toStri ng(prefix)}';
255 } 269 }
256 270
257 271
258 // GENERIC MIXIN FOR RENDER NODES WITH A LIST OF CHILDREN 272 // GENERIC MIXIN FOR RENDER NODES WITH A LIST OF CHILDREN
259 273
260 abstract class ContainerParentDataMixin<ChildType extends RenderObject> { 274 abstract class ContainerParentDataMixin<ChildType extends RenderObject> {
261 ChildType previousSibling; 275 ChildType previousSibling;
262 ChildType nextSibling; 276 ChildType nextSibling;
263 void detachSiblings() { 277 void detachSiblings() {
264 if (previousSibling != null) { 278 if (previousSibling != null) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 child = child.parentData.nextSibling; 408 child = child.parentData.nextSibling;
395 } 409 }
396 } 410 }
397 411
398 ChildType get firstChild => _firstChild; 412 ChildType get firstChild => _firstChild;
399 ChildType get lastChild => _lastChild; 413 ChildType get lastChild => _lastChild;
400 ChildType childAfter(ChildType child) { 414 ChildType childAfter(ChildType child) {
401 assert(child.parentData is ParentDataType); 415 assert(child.parentData is ParentDataType);
402 return child.parentData.nextSibling; 416 return child.parentData.nextSibling;
403 } 417 }
418
419 String debugDescribeChildren(String prefix) {
420 String result = '';
421 int count = 1;
422 ChildType child = _firstChild;
423 while (child != null) {
424 if (result != '')
425 result += '\n';
426 result += '${prefix}child ${count}: ${child.toString(prefix)}';
427 count += 1;
428 child = child.parentData.nextSibling;
429 }
430 return result;
431 }
404 } 432 }
OLDNEW
« no previous file with comments | « sky/sdk/lib/framework/rendering/flex.dart ('k') | sky/sdk/lib/framework/rendering/paragraph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698