AX: AX hit-testing does not work on WebKit video playback buttons
authorn_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Apr 2016 05:34:46 +0000 (05:34 +0000)
committern_wang@apple.com <n_wang@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 1 Apr 2016 05:34:46 +0000 (05:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156084

Reviewed by Darin Adler.

Source/WebCore:

Use the element at point instead of the shadow host for hit testing on video tags.

Test: accessibility/mac/video-tag-hit-test.html

* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::elementAccessibilityHitTest):
(WebCore::shouldUseShadowHostForHitTesting):
(WebCore::AccessibilityRenderObject::accessibilityHitTest):

LayoutTests:

* accessibility/mac/video-tag-hit-test-expected.txt: Added.
* accessibility/mac/video-tag-hit-test.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/mac/video-tag-hit-test-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/mac/video-tag-hit-test.html [new file with mode: 0644]
LayoutTests/platform/mac-wk1/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityRenderObject.cpp

index 73486f4..fe9cf4b 100644 (file)
@@ -1,3 +1,13 @@
+2016-03-31  Nan Wang  <n_wang@apple.com>
+
+        AX: AX hit-testing does not work on WebKit video playback buttons
+        https://bugs.webkit.org/show_bug.cgi?id=156084
+
+        Reviewed by Darin Adler.
+
+        * accessibility/mac/video-tag-hit-test-expected.txt: Added.
+        * accessibility/mac/video-tag-hit-test.html: Added.
+
 2016-03-31  Daniel Bates  <dabates@apple.com>
 
         REGRESSION (r197724): <object>/<embed> with no URL does not match source *
diff --git a/LayoutTests/accessibility/mac/video-tag-hit-test-expected.txt b/LayoutTests/accessibility/mac/video-tag-hit-test-expected.txt
new file mode 100644 (file)
index 0000000..40321cc
--- /dev/null
@@ -0,0 +1,13 @@
+
+This tests that hit testing works on video tag.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS element.role is 'AXRole: AXButton'
+PASS element.description is 'AXDescription: Play'
+PASS element.parentElement().role is 'AXRole: AXToolbar'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/mac/video-tag-hit-test.html b/LayoutTests/accessibility/mac/video-tag-hit-test.html
new file mode 100644 (file)
index 0000000..2a6159a
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+<style>
+div.absolute {
+    position: absolute;
+    top: 0px;
+    left: 0px;
+    width: 400px;
+    height: 200px;
+    border: 1px solid #73AD21;
+}
+</style>
+</head>
+<body id="body">
+
+<div class="absolute" id="container" tabindex=0 id="region" title="region">
+<video id="video" width="400" height="200" controls>
+  <source src="" type="video/mp4">
+  Test Video.
+</video>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests that hit testing works on video tag.");
+
+    if (window.accessibilityController) {
+    
+          var element = accessibilityController.elementAtPoint(10, 185);
+          shouldBe("element.role", "'AXRole: AXButton'");
+          shouldBe("element.description", "'AXDescription: Play'");
+          shouldBe("element.parentElement().role", "'AXRole: AXToolbar'");
+    }
+
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index e5a3d0f..76bae87 100644 (file)
@@ -198,3 +198,6 @@ inspector/unit-tests/heap-snapshot.html [ Skip ]
 
 # This test checks ScrollAnimator events only for main frame scrollbars that use native widgets in WK1.
 fast/scrolling/scroll-animator-overlay-scrollbars-hovered.html [ Skip ]
+
+# This hit-test test doesn't work on DRT
+webkit.org/b/156084 accessibility/mac/video-tag-hit-test.html [ Skip ]
index 5b9d214..7c138f0 100644 (file)
@@ -1,3 +1,19 @@
+2016-03-31  Nan Wang  <n_wang@apple.com>
+
+        AX: AX hit-testing does not work on WebKit video playback buttons
+        https://bugs.webkit.org/show_bug.cgi?id=156084
+
+        Reviewed by Darin Adler.
+
+        Use the element at point instead of the shadow host for hit testing on video tags.
+
+        Test: accessibility/mac/video-tag-hit-test.html
+
+        * accessibility/AccessibilityRenderObject.cpp:
+        (WebCore::AccessibilityRenderObject::elementAccessibilityHitTest):
+        (WebCore::shouldUseShadowHostForHitTesting):
+        (WebCore::AccessibilityRenderObject::accessibilityHitTest):
+
 2016-03-31  Alexey Proskuryakov  <ap@apple.com>
 
         Page overlay tests sometimes crash under MockPageOverlayClient::uninstallAllOverlays()
index 419f518..ca93bb7 100644 (file)
@@ -2249,6 +2249,12 @@ AccessibilityObject* AccessibilityRenderObject::elementAccessibilityHitTest(cons
     return AccessibilityObject::elementAccessibilityHitTest(point);
 }
     
+static bool shouldUseShadowHostForHitTesting(Node* shadowHost)
+{
+    // We need to allow automation of mouse events on video tags.
+    return shadowHost && !shadowHost->hasTagName(videoTag);
+}
+
 AccessibilityObject* AccessibilityRenderObject::accessibilityHitTest(const IntPoint& point) const
 {
     if (!m_renderer || !m_renderer->hasLayer())
@@ -2261,9 +2267,12 @@ AccessibilityObject* AccessibilityRenderObject::accessibilityHitTest(const IntPo
     HitTestRequest request(HitTestRequest::ReadOnly | HitTestRequest::Active | HitTestRequest::AccessibilityHitTest);
     HitTestResult hitTestResult = HitTestResult(point);
     layer->hitTest(request, hitTestResult);
-    if (!hitTestResult.innerNode())
+    Node* node = hitTestResult.innerNode();
+    if (!node)
         return nullptr;
-    Node* node = hitTestResult.innerNode()->deprecatedShadowAncestorNode();
+    Node* shadowAncestorNode = node->shadowHost();
+    if (shouldUseShadowHostForHitTesting(shadowAncestorNode))
+        node = shadowAncestorNode;
     ASSERT(node);
 
     if (is<HTMLAreaElement>(*node))