Bug 944894 - Fix char16_t/wchar_t mismatch in widget/windows/. r=jimm

--HG--
extra : rebase_source : 829390ff7e6f4eb71dcd32c9d1aa27f61baa6653
This commit is contained in:
Jacek Caban 2013-12-03 16:12:57 +01:00
Родитель 919a5b3c9b
Коммит 54f8cc293a
26 изменённых файлов: 111 добавлений и 127 удалений

Просмотреть файл

@ -210,7 +210,7 @@ AudioSession::Start()
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

Просмотреть файл

@ -77,22 +77,17 @@ GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams)
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) {
@ -100,33 +95,26 @@ GfxInfo::GetCleartypeParameters(nsAString & aCleartypeParams)
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("] "));
}
}
@ -372,7 +360,7 @@ GfxInfo::Init()
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);
@ -446,7 +434,7 @@ GfxInfo::Init()
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,
@ -469,7 +457,7 @@ GfxInfo::Init()
// 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;
@ -526,11 +514,11 @@ GfxInfo::Init()
// 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);
@ -594,7 +582,7 @@ GfxInfo::GetAdapterDescription2(nsAString & aAdapterDescription)
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;
}
@ -605,7 +593,7 @@ 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;
@ -615,7 +603,7 @@ GfxInfo::GetAdapterRAM2(nsAString & aAdapterRAM)
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;
}
@ -626,7 +614,7 @@ 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;

Просмотреть файл

@ -376,7 +376,7 @@ NS_IMETHODIMP JumpListBuilder::AddListToBuild(int16_t aCatType, nsIArray *items,
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;

Просмотреть файл

@ -429,7 +429,7 @@ nsresult JumpListShortcut::GetShellLink(nsCOMPtr<nsIJumpListItem>& item,
// 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);
@ -473,10 +473,10 @@ nsresult JumpListShortcut::GetJumpListShortcut(IShellLinkW *pLink, nsCOMPtr<nsIJ
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;
@ -489,7 +489,7 @@ nsresult JumpListShortcut::GetJumpListShortcut(IShellLinkW *pLink, nsCOMPtr<nsIJ
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;
@ -511,7 +511,7 @@ nsresult JumpListShortcut::GetJumpListShortcut(IShellLinkW *pLink, nsCOMPtr<nsIJ
// 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);
@ -519,7 +519,7 @@ nsresult JumpListShortcut::GetJumpListShortcut(IShellLinkW *pLink, nsCOMPtr<nsIJ
// 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);

Просмотреть файл

@ -65,12 +65,12 @@ public:
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;

Просмотреть файл

@ -18,7 +18,7 @@ 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),

Просмотреть файл

@ -1142,7 +1142,7 @@ MouseScrollHandler::Device::Elantech::Init()
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,
@ -1163,7 +1163,7 @@ MouseScrollHandler::Device::Elantech::GetDriverMajorVersion()
// 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);
}
@ -1179,7 +1179,7 @@ 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;
@ -1191,7 +1191,7 @@ MouseScrollHandler::Device::Elantech::IsHelperWindow(HWND aWnd)
}
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) {
@ -1389,7 +1389,7 @@ MouseScrollHandler::Device::UltraNav::IsObsoleteDriverInstalled()
return false;
}
PRUnichar buf[40];
wchar_t buf[40];
bool foundKey =
WinUtils::GetRegistryKey(HKEY_LOCAL_MACHINE,
L"Software\\Synaptics\\SynTP\\Install",
@ -1404,7 +1404,7 @@ MouseScrollHandler::Device::UltraNav::IsObsoleteDriverInstalled()
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);
}

Просмотреть файл

@ -34,7 +34,7 @@
#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);
@ -291,14 +291,14 @@ WinTaskbar::GetAppUserModelID(nsAString & aDefaultGroupId) {
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,

Просмотреть файл

@ -66,9 +66,9 @@ 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;
@ -243,9 +243,9 @@ WinUtils::WaitForMessage()
/* 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");
@ -277,7 +277,7 @@ WinUtils::GetRegistryKey(HKEY aRoot,
/* 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");
@ -329,10 +329,10 @@ WinUtils::GetTopLevelHWND(HWND aWnd,
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());

Просмотреть файл

@ -114,9 +114,9 @@ public:
* @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);
/**
@ -128,7 +128,7 @@ public:
* @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

Просмотреть файл

@ -25,7 +25,7 @@ namespace widget {
UINT sAppShellGeckoMsgId = RegisterWindowMessageW(L"nsAppShell:EventID");
} }
const PRUnichar* kTaskbarButtonEventId = L"TaskbarButtonCreated";
const wchar_t* kTaskbarButtonEventId = L"TaskbarButtonCreated";
UINT sTaskbarButtonCreatedMsg;
/* static */
@ -80,7 +80,7 @@ nsAppShell::Init()
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;

Просмотреть файл

@ -37,8 +37,8 @@ NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(uint8_t aLevel)
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,
@ -118,7 +118,7 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards()
int keyboards;
HKL far* buf;
HKL locale;
PRUnichar localeName[KL_NAMELENGTH];
wchar_t localeName[KL_NAMELENGTH];
bool isLTRKeyboardSet = false;
bool isRTLKeyboardSet = false;

Просмотреть файл

@ -25,9 +25,9 @@ protected:
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];
};

Просмотреть файл

@ -494,7 +494,7 @@ nsresult nsClipboard::GetNativeDataOffClipboard(IDataObject * aDataObject, UINT
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;

Просмотреть файл

@ -183,7 +183,7 @@ static PRUnichar * GetDefaultPrinterNameFromGlobalPrinters()
//----------------------------------------------------------------
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;
@ -221,7 +221,7 @@ EnumerateNativePrinters(DWORD aWhichPrinters, LPWSTR aPrinterName, bool& aIsFoun
//----------------------------------------------------------------
static void
CheckForPrintToFileWithName(LPWSTR aPrinterName, bool& aIsFile)
CheckForPrintToFileWithName(char16ptr_t aPrinterName, bool& aIsFile)
{
bool isFound = false;
aIsFile = false;
@ -334,7 +334,7 @@ GetFileNameForPrintSettings(nsIPrintSettings* aPS)
//----------------------------------------------------------------------------------
static nsresult
CheckForPrintToFile(nsIPrintSettings* aPS, LPWSTR aPrinterName, PRUnichar* aUPrinterName)
CheckForPrintToFile(nsIPrintSettings* aPS, const PRUnichar* aPrinterName, const PRUnichar* aUPrinterName)
{
nsresult rv = NS_OK;
@ -446,7 +446,7 @@ NS_IMETHODIMP nsDeviceContextSpecWin::Init(nsIWidget* aWidget,
//----------------------------------------------------------
// 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
@ -459,7 +459,7 @@ static void CleanAndCopyString(PRUnichar*& aStr, const PRUnichar* aNewStr)
}
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);
}
}
@ -517,13 +517,13 @@ NS_IMETHODIMP nsDeviceContextSpecWin::GetSurfaceForPrinter(gfxASurface **surface
}
//----------------------------------------------------------------------------------
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);
}
@ -640,7 +640,7 @@ SetupDevModeFromSettings(LPDEVMODEW aDevMode, nsIPrintSettings* aPrintSettings)
//----------------------------------------------------------------------------------
// 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;
@ -654,32 +654,28 @@ nsDeviceContextSpecWin::GetDataFromPrinter(const PRUnichar * aName, nsIPrintSett
}
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);
}

Просмотреть файл

@ -34,8 +34,8 @@ public:
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
@ -44,23 +44,23 @@ public:
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;

Просмотреть файл

@ -31,7 +31,7 @@ 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;
@ -70,7 +70,7 @@ 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;
}
@ -86,7 +86,7 @@ public:
return mWorkingPath != nullptr;
}
private:
nsAutoArrayPtr<PRUnichar> mWorkingPath;
nsAutoArrayPtr<wchar_t> mWorkingPath;
};
// Manages NS_NATIVE_TMP_WINDOW child windows. NS_NATIVE_TMP_WINDOWs are
@ -372,8 +372,8 @@ nsFilePicker::MultiFilePickerHook(HWND hwnd,
// 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;
@ -483,7 +483,7 @@ nsFilePicker::ClosePickerIfNeeded(bool aIsXPDialog)
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") &&
@ -523,7 +523,7 @@ 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';
@ -532,7 +532,7 @@ nsFilePicker::ShowXPFolderPicker(const nsString& aInitialDir)
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();
@ -551,9 +551,9 @@ nsFilePicker::ShowXPFolderPicker(const nsString& aInitialDir)
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);
}
@ -663,7 +663,7 @@ nsFilePicker::ShowXPFilePicker(const nsString& aInitialDir)
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
@ -804,15 +804,15 @@ nsFilePicker::ShowXPFilePicker(const nsString& aInitialDir)
// 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);
@ -1208,12 +1208,12 @@ nsFilePicker::InitNative(nsIWidget *aParent,
}
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 {

Просмотреть файл

@ -95,7 +95,7 @@ protected:
/* 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);

Просмотреть файл

@ -51,13 +51,13 @@ 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;
}
@ -67,13 +67,13 @@ 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;
}

Просмотреть файл

@ -44,8 +44,8 @@ public:
protected:
void CopyDevMode(DEVMODEW* aInDevMode, DEVMODEW *& aOutDevMode);
PRUnichar* mDeviceName;
PRUnichar* mDriverName;
wchar_t* mDeviceName;
wchar_t* mDriverName;
LPDEVMODEW mDevMode;
};

Просмотреть файл

@ -264,7 +264,7 @@ GetRIIDNameStr(REFIID aRIID)
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);

Просмотреть файл

@ -16,7 +16,7 @@
using namespace mozilla;
using namespace mozilla::widget;
const PRUnichar
const wchar_t
nsUXThemeData::kThemeLibraryName[] = L"uxtheme.dll";
HANDLE

Просмотреть файл

@ -85,7 +85,7 @@ class nsUXThemeData {
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;

Просмотреть файл

@ -24,7 +24,7 @@ using namespace mozilla::widget;
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;

Просмотреть файл

@ -263,7 +263,7 @@ private:
bool InitLibrary();
static HMODULE sLibraryHandle;
static const PRUnichar kGestureLibraryName[];
static const wchar_t kGestureLibraryName[];
// Pan and feedback state
nsPointWin mPanIntermediate;

Просмотреть файл

@ -246,7 +246,7 @@ 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);
@ -1997,7 +1997,7 @@ nsWindow::ResetLayout()
// 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;
@ -4206,7 +4206,7 @@ nsWindow::IPCWindowProcHandler(UINT& msg, WPARAM& wParam, LPARAM& 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,