Title: [153907] trunk
Revision
153907
Author
[email protected]
Date
2013-08-09 12:58:51 -0700 (Fri, 09 Aug 2013)

Log Message

AX: Not able to use arrow keys to read text in a WK2 app
https://bugs.webkit.org/show_bug.cgi?id=119605
-and corresponding-
<rdar://problem/14281275>

Reviewed by Darin Adler.

Source/WebCore: 

This code from defaultKeyboardEventHandler() is the magic that makes this AX 
functionality work. This patch moves that into a separate function so that we can 
call it from WK2.
* WebCore.exp.in:
* page/EventHandler.cpp:
(WebCore::EventHandler::handleKeyboardSelectionMovementForAccessibility):
(WebCore::EventHandler::defaultKeyboardEventHandler):
* page/EventHandler.h:

Source/WebKit2: 

Make all of these scrolling functions actually return the WebCore bools that 
indicate whether or not scrolling happened. 
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::scroll):
(WebKit::WebPage::logicalScroll):
(WebKit::WebPage::scrollBy):
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::executeKeypressCommandsInternal):

This function now gives accessibility a chance to handle the event too. And it 
also actually tracks whether or not the event was handled by scrolling instead of 
assuming that it was and universally returning true.
(WebKit::WebPage::performNonEditingBehaviorForSelector):

Tools: 

New test verifies that didNotHandleKeyEvent will be called when there is nothing 
to scroll. 
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp: Added.
(TestWebKitAPI::didFinishLoadForFrame):
(TestWebKitAPI::didNotHandleKeyEventCallback):
(TestWebKitAPI::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (153906 => 153907)


--- trunk/Source/WebCore/ChangeLog	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Source/WebCore/ChangeLog	2013-08-09 19:58:51 UTC (rev 153907)
@@ -1,3 +1,21 @@
+2013-08-09  Beth Dakin  <[email protected]>
+
+        AX: Not able to use arrow keys to read text in a WK2 app
+        https://bugs.webkit.org/show_bug.cgi?id=119605
+        -and corresponding-
+        <rdar://problem/14281275>
+
+        Reviewed by Darin Adler.
+
+        This code from defaultKeyboardEventHandler() is the magic that makes this AX 
+        functionality work. This patch moves that into a separate function so that we can 
+        call it from WK2.
+        * WebCore.exp.in:
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::handleKeyboardSelectionMovementForAccessibility):
+        (WebCore::EventHandler::defaultKeyboardEventHandler):
+        * page/EventHandler.h:
+
 2013-08-09  Antti Koivisto  <[email protected]>
 
         Move static StyleResolver functions to Style namespace

Modified: trunk/Source/WebCore/WebCore.exp.in (153906 => 153907)


--- trunk/Source/WebCore/WebCore.exp.in	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Source/WebCore/WebCore.exp.in	2013-08-09 19:58:51 UTC (rev 153907)
@@ -1837,6 +1837,7 @@
 __ZN7WebCore12EventHandler12mouseDraggedEP7NSEvent
 __ZN7WebCore12EventHandler14currentNSEventEv
 __ZN7WebCore12EventHandler31passMouseMovedEventToScrollbarsEP7NSEvent
+__ZN7WebCore12EventHandler47handleKeyboardSelectionMovementForAccessibilityEPNS_13KeyboardEventE
 __ZN7WebCore12EventHandler7mouseUpEP7NSEvent
 __ZN7WebCore12EventHandler8keyEventEP7NSEvent
 __ZN7WebCore12EventHandler9mouseDownEP7NSEvent

Modified: trunk/Source/WebCore/page/EventHandler.cpp (153906 => 153907)


--- trunk/Source/WebCore/page/EventHandler.cpp	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2013-08-09 19:58:51 UTC (rev 153907)
@@ -3342,7 +3342,15 @@
     selection->modify(alternation, direction, granularity, UserTriggered);
     event->setDefaultHandled();
 }
-    
+
+void EventHandler::handleKeyboardSelectionMovementForAccessibility(KeyboardEvent* event)
+{
+    if (event->type() == eventNames().keydownEvent) {
+        if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled())
+            handleKeyboardSelectionMovement(m_frame->selection(), event);
+    }
+}
+
 void EventHandler::defaultKeyboardEventHandler(KeyboardEvent* event)
 {
     if (event->type() == eventNames().keydownEvent) {
@@ -3359,9 +3367,7 @@
                 defaultArrowEventHandler(direction, event);
         }
 
-        // provides KB navigation and selection for enhanced accessibility users
-        if (AXObjectCache::accessibilityEnhancedUserInterfaceEnabled())
-            handleKeyboardSelectionMovement(m_frame->selection(), event);
+        handleKeyboardSelectionMovementForAccessibility(event);
     }
     if (event->type() == eventNames().keypressEvent) {
         m_frame->editor().handleKeyboardEvent(event);

Modified: trunk/Source/WebCore/page/EventHandler.h (153906 => 153907)


--- trunk/Source/WebCore/page/EventHandler.h	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Source/WebCore/page/EventHandler.h	2013-08-09 19:58:51 UTC (rev 153907)
@@ -216,6 +216,8 @@
     bool keyEvent(const PlatformKeyboardEvent&);
     void defaultKeyboardEventHandler(KeyboardEvent*);
 
+    void handleKeyboardSelectionMovementForAccessibility(KeyboardEvent*);
+
     bool handleTextInputEvent(const String& text, Event* underlyingEvent = 0, TextEventInputType = TextEventInputKeyboard);
     void defaultTextInputEventHandler(TextEvent*);
 

Modified: trunk/Source/WebKit2/ChangeLog (153906 => 153907)


--- trunk/Source/WebKit2/ChangeLog	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Source/WebKit2/ChangeLog	2013-08-09 19:58:51 UTC (rev 153907)
@@ -1,3 +1,27 @@
+2013-08-09  Beth Dakin  <[email protected]>
+
+        AX: Not able to use arrow keys to read text in a WK2 app
+        https://bugs.webkit.org/show_bug.cgi?id=119605
+        -and corresponding-
+        <rdar://problem/14281275>
+
+        Reviewed by Darin Adler.
+
+        Make all of these scrolling functions actually return the WebCore bools that 
+        indicate whether or not scrolling happened. 
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::scroll):
+        (WebKit::WebPage::logicalScroll):
+        (WebKit::WebPage::scrollBy):
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::executeKeypressCommandsInternal):
+
+        This function now gives accessibility a chance to handle the event too. And it 
+        also actually tracks whether or not the event was handled by scrolling instead of 
+        assuming that it was and universally returning true.
+        (WebKit::WebPage::performNonEditingBehaviorForSelector):
+
 2013-08-09  Brian Holt  <[email protected]>
 
         [GTK] [WebKit2] Add an 'authenticate' signal to WebKitWebView

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (153906 => 153907)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2013-08-09 19:58:51 UTC (rev 153907)
@@ -1974,19 +1974,19 @@
 }
 #endif
 
-void WebPage::scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
+bool WebPage::scroll(Page* page, ScrollDirection direction, ScrollGranularity granularity)
 {
-    page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
+    return page->focusController()->focusedOrMainFrame()->eventHandler()->scrollRecursively(direction, granularity);
 }
 
-void WebPage::logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
+bool WebPage::logicalScroll(Page* page, ScrollLogicalDirection direction, ScrollGranularity granularity)
 {
-    page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
+    return page->focusController()->focusedOrMainFrame()->eventHandler()->logicalScrollRecursively(direction, granularity);
 }
 
-void WebPage::scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
+bool WebPage::scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity)
 {
-    scroll(m_page.get(), static_cast<ScrollDirection>(scrollDirection), static_cast<ScrollGranularity>(scrollGranularity));
+    return scroll(m_page.get(), static_cast<ScrollDirection>(scrollDirection), static_cast<ScrollGranularity>(scrollGranularity));
 }
 
 void WebPage::centerSelectionInVisibleArea()

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (153906 => 153907)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h	2013-08-09 19:58:51 UTC (rev 153907)
@@ -190,7 +190,7 @@
 
     void scrollMainFrameIfNotAtMaxScrollPosition(const WebCore::IntSize& scrollOffset);
 
-    void scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
+    bool scrollBy(uint32_t scrollDirection, uint32_t scrollGranularity);
 
     void centerSelectionInVisibleArea();
 
@@ -481,7 +481,7 @@
     void getDataSelectionForPasteboard(const WTF::String pasteboardType, SharedMemory::Handle& handle, uint64_t& size);
     void shouldDelayWindowOrderingEvent(const WebKit::WebMouseEvent&, bool& result);
     void acceptsFirstMouse(int eventNumber, const WebKit::WebMouseEvent&, bool& result);
-    bool performNonEditingBehaviorForSelector(const String&);
+    bool performNonEditingBehaviorForSelector(const String&, WebCore::KeyboardEvent*);
     void insertDictatedText(const String& text, uint64_t replacementRangeStart, uint64_t replacementRangeEnd, const Vector<WebCore::DictationAlternative>& dictationAlternativeLocations, bool& handled, EditorState& newState);
 #elif PLATFORM(EFL)
     void confirmComposition(const String& compositionString);
@@ -729,8 +729,8 @@
     void contextMenuHidden() { m_isShowingContextMenu = false; }
 #endif
 
-    static void scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
-    static void logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
+    static bool scroll(WebCore::Page*, WebCore::ScrollDirection, WebCore::ScrollGranularity);
+    static bool logicalScroll(WebCore::Page*, WebCore::ScrollLogicalDirection, WebCore::ScrollGranularity);
 
     uint64_t restoreSession(const SessionState&);
     void restoreSessionAndNavigateToCurrentItem(const SessionState&);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (153906 => 153907)


--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm	2013-08-09 19:58:51 UTC (rev 153907)
@@ -186,7 +186,7 @@
                 bool commandExecutedByEditor = command.execute(event);
                 eventWasHandled |= commandExecutedByEditor;
                 if (!commandExecutedByEditor) {
-                    bool performedNonEditingBehavior = event->keyEvent()->type() == PlatformEvent::RawKeyDown && performNonEditingBehaviorForSelector(commands[i].commandName);
+                    bool performedNonEditingBehavior = event->keyEvent()->type() == PlatformEvent::RawKeyDown && performNonEditingBehaviorForSelector(commands[i].commandName, event);
                     eventWasHandled |= performedNonEditingBehavior;
                 }
             } else {
@@ -624,40 +624,47 @@
     send(Messages::WebPageProxy::DidPerformDictionaryLookup(attributedString, dictionaryPopupInfo));
 }
 
-bool WebPage::performNonEditingBehaviorForSelector(const String& selector)
+bool WebPage::performNonEditingBehaviorForSelector(const String& selector, KeyboardEvent* event)
 {
+    // First give accessibility a chance to handle the event.
+    Frame* frame = frameForEvent(event);
+    frame->eventHandler()->handleKeyboardSelectionMovementForAccessibility(event);
+    if (event->defaultHandled())
+        return true;
+
     // FIXME: All these selectors have corresponding Editor commands, but the commands only work in editable content.
     // Should such non-editing behaviors be implemented in Editor or EventHandler::defaultArrowEventHandler() perhaps?
+    
+    bool didPerformAction = false;
+
     if (selector == "moveUp:")
-        scroll(m_page.get(), ScrollUp, ScrollByLine);
+        didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByLine);
     else if (selector == "moveToBeginningOfParagraph:")
-        scroll(m_page.get(), ScrollUp, ScrollByPage);
+        didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByPage);
     else if (selector == "moveToBeginningOfDocument:") {
-        scroll(m_page.get(), ScrollUp, ScrollByDocument);
-        scroll(m_page.get(), ScrollLeft, ScrollByDocument);
+        didPerformAction = scroll(m_page.get(), ScrollUp, ScrollByDocument);
+        didPerformAction |= scroll(m_page.get(), ScrollLeft, ScrollByDocument);
     } else if (selector == "moveDown:")
-        scroll(m_page.get(), ScrollDown, ScrollByLine);
+        didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByLine);
     else if (selector == "moveToEndOfParagraph:")
-        scroll(m_page.get(), ScrollDown, ScrollByPage);
+        didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByPage);
     else if (selector == "moveToEndOfDocument:") {
-        scroll(m_page.get(), ScrollDown, ScrollByDocument);
-        scroll(m_page.get(), ScrollLeft, ScrollByDocument);
+        didPerformAction = scroll(m_page.get(), ScrollDown, ScrollByDocument);
+        didPerformAction |= scroll(m_page.get(), ScrollLeft, ScrollByDocument);
     } else if (selector == "moveLeft:")
-        scroll(m_page.get(), ScrollLeft, ScrollByLine);
+        didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByLine);
     else if (selector == "moveWordLeft:")
-        scroll(m_page.get(), ScrollLeft, ScrollByPage);
+        didPerformAction = scroll(m_page.get(), ScrollLeft, ScrollByPage);
     else if (selector == "moveToLeftEndOfLine:")
-        m_page->goBack();
+        didPerformAction = m_page->goBack();
     else if (selector == "moveRight:")
-        scroll(m_page.get(), ScrollRight, ScrollByLine);
+        didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByLine);
     else if (selector == "moveWordRight:")
-        scroll(m_page.get(), ScrollRight, ScrollByPage);
+        didPerformAction = scroll(m_page.get(), ScrollRight, ScrollByPage);
     else if (selector == "moveToRightEndOfLine:")
-        m_page->goForward();
-    else
-        return false;
+        didPerformAction = m_page->goForward();
 
-    return true;
+    return didPerformAction;
 }
 
 bool WebPage::performDefaultBehaviorForKeyEvent(const WebKeyboardEvent&)

Modified: trunk/Tools/ChangeLog (153906 => 153907)


--- trunk/Tools/ChangeLog	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Tools/ChangeLog	2013-08-09 19:58:51 UTC (rev 153907)
@@ -1,3 +1,20 @@
+2013-08-09  Beth Dakin  <[email protected]>
+
+        AX: Not able to use arrow keys to read text in a WK2 app
+        https://bugs.webkit.org/show_bug.cgi?id=119605
+        -and corresponding-
+        <rdar://problem/14281275>
+
+        Reviewed by Darin Adler.
+
+        New test verifies that didNotHandleKeyEvent will be called when there is nothing 
+        to scroll. 
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp: Added.
+        (TestWebKitAPI::didFinishLoadForFrame):
+        (TestWebKitAPI::didNotHandleKeyEventCallback):
+        (TestWebKitAPI::TEST):
+
 2013-08-09  Christophe Dumez  <[email protected]>
 
         Add support for KeyboardEvent.location attribute

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (153906 => 153907)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2013-08-09 19:44:07 UTC (rev 153906)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2013-08-09 19:58:51 UTC (rev 153907)
@@ -110,6 +110,7 @@
 		8AA28C1A16D2FA7B002FF4DB /* LoadPageOnCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8AA28C1916D2FA7B002FF4DB /* LoadPageOnCrash.cpp */; };
 		930AD402150698D00067970F /* lots-of-text.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 930AD401150698B30067970F /* lots-of-text.html */; };
 		9318778915EEC57700A9CCE3 /* NewFirstVisuallyNonEmptyLayoutForImages.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93AF4ECA1506F035007FD57E /* NewFirstVisuallyNonEmptyLayoutForImages.cpp */; };
+		9331407C17B4419000F083B1 /* DidNotHandleKeyDown.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */; };
 		9361002914DC95A70061379D /* lots-of-iframes.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 9361002814DC957B0061379D /* lots-of-iframes.html */; };
 		939BA91714103412001A01BD /* DeviceScaleFactorOnBack.mm in Sources */ = {isa = PBXBuildFile; fileRef = 939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */; };
 		93ABA80916DDAB91002DB2FA /* StringHasher.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93ABA80816DDAB91002DB2FA /* StringHasher.cpp */; };
@@ -414,6 +415,7 @@
 		8AA28C1916D2FA7B002FF4DB /* LoadPageOnCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadPageOnCrash.cpp; sourceTree = "<group>"; };
 		8DD76FA10486AA7600D96B5E /* TestWebKitAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebKitAPI; sourceTree = BUILT_PRODUCTS_DIR; };
 		930AD401150698B30067970F /* lots-of-text.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-text.html"; sourceTree = "<group>"; };
+		9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DidNotHandleKeyDown.cpp; sourceTree = "<group>"; };
 		9361002814DC957B0061379D /* lots-of-iframes.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "lots-of-iframes.html"; sourceTree = "<group>"; };
 		939BA91614103412001A01BD /* DeviceScaleFactorOnBack.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DeviceScaleFactorOnBack.mm; sourceTree = "<group>"; };
 		93ABA80816DDAB91002DB2FA /* StringHasher.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringHasher.cpp; path = WTF/StringHasher.cpp; sourceTree = "<group>"; };
@@ -707,6 +709,7 @@
 				F6F3F29013342FEB00A6BF19 /* CookieManager.cpp */,
 				F6B7BE93174691EF008A3445 /* DidAssociateFormControls.cpp */,
 				F6B7BE92174691EF008A3445 /* DidAssociateFormControls_Bundle.cpp */,
+				9331407B17B4419000F083B1 /* DidNotHandleKeyDown.cpp */,
 				BCB6803F126FBFE100642A61 /* DocumentStartUserScriptAlertCrash.cpp */,
 				BCB68041126FBFF100642A61 /* DocumentStartUserScriptAlertCrash_Bundle.cpp */,
 				51393E1E1523944A005F39C5 /* DOMWindowExtensionBasic.cpp */,
@@ -1156,6 +1159,7 @@
 				93F7E86C14DC8E4D00C84A99 /* NewFirstVisuallyNonEmptyLayoutFrames.cpp in Sources */,
 				BC90977A125571AB00083756 /* PageLoadBasic.cpp in Sources */,
 				BC2D004912A9FDFA00E732A3 /* PageLoadDidChangeLocationWithinPageForFrame.cpp in Sources */,
+				9331407C17B4419000F083B1 /* DidNotHandleKeyDown.cpp in Sources */,
 				A51B650916ADF9B1007AA5D9 /* PageVisibilityState.cpp in Sources */,
 				A57A34F016AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm in Sources */,
 				52E5CE4614D21E9D003B2BD8 /* ParentFrame.cpp in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp (0 => 153907)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/DidNotHandleKeyDown.cpp	2013-08-09 19:58:51 UTC (rev 153907)
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2013 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 "config.h"
+#include "_javascript_Test.h"
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include <WebKit2/WKRetainPtr.h>
+
+namespace TestWebKitAPI {
+
+static bool didFinishTest;
+static bool didNotHandleKeyDownEvent;
+
+static void didFinishLoadForFrame(WKPageRef, WKFrameRef, WKTypeRef, const void*)
+{
+}
+
+static void didNotHandleKeyEventCallback(WKPageRef, WKNativeEventPtr event, const void*)
+{
+    if (Util::isKeyDown(event))
+        didNotHandleKeyDownEvent = true;
+    didFinishTest = true;
+}
+
+TEST(WebKit2, DidNotHandleKeyDown)
+{
+    WKRetainPtr<WKContextRef> context(AdoptWK, Util::createContextWithInjectedBundle());
+    PlatformWebView webView(context.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("simple", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+
+    webView.simulateSpacebarKeyPress();
+
+    Util::run(&didFinishTest);
+    EXPECT_TRUE(didNotHandleKeyDownEvent);
+}
+
+} // namespace TestWebKitAPI
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to