Title: [240195] trunk/Source
Revision
240195
Author
bb...@apple.com
Date
2019-01-18 20:22:41 -0800 (Fri, 18 Jan 2019)

Log Message

Automation.computeElementLayout should return visual viewport-aware coordinates
https://bugs.webkit.org/show_bug.cgi?id=193598
<rdar://problem/35325644>

Reviewed by Simon Fraser.

Source/WebCore:

* page/FrameView.h: export symbol to be usable from WebKit.
* page/FrameView.cpp:
(WebCore::FrameView::clientToLayoutViewportRect const): Added.
Do the same thing as clientToLayoutViewportPoint with a rect instead.

Source/WebKit:

Previously I added CoordinateSystem::VisualViewport to stub out this for iOS.
But I think that it's a mistake for safaridriver to care about VisualViewport
being enabled or not, because it is a runtime-switchable setting.

This patch removes CoordinateSystem::VisualViewport. Make the existing
CoordinateSystem::LayoutViewport use visual viewport semantics if needed.

This is tested by WebDriver element clicking tests. There should not be any
difference in behavior until it is possible to zoom with gestures via WebDriver.

* Shared/CoordinateSystem.h:
* UIProcess/Automation/Automation.json:
* UIProcess/Automation/WebAutomationSession.cpp:
(WebKit::protocolStringToCoordinateSystem):
* WebProcess/Automation/WebAutomationSessionProxy.cpp:
(WebKit::WebAutomationSessionProxy::computeElementLayout):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (240194 => 240195)


--- trunk/Source/WebCore/ChangeLog	2019-01-19 03:35:44 UTC (rev 240194)
+++ trunk/Source/WebCore/ChangeLog	2019-01-19 04:22:41 UTC (rev 240195)
@@ -1,3 +1,17 @@
+2019-01-18  Brian Burg  <bb...@apple.com>
+
+        Automation.computeElementLayout should return visual viewport-aware coordinates
+        https://bugs.webkit.org/show_bug.cgi?id=193598
+        <rdar://problem/35325644>
+
+        Reviewed by Simon Fraser.
+
+        * page/FrameView.h: export symbol to be usable from WebKit.
+        * page/FrameView.cpp:
+        (WebCore::FrameView::clientToLayoutViewportRect const): Added.
+        Do the same thing as clientToLayoutViewportPoint with a rect instead.
+
+
 2019-01-18  Eric Carlson  <eric.carl...@apple.com>
 
         Revert r238815, it broke WK1 video fullscreen on Mac

Modified: trunk/Source/WebCore/page/FrameView.cpp (240194 => 240195)


--- trunk/Source/WebCore/page/FrameView.cpp	2019-01-19 03:35:44 UTC (rev 240194)
+++ trunk/Source/WebCore/page/FrameView.cpp	2019-01-19 04:22:41 UTC (rev 240195)
@@ -4883,6 +4883,13 @@
     return p.scaled(frame().frameScaleFactor());
 }
 
+FloatRect FrameView::clientToLayoutViewportRect(FloatRect rect) const
+{
+    ASSERT(frame().settings().visualViewportEnabled());
+    rect.scale(frame().pageZoomFactor());
+    return rect;
+}
+
 FloatPoint FrameView::clientToLayoutViewportPoint(FloatPoint p) const
 {
     ASSERT(frame().settings().visualViewportEnabled());

Modified: trunk/Source/WebCore/page/FrameView.h (240194 => 240195)


--- trunk/Source/WebCore/page/FrameView.h	2019-01-19 03:35:44 UTC (rev 240194)
+++ trunk/Source/WebCore/page/FrameView.h	2019-01-19 04:22:41 UTC (rev 240195)
@@ -486,7 +486,8 @@
     FloatPoint layoutViewportToAbsolutePoint(FloatPoint) const;
 
     // Unlike client coordinates, layout viewport coordinates are affected by page zoom.
-    FloatPoint clientToLayoutViewportPoint(FloatPoint) const;
+    WEBCORE_EXPORT FloatRect clientToLayoutViewportRect(FloatRect) const;
+    WEBCORE_EXPORT FloatPoint clientToLayoutViewportPoint(FloatPoint) const;
 
     bool isFrameViewScrollCorner(const RenderScrollbarPart& scrollCorner) const { return m_scrollCorner.get() == &scrollCorner; }
 

Modified: trunk/Source/WebKit/ChangeLog (240194 => 240195)


--- trunk/Source/WebKit/ChangeLog	2019-01-19 03:35:44 UTC (rev 240194)
+++ trunk/Source/WebKit/ChangeLog	2019-01-19 04:22:41 UTC (rev 240195)
@@ -1,3 +1,28 @@
+2019-01-18  Brian Burg  <bb...@apple.com>
+
+        Automation.computeElementLayout should return visual viewport-aware coordinates
+        https://bugs.webkit.org/show_bug.cgi?id=193598
+        <rdar://problem/35325644>
+
+        Reviewed by Simon Fraser.
+
+        Previously I added CoordinateSystem::VisualViewport to stub out this for iOS.
+        But I think that it's a mistake for safaridriver to care about VisualViewport
+        being enabled or not, because it is a runtime-switchable setting.
+
+        This patch removes CoordinateSystem::VisualViewport. Make the existing
+        CoordinateSystem::LayoutViewport use visual viewport semantics if needed.
+
+        This is tested by WebDriver element clicking tests. There should not be any
+        difference in behavior until it is possible to zoom with gestures via WebDriver.
+
+        * Shared/CoordinateSystem.h:
+        * UIProcess/Automation/Automation.json:
+        * UIProcess/Automation/WebAutomationSession.cpp:
+        (WebKit::protocolStringToCoordinateSystem):
+        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
+        (WebKit::WebAutomationSessionProxy::computeElementLayout):
+
 2019-01-18  Daniel Bates  <daba...@apple.com>
 
         Fix some build issues.

Modified: trunk/Source/WebKit/Shared/CoordinateSystem.h (240194 => 240195)


--- trunk/Source/WebKit/Shared/CoordinateSystem.h	2019-01-19 03:35:44 UTC (rev 240194)
+++ trunk/Source/WebKit/Shared/CoordinateSystem.h	2019-01-19 04:22:41 UTC (rev 240195)
@@ -31,8 +31,7 @@
 
 enum class CoordinateSystem : uint8_t {
     Page = 0,
-    LayoutViewport,
-    VisualViewport,
+    LayoutViewport
 };
 
 } // namespace WebKit
@@ -42,9 +41,7 @@
 template<> struct EnumTraits<WebKit::CoordinateSystem> {
     using values = EnumValues<
     WebKit::CoordinateSystem,
-    WebKit::CoordinateSystem::Page,
-    WebKit::CoordinateSystem::LayoutViewport,
-    WebKit::CoordinateSystem::VisualViewport
+    WebKit::CoordinateSystem::Page
     >;
 };
 

Modified: trunk/Source/WebKit/UIProcess/Automation/Automation.json (240194 => 240195)


--- trunk/Source/WebKit/UIProcess/Automation/Automation.json	2019-01-19 03:35:44 UTC (rev 240194)
+++ trunk/Source/WebKit/UIProcess/Automation/Automation.json	2019-01-19 04:22:41 UTC (rev 240195)
@@ -32,8 +32,7 @@
             "description": "The coordinate system in which rects, points, and sizes are to be interpreted.",
             "enum": [
                 "Page",
-                "LayoutViewport",
-                "VisualViewport"
+                "LayoutViewport"
             ]
         },
         {

Modified: trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp (240194 => 240195)


--- trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2019-01-19 03:35:44 UTC (rev 240194)
+++ trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp	2019-01-19 04:22:41 UTC (rev 240195)
@@ -1004,8 +1004,6 @@
         return CoordinateSystem::Page;
     if (coordinateSystemString == "LayoutViewport")
         return CoordinateSystem::LayoutViewport;
-    if (coordinateSystemString == "VisualViewport")
-        return CoordinateSystem::VisualViewport;
     return WTF::nullopt;
 }
 

Modified: trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp (240194 => 240195)


--- trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2019-01-19 03:35:44 UTC (rev 240194)
+++ trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp	2019-01-19 04:22:41 UTC (rev 240195)
@@ -567,11 +567,6 @@
         // FIXME: Wait in an implementation-specific way up to the session implicit wait timeout for the element to become in view.
     }
 
-    if (coordinateSystem == CoordinateSystem::VisualViewport) {
-        WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, { }, WTF::nullopt, false, notImplementedErrorType), 0);
-        return;
-    }
-
     WebCore::FrameView* frameView = frame->coreFrame()->view();
     WebCore::FrameView* mainView = frame->coreFrame()->mainFrame().view();
     WebCore::IntRect frameElementBounds = roundedIntRect(coreElement->boundingClientRect());
@@ -583,11 +578,11 @@
         break;
     case CoordinateSystem::LayoutViewport:
         // The element bounds are already in client coordinates.
-        resultElementBounds = rootElementBounds;
+        if (frame->coreFrame()->settings().visualViewportEnabled())
+            resultElementBounds = WebCore::IntRect(mainView->clientToLayoutViewportRect(WebCore::FloatRect(rootElementBounds)));
+        else
+            resultElementBounds = rootElementBounds;
         break;
-    case CoordinateSystem::VisualViewport:
-        ASSERT_NOT_REACHED();
-        break;
     }
 
     Optional<WebCore::IntPoint> resultInViewCenterPoint;
@@ -602,11 +597,11 @@
                 break;
             case CoordinateSystem::LayoutViewport:
                 // The point is already in client coordinates.
-                resultInViewCenterPoint = rootInViewCenterPoint;
+                if (frame->coreFrame()->settings().visualViewportEnabled())
+                    resultInViewCenterPoint = WebCore::IntPoint(mainView->clientToLayoutViewportPoint(rootInViewCenterPoint));
+                else
+                    resultInViewCenterPoint = rootInViewCenterPoint;
                 break;
-            case CoordinateSystem::VisualViewport:
-                ASSERT_NOT_REACHED();
-                break;
             }
         }
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to