Changeset 109939 in webkit


Ignore:
Timestamp:
Mar 6, 2012 11:33:07 AM (12 years ago)
Author:
Joseph Pecoraro
Message:

<http://webkit.org/b/78575> Web Inspector: Disable dock button when not allowed to dock

There are times when an undocked inspector frontend is not allowed to
attach to the main window. We can disable the dock button in those cases.

Reviewed by Pavel Feldman.

No new tests. This functionality is port specific right now.

  • page/FrameView.cpp:

(WebCore::FrameView::performPostLayoutTasks):
When the main frame is resized we let the inspector client know,
so that it can react to it as needed.

  • WebCore.exp.in:
  • inspector/InspectorClient.h:

(WebCore::InspectorClient::didResizeMainFrame):

  • inspector/InspectorController.cpp:
  • inspector/InspectorController.h:

(WebCore::InspectorController::inspectorClient):
Call up to the port though to the InspectorClient.

  • inspector/InspectorFrontendClientLocal.cpp:

(WebCore::InspectorFrontendClientLocal::frontendLoaded):
(WebCore::InspectorFrontendClientLocal::setDockingUnavailable):

  • inspector/InspectorFrontendClientLocal.h:

On ports where the inspector frontend client is local, provide a
setDockingUnavailable InspectorFrontendAPI to update the docking state.
Automatically update availability when the frontend completes loading.

  • inspector/front-end/InspectorFrontendAPI.js:

(InspectorFrontendAPI.setDockingUnavailable):

  • inspector/front-end/inspector.js:

(WebInspector._createGlobalStatusBarItems):
(WebInspector.setAttachedWindow):
(WebInspector.setDockingUnavailable):
(WebInspector.updateDockToggleButton):
Update the dock button's enabled/disabled state when its created,
when the attached state changes, when get a frontend API notification
that we cannot attach.

  • inspector/front-end/InspectorFrontendHostStub.js:

Remove unused canAttachWindow method.

Source/WebKit/mac: Web Inspector: Hide dock button when not allowed to dock
https://bugs.webkit.org/show_bug.cgi?id=78575

Reviewed by Pavel Feldman.

  • WebCoreSupport/WebInspectorClient.h:

(WebCore):
(WebInspectorClient):

  • WebCoreSupport/WebInspectorClient.mm:

(WebInspectorClient::didResizeMainFrame):

Source/WebKit2: Web Inspector: Hide dock button when not allowed to dock
https://bugs.webkit.org/show_bug.cgi?id=78575

Reviewed by Pavel Feldman.

  • WebProcess/WebCoreSupport/WebInspectorClient.cpp:

(WebKit::WebInspectorClient::didResizeMainFrame):

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

(WebKit::WebInspector::updateDockingAvailability):

  • WebProcess/WebPage/WebInspector.h:
Location:
trunk/Source
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r109938 r109939  
     12012-03-05  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        <http://webkit.org/b/78575> Web Inspector: Disable dock button when not allowed to dock
     4
     5        There are times when an undocked inspector frontend is not allowed to
     6        attach to the main window. We can disable the dock button in those cases.
     7
     8        Reviewed by Pavel Feldman.
     9
     10        No new tests. This functionality is port specific right now.
     11
     12        * page/FrameView.cpp:
     13        (WebCore::FrameView::performPostLayoutTasks):
     14        When the main frame is resized we let the inspector client know,
     15        so that it can react to it as needed.
     16
     17        * WebCore.exp.in:
     18        * inspector/InspectorClient.h:
     19        (WebCore::InspectorClient::didResizeMainFrame):
     20        * inspector/InspectorController.cpp:
     21        * inspector/InspectorController.h:
     22        (WebCore::InspectorController::inspectorClient):
     23        Call up to the port though to the InspectorClient.
     24
     25        * inspector/InspectorFrontendClientLocal.cpp:
     26        (WebCore::InspectorFrontendClientLocal::frontendLoaded):
     27        (WebCore::InspectorFrontendClientLocal::setDockingUnavailable):
     28        * inspector/InspectorFrontendClientLocal.h:
     29        On ports where the inspector frontend client is local, provide a
     30        setDockingUnavailable InspectorFrontendAPI to update the docking state.
     31        Automatically update availability when the frontend completes loading.
     32
     33        * inspector/front-end/InspectorFrontendAPI.js:
     34        (InspectorFrontendAPI.setDockingUnavailable):
     35        * inspector/front-end/inspector.js:
     36        (WebInspector._createGlobalStatusBarItems):
     37        (WebInspector.setAttachedWindow):
     38        (WebInspector.setDockingUnavailable):
     39        (WebInspector.updateDockToggleButton):
     40        Update the dock button's enabled/disabled state when its created,
     41        when the attached state changes, when get a frontend API notification
     42        that we cannot attach.
     43
     44        * inspector/front-end/InspectorFrontendHostStub.js:
     45        Remove unused canAttachWindow method.
     46
    1472012-03-06  Hans Wennborg  <hans@chromium.org>
    248
  • trunk/Source/WebCore/WebCore.exp.in

    r109860 r109939  
    17441744__ZN7WebCore28InspectorFrontendClientLocal20sendMessageToBackendERKN3WTF6StringE
    17451745__ZN7WebCore28InspectorFrontendClientLocal21isProfilingJavaScriptEv
     1746__ZN7WebCore28InspectorFrontendClientLocal21setDockingUnavailableEb
    17461747__ZN7WebCore28InspectorFrontendClientLocal23stopProfilingJavaScriptEv
    17471748__ZN7WebCore28InspectorFrontendClientLocal24showMainResourceForFrameEPNS_5FrameE
  • trunk/Source/WebCore/inspector/InspectorClient.h

    r109860 r109939  
    3535
    3636class InspectorController;
    37 class Node;
     37class Frame;
    3838class Page;
    3939
     
    4747    virtual void closeInspectorFrontend() = 0;
    4848    virtual void bringFrontendToFront() = 0;
     49    virtual void didResizeMainFrame(Frame*) { }
    4950
    5051    virtual void highlight() = 0;
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r109922 r109939  
    362362    }
    363363}
    364 
    365364#endif
    366365
  • trunk/Source/WebCore/inspector/InspectorController.h

    r109860 r109939  
    109109    void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
    110110
     111    InspectorClient* inspectorClient() const { return m_inspectorClient; }
    111112    InspectorPageAgent* pageAgent() const { return m_pageAgent; }
    112113
  • trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp

    r109860 r109939  
    139139{
    140140    bringToFront();
     141    setDockingUnavailable(!canAttachWindow());
    141142    m_frontendLoaded = true;
    142143    for (Vector<String>::iterator it = m_evaluateOnLoad.begin(); it != m_evaluateOnLoad.end(); ++it)
     
    167168    unsigned maximumAttachedHeight = inspectedPageHeight * maximumAttachedHeightRatio;
    168169    return minimumAttachedHeight <= maximumAttachedHeight && !isInspectorPage;
     170}
     171
     172void InspectorFrontendClientLocal::setDockingUnavailable(bool unavailable)
     173{
     174    evaluateOnLoad(String::format("[\"setDockingUnavailable\", %s]", unavailable ? "true" : "false"));
    169175}
    170176
  • trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h

    r109860 r109939  
    7878
    7979    bool canAttachWindow();
     80    void setDockingUnavailable(bool);
    8081
    8182    static unsigned constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight);
  • trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js

    r109860 r109939  
    9696    },
    9797
     98    setDockingUnavailable: function(unavailable)
     99    {
     100        WebInspector.setDockingUnavailable(unavailable);
     101    },
     102
    98103    dispatch: function(signature)
    99104    {
  • trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js

    r108794 r109939  
    138138    },
    139139
    140     canAttachWindow: function()
    141     {
    142         return false;
    143     },
    144 
    145140    sendMessageToBackend: function(message)
    146141    {
  • trunk/Source/WebCore/inspector/front-end/inspector.js

    r109923 r109939  
    7474        this._dockToggleButton.addEventListener("click", this._toggleAttach.bind(this), false);
    7575        this._dockToggleButton.toggled = !this.attached;
     76        WebInspector.updateDockToggleButton();
    7677
    7778        this._settingsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Settings"), "settings-status-bar-item");
     
    565566{
    566567    this.attached = attached;
     568    WebInspector.updateDockToggleButton();
     569}
     570
     571WebInspector.setDockingUnavailable = function(unavailable)
     572{
     573    this._isDockingUnavailable = unavailable;
     574    WebInspector.updateDockToggleButton();
     575}
     576
     577WebInspector.updateDockToggleButton = function()
     578{
     579    if (!this._dockToggleButton)
     580        return;
     581    this._dockToggleButton.disabled = this.attached ? false : this._isDockingUnavailable;
    567582}
    568583
  • trunk/Source/WebCore/page/FrameView.cpp

    r109860 r109939  
    5050#include "HTMLNames.h"
    5151#include "HTMLPlugInImageElement.h"
     52#include "InspectorClient.h"
     53#include "InspectorController.h"
    5254#include "InspectorInstrumentation.h"
    5355#include "OverflowEvent.h"
     
    23322334        m_lastLayoutSize = currentSize;
    23332335        m_lastZoomFactor = currentZoomFactor;
    2334         if (resized)
     2336        if (resized) {
    23352337            m_frame->eventHandler()->sendResizeEvent();
     2338
     2339            if (InspectorInstrumentation::hasFrontends()) {
     2340                if (Page* page = m_frame->page()) {
     2341                    if (page->mainFrame() == m_frame) {
     2342                        if (InspectorClient* inspectorClient = page->inspectorController()->inspectorClient())
     2343                            inspectorClient->didResizeMainFrame(m_frame.get());
     2344                    }
     2345                }
     2346            }
     2347        }
    23362348    }
    23372349}
  • trunk/Source/WebKit/mac/ChangeLog

    r109866 r109939  
     12012-03-05  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Hide dock button when not allowed to dock
     4        https://bugs.webkit.org/show_bug.cgi?id=78575
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * WebCoreSupport/WebInspectorClient.h:
     9        (WebCore):
     10        (WebInspectorClient):
     11        * WebCoreSupport/WebInspectorClient.mm:
     12        (WebInspectorClient::didResizeMainFrame):
     13
    1142012-03-05  Gavin Barraclough  <barraclough@apple.com>
    215
  • trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h

    r109860 r109939  
    4848namespace WebCore {
    4949
     50class Frame;
    5051class Page;
    5152
     
    6364    virtual void closeInspectorFrontend() OVERRIDE;
    6465    virtual void bringFrontendToFront() OVERRIDE;
     66    virtual void didResizeMainFrame(WebCore::Frame*) OVERRIDE;
    6567
    6668    virtual void highlight() OVERRIDE;
  • trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm

    r109860 r109939  
    112112}
    113113
     114void WebInspectorClient::didResizeMainFrame(Frame*)
     115{
     116    m_frontendClient->setDockingUnavailable(!m_frontendClient->canAttachWindow());
     117}
     118
    114119void WebInspectorClient::highlight()
    115120{
  • trunk/Source/WebKit2/ChangeLog

    r109930 r109939  
     12012-03-05  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        Web Inspector: Hide dock button when not allowed to dock
     4        https://bugs.webkit.org/show_bug.cgi?id=78575
     5
     6        Reviewed by Pavel Feldman.
     7
     8        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
     9        (WebKit::WebInspectorClient::didResizeMainFrame):
     10        * WebProcess/WebCoreSupport/WebInspectorClient.h:
     11        * WebProcess/WebPage/WebInspector.cpp:
     12        (WebKit::WebInspector::updateDockingAvailability):
     13        * WebProcess/WebPage/WebInspector.h:
     14
    1152012-03-06  Allan Sandfeld Jensen  <allan.jensen@nokia.com>
    216
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp

    r109860 r109939  
    6161}
    6262
     63void WebInspectorClient::didResizeMainFrame(Frame*)
     64{
     65    m_page->inspector()->updateDockingAvailability();
     66}
     67
    6368void WebInspectorClient::highlight()
    6469{
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h

    r109860 r109939  
    5656    virtual void closeInspectorFrontend() OVERRIDE;
    5757    virtual void bringFrontendToFront() OVERRIDE;
     58    virtual void didResizeMainFrame(WebCore::Frame*) OVERRIDE;
    5859
    5960    virtual void highlight() OVERRIDE;
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp

    r109860 r109939  
    222222}
    223223
     224void WebInspector::updateDockingAvailability()
     225{
     226    if (m_frontendClient)
     227        m_frontendClient->setDockingUnavailable(!m_frontendClient->canAttachWindow());
     228}
     229
    224230} // namespace WebKit
    225231
  • trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h

    r109860 r109939  
    103103    void stopJavaScriptProfiling();
    104104
     105    void updateDockingAvailability();
     106
    105107    WebPage* m_page;
    106108    WebPage* m_inspectorPage;
Note: See TracChangeset for help on using the changeset viewer.