Title: [182355] trunk
Revision
182355
Author
cfleiz...@apple.com
Date
2015-04-04 23:51:15 -0700 (Sat, 04 Apr 2015)

Log Message

AX: Heuristic: Avoid exposing an element as clickable if mouse event delegation is handled on an AXElement with more than one descendant AXElement
https://bugs.webkit.org/show_bug.cgi?id=136247

Reviewed by Mario Sanchez Prada.

Source/WebCore:

Modify the logic for determining whether an element supports the press action by trying to filter out objects being handled by event delegation.
The heuristic is if an element handles click actions and has more than one of a {static text, image, control, link, heading}, then we think
it's using event delegation, and do not expose the press action.

Test: platform/mac/accessibility/press-action-not-exposed-for-event-delegation.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::supportsPressAction):

LayoutTests:

* platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler-expected.txt: Removed.
* platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler.html: Removed.
* platform/mac/accessibility/press-action-not-exposed-for-event-delegation-expected.txt: Added.
* platform/mac/accessibility/press-action-not-exposed-for-event-delegation.html: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (182354 => 182355)


--- trunk/LayoutTests/ChangeLog	2015-04-05 06:11:00 UTC (rev 182354)
+++ trunk/LayoutTests/ChangeLog	2015-04-05 06:51:15 UTC (rev 182355)
@@ -1,3 +1,15 @@
+2015-04-04  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: Heuristic: Avoid exposing an element as clickable if mouse event delegation is handled on an AXElement with more than one descendant AXElement
+        https://bugs.webkit.org/show_bug.cgi?id=136247
+
+        Reviewed by Mario Sanchez Prada.
+
+        * platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler-expected.txt: Removed.
+        * platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler.html: Removed.
+        * platform/mac/accessibility/press-action-not-exposed-for-event-delegation-expected.txt: Added.
+        * platform/mac/accessibility/press-action-not-exposed-for-event-delegation.html: Added.
+
 2015-04-04  Simon Fraser  <simon.fra...@apple.com>
 
         Fix some bad test results committed earlier.

Added: trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-for-event-delegation-expected.txt (0 => 182355)


--- trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-for-event-delegation-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-for-event-delegation-expected.txt	2015-04-05 06:51:15 UTC (rev 182355)
@@ -0,0 +1,40 @@
+
+
+This tests whether static text has the press action supported. If the handler is on an element that has more than one child, then we assume that event delegation is being used. In that case we do not expose press supported.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS text1.role is 'AXRole: AXStaticText'
+PASS text2.role is 'AXRole: AXStaticText'
+When a click handler is on the HTML tag, AXPress should not be supported on static text children elements automatically.
+PASS text1.isPressActionSupported() is false
+PASS text2.isPressActionSupported() is false
+
+When a click handler is on the BODY tag, AXPress should not be supported on static text children elements automatically.
+
+PASS text1.isPressActionSupported() is false
+PASS text2.isPressActionSupported() is false
+
+When a click handler is on a parent tag, AXPress should be supported on static text children elements automatically.
+
+PASS text1.isPressActionSupported() is true
+PASS text2.isPressActionSupported() is false
+
+When a click handler is on the parent, using role=text should expose AXPress.
+
+PASS text2.isPressActionSupported() is true
+
+When a click handler is on a parent that has more than one descendant, do not expose press.
+
+PASS text3.isPressActionSupported() is false
+PASS text3.isPressActionSupported() is false
+
+When a click handler is on a parent that has one direct descendant, but then sub-descendants below that, do not expose press.
+
+PASS text4.isPressActionSupported() is false
+PASS text4.isPressActionSupported() is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-for-event-delegation.html (0 => 182355)


--- trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-for-event-delegation.html	                        (rev 0)
+++ trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-for-event-delegation.html	2015-04-05 06:51:15 UTC (rev 182355)
@@ -0,0 +1,97 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html id="html">
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="group1" role="group">
+text1
+</div>
+
+<br>
+
+<div id="group2" role="group">
+<div role="text" id="text2">text2</div>
+</div>
+
+<div id="group3" role="group">
+a<br>
+<button>b</button>
+</div>
+
+<div id="group4" role="group">
+  <div role="group">
+     <button>a</button>
+     <button>b</button>
+     c
+  </div>
+</div>
+
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests whether static text has the press action supported. If the handler is on an element that has more than one child, then we assume that event delegation is being used. In that case we do not expose press supported.");
+
+    if (window.accessibilityController) {
+
+          function listener() { }
+
+          var group = accessibilityController.accessibleElementById("group1");
+          var text1 = group.childAtIndex(0);
+          var text2 = accessibilityController.accessibleElementById("text2");
+
+          shouldBe("text1.role", "'AXRole: AXStaticText'");
+          shouldBe("text2.role", "'AXRole: AXStaticText'");
+
+          document.getElementById("html").addEventListener('click', listener, false);
+
+          debug("When a click handler is on the HTML tag, AXPress should not be supported on static text children elements automatically.");
+          shouldBeFalse("text1.isPressActionSupported()");
+          shouldBeFalse("text2.isPressActionSupported()");
+
+          document.getElementById("html").removeEventListener('click', listener, false);
+          document.getElementById("body").addEventListener('click', listener, false);
+
+          debug("\nWhen a click handler is on the BODY tag, AXPress should not be supported on static text children elements automatically.\n");
+          shouldBeFalse("text1.isPressActionSupported()");
+          shouldBeFalse("text2.isPressActionSupported()");
+
+          document.getElementById("body").removeEventListener('click', listener, false);
+          document.getElementById("group1").addEventListener('click', listener, false);
+
+          debug("\nWhen a click handler is on a parent tag, AXPress should be supported on static text children elements automatically.\n");
+          shouldBeTrue("text1.isPressActionSupported()");
+          shouldBeFalse("text2.isPressActionSupported()");
+
+          debug("\nWhen a click handler is on the parent, using role=text should expose AXPress.\n");
+          document.getElementById("group2").addEventListener('click', listener, false);
+          shouldBeTrue("text2.isPressActionSupported()");
+
+          debug("\nWhen a click handler is on a parent that has more than one descendant, do not expose press.\n");
+          var text3 = accessibilityController.accessibleElementById('group3').childAtIndex(0);
+          shouldBeFalse("text3.isPressActionSupported()");
+
+          document.getElementById("group3").addEventListener('click', listener, false);
+          shouldBeFalse("text3.isPressActionSupported()");
+
+          debug("\nWhen a click handler is on a parent that has one direct descendant, but then sub-descendants below that, do not expose press.\n");
+          var text4 = accessibilityController.accessibleElementById('group4').childAtIndex(0).childAtIndex(2);
+          shouldBeFalse("text4.isPressActionSupported()");
+
+          document.getElementById("group4").addEventListener('click', listener, false);
+          shouldBeFalse("text4.isPressActionSupported()");
+
+          for (var k = 1; k <= 4; k++)
+              document.getElementById("group" + k).style.visibility = "hidden";
+    }
+
+</script>
+
+<script src=""
+</body>
+</html>

Deleted: trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler-expected.txt (182354 => 182355)


--- trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler-expected.txt	2015-04-05 06:11:00 UTC (rev 182354)
+++ trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler-expected.txt	2015-04-05 06:51:15 UTC (rev 182355)
@@ -1,21 +0,0 @@
-
-This tests that if the body or html tags have click handlers, then non-control elements do not automatically have the press action on them.
-
-On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
-
-
-PASS text1.role is 'AXRole: AXStaticText'
-PASS text2.role is 'AXRole: AXStaticText'
-When a click handler is on the HTML tag, AXPress should not be supported on static text children elements automatically.
-PASS text1.isPressActionSupported() is false
-PASS text2.isPressActionSupported() is false
-When a click handler is on the BODY tag, AXPress should not be supported on static text children elements automatically.
-PASS text1.isPressActionSupported() is false
-PASS text2.isPressActionSupported() is false
-When a click handler is on a parent tag, AXPress should be supported on static text children elements automatically.
-PASS text1.isPressActionSupported() is true
-PASS text2.isPressActionSupported() is true
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Deleted: trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler.html (182354 => 182355)


--- trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler.html	2015-04-05 06:11:00 UTC (rev 182354)
+++ trunk/LayoutTests/platform/mac/accessibility/press-action-not-exposed-when-body-is-click-handler.html	2015-04-05 06:51:15 UTC (rev 182355)
@@ -1,60 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html id="html">
-<head>
-<script src=""
-</head>
-<body id="body">
-
-<div id="group1" role="group">
-text1
-<br>
-<div role="text" id="text2">text2</div>
-
-</div>
-
-<p id="description"></p>
-<div id="console"></div>
-
-<script>
-
-    description("This tests that if the body or html tags have click handlers, then non-control elements do not automatically have the press action on them.");
-
-    if (window.accessibilityController) {
-
-          function listener() { }
-
-          var group = accessibilityController.accessibleElementById("group1");
-          var text1 = group.childAtIndex(0).childAtIndex(0);
-          var text2 = accessibilityController.accessibleElementById("text2");
-
-          shouldBe("text1.role", "'AXRole: AXStaticText'");
-          shouldBe("text2.role", "'AXRole: AXStaticText'");
-
-          document.getElementById("html").addEventListener('click', listener, false);
-
-          debug("When a click handler is on the HTML tag, AXPress should not be supported on static text children elements automatically.");
-          shouldBeFalse("text1.isPressActionSupported()");
-          shouldBeFalse("text2.isPressActionSupported()");
-
-          document.getElementById("html").removeEventListener('click', listener, false);
-          document.getElementById("body").addEventListener('click', listener, false);
-
-          debug("When a click handler is on the BODY tag, AXPress should not be supported on static text children elements automatically.");
-          shouldBeFalse("text1.isPressActionSupported()");
-          shouldBeFalse("text2.isPressActionSupported()");
-
-          document.getElementById("body").removeEventListener('click', listener, false);
-          document.getElementById("group1").addEventListener('click', listener, false);
-
-          debug("When a click handler is on a parent tag, AXPress should be supported on static text children elements automatically.");
-          shouldBeTrue("text1.isPressActionSupported()");
-          shouldBeTrue("text2.isPressActionSupported()");
-
-          document.getElementById("group1").style.visibility = "hidden";
-    }
-
-</script>
-
-<script src=""
-</body>
-</html>

Modified: trunk/Source/WebCore/ChangeLog (182354 => 182355)


--- trunk/Source/WebCore/ChangeLog	2015-04-05 06:11:00 UTC (rev 182354)
+++ trunk/Source/WebCore/ChangeLog	2015-04-05 06:51:15 UTC (rev 182355)
@@ -1,3 +1,19 @@
+2015-04-04  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: Heuristic: Avoid exposing an element as clickable if mouse event delegation is handled on an AXElement with more than one descendant AXElement
+        https://bugs.webkit.org/show_bug.cgi?id=136247
+
+        Reviewed by Mario Sanchez Prada.
+
+        Modify the logic for determining whether an element supports the press action by trying to filter out objects being handled by event delegation.
+        The heuristic is if an element handles click actions and has more than one of a {static text, image, control, link, heading}, then we think
+        it's using event delegation, and do not expose the press action.
+
+        Test: platform/mac/accessibility/press-action-not-exposed-for-event-delegation.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::supportsPressAction):
+
 2015-04-04  Simon Fraser  <simon.fra...@apple.com>
 
         More const in CSSToStyleMap

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (182354 => 182355)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2015-04-05 06:11:00 UTC (rev 182354)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2015-04-05 06:51:15 UTC (rev 182355)
@@ -2002,6 +2002,21 @@
     if (!actionElement)
         return false;
     
+    // [Bug: 136247] Heuristic: element handlers that have more than one accessible descendant should not be exposed as supporting press.
+    if (actionElement != element()) {
+        if (AccessibilityObject* axObj = axObjectCache()->getOrCreate(actionElement)) {
+            AccessibilityChildrenVector results;
+            // Search within for immediate descendants that are static text. If we find more than one
+            // then this is an event delegator actionElement and we should expose the press action.
+            Vector<AccessibilitySearchKey> keys({ StaticTextSearchKey, ControlSearchKey, GraphicSearchKey, HeadingSearchKey, LinkSearchKey });
+            AccessibilitySearchCriteria criteria(axObj, SearchDirectionNext, "", 2, false, false);
+            criteria.searchKeys = keys;
+            axObj->findMatchingObjects(&criteria, results);
+            if (results.size() > 1)
+                return false;
+        }
+    }
+    
     // [Bug: 133613] Heuristic: If the action element is presentational, we shouldn't expose press as a supported action.
     return !nodeHasPresentationRole(actionElement);
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to