Title: [220042] trunk
Revision
220042
Author
n_w...@apple.com
Date
2017-07-29 03:27:00 -0700 (Sat, 29 Jul 2017)

Log Message

AX: findMatchingObjects doesn't work when the startObject is ignored
https://bugs.webkit.org/show_bug.cgi?id=174965

Reviewed by Chris Fleizach.

Source/WebCore:

findMatchingObjects would return a wrong element if we pass in an ignored
start object. To fix this, we should use the closest accessible sibling as
the start object.

Test: accessibility/mac/search-predicate-from-ignored-element.html

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

LayoutTests:

* accessibility/mac/search-predicate-from-ignored-element-expected.txt: Added.
* accessibility/mac/search-predicate-from-ignored-element.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (220041 => 220042)


--- trunk/LayoutTests/ChangeLog	2017-07-29 10:00:33 UTC (rev 220041)
+++ trunk/LayoutTests/ChangeLog	2017-07-29 10:27:00 UTC (rev 220042)
@@ -1,3 +1,13 @@
+2017-07-29  Nan Wang  <n_w...@apple.com>
+
+        AX: findMatchingObjects doesn't work when the startObject is ignored
+        https://bugs.webkit.org/show_bug.cgi?id=174965
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/search-predicate-from-ignored-element-expected.txt: Added.
+        * accessibility/mac/search-predicate-from-ignored-element.html: Added.
+
 2017-07-29  Aaron Chu  <aaron_...@apple.com>
 
         AX: FKA: Buttons need a visible focus indicator

Added: trunk/LayoutTests/accessibility/mac/search-predicate-from-ignored-element-expected.txt (0 => 220042)


--- trunk/LayoutTests/accessibility/mac/search-predicate-from-ignored-element-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/search-predicate-from-ignored-element-expected.txt	2017-07-29 10:27:00 UTC (rev 220042)
@@ -0,0 +1,16 @@
+First line of text
+button 
+Third line of text
+This tests the ability to search for accessible elements from an ignored element.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS element.stringForTextMarkerRange(markerRange) is 'First line of text'
+PASS element.stringForTextMarkerRange(lineRange) is 'button'
+PASS resultElement.stringValue is 'AXValue: Third line of text'
+PASS resultElement.stringValue is 'AXValue: First line of text'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/mac/search-predicate-from-ignored-element.html (0 => 220042)


--- trunk/LayoutTests/accessibility/mac/search-predicate-from-ignored-element.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/search-predicate-from-ignored-element.html	2017-07-29 10:27:00 UTC (rev 220042)
@@ -0,0 +1,50 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body id="body">
+
+<div id="test">First line of text<br>
+<button id="button" aria-hidden="true">button</button>
+<br>Third line of text</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests the ability to search for accessible elements from an ignored element.");
+    
+    if (window.accessibilityController) {
+        
+        document.getElementById("body").focus();
+        var containerElement = accessibilityController.focusedElement;
+        
+        var element = accessibilityController.accessibleElementById("test").childAtIndex(0);
+        var markerRange = element.textMarkerRangeForElement(element);
+        shouldBe("element.stringForTextMarkerRange(markerRange)", "'First line of text'");
+        
+        // Try to get the ignored element using line text marker calls
+        var textMarker = element.endTextMarkerForTextMarkerRange(markerRange);
+        textMarker = element.nextTextMarker(textMarker);
+        textMarker = element.nextTextMarker(textMarker);
+        var lineRange = element.lineTextMarkerRangeForTextMarker(textMarker);
+        shouldBe("element.stringForTextMarkerRange(lineRange)", "'button'");
+        
+        textMarker = element.startTextMarkerForTextMarkerRange(lineRange);
+        var startElement = element.accessibilityElementForTextMarker(textMarker);
+        
+        // Search forward
+        var resultElement = containerElement.uiElementForSearchPredicate(startElement, true, "AXAnyTypeSearchKey", "", false);
+        shouldBe("resultElement.stringValue", "'AXValue: Third line of text'");
+        
+        // Search backward
+        resultElement = containerElement.uiElementForSearchPredicate(startElement, false, "AXAnyTypeSearchKey", "", false);
+        shouldBe("resultElement.stringValue", "'AXValue: First line of text'");
+    }
+        
+</script>
+
+<script src=""
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (220041 => 220042)


--- trunk/Source/WebCore/ChangeLog	2017-07-29 10:00:33 UTC (rev 220041)
+++ trunk/Source/WebCore/ChangeLog	2017-07-29 10:27:00 UTC (rev 220042)
@@ -1,3 +1,19 @@
+2017-07-29  Nan Wang  <n_w...@apple.com>
+
+        AX: findMatchingObjects doesn't work when the startObject is ignored
+        https://bugs.webkit.org/show_bug.cgi?id=174965
+
+        Reviewed by Chris Fleizach.
+
+        findMatchingObjects would return a wrong element if we pass in an ignored
+        start object. To fix this, we should use the closest accessible sibling as 
+        the start object.
+
+        Test: accessibility/mac/search-predicate-from-ignored-element.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::appendChildrenToArray):
+
 2017-07-29  Aaron Chu  <aaron_...@apple.com>
 
         AX: FKA: Buttons need a visible focus indicator

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (220041 => 220042)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2017-07-29 10:00:33 UTC (rev 220041)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2017-07-29 10:27:00 UTC (rev 220042)
@@ -610,7 +610,23 @@
     size_t startIndex = isForward ? childrenSize : 0;
     size_t endIndex = isForward ? 0 : childrenSize;
 
+    // If the startObject is ignored, we should use an accessible sibling as a start element instead.
+    if (startObject && startObject->accessibilityIsIgnored() && startObject->isDescendantOfObject(object)) {
+        AccessibilityObject* parentObject = startObject->parentObject();
+        // Go up the parent chain to find the highest ancestor that's also being ignored.
+        while (parentObject && parentObject->accessibilityIsIgnored()) {
+            if (parentObject == object)
+                break;
+            startObject = parentObject;
+            parentObject = parentObject->parentObject();
+        }
+        // Get the un-ignored sibling based on the search direction, and update the searchPosition.
+        while (startObject && startObject->accessibilityIsIgnored())
+            startObject = isForward ? startObject->previousSibling() : startObject->nextSibling();
+    }
+    
     size_t searchPosition = startObject ? searchChildren.find(startObject) : WTF::notFound;
+    
     if (searchPosition != WTF::notFound) {
         if (isForward)
             endIndex = searchPosition + 1;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to