Changeset 112021 in webkit


Ignore:
Timestamp:
Mar 24, 2012 9:03:03 PM (12 years ago)
Author:
Chris Fleizach
Message:

AX: Support solution to handle invalid ax text marker
https://bugs.webkit.org/show_bug.cgi?id=82023

Reviewed by Oliver Hunt.

Source/WebCore:

This provides methods to better use text markers so that assistive technologies
can know when they are valid, and can convert them to and from absolute positions.

Test: platform/mac/accessibility/textmarker-routines.html

  • accessibility/mac/WebAccessibilityObjectWrapper.mm:

(-[WebAccessibilityObjectWrapper accessibilityParameterizedAttributeNames]):
(-[WebAccessibilityObjectWrapper _convertToNSRange:]):
(-[WebAccessibilityObjectWrapper _indexForTextMarker:]):
(-[WebAccessibilityObjectWrapper _textMarkerForIndex:]):
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):

Tools:

  • DumpRenderTree/AccessibilityUIElement.cpp:

(indexForTextMarkerCallback):
(isTextMarkerValidCallback):
(textMarkerForIndexCallback):
(AccessibilityUIElement::indexForTextMarker):
(AccessibilityUIElement::isTextMarkerValid):
(AccessibilityUIElement::textMarkerForIndex):
(AccessibilityUIElement::getJSClass):

  • DumpRenderTree/AccessibilityUIElement.h:

(AccessibilityUIElement):

  • DumpRenderTree/mac/AccessibilityUIElementMac.mm:

(AccessibilityUIElement::indexForTextMarker):
(AccessibilityUIElement::textMarkerForIndex):
(AccessibilityUIElement::isTextMarkerValid):

  • WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:

(WTR::AccessibilityUIElement::indexForTextMarker):
(WTR::AccessibilityUIElement::isTextMarkerValid):
(WTR::AccessibilityUIElement::textMarkerForIndex):
(WTR):

  • WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:

(AccessibilityUIElement):

  • WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
  • WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:

(WTR):
(WTR::AccessibilityUIElement::indexForTextMarker):
(WTR::AccessibilityUIElement::isTextMarkerValid):
(WTR::AccessibilityUIElement::textMarkerForIndex):

LayoutTests:

  • platform/mac/accessibility/textmarker-routines-expected.txt: Added.
  • platform/mac/accessibility/textmarker-routines.html: Added.
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r112012 r112021  
     12012-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
    1112012-03-24  Abhishek Arya  <inferno@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r112020 r112021  
     12012-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
    1202012-03-24  Victor Carbune  <vcarbune@adobe.com>
    221
  • trunk/Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm

    r110828 r112021  
    333333#endif
    334334
     335#define NSAccessibilityTextMarkerIsValidParameterizedAttribute @"AXTextMarkerIsValid"
     336#define NSAccessibilityIndexForTextMarkerParameterizedAttribute @"AXIndexForTextMarker"
     337#define NSAccessibilityTextMarkerForIndexParameterizedAttribute @"AXTextMarkerForIndex"
    335338
    336339@interface NSObject (WebKitAccessibilityArrayCategory)
     
    24922495    static NSArray* textParamAttrs = nil;
    24932496    static NSArray* tableParamAttrs = nil;
     2497    static NSArray* webAreaParamAttrs = nil;
    24942498    if (paramAttrs == nil) {
    24952499        paramAttrs = [[NSArray alloc] initWithObjects:
     
    25472551        [tempArray release];
    25482552    }
     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    }
    25492561   
    25502562    if (m_object->isPasswordField())
     
    25632575        return nil;
    25642576
     2577    if (m_object->isWebArea())
     2578        return webAreaParamAttrs;
     2579   
    25652580    return paramAttrs;
    25662581}
     
    27542769}
    27552770
     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
    27562807// The RTF representation of the text associated with this accessibility object that is
    27572808// specified by the given range.
     
    28452896    }
    28462897
     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   
    28472909    if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) {
    28482910        VisiblePosition visiblePos = [self visiblePositionForTextMarker:(textMarker)];
  • trunk/Tools/ChangeLog

    r112019 r112021  
     12012-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
    1362012-03-24  Sheriff Bot  <webkit.review.bot@gmail.com>
    237
  • trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp

    r110823 r112021  
    518518}
    519519
     520static 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
     529static 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
     538static 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
    520547static JSValueRef textMarkerRangeLengthCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
    521548{
     
    9781005{
    9791006    return false;
     1007}
     1008
     1009int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker*)
     1010{
     1011    return -1;
     1012}
     1013
     1014bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker*)
     1015{
     1016    return false;
     1017}
     1018
     1019AccessibilityTextMarker AccessibilityUIElement::textMarkerForIndex(int)
     1020{
     1021    return 0;
    9801022}
    9811023
     
    11091151        { "textMarkerRangeForElement", textMarkerRangeForElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    11101152        { "attributedStringForTextMarkerRangeContainsAttribute", attributedStringForTextMarkerRangeContainsAttributeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1153        { "indexForTextMarker", indexForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1154        { "isTextMarkerValid", isTextMarkerValidCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    11111155        { "textMarkerRangeForMarkers", textMarkerRangeForMarkersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1156        { "textMarkerForIndex", textMarkerForIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    11121157        { "startTextMarkerForTextMarkerRange", startTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    11131158        { "endTextMarkerForTextMarkerRange", endTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/Tools/DumpRenderTree/AccessibilityUIElement.h

    r110823 r112021  
    218218    int textMarkerRangeLength(AccessibilityTextMarkerRange*);
    219219    bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
    220 
     220    int indexForTextMarker(AccessibilityTextMarker*);
     221    bool isTextMarkerValid(AccessibilityTextMarker*);
     222    AccessibilityTextMarker textMarkerForIndex(int);
     223   
    221224    void scrollToMakeVisible();
    222225    void scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
  • trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm

    r110823 r112021  
    13221322}
    13231323
     1324int 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
     1334AccessibilityTextMarker 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
     1344bool 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
    13241354AccessibilityTextMarker AccessibilityUIElement::previousTextMarker(AccessibilityTextMarker* textMarker)
    13251355{
  • trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp

    r111233 r112021  
    174174JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange*) { return 0; }
    175175bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*) { return false; }
     176int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker*) { return -1; }
     177bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker*) { return false; }
     178PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForIndex(int) { return 0; }
     179
    176180#endif
    177181
  • trunk/Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h

    r111233 r112021  
    221221    int textMarkerRangeLength(AccessibilityTextMarkerRange*);
    222222    bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
     223    int indexForTextMarker(AccessibilityTextMarker*);
     224    bool isTextMarkerValid(AccessibilityTextMarker*);
     225    PassRefPtr<AccessibilityTextMarker> textMarkerForIndex(int);
    223226
    224227    // Notifications
  • trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl

    r111233 r112021  
    156156        int textMarkerRangeLength(in AccessibilityTextMarkerRange range);
    157157        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
    159162        // Notification support.
    160163        boolean addNotificationListener(in object callbackFunction);
  • trunk/Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm

    r111233 r112021  
    14041404    return false;
    14051405}
     1406   
     1407int 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
     1417bool 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
     1427PassRefPtr<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
    14061437
    14071438} // namespace WTR
Note: See TracChangeset for help on using the changeset viewer.