Title: [262997] trunk/Source/WebKit
Revision
262997
Author
[email protected]
Date
2020-06-12 23:22:51 -0700 (Fri, 12 Jun 2020)

Log Message

Automation.computeElementLayout should return iframe-relative element rects (when coordinate system is 'Page')
https://bugs.webkit.org/show_bug.cgi?id=213139
<rdar://problem/55042445>

Reviewed by Devin Rousso.

Automation.computeElementLayout has two coordinate systems it can use, LayoutViewport (used for hit testing)
and Page (used for Get Element Rect). Since Get Element Rect expects coordinates relative to the current
browsing context, make the mode simpler by reporting the bounds from Element::boundingClientRect() which
are frame-relative.

Covered by existing WPT suite. The semantics of this command are under review, as
the remote end steps seem to describe a different result than what the non-normative text does.

* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::computeElementLayout):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (262996 => 262997)


--- trunk/Source/WebKit/ChangeLog	2020-06-13 06:13:12 UTC (rev 262996)
+++ trunk/Source/WebKit/ChangeLog	2020-06-13 06:22:51 UTC (rev 262997)
@@ -1,3 +1,22 @@
+2020-06-12  Brian Burg  <[email protected]>
+
+        Automation.computeElementLayout should return iframe-relative element rects (when coordinate system is 'Page')
+        https://bugs.webkit.org/show_bug.cgi?id=213139
+        <rdar://problem/55042445>
+
+        Reviewed by Devin Rousso.
+
+        Automation.computeElementLayout has two coordinate systems it can use, LayoutViewport (used for hit testing)
+        and Page (used for Get Element Rect). Since Get Element Rect expects coordinates relative to the current
+        browsing context, make the mode simpler by reporting the bounds from Element::boundingClientRect() which
+        are frame-relative.
+
+        Covered by existing WPT suite. The semantics of this command are under review, as
+        the remote end steps seem to describe a different result than what the non-normative text does.
+
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::computeElementLayout):
+
 2020-06-12  David Kilzer  <[email protected]>
 
         [IPC hardening] Check enum values in IPC::Decoder::decodeEnum() an IPC::Encoder::encodeEnum()

Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp (262996 => 262997)


--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2020-06-13 06:13:12 UTC (rev 262996)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2020-06-13 06:22:51 UTC (rev 262997)
@@ -682,15 +682,16 @@
     Optional<WebCore::IntPoint> resultInViewCenterPoint;
     bool isObscured = false;
 
-    auto elementBoundsInRootCoordinates = convertRectFromFrameClientToRootView(frameView, coreElement->boundingClientRect());
     switch (coordinateSystem) {
     case CoordinateSystem::Page:
-        resultElementBounds = enclosingIntRect(mainView->absoluteToDocumentRect(mainView->rootViewToContents(elementBoundsInRootCoordinates)));
+        resultElementBounds = enclosingIntRect(coreElement->boundingClientRect());
         break;
-    case CoordinateSystem::LayoutViewport:
+    case CoordinateSystem::LayoutViewport: {
+        auto elementBoundsInRootCoordinates = convertRectFromFrameClientToRootView(frameView, coreElement->boundingClientRect());
         resultElementBounds = enclosingIntRect(mainView->absoluteToLayoutViewportRect(mainView->rootViewToContents(elementBoundsInRootCoordinates)));
         break;
     }
+    }
 
     // If an <option> or <optgroup> does not have an associated <select> or <datalist> element, then give up.
     if (!containerElement) {
@@ -739,15 +740,16 @@
     // Node::isDescendantOf() is not self-inclusive, so that is explicitly checked here.
     isObscured = elementList[0] != containerElement && !elementList[0]->isDescendantOf(containerElement);
 
-    auto inViewCenterPointInRootCoordinates = convertPointFromFrameClientToRootView(frameView, elementInViewCenterPoint);
     switch (coordinateSystem) {
     case CoordinateSystem::Page:
-        resultInViewCenterPoint = roundedIntPoint(mainView->absoluteToDocumentPoint(mainView->rootViewToContents(inViewCenterPointInRootCoordinates)));
+        resultInViewCenterPoint = roundedIntPoint(elementInViewCenterPoint);
         break;
-    case CoordinateSystem::LayoutViewport:
+    case CoordinateSystem::LayoutViewport: {
+        auto inViewCenterPointInRootCoordinates = convertPointFromFrameClientToRootView(frameView, elementInViewCenterPoint);
         resultInViewCenterPoint = roundedIntPoint(mainView->absoluteToLayoutViewportPoint(mainView->rootViewToContents(inViewCenterPointInRootCoordinates)));
         break;
     }
+    }
 
     completionHandler(WTF::nullopt, resultElementBounds, resultInViewCenterPoint, isObscured);
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to