AX: Accessibility needs to know which part of the content view is visible on iOS
https://bugs.webkit.org/show_bug.cgi?id=185085
<rdar://problem/39801363>
Reviewed by Chris Fleizach.
Source/WebCore:
Exposed unobscuredContentRect() to iOS accessibility object wrapper.
Test: accessibility/ios-simulator/unobscured-content-rect.html
* accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
(-[WebAccessibilityObjectWrapper accessibilityVisibleContentRect]):
Tools:
* WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
(WTR::AccessibilityUIElement::stringAttributeValue):
LayoutTests:
* accessibility/ios-simulator/unobscured-content-rect-expected.txt: Added.
* accessibility/ios-simulator/unobscured-content-rect.html: Added.
* platform/ios-wk1/TestExpectations:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@231113 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 465e8fa..dc0998f 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,15 @@
+2018-04-27 Nan Wang <n_wang@apple.com>
+
+ AX: Accessibility needs to know which part of the content view is visible on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=185085
+ <rdar://problem/39801363>
+
+ Reviewed by Chris Fleizach.
+
+ * accessibility/ios-simulator/unobscured-content-rect-expected.txt: Added.
+ * accessibility/ios-simulator/unobscured-content-rect.html: Added.
+ * platform/ios-wk1/TestExpectations:
+
2018-04-27 Christopher Reid <chris.reid@sony.com>
URL::appendEncodedHostName is using the deprecated uidna_IDNToASCII function
diff --git a/LayoutTests/accessibility/ios-simulator/unobscured-content-rect-expected.txt b/LayoutTests/accessibility/ios-simulator/unobscured-content-rect-expected.txt
new file mode 100644
index 0000000..f7ddce9
--- /dev/null
+++ b/LayoutTests/accessibility/ios-simulator/unobscured-content-rect-expected.txt
@@ -0,0 +1,12 @@
+test
+This tests that unobscured content rect is exposed to accessibility.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS button.stringAttributeValue('AXVisibleContentRect') is '{0.00, 0.00, 800.00, 600.00}'
+PASS frameButton.stringAttributeValue('AXVisibleContentRect') is '{60.00, 10.00, 200.00, 200.00}'
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/accessibility/ios-simulator/unobscured-content-rect.html b/LayoutTests/accessibility/ios-simulator/unobscured-content-rect.html
new file mode 100644
index 0000000..b7f351e
--- /dev/null
+++ b/LayoutTests/accessibility/ios-simulator/unobscured-content-rect.html
@@ -0,0 +1,38 @@
+
+<!DOCTYPE html>
+<html>
+<body id="body">
+<script src="../../resources/js-test-pre.js"></script>
+<div id="content">
+<button id="button">test</button>
+
+<iframe id="iframe" onload="startTest();" width="200" height="200" src="data:text/html,<body><button id='frame-button'>Click me</button><a href='#' id='frame-link'>a</a></body>"></iframe>
+
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+ description("This tests that unobscured content rect is exposed to accessibility.");
+
+ if (window.accessibilityController) {
+ window.jsTestIsAsync = true;
+ var button = accessibilityController.accessibleElementById("button");
+ shouldBe("button.stringAttributeValue('AXVisibleContentRect')", "'{0.00, 0.00, 800.00, 600.00}'");
+
+ var frameButton;
+ function startTest() {
+ var iframe = document.getElementById("iframe");
+ frameButton = iframe.contentWindow.accessibilityController.accessibleElementById("frame-button");
+ shouldBe("frameButton.stringAttributeValue('AXVisibleContentRect')", "'{60.00, 10.00, 200.00, 200.00}'");
+ finishJSTest();
+ }
+ }
+</script>
+
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
+
diff --git a/LayoutTests/platform/ios-wk1/TestExpectations b/LayoutTests/platform/ios-wk1/TestExpectations
index 3362bd5..0b4a3ca 100644
--- a/LayoutTests/platform/ios-wk1/TestExpectations
+++ b/LayoutTests/platform/ios-wk1/TestExpectations
@@ -105,6 +105,7 @@
# Not supported on WK1
accessibility/ios-simulator/speak-selection-content.html [ Skip ]
accessibility/ios-simulator/accessibility-events-setting.html [ Skip ]
+accessibility/ios-simulator/unobscured-content-rect.html [ Skip ]
# FIXME: Tests that fail due to lack of textInputController <rdar://problem/5106287>
editing/inserting/insert-composition-whitespace.html [ Failure ]
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index faf30ce..ac2119a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2018-04-27 Nan Wang <n_wang@apple.com>
+
+ AX: Accessibility needs to know which part of the content view is visible on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=185085
+ <rdar://problem/39801363>
+
+ Reviewed by Chris Fleizach.
+
+ Exposed unobscuredContentRect() to iOS accessibility object wrapper.
+
+ Test: accessibility/ios-simulator/unobscured-content-rect.html
+
+ * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+ (-[WebAccessibilityObjectWrapper accessibilityVisibleContentRect]):
+
2018-04-27 Simon Fraser <simon.fraser@apple.com>
Refactor filter list checking code
diff --git a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm b/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
index 30ec04a..afdc75a 100644
--- a/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
+++ b/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
@@ -1666,6 +1666,18 @@
return CGRectMake(rect.x(), rect.y(), rect.width(), rect.height());
}
+- (CGRect)accessibilityVisibleContentRect
+{
+ if (![self _prepareAccessibilityCall])
+ return CGRectZero;
+
+ Document* document = m_object->document();
+ if (!document || !document->view())
+ return CGRectZero;
+ IntRect rect = snappedIntRect(document->view()->unobscuredContentRect());
+ return [self convertRectToScreenSpace:rect];
+}
+
// The "center point" is where VoiceOver will "press" an object. This may not be the actual
// center of the accessibilityFrame
- (CGPoint)accessibilityActivationPoint
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 7dc32fb..bb36dc5 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,14 @@
+2018-04-27 Nan Wang <n_wang@apple.com>
+
+ AX: Accessibility needs to know which part of the content view is visible on iOS
+ https://bugs.webkit.org/show_bug.cgi?id=185085
+ <rdar://problem/39801363>
+
+ Reviewed by Chris Fleizach.
+
+ * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+ (WTR::AccessibilityUIElement::stringAttributeValue):
+
2018-04-27 Wenson Hsieh <wenson_hsieh@apple.com>
[Extra zoom mode] Add a mechanism to override default viewport behaviors in extra zoom mode
diff --git a/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm b/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm
index f39647c..ff25691 100644
--- a/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm
+++ b/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm
@@ -81,6 +81,7 @@
- (NSArray *)accessibilityFindMatchingObjects:(NSDictionary *)parameters;
- (NSArray<NSString *> *)accessibilitySpeechHint;
- (BOOL)_accessibilityIsStrongPasswordField;
+- (CGRect)accessibilityVisibleContentRect;
// TextMarker related
- (NSArray *)textMarkerRange;
@@ -356,6 +357,12 @@
if (JSStringIsEqualToUTF8CString(attribute, "AXSortDirection"))
return [[m_element accessibilitySortDirection] createJSStringRef];
+
+ if (JSStringIsEqualToUTF8CString(attribute, "AXVisibleContentRect")) {
+ CGRect screenRect = [m_element accessibilityVisibleContentRect];
+ NSString *rectStr = [NSString stringWithFormat:@"{%.2f, %.2f, %.2f, %.2f}", screenRect.origin.x, screenRect.origin.y, screenRect.size.width, screenRect.size.height];
+ return [rectStr createJSStringRef];
+ }
return JSStringCreateWithCharacters(0, 0);
}