Changeset 240195 in webkit


Ignore:
Timestamp:
Jan 18, 2019 8:22:41 PM (5 years ago)
Author:
BJ Burg
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):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r240190 r240195  
     12019-01-18  Brian Burg  <bburg@apple.com>
     2
     3        Automation.computeElementLayout should return visual viewport-aware coordinates
     4        https://bugs.webkit.org/show_bug.cgi?id=193598
     5        <rdar://problem/35325644>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * page/FrameView.h: export symbol to be usable from WebKit.
     10        * page/FrameView.cpp:
     11        (WebCore::FrameView::clientToLayoutViewportRect const): Added.
     12        Do the same thing as clientToLayoutViewportPoint with a rect instead.
     13
     14
    1152019-01-18  Eric Carlson  <eric.carlson@apple.com>
    216
  • trunk/Source/WebCore/page/FrameView.cpp

    r240139 r240195  
    48844884}
    48854885
     4886FloatRect FrameView::clientToLayoutViewportRect(FloatRect rect) const
     4887{
     4888    ASSERT(frame().settings().visualViewportEnabled());
     4889    rect.scale(frame().pageZoomFactor());
     4890    return rect;
     4891}
     4892
    48864893FloatPoint FrameView::clientToLayoutViewportPoint(FloatPoint p) const
    48874894{
  • trunk/Source/WebCore/page/FrameView.h

    r240139 r240195  
    487487
    488488    // Unlike client coordinates, layout viewport coordinates are affected by page zoom.
    489     FloatPoint clientToLayoutViewportPoint(FloatPoint) const;
     489    WEBCORE_EXPORT FloatRect clientToLayoutViewportRect(FloatRect) const;
     490    WEBCORE_EXPORT FloatPoint clientToLayoutViewportPoint(FloatPoint) const;
    490491
    491492    bool isFrameViewScrollCorner(const RenderScrollbarPart& scrollCorner) const { return m_scrollCorner.get() == &scrollCorner; }
  • trunk/Source/WebKit/ChangeLog

    r240183 r240195  
     12019-01-18  Brian Burg  <bburg@apple.com>
     2
     3        Automation.computeElementLayout should return visual viewport-aware coordinates
     4        https://bugs.webkit.org/show_bug.cgi?id=193598
     5        <rdar://problem/35325644>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Previously I added CoordinateSystem::VisualViewport to stub out this for iOS.
     10        But I think that it's a mistake for safaridriver to care about VisualViewport
     11        being enabled or not, because it is a runtime-switchable setting.
     12
     13        This patch removes CoordinateSystem::VisualViewport. Make the existing
     14        CoordinateSystem::LayoutViewport use visual viewport semantics if needed.
     15
     16        This is tested by WebDriver element clicking tests. There should not be any
     17        difference in behavior until it is possible to zoom with gestures via WebDriver.
     18
     19        * Shared/CoordinateSystem.h:
     20        * UIProcess/Automation/Automation.json:
     21        * UIProcess/Automation/WebAutomationSession.cpp:
     22        (WebKit::protocolStringToCoordinateSystem):
     23        * WebProcess/Automation/WebAutomationSessionProxy.cpp:
     24        (WebKit::WebAutomationSessionProxy::computeElementLayout):
     25
    1262019-01-18  Daniel Bates  <dabates@apple.com>
    227
  • trunk/Source/WebKit/Shared/CoordinateSystem.h

    r237110 r240195  
    3232enum class CoordinateSystem : uint8_t {
    3333    Page = 0,
    34     LayoutViewport,
    35     VisualViewport,
     34    LayoutViewport
    3635};
    3736
     
    4342    using values = EnumValues<
    4443    WebKit::CoordinateSystem,
    45     WebKit::CoordinateSystem::Page,
    46     WebKit::CoordinateSystem::LayoutViewport,
    47     WebKit::CoordinateSystem::VisualViewport
     44    WebKit::CoordinateSystem::Page
    4845    >;
    4946};
  • trunk/Source/WebKit/UIProcess/Automation/Automation.json

    r239988 r240195  
    3333            "enum": [
    3434                "Page",
    35                 "LayoutViewport",
    36                 "VisualViewport"
     35                "LayoutViewport"
    3736            ]
    3837        },
  • trunk/Source/WebKit/UIProcess/Automation/WebAutomationSession.cpp

    r239988 r240195  
    10051005    if (coordinateSystemString == "LayoutViewport")
    10061006        return CoordinateSystem::LayoutViewport;
    1007     if (coordinateSystemString == "VisualViewport")
    1008         return CoordinateSystem::VisualViewport;
    10091007    return WTF::nullopt;
    10101008}
  • trunk/Source/WebKit/WebProcess/Automation/WebAutomationSessionProxy.cpp

    r240014 r240195  
    568568    }
    569569
    570     if (coordinateSystem == CoordinateSystem::VisualViewport) {
    571         WebProcess::singleton().parentProcessConnection()->send(Messages::WebAutomationSession::DidComputeElementLayout(callbackID, { }, WTF::nullopt, false, notImplementedErrorType), 0);
    572         return;
    573     }
    574 
    575570    WebCore::FrameView* frameView = frame->coreFrame()->view();
    576571    WebCore::FrameView* mainView = frame->coreFrame()->mainFrame().view();
     
    584579    case CoordinateSystem::LayoutViewport:
    585580        // The element bounds are already in client coordinates.
    586         resultElementBounds = rootElementBounds;
    587         break;
    588     case CoordinateSystem::VisualViewport:
    589         ASSERT_NOT_REACHED();
     581        if (frame->coreFrame()->settings().visualViewportEnabled())
     582            resultElementBounds = WebCore::IntRect(mainView->clientToLayoutViewportRect(WebCore::FloatRect(rootElementBounds)));
     583        else
     584            resultElementBounds = rootElementBounds;
    590585        break;
    591586    }
     
    603598            case CoordinateSystem::LayoutViewport:
    604599                // The point is already in client coordinates.
    605                 resultInViewCenterPoint = rootInViewCenterPoint;
    606                 break;
    607             case CoordinateSystem::VisualViewport:
    608                 ASSERT_NOT_REACHED();
     600                if (frame->coreFrame()->settings().visualViewportEnabled())
     601                    resultInViewCenterPoint = WebCore::IntPoint(mainView->clientToLayoutViewportPoint(rootInViewCenterPoint));
     602                else
     603                    resultInViewCenterPoint = rootInViewCenterPoint;
    609604                break;
    610605            }
Note: See TracChangeset for help on using the changeset viewer.