Title: [170238] trunk/Source/WebInspectorUI
- Revision
- 170238
- Author
- [email protected]
- Date
- 2014-06-21 07:51:12 -0700 (Sat, 21 Jun 2014)
Log Message
Web Inspector: Esc in quick console no longer toggles console drawer
https://bugs.webkit.org/show_bug.cgi?id=134068
Patch by Joseph Pecoraro <[email protected]> on 2014-06-21
Reviewed by Timothy Hatcher.
For Escape to toggle console behavior we were relying on the Escape
keyboard event to propagate up to the window and be handled by
QuickConsole's global keyboard shortcut. With CodeMirror 4, all
editors have a default "Esc" key handler to reduce multiple selections
to a single selection. Unfortunately this always prevents default,
which our keyboard shortcut respects and doesn't toggle the console.
Workaround this by putting a specific handler for when a Console
Prompt is empty and the Escape key is triggered. This does not go
through the normal ConsolePrompt delegate because the delegate
is never the QuickConsole, it is actually the _javascript_ log.
* UserInterface/Views/ConsolePrompt.js:
(WebInspector.ConsolePrompt):
(WebInspector.ConsolePrompt.prototype.set escapeKeyHandlerWhenEmpty):
(WebInspector.ConsolePrompt.prototype._handleEscapeKey):
* UserInterface/Views/QuickConsole.js:
(WebInspector.QuickConsole.this.prompt.escapeKeyHandlerWhenEmpty):
(WebInspector.QuickConsole):
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (170237 => 170238)
--- trunk/Source/WebInspectorUI/ChangeLog 2014-06-21 14:43:35 UTC (rev 170237)
+++ trunk/Source/WebInspectorUI/ChangeLog 2014-06-21 14:51:12 UTC (rev 170238)
@@ -1,3 +1,30 @@
+2014-06-21 Joseph Pecoraro <[email protected]>
+
+ Web Inspector: Esc in quick console no longer toggles console drawer
+ https://bugs.webkit.org/show_bug.cgi?id=134068
+
+ Reviewed by Timothy Hatcher.
+
+ For Escape to toggle console behavior we were relying on the Escape
+ keyboard event to propagate up to the window and be handled by
+ QuickConsole's global keyboard shortcut. With CodeMirror 4, all
+ editors have a default "Esc" key handler to reduce multiple selections
+ to a single selection. Unfortunately this always prevents default,
+ which our keyboard shortcut respects and doesn't toggle the console.
+
+ Workaround this by putting a specific handler for when a Console
+ Prompt is empty and the Escape key is triggered. This does not go
+ through the normal ConsolePrompt delegate because the delegate
+ is never the QuickConsole, it is actually the _javascript_ log.
+
+ * UserInterface/Views/ConsolePrompt.js:
+ (WebInspector.ConsolePrompt):
+ (WebInspector.ConsolePrompt.prototype.set escapeKeyHandlerWhenEmpty):
+ (WebInspector.ConsolePrompt.prototype._handleEscapeKey):
+ * UserInterface/Views/QuickConsole.js:
+ (WebInspector.QuickConsole.this.prompt.escapeKeyHandlerWhenEmpty):
+ (WebInspector.QuickConsole):
+
2014-06-18 James Craig <[email protected]>
Web Inspector: AXI: expose aria-relevant
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js (170237 => 170238)
--- trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js 2014-06-21 14:43:35 UTC (rev 170237)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ConsolePrompt.js 2014-06-21 14:51:12 UTC (rev 170238)
@@ -49,7 +49,8 @@
"Ctrl-P": this._handlePreviousKey.bind(this),
"Ctrl-N": this._handleNextKey.bind(this),
"Enter": this._handleEnterKey.bind(this),
- "Cmd-Enter": this._handleCommandEnterKey.bind(this)
+ "Cmd-Enter": this._handleCommandEnterKey.bind(this),
+ "Esc": this._handleEscapeKey.bind(this)
};
this._codeMirror.addKeyMap(keyMap);
@@ -84,6 +85,11 @@
this._delegate = delegate || null;
},
+ set escapeKeyHandlerWhenEmpty(handler)
+ {
+ this._escapeKeyHandlerWhenEmpty = handler;
+ },
+
get text()
{
return this._codeMirror.getValue();
@@ -152,7 +158,18 @@
},
// Private
+
+ _handleEscapeKey: function(codeMirror)
+ {
+ if (this.text)
+ return CodeMirror.Pass;
+ if (!this._escapeKeyHandlerWhenEmpty)
+ return CodeMirror.Pass;
+
+ this._escapeKeyHandlerWhenEmpty();
+ },
+
_handlePreviousKey: function(codeMirror)
{
if (this._codeMirror.somethingSelected())
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js (170237 => 170238)
--- trunk/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js 2014-06-21 14:43:35 UTC (rev 170237)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/QuickConsole.js 2014-06-21 14:51:12 UTC (rev 170238)
@@ -43,6 +43,13 @@
this.prompt.element.classList.add(WebInspector.QuickConsole.TextPromptStyleClassName);
this._element.appendChild(this.prompt.element);
+ // FIXME: CodeMirror 4 has a default "Esc" key handler that always prevents default.
+ // Our keyboard shortcut above will respect the default prevented and ignore the event
+ // and not toggle the console. Install our own Escape key handler that will trigger
+ // when the ConsolePrompt is empty, to restore toggling behavior. A better solution
+ // would be for CodeMirror's event handler to pass if it doesn't do anything.
+ this.prompt.escapeKeyHandlerWhenEmpty = function() { WebInspector.toggleSplitConsole(); };
+
this.prompt.shown();
this._navigationBar = new WebInspector.QuickConsoleNavigationBar;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes