Changeset 112021 in webkit
- Timestamp:
- Mar 24, 2012 9:03:03 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r112012 r112021 1 2012-03-24 Chris Fleizach <cfleizach@apple.com> 2 3 AX: Support solution to handle invalid ax text marker 4 https://bugs.webkit.org/show_bug.cgi?id=82023 5 6 Reviewed by Oliver Hunt. 7 8 * platform/mac/accessibility/textmarker-routines-expected.txt: Added. 9 * platform/mac/accessibility/textmarker-routines.html: Added. 10 1 11 2012-03-24 Abhishek Arya <inferno@chromium.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r112020 r112021 1 2012-03-24 Chris Fleizach <cfleizach@apple.com> 2 3 AX: Support solution to handle invalid ax text marker 4 https://bugs.webkit.org/show_bug.cgi?id=82023 5 6 Reviewed by Oliver Hunt. 7 8 This provides methods to better use text markers so that assistive technologies 9 can know when they are valid, and can convert them to and from absolute positions. 10 11 Test: platform/mac/accessibility/textmarker-routines.html 12 13 * accessibility/mac/WebAccessibilityObjectWrapper.mm: 14 (-[WebAccessibilityObjectWrapper accessibilityParameterizedAttributeNames]): 15 (-[WebAccessibilityObjectWrapper _convertToNSRange:]): 16 (-[WebAccessibilityObjectWrapper _indexForTextMarker:]): 17 (-[WebAccessibilityObjectWrapper _textMarkerForIndex:]): 18 (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]): 19 1 20 2012-03-24 Victor Carbune <vcarbune@adobe.com> 2 21 -
trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm
r110828 r112021 333 333 #endif 334 334 335 #define NSAccessibilityTextMarkerIsValidParameterizedAttribute @"AXTextMarkerIsValid" 336 #define NSAccessibilityIndexForTextMarkerParameterizedAttribute @"AXIndexForTextMarker" 337 #define NSAccessibilityTextMarkerForIndexParameterizedAttribute @"AXTextMarkerForIndex" 335 338 336 339 @interface NSObject (WebKitAccessibilityArrayCategory) … … 2492 2495 static NSArray* textParamAttrs = nil; 2493 2496 static NSArray* tableParamAttrs = nil; 2497 static NSArray* webAreaParamAttrs = nil; 2494 2498 if (paramAttrs == nil) { 2495 2499 paramAttrs = [[NSArray alloc] initWithObjects: … … 2547 2551 [tempArray release]; 2548 2552 } 2553 if (!webAreaParamAttrs) { 2554 NSMutableArray* tempArray = [[NSMutableArray alloc] initWithArray:paramAttrs]; 2555 [tempArray addObject:NSAccessibilityTextMarkerForIndexParameterizedAttribute]; 2556 [tempArray addObject:NSAccessibilityTextMarkerIsValidParameterizedAttribute]; 2557 [tempArray addObject:NSAccessibilityIndexForTextMarkerParameterizedAttribute]; 2558 webAreaParamAttrs = [[NSArray alloc] initWithArray:tempArray]; 2559 [tempArray release]; 2560 } 2549 2561 2550 2562 if (m_object->isPasswordField()) … … 2563 2575 return nil; 2564 2576 2577 if (m_object->isWebArea()) 2578 return webAreaParamAttrs; 2579 2565 2580 return paramAttrs; 2566 2581 } … … 2754 2769 } 2755 2770 2771 - (NSRange)_convertToNSRange:(Range*)range 2772 { 2773 NSRange result = NSMakeRange(NSNotFound, 0); 2774 if (!range || !range->startContainer()) 2775 return result; 2776 2777 Document* document = m_object->document(); 2778 if (!document) 2779 return result; 2780 2781 TextIterator::getLocationAndLengthFromRange(document->documentElement(), range, result.location, result.length); 2782 2783 return result; 2784 } 2785 2786 - (NSInteger)_indexForTextMarker:(id)marker 2787 { 2788 if (!marker) 2789 return NSNotFound; 2790 2791 VisibleSelection selection([self visiblePositionForTextMarker:marker]); 2792 return [self _convertToNSRange:selection.toNormalizedRange().get()].location; 2793 } 2794 2795 - (id)_textMarkerForIndex:(NSInteger)textIndex 2796 { 2797 Document* document = m_object->document(); 2798 if (!document) 2799 return nil; 2800 2801 PassRefPtr<Range> textRange = TextIterator::rangeFromLocationAndLength(document->documentElement(), textIndex, 0); 2802 2803 VisiblePosition position(textRange->startPosition()); 2804 return [self textMarkerForVisiblePosition:position]; 2805 } 2806 2756 2807 // The RTF representation of the text associated with this accessibility object that is 2757 2808 // specified by the given range. … … 2845 2896 } 2846 2897 2898 if ([attribute isEqualToString:NSAccessibilityTextMarkerIsValidParameterizedAttribute]) { 2899 VisiblePosition pos = [self visiblePositionForTextMarker:textMarker]; 2900 return [NSNumber numberWithBool:!pos.isNull()]; 2901 } 2902 if ([attribute isEqualToString:NSAccessibilityIndexForTextMarkerParameterizedAttribute]) { 2903 return [NSNumber numberWithInteger:[self _indexForTextMarker:textMarker]]; 2904 } 2905 if ([attribute isEqualToString:NSAccessibilityTextMarkerForIndexParameterizedAttribute]) { 2906 return [self _textMarkerForIndex:[number integerValue]]; 2907 } 2908 2847 2909 if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) { 2848 2910 VisiblePosition visiblePos = [self visiblePositionForTextMarker:(textMarker)]; -
trunk/Tools/ChangeLog
r112019 r112021 1 2012-03-24 Chris Fleizach <cfleizach@apple.com> 2 3 AX: Support solution to handle invalid ax text marker 4 https://bugs.webkit.org/show_bug.cgi?id=82023 5 6 Reviewed by Oliver Hunt. 7 8 * DumpRenderTree/AccessibilityUIElement.cpp: 9 (indexForTextMarkerCallback): 10 (isTextMarkerValidCallback): 11 (textMarkerForIndexCallback): 12 (AccessibilityUIElement::indexForTextMarker): 13 (AccessibilityUIElement::isTextMarkerValid): 14 (AccessibilityUIElement::textMarkerForIndex): 15 (AccessibilityUIElement::getJSClass): 16 * DumpRenderTree/AccessibilityUIElement.h: 17 (AccessibilityUIElement): 18 * DumpRenderTree/mac/AccessibilityUIElementMac.mm: 19 (AccessibilityUIElement::indexForTextMarker): 20 (AccessibilityUIElement::textMarkerForIndex): 21 (AccessibilityUIElement::isTextMarkerValid): 22 * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp: 23 (WTR::AccessibilityUIElement::indexForTextMarker): 24 (WTR::AccessibilityUIElement::isTextMarkerValid): 25 (WTR::AccessibilityUIElement::textMarkerForIndex): 26 (WTR): 27 * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h: 28 (AccessibilityUIElement): 29 * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl: 30 * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm: 31 (WTR): 32 (WTR::AccessibilityUIElement::indexForTextMarker): 33 (WTR::AccessibilityUIElement::isTextMarkerValid): 34 (WTR::AccessibilityUIElement::textMarkerForIndex): 35 1 36 2012-03-24 Sheriff Bot <webkit.review.bot@gmail.com> 2 37 -
trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp
r110823 r112021 518 518 } 519 519 520 static JSValueRef indexForTextMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 521 { 522 AccessibilityTextMarker* marker = 0; 523 if (argumentCount == 1) 524 marker = toTextMarker(JSValueToObject(context, arguments[0], exception)); 525 526 return JSValueMakeNumber(context, toAXElement(thisObject)->indexForTextMarker(marker)); 527 } 528 529 static JSValueRef isTextMarkerValidCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 530 { 531 AccessibilityTextMarker* marker = 0; 532 if (argumentCount == 1) 533 marker = toTextMarker(JSValueToObject(context, arguments[0], exception)); 534 535 return JSValueMakeBoolean(context, toAXElement(thisObject)->isTextMarkerValid(marker)); 536 } 537 538 static JSValueRef textMarkerForIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 539 { 540 int textIndex = 0; 541 if (argumentCount == 1) 542 textIndex = JSValueToNumber(context, arguments[0], exception); 543 544 return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->textMarkerForIndex(textIndex)); 545 } 546 520 547 static JSValueRef textMarkerRangeLengthCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 521 548 { … … 978 1005 { 979 1006 return false; 1007 } 1008 1009 int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker*) 1010 { 1011 return -1; 1012 } 1013 1014 bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker*) 1015 { 1016 return false; 1017 } 1018 1019 AccessibilityTextMarker AccessibilityUIElement::textMarkerForIndex(int) 1020 { 1021 return 0; 980 1022 } 981 1023 … … 1109 1151 { "textMarkerRangeForElement", textMarkerRangeForElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1110 1152 { "attributedStringForTextMarkerRangeContainsAttribute", attributedStringForTextMarkerRangeContainsAttributeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1153 { "indexForTextMarker", indexForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1154 { "isTextMarkerValid", isTextMarkerValidCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1111 1155 { "textMarkerRangeForMarkers", textMarkerRangeForMarkersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1156 { "textMarkerForIndex", textMarkerForIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1112 1157 { "startTextMarkerForTextMarkerRange", startTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 1113 1158 { "endTextMarkerForTextMarkerRange", endTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, -
trunk/Tools/DumpRenderTree/AccessibilityUIElement.h
r110823 r112021 218 218 int textMarkerRangeLength(AccessibilityTextMarkerRange*); 219 219 bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*); 220 220 int indexForTextMarker(AccessibilityTextMarker*); 221 bool isTextMarkerValid(AccessibilityTextMarker*); 222 AccessibilityTextMarker textMarkerForIndex(int); 223 221 224 void scrollToMakeVisible(); 222 225 void scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height); -
trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
r110823 r112021 1322 1322 } 1323 1323 1324 int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker* marker) 1325 { 1326 BEGIN_AX_OBJC_EXCEPTIONS 1327 NSNumber* indexNumber = [m_element accessibilityAttributeValue:@"AXIndexForTextMarker" forParameter:(id)marker->platformTextMarker()]; 1328 return [indexNumber intValue]; 1329 END_AX_OBJC_EXCEPTIONS 1330 1331 return -1; 1332 } 1333 1334 AccessibilityTextMarker AccessibilityUIElement::textMarkerForIndex(int textIndex) 1335 { 1336 BEGIN_AX_OBJC_EXCEPTIONS 1337 id textMarker = [m_element accessibilityAttributeValue:@"AXTextMarkerForIndex" forParameter:[NSNumber numberWithInteger:textIndex]]; 1338 return AccessibilityTextMarker(textMarker); 1339 END_AX_OBJC_EXCEPTIONS 1340 1341 return 0; 1342 } 1343 1344 bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker* textMarker) 1345 { 1346 BEGIN_AX_OBJC_EXCEPTIONS 1347 NSNumber* validNumber = [m_element accessibilityAttributeValue:@"AXTextMarkerIsValid" forParameter:(id)textMarker->platformTextMarker()]; 1348 return [validNumber boolValue]; 1349 END_AX_OBJC_EXCEPTIONS 1350 1351 return false; 1352 } 1353 1324 1354 AccessibilityTextMarker AccessibilityUIElement::previousTextMarker(AccessibilityTextMarker* textMarker) 1325 1355 { -
trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
r111233 r112021 174 174 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange*) { return 0; } 175 175 bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*) { return false; } 176 int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker*) { return -1; } 177 bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker*) { return false; } 178 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForIndex(int) { return 0; } 179 176 180 #endif 177 181 -
trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
r111233 r112021 221 221 int textMarkerRangeLength(AccessibilityTextMarkerRange*); 222 222 bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*); 223 int indexForTextMarker(AccessibilityTextMarker*); 224 bool isTextMarkerValid(AccessibilityTextMarker*); 225 PassRefPtr<AccessibilityTextMarker> textMarkerForIndex(int); 223 226 224 227 // Notifications -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
r111233 r112021 156 156 int textMarkerRangeLength(in AccessibilityTextMarkerRange range); 157 157 boolean attributedStringForTextMarkerRangeContainsAttribute(in DOMString attr, in AccessibilityTextMarkerRange range); 158 158 int indexForTextMarker(in AccessibilityTextMarker marker); 159 boolean isTextMarkerValid(in AccessibilityTextMarker marker); 160 AccessibilityTextMarker textMarkerForIndex(in int textIndex); 161 159 162 // Notification support. 160 163 boolean addNotificationListener(in object callbackFunction); -
trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm
r111233 r112021 1404 1404 return false; 1405 1405 } 1406 1407 int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker* marker) 1408 { 1409 BEGIN_AX_OBJC_EXCEPTIONS 1410 NSNumber* indexNumber = [m_element accessibilityAttributeValue:@"AXIndexForTextMarker" forParameter:(id)marker->platformTextMarker()]; 1411 return [indexNumber intValue]; 1412 END_AX_OBJC_EXCEPTIONS 1413 1414 return -1; 1415 } 1416 1417 bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker* textMarker) 1418 { 1419 BEGIN_AX_OBJC_EXCEPTIONS 1420 NSNumber* validNumber = [m_element accessibilityAttributeValue:@"AXTextMarkerIsValid" forParameter:(id)textMarker->platformTextMarker()]; 1421 return [validNumber boolValue]; 1422 END_AX_OBJC_EXCEPTIONS 1423 1424 return false; 1425 } 1426 1427 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForIndex(int textIndex) 1428 { 1429 BEGIN_AX_OBJC_EXCEPTIONS 1430 id textMarker = [m_element accessibilityAttributeValue:@"AXTextMarkerForIndex" forParameter:[NSNumber numberWithInteger:textIndex]]; 1431 return AccessibilityTextMarker::create(textMarker); 1432 END_AX_OBJC_EXCEPTIONS 1433 1434 return 0; 1435 } 1436 1406 1437 1407 1438 } // namespace WTR
Note: See TracChangeset
for help on using the changeset viewer.