AX: event.target should sometimes be a descendant element on AXPress-triggered mouse...
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Dec 2014 22:59:22 +0000 (22:59 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 18 Dec 2014 22:59:22 +0000 (22:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135689

Reviewed by Mario Sanchez Prada.

Source/WebCore:

When trying to find the right sub-node to target, we need to go back up the parent chain to find
an Element, in case we land on a Text node for example.

Test: accessibility/press-target-uses-text-descendant-node.html

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

LayoutTests:

* accessibility/press-target-uses-text-descendant-node-expected.txt: Added.
* accessibility/press-target-uses-text-descendant-node.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/press-target-uses-text-descendant-node-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/press-target-uses-text-descendant-node.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp

index 763e7fe..9e86ca3 100644 (file)
@@ -1,3 +1,13 @@
+2014-12-18  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: event.target should sometimes be a descendant element on AXPress-triggered mouse clicks
+        https://bugs.webkit.org/show_bug.cgi?id=135689
+
+        Reviewed by Mario Sanchez Prada.
+
+        * accessibility/press-target-uses-text-descendant-node-expected.txt: Added.
+        * accessibility/press-target-uses-text-descendant-node.html: Added.
+
 2014-12-18  Alexey Proskuryakov  <ap@apple.com>
 
         media/media-controls-timeline-updates.html is flaky
diff --git a/LayoutTests/accessibility/press-target-uses-text-descendant-node-expected.txt b/LayoutTests/accessibility/press-target-uses-text-descendant-node-expected.txt
new file mode 100644 (file)
index 0000000..a8cc1c9
--- /dev/null
@@ -0,0 +1,15 @@
+click only works on span inside link, not red link edges   
+Make sure that when performing a press, we target the deepest descendant, but also one that is an Element at the least.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Clicked on element: SPAN
+
+Now pressing on button
+
+Clicked on element: IMG
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/press-target-uses-text-descendant-node.html b/LayoutTests/accessibility/press-target-uses-text-descendant-node.html
new file mode 100644 (file)
index 0000000..a39abfa
--- /dev/null
@@ -0,0 +1,56 @@
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+<script type="text/javascript">
+    function handleClick(e) {
+        if (e.target.classList.contains("target")) {
+            debug("Clicked on element: " + e.target.nodeName);
+        }
+        return false;
+    }
+</script>
+<style type="text/css">
+    a:link, button {
+        padding: 10px;
+        margin: 10px;
+        background-color: red;
+        display: inline-block;
+    }
+    .target {
+        background-color: yellow;
+    }
+</style>
+</head>
+<body>
+
+<a href="#" onclick="return handleClick(event);" id="link">
+    <span class="target">click only works on span inside link, not red link edges</span>
+</a>
+
+<button onclick="return handleClick(event);" id="button">
+    <img src="resources/cake.png" alt="click only works on image inside button, not red button edges" class="target" onload="startTest();">
+</button>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("Make sure that when performing a press, we target the deepest descendant, but also one that is an Element at the least.");
+
+    function startTest() {
+       accessibilityController.accessibleElementById("link").press();
+       debug("\nNow pressing on button\n");
+       accessibilityController.accessibleElementById("button").press();
+       finishJSTest();
+    }
+
+    if (window.accessibilityController) {
+       window.jsTestIsAsync = true;
+    }
+
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
index 32fa3da..ff98872 100644 (file)
@@ -1,3 +1,18 @@
+2014-12-18  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: event.target should sometimes be a descendant element on AXPress-triggered mouse clicks
+        https://bugs.webkit.org/show_bug.cgi?id=135689
+
+        Reviewed by Mario Sanchez Prada.
+
+        When trying to find the right sub-node to target, we need to go back up the parent chain to find 
+        an Element, in case we land on a Text node for example.
+
+        Test: accessibility/press-target-uses-text-descendant-node.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::press):
+
 2014-12-16  Sam Weinig  <sam@webkit.org>
 
         Unify the Mac and iOS implementations of FontPlatformData a bit
index dbec5c3..f2a4313 100644 (file)
@@ -856,6 +856,8 @@ bool AccessibilityObject::press()
             Node* innerNode = hitTestResult.innerNode()->deprecatedShadowAncestorNode();
             if (is<Element>(*innerNode))
                 hitTestElement = downcast<Element>(innerNode);
+            else if (innerNode)
+                hitTestElement = innerNode->parentElement();
         }
     }