Title: [281200] trunk
Revision
281200
Author
[email protected]
Date
2021-08-18 10:57:24 -0700 (Wed, 18 Aug 2021)

Log Message

Add layout test for WebAccessibilityObjectWrapper handler for attribute AXLineForTextMarker on MacOS.
https://bugs.webkit.org/show_bug.cgi?id=229220
<rdar://problem/82057459>

Reviewed by Chris Fleizach.

Source/WebCore:

Test: accessibility/mac/line-index-for-textmarker.html

There was not a layout test that exercised directly the handler for the
AXLineForTextMarker attribute in [WebAccessibilityObjectWrapper
accessibilityAttributeValue:withParameter:].
This patch adds the above test to exercise this method for textarea and
contenteditable elements. The text in these elements includes soft and
hard linebreaks, which are important test cases for this API.
The handler for AXLineForTextMarker in turn calls
AccessibilityObject::lineForPosition, and analyzing this method, made a
minor optimization by getting rid off of an unnecessary local variable
and object copy.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::lineForPosition const):

Tools:

Added AccessibilityUIElement::lineIndexForTextMarker.

* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
(WTR::AccessibilityUIElement::lineIndexForTextMarker const):
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
* WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::lineIndexForTextMarker const):

LayoutTests:

* accessibility/mac/line-index-for-textmarker-expected.txt: Added.
* accessibility/mac/line-index-for-textmarker.html: Added.
* platform/mac-wk1/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (281199 => 281200)


--- trunk/LayoutTests/ChangeLog	2021-08-18 17:45:29 UTC (rev 281199)
+++ trunk/LayoutTests/ChangeLog	2021-08-18 17:57:24 UTC (rev 281200)
@@ -1,3 +1,15 @@
+2021-08-18  Andres Gonzalez  <[email protected]>
+
+        Add layout test for WebAccessibilityObjectWrapper handler for attribute AXLineForTextMarker on MacOS.
+        https://bugs.webkit.org/show_bug.cgi?id=229220
+        <rdar://problem/82057459>
+
+        Reviewed by Chris Fleizach.
+
+        * accessibility/mac/line-index-for-textmarker-expected.txt: Added.
+        * accessibility/mac/line-index-for-textmarker.html: Added.
+        * platform/mac-wk1/TestExpectations:
+
 2021-08-18  Wenson Hsieh  <[email protected]>
 
         Add a layout test for webkit.org/b/229200

Added: trunk/LayoutTests/accessibility/mac/line-index-for-textmarker-expected.txt (0 => 281200)


--- trunk/LayoutTests/accessibility/mac/line-index-for-textmarker-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/line-index-for-textmarker-expected.txt	2021-08-18 17:57:24 UTC (rev 281200)
@@ -0,0 +1,382 @@
+Test for lineIndexForTextMarker in editable text elements. The text contains soft and hard linebreaks.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+textarea:
+0 a 0
+1 b 0
+2 c 0
+3 d 0
+4 e 0
+5 f 0
+6 g 0
+7 h 0
+8 i 0
+9 j 0
+10 k 0
+11 l 0
+12 m 0
+13 n 0
+14 o 0
+15 p 0
+16 q 0
+17 r 0
+18 s 0
+19 t 0
+20 u 0
+21 v 0
+22 w 0
+23 x 1
+24 y 1
+25 z 1
+26 0 1
+27 1 1
+28 2 1
+29 3 1
+30 4 1
+31 5 1
+32 6 1
+33 7 1
+34 8 1
+35 9 1
+36   1
+37 a 2
+38 b 2
+39 c 2
+40 d 2
+41 e 2
+42 f 2
+43 g 2
+44 h 2
+45 i 2
+46 j 2
+47 k 2
+48 l 2
+49 m 2
+50 n 2
+51 o 2
+52 p 2
+53 q 2
+54 r 2
+55 s 2
+56 t 2
+57 u 2
+58 v 2
+59 w 2
+60 x 3
+61 y 3
+62 z 3
+63 0 3
+64 1 3
+65 2 3
+66 3 3
+67 4 3
+68 5 3
+69 6 3
+70 7 3
+71 8 3
+72 9 3
+73   3
+74 a 4
+75 b 4
+76 c 4
+77 d 4
+78 e 4
+79 f 4
+80 g 4
+81 h 4
+82 i 4
+83 j 4
+84 k 4
+85 l 4
+86 m 4
+87 n 4
+88 o 4
+89 p 4
+90 q 4
+91 r 4
+92 s 4
+93 t 4
+94 u 4
+95 v 4
+96 w 4
+97 x 5
+98 y 5
+99 z 5
+100 0 5
+101 1 5
+102 2 5
+103 3 5
+104 4 5
+105 5 5
+106 6 5
+107 7 5
+108 8 5
+109 9 5
+110 - 5
+111 a 6
+112 b 6
+113 c 6
+114 d 6
+115 e 6
+116 f 6
+117 g 6
+118 h 6
+119 i 6
+120 j 6
+121 k 6
+122 l 6
+123 m 6
+124 n 6
+125 o 6
+126 p 6
+127 q 6
+128 r 6
+129 s 6
+130 t 6
+131 u 6
+132 v 6
+133 w 6
+134 x 7
+135 y 7
+136 z 7
+137 0 7
+138 1 7
+139 2 7
+140 3 7
+141 4 7
+142 5 7
+143 6 7
+144 7 7
+145 8 7
+146 9 7
+147 - 7
+148 a 8
+149 b 8
+150 c 8
+151 d 8
+152 e 8
+153 f 8
+154 g 8
+155 h 8
+156 i 8
+157 j 8
+158 k 8
+159 l 8
+160 m 8
+161 n 8
+162 o 8
+163 p 8
+164 q 8
+165 r 8
+166 s 8
+167 t 8
+168 u 8
+169 v 8
+170 w 8
+171 x 9
+172 y 9
+173 z 9
+174 0 9
+175 1 9
+176 2 9
+177 3 9
+178 4 9
+179 5 9
+180 6 9
+181 7 9
+182 8 9
+183 9 9
+contenteditable:
+0 a 0
+1 b 0
+2 c 0
+3 d 0
+4 e 0
+5 f 0
+6 g 0
+7 h 0
+8 i 0
+9 j 0
+10 k 0
+11 l 0
+12 m 0
+13 n 0
+14 o 0
+15 p 0
+16 q 0
+17 r 0
+18 s 0
+19 t 0
+20 u 0
+21 v 0
+22 w 0
+23 x 0
+24 y 0
+25 z 0
+26 0 0
+27 1 0
+28 2 0
+29 3 0
+30 4 0
+31 5 0
+32 6 0
+33 7 0
+34 8 0
+35 9 0
+36   0
+37 a 0
+38 b 0
+39 c 0
+40 d 0
+41 e 0
+42 f 0
+43 g 0
+44 h 0
+45 i 0
+46 j 0
+47 k 0
+48 l 0
+49 m 0
+50 n 0
+51 o 0
+52 p 0
+53 q 0
+54 r 0
+55 s 0
+56 t 0
+57 u 0
+58 v 0
+59 w 0
+60 x 0
+61 y 0
+62 z 0
+63 0 0
+64 1 0
+65 2 0
+66 3 0
+67 4 0
+68 5 0
+69 6 0
+70 7 0
+71 8 0
+72 9 0
+73   0
+74 a 1
+75 b 1
+76 c 1
+77 d 1
+78 e 1
+79 f 1
+80 g 1
+81 h 1
+82 i 1
+83 j 1
+84 k 1
+85 l 1
+86 m 1
+87 n 1
+88 o 1
+89 p 1
+90 q 1
+91 r 1
+92 s 1
+93 t 1
+94 u 1
+95 v 1
+96 w 1
+97 x 1
+98 y 1
+99 z 1
+100 0 1
+101 1 1
+102 2 1
+103 3 1
+104 4 1
+105 5 1
+106 6 1
+107 7 1
+108 8 1
+109 9 1
+110 - 1
+111 a 1
+112 b 1
+113 c 1
+114 d 1
+115 e 1
+116 f 1
+117 g 1
+118 h 1
+119 i 1
+120 j 1
+121 k 1
+122 l 1
+123 m 1
+124 n 1
+125 o 1
+126 p 1
+127 q 1
+128 r 1
+129 s 1
+130 t 1
+131 u 1
+132 v 1
+133 w 1
+134 x 1
+135 y 1
+136 z 1
+137 0 1
+138 1 1
+139 2 1
+140 3 1
+141 4 1
+142 5 1
+143 6 1
+144 7 1
+145 8 1
+146 9 1
+147 - 1
+148 a 2
+149 b 2
+150 c 2
+151 d 2
+152 e 2
+153 f 2
+154 g 2
+155 h 2
+156 i 2
+157 j 2
+158 k 2
+159 l 2
+160 m 2
+161 n 2
+162 o 2
+163 p 2
+164 q 2
+165 r 2
+166 s 2
+167 t 2
+168 u 2
+169 v 2
+170 w 2
+171 x 2
+172 y 2
+173 z 2
+174 0 2
+175 1 2
+176 2 2
+177 3 2
+178 4 2
+179 5 2
+180 6 2
+181 7 2
+182 8 2
+183 9 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
+abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789
+
+

Added: trunk/LayoutTests/accessibility/mac/line-index-for-textmarker.html (0 => 281200)


--- trunk/LayoutTests/accessibility/mac/line-index-for-textmarker.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/mac/line-index-for-textmarker.html	2021-08-18 17:57:24 UTC (rev 281200)
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+<body>
+
+<textarea id="textarea">abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789</textarea>
+<br>
+<div contenteditable="true" id="contenteditable">abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789 abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789-abcdefghijklmnopqrstuvwxyz0123456789</div>
+<br>
+
+<script>
+    description("Test for lineIndexForTextMarker in editable text elements. The text contains soft and hard linebreaks.");
+
+    function logLineIndexesForElement(elementID) {
+        debug(`${elementID}:`);
+        var p = accessibilityController.accessibleElementById(elementID).children[0];
+        var range = p.textMarkerRangeForElement(p);
+        var length = p.textMarkerRangeLength(range);
+        var current = p.startTextMarkerForTextMarkerRange(range);
+        for (let i = 0; i < length; ++i) {
+            let character = p.stringForTextMarkerRange(p.textMarkerRangeForMarkers(current, p.nextTextMarker(current)));
+            debug(`${i} ${character} ${p.lineIndexForTextMarker(current)}`);
+            current = p.nextTextMarker(current);
+        }
+    }
+
+    if (window.accessibilityController) {
+        logLineIndexesForElement("textarea");
+        logLineIndexesForElement("contenteditable");
+    }
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (281199 => 281200)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-08-18 17:45:29 UTC (rev 281199)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2021-08-18 17:57:24 UTC (rev 281200)
@@ -969,6 +969,7 @@
 accessibility/nested-textareas-value-changed-notifications.html [ Skip ]
 accessibility/selected-state-changed-notifications.html [ Skip ]
 accessibility/element-line-rects-and-text.html [ Skip ]
+accessibility/mac/line-index-for-textmarker.html [ Skip ]
 
 # <rdar://problem/61066929> [ Stress GC ] flaky JSC::ExceptionScope::assertNoException crash under WebCore::ReadableStreamDefaultController
 webkit.org/b/211923 imported/w3c/web-platform-tests/fetch/api/basic/stream-safe-creation.any.html [ Pass Crash ]

Modified: trunk/Source/WebCore/ChangeLog (281199 => 281200)


--- trunk/Source/WebCore/ChangeLog	2021-08-18 17:45:29 UTC (rev 281199)
+++ trunk/Source/WebCore/ChangeLog	2021-08-18 17:57:24 UTC (rev 281200)
@@ -1,3 +1,27 @@
+2021-08-18  Andres Gonzalez  <[email protected]>
+
+        Add layout test for WebAccessibilityObjectWrapper handler for attribute AXLineForTextMarker on MacOS.
+        https://bugs.webkit.org/show_bug.cgi?id=229220
+        <rdar://problem/82057459>
+
+        Reviewed by Chris Fleizach.
+
+        Test: accessibility/mac/line-index-for-textmarker.html
+
+        There was not a layout test that exercised directly the handler for the
+        AXLineForTextMarker attribute in [WebAccessibilityObjectWrapper
+        accessibilityAttributeValue:withParameter:].
+        This patch adds the above test to exercise this method for textarea and
+        contenteditable elements. The text in these elements includes soft and
+        hard linebreaks, which are important test cases for this API.
+        The handler for AXLineForTextMarker in turn calls
+        AccessibilityObject::lineForPosition, and analyzing this method, made a
+        minor optimization by getting rid off of an unnecessary local variable
+        and object copy.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::lineForPosition const):
+
 2021-08-18  Simon Fraser  <[email protected]>
 
         Update feature statuses in features.json

Modified: trunk/Source/WebCore/accessibility/AccessibilityObject.cpp (281199 => 281200)


--- trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2021-08-18 17:45:29 UTC (rev 281199)
+++ trunk/Source/WebCore/accessibility/AccessibilityObject.cpp	2021-08-18 17:57:24 UTC (rev 281200)
@@ -1505,10 +1505,9 @@
     // top document.
     do {
         savedVisiblePos = currentVisiblePos;
-        VisiblePosition prevVisiblePos = previousLinePosition(currentVisiblePos, 0, HasEditableAXRole);
-        currentVisiblePos = prevVisiblePos;
+        currentVisiblePos = previousLinePosition(currentVisiblePos, 0, HasEditableAXRole);
         ++lineCount;
-    }  while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, savedVisiblePos)));
+    } while (currentVisiblePos.isNotNull() && !(inSameLine(currentVisiblePos, savedVisiblePos)));
 
     return lineCount;
 }

Modified: trunk/Tools/ChangeLog (281199 => 281200)


--- trunk/Tools/ChangeLog	2021-08-18 17:45:29 UTC (rev 281199)
+++ trunk/Tools/ChangeLog	2021-08-18 17:57:24 UTC (rev 281200)
@@ -1,3 +1,20 @@
+2021-08-18  Andres Gonzalez  <[email protected]>
+
+        Add layout test for WebAccessibilityObjectWrapper handler for attribute AXLineForTextMarker on MacOS.
+        https://bugs.webkit.org/show_bug.cgi?id=229220
+        <rdar://problem/82057459>
+
+        Reviewed by Chris Fleizach.
+
+        Added AccessibilityUIElement::lineIndexForTextMarker.
+
+        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+        (WTR::AccessibilityUIElement::lineIndexForTextMarker const):
+        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
+        * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::AccessibilityUIElement::lineIndexForTextMarker const):
+
 2021-08-18  Jonathan Bedard  <[email protected]>
 
         [git-webkit] "IndexError: list index out of range" using log

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp (281199 => 281200)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp	2021-08-18 17:45:29 UTC (rev 281199)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp	2021-08-18 17:57:24 UTC (rev 281200)
@@ -102,6 +102,7 @@
 #endif
 
 #if !PLATFORM(MAC) || !HAVE(ACCESSIBILITY)
+int AccessibilityUIElement::lineIndexForTextMarker(AccessibilityTextMarker*) const { return -1; }
 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForRange(unsigned, unsigned) { return nullptr; }
 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::selectedTextMarkerRange() { return nullptr; }
 void AccessibilityUIElement::resetSelectedTextMarkerRange() { }

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h (281199 => 281200)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h	2021-08-18 17:45:29 UTC (rev 281199)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h	2021-08-18 17:57:24 UTC (rev 281200)
@@ -305,6 +305,7 @@
     
     // Text markers.
     RefPtr<AccessibilityTextMarkerRange> lineTextMarkerRangeForTextMarker(AccessibilityTextMarker*);
+    int lineIndexForTextMarker(AccessibilityTextMarker*) const;
     RefPtr<AccessibilityTextMarkerRange> misspellingTextMarkerRange(AccessibilityTextMarkerRange* start, bool forward);
     RefPtr<AccessibilityTextMarkerRange> textMarkerRangeForElement(AccessibilityUIElement*);
     RefPtr<AccessibilityTextMarkerRange> textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl (281199 => 281200)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl	2021-08-18 17:45:29 UTC (rev 281199)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl	2021-08-18 17:57:24 UTC (rev 281200)
@@ -221,6 +221,7 @@
 
     // Text markers.
     AccessibilityTextMarkerRange lineTextMarkerRangeForTextMarker(AccessibilityTextMarker textMarker);
+    long lineIndexForTextMarker(AccessibilityTextMarker textMarker);
     AccessibilityTextMarkerRange misspellingTextMarkerRange(AccessibilityTextMarkerRange start, boolean forward);
     AccessibilityTextMarkerRange textMarkerRangeForElement(AccessibilityUIElement element);
     AccessibilityTextMarkerRange textMarkerRangeForMarkers(AccessibilityTextMarker startMarker, AccessibilityTextMarker endMarker);

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm (281199 => 281200)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2021-08-18 17:45:29 UTC (rev 281199)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm	2021-08-18 17:57:24 UTC (rev 281200)
@@ -1776,6 +1776,18 @@
     return nullptr;
 }
 
+int AccessibilityUIElement::lineIndexForTextMarker(AccessibilityTextMarker* marker) const
+{
+    if (!marker)
+        return -1;
+
+    BEGIN_AX_OBJC_EXCEPTIONS
+    return [[m_element accessibilityAttributeValue:@"AXLineForTextMarker" forParameter:marker->platformTextMarker()] intValue];
+    END_AX_OBJC_EXCEPTIONS
+
+    return -1;
+}
+
 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::misspellingTextMarkerRange(AccessibilityTextMarkerRange* start, bool forward)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to