Bug 944894 - Fix char16_t/wchar_t mismatch in widget/windows/. r=jimm
authorJacek Caban <jacek@codeweavers.com>
Tue, 03 Dec 2013 16:12:57 +0100
changeset 158568 eba1adf9482af8a9b7dd2d2b77095e94f1177f3d
parent 158567 32fcd54fd18b111cf6d4ade2276d0a04ca9e56fe
child 158569 933c28b72a55c72845845a8c7240fd01a0cf2876
push id25749
push userryanvm@gmail.com
push dateTue, 03 Dec 2013 21:45:20 +0000
treeherdermozilla-central@85694fd9b17c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs944894
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 944894 - Fix char16_t/wchar_t mismatch in widget/windows/. r=jimm
widget/windows/AudioSession.cpp
widget/windows/GfxInfo.cpp
widget/windows/JumpListBuilder.cpp
widget/windows/JumpListItem.cpp
widget/windows/KeyboardLayout.h
widget/windows/TaskbarTabPreview.cpp
widget/windows/WinMouseScrollHandler.cpp
widget/windows/WinTaskbar.cpp
widget/windows/WinUtils.cpp
widget/windows/WinUtils.h
widget/windows/nsAppShell.cpp
widget/windows/nsBidiKeyboard.cpp
widget/windows/nsBidiKeyboard.h
widget/windows/nsClipboard.cpp
widget/windows/nsDeviceContextSpecWin.cpp
widget/windows/nsDeviceContextSpecWin.h
widget/windows/nsFilePicker.cpp
widget/windows/nsFilePicker.h
widget/windows/nsPrintSettingsWin.cpp
widget/windows/nsPrintSettingsWin.h
widget/windows/nsTextStore.cpp
widget/windows/nsUXThemeData.cpp
widget/windows/nsUXThemeData.h
widget/windows/nsWinGesture.cpp
widget/windows/nsWinGesture.h
widget/windows/nsWindow.cpp
--- a/widget/windows/AudioSession.cpp
+++ b/widget/windows/AudioSession.cpp
@@ -205,17 +205,17 @@ AudioSession::Start()
     nsCOMPtr<nsIStringBundle> bundle;
     bundleService->CreateBundle("chrome://branding/locale/brand.properties",
                                 getter_AddRefs(bundle));
     NS_ENSURE_TRUE(bundle, NS_ERROR_FAILURE);
 
     bundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
                               getter_Copies(mDisplayName));
 
-    PRUnichar *buffer;
+    wchar_t *buffer;
     mIconPath.GetMutableData(&buffer, MAX_PATH);
 
     // XXXkhuey we should provide a way for a xulrunner app to specify an icon
     // that's not in the product binary.
     ::GetModuleFileNameW(nullptr, buffer, MAX_PATH);
 
     nsCOMPtr<nsIUUIDGenerator> uuidgen =
       do_GetService("@mozilla.org/uuid-generator;1");
--- a/widget/windows/GfxInfo.cpp
+++ b/widget/windows/GfxInfo.cpp
@@ -72,66 +72,54 @@ GfxInfo::GetCleartypeParameters(nsAStrin
 {
   nsTArray<ClearTypeParameterInfo> clearTypeParams;
 
   gfxWindowsPlatform::GetPlatform()->GetCleartypeParams(clearTypeParams);
   uint32_t d, numDisplays = clearTypeParams.Length();
   bool displayNames = (numDisplays > 1);
   bool foundData = false;
   nsString outStr;
-  WCHAR valStr[256];
 
   for (d = 0; d < numDisplays; d++) {
     ClearTypeParameterInfo& params = clearTypeParams[d];
 
     if (displayNames) {
-      swprintf_s(valStr, ArrayLength(valStr),
-                 L"%s [ ", params.displayName.get());
-      outStr.Append(valStr);
+      outStr.AppendPrintf("%s [ ", params.displayName.get());
     }
 
     if (params.gamma >= 0) {
       foundData = true;
-      swprintf_s(valStr, ArrayLength(valStr),
-                 L"Gamma: %d ", params.gamma);
-      outStr.Append(valStr);
+      outStr.AppendPrintf("Gamma: %d ", params.gamma);
     }
 
     if (params.pixelStructure >= 0) {
       foundData = true;
       if (params.pixelStructure == PIXEL_STRUCT_RGB ||
           params.pixelStructure == PIXEL_STRUCT_BGR)
       {
-        swprintf_s(valStr, ArrayLength(valStr),
-                   L"Pixel Structure: %s ",
+        outStr.AppendPrintf("Pixel Structure: %s ",
                    (params.pixelStructure == PIXEL_STRUCT_RGB ?
                       L"RGB" : L"BGR"));
       } else {
-        swprintf_s(valStr, ArrayLength(valStr),
-                   L"Pixel Structure: %d ", params.pixelStructure);
+        outStr.AppendPrintf("Pixel Structure: %d ", params.pixelStructure);
       }
-      outStr.Append(valStr);
     }
 
     if (params.clearTypeLevel >= 0) {
       foundData = true;
-      swprintf_s(valStr, ArrayLength(valStr),
-                 L"ClearType Level: %d ", params.clearTypeLevel);
-      outStr.Append(valStr);
+      outStr.AppendPrintf("ClearType Level: %d ", params.clearTypeLevel);
     }
 
     if (params.enhancedContrast >= 0) {
       foundData = true;
-      swprintf_s(valStr, ArrayLength(valStr),
-                 L"Enhanced Contrast: %d ", params.enhancedContrast);
-      outStr.Append(valStr);
+      outStr.AppendPrintf("Enhanced Contrast: %d ", params.enhancedContrast);
     }
 
     if (displayNames) {
-      outStr.Append(L"] ");
+      outStr.Append(MOZ_UTF16("] "));
     }
   }
 
   if (foundData) {
     aCleartypeParams.Assign(outStr);
     return NS_OK;
   }
   return NS_ERROR_FAILURE;
@@ -367,17 +355,17 @@ GfxInfo::Init()
                                             &devinfoData,
                                             SPDRP_DRIVER,
                                             nullptr,
                                             (PBYTE)value,
                                             sizeof(value),
                                             nullptr)) {
         nsAutoString driverKey(driverKeyPre);
         driverKey += value;
-        result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey.BeginReading(), 0, KEY_QUERY_VALUE, &key);
+        result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey.get(), 0, KEY_QUERY_VALUE, &key);
         if (result == ERROR_SUCCESS) {
           /* we've found the driver we're looking for */
           dwcbData = sizeof(value);
           result = RegQueryValueExW(key, L"DriverVersion", nullptr, nullptr,
                                     (LPBYTE)value, &dwcbData);
           if (result == ERROR_SUCCESS) {
             mDriverVersion = value;
           } else {
@@ -441,17 +429,17 @@ GfxInfo::Init()
                                               &devinfoData,
                                               SPDRP_DRIVER,
                                               nullptr,
                                               (PBYTE)value,
                                               sizeof(value),
                                               nullptr)) {
           nsAutoString driverKey2(driverKeyPre);
           driverKey2 += value;
-          result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey2.BeginReading(), 0, KEY_QUERY_VALUE, &key);
+          result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, driverKey2.get(), 0, KEY_QUERY_VALUE, &key);
           if (result == ERROR_SUCCESS) {
             dwcbData = sizeof(value);
             result = RegQueryValueExW(key, L"MatchingDeviceId", nullptr,
                                       nullptr, (LPBYTE)value, &dwcbData);
             if (result != ERROR_SUCCESS) {
               continue;
             }
             deviceID2 = value;
@@ -464,17 +452,17 @@ GfxInfo::Init()
             if (mAdapterVendorID == adapterVendorID2String &&
                 mAdapterDeviceID == adapterDeviceID2String) {
               RegCloseKey(key);
               continue;
             }
 
             // If this device is missing driver information, it is unlikely to
             // be a real display adapter.
-            if (NS_FAILED(GetKeyValue(driverKey2.BeginReading(), L"InstalledDisplayDrivers",
+            if (NS_FAILED(GetKeyValue(driverKey2.get(), L"InstalledDisplayDrivers",
                            adapterDriver2, REG_MULTI_SZ))) {
               RegCloseKey(key);
               continue;
             }
             dwcbData = sizeof(value);
             result = RegQueryValueExW(key, L"DriverVersion", nullptr, nullptr,
                                       (LPBYTE)value, &dwcbData);
             if (result != ERROR_SUCCESS) {
@@ -521,21 +509,21 @@ GfxInfo::Init()
 
   mHasDriverVersionMismatch = false;
   if (mAdapterVendorID == GfxDriverInfo::GetDeviceVendor(VendorIntel)) {
     // we've had big crashers (bugs 590373 and 595364) apparently correlated
     // with bad Intel driver installations where the DriverVersion reported
     // by the registry was not the version of the DLL.
     bool is64bitApp = sizeof(void*) == 8;
     const PRUnichar *dllFileName = is64bitApp
-                                 ? L"igd10umd64.dll"
-                                 : L"igd10umd32.dll",
+                                 ? MOZ_UTF16("igd10umd64.dll")
+                                 : MOZ_UTF16("igd10umd32.dll"),
                     *dllFileName2 = is64bitApp
-                                 ? L"igd10iumd64.dll"
-                                 : L"igd10iumd32.dll";
+                                 ? MOZ_UTF16("igd10iumd64.dll")
+                                 : MOZ_UTF16("igd10iumd32.dll");
     nsString dllVersion, dllVersion2;
     gfxWindowsPlatform::GetDLLVersion((PRUnichar*)dllFileName, dllVersion);
     gfxWindowsPlatform::GetDLLVersion((PRUnichar*)dllFileName2, dllVersion2);
 
     uint64_t dllNumericVersion = 0, dllNumericVersion2 = 0,
              driverNumericVersion = 0, knownSafeMismatchVersion = 0;
     ParseDriverVersion(dllVersion, &dllNumericVersion);
     ParseDriverVersion(dllVersion2, &dllNumericVersion2);
@@ -589,49 +577,49 @@ GfxInfo::GetAdapterDescription2(nsAStrin
   aAdapterDescription = mDeviceString2;
   return NS_OK;
 }
 
 /* readonly attribute DOMString adapterRAM; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterRAM(nsAString & aAdapterRAM)
 {
-  if (NS_FAILED(GetKeyValue(mDeviceKey.BeginReading(), L"HardwareInformation.MemorySize", aAdapterRAM, REG_DWORD)))
+  if (NS_FAILED(GetKeyValue(mDeviceKey.get(), L"HardwareInformation.MemorySize", aAdapterRAM, REG_DWORD)))
     aAdapterRAM = L"Unknown";
   return NS_OK;
 }
 
 /* readonly attribute DOMString adapterRAM2; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterRAM2(nsAString & aAdapterRAM)
 {
   if (!mHasDualGPU) {
     aAdapterRAM.AssignLiteral("");
-  } else if (NS_FAILED(GetKeyValue(mDeviceKey2.BeginReading(), L"HardwareInformation.MemorySize", aAdapterRAM, REG_DWORD))) {
+  } else if (NS_FAILED(GetKeyValue(mDeviceKey2.get(), L"HardwareInformation.MemorySize", aAdapterRAM, REG_DWORD))) {
     aAdapterRAM = L"Unknown";
   }
   return NS_OK;
 }
 
 /* readonly attribute DOMString adapterDriver; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDriver(nsAString & aAdapterDriver)
 {
-  if (NS_FAILED(GetKeyValue(mDeviceKey.BeginReading(), L"InstalledDisplayDrivers", aAdapterDriver, REG_MULTI_SZ)))
+  if (NS_FAILED(GetKeyValue(mDeviceKey.get(), L"InstalledDisplayDrivers", aAdapterDriver, REG_MULTI_SZ)))
     aAdapterDriver = L"Unknown";
   return NS_OK;
 }
 
 /* readonly attribute DOMString adapterDriver2; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDriver2(nsAString & aAdapterDriver)
 {
   if (!mHasDualGPU) {
     aAdapterDriver.AssignLiteral("");
-  } else if (NS_FAILED(GetKeyValue(mDeviceKey2.BeginReading(), L"InstalledDisplayDrivers", aAdapterDriver, REG_MULTI_SZ))) {
+  } else if (NS_FAILED(GetKeyValue(mDeviceKey2.get(), L"InstalledDisplayDrivers", aAdapterDriver, REG_MULTI_SZ))) {
     aAdapterDriver = L"Unknown";
   }
   return NS_OK;
 }
 
 /* readonly attribute DOMString adapterDriverVersion; */
 NS_IMETHODIMP
 GfxInfo::GetAdapterDriverVersion(nsAString & aAdapterDriverVersion)
--- a/widget/windows/JumpListBuilder.cpp
+++ b/widget/windows/JumpListBuilder.cpp
@@ -371,17 +371,17 @@ NS_IMETHODIMP JumpListBuilder::AddListTo
 
       // We need IObjectArray to submit
       nsRefPtr<IObjectArray> pArray;
       hr = collection->QueryInterface(IID_IObjectArray, (LPVOID*)&pArray);
       if (FAILED(hr))
         return NS_ERROR_UNEXPECTED;
 
       // Add the tasks
-      hr = mJumpListMgr->AppendCategory(catName.BeginReading(), pArray);
+      hr = mJumpListMgr->AppendCategory(reinterpret_cast<const wchar_t*>(catName.BeginReading()), pArray);
       if (SUCCEEDED(hr))
         *_retval = true;
       return NS_OK;
     }
     break;
   }
   return NS_OK;
 }
--- a/widget/windows/JumpListItem.cpp
+++ b/widget/windows/JumpListItem.cpp
@@ -424,17 +424,17 @@ nsresult JumpListShortcut::GetShellLink(
   aShellLink = dont_AddRef(psl);
 
   return NS_OK;
 }
 
 // If successful fills in the aSame parameter
 // aSame will be true if the path is in our icon cache
 static nsresult IsPathInOurIconCache(nsCOMPtr<nsIJumpListShortcut>& aShortcut, 
-                                     PRUnichar *aPath, bool *aSame)
+                                     wchar_t *aPath, bool *aSame)
 {
   NS_ENSURE_ARG_POINTER(aPath);
   NS_ENSURE_ARG_POINTER(aSame);
  
   *aSame = false;
 
   // Construct the path of our jump list cache
   nsCOMPtr<nsIFile> jumpListCache;
@@ -468,33 +468,33 @@ nsresult JumpListShortcut::GetJumpListSh
 
   nsresult rv;
   HRESULT hres;
 
   nsCOMPtr<nsILocalHandlerApp> handlerApp = 
     do_CreateInstance(NS_LOCALHANDLERAPP_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  PRUnichar buf[MAX_PATH];
+  wchar_t buf[MAX_PATH];
 
   // Path
-  hres = pLink->GetPath((LPWSTR)&buf, MAX_PATH, nullptr, SLGP_UNCPRIORITY);
+  hres = pLink->GetPath(buf, MAX_PATH, nullptr, SLGP_UNCPRIORITY);
   if (FAILED(hres))
     return NS_ERROR_INVALID_ARG;
 
   nsCOMPtr<nsIFile> file;
   nsDependentString filepath(buf);
   rv = NS_NewLocalFile(filepath, false, getter_AddRefs(file));
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = handlerApp->SetExecutable(file);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Parameters
-  hres = pLink->GetArguments((LPWSTR)&buf, MAX_PATH);
+  hres = pLink->GetArguments(buf, MAX_PATH);
   if (SUCCEEDED(hres)) {
     LPWSTR *arglist;
     int32_t numArgs;
     int32_t idx;
 
     arglist = ::CommandLineToArgvW(buf, &numArgs);
     if(arglist) {
       for (idx = 0; idx < numArgs; idx++) {
@@ -506,25 +506,25 @@ nsresult JumpListShortcut::GetJumpListSh
     }
   }
 
   rv = aShortcut->SetApp(handlerApp);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Icon index or file location
   int iconIdx = 0;
-  hres = pLink->GetIconLocation((LPWSTR)&buf, MAX_PATH, &iconIdx);
+  hres = pLink->GetIconLocation(buf, MAX_PATH, &iconIdx);
   if (SUCCEEDED(hres)) {
     // XXX How do we handle converting local files to images here? Do we need to?
     aShortcut->SetIconIndex(iconIdx);
 
     // Obtain the local profile directory and construct the output icon file path
     // We only set the Icon Uri if we're sure it was from our icon cache.
     bool isInOurCache;
-    if (NS_SUCCEEDED(IsPathInOurIconCache(aShortcut, buf, &isInOurCache)) && 
+    if (NS_SUCCEEDED(IsPathInOurIconCache(aShortcut, buf, &isInOurCache)) &&
         isInOurCache) {
       nsCOMPtr<nsIURI> iconUri;
       nsAutoString path(buf);
       rv = NS_NewURI(getter_AddRefs(iconUri), path);
       if (NS_SUCCEEDED(rv)) {
         aShortcut->SetFaviconPageUri(iconUri);
       }
     }
--- a/widget/windows/KeyboardLayout.h
+++ b/widget/windows/KeyboardLayout.h
@@ -60,22 +60,22 @@ class ModifierKeyState
 public:
   ModifierKeyState();
   ModifierKeyState(bool aIsShiftDown, bool aIsControlDown, bool aIsAltDown);
   ModifierKeyState(Modifiers aModifiers);
 
   MOZ_ALWAYS_INLINE void Update();
 
   MOZ_ALWAYS_INLINE void Unset(Modifiers aRemovingModifiers);
-  MOZ_ALWAYS_INLINE void Set(Modifiers aAddingModifiers);
+  void Set(Modifiers aAddingModifiers);
 
   void InitInputEvent(WidgetInputEvent& aInputEvent) const;
 
-  MOZ_ALWAYS_INLINE bool IsShift() const;
-  MOZ_ALWAYS_INLINE bool IsControl() const;
+  bool IsShift() const;
+  bool IsControl() const;
   MOZ_ALWAYS_INLINE bool IsAlt() const;
   MOZ_ALWAYS_INLINE bool IsAltGr() const;
   MOZ_ALWAYS_INLINE bool IsWin() const;
 
   MOZ_ALWAYS_INLINE bool IsCapsLocked() const;
   MOZ_ALWAYS_INLINE bool IsNumLocked() const;
   MOZ_ALWAYS_INLINE bool IsScrollLocked() const;
 
--- a/widget/windows/TaskbarTabPreview.cpp
+++ b/widget/windows/TaskbarTabPreview.cpp
@@ -13,17 +13,17 @@
 
 #define TASKBARPREVIEW_HWNDID L"TaskbarTabPreviewHwnd"
 
 namespace mozilla {
 namespace widget {
 
 NS_IMPL_ISUPPORTS1(TaskbarTabPreview, nsITaskbarTabPreview)
 
-const PRUnichar *const kWindowClass = L"MozillaTaskbarPreviewClass";
+const wchar_t *const kWindowClass = L"MozillaTaskbarPreviewClass";
 
 TaskbarTabPreview::TaskbarTabPreview(ITaskbarList4 *aTaskbar, nsITaskbarPreviewController *aController, HWND aHWND, nsIDocShell *aShell)
   : TaskbarPreview(aTaskbar, aController, aHWND, aShell),
     mProxyWindow(nullptr),
     mIcon(nullptr),
     mRegistered(false)
 {
   WindowHook &hook = GetWindowHook();
--- a/widget/windows/WinMouseScrollHandler.cpp
+++ b/widget/windows/WinMouseScrollHandler.cpp
@@ -1137,17 +1137,17 @@ MouseScrollHandler::Device::Elantech::In
      "sUsePinchHack=%s",
      version, GetBoolName(sUseSwipeHack), GetBoolName(sUsePinchHack)));
 }
 
 /* static */
 int32_t
 MouseScrollHandler::Device::Elantech::GetDriverMajorVersion()
 {
-  PRUnichar buf[40];
+  wchar_t buf[40];
   // The driver version is found in one of these two registry keys.
   bool foundKey =
     WinUtils::GetRegistryKey(HKEY_CURRENT_USER,
                              L"Software\\Elantech\\MainOption",
                              L"DriverVersion",
                              buf, sizeof buf);
   if (!foundKey) {
     foundKey =
@@ -1158,45 +1158,45 @@ MouseScrollHandler::Device::Elantech::Ge
   }
 
   if (!foundKey) {
     return 0;
   }
 
   // Assume that the major version number can be found just after a space
   // or at the start of the string.
-  for (PRUnichar* p = buf; *p; p++) {
+  for (wchar_t* p = buf; *p; p++) {
     if (*p >= L'0' && *p <= L'9' && (p == buf || *(p - 1) == L' ')) {
       return wcstol(p, nullptr, 10);
     }
   }
 
   return 0;
 }
 
 /* static */
 bool
 MouseScrollHandler::Device::Elantech::IsHelperWindow(HWND aWnd)
 {
   // The helper window cannot be distinguished based on its window class, so we
   // need to check if it is owned by the helper process, ETDCtrl.exe.
 
-  const PRUnichar* filenameSuffix = L"\\etdctrl.exe";
+  const wchar_t* filenameSuffix = L"\\etdctrl.exe";
   const int filenameSuffixLength = 12;
 
   DWORD pid;
   ::GetWindowThreadProcessId(aWnd, &pid);
 
   HANDLE hProcess = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
   if (!hProcess) {
     return false;
   }
 
   bool result = false;
-  PRUnichar path[256] = {L'\0'};
+  wchar_t path[256] = {L'\0'};
   if (::GetProcessImageFileNameW(hProcess, path, ArrayLength(path))) {
     int pathLength = lstrlenW(path);
     if (pathLength >= filenameSuffixLength) {
       if (lstrcmpiW(path + pathLength - filenameSuffixLength,
                     filenameSuffix) == 0) {
         result = true;
       }
     }
@@ -1384,32 +1384,32 @@ MouseScrollHandler::Device::UltraNav::Is
        "Synaptics's UltraNav (PS/2) driver is found"));
     installed = true;
   }
 
   if (!installed) {
     return false;
   }
 
-  PRUnichar buf[40];
+  wchar_t buf[40];
   bool foundKey =
     WinUtils::GetRegistryKey(HKEY_LOCAL_MACHINE,
                              L"Software\\Synaptics\\SynTP\\Install",
                              L"DriverVersion",
                              buf, sizeof buf);
   if (!foundKey) {
     PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
       ("MouseScroll::Device::UltraNav::IsObsoleteDriverInstalled(): "
        "Failed to get UltraNav driver version"));
     return false;
   }
 
   int majorVersion = wcstol(buf, nullptr, 10);
   int minorVersion = 0;
-  PRUnichar* p = wcschr(buf, L'.');
+  wchar_t* p = wcschr(buf, L'.');
   if (p) {
     minorVersion = wcstol(p + 1, nullptr, 10);
   }
   PR_LOG(gMouseScrollLog, PR_LOG_ALWAYS,
     ("MouseScroll::Device::UltraNav::IsObsoleteDriverInstalled(): "
      "found driver version = %d.%d",
      majorVersion, minorVersion));
   return majorVersion < 15 || (majorVersion == 15 && minorVersion == 0);
--- a/widget/windows/WinTaskbar.cpp
+++ b/widget/windows/WinTaskbar.cpp
@@ -29,17 +29,17 @@
 #include "nsAppDirectoryServiceDefs.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/WindowsVersion.h"
 #include <io.h>
 #include <propvarutil.h>
 #include <propkey.h>
 #include <shellapi.h>
 
-const PRUnichar kShellLibraryName[] =  L"shell32.dll";
+const wchar_t kShellLibraryName[] =  L"shell32.dll";
 
 static NS_DEFINE_CID(kJumpListBuilderCID, NS_WIN_JUMPLISTBUILDER_CID);
 
 namespace {
 
 HWND
 GetHWNDFromDocShell(nsIDocShell *aShell) {
   nsCOMPtr<nsIBaseWindow> baseWindow(do_QueryInterface(reinterpret_cast<nsISupports*>(aShell)));
@@ -286,24 +286,24 @@ WinTaskbar::GetAppUserModelID(nsAString 
 
   nsAutoString regKey;
   regKey.AssignLiteral("Software\\Mozilla\\");
   AppendASCIItoUTF16(appName, regKey);
   regKey.AppendLiteral("\\TaskBarIDs");
 
   WCHAR path[MAX_PATH];
   if (GetModuleFileNameW(nullptr, path, MAX_PATH)) {
-    PRUnichar* slash = wcsrchr(path, '\\');
+    wchar_t* slash = wcsrchr(path, '\\');
     if (!slash)
       return false;
     *slash = '\0'; // no trailing slash
 
     // The hash is short, but users may customize this, so use a respectable
     // string buffer.
-    PRUnichar buf[256];
+    wchar_t buf[256];
     if (WinUtils::GetRegistryKey(HKEY_LOCAL_MACHINE,
                                  regKey.get(),
                                  path,
                                  buf,
                                  sizeof buf)) {
       aDefaultGroupId.Assign(buf);
     } else if (WinUtils::GetRegistryKey(HKEY_CURRENT_USER,
                                         regKey.get(),
--- a/widget/windows/WinUtils.cpp
+++ b/widget/windows/WinUtils.cpp
@@ -61,19 +61,19 @@ const char FaviconHelper::kJumpListCache
 const char FaviconHelper::kShortcutCacheDir[] = "shortcutCache";
 
 // apis available on vista and up.
 WinUtils::SHCreateItemFromParsingNamePtr WinUtils::sCreateItemFromParsingName = nullptr;
 WinUtils::SHGetKnownFolderPathPtr WinUtils::sGetKnownFolderPath = nullptr;
 
 // We just leak these DLL HMODULEs. There's no point in calling FreeLibrary
 // on them during shutdown anyway.
-static const PRUnichar kShellLibraryName[] =  L"shell32.dll";
+static const wchar_t kShellLibraryName[] =  L"shell32.dll";
 static HMODULE sShellDll = nullptr;
-static const PRUnichar kDwmLibraryName[] = L"dwmapi.dll";
+static const wchar_t kDwmLibraryName[] = L"dwmapi.dll";
 static HMODULE sDwmDll = nullptr;
 
 WinUtils::DwmExtendFrameIntoClientAreaProc WinUtils::dwmExtendFrameIntoClientAreaPtr = nullptr;
 WinUtils::DwmIsCompositionEnabledProc WinUtils::dwmIsCompositionEnabledPtr = nullptr;
 WinUtils::DwmSetIconicThumbnailProc WinUtils::dwmSetIconicThumbnailPtr = nullptr;
 WinUtils::DwmSetIconicLivePreviewBitmapProc WinUtils::dwmSetIconicLivePreviewBitmapPtr = nullptr;
 WinUtils::DwmGetWindowAttributeProc WinUtils::dwmGetWindowAttributePtr = nullptr;
 WinUtils::DwmSetWindowAttributeProc WinUtils::dwmSetWindowAttributePtr = nullptr;
@@ -238,19 +238,19 @@ WinUtils::WaitForMessage()
       ::WaitMessage();
     }
   }
 }
 
 /* static */
 bool
 WinUtils::GetRegistryKey(HKEY aRoot,
-                         const PRUnichar* aKeyName,
-                         const PRUnichar* aValueName,
-                         PRUnichar* aBuffer,
+                         char16ptr_t aKeyName,
+                         char16ptr_t aValueName,
+                         wchar_t* aBuffer,
                          DWORD aBufferLength)
 {
   NS_PRECONDITION(aKeyName, "The key name is NULL");
 
   HKEY key;
   LONG result =
     ::RegOpenKeyExW(aRoot, aKeyName, 0, KEY_READ | KEY_WOW64_32KEY, &key);
   if (result != ERROR_SUCCESS) {
@@ -272,17 +272,17 @@ WinUtils::GetRegistryKey(HKEY aRoot,
   if (aBuffer) {
     aBuffer[aBufferLength / sizeof(*aBuffer) - 1] = 0;
   }
   return true;
 }
 
 /* static */
 bool
-WinUtils::HasRegistryKey(HKEY aRoot, const PRUnichar* aKeyName)
+WinUtils::HasRegistryKey(HKEY aRoot, char16ptr_t aKeyName)
 {
   MOZ_ASSERT(aRoot, "aRoot must not be NULL");
   MOZ_ASSERT(aKeyName, "aKeyName must not be NULL");
   HKEY key;
   LONG result =
     ::RegOpenKeyExW(aRoot, aKeyName, 0, KEY_READ | KEY_WOW64_32KEY, &key);
   if (result != ERROR_SUCCESS) {
     result =
@@ -324,20 +324,20 @@ WinUtils::GetTopLevelHWND(HWND aWnd,
       upWnd = ::GetWindow(curWnd, GW_OWNER);
     }
     curWnd = upWnd;
   }
 
   return topWnd;
 }
 
-static PRUnichar*
+static const wchar_t*
 GetNSWindowPropName()
 {
-  static PRUnichar sPropName[40] = L"";
+  static wchar_t sPropName[40] = L"";
   if (!*sPropName) {
     _snwprintf(sPropName, 39, L"MozillansIWidgetPtr%p",
                ::GetCurrentProcessId());
     sPropName[39] = '\0';
   }
   return sPropName;
 }
 
--- a/widget/windows/WinUtils.h
+++ b/widget/windows/WinUtils.h
@@ -109,31 +109,31 @@ public:
    *   default value.
    * @param aBuffer The buffer into which to store the string value.  Can be
    *   null, in which case the return value indicates just whether the value
    *   exists.
    * @param aBufferLength The size of aBuffer, in bytes.
    * @return Whether the value exists and is a string.
    */
   static bool GetRegistryKey(HKEY aRoot,
-                             const PRUnichar* aKeyName,
-                             const PRUnichar* aValueName,
-                             PRUnichar* aBuffer,
+                             char16ptr_t aKeyName,
+                             char16ptr_t aValueName,
+                             wchar_t* aBuffer,
                              DWORD aBufferLength);
 
   /**
    * Checks whether the registry key exists in either 32bit or 64bit branch on
    * the environment.
    *
    * @param aRoot The registry root of aName.
    * @param aKeyName The name of the registry key to check.
    * @return TRUE if it exists and is readable.  Otherwise, FALSE.
    */
   static bool HasRegistryKey(HKEY aRoot,
-                             const PRUnichar* aKeyName);
+                             char16ptr_t aKeyName);
 
   /**
    * GetTopLevelHWND() returns a window handle of the top level window which
    * aWnd belongs to.  Note that the result may not be our window, i.e., it
    * may not be managed by nsWindow.
    *
    * See follwing table for the detail of the result window type.
    *
--- a/widget/windows/nsAppShell.cpp
+++ b/widget/windows/nsAppShell.cpp
@@ -20,17 +20,17 @@ using namespace mozilla;
 using namespace mozilla::widget;
 
 namespace mozilla {
 namespace widget {
 // Native event callback message.
 UINT sAppShellGeckoMsgId = RegisterWindowMessageW(L"nsAppShell:EventID");
 } }
 
-const PRUnichar* kTaskbarButtonEventId = L"TaskbarButtonCreated";
+const wchar_t* kTaskbarButtonEventId = L"TaskbarButtonCreated";
 UINT sTaskbarButtonCreatedMsg;
 
 /* static */
 UINT nsAppShell::GetTaskbarButtonCreatedMessage() {
 	return sTaskbarButtonCreatedMsg;
 }
 
 namespace mozilla {
@@ -75,17 +75,17 @@ nsAppShell::Init()
   mLastNativeEventScheduled = TimeStamp::NowLoRes();
 
   sTaskbarButtonCreatedMsg = ::RegisterWindowMessageW(kTaskbarButtonEventId);
   NS_ASSERTION(sTaskbarButtonCreatedMsg, "Could not register taskbar button creation message");
 
   WNDCLASSW wc;
   HINSTANCE module = GetModuleHandle(nullptr);
 
-  const PRUnichar *const kWindowClass = L"nsAppShell:EventWindowClass";
+  const wchar_t *const kWindowClass = L"nsAppShell:EventWindowClass";
   if (!GetClassInfoW(module, kWindowClass, &wc)) {
     wc.style         = 0;
     wc.lpfnWndProc   = EventWindowProc;
     wc.cbClsExtra    = 0;
     wc.cbWndExtra    = 0;
     wc.hInstance     = module;
     wc.hIcon         = nullptr;
     wc.hCursor       = nullptr;
--- a/widget/windows/nsBidiKeyboard.cpp
+++ b/widget/windows/nsBidiKeyboard.cpp
@@ -32,18 +32,18 @@ NS_IMETHODIMP nsBidiKeyboard::Reset()
 
 NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(uint8_t aLevel)
 {
   nsresult result = SetupBidiKeyboards();
   if (NS_FAILED(result))
     return result;
 
   // call LoadKeyboardLayout() only if the target keyboard layout is different from the current
-  PRUnichar currentLocaleName[KL_NAMELENGTH];
-  wcsncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH);
+  wchar_t currentLocaleName[KL_NAMELENGTH];
+  wcsncpy(currentLocaleName, char16ptr_t((aLevel & 1) ? mRTLKeyboard : mLTRKeyboard), KL_NAMELENGTH);
   currentLocaleName[KL_NAMELENGTH-1] = '\0'; // null terminate
 
   NS_ASSERTION(*currentLocaleName, 
     "currentLocaleName has string length == 0");
 
 #if 0
   /* This implementation of automatic keyboard layout switching is too buggy to be useful
      and the feature itself is inconsistent with Windows. See Bug 162242 */
@@ -113,17 +113,17 @@ NS_IMETHODIMP nsBidiKeyboard::GetHaveBid
 nsresult nsBidiKeyboard::SetupBidiKeyboards()
 {
   if (mInitialized)
     return mHaveBidiKeyboards ? NS_OK : NS_ERROR_FAILURE;
 
   int keyboards;
   HKL far* buf;
   HKL locale;
-  PRUnichar localeName[KL_NAMELENGTH];
+  wchar_t localeName[KL_NAMELENGTH];
   bool isLTRKeyboardSet = false;
   bool isRTLKeyboardSet = false;
   
   // GetKeyboardLayoutList with 0 as first parameter returns the number of keyboard layouts available
   keyboards = ::GetKeyboardLayoutList(0, nullptr);
   if (!keyboards)
     return NS_ERROR_FAILURE;
 
--- a/widget/windows/nsBidiKeyboard.h
+++ b/widget/windows/nsBidiKeyboard.h
@@ -20,15 +20,15 @@ public:
 
 protected:
 
   nsresult SetupBidiKeyboards();
   bool IsRTLLanguage(HKL aLocale);
 
   bool mInitialized;
   bool mHaveBidiKeyboards;
-  PRUnichar  mLTRKeyboard[KL_NAMELENGTH];
-  PRUnichar  mRTLKeyboard[KL_NAMELENGTH];
-  PRUnichar  mCurrentLocaleName[KL_NAMELENGTH];
+  wchar_t  mLTRKeyboard[KL_NAMELENGTH];
+  wchar_t  mRTLKeyboard[KL_NAMELENGTH];
+  wchar_t  mCurrentLocaleName[KL_NAMELENGTH];
 };
 
 
 #endif // __nsBidiKeyboard
--- a/widget/windows/nsClipboard.cpp
+++ b/widget/windows/nsClipboard.cpp
@@ -489,17 +489,17 @@ nsresult nsClipboard::GetNativeDataOffCl
                 // if there really are multiple drag items.
                 HDROP dropFiles = (HDROP) GlobalLock(stm.hGlobal);
 
                 UINT numFiles = ::DragQueryFileW(dropFiles, 0xFFFFFFFF, nullptr, 0);
                 NS_ASSERTION ( numFiles > 0, "File drop flavor, but no files...hmmmm" );
                 NS_ASSERTION ( aIndex < numFiles, "Asked for a file index out of range of list" );
                 if (numFiles > 0) {
                   UINT fileNameLen = ::DragQueryFileW(dropFiles, aIndex, nullptr, 0);
-                  PRUnichar* buffer = reinterpret_cast<PRUnichar*>(nsMemory::Alloc((fileNameLen + 1) * sizeof(PRUnichar)));
+                  wchar_t* buffer = reinterpret_cast<wchar_t*>(nsMemory::Alloc((fileNameLen + 1) * sizeof(wchar_t)));
                   if ( buffer ) {
                     ::DragQueryFileW(dropFiles, aIndex, buffer, fileNameLen + 1);
                     *aData = buffer;
                     *aLen = fileNameLen * sizeof(PRUnichar);
                     result = NS_OK;
                   }
                   else
                     result = NS_ERROR_OUT_OF_MEMORY;
--- a/widget/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/windows/nsDeviceContextSpecWin.cpp
@@ -178,17 +178,17 @@ static PRUnichar * GetDefaultPrinterName
 {
   nsAutoString printerName;
   GlobalPrinters::GetInstance()->GetDefaultPrinterName(printerName);
   return ToNewUnicode(printerName);
 }
 
 //----------------------------------------------------------------
 static nsresult 
-EnumerateNativePrinters(DWORD aWhichPrinters, LPWSTR aPrinterName, bool& aIsFound, bool& aIsFile)
+EnumerateNativePrinters(DWORD aWhichPrinters, const wchar_t *aPrinterName, bool& aIsFound, bool& aIsFile)
 {
   DWORD             dwSizeNeeded = 0;
   DWORD             dwNumItems   = 0;
   LPPRINTER_INFO_2W  lpInfo        = nullptr;
 
   // Get buffer size
   if (::EnumPrintersW(aWhichPrinters, nullptr, 2, nullptr, 0, &dwSizeNeeded,
                       &dwNumItems)) {
@@ -216,17 +216,17 @@ EnumerateNativePrinters(DWORD aWhichPrin
   }
 
   free(lpInfo);
   return NS_OK;
 }
 
 //----------------------------------------------------------------
 static void 
-CheckForPrintToFileWithName(LPWSTR aPrinterName, bool& aIsFile)
+CheckForPrintToFileWithName(char16ptr_t aPrinterName, bool& aIsFile)
 {
   bool isFound = false;
   aIsFile = false;
   nsresult rv = EnumerateNativePrinters(PRINTER_ENUM_LOCAL, aPrinterName, isFound, aIsFile);
   if (isFound) return;
 
   rv = EnumerateNativePrinters(PRINTER_ENUM_NETWORK, aPrinterName, isFound, aIsFile);
   if (isFound) return;
@@ -329,17 +329,17 @@ GetFileNameForPrintSettings(nsIPrintSett
 
   if (NS_SUCCEEDED(rv)) aPS->SetToFileName(unicodePath.get());
 
   return rv;
 }
 
 //----------------------------------------------------------------------------------
 static nsresult
-CheckForPrintToFile(nsIPrintSettings* aPS, LPWSTR aPrinterName, PRUnichar* aUPrinterName)
+CheckForPrintToFile(nsIPrintSettings* aPS, const PRUnichar* aPrinterName, const PRUnichar* aUPrinterName)
 {
   nsresult rv = NS_OK;
 
   if (!aPrinterName && !aUPrinterName) return rv;
 
   bool toFile;
   CheckForPrintToFileWithName(aPrinterName?aPrinterName:aUPrinterName, toFile);
   // Since the driver wasn't a "Print To File" Driver, check to see
@@ -441,30 +441,30 @@ NS_IMETHODIMP nsDeviceContextSpecWin::In
     CheckForPrintToFile(mPrintSettings, nullptr, printerName);
   }
  
   return GetDataFromPrinter(printerName, mPrintSettings);
 }
 
 //----------------------------------------------------------
 // Helper Function - Free and reallocate the string
-static void CleanAndCopyString(PRUnichar*& aStr, const PRUnichar* aNewStr)
+static void CleanAndCopyString(wchar_t*& aStr, const wchar_t* aNewStr)
 {
   if (aStr != nullptr) {
     if (aNewStr != nullptr && wcslen(aStr) > wcslen(aNewStr)) { // reuse it if we can
       wcscpy(aStr, aNewStr);
       return;
     } else {
       PR_Free(aStr);
       aStr = nullptr;
     }
   }
 
   if (nullptr != aNewStr) {
-    aStr = (PRUnichar *)PR_Malloc(sizeof(PRUnichar)*(wcslen(aNewStr) + 1));
+    aStr = (wchar_t *)PR_Malloc(sizeof(wchar_t)*(wcslen(aNewStr) + 1));
     wcscpy(aStr, aNewStr);
   }
 }
 
 NS_IMETHODIMP nsDeviceContextSpecWin::GetSurfaceForPrinter(gfxASurface **surface)
 {
   NS_ASSERTION(mDevMode, "DevMode can't be NULL here");
 
@@ -512,23 +512,23 @@ NS_IMETHODIMP nsDeviceContextSpecWin::Ge
     return NS_OK;
   }
 
   *surface = nullptr;
   return NS_ERROR_FAILURE;
 }
 
 //----------------------------------------------------------------------------------
-void nsDeviceContextSpecWin::SetDeviceName(const PRUnichar* aDeviceName)
+void nsDeviceContextSpecWin::SetDeviceName(char16ptr_t aDeviceName)
 {
   CleanAndCopyString(mDeviceName, aDeviceName);
 }
 
 //----------------------------------------------------------------------------------
-void nsDeviceContextSpecWin::SetDriverName(const PRUnichar* aDriverName)
+void nsDeviceContextSpecWin::SetDriverName(char16ptr_t aDriverName)
 {
   CleanAndCopyString(mDriverName, aDriverName);
 }
 
 //----------------------------------------------------------------------------------
 void nsDeviceContextSpecWin::SetDevMode(LPDEVMODEW aDevMode)
 {
   if (mDevMode) {
@@ -635,56 +635,52 @@ SetupDevModeFromSettings(LPDEVMODEW aDev
 
 }
 
 #define DISPLAY_LAST_ERROR 
 
 //----------------------------------------------------------------------------------
 // Setup the object's data member with the selected printer's data
 nsresult
-nsDeviceContextSpecWin::GetDataFromPrinter(const PRUnichar * aName, nsIPrintSettings* aPS)
+nsDeviceContextSpecWin::GetDataFromPrinter(char16ptr_t aName, nsIPrintSettings* aPS)
 {
   nsresult rv = NS_ERROR_FAILURE;
 
   if (!GlobalPrinters::GetInstance()->PrintersAreAllocated()) {
     rv = GlobalPrinters::GetInstance()->EnumeratePrinterList();
     if (NS_FAILED(rv)) {
       PR_PL(("***** nsDeviceContextSpecWin::GetDataFromPrinter - Couldn't enumerate printers!\n"));
       DISPLAY_LAST_ERROR
     }
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   HANDLE hPrinter = nullptr;
+  wchar_t *name = (wchar_t*)aName; // Windows APIs use non-const name argument
   
-  BOOL status = ::OpenPrinterW((LPWSTR)(aName),
-                              &hPrinter, nullptr);
+  BOOL status = ::OpenPrinterW(name, &hPrinter, nullptr);
   if (status) {
 
     LPDEVMODEW   pDevMode;
     DWORD       dwNeeded, dwRet;
 
     // Allocate a buffer of the correct size.
-    dwNeeded = ::DocumentPropertiesW(nullptr, hPrinter,
-                                    const_cast<wchar_t*>(aName),
-                                    nullptr, nullptr, 0);
+    dwNeeded = ::DocumentPropertiesW(nullptr, hPrinter, name, nullptr, nullptr, 0);
 
     pDevMode = (LPDEVMODEW)::HeapAlloc (::GetProcessHeap(), HEAP_ZERO_MEMORY, dwNeeded);
     if (!pDevMode) return NS_ERROR_FAILURE;
 
     // Get the default DevMode for the printer and modify it for our needs.
-    dwRet = DocumentPropertiesW(nullptr, hPrinter, 
-                               const_cast<wchar_t*>(aName),
+    dwRet = DocumentPropertiesW(nullptr, hPrinter, name,
                                pDevMode, nullptr, DM_OUT_BUFFER);
 
     if (dwRet == IDOK && aPS) {
       SetupDevModeFromSettings(pDevMode, aPS);
       // Sets back the changes we made to the DevMode into the Printer Driver
-      dwRet = ::DocumentPropertiesW(nullptr, hPrinter,
-                                   const_cast<wchar_t*>(aName),
+      dwRet = ::DocumentPropertiesW(nullptr, hPrinter, name,
                                    pDevMode, pDevMode,
                                    DM_IN_BUFFER | DM_OUT_BUFFER);
     }
 
     if (dwRet != IDOK) {
       ::HeapFree(::GetProcessHeap(), 0, pDevMode);
       ::ClosePrinter(hPrinter);
       PR_PL(("***** nsDeviceContextSpecWin::GetDataFromPrinter - DocumentProperties call failed code: %d/0x%x\n", dwRet, dwRet));
--- a/widget/windows/nsDeviceContextSpecWin.h
+++ b/widget/windows/nsDeviceContextSpecWin.h
@@ -29,43 +29,43 @@ public:
                            int32_t          aStartPage,
                            int32_t          aEndPage) { return NS_OK; }
   NS_IMETHOD EndDocument() { return NS_OK; }
   NS_IMETHOD BeginPage() { return NS_OK; }
   NS_IMETHOD EndPage() { return NS_OK; }
 
   NS_IMETHOD Init(nsIWidget* aWidget, nsIPrintSettings* aPS, bool aIsPrintPreview);
 
-  void GetDriverName(PRUnichar *&aDriverName) const   { aDriverName = mDriverName;     }
-  void GetDeviceName(PRUnichar *&aDeviceName) const   { aDeviceName = mDeviceName;     }
+  void GetDriverName(wchar_t *&aDriverName) const   { aDriverName = mDriverName;     }
+  void GetDeviceName(wchar_t *&aDeviceName) const   { aDeviceName = mDeviceName;     }
 
   // The GetDevMode will return a pointer to a DevMode
   // whether it is from the Global memory handle or just the DevMode
   // To get the DevMode from the Global memory Handle it must lock it 
   // So this call must be paired with a call to UnlockGlobalHandle
   void GetDevMode(LPDEVMODEW &aDevMode);
 
   // helper functions
-  nsresult GetDataFromPrinter(const PRUnichar * aName, nsIPrintSettings* aPS = nullptr);
+  nsresult GetDataFromPrinter(char16ptr_t aName, nsIPrintSettings* aPS = nullptr);
 
   static nsresult SetPrintSettingsFromDevMode(nsIPrintSettings* aPrintSettings, 
                                               LPDEVMODEW         aDevMode);
 
 protected:
 
-  void SetDeviceName(const PRUnichar* aDeviceName);
-  void SetDriverName(const PRUnichar* aDriverName);
+  void SetDeviceName(char16ptr_t aDeviceName);
+  void SetDriverName(char16ptr_t aDriverName);
   void SetDevMode(LPDEVMODEW aDevMode);
 
   void SetupPaperInfoFromSettings();
 
   virtual ~nsDeviceContextSpecWin();
 
-  PRUnichar*      mDriverName;
-  PRUnichar*      mDeviceName;
+  wchar_t*      mDriverName;
+  wchar_t*      mDeviceName;
   LPDEVMODEW mDevMode;
 
   nsCOMPtr<nsIPrintSettings> mPrintSettings;
 };
 
 
 //-------------------------------------------------------------------------
 // Printer Enumerator
--- a/widget/windows/nsFilePicker.cpp
+++ b/widget/windows/nsFilePicker.cpp
@@ -26,17 +26,17 @@
 #include "nsPIDOMWindow.h"
 
 using mozilla::IsVistaOrLater;
 using namespace mozilla::widget;
 
 PRUnichar *nsFilePicker::mLastUsedUnicodeDirectory;
 char nsFilePicker::mLastUsedDirectory[MAX_PATH+1] = { 0 };
 
-static const PRUnichar kDialogPtrProp[] = L"DialogPtrProperty";
+static const wchar_t kDialogPtrProp[] = L"DialogPtrProperty";
 static const DWORD kDialogTimerID = 9999;
 static const unsigned long kDialogTimerTimeout = 300;
 
 #define MAX_EXTENSION_LENGTH 10
 #define FILE_BUFFER_SIZE     4096 
 
 typedef DWORD FILEOPENDIALOGOPTIONS;
 
@@ -65,33 +65,33 @@ private:
 };
 
 // Manages the current working path.
 class AutoRestoreWorkingPath
 {
 public:
   AutoRestoreWorkingPath() {
     DWORD bufferLength = GetCurrentDirectoryW(0, nullptr);
-    mWorkingPath = new PRUnichar[bufferLength];
+    mWorkingPath = new wchar_t[bufferLength];
     if (GetCurrentDirectoryW(bufferLength, mWorkingPath) == 0) {
       mWorkingPath = nullptr;
     }
   }
 
   ~AutoRestoreWorkingPath() {
     if (HasWorkingPath()) {
       ::SetCurrentDirectoryW(mWorkingPath);
     }
   }
 
   inline bool HasWorkingPath() const {
     return mWorkingPath != nullptr;
   }
 private:
-  nsAutoArrayPtr<PRUnichar> mWorkingPath;
+  nsAutoArrayPtr<wchar_t> mWorkingPath;
 };
 
 // Manages NS_NATIVE_TMP_WINDOW child windows. NS_NATIVE_TMP_WINDOWs are
 // temporary child windows of mParentWidget created to address RTL issues
 // in picker dialogs. We are responsible for destroying these.
 class AutoDestroyTmpWindow
 {
 public:
@@ -367,18 +367,18 @@ nsFilePicker::MultiFilePickerHook(HWND h
             if (lpofn->lpOFN->lpstrFile)
               delete[] lpofn->lpOFN->lpstrFile;
 
             // We allocate FILE_BUFFER_SIZE more bytes than is needed so that
             // if the user selects a file and holds down shift and down to 
             // select  additional items, we will not continuously reallocate
             newBufLength += FILE_BUFFER_SIZE;
 
-            PRUnichar* filesBuffer = new PRUnichar[newBufLength];
-            ZeroMemory(filesBuffer, newBufLength * sizeof(PRUnichar));
+            wchar_t* filesBuffer = new wchar_t[newBufLength];
+            ZeroMemory(filesBuffer, newBufLength * sizeof(wchar_t));
 
             lpofn->lpOFN->lpstrFile = filesBuffer;
             lpofn->lpOFN->nMaxFile  = newBufLength;
           }
         }
       }
       break;
     case WM_TIMER:
@@ -478,17 +478,17 @@ nsFilePicker::ClosePickerIfNeeded(bool a
   // Note, the xp callbacks hand us an inner window, so we have to step up
   // one to get the actual dialog.
   HWND dlgWnd;
   if (aIsXPDialog)
     dlgWnd = GetParent(mDlgWnd);
   else
     dlgWnd = mDlgWnd;
   if (IsWindow(dlgWnd) && IsWindowVisible(dlgWnd) && win->DestroyCalled()) {
-    PRUnichar className[64];
+    wchar_t className[64];
     // Make sure we have the right window
     if (GetClassNameW(dlgWnd, className, mozilla::ArrayLength(className)) &&
         !wcscmp(className, L"#32770") &&
         DestroyWindow(dlgWnd)) {
       mDlgWnd = nullptr;
       return true;
     }
   }
@@ -518,26 +518,26 @@ nsFilePicker::SetDialogHandle(HWND aWnd)
 
 // Open the older XP style folder picker dialog. We end up in this call
 // on XP systems or when platform is built without the longhorn SDK.
 bool
 nsFilePicker::ShowXPFolderPicker(const nsString& aInitialDir)
 {
   bool result = false;
 
-  nsAutoArrayPtr<PRUnichar> dirBuffer(new PRUnichar[FILE_BUFFER_SIZE]);
+  nsAutoArrayPtr<wchar_t> dirBuffer(new wchar_t[FILE_BUFFER_SIZE]);
   wcsncpy(dirBuffer, aInitialDir.get(), FILE_BUFFER_SIZE);
   dirBuffer[FILE_BUFFER_SIZE-1] = '\0';
 
   AutoDestroyTmpWindow adtw((HWND)(mParentWidget.get() ?
     mParentWidget->GetNativeData(NS_NATIVE_TMP_WINDOW) : nullptr));
 
   BROWSEINFOW browserInfo = {0};
   browserInfo.pidlRoot       = nullptr;
-  browserInfo.pszDisplayName = (LPWSTR)dirBuffer;
+  browserInfo.pszDisplayName = dirBuffer;
   browserInfo.lpszTitle      = mTitle.get();
   browserInfo.ulFlags        = BIF_USENEWUI | BIF_RETURNONLYFSDIRS;
   browserInfo.hwndOwner      = adtw.get(); 
   browserInfo.iImage         = 0;
   browserInfo.lParam         = reinterpret_cast<LPARAM>(this);
 
   if (!aInitialDir.IsEmpty()) {
     // the dialog is modal so that |initialDir.get()| will be valid in 
@@ -546,19 +546,19 @@ nsFilePicker::ShowXPFolderPicker(const n
     browserInfo.lpfn   = &BrowseCallbackProc;
   } else {
     browserInfo.lParam = 0;
     browserInfo.lpfn   = nullptr;
   }
 
   LPITEMIDLIST list = ::SHBrowseForFolderW(&browserInfo);
   if (list) {
-    result = ::SHGetPathFromIDListW(list, (LPWSTR)dirBuffer);
+    result = ::SHGetPathFromIDListW(list, dirBuffer);
     if (result)
-      mUnicodeFile.Assign(dirBuffer);
+      mUnicodeFile.Assign(static_cast<const wchar_t*>(dirBuffer));
     // free PIDL
     CoTaskMemFree(list);
   }
 
   return result;
 }
 
 /*
@@ -658,17 +658,17 @@ nsFilePicker::FilePickerWrapper(OPENFILE
 
 bool
 nsFilePicker::ShowXPFilePicker(const nsString& aInitialDir)
 {
   OPENFILENAMEW ofn = {0};
   ofn.lStructSize = sizeof(ofn);
   nsString filterBuffer = mFilterList;
                                 
-  nsAutoArrayPtr<PRUnichar> fileBuffer(new PRUnichar[FILE_BUFFER_SIZE]);
+  nsAutoArrayPtr<wchar_t> fileBuffer(new wchar_t[FILE_BUFFER_SIZE]);
   wcsncpy(fileBuffer,  mDefaultFilePath.get(), FILE_BUFFER_SIZE);
   fileBuffer[FILE_BUFFER_SIZE-1] = '\0'; // null terminate in case copy truncated
 
   if (!aInitialDir.IsEmpty()) {
     ofn.lpstrInitialDir = aInitialDir.get();
   }
 
   AutoDestroyTmpWindow adtw((HWND) (mParentWidget.get() ?
@@ -799,25 +799,25 @@ nsFilePicker::ShowXPFilePicker(const nsS
   }
 
   // Set user-selected location of file or directory.  From msdn's "Open and
   // Save As Dialog Boxes" section:
   // If you specify OFN_EXPLORER, the directory and file name strings are '\0'
   // separated, with an extra '\0' character after the last file name. This
   // format enables the Explorer-style dialog boxes to return long file names
   // that include spaces. 
-  PRUnichar *current = fileBuffer;
+  wchar_t *current = fileBuffer;
   
   nsAutoString dirName(current);
   // Sometimes dirName contains a trailing slash and sometimes it doesn't:
   if (current[dirName.Length() - 1] != '\\')
     dirName.Append((PRUnichar)'\\');
   
-  while (current && *current && *(current + NS_strlen(current) + 1)) {
-    current = current + NS_strlen(current) + 1;
+  while (current && *current && *(current + wcslen(current) + 1)) {
+    current = current + wcslen(current) + 1;
     
     nsCOMPtr<nsIFile> file = do_CreateInstance("@mozilla.org/file/local;1");
     NS_ENSURE_TRUE(file, false);
 
     // Only prepend the directory if the path specified is a relative path
     nsAutoString path;
     if (PathIsRelativeW(current)) {
       path = dirName + nsDependentString(current);
@@ -1203,22 +1203,22 @@ void
 nsFilePicker::InitNative(nsIWidget *aParent,
                          const nsAString& aTitle)
 {
   mParentWidget = aParent;
   mTitle.Assign(aTitle);
 }
 
 void 
-nsFilePicker::GetQualifiedPath(const PRUnichar *aInPath, nsString &aOutPath)
+nsFilePicker::GetQualifiedPath(const wchar_t *aInPath, nsString &aOutPath)
 {
   // Prefer a qualified path over a non qualified path.
   // Things like c:file.txt would be accepted in Win XP but would later
   // fail to open from the download manager.
-  PRUnichar qualifiedFileBuffer[MAX_PATH];
+  wchar_t qualifiedFileBuffer[MAX_PATH];
   if (PathSearchAndQualifyW(aInPath, qualifiedFileBuffer, MAX_PATH)) {
     aOutPath.Assign(qualifiedFileBuffer);
   } else {
     aOutPath.Assign(aInPath);
   }
 }
 
 void
--- a/widget/windows/nsFilePicker.h
+++ b/widget/windows/nsFilePicker.h
@@ -90,17 +90,17 @@ protected:
   enum PickerType {
     PICKER_TYPE_OPEN,
     PICKER_TYPE_SAVE,
   };
 
   /* method from nsBaseFilePicker */
   virtual void InitNative(nsIWidget *aParent,
                           const nsAString& aTitle);
-  static void GetQualifiedPath(const PRUnichar *aInPath, nsString &aOutPath);
+  static void GetQualifiedPath(const wchar_t *aInPath, nsString &aOutPath);
   void GetFilterListArray(nsString& aFilterList);
   bool FilePickerWrapper(OPENFILENAMEW* ofn, PickerType aType);
   bool ShowXPFolderPicker(const nsString& aInitialDir);
   bool ShowXPFilePicker(const nsString& aInitialDir);
   bool ShowFolderPicker(const nsString& aInitialDir, bool &aWasInitError);
   bool ShowFilePicker(const nsString& aInitialDir, bool &aWasInitError);
   void AppendXPFilter(const nsAString& aTitle, const nsAString& aFilter);
   void RememberLastUsedDirectory();
--- a/widget/windows/nsPrintSettingsWin.cpp
+++ b/widget/windows/nsPrintSettingsWin.cpp
@@ -46,39 +46,39 @@ nsPrintSettingsWin::~nsPrintSettingsWin(
 }
 
 /* [noscript] attribute charPtr deviceName; */
 NS_IMETHODIMP nsPrintSettingsWin::SetDeviceName(const PRUnichar * aDeviceName)
 {
   if (mDeviceName) {
     nsMemory::Free(mDeviceName);
   }
-  mDeviceName = aDeviceName?wcsdup(aDeviceName):nullptr;
+  mDeviceName = aDeviceName?wcsdup(char16ptr_t(aDeviceName)):nullptr;
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintSettingsWin::GetDeviceName(PRUnichar **aDeviceName)
 {
   NS_ENSURE_ARG_POINTER(aDeviceName);
-  *aDeviceName = mDeviceName?wcsdup(mDeviceName):nullptr;
+  *aDeviceName = mDeviceName?reinterpret_cast<PRUnichar*>(wcsdup(mDeviceName)):nullptr;
   return NS_OK;
 }
 
 /* [noscript] attribute charPtr driverName; */
 NS_IMETHODIMP nsPrintSettingsWin::SetDriverName(const PRUnichar * aDriverName)
 {
   if (mDriverName) {
     nsMemory::Free(mDriverName);
   }
-  mDriverName = aDriverName?wcsdup(aDriverName):nullptr;
+  mDriverName = aDriverName?wcsdup(char16ptr_t(aDriverName)):nullptr;
   return NS_OK;
 }
 NS_IMETHODIMP nsPrintSettingsWin::GetDriverName(PRUnichar **aDriverName)
 {
   NS_ENSURE_ARG_POINTER(aDriverName);
-  *aDriverName = mDriverName?wcsdup(mDriverName):nullptr;
+  *aDriverName = mDriverName?reinterpret_cast<PRUnichar*>(wcsdup(mDriverName)):nullptr;
   return NS_OK;
 }
 
 void nsPrintSettingsWin::CopyDevMode(DEVMODEW* aInDevMode, DEVMODEW *& aOutDevMode)
 {
   aOutDevMode = nullptr;
   size_t size = aInDevMode->dmSize + aInDevMode->dmDriverExtra;
   aOutDevMode = (LPDEVMODEW)::HeapAlloc (::GetProcessHeap(), HEAP_ZERO_MEMORY, size);
--- a/widget/windows/nsPrintSettingsWin.h
+++ b/widget/windows/nsPrintSettingsWin.h
@@ -39,16 +39,16 @@ public:
   /**
    * Assignment
    */
   nsPrintSettingsWin& operator=(const nsPrintSettingsWin& rhs);
 
 protected:
   void CopyDevMode(DEVMODEW* aInDevMode, DEVMODEW *& aOutDevMode);
 
-  PRUnichar*      mDeviceName;
-  PRUnichar*      mDriverName;
+  wchar_t*      mDeviceName;
+  wchar_t*      mDriverName;
   LPDEVMODEW mDevMode;
 };
 
 
 
 #endif /* nsPrintSettingsWin_h__ */
--- a/widget/windows/nsTextStore.cpp
+++ b/widget/windows/nsTextStore.cpp
@@ -259,17 +259,17 @@ GetRIIDNameStr(REFIID aRIID)
   if (FAILED(hr) || !str || !str[0]) {
     return EmptyCString();
   }
 
   nsAutoString key(L"Interface\\");
   key += str;
 
   nsAutoCString result;
-  PRUnichar buf[256];
+  wchar_t buf[256];
   if (WinUtils::GetRegistryKey(HKEY_CLASSES_ROOT, key.get(), nullptr,
                                buf, sizeof(buf))) {
     result = NS_ConvertUTF16toUTF8(buf);
   } else {
     result = NS_ConvertUTF16toUTF8(str);
   }
 
   ::CoTaskMemFree(str);
--- a/widget/windows/nsUXThemeData.cpp
+++ b/widget/windows/nsUXThemeData.cpp
@@ -11,17 +11,17 @@
 #include "nsUXThemeData.h"
 #include "nsDebug.h"
 #include "nsToolkit.h"
 #include "nsUXThemeConstants.h"
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
-const PRUnichar
+const wchar_t
 nsUXThemeData::kThemeLibraryName[] = L"uxtheme.dll";
 
 HANDLE
 nsUXThemeData::sThemes[eUXNumClasses];
 
 HMODULE
 nsUXThemeData::sThemeDLL = nullptr;
 
--- a/widget/windows/nsUXThemeData.h
+++ b/widget/windows/nsUXThemeData.h
@@ -80,17 +80,17 @@ enum WindowsThemeColor {
 
 class nsUXThemeData {
   static HMODULE sThemeDLL;
   static HANDLE sThemes[eUXNumClasses];
   
   static const wchar_t *GetClassName(nsUXThemeClass);
 
 public:
-  static const PRUnichar kThemeLibraryName[];
+  static const wchar_t kThemeLibraryName[];
   static bool sFlatMenus;
   static bool sTitlebarInfoPopulatedAero;
   static bool sTitlebarInfoPopulatedThemed;
   static SIZE sCommandButtons[4];
   static mozilla::LookAndFeel::WindowsTheme sThemeId;
   static bool sIsDefaultWindowsTheme;
 
   static void Initialize();
--- a/widget/windows/nsWinGesture.cpp
+++ b/widget/windows/nsWinGesture.cpp
@@ -19,17 +19,17 @@
 
 using namespace mozilla;
 using namespace mozilla::widget;
 
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gWindowsLog;
 #endif
 
-const PRUnichar nsWinGesture::kGestureLibraryName[] =  L"user32.dll";
+const wchar_t nsWinGesture::kGestureLibraryName[] =  L"user32.dll";
 HMODULE nsWinGesture::sLibraryHandle = nullptr;
 nsWinGesture::GetGestureInfoPtr nsWinGesture::getGestureInfo = nullptr;
 nsWinGesture::CloseGestureInfoHandlePtr nsWinGesture::closeGestureInfoHandle = nullptr;
 nsWinGesture::GetGestureExtraArgsPtr nsWinGesture::getGestureExtraArgs = nullptr;
 nsWinGesture::SetGestureConfigPtr nsWinGesture::setGestureConfig = nullptr;
 nsWinGesture::GetGestureConfigPtr nsWinGesture::getGestureConfig = nullptr;
 nsWinGesture::BeginPanningFeedbackPtr nsWinGesture::beginPanningFeedback = nullptr;
 nsWinGesture::EndPanningFeedbackPtr nsWinGesture::endPanningFeedback = nullptr;
--- a/widget/windows/nsWinGesture.h
+++ b/widget/windows/nsWinGesture.h
@@ -258,17 +258,17 @@ private:
   static UnregisterTouchWindowPtr unregisterTouchWindow;
   static GetTouchInputInfoPtr getTouchInputInfo;
   static CloseTouchInputHandlePtr closeTouchInputHandle;
 
   // Delay load info 
   bool InitLibrary();
 
   static HMODULE sLibraryHandle;
-  static const PRUnichar kGestureLibraryName[];
+  static const wchar_t kGestureLibraryName[];
 
   // Pan and feedback state
   nsPointWin mPanIntermediate;
   nsPointWin mPanRefPoint;
   nsPointWin mPixelScrollDelta;
   bool mPanActive;
   bool mFeedbackActive;
   bool mXAxisFeedback;
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -241,17 +241,17 @@ int             nsWindow::sTrimOnMinimiz
 const char*     nsWindow::sDefaultMainWindowClass = kClassNameGeneral;
 
 // If we're using D3D9, this will not be allowed during initial 5 seconds.
 bool            nsWindow::sAllowD3D9              = false;
 
 TriStateBool nsWindow::sHasBogusPopupsDropShadowOnMultiMonitor = TRI_UNKNOWN;
 
 // Used in OOPP plugin focus processing.
-const PRUnichar* kOOPPPluginFocusEventId   = L"OOPP Plugin Focus Widget Event";
+const wchar_t* kOOPPPluginFocusEventId   = L"OOPP Plugin Focus Widget Event";
 uint32_t        nsWindow::sOOPPPluginFocusEvent   =
                   RegisterWindowMessageW(kOOPPPluginFocusEventId);
 
 /**************************************************************
  *
  * SECTION: globals variables
  *
  **************************************************************/
@@ -1992,17 +1992,17 @@ nsWindow::ResetLayout()
 
   // Invalidate and update
   Invalidate();
 }
 
 // Internally track the caption status via a window property. Required
 // due to our internal handling of WM_NCACTIVATE when custom client
 // margins are set.
-static const PRUnichar kManageWindowInfoProperty[] = L"ManageWindowInfoProperty";
+static const wchar_t kManageWindowInfoProperty[] = L"ManageWindowInfoProperty";
 typedef BOOL (WINAPI *GetWindowInfoPtr)(HWND hwnd, PWINDOWINFO pwi);
 static GetWindowInfoPtr sGetWindowInfoPtrStub = nullptr;
 
 BOOL WINAPI
 GetWindowInfoHook(HWND hWnd, PWINDOWINFO pwi)
 {
   if (!sGetWindowInfoPtrStub) {
     NS_ASSERTION(FALSE, "Something is horribly wrong in GetWindowInfoHook!");
@@ -4201,17 +4201,17 @@ nsWindow::IPCWindowProcHandler(UINT& msg
     // Windowless flash sending WM_ACTIVATE events to the main window
     // via calls to ShowWindow.
     case WM_ACTIVATE:
       if (lParam != 0 && LOWORD(wParam) == WA_ACTIVE &&
           IsWindow((HWND)lParam)) {
         // Check for Adobe Reader X sync activate message from their
         // helper window and ignore. Fixes an annoying focus problem.
         if ((InSendMessageEx(nullptr) & (ISMEX_REPLIED|ISMEX_SEND)) == ISMEX_SEND) {
-          PRUnichar szClass[10];
+          wchar_t szClass[10];
           HWND focusWnd = (HWND)lParam;
           if (IsWindowVisible(focusWnd) &&
               GetClassNameW(focusWnd, szClass,
                             sizeof(szClass)/sizeof(PRUnichar)) &&
               !wcscmp(szClass, L"Edit") &&
               !WinUtils::IsOurProcessWindow(focusWnd)) {
             break;
           }