Changeset 244059 in webkit
- Timestamp:
- Apr 8, 2019, 5:39:50 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 14 edited
-
LayoutTests/accessibility/mac/replace-text-with-range-expected.txt (added)
-
LayoutTests/accessibility/mac/replace-text-with-range.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/accessibility/AccessibilityObject.cpp (modified) (1 diff)
-
Source/WebCore/accessibility/AccessibilityObject.h (modified) (2 diffs)
-
Source/WebCore/accessibility/mac/AccessibilityObjectBase.mm (modified) (1 diff)
-
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm (modified) (1 diff)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/DumpRenderTree/AccessibilityUIElement.cpp (modified) (3 diffs)
-
Tools/DumpRenderTree/AccessibilityUIElement.h (modified) (1 diff)
-
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm (modified) (1 diff)
-
Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm (modified) (2 diffs)
-
Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm (modified) (1 diff)
-
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r244056 r244059 1 2019-04-08 Chris Fleizach <cfleizach@apple.com> 2 3 AX: Support API: accessibilityReplaceRange:withText 4 https://bugs.webkit.org/show_bug.cgi?id=196636 5 6 Reviewed by Daniel Bates. 7 8 Support this platform API on mac to provide a way to replace a range of editable text. 9 10 Test: accessibility/mac/replace-text-with-range.html 11 12 * accessibility/AccessibilityObject.cpp: 13 (WebCore::AccessibilityObject::replaceTextInRange): 14 * accessibility/AccessibilityObject.h: 15 * accessibility/mac/AccessibilityObjectBase.mm: 16 (WebCore::PlainTextRange::PlainTextRange): 17 * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: 18 (-[WebAccessibilityObjectWrapper accessibilityReplaceRange:withText:]): 19 1 20 2019-04-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 21 -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r243198 r244059 2275 2275 return dispatchAccessibilityEvent(event); 2276 2276 } 2277 2277 2278 bool AccessibilityObject::replaceTextInRange(const String& replacementString, const PlainTextRange& range) 2279 { 2280 if (!renderer() || !is<Element>(node())) 2281 return false; 2282 2283 auto& element = downcast<Element>(*renderer()->node()); 2284 2285 // We should use the editor's insertText to mimic typing into the field. 2286 // Also only do this when the field is in editing mode. 2287 auto& frame = renderer()->frame(); 2288 if (element.shouldUseInputMethod()) { 2289 frame.selection().setSelectedRange(rangeForPlainTextRange(range).get(), DOWNSTREAM, FrameSelection::ShouldCloseTyping::Yes); 2290 frame.editor().replaceSelectionWithText(replacementString, Editor::SelectReplacement::No, Editor::SmartReplace::No); 2291 return true; 2292 } 2293 2294 if (is<HTMLInputElement>(element)) { 2295 downcast<HTMLInputElement>(element).setRangeText(replacementString, range.start, range.length, ""); 2296 return true; 2297 } 2298 if (is<HTMLTextAreaElement>(element)) { 2299 downcast<HTMLTextAreaElement>(element).setRangeText(replacementString, range.start, range.length, ""); 2300 return true; 2301 } 2302 2303 return false; 2304 } 2305 2278 2306 bool AccessibilityObject::dispatchAccessibleSetValueEvent(const String& value) const 2279 2307 { -
trunk/Source/WebCore/accessibility/AccessibilityObject.h
r243928 r244059 297 297 , length(l) 298 298 { } 299 300 #if PLATFORM(COCOA) 301 PlainTextRange(NSRange); 302 #endif 299 303 300 304 bool isNull() const { return !start && !length; } … … 702 706 virtual void setSelectedTextRange(const PlainTextRange&) { } 703 707 virtual void setValue(const String&) { } 708 bool replaceTextInRange(const String&, const PlainTextRange&); 709 704 710 virtual void setValue(float) { } 705 711 virtual void setSelected(bool) { } -
trunk/Source/WebCore/accessibility/mac/AccessibilityObjectBase.mm
r241321 r244059 33 33 namespace WebCore { 34 34 35 PlainTextRange::PlainTextRange(NSRange r) 36 : start(r.location) 37 , length(r.length) 38 { 39 } 40 35 41 String AccessibilityObject::speechHintAttributeValue() const 36 42 { -
trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
r242051 r244059 3643 3643 } 3644 3644 3645 - (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string 3646 { 3647 if (![self updateObjectBackingStore]) 3648 return NO; 3649 3650 return m_object->replaceTextInRange(string, PlainTextRange(range)); 3651 } 3652 3645 3653 IGNORE_WARNINGS_BEGIN("deprecated-implementations") 3646 3654 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attributeName -
trunk/Tools/ChangeLog
r244056 r244059 1 2019-04-08 Chris Fleizach <cfleizach@apple.com> 2 3 AX: Support API: accessibilityReplaceRange:withText 4 https://bugs.webkit.org/show_bug.cgi?id=196636 5 6 Reviewed by Daniel Bates. 7 8 * DumpRenderTree/AccessibilityUIElement.cpp: 9 (replaceTextInRangeCallback): 10 (AccessibilityUIElement::replaceTextInRange): 11 (AccessibilityUIElement::getJSClass): 12 * DumpRenderTree/AccessibilityUIElement.h: 13 * DumpRenderTree/ios/AccessibilityUIElementIOS.mm: 14 (AccessibilityUIElement::replaceTextInRange): 15 * DumpRenderTree/mac/AccessibilityUIElementMac.mm: 16 (AccessibilityUIElement::replaceTextInRange): 17 * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: 18 * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl: 19 * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: 20 (WTR::AccessibilityUIElement::replaceTextInRange): 21 * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: 22 (WTR::AccessibilityUIElement::replaceTextInRange): 23 1 24 2019-04-08 Wenson Hsieh <wenson_hsieh@apple.com> 2 25 -
trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp
r237266 r244059 807 807 } 808 808 809 static JSValueRef replaceTextInRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 810 { 811 if (argumentCount < 3) 812 return JSValueMakeUndefined(context); 813 814 auto text = adopt(JSValueToStringCopy(context, arguments[0], exception)); 815 int position = JSValueToNumber(context, arguments[1], exception); 816 int length = JSValueToNumber(context, arguments[2], exception); 817 818 return JSValueMakeBoolean(context, toAXElement(thisObject)->replaceTextInRange(text.get(), position, length)); 819 } 820 809 821 static JSValueRef attributedStringForTextMarkerRangeContainsAttributeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 810 822 { … … 1608 1620 void AccessibilityUIElement::resetSelectedTextMarkerRange() 1609 1621 { 1622 } 1623 1624 void AccessibilityUIElement::replaceTextInRange(JSStringRef, int, int) 1625 { 1626 return false; 1610 1627 } 1611 1628 … … 1932 1949 { "selectedTextMarkerRange", selectedTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1933 1950 { "resetSelectedTextMarkerRange", resetSelectedTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1951 { "replaceTextInRange", replaceTextInRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1934 1952 { "attributedStringForTextMarkerRangeContainsAttribute", attributedStringForTextMarkerRangeContainsAttributeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1935 1953 { "indexForTextMarker", indexForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, -
trunk/Tools/DumpRenderTree/AccessibilityUIElement.h
r237266 r244059 278 278 void resetSelectedTextMarkerRange(); 279 279 bool setSelectedVisibleTextRange(AccessibilityTextMarkerRange*); 280 280 bool replaceTextInRange(JSStringRef, int position, int length); 281 281 282 JSRetainPtr<JSStringRef> stringForTextMarkerRange(AccessibilityTextMarkerRange*); 282 283 JSRetainPtr<JSStringRef> attributedStringForTextMarkerRange(AccessibilityTextMarkerRange*); -
trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
r237266 r244059 478 478 } 479 479 480 bool AccessibilityUIElement::replaceTextInRange(JSStringRef, int, int) 481 { 482 return false; 483 } 484 480 485 void AccessibilityUIElement::resetSelectedTextMarkerRange() 481 486 { -
trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
r240219 r244059 71 71 72 72 @interface NSObject (WebKitAccessibilityAdditions) 73 - (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string; 73 74 - (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount; 74 75 - (NSUInteger)accessibilityIndexOfChild:(id)child; … … 1634 1635 } 1635 1636 1637 bool AccessibilityUIElement::replaceTextInRange(JSStringRef string, int location, int length) 1638 { 1639 BEGIN_AX_OBJC_EXCEPTIONS 1640 return [m_element accessibilityReplaceRange:NSMakeRange(location, length) withText:[NSString stringWithJSStringRef:string]]; 1641 END_AX_OBJC_EXCEPTIONS 1642 return false; 1643 } 1644 1636 1645 int AccessibilityUIElement::textMarkerRangeLength(AccessibilityTextMarkerRange* range) 1637 1646 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
r240219 r244059 280 280 RefPtr<AccessibilityTextMarkerRange> selectedTextMarkerRange(); 281 281 void resetSelectedTextMarkerRange(); 282 bool replaceTextInRange(JSStringRef, int position, int length); 282 283 RefPtr<AccessibilityTextMarker> startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*); 283 284 RefPtr<AccessibilityTextMarker> endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*); -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
r240219 r244059 206 206 AccessibilityTextMarkerRange selectedTextMarkerRange(); 207 207 void resetSelectedTextMarkerRange(); 208 boolean replaceTextInRange(DOMString string, long position, long length); 208 209 AccessibilityTextMarker startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange range); 209 210 AccessibilityTextMarker endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange range); -
trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm
r240710 r244059 1145 1145 return nullptr; 1146 1146 } 1147 1148 bool AccessibilityUIElement::replaceTextInRange(JSStringRef, int, int) 1149 { 1150 return false; 1151 } 1147 1152 1148 1153 RefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForPoint(int x, int y) -
trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
r240219 r244059 75 75 76 76 @interface NSObject (WebKitAccessibilityAdditions) 77 - (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string; 77 78 - (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount; 78 79 - (NSUInteger)accessibilityIndexOfChild:(id)child; … … 1807 1808 } 1808 1809 1810 bool AccessibilityUIElement::replaceTextInRange(JSStringRef string, int location, int length) 1811 { 1812 BEGIN_AX_OBJC_EXCEPTIONS 1813 return [m_element accessibilityReplaceRange:NSMakeRange(location, length) withText:[NSString stringWithJSStringRef:string]]; 1814 END_AX_OBJC_EXCEPTIONS 1815 return false; 1816 } 1817 1809 1818 RefPtr<AccessibilityTextMarker> AccessibilityUIElement::startTextMarkerForBounds(int x, int y, int width, int height) 1810 1819 {
Note:
See TracChangeset
for help on using the changeset viewer.