Source/WebCore: WebKit2: Web Inspector always starts in undocked mode
authorbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Aug 2011 17:45:31 +0000 (17:45 +0000)
committerbweinstein@apple.com <bweinstein@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 4 Aug 2011 17:45:31 +0000 (17:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=65493
<rdar://problem/9353114>

Reviewed by Adam Roben.

Expose some methods on InspectorFrontendClient through the InspectorController so WebKit2
can request the inspector be docked, or ask whether or not it can be docked.

* WebCore.exp.in: Export needed methods.
* inspector/InspectorController.cpp:
(WebCore::InspectorController::requestAttachWindow): Call through to InspectorFrontendClient.
(WebCore::InspectorController::canAttachWindow): Ditto.
* inspector/InspectorController.h:
* inspector/InspectorFrontendClient.h:
* inspector/InspectorFrontendClientLocal.h:

Source/WebKit/chromium: WebKit2: Web Inspector always starts in undocked mode
https://bugs.webkit.org/show_bug.cgi?id=65493
<rdar://problem/9353114>

Reviewed by Adam Roben.

Add a stub method for Chromium.

* src/InspectorFrontendClientImpl.cpp:
(WebKit::InspectorFrontendClientImpl::canAttachWindow):
* src/InspectorFrontendClientImpl.h:

Source/WebKit2: WebKit2: Web Inspector always starts in undocked mode
https://bugs.webkit.org/show_bug.cgi?id=65493
<rdar://problem/9353114>

Reviewed by Adam Roben.

When opening the inspector, the web process tells the UI process that the inspector page has loaded,
but now will pass another bit of data, whether the inspector can start attached, so the UI process
doesn't need to ask the web process to do another calculation on whether or not it can be attached.

If the user prefers the inspector to start docked (this defaults to true), and there is room for the
window, we send a message to the web process to try and attach the inspector. This makes sure that the
inspector knows it is docked (in the web process).

* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::attach): Update the user's docked/undocked preference if the inspector is visible
    when it was attached.
(WebKit::WebInspectorProxy::detach): Ditto (but when it was detached).
(WebKit::WebInspectorProxy::didLoadInspectorPage): If we can start docked, and the user prefers to start docked,
    then request the inspector be attached to the window.
* UIProcess/WebInspectorProxy.h:

* UIProcess/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::platformOpen): Only show the window if we are going to start undocked.
* UIProcess/win/WebInspectorProxyWin.cpp:
(WebKit::WebInspectorProxy::platformOpen): Ditto.

* WebProcess/WebPage/WebInspector.cpp:
(WebKit::WebInspector::didLoadInspectorPage): Pass whether or not we can attach the window.
(WebKit::WebInspector::requestAttachWindow): Call through to the InspectorController to attach the inspector.
(WebKit::WebInspector::canAttachWindow): Ask the InspectorController if we can attach the inspector.
* WebProcess/WebPage/WebInspector.h:

* Shared/WebPreferencesStore.h: Add a new preference for whether or not the inspector should
    start attached.

* UIProcess/WebInspectorProxy.messages.in: When the inspector page is loaded, tell the UI Process whether
    we can attach the inspector without needing another message.
* WebProcess/WebPage/WebInspector.messages.in: Add a new message for RequestAttachWindow

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@92384 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorFrontendClient.h
Source/WebCore/inspector/InspectorFrontendClientLocal.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp
Source/WebKit/chromium/src/InspectorFrontendClientImpl.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebPreferencesStore.h
Source/WebKit2/UIProcess/WebInspectorProxy.cpp
Source/WebKit2/UIProcess/WebInspectorProxy.h
Source/WebKit2/UIProcess/WebInspectorProxy.messages.in
Source/WebKit2/UIProcess/mac/WebInspectorProxyMac.mm
Source/WebKit2/UIProcess/qt/WebInspectorProxyQt.cpp
Source/WebKit2/UIProcess/win/WebInspectorProxyWin.cpp
Source/WebKit2/WebProcess/WebPage/WebInspector.cpp
Source/WebKit2/WebProcess/WebPage/WebInspector.h
Source/WebKit2/WebProcess/WebPage/WebInspector.messages.in

index fb01a2e..21a8563 100644 (file)
@@ -1,3 +1,22 @@
+2011-08-01  Brian Weinstein  <bweinstein@apple.com>
+
+        WebKit2: Web Inspector always starts in undocked mode
+        https://bugs.webkit.org/show_bug.cgi?id=65493
+        <rdar://problem/9353114>
+        
+        Reviewed by Adam Roben.
+        
+        Expose some methods on InspectorFrontendClient through the InspectorController so WebKit2
+        can request the inspector be docked, or ask whether or not it can be docked.
+
+        * WebCore.exp.in: Export needed methods.
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::requestAttachWindow): Call through to InspectorFrontendClient.
+        (WebCore::InspectorController::canAttachWindow): Ditto.
+        * inspector/InspectorController.h:
+        * inspector/InspectorFrontendClient.h:
+        * inspector/InspectorFrontendClientLocal.h:
+
 2011-08-04  Luke Macpherson   <macpherson@chromium.org>
 
         Support cast between CSSPrimitiveValue and EborderFit, use in CSSStyleSelector.
index 006506c..a25eecf 100644 (file)
@@ -1586,11 +1586,13 @@ __ZN7WebCore22GeolocationServiceMock8setErrorEN3WTF10PassRefPtrINS_13PositionErr
 #if ENABLE(INSPECTOR)
 __ZN7WebCore15InspectorClient31doDispatchMessageOnFrontendPageEPNS_4PageERKN3WTF6StringE
 __ZN7WebCore19InspectorController14enableProfilerEv
+__ZN7WebCore19InspectorController15canAttachWindowEv
 __ZN7WebCore19InspectorController15debuggerEnabledEv
 __ZN7WebCore19InspectorController15disableDebuggerEv
 __ZN7WebCore19InspectorController15disableProfilerEv
 __ZN7WebCore19InspectorController15profilerEnabledEv
 __ZN7WebCore19InspectorController18disconnectFrontendEv
+__ZN7WebCore19InspectorController19requestAttachWindowEv
 __ZN7WebCore19InspectorController20stopTimelineProfilerEv
 __ZN7WebCore19InspectorController21showAndEnableDebuggerEv
 __ZN7WebCore19InspectorController11showConsoleEv
index 6291a33..6522a63 100644 (file)
@@ -509,6 +509,22 @@ void InspectorController::setResourcesDataSizeLimitsFromInternals(int maximumRes
     m_resourceAgent->setResourcesDataSizeLimitsFromInternals(maximumResourcesContentSize, maximumSingleResourceContentSize);
 }
 
+void InspectorController::requestAttachWindow()
+{
+    if (!m_inspectorFrontendClient)
+        return;
+
+    m_inspectorFrontendClient->requestAttachWindow();
+}
+    
+bool InspectorController::canAttachWindow()
+{
+    if (!m_inspectorFrontendClient)
+        return false;
+    
+    return m_inspectorFrontendClient->canAttachWindow();
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index 9d76835..86ff76b 100644 (file)
@@ -121,6 +121,9 @@ public:
 #endif
 
     void setResourcesDataSizeLimitsFromInternals(int maximumResourcesContentSize, int maximumSingleResourceContentSize);
+    
+    void requestAttachWindow();
+    bool canAttachWindow();
 
 private:
     friend class PostWorkerNotificationToFrontendTask;
index bc8a135..1733742 100644 (file)
@@ -58,6 +58,7 @@ public:
     virtual void requestAttachWindow() = 0;
     virtual void requestDetachWindow() = 0;
     virtual void changeAttachedWindowHeight(unsigned) = 0;
+    virtual bool canAttachWindow() = 0;
     virtual void saveAs(const WTF::String& fileName, const WTF::String& content) = 0;
 
     virtual void inspectedURLChanged(const String&) = 0;
index 3e4d2c2..423ef36 100644 (file)
@@ -64,11 +64,11 @@ public:
     virtual void requestAttachWindow();
     virtual void requestDetachWindow();
     virtual void changeAttachedWindowHeight(unsigned);
+    virtual bool canAttachWindow();
     virtual void saveAs(const String&, const String&) { }
 
     virtual void attachWindow() = 0;
     virtual void detachWindow() = 0;
-    bool canAttachWindow();
 
     virtual void sendMessageToBackend(const String& message);
 
index d168ae9..d28646d 100644 (file)
@@ -1,3 +1,17 @@
+2011-08-04  Brian Weinstein  <bweinstein@apple.com>
+
+        WebKit2: Web Inspector always starts in undocked mode
+        https://bugs.webkit.org/show_bug.cgi?id=65493
+        <rdar://problem/9353114>
+
+        Reviewed by Adam Roben.
+        
+        Add a stub method for Chromium.
+
+        * src/InspectorFrontendClientImpl.cpp:
+        (WebKit::InspectorFrontendClientImpl::canAttachWindow):
+        * src/InspectorFrontendClientImpl.h:
+
 2011-08-03  Kentaro Hara  <haraken@google.com>
 
         Implement EventSender.scalePageBy()
index b6c076a..5616323 100644 (file)
@@ -124,6 +124,12 @@ void InspectorFrontendClientImpl::changeAttachedWindowHeight(unsigned)
 {
     // Do nothing;
 }
+
+bool InspectorFrontendClientImpl::canAttachWindow()
+{
+    // FIXME: Implement this if it is ever called by Chromium.
+    return false;
+}
     
 void InspectorFrontendClientImpl::saveAs(const String& fileName, const String& content)
 {
index fd45f5b..0ebbf07 100644 (file)
@@ -66,6 +66,7 @@ public:
     virtual void requestAttachWindow();
     virtual void requestDetachWindow();
     virtual void changeAttachedWindowHeight(unsigned);
+    virtual bool canAttachWindow();
     virtual void saveAs(const WTF::String& fileName, const WTF::String& content);
 
     virtual void inspectedURLChanged(const WTF::String&);
index 52f37cb..d0aae0c 100644 (file)
@@ -1,3 +1,45 @@
+2011-08-01  Brian Weinstein  <bweinstein@apple.com>
+
+        WebKit2: Web Inspector always starts in undocked mode
+        https://bugs.webkit.org/show_bug.cgi?id=65493
+        <rdar://problem/9353114>
+        
+        Reviewed by Adam Roben.
+        
+        When opening the inspector, the web process tells the UI process that the inspector page has loaded,
+        but now will pass another bit of data, whether the inspector can start attached, so the UI process
+        doesn't need to ask the web process to do another calculation on whether or not it can be attached.
+        
+        If the user prefers the inspector to start docked (this defaults to true), and there is room for the
+        window, we send a message to the web process to try and attach the inspector. This makes sure that the
+        inspector knows it is docked (in the web process).
+        
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::attach): Update the user's docked/undocked preference if the inspector is visible
+            when it was attached.
+        (WebKit::WebInspectorProxy::detach): Ditto (but when it was detached).
+        (WebKit::WebInspectorProxy::didLoadInspectorPage): If we can start docked, and the user prefers to start docked,
+            then request the inspector be attached to the window.
+        * UIProcess/WebInspectorProxy.h:
+
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (WebKit::WebInspectorProxy::platformOpen): Only show the window if we are going to start undocked.
+        * UIProcess/win/WebInspectorProxyWin.cpp:
+        (WebKit::WebInspectorProxy::platformOpen): Ditto.
+
+        * WebProcess/WebPage/WebInspector.cpp:
+        (WebKit::WebInspector::didLoadInspectorPage): Pass whether or not we can attach the window.
+        (WebKit::WebInspector::requestAttachWindow): Call through to the InspectorController to attach the inspector.
+        (WebKit::WebInspector::canAttachWindow): Ask the InspectorController if we can attach the inspector.
+        * WebProcess/WebPage/WebInspector.h:
+
+        * Shared/WebPreferencesStore.h: Add a new preference for whether or not the inspector should
+            start attached.
+
+        * UIProcess/WebInspectorProxy.messages.in: When the inspector page is loaded, tell the UI Process whether
+            we can attach the inspector without needing another message.
+        * WebProcess/WebPage/WebInspector.messages.in: Add a new message for RequestAttachWindow
+
 2011-08-02  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
 
         [Qt][WK2] Create scene graph nodes for tiles in QTouchWebView instead of using imperative painting.
index 9ef74a8..0d90bd0 100644 (file)
@@ -84,6 +84,7 @@ namespace WebKit {
     macro(Hixie76WebSocketProtocolEnabled, hixie76WebSocketProtocolEnabled, Bool, bool, true) \
     macro(MediaPlaybackRequiresUserGesture, mediaPlaybackRequiresUserGesture, Bool, bool, false) \
     macro(MediaPlaybackAllowsInline, mediaPlaybackAllowsInline, Bool, bool, true) \
+    macro(InspectorStartsAttached, inspectorStartsAttached, Bool, bool, true) \
     \
 
 #define FOR_EACH_WEBKIT_DOUBLE_PREFERENCE(macro) \
index 1b53d77..afd4f5b 100644 (file)
@@ -121,6 +121,9 @@ void WebInspectorProxy::showConsole()
 void WebInspectorProxy::attach()
 {
     m_isAttached = true;
+    
+    if (m_isVisible)
+        inspectorPageGroup()->preferences()->setInspectorStartsAttached(true);
 
     platformAttach();
 }
@@ -128,6 +131,9 @@ void WebInspectorProxy::attach()
 void WebInspectorProxy::detach()
 {
     m_isAttached = false;
+    
+    if (m_isVisible)
+        inspectorPageGroup()->preferences()->setInspectorStartsAttached(false);
 
     platformDetach();
 }
@@ -203,11 +209,15 @@ void WebInspectorProxy::createInspectorPage(uint64_t& inspectorPageID, WebPageCr
     inspectorPage->loadURL(inspectorPageURL());
 }
 
-void WebInspectorProxy::didLoadInspectorPage()
+void WebInspectorProxy::didLoadInspectorPage(bool canStartAttached)
 {
     m_isVisible = true;
 
-    platformOpen();
+    bool willOpenAttached = canStartAttached && inspectorPageGroup()->preferences()->inspectorStartsAttached();
+    platformOpen(willOpenAttached);
+    
+    if (willOpenAttached)
+        m_page->process()->send(Messages::WebInspector::RequestAttachWindow(), m_page->pageID());
 }
 
 void WebInspectorProxy::didClose()
index 63fb7f4..009ef6a 100644 (file)
@@ -114,7 +114,7 @@ private:
     virtual Type type() const { return APIType; }
 
     WebPageProxy* platformCreateInspectorPage();
-    void platformOpen();
+    void platformOpen(bool willOpenAttached);
     void platformDidClose();
     void platformBringToFront();
     void platformInspectedURLChanged(const String&);
@@ -127,7 +127,7 @@ private:
 
     // Called by WebInspectorProxy messages
     void createInspectorPage(uint64_t& inspectorPageID, WebPageCreationParameters&);
-    void didLoadInspectorPage();
+    void didLoadInspectorPage(bool canStartAttached);
     void didClose();
     void bringToFront();
     void inspectedURLChanged(const String&);
index e87321b..d0066f4 100644 (file)
@@ -24,7 +24,7 @@
 
 messages -> WebInspectorProxy {
     CreateInspectorPage() -> (uint64_t inspectorPageID, WebKit::WebPageCreationParameters inspectorPageParameters)
-    DidLoadInspectorPage()
+    DidLoadInspectorPage(bool canStartAttached)
     DidClose()
     BringToFront()
     InspectedURLChanged(WTF::String urlString)
index 8840267..0472506 100644 (file)
@@ -109,14 +109,12 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
     return toImpl(m_inspectorView.get().pageRef);
 }
 
-void WebInspectorProxy::platformOpen()
+void WebInspectorProxy::platformOpen(bool willOpenAttached)
 {
     ASSERT(!m_inspectorWindow);
 
     m_inspectorProxyObjCAdapter.adoptNS([[WebInspectorProxyObjCAdapter alloc] initWithWebInspectorProxy:this]);
 
-    // FIXME: support opening in docked mode here.
-
     NSUInteger styleMask = (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask | NSTexturedBackgroundWindowMask);
     NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, initialWindowWidth, initialWindowHeight) styleMask:styleMask backing:NSBackingStoreBuffered defer:NO];
     [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
@@ -137,7 +135,8 @@ void WebInspectorProxy::platformOpen()
     [m_inspectorView.get() setAutoresizingMask:(NSViewWidthSizable | NSViewHeightSizable)];
     [contentView addSubview:m_inspectorView.get()];
 
-    [window makeKeyAndOrderFront:nil];
+    if (!willOpenAttached)
+        [window makeKeyAndOrderFront:nil];
 
     m_inspectorWindow.adoptNS(window);
 }
index ac9bd20..b57aa9f 100644 (file)
@@ -39,7 +39,7 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
     return 0;
 }
 
-void WebInspectorProxy::platformOpen()
+void WebInspectorProxy::platformOpen(bool)
 {
     notImplemented();
 }
index fcaa7ce..e8a9e1d 100644 (file)
@@ -198,7 +198,7 @@ WebPageProxy* WebInspectorProxy::platformCreateInspectorPage()
     return m_inspectorView->page();
 }
 
-void WebInspectorProxy::platformOpen()
+void WebInspectorProxy::platformOpen(bool willOpenAttached)
 {
     registerInspectorViewWindowClass();
 
@@ -207,7 +207,9 @@ void WebInspectorProxy::platformOpen()
     ASSERT(::IsWindow(m_inspectorWindow));
 
     m_inspectorView->setParentWindow(m_inspectorWindow);
-    ::ShowWindow(m_inspectorWindow, SW_SHOW);
+
+    if (!willOpenAttached)
+        ::ShowWindow(m_inspectorWindow, SW_SHOW);
 }
 
 void WebInspectorProxy::platformDidClose()
index 16c3b39..53c25c7 100644 (file)
@@ -78,7 +78,7 @@ WebPage* WebInspector::createInspectorPage()
 // Called from WebInspectorFrontendClient
 void WebInspector::didLoadInspectorPage()
 {
-    WebProcess::shared().connection()->send(Messages::WebInspectorProxy::DidLoadInspectorPage(), m_page->pageID());
+    WebProcess::shared().connection()->send(Messages::WebInspectorProxy::DidLoadInspectorPage(canAttachWindow()), m_page->pageID());
 }
 
 void WebInspector::didClose()
@@ -181,6 +181,16 @@ void WebInspector::stopPageProfiling()
     // FIXME: show the Timeline panel.
 }
 
+void WebInspector::requestAttachWindow()
+{
+    m_inspectorPage->corePage()->inspectorController()->requestAttachWindow();
+}
+
+bool WebInspector::canAttachWindow() const
+{
+    return m_inspectorPage->corePage()->inspectorController()->canAttachWindow();
+}
+
 } // namespace WebKit
 
 #endif // ENABLE(INSPECTOR)
index b4a76b4..c16cd28 100644 (file)
@@ -59,6 +59,9 @@ public:
     void setJavaScriptProfilingEnabled(bool);
     void startPageProfiling();
     void stopPageProfiling();
+    
+    bool canAttachWindow() const;
+    void requestAttachWindow();
 
 private:
     friend class WebInspectorClient;
index dc184b6..5582ce9 100644 (file)
@@ -32,6 +32,8 @@ messages -> WebInspector {
     StopJavaScriptProfiling()
     StartPageProfiling()
     StopPageProfiling()
+
+    RequestAttachWindow()
 }
 
 #endif