Web Automation: Fix element and event coord space issues
authortimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Jul 2016 01:19:21 +0000 (01:19 +0000)
committertimothy@apple.com <timothy@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 16 Jul 2016 01:19:21 +0000 (01:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159851
rdar://problem/27375780

Reviewed by Brian Burg.

* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::WebAutomationSession::performMouseInteraction): Subtract topContentInset() before
it goes back out to WebDriver.
* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::computeElementLayout): When using useViewportCoordinates,
subtract topContentInset() so it matches expectations.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Automation/WebAutomationSession.cpp
Source/WebKit2/WebProcess/Automation/WebAutomationSessionProxy.cpp

index 7bf75db..d43ea31 100644 (file)
@@ -1,3 +1,18 @@
+2016-07-15  Timothy Hatcher  <timothy@apple.com>
+
+        Web Automation: Fix element and event coord space issues
+        https://bugs.webkit.org/show_bug.cgi?id=159851
+        rdar://problem/27375780
+
+        Reviewed by Brian Burg.
+
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::WebAutomationSession::performMouseInteraction): Subtract topContentInset() before
+        it goes back out to WebDriver.
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::computeElementLayout): When using useViewportCoordinates,
+        subtract topContentInset() so it matches expectations.
+
 2016-07-15  Beth Dakin  <bdakin@apple.com>
 
         Mac UI process needs to know about element focus and blur, much like iOS
index 735d3db..1b4a72e 100644 (file)
@@ -918,7 +918,7 @@ void WebAutomationSession::performMouseInteraction(Inspector::ErrorString& error
 
     updatedPositionObject = Inspector::Protocol::Automation::Point::create()
         .setX(x)
-        .setY(y)
+        .setY(y - page->topContentInset())
         .release();
 #endif // USE(APPKIT)
 }
index e2c8680..90f95a7 100644 (file)
@@ -487,21 +487,22 @@ void WebAutomationSessionProxy::computeElementLayout(uint64_t pageID, uint64_t f
 
     WebCore::IntRect rect = coreElement->clientRect();
 
-    if (!useViewportCoordinates) {
-        WebCore::Frame* coreFrame = frame->coreFrame();
-        if (!coreFrame) {
-            WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
-            return;
-        }
+    WebCore::Frame* coreFrame = frame->coreFrame();
+    if (!coreFrame) {
+        WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
+        return;
+    }
 
-        WebCore::FrameView *coreFrameView = coreFrame->view();
-        if (!coreFrameView) {
-            WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
-            return;
-        }
+    WebCore::FrameView *coreFrameView = coreFrame->view();
+    if (!coreFrameView) {
+        WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, WebCore::IntRect(), frameNotFoundErrorType), 0);
+        return;
+    }
 
+    if (useViewportCoordinates)
+        rect.moveBy(WebCore::IntPoint(0, -coreFrameView->topContentInset()));
+    else
         rect = coreFrameView->rootViewToContents(rect);
-    }
 
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, rect, String()), 0);
 }