Allow multiple searchKeys to be passed to AXUIElementCopyParameterizedAttributeValue
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2013 19:14:35 +0000 (19:14 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 29 Mar 2013 19:14:35 +0000 (19:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=112276

Patch by Greg Hughes <ghughes@apple.com> on 2013-03-29
Reviewed by Chris Fleizach.

Source/WebCore:

Added support for accessibility search predicates to accept multiple search keys. The search will return the first item that matches any one of the provided search keys.

* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::isAccessibilityObjectSearchMatchAtIndex):
(WebCore::AccessibilityObject::isAccessibilityObjectSearchMatch):
(WebCore):
* accessibility/AccessibilityObject.h:
(AccessibilitySearchCriteria):
(WebCore::AccessibilitySearchCriteria::AccessibilitySearchCriteria):
(AccessibilityObject):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):

Tools:

Added support to test accessibility search predicates with multiple keys.

* DumpRenderTree/AccessibilityUIElement.cpp:
(uiElementForSearchPredicateCallback):
* DumpRenderTree/AccessibilityUIElement.h:
(AccessibilityUIElement):
* DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
(AccessibilityUIElement::uiElementForSearchPredicate):
* DumpRenderTree/blackberry/AccessibilityUIElementBlackBerry.cpp:
(AccessibilityUIElement::uiElementForSearchPredicate):
* DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
(AccessibilityUIElement::uiElementForSearchPredicate):
* DumpRenderTree/mac/AccessibilityUIElementMac.mm:
(AccessibilityUIElement::uiElementForSearchPredicate):
* DumpRenderTree/win/AccessibilityUIElementWin.cpp:
(AccessibilityUIElement::uiElementForSearchPredicate):
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
(WTR::AccessibilityUIElement::uiElementForSearchPredicate):
* WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
(AccessibilityUIElement):
* WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
* WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
(WTR::AccessibilityUIElement::uiElementForSearchPredicate):
* WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
(WTR::AccessibilityUIElement::uiElementForSearchPredicate):

LayoutTests:

Updated the search predicate test to test passing multiple search keys (link OR heading).

* platform/mac/accessibility/search-predicate-expected.txt:
* platform/mac/accessibility/search-predicate.html:

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

20 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/accessibility/search-predicate-expected.txt
LayoutTests/platform/mac/accessibility/search-predicate.html
Source/WebCore/ChangeLog
Source/WebCore/accessibility/AccessibilityObject.cpp
Source/WebCore/accessibility/AccessibilityObject.h
Source/WebCore/accessibility/mac/WebAccessibilityObjectWrapperMac.mm
Tools/ChangeLog
Tools/DumpRenderTree/AccessibilityUIElement.cpp
Tools/DumpRenderTree/AccessibilityUIElement.h
Tools/DumpRenderTree/atk/AccessibilityUIElementAtk.cpp
Tools/DumpRenderTree/blackberry/AccessibilityUIElementBlackBerry.cpp
Tools/DumpRenderTree/ios/AccessibilityUIElementIOS.mm
Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp
Tools/WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h
Tools/WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl
Tools/WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp
Tools/WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm

index d58eb324e4cd665eb29c8c257f5bfb58c1a9ec86..b464a7986060df6e61713f99921860b17ad5f4e4 100644 (file)
@@ -1,3 +1,15 @@
+2013-03-29  Greg Hughes  <ghughes@apple.com>
+
+        Allow multiple searchKeys to be passed to AXUIElementCopyParameterizedAttributeValue
+        https://bugs.webkit.org/show_bug.cgi?id=112276
+
+        Reviewed by Chris Fleizach.
+
+        Updated the search predicate test to test passing multiple search keys (link OR heading).
+
+        * platform/mac/accessibility/search-predicate-expected.txt:
+        * platform/mac/accessibility/search-predicate.html:
+
 2013-03-29  Timothy Hatcher  <timothy@apple.com>
 
         Mark fast/workers/worker-close-more.html, worker-document-leak.html and
index 6f0cebe3934f533d1ef94e60dc79e733a6456243..1a8c72c5b1526faecd0d8d6b6a9487767a9a8df3 100644 (file)
@@ -103,6 +103,12 @@ PASS resultElement.boolAttributeValue('AXVisited') is true
 PASS resultElement.childAtIndex(0).stringValue is 'AXValue: link'
 PASS resultElement.role is 'AXRole: AXStaticText'
 PASS resultElement.stringValue is 'AXValue: sans-serif black bold text with underline'
+PASS resultElement.role is 'AXRole: AXHeading'
+PASS resultElement.childAtIndex(0).stringValue is 'AXValue: heading level 2'
+PASS resultElement.role is 'AXRole: AXLink'
+PASS resultElement.childAtIndex(0).stringValue is 'AXValue: link'
+PASS resultElement.role is 'AXRole: AXHeading'
+PASS resultElement.childAtIndex(0).stringValue is 'AXValue: heading level 2'
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 9a557467a612211d62d613736687bef909999ca4..f896ae5d3d1a6cecd7fa8f4c67a64ebd7f91c4b8 100644 (file)
         resultElement = containerElement.uiElementForSearchPredicate(startElement, false, "", "sans-serif black bold text with underline");
         shouldBe("resultElement.role", "'AXRole: AXStaticText'");
         shouldBe("resultElement.stringValue", "'AXValue: sans-serif black bold text with underline'");
+        
+        // Execute a search for the next heading level 2 or the next link.
+        startElement = accessibilityController.focusedElement.childAtIndex(0);
+        resultElement = containerElement.uiElementForSearchPredicate(startElement, true, ["AXHeadingLevel2SearchKey", "AXLinkSearchKey"], "");
+        shouldBe("resultElement.role", "'AXRole: AXHeading'");
+        shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 2'");
+        
+        // After finding the heading, execute the search again and we should find the link.
+        resultElement = containerElement.uiElementForSearchPredicate(resultElement, true, ["AXHeadingLevel2SearchKey", "AXLinkSearchKey"], "");
+        shouldBe("resultElement.role", "'AXRole: AXLink'");
+        shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: link'");
+
+        // From the link, execute the search in reverse and we should land back on the heading.
+        resultElement = containerElement.uiElementForSearchPredicate(resultElement, false, ["AXHeadingLevel2SearchKey", "AXLinkSearchKey"], "");
+        shouldBe("resultElement.role", "'AXRole: AXHeading'");
+        shouldBe("resultElement.childAtIndex(0).stringValue", "'AXValue: heading level 2'");
     }
     
 </script>
index a2713f0eac74b7b8eb11971f83494f79812bbf6a..5f7326c425c6f2149251de1fdf1633b7cde33694 100644 (file)
@@ -1,3 +1,23 @@
+2013-03-29  Greg Hughes  <ghughes@apple.com>
+
+        Allow multiple searchKeys to be passed to AXUIElementCopyParameterizedAttributeValue
+        https://bugs.webkit.org/show_bug.cgi?id=112276
+
+        Reviewed by Chris Fleizach.
+
+        Added support for accessibility search predicates to accept multiple search keys. The search will return the first item that matches any one of the provided search keys.
+
+        * accessibility/AccessibilityObject.cpp:
+        (WebCore::AccessibilityObject::isAccessibilityObjectSearchMatchAtIndex):
+        (WebCore::AccessibilityObject::isAccessibilityObjectSearchMatch):
+        (WebCore):
+        * accessibility/AccessibilityObject.h:
+        (AccessibilitySearchCriteria):
+        (WebCore::AccessibilitySearchCriteria::AccessibilitySearchCriteria):
+        (AccessibilityObject):
+        * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+        (-[WebAccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]):
+
 2013-03-29  Joshua Bell  <jsbell@chromium.org>
 
         IndexedDB: Bind lifetime of in-memory backing stores to IDBFactory backend
index 2568677d31217eb4a83ed74773212a896d511c6f..37f092365625fccea614a28d1c9beb83d71ad239 100644 (file)
@@ -112,12 +112,9 @@ bool AccessibilityObject::isDetached() const
 #endif
 }
 
-bool AccessibilityObject::isAccessibilityObjectSearchMatch(AccessibilityObject* axObject, AccessibilitySearchCriteria* criteria)
+bool AccessibilityObject::isAccessibilityObjectSearchMatchAtIndex(AccessibilityObject* axObject, AccessibilitySearchCriteria* criteria, size_t index)
 {
-    if (!axObject || !criteria)
-        return false;
-    
-    switch (criteria->searchKey) {
+    switch (criteria->searchKeys[index]) {
     // The AnyTypeSearchKey matches any non-null AccessibilityObject.
     case AnyTypeSearchKey:
         return true;
@@ -249,6 +246,19 @@ bool AccessibilityObject::isAccessibilityObjectSearchMatch(AccessibilityObject*
     }
 }
 
+bool AccessibilityObject::isAccessibilityObjectSearchMatch(AccessibilityObject* axObject, AccessibilitySearchCriteria* criteria)
+{
+    if (!axObject || !criteria)
+        return false;
+    
+    size_t length = criteria->searchKeys.size();
+    for (size_t i = 0; i < length; ++i) {
+        if (isAccessibilityObjectSearchMatchAtIndex(axObject, criteria, i))
+            return true;
+    }
+    return false;
+}
+
 bool AccessibilityObject::isAccessibilityTextSearchMatch(AccessibilityObject* axObject, AccessibilitySearchCriteria* criteria)
 {
     if (!axObject || !criteria)
index 6da9bcd21ab69d5007225817f6a38b004401937c..805b333703f564b9fcaed2c4a7a4064ed885e044 100644 (file)
@@ -312,9 +312,16 @@ enum AccessibilitySearchKey {
 struct AccessibilitySearchCriteria {
     AccessibilityObject* startObject;
     AccessibilitySearchDirection searchDirection;
-    AccessibilitySearchKey searchKey;
+    Vector<AccessibilitySearchKey> searchKeys;
     String* searchText;
     unsigned resultsLimit;
+    
+    AccessibilitySearchCriteria(AccessibilityObject* o, AccessibilitySearchDirection d, String* t, unsigned l)
+    : startObject(o)
+    , searchDirection(d)
+    , searchText(t)
+    , resultsLimit(l)
+    { }
 };
 
 struct VisiblePositionRange {
@@ -848,6 +855,7 @@ protected:
     virtual ScrollableArea* getScrollableAreaIfScrollable() const { return 0; }
     virtual void scrollTo(const IntPoint&) const { }
 
+    static bool isAccessibilityObjectSearchMatchAtIndex(AccessibilityObject*, AccessibilitySearchCriteria*, size_t);
     static bool isAccessibilityObjectSearchMatch(AccessibilityObject*, AccessibilitySearchCriteria*);
     static bool isAccessibilityTextSearchMatch(AccessibilityObject*, AccessibilitySearchCriteria*);
     static bool objectMatchesSearchCriteriaWithResultLimit(AccessibilityObject*, AccessibilitySearchCriteria*, AccessibilityChildrenVector&);
index 410d9f6a8aced08c784d208b794c922cfbf4f5e6..714f5679ad3a94666f371a3145abd8bf1f70a20e 100644 (file)
@@ -3183,11 +3183,7 @@ static RenderObject* rendererForView(NSView* view)
         AccessibilitySearchDirection searchDirection = SearchDirectionNext;
         if ([[dictionary objectForKey:@"AXDirection"] isKindOfClass:[NSString self]])
             searchDirection = ([(NSString*)[dictionary objectForKey:@"AXDirection"] isEqualToString:@"AXDirectionNext"]) ? SearchDirectionNext : SearchDirectionPrevious;
-        
-        AccessibilitySearchKey searchKey = AnyTypeSearchKey;
-        if ([[dictionary objectForKey:@"AXSearchKey"] isKindOfClass:[NSString self]])
-            searchKey = accessibilitySearchKeyForString((CFStringRef)[dictionary objectForKey:@"AXSearchKey"]);
-        
+
         String searchText;
         if ([[dictionary objectForKey:@"AXSearchText"] isKindOfClass:[NSString self]])
             searchText = (CFStringRef)[dictionary objectForKey:@"AXSearchText"];
@@ -3196,7 +3192,20 @@ static RenderObject* rendererForView(NSView* view)
         if ([[dictionary objectForKey:@"AXResultsLimit"] isKindOfClass:[NSNumber self]])
             resultsLimit = [(NSNumber*)[dictionary objectForKey:@"AXResultsLimit"] unsignedIntValue];
         
-        AccessibilitySearchCriteria criteria = {startObject, searchDirection, searchKey, &searchText, resultsLimit};
+        AccessibilitySearchCriteria criteria = AccessibilitySearchCriteria(startObject, searchDirection, &searchText, resultsLimit);
+                
+        id searchKeyEntry = [dictionary objectForKey:@"AXSearchKey"];
+        if ([searchKeyEntry isKindOfClass:[NSString class]])
+            criteria.searchKeys.append(accessibilitySearchKeyForString((CFStringRef)searchKeyEntry));
+        else if ([searchKeyEntry isKindOfClass:[NSArray class]]) {
+            size_t length = static_cast<size_t>([(NSArray *)searchKeyEntry count]);
+            criteria.searchKeys.reserveInitialCapacity(length);
+            for (size_t i = 0; i < length; ++i) {
+                id searchKey = [(NSArray *)searchKeyEntry objectAtIndex:i];
+                if ([searchKey isKindOfClass:[NSString class]])
+                    criteria.searchKeys.append(accessibilitySearchKeyForString((CFStringRef)searchKey));
+            }
+        }
         
         AccessibilityObject::AccessibilityChildrenVector results;
         m_object->findMatchingObjects(&criteria, results);
index a8fb0a7ca7c99f7fce94452817c4633e9606d279..8343e9654fb14c427c6bd1ddde743a115f140aa7 100644 (file)
@@ -1,3 +1,36 @@
+2013-03-29  Greg Hughes  <ghughes@apple.com>
+
+        Allow multiple searchKeys to be passed to AXUIElementCopyParameterizedAttributeValue
+        https://bugs.webkit.org/show_bug.cgi?id=112276
+
+        Reviewed by Chris Fleizach.
+
+        Added support to test accessibility search predicates with multiple keys.  
+
+        * DumpRenderTree/AccessibilityUIElement.cpp:
+        (uiElementForSearchPredicateCallback):
+        * DumpRenderTree/AccessibilityUIElement.h:
+        (AccessibilityUIElement):
+        * DumpRenderTree/atk/AccessibilityUIElementAtk.cpp:
+        (AccessibilityUIElement::uiElementForSearchPredicate):
+        * DumpRenderTree/blackberry/AccessibilityUIElementBlackBerry.cpp:
+        (AccessibilityUIElement::uiElementForSearchPredicate):
+        * DumpRenderTree/ios/AccessibilityUIElementIOS.mm:
+        (AccessibilityUIElement::uiElementForSearchPredicate):
+        * DumpRenderTree/mac/AccessibilityUIElementMac.mm:
+        (AccessibilityUIElement::uiElementForSearchPredicate):
+        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
+        (AccessibilityUIElement::uiElementForSearchPredicate):
+        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.cpp:
+        (WTR::AccessibilityUIElement::uiElementForSearchPredicate):
+        * WebKitTestRunner/InjectedBundle/AccessibilityUIElement.h:
+        (AccessibilityUIElement):
+        * WebKitTestRunner/InjectedBundle/Bindings/AccessibilityUIElement.idl:
+        * WebKitTestRunner/InjectedBundle/atk/AccessibilityUIElementAtk.cpp:
+        (WTR::AccessibilityUIElement::uiElementForSearchPredicate):
+        * WebKitTestRunner/InjectedBundle/mac/AccessibilityUIElementMac.mm:
+        (WTR::AccessibilityUIElement::uiElementForSearchPredicate):
+
 2013-03-29  Ryosuke Niwa  <rniwa@webkit.org>
 
         Fix a typo in r147147 to fix Mac EWS.
index 9dfbc6ce585f3cdaee2259ca6dec8e32661ab959..d1f24bec4b8414ee0e6e403e851acbf6f1131e52 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #include "AccessibilityUIElement.h"
 
+#include <JavaScriptCore/JSObjectRef.h>
 #include <JavaScriptCore/JSRetainPtr.h>
 
 // Static Functions
@@ -201,22 +202,21 @@ static JSValueRef uiElementForSearchPredicateCallback(JSContextRef context, JSOb
 {
     AccessibilityUIElement* startElement = 0;
     bool isDirectionNext = true;
-    JSStringRef searchKey = 0;
+    JSValueRef searchKey = 0;
     JSStringRef searchText = 0;
     if (argumentCount == 4) {
         JSObjectRef startElementObject = JSValueToObject(context, arguments[0], exception);
         if (startElementObject)
             startElement = toAXElement(startElementObject);
-        isDirectionNext = JSValueToBoolean(context, arguments[1]);
-        if (JSValueIsString(context, arguments[2]))
-            searchKey = JSValueToStringCopy(context, arguments[2], exception);
+        isDirectionNext = JSValueToBoolean(context, arguments[1]);      
+        
+        searchKey = arguments[2];
+        
         if (JSValueIsString(context, arguments[3]))
             searchText = JSValueToStringCopy(context, arguments[3], exception);
     }
-    
-    JSObjectRef resultObject = AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText));
-    if (searchKey)
-        JSStringRelease(searchKey);
+    JSObjectRef resultObject = AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->uiElementForSearchPredicate(context, startElement, isDirectionNext, searchKey, searchText));
+
     if (searchText)
         JSStringRelease(searchText);
     
index 794a15df6518f7e718e901410cba4fa1d0e6a8d6..03b56697514d5a2f496001ea315ee9ab5d3e3e67 100644 (file)
@@ -199,7 +199,7 @@ public:
     JSStringRef stringForRange(unsigned location, unsigned length);
     JSStringRef attributedStringForRange(unsigned location, unsigned length);
     bool attributedStringRangeIsMisspelled(unsigned location, unsigned length);
-    AccessibilityUIElement uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText);
+    AccessibilityUIElement uiElementForSearchPredicate(JSContextRef, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText);
 #if PLATFORM(IOS)
     void elementsForRange(unsigned location, unsigned length, Vector<AccessibilityUIElement>& elements);
     JSStringRef stringForSelection();
index 00157231ea193b1f14c3bf8de6a6981b20a72312..10e37670208f25b21e0bad3d43eb36aa3ccdb3d5 100644 (file)
@@ -773,7 +773,7 @@ bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location
     return false;
 }
 
-AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText)
+AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText)
 {
     // FIXME: implement
     return 0;
index bd34782a39f96c38c2ef8fa493120048d64c62a7..2bf7d12d1ac09d71f8356b0808c80001570e023a 100644 (file)
@@ -361,7 +361,7 @@ JSStringRef AccessibilityUIElement::stringForRange(unsigned, unsigned)
     return 0;
 }
 
-AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement*, bool, JSStringRef, JSStringRef)
+AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef, AccessibilityUIElement*, bool, JSValueRef, JSStringRef)
 {
     notImplemented();
     return 0;
index 0f0fa494476f13d399c7aa727d1f837b91fc9015..66ee09fc7c855d53112c56d644d0fdba7e6f1117 100644 (file)
@@ -754,7 +754,7 @@ void AccessibilityUIElement::removeSelection()
     // FIXME: implement
 }
 
-AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText)
+AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText)
 {
     // FIXME: implement
     return 0;
index 63a6bd900f4a423179b927c8419ff90fced106fe..168038e42c979ea52ce206756bce1949714017fb 100644 (file)
@@ -908,7 +908,7 @@ bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location
     return false;
 }
 
-AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText)
+AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSMutableDictionary* parameter = [NSMutableDictionary dictionary];
@@ -916,9 +916,46 @@ AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(Acces
     [parameter setObject:[NSNumber numberWithInt:1] forKey:@"AXResultsLimit"];
     if (startElement && startElement->platformUIElement())
         [parameter setObject:(id)startElement->platformUIElement() forKey:@"AXStartElement"];
-    if (searchKey)
-        [parameter setObject:[NSString stringWithJSStringRef:searchKey] forKey:@"AXSearchKey"];
-    if (searchText)
+    if (searchKey) {
+        if (JSValueIsString(context, searchKey)) {
+            NSString *searchKeyParameter = nil;
+            JSStringRef singleSearchKey = JSValueToStringCopy(context, searchKey, 0);
+            if (singleSearchKey) {
+                searchKeyParameter = [NSString stringWithJSStringRef:singleSearchKey];
+                JSStringRelease(singleSearchKey);
+                if (searchKeyParameter)
+                    [parameter setObject:searchKeyParameter forKey:@"AXSearchKey"];
+            }
+        }
+        else if (JSValueIsObject(context, searchKey)) {
+            NSMutableArray *searchKeyParameter = nil;
+            JSObjectRef array = const_cast<JSObjectRef>(searchKey);
+            unsigned arrayLength = 0;
+            JSRetainPtr<JSStringRef> arrayLengthString(Adopt, JSStringCreateWithUTF8CString("length"));
+            JSValueRef arrayLengthValue = JSObjectGetProperty(context, array, arrayLengthString.get(), 0);
+            if (arrayLengthValue && JSValueIsNumber(context, arrayLengthValue))
+                arrayLength = static_cast<unsigned>(JSValueToNumber(context, arrayLengthValue, 0));
+            
+            for (unsigned i = 0; i < arrayLength; ++i) {
+                JSValueRef exception = 0;
+                JSValueRef value = JSObjectGetPropertyAtIndex(context, array, i, &exception);
+                if (exception)
+                    break;
+                JSStringRef singleSearchKey = JSValueToStringCopy(context, value, &exception);
+                if (exception)
+                    break;
+                if (singleSearchKey) {
+                    if (!searchKeyParameter)
+                        searchKeyParameter = [NSMutableArray array];
+                    [searchKeyParameter addObject:[NSString stringWithJSStringRef:singleSearchKey]];
+                    JSStringRelease(singleSearchKey);
+                }
+            }
+            if (searchKeyParameter)
+                [parameter setObject:searchKeyParameter forKey:@"AXSearchKey"];
+        }
+    }
+    if (searchText && JSStringGetLength(searchText))
         [parameter setObject:[NSString stringWithJSStringRef:searchText] forKey:@"AXSearchText"];
     
     id uiElement = [[m_element accessibilityAttributeValue:@"AXUIElementsForSearchPredicate" forParameter:parameter] lastObject];
index 973ba890f52a44dae8f3c76aea4473e872a363db..a26c1b0746f9b2a941992ac80fdfcee0b70c0b03 100644 (file)
@@ -498,7 +498,7 @@ bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned, unsigne
     return false;
 }
 
-AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText)
+AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText)
 {
     return 0;
 }
index f03fd4fdd4f95aeff176d3dfa18e0ed1d85881ce..1c23a6352d8818972574e420c635242187ab3026 100644 (file)
@@ -159,7 +159,7 @@ void AccessibilityUIElement::setSelectedTextRange(unsigned, unsigned) { }
 JSRetainPtr<JSStringRef> AccessibilityUIElement::stringForRange(unsigned, unsigned) { return 0; }
 JSRetainPtr<JSStringRef> AccessibilityUIElement::attributedStringForRange(unsigned, unsigned) { return 0; }
 bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned, unsigned) { return false; }
-PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement*, bool, JSStringRef, JSStringRef) { return 0; }
+PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef, AccessibilityUIElement*, bool, JSValueRef, JSStringRef) { return 0; }
 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::cellForColumnAndRow(unsigned, unsigned) { return 0; }
 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::horizontalScrollbar() const { return 0; }
 PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::verticalScrollbar() const { return 0; }
index 43c4180c2831547c1ecc2396fd23ca05fe8ad5ff..0da3fc7ac20430f82e78bf506f3b3fdb93fe161a 100644 (file)
@@ -202,7 +202,7 @@ public:
     JSRetainPtr<JSStringRef> stringForRange(unsigned location, unsigned length);
     JSRetainPtr<JSStringRef> attributedStringForRange(unsigned location, unsigned length);
     bool attributedStringRangeIsMisspelled(unsigned location, unsigned length);
-    PassRefPtr<AccessibilityUIElement> uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText);
+    PassRefPtr<AccessibilityUIElement> uiElementForSearchPredicate(JSContextRef, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText);
     
     // Table-specific
     PassRefPtr<AccessibilityUIElement> cellForColumnAndRow(unsigned column, unsigned row);
index 44253e317e968f60e66237dd62c6ce0f58a03282..546ec5bf7206c8abf2eecd5e9ca84ab5fa9c805e 100644 (file)
@@ -141,7 +141,7 @@ interface AccessibilityUIElement {
     DOMString stringForRange(in unsigned long location, in unsigned long length);
     DOMString attributedStringForRange(in unsigned long location, in unsigned long length);
     boolean attributedStringRangeIsMisspelled(in unsigned long location, in unsigned long length);
-    AccessibilityUIElement uiElementForSearchPredicate(in AccessibilityUIElement startElement, in boolean isDirectionNext, in DOMString searchKey, in DOMString searchText);
+    [PassContext] AccessibilityUIElement uiElementForSearchPredicate(in AccessibilityUIElement startElement, in boolean isDirectionNext, in object searchKey, in DOMString searchText);
     void setSelectedTextRange(in unsigned long location, in unsigned long length);
 
     // Scroll area attributes.
index 361d11b91a7676b0d309fc29e40f32c87bd936f9..4eea312c81dbbb6aaae3d067b6b942a0518ed9fb 100644 (file)
@@ -801,7 +801,7 @@ bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location
     return false;
 }
 
-PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText)
+PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText)
 {
     // FIXME: implement
     return 0;
index ec0bd3058a8f0e6b0bade002d5802f65f123a76d..1aab6e490c62aff5e67bcd0bfec941199ff483ff 100644 (file)
@@ -35,6 +35,7 @@
 #import <JavaScriptCore/JSRetainPtr.h>
 #import <JavaScriptCore/JSStringRef.h>
 #import <JavaScriptCore/JSStringRefCF.h>
+#import <JavaScriptCore/JSObjectRef.h>
 #import <WebKit2/WKBundleFrame.h>
 #import <wtf/RetainPtr.h>
 #import <wtf/Vector.h>
@@ -917,7 +918,7 @@ bool AccessibilityUIElement::attributedStringRangeIsMisspelled(unsigned location
     return false;
 }
 
-PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText)
+PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPredicate(JSContextRef context, AccessibilityUIElement* startElement, bool isDirectionNext, JSValueRef searchKey, JSStringRef searchText)
 {
     BEGIN_AX_OBJC_EXCEPTIONS
     NSMutableDictionary* parameter = [NSMutableDictionary dictionary];
@@ -925,8 +926,45 @@ PassRefPtr<AccessibilityUIElement> AccessibilityUIElement::uiElementForSearchPre
     [parameter setObject:[NSNumber numberWithInt:1] forKey:@"AXResultsLimit"];
     if (startElement && startElement->platformUIElement())
         [parameter setObject:(id)startElement->platformUIElement() forKey:@"AXStartElement"];
-    if (searchKey)
-        [parameter setObject:[NSString stringWithJSStringRef:searchKey] forKey:@"AXSearchKey"];
+    if (searchKey) {
+        if (JSValueIsString(context, searchKey)) {
+            NSString *searchKeyParameter = nil;
+            JSStringRef singleSearchKey = JSValueToStringCopy(context, searchKey, 0);
+            if (singleSearchKey) {
+                searchKeyParameter = [NSString stringWithJSStringRef:singleSearchKey];
+                JSStringRelease(singleSearchKey);
+                if (searchKeyParameter)
+                    [parameter setObject:searchKeyParameter forKey:@"AXSearchKey"];
+            }
+        }
+        else if (JSValueIsObject(context, searchKey)) {
+            NSMutableArray *searchKeyParameter = nil;
+            JSObjectRef array = const_cast<JSObjectRef>(searchKey);
+            unsigned arrayLength = 0;
+            JSRetainPtr<JSStringRef> arrayLengthString(Adopt, JSStringCreateWithUTF8CString("length"));
+            JSValueRef arrayLengthValue = JSObjectGetProperty(context, array, arrayLengthString.get(), 0);
+            if (arrayLengthValue && JSValueIsNumber(context, arrayLengthValue))
+                arrayLength = static_cast<unsigned>(JSValueToNumber(context, arrayLengthValue, 0));
+            
+            for (unsigned i = 0; i < arrayLength; ++i) {
+                JSValueRef exception = 0;
+                JSValueRef value = JSObjectGetPropertyAtIndex(context, array, i, &exception);
+                if (exception)
+                    break;
+                JSStringRef singleSearchKey = JSValueToStringCopy(context, value, &exception);
+                if (exception)
+                    break;
+                if (singleSearchKey) {
+                    if (!searchKeyParameter)
+                        searchKeyParameter = [NSMutableArray array];
+                    [searchKeyParameter addObject:[NSString stringWithJSStringRef:singleSearchKey]];
+                    JSStringRelease(singleSearchKey);
+                }
+            }
+            if (searchKeyParameter)
+                [parameter setObject:searchKeyParameter forKey:@"AXSearchKey"];
+        }
+    }
     if (searchText && JSStringGetLength(searchText))
         [parameter setObject:[NSString stringWithJSStringRef:searchText] forKey:@"AXSearchText"];