Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(971)

Side by Side Diff: Source/testing/runner/AccessibilityUIElementChromium.cpp

Issue 23726007: Remove old accessibility enums, finish renaming public interface. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove unnecessary include Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "AccessibilityUIElementChromium.h" 31 #include "AccessibilityUIElementChromium.h"
32 32
33 #include "TestCommon.h" 33 #include "TestCommon.h"
34 #include "public/platform/WebCString.h" 34 #include "public/platform/WebCString.h"
35 #include "public/platform/WebPoint.h" 35 #include "public/platform/WebPoint.h"
36 #include "public/platform/WebRect.h" 36 #include "public/platform/WebRect.h"
37 #include "public/platform/WebString.h" 37 #include "public/platform/WebString.h"
38 #include "public/web/WebAccessibilityObject.h" 38 #include "public/web/WebAXObject.h"
39 39
40 using namespace WebKit; 40 using namespace WebKit;
41 using namespace std; 41 using namespace std;
42 42
43 namespace WebTestRunner { 43 namespace WebTestRunner {
44 44
45 namespace { 45 namespace {
46 46
47 // Map role value to string, matching Safari/Mac platform implementation to 47 // Map role value to string, matching Safari/Mac platform implementation to
48 // avoid rebaselining layout tests. 48 // avoid rebaselining layout tests.
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 return result.append("ValueIndicator"); 268 return result.append("ValueIndicator");
269 case WebAXRoleWebArea: 269 case WebAXRoleWebArea:
270 return result.append("WebArea"); 270 return result.append("WebArea");
271 case WebAXRoleWindow: 271 case WebAXRoleWindow:
272 return result.append("Window"); 272 return result.append("Window");
273 default: 273 default:
274 return result.append("Unknown"); 274 return result.append("Unknown");
275 } 275 }
276 } 276 }
277 277
278 string getDescription(const WebAccessibilityObject& object) 278 string getDescription(const WebAXObject& object)
279 { 279 {
280 string description = object.accessibilityDescription().utf8(); 280 string description = object.accessibilityDescription().utf8();
281 return description.insert(0, "AXDescription: "); 281 return description.insert(0, "AXDescription: ");
282 } 282 }
283 283
284 string getHelpText(const WebAccessibilityObject& object) 284 string getHelpText(const WebAXObject& object)
285 { 285 {
286 string helpText = object.helpText().utf8(); 286 string helpText = object.helpText().utf8();
287 return helpText.insert(0, "AXHelp: "); 287 return helpText.insert(0, "AXHelp: ");
288 } 288 }
289 289
290 string getStringValue(const WebAccessibilityObject& object) 290 string getStringValue(const WebAXObject& object)
291 { 291 {
292 string value; 292 string value;
293 if (object.roleValue() == WebAccessibilityRoleColorWell) { 293 if (object.role() == WebAXRoleColorWell) {
294 int r, g, b; 294 int r, g, b;
295 char buffer[100]; 295 char buffer[100];
296 object.colorValue(r, g, b); 296 object.colorValue(r, g, b);
297 snprintf(buffer, sizeof(buffer), "rgb %7.5f %7.5f %7.5f 1", r / 255., g / 255., b / 255.); 297 snprintf(buffer, sizeof(buffer), "rgb %7.5f %7.5f %7.5f 1", r / 255., g / 255., b / 255.);
298 value = buffer; 298 value = buffer;
299 } else 299 } else
300 value = object.stringValue().utf8(); 300 value = object.stringValue().utf8();
301 return value.insert(0, "AXValue: "); 301 return value.insert(0, "AXValue: ");
302 } 302 }
303 303
304 string getRole(const WebAccessibilityObject& object) 304 string getRole(const WebAXObject& object)
305 { 305 {
306 string roleString = roleToString(object.role()); 306 string roleString = roleToString(object.role());
307 307
308 // Special-case canvas with fallback content because Chromium wants to 308 // Special-case canvas with fallback content because Chromium wants to
309 // treat this as essentially a separate role that it can map differently dep ending 309 // treat this as essentially a separate role that it can map differently dep ending
310 // on the platform. 310 // on the platform.
311 if (object.roleValue() == WebAccessibilityRoleCanvas && object.canvasHasFall backContent()) 311 if (object.role() == WebAXRoleCanvas && object.canvasHasFallbackContent())
312 roleString += "WithFallbackContent"; 312 roleString += "WithFallbackContent";
313 313
314 return roleString; 314 return roleString;
315 } 315 }
316 316
317 string getTitle(const WebAccessibilityObject& object) 317 string getTitle(const WebAXObject& object)
318 { 318 {
319 string title = object.title().utf8(); 319 string title = object.title().utf8();
320 return title.insert(0, "AXTitle: "); 320 return title.insert(0, "AXTitle: ");
321 } 321 }
322 322
323 string getOrientation(const WebAccessibilityObject& object) 323 string getOrientation(const WebAXObject& object)
324 { 324 {
325 if (object.isVertical()) 325 if (object.isVertical())
326 return "AXOrientation: AXVerticalOrientation"; 326 return "AXOrientation: AXVerticalOrientation";
327 327
328 return "AXOrientation: AXHorizontalOrientation"; 328 return "AXOrientation: AXHorizontalOrientation";
329 } 329 }
330 330
331 string getValueDescription(const WebAccessibilityObject& object) 331 string getValueDescription(const WebAXObject& object)
332 { 332 {
333 string valueDescription = object.valueDescription().utf8(); 333 string valueDescription = object.valueDescription().utf8();
334 return valueDescription.insert(0, "AXValueDescription: "); 334 return valueDescription.insert(0, "AXValueDescription: ");
335 } 335 }
336 336
337 string getAttributes(const WebAccessibilityObject& object) 337 string getAttributes(const WebAXObject& object)
338 { 338 {
339 // FIXME: Concatenate all attributes of the AccessibilityObject. 339 // FIXME: Concatenate all attributes of the AccessibilityObject.
340 string attributes(getTitle(object)); 340 string attributes(getTitle(object));
341 attributes.append("\n"); 341 attributes.append("\n");
342 attributes.append(getRole(object)); 342 attributes.append(getRole(object));
343 attributes.append("\n"); 343 attributes.append("\n");
344 attributes.append(getDescription(object)); 344 attributes.append(getDescription(object));
345 return attributes; 345 return attributes;
346 } 346 }
347 347
348 348
349 // Collects attributes into a string, delimited by dashes. Used by all methods 349 // Collects attributes into a string, delimited by dashes. Used by all methods
350 // that output lists of attributes: attributesOfLinkedUIElementsCallback, 350 // that output lists of attributes: attributesOfLinkedUIElementsCallback,
351 // AttributesOfChildrenCallback, etc. 351 // AttributesOfChildrenCallback, etc.
352 class AttributesCollector { 352 class AttributesCollector {
353 public: 353 public:
354 void collectAttributes(const WebAccessibilityObject& object) 354 void collectAttributes(const WebAXObject& object)
355 { 355 {
356 m_attributes.append("\n------------\n"); 356 m_attributes.append("\n------------\n");
357 m_attributes.append(getAttributes(object)); 357 m_attributes.append(getAttributes(object));
358 } 358 }
359 359
360 string attributes() const { return m_attributes; } 360 string attributes() const { return m_attributes; }
361 361
362 private: 362 private:
363 string m_attributes; 363 string m_attributes;
364 }; 364 };
365 365
366 } 366 }
367 367
368 AccessibilityUIElement::AccessibilityUIElement(const WebAccessibilityObject& obj ect, Factory* factory) 368 AccessibilityUIElement::AccessibilityUIElement(const WebAXObject& object, Factor y* factory)
369 : m_accessibilityObject(object) 369 : m_accessibilityObject(object)
370 , m_factory(factory) 370 , m_factory(factory)
371 { 371 {
372 372
373 WEBKIT_ASSERT(factory); 373 WEBKIT_ASSERT(factory);
374 374
375 // 375 //
376 // Properties 376 // Properties
377 // 377 //
378 378
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 bindMethod("scrollToGlobalPoint", &AccessibilityUIElement::scrollToGlobalPoi ntCallback); 460 bindMethod("scrollToGlobalPoint", &AccessibilityUIElement::scrollToGlobalPoi ntCallback);
461 461
462 bindFallbackMethod(&AccessibilityUIElement::fallbackCallback); 462 bindFallbackMethod(&AccessibilityUIElement::fallbackCallback);
463 } 463 }
464 464
465 AccessibilityUIElement* AccessibilityUIElement::getChildAtIndex(unsigned index) 465 AccessibilityUIElement* AccessibilityUIElement::getChildAtIndex(unsigned index)
466 { 466 {
467 return m_factory->getOrCreate(accessibilityObject().childAt(index)); 467 return m_factory->getOrCreate(accessibilityObject().childAt(index));
468 } 468 }
469 469
470 bool AccessibilityUIElement::isEqual(const WebKit::WebAccessibilityObject& other ) 470 bool AccessibilityUIElement::isEqual(const WebKit::WebAXObject& other)
471 { 471 {
472 return accessibilityObject().equals(other); 472 return accessibilityObject().equals(other);
473 } 473 }
474 474
475 void AccessibilityUIElement::notificationReceived(const char* notificationName) 475 void AccessibilityUIElement::notificationReceived(const char* notificationName)
476 { 476 {
477 size_t callbackCount = m_notificationCallbacks.size(); 477 size_t callbackCount = m_notificationCallbacks.size();
478 for (size_t i = 0; i < callbackCount; i++) { 478 for (size_t i = 0; i < callbackCount; i++) {
479 CppVariant notificationNameArgument; 479 CppVariant notificationNameArgument;
480 notificationNameArgument.set(notificationName); 480 notificationNameArgument.set(notificationName);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 529
530 void AccessibilityUIElement::heightGetterCallback(CppVariant* result) 530 void AccessibilityUIElement::heightGetterCallback(CppVariant* result)
531 { 531 {
532 result->set(accessibilityObject().boundingBoxRect().height); 532 result->set(accessibilityObject().boundingBoxRect().height);
533 } 533 }
534 534
535 void AccessibilityUIElement::intValueGetterCallback(CppVariant* result) 535 void AccessibilityUIElement::intValueGetterCallback(CppVariant* result)
536 { 536 {
537 if (accessibilityObject().supportsRangeValue()) 537 if (accessibilityObject().supportsRangeValue())
538 result->set(accessibilityObject().valueForRange()); 538 result->set(accessibilityObject().valueForRange());
539 else if (accessibilityObject().roleValue() == WebAccessibilityRoleHeading) 539 else if (accessibilityObject().role() == WebAXRoleHeading)
540 result->set(accessibilityObject().headingLevel()); 540 result->set(accessibilityObject().headingLevel());
541 else 541 else
542 result->set(atoi(accessibilityObject().stringValue().utf8().data())); 542 result->set(atoi(accessibilityObject().stringValue().utf8().data()));
543 } 543 }
544 544
545 void AccessibilityUIElement::minValueGetterCallback(CppVariant* result) 545 void AccessibilityUIElement::minValueGetterCallback(CppVariant* result)
546 { 546 {
547 result->set(accessibilityObject().minValueForRange()); 547 result->set(accessibilityObject().minValueForRange());
548 } 548 }
549 549
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
776 void AccessibilityUIElement::elementAtPointCallback(const CppArgumentList& argum ents, CppVariant* result) 776 void AccessibilityUIElement::elementAtPointCallback(const CppArgumentList& argum ents, CppVariant* result)
777 { 777 {
778 result->setNull(); 778 result->setNull();
779 779
780 if (arguments.size() != 2 || !arguments[0].isNumber() || !arguments[1].isNum ber()) 780 if (arguments.size() != 2 || !arguments[0].isNumber() || !arguments[1].isNum ber())
781 return; 781 return;
782 782
783 int x = arguments[0].toInt32(); 783 int x = arguments[0].toInt32();
784 int y = arguments[1].toInt32(); 784 int y = arguments[1].toInt32();
785 WebPoint point(x, y); 785 WebPoint point(x, y);
786 WebAccessibilityObject obj = accessibilityObject().hitTest(point); 786 WebAXObject obj = accessibilityObject().hitTest(point);
787 if (obj.isNull()) 787 if (obj.isNull())
788 return; 788 return;
789 789
790 result->set(*(m_factory->getOrCreate(obj)->getAsCppVariant())); 790 result->set(*(m_factory->getOrCreate(obj)->getAsCppVariant()));
791 } 791 }
792 792
793 void AccessibilityUIElement::attributesOfColumnHeadersCallback(const CppArgument List&, CppVariant* result) 793 void AccessibilityUIElement::attributesOfColumnHeadersCallback(const CppArgument List&, CppVariant* result)
794 { 794 {
795 result->setNull(); 795 result->setNull();
796 } 796 }
(...skipping 18 matching lines...) Expand all
815 result->setNull(); 815 result->setNull();
816 } 816 }
817 817
818 void AccessibilityUIElement::attributesOfHeaderCallback(const CppArgumentList&, CppVariant* result) 818 void AccessibilityUIElement::attributesOfHeaderCallback(const CppArgumentList&, CppVariant* result)
819 { 819 {
820 result->setNull(); 820 result->setNull();
821 } 821 }
822 822
823 void AccessibilityUIElement::tableHeaderCallback(const CppArgumentList&, CppVari ant* result) 823 void AccessibilityUIElement::tableHeaderCallback(const CppArgumentList&, CppVari ant* result)
824 { 824 {
825 WebAccessibilityObject obj = accessibilityObject().headerContainerObject(); 825 WebAXObject obj = accessibilityObject().headerContainerObject();
826 if (obj.isNull()) { 826 if (obj.isNull()) {
827 result->setNull(); 827 result->setNull();
828 return; 828 return;
829 } 829 }
830 830
831 result->set(*(m_factory->getOrCreate(obj)->getAsCppVariant())); 831 result->set(*(m_factory->getOrCreate(obj)->getAsCppVariant()));
832 } 832 }
833 833
834 void AccessibilityUIElement::indexInTableCallback(const CppArgumentList&, CppVar iant* result) 834 void AccessibilityUIElement::indexInTableCallback(const CppArgumentList&, CppVar iant* result)
835 { 835 {
(...skipping 19 matching lines...) Expand all
855 result->set(std::string(buffer)); 855 result->set(std::string(buffer));
856 } 856 }
857 857
858 void AccessibilityUIElement::cellForColumnAndRowCallback(const CppArgumentList& arguments, CppVariant* result) 858 void AccessibilityUIElement::cellForColumnAndRowCallback(const CppArgumentList& arguments, CppVariant* result)
859 { 859 {
860 if (arguments.size() != 2 || !arguments[0].isNumber() || !arguments[1].isNum ber()) 860 if (arguments.size() != 2 || !arguments[0].isNumber() || !arguments[1].isNum ber())
861 return; 861 return;
862 862
863 int column = arguments[0].toInt32(); 863 int column = arguments[0].toInt32();
864 int row = arguments[1].toInt32(); 864 int row = arguments[1].toInt32();
865 WebAccessibilityObject obj = accessibilityObject().cellForColumnAndRow(colum n, row); 865 WebAXObject obj = accessibilityObject().cellForColumnAndRow(column, row);
866 if (obj.isNull()) { 866 if (obj.isNull()) {
867 result->setNull(); 867 result->setNull();
868 return; 868 return;
869 } 869 }
870 870
871 result->set(*(m_factory->getOrCreate(obj)->getAsCppVariant())); 871 result->set(*(m_factory->getOrCreate(obj)->getAsCppVariant()));
872 } 872 }
873 873
874 void AccessibilityUIElement::titleUIElementCallback(const CppArgumentList&, CppV ariant* result) 874 void AccessibilityUIElement::titleUIElementCallback(const CppArgumentList&, CppV ariant* result)
875 { 875 {
876 WebAccessibilityObject obj = accessibilityObject().titleUIElement(); 876 WebAXObject obj = accessibilityObject().titleUIElement();
877 if (obj.isNull()) { 877 if (obj.isNull()) {
878 result->setNull(); 878 result->setNull();
879 return; 879 return;
880 } 880 }
881 881
882 result->set(*(m_factory->getOrCreate(obj)->getAsCppVariant())); 882 result->set(*(m_factory->getOrCreate(obj)->getAsCppVariant()));
883 } 883 }
884 884
885 void AccessibilityUIElement::setSelectedTextRangeCallback(const CppArgumentList& arguments, CppVariant* result) 885 void AccessibilityUIElement::setSelectedTextRangeCallback(const CppArgumentList& arguments, CppVariant* result)
886 { 886 {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 accessibilityObject().scrollToGlobalPoint(WebPoint(x, y)); 1034 accessibilityObject().scrollToGlobalPoint(WebPoint(x, y));
1035 result->setNull(); 1035 result->setNull();
1036 } 1036 }
1037 1037
1038 void AccessibilityUIElement::fallbackCallback(const CppArgumentList &, CppVarian t* result) 1038 void AccessibilityUIElement::fallbackCallback(const CppArgumentList &, CppVarian t* result)
1039 { 1039 {
1040 // FIXME: Implement this. 1040 // FIXME: Implement this.
1041 result->setNull(); 1041 result->setNull();
1042 } 1042 }
1043 1043
1044 RootAccessibilityUIElement::RootAccessibilityUIElement(const WebAccessibilityObj ect &object, Factory *factory) 1044 RootAccessibilityUIElement::RootAccessibilityUIElement(const WebAXObject &object , Factory *factory)
1045 : AccessibilityUIElement(object, factory) { } 1045 : AccessibilityUIElement(object, factory) { }
1046 1046
1047 AccessibilityUIElement* RootAccessibilityUIElement::getChildAtIndex(unsigned ind ex) 1047 AccessibilityUIElement* RootAccessibilityUIElement::getChildAtIndex(unsigned ind ex)
1048 { 1048 {
1049 if (index) 1049 if (index)
1050 return 0; 1050 return 0;
1051 1051
1052 return factory()->getOrCreate(accessibilityObject()); 1052 return factory()->getOrCreate(accessibilityObject());
1053 } 1053 }
1054 1054
1055 1055
1056 AccessibilityUIElementList ::~AccessibilityUIElementList() 1056 AccessibilityUIElementList ::~AccessibilityUIElementList()
1057 { 1057 {
1058 clear(); 1058 clear();
1059 } 1059 }
1060 1060
1061 void AccessibilityUIElementList::clear() 1061 void AccessibilityUIElementList::clear()
1062 { 1062 {
1063 for (ElementList::iterator i = m_elements.begin(); i != m_elements.end(); ++ i) 1063 for (ElementList::iterator i = m_elements.begin(); i != m_elements.end(); ++ i)
1064 delete (*i); 1064 delete (*i);
1065 m_elements.clear(); 1065 m_elements.clear();
1066 } 1066 }
1067 1067
1068 AccessibilityUIElement* AccessibilityUIElementList::getOrCreate(const WebAccessi bilityObject& object) 1068 AccessibilityUIElement* AccessibilityUIElementList::getOrCreate(const WebAXObjec t& object)
1069 { 1069 {
1070 if (object.isNull()) 1070 if (object.isNull())
1071 return 0; 1071 return 0;
1072 1072
1073 size_t elementCount = m_elements.size(); 1073 size_t elementCount = m_elements.size();
1074 for (size_t i = 0; i < elementCount; i++) { 1074 for (size_t i = 0; i < elementCount; i++) {
1075 if (m_elements[i]->isEqual(object)) 1075 if (m_elements[i]->isEqual(object))
1076 return m_elements[i]; 1076 return m_elements[i];
1077 } 1077 }
1078 1078
1079 AccessibilityUIElement* element = new AccessibilityUIElement(object, this); 1079 AccessibilityUIElement* element = new AccessibilityUIElement(object, this);
1080 m_elements.push_back(element); 1080 m_elements.push_back(element);
1081 return element; 1081 return element;
1082 } 1082 }
1083 1083
1084 AccessibilityUIElement* AccessibilityUIElementList::createRoot(const WebAccessib ilityObject& object) 1084 AccessibilityUIElement* AccessibilityUIElementList::createRoot(const WebAXObject & object)
1085 { 1085 {
1086 AccessibilityUIElement* element = new RootAccessibilityUIElement(object, thi s); 1086 AccessibilityUIElement* element = new RootAccessibilityUIElement(object, thi s);
1087 m_elements.push_back(element); 1087 m_elements.push_back(element);
1088 return element; 1088 return element;
1089 } 1089 }
1090 1090
1091 } 1091 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698