Backed out changeset 6b496b906af4, bug 422792

This commit is contained in:
Brian Crowder 2008-08-29 13:37:23 -07:00
parent c0a7e081e1
commit bedbcdf9aa
10 changed files with 65 additions and 72 deletions

View File

@ -93,13 +93,13 @@ nsresult
nsAppShell::Init()
{
if (!sMsgId)
sMsgId = RegisterWindowMessageW(L"nsAppShell:EventID");
sMsgId = RegisterWindowMessage("nsAppShell:EventID");
WNDCLASSW wc;
WNDCLASS wc;
HINSTANCE module = GetModuleHandle(NULL);
const PRUnichar *const kWindowClass = L"nsAppShell:EventWindowClass";
if (!GetClassInfoW(module, kWindowClass, &wc)) {
const char *const kWindowClass = "nsAppShell:EventWindowClass";
if (!GetClassInfo(module, kWindowClass, &wc)) {
wc.style = 0;
wc.lpfnWndProc = EventWindowProc;
wc.cbClsExtra = 0;
@ -108,12 +108,12 @@ nsAppShell::Init()
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = (HBRUSH) NULL;
wc.lpszMenuName = (LPCWSTR) NULL;
wc.lpszMenuName = (LPCSTR) NULL;
wc.lpszClassName = kWindowClass;
RegisterClassW(&wc);
RegisterClass(&wc);
}
mEventWnd = CreateWindowW(kWindowClass, L"nsAppShell:EventWindow",
mEventWnd = CreateWindow(kWindowClass, "nsAppShell:EventWindow",
0, 0, 0, 10, 10, NULL, NULL, module, NULL);
NS_ENSURE_STATE(mEventWnd);

View File

@ -40,7 +40,6 @@
#include <stdio.h>
#include "nsBidiKeyboard.h"
#include "prmem.h"
#include <tchar.h>
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
@ -64,8 +63,8 @@ NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 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);
char currentLocaleName[KL_NAMELENGTH];
strncpy(currentLocaleName, (aLevel & 1) ? mRTLKeyboard : mLTRKeyboard, KL_NAMELENGTH);
currentLocaleName[KL_NAMELENGTH-1] = '\0'; // null terminate
NS_ASSERTION(*currentLocaleName,
@ -97,26 +96,26 @@ NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
currentLocale = ::GetKeyboardLayout(0);
*aIsRTL = IsRTLLanguage(currentLocale);
if (!::GetKeyboardLayoutNameW(mCurrentLocaleName))
if (!::GetKeyboardLayoutName(mCurrentLocaleName))
return NS_ERROR_FAILURE;
NS_ASSERTION(*mCurrentLocaleName,
"GetKeyboardLayoutName return string length == 0");
NS_ASSERTION((wcslen(mCurrentLocaleName) < KL_NAMELENGTH),
NS_ASSERTION((strlen(mCurrentLocaleName) < KL_NAMELENGTH),
"GetKeyboardLayoutName return string length >= KL_NAMELENGTH");
// The language set by the user overrides the default language for that direction
if (*aIsRTL) {
wcsncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
strncpy(mRTLKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
} else {
wcsncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
strncpy(mLTRKeyboard, mCurrentLocaleName, KL_NAMELENGTH);
mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
}
NS_ASSERTION((wcslen(mRTLKeyboard) < KL_NAMELENGTH),
NS_ASSERTION((strlen(mRTLKeyboard) < KL_NAMELENGTH),
"mLTRKeyboard has string length >= KL_NAMELENGTH");
NS_ASSERTION((wcslen(mLTRKeyboard) < KL_NAMELENGTH),
NS_ASSERTION((strlen(mLTRKeyboard) < KL_NAMELENGTH),
"mRTLKeyboard has string length >= KL_NAMELENGTH");
return NS_OK;
}
@ -133,7 +132,7 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards()
int keyboards;
HKL far* buf;
HKL locale;
PRUnichar localeName[KL_NAMELENGTH];
char localeName[KL_NAMELENGTH];
PRBool isLTRKeyboardSet = PR_FALSE;
PRBool isRTLKeyboardSet = PR_FALSE;
@ -157,13 +156,11 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards()
while (keyboards--) {
locale = buf[keyboards];
if (IsRTLLanguage(locale)) {
swprintf(mRTLKeyboard, KL_NAMELENGTH, L"%.*x", KL_NAMELENGTH - 1,
LANGIDFROMLCID((DWORD)locale));
sprintf(mRTLKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID((DWORD)locale));
isRTLKeyboardSet = PR_TRUE;
}
else {
swprintf(mLTRKeyboard, KL_NAMELENGTH, L"%.*x", KL_NAMELENGTH - 1,
LANGIDFROMLCID((DWORD)locale));
sprintf(mLTRKeyboard, "%.*x", KL_NAMELENGTH - 1, LANGIDFROMLCID((DWORD)locale));
isLTRKeyboardSet = PR_TRUE;
}
}
@ -181,20 +178,20 @@ nsresult nsBidiKeyboard::SetupBidiKeyboards()
// installed this prevents us from arbitrarily resetting the current
// layout (bug 80274)
locale = ::GetKeyboardLayout(0);
if (!::GetKeyboardLayoutNameW(localeName))
if (!::GetKeyboardLayoutName(localeName))
return NS_ERROR_FAILURE;
NS_ASSERTION(*localeName,
"GetKeyboardLayoutName return string length == 0");
NS_ASSERTION((wcslen(localeName) < KL_NAMELENGTH),
NS_ASSERTION((strlen(localeName) < KL_NAMELENGTH),
"GetKeyboardLayout return string length >= KL_NAMELENGTH");
if (IsRTLLanguage(locale)) {
wcsncpy(mRTLKeyboard, localeName, KL_NAMELENGTH);
strncpy(mRTLKeyboard, localeName, KL_NAMELENGTH);
mRTLKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
}
else {
wcsncpy(mLTRKeyboard, localeName, KL_NAMELENGTH);
strncpy(mLTRKeyboard, localeName, KL_NAMELENGTH);
mLTRKeyboard[KL_NAMELENGTH-1] = '\0'; // null terminate
}

View File

@ -58,9 +58,9 @@ protected:
PRPackedBool mInitialized;
PRPackedBool mHaveBidiKeyboards;
PRUnichar mLTRKeyboard[KL_NAMELENGTH];
PRUnichar mRTLKeyboard[KL_NAMELENGTH];
PRUnichar mCurrentLocaleName[KL_NAMELENGTH];
char mLTRKeyboard[KL_NAMELENGTH];
char mRTLKeyboard[KL_NAMELENGTH];
char mCurrentLocaleName[KL_NAMELENGTH];
};

View File

@ -70,7 +70,7 @@
// oddly, this isn't in the MSVC headers anywhere.
UINT nsClipboard::CF_HTML = ::RegisterClipboardFormatW(L"HTML Format");
UINT nsClipboard::CF_HTML = ::RegisterClipboardFormat("HTML Format");
//-------------------------------------------------------------------------
@ -111,9 +111,7 @@ UINT nsClipboard::GetFormat(const char* aMimeStr)
else if (strcmp(aMimeStr, kNativeHTMLMime) == 0)
format = CF_HTML;
else
format = ::RegisterClipboardFormatW(NS_ConvertASCIItoUTF16(aMimeStr).get());
format = ::RegisterClipboardFormat(aMimeStr);
return format;
}
@ -308,18 +306,18 @@ nsresult nsClipboard::GetGlobalData(HGLOBAL aHGBL, void ** aData, PRUint32 * aLe
*aLen = 0;
LPVOID lpMsgBuf;
FormatMessageW(
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPWSTR) &lpMsgBuf,
(LPTSTR) &lpMsgBuf,
0,
NULL
);
// Display the string.
MessageBoxW( NULL, (LPCWSTR) lpMsgBuf, L"GetLastError", MB_OK|MB_ICONINFORMATION );
MessageBox( NULL, (const char *)lpMsgBuf, "GetLastError", MB_OK|MB_ICONINFORMATION );
// Free the buffer.
LocalFree( lpMsgBuf );

View File

@ -82,10 +82,10 @@ IAsyncOperation : public IUnknown
* See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/programmersguide/shell_basics/shell_basics_programming/transferring/clipboard.asp
*/
#ifndef CFSTR_INETURLA
#define CFSTR_INETURLA L"UniformResourceLocator"
#define CFSTR_INETURLA "UniformResourceLocator"
#endif
#ifndef CFSTR_INETURLW
#define CFSTR_INETURLW L"UniformResourceLocatorW"
#define CFSTR_INETURLW "UniformResourceLocatorW"
#endif
// For support of MinGW w32api v2.4.
@ -93,10 +93,10 @@ IAsyncOperation : public IUnknown
// http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/winsup/w32api/include/shlobj.h?cvsroot=src
// then that can be made the base required version and this code should be removed.
#ifndef CFSTR_FILEDESCRIPTORA
# define CFSTR_FILEDESCRIPTORA L"FileGroupDescriptor"
# define CFSTR_FILEDESCRIPTORA "FileGroupDescriptor"
#endif
#ifndef CFSTR_FILEDESCRIPTORW
# define CFSTR_FILEDESCRIPTORW L"FileGroupDescriptorW"
# define CFSTR_FILEDESCRIPTORW "FileGroupDescriptorW"
#endif
#ifdef __MINGW32__

View File

@ -280,10 +280,10 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
#ifndef WINCE
}
catch(...) {
MessageBoxW(ofn.hwndOwner,
0,
L"The filepicker was unexpectedly closed by Windows.",
MB_ICONERROR);
MessageBox(ofn.hwndOwner,
0,
"The filepicker was unexpectedly closed by Windows.",
MB_ICONERROR);
result = PR_FALSE;
}
#endif

View File

@ -83,7 +83,7 @@ static PRInt32 GetSystemParam(long flag, PRInt32 def)
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
{
#ifndef WINCE
gShell32DLLInst = LoadLibraryW(L"Shell32.dll");
gShell32DLLInst = LoadLibrary("Shell32.dll");
if (gShell32DLLInst)
{
gSHAppBarMessage = (SHAppBarMessagePtr) GetProcAddress(gShell32DLLInst,
@ -531,7 +531,7 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
if (gSHAppBarMessage)
{
// Get task bar window handle
HWND shellWindow = FindWindowW(L"Shell_TrayWnd", NULL);
HWND shellWindow = FindWindow("Shell_TrayWnd", NULL);
if (shellWindow != NULL)
{

View File

@ -40,7 +40,7 @@
#include "nscore.h"
#include "plstr.h"
#include <stdio.h>
#include "nsString.h"
#include <windows.h>
// mmsystem.h is needed to build with WIN32_LEAN_AND_MEAN
@ -124,7 +124,8 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
data = mLastSound;
flags |= SND_ASYNC;
}
::PlaySoundW(reinterpret_cast<LPCWSTR>(data), 0, flags);
::PlaySound(reinterpret_cast<const char*>(data), 0, flags);
}
return NS_OK;
@ -165,10 +166,12 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
PurgeLastSound();
if (aSoundAlias.EqualsLiteral("_moz_mailbeep")) {
::PlaySoundW(L"MailBeep", nsnull, SND_ALIAS | SND_ASYNC);
::PlaySound("MailBeep", nsnull, SND_ALIAS | SND_ASYNC);
}
else {
::PlaySoundW(PromiseFlatString(aSoundAlias).get(), nsnull, SND_ALIAS | SND_ASYNC);
nsCAutoString nativeSoundAlias;
NS_CopyUnicodeToNative(aSoundAlias, nativeSoundAlias);
::PlaySound(nativeSoundAlias.get(), nsnull, SND_ALIAS | SND_ASYNC);
}
return NS_OK;

View File

@ -265,7 +265,8 @@ nsToolkit::Startup(HMODULE hModule)
typedef BOOL (*SetProcessDPIAwareFunc)(VOID);
SetProcessDPIAwareFunc setDPIAware = (SetProcessDPIAwareFunc)
GetProcAddress(LoadLibraryW(L"user32.dll"), "SetProcessDPIAware");
GetProcAddress(LoadLibrary("user32.dll"),
"SetProcessDPIAware");
if (setDPIAware)
setDPIAware();
@ -299,8 +300,8 @@ void nsToolkit::CreateInternalWindow(PRThread *aThread)
// create the internal window
//
mDispatchWnd = ::CreateWindowW(L"nsToolkitClass",
L"NetscapeDispatchWnd",
mDispatchWnd = ::CreateWindow("nsToolkitClass",
"NetscapeDispatchWnd",
WS_DISABLED,
-50, -50,
10, 10,

View File

@ -158,7 +158,7 @@
PRLogModuleInfo* sWindowsLog = nsnull;
#endif
static const PRUnichar kMozHeapDumpMessageString[] = L"MOZ_HeapDump";
static const char kMozHeapDumpMessageString[] = "MOZ_HeapDump";
#define kWindowPositionSlop 20
@ -678,7 +678,7 @@ nsWindow::nsWindow() : nsBaseWidget()
// Heap dump
#ifndef WINCE
nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessageW(kMozHeapDumpMessageString);
nsWindow::uWM_HEAP_DUMP = ::RegisterWindowMessage(kMozHeapDumpMessageString);
#endif
}
@ -1096,26 +1096,26 @@ nsWindow::EventIsInsideWindow(UINT Msg, nsWindow* aWindow)
return (PRBool) PtInRect(&r, mp);
}
static PRUnichar sPropName[40] = L"";
static PRUnichar* GetNSWindowPropName() {
static char sPropName[40] = "";
static char* GetNSWindowPropName() {
if (!*sPropName)
{
_snwprintf(sPropName, 39, L"MozillansIWidgetPtr%p", _getpid());
_snprintf(sPropName, 39, "MozillansIWidgetPtr%p", _getpid());
sPropName[39] = '\0';
}
return sPropName;
}
nsWindow * nsWindow::GetNSWindowPtr(HWND aWnd) {
return (nsWindow *) ::GetPropW(aWnd, GetNSWindowPropName());
return (nsWindow *) ::GetPropA(aWnd, GetNSWindowPropName());
}
BOOL nsWindow::SetNSWindowPtr(HWND aWnd, nsWindow * ptr) {
if (ptr == NULL) {
::RemovePropW(aWnd, GetNSWindowPropName());
::RemovePropA(aWnd, GetNSWindowPropName());
return TRUE;
} else {
return ::SetPropW(aWnd, GetNSWindowPropName(), (HANDLE)ptr);
return ::SetPropA(aWnd, GetNSWindowPropName(), (HANDLE)ptr);
}
}
@ -1766,7 +1766,7 @@ NS_IMETHODIMP nsWindow::SetSizeMode(PRInt32 aMode) {
// Play the minimize sound while we're here, since that is also
// forgotten when we use SW_SHOWMINIMIZED.
::PlaySoundW(L"Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC);
::PlaySound("Minimize", nsnull, SND_ALIAS | SND_NODEFAULT | SND_ASYNC);
}
#endif
break;
@ -5397,7 +5397,7 @@ LPCWSTR nsWindow::WindowPopupClassW()
return className;
}
LPCTSTR nsWindow::WindowClass()
LPCSTR nsWindow::WindowClass()
{
// Call into the wide version to make sure things get
// registered properly.
@ -5405,9 +5405,7 @@ LPCTSTR nsWindow::WindowClass()
// XXX: The class name used here must be kept in sync with
// the classname used in WindowClassW();
#ifdef UNICODE
return classNameW;
#else
if (classNameW == kWClassNameHidden) {
return kClassNameHidden;
}
@ -5424,21 +5422,17 @@ LPCTSTR nsWindow::WindowClass()
return kClassNameContentFrame;
}
return kClassNameGeneral;
#endif
}
LPCTSTR nsWindow::WindowPopupClass()
LPCSTR nsWindow::WindowPopupClass()
{
// Call into the wide version to make sure things get
// registered properly.
#ifdef UNICODE
return WindowPopupClassW();
#else
WindowPopupClassW();
// XXX: The class name used here must be kept in sync with
// the classname used in WindowPopupClassW();
return "MozillaDropShadowWindowClass";
#endif
}
//-------------------------------------------------------------------------
@ -7932,7 +7926,7 @@ STDMETHODIMP_(LRESULT) nsWindow::LresultFromObject(REFIID riid, WPARAM wParam, L
{
// open the dll dynamically
if (!gmAccLib)
gmAccLib =::LoadLibraryW(L"OLEACC.DLL");
gmAccLib =::LoadLibrary("OLEACC.DLL");
if (gmAccLib) {
if (!gmLresultFromObject)