AX: Support AccessibilityTextMarkers in DRT
authorcfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Sep 2010 17:32:22 +0000 (17:32 +0000)
committercfleizach@apple.com <cfleizach@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Sep 2010 17:32:22 +0000 (17:32 +0000)
https://bugs.webkit.org/show_bug.cgi?id=44778

Reviewed by David Kilzer.

WebCore:

Provide support in DRT for accessing and manipulating the text marker system that AX exposes.
This will allow future bug fixes in the text marker system to be adequately tested.

Tests: platform/mac/accessibility/element-for-text-marker.html
       platform/mac/accessibility/text-marker-length.html

* accessibility/mac/AccessibilityObjectWrapper.mm:
(-[AccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):

WebKitTools:

Add AccessibilityTextMarker and AccessibilityTextMarkerRange which encapsulate the AXTextMarkers
that WebCore uses when vending information about its VisiblePositions through AX.

There are a few new methods in AccessibilityUIElement to retrieve and use text markers, and some basic
methods for encapsulating and checking equality.

This will allow future bug fixes in the text marker system to be adequately tested.

* DumpRenderTree/AccessibilityTextMarker.cpp: Added.
(toTextMarker):
(isMarkerEqualCallback):
(markerFinalize):
(AccessibilityTextMarker::makeJSAccessibilityTextMarker):
(AccessibilityTextMarker::getJSClass):
(toTextMarkerRange):
(isMarkerRangeEqualCallback):
(markerRangeFinalize):
(AccessibilityTextMarkerRange::makeJSAccessibilityTextMarkerRange):
(AccessibilityTextMarkerRange::getJSClass):
* DumpRenderTree/AccessibilityTextMarker.h: Added.
(AccessibilityTextMarker::platformTextMarker):
(AccessibilityTextMarkerRange::platformTextMarkerRange):
(AccessibilityTextMarker::AccessibilityTextMarker):
(AccessibilityTextMarker::~AccessibilityTextMarker):
(AccessibilityTextMarker::isEqual):
(AccessibilityTextMarkerRange::AccessibilityTextMarkerRange):
(AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange):
(AccessibilityTextMarkerRange::isEqual):
* DumpRenderTree/AccessibilityUIElement.cpp:
(textMarkerRangeForElementCallback):
(textMarkerRangeLengthCallback):
(textMarkerRangeForMarkersCallback):
(startTextMarkerForTextMarkerRangeCallback):
(endTextMarkerForTextMarkerRangeCallback):
(accessibilityElementForTextMarkerCallback):
(AccessibilityUIElement::textMarkerRangeForElement):
(AccessibilityUIElement::textMarkerRangeLength):
(AccessibilityUIElement::startTextMarkerForTextMarkerRange):
(AccessibilityUIElement::endTextMarkerForTextMarkerRange):
(AccessibilityUIElement::accessibilityElementForTextMarker):
(AccessibilityUIElement::getJSClass):
* DumpRenderTree/AccessibilityUIElement.h:
* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/mac/AccessibilityTextMarkerMac.mm: Added.
(AccessibilityTextMarker::AccessibilityTextMarker):
(AccessibilityTextMarker::~AccessibilityTextMarker):
(AccessibilityTextMarker::isEqual):
(AccessibilityTextMarkerRange::AccessibilityTextMarkerRange):
(AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange):
(AccessibilityTextMarkerRange::isEqual):
* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::textMarkerRangeForElement):
(AccessibilityUIElement::textMarkerRangeLength):
(AccessibilityUIElement::textMarkerRangeForMarkers):
(AccessibilityUIElement::startTextMarkerForTextMarkerRange):
(AccessibilityUIElement::endTextMarkerForTextMarkerRange):
(AccessibilityUIElement::accessibilityElementForTextMarker):
* DumpRenderTree/win/DumpRenderTree.vcproj:

LayoutTests:

Add basic text marker tests to validate functions are working.

* platform/mac/accessibility/element-for-text-marker-expected.txt: Added.
* platform/mac/accessibility/element-for-text-marker.html: Added.
* platform/mac/accessibility/text-marker-length-expected.txt: Added.
* platform/mac/accessibility/text-marker-length.html: Added.

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

17 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/element-for-text-marker-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/element-for-text-marker.html [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/text-marker-length-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/accessibility/text-marker-length.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/AccessibilityTextMarker.cpp [new file with mode: 0644]
WebKitTools/DumpRenderTree/AccessibilityTextMarker.h [new file with mode: 0644]
WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp
WebKitTools/DumpRenderTree/AccessibilityUIElement.h
WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
WebKitTools/DumpRenderTree/mac/AccessibilityTextMarkerMac.mm [new file with mode: 0644]
WebKitTools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
WebKitTools/DumpRenderTree/win/DumpRenderTree.vcproj
WebKitTools/GNUmakefile.am

index 834fc2d..5a2ed28 100644 (file)
@@ -1,3 +1,17 @@
+2010-09-09  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by David Kilzer.
+
+        AX: Support AccessibilityTextMarkers in DRT
+        https://bugs.webkit.org/show_bug.cgi?id=44778
+
+        Add basic text marker tests to validate functions are working.
+
+        * platform/mac/accessibility/element-for-text-marker-expected.txt: Added.
+        * platform/mac/accessibility/element-for-text-marker.html: Added.
+        * platform/mac/accessibility/text-marker-length-expected.txt: Added.
+        * platform/mac/accessibility/text-marker-length.html: Added.
+
 2010-09-09  Tony Chang  <tony@chromium.org>
 
         Unreviewed.  This test failed after I landed the new checksums. I
diff --git a/LayoutTests/platform/mac/accessibility/element-for-text-marker-expected.txt b/LayoutTests/platform/mac/accessibility/element-for-text-marker-expected.txt
new file mode 100644 (file)
index 0000000..5d33dac
--- /dev/null
@@ -0,0 +1,17 @@
+text here
+text block
+text here
+This tests the text marker system will return the correct element when given a text marker.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS text.textMarkerRangeLength(textMarkerRange1) is 10
+PASS text.accessibilityElementForTextMarker(startMarker).isEqual(text) is true
+PASS text.accessibilityElementForTextMarker(endMarker).isEqual(text) is true
+PASS text.textMarkerRangeLength(newMarkerRange) is 10
+PASS newMarkerRange.isEqual(textMarkerRange1) is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/element-for-text-marker.html b/LayoutTests/platform/mac/accessibility/element-for-text-marker.html
new file mode 100644 (file)
index 0000000..8e71df4
--- /dev/null
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+text here
+<div id="text1" tabindex="0">text block</div>
+text here
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests the text marker system will return the correct element when given a text marker.");
+
+    if (window.accessibilityController) {
+
+          document.getElementById("text1").focus();
+          var text = accessibilityController.focusedElement;
+
+          // Get the actual text node.
+          text = text.childAtIndex(0);
+
+          // Check that we can get the start marker for this range.
+          var textMarkerRange1 = text.textMarkerRangeForElement(text);
+          shouldBe("text.textMarkerRangeLength(textMarkerRange1)", "10");
+          var startMarker = text.startTextMarkerForTextMarkerRange(textMarkerRange1);
+
+          // Check that the start marker will give us the same element that we started with.
+          shouldBeTrue("text.accessibilityElementForTextMarker(startMarker).isEqual(text)");
+
+          // Get the end marker and check that it gives us the same element.
+          var endMarker = text.endTextMarkerForTextMarkerRange(textMarkerRange1);
+          shouldBeTrue("text.accessibilityElementForTextMarker(endMarker).isEqual(text)");
+
+          // Make a marker range out of the start and end markers and check the length
+          var newMarkerRange = text.textMarkerRangeForMarkers(startMarker, endMarker);
+          shouldBe("text.textMarkerRangeLength(newMarkerRange)", "10");
+
+          // And make sure it equals the same marker range we started with
+          shouldBeTrue("newMarkerRange.isEqual(textMarkerRange1)");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/platform/mac/accessibility/text-marker-length-expected.txt b/LayoutTests/platform/mac/accessibility/text-marker-length-expected.txt
new file mode 100644 (file)
index 0000000..f3558e5
--- /dev/null
@@ -0,0 +1,11 @@
+text block
+This tests the text marker implemention of DRT is working by returning a marker range and by returning its correct length.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS text.textMarkerRangeLength(textMarkerRange) is 10
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/platform/mac/accessibility/text-marker-length.html b/LayoutTests/platform/mac/accessibility/text-marker-length.html
new file mode 100644 (file)
index 0000000..c6a3e54
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css">
+<script>
+var successfullyParsed = false;
+</script>
+<script src="../../../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body id="body">
+
+<div id="text" tabindex="0">text block</div>
+
+<p id="description"></p>
+<div id="console"></div>
+
+<script>
+
+    description("This tests the text marker implemention of DRT is working by returning a marker range and by returning its correct length.");
+
+    if (window.accessibilityController) {
+
+          document.getElementById("text").focus();
+          var text = accessibilityController.focusedElement;
+          var textMarkerRange = text.textMarkerRangeForElement(text);
+          shouldBe("text.textMarkerRangeLength(textMarkerRange)", "10");
+    }
+
+    successfullyParsed = true;
+</script>
+
+<script src="../../../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index a9d89ee..1ed45db 100644 (file)
@@ -1,3 +1,19 @@
+2010-09-09  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by David Kilzer.
+
+        AX: Support AccessibilityTextMarkers in DRT
+        https://bugs.webkit.org/show_bug.cgi?id=44778
+
+        Provide support in DRT for accessing and manipulating the text marker system that AX exposes.
+        This will allow future bug fixes in the text marker system to be adequately tested.
+
+        Tests: platform/mac/accessibility/element-for-text-marker.html
+               platform/mac/accessibility/text-marker-length.html
+
+        * accessibility/mac/AccessibilityObjectWrapper.mm:
+        (-[AccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+
 2010-09-09  Simon Fraser  <simon.fraser@apple.com>
 
         Reviewed by Dan Bernstein.
index 9595e25..859a799 100644 (file)
@@ -2352,37 +2352,37 @@ static RenderObject* rendererForView(NSView* view)
     }
     
     // dispatch
-    if ([attribute isEqualToString: @"AXUIElementForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return m_object->accessibilityObjectForPosition(visiblePos)->wrapper();
     }
 
-    if ([attribute isEqualToString: @"AXTextMarkerRangeForUIElement"]) {
+    if ([attribute isEqualToString:@"AXTextMarkerRangeForUIElement"]) {
         VisiblePositionRange vpRange = uiElement.get()->visiblePositionRange();
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXLineForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXLineForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return [NSNumber numberWithUnsignedInt:m_object->lineForPosition(visiblePos)];
     }
 
-    if ([attribute isEqualToString: @"AXTextMarkerRangeForLine"]) {
+    if ([attribute isEqualToString:@"AXTextMarkerRangeForLine"]) {
         VisiblePositionRange vpRange = m_object->visiblePositionRangeForLine([number intValue]);
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXStringForTextMarkerRange"]) {
+    if ([attribute isEqualToString:@"AXStringForTextMarkerRange"]) {
         VisiblePositionRange visiblePosRange = [self visiblePositionRangeForTextMarkerRange:textMarkerRange];
         return m_object->stringForVisiblePositionRange(visiblePosRange);
     }
 
-    if ([attribute isEqualToString: @"AXTextMarkerForPosition"]) {
+    if ([attribute isEqualToString:@"AXTextMarkerForPosition"]) {
         IntPoint webCorePoint = IntPoint(point);
         return pointSet ? textMarkerForVisiblePosition(m_object->visiblePositionForPoint(webCorePoint)) : nil;
     }
 
-    if ([attribute isEqualToString: @"AXBoundsForTextMarkerRange"]) {
+    if ([attribute isEqualToString:@"AXBoundsForTextMarkerRange"]) {
         VisiblePositionRange visiblePosRange = [self visiblePositionRangeForTextMarkerRange:textMarkerRange];
         NSRect rect = m_object->boundsForVisiblePositionRange(visiblePosRange);
         return [NSValue valueWithRect:rect];
@@ -2405,10 +2405,10 @@ static RenderObject* rendererForView(NSView* view)
         return m_object->stringForVisiblePositionRange(VisiblePositionRange(start, end));
     }
 
-    if ([attribute isEqualToString: @"AXAttributedStringForTextMarkerRange"])
+    if ([attribute isEqualToString:@"AXAttributedStringForTextMarkerRange"])
         return [self doAXAttributedStringForTextMarkerRange:textMarkerRange];
 
-    if ([attribute isEqualToString: @"AXTextMarkerRangeForUnorderedTextMarkers"]) {
+    if ([attribute isEqualToString:@"AXTextMarkerRangeForUnorderedTextMarkers"]) {
         if ([array count] < 2)
             return nil;
 
@@ -2424,99 +2424,99 @@ static RenderObject* rendererForView(NSView* view)
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXNextTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXNextTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->nextVisiblePosition(visiblePos));
     }
 
-    if ([attribute isEqualToString: @"AXPreviousTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXPreviousTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->previousVisiblePosition(visiblePos));
     }
 
-    if ([attribute isEqualToString: @"AXLeftWordTextMarkerRangeForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXLeftWordTextMarkerRangeForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         VisiblePositionRange vpRange = m_object->positionOfLeftWord(visiblePos);
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXRightWordTextMarkerRangeForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXRightWordTextMarkerRangeForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         VisiblePositionRange vpRange = m_object->positionOfRightWord(visiblePos);
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXLeftLineTextMarkerRangeForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXLeftLineTextMarkerRangeForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         VisiblePositionRange vpRange = m_object->leftLineVisiblePositionRange(visiblePos);
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXRightLineTextMarkerRangeForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXRightLineTextMarkerRangeForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         VisiblePositionRange vpRange = m_object->rightLineVisiblePositionRange(visiblePos);
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXSentenceTextMarkerRangeForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXSentenceTextMarkerRangeForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         VisiblePositionRange vpRange = m_object->sentenceForPosition(visiblePos);
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXParagraphTextMarkerRangeForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXParagraphTextMarkerRangeForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         VisiblePositionRange vpRange = m_object->paragraphForPosition(visiblePos);
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXNextWordEndTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXNextWordEndTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->nextWordEnd(visiblePos));
     }
     
-    if ([attribute isEqualToString: @"AXPreviousWordStartTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXPreviousWordStartTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->previousWordStart(visiblePos));
     }
 
-    if ([attribute isEqualToString: @"AXNextLineEndTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXNextLineEndTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->nextLineEndPosition(visiblePos));
     }
 
-    if ([attribute isEqualToString: @"AXPreviousLineStartTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXPreviousLineStartTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->previousLineStartPosition(visiblePos));
     }
 
-    if ([attribute isEqualToString: @"AXNextSentenceEndTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXNextSentenceEndTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->nextSentenceEndPosition(visiblePos));
     }
 
-    if ([attribute isEqualToString: @"AXPreviousSentenceStartTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXPreviousSentenceStartTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->previousSentenceStartPosition(visiblePos));
     }
 
-    if ([attribute isEqualToString: @"AXNextParagraphEndTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXNextParagraphEndTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->nextParagraphEndPosition(visiblePos));
     }
 
-    if ([attribute isEqualToString: @"AXPreviousParagraphStartTextMarkerForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXPreviousParagraphStartTextMarkerForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         return textMarkerForVisiblePosition(m_object->previousParagraphStartPosition(visiblePos));
     }
 
-    if ([attribute isEqualToString: @"AXStyleTextMarkerRangeForTextMarker"]) {
+    if ([attribute isEqualToString:@"AXStyleTextMarkerRangeForTextMarker"]) {
         VisiblePosition visiblePos = visiblePositionForTextMarker(textMarker);
         VisiblePositionRange vpRange = m_object->styleRangeForPosition(visiblePos);
         return (id)textMarkerRangeFromVisiblePositions(vpRange.start, vpRange.end);
     }
 
-    if ([attribute isEqualToString: @"AXLengthForTextMarkerRange"]) {
+    if ([attribute isEqualToString:@"AXLengthForTextMarkerRange"]) {
         VisiblePositionRange visiblePosRange = [self visiblePositionRangeForTextMarkerRange:textMarkerRange];
         int length = m_object->lengthForVisiblePositionRange(visiblePosRange);
         if (length < 0)
@@ -2524,6 +2524,17 @@ static RenderObject* rendererForView(NSView* view)
         return [NSNumber numberWithInt:length];
     }
 
+    // Used only by DumpRenderTree (so far).
+    if ([attribute isEqualToString:@"AXStartTextMarkerForTextMarkerRange"]) {
+        VisiblePositionRange visiblePosRange = [self visiblePositionRangeForTextMarkerRange:textMarkerRange];
+        return textMarkerForVisiblePosition(visiblePosRange.start);
+    }
+
+    if ([attribute isEqualToString:@"AXEndTextMarkerForTextMarkerRange"]) {
+        VisiblePositionRange visiblePosRange = [self visiblePositionRangeForTextMarkerRange:textMarkerRange];
+        return textMarkerForVisiblePosition(visiblePosRange.end);
+    }
+    
     if (m_object->isDataTable()) {
         if ([attribute isEqualToString:NSAccessibilityCellForColumnAndRowParameterizedAttribute]) {
             if (array == nil || [array count] != 2)
index 54bee93..dbf74a4 100644 (file)
@@ -1,3 +1,69 @@
+2010-09-09  Chris Fleizach  <cfleizach@apple.com>
+
+        Reviewed by David Kilzer.
+
+        AX: Support AccessibilityTextMarkers in DRT
+        https://bugs.webkit.org/show_bug.cgi?id=44778
+
+        Add AccessibilityTextMarker and AccessibilityTextMarkerRange which encapsulate the AXTextMarkers 
+        that WebCore uses when vending information about its VisiblePositions through AX.
+
+        There are a few new methods in AccessibilityUIElement to retrieve and use text markers, and some basic
+        methods for encapsulating and checking equality.
+
+        This will allow future bug fixes in the text marker system to be adequately tested.
+
+        * DumpRenderTree/AccessibilityTextMarker.cpp: Added.
+        (toTextMarker):
+        (isMarkerEqualCallback):
+        (markerFinalize):
+        (AccessibilityTextMarker::makeJSAccessibilityTextMarker):
+        (AccessibilityTextMarker::getJSClass):
+        (toTextMarkerRange):
+        (isMarkerRangeEqualCallback):
+        (markerRangeFinalize):
+        (AccessibilityTextMarkerRange::makeJSAccessibilityTextMarkerRange):
+        (AccessibilityTextMarkerRange::getJSClass):
+        * DumpRenderTree/AccessibilityTextMarker.h: Added.
+        (AccessibilityTextMarker::platformTextMarker):
+        (AccessibilityTextMarkerRange::platformTextMarkerRange):
+        (AccessibilityTextMarker::AccessibilityTextMarker):
+        (AccessibilityTextMarker::~AccessibilityTextMarker):
+        (AccessibilityTextMarker::isEqual):
+        (AccessibilityTextMarkerRange::AccessibilityTextMarkerRange):
+        (AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange):
+        (AccessibilityTextMarkerRange::isEqual):
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (textMarkerRangeForElementCallback):
+        (textMarkerRangeLengthCallback):
+        (textMarkerRangeForMarkersCallback):
+        (startTextMarkerForTextMarkerRangeCallback):
+        (endTextMarkerForTextMarkerRangeCallback):
+        (accessibilityElementForTextMarkerCallback):
+        (AccessibilityUIElement::textMarkerRangeForElement):
+        (AccessibilityUIElement::textMarkerRangeLength):
+        (AccessibilityUIElement::startTextMarkerForTextMarkerRange):
+        (AccessibilityUIElement::endTextMarkerForTextMarkerRange):
+        (AccessibilityUIElement::accessibilityElementForTextMarker):
+        (AccessibilityUIElement::getJSClass):
+        * DumpRenderTree/AccessibilityUIElement.h:
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/mac/AccessibilityTextMarkerMac.mm: Added.
+        (AccessibilityTextMarker::AccessibilityTextMarker):
+        (AccessibilityTextMarker::~AccessibilityTextMarker):
+        (AccessibilityTextMarker::isEqual):
+        (AccessibilityTextMarkerRange::AccessibilityTextMarkerRange):
+        (AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange):
+        (AccessibilityTextMarkerRange::isEqual):
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::textMarkerRangeForElement):
+        (AccessibilityUIElement::textMarkerRangeLength):
+        (AccessibilityUIElement::textMarkerRangeForMarkers):
+        (AccessibilityUIElement::startTextMarkerForTextMarkerRange):
+        (AccessibilityUIElement::endTextMarkerForTextMarkerRange):
+        (AccessibilityUIElement::accessibilityElementForTextMarker):
+        * DumpRenderTree/win/DumpRenderTree.vcproj:
+
 2010-08-25  Tony Chang  <tony@chromium.org>
 
         Reviewed by Ojan Vafai.
diff --git a/WebKitTools/DumpRenderTree/AccessibilityTextMarker.cpp b/WebKitTools/DumpRenderTree/AccessibilityTextMarker.cpp
new file mode 100644 (file)
index 0000000..d84ee80
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "AccessibilityTextMarker.h"
+
+#include "AccessibilityUIElement.h"
+#include <JavaScriptCore/JSRetainPtr.h>
+
+#pragma mark AccessibilityTextMarker
+
+// Callback methods
+
+AccessibilityTextMarker* toTextMarker(JSObjectRef object)
+{
+    return static_cast<AccessibilityTextMarker*>(JSObjectGetPrivate(object));
+}
+
+static JSValueRef isMarkerEqualCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount != 1)
+        return JSValueMakeBoolean(context, false);
+
+    JSObjectRef otherMarker = JSValueToObject(context, arguments[0], exception);
+    return JSValueMakeBoolean(context, toTextMarker(thisObject)->isEqual(toTextMarker(otherMarker)));
+}
+
+// Destruction
+
+static void markerFinalize(JSObjectRef thisObject)
+{
+    delete toTextMarker(thisObject);
+}
+
+// Object Creation
+
+JSObjectRef AccessibilityTextMarker::makeJSAccessibilityTextMarker(JSContextRef context, const AccessibilityTextMarker& element)
+{
+    return JSObjectMake(context, AccessibilityTextMarker::getJSClass(), new AccessibilityTextMarker(element));
+}
+
+JSClassRef AccessibilityTextMarker::getJSClass()
+{
+    static JSStaticValue staticValues[] = {
+        { 0, 0, 0, 0 }
+    };
+    
+    static JSStaticFunction staticFunctions[] = {
+        { "isEqual", isMarkerEqualCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { 0, 0, 0 }
+    };
+    
+    static JSClassDefinition classDefinition = {
+        0, kJSClassAttributeNone, "AccessibilityTextMarker", 0, staticValues, staticFunctions,
+        0, markerFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
+    };
+    
+    static JSClassRef accessibilityTextMarkerClass = JSClassCreate(&classDefinition);
+    return accessibilityTextMarkerClass;
+}
+
+#pragma mark AccessibilityTextMarkerRange
+
+// Callback methods
+
+AccessibilityTextMarkerRange* toTextMarkerRange(JSObjectRef object)
+{
+    return static_cast<AccessibilityTextMarkerRange*>(JSObjectGetPrivate(object));
+}
+
+static JSValueRef isMarkerRangeEqualCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if (argumentCount != 1)
+        return JSValueMakeBoolean(context, false);
+    
+    JSObjectRef otherMarker = JSValueToObject(context, arguments[0], exception);
+    return JSValueMakeBoolean(context, toTextMarkerRange(thisObject)->isEqual(toTextMarkerRange(otherMarker)));
+}
+
+// Destruction
+
+static void markerRangeFinalize(JSObjectRef thisObject)
+{
+    delete toTextMarkerRange(thisObject);
+}
+
+// Object Creation
+
+JSObjectRef AccessibilityTextMarkerRange::makeJSAccessibilityTextMarkerRange(JSContextRef context, const AccessibilityTextMarkerRange& element)
+{
+    return JSObjectMake(context, AccessibilityTextMarkerRange::getJSClass(), new AccessibilityTextMarkerRange(element));
+}
+
+JSClassRef AccessibilityTextMarkerRange::getJSClass()
+{
+    static JSStaticValue staticValues[] = {
+        { 0, 0, 0, 0 }
+    };
+    
+    static JSStaticFunction staticFunctions[] = {
+        { "isEqual", isMarkerRangeEqualCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { 0, 0, 0 }
+    };
+    
+    static JSClassDefinition classDefinition = {
+        0, kJSClassAttributeNone, "AccessibilityTextMarkerRange", 0, staticValues, staticFunctions,
+        0, markerRangeFinalize, 0, 0, 0, 0, 0, 0, 0, 0, 0
+    };
+    
+    static JSClassRef accessibilityTextMarkerRangeClass = JSClassCreate(&classDefinition);
+    return accessibilityTextMarkerRangeClass;
+}
diff --git a/WebKitTools/DumpRenderTree/AccessibilityTextMarker.h b/WebKitTools/DumpRenderTree/AccessibilityTextMarker.h
new file mode 100644 (file)
index 0000000..cbb00cc
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef AccessibilityTextMarker_h
+#define AccessibilityTextMarker_h
+
+#include <JavaScriptCore/JSObjectRef.h>
+
+#if PLATFORM(MAC)
+#define SUPPORTS_AX_TEXTMARKERS 1
+#else
+#define SUPPORTS_AX_TEXTMARKERS 0
+#endif
+
+#if PLATFORM(MAC)
+#include <wtf/RetainPtr.h>
+typedef CFTypeRef PlatformTextMarker;
+typedef CFTypeRef PlatformTextMarkerRange;
+#else
+typedef void* PlatformTextMarker;
+typedef void* PlatformTextMarkerRange;
+#endif
+
+class AccessibilityUIElement;
+
+class AccessibilityTextMarker {
+public:
+    AccessibilityTextMarker(PlatformTextMarker);
+    AccessibilityTextMarker(const AccessibilityTextMarker&);
+    ~AccessibilityTextMarker();
+    
+    PlatformTextMarker platformTextMarker() const { return m_textMarker.get(); }
+    
+    static JSObjectRef makeJSAccessibilityTextMarker(JSContextRef, const AccessibilityTextMarker&);
+    bool isEqual(AccessibilityTextMarker*);
+    
+private:
+    static JSClassRef getJSClass();
+#if PLATFORM(MAC)
+    RetainPtr<PlatformTextMarker> m_textMarker;
+#else
+    PlatformTextMarker m_textMarker;
+#endif
+};
+
+class AccessibilityTextMarkerRange {
+public:
+    AccessibilityTextMarkerRange(PlatformTextMarkerRange);
+    AccessibilityTextMarkerRange(const AccessibilityTextMarkerRange&);
+    ~AccessibilityTextMarkerRange();
+    
+    PlatformTextMarkerRange platformTextMarkerRange() const { return m_textMarkerRange.get(); }
+    
+    static JSObjectRef makeJSAccessibilityTextMarkerRange(JSContextRef, const AccessibilityTextMarkerRange&);
+    bool isEqual(AccessibilityTextMarkerRange*);
+    
+private:
+    static JSClassRef getJSClass();
+#if PLATFORM(MAC)
+    RetainPtr<PlatformTextMarkerRange> m_textMarkerRange;
+#else
+    PlatformTextMarkerRange m_textMarkerRange;
+#endif
+};
+
+AccessibilityTextMarker* toTextMarker(JSObjectRef object);
+AccessibilityTextMarkerRange* toTextMarkerRange(JSObjectRef object);
+
+#if !SUPPORTS_AX_TEXTMARKERS
+inline AccessibilityTextMarker::AccessibilityTextMarker(PlatformTextMarker) { }
+inline AccessibilityTextMarker::AccessibilityTextMarker(const AccessibilityTextMarker&) { }
+inline AccessibilityTextMarker::~AccessibilityTextMarker() { }
+inline bool AccessibilityTextMarker::isEqual(AccessibilityTextMarker*) { return false; }
+
+inline AccessibilityTextMarkerRange::AccessibilityTextMarkerRange(PlatformTextMarkerRange) { }
+inline AccessibilityTextMarkerRange::AccessibilityTextMarkerRange(const AccessibilityTextMarkerRange&) { }
+inline AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange() { }
+inline bool AccessibilityTextMarkerRange::isEqual(AccessibilityTextMarkerRange*) { return false; }
+#endif
+
+#endif // AccessibilityUIElement_h
index e09eb35..22bbbaa 100644 (file)
@@ -406,6 +406,62 @@ static JSValueRef removeSelectionCallback(JSContextRef context, JSObjectRef func
     return JSValueMakeUndefined(context);
 }
 
+static JSValueRef textMarkerRangeForElementCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AccessibilityUIElement* uiElement = 0;
+    if (argumentCount == 1)
+        uiElement = toAXElement(JSValueToObject(context, arguments[0], exception));
+    
+    return AccessibilityTextMarkerRange::makeJSAccessibilityTextMarkerRange(context, toAXElement(thisObject)->textMarkerRangeForElement(uiElement));
+}
+
+static JSValueRef textMarkerRangeLengthCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AccessibilityTextMarkerRange* range = 0;
+    if (argumentCount == 1)
+        range = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
+    
+    return JSValueMakeNumber(context, (int)toAXElement(thisObject)->textMarkerRangeLength(range));
+}
+
+static JSValueRef textMarkerRangeForMarkersCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AccessibilityTextMarker* startMarker = 0;
+    AccessibilityTextMarker* endMarker = 0;
+    if (argumentCount == 2) {
+        startMarker = toTextMarker(JSValueToObject(context, arguments[0], exception));
+        endMarker = toTextMarker(JSValueToObject(context, arguments[1], exception));
+    }
+    
+    return AccessibilityTextMarkerRange::makeJSAccessibilityTextMarkerRange(context, toAXElement(thisObject)->textMarkerRangeForMarkers(startMarker, endMarker));
+}
+
+static JSValueRef startTextMarkerForTextMarkerRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AccessibilityTextMarkerRange* markerRange = 0;
+    if (argumentCount == 1)
+        markerRange = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
+    
+    return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->startTextMarkerForTextMarkerRange(markerRange));
+}
+
+static JSValueRef endTextMarkerForTextMarkerRangeCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AccessibilityTextMarkerRange* markerRange = 0;
+    if (argumentCount == 1)
+        markerRange = toTextMarkerRange(JSValueToObject(context, arguments[0], exception));
+    
+    return AccessibilityTextMarker::makeJSAccessibilityTextMarker(context, toAXElement(thisObject)->endTextMarkerForTextMarkerRange(markerRange));
+}
+
+static JSValueRef accessibilityElementForTextMarkerCallback(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 AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->accessibilityElementForTextMarker(marker));
+}
 
 // Static Value Getters
 
@@ -662,6 +718,42 @@ static JSValueRef removeNotificationListenerCallback(JSContextRef context, JSObj
     return JSValueMakeUndefined(context);
 }
 
+// Implementation
+
+#if !SUPPORTS_AX_TEXTMARKERS
+
+AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeForElement(AccessibilityUIElement*)
+{
+    return 0;
+}
+
+int AccessibilityUIElement::textMarkerRangeLength(AccessibilityTextMarkerRange*)
+{
+    return 0;
+}
+
+AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeForMarkers(AccessibilityTextMarker*, AccessibilityTextMarker*)
+{
+    return 0;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*)
+{
+    return 0;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*)
+{
+    return 0;   
+}
+
+AccessibilityUIElement AccessibilityUIElement::accessibilityElementForTextMarker(AccessibilityTextMarker*)
+{
+    return 0;
+}
+
+#endif
+
 // Destruction
 
 static void finalize(JSObjectRef thisObject)
@@ -774,6 +866,12 @@ JSClassRef AccessibilityUIElement::getJSClass()
         { "takeSelection", takeSelectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "addSelection", addSelectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { "removeSelection", removeSelectionCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "textMarkerRangeForElement", textMarkerRangeForElementCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "textMarkerRangeForMarkers", textMarkerRangeForMarkersCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "startTextMarkerForTextMarkerRange", startTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "endTextMarkerForTextMarkerRange", endTextMarkerForTextMarkerRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "accessibilityElementForTextMarker", accessibilityElementForTextMarkerCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
+        { "textMarkerRangeLength", textMarkerRangeLengthCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
         { 0, 0, 0 }
     };
 
index 13415cd..2606795 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef AccessibilityUIElement_h
 #define AccessibilityUIElement_h
 
+#include "AccessibilityTextMarker.h"
 #include <JavaScriptCore/JSObjectRef.h>
 #include <wtf/Platform.h>
 #include <wtf/Vector.h>
@@ -40,8 +41,8 @@ typedef struct objc_object* PlatformUIElement;
 #undef _WINSOCKAPI_
 #define _WINSOCKAPI_ // Prevent inclusion of winsock.h in windows.h
 
-#include <oleacc.h>
 #include <WebCore/COMPtr.h>
+#include <oleacc.h>
 
 typedef COMPtr<IAccessible> PlatformUIElement;
 #elif PLATFORM(GTK)
@@ -183,6 +184,14 @@ public:
     // Table-specific
     AccessibilityUIElement cellForColumnAndRow(unsigned column, unsigned row);
 
+    // Text markers.
+    AccessibilityTextMarkerRange textMarkerRangeForElement(AccessibilityUIElement*);    
+    AccessibilityTextMarkerRange textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker);
+    AccessibilityTextMarker startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
+    AccessibilityTextMarker endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange*);
+    AccessibilityUIElement accessibilityElementForTextMarker(AccessibilityTextMarker*);
+    int textMarkerRangeLength(AccessibilityTextMarkerRange*);
+    
     // Notifications
     // Function callback should take one argument, the name of the notification.
     bool addNotificationListener(JSObjectRef functionCallback);
index c92c704..c01ca4e 100644 (file)
@@ -43,6 +43,9 @@
                1AC77DCF120605B6005C19EF /* NPRuntimeRemoveProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AC77DCE120605B6005C19EF /* NPRuntimeRemoveProperty.cpp */; };
                1AD9D2FE12028409001A70D1 /* PluginScriptableNPObjectInvokeDefault.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1AD9D2FD12028409001A70D1 /* PluginScriptableNPObjectInvokeDefault.cpp */; };
                23BCB8900EA57623003C6289 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23BCB88F0EA57623003C6289 /* OpenGL.framework */; };
+               29CFBA10122736E600BC30C0 /* AccessibilityTextMarker.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CFBA0E122736E600BC30C0 /* AccessibilityTextMarker.h */; };
+               29CFBA11122736E600BC30C0 /* AccessibilityTextMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CFBA0F122736E600BC30C0 /* AccessibilityTextMarker.cpp */; };
+               29CFBA2E12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29CFBA2D12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm */; };
                3713EDE2115BE19300705720 /* ColorBits-A.png in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 3713EDDF115BE16F00705720 /* ColorBits-A.png */; };
                3713EDE3115BE19300705720 /* ColorBits.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = 3713EDE0115BE16F00705720 /* ColorBits.ttf */; };
                5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5185F69F10714A57007AA393 /* HistoryDelegate.mm */; };
                1AC77DCE120605B6005C19EF /* NPRuntimeRemoveProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NPRuntimeRemoveProperty.cpp; sourceTree = "<group>"; };
                1AD9D2FD12028409001A70D1 /* PluginScriptableNPObjectInvokeDefault.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PluginScriptableNPObjectInvokeDefault.cpp; sourceTree = "<group>"; };
                23BCB88F0EA57623003C6289 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; };
+               29CFBA0E122736E600BC30C0 /* AccessibilityTextMarker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityTextMarker.h; sourceTree = "<group>"; };
+               29CFBA0F122736E600BC30C0 /* AccessibilityTextMarker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AccessibilityTextMarker.cpp; sourceTree = "<group>"; };
+               29CFBA2D12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AccessibilityTextMarkerMac.mm; path = mac/AccessibilityTextMarkerMac.mm; sourceTree = "<group>"; };
                32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumpRenderTreePrefix.h; sourceTree = "<group>"; };
                3713EDDF115BE16F00705720 /* ColorBits-A.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "ColorBits-A.png"; path = "fonts/ColorBits-A.png"; sourceTree = "<group>"; };
                3713EDE0115BE16F00705720 /* ColorBits.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = ColorBits.ttf; path = fonts/ColorBits.ttf; sourceTree = "<group>"; };
                                BCD08B390E1057EF00A7D0C1 /* AccessibilityController.cpp */,
                                BCD08A580E10496B00A7D0C1 /* AccessibilityController.h */,
                                BCD08B700E1059D200A7D0C1 /* AccessibilityControllerMac.mm */,
+                               29CFBA0F122736E600BC30C0 /* AccessibilityTextMarker.cpp */,
+                               29CFBA0E122736E600BC30C0 /* AccessibilityTextMarker.h */,
+                               29CFBA2D12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm */,
                                BC0E24DF0E2D9451001B6BC2 /* AccessibilityUIElement.cpp */,
                                BC0E24DE0E2D9451001B6BC2 /* AccessibilityUIElement.h */,
                                BC0E26140E2DA4C6001B6BC2 /* AccessibilityUIElementMac.mm */,
                                BC9D90260C97472E0099A4A3 /* WorkQueueItem.h in Headers */,
                                5185F6B310714E12007AA393 /* HistoryDelegate.h in Headers */,
                                E1B7816711AF31C3007E1BC2 /* MockGeolocationProvider.h in Headers */,
+                               29CFBA10122736E600BC30C0 /* AccessibilityTextMarker.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCA18B260C9B015C00114369 /* WorkQueueItemMac.mm in Sources */,
                                5185F6B210714E07007AA393 /* HistoryDelegate.mm in Sources */,
                                E1B7816511AF31B7007E1BC2 /* MockGeolocationProvider.mm in Sources */,
+                               29CFBA11122736E600BC30C0 /* AccessibilityTextMarker.cpp in Sources */,
+                               29CFBA2E12273A1000BC30C0 /* AccessibilityTextMarkerMac.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/WebKitTools/DumpRenderTree/mac/AccessibilityTextMarkerMac.mm b/WebKitTools/DumpRenderTree/mac/AccessibilityTextMarkerMac.mm
new file mode 100644 (file)
index 0000000..5856414
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#import "config.h"
+
+#import "AccessibilityTextMarker.h"
+#import "DumpRenderTree.h"
+
+#pragma mark AccessibilityTextMarker
+
+AccessibilityTextMarker::AccessibilityTextMarker(PlatformTextMarker marker)
+    : m_textMarker(marker)
+{
+}
+
+AccessibilityTextMarker::AccessibilityTextMarker(const AccessibilityTextMarker& marker)
+    : m_textMarker(marker.platformTextMarker())
+{
+}
+
+AccessibilityTextMarker::~AccessibilityTextMarker()
+{
+}
+
+bool AccessibilityTextMarker::isEqual(AccessibilityTextMarker* other)
+{
+    return [(id)platformTextMarker() isEqual:(id)other->platformTextMarker()];
+}
+
+#pragma mark AccessibilityTextMarkerRange
+
+AccessibilityTextMarkerRange::AccessibilityTextMarkerRange(PlatformTextMarkerRange markerRange)
+    : m_textMarkerRange(markerRange)
+{
+}
+
+AccessibilityTextMarkerRange::AccessibilityTextMarkerRange(const AccessibilityTextMarkerRange& markerRange)
+    : m_textMarkerRange(markerRange.platformTextMarkerRange())
+{
+}
+
+AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange()
+{
+}
+
+bool AccessibilityTextMarkerRange::isEqual(AccessibilityTextMarkerRange* other)
+{
+    return [(id)platformTextMarkerRange() isEqual:(id)other->platformTextMarkerRange()];
+}
+
index d1592b2..fa4acf5 100644 (file)
@@ -1190,3 +1190,70 @@ void AccessibilityUIElement::removeSelection()
 {
     // FIXME: implement
 }
+
+#if SUPPORTS_AX_TEXTMARKERS
+
+// Text markers
+AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeForElement(AccessibilityUIElement* element)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    id textMarkerRange = [m_element accessibilityAttributeValue:@"AXTextMarkerRangeForUIElement" forParameter:element->platformUIElement()];
+    return AccessibilityTextMarkerRange(textMarkerRange);
+    END_AX_OBJC_EXCEPTIONS
+    
+    return 0;
+}
+
+int AccessibilityUIElement::textMarkerRangeLength(AccessibilityTextMarkerRange* range)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    NSNumber* lengthValue = [m_element accessibilityAttributeValue:@"AXLengthForTextMarkerRange" forParameter:(id)range->platformTextMarkerRange()];
+    return [lengthValue intValue];
+    END_AX_OBJC_EXCEPTIONS
+    
+    return 0;
+}
+
+
+AccessibilityTextMarkerRange AccessibilityUIElement::textMarkerRangeForMarkers(AccessibilityTextMarker* startMarker, AccessibilityTextMarker* endMarker)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    NSArray* textMarkers = [NSArray arrayWithObjects:(id)startMarker->platformTextMarker(), (id)endMarker->platformTextMarker(), nil];
+    id textMarkerRange = [m_element accessibilityAttributeValue:@"AXTextMarkerRangeForUnorderedTextMarkers" forParameter:textMarkers];
+    return AccessibilityTextMarkerRange(textMarkerRange);
+    END_AX_OBJC_EXCEPTIONS
+    
+    return 0;
+}
+
+AccessibilityTextMarker AccessibilityUIElement::startTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    id textMarker = [m_element accessibilityAttributeValue:@"AXStartTextMarkerForTextMarkerRange" forParameter:(id)range->platformTextMarkerRange()];
+    return AccessibilityTextMarker(textMarker);
+    END_AX_OBJC_EXCEPTIONS
+    
+    return 0;    
+}
+
+AccessibilityTextMarker AccessibilityUIElement::endTextMarkerForTextMarkerRange(AccessibilityTextMarkerRange* range)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    id textMarker = [m_element accessibilityAttributeValue:@"AXEndTextMarkerForTextMarkerRange" forParameter:(id)range->platformTextMarkerRange()];
+    return AccessibilityTextMarker(textMarker);
+    END_AX_OBJC_EXCEPTIONS
+    
+    return 0;    
+}
+
+AccessibilityUIElement AccessibilityUIElement::accessibilityElementForTextMarker(AccessibilityTextMarker* marker)
+{
+    BEGIN_AX_OBJC_EXCEPTIONS
+    id uiElement = [m_element accessibilityAttributeValue:@"AXUIElementForTextMarker" forParameter:(id)marker->platformTextMarker()];
+    return AccessibilityUIElement(uiElement);
+    END_AX_OBJC_EXCEPTIONS
+    
+    return 0;  
+}
+
+#endif // SUPPORTS_AX_TEXTMARKERS
index 125c6c6..1e765c6 100644 (file)
                        >\r
                </File>\r
                <File\r
+                       RelativePath="..\AccessibilityTextMarker.cpp"\r
+                       >\r
+               </File>\r
+               <File\r
+                       RelativePath="..\AccessibilityTextMarker.h"\r
+                       >\r
+               </File>\r
+               <File\r
                        RelativePath=".\DraggingInfo.h"\r
                        >\r
                </File>\r
index 39df421..292ca7e 100644 (file)
@@ -49,6 +49,8 @@ Programs_DumpRenderTree_SOURCES = \
        WebKitTools/DumpRenderTree/DumpRenderTreePrefix.h \
        WebKitTools/DumpRenderTree/AccessibilityController.cpp \
        WebKitTools/DumpRenderTree/AccessibilityController.h \
+       WebKitTools/DumpRenderTree/AccessibilityTextMarker.cpp \
+       WebKitTools/DumpRenderTree/AccessibilityTextMarker.h \
        WebKitTools/DumpRenderTree/AccessibilityUIElement.cpp \
        WebKitTools/DumpRenderTree/AccessibilityUIElement.h \
        WebKitTools/DumpRenderTree/GCController.cpp \