Title: [109858] trunk/Source
Revision
109858
Author
[email protected]
Date
2012-03-05 22:03:12 -0800 (Mon, 05 Mar 2012)

Log Message

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

Source/WebCore:

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

Reviewed by Timothy Hatcher.

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 frontend client
update its docked availability.

* WebCore.exp.in:
* inspector/InspectorInstrumentation.h:
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::didResizeMainFrameImpl):
(WebCore::InspectorInstrumentation::didResizeMainFrame):
* inspector/InspectorClient.h:
(WebCore::InspectorClient::updateDockingAvailability):
* inspector/InspectorController.h:
* inspector/InspectorController.cpp:
(WebCore::InspectorController::resume):
(WebCore::InspectorController::updateDockingAvailability):
When the main frame is resized call up to the InspectorClient to let
it update docking availability of the inspector frontend.

* inspector/InspectorFrontendClient.h:
* inspector/InspectorFrontendClientLocal.h:
* inspector/InspectorFrontendClientLocal.cpp:
(WebCore::InspectorFrontendClientLocal::frontendLoaded):
(WebCore::InspectorFrontendClientLocal::setDockingUnavailable):
On ports where the inspector frontend client is local, provide a
setDockingUnavailable InspectorFrontendAPI to update the docking state.
Automatically update availablity when the frontend completes loading.

* inspector/front-end/InspectorFrontendAPI.js:
(InspectorFrontendAPI.setDockingUnavailable):
* inspector/front-end/inspector.js:
(WebInspector._createGlobalStatusBarItems):
(WebInspector.setAttachedWindow):
(WebInspector.setDockingUnavailable):
(WebInspector.updateDockToggleButtonVisibility):
Update the dock button's visibility when its created, when the attached
state changes, when get a frontend API notification that we cannot attach.

Source/WebKit/mac:

* WebCoreSupport/WebInspectorClient.h:
(WebInspectorClient):
* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorClient::updateDockingAvailability):

Source/WebKit2:

* WebProcess/WebCoreSupport/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::updateDockingAvailability):
* WebProcess/WebCoreSupport/WebInspectorClient.h:
* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::updateDockingAvailability):
* WebProcess/WebPage/WebInspector.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109857 => 109858)


--- trunk/Source/WebCore/ChangeLog	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/ChangeLog	2012-03-06 06:03:12 UTC (rev 109858)
@@ -1,3 +1,52 @@
+2012-03-05  Joseph Pecoraro  <[email protected]>
+
+        <http://webkit.org/b/78575> Web Inspector: Hide 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 remove the dock button in those cases.
+
+        Reviewed by Timothy Hatcher.
+
+        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 frontend client
+        update its docked availablility.
+
+        * WebCore.exp.in:
+        * inspector/InspectorInstrumentation.h:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::didResizeMainFrameImpl):
+        (WebCore::InspectorInstrumentation::didResizeMainFrame):
+        * inspector/InspectorClient.h:
+        (WebCore::InspectorClient::updateDockingAvailability):
+        * inspector/InspectorController.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::resume):
+        (WebCore::InspectorController::updateDockingAvailability):
+        When the main frame is resized call up to the InspectorClient to let
+        it update docking availability of the inspector frontend.
+
+        * inspector/InspectorFrontendClient.h:
+        * inspector/InspectorFrontendClientLocal.h:
+        * inspector/InspectorFrontendClientLocal.cpp:
+        (WebCore::InspectorFrontendClientLocal::frontendLoaded):
+        (WebCore::InspectorFrontendClientLocal::setDockingUnavailable):
+        On ports where the inspector frontend client is local, provide a 
+        setDockingUnavailable InspectorFrontendAPI to update the docking state.
+        Automatically update availablity when the frontend completes loading.
+
+        * inspector/front-end/InspectorFrontendAPI.js:
+        (InspectorFrontendAPI.setDockingUnavailable):
+        * inspector/front-end/inspector.js:
+        (WebInspector._createGlobalStatusBarItems):
+        (WebInspector.setAttachedWindow):
+        (WebInspector.setDockingUnavailable):
+        (WebInspector.updateDockToggleButtonVisibility):
+        Update the dock button's visibility when its created, when the attached
+        state changes, when get a frontend API notification that we cannot attach.
+
 2012-03-05  Adrienne Walker  <[email protected]>
 
         Compositing overlap testing can throw layers into compositing when they should not be.

Modified: trunk/Source/WebCore/WebCore.exp.in (109857 => 109858)


--- trunk/Source/WebCore/WebCore.exp.in	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-03-06 06:03:12 UTC (rev 109858)
@@ -1743,6 +1743,7 @@
 __ZN7WebCore28InspectorFrontendClientLocal19windowObjectClearedEv
 __ZN7WebCore28InspectorFrontendClientLocal20sendMessageToBackendERKN3WTF6StringE
 __ZN7WebCore28InspectorFrontendClientLocal21isProfilingJavaScriptEv
+__ZN7WebCore28InspectorFrontendClientLocal21setDockingUnavailableEb
 __ZN7WebCore28InspectorFrontendClientLocal23stopProfilingJavaScriptEv
 __ZN7WebCore28InspectorFrontendClientLocal24showMainResourceForFrameEPNS_5FrameE
 __ZN7WebCore28InspectorFrontendClientLocal24startProfilingJavaScriptEv

Modified: trunk/Source/WebCore/inspector/InspectorClient.h (109857 => 109858)


--- trunk/Source/WebCore/inspector/InspectorClient.h	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/InspectorClient.h	2012-03-06 06:03:12 UTC (rev 109858)
@@ -46,6 +46,7 @@
     virtual void openInspectorFrontend(InspectorController*) = 0;
     virtual void closeInspectorFrontend() = 0;
     virtual void bringFrontendToFront() = 0;
+    virtual void updateDockingAvailability() { }
 
     virtual void highlight() = 0;
     virtual void hideHighlight() = 0;

Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (109857 => 109858)


--- trunk/Source/WebCore/inspector/InspectorController.cpp	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp	2012-03-06 06:03:12 UTC (rev 109858)
@@ -361,9 +361,13 @@
         m_debuggerAgent->resume(&error);
     }
 }
-
 #endif
 
+void InspectorController::updateDockingAvailability()
+{
+    m_inspectorClient->updateDockingAvailability();
+}
+
 void InspectorController::setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize)
 {
     m_resourceAgent->setResourcesDataSizeLimitsFromInternals(maximumResourcesContentSize, maximumSingleResourceContentSize);

Modified: trunk/Source/WebCore/inspector/InspectorController.h (109857 => 109858)


--- trunk/Source/WebCore/inspector/InspectorController.h	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/InspectorController.h	2012-03-06 06:03:12 UTC (rev 109858)
@@ -106,6 +106,8 @@
     void resume();
 #endif
 
+    void updateDockingAvailability();
+
     void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
 
     InspectorPageAgent* pageAgent() const { return m_pageAgent; }

Modified: trunk/Source/WebCore/inspector/InspectorFrontendClient.h (109857 => 109858)


--- trunk/Source/WebCore/inspector/InspectorFrontendClient.h	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClient.h	2012-03-06 06:03:12 UTC (rev 109858)
@@ -65,6 +65,9 @@
     virtual void inspectedURLChanged(const String&) = 0;
 
     virtual void sendMessageToBackend(const String&) = 0;
+
+    virtual bool canAttachWindow() { return true; }
+    virtual void setDockingUnavailable(bool) { }
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp (109857 => 109858)


--- trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp	2012-03-06 06:03:12 UTC (rev 109858)
@@ -138,6 +138,7 @@
 void InspectorFrontendClientLocal::frontendLoaded()
 {
     bringToFront();
+    setDockingUnavailable(!canAttachWindow());
     m_frontendLoaded = true;
     for (Vector<String>::iterator it = m_evaluateOnLoad.begin(); it != m_evaluateOnLoad.end(); ++it)
         evaluateOnLoad(*it);
@@ -168,6 +169,11 @@
     return minimumAttachedHeight <= maximumAttachedHeight && !isInspectorPage;
 }
 
+void InspectorFrontendClientLocal::setDockingUnavailable(bool unavailable)
+{
+    evaluateOnLoad(String::format("[\"setDockingUnavailable\", %s]", unavailable ? "true" : "false"));
+}
+
 void InspectorFrontendClientLocal::changeAttachedWindowHeight(unsigned height)
 {
     unsigned totalHeight = m_frontendPage->mainFrame()->view()->visibleHeight() + m_inspectorController->inspectedPage()->mainFrame()->view()->visibleHeight();

Modified: trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h (109857 => 109858)


--- trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h	2012-03-06 06:03:12 UTC (rev 109858)
@@ -76,7 +76,8 @@
 
     virtual void sendMessageToBackend(const String& message);
 
-    bool canAttachWindow();
+    virtual bool canAttachWindow();
+    virtual void setDockingUnavailable(bool);
 
     static unsigned constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight);
 

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (109857 => 109858)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2012-03-06 06:03:12 UTC (rev 109858)
@@ -268,6 +268,12 @@
         timelineAgent->didRemoveTimer(timerId);
 }
 
+void InspectorInstrumentation::didResizeMainFrameImpl(Frame* frame)
+{
+    if (Page* page = frame->page())
+        page->inspectorController()->updateDockingAvailability();
+}
+
 InspectorInstrumentationCookie InspectorInstrumentation::willCallFunctionImpl(InstrumentingAgents* instrumentingAgents, const String& scriptName, int scriptLine)
 {
     int timelineAgentId = 0;

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (109857 => 109858)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2012-03-06 06:03:12 UTC (rev 109858)
@@ -106,6 +106,8 @@
     static void didInstallTimer(ScriptExecutionContext*, int timerId, int timeout, bool singleShot);
     static void didRemoveTimer(ScriptExecutionContext*, int timerId);
 
+    static void didResizeMainFrame(Frame*);
+
     static InspectorInstrumentationCookie willCallFunction(ScriptExecutionContext*, const String& scriptName, int scriptLine);
     static void didCallFunction(const InspectorInstrumentationCookie&);
     static InspectorInstrumentationCookie willChangeXHRReadyState(ScriptExecutionContext*, XMLHttpRequest* request);
@@ -259,6 +261,8 @@
     static void didInstallTimerImpl(InstrumentingAgents*, int timerId, int timeout, bool singleShot);
     static void didRemoveTimerImpl(InstrumentingAgents*, int timerId);
 
+    static void didResizeMainFrameImpl(Frame*);
+
     static InspectorInstrumentationCookie willCallFunctionImpl(InstrumentingAgents*, const String& scriptName, int scriptLine);
     static void didCallFunctionImpl(const InspectorInstrumentationCookie&);
     static InspectorInstrumentationCookie willChangeXHRReadyStateImpl(InstrumentingAgents*, XMLHttpRequest*);
@@ -578,6 +582,14 @@
 #endif
 }
 
+inline void InspectorInstrumentation::didResizeMainFrame(Frame* frame)
+{
+#if ENABLE(INSPECTOR)
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    didResizeMainFrameImpl(frame);
+#endif
+}
+
 inline InspectorInstrumentationCookie InspectorInstrumentation::willCallFunction(ScriptExecutionContext* context, const String& scriptName, int scriptLine)
 {
 #if ENABLE(INSPECTOR)

Modified: trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js (109857 => 109858)


--- trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js	2012-03-06 06:03:12 UTC (rev 109858)
@@ -95,6 +95,11 @@
         WebInspector.inspectorView.setCurrentPanel(WebInspector.panels.resources);
     },
 
+    setDockingUnavailable: function(unavailable)
+    {
+        WebInspector.setDockingUnavailable(unavailable);
+    },
+
     dispatch: function(signature)
     {
         if (WebInspector.panels) {

Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (109857 => 109858)


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2012-03-06 06:03:12 UTC (rev 109858)
@@ -73,6 +73,7 @@
         this._dockToggleButton = new WebInspector.StatusBarButton(this._dockButtonTitle(), "dock-status-bar-item");
         this._dockToggleButton.addEventListener("click", this._toggleAttach.bind(this), false);
         this._dockToggleButton.toggled = !this.attached;
+        WebInspector.updateDockToggleButtonVisibility();
 
         this._settingsButton = new WebInspector.StatusBarButton(WebInspector.UIString("Settings"), "settings-status-bar-item");
         this._settingsButton.addEventListener("click", this._toggleSettings.bind(this), false);
@@ -564,8 +565,22 @@
 WebInspector.setAttachedWindow = function(attached)
 {
     this.attached = attached;
+    WebInspector.updateDockToggleButtonVisibility();
 }
 
+WebInspector.setDockingUnavailable = function(unavailable)
+{
+    this._isDockingUnavailable = unavailable;
+    WebInspector.updateDockToggleButtonVisibility();
+}
+
+WebInspector.updateDockToggleButtonVisibility = function()
+{
+    if (!this._dockToggleButton)
+        return;
+    this._dockToggleButton.visible = this.attached ? true : !this._isDockingUnavailable;
+}
+
 WebInspector.close = function(event)
 {
     if (this._isClosing)

Modified: trunk/Source/WebCore/page/FrameView.cpp (109857 => 109858)


--- trunk/Source/WebCore/page/FrameView.cpp	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebCore/page/FrameView.cpp	2012-03-06 06:03:12 UTC (rev 109858)
@@ -2331,8 +2331,13 @@
         bool resized = !m_firstLayout && (currentSize != m_lastLayoutSize || currentZoomFactor != m_lastZoomFactor);
         m_lastLayoutSize = currentSize;
         m_lastZoomFactor = currentZoomFactor;
-        if (resized)
+        if (resized) {
             m_frame->eventHandler()->sendResizeEvent();
+            if (Page* page = m_frame->page()) {
+                if (page->mainFrame() == m_frame)
+                    InspectorInstrumentation::didResizeMainFrame(m_frame.get());
+            }
+        }
     }
 }
 

Modified: trunk/Source/WebKit/mac/ChangeLog (109857 => 109858)


--- trunk/Source/WebKit/mac/ChangeLog	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-03-06 06:03:12 UTC (rev 109858)
@@ -1,3 +1,14 @@
+2012-03-05  Joseph Pecoraro  <[email protected]>
+
+        <http://webkit.org/b/78575> Web Inspector: Hide dock button when not allowed to dock
+
+        Reviewed by Timothy Hatcher.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        (WebInspectorClient):
+        * WebCoreSupport/WebInspectorClient.mm:
+        (WebInspectorClient::updateDockingAvailability):
+
 2012-03-02  Jon Lee  <[email protected]>
 
         Add support for notification replaceId in Mac WebKit and WK2

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h (109857 => 109858)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h	2012-03-06 06:03:12 UTC (rev 109858)
@@ -62,6 +62,7 @@
     virtual void openInspectorFrontend(WebCore::InspectorController*) OVERRIDE;
     virtual void closeInspectorFrontend() OVERRIDE;
     virtual void bringFrontendToFront() OVERRIDE;
+    virtual void updateDockingAvailability() OVERRIDE;
 
     virtual void highlight() OVERRIDE;
     virtual void hideHighlight() OVERRIDE;

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm (109857 => 109858)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm	2012-03-06 06:03:12 UTC (rev 109858)
@@ -111,6 +111,11 @@
     m_frontendClient->bringToFront();
 }
 
+void WebInspectorClient::updateDockingAvailability()
+{
+    m_frontendClient->setDockingUnavailable(!m_frontendClient->canAttachWindow());
+}
+
 void WebInspectorClient::highlight()
 {
     [m_highlighter.get() highlight];

Modified: trunk/Source/WebKit2/ChangeLog (109857 => 109858)


--- trunk/Source/WebKit2/ChangeLog	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebKit2/ChangeLog	2012-03-06 06:03:12 UTC (rev 109858)
@@ -1,3 +1,16 @@
+2012-03-05  Joseph Pecoraro  <[email protected]>
+
+        <http://webkit.org/b/78575> Web Inspector: Hide dock button when not allowed to dock
+
+        Reviewed by Timothy Hatcher.
+
+        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
+        (WebKit::WebInspectorClient::updateDockingAvailability):
+        * WebProcess/WebCoreSupport/WebInspectorClient.h:
+        * WebProcess/WebPage/WebInspector.cpp:
+        (WebKit::WebInspector::updateDockingAvailability):
+        * WebProcess/WebPage/WebInspector.h:
+
 2012-03-05  Anders Carlsson  <[email protected]>
 
         pinch-to-zoom and double-tap flicker when using the new scrolling model

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp (109857 => 109858)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp	2012-03-06 06:03:12 UTC (rev 109858)
@@ -60,6 +60,11 @@
     m_page->inspector()->bringToFront();
 }
 
+void WebInspectorClient::updateDockingAvailability()
+{
+    m_page->inspector()->updateDockingAvailability();
+}
+
 void WebInspectorClient::highlight()
 {
     if (!m_highlightOverlay) {

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h (109857 => 109858)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h	2012-03-06 06:03:12 UTC (rev 109858)
@@ -55,6 +55,7 @@
     virtual void openInspectorFrontend(WebCore::InspectorController*) OVERRIDE;
     virtual void closeInspectorFrontend() OVERRIDE;
     virtual void bringFrontendToFront() OVERRIDE;
+    virtual void updateDockingAvailability() OVERRIDE;
 
     virtual void highlight() OVERRIDE;
     virtual void hideHighlight() OVERRIDE;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp (109857 => 109858)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp	2012-03-06 06:03:12 UTC (rev 109858)
@@ -221,6 +221,12 @@
         m_frontendClient->setTimelineProfilingEnabled(false);
 }
 
+void WebInspector::updateDockingAvailability()
+{
+    if (m_frontendClient)
+        m_frontendClient->setDockingUnavailable(!m_frontendClient->canAttachWindow());
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(INSPECTOR)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h (109857 => 109858)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h	2012-03-06 05:26:21 UTC (rev 109857)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h	2012-03-06 06:03:12 UTC (rev 109858)
@@ -102,6 +102,8 @@
     void startJavaScriptProfiling();
     void stopJavaScriptProfiling();
 
+    void updateDockingAvailability();
+
     WebPage* m_page;
     WebPage* m_inspectorPage;
     WebInspectorFrontendClient* m_frontendClient;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to