AX: Expose block quote level to iOS API
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jan 2017 09:02:12 +0000 (09:02 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 2 Jan 2017 09:02:12 +0000 (09:02 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166629
<rdar://problem/29834793>

Reviewed by Darin Adler.

Source/WebCore:

Expose the blockquote level to iOS Accessbility API.
Change the return type of blockquote level to unsigned.

Test: accessibility/ios-simulator/blockquote-level.html

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::blockquoteLevel):
* accessibility/AccessibilityObject.h:
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper accessibilityBlockquoteLevel]):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):

Tools:

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

LayoutTests:

* accessibility/ios-simulator/blockquote-level-expected.txt: Added.
* accessibility/ios-simulator/blockquote-level.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/accessibility/ios-simulator/blockquote-level-expected.txt [new file with mode: 0644]
LayoutTests/accessibility/ios-simulator/blockquote-level.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Tools/ChangeLog
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm

index 1b9aa3c..b357c9d 100644 (file)
@@ -1,3 +1,14 @@
+2017-01-02  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Expose block quote level to iOS API
+        https://bugs.webkit.org/show_bug.cgi?id=166629
+        <rdar://problem/29834793>
+
+        Reviewed by Darin Adler.
+
+        * accessibility/ios-simulator/blockquote-level-expected.txt: Added.
+        * accessibility/ios-simulator/blockquote-level.html: Added.
+
 2016-12-31  Darin Adler  <darin@apple.com>
 
         Remove PassRefPtr use from the "dom" directory, related cleanup
diff --git a/LayoutTests/accessibility/ios-simulator/blockquote-level-expected.txt b/LayoutTests/accessibility/ios-simulator/blockquote-level-expected.txt
new file mode 100644 (file)
index 0000000..7368965
--- /dev/null
@@ -0,0 +1,13 @@
+1
+2
+This tests that blockquote level is correctly exposed to the iOS accessibility API.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS item1.numberAttributeValue('AXBlockquoteLevel') is 1
+PASS item2.numberAttributeValue('AXBlockquoteLevel') is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/blockquote-level.html b/LayoutTests/accessibility/ios-simulator/blockquote-level.html
new file mode 100644 (file)
index 0000000..4057bc0
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+
+<blockquote><div role="text" id="item1">1</div></blockquote>
+
+<blockquote><blockquote><div role="text" id="item2">2</div></blockquote></blockquote>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+    description("This tests that blockquote level is correctly exposed to the iOS accessibility API.");
+    
+    if (window.accessibilityController) {
+        var item1 = accessibilityController.accessibleElementById("item1");
+        shouldBe("item1.numberAttributeValue('AXBlockquoteLevel')", "1");
+
+        var item2 = accessibilityController.accessibleElementById("item2");
+        shouldBe("item2.numberAttributeValue('AXBlockquoteLevel')", "2");
+    }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index 427ec90..6ab4490 100644 (file)
@@ -1,3 +1,24 @@
+2017-01-02  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Expose block quote level to iOS API
+        https://bugs.webkit.org/show_bug.cgi?id=166629
+        <rdar://problem/29834793>
+
+        Reviewed by Darin Adler.
+
+        Expose the blockquote level to iOS Accessbility API.
+        Change the return type of blockquote level to unsigned.
+
+        Test: accessibility/ios-simulator/blockquote-level.html
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::blockquoteLevel):
+        * accessibility/AccessibilityObject.h:
+        * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityBlockquoteLevel]):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:]):
+
 2017-01-01  Jeff Miller  <jeffm@apple.com>
 
         Update user-visible copyright strings to include 2017
index 86b1eec..e3bb1e8 100644 (file)
@@ -444,9 +444,9 @@ bool AccessibilityObject::hasMisspelling() const
     return isMisspelled;
 }
 
-int AccessibilityObject::blockquoteLevel() const
+unsigned AccessibilityObject::blockquoteLevel() const
 {
-    int level = 0;
+    unsigned level = 0;
     for (Node* elementNode = node(); elementNode; elementNode = elementNode->parentNode()) {
         if (elementNode->hasTagName(blockquoteTag))
             ++level;
index f8309d0..ae32a04 100644 (file)
@@ -613,7 +613,7 @@ public:
     virtual AccessibilityObjectInclusion defaultObjectInclusion() const;
     bool accessibilityIsIgnoredByDefault() const;
     
-    int blockquoteLevel() const;
+    unsigned blockquoteLevel() const;
     virtual int headingLevel() const { return 0; }
     virtual int tableLevel() const { return 0; }
     virtual AccessibilityButtonState checkboxOrRadioValue() const;
index 7b38fea..9b036f4 100644 (file)
@@ -1251,6 +1251,13 @@ static void appendStringToResult(NSMutableString *result, NSString *string)
     return NSMakeRange(columnRange.first, columnRange.second);
 }
 
+- (NSUInteger)accessibilityBlockquoteLevel
+{
+    if (![self _prepareAccessibilityCall])
+        return 0;
+    return m_object->blockquoteLevel();
+}
+
 - (NSString *)accessibilityPlaceholderValue
 {
     if (![self _prepareAccessibilityCall])
index 40ddc41..b0376da 100644 (file)
@@ -3176,7 +3176,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     }
     
     if ([attributeName isEqualToString:NSAccessibilityBlockQuoteLevelAttribute])
-        return [NSNumber numberWithInt:m_object->blockquoteLevel()];
+        return [NSNumber numberWithUnsignedInt:m_object->blockquoteLevel()];
     if ([attributeName isEqualToString:@"AXTableLevel"])
         return [NSNumber numberWithInt:m_object->tableLevel()];
     
index c6719fb..bf82477 100644 (file)
@@ -1,3 +1,16 @@
+2017-01-02  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Expose block quote level to iOS API
+        https://bugs.webkit.org/show_bug.cgi?id=166629
+        <rdar://problem/29834793>
+
+        Reviewed by Darin Adler.
+
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::numberAttributeValue):
+        * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+        (WTR::AccessibilityUIElement::numberAttributeValue):
+
 2016-12-31  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         SecurityOrigin::create triplet constructor does not canonicalize port
index 060adc8..b3fc9de 100644 (file)
@@ -99,6 +99,7 @@ AccessibilityUIElement::~AccessibilityUIElement()
 - (NSString *)accessibilityExpandedTextValue;
 - (NSString *)accessibilitySortDirection;
 - (BOOL)accessibilityIsExpanded;
+- (NSUInteger)accessibilityBlockquoteLevel;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -1142,6 +1143,8 @@ double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
         return [m_element accessibilityARIAColumnIndex];
     if (JSStringIsEqualToUTF8CString(attribute, "AXARIARowIndex"))
         return [m_element accessibilityARIARowIndex];
+    if (JSStringIsEqualToUTF8CString(attribute, "AXBlockquoteLevel"))
+        return [m_element accessibilityBlockquoteLevel];
     
     return 0;
 }
index d5bd6c3..662ed47 100644 (file)
@@ -76,6 +76,7 @@ typedef void (*AXPostedNotificationCallback)(id element, NSString* notification,
 - (NSString *)accessibilityExpandedTextValue;
 - (NSString *)accessibilitySortDirection;
 - (BOOL)accessibilityIsExpanded;
+- (NSUInteger)accessibilityBlockquoteLevel;
 
 // TextMarker related
 - (NSArray *)textMarkerRange;
@@ -365,6 +366,8 @@ double AccessibilityUIElement::numberAttributeValue(JSStringRef attribute)
         return [m_element accessibilityARIAColumnIndex];
     if (JSStringIsEqualToUTF8CString(attribute, "AXARIARowIndex"))
         return [m_element accessibilityARIARowIndex];
+    if (JSStringIsEqualToUTF8CString(attribute, "AXBlockquoteLevel"))
+        return [m_element accessibilityBlockquoteLevel];
     
     return 0;
 }