Title: [109939] trunk/Source
Revision
109939
Author
[email protected]
Date
2012-03-06 11:33:07 -0800 (Tue, 06 Mar 2012)

Log 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:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (109938 => 109939)


--- trunk/Source/WebCore/ChangeLog	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/ChangeLog	2012-03-06 19:33:07 UTC (rev 109939)
@@ -1,3 +1,49 @@
+2012-03-05  Joseph Pecoraro  <[email protected]>
+
+        <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.
+
 2012-03-06  Hans Wennborg  <[email protected]>
 
         Speech _javascript_ API: add SpeechRecognitionError

Modified: trunk/Source/WebCore/WebCore.exp.in (109938 => 109939)


--- trunk/Source/WebCore/WebCore.exp.in	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/WebCore.exp.in	2012-03-06 19:33:07 UTC (rev 109939)
@@ -1743,6 +1743,7 @@
 __ZN7WebCore28InspectorFrontendClientLocal19windowObjectClearedEv
 __ZN7WebCore28InspectorFrontendClientLocal20sendMessageToBackendERKN3WTF6StringE
 __ZN7WebCore28InspectorFrontendClientLocal21isProfilingJavaScriptEv
+__ZN7WebCore28InspectorFrontendClientLocal21setDockingUnavailableEb
 __ZN7WebCore28InspectorFrontendClientLocal23stopProfilingJavaScriptEv
 __ZN7WebCore28InspectorFrontendClientLocal24showMainResourceForFrameEPNS_5FrameE
 __ZN7WebCore28InspectorFrontendClientLocal24startProfilingJavaScriptEv

Modified: trunk/Source/WebCore/inspector/InspectorClient.h (109938 => 109939)


--- trunk/Source/WebCore/inspector/InspectorClient.h	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/inspector/InspectorClient.h	2012-03-06 19:33:07 UTC (rev 109939)
@@ -34,7 +34,7 @@
 namespace WebCore {
 
 class InspectorController;
-class Node;
+class Frame;
 class Page;
 
 class InspectorClient : public InspectorFrontendChannel, public InspectorStateClient {
@@ -46,6 +46,7 @@
     virtual void openInspectorFrontend(InspectorController*) = 0;
     virtual void closeInspectorFrontend() = 0;
     virtual void bringFrontendToFront() = 0;
+    virtual void didResizeMainFrame(Frame*) { }
 
     virtual void highlight() = 0;
     virtual void hideHighlight() = 0;

Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (109938 => 109939)


--- trunk/Source/WebCore/inspector/InspectorController.cpp	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp	2012-03-06 19:33:07 UTC (rev 109939)
@@ -361,7 +361,6 @@
         m_debuggerAgent->resume(&error);
     }
 }
-
 #endif
 
 void InspectorController::setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize)

Modified: trunk/Source/WebCore/inspector/InspectorController.h (109938 => 109939)


--- trunk/Source/WebCore/inspector/InspectorController.h	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/inspector/InspectorController.h	2012-03-06 19:33:07 UTC (rev 109939)
@@ -108,6 +108,7 @@
 
     void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
 
+    InspectorClient* inspectorClient() const { return m_inspectorClient; }
     InspectorPageAgent* pageAgent() const { return m_pageAgent; }
 
 private:

Modified: trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp (109938 => 109939)


--- trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.cpp	2012-03-06 19:33:07 UTC (rev 109939)
@@ -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 (109938 => 109939)


--- trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/inspector/InspectorFrontendClientLocal.h	2012-03-06 19:33:07 UTC (rev 109939)
@@ -77,6 +77,7 @@
     virtual void sendMessageToBackend(const String& message);
 
     bool canAttachWindow();
+    void setDockingUnavailable(bool);
 
     static unsigned constrainedAttachedWindowHeight(unsigned preferredHeight, unsigned totalWindowHeight);
 

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


--- trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js	2012-03-06 19:33:07 UTC (rev 109939)
@@ -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/InspectorFrontendHostStub.js (109938 => 109939)


--- trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/inspector/front-end/InspectorFrontendHostStub.js	2012-03-06 19:33:07 UTC (rev 109939)
@@ -137,11 +137,6 @@
         fr.readAsDataURL(blob);
     },
 
-    canAttachWindow: function()
-    {
-        return false;
-    },
-
     sendMessageToBackend: function(message)
     {
     },

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


--- trunk/Source/WebCore/inspector/front-end/inspector.js	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js	2012-03-06 19:33:07 UTC (rev 109939)
@@ -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.updateDockToggleButton();
 
         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.updateDockToggleButton();
 }
 
+WebInspector.setDockingUnavailable = function(unavailable)
+{
+    this._isDockingUnavailable = unavailable;
+    WebInspector.updateDockToggleButton();
+}
+
+WebInspector.updateDockToggleButton = function()
+{
+    if (!this._dockToggleButton)
+        return;
+    this._dockToggleButton.disabled = this.attached ? false : this._isDockingUnavailable;
+}
+
 WebInspector.close = function(event)
 {
     if (this._isClosing)

Modified: trunk/Source/WebCore/page/FrameView.cpp (109938 => 109939)


--- trunk/Source/WebCore/page/FrameView.cpp	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebCore/page/FrameView.cpp	2012-03-06 19:33:07 UTC (rev 109939)
@@ -49,6 +49,8 @@
 #include "HTMLFrameSetElement.h"
 #include "HTMLNames.h"
 #include "HTMLPlugInImageElement.h"
+#include "InspectorClient.h"
+#include "InspectorController.h"
 #include "InspectorInstrumentation.h"
 #include "OverflowEvent.h"
 #include "RenderArena.h"
@@ -2331,8 +2333,18 @@
         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 (InspectorInstrumentation::hasFrontends()) {
+                if (Page* page = m_frame->page()) {
+                    if (page->mainFrame() == m_frame) {
+                        if (InspectorClient* inspectorClient = page->inspectorController()->inspectorClient())
+                            inspectorClient->didResizeMainFrame(m_frame.get());
+                    }
+                }
+            }
+        }
     }
 }
 

Modified: trunk/Source/WebKit/mac/ChangeLog (109938 => 109939)


--- trunk/Source/WebKit/mac/ChangeLog	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebKit/mac/ChangeLog	2012-03-06 19:33:07 UTC (rev 109939)
@@ -1,3 +1,16 @@
+2012-03-05  Joseph Pecoraro  <[email protected]>
+
+        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):
+
 2012-03-05  Gavin Barraclough  <[email protected]>
 
         putByIndex should throw in strict mode

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h (109938 => 109939)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.h	2012-03-06 19:33:07 UTC (rev 109939)
@@ -47,6 +47,7 @@
 
 namespace WebCore {
 
+class Frame;
 class Page;
 
 }
@@ -62,6 +63,7 @@
     virtual void openInspectorFrontend(WebCore::InspectorController*) OVERRIDE;
     virtual void closeInspectorFrontend() OVERRIDE;
     virtual void bringFrontendToFront() OVERRIDE;
+    virtual void didResizeMainFrame(WebCore::Frame*) OVERRIDE;
 
     virtual void highlight() OVERRIDE;
     virtual void hideHighlight() OVERRIDE;

Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm (109938 => 109939)


--- trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebInspectorClient.mm	2012-03-06 19:33:07 UTC (rev 109939)
@@ -111,6 +111,11 @@
     m_frontendClient->bringToFront();
 }
 
+void WebInspectorClient::didResizeMainFrame(Frame*)
+{
+    m_frontendClient->setDockingUnavailable(!m_frontendClient->canAttachWindow());
+}
+
 void WebInspectorClient::highlight()
 {
     [m_highlighter.get() highlight];

Modified: trunk/Source/WebKit2/ChangeLog (109938 => 109939)


--- trunk/Source/WebKit2/ChangeLog	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebKit2/ChangeLog	2012-03-06 19:33:07 UTC (rev 109939)
@@ -1,3 +1,17 @@
+2012-03-05  Joseph Pecoraro  <[email protected]>
+
+        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:
+
 2012-03-06  Allan Sandfeld Jensen  <[email protected]>
 
         [Qt] Interaction Engine suspends content during pageload.

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp (109938 => 109939)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp	2012-03-06 19:33:07 UTC (rev 109939)
@@ -60,6 +60,11 @@
     m_page->inspector()->bringToFront();
 }
 
+void WebInspectorClient::didResizeMainFrame(Frame*)
+{
+    m_page->inspector()->updateDockingAvailability();
+}
+
 void WebInspectorClient::highlight()
 {
     if (!m_highlightOverlay) {

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h (109938 => 109939)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h	2012-03-06 19:33:07 UTC (rev 109939)
@@ -55,6 +55,7 @@
     virtual void openInspectorFrontend(WebCore::InspectorController*) OVERRIDE;
     virtual void closeInspectorFrontend() OVERRIDE;
     virtual void bringFrontendToFront() OVERRIDE;
+    virtual void didResizeMainFrame(WebCore::Frame*) OVERRIDE;
 
     virtual void highlight() OVERRIDE;
     virtual void hideHighlight() OVERRIDE;

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp (109938 => 109939)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.cpp	2012-03-06 19:33:07 UTC (rev 109939)
@@ -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 (109938 => 109939)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h	2012-03-06 19:23:15 UTC (rev 109938)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebInspector.h	2012-03-06 19:33:07 UTC (rev 109939)
@@ -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