2009-06-26 Yongjun Zhang <yongjun.zhang@nokia.com>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jun 2009 10:06:33 +0000 (10:06 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jun 2009 10:06:33 +0000 (10:06 +0000)
        Reviewed by Eric Seidel.

        Bug 20303: [Qt] Key events are not working in frames.

        Add a layout test to test the event is sent to the right sub-frame.

        * platform/qt/fast/events/event-sender-keydown-frame-expected.txt: Added.
        * platform/qt/fast/events/event-sender-keydown-frame.html: Added.

2009-06-26  Yongjun Zhang  <yongjun.zhang@nokia.com>

        Reviewed by Eric Seidel.

        Test: platform/qt/fast/events/event-sender-keydown-frame.html

        Bug 20303: [Qt] Key events are not working in frames.

        Merge scrolling handling code in qt and win port, move it to
        EventHandler.

        * page/EventHandler.cpp:
        (WebCore::EventHandler::scrollRecursively):
        * page/EventHandler.h:

2009-06-26  Yongjun Zhang  <yongjun.zhang@nokia.com>

        Reviewed by Eric Seidel.

        Bug 20303: [Qt] Key events are not working in frames.

        Send scrolling events to current focused frame, bubble the event
        up to parent frame if it is not handled.  Use EventHandler's new
        shared scrolling code.

        * Api/qwebpage.cpp:
        (QWebPagePrivate::keyPressEvent):
        (QWebPagePrivate::handleScrolling):
        * Api/qwebpage_p.h:

2009-06-26  Yongjun Zhang  <yongjun.zhang@nokia.com>

        Reviewed by Eric Seidel.

        Bug 20303: [Qt] Key events are not working in frames.

        Move the scroll handling code to EventHandler so that other
        ports can share the functionality.

        * WebView.cpp:
        (WebView::keyDown):
        (EnumTextMatches::QueryInterface):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@45257 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/qt/fast/events/event-sender-keydown-frame-expected.txt [new file with mode: 0644]
LayoutTests/platform/qt/fast/events/event-sender-keydown-frame.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/page/EventHandler.cpp
WebCore/page/EventHandler.h
WebKit/qt/Api/qwebpage.cpp
WebKit/qt/Api/qwebpage_p.h
WebKit/qt/ChangeLog
WebKit/win/ChangeLog
WebKit/win/WebView.cpp

index 9577d10..f21ed17 100644 (file)
@@ -1,3 +1,14 @@
+2009-06-26  Yongjun Zhang  <yongjun.zhang@nokia.com>
+
+        Reviewed by Eric Seidel.
+
+        Bug 20303: [Qt] Key events are not working in frames.
+
+        Add a layout test to test the event is sent to the right sub-frame.
+
+        * platform/qt/fast/events/event-sender-keydown-frame-expected.txt: Added.
+        * platform/qt/fast/events/event-sender-keydown-frame.html: Added.
+
 2009-06-26  Rob Buis  <rwlbuis@gmail.com>
 
         Reviewed by Eric Seidel.
diff --git a/LayoutTests/platform/qt/fast/events/event-sender-keydown-frame-expected.txt b/LayoutTests/platform/qt/fast/events/event-sender-keydown-frame-expected.txt
new file mode 100644 (file)
index 0000000..89c1be3
--- /dev/null
@@ -0,0 +1,4 @@
+Test for bug 20303: [Qt] key events are not working in frames.
+
+
+SUCCESS
diff --git a/LayoutTests/platform/qt/fast/events/event-sender-keydown-frame.html b/LayoutTests/platform/qt/fast/events/event-sender-keydown-frame.html
new file mode 100644 (file)
index 0000000..92a090a
--- /dev/null
@@ -0,0 +1,53 @@
+<head>
+</head>
+<body>
+    <p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=20303">bug 20303</a>:
+    [Qt] key events are not working in frames.</p>
+<script>
+    function reportIFramePos()
+    {
+        var x = document.getElementById("anIFrame").contentDocument.body.scrollLeft;
+        var y = document.getElementById("anIFrame").contentDocument.body.scrollTop;
+
+        // result, the iframe should be scrolled down
+        if (y > 0)
+            document.getElementById("console").innerHTML = "SUCCESS";
+        else
+            document.getElementById("console").innerHTML = "FAILURE";
+    }
+
+    function testAndReport() {
+         if (window.layoutTestController)
+            layoutTestController.dumpAsText();
+
+        if (window.eventSender) {
+            var frame = document.getElementById("anIFrame");
+
+            // center the mouse cursor
+            var x = frame.offsetLeft + frame.offsetWidth/2;
+            var y = frame.offsetTop + frame.offsetHeight/2;
+
+            // send mouse event to focus the iframe
+            eventSender.mouseMoveTo(x, y);
+            eventSender.mouseDown();
+            eventSender.mouseUp();
+
+            // send key down event
+            eventSender.keyDown('\uf701');
+
+            // report
+            reportIFramePos();
+            layoutTestController.notifyDone();
+        }
+    }
+</script>
+
+<iframe style="width:350px;border:dotted green 1px" width="200" height="200"
+ id="anIFrame" src="resources/divs.html" onload="javascript:testAndReport()"></iframe>
+</iframe>
+<div id="result">
+</div>
+<div id="console">
+</div>
+</body>
+</html>
index f081954..41064e7 100644 (file)
@@ -1,3 +1,18 @@
+2009-06-26  Yongjun Zhang  <yongjun.zhang@nokia.com>
+
+        Reviewed by Eric Seidel.
+
+        Test: platform/qt/fast/events/event-sender-keydown-frame.html
+
+        Bug 20303: [Qt] Key events are not working in frames.
+
+        Merge scrolling handling code in qt and win port, move it to
+        EventHandler.
+
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::scrollRecursively):
+        * page/EventHandler.h:
+
 2009-06-26  Rob Buis  <rwlbuis@gmail.com>
 
         Reviewed by Eric Seidel.
index e412939..329c3a7 100644 (file)
@@ -856,6 +856,21 @@ bool EventHandler::scrollOverflow(ScrollDirection direction, ScrollGranularity g
     return false;
 }
 
+bool EventHandler::scrollRecursively(ScrollDirection direction, ScrollGranularity granularity)
+{
+    bool handled = scrollOverflow(direction, granularity);
+    if (!handled) {
+        Frame* frame = m_frame;
+        do {
+            FrameView* view = frame->view();
+            handled = view ? view->scroll(direction, granularity) : false;
+            frame = frame->tree()->parent();
+        } while (!handled && frame);
+     }
+
+    return handled;
+}
+
 IntPoint EventHandler::currentMousePosition() const
 {
     return m_currentMousePosition;
index 06ed956..583122c 100644 (file)
@@ -109,6 +109,8 @@ public:
 
     bool scrollOverflow(ScrollDirection, ScrollGranularity);
 
+    bool scrollRecursively(ScrollDirection, ScrollGranularity);
+
     bool shouldDragAutoNode(Node*, const IntPoint&) const; // -webkit-user-drag == auto
 
     bool tabsToLinks(KeyboardEvent*) const;
index 92e61db..5c2214d 100644 (file)
@@ -796,7 +796,7 @@ void QWebPagePrivate::keyPressEvent(QKeyEvent *ev)
             defaultFont = view->font();
         QFontMetrics fm(defaultFont);
         int fontHeight = fm.height();
-        if (!handleScrolling(ev)) {
+        if (!handleScrolling(ev, frame)) {
             switch (ev->key()) {
             case Qt::Key_Back:
                 q->triggerAction(QWebPage::Back);
@@ -999,7 +999,7 @@ void QWebPagePrivate::shortcutOverrideEvent(QKeyEvent* event)
     }
 }
 
-bool QWebPagePrivate::handleScrolling(QKeyEvent *ev)
+bool QWebPagePrivate::handleScrolling(QKeyEvent *ev, Frame *frame)
 {
     ScrollDirection direction;
     ScrollGranularity granularity;
@@ -1046,10 +1046,7 @@ bool QWebPagePrivate::handleScrolling(QKeyEvent *ev)
         }
     }
 
-    if (!mainFrame->d->frame->eventHandler()->scrollOverflow(direction, granularity))
-        mainFrame->d->frame->view()->scroll(direction, granularity);
-
-    return true;
+    return frame->eventHandler()->scrollRecursively(direction, granularity);
 }
 
 /*!
index a897bf1..984bec1 100644 (file)
@@ -45,6 +45,7 @@ namespace WebCore
     class Element;
     class Node;
     class Page;
+    class Frame;
 
 #ifndef QT_NO_CURSOR
     class SetCursorEvent : public QEvent {
@@ -113,7 +114,7 @@ public:
 
     void shortcutOverrideEvent(QKeyEvent*);
     void leaveEvent(QEvent *);
-    bool handleScrolling(QKeyEvent*);
+    bool handleScrolling(QKeyEvent*, WebCore::Frame*);
 
 #ifndef QT_NO_SHORTCUT
     static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
index 7da1014..38935a4 100644 (file)
@@ -1,3 +1,18 @@
+2009-06-26  Yongjun Zhang  <yongjun.zhang@nokia.com>
+
+        Reviewed by Eric Seidel.
+
+        Bug 20303: [Qt] Key events are not working in frames.
+
+        Send scrolling events to current focused frame, bubble the event
+        up to parent frame if it is not handled.  Use EventHandler's new
+        shared scrolling code.
+
+        * Api/qwebpage.cpp:
+        (QWebPagePrivate::keyPressEvent):
+        (QWebPagePrivate::handleScrolling):
+        * Api/qwebpage_p.h:
+
 2009-06-25  Jakub Wieczorek  <faw217@gmail.com>
 
         Reviewed by Adam Treat.
index d1600f6..410d972 100644 (file)
@@ -1,3 +1,16 @@
+2009-06-26  Yongjun Zhang  <yongjun.zhang@nokia.com>
+
+        Reviewed by Eric Seidel.
+
+        Bug 20303: [Qt] Key events are not working in frames.
+
+        Move the scroll handling code to EventHandler so that other
+        ports can share the functionality.
+
+        * WebView.cpp:
+        (WebView::keyDown):
+        (EnumTextMatches::QueryInterface):
+
 2009-06-23  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Darin Adler.
index 8c1f713..4faa3ba 100644 (file)
@@ -1722,15 +1722,7 @@ bool WebView::keyDown(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
             return false;
     }
 
-    if (!frame->eventHandler()->scrollOverflow(direction, granularity)) {
-        handled = frame->view()->scroll(direction, granularity);
-        Frame* parent = frame->tree()->parent();
-        while(!handled && parent) {
-            handled = parent->view()->scroll(direction, granularity);
-            parent = parent->tree()->parent();
-        }
-    }
-    return handled;
+    return frame->eventHandler()->scrollRecursively(direction, granularity);
 }
 
 bool WebView::keyPress(WPARAM charCode, LPARAM keyData, bool systemKeyDown)