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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/framework/rendering/object.dart
diff --git a/sky/sdk/lib/framework/rendering/object.dart b/sky/sdk/lib/framework/rendering/object.dart
index 736d67771c26f263b17d5df476f26d7d52a8778d..46b414f3c14e8d032a92e140ac83ae18b559b408 100644
--- a/sky/sdk/lib/framework/rendering/object.dart
+++ b/sky/sdk/lib/framework/rendering/object.dart
@@ -16,6 +16,7 @@ class ParentData {
// override this in subclasses to merge in data from other into this
assert(other.runtimeType == this.runtimeType);
}
+ String toString() => '<none>';
}
const kLayoutDirections = 4;
@@ -219,6 +220,18 @@ abstract class RenderObject extends AbstractNode {
// }
// You must not add yourself to /result/ if you return false.
+
+ String toString([String prefix = '']) {
+ String header = '${runtimeType}\n';
+ prefix += ' ';
+ String settings = '${debugDescribeSettings(prefix)}';
+ if (settings != '')
+ settings += '\n';
+ return '${header}${settings}${debugDescribeChildren(prefix)}';
+ }
+ String debugDescribeSettings(String prefix) => '${prefix}parentData: ${parentData}';
+ String debugDescribeChildren(String prefix) => '';
+
}
class HitTestResult {
@@ -252,6 +265,7 @@ abstract class RenderObjectWithChildMixin<ChildType extends RenderObject> {
if (_child != null)
_child.detach();
}
+ String debugDescribeChildren(String prefix) => '${prefix}child: ${child.toString(prefix)}';
}
@@ -401,4 +415,18 @@ abstract class ContainerRenderObjectMixin<ChildType extends RenderObject, Parent
assert(child.parentData is ParentDataType);
return child.parentData.nextSibling;
}
+
+ String debugDescribeChildren(String prefix) {
+ String result = '';
+ int count = 1;
+ ChildType child = _firstChild;
+ while (child != null) {
+ if (result != '')
+ result += '\n';
+ result += '${prefix}child ${count}: ${child.toString(prefix)}';
+ count += 1;
+ child = child.parentData.nextSibling;
+ }
+ return result;
+ }
}
« 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