Changeset 273227 in webkit
- Timestamp:
- Feb 21, 2021 6:13:13 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r273214 r273227 1 2021-02-21 Andres Gonzalez <andresg_22@apple.com> 2 3 Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange. 4 https://bugs.webkit.org/show_bug.cgi?id=222154 5 6 Reviewed by Chris Fleizach and Darin Adler. 7 8 * accessibility/mac/textmarker-range-for-range-expected.txt: Added. 9 * accessibility/mac/textmarker-range-for-range.html: Added. 10 1 11 2021-02-20 Chris Fleizach <cfleizach@apple.com> 2 12 -
trunk/LayoutTests/platform/mac-wk1/TestExpectations
r273043 r273227 967 967 968 968 webkit.org/b/208477 accessibility/mac/text-marker-for-index.html [ Skip ] 969 accessibility/mac/textmarker-range-for-range.html [ Skip ] 969 970 accessibility/mac/isolated-tree-mode-on-off.html [ Skip ] 970 971 accessibility/aria-current-state-changed-notification.html [ Skip ] -
trunk/Source/WebCore/ChangeLog
r273225 r273227 1 2021-02-21 Andres Gonzalez <andresg_22@apple.com> 2 3 Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange. 4 https://bugs.webkit.org/show_bug.cgi?id=222154 5 6 Reviewed by Chris Fleizach and Darin Adler. 7 8 Test: accessibility/mac/textmarker-range-for-range.html 9 10 Clients like VoiceOver often need the ability to convert a text range 11 into an accessibility TextMarkerRange. 12 This patch adds [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] 13 to allow clients to efficiently perform this conversion. 14 This is the Mac implementation, iOS implementation is pending. 15 16 * accessibility/AccessibilityObject.h: 17 (WebCore::AccessibilityObject::allowsTextRanges const): 18 * accessibility/AccessibilityObjectInterface.h: 19 * accessibility/isolatedtree/AXIsolatedObject.h: 20 * accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm: 21 (WebCore::AXIsolatedObject::textMarkerRangeForNSRange const): 22 * accessibility/mac/AccessibilityObjectMac.mm: 23 (WebCore::AccessibilityObject::textMarkerRangeForNSRange const): 24 * accessibility/mac/WebAccessibilityObjectWrapperMac.mm: 25 (-[WebAccessibilityObjectWrapper textMarkerRangeForNSRange:]): 26 (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]): 27 * editing/Editing.cpp: 28 (WebCore::visiblePositionForIndexUsingCharacterIterator): 29 Only advance the CharacterIterator if not atEnd yet. 30 1 31 2021-02-21 Keith Miller <keith_miller@apple.com> 2 32 -
trunk/Source/WebCore/accessibility/AccessibilityObject.h
r273214 r273227 541 541 542 542 Optional<SimpleRange> rangeForPlainTextRange(const PlainTextRange&) const override; 543 #if PLATFORM(MAC) 544 AXTextMarkerRangeRef textMarkerRangeForNSRange(const NSRange&) const override; 545 #endif 543 546 544 547 static String stringForVisiblePositionRange(const VisiblePositionRange&); … … 825 828 826 829 #if !(ENABLE(ACCESSIBILITY) && USE(ATK)) 827 inline bool AccessibilityObject::allowsTextRanges() const { return isTextControl(); }830 inline bool AccessibilityObject::allowsTextRanges() const { return true; } 828 831 inline unsigned AccessibilityObject::getLengthForTextRange() const { return text().length(); } 829 832 #endif -
trunk/Source/WebCore/accessibility/AccessibilityObjectInterface.h
r273214 r273227 50 50 typedef WebAccessibilityObjectWrapper AccessibilityObjectWrapper; 51 51 typedef struct _NSRange NSRange; 52 typedef const struct __AXTextMarker* AXTextMarkerRef; 53 typedef const struct __AXTextMarkerRange* AXTextMarkerRangeRef; 52 54 #elif USE(ATK) 53 55 typedef struct _WebKitAccessible WebKitAccessible; … … 1276 1278 1277 1279 virtual Optional<SimpleRange> rangeForPlainTextRange(const PlainTextRange&) const = 0; 1280 #if PLATFORM(MAC) 1281 // FIXME: make this a COCOA method. 1282 virtual AXTextMarkerRangeRef textMarkerRangeForNSRange(const NSRange&) const = 0; 1283 #endif 1278 1284 1279 1285 virtual String stringForRange(const SimpleRange&) const = 0; -
trunk/Source/WebCore/accessibility/isolatedtree/AXIsolatedObject.h
r273214 r273227 404 404 VisiblePositionRange lineRangeForPosition(const VisiblePosition&) const override; 405 405 Optional<SimpleRange> rangeForPlainTextRange(const PlainTextRange&) const override; 406 #if PLATFORM(MAC) 407 AXTextMarkerRangeRef textMarkerRangeForNSRange(const NSRange&) const override; 408 #endif 406 409 String stringForRange(const SimpleRange&) const override; 407 410 IntRect boundsForVisiblePositionRange(const VisiblePositionRange&) const override; -
trunk/Source/WebCore/accessibility/isolatedtree/mac/AXIsolatedObjectMac.mm
r265311 r273227 60 60 } 61 61 62 AXTextMarkerRangeRef AXIsolatedObject::textMarkerRangeForNSRange(const NSRange& range) const 63 { 64 return Accessibility::retrieveValueFromMainThread<AXTextMarkerRangeRef>([&range, this] () -> AXTextMarkerRangeRef { 65 auto* axObject = associatedAXObject(); 66 return axObject ? axObject->textMarkerRangeForNSRange(range) : nullptr; 67 }); 68 } 69 62 70 } // WebCore 63 71 -
trunk/Source/WebCore/accessibility/mac/AccessibilityObjectMac.mm
r269833 r273227 279 279 280 280 return String(); 281 } 282 283 AXTextMarkerRangeRef AccessibilityObject::textMarkerRangeForNSRange(const NSRange& range) const 284 { 285 return textMarkerRangeFromVisiblePositions(axObjectCache(), 286 visiblePositionForIndex(range.location), 287 visiblePositionForIndex(range.location + range.length)); 281 288 } 282 289 -
trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
r273214 r273227 3479 3479 } 3480 3480 3481 - (AXTextMarkerRangeRef)textMarkerRangeForNSRange:(const NSRange&)range 3482 { 3483 auto* backingObject = self.updateObjectBackingStore; 3484 return backingObject ? backingObject->textMarkerRangeForNSRange(range) : nil; 3485 } 3486 3481 3487 // FIXME: No reason for this to be a method instead of a function; can get document from range. 3482 3488 - (NSRange)_convertToNSRange:(const SimpleRange&)range … … 4023 4029 if (!backingObject) 4024 4030 return CGRectZero; 4025 auto* cache = backingObject->axObjectCache(); 4026 if (!cache) 4031 4032 auto start = backingObject->visiblePositionForIndex(range.location); 4033 auto end = backingObject->visiblePositionForIndex(range.location + range.length); 4034 auto webRange = makeSimpleRange({ start, end }); 4035 if (!webRange) 4027 4036 return CGRectZero; 4028 CharacterOffset start = cache->characterOffsetForIndex(range.location, backingObject); 4029 CharacterOffset end = cache->characterOffsetForIndex(range.location+range.length, backingObject); 4030 auto range = cache->rangeForUnorderedCharacterOffsets(start, end); 4031 if (!range) 4032 return CGRectZero; 4033 auto bounds = FloatRect(backingObject->boundsForRange(*range)); 4037 4038 auto bounds = FloatRect(backingObject->boundsForRange(*webRange)); 4034 4039 return [protectedSelf convertRectToSpace:bounds space:AccessibilityConversionSpace::Screen]; 4035 4040 }); -
trunk/Source/WebCore/editing/Editing.cpp
r269253 r273227 1102 1102 auto range = makeRangeSelectingNodeContents(node); 1103 1103 CharacterIterator it(range); 1104 it.advance(index - 1); 1104 if (!it.atEnd()) 1105 it.advance(index - 1); 1105 1106 1106 1107 if (!it.atEnd() && it.text().length() == 1 && it.text()[0] == '\n') { -
trunk/Tools/ChangeLog
r273214 r273227 1 2021-02-21 Andres Gonzalez <andresg_22@apple.com> 2 3 Add [WebAccessibilityObjectWrapper textMarkerRangeForNSRange] to allow clients to efficiently get a TextMarkerRange from an NSRange. 4 https://bugs.webkit.org/show_bug.cgi?id=222154 5 6 Reviewed by Chris Fleizach and Darin Adler. 7 8 * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp: 9 (WTR::AccessibilityUIElement::textMarkerRangeForRange): 10 * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: 11 * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl: 12 * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: 13 (WTR::AccessibilityUIElement::textMarkerRangeForRange): 14 1 15 2021-02-20 Chris Fleizach <cfleizach@apple.com> 2 16 -
trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
r273214 r273227 103 103 104 104 #if !PLATFORM(MAC) || !HAVE(ACCESSIBILITY) 105 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForRange(unsigned, unsigned) { return nullptr; } 105 106 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::selectedTextMarkerRange() { return nullptr; } 106 107 void AccessibilityUIElement::resetSelectedTextMarkerRange() { } -
trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
r273214 r273227 304 304 RefPtr<AccessibilityTextMarkerRange> textMarkerRangeForElement(AccessibilityUIElement*); 305 305 RefPtr<AccessibilityTextMarkerRange> textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker); 306 RefPtr<AccessibilityTextMarkerRange> textMarkerRangeForRange(unsigned location, unsigned length); 306 307 RefPtr<AccessibilityTextMarkerRange> selectedTextMarkerRange(); 307 308 void resetSelectedTextMarkerRange(); -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
r273214 r273227 221 221 AccessibilityTextMarkerRange textMarkerRangeForElement(AccessibilityUIElement element); 222 222 AccessibilityTextMarkerRange textMarkerRangeForMarkers(AccessibilityTextMarker startMarker, AccessibilityTextMarker endMarker); 223 AccessibilityTextMarkerRange textMarkerRangeForRange(unsigned long location, unsigned long length); 223 224 AccessibilityTextMarkerRange selectedTextMarkerRange(); 224 225 undefined resetSelectedTextMarkerRange(); -
trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
r273214 r273227 84 84 - (BOOL)accessibilityReplaceRange:(NSRange)range withText:(NSString *)string; 85 85 - (BOOL)accessibilityInsertText:(NSString *)text; 86 - (id)textMarkerRangeForNSRange:(const NSRange&)nsRange; 86 87 - (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount; 87 88 - (NSUInteger)accessibilityIndexOfChild:(id)child; … … 1822 1823 END_AX_OBJC_EXCEPTIONS 1823 1824 1825 return nullptr; 1826 } 1827 1828 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeForRange(unsigned location, unsigned length) 1829 { 1830 BEGIN_AX_OBJC_EXCEPTIONS 1831 return AccessibilityTextMarkerRange::create([m_element textMarkerRangeForNSRange:NSMakeRange(location, length)]); 1832 END_AX_OBJC_EXCEPTIONS 1833 1824 1834 return nullptr; 1825 1835 }
Note: See TracChangeset
for help on using the changeset viewer.