Title: [237225] trunk
Revision
237225
Author
cfleiz...@apple.com
Date
2018-10-17 10:52:15 -0700 (Wed, 17 Oct 2018)

Log Message

AX: Certain tags should identify their context to iOS API
https://bugs.webkit.org/show_bug.cgi?id=190622
<rdar://problem/45308194>

Reviewed by Zalan Bujtas.

Source/WebCore:

Convey the semantic meaning of <code> tag to the iOS API so VoiceOver can make use of it.

Tests: accessibility/ios-simulator/text-context-attributes.html

* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper accessibilityTextualContext]):
(AXAttributeStringSetStyle):

Tools:

* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::stringAttributeValue):
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::stringAttributeValue):

LayoutTests:

* accessibility/ios-simulator/text-context-attributes.html: Added.
* accessibility/ios-simulator/text-context-attributes-expcted.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (237224 => 237225)


--- trunk/LayoutTests/ChangeLog	2018-10-17 17:51:46 UTC (rev 237224)
+++ trunk/LayoutTests/ChangeLog	2018-10-17 17:52:15 UTC (rev 237225)
@@ -1,3 +1,14 @@
+2018-10-17  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: Certain tags should identify their context to iOS API
+        https://bugs.webkit.org/show_bug.cgi?id=190622
+        <rdar://problem/45308194>
+
+        Reviewed by Zalan Bujtas.
+
+        * accessibility/ios-simulator/text-context-attributes.html: Added.
+        * accessibility/ios-simulator/text-context-attributes-expcted.txt: Added.
+
 2018-10-17  Ali Juma  <aj...@chromium.org>
 
         Flaky IntersectionObserver web platform tests involving style updates

Added: trunk/LayoutTests/accessibility/ios-simulator/text-context-attributes-expected.txt (0 => 237225)


--- trunk/LayoutTests/accessibility/ios-simulator/text-context-attributes-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/text-context-attributes-expected.txt	2018-10-17 17:52:15 UTC (rev 237225)
@@ -0,0 +1,17 @@
+code
+This test ensures that ios simulator exposes textual context attributes for elements correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+context value: UIAccessibilityTextualContextSourceCode
+Attributed string: code{
+    UIAccessibilityTextAttributeContext = UIAccessibilityTextualContextSourceCode;
+    UIAccessibilityTokenFontFamily = Courier;
+    UIAccessibilityTokenFontName = Courier;
+    UIAccessibilityTokenFontSize = 13;
+}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/accessibility/ios-simulator/text-context-attributes.html (0 => 237225)


--- trunk/LayoutTests/accessibility/ios-simulator/text-context-attributes.html	                        (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/text-context-attributes.html	2018-10-17 17:52:15 UTC (rev 237225)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<body id="body">
+
+<code id="code">
+code
+</code>
+
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script>
+
+    description("This test ensures that ios simulator exposes textual context attributes for elements correctly.");
+
+    if (window.accessibilityController) {
+
+        var obj = accessibilityController.accessibleElementById("code");
+        debug("context value: " + obj.stringAttributeValue("AXTextualContext"));
+
+        var text = obj.attributedStringForElement();
+        debug("Attributed string: " + text);
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src=""
+</body>
+</html>
+

Modified: trunk/Source/WebCore/ChangeLog (237224 => 237225)


--- trunk/Source/WebCore/ChangeLog	2018-10-17 17:51:46 UTC (rev 237224)
+++ trunk/Source/WebCore/ChangeLog	2018-10-17 17:52:15 UTC (rev 237225)
@@ -1,3 +1,19 @@
+2018-10-17  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: Certain tags should identify their context to iOS API
+        https://bugs.webkit.org/show_bug.cgi?id=190622
+        <rdar://problem/45308194>
+
+        Reviewed by Zalan Bujtas.
+
+        Convey the semantic meaning of <code> tag to the iOS API so VoiceOver can make use of it.
+
+        Tests: accessibility/ios-simulator/text-context-attributes.html
+
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityTextualContext]):
+        (AXAttributeStringSetStyle):
+
 2018-10-17  Youenn Fablet  <you...@apple.com>
 
         Remove unused code from RealtimeOutgoingVideoSourceCocoa

Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (237224 => 237225)


--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2018-10-17 17:51:46 UTC (rev 237224)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm	2018-10-17 17:52:15 UTC (rev 237225)
@@ -118,6 +118,9 @@
 static NSString * const UIAccessibilityTokenLanguage = @"UIAccessibilityTokenLanguage";
 static NSString * const UIAccessibilityTokenAttachment = @"UIAccessibilityTokenAttachment";
 
+static NSString * const UIAccessibilityTextAttributeContext = @"UIAccessibilityTextAttributeContext";
+static NSString * const UIAccessibilityTextualContextSourceCode = @"UIAccessibilityTextualContextSourceCode";
+
 static AccessibilityObjectWrapper* AccessibilityUnignoredAncestor(AccessibilityObjectWrapper *wrapper)
 {
     while (wrapper && ![wrapper isAccessibilityElement]) {
@@ -1889,6 +1892,17 @@
     return m_object->isAttachment();
 }
 
+- (NSString *)accessibilityTextualContext
+{
+    if (![self _prepareAccessibilityCall])
+        return nil;
+
+    if (m_object->node() && m_object->node()->hasTagName(codeTag))
+        return UIAccessibilityTextualContextSourceCode;
+    
+    return nil;
+}
+
 - (void)_accessibilityActivate
 {
     if (![self _prepareAccessibilityCall])
@@ -2256,6 +2270,15 @@
     auto decor = style.textDecorationsInEffect();
     if (decor & TextDecoration::Underline)
         AXAttributeStringSetNumber(attrString, UIAccessibilityTokenUnderline, @YES, range);
+
+    // Add code context if this node is within a <code> block.
+    AccessibilityObject* axObject = renderer->document().axObjectCache()->getOrCreate(renderer);
+    auto matchFunc = [] (const AccessibilityObject& object) {
+        return object.node() && object.node()->hasTagName(codeTag);
+    };
+    
+    if (const AccessibilityObject* parent = AccessibilityObject::matchedParent(*axObject, true, WTFMove(matchFunc)))
+        [attrString addAttribute:UIAccessibilityTextAttributeContext value:UIAccessibilityTextualContextSourceCode range:range];
 }
 
 static void AXAttributedStringAppendText(NSMutableAttributedString* attrString, Node* node, NSString *text)

Modified: trunk/Tools/ChangeLog (237224 => 237225)


--- trunk/Tools/ChangeLog	2018-10-17 17:51:46 UTC (rev 237224)
+++ trunk/Tools/ChangeLog	2018-10-17 17:52:15 UTC (rev 237225)
@@ -1,3 +1,16 @@
+2018-10-17  Chris Fleizach  <cfleiz...@apple.com>
+
+        AX: Certain tags should identify their context to iOS API
+        https://bugs.webkit.org/show_bug.cgi?id=190622
+        <rdar://problem/45308194>
+
+        Reviewed by Zalan Bujtas.
+
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::stringAttributeValue):
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::stringAttributeValue):
+
 2018-10-16  Sihui Liu  <sihui_...@apple.com>
 
         Add a switch for Web SQL

Modified: trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm (237224 => 237225)


--- trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm	2018-10-17 17:51:46 UTC (rev 237224)
+++ trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm	2018-10-17 17:52:15 UTC (rev 237225)
@@ -102,6 +102,7 @@
 - (NSArray *)accessibilityFindMatchingObjects:(NSDictionary *)parameters;
 - (NSArray *)accessibilitySpeechHint;
 - (BOOL)_accessibilityIsStrongPasswordField;
+- (NSString *)accessibilityTextualContext;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -701,6 +702,9 @@
     if (JSStringIsEqualToUTF8CString(attribute, "AXSortDirection"))
         return [[m_element accessibilitySortDirection] createJSStringRef];
     
+    if (JSStringIsEqualToUTF8CString(attribute, "AXTextualContext"))
+        return [[m_element accessibilityTextualContext] createJSStringRef];
+    
     return createEmptyJSString();
 }
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm (237224 => 237225)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm	2018-10-17 17:51:46 UTC (rev 237224)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm	2018-10-17 17:52:15 UTC (rev 237225)
@@ -81,6 +81,7 @@
 - (NSArray<NSString *> *)accessibilitySpeechHint;
 - (BOOL)_accessibilityIsStrongPasswordField;
 - (CGRect)accessibilityVisibleContentRect;
+- (NSString *)accessibilityTextualContext;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -367,6 +368,9 @@
         return [rectStr createJSStringRef];
     }
 
+    if (JSStringIsEqualToUTF8CString(attribute, "AXTextualContext"))
+        return [[m_element accessibilityTextualContext] createJSStringRef];
+    
     return createEmptyJSString();
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to