Web Inspector: default to focusing the console prompt if no other content is focused after opening Web Inspector
https://bugs.webkit.org/show_bug.cgi?id=203743
Reviewed by Eric Carlson and Brian Burg.
* UserInterface/Base/Main.js:
(WI.isContentAreaFocused): Added.
(WI.isConsoleFocused):
(WI._focusChanged):
(WI._restoreCookieForOpenTabs):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebInspectorUI/ChangeLog b/Source/WebInspectorUI/ChangeLog
index bf42c9c..6c7019d 100644
--- a/Source/WebInspectorUI/ChangeLog
+++ b/Source/WebInspectorUI/ChangeLog
@@ -1,3 +1,16 @@
+2019-11-01 Devin Rousso <drousso@apple.com>
+
+ Web Inspector: default to focusing the console prompt if no other content is focused after opening Web Inspector
+ https://bugs.webkit.org/show_bug.cgi?id=203743
+
+ Reviewed by Eric Carlson and Brian Burg.
+
+ * UserInterface/Base/Main.js:
+ (WI.isContentAreaFocused): Added.
+ (WI.isConsoleFocused):
+ (WI._focusChanged):
+ (WI._restoreCookieForOpenTabs):
+
2019-11-01 Nikita Vasilyev <nvasilyev@apple.com>
Web Inspector: Display color swatches for p3 colors
diff --git a/Source/WebInspectorUI/UserInterface/Base/Main.js b/Source/WebInspectorUI/UserInterface/Base/Main.js
index 66335b7..4b7fb11 100644
--- a/Source/WebInspectorUI/UserInterface/Base/Main.js
+++ b/Source/WebInspectorUI/UserInterface/Base/Main.js
@@ -933,9 +933,14 @@
InspectorFrontendHost.closeWindow();
};
+WI.isContentAreaFocused = function()
+{
+ return WI._contentElement.contains(document.activeElement);
+}
+
WI.isConsoleFocused = function()
{
- return WI.quickConsole.prompt.focused;
+ return !WI._didAutofocusConsolePrompt && WI.quickConsole.prompt.focused;
};
WI.isShowingSplitConsole = function()
@@ -1374,6 +1379,8 @@
WI._focusChanged = function(event)
{
+ WI._didAutofocusConsolePrompt = false;
+
// Make a caret selection inside the focused element if there isn't a range selection and there isn't already
// a caret selection inside. This is needed (at least) to remove caret from console when focus is moved.
// The selection change should not apply to text fields and text areas either.
@@ -1548,6 +1555,14 @@
continue;
tabContentView.restoreStateFromCookie(restorationType);
}
+
+ window.requestAnimationFrame(() => {
+ if (WI.isContentAreaFocused())
+ return;
+
+ WI.quickConsole.prompt.focus();
+ WI._didAutofocusConsolePrompt = true;
+ });
};
WI._saveCookieForOpenTabs = function()