WebKit Bugzilla
Attachment 346416 Details for
Bug 188276
: AX: [iOS] add support to return the attributed string under the element
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
patch.txt (text/plain), 17.12 KB, created by
Nan Wang
on 2018-08-02 14:20:41 PDT
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Nan Wang
Created:
2018-08-02 14:20:41 PDT
Size:
17.12 KB
patch
obsolete
>Index: Source/WebCore/ChangeLog >=================================================================== >--- Source/WebCore/ChangeLog (revision 234486) >+++ Source/WebCore/ChangeLog (working copy) >@@ -1,3 +1,21 @@ >+2018-08-02 Nan Wang <n_wang@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 NOBODY (OOPS!). >+ >+ 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-01 Alex Christensen <achristensen@webkit.org> > > Move all calls to ResourceLoader::start to WebKitLegacy >Index: Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm >=================================================================== >--- Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (revision 234486) >+++ Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm (working copy) >@@ -2514,26 +2514,11 @@ - (WebAccessibilityTextMarker *)textMark > 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]; >@@ -2542,7 +2527,7 @@ - (id)_stringForRange:(NSRange)range att > NSInteger count = [array count]; > for (NSInteger k = 0; k < count; ++k) { > id object = [array objectAtIndex:k]; >- >+ > if (attributed && [object isKindOfClass:[WebAccessibilityObjectWrapper class]]) > object = [[[NSMutableAttributedString alloc] initWithString:[NSString stringWithCharacters:&attachmentChar length:1] attributes:@{ UIAccessibilityTokenAttachment : object }] autorelease]; > >@@ -2557,6 +2542,29 @@ - (id)_stringForRange:(NSRange)range att > 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 @@ - (NSAttributedString *)attributedString > 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()) >Index: Tools/ChangeLog >=================================================================== >--- Tools/ChangeLog (revision 234514) >+++ Tools/ChangeLog (working copy) >@@ -1,3 +1,24 @@ >+2018-08-02 Nan Wang <n_wang@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 NOBODY (OOPS!). >+ >+ * 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 Dan Bernstein <mitz@apple.com> > > Fixed WebKit.AttrStyle timing out on build.webkit.org. >Index: Tools/DumpRenderTree/AccessibilityUIElement.cpp >=================================================================== >--- Tools/DumpRenderTree/AccessibilityUIElement.cpp (revision 234486) >+++ Tools/DumpRenderTree/AccessibilityUIElement.cpp (working copy) >@@ -369,6 +369,12 @@ static JSValueRef fieldsetAncestorElemen > 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 @@ JSClassRef AccessibilityUIElement::getJS > { "assistiveTechnologySimulatedFocus", assistiveTechnologySimulatedFocusCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "fieldsetAncestorElement", fieldsetAncestorElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > { "textMarkerRangeMatchesTextNearMarkers", textMarkerRangeMatchesTextNearMarkersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, >+ { "attributedStringForElement", attributedStringForElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, > #endif > { 0, 0, 0 } > }; >Index: Tools/DumpRenderTree/AccessibilityUIElement.h >=================================================================== >--- Tools/DumpRenderTree/AccessibilityUIElement.h (revision 234486) >+++ Tools/DumpRenderTree/AccessibilityUIElement.h (working copy) >@@ -232,6 +232,7 @@ public: > > bool hasContainedByFieldsetTrait(); > AccessibilityUIElement fieldsetAncestorElement(); >+ JSStringRef attributedStringForElement(); > #endif > > #if PLATFORM(GTK) >Index: Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm >=================================================================== >--- Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm (revision 234486) >+++ Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm (working copy) >@@ -74,6 +74,7 @@ - (NSArray *)accessibilityHeaderElements > - (NSString *)accessibilityPlaceholderValue; > - (NSString *)stringForRange:(NSRange)range; > - (NSAttributedString *)attributedStringForRange:(NSRange)range; >+- (NSAttributedString *)attributedStringForElement; > - (NSArray *)elementsForRange:(NSRange)range; > - (NSString *)selectionRangeString; > - (CGPoint)accessibilityClickPoint; >@@ -393,6 +394,15 @@ JSStringRef AccessibilityUIElement::attr > 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; >Index: Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp >=================================================================== >--- Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp (revision 234486) >+++ Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp (working copy) >@@ -76,6 +76,7 @@ bool AccessibilityUIElement::isSearchFie > 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. >Index: Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h >=================================================================== >--- Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h (revision 234486) >+++ Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h (working copy) >@@ -248,6 +248,8 @@ public: > 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); >Index: Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl >=================================================================== >--- Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl (revision 234486) >+++ Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl (working copy) >@@ -177,6 +177,7 @@ interface AccessibilityUIElement { > 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); >Index: Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm >=================================================================== >--- Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm (revision 234486) >+++ Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm (working copy) >@@ -52,6 +52,7 @@ - (NSArray *)accessibilityHeaderElements > - (NSString *)accessibilityPlaceholderValue; > - (NSString *)stringForRange:(NSRange)range; > - (NSAttributedString *)attributedStringForRange:(NSRange)range; >+- (NSAttributedString *)attributedStringForElement; > - (NSArray *)elementsForRange:(NSRange)range; > - (NSString *)selectionRangeString; > - (CGPoint)accessibilityClickPoint; >@@ -661,6 +662,15 @@ JSRetainPtr<JSStringRef> AccessibilityUI > 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; >Index: LayoutTests/ChangeLog >=================================================================== >--- LayoutTests/ChangeLog (revision 234486) >+++ LayoutTests/ChangeLog (working copy) >@@ -1,3 +1,14 @@ >+2018-08-02 Nan Wang <n_wang@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 NOBODY (OOPS!). >+ >+ * accessibility/ios-simulator/attributed-string-for-element-expected.txt: Added. >+ * accessibility/ios-simulator/attributed-string-for-element.html: Added. >+ > 2018-08-01 Ryosuke Niwa <rniwa@webkit.org> > > REGRESSION(r227983): fast/dom/adopt-node-crash-2.html is flaky >Index: LayoutTests/accessibility/ios-simulator/attributed-string-for-element-expected.txt >=================================================================== >--- LayoutTests/accessibility/ios-simulator/attributed-string-for-element-expected.txt (nonexistent) >+++ LayoutTests/accessibility/ios-simulator/attributed-string-for-element-expected.txt (working copy) >@@ -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 >+ >Index: LayoutTests/accessibility/ios-simulator/attributed-string-for-element.html >=================================================================== >--- LayoutTests/accessibility/ios-simulator/attributed-string-for-element.html (nonexistent) >+++ LayoutTests/accessibility/ios-simulator/attributed-string-for-element.html (working copy) >@@ -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="../../resources/js-test-pre.js"></script> >+<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="../../resources/js-test-post.js"></script> >+</body> >+</html> >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
cfleizach
:
review+
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 188276
: 346416