Changeset 92571 in webkit
- Timestamp:
- Aug 7, 2011 2:48:04 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r92570 r92571 1 2011-08-07 Sam White <samuel.white@rochester.edu> 2 3 Add the ability to search the AccessibilityObject cache 4 https://bugs.webkit.org/show_bug.cgi?id=64994 5 6 Tests for the new AccessibilityObject cache search API and the additional 7 functionality in the AccessibilityObject class that makes AccessibilityObject 8 cache searching possible. 9 10 Additional tests for finding frames, misspellings, and visited links will be 11 included in a subsequent patch. 12 13 Reviewed by Chris Fleizach. 14 15 * platform/mac/accessibility/bounds-for-range-expected.txt: 16 * platform/mac/accessibility/search-predicate-expected.txt: Added. 17 * platform/mac/accessibility/search-predicate.html: Added. 18 1 19 2011-08-07 Martin Robinson <mrobinson@igalia.com> 2 20 -
trunk/LayoutTests/platform/mac/accessibility/bounds-for-range-expected.txt
r47076 r92571 52 52 AXBoundsForRange 53 53 AXStringForRange 54 AXUIElementsForSearchPredicate 54 55 55 56 ---------------------- -
trunk/Source/WebCore/ChangeLog
r92567 r92571 1 2011-08-07 Sam White <samuel.white@rochester.edu> 2 3 Add the ability to search the AccessibilityObject cache 4 https://bugs.webkit.org/show_bug.cgi?id=64994 5 6 New AccessibilityObject cache search functionality and API for the mac 7 platform to expose it. At this point the AccessibilityObject cache can 8 be searched using one of the supported search keys that have been defined 9 in AccessibilityObject.h, or by passing search text. 10 11 Reviewed by Chris Fleizach. 12 13 Test: platform/mac/accessibility/search-predicate.html 14 15 * accessibility/AccessibilityObject.cpp: 16 (WebCore::AccessibilityObject::isAccessibilityObjectSearchMatch): 17 (WebCore::AccessibilityObject::isAccessibilityTextSearchMatch): 18 (WebCore::AccessibilityObject::accessibilityObjectContainsText): 19 (WebCore::AccessibilityObject::accessibleObjectsWithAccessibilitySearchPredicate): 20 * accessibility/AccessibilityObject.h: 21 * accessibility/mac/AccessibilityObjectWrapper.mm: 22 (createAccessibilitySearchKeyMap): 23 (accessibilitySearchKeyForString): 24 (-[AccessibilityObjectWrapper accessibilityParameterizedAttributeNames]): 25 (-[AccessibilityObjectWrapper accessibilityAttributeValue:forParameter:]): 26 1 27 2011-08-06 Mark Rowe <mrowe@apple.com> 2 28 -
trunk/Source/WebCore/accessibility/AccessibilityObject.cpp
r92451 r92571 88 88 } 89 89 90 bool AccessibilityObject::isAccessibilityObjectSearchMatch(AccessibilityObject* axObject, AccessibilitySearchPredicate* axSearchPredicate) 91 { 92 if (!axObject || !axSearchPredicate) 93 return false; 94 95 switch (axSearchPredicate->axSearchKey) { 96 // The AnyTypeSearchKey matches any non-null AccessibilityObject. 97 case AnyTypeSearchKey: 98 return true; 99 100 case BlockquoteSameLevelSearchKey: 101 return axSearchPredicate->axStartObject 102 && axObject->isBlockquote() 103 && axObject->blockquoteLevel() == axSearchPredicate->axStartObject->blockquoteLevel(); 104 105 case BlockquoteSearchKey: 106 return axObject->isBlockquote(); 107 108 case BoldFontSearchKey: 109 return axObject->hasBoldFont(); 110 111 case ButtonSearchKey: 112 return axObject->isButton(); 113 114 case CheckBoxSearchKey: 115 return axObject->isCheckbox(); 116 117 case ControlSearchKey: 118 return axObject->isControl(); 119 120 case DifferentTypeSearchKey: 121 return axSearchPredicate->axStartObject 122 && axObject->roleValue() != axSearchPredicate->axStartObject->roleValue(); 123 124 case FontChangeSearchKey: 125 return axSearchPredicate->axStartObject 126 && !axObject->hasSameFont(axSearchPredicate->axStartObject->renderer()); 127 128 case FontColorChangeSearchKey: 129 return axSearchPredicate->axStartObject 130 && !axObject->hasSameFontColor(axSearchPredicate->axStartObject->renderer()); 131 132 // FIXME: Handle this search key. 133 case FrameSearchKey: 134 return false; 135 136 case GraphicSearchKey: 137 return axObject->isImage(); 138 139 case HeadingLevel1SearchKey: 140 return axObject->headingLevel() == 1; 141 142 case HeadingLevel2SearchKey: 143 return axObject->headingLevel() == 2; 144 145 case HeadingLevel3SearchKey: 146 return axObject->headingLevel() == 3; 147 148 case HeadingLevel4SearchKey: 149 return axObject->headingLevel() == 4; 150 151 case HeadingLevel5SearchKey: 152 return axObject->headingLevel() == 5; 153 154 case HeadingLevel6SearchKey: 155 return axObject->headingLevel() == 6; 156 157 case HeadingSameLevelSearchKey: 158 return axSearchPredicate->axStartObject 159 && axObject->isHeading() 160 && axObject->headingLevel() == axSearchPredicate->axStartObject->headingLevel(); 161 162 case HeadingSearchKey: 163 return axObject->isHeading(); 164 165 case ItalicFontSearchKey: 166 return axObject->hasItalicFont(); 167 168 case LandmarkSearchKey: 169 return axObject->isLandmark(); 170 171 case LinkSearchKey: 172 return axObject->isLink(); 173 174 case ListSearchKey: 175 return axObject->isList(); 176 177 case LiveRegionSearchKey: 178 return axObject->supportsARIALiveRegion(); 179 180 case MisspelledWordSearchKey: 181 return axObject->hasMisspelling(); 182 183 case PlainTextSearchKey: 184 return axObject->hasPlainText(); 185 186 case RadioGroupSearchKey: 187 return axObject->isRadioGroup(); 188 189 case SameTypeSearchKey: 190 return axSearchPredicate->axStartObject 191 && axObject->roleValue() == axSearchPredicate->axStartObject->roleValue(); 192 193 case StaticTextSearchKey: 194 return axObject->hasStaticText(); 195 196 case StyleChangeSearchKey: 197 return axSearchPredicate->axStartObject 198 && !axObject->hasSameStyle(axSearchPredicate->axStartObject->renderer()); 199 200 case TableSameLevelSearchKey: 201 return axSearchPredicate->axStartObject 202 && axObject->isAccessibilityTable() 203 && axObject->tableLevel() == axSearchPredicate->axStartObject->tableLevel(); 204 205 case TableSearchKey: 206 return axObject->isAccessibilityTable(); 207 208 case TextFieldSearchKey: 209 return axObject->isTextControl(); 210 211 case UnderlineSearchKey: 212 return axObject->hasUnderline(); 213 214 case UnvisitedLinkSearchKey: 215 return axObject->isUnvisited(); 216 217 case VisitedLinkSearchKey: 218 return axObject->isVisited(); 219 220 default: 221 return false; 222 } 223 } 224 225 bool AccessibilityObject::isAccessibilityTextSearchMatch(AccessibilityObject* axObject, AccessibilitySearchPredicate* axSearchPredicate) 226 { 227 if (!axObject || !axSearchPredicate) 228 return false; 229 230 return axObject->accessibilityObjectContainsText(axSearchPredicate->searchText); 231 } 232 233 bool AccessibilityObject::accessibilityObjectContainsText(String* text) const 234 { 235 // If text is null or empty we return true. 236 return !text 237 || text->isEmpty() 238 || title().contains(*text, false) 239 || accessibilityDescription().contains(*text, false) 240 || stringValue().contains(*text, false); 241 } 242 90 243 bool AccessibilityObject::isBlockquote() const 91 244 { … … 194 347 195 348 return accessibleObject; 349 } 350 351 void AccessibilityObject::accessibleObjectsWithAccessibilitySearchPredicate(AccessibilitySearchPredicate* axSearchPredicate, AccessibilityChildrenVector& axResults) 352 { 353 ASSERT(AXObjectCache::accessibilityEnabled()); 354 355 if (!axSearchPredicate) 356 return; 357 358 AccessibilityChildrenVector axChildren; 359 if (axSearchPredicate->axContainerObject) 360 axChildren.append(axSearchPredicate->axContainerObject); 361 362 bool isSearchDirectionNext = (axSearchPredicate->axSearchDirection == SearchDirectionNext); 363 bool didFindAXStartObject = (!axSearchPredicate->axStartObject); 364 365 // FIXME: Iterate the AccessibilityObject cache creating and adding objects if nessesary. 366 while (!axChildren.isEmpty() && axResults.size() < axSearchPredicate->resultsLimit) { 367 AccessibilityObject* axChild = axChildren.last().get(); 368 axChildren.removeLast(); 369 370 if (didFindAXStartObject) { 371 if (isAccessibilityObjectSearchMatch(axChild, axSearchPredicate) 372 && isAccessibilityTextSearchMatch(axChild, axSearchPredicate)) 373 axResults.append(axChild); 374 } else if (axChild == axSearchPredicate->axStartObject) 375 didFindAXStartObject = true; 376 377 AccessibilityChildrenVector axGrandchildren = axChild->children(); 378 unsigned axGrandchildrenSize = axChild->children().size(); 379 for (unsigned i = (isSearchDirectionNext) ? axGrandchildrenSize : 0; (isSearchDirectionNext) ? i > 0 : i < axGrandchildrenSize; (isSearchDirectionNext) ? i-- : i++) 380 // FIXME: Handle attachments. 381 axChildren.append(axGrandchildren.at((isSearchDirectionNext) ? i - 1 : i).get()); 382 } 196 383 } 197 384 -
trunk/Source/WebCore/accessibility/AccessibilityObject.h
r92000 r92571 76 76 namespace WebCore { 77 77 78 class AccessibilityObject; 78 79 class AXObjectCache; 79 80 class Element; … … 218 219 }; 219 220 221 enum AccessibilitySearchDirection { 222 SearchDirectionNext = 1, 223 SearchDirectionPrevious 224 }; 225 226 enum AccessibilitySearchKey { 227 AnyTypeSearchKey = 1, 228 BlockquoteSameLevelSearchKey, 229 BlockquoteSearchKey, 230 BoldFontSearchKey, 231 ButtonSearchKey, 232 CheckBoxSearchKey, 233 ControlSearchKey, 234 DifferentTypeSearchKey, 235 FontChangeSearchKey, 236 FontColorChangeSearchKey, 237 FrameSearchKey, 238 GraphicSearchKey, 239 HeadingLevel1SearchKey, 240 HeadingLevel2SearchKey, 241 HeadingLevel3SearchKey, 242 HeadingLevel4SearchKey, 243 HeadingLevel5SearchKey, 244 HeadingLevel6SearchKey, 245 HeadingSameLevelSearchKey, 246 HeadingSearchKey, 247 ItalicFontSearchKey, 248 LandmarkSearchKey, 249 LinkSearchKey, 250 ListSearchKey, 251 LiveRegionSearchKey, 252 MisspelledWordSearchKey, 253 PlainTextSearchKey, 254 RadioGroupSearchKey, 255 SameTypeSearchKey, 256 StaticTextSearchKey, 257 StyleChangeSearchKey, 258 TableSameLevelSearchKey, 259 TableSearchKey, 260 TextFieldSearchKey, 261 UnderlineSearchKey, 262 UnvisitedLinkSearchKey, 263 VisitedLinkSearchKey 264 }; 265 266 struct AccessibilitySearchPredicate { 267 AccessibilityObject* axContainerObject; 268 AccessibilityObject* axStartObject; 269 AccessibilitySearchDirection axSearchDirection; 270 AccessibilitySearchKey axSearchKey; 271 String* searchText; 272 unsigned resultsLimit; 273 }; 274 220 275 struct VisiblePositionRange { 221 276 … … 254 309 protected: 255 310 AccessibilityObject(); 311 312 // Should only be called by accessibleObjectsWithAccessibilitySearchPredicate for AccessibilityObject searching. 313 static bool isAccessibilityObjectSearchMatch(AccessibilityObject*, AccessibilitySearchPredicate*); 314 static bool isAccessibilityTextSearchMatch(AccessibilityObject*, AccessibilitySearchPredicate*); 256 315 public: 257 316 virtual ~AccessibilityObject(); … … 263 322 virtual bool isAccessibilityScrollbar() const { return false; } 264 323 virtual bool isAccessibilityScrollView() const { return false; } 324 325 bool accessibilityObjectContainsText(String *) const; 265 326 266 327 virtual bool isAnchor() const { return false; } … … 409 470 virtual AccessibilityObject* parentObjectIfExists() const { return 0; } 410 471 static AccessibilityObject* firstAccessibleObjectFromNode(const Node*); 472 static void accessibleObjectsWithAccessibilitySearchPredicate(AccessibilitySearchPredicate*, AccessibilityChildrenVector&); 411 473 412 474 virtual AccessibilityObject* observableObject() const { return 0; } -
trunk/Source/WebCore/accessibility/mac/AccessibilityObjectWrapper.mm
r92000 r92571 172 172 #endif 173 173 174 // Search 175 #ifndef NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute 176 #define NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute @"AXUIElementsForSearchPredicate" 177 #endif 178 179 // Search Keys 180 #ifndef NSAccessibilityAnyTypeSearchKey 181 #define NSAccessibilityAnyTypeSearchKey @"AXAnyTypeSearchKey" 182 #endif 183 184 #ifndef NSAccessibilityBlockquoteSameLevelSearchKey 185 #define NSAccessibilityBlockquoteSameLevelSearchKey @"AXBlockquoteSameLevelSearchKey" 186 #endif 187 188 #ifndef NSAccessibilityBlockquoteSearchKey 189 #define NSAccessibilityBlockquoteSearchKey @"AXBlockquoteSearchKey" 190 #endif 191 192 #ifndef NSAccessibilityBoldFontSearchKey 193 #define NSAccessibilityBoldFontSearchKey @"AXBoldFontSearchKey" 194 #endif 195 196 #ifndef NSAccessibilityButtonSearchKey 197 #define NSAccessibilityButtonSearchKey @"AXButtonSearchKey" 198 #endif 199 200 #ifndef NSAccessibilityCheckBoxSearchKey 201 #define NSAccessibilityCheckBoxSearchKey @"AXCheckBoxSearchKey" 202 #endif 203 204 #ifndef NSAccessibilityControlSearchKey 205 #define NSAccessibilityControlSearchKey @"AXControlSearchKey" 206 #endif 207 208 #ifndef NSAccessibilityDifferentTypeSearchKey 209 #define NSAccessibilityDifferentTypeSearchKey @"AXDifferentTypeSearchKey" 210 #endif 211 212 #ifndef NSAccessibilityFontChangeSearchKey 213 #define NSAccessibilityFontChangeSearchKey @"AXFontChangeSearchKey" 214 #endif 215 216 #ifndef NSAccessibilityFontColorChangeSearchKey 217 #define NSAccessibilityFontColorChangeSearchKey @"AXFontColorChangeSearchKey" 218 #endif 219 220 #ifndef NSAccessibilityFrameSearchKey 221 #define NSAccessibilityFrameSearchKey @"AXFrameSearchKey" 222 #endif 223 224 #ifndef NSAccessibilityGraphicSearchKey 225 #define NSAccessibilityGraphicSearchKey @"AXGraphicSearchKey" 226 #endif 227 228 #ifndef NSAccessibilityHeadingLevel1SearchKey 229 #define NSAccessibilityHeadingLevel1SearchKey @"AXHeadingLevel1SearchKey" 230 #endif 231 232 #ifndef NSAccessibilityHeadingLevel2SearchKey 233 #define NSAccessibilityHeadingLevel2SearchKey @"AXHeadingLevel2SearchKey" 234 #endif 235 236 #ifndef NSAccessibilityHeadingLevel3SearchKey 237 #define NSAccessibilityHeadingLevel3SearchKey @"AXHeadingLevel3SearchKey" 238 #endif 239 240 #ifndef NSAccessibilityHeadingLevel4SearchKey 241 #define NSAccessibilityHeadingLevel4SearchKey @"AXHeadingLevel4SearchKey" 242 #endif 243 244 #ifndef NSAccessibilityHeadingLevel5SearchKey 245 #define NSAccessibilityHeadingLevel5SearchKey @"AXHeadingLevel5SearchKey" 246 #endif 247 248 #ifndef NSAccessibilityHeadingLevel6SearchKey 249 #define NSAccessibilityHeadingLevel6SearchKey @"AXHeadingLevel6SearchKey" 250 #endif 251 252 #ifndef NSAccessibilityHeadingSameLevelSearchKey 253 #define NSAccessibilityHeadingSameLevelSearchKey @"AXHeadingSameLevelSearchKey" 254 #endif 255 256 #ifndef NSAccessibilityHeadingSearchKey 257 #define NSAccessibilityHeadingSearchKey @"AXHeadingSearchKey" 258 #endif 259 260 #ifndef NSAccessibilityItalicFontSearchKey 261 #define NSAccessibilityItalicFontSearchKey @"AXItalicFontSearchKey" 262 #endif 263 264 #ifndef NSAccessibilityLandmarkSearchKey 265 #define NSAccessibilityLandmarkSearchKey @"AXLandmarkSearchKey" 266 #endif 267 268 #ifndef NSAccessibilityLinkSearchKey 269 #define NSAccessibilityLinkSearchKey @"AXLinkSearchKey" 270 #endif 271 272 #ifndef NSAccessibilityListSearchKey 273 #define NSAccessibilityListSearchKey @"AXListSearchKey" 274 #endif 275 276 #ifndef NSAccessibilityLiveRegionSearchKey 277 #define NSAccessibilityLiveRegionSearchKey @"AXLiveRegionSearchKey" 278 #endif 279 280 #ifndef NSAccessibilityMisspelledWordSearchKey 281 #define NSAccessibilityMisspelledWordSearchKey @"AXMisspelledWordSearchKey" 282 #endif 283 284 #ifndef NSAccessibilityPlainTextSearchKey 285 #define NSAccessibilityPlainTextSearchKey @"AXPlainTextSearchKey" 286 #endif 287 288 #ifndef NSAccessibilityRadioGroupSearchKey 289 #define NSAccessibilityRadioGroupSearchKey @"AXRadioGroupSearchKey" 290 #endif 291 292 #ifndef NSAccessibilitySameTypeSearchKey 293 #define NSAccessibilitySameTypeSearchKey @"AXSameTypeSearchKey" 294 #endif 295 296 #ifndef NSAccessibilityStaticTextSearchKey 297 #define NSAccessibilityStaticTextSearchKey @"AXStaticTextSearchKey" 298 #endif 299 300 #ifndef NSAccessibilityStyleChangeSearchKey 301 #define NSAccessibilityStyleChangeSearchKey @"AXStyleChangeSearchKey" 302 #endif 303 304 #ifndef NSAccessibilityTableSameLevelSearchKey 305 #define NSAccessibilityTableSameLevelSearchKey @"AXTableSameLevelSearchKey" 306 #endif 307 308 #ifndef NSAccessibilityTableSearchKey 309 #define NSAccessibilityTableSearchKey @"AXTableSearchKey" 310 #endif 311 312 #ifndef NSAccessibilityTextFieldSearchKey 313 #define NSAccessibilityTextFieldSearchKey @"AXTextFieldSearchKey" 314 #endif 315 316 #ifndef NSAccessibilityUnderlineSearchKey 317 #define NSAccessibilityUnderlineSearchKey @"AXUnderlineSearchKey" 318 #endif 319 320 #ifndef NSAccessibilityUnvisitedLinkSearchKey 321 #define NSAccessibilityUnvisitedLinkSearchKey @"AXUnvisitedLinkSearchKey" 322 #endif 323 324 #ifndef NSAccessibilityVisitedLinkSearchKey 325 #define NSAccessibilityVisitedLinkSearchKey @"AXVisitedLinkSearchKey" 326 #endif 327 174 328 175 329 @interface NSObject (WebKitAccessibilityArrayCategory) … … 277 431 ASSERT(CFGetTypeID(range) == wkGetAXTextMarkerRangeTypeID()); 278 432 return CFAutoreleaseHelper(wkCopyAXTextMarkerRangeEnd(range)); 433 } 434 435 #pragma mark Search helpers 436 437 typedef HashMap<String, AccessibilitySearchKey> AccessibilitySearchKeyMap; 438 439 struct SearchKeyEntry { 440 String key; 441 AccessibilitySearchKey value; 442 }; 443 444 static AccessibilitySearchKeyMap* createAccessibilitySearchKeyMap() 445 { 446 const SearchKeyEntry searchKeys[] = { 447 { NSAccessibilityAnyTypeSearchKey, AnyTypeSearchKey }, 448 { NSAccessibilityBlockquoteSameLevelSearchKey, BlockquoteSameLevelSearchKey }, 449 { NSAccessibilityBlockquoteSearchKey, BlockquoteSearchKey }, 450 { NSAccessibilityBoldFontSearchKey, BoldFontSearchKey }, 451 { NSAccessibilityButtonSearchKey, ButtonSearchKey }, 452 { NSAccessibilityCheckBoxSearchKey, CheckBoxSearchKey }, 453 { NSAccessibilityControlSearchKey, ControlSearchKey }, 454 { NSAccessibilityDifferentTypeSearchKey, DifferentTypeSearchKey }, 455 { NSAccessibilityFontChangeSearchKey, FontChangeSearchKey }, 456 { NSAccessibilityFontColorChangeSearchKey, FontColorChangeSearchKey }, 457 { NSAccessibilityFrameSearchKey, FrameSearchKey }, 458 { NSAccessibilityGraphicSearchKey, GraphicSearchKey }, 459 { NSAccessibilityHeadingLevel1SearchKey, HeadingLevel1SearchKey }, 460 { NSAccessibilityHeadingLevel2SearchKey, HeadingLevel2SearchKey }, 461 { NSAccessibilityHeadingLevel3SearchKey, HeadingLevel3SearchKey }, 462 { NSAccessibilityHeadingLevel4SearchKey, HeadingLevel4SearchKey }, 463 { NSAccessibilityHeadingLevel5SearchKey, HeadingLevel5SearchKey }, 464 { NSAccessibilityHeadingLevel6SearchKey, HeadingLevel6SearchKey }, 465 { NSAccessibilityHeadingSameLevelSearchKey, HeadingSameLevelSearchKey }, 466 { NSAccessibilityHeadingSearchKey, HeadingSearchKey }, 467 { NSAccessibilityItalicFontSearchKey, ItalicFontSearchKey }, 468 { NSAccessibilityLandmarkSearchKey, LandmarkSearchKey }, 469 { NSAccessibilityLinkSearchKey, LinkSearchKey }, 470 { NSAccessibilityListSearchKey, ListSearchKey }, 471 { NSAccessibilityLiveRegionSearchKey, LiveRegionSearchKey }, 472 { NSAccessibilityMisspelledWordSearchKey, MisspelledWordSearchKey }, 473 { NSAccessibilityPlainTextSearchKey, PlainTextSearchKey }, 474 { NSAccessibilityRadioGroupSearchKey, RadioGroupSearchKey }, 475 { NSAccessibilitySameTypeSearchKey, SameTypeSearchKey }, 476 { NSAccessibilityStaticTextSearchKey, StaticTextSearchKey }, 477 { NSAccessibilityStyleChangeSearchKey, StyleChangeSearchKey }, 478 { NSAccessibilityTableSameLevelSearchKey, TableSameLevelSearchKey }, 479 { NSAccessibilityTableSearchKey, TableSearchKey }, 480 { NSAccessibilityTextFieldSearchKey, TextFieldSearchKey }, 481 { NSAccessibilityUnderlineSearchKey, UnderlineSearchKey }, 482 { NSAccessibilityUnvisitedLinkSearchKey, UnvisitedLinkSearchKey }, 483 { NSAccessibilityVisitedLinkSearchKey, VisitedLinkSearchKey } 484 }; 485 486 AccessibilitySearchKeyMap* searchKeyMap = new AccessibilitySearchKeyMap; 487 for (size_t i = 0; i < WTF_ARRAY_LENGTH(searchKeys); i++) 488 searchKeyMap->set(searchKeys[i].key, searchKeys[i].value); 489 490 return searchKeyMap; 491 } 492 493 static AccessibilitySearchKey accessibilitySearchKeyForString(const String& value) 494 { 495 ASSERT(!value.isEmpty()); 496 497 static const AccessibilitySearchKeyMap* searchKeyMap = createAccessibilitySearchKeyMap(); 498 499 AccessibilitySearchKey searchKey = searchKeyMap->get(value); 500 501 return searchKey ? searchKey : AnyTypeSearchKey; 279 502 } 280 503 … … 2242 2465 NSAccessibilityBoundsForRangeParameterizedAttribute, 2243 2466 NSAccessibilityStringForRangeParameterizedAttribute, 2467 NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute, 2244 2468 nil]; 2245 2469 } … … 2493 2717 NSNumber* number = nil; 2494 2718 NSArray* array = nil; 2719 NSDictionary* dictionary = nil; 2495 2720 RefPtr<AccessibilityObject> uiElement = 0; 2496 2721 NSPoint point = NSZeroPoint; … … 2523 2748 else if ([parameter isKindOfClass:[NSArray self]]) 2524 2749 array = parameter; 2750 2751 else if ([parameter isKindOfClass:[NSDictionary self]]) 2752 dictionary = parameter; 2525 2753 2526 2754 else if ([parameter isKindOfClass:[NSValue self]] && strcmp([(NSValue*)parameter objCType], @encode(NSPoint)) == 0) { … … 2537 2765 2538 2766 // dispatch 2767 if ([attribute isEqualToString:NSAccessibilityUIElementsForSearchPredicateParameterizedAttribute]) { 2768 AccessibilityObject* axStartObject = 0; 2769 if ([[dictionary objectForKey:@"AXStartElement"] isKindOfClass:[AccessibilityObjectWrapper self]]) 2770 axStartObject = [(AccessibilityObjectWrapper*)[dictionary objectForKey:@"AXStartElement"] accessibilityObject]; 2771 2772 AccessibilitySearchDirection axSearchDirection = SearchDirectionNext; 2773 if ([[dictionary objectForKey:@"AXDirection"] isKindOfClass:[NSString self]]) 2774 axSearchDirection = ([(NSString*)[dictionary objectForKey:@"AXDirection"] isEqualToString:@"AXDirectionNext"]) ? SearchDirectionNext : SearchDirectionPrevious; 2775 2776 AccessibilitySearchKey axSearchKey = AnyTypeSearchKey; 2777 if ([[dictionary objectForKey:@"AXSearchKey"] isKindOfClass:[NSString self]]) 2778 axSearchKey = accessibilitySearchKeyForString((CFStringRef)[dictionary objectForKey:@"AXSearchKey"]); 2779 2780 String searchText; 2781 if ([[dictionary objectForKey:@"AXSearchText"] isKindOfClass:[NSString self]]) 2782 searchText = (CFStringRef)[dictionary objectForKey:@"AXSearchText"]; 2783 2784 unsigned resultsLimit = 0; 2785 if ([[dictionary objectForKey:@"AXResultsLimit"] isKindOfClass:[NSNumber self]]) 2786 resultsLimit = [(NSNumber*)[dictionary objectForKey:@"AXResultsLimit"] unsignedIntValue]; 2787 2788 AccessibilitySearchPredicate axSearchPredicate = {m_object, axStartObject, axSearchDirection, axSearchKey, &searchText, resultsLimit}; 2789 AccessibilityObject::AccessibilityChildrenVector axResults; 2790 AccessibilityObject::accessibleObjectsWithAccessibilitySearchPredicate(&axSearchPredicate, axResults); 2791 2792 return convertToNSArray(axResults); 2793 } 2794 2539 2795 if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) { 2540 2796 VisiblePosition visiblePos = [self visiblePositionForTextMarker:(textMarker)]; -
trunk/Tools/ChangeLog
r92563 r92571 1 2011-08-07 Sam White <samuel.white@rochester.edu> 2 3 Add the ability to search the AccessibilityObject cache 4 https://bugs.webkit.org/show_bug.cgi?id=64994 5 6 Added testing support for AccessibilityObject cache searching. Currently, 7 only the mac platform is full supported and has had API exposed. Other 8 platforms have only have this new functionality stubbed. Full implementation 9 is a job suited only for an accessibility expert of each respective platform. 10 11 Reviewed by Chris Fleizach. 12 13 * DumpRenderTree/AccessibilityUIElement.cpp: 14 (uiElementForSearchPredicateCallback): 15 (AccessibilityUIElement::getJSClass): 16 * DumpRenderTree/AccessibilityUIElement.h: 17 * DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp: 18 (AccessibilityUIElement::uiElementForSearchPredicate): 19 * DumpRenderTree/mac/AccessibilityUIElementMac.mm: 20 (AccessibilityUIElement::uiElementForSearchPredicate): 21 * DumpRenderTree/win/AccessibilityUIElementWin.cpp: 22 (AccessibilityUIElement::uiElementForSearchPredicate): 23 1 24 2011-08-06 Adam Barth <abarth@webkit.org> 2 25 -
trunk/Tools/DumpRenderTree/AccessibilityUIElement.cpp
r85007 r92571 184 184 185 185 return JSValueMakeBoolean(context, toAXElement(thisObject)->attributedStringRangeIsMisspelled(location, length)); 186 } 187 188 static JSValueRef uiElementForSearchPredicateCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 189 { 190 AccessibilityUIElement* startElement = 0; 191 bool isDirectionNext = true; 192 JSStringRef searchKey = 0; 193 JSStringRef searchText = 0; 194 if (argumentCount == 4) { 195 startElement = toAXElement(JSValueToObject(context, arguments[0], exception)); 196 isDirectionNext = JSValueToBoolean(context, arguments[1]); 197 if (JSValueIsString(context, arguments[2])) 198 searchKey = JSValueToStringCopy(context, arguments[2], exception); 199 if (JSValueIsString(context, arguments[3])) 200 searchText = JSValueToStringCopy(context, arguments[3], exception); 201 } 202 203 JSObjectRef resultObject = AccessibilityUIElement::makeJSAccessibilityUIElement(context, toAXElement(thisObject)->uiElementForSearchPredicate(startElement, isDirectionNext, searchKey, searchText)); 204 if (searchKey) 205 JSStringRelease(searchKey); 206 if (searchText) 207 JSStringRelease(searchText); 208 209 return resultObject; 186 210 } 187 211 … … 967 991 { "attributedStringForRange", attributedStringForRangeCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 968 992 { "attributedStringRangeIsMisspelled", attributedStringRangeIsMisspelledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 993 { "uiElementForSearchPredicate", uiElementForSearchPredicateCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 969 994 { "childAtIndex", childAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, 970 995 { "linkedUIElementAtIndex", linkedUIElementAtIndexCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete }, -
trunk/Tools/DumpRenderTree/AccessibilityUIElement.h
r85007 r92571 193 193 JSStringRef attributedStringForRange(unsigned location, unsigned length); 194 194 bool attributedStringRangeIsMisspelled(unsigned location, unsigned length); 195 AccessibilityUIElement uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText); 195 196 196 197 // Table-specific -
trunk/Tools/DumpRenderTree/gtk/AccessibilityUIElementGtk.cpp
r84975 r92571 581 581 } 582 582 583 AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText) 584 { 585 // FIXME: implement 586 return 0; 587 } 588 583 589 AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row) 584 590 { -
trunk/Tools/DumpRenderTree/mac/AccessibilityUIElementMac.mm
r85036 r92571 933 933 } 934 934 935 AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText) 936 { 937 BEGIN_AX_OBJC_EXCEPTIONS 938 NSMutableDictionary* parameter = [NSMutableDictionary dictionary]; 939 [parameter setObject:(isDirectionNext) ? @"AXDirectionNext" : @"AXDirectionPrevious" forKey:@"AXDirection"]; 940 [parameter setObject:[NSNumber numberWithInt:1] forKey:@"AXResultsLimit"]; 941 if (startElement) 942 [parameter setObject:(id)startElement->platformUIElement() forKey:@"AXStartElement"]; 943 if (searchKey) 944 [parameter setObject:[NSString stringWithJSStringRef:searchKey] forKey:@"AXSearchKey"]; 945 if (searchText) 946 [parameter setObject:[NSString stringWithJSStringRef:searchText] forKey:@"AXSearchText"]; 947 948 id uiElement = [[m_element accessibilityAttributeValue:@"AXUIElementsForSearchPredicate" forParameter:parameter] lastObject]; 949 return AccessibilityUIElement(uiElement); 950 END_AX_OBJC_EXCEPTIONS 951 952 return 0; 953 } 954 935 955 JSStringRef AccessibilityUIElement::attributesOfColumnHeaders() 936 956 { -
trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp
r74025 r92571 489 489 } 490 490 491 AccessibilityUIElement AccessibilityUIElement::uiElementForSearchPredicate(AccessibilityUIElement* startElement, bool isDirectionNext, JSStringRef searchKey, JSStringRef searchText) 492 { 493 return 0; 494 } 495 491 496 AccessibilityUIElement AccessibilityUIElement::cellForColumnAndRow(unsigned column, unsigned row) 492 497 {
Note: See TracChangeset
for help on using the changeset viewer.