Title: [176904] trunk
Revision
176904
Author
[email protected]
Date
2014-12-05 21:44:10 -0800 (Fri, 05 Dec 2014)

Log Message

AX: I cannot activate links on the mobile version of news.google.com
https://bugs.webkit.org/show_bug.cgi?id=139330

Reviewed by Simon Fraser.

Source/WebCore:

This website only listens for touch events. VoiceOver normally dispatches click and mouse events,
so on iOS this falls and VoiceOver is not able to activate anything.

The solution here is to dispatch simulated touch down/up events.

Test: platform/ios-simulator/ios-accessibility/press-fires-touch-events.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::press):
(WebCore::AccessibilityObject::dispatchTouchEvent):
* accessibility/AccessibilityObject.h:
(WebCore::AccessibilityObject::isDetachedFromParent):
* page/EventHandler.h:
* page/ios/EventHandlerIOS.mm:
(WebCore::EventHandler::dispatchSimulatedTouchEvent):
* platform/ios/PlatformEventFactoryIOS.h:
* platform/ios/PlatformEventFactoryIOS.mm:
(WebCore::PlatformTouchEventBuilder::PlatformTouchEventBuilder):
(WebCore::PlatformEventFactory::createPlatformSimulatedTouchEvent):

Tools:

Implement press for iOS.

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::press):

LayoutTests:

* platform/ios-simulator/ios-accessibility: Added.
* platform/ios-simulator/ios-accessibility/press-fires-touch-events-expected.txt: Added.
* platform/ios-simulator/ios-accessibility/press-fires-touch-events.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (176903 => 176904)


--- trunk/LayoutTests/ChangeLog	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/LayoutTests/ChangeLog	2014-12-06 05:44:10 UTC (rev 176904)
@@ -1,3 +1,14 @@
+2014-12-05  Chris Fleizach  <[email protected]>
+
+        AX: I cannot activate links on the mobile version of news.google.com
+        https://bugs.webkit.org/show_bug.cgi?id=139330
+
+        Reviewed by Simon Fraser.
+
+        * platform/ios-simulator/ios-accessibility: Added.
+        * platform/ios-simulator/ios-accessibility/press-fires-touch-events-expected.txt: Added.
+        * platform/ios-simulator/ios-accessibility/press-fires-touch-events.html: Added.
+
 2014-12-05  Myles C. Maxfield  <[email protected]>
 
         Directional single quotation marks are not rotated in vertical text

Added: trunk/LayoutTests/platform/ios-simulator/ios-accessibility/press-fires-touch-events-expected.txt (0 => 176904)


--- trunk/LayoutTests/platform/ios-simulator/ios-accessibility/press-fires-touch-events-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/ios-accessibility/press-fires-touch-events-expected.txt	2014-12-06 05:44:10 UTC (rev 176904)
@@ -0,0 +1,12 @@
+button
+Ensure that if an element on handles touch events, the simulated accessibility press will still activate those elements.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Received touch start [object TouchEvent]
+Received touch ended [object TouchEvent]
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/ios-simulator/ios-accessibility/press-fires-touch-events.html (0 => 176904)


--- trunk/LayoutTests/platform/ios-simulator/ios-accessibility/press-fires-touch-events.html	                        (rev 0)
+++ trunk/LayoutTests/platform/ios-simulator/ios-accessibility/press-fires-touch-events.html	2014-12-06 05:44:10 UTC (rev 176904)
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+<script>
+var successfullyParsed = false;
+if (window.testRunner)
+   testRunner.dumpAsText();
+
+function touchEnd(event) {
+    debug("Received touch ended " + event);
+    event.stopPropagation(); 
+    event.preventDefault();
+}
+
+function touchStart(event) {
+    debug("Received touch start " + event);
+    event.stopPropagation(); 
+    event.preventDefault();
+}
+
+</script>
+</head>
+<body>
+
+<div role="button" id="button" _ontouchstart_="touchStart(event);" _ontouchend_="touchEnd(event);">button</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("Ensure that if an element on handles touch events, the simulated accessibility press will still activate those elements.");
+
+    if (window.accessibilityController) {
+        var button = accessibilityController.accessibleElementById("button");
+        button.press();
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src=""
+
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (176903 => 176904)


--- trunk/Source/WebCore/ChangeLog	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/Source/WebCore/ChangeLog	2014-12-06 05:44:10 UTC (rev 176904)
@@ -1,3 +1,30 @@
+2014-12-05  Chris Fleizach  <[email protected]>
+
+        AX: I cannot activate links on the mobile version of news.google.com
+        https://bugs.webkit.org/show_bug.cgi?id=139330
+
+        Reviewed by Simon Fraser.
+
+        This website only listens for touch events. VoiceOver normally dispatches click and mouse events,
+        so on iOS this falls and VoiceOver is not able to activate anything.
+
+        The solution here is to dispatch simulated touch down/up events.
+
+        Test: platform/ios-simulator/ios-accessibility/press-fires-touch-events.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::press):
+        (WebCore::AccessibilityObject::dispatchTouchEvent):
+        * accessibility/AccessibilityObject.h:
+        (WebCore::AccessibilityObject::isDetachedFromParent):
+        * page/EventHandler.h:
+        * page/ios/EventHandlerIOS.mm:
+        (WebCore::EventHandler::dispatchSimulatedTouchEvent):
+        * platform/ios/PlatformEventFactoryIOS.h:
+        * platform/ios/PlatformEventFactoryIOS.mm:
+        (WebCore::PlatformTouchEventBuilder::PlatformTouchEventBuilder):
+        (WebCore::PlatformEventFactory::createPlatformSimulatedTouchEvent):
+
 2014-12-05  Myles C. Maxfield  <[email protected]>
 
         Directional single quotation marks are not rotated in vertical text

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (176903 => 176904)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2014-12-06 05:44:10 UTC (rev 176904)
@@ -35,6 +35,7 @@
 #include "AccessibilityTable.h"
 #include "DOMTokenList.h"
 #include "Editor.h"
+#include "EventHandler.h"
 #include "FloatRect.h"
 #include "FocusController.h"
 #include "Frame.h"
@@ -869,10 +870,27 @@
         pressElement = hitTestElement;
     
     UserGestureIndicator gestureIndicator(DefinitelyProcessingUserGesture, document);
-    pressElement->accessKeyAction(true);
+    
+    bool dispatchedTouchEvent = dispatchTouchEvent();
+    if (!dispatchedTouchEvent)
+        pressElement->accessKeyAction(true);
+    
     return true;
 }
+    
+bool AccessibilityObject::dispatchTouchEvent()
+{
+    bool handled = false;
+#if ENABLE(IOS_TOUCH_EVENTS)
+    MainFrame* frame = mainFrame();
+    if (!frame)
+        return false;
 
+    frame->eventHandler().dispatchSimulatedTouchEvent(clickPoint());
+#endif
+    return handled;
+}
+
 Frame* AccessibilityObject::frame() const
 {
     Node* node = this->node();

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.h (176903 => 176904)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.h	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.h	2014-12-06 05:44:10 UTC (rev 176904)
@@ -984,7 +984,8 @@
     static bool objectMatchesSearchCriteriaWithResultLimit(AccessibilityObject*, AccessibilitySearchCriteria*, AccessibilityChildrenVector&);
     virtual AccessibilityRole buttonRoleType() const;
     bool isOnscreen() const;
-    
+    bool dispatchTouchEvent();
+
 #if (PLATFORM(GTK) || PLATFORM(EFL)) && HAVE(ACCESSIBILITY)
     bool allowsTextRanges() const;
     unsigned getLengthForTextRange() const;

Modified: trunk/Source/WebCore/page/EventHandler.h (176903 => 176904)


--- trunk/Source/WebCore/page/EventHandler.h	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/Source/WebCore/page/EventHandler.h	2014-12-06 05:44:10 UTC (rev 176904)
@@ -210,6 +210,7 @@
 
 #if ENABLE(IOS_TOUCH_EVENTS)
     bool dispatchTouchEvent(const PlatformTouchEvent&, const AtomicString&, const EventTargetTouchMap&, float, float);
+    bool dispatchSimulatedTouchEvent(IntPoint location);
 #endif
 
 #if ENABLE(IOS_GESTURE_EVENTS)

Modified: trunk/Source/WebCore/page/ios/EventHandlerIOS.mm (176903 => 176904)


--- trunk/Source/WebCore/page/ios/EventHandlerIOS.mm	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/Source/WebCore/page/ios/EventHandlerIOS.mm	2014-12-06 05:44:10 UTC (rev 176904)
@@ -104,6 +104,15 @@
 }
 
 #if ENABLE(IOS_TOUCH_EVENTS)
+
+bool EventHandler::dispatchSimulatedTouchEvent(IntPoint location)
+{
+    bool handled = handleTouchEvent(PlatformEventFactory::createPlatformSimulatedTouchEvent(PlatformEvent::TouchStart, location));
+    if (handled)
+        handleTouchEvent(PlatformEventFactory::createPlatformSimulatedTouchEvent(PlatformEvent::TouchEnd, location));
+    return handled;
+}
+    
 void EventHandler::touchEvent(WebEvent *event)
 {
     CurrentEventScope scope(event);

Modified: trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h (176903 => 176904)


--- trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.h	2014-12-06 05:44:10 UTC (rev 176904)
@@ -45,6 +45,7 @@
     WEBCORE_EXPORT static PlatformKeyboardEvent createPlatformKeyboardEvent(WebEvent *);
 #if ENABLE(TOUCH_EVENTS) || ENABLE(IOS_TOUCH_EVENTS)
     static PlatformTouchEvent createPlatformTouchEvent(WebEvent *);
+    static PlatformTouchEvent createPlatformSimulatedTouchEvent(PlatformEvent::Type, IntPoint location);
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm (176903 => 176904)


--- trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/Source/WebCore/platform/ios/PlatformEventFactoryIOS.mm	2014-12-06 05:44:10 UTC (rev 176904)
@@ -214,6 +214,21 @@
         return PlatformEvent::TouchCancel;
     }
 }
+    
+static PlatformTouchPoint::TouchPhaseType touchPhaseFromPlatformEventType(PlatformEvent::Type type)
+{
+    switch (type) {
+    case PlatformEvent::TouchStart:
+        return PlatformTouchPoint::TouchPhaseBegan;
+    case PlatformEvent::TouchMove:
+        return PlatformTouchPoint::TouchPhaseMoved;
+    case PlatformEvent::TouchEnd:
+        return PlatformTouchPoint::TouchPhaseEnded;
+    default:
+        ASSERT_NOT_REACHED();
+        return PlatformTouchPoint::TouchPhaseCancelled;
+    }
+}
 
 class PlatformTouchPointBuilder : public PlatformTouchPoint {
 public:
@@ -246,12 +261,35 @@
             m_touchPoints.uncheckedAppend(PlatformTouchPointBuilder(identifier, location, touchPhase));
         }
     }
+    
+    PlatformTouchEventBuilder(PlatformEvent::Type type, IntPoint location)
+    {
+        m_type = type;
+        m_timestamp = currentTime();
+        
+        m_gestureScale = 1;
+        m_gestureRotation = 0;
+        m_isGesture = 0;
+        m_position = location;
+        m_globalPosition = location;
+        
+        unsigned touchCount = 1;
+        m_touchPoints.reserveInitialCapacity(touchCount);
+        for (unsigned i = 0; i < touchCount; ++i)
+            m_touchPoints.uncheckedAppend(PlatformTouchPointBuilder(1, location, touchPhaseFromPlatformEventType(type)));
+    }
 };
 
 PlatformTouchEvent PlatformEventFactory::createPlatformTouchEvent(WebEvent *event)
 {
     return PlatformTouchEventBuilder(event);
 }
+    
+PlatformTouchEvent PlatformEventFactory::createPlatformSimulatedTouchEvent(PlatformEvent::Type type, IntPoint location)
+{
+    return PlatformTouchEventBuilder(type, location);
+}
+
 #endif // ENABLE(TOUCH_EVENTS)
 
 } // namespace WebCore

Modified: trunk/Tools/ChangeLog (176903 => 176904)


--- trunk/Tools/ChangeLog	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/Tools/ChangeLog	2014-12-06 05:44:10 UTC (rev 176904)
@@ -1,3 +1,15 @@
+2014-12-05  Chris Fleizach  <[email protected]>
+
+        AX: I cannot activate links on the mobile version of news.google.com
+        https://bugs.webkit.org/show_bug.cgi?id=139330
+
+        Reviewed by Simon Fraser.
+
+        Implement press for iOS.
+
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::press):
+
 2014-12-05  Daniel Bates  <[email protected]>
 
         [iOS] Query -[WAKWindow screenScale] instead of using WKGetScreenScaleFactor()

Modified: trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm (176903 => 176904)


--- trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm	2014-12-06 05:14:12 UTC (rev 176903)
+++ trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm	2014-12-06 05:44:10 UTC (rev 176904)
@@ -77,6 +77,7 @@
 - (CGFloat)_accessibilityMinValue;
 - (CGFloat)_accessibilityMaxValue;
 - (void)_accessibilitySetValue:(NSString *)value;
+- (void)_accessibilityActivate;
 @end
 
 @interface NSObject (WebAccessibilityObjectWrapperPrivate)
@@ -704,6 +705,7 @@
 
 void AccessibilityUIElement::press()
 {
+    [m_element _accessibilityActivate];
 }
 
 JSStringRef AccessibilityUIElement::accessibilityValue() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to