Changeset 146518 in webkit


Ignore:
Timestamp:
Mar 21, 2013 2:16:41 PM (11 years ago)
Author:
timothy@apple.com
Message:

Support connecting the Web Inspector without showing it.

This allows you to get the debugger attached in the background. When a breakpoint is hit
the Inspector will open. This change also reduces some WebProcess messaging by removing
the DidLoadInspectorPage message and stops sending the SetAttachedWindow message on close.

https://bugs.webkit.org/show_bug.cgi?id=112445

Reviewed by Sam Weinig.

  • UIProcess/API/C/WKInspector.cpp:

(WKInspectorIsConnected): Added.
(WKInspectorConnect): Added.
(WKInspectorHide): Added.

  • UIProcess/API/C/WKInspector.h:

Added new APIs.

  • UIProcess/WebInspectorProxy.cpp:

(WebKit::WebInspectorProxy::WebInspectorProxy):
Initialize new state booleans.

(WebKit::WebInspectorProxy::invalidate):
Don't set state booleans that didClose already resets.

(WebKit::WebInspectorProxy::connect): Added.
(WebKit::WebInspectorProxy::show):
Open if we are already connected. Call connect().

(WebKit::WebInspectorProxy::hide): Added.

(WebKit::WebInspectorProxy::close):
Call didClose we can detach or close the window immediately instead of waiting for a
message from the WebProcess.

(WebKit::WebInspectorProxy::attach):
(WebKit::WebInspectorProxy::detach):
Check for !m_page to match other functions.

(WebKit::WebInspectorProxy::createInspectorPage):
(WebKit::WebInspectorProxy::didLoadInspectorPage):
Removed. Moved logic to open().

(WebKit::WebInspectorProxy::open): Added.

(WebKit::WebInspectorProxy::didClose):
Clear new state booleans. Don't perform work again if already closed. Use platformDetach()
instead of detach() to avoid sending the SetAttachedWindow message.

(WebKit::WebInspectorProxy::bringToFront):
Call open() if we are not visible yet, otherwise platformBringToFront.

  • UIProcess/WebInspectorProxy.h:

(WebKit::WebInspectorProxy::isConnected): Added.

  • UIProcess/WebInspectorProxy.messages.in: Removed DidLoadInspectorPage.
  • UIProcess/gtk/WebInspectorProxyGtk.cpp:

(WebKit::WebInspectorProxy::platformHide): Added stub.

  • UIProcess/mac/WebInspectorProxyMac.mm:

(WebKit::WebInspectorProxy::platformHide): Added.

  • UIProcess/qt/WebInspectorProxyQt.cpp:

(WebKit::WebInspectorProxy::platformHide): Added stub.

  • WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp:
  • WebProcess/WebCoreSupport/WebInspectorFrontendClient.h:

Removed frontendLoaded().

  • WebProcess/WebPage/WebInspector.cpp:
  • WebProcess/WebPage/WebInspector.h:

Removed didLoadInspectorPage().

Location:
trunk/Source/WebKit2
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r146513 r146518  
     12013-03-21  Timothy Hatcher  <timothy@apple.com>
     2
     3        Support connecting the Web Inspector without showing it.
     4
     5        This allows you to get the debugger attached in the background. When a breakpoint is hit
     6        the Inspector will open. This change also reduces some WebProcess messaging by removing
     7        the DidLoadInspectorPage message and stops sending the SetAttachedWindow message on close.
     8
     9        https://bugs.webkit.org/show_bug.cgi?id=112445
     10
     11        Reviewed by Sam Weinig.
     12
     13        * UIProcess/API/C/WKInspector.cpp:
     14        (WKInspectorIsConnected): Added.
     15        (WKInspectorConnect): Added.
     16        (WKInspectorHide): Added.
     17
     18        * UIProcess/API/C/WKInspector.h:
     19        Added new APIs.
     20
     21        * UIProcess/WebInspectorProxy.cpp:
     22        (WebKit::WebInspectorProxy::WebInspectorProxy):
     23        Initialize new state booleans.
     24
     25        (WebKit::WebInspectorProxy::invalidate):
     26        Don't set state booleans that didClose already resets.
     27
     28        (WebKit::WebInspectorProxy::connect): Added.
     29        (WebKit::WebInspectorProxy::show):
     30        Open if we are already connected. Call connect().
     31
     32        (WebKit::WebInspectorProxy::hide): Added.
     33
     34        (WebKit::WebInspectorProxy::close):
     35        Call didClose we can detach or close the window immediately instead of waiting for a
     36        message from the WebProcess.
     37
     38        (WebKit::WebInspectorProxy::attach):
     39        (WebKit::WebInspectorProxy::detach):
     40        Check for !m_page to match other functions.
     41
     42        (WebKit::WebInspectorProxy::createInspectorPage):
     43        (WebKit::WebInspectorProxy::didLoadInspectorPage):
     44        Removed. Moved logic to open().
     45
     46        (WebKit::WebInspectorProxy::open): Added.
     47
     48        (WebKit::WebInspectorProxy::didClose):
     49        Clear new state booleans. Don't perform work again if already closed. Use platformDetach()
     50        instead of detach() to avoid sending the SetAttachedWindow message.
     51
     52        (WebKit::WebInspectorProxy::bringToFront):
     53        Call open() if we are not visible yet, otherwise platformBringToFront.
     54
     55        * UIProcess/WebInspectorProxy.h:
     56        (WebKit::WebInspectorProxy::isConnected): Added.
     57
     58        * UIProcess/WebInspectorProxy.messages.in: Removed DidLoadInspectorPage.
     59
     60        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
     61        (WebKit::WebInspectorProxy::platformHide): Added stub.
     62
     63        * UIProcess/mac/WebInspectorProxyMac.mm:
     64        (WebKit::WebInspectorProxy::platformHide): Added.
     65
     66        * UIProcess/qt/WebInspectorProxyQt.cpp:
     67        (WebKit::WebInspectorProxy::platformHide): Added stub.
     68
     69        * WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp:
     70        * WebProcess/WebCoreSupport/WebInspectorFrontendClient.h:
     71        Removed frontendLoaded().
     72
     73        * WebProcess/WebPage/WebInspector.cpp:
     74        * WebProcess/WebPage/WebInspector.h:
     75        Removed didLoadInspectorPage().
     76
    1772013-03-21  Alexey Proskuryakov  <ap@apple.com>
    278
  • trunk/Source/WebKit2/UIProcess/API/C/WKInspector.cpp

    r137688 r146518  
    5252}
    5353
     54bool WKInspectorIsConnected(WKInspectorRef inspectorRef)
     55{
     56#if ENABLE(INSPECTOR)
     57    return toImpl(inspectorRef)->isConnected();
     58#else
     59    UNUSED_PARAM(inspectorRef);
     60    return false;
     61#endif
     62}
     63
    5464bool WKInspectorIsVisible(WKInspectorRef inspectorRef)
    5565{
     
    7282}
    7383
     84void WKInspectorConnect(WKInspectorRef inspectorRef)
     85{
     86#if ENABLE(INSPECTOR)
     87    toImpl(inspectorRef)->connect();
     88#else
     89    UNUSED_PARAM(inspectorRef);
     90#endif
     91}
     92
    7493void WKInspectorShow(WKInspectorRef inspectorRef)
    7594{
     
    81100}
    82101
     102void WKInspectorHide(WKInspectorRef inspectorRef)
     103{
     104#if ENABLE(INSPECTOR)
     105    toImpl(inspectorRef)->hide();
     106#else
     107    UNUSED_PARAM(inspectorRef);
     108#endif
     109}
     110
    83111void WKInspectorClose(WKInspectorRef inspectorRef)
    84112{
  • trunk/Source/WebKit2/UIProcess/API/C/WKInspector.h

    r132875 r146518  
    4141WK_EXPORT WKPageRef WKInspectorGetPage(WKInspectorRef inspector);
    4242
     43WK_EXPORT bool WKInspectorIsConnected(WKInspectorRef inspector);
    4344WK_EXPORT bool WKInspectorIsVisible(WKInspectorRef inspector);
    4445WK_EXPORT bool WKInspectorIsFront(WKInspectorRef inspector);
     46
     47WK_EXPORT void WKInspectorConnect(WKInspectorRef inspector);
     48
    4549WK_EXPORT void WKInspectorShow(WKInspectorRef inspector);
     50WK_EXPORT void WKInspectorHide(WKInspectorRef inspector);
    4651WK_EXPORT void WKInspectorClose(WKInspectorRef inspector);
    4752
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.cpp

    r145963 r146518  
    8989    , m_isProfilingJavaScript(false)
    9090    , m_isProfilingPage(false)
     91    , m_showMessageSent(false)
     92    , m_createdInspectorPage(false)
     93    , m_ignoreFirstBringToFront(false)
    9194#if PLATFORM(GTK) || PLATFORM(EFL)
    9295    , m_inspectorView(0)
     
    114117
    115118    m_page->close();
     119
    116120    didClose();
    117121
    118122    m_page = 0;
    119 
    120     m_isVisible = false;
    121     m_isDebuggingJavaScript = false;
    122     m_isProfilingJavaScript = false;
    123     m_isProfilingPage = false;
    124123}
    125124
     
    133132}
    134133
     134void WebInspectorProxy::connect()
     135{
     136    if (!m_page)
     137        return;
     138
     139    if (m_showMessageSent)
     140        return;
     141
     142    m_showMessageSent = true;
     143    m_ignoreFirstBringToFront = true;
     144
     145    m_page->process()->send(Messages::WebInspector::Show(), m_page->pageID());
     146}
     147
    135148void WebInspectorProxy::show()
    136149{
     
    138151        return;
    139152
    140     m_page->process()->send(Messages::WebInspector::Show(), m_page->pageID());
     153    if (isConnected()) {
     154        open();
     155        return;
     156    }
     157
     158    connect();
     159
     160    // Don't ignore the first bringToFront so it opens the Inspector.
     161    m_ignoreFirstBringToFront = false;
     162}
     163
     164void WebInspectorProxy::hide()
     165{
     166    if (!m_page)
     167        return;
     168
     169    m_isVisible = false;
     170
     171    platformHide();
    141172}
    142173
     
    147178
    148179    m_page->process()->send(Messages::WebInspector::Close(), m_page->pageID());
     180
     181    didClose();
    149182}
    150183
     
    169202    if (!m_page)
    170203        return;
    171    
     204
    172205    m_page->process()->send(Messages::WebInspector::ShowMainResourceForFrame(frame->frameID()), m_page->pageID());
    173206}
     
    175208void WebInspectorProxy::attach()
    176209{
    177     if (!canAttach())
     210    if (!m_page || !canAttach())
    178211        return;
    179212
     
    190223void WebInspectorProxy::detach()
    191224{
     225    if (!m_page)
     226        return;
     227
    192228    m_isAttached = false;
    193    
     229
    194230    if (m_isVisible)
    195231        inspectorPageGroup()->preferences()->setInspectorStartsAttached(false);
     
    342378
    343379    inspectorPage->loadURL(url);
    344 }
    345 
    346 void WebInspectorProxy::didLoadInspectorPage()
    347 {
     380
     381    m_createdInspectorPage = true;
     382}
     383
     384void WebInspectorProxy::open()
     385{
     386    ASSERT(m_createdInspectorPage);
     387
    348388    m_isVisible = true;
    349389
    350     // platformOpen is responsible for rendering attached mode depending on m_isAttached.
    351390    platformOpen();
    352391}
     
    354393void WebInspectorProxy::didClose()
    355394{
     395    if (!m_createdInspectorPage)
     396        return;
     397
    356398    m_isVisible = false;
    357399    m_isDebuggingJavaScript = false;
    358400    m_isProfilingJavaScript = false;
    359401    m_isProfilingPage = false;
    360 
    361     if (m_isAttached) {
    362         // Detach here so we only need to have one code path that is responsible for cleaning up the inspector
    363         // state.
    364         detach();
     402    m_createdInspectorPage = false;
     403    m_showMessageSent = false;
     404    m_ignoreFirstBringToFront = false;
     405
     406    if (m_isAttached)
     407        platformDetach();
     408    m_isAttached = false;
     409
     410    platformDidClose();
     411}
     412
     413void WebInspectorProxy::bringToFront()
     414{
     415    // WebCore::InspectorFrontendClientLocal tells us to do this on load. We want to
     416    // ignore it once if we only wanted to connect. This allows the Inspector to later
     417    // request to be brought to the front when a breakpoint is hit or some other action.
     418    if (m_ignoreFirstBringToFront) {
     419        m_ignoreFirstBringToFront = false;
     420        return;
    365421    }
    366422
    367     platformDidClose();
    368 }
    369 
    370 void WebInspectorProxy::bringToFront()
    371 {
    372     platformBringToFront();
     423    if (m_isVisible)
     424        platformBringToFront();
     425    else
     426        open();
    373427}
    374428
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.h

    r145961 r146518  
    7979    WebPageProxy* page() const { return m_page; }
    8080
     81    bool isConnected() const { return m_createdInspectorPage; }
    8182    bool isVisible() const { return m_isVisible; }
    8283    bool isFront();
    8384
     85    void connect();
     86
    8487    void show();
     88    void hide();
    8589    void close();
    8690   
     
    145149    void platformDidClose();
    146150    void platformBringToFront();
     151    void platformHide();
    147152    bool platformIsFront();
    148153    void platformAttachAvailabilityChanged(bool);
     
    155160    // Called by WebInspectorProxy messages
    156161    void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&);
    157     void didLoadInspectorPage();
    158162    void didClose();
    159163    void bringToFront();
     
    167171    bool canAttach();
    168172    bool shouldOpenAttached();
     173
     174    void open();
    169175
    170176    static WebPageGroup* inspectorPageGroup();
     
    190196    bool m_isProfilingJavaScript;
    191197    bool m_isProfilingPage;
     198    bool m_showMessageSent;
     199    bool m_createdInspectorPage;
     200    bool m_ignoreFirstBringToFront;
    192201
    193202#if PLATFORM(MAC)
  • trunk/Source/WebKit2/UIProcess/WebInspectorProxy.messages.in

    r142160 r146518  
    2525messages -> WebInspectorProxy {
    2626    CreateInspectorPage() -> (uint64_t inspectorPageID, WebKit::WebPageCreationParameters inspectorPageParameters)
    27     DidLoadInspectorPage()
    2827    DidClose()
    2928    BringToFront()
  • trunk/Source/WebKit2/UIProcess/efl/WebInspectorProxyEfl.cpp

    r146265 r146518  
    143143}
    144144
     145void WebInspectorProxy::platformHide()
     146{
     147    notImplemented();
     148}
     149
    145150void WebInspectorProxy::platformBringToFront()
    146151{
  • trunk/Source/WebKit2/UIProcess/gtk/WebInspectorProxyGtk.cpp

    r145951 r146518  
    126126}
    127127
     128void WebInspectorProxy::platformHide()
     129{
     130    notImplemented();
     131}
     132
    128133void WebInspectorProxy::platformBringToFront()
    129134{
  • trunk/Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm

    r145961 r146518  
    420420}
    421421
     422void WebInspectorProxy::platformHide()
     423{
     424    if (m_isAttached) {
     425        platformDetach();
     426        return;
     427    }
     428
     429    if (m_inspectorWindow) {
     430        [m_inspectorWindow.get() setDelegate:nil];
     431        [m_inspectorWindow.get() orderOut:nil];
     432        m_inspectorWindow = 0;
     433    }
     434}
     435
    422436void WebInspectorProxy::platformBringToFront()
    423437{
  • trunk/Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp

    r134346 r146518  
    4646
    4747void WebInspectorProxy::platformDidClose()
     48{
     49    notImplemented();
     50}
     51
     52void WebInspectorProxy::platformHide()
    4853{
    4954    notImplemented();
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.cpp

    r145717 r146518  
    4646}
    4747
    48 void WebInspectorFrontendClient::frontendLoaded()
    49 {
    50     InspectorFrontendClientLocal::frontendLoaded();
    51 
    52     m_page->inspector()->didLoadInspectorPage();
    53 }
    54 
    5548String WebInspectorFrontendClient::localizedStringsURL()
    5649{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorFrontendClient.h

    r145717 r146518  
    4040
    4141private:
    42     virtual void frontendLoaded() OVERRIDE;
    43 
    4442    virtual String localizedStringsURL() OVERRIDE;
    4543
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp

    r140903 r146518  
    101101
    102102// Called from WebInspectorFrontendClient
    103 void WebInspector::didLoadInspectorPage()
    104 {
    105     WebProcess::shared().connection()->send(Messages::WebInspectorProxy::DidLoadInspectorPage(), m_page->pageID());
    106 }
    107 
    108103void WebInspector::didClose()
    109104{
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h

    r141322 r146518  
    9393
    9494    // Called from WebInspectorFrontendClient
    95     void didLoadInspectorPage();
    9695    void didClose();
    9796    void bringToFront();
Note: See TracChangeset for help on using the changeset viewer.