Web Inspector: re-add `InspectorFrontendHost` support for moving the inspected window
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2020 06:31:10 +0000 (06:31 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Mar 2020 06:31:10 +0000 (06:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=208555

Reviewed by Timothy Hatcher.

Partially revert r257759, as the design changed enough such that this code is still useful.

Source/WebCore:

Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
whether it supports the given docking configuration.

* inspector/InspectorFrontendHost.idl:
* inspector/InspectorFrontendHost.h:
* inspector/InspectorFrontendHost.cpp:
(WebCore::dockSideFromString): Added.
(WebCore::InspectorFrontendHost::supportsDockSide): Added.
(WebCore::InspectorFrontendHost::requestSetDockSide):
(WebCore::InspectorFrontendHost::startWindowDrag): Added.
(WebCore::InspectorFrontendHost::moveWindowBy const): Added.

* inspector/InspectorFrontendClient.h:

* inspector/InspectorFrontendClientLocal.cpp:
* inspector/InspectorFrontendClientLocal.h:
(WebCore::InspectorFrontendClientLocal::moveWindowBy): Added.

* testing/Internals.cpp:
(WebCore::InspectorStubFrontend::supportsDockSide): Added.

Source/WebInspectorUI:

* UserInterface/Base/Main.js:
(WI.loaded):
(WI.updateDockedState):
(WI.resizeDockedFrameMouseDown): Added.
(WI.moveUndockedWindowMouseDown): Added.
(WI.dockedConfigurationSupportsSplitContentBrowser):
(WI._windowFocused):
(WI._windowBlurred):
(WI._updateDockNavigationItems):
(WI._handleDockedResizerMouseDown):
(WI._handleUndockedTitleAreaMouseDown):
(WI._updateTabBarDividers):
(WI.setLayoutDirection):
Don't create tab bar navigation items for the various docking configurations if the platform
doesn't support that particular configuration.

* UserInterface/Views/TabBar.js:
(WI.TabBar):
(WI.TabBar.get horizontalPadding):
(WI.TabBar.prototype._handleMouseDown):
(WI.TabBar.prototype._handleTabContainerMouseDown): Added.
(WI.TabBar.prototype._handleTabContainerClick): Added.
(WI.TabBar.prototype._handleTabContainerMouseLeave): Added.
(WI.TabBar.prototype._handleTabContainerContextMenu): Added.
(WI.TabBar.prototype._handleClick): Deleted.
(WI.TabBar.prototype._handleMouseLeave): Deleted.
(WI.TabBar.prototype._handleContextMenu): Deleted.
* UserInterface/Views/TabBar.css:
(body.docked.bottom .tab-bar > .tabs > .flexible-space):
Dragging on empty space in the tab bar should adjust Web Inspector's bottom docked height.

* UserInterface/Views/TabBarItem.js:
(WI.TabBarItem.get horizontalMargin):

Source/WebKit:

Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
whether it supports the given docking configuration.

* WebProcess/Inspector/WebInspectorUI.h:
* WebProcess/Inspector/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::startWindowDrag): Added.
(WebKit::WebInspectorUI::moveWindowBy): Added.
(WebKit::WebInspectorUI::supportsDockSide): Added.
(WebKit::WebInspectorUI::requestSetDockSide):
(WebKit::WebInspectorUI::setDockSide):
* UIProcess/Inspector/WebInspectorProxy.messages.in:
* UIProcess/Inspector/WebInspectorProxy.h:
* UIProcess/Inspector/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::startWindowDrag): Added.
(WebKit::WebInspectorProxy::platformStartWindowDrag): Added.
* UIProcess/Inspector/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::platformStartWindowDrag): Added.
* UIProcess/Inspector/mac/WebInspectorProxyMac.mm:
(WebKit::WebInspectorProxy::platformStartWindowDrag): Added.
* UIProcess/Inspector/win/WebInspectorProxyWin.cpp:
(WebKit::WebInspectorProxy::platformStartWindowDrag): Added.

* WebProcess/Inspector/RemoteWebInspectorUI.h:
* WebProcess/Inspector/RemoteWebInspectorUI.cpp:
(WebKit::RemoteWebInspectorUI::startWindowDrag): Added.
(WebKit::RemoteWebInspectorUI::moveWindowBy): Added.
(WebKit::RemoteWebInspectorUI::supportsDockSide): Added.
* UIProcess/Inspector/RemoteWebInspectorProxy.messages.in:
* UIProcess/Inspector/RemoteWebInspectorProxy.h:
* UIProcess/Inspector/RemoteWebInspectorProxy.cpp:
(WebKit::RemoteWebInspectorProxy::startWindowDrag): Added.
(WebKit::RemoteWebInspectorProxy::platformStartWindowDrag): Added.
* UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp:
(WebKit::RemoteWebInspectorProxy::platformStartWindowDrag): Added.
* UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm:
(WebKit::RemoteWebInspectorProxy::platformStartWindowDrag): Added.
* UIProcess/Inspector/win/RemoteWebInspectorProxyWin.cpp:
(WebKit::RemoteWebInspectorProxy::platformStartWindowDrag): Added.

Source/WebKitLegacy/ios:

Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
whether it supports the given docking configuration.

* WebCoreSupport/WebInspectorClientIOS.mm:
(WebInspectorFrontendClient::supportsDockSide): Added.
(WebInspectorFrontendClient::startWindowDrag): Added.

Source/WebKitLegacy/mac:

Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
whether it supports the given docking configuration.

* WebCoreSupport/WebInspectorClient.h:
* WebCoreSupport/WebInspectorClient.mm:
(WebInspectorFrontendClient::startWindowDrag): Added.
(WebInspectorFrontendClient::supportsDockSide): Added.

Source/WebKitLegacy/win:

Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
whether it supports the given docking configuration.

* WebCoreSupport/WebInspectorClient.h:
* WebCoreSupport/WebInspectorClient.cpp:
(WebInspectorFrontendClient::supportsDockSide): Added.

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

38 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorFrontendClient.h
Source/WebCore/inspector/InspectorFrontendClientLocal.cpp
Source/WebCore/inspector/InspectorFrontendClientLocal.h
Source/WebCore/inspector/InspectorFrontendHost.cpp
Source/WebCore/inspector/InspectorFrontendHost.h
Source/WebCore/inspector/InspectorFrontendHost.idl
Source/WebCore/testing/Internals.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebInspectorUI/UserInterface/Views/TabBar.css
Source/WebInspectorUI/UserInterface/Views/TabBar.js
Source/WebInspectorUI/UserInterface/Views/TabBarItem.js
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.cpp
Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.h
Source/WebKit/UIProcess/Inspector/RemoteWebInspectorProxy.messages.in
Source/WebKit/UIProcess/Inspector/WebInspectorProxy.cpp
Source/WebKit/UIProcess/Inspector/WebInspectorProxy.h
Source/WebKit/UIProcess/Inspector/WebInspectorProxy.messages.in
Source/WebKit/UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp
Source/WebKit/UIProcess/Inspector/gtk/WebInspectorProxyGtk.cpp
Source/WebKit/UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm
Source/WebKit/UIProcess/Inspector/mac/WebInspectorProxyMac.mm
Source/WebKit/UIProcess/Inspector/win/RemoteWebInspectorProxyWin.cpp
Source/WebKit/UIProcess/Inspector/win/WebInspectorProxyWin.cpp
Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp
Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.h
Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp
Source/WebKit/WebProcess/Inspector/WebInspectorUI.h
Source/WebKitLegacy/ios/ChangeLog
Source/WebKitLegacy/ios/WebCoreSupport/WebInspectorClientIOS.mm
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/WebCoreSupport/WebInspectorClient.h
Source/WebKitLegacy/mac/WebCoreSupport/WebInspectorClient.mm
Source/WebKitLegacy/win/ChangeLog
Source/WebKitLegacy/win/WebCoreSupport/WebInspectorClient.cpp
Source/WebKitLegacy/win/WebCoreSupport/WebInspectorClient.h

index 6118dfa..73a88d6 100644 (file)
@@ -1,5 +1,35 @@
 2020-03-03  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: re-add `InspectorFrontendHost` support for moving the inspected window
+        https://bugs.webkit.org/show_bug.cgi?id=208555
+
+        Reviewed by Timothy Hatcher.
+
+        Partially revert r257759, as the design changed enough such that this code is still useful.
+
+        Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
+        whether it supports the given docking configuration.
+
+        * inspector/InspectorFrontendHost.idl:
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::dockSideFromString): Added.
+        (WebCore::InspectorFrontendHost::supportsDockSide): Added.
+        (WebCore::InspectorFrontendHost::requestSetDockSide):
+        (WebCore::InspectorFrontendHost::startWindowDrag): Added.
+        (WebCore::InspectorFrontendHost::moveWindowBy const): Added.
+
+        * inspector/InspectorFrontendClient.h:
+
+        * inspector/InspectorFrontendClientLocal.cpp:
+        * inspector/InspectorFrontendClientLocal.h:
+        (WebCore::InspectorFrontendClientLocal::moveWindowBy): Added.
+
+        * testing/Internals.cpp:
+        (WebCore::InspectorStubFrontend::supportsDockSide): Added.
+
+2020-03-03  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: set both the page's and the window's appearance when modifying the frontend forced appearance in the case that the frontend is docked
         https://bugs.webkit.org/show_bug.cgi?id=208557
 
index 18ac443..15068f9 100644 (file)
@@ -55,6 +55,9 @@ public:
     WEBCORE_EXPORT virtual void windowObjectCleared() = 0;
     virtual void frontendLoaded() = 0;
 
+    virtual void startWindowDrag() = 0;
+    virtual void moveWindowBy(float x, float y) = 0;
+
     // Information about the debuggable.
     virtual bool isRemote() const = 0;
     virtual String localizedStringsURL() const = 0;
@@ -80,6 +83,7 @@ public:
 
     virtual UserInterfaceLayoutDirection userInterfaceLayoutDirection() const = 0;
 
+    WEBCORE_EXPORT virtual bool supportsDockSide(DockSide) = 0;
     WEBCORE_EXPORT virtual void requestSetDockSide(DockSide) = 0;
     WEBCORE_EXPORT virtual void changeAttachedWindowHeight(unsigned) = 0;
     WEBCORE_EXPORT virtual void changeAttachedWindowWidth(unsigned) = 0;
index 40a0978..a486127 100644 (file)
@@ -270,6 +270,13 @@ void InspectorFrontendClientLocal::openInNewTab(const String& url)
     frame->loader().changeLocation(WTFMove(frameLoadRequest2));
 }
 
+void InspectorFrontendClientLocal::moveWindowBy(float x, float y)
+{
+    FloatRect frameRect = m_frontendPage->chrome().windowRect();
+    frameRect.move(x, y);
+    m_frontendPage->chrome().setWindowRect(frameRect);
+}
+
 void InspectorFrontendClientLocal::setAttachedWindow(DockSide dockSide)
 {
     const char* side = "undocked";
index 055df42..0ec320d 100644 (file)
@@ -67,6 +67,9 @@ public:
     WEBCORE_EXPORT void windowObjectCleared() final;
     WEBCORE_EXPORT void frontendLoaded() override;
 
+    void startWindowDrag() override { }
+    WEBCORE_EXPORT void moveWindowBy(float x, float y) final;
+
     WEBCORE_EXPORT UserInterfaceLayoutDirection userInterfaceLayoutDirection() const final;
 
     WEBCORE_EXPORT void requestSetDockSide(DockSide) final;
index 7bc30d0..84705e2 100644 (file)
@@ -171,18 +171,41 @@ void InspectorFrontendHost::loaded()
         m_client->frontendLoaded();
 }
 
-void InspectorFrontendHost::requestSetDockSide(const String& side)
+static Optional<InspectorFrontendClient::DockSide> dockSideFromString(const String& dockSideString)
+{
+    if (dockSideString == "undocked")
+        return InspectorFrontendClient::DockSide::Undocked;
+    if (dockSideString == "right")
+        return InspectorFrontendClient::DockSide::Right;
+    if (dockSideString == "left")
+        return InspectorFrontendClient::DockSide::Left;
+    if (dockSideString == "bottom")
+        return InspectorFrontendClient::DockSide::Bottom;
+    return WTF::nullopt;
+}
+
+bool InspectorFrontendHost::supportsDockSide(const String& dockSideString)
+{
+    if (!m_client)
+        return false;
+
+    auto dockSide = dockSideFromString(dockSideString);
+    if (!dockSide)
+        return false;
+
+    return m_client->supportsDockSide(dockSide.value());
+}
+
+void InspectorFrontendHost::requestSetDockSide(const String& dockSideString)
 {
     if (!m_client)
         return;
-    if (side == "undocked")
-        m_client->requestSetDockSide(InspectorFrontendClient::DockSide::Undocked);
-    else if (side == "right")
-        m_client->requestSetDockSide(InspectorFrontendClient::DockSide::Right);
-    else if (side == "left")
-        m_client->requestSetDockSide(InspectorFrontendClient::DockSide::Left);
-    else if (side == "bottom")
-        m_client->requestSetDockSide(InspectorFrontendClient::DockSide::Bottom);
+
+    auto dockSide = dockSideFromString(dockSideString);
+    if (!dockSide)
+        return;
+
+    m_client->requestSetDockSide(dockSide.value());
 }
 
 void InspectorFrontendHost::closeWindow()
@@ -282,6 +305,18 @@ void InspectorFrontendHost::setSheetRect(float x, float y, unsigned width, unsig
         m_client->changeSheetRect(FloatRect(x, y, width, height));
 }
 
+void InspectorFrontendHost::startWindowDrag()
+{
+    if (m_client)
+        m_client->startWindowDrag();
+}
+
+void InspectorFrontendHost::moveWindowBy(float x, float y) const
+{
+    if (m_client)
+        m_client->moveWindowBy(x, y);
+}
+
 bool InspectorFrontendHost::isRemote() const
 {
     return m_client && m_client->isRemote();
index 7a65ed1..6742287 100644 (file)
@@ -72,6 +72,7 @@ public:
 
     String userInterfaceLayoutDirection();
 
+    bool supportsDockSide(const String&);
     void requestSetDockSide(const String&);
 
     void setAttachedWindowHeight(unsigned);
@@ -79,6 +80,9 @@ public:
 
     void setSheetRect(float x, float y, unsigned width, unsigned height);
 
+    void startWindowDrag();
+    void moveWindowBy(float x, float y) const;
+
     bool isRemote() const;
     String localizedStringsURL() const;
     String backendCommandsURL() const;
index 3db0e7f..e78c189 100644 (file)
 
     DOMString userInterfaceLayoutDirection();
 
-    void requestSetDockSide(DOMString side);
+    boolean supportsDockSide(DOMString dockSide);
+    void requestSetDockSide(DOMString dockSide);
 
     void setAttachedWindowHeight(unsigned long height);
     void setAttachedWindowWidth(unsigned long width);
 
     void setSheetRect(unrestricted float x, unrestricted float y, unsigned long width, unsigned long height);
 
+    void startWindowDrag();
+    void moveWindowBy(unrestricted float x, unrestricted float y);
+
     readonly attribute boolean isRemote;
     readonly attribute DOMString localizedStringsURL;
     readonly attribute DOMString backendCommandsURL;
index 3d75a4f..492df2f 100644 (file)
@@ -344,6 +344,7 @@ public:
     virtual ~InspectorStubFrontend();
 
 private:
+    bool supportsDockSide(DockSide) final { return false; }
     void attachWindow(DockSide) final { }
     void detachWindow() final { }
     void closeWindow() final;
index 567b711..9462761 100644 (file)
@@ -1,5 +1,48 @@
 2020-03-03  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: re-add `InspectorFrontendHost` support for moving the inspected window
+        https://bugs.webkit.org/show_bug.cgi?id=208555
+
+        Reviewed by Timothy Hatcher.
+
+        Partially revert r257759, as the design changed enough such that this code is still useful.
+
+        * UserInterface/Base/Main.js:
+        (WI.loaded):
+        (WI.updateDockedState):
+        (WI.resizeDockedFrameMouseDown): Added.
+        (WI.moveUndockedWindowMouseDown): Added.
+        (WI.dockedConfigurationSupportsSplitContentBrowser):
+        (WI._windowFocused):
+        (WI._windowBlurred):
+        (WI._updateDockNavigationItems):
+        (WI._handleDockedResizerMouseDown):
+        (WI._handleUndockedTitleAreaMouseDown):
+        (WI._updateTabBarDividers):
+        (WI.setLayoutDirection):
+        Don't create tab bar navigation items for the various docking configurations if the platform
+        doesn't support that particular configuration.
+
+        * UserInterface/Views/TabBar.js:
+        (WI.TabBar):
+        (WI.TabBar.get horizontalPadding):
+        (WI.TabBar.prototype._handleMouseDown):
+        (WI.TabBar.prototype._handleTabContainerMouseDown): Added.
+        (WI.TabBar.prototype._handleTabContainerClick): Added.
+        (WI.TabBar.prototype._handleTabContainerMouseLeave): Added.
+        (WI.TabBar.prototype._handleTabContainerContextMenu): Added.
+        (WI.TabBar.prototype._handleClick): Deleted.
+        (WI.TabBar.prototype._handleMouseLeave): Deleted.
+        (WI.TabBar.prototype._handleContextMenu): Deleted.
+        * UserInterface/Views/TabBar.css:
+        (body.docked.bottom .tab-bar > .tabs > .flexible-space):
+        Dragging on empty space in the tab bar should adjust Web Inspector's bottom docked height.
+
+        * UserInterface/Views/TabBarItem.js:
+        (WI.TabBarItem.get horizontalMargin):
+
+2020-03-03  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: the background of the navigation items in the tab bar doesn't match when unfocusing the window
         https://bugs.webkit.org/show_bug.cgi?id=208538
 
index 3ac63d9..ff71abe 100644 (file)
@@ -370,17 +370,28 @@ WI.contentLoaded = function()
     WI._closeTabBarButton = new WI.ButtonNavigationItem("dock-close", WI.UIString("Close"), "Images/CloseLarge.svg");
     WI._closeTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.close);
 
-    WI._dockToSideTabBarButton = new WI.ButtonNavigationItem("dock-right", WI.UIString("Dock to side of window"), WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? "Images/DockLeft.svg" : "Images/DockRight.svg", 16, 16);
-    WI._dockToSideTabBarButton.element.classList.add(WI.Popover.IgnoreAutoDismissClassName);
-    WI._dockToSideTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? WI._dockLeft : WI._dockRight);
+    let dockingConfigurationNavigationItems = [];
 
-    WI._dockBottomTabBarButton = new WI.ButtonNavigationItem("dock-bottom", WI.UIString("Dock to bottom of window"), "Images/DockBottom.svg", 16, 16);
-    WI._dockBottomTabBarButton.element.classList.add(WI.Popover.IgnoreAutoDismissClassName);
-    WI._dockBottomTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._dockBottom);
+    if (InspectorFrontendHost.supportsDockSide(WI.DockConfiguration.Right) && InspectorFrontendHost.supportsDockSide(WI.DockConfiguration.Left)) {
+        WI._dockToSideTabBarButton = new WI.ButtonNavigationItem("dock-right", WI.UIString("Dock to side of window"), WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? "Images/DockLeft.svg" : "Images/DockRight.svg", 16, 16);
+        WI._dockToSideTabBarButton.element.classList.add(WI.Popover.IgnoreAutoDismissClassName);
+        WI._dockToSideTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? WI._dockLeft : WI._dockRight);
+        dockingConfigurationNavigationItems.push(WI._dockToSideTabBarButton);
+    }
 
-    WI._undockTabBarButton = new WI.ButtonNavigationItem("undock", WI.UIString("Detach into separate window"), "Images/Undock.svg", 16, 16);
-    WI._undockTabBarButton.element.classList.add(WI.Popover.IgnoreAutoDismissClassName);
-    WI._undockTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._undock);
+    if (InspectorFrontendHost.supportsDockSide(WI.DockConfiguration.Bottom)) {
+        WI._dockBottomTabBarButton = new WI.ButtonNavigationItem("dock-bottom", WI.UIString("Dock to bottom of window"), "Images/DockBottom.svg", 16, 16);
+        WI._dockBottomTabBarButton.element.classList.add(WI.Popover.IgnoreAutoDismissClassName);
+        WI._dockBottomTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._dockBottom);
+        dockingConfigurationNavigationItems.push(WI._dockBottomTabBarButton);
+    }
+
+    if (InspectorFrontendHost.supportsDockSide(WI.DockConfiguration.Undocked)) {
+        WI._undockTabBarButton = new WI.ButtonNavigationItem("undock", WI.UIString("Detach into separate window"), "Images/Undock.svg", 16, 16);
+        WI._undockTabBarButton.element.classList.add(WI.Popover.IgnoreAutoDismissClassName);
+        WI._undockTabBarButton.addEventListener(WI.ButtonNavigationItem.Event.Clicked, WI._undock);
+        dockingConfigurationNavigationItems.push(WI._undockTabBarButton);
+    }
 
     let inspectedPageControlNavigationItems = [];
 
@@ -417,9 +428,7 @@ WI.contentLoaded = function()
 
     WI.tabBar.addNavigationItemBefore(new WI.GroupNavigationItem([
         WI._closeTabBarButton,
-        WI._dockToSideTabBarButton,
-        WI._dockBottomTabBarButton,
-        WI._undockTabBarButton,
+        ...dockingConfigurationNavigationItems,
         ...inspectedPageControlNavigationItems,
     ]));
 
@@ -460,7 +469,10 @@ WI.contentLoaded = function()
 
     WI._dockedResizerElement = document.getElementById("docked-resizer");
     WI._dockedResizerElement.classList.add(WI.Popover.IgnoreAutoDismissClassName);
-    WI._dockedResizerElement.addEventListener("mousedown", WI._dockedResizerMouseDown);
+    WI._dockedResizerElement.addEventListener("mousedown", WI._handleDockedResizerMouseDown);
+
+    let undockedTitleAreaElement = document.getElementById("undocked-title-area");
+    undockedTitleAreaElement.addEventListener("mousedown", WI._handleUndockedTitleAreaMouseDown);
 
     WI._dockingAvailable = false;
 
@@ -833,10 +845,10 @@ WI.updateDockingAvailability = function(available)
 
 WI.updateDockedState = function(side)
 {
-    if (WI._dockConfiguration === side)
+    if (WI.dockConfiguration === side)
         return;
 
-    WI._previousDockConfiguration = WI._dockConfiguration;
+    WI._previousDockConfiguration = WI.dockConfiguration;
 
     if (!WI._previousDockConfiguration) {
         if (side === WI.DockConfiguration.Right || side === WI.DockConfiguration.Left)
@@ -845,21 +857,28 @@ WI.updateDockedState = function(side)
             WI._previousDockConfiguration = WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL ? WI.DockConfiguration.Left : WI.DockConfiguration.Right;
     }
 
-    WI._dockConfiguration = side;
+    WI.dockConfiguration = side;
 
-    WI.docked = side !== WI.DockConfiguration.Undocked;
-
-    if (side === WI.DockConfiguration.Bottom) {
+    switch (WI.dockConfiguration) {
+    case WI.DockConfiguration.Bottom:
         document.body.classList.add("docked", WI.DockConfiguration.Bottom);
         document.body.classList.remove("window-inactive", WI.DockConfiguration.Right, WI.DockConfiguration.Left);
-    } else if (side === WI.DockConfiguration.Right) {
+        break;
+
+    case WI.DockConfiguration.Right:
         document.body.classList.add("docked", WI.DockConfiguration.Right);
         document.body.classList.remove("window-inactive", WI.DockConfiguration.Bottom, WI.DockConfiguration.Left);
-    } else if (side === WI.DockConfiguration.Left) {
+        break;
+
+    case WI.DockConfiguration.Left:
         document.body.classList.add("docked", WI.DockConfiguration.Left);
         document.body.classList.remove("window-inactive", WI.DockConfiguration.Bottom, WI.DockConfiguration.Right);
-    } else
+        break;
+
+    default:
         document.body.classList.remove("docked", WI.DockConfiguration.Right, WI.DockConfiguration.Left, WI.DockConfiguration.Bottom);
+        break;
+    }
 
     WI._updateDockNavigationItems();
 
@@ -867,6 +886,123 @@ WI.updateDockedState = function(side)
         WI.hideSplitConsole();
 };
 
+WI.resizeDockedFrameMouseDown = function(event)
+{
+    console.assert(WI.dockConfiguration !== WI.DockConfiguration.Undocked);
+
+    if (event.button !== 0 || event.ctrlKey)
+        return;
+
+    event[WI.Popover.EventPreventDismissSymbol] = true;
+
+    let isDockedBottom = WI.dockConfiguration === WI.DockConfiguration.Bottom;
+
+    let windowProperty = isDockedBottom ? "innerHeight" : "innerWidth";
+    let eventScreenProperty = isDockedBottom ? "screenY" : "screenX";
+    let eventClientProperty = isDockedBottom ? "clientY" : "clientX";
+
+    let resizerElement = event.target;
+    let firstClientPosition = event[eventClientProperty];
+    let lastScreenPosition = event[eventScreenProperty];
+
+    function dividerDrag(event)
+    {
+        if (event.button !== 0)
+            return;
+
+        let position = event[eventScreenProperty];
+        let delta = position - lastScreenPosition;
+        let clientPosition = event[eventClientProperty];
+
+        lastScreenPosition = position;
+
+        if (WI.dockConfiguration === WI.DockConfiguration.Left) {
+            // If the mouse is travelling rightward but is positioned left of the resizer, ignore the event.
+            if (delta > 0 && clientPosition < firstClientPosition)
+                return;
+
+            // If the mouse is travelling leftward but is positioned to the right of the resizer, ignore the event.
+            if (delta < 0 && clientPosition > window[windowProperty])
+                return;
+
+            // We later subtract the delta from the current position, but since the inspected view and inspector view
+            // are flipped when docked to left, we want dragging to have the opposite effect from docked to right.
+            delta *= -1;
+        } else {
+            // If the mouse is travelling downward/rightward but is positioned above/left of the resizer, ignore the event.
+            if (delta > 0 && clientPosition < firstClientPosition)
+                return;
+
+            // If the mouse is travelling upward/leftward but is positioned below/right of the resizer, ignore the event.
+            if (delta < 0 && clientPosition > firstClientPosition)
+                return;
+        }
+
+        let dimension = Math.max(0, window[windowProperty] - delta);
+        // If zoomed in/out, there be greater/fewer document pixels shown, but the inspector's
+        // width or height should be the same in device pixels regardless of the document zoom.
+        dimension *= WI.getZoomFactor();
+
+        if (isDockedBottom)
+            InspectorFrontendHost.setAttachedWindowHeight(dimension);
+        else
+            InspectorFrontendHost.setAttachedWindowWidth(dimension);
+    }
+
+    function elementDragEnd(event)
+    {
+        if (event.button !== 0)
+            return;
+
+        WI.elementDragEnd(event);
+    }
+
+    let cursor = isDockedBottom ? "row-resize" : "col-resize";
+    WI.elementDragStart(resizerElement, dividerDrag, elementDragEnd, event, cursor);
+};
+
+WI.moveUndockedWindowMouseDown = function(event)
+{
+    console.assert(WI.dockConfiguration === WI.DockConfiguration.Undocked);
+
+    if (event.button !== 0 || event.ctrlKey)
+        return;
+
+    event[WI.Popover.EventPreventDismissSymbol] = true;
+
+    if (WI.Platform.name === "mac") {
+        InspectorFrontendHost.startWindowDrag();
+        event.preventDefault();
+        return;
+    }
+
+    let lastScreenX = event.screenX;
+    let lastScreenY = event.screenY;
+
+    function dividerDrag(event) {
+        if (event.button !== 0)
+            return;
+
+        let x = event.screenX - lastScreenX;
+        let y = event.screenY - lastScreenY;
+
+        InspectorFrontendHost.moveWindowBy(x, y);
+
+        lastScreenX = event.screenX;
+        lastScreenY = event.screenY;
+    }
+
+    function elementDragEnd(event) {
+        if (event.button !== 0)
+            return;
+
+        WI.elementDragEnd(event);
+    }
+
+    const cursor = "default";
+    WI.elementDragStart(event.target, dividerDrag, elementDragEnd, event, cursor);
+};
+
 WI.updateVisibilityState = function(visible)
 {
     WI.visible = visible;
@@ -967,7 +1103,7 @@ WI.isShowingSplitConsole = function()
 
 WI.dockedConfigurationSupportsSplitContentBrowser = function()
 {
-    return WI._dockConfiguration !== WI.DockConfiguration.Bottom;
+    return WI.dockConfiguration !== WI.DockConfiguration.Bottom;
 };
 
 WI.doesCurrentTabSupportSplitContentBrowser = function()
@@ -1588,7 +1724,7 @@ WI._windowFocused = function(event)
         return;
 
     // FIXME: We should use the :window-inactive pseudo class once https://webkit.org/b/38927 is fixed.
-    document.body.classList.remove(WI.docked ? "window-docked-inactive" : "window-inactive");
+    document.body.classList.remove(WI.dockConfiguration === WI.DockConfiguration.Undocked ? "window-inactive" : "window-docked-inactive");
 };
 
 WI._windowBlurred = function(event)
@@ -1597,7 +1733,7 @@ WI._windowBlurred = function(event)
         return;
 
     // FIXME: We should use the :window-inactive pseudo class once https://webkit.org/b/38927 is fixed.
-    document.body.classList.add(WI.docked ? "window-docked-inactive" : "window-inactive");
+    document.body.classList.add(WI.dockConfiguration === WI.DockConfiguration.Undocked ? "window-inactive" : "window-docked-inactive");
 };
 
 WI._windowResized = function(event)
@@ -1728,16 +1864,24 @@ WI._togglePreviousDockConfiguration = function(event)
 
 WI._updateDockNavigationItems = function()
 {
-    if (WI._dockingAvailable || WI.docked) {
-        WI._closeTabBarButton.hidden = !WI.docked;
-        WI._undockTabBarButton.hidden = WI._dockConfiguration === WI.DockConfiguration.Undocked;
-        WI._dockBottomTabBarButton.hidden = WI._dockConfiguration === WI.DockConfiguration.Bottom;
-        WI._dockToSideTabBarButton.hidden = WI._dockConfiguration === WI.DockConfiguration.Right || WI._dockConfiguration === WI.DockConfiguration.Left;
+    let docked = WI.dockConfiguration !== WI.DockConfiguration.Undocked;
+
+    if (WI._dockingAvailable || docked) {
+        WI._closeTabBarButton.hidden = !docked;
+        if (WI._dockToSideTabBarButton)
+            WI._dockToSideTabBarButton.hidden = WI.dockConfiguration === WI.DockConfiguration.Right || WI.dockConfiguration === WI.DockConfiguration.Left;
+        if (WI._dockBottomTabBarButton)
+            WI._dockBottomTabBarButton.hidden = WI.dockConfiguration === WI.DockConfiguration.Bottom;
+        if (WI._undockTabBarButton)
+            WI._undockTabBarButton.hidden = WI.dockConfiguration === WI.DockConfiguration.Undocked;
     } else {
         WI._closeTabBarButton.hidden = true;
-        WI._undockTabBarButton.hidden = true;
-        WI._dockBottomTabBarButton.hidden = true;
-        WI._dockToSideTabBarButton.hidden = true;
+        if (WI._dockToSideTabBarButton)
+            WI._dockToSideTabBarButton.hidden = true;
+        if (WI._dockBottomTabBarButton)
+            WI._dockBottomTabBarButton.hidden = true;
+        if (WI._undockTabBarButton)
+            WI._undockTabBarButton.hidden = true;
     }
 
     WI._updateTabBarDividers();
@@ -1795,81 +1939,14 @@ WI._tabBrowserSelectedTabContentViewDidChange = function(event)
     WI.hideSplitConsole();
 };
 
-WI._dockedResizerMouseDown = function(event)
+WI._handleDockedResizerMouseDown = function(event)
 {
-    if (event.button !== 0 || event.ctrlKey)
-        return;
-
-    if (!WI.docked)
-        return;
-
-    // Only start dragging if the target is one of the elements that we expect.
-    if (event.target !== WI._dockedResizerElement)
-        return;
-
-    event[WI.Popover.EventPreventDismissSymbol] = true;
-
-    let windowProperty = WI._dockConfiguration === WI.DockConfiguration.Bottom ? "innerHeight" : "innerWidth";
-    let eventScreenProperty = WI._dockConfiguration === WI.DockConfiguration.Bottom ? "screenY" : "screenX";
-    let eventClientProperty = WI._dockConfiguration === WI.DockConfiguration.Bottom ? "clientY" : "clientX";
-
-    var resizerElement = event.target;
-    var firstClientPosition = event[eventClientProperty];
-    var lastScreenPosition = event[eventScreenProperty];
-
-    function dockedResizerDrag(event)
-    {
-        if (event.button !== 0)
-            return;
-
-        var position = event[eventScreenProperty];
-        var delta = position - lastScreenPosition;
-        var clientPosition = event[eventClientProperty];
-
-        lastScreenPosition = position;
-
-        if (WI._dockConfiguration === WI.DockConfiguration.Left) {
-            // If the mouse is travelling rightward but is positioned left of the resizer, ignore the event.
-            if (delta > 0 && clientPosition < firstClientPosition)
-                return;
-
-            // If the mouse is travelling leftward but is positioned to the right of the resizer, ignore the event.
-            if (delta < 0 && clientPosition > window[windowProperty])
-                return;
-
-            // We later subtract the delta from the current position, but since the inspected view and inspector view
-            // are flipped when docked to left, we want dragging to have the opposite effect from docked to right.
-            delta *= -1;
-        } else {
-            // If the mouse is travelling downward/rightward but is positioned above/left of the resizer, ignore the event.
-            if (delta > 0 && clientPosition < firstClientPosition)
-                return;
-
-            // If the mouse is travelling upward/leftward but is positioned below/right of the resizer, ignore the event.
-            if (delta < 0 && clientPosition > firstClientPosition)
-                return;
-        }
-
-        let dimension = Math.max(0, window[windowProperty] - delta);
-        // If zoomed in/out, there be greater/fewer document pixels shown, but the inspector's
-        // width or height should be the same in device pixels regardless of the document zoom.
-        dimension *= WI.getZoomFactor();
-
-        if (WI._dockConfiguration === WI.DockConfiguration.Bottom)
-            InspectorFrontendHost.setAttachedWindowHeight(dimension);
-        else
-            InspectorFrontendHost.setAttachedWindowWidth(dimension);
-    }
-
-    function dockedResizerDragEnd(event)
-    {
-        if (event.button !== 0)
-            return;
-
-        WI.elementDragEnd(event);
-    }
+    WI.resizeDockedFrameMouseDown(event);
+};
 
-    WI.elementDragStart(resizerElement, dockedResizerDrag, dockedResizerDragEnd, event, WI._dockConfiguration === WI.DockConfiguration.Bottom ? "row-resize" : "col-resize");
+WI._handleUndockedTitleAreaMouseDown = function(event)
+{
+    WI.moveUndockedWindowMouseDown(event);
 };
 
 WI._domStorageWasInspected = function(event)
@@ -2256,9 +2333,9 @@ WI._updateInspectModeTabBarButton = function()
 WI._updateTabBarDividers = function()
 {
     let closeHidden = WI._closeTabBarButton.hidden;
-    let dockToSideHidden = WI._dockToSideTabBarButton.hidden;
-    let dockBottomHidden = WI._dockBottomTabBarButton.hidden;
-    let undockHidden = WI._undockTabBarButton.hidden;
+    let dockToSideHidden = WI._dockToSideTabBarButton?.hidden;
+    let dockBottomHidden = WI._dockBottomTabBarButton?.hidden;
+    let undockHidden = WI._undockTabBarButton?.hidden;
 
     let inspectModeHidden = WI._inspectModeTabBarButton.hidden;
     let deviceSettingsHidden = WI._deviceSettingsTabBarButton && WI._deviceSettingsTabBarButton.hidden;
@@ -2663,10 +2740,10 @@ WI.setLayoutDirection = function(value)
 
     WI.settings.debugLayoutDirection.value = value;
 
-    if (WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL && WI._dockConfiguration === WI.DockConfiguration.Right)
+    if (WI.resolvedLayoutDirection() === WI.LayoutDirection.RTL && WI.dockConfiguration === WI.DockConfiguration.Right)
         WI._dockLeft();
 
-    if (WI.resolvedLayoutDirection() === WI.LayoutDirection.LTR && WI._dockConfiguration === WI.DockConfiguration.Left)
+    if (WI.resolvedLayoutDirection() === WI.LayoutDirection.LTR && WI.dockConfiguration === WI.DockConfiguration.Left)
         WI._dockRight();
 
     InspectorFrontendHost.reopen();
index e7120a3..5b0f82b 100644 (file)
@@ -125,6 +125,10 @@ body.docked .tab-bar > .tabs > .flexible-space {
     flex-grow: 1;
 }
 
+body.docked.bottom .tab-bar > .tabs > .flexible-space {
+    cursor: row-resize;
+}
+
 .tab-bar > .tabs > .item {
     display: flex;
 
index 8111ee0..8a130c3 100644 (file)
@@ -30,6 +30,7 @@ WI.TabBar = class TabBar extends WI.View
         super(element);
 
         this.element.classList.add("tab-bar");
+        this.element.addEventListener("mousedown", this._handleMouseDown.bind(this));
 
         this.element.createChild("div", "border top");
 
@@ -40,10 +41,10 @@ WI.TabBar = class TabBar extends WI.View
         this._tabContainer = this.element.appendChild(document.createElement("div"));
         this._tabContainer.className = "tabs";
         this._tabContainer.setAttribute("role", "tablist");
-        this._tabContainer.addEventListener("mousedown", this._handleMouseDown.bind(this));
-        this._tabContainer.addEventListener("click", this._handleClick.bind(this));
-        this._tabContainer.addEventListener("mouseleave", this._handleMouseLeave.bind(this));
-        this._tabContainer.addEventListener("contextmenu", this._handleContextMenu.bind(this));
+        this._tabContainer.addEventListener("mousedown", this._handleTabContainerMouseDown.bind(this));
+        this._tabContainer.addEventListener("click", this._handleTabContainerClick.bind(this));
+        this._tabContainer.addEventListener("mouseleave", this._handleTabContainerMouseLeave.bind(this));
+        this._tabContainer.addEventListener("contextmenu", this._handleTabContainerContextMenu.bind(this));
 
         this._flexibleSpaceBeforeElement = this._tabContainer.appendChild(document.createElement("div"));
         this._flexibleSpaceBeforeElement.className = "flexible-space";
@@ -71,7 +72,7 @@ WI.TabBar = class TabBar extends WI.View
 
     static get horizontalPadding()
     {
-        return WI.docked ? 8 : 0; // Keep in sync with `body.docked .tab-bar .tabs`
+        return (WI.dockConfiguration !== WI.DockConfiguration.Undocked) ? 8 : 0; // Keep in sync with `body.docked .tab-bar .tabs`
     }
 
     // Public
@@ -640,6 +641,25 @@ WI.TabBar = class TabBar extends WI.View
 
     _handleMouseDown(event)
     {
+        if (event.button !== 0 || event.ctrlKey)
+            return;
+
+        if (event.target !== this.element && event.target !== this._flexibleSpaceBeforeElement && event.target !== this._flexibleSpaceAfterElement)
+            return;
+
+        switch (WI.dockConfiguration) {
+        case WI.DockConfiguration.Bottom:
+            WI.resizeDockedFrameMouseDown(event);
+            break;
+
+        case WI.DockConfiguration.Undocked:
+            WI.moveUndockedWindowMouseDown(event);
+            break;
+        }
+    }
+
+    _handleTabContainerMouseDown(event)
+    {
         // Only consider left mouse clicks for tab movement.
         if (event.button !== 0 || event.ctrlKey)
             return;
@@ -710,7 +730,7 @@ WI.TabBar = class TabBar extends WI.View
         event.stopPropagation();
     }
 
-    _handleClick(event)
+    _handleTabContainerClick(event)
     {
         var itemElement = event.target.closest("." + WI.TabBarItem.StyleClassName);
         if (!itemElement)
@@ -880,7 +900,7 @@ WI.TabBar = class TabBar extends WI.View
         this.dispatchEventToListeners(WI.TabBar.Event.TabBarItemsReordered);
     }
 
-    _handleMouseLeave(event)
+    _handleTabContainerMouseLeave(event)
     {
         if (this._mouseIsDown || !this._tabAnimatedClosedSinceMouseEnter || !this._tabContainer.classList.contains("static-layout") || this._tabContainer.classList.contains("animating"))
             return;
@@ -895,7 +915,7 @@ WI.TabBar = class TabBar extends WI.View
         this._finishExpandingTabsAfterClose();
     }
 
-    _handleContextMenu(event)
+    _handleTabContainerContextMenu(event)
     {
         let contextMenu = WI.ContextMenu.createFromEvent(event);
 
index fe824db..dccb26f 100644 (file)
@@ -53,7 +53,7 @@ WI.TabBarItem = class TabBarItem
 
     static get horizontalMargin()
     {
-        return WI.docked ? 4 : 0; // Keep in sync with `body.docked .tab-bar > .tabs > .item`
+        return (WI.dockConfiguration !== WI.DockConfiguration.Undocked) ? 4 : 0; // Keep in sync with `body.docked .tab-bar > .tabs > .item`
     }
 
     // Public
index 9c1384b..7f4977f 100644 (file)
@@ -1,3 +1,51 @@
+2020-03-03  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: re-add `InspectorFrontendHost` support for moving the inspected window
+        https://bugs.webkit.org/show_bug.cgi?id=208555
+
+        Reviewed by Timothy Hatcher.
+
+        Partially revert r257759, as the design changed enough such that this code is still useful.
+
+        Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
+        whether it supports the given docking configuration.
+
+        * WebProcess/Inspector/WebInspectorUI.h:
+        * WebProcess/Inspector/WebInspectorUI.cpp:
+        (WebKit::WebInspectorUI::startWindowDrag): Added.
+        (WebKit::WebInspectorUI::moveWindowBy): Added.
+        (WebKit::WebInspectorUI::supportsDockSide): Added.
+        (WebKit::WebInspectorUI::requestSetDockSide):
+        (WebKit::WebInspectorUI::setDockSide):
+        * UIProcess/Inspector/WebInspectorProxy.messages.in:
+        * UIProcess/Inspector/WebInspectorProxy.h:
+        * UIProcess/Inspector/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::startWindowDrag): Added.
+        (WebKit::WebInspectorProxy::platformStartWindowDrag): Added.
+        * UIProcess/Inspector/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::WebInspectorProxy::platformStartWindowDrag): Added.
+        * UIProcess/Inspector/mac/WebInspectorProxyMac.mm:
+        (WebKit::WebInspectorProxy::platformStartWindowDrag): Added.
+        * UIProcess/Inspector/win/WebInspectorProxyWin.cpp:
+        (WebKit::WebInspectorProxy::platformStartWindowDrag): Added.
+
+        * WebProcess/Inspector/RemoteWebInspectorUI.h:
+        * WebProcess/Inspector/RemoteWebInspectorUI.cpp:
+        (WebKit::RemoteWebInspectorUI::startWindowDrag): Added.
+        (WebKit::RemoteWebInspectorUI::moveWindowBy): Added.
+        (WebKit::RemoteWebInspectorUI::supportsDockSide): Added.
+        * UIProcess/Inspector/RemoteWebInspectorProxy.messages.in:
+        * UIProcess/Inspector/RemoteWebInspectorProxy.h:
+        * UIProcess/Inspector/RemoteWebInspectorProxy.cpp:
+        (WebKit::RemoteWebInspectorProxy::startWindowDrag): Added.
+        (WebKit::RemoteWebInspectorProxy::platformStartWindowDrag): Added.
+        * UIProcess/Inspector/gtk/RemoteWebInspectorProxyGtk.cpp:
+        (WebKit::RemoteWebInspectorProxy::platformStartWindowDrag): Added.
+        * UIProcess/Inspector/mac/RemoteWebInspectorProxyMac.mm:
+        (WebKit::RemoteWebInspectorProxy::platformStartWindowDrag): Added.
+        * UIProcess/Inspector/win/RemoteWebInspectorProxyWin.cpp:
+        (WebKit::RemoteWebInspectorProxy::platformStartWindowDrag): Added.
+
 2020-03-03  Alex Christensen  <achristensen@webkit.org>
 
         Add SPI _WKResourceLoadInfo.loadedFromCache
index 4ace413..40f03bf 100644 (file)
@@ -143,6 +143,11 @@ void RemoteWebInspectorProxy::setForcedAppearance(InspectorFrontendClient::Appea
     platformSetForcedAppearance(appearance);
 }
 
+void RemoteWebInspectorProxy::startWindowDrag()
+{
+    platformStartWindowDrag();
+}
+
 void RemoteWebInspectorProxy::openInNewTab(const String& url)
 {
     platformOpenInNewTab(url);
@@ -199,6 +204,7 @@ void RemoteWebInspectorProxy::platformSave(const String&, const String&, bool, b
 void RemoteWebInspectorProxy::platformAppend(const String&, const String&) { }
 void RemoteWebInspectorProxy::platformSetSheetRect(const FloatRect&) { }
 void RemoteWebInspectorProxy::platformSetForcedAppearance(InspectorFrontendClient::Appearance) { }
+void RemoteWebInspectorProxy::platformStartWindowDrag() { }
 void RemoteWebInspectorProxy::platformOpenInNewTab(const String&) { }
 void RemoteWebInspectorProxy::platformShowCertificate(const CertificateInfo&) { }
 void RemoteWebInspectorProxy::platformCloseFrontendPageAndWindow() { }
index 763e691..2137575 100644 (file)
@@ -120,6 +120,7 @@ private:
     void append(const String& filename, const String& content);
     void setSheetRect(const WebCore::FloatRect&);
     void setForcedAppearance(WebCore::InspectorFrontendClient::Appearance);
+    void startWindowDrag();
     void openInNewTab(const String& url);
     void showCertificate(const WebCore::CertificateInfo&);
     void sendMessageToBackend(const String& message);
@@ -136,6 +137,7 @@ private:
     void platformAppend(const String& filename, const String& content);
     void platformSetSheetRect(const WebCore::FloatRect&);
     void platformSetForcedAppearance(WebCore::InspectorFrontendClient::Appearance);
+    void platformStartWindowDrag();
     void platformOpenInNewTab(const String& url);
     void platformShowCertificate(const WebCore::CertificateInfo&);
 
index 33203ea..64f3812 100644 (file)
@@ -33,6 +33,8 @@ messages -> RemoteWebInspectorProxy {
 
     SetSheetRect(WebCore::FloatRect rect)
 
+    StartWindowDrag()
+
     OpenInNewTab(String url)
     ShowCertificate(WebCore::CertificateInfo certificateInfo)
 
index d610801..fa81665 100644 (file)
@@ -352,6 +352,11 @@ void WebInspectorProxy::setSheetRect(const FloatRect& rect)
     platformSetSheetRect(rect);
 }
 
+void WebInspectorProxy::startWindowDrag()
+{
+    platformStartWindowDrag();
+}
+
 void WebInspectorProxy::togglePageProfiling()
 {
     if (!m_inspectedPage)
@@ -786,6 +791,11 @@ void WebInspectorProxy::platformSetSheetRect(const FloatRect&)
     notImplemented();
 }
 
+void WebInspectorProxy::platformStartWindowDrag()
+{
+    notImplemented();
+}
+
 String WebInspectorProxy::inspectorPageURL()
 {
     notImplemented();
index 2d113cb..f42be4f 100644 (file)
@@ -151,6 +151,8 @@ public:
 
     void setSheetRect(const WebCore::FloatRect&);
 
+    void startWindowDrag();
+
     bool isProfilingPage() const { return m_isProfilingPage; }
     void togglePageProfiling();
 
@@ -213,6 +215,7 @@ private:
     void platformSetAttachedWindowHeight(unsigned);
     void platformSetAttachedWindowWidth(unsigned);
     void platformSetSheetRect(const WebCore::FloatRect&);
+    void platformStartWindowDrag();
     void platformSave(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
     void platformAppend(const String& filename, const String& content);
 
index b336b1c..84a630a 100644 (file)
@@ -55,4 +55,6 @@ messages -> WebInspectorProxy {
     SetAttachedWindowWidth(unsigned width)
 
     SetSheetRect(WebCore::FloatRect rect)
+
+    StartWindowDrag()
 }
index 3442951..78f61f0 100644 (file)
@@ -161,6 +161,10 @@ void RemoteWebInspectorProxy::platformSetForcedAppearance(InspectorFrontendClien
 {
 }
 
+void RemoteWebInspectorProxy::platformStartWindowDrag()
+{
+}
+
 void RemoteWebInspectorProxy::platformOpenInNewTab(const String&)
 {
 }
index 81e26ab..8ad92ed 100644 (file)
@@ -466,6 +466,11 @@ void WebInspectorProxy::platformSetSheetRect(const WebCore::FloatRect&)
     notImplemented();
 }
 
+void WebInspectorProxy::platformStartWindowDrag()
+{
+    notImplemented();
+}
+
 static void fileReplaceContentsCallback(GObject* sourceObject, GAsyncResult* result, gpointer userData)
 {
     GFile* file = G_FILE(sourceObject);
index e1d248a..514fd4a 100644 (file)
@@ -245,6 +245,11 @@ void RemoteWebInspectorProxy::platformSetForcedAppearance(InspectorFrontendClien
     }
 }
 
+void RemoteWebInspectorProxy::platformStartWindowDrag()
+{
+    webView()->_page->startWindowDrag();
+}
+
 void RemoteWebInspectorProxy::platformOpenInNewTab(const String& url)
 {
     [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:url]];
index f6d55b2..6b31de5 100644 (file)
@@ -742,6 +742,11 @@ void WebInspectorProxy::platformSetSheetRect(const FloatRect& rect)
     m_sheetRect = rect;
 }
 
+void WebInspectorProxy::platformStartWindowDrag()
+{
+    [m_inspectorViewController webView]->_page->startWindowDrag();
+}
+
 String WebInspectorProxy::inspectorPageURL()
 {
     NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebInspectorUI"];
index bdacb35..01ff869 100644 (file)
@@ -136,6 +136,7 @@ void RemoteWebInspectorProxy::platformSave(const String&, const String&, bool, b
 void RemoteWebInspectorProxy::platformAppend(const String&, const String&) { }
 void RemoteWebInspectorProxy::platformSetSheetRect(const WebCore::FloatRect&) { }
 void RemoteWebInspectorProxy::platformSetForcedAppearance(WebCore::InspectorFrontendClient::Appearance) { }
+void RemoteWebInspectorProxy::platformStartWindowDrag() { }
 void RemoteWebInspectorProxy::platformOpenInNewTab(const String&) { }
 void RemoteWebInspectorProxy::platformShowCertificate(const WebCore::CertificateInfo&) { }
 
index ebd7cf3..b748941 100644 (file)
@@ -456,4 +456,9 @@ void WebInspectorProxy::platformInvalidate()
     notImplemented();
 }
 
+void WebInspectorProxy::platformStartWindowDrag()
+{
+    notImplemented();
+}
+
 }
index 146a162..5fcc9f8 100644 (file)
@@ -115,11 +115,39 @@ void RemoteWebInspectorUI::setForcedAppearance(WebCore::InspectorFrontendClient:
     WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::SetForcedAppearance(appearance), m_page.identifier());
 }
 
+void RemoteWebInspectorUI::startWindowDrag()
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::StartWindowDrag(), m_page.identifier());
+}
+
+void RemoteWebInspectorUI::moveWindowBy(float x, float y)
+{
+    FloatRect frameRect = m_page.corePage()->chrome().windowRect();
+    frameRect.move(x, y);
+    m_page.corePage()->chrome().setWindowRect(frameRect);
+}
+
 WebCore::UserInterfaceLayoutDirection RemoteWebInspectorUI::userInterfaceLayoutDirection() const
 {
     return m_page.corePage()->userInterfaceLayoutDirection();
 }
 
+bool RemoteWebInspectorUI::supportsDockSide(DockSide dockSide)
+{
+    switch (dockSide) {
+    case DockSide::Undocked:
+        return true;
+
+    case DockSide::Right:
+    case DockSide::Left:
+    case DockSide::Bottom:
+        return false;
+    }
+
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 void RemoteWebInspectorUI::bringToFront()
 {
     WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::BringToFront(), m_page.identifier());
index cca987b..667a657 100644 (file)
@@ -62,6 +62,8 @@ public:
     void windowObjectCleared() override;
     void frontendLoaded() override;
     void changeSheetRect(const WebCore::FloatRect&) override;
+    void startWindowDrag() override;
+    void moveWindowBy(float x, float y) override;
 
     bool isRemote() const final { return true; }
     String localizedStringsURL() const override;
@@ -76,6 +78,8 @@ public:
 
     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() const override;
 
+    bool supportsDockSide(DockSide) override;
+
     void bringToFront() override;
     void closeWindow() override;
     void reopen() override;
index c1f3360..c5c5b76 100644 (file)
@@ -137,6 +137,18 @@ void WebInspectorUI::frontendLoaded()
     bringToFront();
 }
 
+void WebInspectorUI::startWindowDrag()
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::StartWindowDrag(), m_inspectedPageIdentifier);
+}
+
+void WebInspectorUI::moveWindowBy(float x, float y)
+{
+    FloatRect frameRect = m_page.corePage()->chrome().windowRect();
+    frameRect.move(x, y);
+    m_page.corePage()->chrome().setWindowRect(frameRect);
+}
+
 void WebInspectorUI::bringToFront()
 {
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::BringToFront(), m_inspectedPageIdentifier);
@@ -183,10 +195,24 @@ WebCore::UserInterfaceLayoutDirection WebInspectorUI::userInterfaceLayoutDirecti
     return m_page.corePage()->userInterfaceLayoutDirection();
 }
 
-void WebInspectorUI::requestSetDockSide(DockSide side)
+bool WebInspectorUI::supportsDockSide(DockSide dockSide)
+{
+    switch (dockSide) {
+    case DockSide::Undocked:
+    case DockSide::Right:
+    case DockSide::Left:
+    case DockSide::Bottom:
+        return true;
+    }
+
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
+void WebInspectorUI::requestSetDockSide(DockSide dockSide)
 {
     auto& webProcess = WebProcess::singleton();
-    switch (side) {
+    switch (dockSide) {
     case DockSide::Undocked:
         webProcess.parentProcessConnection()->send(Messages::WebInspectorProxy::Detach(), m_inspectedPageIdentifier);
         break;
@@ -202,31 +228,31 @@ void WebInspectorUI::requestSetDockSide(DockSide side)
     }
 }
 
-void WebInspectorUI::setDockSide(DockSide side)
+void WebInspectorUI::setDockSide(DockSide dockSide)
 {
-    ASCIILiteral sideString { ASCIILiteral::null() };
+    ASCIILiteral dockSideString { ASCIILiteral::null() };
 
-    switch (side) {
+    switch (dockSide) {
     case DockSide::Undocked:
-        sideString = "undocked"_s;
+        dockSideString = "undocked"_s;
         break;
 
     case DockSide::Right:
-        sideString = "right"_s;
+        dockSideString = "right"_s;
         break;
 
     case DockSide::Left:
-        sideString = "left"_s;
+        dockSideString = "left"_s;
         break;
 
     case DockSide::Bottom:
-        sideString = "bottom"_s;
+        dockSideString = "bottom"_s;
         break;
     }
 
-    m_dockSide = side;
+    m_dockSide = dockSide;
 
-    m_frontendAPIDispatcher.dispatchCommand("setDockSide"_s, String(sideString));
+    m_frontendAPIDispatcher.dispatchCommand("setDockSide"_s, String(dockSideString));
 }
 
 void WebInspectorUI::setDockingUnavailable(bool unavailable)
index 2fd851b..c6b8715 100644 (file)
@@ -92,6 +92,9 @@ public:
     void windowObjectCleared() override;
     void frontendLoaded() override;
 
+    void startWindowDrag() override;
+    void moveWindowBy(float x, float y) override;
+
     bool isRemote() const final { return false; }
     String localizedStringsURL() const override;
     String backendCommandsURL() const final { return String(); }
@@ -111,6 +114,7 @@ public:
 
     WebCore::UserInterfaceLayoutDirection userInterfaceLayoutDirection() const override;
 
+    bool supportsDockSide(DockSide) override;
     void requestSetDockSide(DockSide) override;
     void changeAttachedWindowHeight(unsigned) override;
     void changeAttachedWindowWidth(unsigned) override;
index a4f1c59..1598ea6 100644 (file)
@@ -1,5 +1,21 @@
 2020-03-03  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: re-add `InspectorFrontendHost` support for moving the inspected window
+        https://bugs.webkit.org/show_bug.cgi?id=208555
+
+        Reviewed by Timothy Hatcher.
+
+        Partially revert r257759, as the design changed enough such that this code is still useful.
+
+        Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
+        whether it supports the given docking configuration.
+
+        * WebCoreSupport/WebInspectorClientIOS.mm:
+        (WebInspectorFrontendClient::supportsDockSide): Added.
+        (WebInspectorFrontendClient::startWindowDrag): Added.
+
+2020-03-03  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: setting the frontend appearance doesn't update the window when undocked
         https://bugs.webkit.org/show_bug.cgi?id=208503
 
index 07fef8a..f537d95 100644 (file)
@@ -129,11 +129,13 @@ void WebInspectorFrontendClient::closeWindow() { }
 void WebInspectorFrontendClient::reopen() { }
 void WebInspectorFrontendClient::resetState() { }
 void WebInspectorFrontendClient::setForcedAppearance(InspectorFrontendClient::Appearance) { }
+bool WebInspectorFrontendClient::supportsDockSide(DockSide) { return false; }
 void WebInspectorFrontendClient::attachWindow(DockSide) { }
 void WebInspectorFrontendClient::detachWindow() { }
 void WebInspectorFrontendClient::setAttachedWindowHeight(unsigned) { }
 void WebInspectorFrontendClient::setAttachedWindowWidth(unsigned) { }
 void WebInspectorFrontendClient::setSheetRect(const FloatRect&) { }
+void WebInspectorFrontendClient::startWindowDrag() { }
 void WebInspectorFrontendClient::inspectedURLChanged(const String&) { }
 void WebInspectorFrontendClient::showCertificate(const CertificateInfo&) { }
 void WebInspectorFrontendClient::updateWindowTitle() const { }
index 4f60987..167ffc7 100644 (file)
@@ -1,5 +1,22 @@
 2020-03-03  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: re-add `InspectorFrontendHost` support for moving the inspected window
+        https://bugs.webkit.org/show_bug.cgi?id=208555
+
+        Reviewed by Timothy Hatcher.
+
+        Partially revert r257759, as the design changed enough such that this code is still useful.
+
+        Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
+        whether it supports the given docking configuration.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        * WebCoreSupport/WebInspectorClient.mm:
+        (WebInspectorFrontendClient::startWindowDrag): Added.
+        (WebInspectorFrontendClient::supportsDockSide): Added.
+
+2020-03-03  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: setting the frontend appearance doesn't update the window when undocked
         https://bugs.webkit.org/show_bug.cgi?id=208503
 
index ec8e220..30ea298 100644 (file)
@@ -116,6 +116,8 @@ public:
 
     void frontendLoaded() override;
 
+    void startWindowDrag() override;
+
     String localizedStringsURL() const override;
     Inspector::DebuggableType debuggableType() const final { return Inspector::DebuggableType::Page; };
     String targetPlatformName() const final { return "macOS"_s; };
@@ -131,6 +133,7 @@ public:
 
     void setForcedAppearance(InspectorFrontendClient::Appearance) override;
 
+    bool supportsDockSide(DockSide) override;
     void attachWindow(DockSide) override;
     void detachWindow() override;
 
index 5e626f9..66f6672 100644 (file)
@@ -216,6 +216,11 @@ void WebInspectorFrontendClient::frontendLoaded()
     setAttachedWindow(attached ? DockSide::Bottom : DockSide::Undocked);
 }
 
+void WebInspectorFrontendClient::startWindowDrag()
+{
+    [[m_frontendWindowController window] performWindowDragWithEvent:[NSApp currentEvent]];
+}
+
 String WebInspectorFrontendClient::localizedStringsURL() const
 {
     NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.apple.WebInspectorUI"];
@@ -284,6 +289,22 @@ void WebInspectorFrontendClient::setForcedAppearance(InspectorFrontendClient::Ap
     }
 }
 
+bool WebInspectorFrontendClient::supportsDockSide(DockSide dockSide)
+{
+    switch (dockSide) {
+    case DockSide::Undocked:
+    case DockSide::Bottom:
+        return true;
+
+    case DockSide::Right:
+    case DockSide::Left:
+        return false;
+    }
+
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 void WebInspectorFrontendClient::attachWindow(DockSide)
 {
     if ([m_frontendWindowController.get() attached])
index f2807cc..87ffa5e 100644 (file)
@@ -1,3 +1,19 @@
+2020-03-03  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: re-add `InspectorFrontendHost` support for moving the inspected window
+        https://bugs.webkit.org/show_bug.cgi?id=208555
+
+        Reviewed by Timothy Hatcher.
+
+        Partially revert r257759, as the design changed enough such that this code is still useful.
+
+        Allow the Web Inspector frontend to ask the containing app (via `InspectorFrontendClient`)
+        whether it supports the given docking configuration.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        * WebCoreSupport/WebInspectorClient.cpp:
+        (WebInspectorFrontendClient::supportsDockSide): Added.
+
 2020-03-03  Per Arne Vollan  <pvollan@apple.com>
 
         [Win] API header file has USE macro
index b6470af..6a45001 100644 (file)
@@ -320,6 +320,22 @@ void WebInspectorFrontendClient::detachWindow()
     showWindowWithoutNotifications();
 }
 
+bool WebInspectorFrontendClient::supportsDockSide(DockSide dockSide)
+{
+    switch (dockSide) {
+    case DockSide::Undocked:
+    case DockSide::Bottom:
+        return true;
+
+    case DockSide::Right:
+    case DockSide::Left:
+        return false;
+    }
+
+    ASSERT_NOT_REACHED();
+    return false;
+}
+
 void WebInspectorFrontendClient::setAttachedWindowHeight(unsigned height)
 {
     if (!m_attached)
index 931acef..2a8849e 100644 (file)
@@ -118,6 +118,7 @@ public:
 
     void setForcedAppearance(InspectorFrontendClient::Appearance) override;
 
+    bool supportsDockSide(DockSide) override;
     void setAttachedWindowHeight(unsigned) override;
     void setAttachedWindowWidth(unsigned) override;