Changeset 292120 in webkit


Ignore:
Timestamp:
Mar 30, 2022 1:55:57 PM (4 months ago)
Author:
Devin Rousso
Message:

Web Inspector: Sources: the mapped file URL of a Response Local Override should be clickable
https://bugs.webkit.org/show_bug.cgi?id=238533

Reviewed by Patrick Angle.

Source/WebCore:

  • inspector/InspectorFrontendHost.h:
  • inspector/InspectorFrontendHost.idl:
  • inspector/InspectorFrontendHost.cpp:

(WebCore::InspectorFrontendHost::revealFileExternally): Added.
Add a helper for selecting a file in the system file explorer.

  • inspector/InspectorFrontendClient.h:
  • inspector/InspectorFrontendClientLocal.h:

(WebCore::InspectorFrontendClientLocal::revealFileExternally): Added.
Do nothing in tests (and WK1) as there is no way to check for another app being opened.

Source/WebInspectorUI:

  • UserInterface/Views/ResourceContentView.js:

(WI.ResourceContentView.prototype._handleMappedFilePathChanged):
Instead of showing the mapped file path as basic text, linkify it such that it is shown in
the system file explorer when clicked.

  • UserInterface/Base/Main.js:

(WI.createMessageTextView):
Allow the message to be a Node (in addition to a String).

Source/WebKit:

  • WebProcess/Inspector/RemoteWebInspectorUI.h:
  • WebProcess/Inspector/RemoteWebInspectorUI.cpp:

(WebKit::RemoteWebInspectorUI::revealFileExternally): Added.

  • WebProcess/Inspector/WebInspectorUI.h:
  • WebProcess/Inspector/WebInspectorUI.cpp:

(WebKit::WebInspectorUI::revealFileExternally): Added.

  • UIProcess/Inspector/WebInspectorUIProxy.messages.in:
  • UIProcess/Inspector/WebInspectorUIProxy.h:
  • UIProcess/Inspector/WebInspectorUIProxy.cpp:

(WebKit::WebInspectorUIProxy::revealFileExternally): Added.
(WebKit::WebInspectorUIProxy::platformRevealFileExternally): Added.

  • UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.mm:

(WebKit::WebInspectorUIProxy::platformRevealFileExternally): Added.

  • UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:

(WebKit::WebInspectorUIProxy::platformRevealFileExternally): Added.

  • UIProcess/Inspector/win/WebInspectorUIProxyWin.mm:

(WebKit::WebInspectorUIProxy::platformRevealFileExternally): Added.

  • UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in:
  • UIProcess/Inspector/RemoteWebInspectorUIProxy.h:
  • UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp:

(WebKit::RemoteWebInspectorUIProxy::revealFileExternally): Added.
(WebKit::RemoteWebInspectorUIProxy::platformRevealFileExternally): Added.

  • UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp:

(WebKit::RemoteWebInspectorUIProxy::platformRevealFileExternally): Added.

  • UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm:

(WebKit::RemoteWebInspectorUIProxy::platformRevealFileExternally): Added.

  • UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp:

(WebKit::RemoteWebInspectorUIProxy::platformRevealFileExternally): Added.
Add a helper for selecting a file in the system file explorer.

Location:
trunk/Source
Files:
26 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r292118 r292120  
     12022-03-30  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Sources: the mapped file URL of a Response Local Override should be clickable
     4        https://bugs.webkit.org/show_bug.cgi?id=238533
     5
     6        Reviewed by Patrick Angle.
     7
     8        * inspector/InspectorFrontendHost.h:
     9        * inspector/InspectorFrontendHost.idl:
     10        * inspector/InspectorFrontendHost.cpp:
     11        (WebCore::InspectorFrontendHost::revealFileExternally): Added.
     12        Add a helper for selecting a file in the system file explorer.
     13
     14        * inspector/InspectorFrontendClient.h:
     15        * inspector/InspectorFrontendClientLocal.h:
     16        (WebCore::InspectorFrontendClientLocal::revealFileExternally): Added.
     17        Do nothing in tests (and WK1) as there is no way to check for another app being opened.
     18
    1192022-03-30  Chris Dumez  <cdumez@apple.com>
    220
  • trunk/Source/WebCore/inspector/InspectorFrontendClient.h

    r292084 r292120  
    107107
    108108    WEBCORE_EXPORT virtual void openURLExternally(const String& url) = 0;
     109    WEBCORE_EXPORT virtual void revealFileExternally(const String& path) = 0;
    109110    virtual bool canSave() = 0;
    110111    virtual void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs) = 0;
  • trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h

    r292084 r292120  
    8181    WEBCORE_EXPORT void changeSheetRect(const FloatRect&) final;
    8282    WEBCORE_EXPORT void openURLExternally(const String& url) final;
     83    void revealFileExternally(const String&) override { }
    8384    bool canSave()  override { return false; }
    8485    void save(const String&, const String&, bool, bool) override { }
  • trunk/Source/WebCore/inspector/InspectorFrontendHost.cpp

    r292100 r292120  
    445445}
    446446
     447void InspectorFrontendHost::revealFileExternally(const String& path)
     448{
     449    if (!WTF::protocolIs(path, "file"))
     450        return;
     451
     452    if (m_client)
     453        m_client->revealFileExternally(path);
     454}
     455
    447456bool InspectorFrontendHost::canSave()
    448457{
  • trunk/Source/WebCore/inspector/InspectorFrontendHost.h

    r292084 r292120  
    109109    void killText(const String& text, bool shouldPrependToKillRing, bool shouldStartNewSequence);
    110110    void openURLExternally(const String& url);
     111    void revealFileExternally(const String& path);
    111112    bool canSave();
    112113    void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs);
  • trunk/Source/WebCore/inspector/InspectorFrontendHost.idl

    r292084 r292120  
    7272    undefined killText(DOMString text, boolean shouldPrependToKillRing, boolean shouldStartNewSequence);
    7373    undefined openURLExternally(DOMString url);
     74    undefined revealFileExternally(DOMString path);
    7475    boolean canSave();
    7576    undefined save(DOMString url, DOMString content, boolean base64Encoded, boolean forceSaveAs);
  • trunk/Source/WebInspectorUI/ChangeLog

    r292084 r292120  
     12022-03-30  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Sources: the mapped file URL of a Response Local Override should be clickable
     4        https://bugs.webkit.org/show_bug.cgi?id=238533
     5
     6        Reviewed by Patrick Angle.
     7
     8        * UserInterface/Views/ResourceContentView.js:
     9        (WI.ResourceContentView.prototype._handleMappedFilePathChanged):
     10        Instead of showing the mapped file path as basic text, linkify it such that it is shown in
     11        the system file explorer when clicked.
     12
     13        * UserInterface/Base/Main.js:
     14        (WI.createMessageTextView):
     15        Allow the `message` to be a `Node` (in addition to a `String`).
     16
    1172022-03-29  Devin Rousso  <drousso@apple.com>
    218
  • trunk/Source/WebInspectorUI/UserInterface/Base/Main.js

    r291093 r292120  
    30853085    let textElement = messageElement.appendChild(document.createElement("div"));
    30863086    textElement.className = "message";
    3087     textElement.textContent = message;
     3087    textElement.append(message);
    30883088
    30893089    return messageElement;
  • trunk/Source/WebInspectorUI/UserInterface/Views/ResourceContentView.js

    r292084 r292120  
    385385    _handleMappedFilePathChanged(event)
    386386    {
    387         this.showMessage(WI.UIString("Mapped to \u201C%s\u201D").format(this.resource.mappedFilePath));
     387        let mappedFilePath = this.resource.mappedFilePath;
     388
     389        let mappedFilePathLink = document.createElement("a");
     390        mappedFilePathLink.href = "file://" + mappedFilePath;
     391        mappedFilePathLink.textContent = mappedFilePath;
     392        mappedFilePathLink.addEventListener("click", (event) => {
     393            event.stop();
     394
     395            InspectorFrontendHost.revealFileExternally(event.target.href);
     396        });
     397
     398        let fragment = document.createDocumentFragment();
     399        String.format(WI.UIString("Mapped to \u201C%s\u201D"), [mappedFilePathLink], String.standardFormatters, fragment, (a, b) => {
     400            a.append(b);
     401            return a;
     402        });
     403        this.showMessage(fragment);
    388404
    389405        if (this._localResourceOverrideBannerView) {
  • trunk/Source/WebKit/ChangeLog

    r292119 r292120  
     12022-03-30  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Sources: the mapped file URL of a Response Local Override should be clickable
     4        https://bugs.webkit.org/show_bug.cgi?id=238533
     5
     6        Reviewed by Patrick Angle.
     7
     8        * WebProcess/Inspector/RemoteWebInspectorUI.h:
     9        * WebProcess/Inspector/RemoteWebInspectorUI.cpp:
     10        (WebKit::RemoteWebInspectorUI::revealFileExternally): Added.
     11        * WebProcess/Inspector/WebInspectorUI.h:
     12        * WebProcess/Inspector/WebInspectorUI.cpp:
     13        (WebKit::WebInspectorUI::revealFileExternally): Added.
     14        * UIProcess/Inspector/WebInspectorUIProxy.messages.in:
     15        * UIProcess/Inspector/WebInspectorUIProxy.h:
     16        * UIProcess/Inspector/WebInspectorUIProxy.cpp:
     17        (WebKit::WebInspectorUIProxy::revealFileExternally): Added.
     18        (WebKit::WebInspectorUIProxy::platformRevealFileExternally): Added.
     19        * UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.mm:
     20        (WebKit::WebInspectorUIProxy::platformRevealFileExternally): Added.
     21        * UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm:
     22        (WebKit::WebInspectorUIProxy::platformRevealFileExternally): Added.
     23        * UIProcess/Inspector/win/WebInspectorUIProxyWin.mm:
     24        (WebKit::WebInspectorUIProxy::platformRevealFileExternally): Added.
     25        * UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in:
     26        * UIProcess/Inspector/RemoteWebInspectorUIProxy.h:
     27        * UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp:
     28        (WebKit::RemoteWebInspectorUIProxy::revealFileExternally): Added.
     29        (WebKit::RemoteWebInspectorUIProxy::platformRevealFileExternally): Added.
     30        * UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp:
     31        (WebKit::RemoteWebInspectorUIProxy::platformRevealFileExternally): Added.
     32        * UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm:
     33        (WebKit::RemoteWebInspectorUIProxy::platformRevealFileExternally): Added.
     34        * UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp:
     35        (WebKit::RemoteWebInspectorUIProxy::platformRevealFileExternally): Added.
     36        Add a helper for selecting a file in the system file explorer.
     37
    1382022-03-30  Sihui Liu  <sihui_liu@apple.com>
    239
  • trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.cpp

    r292084 r292120  
    180180}
    181181
     182void RemoteWebInspectorUIProxy::revealFileExternally(const String& path)
     183{
     184    platformRevealFileExternally(path);
     185}
     186
    182187void RemoteWebInspectorUIProxy::showCertificate(const CertificateInfo& certificateInfo)
    183188{
     
    244249void RemoteWebInspectorUIProxy::platformStartWindowDrag() { }
    245250void RemoteWebInspectorUIProxy::platformOpenURLExternally(const String&) { }
     251void RemoteWebInspectorUIProxy::platformRevealFileExternally(const String&) { }
    246252void RemoteWebInspectorUIProxy::platformShowCertificate(const CertificateInfo&) { }
    247253void RemoteWebInspectorUIProxy::platformCloseFrontendPageAndWindow() { }
  • trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.h

    r292084 r292120  
    139139    void startWindowDrag();
    140140    void openURLExternally(const String& url);
     141    void revealFileExternally(const String& path);
    141142    void showCertificate(const WebCore::CertificateInfo&);
    142143    void sendMessageToBackend(const String& message);
     
    157158    void platformStartWindowDrag();
    158159    void platformOpenURLExternally(const String& url);
     160    void platformRevealFileExternally(const String& path);
    159161    void platformShowCertificate(const WebCore::CertificateInfo&);
    160162
  • trunk/Source/WebKit/UIProcess/Inspector/RemoteWebInspectorUIProxy.messages.in

    r292084 r292120  
    3939
    4040    OpenURLExternally(String url)
     41    RevealFileExternally(String path)
     42
    4143    ShowCertificate(WebCore::CertificateInfo certificateInfo)
    4244
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.cpp

    r292084 r292120  
    641641}
    642642
     643void WebInspectorUIProxy::revealFileExternally(const String& path)
     644{
     645    platformRevealFileExternally(path);
     646}
     647
    643648void WebInspectorUIProxy::inspectedURLChanged(const String& urlString)
    644649{
     
    816821}
    817822
     823void WebInspectorUIProxy::platformRevealFileExternally(const String&)
     824{
     825    notImplemented();
     826}
     827
    818828void WebInspectorUIProxy::platformInspectedURLChanged(const String&)
    819829{
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.h

    r292084 r292120  
    159159    void showMainResourceForFrame(WebFrameProxy*);
    160160    void openURLExternally(const String& url);
     161    void revealFileExternally(const String& path);
    161162
    162163    AttachmentSide attachmentSide() const { return m_attachmentSide; }
     
    235236    void platformSetSheetRect(const WebCore::FloatRect&);
    236237    void platformStartWindowDrag();
     238    void platformRevealFileExternally(const String&);
    237239    void platformSave(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
    238240    void platformAppend(const String& filename, const String& content);
  • trunk/Source/WebKit/UIProcess/Inspector/WebInspectorUIProxy.messages.in

    r292084 r292120  
    3636    SetForcedAppearance(WebCore::InspectorFrontendClient::Appearance appearance)
    3737    OpenURLExternally(String url)
     38    RevealFileExternally(String path)
    3839
    3940    InspectedURLChanged(String urlString)
  • trunk/Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorUIProxyGtk.cpp

    r292084 r292120  
    184184}
    185185
     186void RemoteWebInspectorUIProxy::platformRevealFileExternally(const String&)
     187{
     188}
     189
    186190void RemoteWebInspectorUIProxy::platformShowCertificate(const CertificateInfo&)
    187191{
  • trunk/Source/WebKit/UIProcess/Inspector/gtk/WebInspectorUIProxyGtk.cpp

    r292084 r292120  
    369369}
    370370
     371void WebInspectorUIProxy::platformRevealFileExternally(const String&)
     372{
     373    notImplemented();
     374}
     375
    371376void WebInspectorUIProxy::platformInspectedURLChanged(const String& url)
    372377{
  • trunk/Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorUIProxyMac.mm

    r292084 r292120  
    281281}
    282282
     283void RemoteWebInspectorUIProxy::platformRevealFileExternally(const String& path)
     284{
     285    [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:@[ [NSURL URLWithString:path] ]];
     286}
     287
    283288void RemoteWebInspectorUIProxy::platformShowCertificate(const CertificateInfo& certificateInfo)
    284289{
  • trunk/Source/WebKit/UIProcess/Inspector/mac/WebInspectorUIProxyMac.mm

    r292084 r292120  
    497497}
    498498
     499void WebInspectorUIProxy::platformRevealFileExternally(const String& path)
     500{
     501    [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:@[ [NSURL URLWithString:path] ]];
     502}
     503
    499504void WebInspectorUIProxy::platformSave(const String& suggestedURL, const String& content, bool base64Encoded, bool forceSaveDialog)
    500505{
  • trunk/Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorUIProxyWin.cpp

    r292084 r292120  
    140140void RemoteWebInspectorUIProxy::platformStartWindowDrag() { }
    141141void RemoteWebInspectorUIProxy::platformOpenURLExternally(const String&) { }
     142void RemoteWebInspectorUIProxy::platformRevealFileExternally(const String&) { }
    142143void RemoteWebInspectorUIProxy::platformShowCertificate(const WebCore::CertificateInfo&) { }
    143144
  • trunk/Source/WebKit/UIProcess/Inspector/win/WebInspectorUIProxyWin.cpp

    r292084 r292120  
    399399}
    400400
     401void WebInspectorUIProxy::platformRevealFileExternally(const String&)
     402{
     403    notImplemented();
     404}
     405
    401406void WebInspectorUIProxy::platformInspectedURLChanged(const String& /* url */)
    402407{
  • trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp

    r292084 r292120  
    219219}
    220220
     221void RemoteWebInspectorUI::revealFileExternally(const String& path)
     222{
     223    WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorUIProxy::RevealFileExternally(path), m_page.identifier());
     224}
     225
    221226void RemoteWebInspectorUI::save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs)
    222227{
  • trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h

    r292084 r292120  
    106106
    107107    void openURLExternally(const String& url) override;
     108    void revealFileExternally(const String& path) override;
    108109    void save(const String& url, const String& content, bool base64Encoded, bool forceSaveAs) override;
    109110    void append(const String& url, const String& content) override;
  • trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp

    r292102 r292120  
    294294}
    295295
     296void WebInspectorUI::revealFileExternally(const String& path)
     297{
     298    WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorUIProxy::RevealFileExternally(path), m_inspectedPageIdentifier);
     299}
     300
    296301void WebInspectorUI::save(const WTF::String& filename, const WTF::String& content, bool base64Encoded, bool forceSaveAs)
    297302{
  • trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.h

    r292084 r292120  
    140140
    141141    void openURLExternally(const String& url) override;
    142 
     142    void revealFileExternally(const String& path) override;
    143143    bool canSave() override;
    144144    void save(const WTF::String& url, const WTF::String& content, bool base64Encoded, bool forceSaveAs) override;
Note: See TracChangeset for help on using the changeset viewer.