diff options
author | Steve Block <steveblock@google.com> | 2010-02-02 14:57:50 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-02-04 15:06:55 +0000 |
commit | d0825bca7fe65beaee391d30da42e937db621564 (patch) | |
tree | 7461c49eb5844ffd1f35d1ba2c8b7584c1620823 /WebKitTools/DumpRenderTree/win/EventSender.cpp | |
parent | 3db770bd97c5a59b6c7574ca80a39e5a51c1defd (diff) | |
download | external_webkit-d0825bca7fe65beaee391d30da42e937db621564.zip external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.gz external_webkit-d0825bca7fe65beaee391d30da42e937db621564.tar.bz2 |
Merge webkit.org at r54127 : Initial merge by git
Change-Id: Ib661abb595522f50ea406f72d3a0ce17f7193c82
Diffstat (limited to 'WebKitTools/DumpRenderTree/win/EventSender.cpp')
-rw-r--r-- | WebKitTools/DumpRenderTree/win/EventSender.cpp | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/WebKitTools/DumpRenderTree/win/EventSender.cpp b/WebKitTools/DumpRenderTree/win/EventSender.cpp index dd5bf9d..5a42b00 100644 --- a/WebKitTools/DumpRenderTree/win/EventSender.cpp +++ b/WebKitTools/DumpRenderTree/win/EventSender.cpp @@ -144,6 +144,30 @@ static JSValueRef contextClickCallback(JSContextRef context, JSObjectRef functio return JSValueMakeUndefined(context); } +static WPARAM buildModifierFlags(JSContextRef context, const JSValueRef modifiers) +{ + JSObjectRef modifiersArray = JSValueToObject(context, modifiers, 0); + if (!modifiersArray) + return 0; + + WPARAM flags = 0; + int modifiersCount = JSValueToNumber(context, JSObjectGetProperty(context, modifiersArray, JSStringCreateWithUTF8CString("length"), 0), 0); + for (int i = 0; i < modifiersCount; ++i) { + JSValueRef value = JSObjectGetPropertyAtIndex(context, modifiersArray, i, 0); + JSStringRef string = JSValueToStringCopy(context, value, 0); + if (JSStringIsEqualToUTF8CString(string, "ctrlKey") + || JSStringIsEqualToUTF8CString(string, "addSelectionKey")) + flags |= MK_CONTROL; + else if (JSStringIsEqualToUTF8CString(string, "shiftKey") + || JSStringIsEqualToUTF8CString(string, "rangeSelectionKey")) + flags |= MK_SHIFT; + // No way to specifiy altKey in a MSG. + + JSStringRelease(string); + } + return flags; +} + static JSValueRef mouseDownCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { COMPtr<IWebFramePrivate> framePrivate; @@ -152,7 +176,7 @@ static JSValueRef mouseDownCallback(JSContextRef context, JSObjectRef function, down = true; int mouseType = WM_LBUTTONDOWN; - if (argumentCount == 1) { + if (argumentCount >= 1) { int mouseNumber = JSValueToNumber(context, arguments[0], exception); switch (mouseNumber) { case 0: @@ -173,8 +197,12 @@ static JSValueRef mouseDownCallback(JSContextRef context, JSObjectRef function, break; } } + + WPARAM wparam = 0; + if (argumentCount >= 2) + wparam |= buildModifierFlags(context, arguments[1]); - MSG msg = makeMsg(webViewWindow, mouseType, 0, MAKELPARAM(lastMousePosition.x, lastMousePosition.y)); + MSG msg = makeMsg(webViewWindow, mouseType, wparam, MAKELPARAM(lastMousePosition.x, lastMousePosition.y)); if (!msgQueue[endOfQueue].delay) dispatchMessage(&msg); else { @@ -234,7 +262,7 @@ static void doMouseUp(MSG msg, HRESULT* oleDragAndDropReturnValue = 0) static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { int mouseType = WM_LBUTTONUP; - if (argumentCount == 1) { + if (argumentCount >= 1) { int mouseNumber = JSValueToNumber(context, arguments[0], exception); switch (mouseNumber) { case 0: @@ -256,7 +284,11 @@ static JSValueRef mouseUpCallback(JSContextRef context, JSObjectRef function, JS } } - MSG msg = makeMsg(webViewWindow, mouseType, 0, MAKELPARAM(lastMousePosition.x, lastMousePosition.y)); + WPARAM wparam = 0; + if (argumentCount >= 2) + wparam |= buildModifierFlags(context, arguments[1]); + + MSG msg = makeMsg(webViewWindow, mouseType, wparam, MAKELPARAM(lastMousePosition.x, lastMousePosition.y)); if ((dragMode && !replayingSavedEvents) || msgQueue[endOfQueue].delay) { msgQueue[endOfQueue++].msg = msg; @@ -462,9 +494,9 @@ static JSValueRef keyDownCallback(JSContextRef context, JSObjectRef function, JS for (int i = 0; i < modifiersCount; ++i) { JSValueRef value = JSObjectGetPropertyAtIndex(context, modifiersArray, i, 0); JSStringRef string = JSValueToStringCopy(context, value, 0); - if (JSStringIsEqualToUTF8CString(string, "ctrlKey")) + if (JSStringIsEqualToUTF8CString(string, "ctrlKey") || JSStringIsEqualToUTF8CString(string, "addSelectionKey")) newKeyState[VK_CONTROL] = 0x80; - else if (JSStringIsEqualToUTF8CString(string, "shiftKey")) + else if (JSStringIsEqualToUTF8CString(string, "shiftKey") || JSStringIsEqualToUTF8CString(string, "rangeSelectionKey")) newKeyState[VK_SHIFT] = 0x80; else if (JSStringIsEqualToUTF8CString(string, "altKey")) newKeyState[VK_MENU] = 0x80; |