diff --git a/browser/app/Makefile.in b/browser/app/Makefile.in
index 096949b22267a07684495606f84f531a93043914..85b420d6c355a7db1edb4a08a05ad1ac5d8f10db 100644
--- a/browser/app/Makefile.in
+++ b/browser/app/Makefile.in
@@ -166,7 +166,7 @@ EXTRA_LIBS	+= $(STATIC_EXTRA_LIBS)
 endif
 
 ifeq ($(OS_ARCH),WINNT)
-OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool gdi32)
+OS_LIBS += $(call EXPAND_LIBNAME,comctl32 comdlg32 uuid shell32 ole32 oleaut32 version winspool gdi32 imm32)
 ifdef MOZ_ENABLE_CAIRO_GFX
 OS_LIBS += $(call EXPAND_LIBNAME,usp10)
 endif
diff --git a/widget/src/windows/nsAppShell.cpp b/widget/src/windows/nsAppShell.cpp
index b3805bed10bbdc694831e20fabd34f47a33fe7c7..064b713f14c748c1c5c718d54c1498d7f90546d4 100644
--- a/widget/src/windows/nsAppShell.cpp
+++ b/widget/src/windows/nsAppShell.cpp
@@ -87,8 +87,8 @@ BOOL PeekKeyAndIMEMessage(LPMSG msg, HWND hwnd)
 {
   MSG msg1, msg2, *lpMsg;
   BOOL b1, b2;
-  b1 = nsToolkit::mPeekMessage(&msg1, NULL, WM_KEYFIRST, WM_IME_KEYLAST, PM_NOREMOVE);
-  b2 = nsToolkit::mPeekMessage(&msg2, NULL, WM_IME_SETCONTEXT, WM_IME_KEYUP, PM_NOREMOVE);
+  b1 = ::PeekMessageW(&msg1, NULL, WM_KEYFIRST, WM_IME_KEYLAST, PM_NOREMOVE);
+  b2 = ::PeekMessageW(&msg2, NULL, WM_IME_SETCONTEXT, WM_IME_KEYUP, PM_NOREMOVE);
   if (b1 || b2) {
     if (b1 && b2) {
       if (msg1.time < msg2.time)
@@ -99,7 +99,7 @@ BOOL PeekKeyAndIMEMessage(LPMSG msg, HWND hwnd)
       lpMsg = &msg1;
     else
       lpMsg = &msg2;
-    return nsToolkit::mPeekMessage(msg, hwnd, lpMsg->message, lpMsg->message, PM_REMOVE);
+    return ::PeekMessageW(msg, hwnd, lpMsg->message, lpMsg->message, PM_REMOVE);
   }
 
   return false;
@@ -124,13 +124,13 @@ NS_METHOD nsAppShell::Run(void)
     // Give priority to system messages (in particular keyboard, mouse,
     // timer, and paint messages).
      if (PeekKeyAndIMEMessage(&msg, NULL) ||
-         nsToolkit::mPeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || 
-         nsToolkit::mPeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+         ::PeekMessageW(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || 
+         ::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
       keepGoing = (msg.message != WM_QUIT);
 
       if (keepGoing != 0) {
         TranslateMessage(&msg);
-        nsToolkit::mDispatchMessage(&msg);
+        ::DispatchMessageW(&msg);
       }
     } else {
 
@@ -140,7 +140,7 @@ NS_METHOD nsAppShell::Run(void)
         do {
           timerManager->FireNextIdleTimer();
           timerManager->HasIdleTimers(&hasTimers);
-        } while (hasTimers && !nsToolkit::mPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE));
+        } while (hasTimers && !::PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE));
       } else {
 
         if (!gKeepGoing) {
@@ -185,8 +185,8 @@ nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent)
     // Give priority to system messages (in particular keyboard, mouse,
     // timer, and paint messages).
      if (PeekKeyAndIMEMessage(&msg, NULL) ||
-        nsToolkit::mPeekMessage(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || 
-        nsToolkit::mPeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
+        ::PeekMessageW(&msg, NULL, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || 
+        ::PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) {
       gotMessage = true;
     } else {
       PRBool hasTimers;
@@ -195,7 +195,7 @@ nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent)
         do {
           timerManager->FireNextIdleTimer();
           timerManager->HasIdleTimers(&hasTimers);
-        } while (hasTimers && !nsToolkit::mPeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE));
+        } while (hasTimers && !::PeekMessageW(&msg, NULL, 0, 0, PM_NOREMOVE));
       } else {
         // Block and wait for any posted application message
         ::WaitMessage();
@@ -217,7 +217,7 @@ nsAppShell::GetNativeEvent(PRBool &aRealEvent, void *&aEvent)
 
 nsresult nsAppShell::DispatchNativeEvent(PRBool aRealEvent, void *aEvent)
 {
-  nsToolkit::mDispatchMessage((MSG *)aEvent);
+  ::DispatchMessageW((MSG *)aEvent);
   return NS_OK;
 }
 
diff --git a/widget/src/windows/nsDeviceContextSpecWin.cpp b/widget/src/windows/nsDeviceContextSpecWin.cpp
index 47578e255cbc0c04faf1250b568efc2bd1e0701b..41452b27ea202b8f4e31dc0bbb0ae99349e4eaec 100644
--- a/widget/src/windows/nsDeviceContextSpecWin.cpp
+++ b/widget/src/windows/nsDeviceContextSpecWin.cpp
@@ -764,16 +764,9 @@ nsDeviceContextSpecWin::GetDataFromPrinter(const PRUnichar * aName, nsIPrintSett
     SetDevMode(pDevMode); // cache the pointer and takes responsibility for the memory
 
     SetDeviceName(NS_CONST_CAST(char*, nativeName.get()));
-  
-    // The driver should be NULL for Win95/Win98
-    OSVERSIONINFO os;
-    os.dwOSVersionInfoSize = sizeof(os);
-    ::GetVersionEx(&os);
-    if (VER_PLATFORM_WIN32_NT == os.dwPlatformId) {
-      SetDriverName("WINSPOOL");
-    } else {
-      SetDriverName(NULL);
-    }
+
+    SetDriverName("WINSPOOL");
+
     ::ClosePrinter(hPrinter);
     rv = NS_OK;
   } else {
diff --git a/widget/src/windows/nsDragService.cpp b/widget/src/windows/nsDragService.cpp
index b12e055b34443b5d574c877c65a0e10679c7c06c..859ed57e7f3a7ab9cb55864490cac9f6c62c3568 100644
--- a/widget/src/windows/nsDragService.cpp
+++ b/widget/src/windows/nsDragService.cpp
@@ -709,9 +709,9 @@ LRESULT WINAPI nsDragService::HiddenWndProc(HWND aWnd, UINT aMsg, WPARAM awParam
       // Get From path (where the file is comming from)
       WCHAR szPathFrom[MAX_PATH + 1];
       WCHAR szPathTo[MAX_PATH + 1];
-      nsToolkit::mSHGetPathFromIDList(ppidl[0], szPathFrom);
+      ::SHGetPathFromIDListW(ppidl[0], szPathFrom);
       // Get To path (where the file is going to)
-      nsToolkit::mSHGetPathFromIDList(ppidl[1], szPathTo);
+      ::SHGetPathFromIDListW(ppidl[1], szPathTo);
 
       // first is from where the file is coming
       // and the second is where the file is going
diff --git a/widget/src/windows/nsFilePicker.cpp b/widget/src/windows/nsFilePicker.cpp
index 683ecf7be377db0e3f5adb643cb40309264b3f20..6b4ef3f5024c654f32b2458b22fec5fde6c8f4e1 100644
--- a/widget/src/windows/nsFilePicker.cpp
+++ b/widget/src/windows/nsFilePicker.cpp
@@ -179,9 +179,9 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
     browserInfo.iImage         = nsnull;
 
     // XXX UNICODE support is needed here --> DONE
-    LPITEMIDLIST list = nsToolkit::mSHBrowseForFolder(&browserInfo);
+    LPITEMIDLIST list = ::SHBrowseForFolderW(&browserInfo);
     if (list != NULL) {
-      result = nsToolkit::mSHGetPathFromIDList(list, (LPWSTR)fileBuffer);
+      result = ::SHGetPathFromIDListW(list, (LPWSTR)fileBuffer);
       if (result) {
           mUnicodeFile.Assign(fileBuffer);
       }
@@ -196,11 +196,7 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
 
     OPENFILENAMEW ofn;
     memset(&ofn, 0, sizeof(ofn));
-#if _WIN32_WINNT >= 0x0500
-    ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
-#else
     ofn.lStructSize = sizeof(ofn);
-#endif
     nsString filterBuffer = mFilterList;
                                   
     if (!initialDir.IsEmpty()) {
@@ -249,11 +245,11 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
       if (mMode == modeOpen) {
         // FILE MUST EXIST!
         ofn.Flags |= OFN_FILEMUSTEXIST;
-        result = nsToolkit::mGetOpenFileName(&ofn);
+        result = ::GetOpenFileNameW(&ofn);
       }
       else if (mMode == modeOpenMultiple) {
         ofn.Flags |= OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER;
-        result = nsToolkit::mGetOpenFileName(&ofn);
+        result = ::GetOpenFileNameW(&ofn);
       }
       else if (mMode == modeSave) {
         ofn.Flags |= OFN_NOREADONLYRETURN;
@@ -268,7 +264,7 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
             StringEndsWith(ext, NS_LITERAL_CSTRING(".url")))
           ofn.Flags |= OFN_NODEREFERENCELINKS;
 
-        result = nsToolkit::mGetSaveFileName(&ofn);
+        result = ::GetSaveFileNameW(&ofn);
         if (!result) {
           // Error, find out what kind.
           if (::GetLastError() == ERROR_INVALID_PARAMETER ||
@@ -276,7 +272,7 @@ NS_IMETHODIMP nsFilePicker::ShowW(PRInt16 *aReturnVal)
             // probably the default file name is too long or contains illegal characters!
             // Try again, without a starting file name.
             ofn.lpstrFile[0] = 0;
-            result = nsToolkit::mGetSaveFileName(&ofn);
+            result = ::GetSaveFileNameW(&ofn);
           }
         }
       }
diff --git a/widget/src/windows/nsKeyboardLayout.cpp b/widget/src/windows/nsKeyboardLayout.cpp
index 9345afc9bfe4dd28d0c4a485af132a36cd67b61c..44c7f59c4825ec9a8b6195c3c0bd13c1f78ba2fc 100644
--- a/widget/src/windows/nsKeyboardLayout.cpp
+++ b/widget/src/windows/nsKeyboardLayout.cpp
@@ -41,9 +41,9 @@
 #include "nsToolkit.h"
 #include "nsQuickSort.h"
 
+#include <winable.h>
 
 #ifndef WINCE
-static PRBool LangIDToCP (WORD aLangID, UINT* aCodePage);
 
 struct DeadKeyEntry
 {
@@ -88,36 +88,6 @@ public:
 
 
 
-static BOOL WINAPI DummyBlockInput (BOOL)
-{
-  return TRUE;
-}
-
-static BOOL WINAPI BlockInputProc (BOOL fBlockIt)
-{
-  typedef BOOL WINAPI BlockInputProcType (BOOL fBlockIt);
-  static BlockInputProcType* proc = nsnull;
-  
-  if (proc == nsnull)
-  {
-    HMODULE user32 = ::GetModuleHandle ("user32.dll");
-
-    if (user32)
-      proc = NS_REINTERPRET_CAST (BlockInputProcType*, ::GetProcAddress (user32, "BlockInput"));
-    
-    if (!proc)
-      proc = &DummyBlockInput;
-
-  #ifdef DEBUG
-    proc = &DummyBlockInput;    // To be able to debug program we should not block keyboard/mouse input!
-  #endif
-  }
-
-  return proc (fBlockIt);
-}
-
-
-
 inline PRUint16 VirtualKey::GetCompositeChar (PRUint8 aShiftState, PRUint16 aBaseChar) const
 {
   return mShiftStates [aShiftState].DeadKey.Table->GetCompositeChar (aBaseChar);
@@ -355,11 +325,10 @@ void KeyboardLayout::LoadLayout ()
   mActiveDeadKey = -1;
   mNumOfChars = 0;
   mKeyboardLayout = ::GetKeyboardLayout (0);
-  LangIDToCP ((WORD)mKeyboardLayout, &mCodePage);
 
   ReleaseDeadKeyTables ();
 
-  PRBool keyboardInputAlreadyBlocked = !BlockInputProc (PR_TRUE);
+  PRBool keyboardInputAlreadyBlocked = !::BlockInput (PR_TRUE);
 
   // For each shift state gather all printable characters that are produced
   // for normal case when no any dead-key is active.
@@ -377,13 +346,9 @@ void KeyboardLayout::LoadLayout ()
       NS_ASSERTION (vki < NS_ARRAY_LENGTH (mVirtualKeys), "invalid index"); 
 
       PRUint16 uniChars [5];
-      WORD ascii [2];     // On Win9x ToAsciiEx returns WORD per character, on Win2k BYTE per character.
       PRInt32 rv;
 
-      if (nsToolkit::mIsNT)
-        rv = ::ToUnicode (virtualKey, 0, kbdState, (LPWSTR)uniChars, NS_ARRAY_LENGTH (uniChars), 0);
-      else
-        rv = ::ToAsciiEx (virtualKey, 0, kbdState, ascii, 0, mKeyboardLayout);
+      rv = ::ToUnicode (virtualKey, 0, kbdState, (LPWSTR)uniChars, NS_ARRAY_LENGTH (uniChars), 0);
 
       if (rv < 0)   // dead-key
       {      
@@ -392,13 +357,7 @@ void KeyboardLayout::LoadLayout ()
         // Repeat dead-key to deactivate it and get its character representation.
         PRUint16 deadChar [2];
 
-        if (nsToolkit::mIsNT)
-          rv = ::ToUnicode (virtualKey, 0, kbdState, (LPWSTR)deadChar, NS_ARRAY_LENGTH (deadChar), 0);
-        else
-        {
-          rv = ::ToAsciiEx (virtualKey, 0, kbdState, ascii, 0, mKeyboardLayout);
-          ::MultiByteToWideChar (mCodePage, 0, (LPCSTR)ascii, 1, (WCHAR*)deadChar, 1);
-        }
+        rv = ::ToUnicode (virtualKey, 0, kbdState, (LPWSTR)deadChar, NS_ARRAY_LENGTH (deadChar), 0);
 
         NS_ASSERTION (rv == 2, "Expecting twice repeated dead-key character");
 
@@ -408,9 +367,6 @@ void KeyboardLayout::LoadLayout ()
         if (rv == 1)  // dead-key can pair only with exactly one base character.
           shiftStatesWithBaseChars |= 1 << shiftState;
 
-        if (!nsToolkit::mIsNT)
-          rv = ::MultiByteToWideChar (mCodePage, 0, (LPCSTR)ascii, rv, (WCHAR*)uniChars, NS_ARRAY_LENGTH (uniChars));
-
         mVirtualKeys [vki].SetNormalChars (shiftState, uniChars, rv);
       }
     }
@@ -448,7 +404,7 @@ void KeyboardLayout::LoadLayout ()
   }
 
   if (!keyboardInputAlreadyBlocked)
-    BlockInputProc (PR_FALSE);
+    ::BlockInput (PR_FALSE);
 #endif
 }
 
@@ -591,10 +547,7 @@ PRBool KeyboardLayout::EnsureDeadKeyActive (PRBool aIsActive, PRUint8 aDeadKey,
   {
     PRUint16 dummyChars [5];
 
-    if (nsToolkit::mIsNT)
-      rv = ::ToUnicode (aDeadKey, 0, (PBYTE)aDeadKeyKbdState, (LPWSTR)dummyChars, NS_ARRAY_LENGTH (dummyChars), 0);
-    else
-      rv = ::ToAsciiEx (aDeadKey, 0, (PBYTE)aDeadKeyKbdState, dummyChars, 0, mKeyboardLayout);
+    rv = ::ToUnicode (aDeadKey, 0, (PBYTE)aDeadKeyKbdState, (LPWSTR)dummyChars, NS_ARRAY_LENGTH (dummyChars), 0);
     // returned values:
     // <0 - Dead key state is active. The keyboard driver will wait for next character.
     //  1 - Previous pressed key was a valid base character that produced exactly one composite character.
@@ -663,13 +616,9 @@ PRUint32 KeyboardLayout::GetDeadKeyCombinations (PRUint8 aDeadKey, const PBYTE a
         // Depending on the character the followed the dead-key, the keyboard driver can produce
         // one composite character, or a dead-key character followed by a second character.
         PRUint16 compositeChars [5];
-        WORD ascii [2];     // On Win9x ToAsciiEx returns WORD per character, on Win2k BYTE per character.
         PRInt32 rv;
 
-        if (nsToolkit::mIsNT)
-          rv = ::ToUnicode (virtualKey, 0, kbdState, (LPWSTR)compositeChars, NS_ARRAY_LENGTH (compositeChars), 0);
-        else
-          rv = ::ToAsciiEx (virtualKey, 0, kbdState, ascii, 0, mKeyboardLayout);
+        rv = ::ToUnicode (virtualKey, 0, kbdState, (LPWSTR)compositeChars, NS_ARRAY_LENGTH (compositeChars), 0);
 
         switch (rv)
         {
@@ -683,15 +632,7 @@ PRUint32 KeyboardLayout::GetDeadKeyCombinations (PRUint8 aDeadKey, const PBYTE a
             // character one more time to determine the base character.
             PRUint16 baseChars [5];
 
-            if (nsToolkit::mIsNT)
-              rv = ::ToUnicode (virtualKey, 0, kbdState, (LPWSTR)baseChars, NS_ARRAY_LENGTH (baseChars), 0);
-            else
-            {
-              ::MultiByteToWideChar (mCodePage, 0, (LPCSTR)ascii, 1, (WCHAR*)compositeChars, NS_ARRAY_LENGTH (compositeChars));
-
-              rv = ::ToAsciiEx (virtualKey, 0, kbdState, ascii, 0, mKeyboardLayout);
-              rv = ::MultiByteToWideChar (mCodePage, 0, (LPCSTR)ascii, rv, (WCHAR*)baseChars, NS_ARRAY_LENGTH (baseChars));
-            }
+            rv = ::ToUnicode (virtualKey, 0, kbdState, (LPWSTR)baseChars, NS_ARRAY_LENGTH (baseChars), 0);
 
             NS_ASSERTION (rv == 1, "One base character expected");
 
@@ -738,29 +679,4 @@ PRUint16 DeadKeyTable::GetCompositeChar (PRUint16 aBaseChar) const
   return 0;
 }
 
-PRBool LangIDToCP (WORD aLangID, UINT* aCodePage)
-{
-  DWORD localeid = MAKELCID (aLangID, SORT_DEFAULT);
-  int numchar = ::GetLocaleInfo (localeid, LOCALE_IDEFAULTANSICODEPAGE, NULL, 0);
-  char cp_on_stack [32];
-  char* cp_name;
-
-  if (numchar > 32)
-    cp_name  = new char [numchar];
-  else
-    cp_name = cp_on_stack;
-
-  if (cp_name)
-  {
-    ::GetLocaleInfo (localeid, LOCALE_IDEFAULTANSICODEPAGE, cp_name, numchar);
-    *aCodePage = atoi (cp_name);
-    if (cp_name != cp_on_stack)
-      delete [] cp_name;
-    return PR_TRUE;
-  } else
-  {
-    *aCodePage = CP_ACP;
-    return PR_FALSE;
-  }
-}
 #endif
diff --git a/widget/src/windows/nsScreenManagerWin.cpp b/widget/src/windows/nsScreenManagerWin.cpp
index 94cb1182f593b7404b32e7660f66f57f25ae8e31..a801a99fc808d424338a94bec2f2120a4f9328f8 100644
--- a/widget/src/windows/nsScreenManagerWin.cpp
+++ b/widget/src/windows/nsScreenManagerWin.cpp
@@ -48,23 +48,8 @@
 #include "nsScreenManagerWin.h"
 #include "nsScreenWin.h"
 
-// needed because there are unicode/ansi versions of this routine
-// and we need to make sure we get the correct one.
-#ifdef UNICODE
-#define GetMonitorInfoQuoted "GetMonitorInfoW"
-#else
-#define GetMonitorInfoQuoted "GetMonitorInfoA"
-#endif
-
-
-#if defined(__MINGW32__) || _MSC_VER >= 1200
-typedef HMONITOR (WINAPI *MonitorFromRectProc)(LPCRECT inRect, DWORD inFlag); 
-typedef BOOL (WINAPI *EnumDisplayMonitorsProc)(HDC, LPCRECT, MONITORENUMPROC, LPARAM);
 
 BOOL CALLBACK CountMonitors ( HMONITOR, HDC, LPRECT, LPARAM ioCount ) ;
-#else
-typedef void* HMONITOR;
-#endif
 
 
 class ScreenListItem
@@ -79,22 +64,9 @@ public:
 
 
 nsScreenManagerWin :: nsScreenManagerWin ( )
-  : mHasMultiMonitorAPIs(PR_FALSE), mNumberOfScreens(0),
-    mGetMonitorInfoProc(nsnull), mMonitorFromRectProc(nsnull),
-    mEnumDisplayMonitorsProc(nsnull)
+  : mNumberOfScreens(0)
 {
-  // figure out if we can call the multiple monitor APIs that are only
-  // available on Win98/2000.
-  HMODULE lib = GetModuleHandle("user32.dll");
-  if ( lib ) {
-    mGetMonitorInfoProc = GetProcAddress ( lib, GetMonitorInfoQuoted );
-    mMonitorFromRectProc = GetProcAddress ( lib, "MonitorFromRect" );
-    mEnumDisplayMonitorsProc = GetProcAddress ( lib, "EnumDisplayMonitors" );
-    if ( mGetMonitorInfoProc && mMonitorFromRectProc && mEnumDisplayMonitorsProc )
-      mHasMultiMonitorAPIs = PR_TRUE;
-  }
-
-  // nothing else to do. I guess we could cache a bunch of information
+  // nothing to do. I guess we could cache a bunch of information
   // here, but we want to ask the device at runtime in case anything
   // has changed.
 }
@@ -166,16 +138,7 @@ nsScreenManagerWin :: ScreenForRect ( PRInt32 inLeft, PRInt32 inTop, PRInt32 inW
 
   RECT globalWindowBounds = { inLeft, inTop, inLeft + inWidth, inTop + inHeight };
 
-  void* genScreen = nsnull;
-#if defined(__MINGW32__) || _MSC_VER >= 1200
-  if ( mHasMultiMonitorAPIs ) {
-    MonitorFromRectProc proc = (MonitorFromRectProc)mMonitorFromRectProc;
-    HMONITOR screen = (*proc)( &globalWindowBounds, MONITOR_DEFAULTTOPRIMARY );
-    genScreen = screen;
-
-    //XXX find the DC for this screen??
-  }
-#endif
+  void* genScreen = ::MonitorFromRect( &globalWindowBounds, MONITOR_DEFAULTTOPRIMARY );
 
   *outScreen = CreateNewScreenObject ( genScreen );    // addrefs
   
@@ -199,7 +162,6 @@ nsScreenManagerWin :: GetPrimaryScreen(nsIScreen** aPrimaryScreen)
 } // GetPrimaryScreen
 
 
-#if defined(__MINGW32__) || _MSC_VER >= 1200
 //
 // CountMonitors
 //
@@ -216,7 +178,6 @@ CountMonitors ( HMONITOR, HDC, LPRECT, LPARAM ioParam )
   return TRUE; // continue the enumeration
 
 } // CountMonitors
-#endif
 
 
 //
@@ -229,18 +190,13 @@ nsScreenManagerWin :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
 {
   if ( mNumberOfScreens )
     *aNumberOfScreens = mNumberOfScreens;
-#if defined(__MINGW32__) || _MSC_VER >= 1200
-  else if ( mHasMultiMonitorAPIs ) {
-      PRUint32 count = 0;
-      EnumDisplayMonitorsProc proc = (EnumDisplayMonitorsProc)mEnumDisplayMonitorsProc;
-      BOOL result = (*proc)(nsnull, nsnull, (MONITORENUMPROC)CountMonitors, (LPARAM)&count);
-      if (!result)
-        return NS_ERROR_FAILURE;
-      *aNumberOfScreens = mNumberOfScreens = count;      
-  } // if there can be > 1 screen
-#endif
-  else
-    *aNumberOfScreens = mNumberOfScreens = 1;
+  else {
+    PRUint32 count = 0;
+    BOOL result = ::EnumDisplayMonitors(nsnull, nsnull, (MONITORENUMPROC)CountMonitors, (LPARAM)&count);
+    if (!result)
+      return NS_ERROR_FAILURE;
+    *aNumberOfScreens = mNumberOfScreens = count;
+  }
 
   return NS_OK;
   
diff --git a/widget/src/windows/nsScreenManagerWin.h b/widget/src/windows/nsScreenManagerWin.h
index bbb87f336dff1df9a0a5bc632d1b459aaa1bb3a0..1decf4f964be9f3d9286b11f5aecb18a00b7557f 100644
--- a/widget/src/windows/nsScreenManagerWin.h
+++ b/widget/src/windows/nsScreenManagerWin.h
@@ -62,15 +62,8 @@ private:
 
   nsIScreen* CreateNewScreenObject ( void* inScreen ) ;
 
-  PRBool mHasMultiMonitorAPIs;
   PRUint32 mNumberOfScreens;
 
-    // function pointers for multi-monitor API system calls that we use. Not
-    // valid unless |mHasMultiMonitorAPIs| is true
-  FARPROC mGetMonitorInfoProc;
-  FARPROC mMonitorFromRectProc;
-  FARPROC mEnumDisplayMonitorsProc;
-
     // cache the screens to avoid the memory allocations
   nsAutoVoidArray mScreenList;
 
diff --git a/widget/src/windows/nsScreenWin.cpp b/widget/src/windows/nsScreenWin.cpp
index d00e7510ca70fdc3c7595650c448f960e69d4a98..f1bbe2a9c6d475c3a1d65a7bba931ce646261a7e 100644
--- a/widget/src/windows/nsScreenWin.cpp
+++ b/widget/src/windows/nsScreenWin.cpp
@@ -48,23 +48,10 @@
 #include "nsScreenWin.h"
 
 
-// needed because there are unicode/ansi versions of this routine
-// and we need to make sure we get the correct one.
-#ifdef UNICODE
-#define GetMonitorInfoQuoted "GetMonitorInfoW"
-#else
-#define GetMonitorInfoQuoted "GetMonitorInfoA"
-#endif
-
-
-#if _MSC_VER >= 1200
-typedef BOOL (WINAPI *GetMonitorInfoProc)(HMONITOR inMon, LPMONITORINFO ioInfo); 
-#endif
 
 
 nsScreenWin :: nsScreenWin ( void* inScreen )
-  : mScreen(inScreen), mHasMultiMonitorAPIs(PR_FALSE),
-      mGetMonitorInfoProc(nsnull)
+  : mScreen(inScreen)
 {
 #ifdef DEBUG
   HDC hDCScreen = ::GetDC(nsnull);
@@ -72,17 +59,6 @@ nsScreenWin :: nsScreenWin ( void* inScreen )
   NS_ASSERTION ( ::GetDeviceCaps(hDCScreen, TECHNOLOGY) == DT_RASDISPLAY, "Not a display screen");
   ::ReleaseDC(nsnull,hDCScreen);
 #endif
-   
-#if _MSC_VER >= 1200
-  // figure out if we can call the multiple monitor APIs that are only
-  // available on Win98/2000.
-  HMODULE lib = GetModuleHandle("user32.dll");
-  if ( lib ) {
-    mGetMonitorInfoProc = GetProcAddress ( lib, GetMonitorInfoQuoted );
-    if ( mGetMonitorInfoProc )
-      mHasMultiMonitorAPIs = PR_TRUE;
-  }
-#endif
 
   // nothing else to do. I guess we could cache a bunch of information
   // here, but we want to ask the device at runtime in case anything
@@ -105,11 +81,10 @@ nsScreenWin :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRI
 {
   BOOL success = FALSE;
 #if _MSC_VER >= 1200
-  if ( mScreen && mHasMultiMonitorAPIs ) {
-    GetMonitorInfoProc proc = (GetMonitorInfoProc)mGetMonitorInfoProc;
+  if ( mScreen ) {
     MONITORINFO info;
     info.cbSize = sizeof(MONITORINFO);
-    success = (*proc)( (HMONITOR)mScreen, &info );
+    success = ::GetMonitorInfoW( (HMONITOR)mScreen, &info );
     if ( success ) {
       *outLeft = info.rcMonitor.left;
       *outTop = info.rcMonitor.top;
@@ -138,11 +113,10 @@ nsScreenWin :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth
 {
   BOOL success = FALSE;
 #if _MSC_VER >= 1200
-  if ( mScreen && mHasMultiMonitorAPIs ) {
-    GetMonitorInfoProc proc = (GetMonitorInfoProc)mGetMonitorInfoProc;
+  if ( mScreen ) {
     MONITORINFO info;
     info.cbSize = sizeof(MONITORINFO);
-    success = (*proc)( (HMONITOR)mScreen, &info );
+    success = ::GetMonitorInfoW( (HMONITOR)mScreen, &info );
     if ( success ) {
       *outLeft = info.rcWork.left;
       *outTop = info.rcWork.top;
diff --git a/widget/src/windows/nsScreenWin.h b/widget/src/windows/nsScreenWin.h
index eca53adfbc6aa5994fcf4565115cc2cefa2087ca..5eb01d16381e97a344ade26c10d2cebbb38ccb9b 100644
--- a/widget/src/windows/nsScreenWin.h
+++ b/widget/src/windows/nsScreenWin.h
@@ -53,11 +53,6 @@ public:
   NS_DECL_NSISCREEN
 
 private:
-  
-    // function pointers for multi-monitor API system calls that we use. Not
-    // valid unless |mHasMultiMonitorAPIs| is true
-  PRBool mHasMultiMonitorAPIs;
-  FARPROC mGetMonitorInfoProc ;
 
   void* mScreen;                    // a |HMONITOR|, can't use this type in header file though.
 };
diff --git a/widget/src/windows/nsSound.cpp b/widget/src/windows/nsSound.cpp
index 5dcd24efb36c805c26b859e1fa444ee11afc6cc4..4be07cf16dd5a4764ed09e5da3c0a4bd1788f4c0 100644
--- a/widget/src/windows/nsSound.cpp
+++ b/widget/src/windows/nsSound.cpp
@@ -55,50 +55,6 @@
 
 NS_IMPL_ISUPPORTS2(nsSound, nsISound, nsIStreamLoaderObserver)
 
-////////////////////////////////////////////////////////////////////////
-// This hidden class is used to load the winmm.dll when it's needed.
-
-class CWinMM {
-  typedef int (CALLBACK *PlayPtr)(const char*,HMODULE,DWORD);
-
-public:
-
-  static CWinMM& GetModule() {
-    static CWinMM gSharedWinMM;  //construct this only after you *really* need it.
-    return gSharedWinMM;
-  }
-
-
-  CWinMM(const char* aModuleName="WINMM.DLL") {
-    mInstance=::LoadLibrary(aModuleName);  
-    mPlay=(mInstance) ? (PlayPtr)GetProcAddress(mInstance,"PlaySound") : 0;
-    sIsInitialized = PR_TRUE;
-  }
-
-  ~CWinMM() {
-    if(mInstance)
-      ::FreeLibrary(mInstance);
-    mInstance=0;
-    mPlay=0;
-  }
-
-  BOOL PlaySound(const char *aSoundFile,HMODULE aModule,DWORD aOptions) {
-    return (mPlay) ? mPlay(aSoundFile, aModule, aOptions) : FALSE;
-  }
-
-  static BOOL IsInitialized() {
-    return sIsInitialized;
-  }
- 
-private:
-  HINSTANCE mInstance;  
-  PlayPtr mPlay;
-  static BOOL sIsInitialized;
-};
-
-BOOL CWinMM::sIsInitialized = PR_FALSE;
-
-////////////////////////////////////////////////////////////////////////
 
 nsSound::nsSound()
 {
@@ -113,8 +69,7 @@ nsSound::~nsSound()
 void nsSound::PurgeLastSound() {
   if (mLastSound) {
     // Purge the current sound buffer.
-    CWinMM& theMM = CWinMM::GetModule();
-    theMM.PlaySound(nsnull, nsnull, SND_PURGE); // This call halts the sound if it was still playing.
+    ::PlaySound(nsnull, nsnull, SND_PURGE); // This call halts the sound if it was still playing.
 
     // Now delete the buffer.
     free(mLastSound);
@@ -170,8 +125,7 @@ NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
       flags |= SND_ASYNC;
     }
 
-    CWinMM& theMM = CWinMM::GetModule();
-    theMM.PlaySound(NS_REINTERPRET_CAST(const char*, data), 0, flags);
+    ::PlaySound(NS_REINTERPRET_CAST(const char*, data), 0, flags);
   }
 
   return NS_OK;
@@ -196,16 +150,12 @@ NS_IMETHODIMP nsSound::Play(nsIURL *aURL)
 
 NS_IMETHODIMP nsSound::Init()
 {
-  if (CWinMM::IsInitialized())
-    return NS_OK;
-  CWinMM& theMM = CWinMM::GetModule();
-
   // This call halts a sound if it was still playing.
   // We have to use the sound library for something to make sure
   // it is initialized.
   // If we wait until the first sound is played, there will
   // be a time lag as the library gets loaded.
-  theMM.PlaySound(nsnull, nsnull, SND_PURGE); 
+  ::PlaySound(nsnull, nsnull, SND_PURGE); 
 
   return NS_OK;
 }
@@ -215,15 +165,13 @@ NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
 {
   PurgeLastSound();
 
-  CWinMM& theMM = CWinMM::GetModule();
-
   if (aSoundAlias.EqualsLiteral("_moz_mailbeep")) {
-    theMM.PlaySound("MailBeep", nsnull, SND_ALIAS | SND_ASYNC);
+    ::PlaySound("MailBeep", nsnull, SND_ALIAS | SND_ASYNC);
   }
   else {
     nsCAutoString nativeSoundAlias;
     NS_CopyUnicodeToNative(aSoundAlias, nativeSoundAlias);
-    theMM.PlaySound(nativeSoundAlias.get(), nsnull, SND_ALIAS | SND_ASYNC);
+    ::PlaySound(nativeSoundAlias.get(), nsnull, SND_ALIAS | SND_ASYNC);
   }
 
   return NS_OK;
diff --git a/widget/src/windows/nsToolkit.cpp b/widget/src/windows/nsToolkit.cpp
index 039fca68cb86947cecfc745a15983b56cbba79ab..140f239f89ac6788609a238fd72827527a7d0448 100644
--- a/widget/src/windows/nsToolkit.cpp
+++ b/widget/src/windows/nsToolkit.cpp
@@ -46,7 +46,6 @@
 #include "nsIEventQueueService.h"
 #include "nsIEventQueue.h"
 #include "nsComponentManagerUtils.h"
-#include "nsNativeCharsetUtils.h"
 #include <objbase.h>
 #include <initguid.h>
 
@@ -75,24 +74,9 @@ static PRUintn gToolkitTLSIndex = 0;
 
 
 HINSTANCE nsToolkit::mDllInstance = 0;
-PRBool    nsToolkit::mIsNT = PR_FALSE;
-PRBool    nsToolkit::mUseImeApiW  = PR_FALSE;
-PRBool    nsToolkit::mW2KXP_CP936 = PR_FALSE;
 PRBool    nsToolkit::mIsWinXP     = PR_FALSE;
 static PRBool dummy = nsToolkit::InitVersionInfo();
 
-DEFINE_GUID(IID_IActiveIMMApp, 
-0x08c0e040, 0x62d1, 0x11d1, 0x93, 0x26, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
-
-DEFINE_GUID(CLSID_CActiveIMM,
-0x4955DD33, 0xB159, 0x11d0, 0x8F, 0xCF, 0x0, 0xAA, 0x00, 0x6B, 0xCC, 0x59);
-
-DEFINE_GUID(IID_IActiveIMMMessagePumpOwner,
-0xb5cf2cfa, 0x8aeb, 0x11d1, 0x93, 0x64, 0x0, 0x60, 0xb0, 0x67, 0xb8, 0x6e);
-
-IActiveIMMApp* nsToolkit::gAIMMApp   = NULL;
-PRInt32        nsToolkit::gAIMMCount = 0;
-
 #if !defined(MOZ_STATIC_COMPONENT_LIBS) && !defined(MOZ_ENABLE_LIBXUL)
 //
 // Dll entry point. Keep the dll instance
@@ -182,316 +166,13 @@ LRESULT CALLBACK DetectWindowMove(int code, WPARAM wParam, LPARAM lParam)
 #define MAX_MENU_NAME   128
 #define MAX_FILTER_NAME 256
 
-BOOL CallOpenSaveFileNameA(LPOPENFILENAMEW aFileNameW, BOOL aOpen)
-{
-  BOOL rtn;
-  OPENFILENAMEA ofnA;
-  char filterA[MAX_FILTER_NAME+2];
-  char customFilterA[MAX_FILTER_NAME+1];
-  char fileA[FILE_BUFFER_SIZE+1];
-  char fileTitleA[MAX_PATH+1];
-  char initDirA[MAX_PATH+1];
-  char titleA[MAX_PATH+1];
-  char defExtA[MAX_PATH+1];
-  char tempNameA[MAX_PATH+1];
-
-  memset(&ofnA, 0, sizeof(OPENFILENAMEA));
-#if _WIN32_WINNT >= 0x0500
-  ofnA.lStructSize = OPENFILENAME_SIZE_VERSION_400; 
-#else
-  ofnA.lStructSize = sizeof(OPENFILENAME); 
-#endif
-  ofnA.hwndOwner = aFileNameW->hwndOwner; 
-  ofnA.hInstance = aFileNameW->hInstance; 
-  if (aFileNameW->lpstrFilter)  {
-    // find the true filter length
-    int len = 0;
-    while ((aFileNameW->lpstrFilter[len]) ||
-           (aFileNameW->lpstrFilter[len+1]))
-    {
-      ++len;
-    }
-
-    len = WideCharToMultiByte(CP_ACP, 0,
-                              aFileNameW->lpstrFilter,
-                              len,
-                              filterA,
-                              MAX_FILTER_NAME, NULL, NULL);
-    filterA[len] = '\0';
-    filterA[len+1] = '\0';
-    ofnA.lpstrFilter = filterA; 
-  }
-  if (aFileNameW->lpstrCustomFilter)  {
-    NS_ConvertWtoA(aFileNameW->lpstrCustomFilter, MAX_FILTER_NAME,
-                   customFilterA, "?");
-    ofnA.lpstrCustomFilter = customFilterA; 
-    ofnA.nMaxCustFilter = MAX_FILTER_NAME;  
-  }
-  ofnA.nFilterIndex = aFileNameW->nFilterIndex; // Index of pair of filter strings. Should be ok.
-  if (aFileNameW->lpstrFile)  {
-    NS_ConvertWtoA(aFileNameW->lpstrFile, FILE_BUFFER_SIZE, fileA, "?");
-    ofnA.lpstrFile = fileA;
-    ofnA.nMaxFile = FILE_BUFFER_SIZE;
-    if (strlen(fileA))  {
-      // find last file offset
-      ofnA.nFileOffset = strrchr(fileA, '\\') - fileA + 1; 
-      // find last file extension offset
-      ofnA.nFileExtension = strrchr(fileA, '.') - fileA + 1; 
-    }
-  }
-  if (aFileNameW->lpstrFileTitle) {
-    NS_ConvertWtoA(aFileNameW->lpstrFileTitle, MAX_PATH, fileTitleA, "?");
-    ofnA.lpstrFileTitle = fileTitleA;
-    ofnA.nMaxFileTitle = MAX_PATH;  
-  }
-  if (aFileNameW->lpstrInitialDir)  {
-    NS_ConvertWtoA(aFileNameW->lpstrInitialDir, MAX_PATH, initDirA, "?");
-    ofnA.lpstrInitialDir = initDirA; 
-  }
-  if (aFileNameW->lpstrTitle) {
-    NS_ConvertWtoA(aFileNameW->lpstrTitle, MAX_PATH, titleA, "?");
-    ofnA.lpstrTitle = titleA; 
-  }
-  ofnA.Flags = aFileNameW->Flags; 
-  if (aFileNameW->lpstrDefExt)  {
-    NS_ConvertWtoA(aFileNameW->lpstrDefExt, MAX_PATH, defExtA, "?");
-    ofnA.lpstrDefExt = defExtA; 
-  }
-  // Warning:  No WtoA() is done to application-defined data 
-  ofnA.lCustData = aFileNameW->lCustData; 
-  ofnA.lpfnHook = aFileNameW->lpfnHook;   
-  if (aFileNameW->lpTemplateName) {
-    NS_ConvertWtoA(aFileNameW->lpTemplateName, MAX_PATH, tempNameA, "?");
-    ofnA.lpTemplateName = tempNameA; 
-  }
-  
-  if (aOpen)
-    rtn = GetOpenFileNameA(&ofnA);
-  else
-    rtn = GetSaveFileNameA(&ofnA);
-
-  if (!rtn)
-    return 0;
-
-  if (ofnA.lpstrFile) {
-    if ((ofnA.Flags & OFN_ALLOWMULTISELECT) && (ofnA.Flags & OFN_EXPLORER)) {
-      // lpstrFile contains the directory and file name strings 
-      // which are NULL separated, with an extra NULL character after the last file name. 
-      int lenA = 0;
-      while ((ofnA.lpstrFile[lenA]) || (ofnA.lpstrFile[lenA+1]))
-      {
-        ++lenA;
-      }
-      // get the size of required Wide Char and make sure aFileNameW->lpstrFile has enough space
-      int lenW = MultiByteToWideChar(CP_ACP, 0, ofnA.lpstrFile, lenA, 0, 0);
-      if (aFileNameW->nMaxFile < lenW+2)
-        return 0; // doesn't have enough allocated space
-      MultiByteToWideChar(CP_ACP, 0, ofnA.lpstrFile, lenA, aFileNameW->lpstrFile, aFileNameW->nMaxFile);
-      aFileNameW->lpstrFile[lenW] = '\0';
-      aFileNameW->lpstrFile[lenW+1] = '\0';
-    }
-    else  { 
-      NS_ConvertAtoW(ofnA.lpstrFile, aFileNameW->nMaxFile, aFileNameW->lpstrFile);
-    }
-  }
-
-  aFileNameW->nFilterIndex = ofnA.nFilterIndex;
-
-  return rtn;
-}
-
-BOOL WINAPI nsGetOpenFileName(LPOPENFILENAMEW aOpenFileNameW)
-{
-  return CallOpenSaveFileNameA(aOpenFileNameW, TRUE);
-}
-
-BOOL WINAPI nsGetSaveFileName(LPOPENFILENAMEW aSaveFileNameW)
-{
-  return CallOpenSaveFileNameA(aSaveFileNameW, FALSE);
-}
-
-int WINAPI nsGetClassName(HWND aWnd, LPWSTR aClassName, int aMaxCount)
-{
-  char classNameA[MAX_CLASS_NAME];
-
-  if (!GetClassNameA(aWnd, classNameA, MAX_CLASS_NAME))
-    return 0;
-
-  aMaxCount = NS_ConvertAtoW(classNameA, MAX_CLASS_NAME, aClassName);
-
-  return aMaxCount;
-}
-
-HWND WINAPI nsCreateWindowEx(DWORD aExStyle,      
-                             LPCWSTR aClassNameW,  
-                             LPCWSTR aWindowNameW, 
-                             DWORD aStyle,        
-                             int aX,                
-                             int aY,                
-                             int aWidth,           
-                             int aHeight,          
-                             HWND aWndParent,      
-                             HMENU aMenu,          
-                             HINSTANCE aInstance,  
-                             LPVOID aParam)
-{
-  char classNameA [MAX_CLASS_NAME];
-  char windowNameA[MAX_CLASS_NAME];
-
-  // Convert class name and Window name from Unicode to ANSI
-  if (aClassNameW)
-      NS_ConvertWtoA(aClassNameW, MAX_CLASS_NAME, classNameA, "?");
-  if (aWindowNameW)
-      NS_ConvertWtoA(aWindowNameW, MAX_CLASS_NAME, windowNameA, "?");
-  
-  // so far only NULL is passed
-  if (aParam != NULL) {
-    NS_ASSERTION(0 , "non-NULL lParam is provided in CreateWindowExA");
-    return NULL;
-  }
-
-  return CreateWindowExA(aExStyle, classNameA, windowNameA,
-      aStyle, aX, aY, aWidth, aHeight, aWndParent, aMenu, aInstance, aParam) ;
-}
-
-LRESULT WINAPI nsSendMessage(HWND aWnd, UINT aMsg, WPARAM awParam, LPARAM alParam)
-{
-  // ************ Developers **********************************************
-  // As far as I am aware, WM_SETTEXT is the only text related message 
-  // we call to SendMessage().  When you need to send other text related message,
-  // please use appropriate converters.
-  NS_ASSERTION((WM_SETTEXT == aMsg || WM_SETICON == aMsg || WM_SETFONT == aMsg), 
-			"Warning. Make sure sending non-Unicode string to ::SendMessage().");
-  if (WM_SETTEXT == aMsg)  {
-    char title[MAX_PATH];
-    if (alParam) // Note: Window titles are truncated to 159 chars by Windows
-      NS_ConvertWtoA((LPCWSTR)alParam, MAX_PATH, title, "?");
-    return SendMessageA(aWnd, aMsg, awParam, (LPARAM)&title);
-  }
-
-  return SendMessageA(aWnd, aMsg, awParam, alParam);
-}
-
-ATOM WINAPI nsRegisterClass(const WNDCLASSW *aClassW)
-{
-  WNDCLASSA wClass;
-  char classNameA[MAX_CLASS_NAME];
-  char menuNameA[MAX_MENU_NAME];
-
-  // Set up ANSI version of class struct
-  wClass.cbClsExtra   = aClassW->cbClsExtra;
-  wClass.cbWndExtra   = aClassW->cbWndExtra;
-  wClass.hbrBackground= aClassW->hbrBackground;
-  wClass.hCursor      = aClassW->hCursor;
-  wClass.hIcon        = aClassW->hIcon;
-  wClass.hInstance    = aClassW->hInstance;
-  wClass.lpfnWndProc  = aClassW->lpfnWndProc;
-  wClass.style        = aClassW->style;
-
-  if (NULL == aClassW->lpszClassName)
-    return 0 ;
-
-  wClass.lpszClassName = classNameA;
-  if (aClassW->lpszClassName)
-    NS_ConvertWtoA(aClassW->lpszClassName, MAX_CLASS_NAME, classNameA, "?");
-  
-  wClass.lpszMenuName = menuNameA; 
-  if (aClassW->lpszMenuName)
-    NS_ConvertWtoA(aClassW->lpszMenuName, MAX_MENU_NAME, menuNameA, "?");
-
-  return RegisterClassA(&wClass);
-}
-
-BOOL WINAPI nsUnregisterClass(LPCWSTR aClassW, HINSTANCE aInst)
-{
-  char classA[MAX_PATH+1];
-
-  if (aClassW)  {
-    NS_ConvertWtoA(aClassW, MAX_PATH, classA, "?");
-    return UnregisterClassA((LPCSTR)classA, aInst);
-  }
-  return FALSE;
-}
-
-#ifndef WINCE
-BOOL WINAPI nsSHGetPathFromIDList(LPCITEMIDLIST aIdList, LPWSTR aPathW)
-{
-  char pathA[MAX_PATH+1];
-
-  if (aPathW)  {
-    NS_ConvertWtoA(aPathW, MAX_PATH, pathA, "?");
-    if (SHGetPathFromIDListA(aIdList, pathA)) {
-      NS_ConvertAtoW(pathA, MAX_PATH, aPathW);
-      return TRUE;
-    }
-  }
-
-  return FALSE;
-}
-
-LPITEMIDLIST WINAPI nsSHBrowseForFolder(LPBROWSEINFOW aBiW)
-{
-  BROWSEINFO biA;
-  LPITEMIDLIST itemIdList;
-  char displayNameA[MAX_PATH];
-  char titleA[MAX_PATH];
-
-  memset(&biA, 0, sizeof(BROWSEINFO));
-  biA.hwndOwner = aBiW->hwndOwner;
-  biA.pidlRoot = aBiW->pidlRoot;
-  if (aBiW->pszDisplayName)  {
-    NS_ConvertWtoA(aBiW->pszDisplayName, MAX_PATH, displayNameA, "?");
-    biA.pszDisplayName = displayNameA; 
-  }
-  if (aBiW->lpszTitle)  {
-    NS_ConvertWtoA(aBiW->lpszTitle, MAX_PATH, titleA, "?");
-    biA.lpszTitle = titleA; 
-  }
-  biA.ulFlags = aBiW->ulFlags;
-  biA.lpfn = aBiW->lpfn;
-  biA.lParam = aBiW->lParam;
-  biA.iImage = aBiW->iImage;
-
-  itemIdList = SHBrowseForFolderA(&biA);
-  if (biA.pszDisplayName)  {
-    NS_ConvertAtoW(biA.pszDisplayName, MAX_PATH, aBiW->pszDisplayName);
-  }
-  return itemIdList;
-}
-#endif //#ifndef WINCE
-
-HMODULE             nsToolkit::mShell32Module = NULL;
-NS_DefWindowProc    nsToolkit::mDefWindowProc = DefWindowProcA;
-NS_CallWindowProc   nsToolkit::mCallWindowProc = CallWindowProcA;
-NS_SetWindowLong    nsToolkit::mSetWindowLong = SetWindowLongA;
-NS_GetWindowLong    nsToolkit::mGetWindowLong = GetWindowLongA;
-NS_SendMessage      nsToolkit::mSendMessage = nsSendMessage;
-NS_DispatchMessage  nsToolkit::mDispatchMessage = DispatchMessageA;
-NS_GetMessage       nsToolkit::mGetMessage = GetMessageA;
-NS_PeekMessage      nsToolkit::mPeekMessage = PeekMessageA;
-NS_GetOpenFileName  nsToolkit::mGetOpenFileName = nsGetOpenFileName;
-NS_GetSaveFileName  nsToolkit::mGetSaveFileName = nsGetSaveFileName;
-NS_GetClassName     nsToolkit::mGetClassName = nsGetClassName;
-NS_CreateWindowEx   nsToolkit::mCreateWindowEx = nsCreateWindowEx;
-NS_RegisterClass    nsToolkit::mRegisterClass = nsRegisterClass; 
-NS_UnregisterClass  nsToolkit::mUnregisterClass = nsUnregisterClass; 
-
 MouseTrailer*       nsToolkit::gMouseTrailer;
 
-#ifndef WINCE
-NS_SHGetPathFromIDList  nsToolkit::mSHGetPathFromIDList = nsSHGetPathFromIDList; 
-NS_SHBrowseForFolder    nsToolkit::mSHBrowseForFolder = nsSHBrowseForFolder; 
-#endif
-
 void RunPump(void* arg)
 {
     ThreadInitInfo *info = (ThreadInitInfo*)arg;
     ::PR_EnterMonitor(info->monitor);
 
-    // Start Active Input Method Manager on this thread
-    if(nsToolkit::gAIMMApp)
-        nsToolkit::gAIMMApp->Activate(TRUE);
-
     // do registration and creation in this thread
     info->toolkit->CreateInternalWindow(PR_GetCurrentThread());
 
@@ -504,9 +185,9 @@ void RunPump(void* arg)
 
     // Process messages
     MSG msg;
-    while (nsToolkit::mGetMessage(&msg, NULL, 0, 0)) {
+    while (::GetMessageW(&msg, NULL, 0, 0)) {
         TranslateMessage(&msg);
-        nsToolkit::mDispatchMessage(&msg);
+        ::DispatchMessageW(&msg);
     }
 }
 
@@ -520,17 +201,6 @@ nsToolkit::nsToolkit()
     mGuiThread  = NULL;
     mDispatchWnd = 0;
 
-    //
-    // Initialize COM since create Active Input Method Manager object
-    //
-    if (!nsToolkit::gAIMMCount)
-      ::CoInitialize(NULL);
-
-    if(!nsToolkit::gAIMMApp)
-      ::CoCreateInstance(CLSID_CActiveIMM, NULL, CLSCTX_INPROC_SERVER, IID_IActiveIMMApp, (void**) &nsToolkit::gAIMMApp);
-
-    nsToolkit::gAIMMCount++;
-
 #if defined(MOZ_STATIC_COMPONENT_LIBS) || defined (WINCE)
     nsToolkit::Startup(GetModuleHandle(NULL));
 #endif
@@ -548,17 +218,6 @@ nsToolkit::~nsToolkit()
 {
     NS_PRECONDITION(::IsWindow(mDispatchWnd), "Invalid window handle");
 
-    nsToolkit::gAIMMCount--;
-
-    if (!nsToolkit::gAIMMCount) {
-        if(nsToolkit::gAIMMApp) {
-            nsToolkit::gAIMMApp->Deactivate();
-            nsToolkit::gAIMMApp->Release();
-            nsToolkit::gAIMMApp = NULL;
-        }
-        ::CoUninitialize();
-    }
-
     // Destroy the Dispatch Window
     ::DestroyWindow(mDispatchWnd);
     mDispatchWnd = NULL;
@@ -592,41 +251,6 @@ nsToolkit::~nsToolkit()
 void
 nsToolkit::Startup(HMODULE hModule)
 {
-#ifndef WINCE
-    if (nsToolkit::mIsNT)
-#endif // #ifndef WINCE
-
-    {
-      // For Windows 9x base OS nsFoo is already pointing to A functions
-      // However on NT base OS we should point them to respective W functions
-      nsToolkit::mDefWindowProc = DefWindowProcW;
-      nsToolkit::mCallWindowProc = CallWindowProcW;
-      nsToolkit::mSetWindowLong = SetWindowLongW;
-      nsToolkit::mGetWindowLong = GetWindowLongW; 
-      nsToolkit::mSendMessage = SendMessageW;
-      nsToolkit::mDispatchMessage = DispatchMessageW;
-      nsToolkit::mGetMessage = GetMessageW;
-      nsToolkit::mPeekMessage = PeekMessageW;
-      nsToolkit::mGetOpenFileName = GetOpenFileNameW;
-      nsToolkit::mGetSaveFileName = GetSaveFileNameW;
-      nsToolkit::mGetClassName = GetClassNameW;
-      nsToolkit::mCreateWindowEx = CreateWindowExW;
-      nsToolkit::mRegisterClass = RegisterClassW; 
-      nsToolkit::mUnregisterClass = UnregisterClassW; 
-      // Explicit call of SHxxxW in Win95 makes moz fails to run (170969)
-      // we use GetProcAddress() to hide
-#ifndef WINCE
-      nsToolkit::mShell32Module = ::LoadLibrary("Shell32.dll");
-      if (nsToolkit::mShell32Module) {
-        nsToolkit::mSHGetPathFromIDList = (NS_SHGetPathFromIDList)GetProcAddress(nsToolkit::mShell32Module, "SHGetPathFromIDListW"); 
-        if (!nsToolkit::mSHGetPathFromIDList)
-          nsToolkit::mSHGetPathFromIDList = &nsSHGetPathFromIDList;
-        nsToolkit::mSHBrowseForFolder = (NS_SHBrowseForFolder)GetProcAddress(nsToolkit::mShell32Module, "SHBrowseForFolderW"); 
-        if (!nsToolkit::mSHBrowseForFolder)
-          nsToolkit::mSHBrowseForFolder = &nsSHBrowseForFolder;
-      }
-#endif // #ifndef WINCE
-    }
     nsToolkit::mDllInstance = hModule;
 
     //
@@ -643,18 +267,15 @@ nsToolkit::Startup(HMODULE hModule)
     wc.hbrBackground    = NULL;
     wc.lpszMenuName     = NULL;
     wc.lpszClassName    = L"nsToolkitClass";
-    VERIFY(nsToolkit::mRegisterClass(&wc));
+    VERIFY(::RegisterClassW(&wc));
 }
 
 
 void
 nsToolkit::Shutdown()
 {
-    if (nsToolkit::mShell32Module)
-      ::FreeLibrary(nsToolkit::mShell32Module);
-
     //VERIFY(::UnregisterClass("nsToolkitClass", nsToolkit::mDllInstance));
-    nsToolkit::mUnregisterClass(L"nsToolkitClass", nsToolkit::mDllInstance);
+    ::UnregisterClassW(L"nsToolkitClass", nsToolkit::mDllInstance);
 }
 
 nsIEventQueue* 
@@ -748,9 +369,6 @@ NS_METHOD nsToolkit::Init(PRThread *aThread)
     // Store the thread ID of the thread containing the message pump.  
     // If no thread is provided create one
     if (NULL != aThread) {
-        // Start Active Input Method Manager on this thread
-        if(nsToolkit::gAIMMApp)
-            nsToolkit::gAIMMApp->Activate(TRUE);
         CreateInternalWindow(aThread);
     } else {
         // create a thread where the message pump will run
@@ -805,12 +423,7 @@ LRESULT CALLBACK nsToolkit::WindowProc(HWND hWnd, UINT msg, WPARAM wParam,
 
     }
 
-    if(nsToolkit::gAIMMApp) {
-        LRESULT lResult;
-        if (nsToolkit::gAIMMApp->OnDefWindowProc(hWnd, msg, wParam, lParam, &lResult) == S_OK)
-            return lResult;
-    }
-    return nsToolkit::mDefWindowProc(hWnd, msg, wParam, lParam);
+    return ::DefWindowProcW(hWnd, msg, wParam, lParam);
 }
 
 
@@ -873,9 +486,7 @@ PRBool nsToolkit::InitVersionInfo()
   {
     isInitialized = PR_TRUE;
 
-#ifdef WINCE
-    nsToolkit::mUseImeApiW  = PR_TRUE;
-#else
+#ifndef WINCE
     OSVERSIONINFOEX osversion;
     BOOL osVersionInfoEx;
     
@@ -883,30 +494,12 @@ PRBool nsToolkit::InitVersionInfo()
     osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
 
     if (!(osVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osversion))) {
-      // if OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
-      osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-      if (!GetVersionEx((OSVERSIONINFO *)&osversion)) {
-        // maybe we are running on very old Windows OS. Assign FALSE.
-        nsToolkit::mUseImeApiW = PR_FALSE; 
-        return PR_TRUE;
-      }
+      // Win2k or later should support OSVERSIONINFOEX.
+      return PR_FALSE;
     }
 
-    nsToolkit::mIsNT = (osversion.dwPlatformId == VER_PLATFORM_WIN32_NT);
-
-    if (nsToolkit::mIsNT)
-    {
-      // Set flag of nsToolkit::mUseImeApiW due to using Unicode API.
-      nsToolkit::mUseImeApiW = PR_TRUE;
-      // XXX Hack for stopping the crash (125573)
-      if (osversion.dwMajorVersion == 5 && (osversion.dwMinorVersion == 0 || osversion.dwMinorVersion == 1))  { 
-        nsToolkit::mIsWinXP = (osversion.dwMinorVersion == 1);
-        // "Microsoft Windows 2000 " or "Microsoft Windows XP "
-        if (936 == ::GetACP())  {  // Chinese (PRC, Singapore)
-          nsToolkit::mUseImeApiW = PR_FALSE;
-          nsToolkit::mW2KXP_CP936 = PR_TRUE;
-        }
-      }
+    if (osversion.dwMajorVersion == 5)  { 
+      nsToolkit::mIsWinXP = (osversion.dwMinorVersion == 1);
     }
 #endif
   }
@@ -1037,285 +630,3 @@ void MouseTrailer::TimerProc(nsITimer* aTimer, void* aClosure)
   }
 }
 
-//-------------------------------------------------------------------------
-//
-//  nsIMM class(Native IMM wrapper)
-//
-//-------------------------------------------------------------------------
-nsIMM&
-nsIMM::LoadModule()
-{
-  static nsIMM gIMM;
-  return gIMM;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-nsIMM::nsIMM(const char* aModuleName /* = "IMM32.DLL" */)
-{
-#ifndef WINCE
-  mInstance=::LoadLibrary(aModuleName);
-
-  if (mInstance) {
-    mGetCompositionStringA =
-      (GetCompStrPtr)GetProcAddress(mInstance, "ImmGetCompositionStringA");
-    NS_ASSERTION(mGetCompositionStringA != NULL,
-                 "nsIMM.ImmGetCompositionStringA failed.");
-
-    mGetCompositionStringW =
-      (GetCompStrPtr)GetProcAddress(mInstance, "ImmGetCompositionStringW");
-    NS_ASSERTION(mGetCompositionStringW != NULL,
-                 "nsIMM.ImmGetCompositionStringW failed.");
-
-    mGetContext =
-      (GetContextPtr)GetProcAddress(mInstance, "ImmGetContext");
-    NS_ASSERTION(mGetContext != NULL,
-                 "nsIMM.ImmGetContext failed.");
-
-    mReleaseContext =
-      (RelContextPtr)GetProcAddress(mInstance, "ImmReleaseContext");
-    NS_ASSERTION(mReleaseContext != NULL,
-                 "nsIMM.ImmReleaseContext failed.");
-
-    mNotifyIME =
-      (NotifyIMEPtr)GetProcAddress(mInstance, "ImmNotifyIME");
-    NS_ASSERTION(mNotifyIME != NULL,
-                 "nsIMM.ImmNotifyIME failed.");
-
-    mSetCandiateWindow =
-      (SetCandWindowPtr)GetProcAddress(mInstance, "ImmSetCandidateWindow");
-    NS_ASSERTION(mSetCandiateWindow != NULL,
-                 "nsIMM.ImmSetCandidateWindow failed.");
-
-    mGetCompositionWindow =
-      (GetCompWindowPtr)GetProcAddress(mInstance, "ImmGetCompositionWindow");
-    NS_ASSERTION(mGetCompositionWindow != NULL,
-                 "nsIMM.ImmGetCompositionWindow failed.");
-
-    mSetCompositionWindow =
-      (SetCompWindowPtr)GetProcAddress(mInstance, "ImmSetCompositionWindow");
-    NS_ASSERTION(mSetCompositionWindow != NULL,
-                 "nsIMM.ImmSetCompositionWindow failed.");
-
-    mGetProperty =
-      (GetPropertyPtr)GetProcAddress(mInstance, "ImmGetProperty");
-    NS_ASSERTION(mGetProperty != NULL,
-                 "nsIMM.ImmGetProperty failed.");
-
-    mGetDefaultIMEWnd =
-      (GetDefaultIMEWndPtr)GetProcAddress(mInstance, "ImmGetDefaultIMEWnd");
-    NS_ASSERTION(mGetDefaultIMEWnd != NULL,
-                 "nsIMM.ImmGetDefaultIMEWnd failed.");
-
-    mGetOpenStatus =
-      (GetOpenStatusPtr)GetProcAddress(mInstance,"ImmGetOpenStatus");
-    NS_ASSERTION(mGetOpenStatus != NULL,
-                 "nsIMM.ImmGetOpenStatus failed.");
-
-    mSetOpenStatus =
-      (SetOpenStatusPtr)GetProcAddress(mInstance,"ImmSetOpenStatus");
-    NS_ASSERTION(mSetOpenStatus != NULL,
-                 "nsIMM.ImmSetOpenStatus failed.");
-
-    mAssociateContext =
-      (AssociateContextPtr)GetProcAddress(mInstance,"ImmAssociateContext");
-    NS_ASSERTION(mAssociateContext != NULL,
-                 "nsIMM.ImmAssociateContext failed.");
-  } else {
-    mGetCompositionStringA=NULL;
-    mGetCompositionStringW=NULL;
-    mGetContext=NULL;
-    mReleaseContext=NULL;
-    mNotifyIME=NULL;
-    mSetCandiateWindow=NULL;
-    mGetCompositionWindow=NULL;
-    mSetCompositionWindow=NULL;
-    mGetProperty=NULL;
-    mGetDefaultIMEWnd=NULL;
-    mGetOpenStatus=NULL;
-    mSetOpenStatus=NULL;
-    mAssociateContext=NULL;
-  }
-
-#else // WinCE
-  mInstance=NULL;
-
-  mGetCompositionStringA=(GetCompStrPtr)ImmGetCompositionStringW;
-  mGetCompositionStringW=(GetCompStrPtr)ImmGetCompositionStringW;
-  mGetContext=(GetContextPtr)ImmGetContext;
-  mReleaseContext=(RelContextPtr)ImmReleaseContext;
-  mNotifyIME=(NotifyIMEPtr)ImmNotifyIME;
-  mSetCandiateWindow=(SetCandWindowPtr)ImmSetCandidateWindow;
-  mGetCompositionWindow=(GetCompWindowPtr)ImmGetCompositionWindow;
-  mSetCompositionWindow=(SetCompWindowPtr)ImmSetCompositionWindow;
-  mGetProperty=(GetPropertyPtr)ImmGetProperty;
-  mGetDefaultIMEWnd=(GetDefaultIMEWndPtr)ImmGetDefaultIMEWnd;
-  mGetOpenStatus=(GetOpenStatusPtr)ImmGetOpenStatus;
-  mSetOpenStatus=(SetOpenStatusPtr)ImmSetOpenStatus;
-  mAssociateContext=(AssociateContextPtr)ImmAssociateContext;
-#endif
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-nsIMM::~nsIMM()
-{
-  if(mInstance)
-    ::FreeLibrary(mInstance);
-
-  mGetCompositionStringA=NULL;
-  mGetCompositionStringW=NULL;
-  mGetContext=NULL;
-  mReleaseContext=NULL;
-  mNotifyIME=NULL;
-  mSetCandiateWindow=NULL;
-  mGetCompositionWindow=NULL;
-  mSetCompositionWindow=NULL;
-  mGetProperty=NULL;
-  mGetDefaultIMEWnd=NULL;
-  mGetOpenStatus=NULL;
-  mSetOpenStatus=NULL;
-  mAssociateContext=NULL;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::GetCompositionStringA(HIMC aIMC, DWORD aIndex,
-                             LPVOID aBuf, DWORD aBufLen)
-{
-  return (mGetCompositionStringA) ?
-    mGetCompositionStringA(aIMC, aIndex, aBuf, aBufLen) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::GetCompositionStringW(HIMC aIMC, DWORD aIndex,
-                             LPVOID aBuf, DWORD aBufLen)
-{
-  return (mGetCompositionStringW) ?
-    mGetCompositionStringW(aIMC, aIndex, aBuf, aBufLen) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::GetContext(HWND aWnd)
-{
-  return (mGetContext) ? mGetContext(aWnd) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::ReleaseContext(HWND aWnd, HIMC aIMC)
-{
-  return (mReleaseContext) ? mReleaseContext(aWnd, aIMC) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::NotifyIME(HIMC aIMC, DWORD aAction, DWORD aIndex, DWORD aValue)
-{
-  return (mNotifyIME) ? mNotifyIME(aIMC, aAction, aIndex, aValue) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::SetCandidateWindow(HIMC aIMC, LPCANDIDATEFORM aCandidateForm)
-{
-  return (mSetCandiateWindow) ?
-    mSetCandiateWindow(aIMC, aCandidateForm) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::SetCompositionWindow(HIMC aIMC, LPCOMPOSITIONFORM aCompositionForm)
-{
-  return (mSetCompositionWindow) ?
-    mSetCompositionWindow(aIMC, aCompositionForm) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::GetCompositionWindow(HIMC aIMC, LPCOMPOSITIONFORM aCompositionForm)
-{
-  return (mGetCompositionWindow) ?
-    mGetCompositionWindow(aIMC, aCompositionForm) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::GetProperty(HKL aKL, DWORD aIndex)
-{
-  return (mGetProperty) ? mGetProperty(aKL, aIndex) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-LONG
-nsIMM::GetDefaultIMEWnd(HWND aWnd)
-{
-  return (mGetDefaultIMEWnd) ? mGetDefaultIMEWnd(aWnd) : 0L;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-BOOL
-nsIMM::GetOpenStatus(HIMC aIMC)
-{
-  return (mGetOpenStatus) ? mGetOpenStatus(aIMC) : FALSE;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-BOOL
-nsIMM::SetOpenStatus(HIMC aIMC, BOOL aStatus)
-{
-  return (mSetOpenStatus) ? mSetOpenStatus(aIMC, aStatus) : FALSE;
-}
-
-//-------------------------------------------------------------------------
-//
-//
-//-------------------------------------------------------------------------
-HIMC
-nsIMM::AssociateContext(HWND aWnd, HIMC aIMC)
-{
-  return (mAssociateContext) ? mAssociateContext(aWnd, aIMC) : NULL;
-}
-
diff --git a/widget/src/windows/nsToolkit.h b/widget/src/windows/nsToolkit.h
index 9ad47a8af3fedb4827eb9d43a63b388202e8dd70..2b2998fd509b44e8ba66fa3833d240b99be5c18d 100644
--- a/widget/src/windows/nsToolkit.h
+++ b/widget/src/windows/nsToolkit.h
@@ -46,8 +46,6 @@
 #include "nsITimer.h"
 #include "nsCOMPtr.h"
 
-#include "aimm.h"
-
 struct MethodInfo;
 class nsIEventQueue;
 class MouseTrailer;
@@ -106,40 +104,12 @@ protected:
 public:
     static HINSTANCE mDllInstance;
     // OS flag
-    static PRBool    mIsNT;
     static PRBool    mIsWinXP;
-    static PRBool    mUseImeApiW;
-    static PRBool    mW2KXP_CP936;
 
     static PRBool InitVersionInfo();
     static void Startup(HINSTANCE hModule);
     static void Shutdown();
 
-    // Active Input Method support
-    static IActiveIMMApp *gAIMMApp;
-    static PRInt32       gAIMMCount;
-
-    // Ansi API support
-    static HMODULE              mShell32Module;
-    static NS_DefWindowProc     mDefWindowProc;
-    static NS_CallWindowProc    mCallWindowProc;
-    static NS_SetWindowLong     mSetWindowLong;
-    static NS_GetWindowLong     mGetWindowLong;
-    static NS_SendMessage       mSendMessage;
-    static NS_DispatchMessage   mDispatchMessage;
-    static NS_GetMessage        mGetMessage;
-    static NS_PeekMessage       mPeekMessage;
-    static NS_GetOpenFileName   mGetOpenFileName;
-    static NS_GetSaveFileName   mGetSaveFileName;
-    static NS_GetClassName      mGetClassName;
-    static NS_CreateWindowEx    mCreateWindowEx;
-    static NS_RegisterClass     mRegisterClass;
-    static NS_UnregisterClass   mUnregisterClass;
-    static NS_SHGetPathFromIDList mSHGetPathFromIDList;
-#ifndef WINCE
-    static NS_SHBrowseForFolder   mSHBrowseForFolder;
-#endif
-
     static MouseTrailer *gMouseTrailer;
 };
 
@@ -188,234 +158,6 @@ private:
     nsCOMPtr<nsITimer>    mTimer;
 };
 
-//-------------------------------------------------------------------------
-//
-// Native IMM wrapper
-//
-//-------------------------------------------------------------------------
-class nsIMM
-{
-  //prototypes for DLL function calls...
-  typedef LONG (CALLBACK *GetCompStrPtr)       (HIMC, DWORD, LPVOID, DWORD);
-  typedef LONG (CALLBACK *GetContextPtr)       (HWND);
-  typedef LONG (CALLBACK *RelContextPtr)       (HWND, HIMC);
-  typedef LONG (CALLBACK *NotifyIMEPtr)        (HIMC, DWORD, DWORD, DWORD);
-  typedef LONG (CALLBACK *SetCandWindowPtr)    (HIMC, LPCANDIDATEFORM);
-  typedef LONG (CALLBACK *SetCompWindowPtr)    (HIMC, LPCOMPOSITIONFORM);
-  typedef LONG (CALLBACK *GetCompWindowPtr)    (HIMC, LPCOMPOSITIONFORM);
-  typedef LONG (CALLBACK *GetPropertyPtr)      (HKL, DWORD);
-  typedef LONG (CALLBACK *GetDefaultIMEWndPtr) (HWND);
-  typedef BOOL (CALLBACK *GetOpenStatusPtr)    (HIMC);
-  typedef BOOL (CALLBACK *SetOpenStatusPtr)    (HIMC, BOOL);
-  typedef HIMC (CALLBACK *AssociateContextPtr) (HWND, HIMC);
-public:
-
-  static nsIMM& LoadModule();
-
-  nsIMM(const char* aModuleName="IMM32.DLL");
-  ~nsIMM();
-
-  LONG GetCompositionStringA(HIMC aIMC, DWORD aIndex,
-                             LPVOID aBuf, DWORD aBufLen);
-  LONG GetCompositionStringW(HIMC aIMC, DWORD aIndex,
-                             LPVOID aBuf, DWORD aBufLen);
-  LONG GetContext(HWND aWnd);
-  LONG ReleaseContext(HWND aWnd, HIMC aIMC);
-  LONG NotifyIME(HIMC aIMC, DWORD aAction, DWORD aIndex, DWORD aValue);
-  LONG SetCandidateWindow(HIMC aIMC, LPCANDIDATEFORM aCandidateForm);
-  LONG SetCompositionWindow(HIMC aIMC, LPCOMPOSITIONFORM aCompositionForm);
-  LONG GetCompositionWindow(HIMC aIMC,LPCOMPOSITIONFORM aCompositionForm);
-  LONG GetProperty(HKL aKL, DWORD aIndex);
-  LONG GetDefaultIMEWnd(HWND aWnd);
-  BOOL GetOpenStatus(HIMC aIMC);
-  BOOL SetOpenStatus(HIMC aIMC, BOOL aStatus);
-  HIMC AssociateContext(HWND aWnd, HIMC aIMC);
-private:
-
-  HINSTANCE           mInstance;
-  GetCompStrPtr       mGetCompositionStringA;
-  GetCompStrPtr       mGetCompositionStringW;
-  GetContextPtr       mGetContext;
-  RelContextPtr       mReleaseContext;
-  NotifyIMEPtr        mNotifyIME;
-  SetCandWindowPtr    mSetCandiateWindow;
-  SetCompWindowPtr    mSetCompositionWindow;
-  GetCompWindowPtr    mGetCompositionWindow;
-  GetPropertyPtr      mGetProperty;
-  GetDefaultIMEWndPtr mGetDefaultIMEWnd;
-  GetOpenStatusPtr    mGetOpenStatus;
-  SetOpenStatusPtr    mSetOpenStatus;
-  AssociateContextPtr mAssociateContext;
-};
-
-//-------------------------------------------------------------------------
-//
-// Macro for Active Input Method Manager (AIMM) support.
-// Use AIMM method instead of Win32 Imm APIs.
-//
-//-------------------------------------------------------------------------
-#define NS_IMM_GETCOMPOSITIONSTRINGA(hIMC, dwIndex, pBuf, \
-                                     dwBufLen, compStrLen) \
-{ \
-  compStrLen = 0; \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->GetCompositionStringA(hIMC, dwIndex, \
-                                               dwBufLen, &(compStrLen), \
-                                               pBuf); \
- else { \
-    nsIMM &theIMM = nsIMM::LoadModule(); \
-    compStrLen = \
-      theIMM.GetCompositionStringA(hIMC, dwIndex, pBuf, dwBufLen); \
- } \
-}
-
-#define NS_IMM_GETCOMPOSITIONSTRINGW(hIMC, dwIndex, pBuf, \
-                                     dwBufLen, compStrLen) \
-{ \
-  compStrLen = 0; \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->GetCompositionStringW(hIMC, dwIndex, \
-                                               dwBufLen, &(compStrLen), \
-                                               pBuf); \
-  else { \
-    nsIMM &theIMM = nsIMM::LoadModule(); \
-    compStrLen = \
-      theIMM.GetCompositionStringW(hIMC, dwIndex, pBuf, dwBufLen); \
-  } \
-}
-
-#define NS_IMM_GETCONTEXT(hWnd, hIMC) \
-{ \
-  hIMC = NULL; \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->GetContext(hWnd, &(hIMC)); \
-  else { \
-    nsIMM& theIMM = nsIMM::LoadModule(); \
-    hIMC = (HIMC)theIMM.GetContext(hWnd);  \
-  } \
-}
-
-#define NS_IMM_RELEASECONTEXT(hWnd, hIMC) \
-{ \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->ReleaseContext(hWnd, hIMC); \
-  else { \
-    nsIMM &theIMM = nsIMM::LoadModule(); \
-    theIMM.ReleaseContext(hWnd, hIMC); \
-  } \
-}
-
-#define NS_IMM_NOTIFYIME(hIMC, dwAction, dwIndex, dwValue, bRtn) \
-{ \
-  bRtn = TRUE; \
-  if (nsToolkit::gAIMMApp) { \
-    bRtn = (nsToolkit::gAIMMApp->NotifyIME(hIMC, dwAction, \
-                                           dwIndex, dwValue) == S_OK); \
-  }\
-  else { \
-    nsIMM &theIMM = nsIMM::LoadModule(); \
-    (theIMM.NotifyIME(hIMC, dwAction, dwIndex, dwValue)); \
-  } \
-}
-
-#define NS_IMM_SETCANDIDATEWINDOW(hIMC, candForm) \
-{ \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->SetCandidateWindow(hIMC, candForm); \
-  else { \
-    nsIMM &theIMM = nsIMM::LoadModule(); \
-    theIMM.SetCandidateWindow(hIMC, candForm); \
-  } \
-}
-
-#define NS_IMM_SETCOMPOSITIONWINDOW(hIMC, compForm) \
-{ \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->SetCompositionWindow(hIMC, compForm); \
-  else { \
-    nsIMM &theIMM = nsIMM::LoadModule(); \
-    theIMM.SetCompositionWindow(hIMC, compForm); \
-  } \
-}
-
-#define NS_IMM_GETCOMPOSITIONWINDOW(hIMC, compForm) \
-{ \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->GetCompositionWindow(hIMC, compForm); \
-  else { \
-    nsIMM &theIMM = nsIMM::LoadModule(); \
-    theIMM.GetCompositionWindow(hIMC, compForm); \
-  } \
-}
-
-#define NS_IMM_GETPROPERTY(hKL, dwIndex, dwProp) \
-{ \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->GetProperty(hKL, dwIndex, &(dwProp)); \
-  else { \
-    nsIMM& theIMM = nsIMM::LoadModule(); \
-    dwProp = (DWORD)theIMM.GetProperty(hKL, dwIndex);  \
-  } \
-}
-
-#define NS_IMM_GETDEFAULTIMEWND(hWnd, phDefWnd) \
-{ \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->GetDefaultIMEWnd(hWnd, phDefWnd); \
-  else { \
-    nsIMM& theIMM = nsIMM::LoadModule(); \
-    *(phDefWnd) = (HWND)theIMM.GetDefaultIMEWnd(hWnd);  \
-  } \
-}
-
-#define NS_IMM_GETOPENSTATUS(hIMC, bRtn) \
-{ \
-  if (nsToolkit::gAIMMApp) \
-    bRtn = nsToolkit::gAIMMApp->GetOpenStatus(hIMC); \
-  else { \
-    nsIMM& theIMM = nsIMM::LoadModule(); \
-    bRtn = theIMM.GetOpenStatus(hIMC);  \
-  } \
-}
-
-#define NS_IMM_SETOPENSTATUS(hIMC, bOpen) \
-{ \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->SetOpenStatus(hIMC, bOpen); \
-  else { \
-    nsIMM& theIMM = nsIMM::LoadModule(); \
-    theIMM.SetOpenStatus(hIMC, bOpen);  \
-  } \
-}
-
-#define NS_IMM_ASSOCIATECONTEXT(hWnd, hIMC, phOldIMC) \
-{ \
-  if (nsToolkit::gAIMMApp) \
-    nsToolkit::gAIMMApp->AssociateContext(hWnd, hIMC, phOldIMC); \
-  else { \
-    nsIMM& theIMM = nsIMM::LoadModule(); \
-    *(phOldIMC) = theIMM.AssociateContext(hWnd, hIMC);  \
-  } \
-}
-
-//-------------------------------------------------------------------------
-//
-// Macro for Input Method A/W conversion.
-//
-// On Windows 2000, ImmGetCompositionStringA() doesn't work well using IME of
-// different code page.  (See BUG # 29606)
-// And ImmGetCompositionStringW() doesn't work on Windows 9x.
-//
-//-------------------------------------------------------------------------
-
-#define NS_IMM_GETCOMPOSITIONSTRING(hIMC, dwIndex, cBuf, dwBufLen, lRtn) \
-{ \
-  if (nsToolkit::mUseImeApiW) { \
-    NS_IMM_GETCOMPOSITIONSTRINGW(hIMC, dwIndex, cBuf, dwBufLen, lRtn); \
-  } else { \
-    NS_IMM_GETCOMPOSITIONSTRINGA(hIMC, dwIndex, cBuf, dwBufLen, lRtn); \
-  } \
-}
 
 //-------------------------------------------------------------------------
 //
@@ -425,6 +167,11 @@ private:
 //-------------------------------------------------------------------------
 
 #ifndef WM_IME_REQUEST
+#define WM_IME_REQUEST                  0x0288
+#endif    // #ifndef WM_IME_REQUEST
+
+#ifndef IMR_RECONVERTSTRING
+#define IMR_RECONVERTSTRING             0x0004
 typedef struct tagRECONVERTSTRING {
   DWORD dwSize;
   DWORD dwVersion;
@@ -435,7 +182,10 @@ typedef struct tagRECONVERTSTRING {
   DWORD dwTargetStrLen;
   DWORD dwTargetStrOffset;
 } RECONVERTSTRING, FAR * LPRECONVERTSTRING;
+#endif    // #ifndef IMR_RECONVERTSTRING
 
+#ifndef IMR_QUERYCHARPOSITION
+#define IMR_QUERYCHARPOSITION           0x0006
 typedef struct tagIMECHARPOSITION {
   DWORD dwSize;
   DWORD dwCharPos;
@@ -443,19 +193,14 @@ typedef struct tagIMECHARPOSITION {
   UINT  cLineHeight;
   RECT  rcDocument;
 } IMECHARPOSITION, *PIMECHARPOSITION;
-
-#define IMR_RECONVERTSTRING             0x0004
-#define IMR_QUERYCHARPOSITION           0x0006
-#define WM_IME_REQUEST                  0x0288
-#endif    // #ifndef WM_IME_REQUEST
+#endif    // #ifndef IMR_QUERYCHARPOSITION
 
 //-------------------------------------------------------------------------
 //
-// from http://msdn.microsoft.com/library/specs/msime.h
+// from http://msdn.microsoft.com/library/en-us/dnime/html/msime.asp
 //
 //-------------------------------------------------------------------------
 
-#define RWM_RECONVERT       TEXT("MSIMEReconvert")
 #define RWM_MOUSE           TEXT("MSIMEMouseOperation")
 
 #define IMEMOUSE_NONE       0x00    // no mouse button was pushed
@@ -465,12 +210,4 @@ typedef struct tagIMECHARPOSITION {
 #define IMEMOUSE_WUP        0x10    // wheel up
 #define IMEMOUSE_WDOWN      0x20    // wheel down
 
-//-------------------------------------------------------------------------
-//
-// from http://www.justsystem.co.jp/tech/atok/api12_04.html#4_11
-//
-//-------------------------------------------------------------------------
-
-#define MSGNAME_ATOK_RECONVERT TEXT("Atok Message for ReconvertString")
-
 #endif  // TOOLKIT_H
diff --git a/widget/src/windows/nsWindow.cpp b/widget/src/windows/nsWindow.cpp
index f9f1ff019c206f349fef40c45da99fded7ed9144..3faef5ce246bf18d863ff43114eae2e752d830fc 100644
--- a/widget/src/windows/nsWindow.cpp
+++ b/widget/src/windows/nsWindow.cpp
@@ -183,26 +183,14 @@ static const char kMozHeapDumpMessageString[] = "MOZ_HeapDump";
 
 #ifndef ULW_ALPHA
 #define ULW_ALPHA               0x00000002
-#endif
-
-
-typedef BOOL WINAPI UpdateLayeredWindowProc (HWND hWnd, HDC hdcDst, POINT *pptDst,
-                                             SIZE *psize, HDC hdcSrc, POINT *pptSrc,
-                                             COLORREF crKey, BLENDFUNCTION *pblend,
-                                             DWORD dwFlags);
-
-
-static UpdateLayeredWindowProc* GetUpdateLayeredWindowProc()
-{
-  HMODULE user32 = ::GetModuleHandle("user32.dll");
 
-  return NS_REINTERPRET_CAST(UpdateLayeredWindowProc*,
-    (user32) ? ::GetProcAddress(user32, "UpdateLayeredWindow") : nsnull);
-}
-
-static UpdateLayeredWindowProc* pUpdateLayeredWindow = GetUpdateLayeredWindowProc();
-
-static inline PRBool IsAlphaTranslucencySupported() { return pUpdateLayeredWindow != nsnull; }
+extern "C"
+WINUSERAPI
+BOOL WINAPI UpdateLayeredWindow(HWND hWnd, HDC hdcDst, POINT *pptDst,
+                                SIZE *psize, HDC hdcSrc, POINT *pptSrc,
+                                COLORREF crKey, BLENDFUNCTION *pblend,
+                                DWORD dwFlags);
+#endif
 
 #endif
 
@@ -438,10 +426,7 @@ PRInt32    nsWindow::sIMECaretHeight           = 0;
 
 BOOL nsWindow::sIsRegistered       = FALSE;
 BOOL nsWindow::sIsPopupClassRegistered = FALSE;
-UINT nsWindow::uMSH_MOUSEWHEEL     = 0;
-UINT nsWindow::uWM_MSIME_RECONVERT = 0; // reconvert message for MSIME
 UINT nsWindow::uWM_MSIME_MOUSE     = 0; // mouse message for MSIME
-UINT nsWindow::uWM_ATOK_RECONVERT  = 0; // reconvert message for ATOK
 UINT nsWindow::uWM_HEAP_DUMP       = 0; // Heap Dump to a file
 
 HCURSOR        nsWindow::gHCursor            = NULL;
@@ -565,29 +550,6 @@ static PRBool is_vk_down(int vk)
 
 #endif  // #ifndef WM_APPCOMMAND
 
-static PRBool LangIDToCP(WORD aLangID, UINT& oCP)
-{
-  int localeid=MAKELCID(aLangID,SORT_DEFAULT);
-  int numchar=GetLocaleInfo(localeid,LOCALE_IDEFAULTANSICODEPAGE,NULL,0);
-  char cp_on_stack[32];
-  char* cp_name;
-
-  if (numchar > 32)
-    cp_name  = new char[numchar];
-  else
-    cp_name = cp_on_stack;
-  if (cp_name) {
-    GetLocaleInfo(localeid,LOCALE_IDEFAULTANSICODEPAGE,cp_name,numchar);
-    oCP = atoi(cp_name);
-    if (cp_name != cp_on_stack)
-      delete [] cp_name;
-    return PR_TRUE;
-  } else {
-    oCP = CP_ACP;
-    return PR_FALSE;
-  }
-}
-
 /* This object maintains a correlation between attention timers and the
    windows to which they belong. It's lighter than a hashtable (expected usage
    is really just one at a time) and allows nsWindow::GetNSWindowPtr
@@ -713,7 +675,7 @@ HWND nsWindow::GetTopLevelHWND(HWND aWnd, PRBool aStopOnFirstTopLevel)
 #ifndef WINCE
     if (aStopOnFirstTopLevel)
     {
-      DWORD style = nsToolkit::mGetWindowLong(curWnd, GWL_STYLE);
+      DWORD style = ::GetWindowLongW(curWnd, GWL_STYLE);
 
       if (!(style & WS_CHILDWINDOW))    // first top-level window
         break;
@@ -739,10 +701,10 @@ HWND nsWindow::GetTopLevelHWND(HWND aWnd, PRBool aStopOnFirstTopLevel)
 
 BOOL CALLBACK nsWindow::BroadcastMsgToChildren(HWND aWnd, LPARAM aMsg)
 {
-  WNDPROC winProc = (WNDPROC)nsToolkit::mGetWindowLong(aWnd, GWL_WNDPROC);
+  WNDPROC winProc = (WNDPROC)::GetWindowLongW(aWnd, GWL_WNDPROC);
   if (winProc == &nsWindow::WindowProc) {
     // it's one of our windows so go ahead and send a message to it
-    nsToolkit::mCallWindowProc(winProc, aWnd, aMsg, 0, 0);
+    ::CallWindowProcW(winProc, aWnd, aMsg, 0, 0);
   }
   return TRUE;
 }
@@ -831,10 +793,9 @@ nsWindow::nsWindow() : nsBaseWidget()
 #ifdef MOZ_XUL
   mIsTranslucent      = PR_FALSE;
   mIsTopTranslucent   = PR_FALSE;
-  w2k.mMemoryDC       = NULL;
-  w2k.mMemoryBitmap   = NULL;
-  w2k.mMemoryBits     = NULL;
-  w9x.mPerformingSetWindowRgn = PR_FALSE;
+  mMemoryDC           = NULL;
+  mMemoryBitmap       = NULL;
+  mMemoryBits         = NULL;
   mAlphaMask          = nsnull;
 #endif
   mWindowType         = eWindowType_child;
@@ -856,23 +817,6 @@ nsWindow::nsWindow() : nsBaseWidget()
   if (! gbInitGlobalValue) {
     gbInitGlobalValue = TRUE;
     gKeyboardLayout = GetKeyboardLayout(0);
-    LangIDToCP((WORD)(0x0FFFFL & (DWORD)gKeyboardLayout), gCurrentKeyboardCP);
-
-    if (nsToolkit::mW2KXP_CP936) {
-      DWORD imeProp = 0;
-      NS_IMM_GETPROPERTY(gKeyboardLayout, IGP_PROPERTY, imeProp);
-      nsToolkit::mUseImeApiW = (imeProp & IME_PROP_UNICODE) ? PR_TRUE : PR_FALSE;
-    }
-
-    //
-    // Reconvert message for Windows 95 / NT 4.0
-    //
-
-    // MS-IME98/2000
-    nsWindow::uWM_MSIME_RECONVERT = ::RegisterWindowMessage(RWM_RECONVERT);
-
-    // ATOK12/13
-    nsWindow::uWM_ATOK_RECONVERT  = ::RegisterWindowMessage(MSGNAME_ATOK_RECONVERT);
 
     // mouse message of MSIME98/2000
     nsWindow::uWM_MSIME_MOUSE     = ::RegisterWindowMessage(RWM_MOUSE);
@@ -889,11 +833,6 @@ nsWindow::nsWindow() : nsBaseWidget()
 
   sInstanceCount++;
 
-#if !defined (__MINGW32__) && !defined(WINCE) 
-  if (!nsWindow::uMSH_MOUSEWHEEL)
-    nsWindow::uMSH_MOUSEWHEEL = RegisterWindowMessage(MSH_MOUSEWHEEL);
-#endif
-  
 #ifdef WINCE
   nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
   if (prefs) {
@@ -912,7 +851,6 @@ nsWindow::nsWindow() : nsBaseWidget()
 
 
 HKL nsWindow::gKeyboardLayout = 0;
-UINT nsWindow::gCurrentKeyboardCP = 0;
 PRBool nsWindow::gSwitchKeyboardLayout = PR_FALSE;
 static KeyboardLayout gKbdLayout;
 
@@ -1327,7 +1265,7 @@ LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
   // why we are hitting this assert
   if (nsnull == someWindow) {
     NS_ASSERTION(someWindow, "someWindow is null, cannot call any CallWindowProc");
-    return nsToolkit::mDefWindowProc(hWnd, msg, wParam, lParam);
+    return ::DefWindowProcW(hWnd, msg, wParam, lParam);
   }
 
   // hold on to the window for the life of this method, in case it gets
@@ -1354,10 +1292,10 @@ LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
   }
 
 #if defined(STRICT)
-  return nsToolkit::mCallWindowProc((WNDPROC)someWindow->GetPrevWindowProc(), hWnd,
+  return ::CallWindowProcW((WNDPROC)someWindow->GetPrevWindowProc(), hWnd,
                                     msg, wParam, lParam);
 #else
-  return nsToolkit::mCallWindowProc((FARPROC)someWindow->GetPrevWindowProc(), hWnd,
+  return ::CallWindowProcW((FARPROC)someWindow->GetPrevWindowProc(), hWnd,
                                     msg, wParam, lParam);
 #endif
 }
@@ -1367,13 +1305,8 @@ LRESULT CALLBACK nsWindow::WindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM
 //
 LRESULT CALLBACK nsWindow::DefaultWindowProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
-  if (nsToolkit::gAIMMApp)
-  {
-    LRESULT lResult;
-    if (nsToolkit::gAIMMApp->OnDefWindowProc(hWnd, msg, wParam, lParam, &lResult) == S_OK)
-      return lResult;
-  }
-  return nsToolkit::mDefWindowProc(hWnd, msg, wParam, lParam);
+  //XXX nsWindow::DefaultWindowProc still ever required?
+  return ::DefWindowProcW(hWnd, msg, wParam, lParam);
 }
 
 static BOOL CALLBACK DummyDialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
@@ -1501,19 +1434,19 @@ nsWindow::StandardWindowCreate(nsIWidget *aParent,
 
   } else {
 
-    mWnd = nsToolkit::mCreateWindowEx(extendedStyle,
-                                      aInitData && aInitData->mDropShadow ?
-                                      WindowPopupClassW() : WindowClassW(),
-                                      L"",
-                                      style,
-                                      aRect.x,
-                                      aRect.y,
-                                      aRect.width,
-                                      GetHeight(aRect.height),
-                                      parent,
-                                      NULL,
-                                      nsToolkit::mDllInstance,
-                                      NULL);
+    mWnd = ::CreateWindowExW(extendedStyle,
+                             aInitData && aInitData->mDropShadow ?
+                             WindowPopupClassW() : WindowClassW(),
+                             L"",
+                             style,
+                             aRect.x,
+                             aRect.y,
+                             aRect.width,
+                             GetHeight(aRect.height),
+                             parent,
+                             NULL,
+                             nsToolkit::mDllInstance,
+                             NULL);
   }
 
   if (!mWnd)
@@ -1656,16 +1589,16 @@ NS_METHOD nsWindow::Destroy()
 
     // if IME is disabled, restore it.
     if (mOldIMC) {
-      NS_IMM_ASSOCIATECONTEXT(mWnd, mOldIMC, &mOldIMC);
+      mOldIMC = ::ImmAssociateContext(mWnd, mOldIMC);
       NS_ASSERTION(!mOldIMC, "Another IMC was associated");
     }
 
     HICON icon;
-    icon = (HICON) nsToolkit::mSendMessage(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM) 0);
+    icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM) 0);
     if (icon)
       ::DestroyIcon(icon);
 
-    icon = (HICON) nsToolkit::mSendMessage(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) 0);
+    icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM) 0);
     if (icon)
       ::DestroyIcon(icon);
 
@@ -1908,7 +1841,7 @@ NS_METHOD nsWindow::ModalEventFilter(PRBool aRealEvent, void *aEvent,
 
       // if not, accept events for any window that hasn't been disabled.
       if (!acceptEvent) {
-        LONG proc = nsToolkit::mGetWindowLong(msgWindow, GWL_WNDPROC);
+        LONG proc = ::GetWindowLongW(msgWindow, GWL_WNDPROC);
         if (proc == (LONG)&nsWindow::WindowProc) {
           nsWindow *msgWin = GetNSWindowPtr(msgWindow);
           msgWin->IsEnabled(&acceptEvent);
@@ -2383,7 +2316,7 @@ NS_METHOD nsWindow::SetFont(const nsFont &aFont)
   HFONT hfont = (HFONT)fontHandle;
 
   // Draw in the new font
-  nsToolkit::mSendMessage(mWnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)0);
+  ::SendMessageW(mWnd, WM_SETFONT, (WPARAM)hfont, (LPARAM)0);
   NS_RELEASE(metrics);
 
   return NS_OK;
@@ -2417,9 +2350,6 @@ NS_METHOD nsWindow::SetCursor(nsCursor aCursor)
     case eCursor_hyperlink:
     {
       newCursor = ::LoadCursor(NULL, IDC_HAND);
-      if (!newCursor) {
-        newCursor = ::LoadCursor(nsToolkit::mDllInstance, MAKEINTRESOURCE(IDC_SELECTANCHOR));
-      }
       break;
     }
 
@@ -2736,11 +2666,6 @@ HBITMAP nsWindow::CreateOpaqueAlphaChannel(PRUint32 aWidth, PRUint32 aHeight)
   return hAlpha;
 }
 
-/*
-  For Win9x/ME, API specs say the image size must be 
-  SM_CXCURSOR, SM_CYCURSOR (::GetSystemMetrics).  However, ::CreateIconIndirect
-  returns null when the size is not correct.
-*/
 NS_IMETHODIMP nsWindow::SetCursor(imgIContainer* aCursor,
                                   PRUint32 aHotspotX, PRUint32 aHotspotY)
 {
@@ -2895,8 +2820,8 @@ NS_IMETHODIMP nsWindow::HideWindowChrome(PRBool aShouldHide)
 
   DWORD style, exStyle;
   if (aShouldHide) {
-    DWORD tempStyle = nsToolkit::mGetWindowLong(hwnd, GWL_STYLE);
-    DWORD tempExStyle = nsToolkit::mGetWindowLong(hwnd, GWL_EXSTYLE);
+    DWORD tempStyle = ::GetWindowLongW(hwnd, GWL_STYLE);
+    DWORD tempExStyle = ::GetWindowLongW(hwnd, GWL_EXSTYLE);
 
     style = tempStyle & ~(WS_CAPTION | WS_THICKFRAME);
     exStyle = tempExStyle & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE |
@@ -2907,16 +2832,16 @@ NS_IMETHODIMP nsWindow::HideWindowChrome(PRBool aShouldHide)
   }
   else {
     if (!mOldStyle || !mOldExStyle) {
-      mOldStyle = nsToolkit::mGetWindowLong(hwnd, GWL_STYLE);
-      mOldExStyle = nsToolkit::mGetWindowLong(hwnd, GWL_EXSTYLE);
+      mOldStyle = ::GetWindowLongW(hwnd, GWL_STYLE);
+      mOldExStyle = ::GetWindowLongW(hwnd, GWL_EXSTYLE);
     }
 
     style = mOldStyle;
     exStyle = mOldExStyle;
   }
 
-  nsToolkit::mSetWindowLong(hwnd, GWL_STYLE, style);
-  nsToolkit::mSetWindowLong(hwnd, GWL_EXSTYLE, exStyle);
+  ::SetWindowLongW(hwnd, GWL_STYLE, style);
+  ::SetWindowLongW(hwnd, GWL_EXSTYLE, exStyle);
 
   return NS_OK;
 }
@@ -2953,8 +2878,8 @@ NS_METHOD nsWindow::Invalidate(PRBool aIsSynchronous)
 #endif // NS_DEBUG
 
 #ifdef MOZ_XUL
-    if (mIsTranslucent && IsAlphaTranslucencySupported() && !mPainting)
-      OnPaint(w2k.mMemoryDC);
+    if (mIsTranslucent && !mPainting)
+      OnPaint(mMemoryDC);
     else
 #endif
     {
@@ -2986,8 +2911,8 @@ NS_METHOD nsWindow::Invalidate(const nsRect & aRect, PRBool aIsSynchronous)
 #endif // NS_DEBUG
 
 #ifdef MOZ_XUL
-    if (mIsTranslucent && IsAlphaTranslucencySupported() && !mPainting)
-      OnPaint(w2k.mMemoryDC);
+    if (mIsTranslucent && !mPainting)
+      OnPaint(mMemoryDC);
     else
 #endif
     {
@@ -3013,8 +2938,8 @@ nsWindow::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous)
   nsresult rv = NS_OK;
   if (mWnd) {
 #ifdef MOZ_XUL
-    if (mIsTranslucent && IsAlphaTranslucencySupported() && !mPainting)
-      OnPaint(w2k.mMemoryDC);
+    if (mIsTranslucent && !mPainting)
+      OnPaint(mMemoryDC);
     else
 #endif
     {
@@ -3050,7 +2975,7 @@ NS_IMETHODIMP nsWindow::Update()
   if (mWnd)
   {
 #ifdef MOZ_XUL
-    if (mIsTranslucent && IsAlphaTranslucencySupported())
+    if (mIsTranslucent)
     {
 //      rv = UpdateTranslucentWindow();
     } else
@@ -3077,8 +3002,8 @@ void* nsWindow::GetNativeData(PRUint32 aDataType)
     case NS_NATIVE_GRAPHIC:
       // XXX:  This is sleezy!!  Remember to Release the DC after using it!
 #ifdef MOZ_XUL
-      return (void*)(mIsTranslucent && IsAlphaTranslucencySupported()) ?
-        w2k.mMemoryDC : ::GetDC(mWnd);
+      return (void*)(mIsTranslucent) ?
+        mMemoryDC : ::GetDC(mWnd);
 #else
       return (void*)::GetDC(mWnd);
 #endif
@@ -3097,7 +3022,7 @@ void nsWindow::FreeNativeData(void * data, PRUint32 aDataType)
   {
     case NS_NATIVE_GRAPHIC:
 #ifdef MOZ_XUL
-      if (!(mIsTranslucent && IsAlphaTranslucencySupported()))
+      if (!mIsTranslucent)
         ::ReleaseDC(mWnd, (HDC)data);
 #else
       ::ReleaseDC(mWnd, (HDC)data);
@@ -3403,7 +3328,7 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
   PRUint32 extraFlags = (noDefault ? NS_EVENT_FLAG_NO_DEFAULT : 0);
 
   MSG msg;
-  BOOL gotMsg = nsToolkit::mPeekMessage(&msg, mWnd, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE | PM_NOYIELD);
+  BOOL gotMsg = ::PeekMessageW(&msg, mWnd, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE | PM_NOYIELD);
   // Enter and backspace are always handled here to avoid for example the
   // confusion between ctrl-enter and ctrl-J.
   // Ctrl+[Add, Subtract, Equals] are always handled here to make text zoom shortcuts work
@@ -3424,17 +3349,17 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
     
     while (gotMsg && (msg.message == WM_CHAR || msg.message == WM_SYSCHAR))
     {
-      nsToolkit::mGetMessage(&msg, mWnd, WM_KEYFIRST, WM_KEYLAST);
+      ::GetMessageW(&msg, mWnd, WM_KEYFIRST, WM_KEYLAST);
       anyCharMessagesRemoved = PR_TRUE;
 
-      gotMsg = nsToolkit::mPeekMessage (&msg, mWnd, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE | PM_NOYIELD);
+      gotMsg = ::PeekMessageW (&msg, mWnd, WM_KEYFIRST, WM_KEYLAST, PM_NOREMOVE | PM_NOYIELD);
     }
 
     if (!anyCharMessagesRemoved && virtualKeyCode == NS_VK_BACK) {
       MSG imeStartCompositionMsg, imeCompositionMsg;
-      if (nsToolkit::mPeekMessage(&imeStartCompositionMsg, mWnd, WM_IME_STARTCOMPOSITION, WM_IME_STARTCOMPOSITION, PM_NOREMOVE | PM_NOYIELD)
-       && nsToolkit::mPeekMessage(&imeCompositionMsg, mWnd, WM_IME_COMPOSITION, WM_IME_COMPOSITION, PM_NOREMOVE | PM_NOYIELD)
-       && nsToolkit::mPeekMessage(&msg, mWnd, WM_CHAR, WM_CHAR, PM_NOREMOVE | PM_NOYIELD)
+      if (::PeekMessageW(&imeStartCompositionMsg, mWnd, WM_IME_STARTCOMPOSITION, WM_IME_STARTCOMPOSITION, PM_NOREMOVE | PM_NOYIELD)
+       && ::PeekMessageW(&imeCompositionMsg, mWnd, WM_IME_COMPOSITION, WM_IME_COMPOSITION, PM_NOREMOVE | PM_NOYIELD)
+       && ::PeekMessageW(&msg, mWnd, WM_CHAR, WM_CHAR, PM_NOREMOVE | PM_NOYIELD)
        && imeStartCompositionMsg.wParam == 0x0 && imeStartCompositionMsg.lParam == 0x0
        && imeCompositionMsg.wParam == 0x0 && imeCompositionMsg.lParam == 0x1BF
        && msg.wParam == NS_VK_BACK && msg.lParam == 0x1
@@ -3457,14 +3382,14 @@ BOOL nsWindow::OnKeyDown(UINT aVirtualKeyCode, UINT aScanCode, LPARAM aKeyData)
         // http://bugzilla.mozilla.gr.jp/show_bug.cgi?id=2885 (written in Japanese)
         // http://bugzilla.mozilla.org/show_bug.cgi?id=194559 (written in English)
 
-        nsToolkit::mGetMessage(&msg, mWnd, WM_CHAR, WM_CHAR);
+        ::GetMessageW(&msg, mWnd, WM_CHAR, WM_CHAR);
       }
     }
   }
   else if (gotMsg &&
            (msg.message == WM_CHAR || msg.message == WM_SYSCHAR || msg.message == WM_DEADCHAR)) {
     // If prevent default set for keydown, do same for keypress
-    nsToolkit::mGetMessage(&msg, mWnd, msg.message, msg.message);
+    ::GetMessageW(&msg, mWnd, msg.message, msg.message);
 
     if (msg.message == WM_DEADCHAR)
       return PR_FALSE;
@@ -3613,39 +3538,7 @@ BOOL nsWindow::OnChar(UINT charCode, PRUint32 aFlags)
     if (charCode < 0x20 || (charCode == 0x3D && mIsControlDown)) {
       uniChar = 0;
     } else {
-      if (nsToolkit::mIsNT) {
-        uniChar = charCode;
-      } else {
-        char    charToConvert[3];
-        size_t  length;
-
-        if (charCode <= 0xFF) { // not a multibyte character
-          if (mLeadByte) {      // mLeadByte is used for keeping the lead-byte of CJK char
-            charToConvert[0] = mLeadByte;
-            charToConvert[1] = LOBYTE(charCode);
-            mLeadByte = '\0';
-            length = 2;
-          } else {
-            charToConvert[0] = LOBYTE(charCode);
-            if (::IsDBCSLeadByteEx(gCurrentKeyboardCP, charToConvert[0])) {
-              mLeadByte = charToConvert[0];
-              mIsAltDown = saveIsAltDown;
-              mIsControlDown = saveIsControlDown;
-              return TRUE;
-            }
-            length = 1;
-          }
-        } else {
-          // SC double-byte punctuation mark in Windows-English is 0x0000aca3
-          uniChar = LOWORD(charCode);
-          charToConvert[0] = LOBYTE(uniChar);
-          charToConvert[1] = HIBYTE(uniChar);
-          mLeadByte = '\0';
-          length=2;
-        }
-        ::MultiByteToWideChar(gCurrentKeyboardCP, MB_PRECOMPOSED, charToConvert, length,
-                              &uniChar, 1);
-      }
+      uniChar = charCode;
       charCode = 0;
     }
   }
@@ -4116,7 +4009,7 @@ static nsresult HeapDump(const char *filename, const char *heading)
 
 BOOL CALLBACK nsWindow::DispatchStarvedPaints(HWND aWnd, LPARAM aMsg)
 {
-  LONG proc = nsToolkit::mGetWindowLong(aWnd, GWL_WNDPROC);
+  LONG proc = ::GetWindowLongW(aWnd, GWL_WNDPROC);
   if (proc == (LONG)&nsWindow::WindowProc) {
     // its one of our windows so check to see if it has a
     // invalidated rect. If it does. Dispatch a synchronous
@@ -4524,7 +4417,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
 
       // Note: the original code passed (HIWORD(lParam)) to OnKeyUp as
       // scan code. However, this breaks Alt+Num pad input.
-      // http://msdn.microsoft.com/library/psdk/winui/keybinpt_8qp5.htm
+      // http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/toascii.asp
       // states the following:
       //  Typically, ToAscii performs the translation based on the
       //  virtual-key code. In some cases, however, bit 15 of the
@@ -4566,7 +4459,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
 
       // Note: the original code passed (HIWORD(lParam)) to OnKeyDown as
       // scan code. However, this breaks Alt+Num pad input.
-      // http://msdn.microsoft.com/library/psdk/winui/keybinpt_8qp5.htm
+      // http://msdn.microsoft.com/library/en-us/winui/winui/windowsuserinterface/userinput/keyboardinput/keyboardinputreference/keyboardinputfunctions/toascii.asp
       // states the following:
       //  Typically, ToAscii performs the translation based on the
       //  virtual-key code. In some cases, however, bit 15 of the
@@ -4898,7 +4791,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
 
     case WM_KILLFOCUS:
       WCHAR className[kMaxClassNameLength];
-      nsToolkit::mGetClassName((HWND)wParam, className, kMaxClassNameLength);
+      ::GetClassNameW((HWND)wParam, className, kMaxClassNameLength);
       if (wcscmp(className, kWClassNameUI) &&
           wcscmp(className, kWClassNameContent) &&
           wcscmp(className, kWClassNameContentFrame) &&
@@ -4914,14 +4807,6 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
 
     case WM_WINDOWPOSCHANGED:
     {
-#ifdef MOZ_XUL
-      if (mIsTopTranslucent && !IsAlphaTranslucencySupported() && w9x.mPerformingSetWindowRgn)
-      {
-        result = PR_FALSE;    // Ignore events generated by SetWindowRgn
-        break;
-      }
-#endif
-
       WINDOWPOS *wp = (LPWINDOWPOS)lParam;
 
       // We only care about a resize, so filter out things like z-order
@@ -4945,8 +4830,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
         {
           ResizeTranslucentWindow(newWidth, newHeight);
         
-          if (IsAlphaTranslucencySupported())
-            needInvalidate = PR_FALSE;
+          needInvalidate = PR_FALSE;
         }
 #endif
 
@@ -5028,7 +4912,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
         if (pl.showCmd == SW_SHOWMINIMIZED) {
           // Deactivate
           WCHAR className[kMaxClassNameLength];
-          nsToolkit::mGetClassName((HWND)wParam, className, kMaxClassNameLength);
+          ::GetClassNameW((HWND)wParam, className, kMaxClassNameLength);
           if (wcscmp(className, kWClassNameUI) &&
               wcscmp(className, kWClassNameContent) &&
               wcscmp(className, kWClassNameContentFrame) &&
@@ -5133,7 +5017,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
 
     // This is a Window 98/2000 only message
     case WM_IME_REQUEST:
-        result = OnIMERequest(wParam, lParam, aRetValue, nsToolkit::mIsNT);
+      result = OnIMERequest(wParam, lParam, aRetValue);
 
       break;
 
@@ -5226,7 +5110,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
     {
       // Handle both flavors of mouse wheel events.
 #ifndef WINCE
-      if ((msg == WM_MOUSEWHEEL) || (msg == uMSH_MOUSEWHEEL)) {
+      if (msg == WM_MOUSEWHEEL) {
         static int iDeltaPerLine;
         static ULONG ulScrollLines;
 
@@ -5234,34 +5118,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
         if (getWheelInfo) {
           getWheelInfo = PR_FALSE;
 
-          // This needs to be done differently for Win95 than Win98/NT
-          // Taken from sample code in MS Intellimouse SDK
-          // http://www.microsoft.com/Mouse/intellimouse/sdk/sdkmessaging.htm
-
-          OSVERSIONINFO osversion;
-          memset(&osversion, 0, sizeof(OSVERSIONINFO));
-          osversion.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
-          GetVersionEx(&osversion);
-
-          if ((osversion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) &&
-              (osversion.dwMajorVersion == 4) &&
-              (osversion.dwMinorVersion == 0))
-          {
-#ifndef __MINGW32__
-            // This is the Windows 95 case
-            HWND hdlMsWheel = FindWindow(MSH_WHEELMODULE_CLASS, MSH_WHEELMODULE_TITLE);
-            if (hdlMsWheel) {
-              UINT uiMsh_MsgScrollLines = RegisterWindowMessage(MSH_SCROLL_LINES);
-              if (uiMsh_MsgScrollLines) {
-                ulScrollLines = (int) SendMessage(hdlMsWheel, uiMsh_MsgScrollLines, 0, 0);
-              }
-            }
-#endif // __MINGW32__
-          }
-          else if (osversion.dwMajorVersion >= 4) {
-            // This is the Win98/NT4/Win2K case
-            SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &ulScrollLines, 0);
-          }
+          SystemParametersInfo (SPI_GETWHEELSCROLLLINES, 0, &ulScrollLines, 0);
 
           // ulScrollLines usually equals 3 or 0 (for no scrolling)
           // WHEEL_DELTA equals 120, so iDeltaPerLine will be 40.
@@ -5312,7 +5169,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
           break;
         }
 
-        LONG proc = nsToolkit::mGetWindowLong(destWnd, GWL_WNDPROC);
+        LONG proc = ::GetWindowLongW(destWnd, GWL_WNDPROC);
         if (proc != (LONG)&nsWindow::WindowProc) {
           // Some other app, or a plugin window.
           // Windows directs WM_MOUSEWHEEL to the focused window.
@@ -5340,7 +5197,7 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
                 // it will wind it's way back to us, triggering the destWnd case above.
                 // either way, when the call returns, we are all done with the message,
                 mIsInMouseWheelProcessing = PR_TRUE;
-                if (0 == nsToolkit::mSendMessage(destWnd, msg, wParam, lParam)) {
+                if (0 == ::SendMessageW(destWnd, msg, wParam, lParam)) {
                   result = PR_TRUE; // consumed - don't call DefWndProc
                 }
                 destWnd = nsnull;
@@ -5368,15 +5225,9 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
         scrollEvent.scrollFlags = nsMouseScrollEvent::kIsVertical;
         if (ulScrollLines == WHEEL_PAGESCROLL) {
           scrollEvent.scrollFlags |= nsMouseScrollEvent::kIsFullPage;
-          if (msg == WM_MOUSEWHEEL)
-            scrollEvent.delta = (((short) HIWORD (wParam)) > 0) ? -1 : 1;
-          else
-            scrollEvent.delta = ((int) wParam > 0) ? -1 : 1;
+          scrollEvent.delta = (((short) HIWORD (wParam)) > 0) ? -1 : 1;
         } else {
-          if (msg == WM_MOUSEWHEEL)
-            scrollEvent.delta = -((short) HIWORD (wParam) / iDeltaPerLine);
-          else
-            scrollEvent.delta = -((int) wParam / iDeltaPerLine);
+          scrollEvent.delta = -((short) HIWORD (wParam) / iDeltaPerLine);
         }
 
         scrollEvent.isShift   = IS_VK_DOWN(NS_VK_SHIFT);
@@ -5388,18 +5239,8 @@ PRBool nsWindow::ProcessMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT
           result = DispatchWindowEvent(&scrollEvent);
         }
         NS_RELEASE(scrollEvent.widget);
-      } // WM_MOUSEWHEEL || uMSH_MOUSEWHEEL
-
-      //
-      // reconvert message for Windows 95 / NT 4.0
-      //
-      // See the following URL
-      //  http://msdn.microsoft.com/library/specs/msimeif_perimeinterfaces.htm#WM_MSIME_RECONVERT
-      //  http://www.justsystem.co.jp/tech/atok/api12_04.html#4_11
+      } // msg == WM_MOUSEWHEEL
 
-      else if ((msg == nsWindow::uWM_ATOK_RECONVERT) || (msg == nsWindow::uWM_MSIME_RECONVERT)) {
-        result = OnIMERequest(wParam, lParam, aRetValue, PR_TRUE);
-      }
       else if (msg == nsWindow::uWM_HEAP_DUMP) {
         // XXX for now we use c:\heapdump.txt until we figure out how to
         // XXX pass in message parameters.
@@ -5453,33 +5294,30 @@ LPCWSTR nsWindow::WindowClassW()
     wc.lpszMenuName  = NULL;
     wc.lpszClassName = kWClassNameHidden;
 
-    BOOL succeeded =  nsToolkit::mRegisterClass(&wc) != 0;
+    BOOL succeeded = ::RegisterClassW(&wc) != 0;
     nsWindow::sIsRegistered = succeeded;
 
     wc.lpszClassName = kWClassNameContentFrame;
-    if (!nsToolkit::mRegisterClass(&wc)) {
+    if (!::RegisterClassW(&wc)) {
       nsWindow::sIsRegistered = FALSE;
     }
 
     wc.lpszClassName = kWClassNameContent;
-    if (!nsToolkit::mRegisterClass(&wc)) {
+    if (!::RegisterClassW(&wc)) {
       nsWindow::sIsRegistered = FALSE;
     }
 
     wc.lpszClassName = kWClassNameUI;
-    if (!nsToolkit::mRegisterClass(&wc)) {
+    if (!::RegisterClassW(&wc)) {
       nsWindow::sIsRegistered = FALSE;
     }
 
     wc.lpszClassName = kWClassNameGeneral;
-    ATOM generalClassAtom = nsToolkit::mRegisterClass(&wc);
+    ATOM generalClassAtom = ::RegisterClassW(&wc);
     if (!generalClassAtom) {
       nsWindow::sIsRegistered = FALSE;
     }
 
-    // Call FilterClientWindows method since it enables ActiveIME on CJK Windows
-    if (nsToolkit::gAIMMApp && generalClassAtom)
-      nsToolkit::gAIMMApp->FilterClientWindows(&generalClassAtom, 1);
   }
 
   if (mWindowType == eWindowType_invisible) {
@@ -5519,12 +5357,12 @@ LPCWSTR nsWindow::WindowPopupClassW()
     wc.lpszMenuName  = NULL;
     wc.lpszClassName = className;
 
-    nsWindow::sIsPopupClassRegistered = nsToolkit::mRegisterClass(&wc);
+    nsWindow::sIsPopupClassRegistered = ::RegisterClassW(&wc);
     if (!nsWindow::sIsPopupClassRegistered) {
       // For older versions of Win32 (i.e., not XP), the registration will
       // fail, so we have to re-register without the CS_XP_DROPSHADOW flag.
       wc.style = CS_DBLCLKS;
-      nsWindow::sIsPopupClassRegistered = nsToolkit::mRegisterClass(&wc);
+      nsWindow::sIsPopupClassRegistered = ::RegisterClassW(&wc);
     }
   }
 
@@ -5736,10 +5574,10 @@ void nsWindow::SubclassWindow(BOOL bState)
     if (bState) {
       // change the nsWindow proc
       if (mUnicodeWidget)
-        mPrevWndProc = (WNDPROC)nsToolkit::mSetWindowLong(mWnd, GWL_WNDPROC,
+        mPrevWndProc = (WNDPROC)::SetWindowLongW(mWnd, GWL_WNDPROC,
                                                 (LONG)nsWindow::WindowProc);
       else
-        mPrevWndProc = (WNDPROC)::SetWindowLong(mWnd, GWL_WNDPROC,
+        mPrevWndProc = (WNDPROC)::SetWindowLongA(mWnd, GWL_WNDPROC,
                                                 (LONG)nsWindow::WindowProc);
       NS_ASSERTION(mPrevWndProc, "Null standard window procedure");
       // connect the this pointer to the nsWindow handle
@@ -5747,9 +5585,9 @@ void nsWindow::SubclassWindow(BOOL bState)
     }
     else {
       if (mUnicodeWidget)
-        nsToolkit::mSetWindowLong(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc);
+        ::SetWindowLongW(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc);
       else
-        ::SetWindowLong(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc);
+        ::SetWindowLongA(mWnd, GWL_WNDPROC, (LONG)mPrevWndProc);
       SetNSWindowPtr(mWnd, NULL);
       mPrevWndProc = NULL;
     }
@@ -5836,7 +5674,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
   nsEventStatus eventStatus = nsEventStatus_eIgnore;
 
 #ifdef MOZ_XUL
-  if (!aDC && mIsTranslucent && IsAlphaTranslucencySupported())
+  if (!aDC && mIsTranslucent)
   {
     // For layered translucent windows all drawing should go to memory DC and no
     // WM_PAINT messages be generated. 
@@ -5913,7 +5751,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
       nsRefPtr<gfxContext> thebesContext = new gfxContext(targetSurface);
 
 #ifdef MOZ_XUL
-      if (mIsTranslucent && IsAlphaTranslucencySupported()) {
+      if (mIsTranslucent) {
         // If we're rendering with translucency, we're going to be
         // rendering the whole window; make sure we clear it first
         thebesContext->SetOperator(gfxContext::OPERATOR_CLEAR);
@@ -5943,7 +5781,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
       event.renderingContext = nsnull;
 
 #ifdef MOZ_XUL
-      if (mIsTranslucent && IsAlphaTranslucencySupported()) {
+      if (mIsTranslucent) {
         // Data from offscreen drawing surface was copied to memory bitmap of transparent
         // bitmap. Now it can be read from memory bitmap to apply alpha channel and after
         // that displayed on the screen.
@@ -5975,7 +5813,7 @@ PRBool nsWindow::OnPaint(HDC aDC)
             event.renderingContext->DestroyDrawingSurface(surf);
 
 #ifdef MOZ_XUL
-            if (mIsTranslucent && IsAlphaTranslucencySupported())
+            if (mIsTranslucent)
             {
               // Data from offscreen drawing surface was copied to memory bitmap of transparent
               // bitmap. Now it can be read from memory bitmap to apply alpha channel and after
@@ -6452,7 +6290,7 @@ DWORD ChildWindow::WindowStyle()
 NS_METHOD nsWindow::SetTitle(const nsAString& aTitle)
 {
   const nsString& strTitle = PromiseFlatString(aTitle);
-  nsToolkit::mSendMessage(mWnd, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCWSTR)strTitle.get());
+  ::SendMessageW(mWnd, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCWSTR)strTitle.get());
   return NS_OK;
 }
 
@@ -6486,31 +6324,8 @@ NS_METHOD nsWindow::SetIcon(const nsAString& aIconSpec)
                                         ::GetSystemMetrics(SM_CYSMICON),
                                         LR_LOADFROMFILE );
 
-  // See if unicode API not implemented and if not, try ascii version
-  if (::GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
-    nsCOMPtr<nsILocalFile> pathConverter;
-    if (NS_SUCCEEDED(NS_NewLocalFile(iconPath, PR_FALSE,
-                                     getter_AddRefs(pathConverter)))) {
-      // Now try the char* path.
-      nsCAutoString aPath;
-      pathConverter->GetNativePath(aPath);
-      bigIcon = (HICON)::LoadImage(NULL,
-                                   aPath.get(),
-                                   IMAGE_ICON,
-                                   ::GetSystemMetrics(SM_CXICON),
-                                   ::GetSystemMetrics(SM_CYICON),
-                                   LR_LOADFROMFILE );
-      smallIcon = (HICON)::LoadImage(NULL,
-                                     aPath.get(),
-                                     IMAGE_ICON,
-                                     ::GetSystemMetrics(SM_CXSMICON),
-                                     ::GetSystemMetrics(SM_CYSMICON),
-                                     LR_LOADFROMFILE );
-    }
-  }
-
   if (bigIcon) {
-    HICON icon = (HICON) nsToolkit::mSendMessage(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)bigIcon);
+    HICON icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_BIG, (LPARAM)bigIcon);
     if (icon)
       ::DestroyIcon(icon);
   }
@@ -6521,7 +6336,7 @@ NS_METHOD nsWindow::SetIcon(const nsAString& aIconSpec)
   }
 #endif
   if (smallIcon) {
-    HICON icon = (HICON) nsToolkit::mSendMessage(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)smallIcon);
+    HICON icon = (HICON) ::SendMessageW(mWnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)smallIcon);
     if (icon)
       ::DestroyIcon(icon);
   }
@@ -6617,7 +6432,7 @@ nsWindow::HandleTextEvent(HIMC hIMEContext,PRBool aCheckAttr)
       SetCaretPos(candForm.ptCurrentPos.x, candForm.ptCurrentPos.y);
     }
 
-    NS_IMM_SETCANDIDATEWINDOW(hIMEContext, &candForm);
+    ::ImmSetCandidateWindow(hIMEContext, &candForm);
 
     // somehow the "Intellegent ABC IME" in Simplified Chinese
     // window listen to the caret position to decide where to put the
@@ -6702,7 +6517,7 @@ nsWindow::HandleStartComposition(HIMC hIMEContext)
       SetCaretPos(candForm.ptCurrentPos.x, candForm.ptCurrentPos.y);
     }
 
-    NS_IMM_SETCANDIDATEWINDOW(hIMEContext, &candForm);
+    ::ImmSetCandidateWindow(hIMEContext, &candForm);
 
     sIMECompCharPos = (RECT*)PR_MALLOC(IME_MAX_CHAR_POS*sizeof(RECT));
     if (sIMECompCharPos) {
@@ -6845,12 +6660,6 @@ BOOL nsWindow::OnInputLangChange(HKL aHKL, LRESULT *oRetValue)
   if (gKeyboardLayout != aHKL)
   {
     gKeyboardLayout = aHKL;
-    *oRetValue = LangIDToCP((WORD)((DWORD)gKeyboardLayout & 0x0FFFF), gCurrentKeyboardCP);
-    if (nsToolkit::mW2KXP_CP936) {
-      DWORD imeProp = 0;
-      NS_IMM_GETPROPERTY(gKeyboardLayout, IGP_PROPERTY, imeProp);
-      nsToolkit::mUseImeApiW = (imeProp & IME_PROP_UNICODE) ? PR_TRUE : PR_FALSE;
-    }
 
     gKbdLayout.LoadLayout();
   }
@@ -6870,26 +6679,9 @@ BOOL nsWindow::OnIMEChar(BYTE aByte1, BYTE aByte2, LPARAM aKeyState)
   printf("OnIMEChar\n");
 #endif
   wchar_t uniChar;
-  char    charToConvert[3];
-  size_t  length;
   int err = 0;
 
-  if (nsToolkit::mIsNT) {
-    uniChar = MAKEWORD(aByte2, aByte1);
-  }
-  else {
-    if (aByte1) {
-      charToConvert[0] = aByte1;
-      charToConvert[1] = aByte2;
-      length=2;
-    }
-    else {
-      charToConvert[0] = aByte2;
-      length=1;
-    }
-    err = ::MultiByteToWideChar(gCurrentKeyboardCP, MB_PRECOMPOSED, charToConvert,
-                                length, &uniChar, 1);
-  }
+  uniChar = MAKEWORD(aByte2, aByte1);
 
 #ifdef DEBUG_IME
   if (!err) {
@@ -6924,35 +6716,17 @@ BOOL nsWindow::OnIMEChar(BYTE aByte1, BYTE aByte2, LPARAM aKeyState)
 //==========================================================================
 // This function is used when aIndex is GCS_COMPSTR, GCS_COMPREADSTR,
 // GCS_RESULTSTR, and GCS_RESULTREADSTR.
-// Otherwise use NS_IMM_GETCOMPOSITIONSTRING.
-// If on NT, we only need aStrUnicode. aStrAnsi is not used.
-void nsWindow::GetCompositionString(HIMC aHIMC, DWORD aIndex, nsString* aStrUnicode, nsCString* aStrAnsi)
+// Otherwise use ::ImmGetCompositionStringW.
+void nsWindow::GetCompositionString(HIMC aHIMC, DWORD aIndex, nsString* aStrUnicode)
 {
   long lRtn;
-  if (nsToolkit::mUseImeApiW) {
-    NS_IMM_GETCOMPOSITIONSTRINGW(aHIMC, aIndex, NULL, 0, lRtn);
-    aStrUnicode->SetCapacity((lRtn / sizeof(WCHAR)) + 1);
-
-    long buflen = lRtn + sizeof(WCHAR);
-    NS_IMM_GETCOMPOSITIONSTRINGW(aHIMC, aIndex, (LPVOID)aStrUnicode->BeginWriting(), buflen, lRtn);
-    lRtn = lRtn / sizeof(WCHAR);
-    aStrUnicode->SetLength(lRtn);
-  } else {
-    NS_IMM_GETCOMPOSITIONSTRINGA(aHIMC, aIndex, NULL, 0, lRtn);
-    aStrAnsi->SetCapacity(lRtn + 1);
+  lRtn = ::ImmGetCompositionStringW(aHIMC, aIndex, NULL, 0);
+  aStrUnicode->SetCapacity((lRtn / sizeof(WCHAR)) + 1);
 
-    long buflen = lRtn + 1;
-    NS_IMM_GETCOMPOSITIONSTRINGA(aHIMC, aIndex, (LPVOID)aStrAnsi->BeginWriting(), buflen, lRtn);
-    aStrAnsi->SetLength(lRtn);
-
-    size_t unicharSize = MultiByteToWideChar(gCurrentKeyboardCP, MB_PRECOMPOSED,
-      aStrAnsi->get(), aStrAnsi->Length(), NULL, 0);
-    aStrUnicode->SetCapacity(unicharSize + 1);
-
-    unicharSize = MultiByteToWideChar(gCurrentKeyboardCP, MB_PRECOMPOSED,
-      aStrAnsi->get(), aStrAnsi->Length(), aStrUnicode->BeginWriting(), unicharSize + 1);
-    aStrUnicode->SetLength(unicharSize);
-  }
+  long buflen = lRtn + sizeof(WCHAR);
+  lRtn = ::ImmGetCompositionStringW(aHIMC, aIndex, (LPVOID)aStrUnicode->BeginWriting(), buflen);
+  lRtn = lRtn / sizeof(WCHAR);
+  aStrUnicode->SetLength(lRtn);
 }
 
 //==========================================================================
@@ -6971,8 +6745,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
   if (!sIMECompUnicode)
     return PR_TRUE;
 
-  HIMC hIMEContext;
-  NS_IMM_GETCONTEXT(mWnd, hIMEContext);
+  HIMC hIMEContext = ::ImmGetContext(mWnd);
   if (hIMEContext==NULL) 
     return PR_TRUE;
 
@@ -6991,8 +6764,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
     if (!sIMEIsComposing) 
       HandleStartComposition(hIMEContext);
 
-    nsCAutoString strIMECompAnsi;
-    GetCompositionString(hIMEContext, GCS_RESULTSTR, sIMECompUnicode, &strIMECompAnsi);
+    GetCompositionString(hIMEContext, GCS_RESULTSTR, sIMECompUnicode);
 #ifdef DEBUG_IME
     printf("GCS_RESULTSTR compStrLen = %d\n", sIMECompUnicode->Length());
 #endif
@@ -7017,8 +6789,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
     //--------------------------------------------------------
     // 1. Get GCS_COMPSTR
     //--------------------------------------------------------
-    nsCAutoString strIMECompAnsi;
-    GetCompositionString(hIMEContext, GCS_COMPSTR, sIMECompUnicode, &strIMECompAnsi);
+    GetCompositionString(hIMEContext, GCS_COMPSTR, sIMECompUnicode);
 
     // See https://bugzilla.mozilla.org/show_bug.cgi?id=296339
     if (sIMECompUnicode->IsEmpty() &&
@@ -7046,7 +6817,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
     // 2. Get GCS_COMPCLAUSE
     //--------------------------------------------------------
     long compClauseLen, compClauseLen2;
-    NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_COMPCLAUSE, NULL, 0, compClauseLen);
+    compClauseLen = ::ImmGetCompositionStringW(hIMEContext, GCS_COMPCLAUSE, NULL, 0);
 #ifdef DEBUG_IME
     printf("GCS_COMPCLAUSE compClauseLen = %d\n", compClauseLen);
 #endif
@@ -7060,8 +6831,8 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
       sIMECompClauseArraySize = compClauseLen + 32;
     }
 
-    NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_COMPCLAUSE, sIMECompClauseArray,
-      sIMECompClauseArraySize * sizeof(PRUint32), compClauseLen2);
+    compClauseLen2 = ::ImmGetCompositionStringW(hIMEContext, GCS_COMPCLAUSE, sIMECompClauseArray,
+      sIMECompClauseArraySize * sizeof(PRUint32));
 
     compClauseLen2 = compClauseLen2 / sizeof(PRUint32);
     NS_ASSERTION(compClauseLen2 == compClauseLen, "strange result");
@@ -7069,35 +6840,13 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
       compClauseLen = compClauseLen2;
     sIMECompClauseArrayLength = compClauseLen;
 
-    // if using "A" API, we need to convert A's array of "CLAUSE" to W's that.
-    if (!nsToolkit::mUseImeApiW && sIMECompClauseArrayLength > 0) {
-      PRUint32 maxlen = strIMECompAnsi.Length();
-      // sIMECompClauseArray[0] is always 0. So, converting start from 1.
-      for (int i = 1; i < sIMECompClauseArrayLength; i++) {
-#ifdef DEBUG_IME
-        printf("sIMECompClauseArray(ANSI)[%d]: %d\n", i, sIMECompClauseArray[i]);
-#endif
-        NS_ASSERTION(sIMECompClauseArray[i] <= maxlen, "wrong offset");
-        if (sIMECompClauseArray[i] > maxlen)
-          sIMECompClauseArray[i] = maxlen;
-
-        sIMECompClauseArray[i] = ::MultiByteToWideChar(gCurrentKeyboardCP, MB_PRECOMPOSED,
-          strIMECompAnsi.get(), sIMECompClauseArray[i], NULL, 0);
-      }
-#ifdef DEBUG_IME
-      for (int i = 0; i < sIMECompClauseArrayLength; i++) {
-        printf("sIMECompClauseArray(Unicode)[%d]: %d\n", i, sIMECompClauseArray[i]);
-      }
-#endif
-    }
-
     //--------------------------------------------------------
     // 3. Get GCS_COMPATTR
     //--------------------------------------------------------
     // This provides us with the attribute string necessary 
     // for doing hiliting
     long attrStrLen;
-    NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_COMPATTR, NULL, 0, attrStrLen);
+    attrStrLen = ::ImmGetCompositionStringW(hIMEContext, GCS_COMPATTR, NULL, 0);
 #ifdef DEBUG_IME
     printf("GCS_COMPATTR attrStrLen = %d\n", attrStrLen);
 #endif
@@ -7108,46 +6857,14 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
       sIMEAttributeArray = new PRUint8[attrStrLen + 64];
       sIMEAttributeArraySize = attrStrLen + 64;
     }
-    NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_COMPATTR, sIMEAttributeArray, sIMEAttributeArraySize, attrStrLen);
+    attrStrLen = ::ImmGetCompositionStringW(hIMEContext, GCS_COMPATTR, sIMEAttributeArray, sIMEAttributeArraySize);
 
     sIMEAttributeArrayLength = attrStrLen;
 
-    // if using "A" API, we need to convert A's array of "ATTR" to W's that.
-    if (!nsToolkit::mUseImeApiW && sIMEAttributeArrayLength > 0) {
-      int offset = 0;
-      long compUnicodeLength = sIMECompUnicode->Length();
-      for (int i = 0; i < compUnicodeLength; i++) {
-#ifdef DEBUG_IME
-        printf("sIMEAttributeArray(ANSI)[%d]: %d\n", offset, sIMEAttributeArray[offset]);
-#endif
-        NS_ASSERTION(offset < sIMEAttributeArrayLength, "wrong offset");
-        if (offset >= sIMEAttributeArrayLength)
-          offset = sIMEAttributeArrayLength - 1;
-
-        sIMEAttributeArray[i] = sIMEAttributeArray[offset];
-
-        offset += ::WideCharToMultiByte(gCurrentKeyboardCP, 0,
-          sIMECompUnicode->get() + i, 1, NULL, 0, NULL, NULL);
-      }
-
-      sIMEAttributeArrayLength = sIMECompUnicode->Length();
-#ifdef DEBUG_IME
-      for (int i = 0; i < sIMEAttributeArrayLength; i++) {
-        printf("sIMEAttributeArray(Unicode)[%d]: %d\n", i, sIMEAttributeArray[i]);
-      }
-#endif
-    }
-
     //--------------------------------------------------------
     // 4. Get GCS_CURSOPOS
     //--------------------------------------------------------
-    NS_IMM_GETCOMPOSITIONSTRING(hIMEContext, GCS_CURSORPOS, NULL, 0, sIMECursorPosition);
-
-    // if using "A" API, we need to convert A's "CURSORPOS" to W's that.
-    if (!nsToolkit::mUseImeApiW && sIMECursorPosition > 0) {
-      sIMECursorPosition = ::MultiByteToWideChar(gCurrentKeyboardCP, MB_PRECOMPOSED, 
-                            strIMECompAnsi.get(), sIMECursorPosition, NULL, 0);
-    }
+    sIMECursorPosition = ::ImmGetCompositionStringW(hIMEContext, GCS_CURSORPOS, NULL, 0);
 
     NS_ASSERTION(sIMECursorPosition <= sIMECompUnicode->Length(), "illegal pos");
 
@@ -7172,7 +6889,7 @@ BOOL nsWindow::OnIMEComposition(LPARAM aGCS)
     result = PR_TRUE;
   }
 
-  NS_IMM_RELEASECONTEXT(mWnd, hIMEContext);
+  ::ImmReleaseContext(mWnd, hIMEContext);
   return result;
 }
 //==========================================================================
@@ -7197,7 +6914,7 @@ BOOL nsWindow::OnIMEEndComposition()
     if (sIMEProperty & (IME_PROP_SPECIAL_UI | IME_PROP_AT_CARET)) 
       return PR_FALSE;
 
-    NS_IMM_GETCONTEXT(mWnd, hIMEContext);
+    hIMEContext = ::ImmGetContext(mWnd);
     if (hIMEContext==NULL) 
       return PR_TRUE;
 
@@ -7210,7 +6927,7 @@ BOOL nsWindow::OnIMEEndComposition()
     HandleTextEvent(hIMEContext, PR_FALSE);
 
     HandleEndComposition();
-    NS_IMM_RELEASECONTEXT(mWnd, hIMEContext);
+    ::ImmReleaseContext(mWnd, hIMEContext);
   }
   return PR_TRUE;
 }
@@ -7279,7 +6996,7 @@ BOOL nsWindow::OnIMENotify(WPARAM aIMN, LPARAM aData, LRESULT *oResult)
   return PR_FALSE;
 }
 //==========================================================================
-BOOL nsWindow::OnIMERequest(WPARAM aIMR, LPARAM aData, LRESULT *oResult, PRBool aUseUnicode)
+BOOL nsWindow::OnIMERequest(WPARAM aIMR, LPARAM aData, LRESULT *oResult)
 {
 #ifdef DEBUG_IME
   printf("OnIMERequest\n");
@@ -7288,10 +7005,10 @@ BOOL nsWindow::OnIMERequest(WPARAM aIMR, LPARAM aData, LRESULT *oResult, PRBool
 
   switch (aIMR) {
     case IMR_RECONVERTSTRING:
-      result = OnIMEReconvert(aData, oResult, aUseUnicode);
+      result = OnIMEReconvert(aData, oResult);
       break;
     case IMR_QUERYCHARPOSITION:
-      result = OnIMEQueryCharPosition(aData, oResult, aUseUnicode);
+      result = OnIMEQueryCharPosition(aData, oResult);
       break;
   }
 
@@ -7299,7 +7016,7 @@ BOOL nsWindow::OnIMERequest(WPARAM aIMR, LPARAM aData, LRESULT *oResult, PRBool
 }
 
 //==========================================================================
-PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult, PRBool aUseUnicode)
+PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult)
 {
 #ifdef DEBUG_IME
   printf("OnIMEReconvert\n");
@@ -7333,16 +7050,8 @@ PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult, PRBool aUseUnico
     // Return need size
 
     if (sIMEReconvertUnicode) {
-      if (aUseUnicode) {
-        len = nsCRT::strlen(sIMEReconvertUnicode);
-        *oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
-      } else {
-        len = ::WideCharToMultiByte(gCurrentKeyboardCP, 0,
-                                    sIMEReconvertUnicode,
-                                    nsCRT::strlen(sIMEReconvertUnicode),
-                                    NULL, 0, NULL, NULL);
-        *oResult = sizeof(RECONVERTSTRING) + len;
-      }
+      len = nsCRT::strlen(sIMEReconvertUnicode);
+      *oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
 
       result = PR_TRUE;
     }
@@ -7352,16 +7061,8 @@ PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult, PRBool aUseUnico
     // Fill reconvert struct
     //
 
-    if (aUseUnicode) {
-      len = nsCRT::strlen(sIMEReconvertUnicode);
-      *oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
-    } else {
-      len = ::WideCharToMultiByte(gCurrentKeyboardCP, 0,
-                                  sIMEReconvertUnicode,
-                                  nsCRT::strlen(sIMEReconvertUnicode),
-                                  NULL, 0, NULL, NULL);
-      *oResult = sizeof(RECONVERTSTRING) + len;
-    }
+    len = nsCRT::strlen(sIMEReconvertUnicode);
+    *oResult = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
 
     if (pReconv->dwSize < *oResult) {
       *oResult = 0;
@@ -7379,17 +7080,8 @@ PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult, PRBool aUseUnico
     pReconv->dwTargetStrLen    = len;
     pReconv->dwTargetStrOffset = 0;
 
-    if (aUseUnicode) {
-      ::CopyMemory((LPVOID) (aData + sizeof(RECONVERTSTRING)),
-                   sIMEReconvertUnicode, len * sizeof(WCHAR));
-    } else {
-      ::WideCharToMultiByte(gCurrentKeyboardCP, 0,
-                            sIMEReconvertUnicode,
-                            nsCRT::strlen(sIMEReconvertUnicode),
-                            (LPSTR) (aData + sizeof(RECONVERTSTRING)),
-                            len,
-                            NULL, NULL);
-    }
+    ::CopyMemory((LPVOID) (aData + sizeof(RECONVERTSTRING)),
+                 sIMEReconvertUnicode, len * sizeof(WCHAR));
 
     result = PR_TRUE;
   }
@@ -7398,7 +7090,7 @@ PRBool nsWindow::OnIMEReconvert(LPARAM aData, LRESULT *oResult, PRBool aUseUnico
 }
 
 //==========================================================================
-PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult, PRBool aUseUnicode)
+PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult)
 {
 #ifdef DEBUG_IME
   printf("OnIMEQueryCharPosition\n");
@@ -7448,22 +7140,12 @@ PRBool nsWindow::OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult, PRBool a
   }
 
   long charPosition;
-  if (aUseUnicode || pCharPosition->dwCharPos == 0) {
-    if (pCharPosition->dwCharPos > sIMECompUnicode->Length()) {
-      *oResult = FALSE;
-      return PR_FALSE;
-    }
-    charPosition = pCharPosition->dwCharPos;
-  } else {
-    nsCAutoString strIMECompAnsi;
-    NS_CopyUnicodeToNative(*sIMECompUnicode, strIMECompAnsi);
-    if (pCharPosition->dwCharPos > strIMECompAnsi.Length()) {
-      *oResult = FALSE;
-      return PR_FALSE;
-    }
-    charPosition = ::MultiByteToWideChar(gCurrentKeyboardCP, MB_PRECOMPOSED,
-                    strIMECompAnsi.get(), pCharPosition->dwCharPos, NULL, 0);
+  if (pCharPosition->dwCharPos > sIMECompUnicode->Length()) {
+    *oResult = FALSE;
+    return PR_FALSE;
   }
+  charPosition = pCharPosition->dwCharPos;
+
   // We only support insertion at the cursor position or at the leftmost position.
   // Because sIMECompCharPos may be broken by user converting the string.
   // But leftmost position and cursor position is always correctly.
@@ -7545,12 +7227,12 @@ BOOL nsWindow::OnIMEStartComposition()
   if (sIMEProperty & (IME_PROP_SPECIAL_UI | IME_PROP_AT_CARET))
     return PR_FALSE;
 
-  NS_IMM_GETCONTEXT(mWnd, hIMEContext);
+  hIMEContext = ::ImmGetContext(mWnd);
   if (hIMEContext == NULL)
     return PR_TRUE;
 
   PRBool rtn = HandleStartComposition(hIMEContext);
-  NS_IMM_RELEASECONTEXT(mWnd, hIMEContext);
+  ::ImmReleaseContext(mWnd, hIMEContext);
   return rtn;
 }
 
@@ -7560,14 +7242,13 @@ NS_IMETHODIMP nsWindow::ResetInputState()
 #ifdef DEBUG_KBSTATE
   printf("ResetInputState\n");
 #endif
-  HIMC hIMC;
-  NS_IMM_GETCONTEXT(mWnd, hIMC);
+  HIMC hIMC = ::ImmGetContext(mWnd);
   if (hIMC) {
     BOOL ret = FALSE;
-    NS_IMM_NOTIFYIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, NULL, ret);
-    NS_IMM_NOTIFYIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, NULL, ret);
+    ret = ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_COMPLETE, NULL);
+    ret = ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, NULL);
     //NS_ASSERTION(ret, "ImmNotify failed");
-    NS_IMM_RELEASECONTEXT(mWnd, hIMC);
+    ::ImmReleaseContext(mWnd, hIMC);
   }
   return NS_OK;
 }
@@ -7578,11 +7259,10 @@ NS_IMETHODIMP nsWindow::SetIMEOpenState(PRBool aState)
 #ifdef DEBUG_KBSTATE
   printf("SetIMEOpenState %s\n", (aState ? "Open" : "Close"));
 #endif 
-  HIMC hIMC;
-  NS_IMM_GETCONTEXT(mWnd, hIMC);
+  HIMC hIMC = ::ImmGetContext(mWnd);
   if (hIMC) {
-    NS_IMM_SETOPENSTATUS(hIMC, aState ? TRUE : FALSE);
-    NS_IMM_RELEASECONTEXT(mWnd, hIMC);
+    ::ImmSetOpenStatus(hIMC, aState ? TRUE : FALSE);
+    ::ImmReleaseContext(mWnd, hIMC);
   }
   return NS_OK;
 }
@@ -7590,13 +7270,11 @@ NS_IMETHODIMP nsWindow::SetIMEOpenState(PRBool aState)
 //==========================================================================
 NS_IMETHODIMP nsWindow::GetIMEOpenState(PRBool* aState)
 {
-  HIMC hIMC;
-  NS_IMM_GETCONTEXT(mWnd, hIMC);
+  HIMC hIMC = ::ImmGetContext(mWnd);
   if (hIMC) {
-    BOOL isOpen;
-    NS_IMM_GETOPENSTATUS(hIMC, isOpen);
+    BOOL isOpen = ::ImmGetOpenStatus(hIMC);
     *aState = isOpen ? PR_TRUE : PR_FALSE;
-    NS_IMM_RELEASECONTEXT(mWnd, hIMC);
+    ::ImmReleaseContext(mWnd, hIMC);
   } else 
     *aState = PR_FALSE;
   return NS_OK;
@@ -7609,7 +7287,7 @@ NS_IMETHODIMP nsWindow::SetIMEEnabled(PRBool aState)
     ResetInputState();
   if (!aState != !mOldIMC)
     return NS_OK;
-  NS_IMM_ASSOCIATECONTEXT(mWnd, aState ? mOldIMC : NULL, &mOldIMC);
+  mOldIMC = ::ImmAssociateContext(mWnd, aState ? mOldIMC : NULL);
   NS_ASSERTION(!aState || !mOldIMC, "Another IMC was associated");
 
   return NS_OK;
@@ -7628,12 +7306,11 @@ NS_IMETHODIMP nsWindow::CancelIMEComposition()
 #ifdef DEBUG_KBSTATE
   printf("CancelIMEComposition\n");
 #endif 
-  HIMC hIMC;
-  NS_IMM_GETCONTEXT(mWnd, hIMC);
+  HIMC hIMC = ::ImmGetContext(mWnd);
   if (hIMC) {
     BOOL ret = FALSE;
-    NS_IMM_NOTIFYIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, NULL, ret);
-    NS_IMM_RELEASECONTEXT(mWnd, hIMC);
+    ret = ::ImmNotifyIME(hIMC, NI_COMPOSITIONSTR, CPS_CANCEL, NULL);
+    ::ImmReleaseContext(mWnd, hIMC);
   }
   return NS_OK;
 }
@@ -7674,8 +7351,7 @@ nsWindow::HandleMouseActionOfIME(int aAction, POINT *ptPos)
   PRBool IsHandle = PR_FALSE;
 
   if (mWnd) {
-    HIMC hIMC = NULL;
-    NS_IMM_GETCONTEXT(mWnd, hIMC);
+    HIMC hIMC = ::ImmGetContext(mWnd);
     if (hIMC) {
       int positioning = 0;
       int offset = 0;
@@ -7701,14 +7377,13 @@ nsWindow::HandleMouseActionOfIME(int aAction, POINT *ptPos)
       positioning = (positioning + 2) % 4;
 
       // send MS_MSIME_MOUSE message to default IME window.
-      HWND imeWnd;
-      NS_IMM_GETDEFAULTIMEWND(mWnd, &imeWnd);
-      if (nsToolkit::mSendMessage(imeWnd, nsWindow::uWM_MSIME_MOUSE,
-                                  MAKELONG(MAKEWORD(aAction, positioning), offset),
-                                  (LPARAM) hIMC) == 1)
+      HWND imeWnd = ::ImmGetDefaultIMEWnd(mWnd);
+      if (::SendMessageW(imeWnd, nsWindow::uWM_MSIME_MOUSE,
+                         MAKELONG(MAKEWORD(aAction, positioning), offset),
+                         (LPARAM) hIMC) == 1)
         IsHandle = PR_TRUE;
     }
-    NS_IMM_RELEASECONTEXT(mWnd, hIMC);
+    ::ImmReleaseContext(mWnd, hIMC);
   }
 
   return IsHandle;
@@ -7781,7 +7456,7 @@ void nsWindow::GetCompositionWindowPos(HIMC hIMC, PRUint32 aEventType, COMPOSITI
     event.refPoint.y = 0;
   }
 
-  NS_IMM_GETCOMPOSITIONWINDOW(hIMC, cpForm);
+  ::ImmGetCompositionWindow(hIMC, cpForm);
 
   cpForm->ptCurrentPos.x = event.theReply.mCursorPosition.x + IME_X_OFFSET;
   cpForm->ptCurrentPos.y = event.theReply.mCursorPosition.y + IME_Y_OFFSET +
@@ -8129,7 +7804,7 @@ nsWindow :: DealWithPopups ( HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inL
   if (gRollupListener && gRollupWidget && ::IsWindowVisible(inWnd)) {
 
     if (inMsg == WM_LBUTTONDOWN || inMsg == WM_RBUTTONDOWN || inMsg == WM_MBUTTONDOWN ||
-        inMsg == WM_MOUSEWHEEL  || inMsg == uMSH_MOUSEWHEEL || inMsg == WM_ACTIVATE
+        inMsg == WM_MOUSEWHEEL || inMsg == WM_ACTIVATE
 #ifndef WINCE
         || 
         inMsg == WM_NCRBUTTONDOWN || 
@@ -8148,7 +7823,7 @@ nsWindow :: DealWithPopups ( HWND inWnd, UINT inMsg, WPARAM inWParam, LPARAM inL
       // Rollup if the event is outside the popup.
       PRBool rollup = !nsWindow::EventIsInsideWindow(inMsg, (nsWindow*)gRollupWidget);
 
-      if (rollup && (inMsg == WM_MOUSEWHEEL || inMsg == uMSH_MOUSEWHEEL))
+      if (rollup && inMsg == WM_MOUSEWHEEL)
       {
         gRollupListener->ShouldRollupOnMouseWheelEvent(&rollup);
         *outResult = PR_TRUE;
@@ -8379,37 +8054,34 @@ void nsWindow::ResizeTranslucentWindow(PRInt32 aNewWidth, PRInt32 aNewHeight, PR
   mAlphaMask = pBits;
 #endif
 
-  if (IsAlphaTranslucencySupported())
-  {
-    if (!w2k.mMemoryDC)
-      w2k.mMemoryDC = ::CreateCompatibleDC(NULL);
+  if (!mMemoryDC)
+    mMemoryDC = ::CreateCompatibleDC(NULL);
 
-    // Always use at least 24-bit (32 with cairo) bitmaps regardless of the device context.
-    int depth = ::GetDeviceCaps(w2k.mMemoryDC, BITSPIXEL);
+  // Always use at least 24-bit (32 with cairo) bitmaps regardless of the device context.
+  int depth = ::GetDeviceCaps(mMemoryDC, BITSPIXEL);
 #ifdef MOZ_CAIRO_GFX
-    if (depth < 32)
-      depth = 32;
+  if (depth < 32)
+    depth = 32;
 #else
-    if (depth < 24)
-      depth = 24;
+  if (depth < 24)
+    depth = 24;
 #endif
 
-    // resize the memory bitmap
-    BITMAPINFO bi = { 0 };
-    bi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
-    bi.bmiHeader.biWidth = aNewWidth;
-    bi.bmiHeader.biHeight = -aNewHeight;
-    bi.bmiHeader.biPlanes = 1;
-    bi.bmiHeader.biBitCount = depth;
-    bi.bmiHeader.biCompression = BI_RGB;
+  // resize the memory bitmap
+  BITMAPINFO bi = { 0 };
+  bi.bmiHeader.biSize = sizeof (BITMAPINFOHEADER);
+  bi.bmiHeader.biWidth = aNewWidth;
+  bi.bmiHeader.biHeight = -aNewHeight;
+  bi.bmiHeader.biPlanes = 1;
+  bi.bmiHeader.biBitCount = depth;
+  bi.bmiHeader.biCompression = BI_RGB;
 
-    w2k.mMemoryBitmap = ::CreateDIBSection(w2k.mMemoryDC, &bi, DIB_RGB_COLORS, (void**)&w2k.mMemoryBits, NULL, 0);
+  mMemoryBitmap = ::CreateDIBSection(mMemoryDC, &bi, DIB_RGB_COLORS, (void**)&mMemoryBits, NULL, 0);
 
-    if (w2k.mMemoryBitmap)
-    {
-      HGDIOBJ oldBitmap = ::SelectObject(w2k.mMemoryDC, w2k.mMemoryBitmap);
-      ::DeleteObject(oldBitmap);
-    }
+  if (mMemoryBitmap)
+  {
+    HGDIOBJ oldBitmap = ::SelectObject(mMemoryDC, mMemoryBitmap);
+    ::DeleteObject(oldBitmap);
   }
 }
 
@@ -8452,28 +8124,26 @@ nsresult nsWindow::SetWindowTranslucencyInner(PRBool aTranslucent)
 
   if (aTranslucent)
   {
-    style = nsToolkit::mGetWindowLong(hWnd, GWL_STYLE) &
+    style = ::GetWindowLongW(hWnd, GWL_STYLE) &
             ~(WS_CAPTION | WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX);
-    exStyle = nsToolkit::mGetWindowLong(hWnd, GWL_EXSTYLE) &
+    exStyle = ::GetWindowLongW(hWnd, GWL_EXSTYLE) &
               ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE);
 
-    if (IsAlphaTranslucencySupported())
-      exStyle |= WS_EX_LAYERED;
+    exStyle |= WS_EX_LAYERED;
   } else
   {
     style = WindowStyle();
     exStyle = WindowExStyle();
   }
-  nsToolkit::mSetWindowLong(hWnd, GWL_STYLE, style);
-  nsToolkit::mSetWindowLong(hWnd, GWL_EXSTYLE, exStyle);
+  ::SetWindowLongW(hWnd, GWL_STYLE, style);
+  ::SetWindowLongW(hWnd, GWL_EXSTYLE, exStyle);
 
   mIsTranslucent = aTranslucent;
   topWindow->mIsTopTranslucent = aTranslucent;
 
   nsresult rv = NS_OK;
-  
-  if (IsAlphaTranslucencySupported())
-    rv = SetupTranslucentWindowMemoryBitmap(aTranslucent);
+
+  rv = SetupTranslucentWindowMemoryBitmap(aTranslucent);
 
   if (aTranslucent)
   {
@@ -8502,13 +8172,13 @@ nsresult nsWindow::SetupTranslucentWindowMemoryBitmap(PRBool aTranslucent)
   if (aTranslucent) {
     ResizeTranslucentWindow(mBounds.width, mBounds.height, PR_TRUE);
   } else {
-    if (w2k.mMemoryDC)
-      ::DeleteDC(w2k.mMemoryDC);
-    if (w2k.mMemoryBitmap)
-      ::DeleteObject(w2k.mMemoryBitmap);
+    if (mMemoryDC)
+      ::DeleteDC(mMemoryDC);
+    if (mMemoryBitmap)
+      ::DeleteObject(mMemoryBitmap);
 
-    w2k.mMemoryDC = NULL;
-    w2k.mMemoryBitmap = NULL;
+    mMemoryDC = NULL;
+    mMemoryBitmap = NULL;
   }
 
   return NS_OK;
@@ -8528,51 +8198,22 @@ void nsWindow::UpdateTranslucentWindowAlphaInner(const nsRect& aRect, PRUint8* a
 
   if (!aRect.IsEmpty())
   {
-    PRBool skipMaskChangeCheck = IsAlphaTranslucencySupported();
     PRUint8* pSrcRow = aAlphas;
     PRUint8* pDestRow = mAlphaMask + aRect.y * mBounds.width + aRect.x;
 
     for (PRInt32 y = 0 ; y < aRect.height ; y++)
     {
-      if (skipMaskChangeCheck)
-        memcpy(pDestRow, pSrcRow, aRect.width);
-      else
-      {
-        PRUint8* pSrc = pSrcRow;
-        PRUint8* pDest = pDestRow;
-
-        for (PRInt32 x = 0 ; x < aRect.width ; x++)
-        {
-          if (!*pDest != !*pSrc)
-          {
-            transparencyMaskChanged = PR_TRUE;
-            skipMaskChangeCheck = PR_TRUE;
-          }
-
-          *pDest++ = *pSrc++;
-        }
-      }
+      memcpy(pDestRow, pSrcRow, aRect.width);
 
       pSrcRow += aRect.width;
       pDestRow += mBounds.width;
     }
   }
 
-  if (IsAlphaTranslucencySupported())
-  {
-    // Windows 2000 and newer versions support layered windows which allow to implement
-    // full 256 level alpha translucency.
-    // The real screen update is performed in OnPaint() handler only after rendered
-    // bits from offscreen drawing surface are copied back to memory bitmap.
-  } else
-  {
-    // Older Windows versions do not have native support for 256 level alpha translucency.
-    // By use of complex shaped window regions we can achieve the effect of 1-bit
-    // transparency map.
-
-    if (transparencyMaskChanged)
-      SetWindowRegionToAlphaMask();
-  }
+  // Windows 2000 and newer versions support layered windows which allow to implement
+  // full 256 level alpha translucency.
+  // The real screen update is performed in OnPaint() handler only after rendered
+  // bits from offscreen drawing surface are copied back to memory bitmap.
 #endif
 }
 
@@ -8586,19 +8227,21 @@ nsresult nsWindow::UpdateTranslucentWindow()
   ::GdiFlush();
 
   HDC hMemoryDC;
+#ifndef MOZ_CAIRO_GFX
   HBITMAP hAlphaBitmap;
+#endif
   PRBool needConversion;
 
 #ifdef MOZ_CAIRO_GFX
 
-  hMemoryDC = w2k.mMemoryDC;
+  hMemoryDC = mMemoryDC;
   needConversion = PR_FALSE;
 
   rv = NS_OK;
 
 #else
 
-  int depth = ::GetDeviceCaps(w2k.mMemoryDC, BITSPIXEL);
+  int depth = ::GetDeviceCaps(mMemoryDC, BITSPIXEL);
   if (depth < 24)
     depth = 24;
 
@@ -8632,7 +8275,7 @@ nsresult nsWindow::UpdateTranslucentWindow()
 
         for (PRInt32 y = 0 ; y < mBounds.height ; y++)
         {
-          PRUint8* pPixel = w2k.mMemoryBits + y * rasWidth;
+          PRUint8* pPixel = mMemoryBits + y * rasWidth;
 
           for (PRInt32 x = 0 ; x < mBounds.width ; x++)
           {
@@ -8648,11 +8291,11 @@ nsresult nsWindow::UpdateTranslucentWindow()
     }
   } else
   {
-    hMemoryDC = w2k.mMemoryDC;
+    hMemoryDC = mMemoryDC;
 
     if (hMemoryDC)
     {
-      PRUint8* pPixel = w2k.mMemoryBits + 3;    // Point to alpha component of pixel
+      PRUint8* pPixel = mMemoryBits + 3;    // Point to alpha component of pixel
       PRUint8* pAlpha = mAlphaMask;
       PRInt32 pixels = mBounds.width * mBounds.height;
 
@@ -8677,135 +8320,20 @@ nsresult nsWindow::UpdateTranslucentWindow()
     ::GetWindowRect(hWnd, &winRect);
 
     // perform the alpha blend
-    if (!pUpdateLayeredWindow(hWnd, NULL, (POINT*)&winRect, &winSize, hMemoryDC, &srcPos, 0, &bf, ULW_ALPHA))
+    if (!UpdateLayeredWindow(hWnd, NULL, (POINT*)&winRect, &winSize, hMemoryDC, &srcPos, 0, &bf, ULW_ALPHA))
       rv = NS_ERROR_FAILURE;
   }
 
 
   if (needConversion)
   {
+#ifndef MOZ_CAIRO_GFX
     ::DeleteObject(hAlphaBitmap);
+#endif
     ::DeleteDC(hMemoryDC);
   }
 
   return rv;
 }
 
-void nsWindow::SetWindowRegionToAlphaMask()
-{
-  PRInt32 minX = PR_INT32_MAX, maxX = PR_INT32_MIN;
-  PRInt32 minY = PR_INT32_MAX, maxY = PR_INT32_MIN;
-  PRUint8* pPixel = mAlphaMask;
-
-  // Convert all non-zero alpha pixels to be completely opaque (255).
-  // Find minimal bounding rectangle that contains all opaque pixels.
-  for (PRInt32 y = 0 ; y < mBounds.height ; y++)
-  {
-    PRBool lineEmpty = PR_TRUE;
-
-    for (PRInt32 x = 0 ; x < mBounds.width ; x++)
-    {
-      if (*pPixel)
-      {
-        *pPixel = 255;
-        lineEmpty = PR_FALSE;
-
-        if (x < minX) minX = x;
-        if (x > maxX) maxX = x;
-      }
-
-      pPixel++;
-    }
-
-    if (!lineEmpty)
-    {
-      if (y < minY) minY = y;
-      if (y > maxY) maxY = y;
-    }
-  }
-
-
-  HRGN hrgnOpacityMask = ::CreateRectRgn(0, 0, 0, 0);
-  
-  if (maxY >= minY)
-  {
-    HRGN hrgnRectBlock = ::CreateRectRgn(0, 0, 0, 0);
-
-    for (PRInt32 seqY1 = minY ; seqY1 <= maxY ; seqY1++)
-    {
-      PRUint8* pRow = mAlphaMask + seqY1 * mBounds.width;
-
-      for (PRInt32 seqX1 = minX ; seqX1 <= maxX ; seqX1++)
-      {
-        if (pRow [seqX1] == 255)      // Found first opaque pixel of possibly larger block
-        {
-          // Get max sequence of continuous opaque pixels on it's right side.
-          PRInt32 seqX2 = seqX1;
-          PRInt32 sx, sy;
-
-          for (sx = seqX1 ; sx <= maxX && pRow [sx] == 255 ; sx++)
-          {
-            seqX2 = sx;
-            pRow [seqX2] = 1;         // Mark pixel as already handled
-          }
-
-          // Look if found pixel sequence can be combined with exactly same one on next line
-          PRInt32 seqY2 = seqY1;
-          PRUint8* pNextRow = pRow + mBounds.width;
-
-          for (sy = seqY1 + 1 ; sy <= maxY ; sy++)
-          {
-            // Check if line starts and ends right below the original pixel sequence
-            if (pNextRow [seqX1] != 255 ||
-                pNextRow [seqX2] != 255 ||
-                (seqX1 > minX && pNextRow [seqX1 - 1]) ||
-                (seqX2 < maxX && pNextRow [seqX2 + 1]))
-              break;
-
-            // Check if line is continuously opaque and thus exactly same to previous sequence
-            PRBool sequenceContinuous = PR_TRUE;
-
-            for (sx = seqX1 + 1 ; sx < seqX2 ; sx++)
-              if (pNextRow [sx] != 255)
-              {
-                  sequenceContinuous = PR_FALSE;
-                  break;
-              }
-
-            if (!sequenceContinuous)
-              break;
-            
-            seqY2 = sy;                                      // Include this sequence in block
-            memset(pNextRow + seqX1, 1, seqX2 - seqX1 + 1);  // and mark it as handled
-
-            pNextRow += mBounds.width;
-          }
-
-
-          // Continuous opaque region of maximal size found
-          ::SetRectRgn(hrgnRectBlock, seqX1, seqY1, seqX2 + 1, seqY2 + 1);
-          ::CombineRgn(hrgnOpacityMask, hrgnRectBlock, hrgnOpacityMask, RGN_OR);
-
-
-          if (seqX1 == minX && seqX2 == maxX)    // Whole row opaque
-          {
-            seqY1 = seqY2;    // Next sequences can start only below this block
-            break;
-          } else
-            seqX1 = seqX2;    // Next sequence on same row can only be on right side of this block
-        }
-      }
-    }
-
-    ::DeleteObject(hrgnRectBlock);
-  }
-
-  HWND hWnd = GetTopLevelHWND(mWnd, PR_TRUE);
-  nsWindow* topWindow = GetNSWindowPtr(hWnd);
-
-  topWindow->w9x.mPerformingSetWindowRgn = PR_TRUE;
-  ::SetWindowRgn(hWnd, hrgnOpacityMask, TRUE);   // Now system owns this region
-  topWindow->w9x.mPerformingSetWindowRgn = PR_FALSE;
-}
-
 #endif
diff --git a/widget/src/windows/nsWindow.h b/widget/src/windows/nsWindow.h
index bd73346694e3ee2a24febee21531941e23a39999..e9d910d873fa862accbcd05954a4508d92f39ef8 100644
--- a/widget/src/windows/nsWindow.h
+++ b/widget/src/windows/nsWindow.h
@@ -314,14 +314,14 @@ protected:
   BOOL                    OnIMECompositionFull();
   BOOL                    OnIMEEndComposition();
   BOOL                    OnIMENotify(WPARAM  aIMN, LPARAM aData, LRESULT *oResult);
-  BOOL                    OnIMERequest(WPARAM  aIMR, LPARAM aData, LRESULT *oResult, PRBool aUseUnicode);
+  BOOL                    OnIMERequest(WPARAM  aIMR, LPARAM aData, LRESULT *oResult);
   BOOL                    OnIMESelect(BOOL  aSelected, WORD aLangID);
   BOOL                    OnIMESetContext(BOOL aActive, LPARAM& aISC);
   BOOL                    OnIMEStartComposition();
-  BOOL                    OnIMEReconvert(LPARAM aData, LRESULT *oResult, PRBool aUseUnicode);
-  BOOL                    OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult, PRBool aUseUnicode);
+  BOOL                    OnIMEReconvert(LPARAM aData, LRESULT *oResult);
+  BOOL                    OnIMEQueryCharPosition(LPARAM aData, LRESULT *oResult);
 
-  void                    GetCompositionString(HIMC aHIMC, DWORD aIndex, nsString* aStrUnicode, nsCString* aStrAnsi);
+  void                    GetCompositionString(HIMC aHIMC, DWORD aIndex, nsString* aStrUnicode);
   void                    ResolveIMECaretPos(nsWindow* aClient,
                                              nsRect&   aEventResult,
                                              nsRect&   aResult);
@@ -397,21 +397,10 @@ protected:
   HBRUSH        mBrush;
 
 #ifdef MOZ_XUL
-  union
-  {
-    // Windows 2000 and newer use layered windows to support full 256 level alpha translucency
-    struct
-    {
-      HDC       mMemoryDC;
-      HBITMAP   mMemoryBitmap;
-      PRUint8*  mMemoryBits;
-    } w2k;
-    // Windows NT and 9x use complex shaped window regions to support 1-bit transparency masks
-    struct
-    {
-      PRPackedBool mPerformingSetWindowRgn;
-    } w9x;
-  };
+  // use layered windows to support full 256 level alpha translucency
+  HDC           mMemoryDC;
+  HBITMAP       mMemoryBitmap;
+  PRUint8*      mMemoryBits;
   PRUint8*      mAlphaMask;
   PRPackedBool  mIsTranslucent;
   PRPackedBool  mIsTopTranslucent;     // Topmost window itself or any of it's child windows has tranlucency enabled
@@ -448,7 +437,6 @@ protected:
   // To enable/disable IME
   HIMC          mOldIMC;
 
-  static UINT   gCurrentKeyboardCP;
   static HKL    gKeyboardLayout;
   static PRBool gSwitchKeyboardLayout;
 
@@ -477,12 +465,7 @@ protected:
   static BOOL   sIsPopupClassRegistered;
 
   HDWP mDeferredPositioner;
-  static UINT   uMSH_MOUSEWHEEL;
-
-  // IME special message
-  static UINT   uWM_MSIME_RECONVERT; // reconvert message for MSIME
   static UINT   uWM_MSIME_MOUSE;     // mouse message for MSIME
-  static UINT   uWM_ATOK_RECONVERT;  // reconvert message for ATOK
 
   // Heap dump
   static UINT   uWM_HEAP_DUMP;       // Dump heap to a file