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

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

Issue 23726007: Remove old accessibility enums, finish renaming public interface. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase 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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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 "AccessibilityControllerChromium.h" 31 #include "AccessibilityControllerChromium.h"
32 32
33 #include "public/platform/WebCString.h" 33 #include "public/platform/WebCString.h"
34 #include "public/testing/WebTestDelegate.h" 34 #include "public/testing/WebTestDelegate.h"
35 #include "public/web/WebAccessibilityObject.h" 35 #include "public/web/WebAXObject.h"
36 #include "public/web/WebElement.h" 36 #include "public/web/WebElement.h"
37 #include "public/web/WebFrame.h" 37 #include "public/web/WebFrame.h"
38 #include "public/web/WebNode.h" 38 #include "public/web/WebNode.h"
39 #include "public/web/WebView.h" 39 #include "public/web/WebView.h"
40 40
41 using namespace WebKit; 41 using namespace WebKit;
42 42
43 namespace WebTestRunner { 43 namespace WebTestRunner {
44 44
45 AccessibilityController::AccessibilityController() 45 AccessibilityController::AccessibilityController()
46 : m_logAccessibilityEvents(false) 46 : m_logAccessibilityEvents(false)
47 { 47 {
48 48
49 bindMethod("logAccessibilityEvents", &AccessibilityController::logAccessibil ityEventsCallback); 49 bindMethod("logAccessibilityEvents", &AccessibilityController::logAccessibil ityEventsCallback);
50 bindMethod("addNotificationListener", &AccessibilityController::addNotificat ionListenerCallback); 50 bindMethod("addNotificationListener", &AccessibilityController::addNotificat ionListenerCallback);
51 bindMethod("removeNotificationListener", &AccessibilityController::removeNot ificationListenerCallback); 51 bindMethod("removeNotificationListener", &AccessibilityController::removeNot ificationListenerCallback);
52 52
53 bindProperty("focusedElement", &AccessibilityController::focusedElementGette rCallback); 53 bindProperty("focusedElement", &AccessibilityController::focusedElementGette rCallback);
54 bindProperty("rootElement", &AccessibilityController::rootElementGetterCallb ack); 54 bindProperty("rootElement", &AccessibilityController::rootElementGetterCallb ack);
55 55
56 bindMethod("accessibleElementById", &AccessibilityController::accessibleElem entByIdGetterCallback); 56 bindMethod("accessibleElementById", &AccessibilityController::accessibleElem entByIdGetterCallback);
57 57
58 bindFallbackMethod(&AccessibilityController::fallbackCallback); 58 bindFallbackMethod(&AccessibilityController::fallbackCallback);
59 } 59 }
60 60
61 void AccessibilityController::bindToJavascript(WebFrame* frame, const WebString& classname) 61 void AccessibilityController::bindToJavascript(WebFrame* frame, const WebString& classname)
62 { 62 {
63 WebAccessibilityObject::enableAccessibility(); 63 WebAXObject::enableAccessibility();
64 CppBoundClass::bindToJavascript(frame, classname); 64 CppBoundClass::bindToJavascript(frame, classname);
65 } 65 }
66 66
67 void AccessibilityController::reset() 67 void AccessibilityController::reset()
68 { 68 {
69 m_rootElement = WebAccessibilityObject(); 69 m_rootElement = WebAXObject();
70 m_focusedElement = WebAccessibilityObject(); 70 m_focusedElement = WebAXObject();
71 m_elements.clear(); 71 m_elements.clear();
72 m_notificationCallbacks.clear(); 72 m_notificationCallbacks.clear();
73 73
74 m_logAccessibilityEvents = false; 74 m_logAccessibilityEvents = false;
75 } 75 }
76 76
77 void AccessibilityController::setFocusedElement(const WebAccessibilityObject& fo cusedElement) 77 void AccessibilityController::setFocusedElement(const WebAXObject& focusedElemen t)
78 { 78 {
79 m_focusedElement = focusedElement; 79 m_focusedElement = focusedElement;
80 } 80 }
81 81
82 AccessibilityUIElement* AccessibilityController::getFocusedElement() 82 AccessibilityUIElement* AccessibilityController::getFocusedElement()
83 { 83 {
84 if (m_focusedElement.isNull()) 84 if (m_focusedElement.isNull())
85 m_focusedElement = m_webView->accessibilityObject(); 85 m_focusedElement = m_webView->accessibilityObject();
86 return m_elements.getOrCreate(m_focusedElement); 86 return m_elements.getOrCreate(m_focusedElement);
87 } 87 }
88 88
89 AccessibilityUIElement* AccessibilityController::getRootElement() 89 AccessibilityUIElement* AccessibilityController::getRootElement()
90 { 90 {
91 if (m_rootElement.isNull()) 91 if (m_rootElement.isNull())
92 m_rootElement = m_webView->accessibilityObject(); 92 m_rootElement = m_webView->accessibilityObject();
93 return m_elements.createRoot(m_rootElement); 93 return m_elements.createRoot(m_rootElement);
94 } 94 }
95 95
96 AccessibilityUIElement* AccessibilityController::findAccessibleElementByIdRecurs ive(const WebAccessibilityObject& obj, const WebString& id) 96 AccessibilityUIElement* AccessibilityController::findAccessibleElementByIdRecurs ive(const WebAXObject& obj, const WebString& id)
97 { 97 {
98 if (obj.isNull() || obj.isDetached()) 98 if (obj.isNull() || obj.isDetached())
99 return 0; 99 return 0;
100 100
101 WebNode node = obj.node(); 101 WebNode node = obj.node();
102 if (!node.isNull() && node.isElementNode()) { 102 if (!node.isNull() && node.isElementNode()) {
103 WebElement element = node.to<WebElement>(); 103 WebElement element = node.to<WebElement>();
104 element.getAttribute("id"); 104 element.getAttribute("id");
105 if (element.getAttribute("id") == id) 105 if (element.getAttribute("id") == id)
106 return m_elements.getOrCreate(obj); 106 return m_elements.getOrCreate(obj);
(...skipping 17 matching lines...) Expand all
124 return 0; 124 return 0;
125 125
126 return findAccessibleElementByIdRecursive(m_rootElement, WebString::fromUTF8 (id.c_str())); 126 return findAccessibleElementByIdRecursive(m_rootElement, WebString::fromUTF8 (id.c_str()));
127 } 127 }
128 128
129 bool AccessibilityController::shouldLogAccessibilityEvents() 129 bool AccessibilityController::shouldLogAccessibilityEvents()
130 { 130 {
131 return m_logAccessibilityEvents; 131 return m_logAccessibilityEvents;
132 } 132 }
133 133
134 void AccessibilityController::notificationReceived(const WebKit::WebAccessibilit yObject& target, const char* notificationName) 134 void AccessibilityController::notificationReceived(const WebKit::WebAXObject& ta rget, const char* notificationName)
135 { 135 {
136 // Call notification listeners on the element. 136 // Call notification listeners on the element.
137 AccessibilityUIElement* element = m_elements.getOrCreate(target); 137 AccessibilityUIElement* element = m_elements.getOrCreate(target);
138 element->notificationReceived(notificationName); 138 element->notificationReceived(notificationName);
139 139
140 // Call global notification listeners. 140 // Call global notification listeners.
141 size_t callbackCount = m_notificationCallbacks.size(); 141 size_t callbackCount = m_notificationCallbacks.size();
142 for (size_t i = 0; i < callbackCount; i++) { 142 for (size_t i = 0; i < callbackCount; i++) {
143 CppVariant arguments[2]; 143 CppVariant arguments[2];
144 arguments[0].set(*element->getAsCppVariant()); 144 arguments[0].set(*element->getAsCppVariant());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 result->set(*(foundElement->getAsCppVariant())); 196 result->set(*(foundElement->getAsCppVariant()));
197 } 197 }
198 198
199 void AccessibilityController::fallbackCallback(const CppArgumentList&, CppVarian t* result) 199 void AccessibilityController::fallbackCallback(const CppArgumentList&, CppVarian t* result)
200 { 200 {
201 m_delegate->printMessage("CONSOLE MESSAGE: JavaScript ERROR: unknown method called on AccessibilityController\n"); 201 m_delegate->printMessage("CONSOLE MESSAGE: JavaScript ERROR: unknown method called on AccessibilityController\n");
202 result->setNull(); 202 result->setNull();
203 } 203 }
204 204
205 } 205 }
OLDNEW
« no previous file with comments | « Source/testing/runner/AccessibilityControllerChromium.h ('k') | Source/testing/runner/AccessibilityUIElementChromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698