Skip to content

Commit

Permalink
Cherry-pick 08a1f39. rdar://122924275
Browse files Browse the repository at this point in the history
    Fix Web Inspector: Remember the message type selection in the Console tab
    rdar://122924275
    https://bugs.webkit.org/show_bug.cgi?id=268882

    Reviewed by Devin Rousso.

    When showing the the inspector's console using `WI.showConsole()`, the
    caller can optionally pass in a `requestedScope` to control which levels
    (AKA message types) to be filtered automatically when the Console tab
    shows up. However, when `requestedScope` is falsy or left empty, it
    always applies `WI.LogContentView.Scopes.All` instead, which
    overrides the levels selected by default, which are read from local
    settings when the scope bar is created at the inspector's startup.

    This commit removes the forced application of `Scopes.All`, so when
    `requestedScope` is left empty, the Console tab is shown with levels
    unchanged, which is the expected behavior when launching the Console tab
    through Develop -> Show JavaScript Console (or Option-Command-C).

    This fix has one known side-effect: when an inspector tab does not
    support split console view, pressing Esc will switch to the actual
    Console tab instead. (The Settings tab is one example of such tab.)
    This commit will make that also "remember" the previously selected
    levels instead of deselecting back to just `Scopes.All`, which is
    arguably the correct behavior anyway.

    This commit also cleans up on how `requestedScope` gets passed in;
    passing in as part of the `options` parameter allows callers of
    `showConsole()` to self-document the usage `requestedScope`.

    * Source/WebInspectorUI/UserInterface/Base/Main.js:
      - Fix the bug.
      - Adapt to the clean up for the `options` parameter.
    * Source/WebInspectorUI/UserInterface/Protocol/InspectorFrontendAPI.js:
    (InspectorFrontendAPI.showConsole):
      - Adapt to the clean up for the `options` parameter.
    * Source/WebInspectorUI/UserInterface/Views/LogContentView.js:
    (WI.LogContentView.prototype._showConsoleTab):
      - Adapt to the clean up for the `options` parameter.

    Canonical link: https://commits.webkit.org/275143@main
  • Loading branch information
the-chenergy authored and Mohsin Qureshi committed Mar 6, 2024
1 parent 5127628 commit 5ae3830
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
13 changes: 7 additions & 6 deletions Source/WebInspectorUI/UserInterface/Base/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,8 @@ WI.contentLoaded = function()
WI._consoleWarningsTabBarButton.imageType = WI.ButtonNavigationItem.ImageType.IMG;
WI._consoleWarningsTabBarButton.hidden = true;
WI._consoleWarningsTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
WI.showConsoleTab(WI.LogContentView.Scopes.Warnings, {
WI.showConsoleTab({
requestedScope: WI.LogContentView.Scopes.Warnings,
initiatorHint: WI.TabBrowser.TabNavigationInitiator.Dashboard,
});
}, WI);
Expand All @@ -462,7 +463,8 @@ WI.contentLoaded = function()
WI._consoleErrorsTabBarButton.imageType = WI.ButtonNavigationItem.ImageType.IMG;
WI._consoleErrorsTabBarButton.hidden = true;
WI._consoleErrorsTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, function(event) {
WI.showConsoleTab(WI.LogContentView.Scopes.Errors, {
WI.showConsoleTab({
requestedScope: WI.LogContentView.Scopes.Errors,
initiatorHint: WI.TabBrowser.TabNavigationInitiator.Dashboard,
});
}, WI);
Expand Down Expand Up @@ -1199,13 +1201,12 @@ WI.hideSplitConsole = function()
WI.consoleDrawer.collapsed = true;
};

WI.showConsoleTab = function(requestedScope, options = {})
WI.showConsoleTab = function(options = {})
{
requestedScope = requestedScope || WI.LogContentView.Scopes.All;

WI.hideSplitConsole();

WI.consoleContentView.scopeBar.item(requestedScope).selected = true;
if (options.requestedScope)
WI.consoleContentView.scopeBar.item(options.requestedScope).selected = true;

const cookie = null;
WI.showRepresentedObject(WI._consoleRepresentedObject, cookie, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ InspectorFrontendAPI = {

showConsole: function()
{
const requestedScope = null;
WI.showConsoleTab(requestedScope, {
WI.showConsoleTab({
initiatorHint: WI.TabBrowser.TabNavigationInitiator.FrontendAPI,
});

Expand Down
3 changes: 1 addition & 2 deletions Source/WebInspectorUI/UserInterface/Views/LogContentView.js
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,7 @@ WI.LogContentView = class LogContentView extends WI.ContentView

_showConsoleTab()
{
const requestedScope = null;
WI.showConsoleTab(requestedScope, {
WI.showConsoleTab({
initiatorHint: WI.TabBrowser.TabNavigationInitiator.ButtonClick,
});
}
Expand Down

0 comments on commit 5ae3830

Please sign in to comment.