Commit ece851d5 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Minor improvements to the render tree dump. (#6831)

Also fixes https://github.com/flutter/flutter/issues/6510
parent f0b8c866
......@@ -1191,7 +1191,7 @@ class BoxDecoration extends Decoration {
/// If the method is passed a non-empty string argument, then the output will
/// span multiple lines, each prefixed by that argument.
@override
String toString([String prefix = '']) {
String toString([String prefix = '', String indentPrefix]) {
List<String> result = <String>[];
if (backgroundColor != null)
result.add('${prefix}backgroundColor: $backgroundColor');
......@@ -1201,8 +1201,15 @@ class BoxDecoration extends Decoration {
result.add('${prefix}border: $border');
if (borderRadius != null)
result.add('${prefix}borderRadius: $borderRadius');
if (boxShadow != null)
result.add('${prefix}boxShadow: ${boxShadow.map((BoxShadow shadow) => shadow.toString())}');
if (boxShadow != null) {
if (indentPrefix != null && boxShadow.length > 1) {
result.add('${prefix}boxShadow:');
for (BoxShadow shadow in boxShadow)
result.add('$indentPrefix$shadow');
} else {
result.add('${prefix}boxShadow: ${boxShadow.map((BoxShadow shadow) => shadow.toString()).join(", ")}');
}
}
if (gradient != null)
result.add('${prefix}gradient: $gradient');
if (shape != BoxShape.rectangle)
......
......@@ -79,8 +79,16 @@ abstract class Decoration {
/// if it is a [BoxDecoration] with definitely no [BackgroundImage]).
BoxPainter createBoxPainter([VoidCallback onChanged]);
/// Returns a string representation of this object.
///
/// Every line of the output should be prefixed by `prefix`.
///
/// If `indentPrefix` is non-null, then the description can be further split
/// into sublines, and each subline should be prefixed with `indentPrefix`
/// (rather that `prefix`). This is used, for example, by [BoxDecoration] for
/// the otherwise quite verbose [BoxShadow] descriptions.
@override
String toString([String prefix = '']) => '$prefix$runtimeType';
String toString([String prefix = '', String indentPrefix ]) => '$prefix$runtimeType';
}
/// A stateful class that can paint a particular [Decoration].
......
......@@ -220,7 +220,7 @@ class FlutterLogoDecoration extends Decoration {
}
@override
String toString([String prefix = '']) {
String toString([String prefix = '', String prefixIndent ]) {
final String extra = _inTransition ? ', transition $_position:$_opacity' : '';
if (swatch == null)
return '$prefix$runtimeType(null, $style$extra)';
......
......@@ -2409,7 +2409,10 @@ abstract class RenderObject extends AbstractNode implements HitTestTarget {
final String descriptionPrefix = childrenDescription != '' ? '$prefixOtherLines \u2502 ' : '$prefixOtherLines ';
List<String> description = <String>[];
debugFillDescription(description);
result += description.map((String description) => "$descriptionPrefix$description\n").join();
result += description
.expand((String description) => description.split('\n'))
.map/*<String>*/((String line) => "$descriptionPrefix$line\n")
.join();
if (childrenDescription == '')
result += '$prefixOtherLines\n';
result += childrenDescription;
......
......@@ -1298,7 +1298,7 @@ class RenderDecoratedBox extends RenderProxyBox {
void debugFillDescription(List<String> description) {
super.debugFillDescription(description);
description.add('decoration:');
description.addAll(_decoration.toString(" ").split('\n'));
description.addAll(_decoration.toString(' ', ' ').split('\n'));
description.add('configuration: $configuration');
}
}
......
......@@ -2560,7 +2560,19 @@ abstract class Element implements BuildContext {
}
if (node != null)
chain.add('\u22EF');
return chain.join(' \u2190 ');
String result = '';
String line = '';
for (String link in chain) {
if (line != '')
line += ' \u2190 ';
if (link.length > 3 && line.length + link.length > 65) {
result += '$line\n';
line = ' ';
}
line += link;
}
result += line;
return result;
}
/// A short, textual description of this element.
......@@ -3462,7 +3474,10 @@ abstract class RenderObjectElement extends BuildableElement {
}
void _debugUpdateRenderObjectOwner() {
_renderObject.debugCreator = debugGetCreatorChain(10);
assert(() {
_renderObject.debugCreator = new _DebugCreator(this);
return true;
});
}
@override
......@@ -3922,6 +3937,13 @@ class MultiChildRenderObjectElement extends RenderObjectElement {
}
}
class _DebugCreator {
_DebugCreator(this.element);
final RenderObjectElement element;
@override
String toString() => element.debugGetCreatorChain(12);
}
void _debugReportException(String context, dynamic exception, StackTrace stack, {
InformationCollector informationCollector
}) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment