AX: Add a check for touch event listener on iOS accessibility object
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 31 Jul 2016 20:02:54 +0000 (20:02 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 31 Jul 2016 20:02:54 +0000 (20:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160388

Reviewed by Chris Fleizach.

Source/WebCore:

dispatchTouchEvent() is not working correctly within AXPress() sometimes. Need to
investigate it more in the future. Now, adding a check for the touch event listener
on the object's node so that iOS can handle dispatching the touch event instead.

Test: accessibility/ios-simulator/has-touch-event-listener.html

* accessibility/AccessibilityObject.h:
* accessibility/ios/AccessibilityObjectIOS.mm:
(WebCore::AccessibilityObject::accessibilityPlatformIncludesObject):
(WebCore::AccessibilityObject::hasTouchEventListener):
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(appendStringToResult):
(-[WebAccessibilityObjectWrapper _accessibilityHasTouchEventListener]):
(-[WebAccessibilityObjectWrapper _accessibilityValueIsAutofilled]):

Tools:

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::boolAttributeValue):
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::boolAttributeValue):

LayoutTests:

* accessibility/ios-simulator/has-touch-event-listener-expected.txt: Added.
* accessibility/ios-simulator/has-touch-event-listener.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/ios-simulator/has-touch-event-listener-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ios-simulator/has-touch-event-listener.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/ios/AccessibilityObjectIOS.mm
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm

index cfb75c7..ab4b245 100644 (file)
@@ -1,3 +1,13 @@
+2016-07-31  Nan Wang  <n_wang@apple.com>
+
+        AX: Add a check for touch event listener on iOS accessibility object
+        https://bugs.webkit.org/show_bug.cgi?id=160388
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/ios-simulator/has-touch-event-listener-expected.txt: Added.
+        * accessibility/ios-simulator/has-touch-event-listener.html: Added.
+
 2016-07-30  Mark Lam  <mark.lam@apple.com>
 
         Assertion failure while setting the length of an ArrayClass array.
diff --git a/LayoutTests/accessibility/ios-simulator/has-touch-event-listener-expected.txt b/LayoutTests/accessibility/ios-simulator/has-touch-event-listener-expected.txt
new file mode 100644 (file)
index 0000000..6765037
--- /dev/null
@@ -0,0 +1,13 @@
+button
+link
+Makes sure that we can check if an AXObject has touch event listener.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS button.boolAttributeValue('AXHasTouchEventListener') is true
+PASS link.boolAttributeValue('AXHasTouchEventListener') is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/has-touch-event-listener.html b/LayoutTests/accessibility/ios-simulator/has-touch-event-listener.html
new file mode 100644 (file)
index 0000000..2d2c695
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<script>
+var successfullyParsed = false;
+if (window.testRunner)
+   testRunner.dumpAsText();
+
+function click() {}
+
+</script>
+</head>
+<body>
+
+<div role="button" id="button" ontouchstart="chick();"">button</div>
+<div role="link" ontouchend="chick();"><div id="link">link</div></div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("Makes sure that we can check if an AXObject has touch event listener.");
+
+    if (window.accessibilityController) {
+        var button = accessibilityController.accessibleElementById("button");
+        var link = accessibilityController.accessibleElementById("link");
+        shouldBeTrue("button.boolAttributeValue('AXHasTouchEventListener')");
+        shouldBeTrue("link.boolAttributeValue('AXHasTouchEventListener')");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+
+</body>
+</html>
+
index 9a84fa4..102c671 100644 (file)
@@ -1,3 +1,25 @@
+2016-07-31  Nan Wang  <n_wang@apple.com>
+
+        AX: Add a check for touch event listener on iOS accessibility object
+        https://bugs.webkit.org/show_bug.cgi?id=160388
+
+        Reviewed by Chris Fleizach.
+
+        dispatchTouchEvent() is not working correctly within AXPress() sometimes. Need to 
+        investigate it more in the future. Now, adding a check for the touch event listener
+        on the object's node so that iOS can handle dispatching the touch event instead.
+
+        Test: accessibility/ios-simulator/has-touch-event-listener.html
+
+        * accessibility/AccessibilityObject.h:
+        * accessibility/ios/AccessibilityObjectIOS.mm:
+        (WebCore::AccessibilityObject::accessibilityPlatformIncludesObject):
+        (WebCore::AccessibilityObject::hasTouchEventListener):
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (appendStringToResult):
+        (-[WebAccessibilityObjectWrapper _accessibilityHasTouchEventListener]):
+        (-[WebAccessibilityObjectWrapper _accessibilityValueIsAutofilled]):
+
 2016-07-30  Chris Dumez  <cdumez@apple.com>
 
         Unreviewed, rebaseline bindings tests.
index 43424ad..e100920 100644 (file)
@@ -922,6 +922,7 @@ bool AccessibilityObject::press()
     
     UserGestureIndicator gestureIndicator(ProcessingUserGesture, document);
     
+    // FIXME: dispatchTouchEvent() is not dispatching the touch event correctly.
     bool dispatchedTouchEvent = dispatchTouchEvent();
     if (!dispatchedTouchEvent)
         pressElement->accessKeyAction(true);
index dbcfcd2..b3768a6 100644 (file)
@@ -1040,6 +1040,7 @@ public:
 
 #if PLATFORM(IOS)
     int accessibilityPasswordFieldLength();
+    bool hasTouchEventListener() const;
 #endif
     
     // allows for an AccessibilityObject to update its render tree or perform
index 3bb8769..21c4941 100644 (file)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "AccessibilityObject.h"
 #import "AccessibilityRenderObject.h"
+#import "EventNames.h"
 #import "HTMLInputElement.h"
 #import "RenderObject.h"
 #import "WAKView.h"
@@ -80,7 +81,16 @@ AccessibilityObjectInclusion AccessibilityObject::accessibilityPlatformIncludesO
 {
     return DefaultBehavior;
 }
-    
+
+bool AccessibilityObject::hasTouchEventListener() const
+{
+    for (Node* node = this->node(); node; node = node->parentNode()) {
+        if (node->hasEventListeners(eventNames().touchstartEvent) || node->hasEventListeners(eventNames().touchendEvent))
+            return true;
+    }
+    return false;
+}
+
 } // WebCore
 
 #endif // HAVE(ACCESSIBILITY) && PLATFORM(IOS)
index d33ae5a..3290059 100644 (file)
@@ -949,6 +949,14 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
     [result appendString:string];
 }
 
+- (BOOL)_accessibilityHasTouchEventListener
+{
+    if (![self _prepareAccessibilityCall])
+        return NO;
+    
+    return m_object->hasTouchEventListener();
+}
+
 - (BOOL)_accessibilityValueIsAutofilled
 {
     if (![self _prepareAccessibilityCall])
index ccfc64c..1c16c02 100644 (file)
@@ -1,3 +1,15 @@
+2016-07-31  Nan Wang  <n_wang@apple.com>
+
+        AX: Add a check for touch event listener on iOS accessibility object
+        https://bugs.webkit.org/show_bug.cgi?id=160388
+
+        Reviewed by Chris Fleizach.
+
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::boolAttributeValue):
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::boolAttributeValue):
+
 2016-07-30  Manuel Rego Casasnovas  <rego@igalia.com>
 
         Unreviewed: add myself to the reviewers list.
index 5d3b053..12c3a0c 100644 (file)
@@ -95,6 +95,7 @@ AccessibilityUIElement::~AccessibilityUIElement()
 - (NSUInteger)accessibilityARIAColumnIndex;
 - (UIAccessibilityTraits)_axContainedByFieldsetTrait;
 - (id)_accessibilityFieldsetAncestor;
+- (BOOL)_accessibilityHasTouchEventListener;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -667,6 +668,8 @@ bool AccessibilityUIElement::isDecrementActionSupported()
 
 bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
 {
+    if (JSStringIsEqualToUTF8CString(attribute, "AXHasTouchEventListener"))
+        return [m_element _accessibilityHasTouchEventListener];
     return false;
 }
 
index 2903c37..689e1c0 100644 (file)
@@ -72,6 +72,7 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification,
 - (NSUInteger)accessibilityARIAColumnIndex;
 - (UIAccessibilityTraits)_axContainedByFieldsetTrait;
 - (id)_accessibilityFieldsetAncestor;
+- (BOOL)_accessibilityHasTouchEventListener;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -379,6 +380,8 @@ PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementAttributeVal
 
 bool AccessibilityUIElement::boolAttributeValue(JSStringRef attribute)
 {
+    if (JSStringIsEqualToUTF8CString(attribute, "AXHasTouchEventListener"))
+        return [m_element _accessibilityHasTouchEventListener];
     return false;
 }