[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

aroben at apple.com aroben at apple.com
Wed Dec 22 14:34:51 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 2676c8be82351bd6e9f02bd246e0821eb444c57a
Author: aroben at apple.com <aroben at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Oct 13 17:40:59 2010 +0000

    Let WebCore handle scrolling when the spacebar is pressed on Windows
    
    WebCore already has code to do this, and WebKit2 was doing it on
    keydown instead of keypress, which caused problems with text fields.
    
    WebCore's spacebar-handling code is currently compiled out on Mac and
    Qt, so we continue to handle spacebar in WebKit2 on those platforms.
    
    Fixes <http://webkit.org/b/47544> <rdar://problem/8540645> REGRESSION:
    Pressing spacebar in a text field in WebKit2 does not insert a space,
    scrolls the page instead
    
    Test: WebKit2/SpacebarScrolling
    
    Reviewed by Sam Weinig.
    
    WebKit2:
    
    * WebProcess/WebPage/win/WebPageWin.cpp:
    (WebKit::WebPage::performDefaultBehaviorForKeyEvent):
    Removed handling for spacebar presses. WebCore already does this for
    us, and does it better.
    
    WebKitTools:
    
    Test that pressing the spacebar in a text field does not scroll the
    document
    
    * TestWebKitAPI/PlatformUtilities.h: Added isKeyDown.
    
    * TestWebKitAPI/PlatformWebView.h: Added simulateSpacebarKeyPress.
    
    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    * TestWebKitAPI/win/TestWebKitAPI.vcproj:
    * TestWebKitAPI/win/copy-resources.cmd:
    Added new files.
    
    * TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp: Added.
    (TestWebKitAPI::JavaScriptCallbackContext::JavaScriptCallbackContext):
    We use this to track what the result of calling into JavaScript was.
    (TestWebKitAPI::didFinishLoadForFrame): Records when the page
    finishes loading.
    (TestWebKitAPI::didNotHandleKeyEventCallback): Records when a key down
    event is not handled.
    (TestWebKitAPI::javaScriptCallback): Records that JavaScript finished
    executing and whether the result matched our expectation.
    (TestWebKitAPI::wk): Turns a UTF-8 C string into a WKStringRef.
    (TestWebKitAPI::runJSTest): Calls into JS, waits for the call to
    complete, and returns whether we got back the expected result.
    (TestWebKitAPI::WebKit2_SpacebarScrolling): Tests that pressing
    spacebar inside a text field does not scroll the document and that
    pressing it outside the text field does scroll the document.
    
    * TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html: Added.
    
    * TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
    (TestWebKitAPI::Util::isKeyDown): Checks the event's type.
    
    * TestWebKitAPI/mac/PlatformWebViewMac.mm:
    (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress): Copied
    code from DRT's EventSendingController.
    
    * TestWebKitAPI/win/PlatformUtilitiesWin.cpp:
    (TestWebKitAPI::Util::isKeyDown): Checks the message's type.
    
    * TestWebKitAPI/win/PlatformWebViewWin.cpp:
    (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress): Send the
    same messages that get sent when you press spacebar in Notepad.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69671 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit2/ChangeLog b/WebKit2/ChangeLog
index 36eb7fd..1365846 100644
--- a/WebKit2/ChangeLog
+++ b/WebKit2/ChangeLog
@@ -1,3 +1,26 @@
+2010-10-12  Adam Roben  <aroben at apple.com>
+
+        Let WebCore handle scrolling when the spacebar is pressed on Windows
+
+        WebCore already has code to do this, and WebKit2 was doing it on
+        keydown instead of keypress, which caused problems with text fields.
+
+        WebCore's spacebar-handling code is currently compiled out on Mac and
+        Qt, so we continue to handle spacebar in WebKit2 on those platforms.
+
+        Fixes <http://webkit.org/b/47544> <rdar://problem/8540645> REGRESSION:
+        Pressing spacebar in a text field in WebKit2 does not insert a space,
+        scrolls the page instead
+
+        Test: WebKit2/SpacebarScrolling
+
+        Reviewed by Sam Weinig.
+
+        * WebProcess/WebPage/win/WebPageWin.cpp:
+        (WebKit::WebPage::performDefaultBehaviorForKeyEvent):
+        Removed handling for spacebar presses. WebCore already does this for
+        us, and does it better.
+
 2010-10-12  Jessie Berlin  <jberlin at apple.com>
 
         Reviewed by Jon Honeycutt.
diff --git a/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp b/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
index f5ac858..bbe2186 100644
--- a/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
+++ b/WebKit2/WebProcess/WebPage/win/WebPageWin.cpp
@@ -198,12 +198,6 @@ bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent& keyboard
         else
             m_page->goBack();
         break;
-    case VK_SPACE:
-        if (keyboardEvent.shiftKey())
-            scroll(m_page.get(), ScrollUp, ScrollByPage);
-        else
-            scroll(m_page.get(), ScrollDown, ScrollByPage);
-        break;
     case VK_LEFT:
         scroll(m_page.get(), ScrollLeft, ScrollByLine);
         break;
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index d109bfd..97060f4 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,57 @@
 2010-10-13  Adam Roben  <aroben at apple.com>
 
+        Test that pressing the spacebar in a text field does not scroll the
+        document
+
+        Test for <http://webkit.org/b/47544> <rdar://problem/8540645>
+        REGRESSION: Pressing spacebar in a text field in WebKit2 does not
+        insert a space, scrolls the page instead
+
+        Reviewed by Sam Weinig.
+
+        * TestWebKitAPI/PlatformUtilities.h: Added isKeyDown.
+
+        * TestWebKitAPI/PlatformWebView.h: Added simulateSpacebarKeyPress.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/win/TestWebKitAPI.vcproj:
+        * TestWebKitAPI/win/copy-resources.cmd:
+        Added new files.
+
+        * TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp: Added.
+        (TestWebKitAPI::JavaScriptCallbackContext::JavaScriptCallbackContext):
+        We use this to track what the result of calling into JavaScript was.
+        (TestWebKitAPI::didFinishLoadForFrame): Records when the page
+        finishes loading.
+        (TestWebKitAPI::didNotHandleKeyEventCallback): Records when a key down
+        event is not handled.
+        (TestWebKitAPI::javaScriptCallback): Records that JavaScript finished
+        executing and whether the result matched our expectation.
+        (TestWebKitAPI::wk): Turns a UTF-8 C string into a WKStringRef.
+        (TestWebKitAPI::runJSTest): Calls into JS, waits for the call to
+        complete, and returns whether we got back the expected result.
+        (TestWebKitAPI::WebKit2_SpacebarScrolling): Tests that pressing
+        spacebar inside a text field does not scroll the document and that
+        pressing it outside the text field does scroll the document.
+
+        * TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html: Added.
+
+        * TestWebKitAPI/mac/PlatformUtilitiesMac.mm:
+        (TestWebKitAPI::Util::isKeyDown): Checks the event's type.
+
+        * TestWebKitAPI/mac/PlatformWebViewMac.mm:
+        (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress): Copied
+        code from DRT's EventSendingController.
+
+        * TestWebKitAPI/win/PlatformUtilitiesWin.cpp:
+        (TestWebKitAPI::Util::isKeyDown): Checks the message's type.
+
+        * TestWebKitAPI/win/PlatformWebViewWin.cpp:
+        (TestWebKitAPI::PlatformWebView::simulateSpacebarKeyPress): Send the
+        same messages that get sent when you press spacebar in Notepad.
+
+2010-10-13  Adam Roben  <aroben at apple.com>
+
         Fix a couple of issues with the TestWebKitAPI build
 
         * TestWebKitAPI/Configurations/TestWebKitAPICFLite.vsprops:
diff --git a/WebKitTools/TestWebKitAPI/PlatformUtilities.h b/WebKitTools/TestWebKitAPI/PlatformUtilities.h
index 2101259..988e256 100644
--- a/WebKitTools/TestWebKitAPI/PlatformUtilities.h
+++ b/WebKitTools/TestWebKitAPI/PlatformUtilities.h
@@ -40,6 +40,8 @@ void run(bool* done);
 WKURLRef createURLForResource(const char* resource, const char* extension);
 WKURLRef URLForNonExistentResource();
 
+bool isKeyDown(WKNativeEventPtr);
+
 inline std::string toSTD(WKStringRef string)
 {
     size_t bufferSize = WKStringGetMaximumUTF8CStringSize(string);
diff --git a/WebKitTools/TestWebKitAPI/PlatformWebView.h b/WebKitTools/TestWebKitAPI/PlatformWebView.h
index de8e1ce..e5db190 100644
--- a/WebKitTools/TestWebKitAPI/PlatformWebView.h
+++ b/WebKitTools/TestWebKitAPI/PlatformWebView.h
@@ -53,6 +53,8 @@ public:
     void resizeTo(unsigned width, unsigned height);
     void focus();
 
+    void simulateSpacebarKeyPress();
+
 private:
     PlatformWKView m_view;
     PlatformWindow m_window;
diff --git a/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
index 2d7b21d..4815a6f 100644
--- a/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
+++ b/WebKitTools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
@@ -25,6 +25,9 @@
 		BCBD3737125ABBEB00D2C29F /* icon.png in Copy Resources */ = {isa = PBXBuildFile; fileRef = BCBD372E125ABBE600D2C29F /* icon.png */; };
 		BCBD3761125ABCFE00D2C29F /* FrameMIMETypePNG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCBD3760125ABCFE00D2C29F /* FrameMIMETypePNG.cpp */; };
 		BCC8B95B12611F4700DE46A4 /* FailedLoad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC8B95A12611F4700DE46A4 /* FailedLoad.cpp */; };
+		C01A23F21266156700C9ED55 /* spacebar-scrolling.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = C02B7882126615410026BF0F /* spacebar-scrolling.html */; };
+		C02B77F2126612140026BF0F /* SpacebarScrolling.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */; };
+		C02B7854126613AE0026BF0F /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C02B7853126613AE0026BF0F /* Carbon.framework */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXCopyFilesBuildPhase section */
@@ -46,6 +49,7 @@
 				BCBD3737125ABBEB00D2C29F /* icon.png in Copy Resources */,
 				1A02C870125D4CFD00E3F4BD /* find.html in Copy Resources */,
 				BC909784125571CF00083756 /* simple.html in Copy Resources */,
+				C01A23F21266156700C9ED55 /* spacebar-scrolling.html in Copy Resources */,
 			);
 			name = "Copy Resources";
 			runOnlyForDeploymentPostprocessing = 0;
@@ -80,6 +84,9 @@
 		BCBD372E125ABBE600D2C29F /* icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = icon.png; sourceTree = "<group>"; };
 		BCBD3760125ABCFE00D2C29F /* FrameMIMETypePNG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameMIMETypePNG.cpp; sourceTree = "<group>"; };
 		BCC8B95A12611F4700DE46A4 /* FailedLoad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FailedLoad.cpp; sourceTree = "<group>"; };
+		C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SpacebarScrolling.cpp; sourceTree = "<group>"; };
+		C02B7853126613AE0026BF0F /* Carbon.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; name = Carbon.framework; sourceTree = SDKROOT; };
+		C02B7882126615410026BF0F /* spacebar-scrolling.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "spacebar-scrolling.html"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -90,6 +97,7 @@
 				BCB9E9F111235BDE00A137E0 /* Cocoa.framework in Frameworks */,
 				BCA61DB511700EFD00460D1E /* WebKit2.framework in Frameworks */,
 				BC90964E1255620C00083756 /* JavaScriptCore.framework in Frameworks */,
+				C02B7854126613AE0026BF0F /* Carbon.framework in Frameworks */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -128,6 +136,7 @@
 				BCB9E9F011235BDE00A137E0 /* Cocoa.framework */,
 				BC90964D1255620C00083756 /* JavaScriptCore.framework */,
 				BCA61DB411700EFD00460D1E /* WebKit2.framework */,
+				C02B7853126613AE0026BF0F /* Carbon.framework */,
 			);
 			name = "External Frameworks and Libraries";
 			sourceTree = "<group>";
@@ -158,6 +167,7 @@
 				BCBD370F125AA2EB00D2C29F /* FrameMIMETypeHTML.cpp */,
 				BCBD3760125ABCFE00D2C29F /* FrameMIMETypePNG.cpp */,
 				BC909779125571AB00083756 /* PageLoadBasic.cpp */,
+				C02B77F1126612140026BF0F /* SpacebarScrolling.cpp */,
 				BC90995D12567BC100083756 /* WKString.cpp */,
 				BC9099931256ACF100083756 /* WKStringJSString.cpp */,
 				BCC8B95A12611F4700DE46A4 /* FailedLoad.cpp */,
@@ -179,6 +189,7 @@
 				BCBD372E125ABBE600D2C29F /* icon.png */,
 				1A02C84B125D4A5E00E3F4BD /* find.html */,
 				BC909778125571AB00083756 /* simple.html */,
+				C02B7882126615410026BF0F /* spacebar-scrolling.html */,
 			);
 			name = Resources;
 			sourceTree = "<group>";
@@ -265,6 +276,7 @@
 				BCBD3761125ABCFE00D2C29F /* FrameMIMETypePNG.cpp in Sources */,
 				1A02C84F125D4A8400E3F4BD /* Find.cpp in Sources */,
 				BCC8B95B12611F4700DE46A4 /* FailedLoad.cpp in Sources */,
+				C02B77F2126612140026BF0F /* SpacebarScrolling.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp b/WebKitTools/TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp
new file mode 100644
index 0000000..a88db9f
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/Tests/WebKit2/SpacebarScrolling.cpp
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "Test.h"
+
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+struct JavaScriptCallbackContext {
+    JavaScriptCallbackContext(const char* expectedString) : didFinish(false), expectedString(expectedString), didMatchExpectedString(false) { }
+
+    bool didFinish;
+    const char* expectedString;
+    bool didMatchExpectedString;
+};
+
+static bool didFinishLoad;
+static bool didNotHandleKeyDownEvent;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+    didFinishLoad = true;
+}
+
+static void didNotHandleKeyEventCallback(WKPageRef, WKNativeEventPtr event, const void*)
+{
+    if (Util::isKeyDown(event))
+        didNotHandleKeyDownEvent = true;
+}
+
+static void javaScriptCallback(WKStringRef string, WKErrorRef error, void* ctx)
+{
+    JavaScriptCallbackContext* context = static_cast<JavaScriptCallbackContext*>(ctx);
+
+    context->didFinish = true;
+    context->didMatchExpectedString = WKStringIsEqualToUTF8CString(string, context->expectedString);
+
+    TEST_ASSERT(!error);
+}
+
+static WKRetainPtr<WKStringRef> wk(const char* utf8String)
+{
+    return WKRetainPtr<WKStringRef>(AdoptWK, WKStringCreateWithUTF8CString(utf8String));
+}
+
+static bool runJSTest(WKPageRef page, const char* script, const char* expectedResult)
+{
+    JavaScriptCallbackContext context(expectedResult);
+    WKPageRunJavaScriptInMainFrame(page, wk(script).get(), &context, javaScriptCallback);
+    Util::run(&context.didFinish);
+    return context.didMatchExpectedString;
+}
+
+TEST(WebKit2, SpacebarScrolling)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
+    WKRetainPtr<WKPageNamespaceRef> pageNamespace(AdoptWK, WKPageNamespaceCreate(context.get()));
+
+    PlatformWebView webView(pageNamespace.get());
+
+    WKPageLoaderClient loaderClient;
+    memset(&loaderClient, 0, sizeof(loaderClient));
+    
+    loaderClient.version = 0;
+    loaderClient.didFinishLoadForFrame = didFinishLoadForFrame;
+    WKPageSetPageLoaderClient(webView.page(), &loaderClient);
+
+    WKPageUIClient uiClient;
+    memset(&uiClient, 0, sizeof(uiClient));
+
+    uiClient.didNotHandleKeyEvent = didNotHandleKeyEventCallback;
+    WKPageSetPageUIClient(webView.page(), &uiClient);
+
+    WKRetainPtr<WKURLRef> url(AdoptWK, Util::createURLForResource("spacebar-scrolling", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+    Util::run(&didFinishLoad);
+
+    TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "false"));
+    TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "false"));
+
+    webView.simulateSpacebarKeyPress();
+
+    TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "false"));
+    TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "true"));
+
+    // On Mac, a key down event represents both a raw key down and a key press. On Windows, a key
+    // down event only represents a raw key down. We expect the key press to be handled (because it
+    // inserts text into the text field). But the raw key down should not be handled.
+#if PLATFORM(MAC)
+    TEST_ASSERT(!didNotHandleKeyDownEvent);
+#elif PLATFORM(WIN)
+    TEST_ASSERT(didNotHandleKeyDownEvent);
+#endif
+
+    TEST_ASSERT(runJSTest(webView.page(), "blurTextField()", "undefined"));
+
+    didNotHandleKeyDownEvent = false;
+    webView.simulateSpacebarKeyPress();
+
+    TEST_ASSERT(runJSTest(webView.page(), "isDocumentScrolled()", "true"));
+    TEST_ASSERT(runJSTest(webView.page(), "textFieldContainsSpace()", "true"));
+#if PLATFORM(MAC)
+    TEST_ASSERT(!didNotHandleKeyDownEvent);
+#elif PLATFORM(WIN)
+    TEST_ASSERT(didNotHandleKeyDownEvent);
+#endif
+}
+
+} // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html b/WebKitTools/TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html
new file mode 100644
index 0000000..8da08b3
--- /dev/null
+++ b/WebKitTools/TestWebKitAPI/Tests/WebKit2/spacebar-scrolling.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script>
+    function textFieldContainsSpace()
+    {
+        return document.querySelector("input").value === " ";
+    }
+
+    function blurTextField()
+    {
+        document.querySelector("input").blur();
+    }
+
+    function isDocumentScrolled()
+    {
+        return scrollY !== 0;
+    }
+
+    function loaded()
+    {
+        document.querySelector("input").focus();
+    }
+
+    addEventListener("load", loaded);
+</script>
+<input>
+<div style="height: 3000px;"></div>
diff --git a/WebKitTools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm b/WebKitTools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm
index b452950..e5a8bd7 100644
--- a/WebKitTools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm
+++ b/WebKitTools/TestWebKitAPI/mac/PlatformUtilitiesMac.mm
@@ -49,5 +49,10 @@ WKURLRef URLForNonExistentResource()
     return WKURLCreateWithCFURL((CFURLRef)nsURL);
 }
 
+bool isKeyDown(WKNativeEventPtr event)
+{
+    return [event type] == NSKeyDown;
+}
+
 } // namespace Util
 } // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/mac/PlatformWebViewMac.mm b/WebKitTools/TestWebKitAPI/mac/PlatformWebViewMac.mm
index c8f04c8..d4c31eb 100644
--- a/WebKitTools/TestWebKitAPI/mac/PlatformWebViewMac.mm
+++ b/WebKitTools/TestWebKitAPI/mac/PlatformWebViewMac.mm
@@ -25,6 +25,8 @@
 
 #include "PlatformWebView.h"
 
+#import <Carbon/Carbon.h>
+
 namespace TestWebKitAPI {
 
 PlatformWebView::PlatformWebView(WKPageNamespaceRef namespaceRef)
@@ -63,4 +65,33 @@ void PlatformWebView::focus()
     // Implement.
 }
 
+void PlatformWebView::simulateSpacebarKeyPress()
+{
+    NSEvent *event = [NSEvent keyEventWithType:NSKeyDown
+                                      location:NSMakePoint(5, 5)
+                                 modifierFlags:0
+                                     timestamp:GetCurrentEventTime()
+                                  windowNumber:[m_window windowNumber]
+                                       context:[NSGraphicsContext currentContext]
+                                    characters:@" "
+                   charactersIgnoringModifiers:@" "
+                                     isARepeat:NO
+                                       keyCode:0x31];
+
+    [m_view keyDown:event];
+
+    event = [NSEvent keyEventWithType:NSKeyUp
+                             location:NSMakePoint(5, 5)
+                        modifierFlags:0
+                            timestamp:GetCurrentEventTime()
+                         windowNumber:[m_window windowNumber]
+                              context:[NSGraphicsContext currentContext]
+                           characters:@" "
+          charactersIgnoringModifiers:@" "
+                            isARepeat:NO
+                              keyCode:0x31];
+
+    [m_view keyUp:event];
+}
+
 } // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp b/WebKitTools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp
index 1688ba7..4ced578 100644
--- a/WebKitTools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp
+++ b/WebKitTools/TestWebKitAPI/win/PlatformUtilitiesWin.cpp
@@ -59,5 +59,10 @@ WKURLRef URLForNonExistentResource()
     return WKURLCreateWithUTF8CString("file:///does-not-exist.html");
 }
 
+bool isKeyDown(WKNativeEventPtr event)
+{
+    return event->message == WM_KEYDOWN;
+}
+
 } // namespace Util
 } // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/win/PlatformWebViewWin.cpp b/WebKitTools/TestWebKitAPI/win/PlatformWebViewWin.cpp
index 502dd63..04dc83b 100644
--- a/WebKitTools/TestWebKitAPI/win/PlatformWebViewWin.cpp
+++ b/WebKitTools/TestWebKitAPI/win/PlatformWebViewWin.cpp
@@ -66,4 +66,20 @@ WKPageRef PlatformWebView::page()
     return WKViewGetPage(m_view);
 }
 
+void PlatformWebView::simulateSpacebarKeyPress()
+{
+    HWND window = WKViewGetWindow(m_view);
+
+    // These offsets come from rom <http://msdn.microsoft.com/en-us/library/ms646280(VS.85).aspx>.
+    static const size_t repeatCountBitOffset = 0;
+    static const size_t scanCodeBitOffset = 16;
+    static const size_t previousStateBitOffset = 30;
+    static const size_t transitionStateBitOffset = 31;
+
+    // These values match what happens when you press the spacebar in Notepad, as observed by Spy++.
+    ::SendMessageW(window, WM_KEYDOWN, VK_SPACE, (1 << repeatCountBitOffset) | (39 << scanCodeBitOffset));
+    ::SendMessageW(window, WM_CHAR, ' ', (1 << repeatCountBitOffset) | (39 << scanCodeBitOffset));
+    ::SendMessageW(window, WM_KEYUP, VK_SPACE, (1 << repeatCountBitOffset) | (39 << scanCodeBitOffset) | (1 << previousStateBitOffset) | (1 << transitionStateBitOffset));
+}
+
 } // namespace TestWebKitAPI
diff --git a/WebKitTools/TestWebKitAPI/win/TestWebKitAPI.vcproj b/WebKitTools/TestWebKitAPI/win/TestWebKitAPI.vcproj
index 2ea7050..0c8b83c 100644
--- a/WebKitTools/TestWebKitAPI/win/TestWebKitAPI.vcproj
+++ b/WebKitTools/TestWebKitAPI/win/TestWebKitAPI.vcproj
@@ -421,6 +421,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\Tests\WebKit2\find.html"
+					>
+				</File>
+				<File
 					RelativePath="..\Tests\WebKit2\FrameMIMETypeHTML.cpp"
 					>
 				</File>
@@ -429,10 +433,26 @@
 					>
 				</File>
 				<File
+					RelativePath="..\Tests\WebKit2\icon.png"
+					>
+				</File>
+				<File
 					RelativePath="..\Tests\WebKit2\PageLoadBasic.cpp"
 					>
 				</File>
 				<File
+					RelativePath="..\Tests\WebKit2\simple.html"
+					>
+				</File>
+				<File
+					RelativePath="..\Tests\WebKit2\spacebar-scrolling.html"
+					>
+				</File>
+				<File
+					RelativePath="..\Tests\WebKit2\SpacebarScrolling.cpp"
+					>
+				</File>
+				<File
 					RelativePath="..\Tests\WebKit2\WKString.cpp"
 					>
 				</File>
diff --git a/WebKitTools/TestWebKitAPI/win/copy-resources.cmd b/WebKitTools/TestWebKitAPI/win/copy-resources.cmd
index fd03d44..a5b8406 100755
--- a/WebKitTools/TestWebKitAPI/win/copy-resources.cmd
+++ b/WebKitTools/TestWebKitAPI/win/copy-resources.cmd
@@ -11,6 +11,7 @@ for %%f in (
     ..\Tests\WebKit2\find.html
     ..\Tests\WebKit2\icon.png
     ..\Tests\WebKit2\simple.html
+    ..\Tests\WebKit2\spacebar-scrolling.html
 ) do (
     xcopy /y /d %%f "%ResourcesDirectory%"
 )

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list