Diff
Modified: trunk/LayoutTests/ChangeLog (234525 => 234526)
--- trunk/LayoutTests/ChangeLog 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/LayoutTests/ChangeLog 2018-08-02 23:54:45 UTC (rev 234526)
@@ -1,3 +1,14 @@
+2018-08-02 Nan Wang <n_w...@apple.com>
+
+ AX: [iOS] add support to return the attributed string under the element
+ https://bugs.webkit.org/show_bug.cgi?id=188276
+ <rdar://problem/42872357>
+
+ Reviewed by Chris Fleizach.
+
+ * accessibility/ios-simulator/attributed-string-for-element-expected.txt: Added.
+ * accessibility/ios-simulator/attributed-string-for-element.html: Added.
+
2018-08-02 Tim Horton <timothy_hor...@apple.com>
REGRESSION (r234488): Layout test fast/events/ios/keyboard-scrolling-repeat.html is timing out
Added: trunk/LayoutTests/accessibility/ios-simulator/attributed-string-for-element-expected.txt (0 => 234526)
--- trunk/LayoutTests/accessibility/ios-simulator/attributed-string-for-element-expected.txt (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/attributed-string-for-element-expected.txt 2018-08-02 23:54:45 UTC (rev 234526)
@@ -0,0 +1,29 @@
+hello world test bold
+This test ensures that attributed string under the element works
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Attributed string: hello {
+ UIAccessibilityTokenFontFamily = "Times New Roman";
+ UIAccessibilityTokenFontName = "Times New Roman";
+ UIAccessibilityTokenFontSize = 16;
+}world{
+ UIAccessibilityTokenBold = 1;
+ UIAccessibilityTokenFontFamily = "Times New Roman";
+ UIAccessibilityTokenFontName = "Times New Roman Bold";
+ UIAccessibilityTokenFontSize = 16;
+} test {
+ UIAccessibilityTokenFontFamily = "Times New Roman";
+ UIAccessibilityTokenFontName = "Times New Roman";
+ UIAccessibilityTokenFontSize = 16;
+}bold{
+ UIAccessibilityTokenBold = 1;
+ UIAccessibilityTokenFontFamily = "Times New Roman";
+ UIAccessibilityTokenFontName = "Times New Roman Bold";
+ UIAccessibilityTokenFontSize = 16;
+}
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/accessibility/ios-simulator/attributed-string-for-element.html (0 => 234526)
--- trunk/LayoutTests/accessibility/ios-simulator/attributed-string-for-element.html (rev 0)
+++ trunk/LayoutTests/accessibility/ios-simulator/attributed-string-for-element.html 2018-08-02 23:54:45 UTC (rev 234526)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<body id="body">
+
+<div id="content">
+hello <b>world</b> test <b>bold</b>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+<script src=""
+<script>
+
+ description("This test ensures that attributed string under the element works");
+
+ if (window.accessibilityController) {
+
+ var obj = accessibilityController.accessibleElementById("content");
+ var text = obj.attributedStringForElement();
+ debug("Attributed string: " + text);
+ }
+
+ successfullyParsed = true;
+</script>
+
+<script src=""
+</body>
+</html>
+
Modified: trunk/Source/WebCore/ChangeLog (234525 => 234526)
--- trunk/Source/WebCore/ChangeLog 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Source/WebCore/ChangeLog 2018-08-02 23:54:45 UTC (rev 234526)
@@ -1,3 +1,21 @@
+2018-08-02 Nan Wang <n_w...@apple.com>
+
+ AX: [iOS] add support to return the attributed string under the element
+ https://bugs.webkit.org/show_bug.cgi?id=188276
+ <rdar://problem/42872357>
+
+ Reviewed by Chris Fleizach.
+
+ Provided a way on iOS to return the attributed string under the element for
+ better performance.
+
+ Test: accessibility/ios-simulator/attributed-string-for-element.html
+
+ * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm:
+ (-[WebAccessibilityObjectWrapper _stringFromStartMarker:toEndMarker:attributed:]):
+ (-[WebAccessibilityObjectWrapper _stringForRange:attributed:]):
+ (-[WebAccessibilityObjectWrapper attributedStringForElement]):
+
2018-08-02 Zalan Bujtas <za...@apple.com>
[LFC][Floating] Remove redundant LayoutContext member variable.
Modified: trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (234525 => 234526)
--- trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm 2018-08-02 23:54:45 UTC (rev 234526)
@@ -2514,26 +2514,11 @@
return [WebAccessibilityTextMarker textMarkerWithCharacterOffset:characterOffset cache:cache];
}
-- (id)_stringForRange:(NSRange)range attributed:(BOOL)attributed
+- (id)_stringFromStartMarker:(WebAccessibilityTextMarker*)startMarker toEndMarker:(WebAccessibilityTextMarker*)endMarker attributed:(BOOL)attributed
{
- if (![self _prepareAccessibilityCall])
+ if (!startMarker || !endMarker)
return nil;
- WebAccessibilityTextMarker* startMarker = [self textMarkerForPosition:range.location];
- WebAccessibilityTextMarker* endMarker = [self textMarkerForPosition:NSMaxRange(range)];
-
- // Clients don't always know the exact range, rather than force them to compute it,
- // allow clients to overshoot and use the max text marker range.
- if (!startMarker || !endMarker) {
- NSArray *markers = [self textMarkerRange];
- if ([markers count] != 2)
- return nil;
- if (!startMarker)
- startMarker = [markers objectAtIndex:0];
- if (!endMarker)
- endMarker = [markers objectAtIndex:1];
- }
-
NSArray* array = [self arrayOfTextForTextMarkers:[NSArray arrayWithObjects:startMarker, endMarker, nil] attributed:attributed];
Class returnClass = attributed ? [NSMutableAttributedString class] : [NSMutableString class];
id returnValue = [[(NSString *)[returnClass alloc] init] autorelease];
@@ -2557,7 +2542,30 @@
return returnValue;
}
+- (id)_stringForRange:(NSRange)range attributed:(BOOL)attributed
+{
+ if (![self _prepareAccessibilityCall])
+ return nil;
+
+ WebAccessibilityTextMarker* startMarker = [self textMarkerForPosition:range.location];
+ WebAccessibilityTextMarker* endMarker = [self textMarkerForPosition:NSMaxRange(range)];
+
+ // Clients don't always know the exact range, rather than force them to compute it,
+ // allow clients to overshoot and use the max text marker range.
+ if (!startMarker || !endMarker) {
+ NSArray *markers = [self textMarkerRange];
+ if ([markers count] != 2)
+ return nil;
+ if (!startMarker)
+ startMarker = [markers objectAtIndex:0];
+ if (!endMarker)
+ endMarker = [markers objectAtIndex:1];
+ }
+
+ return [self _stringFromStartMarker:startMarker toEndMarker:endMarker attributed:attributed];
+}
+
// A convenience method for getting the text of a NSRange. Currently used only by DRT.
- (NSString *)stringForRange:(NSRange)range
{
@@ -2569,6 +2577,18 @@
return [self _stringForRange:range attributed:YES];
}
+- (NSAttributedString *)attributedStringForElement
+{
+ if (![self _prepareAccessibilityCall])
+ return nil;
+
+ NSArray *markers = [self textMarkerRange];
+ if ([markers count] != 2)
+ return nil;
+
+ return [self _stringFromStartMarker:markers.firstObject toEndMarker:markers.lastObject attributed:YES];
+}
+
- (NSRange)_accessibilitySelectedTextRange
{
if (![self _prepareAccessibilityCall] || !m_object->isTextControl())
Modified: trunk/Tools/ChangeLog (234525 => 234526)
--- trunk/Tools/ChangeLog 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Tools/ChangeLog 2018-08-02 23:54:45 UTC (rev 234526)
@@ -1,3 +1,24 @@
+2018-08-02 Nan Wang <n_w...@apple.com>
+
+ AX: [iOS] add support to return the attributed string under the element
+ https://bugs.webkit.org/show_bug.cgi?id=188276
+ <rdar://problem/42872357>
+
+ Reviewed by Chris Fleizach.
+
+ * DumpRenderTree/AccessibilityUIElement.cpp:
+ (attributedStringForElementCallback):
+ (AccessibilityUIElement::getJSClass):
+ * DumpRenderTree/AccessibilityUIElement.h:
+ * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+ (AccessibilityUIElement::attributedStringForElement):
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+ (WTR::AccessibilityUIElement::attributedStringForElement):
+ * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
+ * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+ * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm:
+ (WTR::AccessibilityUIElement::attributedStringForElement):
+
2018-08-02 Ryan Haddad <ryanhad...@apple.com>
Skip API test DataInteractionTests.CustomActionSheetPopover on current SDKs.
Modified: trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp (234525 => 234526)
--- trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp 2018-08-02 23:54:45 UTC (rev 234526)
@@ -369,6 +369,12 @@
return AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->fieldsetAncestorElement());
}
+static JSValueRef attributedStringForElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+ JSRetainPtr<JSStringRef> stringDescription(Adopt, toAXElement(thisObject)->attributedStringForElement());
+ return JSValueMakeString(context, stringDescription.get());
+}
+
#endif
static JSValueRef childAtIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
@@ -1980,6 +1986,7 @@
{ "assistiveTechnologySimulatedFocus", assistiveTechnologySimulatedFocusCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "fieldsetAncestorElement", fieldsetAncestorElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
{ "textMarkerRangeMatchesTextNearMarkers", textMarkerRangeMatchesTextNearMarkersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+ { "attributedStringForElement", attributedStringForElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
#endif
{ 0, 0, 0 }
};
Modified: trunk/Tools/DumpRenderTree/AccessibilityUIElement.h (234525 => 234526)
--- trunk/Tools/DumpRenderTree/AccessibilityUIElement.h 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Tools/DumpRenderTree/AccessibilityUIElement.h 2018-08-02 23:54:45 UTC (rev 234526)
@@ -232,6 +232,7 @@
bool hasContainedByFieldsetTrait();
AccessibilityUIElement fieldsetAncestorElement();
+ JSStringRef attributedStringForElement();
#endif
#if PLATFORM(GTK)
Modified: trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm (234525 => 234526)
--- trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm 2018-08-02 23:54:45 UTC (rev 234526)
@@ -74,6 +74,7 @@
- (NSString *)accessibilityPlaceholderValue;
- (NSString *)stringForRange:(NSRange)range;
- (NSAttributedString *)attributedStringForRange:(NSRange)range;
+- (NSAttributedString *)attributedStringForElement;
- (NSArray *)elementsForRange:(NSRange)range;
- (NSString *)selectionRangeString;
- (CGPoint)accessibilityClickPoint;
@@ -393,6 +394,15 @@
return [stringWithAttrs createJSStringRef];
}
+JSStringRef AccessibilityUIElement::attributedStringForElement()
+{
+ NSAttributedString *string = [m_element attributedStringForElement];
+ if (![string isKindOfClass:[NSAttributedString class]])
+ return nullptr;
+
+ return [[string description] createJSStringRef];
+}
+
bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned, unsigned)
{
return false;
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp (234525 => 234526)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp 2018-08-02 23:54:45 UTC (rev 234526)
@@ -76,6 +76,7 @@
bool AccessibilityUIElement::isTextArea() const { return false; }
RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers(JSStringRef, AccessibilityTextMarker*, AccessibilityTextMarker*) { return nullptr; }
bool AccessibilityUIElement::dismiss() { return false; }
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForElement() { return nullptr; }
#endif
// Unsupported methods on various platforms. As they're implemented on other platforms this list should be modified.
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h (234525 => 234526)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h 2018-08-02 23:54:45 UTC (rev 234526)
@@ -248,6 +248,8 @@
bool setSelectedTextRange(unsigned location, unsigned length);
JSRetainPtr<JSStringRef> stringForRange(unsigned location, unsigned length);
JSRetainPtr<JSStringRef> attributedStringForRange(unsigned location, unsigned length);
+ JSRetainPtr<JSStringRef> attributedStringForElement();
+
bool attributedStringRangeIsMisspelled(unsigned location, unsigned length);
unsigned uiElementCountForSearchPredicate(JSContextRef, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly, bool immediateDescendantsOnly);
RefPtr<AccessibilityUIElement> uiElementForSearchPredicate(JSContextRef, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText, bool visibleOnly, bool immediateDescendantsOnly);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl (234525 => 234526)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl 2018-08-02 23:54:45 UTC (rev 234526)
@@ -177,6 +177,7 @@
DOMString boundsForRange(unsigned long location, unsigned long length);
DOMString stringForRange(unsigned long location, unsigned long length);
DOMString attributedStringForRange(unsigned long location, unsigned long length);
+ DOMString attributedStringForElement();
boolean attributedStringRangeIsMisspelled(unsigned long location, unsigned long length);
[PassContext] unsigned long uiElementCountForSearchPredicate(AccessibilityUIElement startElement, boolean isDirectionNext, object searchKey, DOMString searchText, boolean visibleOnly, boolean immediateDescendantsOnly);
[PassContext] AccessibilityUIElement uiElementForSearchPredicate(AccessibilityUIElement startElement, boolean isDirectionNext, object searchKey, DOMString searchText, boolean visibleOnly, boolean immediateDescendantsOnly);
Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm (234525 => 234526)
--- trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm 2018-08-02 23:48:16 UTC (rev 234525)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm 2018-08-02 23:54:45 UTC (rev 234526)
@@ -52,6 +52,7 @@
- (NSString *)accessibilityPlaceholderValue;
- (NSString *)stringForRange:(NSRange)range;
- (NSAttributedString *)attributedStringForRange:(NSRange)range;
+- (NSAttributedString *)attributedStringForElement;
- (NSArray *)elementsForRange:(NSRange)range;
- (NSString *)selectionRangeString;
- (CGPoint)accessibilityClickPoint;
@@ -661,6 +662,15 @@
return [[stringForRange description] createJSStringRef];
}
+JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForElement()
+{
+ NSAttributedString *string = [m_element attributedStringForElement];
+ if (![string isKindOfClass:[NSAttributedString class]])
+ return nullptr;
+
+ return [[string description] createJSStringRef];
+}
+
bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location, unsigned length)
{
return false;