Changeset 219571 in webkit


Ignore:
Timestamp:
Jul 17, 2017, 1:24:16 PM (9 years ago)
Author:
Simon Fraser
Message:

clientX/clientY on TouchEvent.touches are wrong
https://bugs.webkit.org/show_bug.cgi?id=174561
Source/WebCore:

rdar://problem/33336041

Reviewed by Tim Horton.

Do some refactoring so that WebKitAdditions code that computes Touch coordinates can use
the same code that MouseRelatedEvent uses.

There is no behavior change in this patch, but the test exercises a behavior change in
WebKitAdditions code.

Test: fast/events/touch/ios/touches-client-coords-after-zoom.html

  • dom/MouseRelatedEvent.cpp:

(WebCore::MouseRelatedEvent::init):
(WebCore::MouseRelatedEvent::frameViewFromDOMWindow):
(WebCore::MouseRelatedEvent::pagePointToClientPoint):
(WebCore::MouseRelatedEvent::pagePointToAbsolutePoint):
(WebCore::MouseRelatedEvent::initCoordinates):
(WebCore::MouseRelatedEvent::documentToAbsoluteScaleFactor):
(WebCore::MouseRelatedEvent::computePageLocation):
(WebCore::MouseRelatedEvent::locationInRootViewCoordinates):
(WebCore::MouseRelatedEvent::frameView): Deleted.

  • dom/MouseRelatedEvent.h:

LayoutTests:

Reviewed by Tim Horton.

  • fast/events/touch/ios/touches-client-coords-after-zoom-expected.txt: Added.
  • fast/events/touch/ios/touches-client-coords-after-zoom.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r219568 r219571  
     12017-07-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        clientX/clientY on TouchEvent.touches are wrong
     4        https://bugs.webkit.org/show_bug.cgi?id=174561
     5
     6        Reviewed by Tim Horton.
     7
     8        * fast/events/touch/ios/touches-client-coords-after-zoom-expected.txt: Added.
     9        * fast/events/touch/ios/touches-client-coords-after-zoom.html: Added.
     10
    1112017-07-17  Chris Dumez  <cdumez@apple.com>
    212
  • trunk/Source/WebCore/ChangeLog

    r219569 r219571  
     12017-07-17  Simon Fraser  <simon.fraser@apple.com>
     2
     3        clientX/clientY on TouchEvent.touches are wrong
     4        https://bugs.webkit.org/show_bug.cgi?id=174561
     5        rdar://problem/33336041
     6
     7        Reviewed by Tim Horton.
     8       
     9        Do some refactoring so that WebKitAdditions code that computes Touch coordinates can use
     10        the same code that MouseRelatedEvent uses.
     11       
     12        There is no behavior change in this patch, but the test exercises a behavior change in
     13        WebKitAdditions code.
     14
     15        Test: fast/events/touch/ios/touches-client-coords-after-zoom.html
     16
     17        * dom/MouseRelatedEvent.cpp:
     18        (WebCore::MouseRelatedEvent::init):
     19        (WebCore::MouseRelatedEvent::frameViewFromDOMWindow):
     20        (WebCore::MouseRelatedEvent::pagePointToClientPoint):
     21        (WebCore::MouseRelatedEvent::pagePointToAbsolutePoint):
     22        (WebCore::MouseRelatedEvent::initCoordinates):
     23        (WebCore::MouseRelatedEvent::documentToAbsoluteScaleFactor):
     24        (WebCore::MouseRelatedEvent::computePageLocation):
     25        (WebCore::MouseRelatedEvent::locationInRootViewCoordinates):
     26        (WebCore::MouseRelatedEvent::frameView): Deleted.
     27        * dom/MouseRelatedEvent.h:
     28
    1292017-07-17  Jeremy Jones  <jeremyj@apple.com>
    230
  • trunk/Source/WebCore/dom/MouseRelatedEvent.cpp

    r219304 r219571  
    6262{
    6363    if (!isSimulated) {
    64         if (auto* frameView = this->frameView()) {
     64        if (auto* frameView = frameViewFromDOMWindow(view())) {
    6565            FloatPoint absolutePoint = frameView->windowToContents(windowLocation);
    6666            FloatPoint documentPoint = frameView->absoluteToDocumentPoint(absolutePoint);
    6767            m_pageLocation = flooredLayoutPoint(documentPoint);
    68             m_clientLocation = flooredLayoutPoint(frameView->documentToClientPoint(documentPoint));
     68            m_clientLocation = pagePointToClientPoint(m_pageLocation, frameView);
    6969        }
    7070    }
     
    8484}
    8585
     86FrameView* MouseRelatedEvent::frameViewFromDOMWindow(DOMWindow* window)
     87{
     88    auto* frame = window ? window->frame() : nullptr;
     89    if (!frame)
     90        return nullptr;
     91
     92    return frame->view();
     93}
     94
     95LayoutPoint MouseRelatedEvent::pagePointToClientPoint(LayoutPoint pagePoint, FrameView* frameView)
     96{
     97    if (!frameView)
     98        return pagePoint;
     99
     100    return flooredLayoutPoint(frameView->documentToClientPoint(pagePoint));
     101}
     102
     103LayoutPoint MouseRelatedEvent::pagePointToAbsolutePoint(LayoutPoint pagePoint, FrameView* frameView)
     104{
     105    if (!frameView)
     106        return pagePoint;
     107   
     108    return pagePoint.scaled(frameView->documentToAbsoluteScaleFactor());
     109}
     110
    86111void MouseRelatedEvent::initCoordinates(const LayoutPoint& clientLocation)
    87112{
     
    89114    // Correct values are computed lazily, see computeRelativePosition.
    90115    FloatSize documentToClientOffset;
    91     if (auto* frameView = this->frameView())
     116    if (auto* frameView = frameViewFromDOMWindow(view()))
    92117        documentToClientOffset = frameView->documentToClientOffset();
    93118
     
    102127}
    103128
    104 FrameView* MouseRelatedEvent::frameView() const
    105 {
    106     auto* frame = view() ? view()->frame() : nullptr;
    107     if (!frame)
    108         return nullptr;
    109 
    110     return frame->view();
    111 }
    112 
    113129float MouseRelatedEvent::documentToAbsoluteScaleFactor() const
    114130{
    115     if (auto* frameView = this->frameView())
     131    if (auto* frameView = frameViewFromDOMWindow(view()))
    116132        return frameView->documentToAbsoluteScaleFactor();
    117133
     
    121137void MouseRelatedEvent::computePageLocation()
    122138{
    123     m_absoluteLocation = m_pageLocation.scaled(documentToAbsoluteScaleFactor());
     139    m_absoluteLocation = pagePointToAbsolutePoint(m_pageLocation, frameViewFromDOMWindow(view()));
    124140}
    125141
     
    170186FloatPoint MouseRelatedEvent::locationInRootViewCoordinates() const
    171187{
    172     return frameView()->contentsToRootView(roundedIntPoint(m_absoluteLocation));
     188    if (auto* frameView = frameViewFromDOMWindow(view()))
     189        return frameView->contentsToRootView(roundedIntPoint(m_absoluteLocation));
     190
     191    return m_absoluteLocation;
    173192}
    174193
  • trunk/Source/WebCore/dom/MouseRelatedEvent.h

    r219304 r219571  
    6666    // usable with RenderObject::absoluteToLocal).
    6767    const LayoutPoint& absoluteLocation() const { return m_absoluteLocation; }
     68   
     69    static FrameView* frameViewFromDOMWindow(DOMWindow*);
     70
     71    static LayoutPoint pagePointToClientPoint(LayoutPoint pagePoint, FrameView*);
     72    static LayoutPoint pagePointToAbsolutePoint(LayoutPoint pagePoint, FrameView*);
    6873
    6974protected:
     
    8590
    8691    float documentToAbsoluteScaleFactor() const;
    87     FrameView* frameView() const;
    8892
    8993    // Expose these so MouseEvent::initMouseEvent can set them.
Note: See TracChangeset for help on using the changeset viewer.