/* void SendKeys (in nsISupports aNode, in wstring value); */ NS_IMETHODIMP nsNativeEvents::SendKeys(nsISupports *aNode, const PRUnichar *value) { nsCOMPtr<nsIConsoleService> aConsoleService = do_GetService( "@mozilla.org/consoleservice;1" ); aConsoleService->LogStringMessage(NS_LITERAL_STRING( "Starting to send keys. First of all, process the node").get()); LOG(DEBUG) << "---------- Got to start of callback. aNode: " << aNode << " ----------"; NS_LossyConvertUTF16toASCII ascii_keys(value); LOG(DEBUG) << "Ascii keys: " << ascii_keys.get(); LOG(DEBUG) << "Ascii string length: " << strlen(ascii_keys.get()); int i = 0; while (value[i] != '\0') { LOG(DEBUG) << value[i] << " "; i++; } WINDOW_HANDLE windowHandle = aNode; // if (aNode) { // AccessibleDocumentWrapper doc(aNode); // // WINDOW_HANDLE windowHandle = doc.getWindowHandle(); // // if (!windowHandle) { // LOG(WARN) << "Sorry, window handle is null."; // return NS_ERROR_NULL_POINTER; // } // } // Note that it's OK to send wchar_t even though wchar_t is *usually* // 32 bit, because this code (and any code that links with it) *MUST* // be compiled with -fshort-wchar, so it's actually 16 bit and, // incidentally, just like PRUnichar. This, of course, breaks any // library function that uses wchar_t. #ifdef BUILD_ON_UNIX assert(sizeof(PRUnichar) == sizeof(wchar_t)); const wchar_t* valuePtr = (const wchar_t*) value; #else const PRUnichar* valuePtr = value; #endif sendKeys(windowHandle, valuePtr, 0); LOG(DEBUG) << "Sent keys sucessfully."; return NS_OK; }
/* void SendKeys (in nsISupports aNode, in wstring value); */ NS_IMETHODIMP nsNativeKeyboard::SendKeys(nsISupports *aNode, const PRUnichar *value, bool releaseModifiers) { LOG(DEBUG) << "---------- Got to start of callback. aNode: " << aNode << " ----------"; NS_LossyConvertUTF16toASCII ascii_keys(value); LOG(DEBUG) << "Ascii keys: " << ascii_keys.get(); LOG(DEBUG) << "Ascii string length: " << strlen(ascii_keys.get()); int i = 0; while (value[i] != '\0') { LOG(DEBUG) << value[i] << " "; i++; } AccessibleDocumentWrapper doc(aNode); WINDOW_HANDLE windowHandle = doc.getWindowHandle(); if (!windowHandle) { LOG(WARN) << "Sorry, window handle is null."; return NS_ERROR_NULL_POINTER; } // Note that it's OK to send wchar_t even though wchar_t is *usually* // 32 bit, because this code (and any code that links with it) *MUST* // be compiled with -fshort-wchar, so it's actually 16 bit and, // incidentally, just like PRUnichar. This, of course, breaks any // library function that uses wchar_t. #ifdef BUILD_ON_UNIX assert(sizeof(PRUnichar) == sizeof(wchar_t)); const wchar_t* valuePtr = (const wchar_t*) value; #else const PRUnichar* valuePtr = value; #endif sendKeys(windowHandle, valuePtr, 0); if (releaseModifiers) { LOG(DEBUG) << "Also releasing modifiers."; releaseModifierKeys(windowHandle, 0); } LOG(DEBUG) << "Sent keys sucessfully."; return NS_OK; }