From 0159728ca5d347006a280d78ac32b1eb01516ad9 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 4 Dec 2013 13:19:38 +0100 Subject: [PATCH] Bug 944427 - Fixed char16_t/wchar_t mismatch in dom/ r=bsmedberg --- dom/base/nsDOMClassInfo.cpp | 4 +--- dom/base/nsJSEnvironment.cpp | 4 +--- dom/plugins/base/nsJSNPRuntime.cpp | 7 ++----- dom/plugins/base/nsNPAPIPlugin.cpp | 3 +-- dom/plugins/base/nsPluginsDirWin.cpp | 4 ++-- dom/plugins/ipc/PluginInstanceChild.cpp | 8 ++++---- dom/plugins/ipc/PluginInstanceParent.cpp | 8 ++++---- dom/plugins/ipc/PluginModuleChild.cpp | 8 ++++---- dom/plugins/ipc/PluginProcessChild.cpp | 2 +- 9 files changed, 20 insertions(+), 28 deletions(-) diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index 0e63ceb73830..7356d6a5b5ee 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -4497,9 +4497,7 @@ nsStorage2SH::NewEnumerate(nsIXPConnectWrappedNative *wrapper, JSContext *cx, if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) { nsString& key = keys->ElementAt(0); JSString *str = - JS_NewUCStringCopyN(cx, reinterpret_cast - (key.get()), - key.Length()); + JS_NewUCStringCopyN(cx, key.get(), key.Length()); NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); JS_ValueToId(cx, STRING_TO_JSVAL(str), idp); diff --git a/dom/base/nsJSEnvironment.cpp b/dom/base/nsJSEnvironment.cpp index f3895ba35cd1..887b4643539b 100644 --- a/dom/base/nsJSEnvironment.cpp +++ b/dom/base/nsJSEnvironment.cpp @@ -1330,9 +1330,7 @@ nsJSContext::AddSupportsPrimitiveTojsvals(nsISupports *aArg, JS::Value *aArgv) // cast is probably safe since wchar_t and jschar are expected // to be equivalent; both unsigned 16-bit entities JSString *str = - ::JS_NewUCStringCopyN(cx, - reinterpret_cast(data.get()), - data.Length()); + ::JS_NewUCStringCopyN(cx, data.get(), data.Length()); NS_ENSURE_TRUE(str, NS_ERROR_OUT_OF_MEMORY); *aArgv = STRING_TO_JSVAL(str); diff --git a/dom/plugins/base/nsJSNPRuntime.cpp b/dom/plugins/base/nsJSNPRuntime.cpp index d5b582e8655b..911e8ddf44c9 100644 --- a/dom/plugins/base/nsJSNPRuntime.cpp +++ b/dom/plugins/base/nsJSNPRuntime.cpp @@ -344,9 +344,7 @@ NPVariantToJSVal(NPP npp, JSContext *cx, const NPVariant *variant) NS_ConvertUTF8toUTF16 utf16String(s->UTF8Characters, s->UTF8Length); JSString *str = - ::JS_NewUCStringCopyN(cx, reinterpret_cast - (utf16String.get()), - utf16String.Length()); + ::JS_NewUCStringCopyN(cx, utf16String.get(), utf16String.Length()); if (str) { return STRING_TO_JSVAL(str); @@ -471,8 +469,7 @@ ThrowJSException(JSContext *cx, const char *message) AppendASCIItoUTF16("].", ucex); } - JSString *str = ::JS_NewUCStringCopyN(cx, (jschar *)ucex.get(), - ucex.Length()); + JSString *str = ::JS_NewUCStringCopyN(cx, ucex.get(), ucex.Length()); if (str) { JS::Rooted exn(cx, JS::StringValue(str)); diff --git a/dom/plugins/base/nsNPAPIPlugin.cpp b/dom/plugins/base/nsNPAPIPlugin.cpp index ddb54c564ace..dec5ae5dcabc 100644 --- a/dom/plugins/base/nsNPAPIPlugin.cpp +++ b/dom/plugins/base/nsNPAPIPlugin.cpp @@ -685,8 +685,7 @@ doGetIdentifier(JSContext *cx, const NPUTF8* name) { NS_ConvertUTF8toUTF16 utf16name(name); - JSString *str = ::JS_InternUCStringN(cx, (jschar *)utf16name.get(), - utf16name.Length()); + JSString *str = ::JS_InternUCStringN(cx, utf16name.get(), utf16name.Length()); if (!str) return nullptr; diff --git a/dom/plugins/base/nsPluginsDirWin.cpp b/dom/plugins/base/nsPluginsDirWin.cpp index 96b7f0c37b17..9e762668a819 100644 --- a/dom/plugins/base/nsPluginsDirWin.cpp +++ b/dom/plugins/base/nsPluginsDirWin.cpp @@ -36,7 +36,7 @@ * @return true if SetDllDirectory can be called for the plugin */ bool -ShouldProtectPluginCurrentDirectory(LPCWSTR pluginFilePath) +ShouldProtectPluginCurrentDirectory(char16ptr_t pluginFilePath) { LPCWSTR passedInFilename = PathFindFileName(pluginFilePath); if (!passedInFilename) { @@ -178,7 +178,7 @@ static void FreeStringArray(uint32_t variants, char ** array) PR_Free(array); } -static bool CanLoadPlugin(const PRUnichar* aBinaryPath) +static bool CanLoadPlugin(char16ptr_t aBinaryPath) { #if defined(_M_IX86) || defined(_M_X64) || defined(_M_IA64) bool canLoad = false; diff --git a/dom/plugins/ipc/PluginInstanceChild.cpp b/dom/plugins/ipc/PluginInstanceChild.cpp index 6627d6561ae1..09dd5877c6b8 100644 --- a/dom/plugins/ipc/PluginInstanceChild.cpp +++ b/dom/plugins/ipc/PluginInstanceChild.cpp @@ -20,7 +20,7 @@ #ifdef XP_WIN #include "mozilla/gfx/SharedDIBSurface.h" #include "nsCrashOnException.h" -extern const PRUnichar* kFlashFullscreenClass; +extern const wchar_t* kFlashFullscreenClass; using mozilla::gfx::SharedDIBSurface; #endif #include "gfxSharedImageSurface.h" @@ -1476,7 +1476,7 @@ PluginInstanceChild::PluginWindowProcInternal(HWND hWnd, // on the window. if (message == WM_LBUTTONDOWN && self->GetQuirks() & PluginModuleChild::QUIRK_FLASH_FIXUP_MOUSE_CAPTURE) { - PRUnichar szClass[26]; + wchar_t szClass[26]; HWND hwnd = GetForegroundWindow(); if (hwnd && GetClassNameW(hwnd, szClass, sizeof(szClass)/sizeof(PRUnichar)) && @@ -1675,7 +1675,7 @@ PluginInstanceChild::TrackPopupHookProc(HMENU hMenu, // Only change the parent when we know this is a context on the plugin // surface within the browser. Prevents resetting the parent on child ui // displayed by plugins that have working parent-child relationships. - PRUnichar szClass[21]; + wchar_t szClass[21]; bool haveClass = GetClassNameW(hWnd, szClass, ArrayLength(szClass)); if (!haveClass || (wcscmp(szClass, L"MozillaWindowClass") && @@ -2061,7 +2061,7 @@ PluginInstanceChild::EnumThreadWindowsCallback(HWND hWnd, return FALSE; } - PRUnichar className[64]; + wchar_t className[64]; if (!GetClassNameW(hWnd, className, sizeof(className)/sizeof(PRUnichar))) return TRUE; diff --git a/dom/plugins/ipc/PluginInstanceParent.cpp b/dom/plugins/ipc/PluginInstanceParent.cpp index 06ca425d1f4e..5e49cb9dcc35 100644 --- a/dom/plugins/ipc/PluginInstanceParent.cpp +++ b/dom/plugins/ipc/PluginInstanceParent.cpp @@ -42,10 +42,10 @@ #include "mozilla/plugins/PluginSurfaceParent.h" // Plugin focus event for widget. -extern const PRUnichar* kOOPPPluginFocusEventId; +extern const wchar_t* kOOPPPluginFocusEventId; UINT gOOPPPluginFocusEvent = RegisterWindowMessage(kOOPPPluginFocusEventId); -extern const PRUnichar* kFlashFullscreenClass; +extern const wchar_t* kFlashFullscreenClass; #elif defined(MOZ_WIDGET_GTK) #include #elif defined(XP_MACOSX) @@ -1213,7 +1213,7 @@ PluginInstanceParent::NPP_HandleEvent(void* event) // which fires WM_KILLFOCUS. Delayed delivery causes Flash to // misinterpret the event, dropping back out of fullscreen. Trap // this event and drop it. - PRUnichar szClass[26]; + wchar_t szClass[26]; HWND hwnd = GetForegroundWindow(); if (hwnd && hwnd != mPluginHWND && GetClassNameW(hwnd, szClass, @@ -1801,7 +1801,7 @@ PluginInstanceParent::RecvReleaseDXGISharedSurface(const DXGISharedSurfaceHandle which fires off a gui event letting the browser know. */ -static const PRUnichar kPluginInstanceParentProperty[] = +static const wchar_t kPluginInstanceParentProperty[] = L"PluginInstanceParentProperty"; // static diff --git a/dom/plugins/ipc/PluginModuleChild.cpp b/dom/plugins/ipc/PluginModuleChild.cpp index 92b47a1aff98..4e8989797daf 100644 --- a/dom/plugins/ipc/PluginModuleChild.cpp +++ b/dom/plugins/ipc/PluginModuleChild.cpp @@ -64,8 +64,8 @@ using mozilla::dom::CrashReporterChild; using mozilla::dom::PCrashReporterChild; #if defined(XP_WIN) -const PRUnichar * kFlashFullscreenClass = L"ShockwaveFlashFullScreen"; -const PRUnichar * kMozillaWindowClass = L"MozillaWindowClass"; +const wchar_t * kFlashFullscreenClass = L"ShockwaveFlashFullScreen"; +const wchar_t * kMozillaWindowClass = L"MozillaWindowClass"; #endif namespace { @@ -1910,7 +1910,7 @@ PMCGetWindowInfoHook(HWND hWnd, PWINDOWINFO pwi) } if (!sBrowserHwnd) { - PRUnichar szClass[20]; + wchar_t szClass[20]; if (GetClassNameW(hWnd, szClass, ArrayLength(szClass)) && !wcscmp(szClass, kMozillaWindowClass)) { sBrowserHwnd = hWnd; @@ -2331,7 +2331,7 @@ PluginModuleChild::CallWindowProcHook(int nCode, WPARAM wParam, LPARAM lParam) // core systems, sync killfocus events need to be handled // after the flash fullscreen window procedure processes this // message, otherwise fullscreen focus will not work correctly. - PRUnichar szClass[26]; + wchar_t szClass[26]; if (GetClassNameW(pCwp->hwnd, szClass, sizeof(szClass)/sizeof(PRUnichar)) && !wcscmp(szClass, kFlashFullscreenClass)) { diff --git a/dom/plugins/ipc/PluginProcessChild.cpp b/dom/plugins/ipc/PluginProcessChild.cpp index bb7b402a9025..057cc7475aed 100644 --- a/dom/plugins/ipc/PluginProcessChild.cpp +++ b/dom/plugins/ipc/PluginProcessChild.cpp @@ -15,7 +15,7 @@ #ifdef XP_WIN #include -bool ShouldProtectPluginCurrentDirectory(LPCWSTR pluginFilePath); +bool ShouldProtectPluginCurrentDirectory(char16ptr_t pluginFilePath); #endif using mozilla::ipc::IOThreadChild;