Reviewed by Adele.
authorap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Dec 2007 22:17:13 +0000 (22:17 +0000)
committerap@webkit.org <ap@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Dec 2007 22:17:13 +0000 (22:17 +0000)
        http://bugs.webkit.org/show_bug.cgi?id=16421
        REGRESSION(r28669): Page scrolls down when you hit space key in text area

        Test: fast/events/space-scroll-event.html

        * WebView.cpp:
        (WebView::keyDown):
        (WebView::keyPress):
        Moved space handliing to keyPress() to fix this bug and to match IE. Scrolling via arrow keys is correctly handled
        in keyDown().

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

LayoutTests/ChangeLog
LayoutTests/fast/events/space-scroll-event-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/space-scroll-event.html [new file with mode: 0644]
WebKit/win/ChangeLog
WebKit/win/WebView.cpp

index e4c93faa30b09051ed85b39f7d8a01c5dbe52a73..eba3db2cb5765d2982b6977778405fe05c60b589 100644 (file)
@@ -1,3 +1,13 @@
+2007-12-13  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Adele.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16421
+        REGRESSION(r28669): Page scrolls down when you hit space key in text area
+
+        * fast/events/space-scroll-event-expected.txt: Added.
+        * fast/events/space-scroll-event.html: Added.
+
 2007-12-13  Justin Garcia  <justin.garcia@apple.com>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/events/space-scroll-event-expected.txt b/LayoutTests/fast/events/space-scroll-event-expected.txt
new file mode 100644 (file)
index 0000000..24f0da5
--- /dev/null
@@ -0,0 +1,5 @@
+Test for bug 16241: REGRESSION(r28669): Page scrolls down when you hit space key in text area.
+
+To test manually, press Space - the page should not scroll.
+
+
diff --git a/LayoutTests/fast/events/space-scroll-event.html b/LayoutTests/fast/events/space-scroll-event.html
new file mode 100644 (file)
index 0000000..db0c899
--- /dev/null
@@ -0,0 +1,15 @@
+<body>
+<p>Test for <a href="http://bugs.webkit.org/show_bug.cgi?id=16421">bug 16241</a>:
+REGRESSION(r28669): Page scrolls down when you hit space key in text area.</p>
+<p>To test manually, press Space - the page should not scroll.</p>
+<div style="width:1;height:5000"></div>
+<script>
+document.onkeypress=function(){return false;}
+document.onscroll=function(){alert("FAIL - scrolled!");}
+
+if (window.layoutTestController) {
+    layoutTestController.dumpAsText();
+    eventSender.keyDown(" ", []);
+}
+</script>
+</body>
index 1f3b0b013b6822226de8bef02cab29d2e0e4e85e..3dba4f8b4984f76e528bd6d61a992f7d692fdc93 100644 (file)
@@ -1,3 +1,18 @@
+2007-12-13  Alexey Proskuryakov  <ap@webkit.org>
+
+        Reviewed by Adele.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16421
+        REGRESSION(r28669): Page scrolls down when you hit space key in text area
+
+        Test: fast/events/space-scroll-event.html
+
+        * WebView.cpp:
+        (WebView::keyDown):
+        (WebView::keyPress):
+        Moved space handliing to keyPress() to fix this bug and to match IE. Scrolling via arrow keys is correctly handled
+        in keyDown().
+
 2007-12-12  Brady Eidson  <beidson@apple.com>
 
         Reviewed by Sam Weinig
index 37dc3ff935bc2bba21171fc0ab512963decf6d21..6331a9b59e07d5cc70830c54b1836cd569203835 100644 (file)
@@ -1441,7 +1441,7 @@ bool WebView::keyDown(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
     else if (virtualKeyCode == VK_BACK || (virtualKeyCode == VK_LEFT && keyEvent.ctrlKey()))
         m_page->goBack();
     
-    // Need to scroll the page if the arrow keys, space(shift), pgup/dn, or home/end are hit.
+    // Need to scroll the page if the arrow keys, pgup/dn, or home/end are hit.
     ScrollDirection direction;
     ScrollGranularity granularity;
     switch (virtualKeyCode) {
@@ -1469,10 +1469,6 @@ bool WebView::keyDown(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
             granularity = ScrollByDocument;
             direction = ScrollDown;
             break;
-        case VK_SPACE:
-            granularity = ScrollByPage;
-            direction = (GetKeyState(VK_SHIFT) & 0x8000) ? ScrollUp : ScrollDown;
-            break;
         case VK_PRIOR:
             granularity = ScrollByPage;
             direction = ScrollUp;
@@ -1482,8 +1478,6 @@ bool WebView::keyDown(WPARAM virtualKeyCode, LPARAM keyData, bool systemKeyDown)
             direction = ScrollDown;
             break;
         default:
-            // We want to let Windows handle the WM_SYSCHAR event if we can't handle it
-            // We do want to return true for regular key down case so the WM_CHAR handler won't pick up unhandled messages
             return false;
     }
 
@@ -1497,7 +1491,17 @@ bool WebView::keyPress(WPARAM charCode, LPARAM keyData, bool systemKeyDown)
     Frame* frame = m_page->focusController()->focusedOrMainFrame();
 
     PlatformKeyboardEvent keyEvent(m_viewWindow, charCode, keyData, PlatformKeyboardEvent::Char, systemKeyDown);
-    return frame->eventHandler()->keyEvent(keyEvent);
+    if (frame->eventHandler()->keyEvent(keyEvent))
+        return true;
+
+    // Need to scroll the page if space is hit.
+    if (charCode == ' ') {
+        ScrollDirection direction = keyEvent.shiftKey() ? ScrollUp : ScrollDown;
+        if (!frame->eventHandler()->scrollOverflow(direction, ScrollByPage))
+            frame->view()->scroll(direction, ScrollByPage);
+        return true;
+    }
+    return false;
 }
 
 bool WebView::inResizer(LPARAM lParam)