AX: Support solution to handle invalid ax text marker
[WebKit-https.git] / Tools / DumpRenderTree / mac / AccessibilityUIElementMac.mm
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