AX: Support solution to handle invalid ax text marker
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Mar 2012 04:03:03 +0000 (04:03 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 25 Mar 2012 04:03:03 +0000 (04:03 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@112021 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/textmarker-routines-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/textmarker-routines.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapper.mm
Tools/ChangeLog
Tools/DumpRenderTree/AccessibilityUIElement.cpp
Tools/DumpRenderTree/AccessibilityUIElement.h
Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm

index 90529e19be480bd1f0a142f6ca626ed3d3249579..353589b715a308733bfd7490c07e75d7bf989a36 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-24  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support solution to handle invalid ax text marker
+        https://bugs.webkit.org/show_bug.cgi?id=82023
+
+        Reviewed by Oliver Hunt.
+
+        * platform/mac/accessibility/textmarker-routines-expected.txt: Added.
+        * platform/mac/accessibility/textmarker-routines.html: Added.
+
 2012-03-24  Abhishek Arya  <inferno@chromium.org>
 
         Crash in ApplyStyleCommand::applyInlineStyleToNodeRange.
diff --git a/LayoutTests/platform/mac/accessibility/textmarker-routines-expected.txt b/LayoutTests/platform/mac/accessibility/textmarker-routines-expected.txt
new file mode 100644 (file)
index 0000000..499745f
--- /dev/null
@@ -0,0 +1,18 @@
+text
+text
+This verifies usage of isTextMarkerValid, indexForTextMarker and textMarkerForIndex.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS item1.isTextMarkerValid(firstTextMarker) is true
+PASS item1.indexForTextMarker(firstTextMarker) is 0
+PASS item1.textMarkerForIndex(0).isEqual(firstTextMarker) is true
+PASS item1.isTextMarkerValid(firstTextMarker) is false
+PASS item2.isTextMarkerValid(secondTextMarker) is true
+PASS item2.indexForTextMarker(secondTextMarker) is 5
+PASS item2.textMarkerForIndex(item2.indexForTextMarker(secondTextMarker)).isEqual(secondTextMarker) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/textmarker-routines.html b/LayoutTests/platform/mac/accessibility/textmarker-routines.html
new file mode 100644 (file)
index 0000000..18a49ee
--- /dev/null
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+<body id="body" tabindex="0">
+
+<div tabindex="0" id="text1">text</div>
+
+text
+
+<div tabindex="0" id="text2">text</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This verifies usage of isTextMarkerValid, indexForTextMarker and textMarkerForIndex.");
+
+    if (window.accessibilityController) {
+        document.getElementById("text1").focus();
+        var item1 = accessibilityController.focusedElement;
+        var markerRange = item1.textMarkerRangeForElement(item1);
+        var firstTextMarker = item1.startTextMarkerForTextMarkerRange(markerRange);
+
+        shouldBeTrue("item1.isTextMarkerValid(firstTextMarker)");
+        shouldBe("item1.indexForTextMarker(firstTextMarker)", "0");
+        shouldBeTrue("item1.textMarkerForIndex(0).isEqual(firstTextMarker)");       
+
+        document.getElementById("body").removeChild(document.getElementById("text1"));
+
+        shouldBeFalse("item1.isTextMarkerValid(firstTextMarker)");
+
+        document.getElementById("text2").focus();
+        var item2 = accessibilityController.focusedElement;
+        markerRange = item2.textMarkerRangeForElement(item2);
+        var secondTextMarker = item2.startTextMarkerForTextMarkerRange(markerRange);
+
+        shouldBeTrue("item2.isTextMarkerValid(secondTextMarker)");
+        shouldBe("item2.indexForTextMarker(secondTextMarker)", "5");
+        shouldBeTrue("item2.textMarkerForIndex(item2.indexForTextMarker(secondTextMarker)).isEqual(secondTextMarker)");       
+    }
+
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+
+</body>
+</html>
+
index a68bab3795178856c660f467136c5d2ae703327c..07d6f6363322126f87428081c84edfcf8241abbf 100644 (file)
@@ -1,3 +1,22 @@
+2012-03-24  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support solution to handle invalid ax text marker
+        https://bugs.webkit.org/show_bug.cgi?id=82023
+
+        Reviewed by Oliver Hunt.
+
+        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:]):
+
 2012-03-24  Victor Carbune  <vcarbune@adobe.com>
 
         Quick fix for rendering controls regression.
index 0b7dc4a88ac1541938a52ac8da7afb60c09f8320..c13ad392c2c324b73f64a67a187287e4dea9b567 100644 (file)
@@ -332,6 +332,9 @@ using namespace std;
 #define NSAccessibilityVisitedLinkSearchKey @"AXVisitedLinkSearchKey"
 #endif
 
+#define NSAccessibilityTextMarkerIsValidParameterizedAttribute @"AXTextMarkerIsValid"
+#define NSAccessibilityIndexForTextMarkerParameterizedAttribute @"AXIndexForTextMarker"
+#define NSAccessibilityTextMarkerForIndexParameterizedAttribute @"AXTextMarkerForIndex"
 
 @interface NSObject (WebKitAccessibilityArrayCategory)
 
@@ -2491,6 +2494,7 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     static NSArray* paramAttrs = nil;
     static NSArray* textParamAttrs = nil;
     static NSArray* tableParamAttrs = nil;
+    static NSArray* webAreaParamAttrs = nil;
     if (paramAttrs == nil) {
         paramAttrs = [[NSArray alloc] initWithObjects:
                       @"AXUIElementForTextMarker",
@@ -2546,6 +2550,14 @@ static NSString* roleValueToNSString(AccessibilityRole value)
         tableParamAttrs = [[NSArray alloc] initWithArray:tempArray];
         [tempArray release];
     }
+    if (!webAreaParamAttrs) {
+        NSMutableArray* tempArray = [[NSMutableArray alloc] initWithArray:paramAttrs];
+        [tempArray addObject:NSAccessibilityTextMarkerForIndexParameterizedAttribute];
+        [tempArray addObject:NSAccessibilityTextMarkerIsValidParameterizedAttribute];
+        [tempArray addObject:NSAccessibilityIndexForTextMarkerParameterizedAttribute];
+        webAreaParamAttrs = [[NSArray alloc] initWithArray:tempArray];
+        [tempArray release];
+    }
     
     if (m_object->isPasswordField())
         return [NSArray array];
@@ -2562,6 +2574,9 @@ static NSString* roleValueToNSString(AccessibilityRole value)
     if (m_object->isMenuRelated())
         return nil;
 
+    if (m_object->isWebArea())
+        return webAreaParamAttrs;
+    
     return paramAttrs;
 }
 
@@ -2753,6 +2768,42 @@ static RenderObject* rendererForView(NSView* view)
     return [self doAXAttributedStringForTextMarkerRange:[self textMarkerRangeFromVisiblePositions:visiblePosRange.start endPosition:visiblePosRange.end]];
 }
 
+- (NSRange)_convertToNSRange:(Range*)range
+{
+    NSRange result = NSMakeRange(NSNotFound, 0);
+    if (!range || !range->startContainer())
+        return result;
+    
+    Document* document = m_object->document();
+    if (!document)
+        return result;
+    
+    TextIterator::getLocationAndLengthFromRange(document->documentElement(), range, result.location, result.length);
+    
+    return result;
+}
+
+- (NSInteger)_indexForTextMarker:(id)marker
+{
+    if (!marker)
+        return NSNotFound;
+    
+    VisibleSelection selection([self visiblePositionForTextMarker:marker]);    
+    return [self _convertToNSRange:selection.toNormalizedRange().get()].location;
+}
+
+- (id)_textMarkerForIndex:(NSInteger)textIndex
+{
+    Document* document = m_object->document();
+    if (!document)
+        return nil;
+    
+    PassRefPtr<Range> textRange = TextIterator::rangeFromLocationAndLength(document->documentElement(), textIndex, 0);
+    
+    VisiblePosition position(textRange->startPosition());
+    return [self textMarkerForVisiblePosition:position];
+}
+
 // The RTF representation of the text associated with this accessibility object that is
 // specified by the given range.
 - (NSData*)doAXRTFForRange:(NSRange)range
@@ -2844,6 +2895,17 @@ static RenderObject* rendererForView(NSView* view)
         return convertToNSArray(results);
     }
 
+    if ([attribute isEqualToString:NSAccessibilityTextMarkerIsValidParameterizedAttribute]) {
+        VisiblePosition pos = [self visiblePositionForTextMarker:textMarker];
+        return [NSNumber numberWithBool:!pos.isNull()];
+    }
+    if ([attribute isEqualToString:NSAccessibilityIndexForTextMarkerParameterizedAttribute]) {
+        return [NSNumber numberWithInteger:[self _indexForTextMarker:textMarker]];
+    }
+    if ([attribute isEqualToString:NSAccessibilityTextMarkerForIndexParameterizedAttribute]) {
+        return [self _textMarkerForIndex:[number integerValue]];
+    }
+    
     if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) {
         VisiblePosition visiblePos = [self visiblePositionForTextMarker:(textMarker)];
         AccessibilityObject* axObject = m_object->accessibilityObjectForPosition(visiblePos);
index 822f312961c9e8004c44155211d434c4a6012c64..8d05b6f352a5f1ce4c31ec17fba42138a69c26b2 100644 (file)
@@ -1,3 +1,38 @@
+2012-03-24  Chris Fleizach  <cfleizach@apple.com>
+
+        AX: Support solution to handle invalid ax text marker
+        https://bugs.webkit.org/show_bug.cgi?id=82023
+
+        Reviewed by Oliver Hunt.
+
+        * 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):
+
 2012-03-24  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r112014.
index f1a29fb519cd53368766300f13c1829782fb3628..5741a6723d2fdda5d1164d0695df05d9e25603e1 100644 (file)
@@ -517,6 +517,33 @@ static JSValueRef attributedStringForTextMarkerRangeContainsAttributeCallback(JS
     return result;    
 }
 
+static JSValueRef indexForTextMarkerCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AccessibilityTextMarker* marker = 0;
+    if (argumentCount == 1)
+        marker = toTextMarker(JSValueToObject(context, arguments[0], exception));
+    
+    return JSValueMakeNumber(context, toAXElement(thisObject)->indexForTextMarker(marker));
+}
+
+static JSValueRef isTextMarkerValidCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AccessibilityTextMarker* marker = 0;
+    if (argumentCount == 1)
+        marker = toTextMarker(JSValueToObject(context, arguments[0], exception));
+    
+    return JSValueMakeBoolean(context, toAXElement(thisObject)->isTextMarkerValid(marker));
+}
+
+static JSValueRef textMarkerForIndexCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    int textIndex = 0;
+    if (argumentCount == 1)
+        textIndex = JSValueToNumber(context, arguments[0], exception);
+    
+    return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->textMarkerForIndex(textIndex));
+}
+
 static JSValueRef textMarkerRangeLengthCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     AccessibilityTextMarkerRange* range = 0;
@@ -979,6 +1006,21 @@ bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute
     return false;
 }
 
+int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker*)
+{
+    return -1;
+}
+
+bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker*)
+{
+    return false;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::textMarkerForIndex(int)
+{
+    return 0;
+}
+
 #endif
 
 // Destruction
@@ -1108,7 +1150,10 @@ JSClassRef AccessibilityUIElement::getJSClass()
         { "removeSelection", removeSelectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "textMarkerRangeForElement", textMarkerRangeForElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "attributedStringForTextMarkerRangeContainsAttribute", attributedStringForTextMarkerRangeContainsAttributeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "indexForTextMarker", indexForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "isTextMarkerValid", isTextMarkerValidCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "textMarkerRangeForMarkers", textMarkerRangeForMarkersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "textMarkerForIndex", textMarkerForIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "startTextMarkerForTextMarkerRange", startTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "endTextMarkerForTextMarkerRange", endTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "accessibilityElementForTextMarker", accessibilityElementForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
index bfbef684fde025a15ea87ccd1848e26e272d37b4..8354d250a73195a1855e463ea231feb00cc5d287 100644 (file)
@@ -217,7 +217,10 @@ public:
     JSStringRef stringForTextMarkerRange(AccessibilityTextMarkerRange*);
     int textMarkerRangeLength(AccessibilityTextMarkerRange*);
     bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
-
+    int indexForTextMarker(AccessibilityTextMarker*);
+    bool isTextMarkerValid(AccessibilityTextMarker*);
+    AccessibilityTextMarker textMarkerForIndex(int);
+    
     void scrollToMakeVisible();
     void scrollToMakeVisibleWithSubFocus(int x, int y, int width, int height);
     void scrollToGlobalPoint(int x, int y);
index 2bbe7fe982bb5d135db05a42fe7a187ff38d3349..cf6748579b1f3f7b010333072994fe54992f0161 100644 (file)
@@ -1321,6 +1321,36 @@ bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute
     return false;
 }
 
+int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker* marker)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    NSNumber* indexNumber = [m_element accessibilityAttributeValue:@"AXIndexForTextMarker" forParameter:(id)marker->platformTextMarker()];
+    return [indexNumber intValue];
+    END_AX_OBJC_EXCEPTIONS
+    
+    return -1;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::textMarkerForIndex(int textIndex)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    id textMarker = [m_element accessibilityAttributeValue:@"AXTextMarkerForIndex" forParameter:[NSNumber numberWithInteger:textIndex]];
+    return AccessibilityTextMarker(textMarker);
+    END_AX_OBJC_EXCEPTIONS
+    
+    return 0;
+}
+
+bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker* textMarker)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    NSNumber* validNumber = [m_element accessibilityAttributeValue:@"AXTextMarkerIsValid" forParameter:(id)textMarker->platformTextMarker()];
+    return [validNumber boolValue];
+    END_AX_OBJC_EXCEPTIONS
+
+    return false;
+}
+
 AccessibilityTextMarker AccessibilityUIElement::previousTextMarker(AccessibilityTextMarker* textMarker)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
index 4be157f6955d0754eeb64ae9c5d61dfb0ed451ee..f480397dd30c1856257008a4d6031411348dface 100644 (file)
@@ -173,6 +173,10 @@ PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::previousTextMarker(A
 PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::nextTextMarker(AccessibilityTextMarker*) { return 0; }
 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForTextMarkerRange(AccessibilityTextMarkerRange*) { return 0; }
 bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*) { return false; }
+int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker*) { return -1; }
+bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker*) { return false; }
+PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForIndex(int) { return 0; }
+
 #endif
 
 } // namespace WTR
index 9654ff855e6c1d1b81f43ca4c7be68a4592ce2f9..548c2cb8b5edfc778e35abb3841e20a793009715 100644 (file)
@@ -220,6 +220,9 @@ public:
     JSRetainPtr<JSStringRef> stringForTextMarkerRange(AccessibilityTextMarkerRange*);
     int textMarkerRangeLength(AccessibilityTextMarkerRange*);
     bool attributedStringForTextMarkerRangeContainsAttribute(JSStringRef, AccessibilityTextMarkerRange*);
+    int indexForTextMarker(AccessibilityTextMarker*);
+    bool isTextMarkerValid(AccessibilityTextMarker*);
+    PassRefPtr<AccessibilityTextMarker> textMarkerForIndex(int);
 
     // Notifications
     // Function callback should take one argument, the name of the notification.
index 4d39fca9ef7a9301b7c22a4f8d2f86bf6473e109..10dc90be4fc5f56f38a16748f2fafa5eff78d02d 100644 (file)
@@ -155,7 +155,10 @@ module WTR {
         DOMString stringForTextMarkerRange(in AccessibilityTextMarkerRange range);
         int textMarkerRangeLength(in AccessibilityTextMarkerRange range);
         boolean attributedStringForTextMarkerRangeContainsAttribute(in DOMString attr, in AccessibilityTextMarkerRange range);
-        
+        int indexForTextMarker(in AccessibilityTextMarker marker);
+        boolean isTextMarkerValid(in AccessibilityTextMarker marker);
+        AccessibilityTextMarker textMarkerForIndex(in int textIndex);
+
         // Notification support.
         boolean addNotificationListener(in object callbackFunction);
         boolean removeNotificationListener();
index 95a99a7c1df98fa2b76cf4ce352bc441444dd47a..49539dd230c637c03e491b484ef168d6fbad54ca 100644 (file)
@@ -1403,6 +1403,37 @@ bool AccessibilityUIElement::attributedStringForTextMarkerRangeContainsAttribute
     
     return false;
 }
+    
+int AccessibilityUIElement::indexForTextMarker(AccessibilityTextMarker* marker)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    NSNumber* indexNumber = [m_element accessibilityAttributeValue:@"AXIndexForTextMarker" forParameter:(id)marker->platformTextMarker()];
+    return [indexNumber intValue];
+    END_AX_OBJC_EXCEPTIONS
+    
+    return -1;
+}
+
+bool AccessibilityUIElement::isTextMarkerValid(AccessibilityTextMarker* textMarker)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    NSNumber* validNumber = [m_element accessibilityAttributeValue:@"AXTextMarkerIsValid" forParameter:(id)textMarker->platformTextMarker()];
+    return [validNumber boolValue];
+    END_AX_OBJC_EXCEPTIONS
+    
+    return false;
+}
+
+PassRefPtr<AccessibilityTextMarker> AccessibilityUIElement::textMarkerForIndex(int textIndex)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    id textMarker = [m_element accessibilityAttributeValue:@"AXTextMarkerForIndex" forParameter:[NSNumber numberWithInteger:textIndex]];
+    return AccessibilityTextMarker::create(textMarker);
+    END_AX_OBJC_EXCEPTIONS
+    
+    return 0;                                                                          
+}
+
 
 } // namespace WTR