Changeset 53994 in webkit


Ignore:
Timestamp:
Jan 28, 2010 3:00:35 AM (14 years ago)
Author:
benm@google.com
Message:

[Android] [Qt] Touch event page co-ordinates are incorrect when touch is received in an iframe.
https://bugs.webkit.org/show_bug.cgi?id=34162

Reviewed by Simon Hausmann.

WebCore:

The pageX/pageY co-ordinates of a touch event should be relative to the containing frame, not the main frame. This change implements that and also updates the existing touch-inside-iframe test to also examine the page co-ordinates.

  • dom/Touch.cpp:

(WebCore::Touch::Touch): Remove dead code.

  • dom/Touch.h: Remove dead code.
  • page/EventHandler.cpp:

(WebCore::EventHandler::handleTouchEvent): Rename framePoint to pagePoint, as it seems a clearer name. Also adjust the pagePoint to be relative to the touch target element's containing frame rather than the main frame.

  • platform/PlatformTouchEvent.h: Rename Android specific constructor parameter to better reflect it's contents.
  • platform/PlatformTouchPoint.h: Ditto.
  • platform/android/PlatformTouchEventAndroid.cpp: Ditto.
  • platform/android/PlatformTouchPointAndroid.cpp: Ditto.

LayoutTests:

Update the existing iframe touch event test to also examine the page co-ordinates of the touch that is received.

  • fast/events/touch/resources/touch-inside-iframe2.html:
  • fast/events/touch/touch-inside-iframe-expected.txt:
  • fast/events/touch/touch-inside-iframe.html:
Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r53992 r53994  
     12010-01-28  Ben Murdoch  <benm@google.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Android] [Qt] Touch event page co-ordinates are incorrect when touch is received in an iframe.
     6        https://bugs.webkit.org/show_bug.cgi?id=34162
     7
     8        Update the existing iframe touch event test to also examine the page co-ordinates of the touch that is received.
     9
     10        * fast/events/touch/resources/touch-inside-iframe2.html:
     11        * fast/events/touch/touch-inside-iframe-expected.txt:
     12        * fast/events/touch/touch-inside-iframe.html:
     13
    1142010-01-28  Xan Lopez  <xlopez@igalia.com>
    215
  • trunk/LayoutTests/fast/events/touch/resources/touch-inside-iframe2.html

    r53597 r53994  
    11<html>
    2 <body>
    3 <div id='mydiv' style='width:100px;height:100px;'></div>
     2<body onload="parent.runTest()">
     3<div id='mydiv' style='width:100px;height:100px;position:absolute;top:0px; left:0px; background-color:blue;'></div>
    44<script type='text/javascript'>
    5 document.getElementById('mydiv').addEventListener('touchstart', function() { parent.testComplete(); }, false);
     5document.getElementById('mydiv').addEventListener('touchstart', function() { parent.testComplete(event); }, false);
    66</script>
    77</body>
  • trunk/LayoutTests/fast/events/touch/touch-inside-iframe-expected.txt

    r53597 r53994  
    1 Test that touch events are sent to iframes that listen for them even if the parent frame does not listen for them.
    21
    3 PASS
     2Test iframes receive touches correctly.
    43
     4On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
     5
     6
     7PASS touch.pageX is 50
     8PASS touch.pageY is 50
     9PASS successfullyParsed is true
     10
     11TEST COMPLETE
     12
  • trunk/LayoutTests/fast/events/touch/touch-inside-iframe.html

    r53597 r53994  
    11<html>
     2<link rel="stylesheet" href="../../js/resources/js-test-style.css">
     3<script src="../../js/resources/js-test-pre.js"></script>
     4<script src="../../js/resources/js-test-post-function.js"></script>
     5<body>
     6<iframe style="position:absolute; top:100px; left:100px;" src="./resources/touch-inside-iframe2.html"></iframe>
     7<p id="description"></p>
     8<div id="console"></div>
    29<script type="text/javascript">
    3 if (window.layoutTestController)
     10description('Test iframes receive touches correctly.');
     11
     12var touch = null;
     13
     14function testComplete(event)
    415{
    5     layoutTestController.dumpAsText();
     16    touch = event.touches[0];
     17    shouldBe("touch.pageX", "50");
     18    shouldBe("touch.pageY", "50");
     19    isSuccessfullyParsed();
     20    layoutTestController.notifyDone();
     21}
     22
     23function runTest() {
     24    if (window.eventSender) {
     25        // Touch the center of the div in the iframe.
     26        // 100px is offset to iframe in main frame,
     27        // 2px for the iframe border, 50px to get to centre of the div.
     28        eventSender.addTouchPoint(152, 152);
     29        eventSender.touchStart();
     30    } else {
     31       debug('This test requires DRT.');
     32    }
     33}
     34
     35if (window.layoutTestController) {
    636    layoutTestController.waitUntilDone();
    737}
    838
    9 function runTest()
    10 {
    11     if (window.eventSender)
    12     {
    13         eventSender.addTouchPoint(50, 150);
    14         eventSender.touchStart();
    15     }
    16 }
    17 
    18 function testComplete()
    19 {
    20     document.getElementById('console').innerText = 'PASS';
    21     layoutTestController.notifyDone();
    22 }
     39var successfullyParsed = true;
    2340</script>
    24 <body onload="runTest();">
    25 <p>Test that touch events are sent to iframes that listen for them even if the parent frame does not listen for them.</p>
    26 <div id="console">
    27 <p>FAIL - no touchstart received!</p>
    28 </div>
    29 <iframe src="./resources/touch-inside-iframe2.html" />
    3041</body>
    3142</html>
  • trunk/WebCore/ChangeLog

    r53993 r53994  
     12010-01-28  Ben Murdoch  <benm@google.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Android] [Qt] Touch event page co-ordinates are incorrect when touch is received in an iframe.
     6        https://bugs.webkit.org/show_bug.cgi?id=34162
     7
     8        The pageX/pageY co-ordinates of a touch event should be relative to the containing frame, not the main frame. This change implements that and also updates the existing touch-inside-iframe test to also examine the page co-ordinates.
     9
     10        * dom/Touch.cpp:
     11        (WebCore::Touch::Touch): Remove dead code.
     12        * dom/Touch.h: Remove dead code.
     13        * page/EventHandler.cpp:
     14        (WebCore::EventHandler::handleTouchEvent): Rename framePoint to pagePoint, as it seems a clearer name. Also adjust the pagePoint to be relative to the touch target element's containing frame rather than the main frame.
     15        * platform/PlatformTouchEvent.h: Rename Android specific constructor parameter to better reflect it's contents.
     16        * platform/PlatformTouchPoint.h: Ditto.
     17        * platform/android/PlatformTouchEventAndroid.cpp: Ditto.
     18        * platform/android/PlatformTouchPointAndroid.cpp: Ditto.
     19
    1202010-01-28  Yury Semikhatsky  <yurys@chromium.org>
    221
  • trunk/WebCore/dom/Touch.cpp

    r53069 r53994  
    5656Touch::Touch(Frame* frame, EventTarget* target, unsigned identifier,
    5757        int screenX, int screenY, int pageX, int pageY)
    58     : m_frame(frame)
    59     , m_target(target)
     58    : m_target(target)
    6059    , m_identifier(identifier)
    61     , m_clientX(pageX - contentsX(m_frame.get()))
    62     , m_clientY(pageY - contentsY(m_frame.get()))
     60    , m_clientX(pageX - contentsX(frame))
     61    , m_clientY(pageY - contentsY(frame))
    6362    , m_screenX(screenX)
    6463    , m_screenY(screenY)
     
    6867}
    6968
    70 void Touch::updateLocation(int screenX, int screenY, int pageX, int pageY)
    71 {
    72     m_clientX = pageX - contentsX(m_frame.get());
    73     m_clientY = pageY - contentsY(m_frame.get());
    74     m_screenX = screenX;
    75     m_screenY = screenY;
    76     m_pageX = pageX;
    77     m_pageY = pageY;
    78 }
    79 
    8069} // namespace WebCore
    8170
  • trunk/WebCore/dom/Touch.h

    r51981 r53994  
    4646    }
    4747
    48     void updateLocation(int screenX, int screenY, int pageX, int pageY);
    49 
    50     Frame* frame() const { return m_frame.get(); }
    5148    EventTarget* target() const { return m_target.get(); }
    5249    unsigned identifier() const { return m_identifier; }
     
    6259            int screenX, int screenY, int pageX, int pageY);
    6360
    64     RefPtr<Frame> m_frame;
    6561    RefPtr<EventTarget> m_target;
    6662    unsigned m_identifier;
  • trunk/WebCore/page/EventHandler.cpp

    r53597 r53994  
    25502550    for (int i = 0; i < points.size(); ++i) {
    25512551        const PlatformTouchPoint& point = points[i];
    2552         IntPoint framePoint = documentPointForWindowPoint(m_frame, point.pos());
    2553         HitTestResult result = hitTestResultAtPoint(framePoint, /*allowShadowContent*/ false);
     2552        IntPoint pagePoint = documentPointForWindowPoint(m_frame, point.pos());
     2553        HitTestResult result = hitTestResultAtPoint(pagePoint, /*allowShadowContent*/ false);
    25542554        Node* target = result.innerNode();
    25552555
     
    25642564            continue;
    25652565
    2566         int adjustedPageX = lroundf(framePoint.x() / m_frame->pageZoomFactor());
    2567         int adjustedPageY = lroundf(framePoint.y() / m_frame->pageZoomFactor());
    2568 
    2569         RefPtr<Touch> touch = Touch::create(m_frame, target, point.id(),
     2566        if (m_frame != doc->frame()) {
     2567            // pagePoint should always be relative to the target elements containing frame.
     2568            pagePoint = documentPointForWindowPoint(doc->frame(), point.pos());
     2569        }
     2570
     2571        int adjustedPageX = lroundf(pagePoint.x() / m_frame->pageZoomFactor());
     2572        int adjustedPageY = lroundf(pagePoint.y() / m_frame->pageZoomFactor());
     2573
     2574        RefPtr<Touch> touch = Touch::create(doc->frame(), target, point.id(),
    25702575                                            point.screenPos().x(), point.screenPos().y(),
    25712576                                            adjustedPageX, adjustedPageY);
     
    25742579            m_touchEventTarget = target;
    25752580            m_firstTouchScreenPos = point.screenPos();
    2576             m_firstTouchPagePos = framePoint;
     2581            m_firstTouchPagePos = pagePoint;
    25772582        }
    25782583
  • trunk/WebCore/platform/PlatformTouchEvent.h

    r53695 r53994  
    5757    PlatformTouchEvent(QTouchEvent*);
    5858#elif PLATFORM(ANDROID)
    59     PlatformTouchEvent(const IntPoint& absolutePagePos, TouchEventType, PlatformTouchPoint::State);
     59    PlatformTouchEvent(const IntPoint& windowPos, TouchEventType, PlatformTouchPoint::State);
    6060#endif
    6161
  • trunk/WebCore/platform/PlatformTouchPoint.h

    r53695 r53994  
    4848    PlatformTouchPoint(const QTouchEvent::TouchPoint&);
    4949#elif PLATFORM(ANDROID)
    50     PlatformTouchPoint(const IntPoint& absolutePagePos, State);
     50    PlatformTouchPoint(const IntPoint& windowPos, State);
    5151#endif
    5252
  • trunk/WebCore/platform/android/PlatformTouchEventAndroid.cpp

    r53695 r53994  
    3131namespace WebCore {
    3232
    33 PlatformTouchEvent::PlatformTouchEvent(const IntPoint& absolutePagePos, TouchEventType type, PlatformTouchPoint::State state)
     33PlatformTouchEvent::PlatformTouchEvent(const IntPoint& windowPos, TouchEventType type, PlatformTouchPoint::State state)
    3434    : m_type(type)
    3535    , m_ctrlKey(false)
     
    3838    , m_metaKey(false)
    3939{
    40     m_touchPoints.append(PlatformTouchPoint(absolutePagePos, state));
     40    m_touchPoints.append(PlatformTouchPoint(windowPos, state));
    4141}
    4242
  • trunk/WebCore/platform/android/PlatformTouchPointAndroid.cpp

    r53695 r53994  
    3131namespace WebCore {
    3232
    33 PlatformTouchPoint::PlatformTouchPoint(const IntPoint& absolutePagePos, State state)
     33PlatformTouchPoint::PlatformTouchPoint(const IntPoint& windowPos, State state)
    3434    : m_id(0)
    3535    , m_state(state)
    36     , m_screenPos(absolutePagePos)
    37     , m_pos(absolutePagePos) { }
     36    , m_screenPos(windowPos)
     37    , m_pos(windowPos) { }
    3838
    3939}
Note: See TracChangeset for help on using the changeset viewer.