Commit 27cceff2 authored by Ian Hickson's avatar Ian Hickson Committed by GitHub

Allow debugPaintSizeEnabled to be toggled from the runner (#7028)

parent 744e89f1
...@@ -535,8 +535,7 @@ class HotRunner extends ResidentRunner { ...@@ -535,8 +535,7 @@ class HotRunner extends ResidentRunner {
); );
printStatus('The Observatory debugger and profiler is available at: http://127.0.0.1:$_observatoryPort/'); printStatus('The Observatory debugger and profiler is available at: http://127.0.0.1:$_observatoryPort/');
if (details) { if (details) {
printStatus('To dump the widget hierarchy of the app (debugDumpApp), press "w".'); printHelpDetails();
printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
printStatus('To repeat this help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.'); printStatus('To repeat this help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.');
} else { } else {
printStatus('For a more detailed help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.'); printStatus('For a more detailed help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.');
......
...@@ -61,17 +61,21 @@ abstract class ResidentRunner { ...@@ -61,17 +61,21 @@ abstract class ResidentRunner {
Future<Null> _debugDumpApp() async { Future<Null> _debugDumpApp() async {
if (vmService != null) if (vmService != null)
await vmService.vm.refreshViews(); await vmService.vm.refreshViews();
await currentView.uiIsolate.flutterDebugDumpApp(); await currentView.uiIsolate.flutterDebugDumpApp();
} }
Future<Null> _debugDumpRenderTree() async { Future<Null> _debugDumpRenderTree() async {
if (vmService != null) if (vmService != null)
await vmService.vm.refreshViews(); await vmService.vm.refreshViews();
await currentView.uiIsolate.flutterDebugDumpRenderTree(); await currentView.uiIsolate.flutterDebugDumpRenderTree();
} }
Future<Null> _debugToggleDebugPaintSizeEnabled() async {
if (vmService != null)
await vmService.vm.refreshViews();
await currentView.uiIsolate.flutterToggleDebugPaintSizeEnabled();
}
void registerSignalHandlers() { void registerSignalHandlers() {
ProcessSignal.SIGINT.watch().listen((ProcessSignal signal) async { ProcessSignal.SIGINT.watch().listen((ProcessSignal signal) async {
_resetTerminal(); _resetTerminal();
...@@ -154,6 +158,11 @@ abstract class ResidentRunner { ...@@ -154,6 +158,11 @@ abstract class ResidentRunner {
return true; return true;
await _debugDumpRenderTree(); await _debugDumpRenderTree();
return true; return true;
} else if (lower == 'p') {
if (!supportsServiceProtocol)
return true;
await _debugToggleDebugPaintSizeEnabled();
return true;
} else if (lower == 'q' || character == AnsiTerminal.KEY_F10) { } else if (lower == 'q' || character == AnsiTerminal.KEY_F10) {
// F10, exit // F10, exit
await stop(); await stop();
...@@ -225,12 +234,19 @@ abstract class ResidentRunner { ...@@ -225,12 +234,19 @@ abstract class ResidentRunner {
appFinished(); appFinished();
} }
/// Called to print help to the terminal.
void printHelp({ @required bool details });
void printHelpDetails() {
printStatus('To dump the widget hierarchy of the app (debugDumpApp), press "w".');
printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
printStatus('To toggle the display of construction lines (debugPaintSizeEnabled), press "p".');
}
/// Called when a signal has requested we exit. /// Called when a signal has requested we exit.
Future<Null> cleanupAfterSignal(); Future<Null> cleanupAfterSignal();
/// Called right before we exit. /// Called right before we exit.
Future<Null> cleanupAtFinish(); Future<Null> cleanupAtFinish();
/// Called to print help to the terminal.
void printHelp({ @required bool details });
/// Called when the runner should handle a terminal command. /// Called when the runner should handle a terminal command.
Future<Null> handleTerminalCommand(String code); Future<Null> handleTerminalCommand(String code);
} }
......
...@@ -179,10 +179,8 @@ class RunAndStayResident extends ResidentRunner { ...@@ -179,10 +179,8 @@ class RunAndStayResident extends ResidentRunner {
printStatus('The Observatory debugger and profiler is available at: http://127.0.0.1:${_result.observatoryPort}/'); printStatus('The Observatory debugger and profiler is available at: http://127.0.0.1:${_result.observatoryPort}/');
if (supportsServiceProtocol) { if (supportsServiceProtocol) {
haveDetails = true; haveDetails = true;
if (details) { if (details)
printStatus('To dump the widget hierarchy of the app (debugDumpApp), press "w".'); printHelpDetails();
printStatus('To dump the rendering tree of the app (debugDumpRenderTree), press "t".');
}
} }
if (haveDetails && !details) { if (haveDetails && !details) {
printStatus('For a more detailed help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.'); printStatus('For a more detailed help message, press "h" or F1. To quit, press "q", F10, or Ctrl-C.');
......
...@@ -810,6 +810,13 @@ class Isolate extends ServiceObjectOwner { ...@@ -810,6 +810,13 @@ class Isolate extends ServiceObjectOwner {
return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpRenderTree'); return invokeFlutterExtensionRpcRaw('ext.flutter.debugDumpRenderTree');
} }
Future<Map<String, dynamic>> flutterToggleDebugPaintSizeEnabled() async {
Map<String, dynamic> state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint');
if (state != null && state.containsKey('enabled') && state['enabled'] is bool)
state = await invokeFlutterExtensionRpcRaw('ext.flutter.debugPaint', <String, dynamic>{ 'enabled': !state['enabled'] });
return state;
}
static bool _isMethodNotFoundException(dynamic e) { static bool _isMethodNotFoundException(dynamic e) {
return (e is rpc.RpcException) && return (e is rpc.RpcException) &&
(e.code == rpc_error_code.METHOD_NOT_FOUND); (e.code == rpc_error_code.METHOD_NOT_FOUND);
......
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