Bug 944427 - Fixed char16_t/wchar_t mismatch in dom/ r=bsmedberg
authorJacek Caban <jacek@codeweavers.com>
Wed, 04 Dec 2013 13:19:38 +0100
changeset 174451 fc2b0e721cd13a69b9314c83ff73b571d6780028
parent 174450 28f646255d25df67c5bf0bd338bb37c9d8a2b34b
child 174452 8f4eaade578ec45187d4cc4680b734cf6bfbed31
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs944427
milestone28.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 944427 - Fixed char16_t/wchar_t mismatch in dom/ r=bsmedberg
dom/base/nsDOMClassInfo.cpp
dom/base/nsJSEnvironment.cpp
dom/plugins/base/nsJSNPRuntime.cpp
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/base/nsPluginsDirWin.cpp
dom/plugins/ipc/PluginInstanceChild.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
dom/plugins/ipc/PluginModuleChild.cpp
dom/plugins/ipc/PluginProcessChild.cpp
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -4492,19 +4492,17 @@ nsStorage2SH::NewEnumerate(nsIXPConnectW
   }
 
   nsTArray<nsString> *keys =
     (nsTArray<nsString> *)JSVAL_TO_PRIVATE(*statep);
 
   if (enum_op == JSENUMERATE_NEXT && keys->Length() != 0) {
     nsString& key = keys->ElementAt(0);
     JSString *str =
-      JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar *>
-                                              (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);
 
     keys->RemoveElementAt(0);
 
     return NS_OK;
   }
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -1325,19 +1325,17 @@ nsJSContext::AddSupportsPrimitiveTojsval
 
       nsAutoString data;
 
       p->GetData(data);
 
       // 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<const jschar *>(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);
       break;
     }
     case nsISupportsPrimitive::TYPE_PRBOOL : {
       nsCOMPtr<nsISupportsPRBool> p(do_QueryInterface(argPrimitive));
       NS_ENSURE_TRUE(p, NS_ERROR_UNEXPECTED);
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -339,19 +339,17 @@ NPVariantToJSVal(NPP npp, JSContext *cx,
       return ::JS_NumberValue(NPVARIANT_TO_DOUBLE(*variant));
     }
   case NPVariantType_String :
     {
       const NPString *s = &NPVARIANT_TO_STRING(*variant);
       NS_ConvertUTF8toUTF16 utf16String(s->UTF8Characters, s->UTF8Length);
 
       JSString *str =
-        ::JS_NewUCStringCopyN(cx, reinterpret_cast<const jschar*>
-                                                  (utf16String.get()),
-                              utf16String.Length());
+        ::JS_NewUCStringCopyN(cx, utf16String.get(), utf16String.Length());
 
       if (str) {
         return STRING_TO_JSVAL(str);
       }
 
       break;
     }
   case NPVariantType_Object:
@@ -466,18 +464,17 @@ ThrowJSException(JSContext *cx, const ch
     }
 
     AppendUTF8toUTF16(ex, ucex);
 
     if (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<JS::Value> exn(cx, JS::StringValue(str));
       ::JS_SetPendingException(cx, exn);
     }
 
     PopException();
   } else {
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -680,18 +680,17 @@ GetChannelFromNPP(NPP npp)
   return channel.forget();
 }
 
 static NPIdentifier
 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;
 
   return StringToNPIdentifier(cx, str);
 }
 
 #if defined(MOZ_MEMORY_WINDOWS)
--- a/dom/plugins/base/nsPluginsDirWin.cpp
+++ b/dom/plugins/base/nsPluginsDirWin.cpp
@@ -31,17 +31,17 @@
 #define SHOCKWAVE_BASE_FILENAME L"np32dsw"
 /**
  * Determines whether or not SetDllDirectory should be called for this plugin.
  *
  * @param pluginFilePath The full path of the plugin file
  * @return true if SetDllDirectory can be called for the plugin
  */
 bool
-ShouldProtectPluginCurrentDirectory(LPCWSTR pluginFilePath)
+ShouldProtectPluginCurrentDirectory(char16ptr_t pluginFilePath)
 {
   LPCWSTR passedInFilename = PathFindFileName(pluginFilePath);
   if (!passedInFilename) {
     return true;
   }
 
   // Somewhere in the middle of 11.6 version of Shockwave, naming of the DLL
   // after its version number is introduced.
@@ -173,17 +173,17 @@ static void FreeStringArray(uint32_t var
     if (array[i]) {
       PL_strfree(array[i]);
       array[i] = nullptr;
     }
   }
   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;
 
   HANDLE file = CreateFileW(aBinaryPath, GENERIC_READ,
                             FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
                             OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
   if (file != INVALID_HANDLE_VALUE) {
--- a/dom/plugins/ipc/PluginInstanceChild.cpp
+++ b/dom/plugins/ipc/PluginInstanceChild.cpp
@@ -15,17 +15,17 @@
 #include "gfxContext.h"
 #include "nsNPAPIPluginInstance.h"
 #ifdef MOZ_X11
 #include "gfxXlibSurface.h"
 #endif
 #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"
 #include "gfxUtils.h"
 #include "gfxAlphaRecovery.h"
 
 #include "mozilla/Util.h"
 #include "mozilla/ipc/MessageChannel.h"
@@ -1471,17 +1471,17 @@ PluginInstanceChild::PluginWindowProcInt
                                  lParam);
 
     // Make sure capture is released by the child on mouse events. Fixes a
     // problem with flash full screen mode mouse input. Appears to be
     // caused by a bug in flash, since we are not setting the capture
     // 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)) &&
           !wcscmp(szClass, kFlashFullscreenClass)) {
         ReleaseCapture();
         SetFocus(hwnd);
       }
     }
@@ -1670,17 +1670,17 @@ PluginInstanceChild::TrackPopupHookProc(
   if (!sUser32TrackPopupMenuStub) {
       NS_ERROR("TrackPopupMenu stub isn't set! Badness!");
       return 0;
   }
 
   // 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") &&
        wcscmp(szClass, L"SWFlash_Placeholder"))) {
       // Unrecognized parent
       return sUser32TrackPopupMenuStub(hMenu, uFlags, x, y, nReserved,
                                        hWnd, prcRect);
   }
@@ -2056,17 +2056,17 @@ PluginInstanceChild::EnumThreadWindowsCa
                                                LPARAM aParam)
 {
     PluginInstanceChild* self = reinterpret_cast<PluginInstanceChild*>(aParam);
     if (!self) {
         NS_NOTREACHED("Enum befuddled!");
         return FALSE;
     }
 
-    PRUnichar className[64];
+    wchar_t className[64];
     if (!GetClassNameW(hWnd, className, sizeof(className)/sizeof(PRUnichar)))
       return TRUE;
     
     if (!wcscmp(className, L"SWFlash_PlaceholderX")) {
         WNDPROC oldWndProc =
             reinterpret_cast<WNDPROC>(GetWindowLongPtr(hWnd, GWLP_WNDPROC));
         // Only set this if we haven't already.
         if (oldWndProc != WinlessHiddenFlashWndProc) {
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -37,20 +37,20 @@
 #endif
 
 #if defined(OS_WIN)
 #include <windowsx.h>
 #include "gfxWindowsPlatform.h"
 #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 <gdk/gdk.h>
 #elif defined(XP_MACOSX)
 #include <ApplicationServices/ApplicationServices.h>
 #endif // defined(XP_MACOSX)
 
 using namespace mozilla::plugins;
 using namespace mozilla::layers;
@@ -1208,17 +1208,17 @@ PluginInstanceParent::NPP_HandleEvent(vo
             case WM_KILLFOCUS:
             {
               // When the user selects fullscreen mode in Flash video players,
               // WM_KILLFOCUS will be delayed by deferred event processing:
               // WM_LBUTTONUP results in a call to CreateWindow within Flash,
               // 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,
                                 sizeof(szClass)/sizeof(PRUnichar)) &&
                   !wcscmp(szClass, kFlashFullscreenClass)) {
                   return 0;
               }
             }
@@ -1796,17 +1796,17 @@ PluginInstanceParent::RecvReleaseDXGISha
     that over ipc to the child which calls set focus on itself. 
 
   focus from child -> focus manager:
     Child picks up the local wm_setfocus and sends it via ipc over
     here. We then post a custom event to widget/windows/nswindow
     which fires off a gui event letting the browser know.
 */
 
-static const PRUnichar kPluginInstanceParentProperty[] =
+static const wchar_t kPluginInstanceParentProperty[] =
                          L"PluginInstanceParentProperty";
 
 // static
 LRESULT CALLBACK
 PluginInstanceParent::PluginWindowHookProc(HWND hWnd,
                                            UINT message,
                                            WPARAM wParam,
                                            LPARAM lParam)
--- a/dom/plugins/ipc/PluginModuleChild.cpp
+++ b/dom/plugins/ipc/PluginModuleChild.cpp
@@ -59,18 +59,18 @@
 #include "GeckoProfiler.h"
 
 using namespace mozilla;
 using namespace mozilla::plugins;
 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 {
 PluginModuleChild* gInstance = nullptr;
 }
 
 #ifdef MOZ_WIDGET_QT
 typedef void (*_gtk_init_fn)(int argc, char **argv);
@@ -1905,17 +1905,17 @@ PMCGetWindowInfoHook(HWND hWnd, PWINDOWI
       return FALSE;
 
   if (!sGetWindowInfoPtrStub) {
      NS_ASSERTION(FALSE, "Something is horribly wrong in PMCGetWindowInfoHook!");
      return FALSE;
   }
 
   if (!sBrowserHwnd) {
-      PRUnichar szClass[20];
+      wchar_t szClass[20];
       if (GetClassNameW(hWnd, szClass, ArrayLength(szClass)) &&
           !wcscmp(szClass, kMozillaWindowClass)) {
           sBrowserHwnd = hWnd;
       }
   }
   // Oddity: flash does strange rect comparisons for mouse input destined for
   // it's internal settings window. Post removing sub widgets for tabs, touch
   // this up so they get the rect they expect.
@@ -2326,17 +2326,17 @@ PluginModuleChild::CallWindowProcHook(in
     if (nCode >= 0 &&
         (InSendMessageEx(nullptr)&(ISMEX_REPLIED|ISMEX_SEND)) == ISMEX_SEND) {
         CWPSTRUCT* pCwp = reinterpret_cast<CWPSTRUCT*>(lParam);
         if (pCwp->message == WM_KILLFOCUS) {
             // Fix for flash fullscreen window loosing focus. On single
             // 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)) {
                 gDelayFlashFocusReplyUntilEval = true;
             }
         }
     }
 
--- a/dom/plugins/ipc/PluginProcessChild.cpp
+++ b/dom/plugins/ipc/PluginProcessChild.cpp
@@ -10,17 +10,17 @@
 #include "prlink.h"
 
 #include "base/command_line.h"
 #include "base/string_util.h"
 #include "chrome/common/chrome_switches.h"
 
 #ifdef XP_WIN
 #include <objbase.h>
-bool ShouldProtectPluginCurrentDirectory(LPCWSTR pluginFilePath);
+bool ShouldProtectPluginCurrentDirectory(char16ptr_t pluginFilePath);
 #endif
 
 using mozilla::ipc::IOThreadChild;
 
 #ifdef OS_WIN
 #include "nsSetDllDirectory.h"
 #include <algorithm>