Title: [198760] trunk/Source/WebKit2
Revision
198760
Author
bb...@apple.com
Date
2016-03-28 15:34:44 -0700 (Mon, 28 Mar 2016)

Log Message

Web Automation: add commands to move and resize a browsing context's window
https://bugs.webkit.org/show_bug.cgi?id=155349
<rdar://problem/25104911>

Reviewed by Timothy Hatcher.

Parse the new origin or size and request the window to change to the
new frame. This calls through to PageUIClient::setWindowFrame().

* UIProcess/Automation/Automation.json:
Add new enum values for protocol parsing error cases.
Add new commands.

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::resizeWindowOfBrowsingContext):
(WebKit::WebAutomationSession::moveWindowOfBrowsingContext):
Added. Parse the incoming payload and bail if nothing would happen
or the values are not usable or out of range. Complain if a change
did not happen when the requested and actual size are different.

* UIProcess/Automation/WebAutomationSession.h:
* UIProcess/WebPageProxy.h: Move setWindowFrame to be public.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (198759 => 198760)


--- trunk/Source/WebKit2/ChangeLog	2016-03-28 22:34:36 UTC (rev 198759)
+++ trunk/Source/WebKit2/ChangeLog	2016-03-28 22:34:44 UTC (rev 198760)
@@ -1,5 +1,30 @@
 2016-03-28  Brian Burg  <bb...@apple.com>
 
+        Web Automation: add commands to move and resize a browsing context's window
+        https://bugs.webkit.org/show_bug.cgi?id=155349
+        <rdar://problem/25104911>
+
+        Reviewed by Timothy Hatcher.
+
+        Parse the new origin or size and request the window to change to the
+        new frame. This calls through to PageUIClient::setWindowFrame().
+
+        * UIProcess/Automation/Automation.json:
+        Add new enum values for protocol parsing error cases.
+        Add new commands.
+
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::resizeWindowOfBrowsingContext):
+        (WebKit::WebAutomationSession::moveWindowOfBrowsingContext):
+        Added. Parse the incoming payload and bail if nothing would happen
+        or the values are not usable or out of range. Complain if a change
+        did not happen when the requested and actual size are different.
+
+        * UIProcess/Automation/WebAutomationSession.h:
+        * UIProcess/WebPageProxy.h: Move setWindowFrame to be public.
+
+2016-03-28  Brian Burg  <bb...@apple.com>
+
         Web Automation: split protocol object BrowsingContext.windowFrame into two separate members
         https://bugs.webkit.org/show_bug.cgi?id=155952
         <rdar://problem/25393597>

Modified: trunk/Source/WebKit2/UIProcess/Automation/Automation.json (198759 => 198760)


--- trunk/Source/WebKit2/UIProcess/Automation/Automation.json	2016-03-28 22:34:36 UTC (rev 198759)
+++ trunk/Source/WebKit2/UIProcess/Automation/Automation.json	2016-03-28 22:34:44 UTC (rev 198760)
@@ -53,7 +53,8 @@
                 "NodeNotFound",
                 "NoJavaScriptDialog",
                 "NotImplemented",
-                "MissingParameter"
+                "MissingParameter",
+                "InvalidParameter"
             ]
         },
         {
@@ -110,6 +111,22 @@
             ]
         },
         {
+            "name": "resizeWindowOfBrowsingContext",
+            "description": "Resizes the window of the specified browsing context to the specified size.",
+            "parameters": [
+                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context to be resized." },
+                { "name": "size", "$ref": "Size", "description": "The new size for the browsing context's window." }
+            ]
+        },
+        {
+            "name": "moveWindowOfBrowsingContext",
+            "description": "Moves the window of the specified browsing context to the specified position.",
+            "parameters": [
+                { "name": "handle", "$ref": "BrowsingContextHandle", "description": "The handle for the browsing context to be moved." },
+                { "name": "origin", "$ref": "Point", "description": "The new origin for the browsing context's window. The position is interpreted in screen coordinate space, relative to the upper left corner of the screen." }
+            ]
+        },
+        {
             "name": "navigateBrowsingContext",
             "description": "Navigates a browsing context to a specified URL.",
             "parameters": [

Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp (198759 => 198760)


--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp	2016-03-28 22:34:36 UTC (rev 198759)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp	2016-03-28 22:34:44 UTC (rev 198760)
@@ -282,6 +282,80 @@
     page->process().send(Messages::WebAutomationSessionProxy::FocusFrame(frame->frameID()), 0);
 }
 
+void WebAutomationSession::resizeWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& sizeObject)
+{
+    // FIXME <rdar://problem/25094106>: Specify what parameter was missing or invalid and how.
+    // This requires some changes to the other end's error handling. Right now it looks for an
+    // exact error message match. We could stuff this into the 'data' field on error object.
+    float width;
+    if (!sizeObject.getDouble(WTF::ASCIILiteral("width"), width))
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(MissingParameter);
+
+    float height;
+    if (!sizeObject.getDouble(WTF::ASCIILiteral("height"), height))
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(MissingParameter);
+
+    if (width < 0 || height < 0)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InvalidParameter);
+
+    WebPageProxy* page = webPageProxyForHandle(handle);
+    if (!page)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+    WebCore::FloatRect originalFrame;
+    page->getWindowFrame(originalFrame);
+    
+    WebCore::FloatRect newFrame = WebCore::FloatRect(originalFrame.location(), WebCore::FloatSize(width, height));
+    if (newFrame == originalFrame)
+        return;
+
+    page->setWindowFrame(newFrame);
+    
+    // If nothing changed at all, it's probably fair to report that something went wrong.
+    // (We can't assume that the requested frame size will be honored exactly, however.)
+    WebCore::FloatRect updatedFrame;
+    page->getWindowFrame(updatedFrame);
+    if (originalFrame == updatedFrame)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InternalError);
+}
+
+void WebAutomationSession::moveWindowOfBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const Inspector::InspectorObject& positionObject)
+{
+    // FIXME <rdar://problem/25094106>: Specify what parameter was missing or invalid and how.
+    // This requires some changes to the other end's error handling. Right now it looks for an
+    // exact error message match. We could stuff this into the 'data' field on error object.
+    float x;
+    if (!positionObject.getDouble(WTF::ASCIILiteral("x"), x))
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(MissingParameter);
+
+    float y;
+    if (!positionObject.getDouble(WTF::ASCIILiteral("y"), y))
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(MissingParameter);
+
+    if (x < 0 || y < 0)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InvalidParameter);
+
+    WebPageProxy* page = webPageProxyForHandle(handle);
+    if (!page)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(WindowNotFound);
+
+    WebCore::FloatRect originalFrame;
+    page->getWindowFrame(originalFrame);
+    
+    WebCore::FloatRect newFrame = WebCore::FloatRect(WebCore::FloatPoint(x, y), originalFrame.size());
+    if (newFrame == originalFrame)
+        return;
+
+    page->setWindowFrame(newFrame);
+    
+    // If nothing changed at all, it's probably fair to report that something went wrong.
+    // (We can't assume that the requested frame size will be honored exactly, however.)
+    WebCore::FloatRect updatedFrame;
+    page->getWindowFrame(updatedFrame);
+    if (originalFrame == updatedFrame)
+        FAIL_WITH_PREDEFINED_ERROR_MESSAGE(InternalError);
+}
+
 void WebAutomationSession::navigateBrowsingContext(Inspector::ErrorString& errorString, const String& handle, const String& url)
 {
     WebPageProxy* page = webPageProxyForHandle(handle);

Modified: trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h (198759 => 198760)


--- trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h	2016-03-28 22:34:36 UTC (rev 198759)
+++ trunk/Source/WebKit2/UIProcess/Automation/WebAutomationSession.h	2016-03-28 22:34:44 UTC (rev 198760)
@@ -87,6 +87,8 @@
     void createBrowsingContext(Inspector::ErrorString&, String*) override;
     void closeBrowsingContext(Inspector::ErrorString&, const String&) override;
     void switchToBrowsingContext(Inspector::ErrorString&, const String& browsingContextHandle, const String* optionalFrameHandle) override;
+    void resizeWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& size) override;
+    void moveWindowOfBrowsingContext(Inspector::ErrorString&, const String& handle, const Inspector::InspectorObject& position) override;
     void navigateBrowsingContext(Inspector::ErrorString&, const String& handle, const String& url) override;
     void goBackInBrowsingContext(Inspector::ErrorString&, const String&) override;
     void goForwardInBrowsingContext(Inspector::ErrorString&, const String&) override;

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.h (198759 => 198760)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2016-03-28 22:34:36 UTC (rev 198759)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.h	2016-03-28 22:34:44 UTC (rev 198760)
@@ -1094,6 +1094,7 @@
     void didRestoreScrollPosition();
 
     void setFocus(bool focused);
+    void setWindowFrame(const WebCore::FloatRect&);
     void getWindowFrame(WebCore::FloatRect&);
 
     bool isResourceCachingDisabled() const { return m_isResourceCachingDisabled; }
@@ -1198,7 +1199,6 @@
     void getStatusBarIsVisible(bool& statusBarIsVisible);
     void setIsResizable(bool isResizable);
     void getIsResizable(bool& isResizable);
-    void setWindowFrame(const WebCore::FloatRect&);
     void screenToRootView(const WebCore::IntPoint& screenPoint, WebCore::IntPoint& windowPoint);
     void rootViewToScreen(const WebCore::IntRect& viewRect, WebCore::IntRect& result);
 #if PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to