Web Inspector: save sheet should be anchored underneath the tab bar when detached
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2019 02:04:57 +0000 (02:04 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 11 Apr 2019 02:04:57 +0000 (02:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196722
<rdar://problem/49613280>

Reviewed by Timothy Hatcher.

Source/WebCore:

No web observable change.

* inspector/InspectorFrontendClient.h:
(WebCore::InspectorFrontendClient::changeSheetRect): Added.

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

* inspector/InspectorFrontendHost.idl:
* inspector/InspectorFrontendHost.h:
* inspector/InspectorFrontendHost.cpp:
(WebCore::InspectorFrontendHost::setSheetRect): Added.

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

Source/WebInspectorUI:

* UserInterface/Base/Main.js:
(WI.contentLoaded):

Source/WebKit:

* WebProcess/WebPage/WebInspectorUI.h:
* WebProcess/WebPage/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::changeSheetRect): Added.
* UIProcess/WebInspectorProxy.messages.in:
* UIProcess/WebInspectorProxy.h:
(WebKit::WebInspectorProxy::sheetRect const): Added.
* UIProcess/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::setSheetRect): Added.
(WebKit::WebInspectorProxy::platformSetSheetRect): Added.
* UIProcess/gtk/WebInspectorProxyGtk.cpp:
(WebKit::WebInspectorProxy::platformSetSheetRect): Added.
* UIProcess/mac/WebInspectorProxyMac.mm:
(-[WKWebInspectorProxyObjCAdapter window:willPositionSheet:usingRect:]): Added.
(WebKit::WebInspectorProxy::platformSetSheetRect): Added.
* UIProcess/win/WebInspectorProxyWin.cpp:
(WebKit::WebInspectorProxy::platformSetSheetRect): Added.
* UIProcess/wpe/WebInspectorProxyWPE.cpp:
(WebKit::WebInspectorProxy::platformSetSheetRect): Added.

* WebProcess/WebPage/RemoteWebInspectorUI.h:
* WebProcess/WebPage/RemoteWebInspectorUI.cpp:
(WebKit::RemoteWebInspectorUI::changeSheetRect): Added.
* UIProcess/RemoteWebInspectorProxy.messages.in:
* UIProcess/RemoteWebInspectorProxy.h:
(WebKit::RemoteWebInspectorProxy::sheetRect const): Added.
* UIProcess/RemoteWebInspectorProxy.cpp:
(WebKit::RemoteWebInspectorProxy::setSheetRect): Added.
(WebKit::RemoteWebInspectorProxy::platformSetSheetRect): Added.
* UIProcess/gtk/RemoteWebInspectorProxyGtk.cpp:
(WebKit::RemoteWebInspectorProxy::platformSetSheetRect): Added.
* UIProcess/mac/RemoteWebInspectorProxyMac.mm:
(-[WKRemoteWebInspectorProxyObjCAdapter window:willPositionSheet:usingRect:]): Added.
(WebKit::RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow):
(WebKit::RemoteWebInspectorProxy::platformSetSheetRect): Added.

Source/WebKitLegacy/ios:

* WebCoreSupport/WebInspectorClientIOS.mm:
(WebInspectorFrontendClient::setSheetRect): Added.

Source/WebKitLegacy/mac:

* WebCoreSupport/WebInspectorClient.h:
(WebInspectorFrontendClient::sheetRect const): Added.
* WebCoreSupport/WebInspectorClient.mm:
(-[WebInspectorWindowController window:willPositionSheet:usingRect:]):
(WebInspectorFrontendClient::setSheetRect): Added.

Source/WebKitLegacy/win:

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

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

35 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/WebKit/ChangeLog
Source/WebKit/UIProcess/RemoteWebInspectorProxy.cpp
Source/WebKit/UIProcess/RemoteWebInspectorProxy.h
Source/WebKit/UIProcess/RemoteWebInspectorProxy.messages.in
Source/WebKit/UIProcess/WebInspectorProxy.cpp
Source/WebKit/UIProcess/WebInspectorProxy.h
Source/WebKit/UIProcess/WebInspectorProxy.messages.in
Source/WebKit/UIProcess/gtk/RemoteWebInspectorProxyGtk.cpp
Source/WebKit/UIProcess/gtk/WebInspectorProxyGtk.cpp
Source/WebKit/UIProcess/mac/RemoteWebInspectorProxyMac.mm
Source/WebKit/UIProcess/mac/WebInspectorProxyMac.mm
Source/WebKit/UIProcess/win/WebInspectorProxyWin.cpp
Source/WebKit/UIProcess/wpe/WebInspectorProxyWPE.cpp
Source/WebKit/WebProcess/WebPage/RemoteWebInspectorUI.cpp
Source/WebKit/WebProcess/WebPage/RemoteWebInspectorUI.h
Source/WebKit/WebProcess/WebPage/WebInspectorUI.cpp
Source/WebKit/WebProcess/WebPage/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 20461d8..fdd8ef5 100644 (file)
@@ -1,5 +1,30 @@
 2019-04-10  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: save sheet should be anchored underneath the tab bar when detached
+        https://bugs.webkit.org/show_bug.cgi?id=196722
+        <rdar://problem/49613280>
+
+        Reviewed by Timothy Hatcher.
+
+        No web observable change.
+
+        * inspector/InspectorFrontendClient.h:
+        (WebCore::InspectorFrontendClient::changeSheetRect): Added.
+
+        * inspector/InspectorFrontendClientLocal.h:
+        * inspector/InspectorFrontendClientLocal.cpp:
+        (WebCore::InspectorFrontendClientLocal::changeSheetRect): Added.
+
+        * inspector/InspectorFrontendHost.idl:
+        * inspector/InspectorFrontendHost.h:
+        * inspector/InspectorFrontendHost.cpp:
+        (WebCore::InspectorFrontendHost::setSheetRect): Added.
+
+        * testing/Internals.cpp:
+        (WebCore::InspectorStubFrontend::setSheetRect): Added.
+
+2019-04-10  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Inspector: lazily create the agent
         https://bugs.webkit.org/show_bug.cgi?id=195971
         <rdar://problem/49039645>
index 3865988..00ce825 100644 (file)
@@ -37,6 +37,8 @@
 
 namespace WebCore {
 
+class FloatRect;
+
 class InspectorFrontendClient {
 public:
     enum class DockSide {
@@ -70,6 +72,8 @@ public:
     WEBCORE_EXPORT virtual void changeAttachedWindowHeight(unsigned) = 0;
     WEBCORE_EXPORT virtual void changeAttachedWindowWidth(unsigned) = 0;
 
+    WEBCORE_EXPORT virtual void changeSheetRect(const FloatRect&) = 0;
+
     WEBCORE_EXPORT virtual void openInNewTab(const String& url) = 0;
 
     virtual bool canSave() = 0;
index 74120d2..ea6af54 100644 (file)
@@ -223,6 +223,11 @@ void InspectorFrontendClientLocal::changeAttachedWindowWidth(unsigned width)
     setAttachedWindowWidth(attachedWidth);
 }
 
+void InspectorFrontendClientLocal::changeSheetRect(const FloatRect& rect)
+{
+    setSheetRect(rect);
+}
+
 void InspectorFrontendClientLocal::openInNewTab(const String& url)
 {
     UserGestureIndicator indicator { ProcessingUserGesture };
index 5139eee..ae26cca 100644 (file)
@@ -38,6 +38,7 @@
 
 namespace WebCore {
 
+class FloatRect;
 class Frame;
 class InspectorController;
 class InspectorBackendDispatchTask;
@@ -70,6 +71,7 @@ public:
     WEBCORE_EXPORT void requestSetDockSide(DockSide) final;
     WEBCORE_EXPORT void changeAttachedWindowHeight(unsigned) final;
     WEBCORE_EXPORT void changeAttachedWindowWidth(unsigned) final;
+    WEBCORE_EXPORT void changeSheetRect(const FloatRect&) final;
     WEBCORE_EXPORT void openInNewTab(const String& url) final;
     bool canSave()  override { return false; }
     void save(const String&, const String&, bool, bool) override { }
@@ -116,6 +118,8 @@ protected:
     virtual void setAttachedWindowWidth(unsigned) = 0;
     WEBCORE_EXPORT void restoreAttachedWindowHeight();
 
+    virtual void setSheetRect(const WebCore::FloatRect&) = 0;
+
 private:
     bool evaluateAsBoolean(const String& expression);
     void evaluateOnLoad(const String& expression);
index 5368e74..64d1aba 100644 (file)
@@ -39,6 +39,7 @@
 #include "Document.h"
 #include "Editor.h"
 #include "Event.h"
+#include "FloatRect.h"
 #include "FocusController.h"
 #include "Frame.h"
 #include "HitTestResult.h"
@@ -242,6 +243,12 @@ void InspectorFrontendHost::setAttachedWindowWidth(unsigned width)
         m_client->changeAttachedWindowWidth(width);
 }
 
+void InspectorFrontendHost::setSheetRect(float x, float y, unsigned width, unsigned height)
+{
+    if (m_client)
+        m_client->changeSheetRect(FloatRect(x, y, width, height));
+}
+
 void InspectorFrontendHost::startWindowDrag()
 {
     if (m_client)
index 76a6fb4..3017cb7 100644 (file)
@@ -72,6 +72,8 @@ public:
     void setAttachedWindowHeight(unsigned);
     void setAttachedWindowWidth(unsigned);
 
+    void setSheetRect(float x, float y, unsigned width, unsigned height);
+
     void startWindowDrag();
     void moveWindowBy(float x, float y) const;
 
index b1e4deb..023a39c 100644 (file)
@@ -53,6 +53,8 @@
     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);
 
index 4fcd6a7..d129066 100644 (file)
@@ -321,6 +321,7 @@ private:
     void showCertificate(const CertificateInfo&) final { }
     void setAttachedWindowHeight(unsigned) final { }
     void setAttachedWindowWidth(unsigned) final { }
+    void setSheetRect(const FloatRect&) final { }
 
     void sendMessageToFrontend(const String& message) final;
     ConnectionType connectionType() const final { return ConnectionType::Local; }
index b3a371f..8529cbd 100644 (file)
@@ -1,5 +1,16 @@
 2019-04-10  Devin Rousso  <drousso@apple.com>
 
+        Web Inspector: save sheet should be anchored underneath the tab bar when detached
+        https://bugs.webkit.org/show_bug.cgi?id=196722
+        <rdar://problem/49613280>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Base/Main.js:
+        (WI.contentLoaded):
+
+2019-04-10  Devin Rousso  <drousso@apple.com>
+
         Web Inspector: Timelines: can't reliably stop/start a recording
         https://bugs.webkit.org/show_bug.cgi?id=196778
         <rdar://problem/47606798>
index 04cf543..7ba467a 100644 (file)
@@ -582,6 +582,9 @@ WI.contentLoaded = function()
         InspectorFrontendAPI.loadCompleted();
     });
 
+    let mainElementRect = document.getElementById("main").getBoundingClientRect();
+    InspectorFrontendHost.setSheetRect(mainElementRect.x, mainElementRect.y, mainElementRect.width, mainElementRect.height);
+
     // Tell the InspectorFrontendHost we loaded, which causes the window to display
     // and pending InspectorFrontendAPI commands to be sent.
     InspectorFrontendHost.loaded();
index 9f00c64..63b7116 100644 (file)
@@ -1,3 +1,46 @@
+2019-04-10  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: save sheet should be anchored underneath the tab bar when detached
+        https://bugs.webkit.org/show_bug.cgi?id=196722
+        <rdar://problem/49613280>
+
+        Reviewed by Timothy Hatcher.
+
+        * WebProcess/WebPage/WebInspectorUI.h:
+        * WebProcess/WebPage/WebInspectorUI.cpp:
+        (WebKit::WebInspectorUI::changeSheetRect): Added.
+        * UIProcess/WebInspectorProxy.messages.in:
+        * UIProcess/WebInspectorProxy.h:
+        (WebKit::WebInspectorProxy::sheetRect const): Added.
+        * UIProcess/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::setSheetRect): Added.
+        (WebKit::WebInspectorProxy::platformSetSheetRect): Added.
+        * UIProcess/gtk/WebInspectorProxyGtk.cpp:
+        (WebKit::WebInspectorProxy::platformSetSheetRect): Added.
+        * UIProcess/mac/WebInspectorProxyMac.mm:
+        (-[WKWebInspectorProxyObjCAdapter window:willPositionSheet:usingRect:]): Added.
+        (WebKit::WebInspectorProxy::platformSetSheetRect): Added.
+        * UIProcess/win/WebInspectorProxyWin.cpp:
+        (WebKit::WebInspectorProxy::platformSetSheetRect): Added.
+        * UIProcess/wpe/WebInspectorProxyWPE.cpp:
+        (WebKit::WebInspectorProxy::platformSetSheetRect): Added.
+
+        * WebProcess/WebPage/RemoteWebInspectorUI.h:
+        * WebProcess/WebPage/RemoteWebInspectorUI.cpp:
+        (WebKit::RemoteWebInspectorUI::changeSheetRect): Added.
+        * UIProcess/RemoteWebInspectorProxy.messages.in:
+        * UIProcess/RemoteWebInspectorProxy.h:
+        (WebKit::RemoteWebInspectorProxy::sheetRect const): Added.
+        * UIProcess/RemoteWebInspectorProxy.cpp:
+        (WebKit::RemoteWebInspectorProxy::setSheetRect): Added.
+        (WebKit::RemoteWebInspectorProxy::platformSetSheetRect): Added.
+        * UIProcess/gtk/RemoteWebInspectorProxyGtk.cpp:
+        (WebKit::RemoteWebInspectorProxy::platformSetSheetRect): Added.
+        * UIProcess/mac/RemoteWebInspectorProxyMac.mm:
+        (-[WKRemoteWebInspectorProxyObjCAdapter window:willPositionSheet:usingRect:]): Added.
+        (WebKit::RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow):
+        (WebKit::RemoteWebInspectorProxy::platformSetSheetRect): Added.
+
 2019-04-10  Andy Estes  <aestes@apple.com>
 
         [iOS] Let PDFHostViewController specify the background color to use for WKPDFView
index 3c9da53..dbe2ac0 100644 (file)
@@ -117,6 +117,11 @@ void RemoteWebInspectorProxy::append(const String& suggestedURL, const String& c
     platformAppend(suggestedURL, content);
 }
 
+void RemoteWebInspectorProxy::setSheetRect(const FloatRect& rect)
+{
+    platformSetSheetRect(rect);
+}
+
 void RemoteWebInspectorProxy::startWindowDrag()
 {
     platformStartWindowDrag();
@@ -175,6 +180,7 @@ WebPageProxy* RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow()
 void RemoteWebInspectorProxy::platformBringToFront() { }
 void RemoteWebInspectorProxy::platformSave(const String&, const String&, bool, bool) { }
 void RemoteWebInspectorProxy::platformAppend(const String&, const String&) { }
+void RemoteWebInspectorProxy::platformSetSheetRect(const FloatRect&) { }
 void RemoteWebInspectorProxy::platformStartWindowDrag() { }
 void RemoteWebInspectorProxy::platformOpenInNewTab(const String&) { }
 void RemoteWebInspectorProxy::platformShowCertificate(const CertificateInfo&) { }
index 9ecb42b..0fd0e83 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "APIObject.h"
 #include "MessageReceiver.h"
+#include <WebCore/FloatRect.h>
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
@@ -79,6 +80,8 @@ public:
 #if PLATFORM(MAC)
     NSWindow *window() const { return m_window.get(); }
     WKWebView *webView() const;
+
+    const WebCore::FloatRect& sheetRect() const { return m_sheetRect; }
 #endif
 
 #if PLATFORM(GTK)
@@ -99,6 +102,7 @@ private:
     void bringToFront();
     void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
     void append(const String& filename, const String& content);
+    void setSheetRect(const WebCore::FloatRect&);
     void startWindowDrag();
     void openInNewTab(const String& url);
     void showCertificate(const WebCore::CertificateInfo&);
@@ -113,6 +117,7 @@ private:
     void platformBringToFront();
     void platformSave(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
     void platformAppend(const String& filename, const String& content);
+    void platformSetSheetRect(const WebCore::FloatRect&);
     void platformStartWindowDrag();
     void platformOpenInNewTab(const String& url);
     void platformShowCertificate(const WebCore::CertificateInfo&);
@@ -128,6 +133,7 @@ private:
     RetainPtr<NSWindow> m_window;
     RetainPtr<WKRemoteWebInspectorProxyObjCAdapter> m_objCAdapter;
     HashMap<String, RetainPtr<NSURL>> m_suggestedToActualURLMap;
+    WebCore::FloatRect m_sheetRect;
 #endif
 #if PLATFORM(GTK)
     GtkWidget* m_webView { nullptr };
index bc591f4..b787235 100644 (file)
@@ -28,6 +28,8 @@ messages -> RemoteWebInspectorProxy {
     Save(String filename, String content, bool base64Encoded, bool forceSaveAs)
     Append(String filename, String content)
 
+    SetSheetRect(WebCore::FloatRect rect)
+
     StartWindowDrag()
 
     OpenInNewTab(String url)
index 6ed0e08..56dca05 100644 (file)
@@ -325,6 +325,11 @@ void WebInspectorProxy::setAttachedWindowWidth(unsigned width)
     platformSetAttachedWindowWidth(width);
 }
 
+void WebInspectorProxy::setSheetRect(const FloatRect& rect)
+{
+    platformSetSheetRect(rect);
+}
+
 void WebInspectorProxy::startWindowDrag()
 {
     platformStartWindowDrag();
@@ -689,6 +694,11 @@ void WebInspectorProxy::platformSetAttachedWindowHeight(unsigned)
     notImplemented();
 }
 
+void WebInspectorProxy::platformSetSheetRect(const FloatRect&)
+{
+    notImplemented();
+}
+
 void WebInspectorProxy::platformStartWindowDrag()
 {
     notImplemented();
index 9b30582..6aaeb81 100644 (file)
@@ -31,6 +31,7 @@
 #include "MessageReceiver.h"
 #include "WebInspectorUtilities.h"
 #include <JavaScriptCore/InspectorFrontendChannel.h>
+#include <WebCore/FloatRect.h>
 #include <wtf/Forward.h>
 #include <wtf/RefPtr.h>
 #include <wtf/text/WTFString.h>
@@ -120,6 +121,8 @@ public:
     void attachmentViewDidChange(NSView *oldView, NSView *newView);
     void attachmentWillMoveFromWindow(NSWindow *oldWindow);
     void attachmentDidMoveToWindow(NSWindow *newWindow);
+
+    const WebCore::FloatRect& sheetRect() const { return m_sheetRect; }
 #endif
 
 #if PLATFORM(GTK)
@@ -143,6 +146,8 @@ public:
     void setAttachedWindowHeight(unsigned);
     void setAttachedWindowWidth(unsigned);
 
+    void setSheetRect(const WebCore::FloatRect&);
+
     void startWindowDrag();
 
     bool isProfilingPage() const { return m_isProfilingPage; }
@@ -197,6 +202,7 @@ private:
     void platformDetach();
     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);
@@ -266,6 +272,7 @@ private:
     HashMap<String, RetainPtr<NSURL>> m_suggestedToActualURLMap;
     RunLoop::Timer<WebInspectorProxy> m_closeFrontendAfterInactivityTimer;
     String m_urlString;
+    WebCore::FloatRect m_sheetRect;
     bool m_isObservingContentLayoutRect { false };
 #elif PLATFORM(GTK)
     std::unique_ptr<WebInspectorProxyClient> m_client;
index 4cce0ff..1284bd4 100644 (file)
@@ -48,5 +48,7 @@ messages -> WebInspectorProxy {
     SetAttachedWindowHeight(unsigned height)
     SetAttachedWindowWidth(unsigned width)
 
+    SetSheetRect(WebCore::FloatRect rect)
+
     StartWindowDrag()
 }
index 92ead04..c1ac043 100644 (file)
@@ -103,6 +103,10 @@ void RemoteWebInspectorProxy::platformAppend(const String&, const String&)
 {
 }
 
+void RemoteWebInspectorProxy::platformSetSheetRect(const FloatRect&)
+{
+}
+
 void RemoteWebInspectorProxy::platformStartWindowDrag()
 {
 }
index 6972b30..28c2078 100644 (file)
@@ -444,6 +444,11 @@ void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned width)
     webkitWebViewBaseSetInspectorViewSize(WEBKIT_WEB_VIEW_BASE(inspectedPage()->viewWidget()), width);
 }
 
+void WebInspectorProxy::platformSetSheetRect(const WebCore::FloatRect&)
+{
+    notImplemented();
+}
+
 void WebInspectorProxy::platformStartWindowDrag()
 {
     notImplemented();
index 54e6e29..760a1d0 100644 (file)
@@ -43,7 +43,7 @@
 #import <WebCore/CertificateInfo.h>
 #import <wtf/text/Base64.h>
 
-@interface WKRemoteWebInspectorProxyObjCAdapter : NSObject <WKInspectorViewControllerDelegate> {
+@interface WKRemoteWebInspectorProxyObjCAdapter : NSObject <NSWindowDelegate, WKInspectorViewControllerDelegate> {
     WebKit::RemoteWebInspectorProxy* _inspectorProxy;
 }
 - (instancetype)initWithRemoteWebInspectorProxy:(WebKit::RemoteWebInspectorProxy*)inspectorProxy;
 
 @implementation WKRemoteWebInspectorProxyObjCAdapter
 
+- (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect
+{
+    if (_inspectorProxy)
+        return NSMakeRect(0, _inspectorProxy->sheetRect().height(), _inspectorProxy->sheetRect().width(), 0);
+    return rect;
+}
+
 - (instancetype)initWithRemoteWebInspectorProxy:(WebKit::RemoteWebInspectorProxy*)inspectorProxy
 {
     if (!(self = [super init]))
@@ -89,6 +96,7 @@ WebPageProxy* RemoteWebInspectorProxy::platformCreateFrontendPageAndWindow()
     [m_inspectorView.get() setDelegate:m_objCAdapter.get()];
 
     m_window = WebInspectorProxy::createFrontendWindow(NSZeroRect, WebInspectorProxy::InspectionTargetType::Remote);
+    [m_window setDelegate:m_objCAdapter.get()];
     [m_window setFrameAutosaveName:@"WKRemoteWebInspectorWindowFrame"];
 
     NSView *contentView = m_window.get().contentView;
@@ -207,6 +215,11 @@ void RemoteWebInspectorProxy::platformAppend(const String& suggestedURL, const S
     inspectorPage->process().send(Messages::RemoteWebInspectorUI::DidAppend([actualURL absoluteString]), inspectorPage->pageID());
 }
 
+void RemoteWebInspectorProxy::platformSetSheetRect(const FloatRect& rect)
+{
+    m_sheetRect = rect;
+}
+
 void RemoteWebInspectorProxy::platformStartWindowDrag()
 {
     webView()->_page->startWindowDrag();
index 97812ff..be3789a 100644 (file)
@@ -52,7 +52,7 @@ static const Seconds webViewCloseTimeout { 1_min };
 
 static void* kWindowContentLayoutObserverContext = &kWindowContentLayoutObserverContext;
 
-@interface WKWebInspectorProxyObjCAdapter () <WKInspectorViewControllerDelegate>
+@interface WKWebInspectorProxyObjCAdapter () <NSWindowDelegate, WKInspectorViewControllerDelegate>
 
 - (instancetype)initWithWebInspectorProxy:(WebKit::WebInspectorProxy*)inspectorProxy;
 - (void)invalidate;
@@ -93,6 +93,13 @@ static void* kWindowContentLayoutObserverContext = &kWindowContentLayoutObserver
     _inspectorProxy = nullptr;
 }
 
+- (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect
+{
+    if (_inspectorProxy)
+        return NSMakeRect(0, _inspectorProxy->sheetRect().height(), _inspectorProxy->sheetRect().width(), 0);
+    return rect;
+}
+
 - (void)windowDidMove:(NSNotification *)notification
 {
     if (_inspectorProxy)
@@ -714,6 +721,11 @@ void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned width)
     inspectedViewFrameDidChange(width);
 }
 
+void WebInspectorProxy::platformSetSheetRect(const FloatRect& rect)
+{
+    m_sheetRect = rect;
+}
+
 void WebInspectorProxy::platformStartWindowDrag()
 {
     [m_inspectorViewController webView]->_page->startWindowDrag();
index 7b96ee5..a7fcce1 100644 (file)
@@ -358,6 +358,11 @@ void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned width)
     ::SetWindowPos(m_inspectedViewWindow, 0, windowInfo.left, windowInfo.top, windowInfo.parentWidth - windowInfo.left, windowInfo.parentHeight - windowInfo.top, SWP_NOZORDER);
 }
 
+void WebInspectorProxy::platformSetSheetRect(const WebCore::FloatRect&)
+{
+    notImplemented();
+}
+
 bool WebInspectorProxy::platformIsFront()
 {
     notImplemented();
index f0657f4..0f42656 100644 (file)
@@ -134,6 +134,11 @@ void WebInspectorProxy::platformSetAttachedWindowWidth(unsigned)
     notImplemented();
 }
 
+void WebInspectorProxy::platformSetSheetRect(const FloatRect&)
+{
+    notImplemented();
+}
+
 void WebInspectorProxy::platformStartWindowDrag()
 {
     notImplemented();
index f018459..0544045 100644 (file)
@@ -34,6 +34,7 @@
 #include <WebCore/CertificateInfo.h>
 #include <WebCore/Chrome.h>
 #include <WebCore/DOMWrapperWorld.h>
+#include <WebCore/FloatRect.h>
 #include <WebCore/InspectorController.h>
 
 namespace WebKit {
@@ -99,6 +100,11 @@ void RemoteWebInspectorUI::frontendLoaded()
     bringToFront();
 }
 
+void RemoteWebInspectorUI::changeSheetRect(const FloatRect& rect)
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::SetSheetRect(rect), m_page.pageID());
+}
+
 void RemoteWebInspectorUI::startWindowDrag()
 {
     WebProcess::singleton().parentProcessConnection()->send(Messages::RemoteWebInspectorProxy::StartWindowDrag(), m_page.pageID());
index f9b67b3..6213110 100644 (file)
@@ -33,6 +33,7 @@
 
 namespace WebCore {
 class CertificateInfo;
+class FloatRect;
 }
 
 namespace WebKit {
@@ -55,6 +56,7 @@ public:
     // WebCore::InspectorFrontendClient
     void windowObjectCleared() override;
     void frontendLoaded() override;
+    void changeSheetRect(const WebCore::FloatRect&) override;
     void startWindowDrag() override;
     void moveWindowBy(float x, float y) override;
 
index ef26a01..02ccd57 100644 (file)
@@ -34,6 +34,7 @@
 #include <WebCore/CertificateInfo.h>
 #include <WebCore/Chrome.h>
 #include <WebCore/DOMWrapperWorld.h>
+#include <WebCore/FloatRect.h>
 #include <WebCore/InspectorController.h>
 #include <WebCore/NotImplemented.h>
 #include <WebCore/RuntimeEnabledFeatures.h>
@@ -247,6 +248,11 @@ void WebInspectorUI::changeAttachedWindowWidth(unsigned width)
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetAttachedWindowWidth(width), m_inspectedPageIdentifier);
 }
 
+void WebInspectorUI::changeSheetRect(const FloatRect& rect)
+{
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetSheetRect(rect), m_inspectedPageIdentifier);
+}
+
 void WebInspectorUI::openInNewTab(const String& url)
 {
     if (m_backendConnection)
index b1537db..8381bf1 100644 (file)
@@ -33,6 +33,7 @@
 namespace WebCore {
 class InspectorController;
 class CertificateInfo;
+class FloatRect;
 }
 
 namespace WebKit {
@@ -101,6 +102,8 @@ public:
     void changeAttachedWindowHeight(unsigned) override;
     void changeAttachedWindowWidth(unsigned) override;
 
+    void changeSheetRect(const WebCore::FloatRect&) override;
+
     void openInNewTab(const String& url) override;
 
     bool canSave() override;
index 342e989..c85c4e7 100644 (file)
@@ -1,3 +1,14 @@
+2019-04-10  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: save sheet should be anchored underneath the tab bar when detached
+        https://bugs.webkit.org/show_bug.cgi?id=196722
+        <rdar://problem/49613280>
+
+        Reviewed by Timothy Hatcher.
+
+        * WebCoreSupport/WebInspectorClientIOS.mm:
+        (WebInspectorFrontendClient::setSheetRect): Added.
+
 2019-03-03  Zalan Bujtas  <zalan@apple.com>
 
         [ContentChangeObserver] Content observation should be limited to the current document.
index e8c2ee5..0716980 100644 (file)
@@ -35,6 +35,7 @@
 #import "WebNodeHighlighter.h"
 #import "WebViewInternal.h"
 #import <WebCore/CertificateInfo.h>
+#import <WebCore/FloatRect.h>
 #import <WebCore/InspectorController.h>
 #import <WebCore/NotImplemented.h>
 #import <WebCore/Page.h>
@@ -130,6 +131,7 @@ 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&) { }
index 9468216..4d11348 100644 (file)
@@ -1,3 +1,17 @@
+2019-04-10  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: save sheet should be anchored underneath the tab bar when detached
+        https://bugs.webkit.org/show_bug.cgi?id=196722
+        <rdar://problem/49613280>
+
+        Reviewed by Timothy Hatcher.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        (WebInspectorFrontendClient::sheetRect const): Added.
+        * WebCoreSupport/WebInspectorClient.mm:
+        (-[WebInspectorWindowController window:willPositionSheet:usingRect:]):
+        (WebInspectorFrontendClient::setSheetRect): Added.
+
 2019-04-10  Alex Christensen  <achristensen@webkit.org>
 
         Add SPI WKNavigationResponse._downloadAttribute
index 8ce97b8..4a25a6c 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #import <JavaScriptCore/InspectorFrontendChannel.h>
+#import <WebCore/FloatRect.h>
 #import <WebCore/InspectorClient.h>
 #import <WebCore/InspectorFrontendClientLocal.h>
 #import <wtf/Forward.h>
@@ -125,6 +126,11 @@ public:
     void setAttachedWindowHeight(unsigned height) override;
     void setAttachedWindowWidth(unsigned height) override;
 
+#if !PLATFORM(IOS_FAMILY)
+    const WebCore::FloatRect& sheetRect() const { return m_sheetRect; }
+#endif
+    void setSheetRect(const WebCore::FloatRect&) override;
+
     void inspectedURLChanged(const String& newURL) override;
     void showCertificate(const WebCore::CertificateInfo&) override;
 
@@ -140,5 +146,6 @@ private:
     RetainPtr<WebInspectorWindowController> m_frontendWindowController;
     String m_inspectedURL;
     HashMap<String, RetainPtr<NSURL>> m_suggestedToActualURLMap;
+    WebCore::FloatRect m_sheetRect;
 #endif
 };
index 6315e68..1b903af 100644 (file)
@@ -279,6 +279,11 @@ void WebInspectorFrontendClient::setAttachedWindowWidth(unsigned)
     // Dock to right is not implemented in WebKit 1.
 }
 
+void WebInspectorFrontendClient::setSheetRect(const FloatRect& rect)
+{
+    m_sheetRect = rect;
+}
+
 void WebInspectorFrontendClient::inspectedURLChanged(const String& newURL)
 {
     m_inspectedURL = newURL;
@@ -515,8 +520,10 @@ void WebInspectorFrontendClient::append(const String& suggestedURL, const String
 
 - (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRect:(NSRect)rect
 {
+    if (_frontendClient)
+        return NSMakeRect(0, _frontendClient->sheetRect().height(), _frontendClient->sheetRect().width(), 0);
+
     // AppKit doesn't know about our HTML toolbar, and places the sheet just a little bit too high.
-    // FIXME: It would be better to get the height of the toolbar and use it in this calculation.
     rect.origin.y -= 1;
     return rect;
 }
index 7829b77..1265a6e 100644 (file)
@@ -1,3 +1,15 @@
+2019-04-10  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: save sheet should be anchored underneath the tab bar when detached
+        https://bugs.webkit.org/show_bug.cgi?id=196722
+        <rdar://problem/49613280>
+
+        Reviewed by Timothy Hatcher.
+
+        * WebCoreSupport/WebInspectorClient.h:
+        * WebCoreSupport/WebInspectorClient.cpp:
+        (WebInspectorFrontendClient::setSheetRect): Added.
+
 2019-04-10  Alex Christensen  <achristensen@webkit.org>
 
         Add SPI WKNavigationResponse._downloadAttribute
index b2daedb..a0d769d 100644 (file)
@@ -340,6 +340,11 @@ void WebInspectorFrontendClient::setAttachedWindowWidth(unsigned)
     notImplemented();
 }
 
+void WebInspectorFrontendClient::setSheetRect(const FloatRect&)
+{
+    notImplemented();
+}
+
 void WebInspectorFrontendClient::inspectedURLChanged(const String& newURL)
 {
     m_inspectedURL = newURL;
index 7966cf2..1733a72 100644 (file)
@@ -108,6 +108,8 @@ public:
     void setAttachedWindowHeight(unsigned) override;
     void setAttachedWindowWidth(unsigned) override;
 
+    void setSheetRect(const WebCore::FloatRect&) override;
+
     void inspectedURLChanged(const WTF::String& newURL) override;
     void showCertificate(const WebCore::CertificateInfo&) override;