summaryrefslogtreecommitdiffstats
path: root/WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-10-08 17:19:54 +0100
committerSteve Block <steveblock@google.com>2009-10-20 00:41:58 +0100
commit231d4e3152a9c27a73b6ac7badbe6be673aa3ddf (patch)
treea6c7e2d6cd7bfa7011cc39abbb436142d7a4a7c8 /WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp
parente196732677050bd463301566a68a643b6d14b907 (diff)
downloadexternal_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.zip
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.gz
external_webkit-231d4e3152a9c27a73b6ac7badbe6be673aa3ddf.tar.bz2
Merge webkit.org at R49305 : Automatic merge by git.
Change-Id: I8968561bc1bfd72b8923b7118d3728579c6dbcc7
Diffstat (limited to 'WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp')
-rw-r--r--WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp79
1 files changed, 79 insertions, 0 deletions
diff --git a/WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp b/WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp
index b6e45f2..ac64efb 100644
--- a/WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp
+++ b/WebKitTools/DumpRenderTree/win/AccessibilityControllerWin.cpp
@@ -32,13 +32,19 @@
#include <WebCore/COMPtr.h>
#include <WebKit/WebKit.h>
#include <oleacc.h>
+#include <string>
+
+using namespace std;
AccessibilityController::AccessibilityController()
+ : m_focusEventHook(0)
+ , m_scrollingStartEventHook(0)
{
}
AccessibilityController::~AccessibilityController()
{
+ setLogFocusEvents(false);
}
AccessibilityUIElement AccessibilityController::focusedElement()
@@ -82,3 +88,76 @@ AccessibilityUIElement AccessibilityController::rootElement()
return rootAccessible;
}
+
+static void CALLBACK logEventProc(HWINEVENTHOOK hWinEventHook, DWORD event, HWND hwnd, LONG idObject, LONG idChild, DWORD, DWORD)
+{
+ // Get the accessible object for this event.
+ COMPtr<IAccessible> parentObject;
+
+ VARIANT vChild;
+ VariantInit(&vChild);
+
+ HRESULT hr = AccessibleObjectFromEvent(hwnd, idObject, idChild, &parentObject, &vChild);
+ ASSERT(SUCCEEDED(hr));
+
+ // Get the name of the focused element, and log it to stdout.
+ BSTR nameBSTR;
+ hr = parentObject->get_accName(vChild, &nameBSTR);
+ ASSERT(SUCCEEDED(hr));
+ wstring name(nameBSTR, ::SysStringLen(nameBSTR));
+ SysFreeString(nameBSTR);
+
+ switch (event) {
+ case EVENT_OBJECT_FOCUS:
+ printf("Received focus event for object '%S'.\n", name.c_str());
+ break;
+
+ case EVENT_SYSTEM_SCROLLINGSTART:
+ printf("Received scrolling start event for object '%S'.\n", name.c_str());
+ break;
+
+ default:
+ printf("Received unknown event for object '%S'.\n", name.c_str());
+ break;
+ }
+}
+
+void AccessibilityController::setLogFocusEvents(bool logFocusEvents)
+{
+ if (!!m_focusEventHook == logFocusEvents)
+ return;
+
+ if (!logFocusEvents) {
+ UnhookWinEvent(m_focusEventHook);
+ m_focusEventHook = 0;
+ return;
+ }
+
+ // Ensure that accessibility is initialized for the WebView by querying for
+ // the root accessible object.
+ rootElement();
+
+ m_focusEventHook = SetWinEventHook(EVENT_OBJECT_FOCUS, EVENT_OBJECT_FOCUS, GetModuleHandle(0), logEventProc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
+
+ ASSERT(m_focusEventHook);
+}
+
+void AccessibilityController::setLogScrollingStartEvents(bool logScrollingStartEvents)
+{
+ if (!!m_scrollingStartEventHook == logScrollingStartEvents)
+ return;
+
+ if (!logScrollingStartEvents) {
+ UnhookWinEvent(m_scrollingStartEventHook);
+ m_scrollingStartEventHook = 0;
+ return;
+ }
+
+ // Ensure that accessibility is initialized for the WebView by querying for
+ // the root accessible object.
+ rootElement();
+
+ m_scrollingStartEventHook = SetWinEventHook(EVENT_SYSTEM_SCROLLINGSTART, EVENT_SYSTEM_SCROLLINGSTART, GetModuleHandle(0), logEventProc, GetCurrentProcessId(), 0, WINEVENT_INCONTEXT);
+
+ ASSERT(m_scrollingStartEventHook);
+}