Bug 141742 - Web Inspector: Add context menu item to Reload the Inspector
Summary: Web Inspector: Add context menu item to Reload the Inspector
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Brian Burg
URL:
Keywords: InRadar
Depends on: 151629
Blocks: InspectorDebug
  Show dependency treegraph
 
Reported: 2015-02-17 19:53 PST by Nikita Vasilyev
Modified: 2015-11-29 16:56 PST (History)
8 users (show)

See Also:


Attachments
Reload Inspector context menu (25.65 KB, image/png)
2015-02-17 19:53 PST, Nikita Vasilyev
no flags Details
Proposed Fix (3.10 KB, patch)
2015-11-27 10:53 PST, Brian Burg
timothy: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikita Vasilyev 2015-02-17 19:53:16 PST
Created attachment 246793 [details]
Reload Inspector context menu

Currently, it is possible to reload the Inspector by inspecting it and pressing Command R. There should be a way to do that without opening another Inspector instance.

We could add a context menu or/and introduce a shortcut.
Comment 1 Radar WebKit Bug Importer 2015-02-17 19:53:49 PST
<rdar://problem/19870852>
Comment 2 Brian Burg 2015-02-19 09:22:05 PST
what about closing and reopening it? This will force a new WKWebView to be created and cause a new navigation.

Note that either option will not reload new resources from the source directory, so you would have to still run the WebInspectorUI build step.
Comment 3 Brian Burg 2015-02-19 09:40:27 PST
Anyway, to implement this, here's a sketch:

1. We need to set a WKPageContextMenuClient in InspectorProxy.cpp, near where the other clients are initialized.

2. The callback in there needs to create an array with proposed menu items. I think these are added before Inspect Element, which is generated deep inside WebCore.

3. The item is created using WKContextMenuItemCreateAsAction(kWKContextMenuItemTagReload, WKStringCreateWithUTF8CString("Reload Inspector"), true)

4. Profit!
Comment 4 Brian Burg 2015-11-27 10:53:40 PST
Created attachment 266202 [details]
Proposed Fix

This patch won't apply without the dependent patch.
Comment 5 Nikita Vasilyev 2015-11-27 20:32:23 PST
Command-Option-R toggles responsive design mode in Safari.
Now, pressing Command-Option-R once enters responsive design mode.
Pressing it again, toggles the right sidebar.
https://cloudup.com/c-qJT91xLhK
Comment 6 Nikita Vasilyev 2015-11-27 20:32:47 PST
(In reply to comment #5)
> Command-Option-R toggles responsive design mode in Safari.
> Now, pressing Command-Option-R once enters responsive design mode.
> Pressing it again, toggles the right sidebar.
> https://cloudup.com/c-qJT91xLhK

Whoops, wrong bug.
Comment 7 Nikita Vasilyev 2015-11-27 20:35:28 PST
Thanks for working on this!

While we are at it, would it make sense to add a keyboard shortcut too? Maybe Cmd-Ctrl-R.
Comment 8 Timothy Hatcher 2015-11-28 13:31:54 PST
Comment on attachment 266202 [details]
Proposed Fix

View in context: https://bugs.webkit.org/attachment.cgi?id=266202&action=review

> Source/WebInspectorUI/UserInterface/Base/Main.js:888
> +    return string;

Worthy of a comment.

> Source/WebInspectorUI/UserInterface/Base/Main.js:1342
> +        proposedContextMenu.appendItem(WebInspector.unlocalizedString("Reload Web Inspector"), () => {

Might want to add a separator item.
Comment 9 Brian Burg 2015-11-28 15:25:42 PST
(In reply to comment #7)
> Thanks for working on this!
> 
> While we are at it, would it make sense to add a keyboard shortcut too?
> Maybe Cmd-Ctrl-R.

I held back from this since we have several reload-related shortcuts already. Do we have a clear system to distinguish shortcuts that affect the inspector vs inspected page? I have been using Cmd-Option- as a prefix for some shortcuts that would typically be in the "View" menu.
Comment 10 Brian Burg 2015-11-29 16:45:12 PST
(In reply to comment #7)
> Thanks for working on this!
> 
> While we are at it, would it make sense to add a keyboard shortcut too?
> Maybe Cmd-Ctrl-R.

I will add it as Cmd-Opt-Shift-R. This matches Cmd-Opt-Shift-D (Toggle Debug UI). We generally don't use Ctrl and Cmd in shortcuts, since they are the same thing on other platforms.
Comment 11 Brian Burg 2015-11-29 16:56:33 PST
Committed r192790: <http://trac.webkit.org/changeset/192790>