Changeset 219426 in webkit
- Timestamp:
- Jul 12, 2017 3:20:43 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r219424 r219426 1 2017-07-12 Nan Wang <n_wang@apple.com> 2 3 AX: [iOS] Implement a way to retrieve a text marker range with desired text that is closest to a position 4 https://bugs.webkit.org/show_bug.cgi?id=174393 5 <rdar://problem/33248006> 6 7 Reviewed by Chris Fleizach. 8 9 * accessibility/ios-simulator/text-marker-range-matches-text-expected.txt: Added. 10 * accessibility/ios-simulator/text-marker-range-matches-text.html: Added. 11 1 12 2017-07-12 Matt Lewis <jlewis3@apple.com> 2 13 -
trunk/Source/WebCore/ChangeLog
r219424 r219426 1 2017-07-12 Nan Wang <n_wang@apple.com> 2 3 AX: [iOS] Implement a way to retrieve a text marker range with desired text that is closest to a position 4 https://bugs.webkit.org/show_bug.cgi?id=174393 5 <rdar://problem/33248006> 6 7 Reviewed by Chris Fleizach. 8 9 Used the existing findClosestPlainText function to search the range on iOS. 10 Also exposed a function on the iOS wrapper to return the selection rects of 11 the result range from the searching. 12 13 Test: accessibility/ios-simulator/text-marker-range-matches-text.html 14 15 * accessibility/AXObjectCache.cpp: 16 (WebCore::visiblePositionForPositionWithOffset): 17 (WebCore::AXObjectCache::rangeMatchesTextNearRange): 18 * accessibility/AXObjectCache.h: 19 * accessibility/ios/WebAccessibilityObjectWrapperIOS.mm: 20 (-[WebAccessibilityObjectWrapper rangeFromMarkers:withText:]): 21 (-[WebAccessibilityObjectWrapper textMarkerRangeFromMarkers:withText:]): 22 (-[WebAccessibilityObjectWrapper textRectsFromMarkers:withText:]): 23 (-[WebAccessibilityObjectWrapper rectsForSelectionRects:]): 24 1 25 2017-07-12 Matt Lewis <jlewis3@apple.com> 2 26 -
trunk/Source/WebCore/accessibility/AXObjectCache.cpp
r219424 r219426 1727 1727 return WTFMove(range); 1728 1728 } 1729 1730 static VisiblePosition visiblePositionForPositionWithOffset(const VisiblePosition& position, int32_t offset) 1731 { 1732 RefPtr<ContainerNode> root; 1733 unsigned startIndex = indexForVisiblePosition(position, root); 1734 return visiblePositionForIndex(startIndex + offset, root.get()); 1735 } 1736 1737 RefPtr<Range> AXObjectCache::rangeMatchesTextNearRange(RefPtr<Range> originalRange, const String& matchText) 1738 { 1739 if (!originalRange) 1740 return nullptr; 1741 1742 // Create a large enough range for searching the text within. 1743 unsigned textLength = matchText.length(); 1744 auto startPosition = visiblePositionForPositionWithOffset(originalRange->startPosition(), -textLength); 1745 auto endPosition = visiblePositionForPositionWithOffset(originalRange->startPosition(), 2 * textLength); 1746 1747 if (startPosition.isNull()) 1748 startPosition = firstPositionInOrBeforeNode(&originalRange->startContainer()); 1749 if (endPosition.isNull()) 1750 endPosition = lastPositionInOrAfterNode(&originalRange->endContainer()); 1751 1752 RefPtr<Range> searchRange = Range::create(m_document, startPosition, endPosition); 1753 if (!searchRange || searchRange->collapsed()) 1754 return nullptr; 1755 1756 RefPtr<Range> range = Range::create(m_document, startPosition, originalRange->startPosition()); 1757 unsigned targetOffset = TextIterator::rangeLength(range.get(), true); 1758 return findClosestPlainText(*searchRange.get(), matchText, 0, targetOffset); 1759 } 1729 1760 1730 1761 static bool isReplacedNodeOrBR(Node* node) -
trunk/Source/WebCore/accessibility/AXObjectCache.h
r219424 r219426 333 333 void deferTextChangedIfNeeded(Node*); 334 334 void performDeferredCacheUpdate(); 335 336 RefPtr<Range> rangeMatchesTextNearRange(RefPtr<Range>, const String&); 337 335 338 336 339 protected: -
trunk/Source/WebCore/accessibility/ios/WebAccessibilityObjectWrapperIOS.mm
r219424 r219426 53 53 #import "SVGNames.h" 54 54 #import "SVGElement.h" 55 #import "SelectionRect.h" 55 56 #import "TextIterator.h" 56 57 #import "WAKScrollView.h" … … 2589 2590 } 2590 2591 2592 - (RefPtr<Range>)rangeFromMarkers:(NSArray *)markers withText:(NSString *)text 2593 { 2594 RefPtr<Range> originalRange = [self rangeForTextMarkers:markers]; 2595 if (!originalRange) 2596 return nil; 2597 2598 AXObjectCache* cache = m_object->axObjectCache(); 2599 if (!cache) 2600 return nil; 2601 2602 return cache->rangeMatchesTextNearRange(originalRange, text); 2603 } 2604 2605 // This is only used in the layout test. 2606 - (NSArray *)textMarkerRangeFromMarkers:(NSArray *)markers withText:(NSString *)text 2607 { 2608 return [self textMarkersForRange:[self rangeFromMarkers:markers withText:text]]; 2609 } 2610 2611 - (NSArray *)textRectsFromMarkers:(NSArray *)markers withText:(NSString *)text 2612 { 2613 if (![self _prepareAccessibilityCall]) 2614 return nil; 2615 2616 RefPtr<Range> range = [self rangeFromMarkers:markers withText:text]; 2617 if (!range || range->collapsed()) 2618 return nil; 2619 2620 Vector<WebCore::SelectionRect> selectionRects; 2621 range->collectSelectionRectsWithoutUnionInteriorLines(selectionRects); 2622 return [self rectsForSelectionRects:selectionRects]; 2623 } 2624 2625 - (NSArray *)rectsForSelectionRects:(const Vector<WebCore::SelectionRect>&)selectionRects 2626 { 2627 unsigned size = selectionRects.size(); 2628 if (!size) 2629 return nil; 2630 2631 NSMutableArray *rects = [NSMutableArray arrayWithCapacity:size]; 2632 for (unsigned i = 0; i < size; i++) { 2633 const WebCore::SelectionRect& coreRect = selectionRects[i]; 2634 IntRect selectionRect = coreRect.rect(); 2635 CGRect rect = [self convertRectToScreenSpace:selectionRect]; 2636 [rects addObject:[NSValue valueWithRect:rect]]; 2637 } 2638 2639 return rects; 2640 } 2641 2591 2642 - (WebAccessibilityTextMarker *)textMarkerForPoint:(CGPoint)point 2592 2643 { -
trunk/Tools/ChangeLog
r219424 r219426 1 2017-07-12 Nan Wang <n_wang@apple.com> 2 3 AX: [iOS] Implement a way to retrieve a text marker range with desired text that is closest to a position 4 https://bugs.webkit.org/show_bug.cgi?id=174393 5 <rdar://problem/33248006> 6 7 Reviewed by Chris Fleizach. 8 9 * DumpRenderTree/AccessibilityUIElement.cpp: 10 (textMarkerRangeMatchesTextNearMarkersCallback): 11 (AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers): 12 (AccessibilityUIElement::getJSClass): 13 * DumpRenderTree/AccessibilityUIElement.h: 14 * DumpRenderTree/ios/AccessibilityUIElementIOS.mm: 15 (AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers): 16 * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp: 17 (WTR::AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers): 18 * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: 19 * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl: 20 * WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm: 21 (WTR::AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers): 22 1 23 2017-07-12 Matt Lewis <jlewis3@apple.com> 2 24 -
trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp
r219424 r219426 928 928 static JSValueRef textMarkerRangeForMarkersCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 929 929 { 930 AccessibilityTextMarker* startMarker = 0;931 AccessibilityTextMarker* endMarker = 0;930 AccessibilityTextMarker* startMarker = nullptr; 931 AccessibilityTextMarker* endMarker = nullptr; 932 932 if (argumentCount == 2) { 933 933 startMarker = toTextMarker(JSValueToObject(context, arguments[0], exception)); … … 1482 1482 { 1483 1483 return JSValueMakeBoolean(context, toAXElement(thisObject)->hasContainedByFieldsetTrait()); 1484 } 1485 1486 static JSValueRef textMarkerRangeMatchesTextNearMarkersCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 1487 { 1488 JSStringRef searchText = nullptr; 1489 AccessibilityTextMarker* startMarker = nullptr; 1490 AccessibilityTextMarker* endMarker = nullptr; 1491 if (argumentCount == 3) { 1492 searchText = JSValueToStringCopy(context, arguments[0], exception); 1493 startMarker = toTextMarker(JSValueToObject(context, arguments[1], exception)); 1494 endMarker = toTextMarker(JSValueToObject(context, arguments[2], exception)); 1495 } 1496 1497 JSValueRef result = AccessibilityTextMarkerRange::makeJSAccessibilityTextMarkerRange(context, toAXElement(thisObject)->textMarkerRangeMatchesTextNearMarkers(searchText, startMarker, endMarker)); 1498 if (searchText) 1499 JSStringRelease(searchText); 1500 return result; 1484 1501 } 1485 1502 … … 1704 1721 return nullptr; 1705 1722 } 1723 1724 #if PLATFORM(IOS) 1725 AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers(JSStringRef, AccessibilityTextMarker*, AccessibilityTextMarker*) 1726 { 1727 return nullptr; 1728 } 1729 #endif 1706 1730 1707 1731 #endif … … 1921 1945 { "assistiveTechnologySimulatedFocus", assistiveTechnologySimulatedFocusCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1922 1946 { "fieldsetAncestorElement", fieldsetAncestorElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1947 { "textMarkerRangeMatchesTextNearMarkers", textMarkerRangeMatchesTextNearMarkersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1923 1948 #endif 1924 1949 { 0, 0, 0 } -
trunk/Tools/DumpRenderTree/AccessibilityUIElement.h
r219424 r219426 307 307 bool isSearchField() const; 308 308 309 AccessibilityTextMarkerRange textMarkerRangeMatchesTextNearMarkers(JSStringRef, AccessibilityTextMarker*, AccessibilityTextMarker*); 310 309 311 #endif // PLATFORM(IOS) 310 312 -
trunk/Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
r219424 r219426 114 114 - (id)lineStartMarkerForMarker:(id)marker; 115 115 - (id)lineEndMarkerForMarker:(id)marker; 116 - (NSArray *)textMarkerRangeFromMarkers:(NSArray *)markers withText:(NSString *)text; 116 117 @end 117 118 … … 621 622 } 622 623 624 AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers(JSStringRef text, AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker) 625 { 626 NSArray *textMarkers = nil; 627 if (startMarker->platformTextMarker() && endMarker->platformTextMarker()) 628 textMarkers = [NSArray arrayWithObjects:(id)startMarker->platformTextMarker(), (id)endMarker->platformTextMarker(), nil]; 629 id textMarkerRange = [m_element textMarkerRangeFromMarkers:textMarkers withText:[NSString stringWithJSStringRef:text]]; 630 return AccessibilityTextMarkerRange(textMarkerRange); 631 } 632 633 623 634 #endif // SUPPORTS_AX_TEXTMARKERS && PLATFORM(IOS) 624 635 -
trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
r219424 r219426 75 75 bool AccessibilityUIElement::isSearchField() const { return false; } 76 76 bool AccessibilityUIElement::isTextArea() const { return false; } 77 77 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers(JSStringRef, AccessibilityTextMarker*, AccessibilityTextMarker*) { return nullptr; } 78 78 #endif 79 79 -
trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
r219424 r219426 290 290 RefPtr<AccessibilityTextMarker> nextSentenceEndTextMarkerForTextMarker(AccessibilityTextMarker*); 291 291 RefPtr<AccessibilityTextMarker> previousSentenceStartTextMarkerForTextMarker(AccessibilityTextMarker*); 292 RefPtr<AccessibilityTextMarkerRange> textMarkerRangeMatchesTextNearMarkers(JSStringRef, AccessibilityTextMarker*, AccessibilityTextMarker*); 292 293 293 294 // Returns an ordered list of supported actions for an element. -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
r219424 r219426 227 227 AccessibilityTextMarker previousSentenceStartTextMarkerForTextMarker(AccessibilityTextMarker textMarker); 228 228 AccessibilityTextMarker nextSentenceEndTextMarkerForTextMarker(AccessibilityTextMarker textMarker); 229 AccessibilityTextMarkerRange textMarkerRangeMatchesTextNearMarkers(DOMString text, AccessibilityTextMarker startMarker, AccessibilityTextMarker endMarker); 229 230 230 231 // Returns an ordered list of supported actions for an element. -
trunk/Tools/WebKitTestRunner/InjectedBundle/ios/AccessibilityUIElementIOS.mm
r219424 r219426 92 92 - (id)lineStartMarkerForMarker:(id)marker; 93 93 - (id)lineEndMarkerForMarker:(id)marker; 94 - (NSArray *)textMarkerRangeFromMarkers:(NSArray *)markers withText:(NSString *)text; 94 95 @end 95 96 … … 1200 1201 { 1201 1202 return nullptr; 1203 } 1204 1205 RefPtr<AccessibilityTextMarkerRange> AccessibilityUIElement::textMarkerRangeMatchesTextNearMarkers(JSStringRef text, AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker) 1206 { 1207 NSArray *textMarkers = nil; 1208 if (startMarker->platformTextMarker() && endMarker->platformTextMarker()) 1209 textMarkers = [NSArray arrayWithObjects:(id)startMarker->platformTextMarker(), (id)endMarker->platformTextMarker(), nil]; 1210 id textMarkerRange = [m_element textMarkerRangeFromMarkers:textMarkers withText:[NSString stringWithJSStringRef:text]]; 1211 return AccessibilityTextMarkerRange::create(textMarkerRange); 1202 1212 } 1203 1213
Note: See TracChangeset
for help on using the changeset viewer.