Merge m-c to m-i.
authorMs2ger <ms2ger@gmail.com>
Thu, 18 Aug 2011 22:01:33 +0200
changeset 75503 ec4956f17090631ec826f27e3da5ac6956717083
parent 75475 932c8414512f32c41e0d3eb9c9e483658ed7ab27 (current diff)
parent 75502 5691363f380fe07517235de738216fb40837fb1b (diff)
child 75504 c51feb247cc4127b01b62a331bd6f370d85fe638
push id21031
push usermak77@bonardo.net
push dateFri, 19 Aug 2011 09:40:40 +0000
treeherdermozilla-central@1881f9b5f8b5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone9.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge m-c to m-i.
docshell/base/nsIGlobalHistory3.idl
modules/libreg/src/mmapio.c
modules/libreg/src/mmapio.h
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -876,17 +876,17 @@ pref("browser.privatebrowsing.autostart"
 // Whether we should skip prompting before starting the private browsing mode
 pref("browser.privatebrowsing.dont_prompt_on_enter", false);
 
 // Don't try to alter this pref, it'll be reset the next time you use the
 // bookmarking dialog
 pref("browser.bookmarks.editDialog.firstEditField", "namePicker");
 
 // base url for the wifi geolocation network provider
-pref("geo.wifi.uri", "https://www.google.com/loc/json");
+pref("geo.wifi.uri", "https://maps.googleapis.com/maps/api/browserlocation/json");
 pref("geo.wifi.protocol", 0);
 
 // Whether to use a panel that looks like an OS X sheet for customization
 #ifdef XP_MACOSX
 pref("toolbar.customization.usesheet", true);
 #else
 pref("toolbar.customization.usesheet", false);
 #endif
--- a/caps/src/nsScriptSecurityManager.cpp
+++ b/caps/src/nsScriptSecurityManager.cpp
@@ -1732,17 +1732,18 @@ nsScriptSecurityManager::CheckFunctionAc
     nsIPrincipal* subject =
         GetFunctionObjectPrincipal(aCx, (JSObject *)aFunObj, nsnull, &rv);
 
     // If subject is null, get a principal from the function object's scope.
     if (NS_SUCCEEDED(rv) && !subject)
     {
 #ifdef DEBUG
         {
-            JSFunction *fun = GET_FUNCTION_PRIVATE(cx, (JSObject *)aFunObj);
+            JS_ASSERT(JS_ObjectIsFunction(aCx, (JSObject *)aFunObj));
+            JSFunction *fun = (JSFunction *)JS_GetPrivate(aCx, (JSObject *)aFunObj);
             JSScript *script = JS_GetFunctionScript(aCx, fun);
 
             NS_ASSERTION(!script, "Null principal for non-native function!");
         }
 #endif
 
         subject = doGetObjectPrincipal((JSObject*)aFunObj);
     }
@@ -2213,17 +2214,17 @@ nsScriptSecurityManager::GetFunctionObje
     {
         // Protect against pseudo-functions (like SJOWs).
         nsIPrincipal *result = doGetObjectPrincipal(obj);
         if (!result)
             *rv = NS_ERROR_FAILURE;
         return result;
     }
 
-    JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj);
+    JSFunction *fun = (JSFunction *)JS_GetPrivate(cx, obj);
     JSScript *script = JS_GetFunctionScript(cx, fun);
 
     if (!script)
     {
         // A native function: skip it in order to find its scripted caller.
         return nsnull;
     }
 
@@ -2279,17 +2280,17 @@ nsScriptSecurityManager::GetFramePrincip
         return GetScriptPrincipal(cx, script, rv);
     }
 
     nsIPrincipal* result = GetFunctionObjectPrincipal(cx, obj, fp, rv);
 
 #ifdef DEBUG
     if (NS_SUCCEEDED(*rv) && !result)
     {
-        JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj);
+        JSFunction *fun = (JSFunction *)JS_GetPrivate(cx, obj);
         JSScript *script = JS_GetFunctionScript(cx, fun);
 
         NS_ASSERTION(!script, "Null principal for non-native function!");
     }
 #endif
 
     return result;
 }
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -218,17 +218,16 @@ MOZ_POST_DSO_LIB_COMMAND = @MOZ_POST_DSO
 MOZ_POST_PROGRAM_COMMAND = @MOZ_POST_PROGRAM_COMMAND@
 
 MOZ_BUILD_ROOT             = @MOZ_BUILD_ROOT@
 
 MOZ_XUL                    = @MOZ_XUL@
 MOZ_RDF                    = @MOZ_RDF@
 
 NECKO_PROTOCOLS = @NECKO_PROTOCOLS@
-NECKO_DISK_CACHE = @NECKO_DISK_CACHE@
 NECKO_COOKIES = @NECKO_COOKIES@
 NECKO_WIFI = @NECKO_WIFI@
 MOZ_AUTH_EXTENSION = @MOZ_AUTH_EXTENSION@
 
 MOZ_NATIVE_HUNSPELL = @SYSTEM_HUNSPELL@
 MOZ_HUNSPELL_LIBS = @MOZ_HUNSPELL_LIBS@
 MOZ_HUNSPELL_CFLAGS = @MOZ_HUNSPELL_CFLAGS@
 
--- a/configure.in
+++ b/configure.in
@@ -3583,63 +3583,16 @@ then
 				CFLAGS="$CFLAGS -mt" 
 				CXXFLAGS="$CXXFLAGS -mt" 
 			fi
 			;;
 	esac
     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
 fi
 
-dnl ========================================================
-dnl See if mmap sees writes
-dnl For cross compiling, just define it as no, which is a safe default
-dnl ========================================================
-AC_MSG_CHECKING(whether mmap() sees write()s)
-
-changequote(,)
-mmap_test_prog='
-    #include <stdlib.h>
-    #include <unistd.h>
-    #include <sys/mman.h>
-    #include <sys/types.h>
-    #include <sys/stat.h>
-    #include <fcntl.h>
-
-    char fname[] = "conftest.file";
-    char zbuff[1024]; /* Fractional page is probably worst case */
-
-    int main() {
-	char *map;
-	int fd;
-	int i;
-	unlink(fname);
-	fd = open(fname, O_RDWR | O_CREAT, 0660);
-	if(fd<0) return 1;
-	unlink(fname);
-	write(fd, zbuff, sizeof(zbuff));
-	lseek(fd, 0, SEEK_SET);
-	map = (char*)mmap(0, sizeof(zbuff), PROT_READ, MAP_SHARED, fd, 0);
-	if(map==(char*)-1) return 2;
-	for(i=0; fname[i]; i++) {
-	    int rc = write(fd, &fname[i], 1);
-	    if(map[i]!=fname[i]) return 4;
-	}
-	return 0;
-    }
-'
-changequote([,])
-
-AC_TRY_RUN($mmap_test_prog , result="yes", result="no", result="yes")
-
-AC_MSG_RESULT("$result")
-
-if test "$result" = "no"; then
-    AC_DEFINE(MMAP_MISSES_WRITES)
-fi
-
 
 dnl Checks for library functions.
 dnl ========================================================
 AC_PROG_GCC_TRADITIONAL
 AC_FUNC_MEMCMP
 AC_CHECK_FUNCS(random strerror lchown fchmod snprintf statvfs memmove rint stat64 lstat64 truncate64 statvfs64 setbuf isatty)
 AC_CHECK_FUNCS(flockfile getpagesize)
 AC_CHECK_FUNCS(localtime_r strtok_r)
@@ -4773,17 +4726,16 @@ MOZ_XTF=1
 MOZ_XUL=1
 MOZ_ZIPWRITER=1
 NS_PRINTING=1
 MOZ_PDF_PRINTING=
 MOZ_DISABLE_DOMCRYPTO=
 NSS_DISABLE_DBM=
 NECKO_WIFI=1
 NECKO_COOKIES=1
-NECKO_DISK_CACHE=1
 NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciwyg"
 USE_ARM_KUSER=
 BUILD_CTYPES=1
 MOZ_USE_NATIVE_POPUP_WINDOWS=
 
 
 case "${target}" in
 *android*|*darwin*)
@@ -5189,30 +5141,31 @@ incorrect])
                       MOZ_ENABLE_QTNETWORK=)
 
     if test "$MOZ_ENABLE_QTNETWORK"; then
       MOZ_ENABLE_QTNETWORK=1
       AC_DEFINE(MOZ_ENABLE_QTNETWORK)
     fi
 
     MOZ_ENABLE_QTMOBILITY=
-    PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback,
+    PKG_CHECK_MODULES(_QTMOBILITY, QtSensors QtFeedback QtLocation,
                       MOZ_ENABLE_QTMOBILITY=1,
                       MOZ_ENABLE_QTMOBILITY=)
     if test "$MOZ_ENABLE_QTMOBILITY"; then
        MOZ_ENABLE_QTMOBILITY=1
        MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS $_QTMOBILITY_CFLAGS"
        MOZ_QT_LIBS="$MOZ_QT_LIBS $_QTMOBILITY_LIBS"
     else
-       AC_CHECK_LIB(QtSensors QtFeedback, main, [
+       AC_CHECK_LIB(QtSensors QtFeedback QtLocation, main, [
           MOZ_ENABLE_QTMOBILITY=1
           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtMobility"
           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtSensors"
           MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtFeedback"
-          MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback"
+          MOZ_QT_CFLAGS="$MOZ_QT_CFLAGS -I/usr/include/qt4/QtLocation"
+          MOZ_QT_LIBS="$MOZ_QT_LIBS -lQtSensors -lQtFeedback -lQtLocation"
        ])
     fi
     if test "$MOZ_ENABLE_QTMOBILITY"; then
        AC_DEFINE(MOZ_ENABLE_QTMOBILITY)
     fi
 fi
 
 AC_SUBST(GTK_CONFIG)
@@ -8760,29 +8713,16 @@ done],
 dnl Remove dupes
 NECKO_PROTOCOLS=`${PERL} ${srcdir}/build/unix/uniq.pl ${NECKO_PROTOCOLS}`
 AC_SUBST(NECKO_PROTOCOLS)
 for p in $NECKO_PROTOCOLS; do
     AC_DEFINE_UNQUOTED(NECKO_PROTOCOL_$p)
 done
 
 dnl
-dnl option to disable necko's disk cache
-dnl
-MOZ_ARG_DISABLE_BOOL(necko-disk-cache,
-[  --disable-necko-disk-cache
-                          Disable necko disk cache],
-    NECKO_DISK_CACHE=,
-    NECKO_DISK_CACHE=1)
-AC_SUBST(NECKO_DISK_CACHE)
-if test "$NECKO_DISK_CACHE"; then
-    AC_DEFINE(NECKO_DISK_CACHE)
-fi
-
-dnl
 dnl option to disable necko's wifi scanner
 dnl
 MOZ_ARG_DISABLE_BOOL(necko-wifi,
 [  --disable-necko-wifi    Disable necko wifi scanner],
     NECKO_WIFI=,
     NECKO_WIFI=1)
 
 if test "$OS_ARCH" = "OS2"; then
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -1054,18 +1054,19 @@ nsINode::AddEventListener(const nsAStrin
   if (!aWantsUntrusted &&
       (aOptionalArgc < 2 &&
        !nsContentUtils::IsChromeDoc(GetOwnerDoc()))) {
     aWantsUntrusted = PR_TRUE;
   }
 
   nsEventListenerManager* listener_manager = GetListenerManager(PR_TRUE);
   NS_ENSURE_STATE(listener_manager);
-  return listener_manager->AddEventListener(aType, aListener, aUseCapture,
-                                            aWantsUntrusted);
+  listener_manager->AddEventListener(aType, aListener, aUseCapture,
+                                     aWantsUntrusted);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsINode::RemoveEventListener(const nsAString& aType,
                              nsIDOMEventListener* aListener,
                              PRBool aUseCapture)
 {
   nsEventListenerManager* elm = GetListenerManager(PR_FALSE);
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -1868,16 +1868,17 @@ GK_ATOM(scrollbar_start_backward, "scrol
 GK_ATOM(scrollbar_start_forward, "scrollbar-start-forward")
 GK_ATOM(scrollbar_end_backward, "scrollbar-end-backward")
 GK_ATOM(scrollbar_end_forward, "scrollbar-end-forward")
 GK_ATOM(scrollbar_thumb_proportional, "scrollbar-thumb-proportional")
 GK_ATOM(images_in_menus, "images-in-menus")
 GK_ATOM(images_in_buttons, "images-in-buttons")
 GK_ATOM(windows_default_theme, "windows-default-theme")
 GK_ATOM(mac_graphite_theme, "mac-graphite-theme")
+GK_ATOM(mac_lion_theme, "mac-lion-theme")
 GK_ATOM(windows_compositor, "windows-compositor")
 GK_ATOM(touch_enabled, "touch-enabled")
 GK_ATOM(maemo_classic, "maemo-classic")
 GK_ATOM(menubar_drag, "menubar-drag")
 
 // windows theme selector metrics
 GK_ATOM(windows_classic, "windows-classic")
 GK_ATOM(windows_theme_aero, "windows-theme-aero")
@@ -1893,16 +1894,17 @@ GK_ATOM(_moz_scrollbar_start_backward, "
 GK_ATOM(_moz_scrollbar_start_forward, "-moz-scrollbar-start-forward")
 GK_ATOM(_moz_scrollbar_end_backward, "-moz-scrollbar-end-backward")
 GK_ATOM(_moz_scrollbar_end_forward, "-moz-scrollbar-end-forward")
 GK_ATOM(_moz_scrollbar_thumb_proportional, "-moz-scrollbar-thumb-proportional")
 GK_ATOM(_moz_images_in_menus, "-moz-images-in-menus")
 GK_ATOM(_moz_images_in_buttons, "-moz-images-in-buttons")
 GK_ATOM(_moz_windows_default_theme, "-moz-windows-default-theme")
 GK_ATOM(_moz_mac_graphite_theme, "-moz-mac-graphite-theme")
+GK_ATOM(_moz_mac_lion_theme, "-moz-mac-lion-theme")
 GK_ATOM(_moz_windows_compositor, "-moz-windows-compositor")
 GK_ATOM(_moz_windows_classic, "-moz-windows-classic")
 GK_ATOM(_moz_windows_theme, "-moz-windows-theme")
 GK_ATOM(_moz_touch_enabled, "-moz-touch-enabled")
 GK_ATOM(_moz_maemo_classic, "-moz-maemo-classic")
 GK_ATOM(_moz_menubar_drag, "-moz-menubar-drag")
 GK_ATOM(_moz_device_pixel_ratio, "-moz-device-pixel-ratio")
 GK_ATOM(_moz_device_orientation, "-moz-device-orientation")
--- a/content/base/test/test_copypaste.html
+++ b/content/base/test/test_copypaste.html
@@ -48,18 +48,18 @@ function testCopyPaste () {
 
   var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]
                             .getService(Components.interfaces.nsIClipboard);
 
   var textarea = document.getElementById('input');
 
   function copySelectionToClipboard() {
     documentViewer.copySelection();
-    is(clipboard.hasDataMatchingFlavors(["text/unicode"], 1,1), true);
-    is(clipboard.hasDataMatchingFlavors(["text/html"], 1,1), true);
+    ok(clipboard.hasDataMatchingFlavors(["text/unicode"], 1,1), "check text/unicode");
+    ok(clipboard.hasDataMatchingFlavors(["text/html"], 1,1), "check text/html");
   }
   function copyToClipboard(node) {
     textarea.blur();
     clipboard.emptyClipboard(1);
     var sel = window.getSelection();
     sel.removeAllRanges();
     var r = document.createRange();
     r.selectNode(node);
--- a/content/events/src/nsDOMEventTargetHelper.cpp
+++ b/content/events/src/nsDOMEventTargetHelper.cpp
@@ -121,17 +121,18 @@ nsDOMEventTargetHelper::AddEventListener
     NS_ENSURE_SUCCESS(rv, rv);
     nsCOMPtr<nsIDocument> doc =
       nsContentUtils::GetDocumentFromScriptContext(context);
     aWantsUntrusted = doc && !nsContentUtils::IsChromeDoc(doc);
   }
 
   nsEventListenerManager* elm = GetListenerManager(PR_TRUE);
   NS_ENSURE_STATE(elm);
-  return elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted);
+  elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMEventTargetHelper::DispatchEvent(nsIDOMEvent* aEvent, PRBool* aRetVal)
 {
   nsEventStatus status = nsEventStatus_eIgnore;
   nsresult rv =
     nsEventDispatcher::DispatchDOMEvent(this, nsnull, aEvent, nsnull, &status);
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -204,34 +204,37 @@ nsEventListenerManager::GetInnerWindowFo
   if (window) {
     NS_ASSERTION(window->IsInnerWindow(), "Target should not be an outer window");
     return window;
   }
 
   return nsnull;
 }
 
-nsresult
+void
 nsEventListenerManager::AddEventListener(nsIDOMEventListener *aListener,
                                          PRUint32 aType,
                                          nsIAtom* aTypeAtom,
                                          PRInt32 aFlags)
 {
-  NS_ENSURE_TRUE(aListener, NS_ERROR_FAILURE);
-  NS_ENSURE_TRUE(aType, NS_ERROR_FAILURE);
+  NS_ABORT_IF_FALSE(aType && aTypeAtom, "Missing type");
+
+  if (!aListener) {
+    return;
+  }
 
   nsRefPtr<nsIDOMEventListener> kungFuDeathGrip = aListener;
 
   nsListenerStruct* ls;
   PRUint32 count = mListeners.Length();
   for (PRUint32 i = 0; i < count; i++) {
     ls = &mListeners.ElementAt(i);
     if (ls->mListener == aListener && ls->mFlags == aFlags &&
         EVENT_TYPE_EQUALS(ls, aType, aTypeAtom)) {
-      return NS_OK;
+      return;
     }
   }
 
   mNoListenerForEvent = NS_EVENT_TYPE_NULL;
   mNoListenerForEventAtom = nsnull;
 
   ls = mListeners.AppendElement();
   ls->mListener = aListener;
@@ -286,18 +289,16 @@ nsEventListenerManager::AddEventListener
               aTypeAtom == nsGkAtoms::ontouchenter ||
               aTypeAtom == nsGkAtoms::ontouchleave ||
               aTypeAtom == nsGkAtoms::ontouchcancel)) {
     mMayHaveTouchEventListener = PR_TRUE;
     nsPIDOMWindow* window = GetInnerWindowForTarget();
     if (window)
       window->SetHasTouchEventListeners();
   }
-
-  return NS_OK;
 }
 
 void
 nsEventListenerManager::RemoveEventListener(nsIDOMEventListener *aListener, 
                                             PRUint32 aType,
                                             nsIAtom* aUserType,
                                             PRInt32 aFlags)
 {
@@ -329,24 +330,24 @@ ListenerCanHandle(nsListenerStruct* aLs,
   // This is slightly different from EVENT_TYPE_EQUALS in that it returns
   // true even when aEvent->message == NS_USER_DEFINED_EVENT and
   // aLs=>mEventType != NS_USER_DEFINED_EVENT as long as the atoms are the same
   return aEvent->message == NS_USER_DEFINED_EVENT ?
     (aLs->mTypeAtom == aEvent->userType) :
     (aLs->mEventType == aEvent->message);
 }
 
-nsresult
+void
 nsEventListenerManager::AddEventListenerByType(nsIDOMEventListener *aListener, 
                                                const nsAString& aType,
                                                PRInt32 aFlags)
 {
   nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aType);
   PRUint32 type = nsContentUtils::GetEventId(atom);
-  return AddEventListener(aListener, type, atom, aFlags);
+  AddEventListener(aListener, type, atom, aFlags);
 }
 
 void
 nsEventListenerManager::RemoveEventListenerByType(nsIDOMEventListener *aListener, 
                                                   const nsAString& aType,
                                                   PRInt32 aFlags)
 {
   nsCOMPtr<nsIAtom> atom = do_GetAtom(NS_LITERAL_STRING("on") + aType);
@@ -938,18 +939,17 @@ nsEventListenerManager::HandleEventInter
 
 void
 nsEventListenerManager::Disconnect()
 {
   mTarget = nsnull;
   RemoveAllListeners();
 }
 
-// nsIDOMEventTarget interface
-nsresult
+void
 nsEventListenerManager::AddEventListener(const nsAString& aType,
                                          nsIDOMEventListener* aListener,
                                          PRBool aUseCapture,
                                          PRBool aWantsUntrusted)
 {
   PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
 
   if (aWantsUntrusted) {
--- a/content/events/src/nsEventListenerManager.h
+++ b/content/events/src/nsEventListenerManager.h
@@ -79,31 +79,31 @@ class nsEventListenerManager
 public:
   nsEventListenerManager(nsISupports* aTarget);
   virtual ~nsEventListenerManager();
 
   NS_INLINE_DECL_REFCOUNTING(nsEventListenerManager)
 
   NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(nsEventListenerManager)
 
-  nsresult AddEventListener(const nsAString& aType,
-                            nsIDOMEventListener* aListener,
-                            PRBool aUseCapture,
-                            PRBool aWantsUntrusted);
+  void AddEventListener(const nsAString& aType,
+                        nsIDOMEventListener* aListener,
+                        PRBool aUseCapture,
+                        PRBool aWantsUntrusted);
   void RemoveEventListener(const nsAString& aType,
                            nsIDOMEventListener* aListener,
                            PRBool aUseCapture);
 
   /**
   * Sets events listeners of all types. 
   * @param an event listener
   */
-  nsresult AddEventListenerByType(nsIDOMEventListener *aListener,
-                                  const nsAString& type,
-                                  PRInt32 aFlags);
+  void AddEventListenerByType(nsIDOMEventListener *aListener,
+                              const nsAString& type,
+                              PRInt32 aFlags);
   void RemoveEventListenerByType(nsIDOMEventListener *aListener,
                                  const nsAString& type,
                                  PRInt32 aFlags);
   nsresult AddScriptEventListener(nsIAtom *aName,
                                   const nsAString& aFunc,
                                   PRUint32 aLanguage,
                                   PRBool aDeferCompilation,
                                   PRBool aPermitUntrustedEvents);
@@ -205,20 +205,20 @@ protected:
                                        nsListenerStruct *aListenerStruct,
                                        nsISupports* aCurrentTarget,
                                        PRBool aNeedsCxPush);
   nsListenerStruct* FindJSEventListener(PRUint32 aEventType, nsIAtom* aTypeAtom);
   nsresult SetJSEventListener(nsIScriptContext *aContext,
                               void *aScopeGlobal,
                               nsIAtom* aName, PRBool aIsString,
                               PRBool aPermitUntrustedEvents);
-  nsresult AddEventListener(nsIDOMEventListener *aListener, 
-                            PRUint32 aType,
-                            nsIAtom* aTypeAtom,
-                            PRInt32 aFlags);
+  void AddEventListener(nsIDOMEventListener *aListener, 
+                        PRUint32 aType,
+                        nsIAtom* aTypeAtom,
+                        PRInt32 aFlags);
   void RemoveEventListener(nsIDOMEventListener *aListener,
                            PRUint32 aType,
                            nsIAtom* aUserType,
                            PRInt32 aFlags);
   void RemoveAllListeners();
   const EventTypeData* GetTypeDataForIID(const nsIID& aIID);
   const EventTypeData* GetTypeDataForEventName(nsIAtom* aName);
   nsPIDOMWindow* GetInnerWindowForTarget();
--- a/content/events/src/nsEventListenerService.cpp
+++ b/content/events/src/nsEventListenerService.cpp
@@ -275,17 +275,18 @@ nsEventListenerService::AddSystemEventLi
 
   nsEventListenerManager* manager = aTarget->GetListenerManager(PR_TRUE);
   NS_ENSURE_STATE(manager);
 
   PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE |
                                 NS_EVENT_FLAG_SYSTEM_EVENT :
                                 NS_EVENT_FLAG_BUBBLE |
                                 NS_EVENT_FLAG_SYSTEM_EVENT;
-  return manager->AddEventListenerByType(aListener, aType, flags);
+  manager->AddEventListenerByType(aListener, aType, flags);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsEventListenerService::RemoveSystemEventListener(nsIDOMEventTarget *aTarget,
                                                   const nsAString& aType,
                                                   nsIDOMEventListener* aListener,
                                                   PRBool aUseCapture)
 {
--- a/content/events/test/Makefile.in
+++ b/content/events/test/Makefile.in
@@ -102,16 +102,18 @@ include $(topsrcdir)/config/rules.mk
 		test_bug648573.html \
 		test_bug615597.html \
 		test_bug656379-1.html \
 		test_bug656379-2.html \
 		test_bug656954.html \
 		test_bug662678.html \
 		test_bug667919-1.html \
 		test_bug667919-2.html \
+		test_bug667612.html \
+		empty.js \
 		$(NULL)
 
 #bug 585630
 ifneq (mobile,$(MOZ_BUILD_APP))
 _TEST_FILES += \
 		test_dragstart.html \
 		$(NULL)
 endif
new file mode 100644
new file mode 100644
--- /dev/null
+++ b/content/events/test/test_bug667612.html
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=667612
+-->
+<head>
+  <title>Test for Bug 667612</title>
+  <script type="text/javascript" src="/MochiKit/packed.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=667612">Mozilla Bug 667612</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+xhr = new XMLHttpRequest;
+w = new Worker("empty.js");
+window.addEventListener("load", null, false);
+document.addEventListener("load", null, false);
+document.body.addEventListener("load", null, false);
+xhr.addEventListener("load", null, false);
+w.addEventListener("load", null, false);
+window.addEventListener("load", undefined, false);
+document.addEventListener("load", undefined, false);
+document.body.addEventListener("load", undefined, false);
+xhr.addEventListener("load", undefined, false);
+w.addEventListener("load", undefined, false);
+
+ok(true, "didn't throw");
+
+</script>
+</pre>
+</body>
+</html>
--- a/docshell/base/Makefile.in
+++ b/docshell/base/Makefile.in
@@ -61,17 +61,16 @@ XPIDLSRCS = \
   nsCDefaultURIFixup.idl \
   nsIDocShell.idl \
   nsIDocShellLoadInfo.idl \
   nsIDocShellTreeItem.idl \
   nsIDocShellTreeNode.idl \
   nsIDocShellTreeOwner.idl \
   nsIDocShellHistory.idl \
   nsIGlobalHistory2.idl \
-  nsIGlobalHistory3.idl \
   nsIMarkupDocumentViewer.idl \
   nsIScrollable.idl \
   nsITextScroll.idl \
   nsIWebNavigation.idl \
   nsIWebNavigationInfo.idl \
   nsIContentViewer.idl \
   nsIContentViewerEdit.idl \
   nsIContentViewerFile.idl \
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -192,17 +192,16 @@
 #include "nsIJARChannel.h"
 
 #include "prlog.h"
 #include "prmem.h"
 
 #include "nsISelectionDisplay.h"
 
 #include "nsIGlobalHistory2.h"
-#include "nsIGlobalHistory3.h"
 
 #ifdef DEBUG_DOCSHELL_FOCUS
 #include "nsEventStateManager.h"
 #endif
 
 #include "nsIFrame.h"
 
 // for embedding
deleted file mode 100644
--- a/docshell/base/nsIGlobalHistory3.idl
+++ /dev/null
@@ -1,103 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is the Mozilla gecko engine.
- *
- * The Initial Developer of the Original Code is
- * Google Inc.
- * Portions created by the Initial Developer are Copyright (C) 2006
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Brett Wilson <brettw@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsISupports.idl"
-#include "nsIGlobalHistory2.idl"
-interface nsIChannel;
-
-%{C++
-
-// This is NOT part of the interface! It could change.
-#define NS_GECKO_FLAG_NEEDS_VERTICAL_SCROLLBAR (1 << 0)
-
-%}
-
-/**
- * Provides information about global history to gecko, extending GlobalHistory2
- */
-[scriptable, uuid(24306852-c60e-49c3-a455-90f6747118ba)]
-interface nsIGlobalHistory3 : nsIGlobalHistory2
-{
-  /**
-   * Notifies the history system that the page loading via aOldChannel
-   * redirected to aNewChannel. Implementations should generally add the URI for
-   * aOldChannel to history for link coloring, but are advised not to expose it
-   * in the history user interface. This function is preferred if
-   * nsIGlobalHistory3 is available. Otherwise, nsIGlobalHistory2.addURI should
-   * be called with redirect=true.
-   *
-   * This function is preferred to nsIGlobalHistory2.addURI because it provides
-   * more information (including the redirect destination, channels involved,
-   * and redirect flags) to the history implementation.
-   *
-   * For implementors of nsIGlobalHistory3: The history implementation is
-   * responsible for sending NS_LINK_VISITED_EVENT_TOPIC to observers for
-   * redirect pages. This notification must be sent for history consumers for
-   * all non-redirect pages.
-   *
-   * @param aToplevel whether the URI is loaded in a top-level window.  If
-   *        false, the load is in a subframe.
-   *
-   * The other params to this function are the same as those for
-   * nsIChannelEventSink::OnChannelRedirect.
-   *
-   * Note: Implementors who wish to implement this interface but rely on
-   * nsIGlobalHistory2.addURI for redirect processing may throw
-   * NS_ERROR_NOT_IMPLEMENTED from this method.  If they do so, then callers
-   * must call nsIGlobalHistory2.addURI upon getting the
-   * NS_ERROR_NOT_IMPLEMENTED result.
-   */
-  void addDocumentRedirect(in nsIChannel aOldChannel,
-                           in nsIChannel aNewChannel,
-                           in PRInt32 aFlags,
-                           in boolean aTopLevel);
-
-  /**
-   * Get the Gecko flags for this URI. These flags are used by Gecko as hints
-   * to optimize page loading. Not all histories have them; this need not be
-   * supported (just return NS_ERROR_NOT_IMPLEMENTED. These flags are opaque
-   * and should not be interpreted by the history engine.
-   */
-  unsigned long getURIGeckoFlags(in nsIURI aURI);
-
-  /**
-   * Set the Gecko flags for this URI. May fail if the history entry
-   * doesn't have any flags or if there is no entry for the URI.
-   */
-  void setURIGeckoFlags(in nsIURI aURI, in unsigned long aFlags);
-};
--- a/docshell/test/chrome/docshell_helpers.js
+++ b/docshell/test/chrome/docshell_helpers.js
@@ -318,18 +318,30 @@ function finish() {
   // enableBFCache(), then restore it now.
   if (typeof(gOrigMaxTotalViewers) != "undefined") {
     SpecialPowers.setIntPref("browser.sessionhistory.max_total_viewers",
       gOrigMaxTotalViewers);
   }
 
   // Close the test window and signal the framework that the test is done.
   let opener = window.opener;
+  let SimpleTest = opener.wrappedJSObject.SimpleTest;
+
+  // Wait for the window to be closed before finishing the test
+  let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher);
+  ww.registerNotification(function(subject, topic, data) {
+    if (topic == "domwindowclosed") {
+      ww.unregisterNotification(arguments.callee);
+      SimpleTest.waitForFocus(function() {
+        SimpleTest.finish();
+      }, opener);
+    }
+  });
+
   window.close();
-  opener.wrappedJSObject.SimpleTest.finish();
 }
 
 /**
  * Helper function which waits until another function returns true, or until a 
  * timeout occurs, and then notifies a callback.
  *
  * Parameters:
  *
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -7371,18 +7371,18 @@ nsGlobalWindow::AddEventListener(const n
 
   if (!aWantsUntrusted &&
       (aOptionalArgc < 2 && !nsContentUtils::IsChromeDoc(mDoc))) {
     aWantsUntrusted = PR_TRUE;
   }
 
   nsEventListenerManager* manager = GetListenerManager(PR_TRUE);
   NS_ENSURE_STATE(manager);
-  return manager->AddEventListener(aType, aListener, aUseCapture,
-                                   aWantsUntrusted);
+  manager->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted);
+  return NS_OK;
 }
 
 nsEventListenerManager*
 nsGlobalWindow::GetListenerManager(PRBool aCreateIfNotFound)
 {
   FORWARD_TO_INNER_CREATE(GetListenerManager, (aCreateIfNotFound), nsnull);
 
   if (!mListenerManager && aCreateIfNotFound) {
--- a/dom/base/nsWindowRoot.cpp
+++ b/dom/base/nsWindowRoot.cpp
@@ -141,17 +141,18 @@ nsWindowRoot::AddEventListener(const nsA
 {
   NS_ASSERTION(!aWantsUntrusted || aOptionalArgc > 1,
                "Won't check if this is chrome, you want to set "
                "aWantsUntrusted to PR_FALSE or make the aWantsUntrusted "
                "explicit by making optional_argc non-zero.");
 
   nsEventListenerManager* elm = GetListenerManager(PR_TRUE);
   NS_ENSURE_STATE(elm);
-  return elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted);
+  elm->AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted);
+  return NS_OK;
 }
 
 nsEventListenerManager*
 nsWindowRoot::GetListenerManager(PRBool aCreateIfNotFound)
 {
   if (!mListenerManager && aCreateIfNotFound) {
     mListenerManager =
       new nsEventListenerManager(static_cast<nsIDOMEventTarget*>(this));
--- a/dom/src/geolocation/Makefile.in
+++ b/dom/src/geolocation/Makefile.in
@@ -63,16 +63,21 @@ LOCAL_INCLUDES = \
 
 EXPORTS        = nsGeoPosition.h
 
 ifdef MOZ_MAEMO_LIBLOCATION
 LOCAL_INCLUDES  += $(MOZ_PLATFORM_MAEMO_CFLAGS) \
                    -I$(topsrcdir)/dom/system/unix \
                    $(NULL)
 endif
+ifdef MOZ_ENABLE_QTMOBILITY
+LOCAL_INCLUDES  += $(MOZ_QT_CFLAGS) \
+                   -I$(topsrcdir)/dom/system/unix \
+                   $(NULL)
+endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),android)
 LOCAL_INCLUDES  += -I$(topsrcdir)/dom/system/android \
                    $(NULL)
 endif
 
 EXPORTS         += nsGeoPositionIPCSerialiser.h
 
--- a/dom/src/geolocation/nsGeolocation.cpp
+++ b/dom/src/geolocation/nsGeolocation.cpp
@@ -75,16 +75,20 @@
 #include "mozilla/Preferences.h"
 
 #include <math.h>
 
 #ifdef MOZ_MAEMO_LIBLOCATION
 #include "MaemoLocationProvider.h"
 #endif
 
+#ifdef MOZ_ENABLE_QTMOBILITY
+#include "QTMLocationProvider.h"
+#endif
+
 #ifdef ANDROID
 #include "AndroidLocationProvider.h"
 #endif
 
 #include "nsIDOMDocument.h"
 #include "nsIDocument.h"
 
 // Some limit to the number of get or watch geolocation requests
@@ -573,16 +577,22 @@ nsresult nsGeolocationService::Init()
   // we should move these providers outside of this file! dft
 
 #ifdef MOZ_MAEMO_LIBLOCATION
   provider = new MaemoLocationProvider();
   if (provider)
     mProviders.AppendObject(provider);
 #endif
 
+#ifdef MOZ_ENABLE_QTMOBILITY
+  provider = new QTMLocationProvider();
+  if (provider)
+    mProviders.AppendObject(provider);
+#endif
+
 #ifdef ANDROID
   provider = new AndroidLocationProvider();
   if (provider)
     mProviders.AppendObject(provider);
 #endif
   return NS_OK;
 }
 
old mode 100755
new mode 100644
--- a/dom/system/NetworkGeolocationProvider.js
+++ b/dom/system/NetworkGeolocationProvider.js
@@ -1,427 +1,311 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Network Location Provider for GLS.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Doug Turner <dougt@dougt.org>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+
+// Do not use this API without permission from Google.
+// See http://www.google.com/support/enterprise/bin/request.py?contact_type=gme&utm_campaign=en-us-ptr-mz
+// for more information.
+
 Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+Components.utils.import("resource://gre/modules/Services.jsm");
 
 const Ci = Components.interfaces;
 const Cc = Components.classes;
 
-var gLoggingEnabled = false;
-var gTestingEnabled = false;
-
-function nowInSeconds()
-{
-    return Date.now() / 1000;
-}
+let gLoggingEnabled = false;
+let gTestingEnabled = false;
 
 function LOG(aMsg) {
   if (gLoggingEnabled)
   {
     aMsg = "*** WIFI GEO: " + aMsg + "\n";
     Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService).logStringMessage(aMsg);
     dump(aMsg);
   }
 }
 
-function WifiGeoAddressObject(streetNumber, street, premises, city, county, region, country, countryCode, postalCode) {
-
-  this.streetNumber = streetNumber;
-  this.street       = street;
-  this.premises     = premises;
-  this.city         = city;
-  this.county       = county;
-  this.region       = region;
-  this.country      = country;
-  this.countryCode  = countryCode;
-  this.postalCode   = postalCode;
+function WifiGeoCoordsObject(lat, lon, acc, alt, altacc) {
+  this.latitude = lat;
+  this.longitude = lon;
+  this.accuracy = acc;
+  this.altitude = alt;
+  this.altitudeAccuracy = altacc;
 }
 
-WifiGeoAddressObject.prototype = {
-
-    QueryInterface:   XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionAddress]),
-
-    classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionAddress],
-                                      flags: Ci.nsIClassInfo.DOM_OBJECT})
-};
-
-function WifiGeoCoordsObject(lat, lon, acc, alt, altacc) {
-    this.latitude = lat;
-    this.longitude = lon;
-    this.accuracy = acc;
-    this.altitude = alt;
-    this.altitudeAccuracy = altacc;
-};
-
 WifiGeoCoordsObject.prototype = {
 
-    QueryInterface:   XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords]),
-
-    classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionCoords],
-                                      flags: Ci.nsIClassInfo.DOM_OBJECT,
-                                      classDescription: "wifi geo position coords object"}),
+  QueryInterface:  XPCOMUtils.generateQI([Ci.nsIDOMGeoPositionCoords]),
 
-    latitude: 0,
-    longitude: 0,
-    accuracy: 0,
-    altitude: 0,
-    altitudeAccuracy: 0,
-
+  classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPositionCoords],
+                                    flags: Ci.nsIClassInfo.DOM_OBJECT,
+                                    classDescription: "wifi geo position coords object"}),
 };
 
-function WifiGeoPositionObject(location) {
-
-    this.coords = new WifiGeoCoordsObject(location.latitude,
-                                          location.longitude,
-                                          location.accuracy || 12450, // .5 * circumference of earth.
-                                          location.altitude || 0,
-                                          location.altitude_accuracy || 0);
-
-    if (location.address) {
-        let address = location.address;
-        this.address = new WifiGeoAddressObject(address.street_number || null,
-                                                address.street || null,
-                                                address.premises || null,
-                                                address.city || null,
-                                                address.county || null,
-                                                address.region || null,
-                                                address.country || null,
-                                                address.country_code || null,
-                                                address.postal_code || null);
-    }
-    else
-      this.address = null;
-
-    this.timestamp = Date.now();
-};
+function WifiGeoPositionObject(lat, lng, acc) {
+  this.coords = new WifiGeoCoordsObject(lat, lng, acc, 0, 0);
+  this.address = null;
+  this.timestamp = Date.now();
+}
 
 WifiGeoPositionObject.prototype = {
 
-    QueryInterface:   XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition]),
+  QueryInterface:   XPCOMUtils.generateQI([Ci.nsIDOMGeoPosition]),
 
-    // Class Info is required to be able to pass objects back into the DOM.
-    classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPosition],
-                                      flags: Ci.nsIClassInfo.DOM_OBJECT,
-                                      classDescription: "wifi geo location position object"}),
-
-    coords: null,
-    timestamp: 0,
+  // Class Info is required to be able to pass objects back into the DOM.
+  classInfo: XPCOMUtils.generateCI({interfaces: [Ci.nsIDOMGeoPosition],
+                                    flags: Ci.nsIClassInfo.DOM_OBJECT,
+                                    classDescription: "wifi geo location position object"}),
 };
 
-function HELD() {};
- // For information about the HELD format, see:
- // http://tools.ietf.org/html/draft-thomson-geopriv-held-measurements-05
-HELD.encode = function(requestObject) {
-    // XML Header
-    var requestString = "<locationRequest xmlns=\"urn:ietf:params:xml:ns:geopriv:held\">";
-    // Measurements
-    if (requestObject.wifi_towers && requestObject.wifi_towers.length > 0) {
-      requestString += "<measurements xmlns=\"urn:ietf:params:xml:ns:geopriv:lm\">";
-      requestString += "<wifi xmlns=\"urn:ietf:params:xml:ns:geopriv:lm:wifi\">";
-      for (var i=0; i < requestObject.wifi_towers.length; ++i) {
-        requestString += "<neighbourWap>";
-        requestString += "<bssid>" + requestObject.wifi_towers[i].mac_address     + "</bssid>";
-        requestString += "<ssid>"  + requestObject.wifi_towers[i].ssid            + "</ssid>";
-        requestString += "<rssi>"  + requestObject.wifi_towers[i].signal_strength + "</rssi>";
-        requestString += "</neighbourWap>";
-      }
-      // XML Footer
-      requestString += "</wifi></measurements>";
+function WifiGeoPositionProvider() {
+  try {
+    gLoggingEnabled = Services.prefs.getBoolPref("geo.wifi.logging.enabled");
+  } catch (e) {}
+
+  try {
+    gTestingEnabled = Services.prefs.getBoolPref("geo.wifi.testing");
+  } catch (e) {}
+
+  wifiService = null;
+  timer = null;
+  hasSeenWiFi = false;
+  started = false;
+}
+
+WifiGeoPositionProvider.prototype = {
+  classID:          Components.ID("{77DA64D3-7458-4920-9491-86CC9914F904}"),
+  QueryInterface:   XPCOMUtils.generateQI([Ci.nsIGeolocationProvider,
+                                           Ci.nsIWifiListener,
+                                           Ci.nsITimerCallback]),
+  startup:  function() {
+    if (this.started)
+      return;
+    this.started = true;
+    this.hasSeenWiFi = false;
+
+    LOG("startup called.  testing mode is" + gTestingEnabled);
+
+    // if we don't see anything in 5 seconds, kick of one IP geo lookup.
+    // if we are testing, just hammer this callback so that we are more or less
+    // always sending data.  It doesn't matter if we have an access point or not.
+    this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
+    if (!gTestingEnabled)
+      this.timer.initWithCallback(this, 5000, this.timer.TYPE_ONE_SHOT);
+    else
+      this.timer.initWithCallback(this, 200, this.timer.TYPE_REPEATING_SLACK);
+  },
+
+  watch: function(c) {
+    LOG("watch called");
+    if (!this.wifiService) {
+      this.wifiService = Cc["@mozilla.org/wifi/monitor;1"].getService(Components.interfaces.nsIWifiMonitor);
+      this.wifiService.startWatching(this);
     }
-    requestString += "</locationRequest>";
-    return requestString;
-};
+  },
 
-// Decode a HELD response into a Gears-style object
-HELD.decode = function(responseXML) {
-    // Find a Circle object in PIDF-LO and decode
-    function nsResolver(prefix) {
-        var ns = {
-            'held': 'urn:ietf:params:xml:ns:geopriv:held',
-            'pres': 'urn:ietf:params:xml:ns:pidf',
-            'gp': 'urn:ietf:params:xml:ns:pidf:geopriv10',
-            'gml': 'http://www.opengis.net/gml',
-            'gs': 'http://www.opengis.net/pidflo/1.0',
-        };
-        return ns[prefix] || null;
+  shutdown: function() { 
+    LOG("shutdown called");
+    if(this.wifiService) {
+      this.wifiService.stopWatching(this);
+      this.wifiService = null;
+    }
+    if (this.timer != null) {
+      this.timer.cancel();
+      this.timer = null;
     }
 
-    var xpathEval = Components.classes["@mozilla.org/dom/xpath-evaluator;1"].createInstance(Ci.nsIDOMXPathEvaluator);
+    // Although we aren't using cookies, we should err on the side of not
+    // saving any access tokens if the user asked us not to save cookies or
+    // has changed the lifetimePolicy.  The access token in these cases is
+    // used and valid for the life of this object (eg. between startup and
+    // shutdown).
+    if (Services.prefs.getIntPref("network.cookie.lifetimePolicy") != 0)
+      Services.prefs.deleteBranch("geo.wifi.access_token.");
+    this.started = false;
+  },
 
-    // Grab values out of XML via XPath
-    var pos = xpathEval.evaluate(
-        '/held:locationResponse/pres:presence/pres:tuple/pres:status/gp:geopriv/gp:location-info/gs:Circle/gml:pos',
-        responseXML,
-        nsResolver,
-        Ci.nsIDOMXPathResult.STRING_TYPE,
-        null);
+  getAccessTokenForURL: function(url)
+  {
+    // check to see if we have an access token:
+    let accessToken = "";
+    try {
+      let accessTokenPrefName = "geo.wifi.access_token." + url;
+      accessToken = Services.prefs.getCharPref(accessTokenPrefName);
+
+      // check to see if it has expired
+      let accessTokenDate = Services.prefs.getIntPref(accessTokenPrefName + ".time");
+      
+      let accessTokenInterval = 1209600;  // seconds in 2 weeks
+      try {
+        accessTokenInterval = Services.prefs.getIntPref("geo.wifi.access_token.recycle_interval");
+      } catch (e) {}
+            
+      if ((Date.now() / 1000) - accessTokenDate > accessTokenInterval)
+        accessToken = "";
+    }
+    catch (e) {
+      accessToken = "";
+    }
+    return accessToken;
+  },
 
-    var rad = xpathEval.evaluate(
-        '/held:locationResponse/pres:presence/pres:tuple/pres:status/gp:geopriv/gp:location-info/gs:Circle/gs:radius',
-        responseXML,
-        nsResolver,
-        Ci.nsIDOMXPathResult.NUMBER_TYPE,
-        null );
+  onChange: function(accessPoints) {
+    LOG("onChange called");
+    this.hasSeenWiFi = true;
+
+    let providerUrlBase = Services.prefs.getCharPref("geo.wifi.uri");
+    let providerUrl;
+
+    let query = providerUrlBase.indexOf("?");
+    if (query == -1)
+      providerUrl = providerUrlBase + "?"
+    else
+      providerUrl = providerUrlBase + "&";
+    providerUrl = providerUrl + "browser=firefox&sensor=true";
+    
+
+    let accessToken = this.getAccessTokenForURL(providerUrlBase);
+    if (accessToken !== "")
+      providerUrl = providerUrl + "&access_token="+access_token;
 
-    var uom = xpathEval.evaluate(
-        '/held:locationResponse/pres:presence/pres:tuple/pres:status/gp:geopriv/gp:location-info/gs:Circle/gs:radius/@uom',
-        responseXML,
-        nsResolver,
-        Ci.nsIDOMXPathResult.STRING_TYPE,
-        null);
+    function sort(a, b) {
+      return b.signal - a.signal;
+    };
+
+    function encode(ap) {
+      // make sure that the ssid doesn't contain any | chars.
+      ap.ssid = ap.ssid.replace("|", "\\|");
+      // gls service parses the | as fields
+      return "&wifi=mac:"+ap.mac+"|ssid:"+ap.ssid+"|ss:"+ap.signal;
+    };
 
-    // Bail if we don't have a valid result (all values && uom==meters)
-    if ((pos.stringValue == null) ||
-        (rad.numberValue == null) ||
-        (uom.stringValue == null) ||
-        (uom.stringValue != "urn:ogc:def:uom:EPSG::9001")) {
-        return null;
+    if (accessPoints) {
+        accessPoints.sort(sort).map(encode).join("");
+        // max length is 2k.  make sure we are under that
+        let x = providerUrl.length - 2000;
+        if (x >= 0) {
+            // we need to trim
+            let doomed = providerUrl.lastIndexOf("&", 2000);
+            LOG("Doomed:"+doomed);
+            providerUrl = providerUrl.substring(0, doomed);
+        }
     }
 
-    // Split the pos value into lat/long
-    var coords = pos.stringValue.split(/[ \t\n]+/);
-
-    // Fill out the object to return:
-    var obj = {
-        location: {
-            latitude: parseFloat(coords[0]),
-            longitude: parseFloat(coords[1]),
-            accuracy: rad.numberValue
-        }
-    };
-    return obj;
-}  
+    providerUrl = encodeURI(providerUrl);
+    LOG("************************************* Sending request:\n" + providerUrl + "\n");
 
-function WifiGeoPositionProvider() {
-    this.prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch).QueryInterface(Ci.nsIPrefService);
-    try {
-        gLoggingEnabled = this.prefService.getBoolPref("geo.wifi.logging.enabled");
-    } catch (e) {}
-
-    try {
-        gTestingEnabled = this.prefService.getBoolPref("geo.wifi.testing");
-    } catch (e) {}
-
-};
-
-WifiGeoPositionProvider.prototype = {
-    classID:          Components.ID("{77DA64D3-7458-4920-9491-86CC9914F904}"),
-    QueryInterface:   XPCOMUtils.generateQI([Ci.nsIGeolocationProvider,
-                                             Ci.nsIWifiListener,
-                                             Ci.nsITimerCallback]),
+    // send our request to a wifi geolocation network provider:
+    let xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
+                        .createInstance(Ci.nsIXMLHttpRequest);
 
-    prefService:     null,
-    wifi_service:    null,
-    timer:           null,
-    hasSeenWiFi:     false,
-    started:         false,
-
-    startup:         function() {
-        if (this.started == true)
-            return;
-
-        this.started = true;
+    // This is a background load
+    xhr.mozBackgroundRequest = true;
+    xhr.open("GET", providerUrl, false);
+    xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS;
+    xhr.onerror = function(req) {
+        LOG("onerror: " + req);
+    };
+    xhr.onload = function (req) {  
+        LOG("service returned: " + req.target.responseText);
+        response = JSON.parse(req.target.responseText);
+        /*
+          {
+            "status": "OK",
+            "accuracy": 150.0,
+            "location": {
+              "lat": -33.85702,
+              "lng": 151.21494
+            },
+            "access_token": "quijibo"
+          }
+        */
 
-        LOG("startup called.  testing mode is" + gTestingEnabled);
-        // if we don't see anything in 5 seconds, kick of one IP geo lookup.
-        // if we are testing, just hammer this callback so that we are more or less
-        // always sending data.  It doesn't matter if we have an access point or not.
-        this.hasSeenWiFi = false;
-        this.timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
-        if (gTestingEnabled == false)
-            this.timer.initWithCallback(this, 5000, this.timer.TYPE_ONE_SHOT);
-        else
-            this.timer.initWithCallback(this, 200, this.timer.TYPE_REPEATING_SLACK);
-    },
+        if (response.status != "OK")
+          return;
 
-    watch: function(c) {
-        LOG("watch called");
-        if (!this.wifi_service) {
-            this.wifi_service = Cc["@mozilla.org/wifi/monitor;1"].getService(Components.interfaces.nsIWifiMonitor);
-            this.wifi_service.startWatching(this);
-        }
-    },
+        if (response.location) {
+          let newLocation = new WifiGeoPositionObject(response.location.lat,
+                                                      response.location.lng,
+                                                      response.accuracy);
 
-    shutdown: function() { 
-        LOG("shutdown  called");
-        if(this.wifi_service)
-            this.wifi_service.stopWatching(this);
-        this.wifi_service = null;
-
-        if (this.timer != null) {
-            this.timer.cancel();
-            this.timer = null;
+          let update = Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationUpdate);
+          update.update(newLocation);
         }
 
-        // Although we aren't using cookies, we should err on the side of not
-        // saving any access tokens if the user asked us not to save cookies or
-        // has changed the lifetimePolicy.  The access token in these cases is
-        // used and valid for the life of this object (eg. between startup and
-        // shutdown).e
-        let prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
-        if (prefBranch.getIntPref("network.cookie.lifetimePolicy") != 0)
-            prefBranch.deleteBranch("geo.wifi.access_token.");
-
-        this.started = false;
-    },
-
-    getAccessTokenForURL: function(url)
-    {
-        // check to see if we have an access token:
-        var accessToken = "";
-        
-        try {
-            var accessTokenPrefName = "geo.wifi.access_token." + url;
-            accessToken = this.prefService.getCharPref(accessTokenPrefName);
-            
-            // check to see if it has expired
-            var accessTokenDate = this.prefService.getIntPref(accessTokenPrefName + ".time");
-            
-            var accessTokenInterval = 1209600;  /* seconds in 2 weeks */
-            try {
-                accessTokenInterval = this.prefService.getIntPref("geo.wifi.access_token.recycle_interval");
-            } catch (e) {}
-            
-            if (nowInSeconds() - accessTokenDate > accessTokenInterval)
-                accessToken = "";
-        }
-        catch (e) {
-            accessToken = "";
-        }
-        return accessToken;
-    },
-
-    onChange: function(accessPoints) {
-
-        LOG("onChange called");
-        this.hasSeenWiFi = true;
-
-        // send our request to a wifi geolocation network provider:
-        var xhr = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
-                            .createInstance(Ci.nsIXMLHttpRequest);
-
-        // This is a background load
-        xhr.mozBackgroundRequest = true;
-
-        var provider_url      = this.prefService.getCharPref("geo.wifi.uri");
-        var provider_protocol = 0;
-        try {
-            provider_protocol = this.prefService.getIntPref("geo.wifi.protocol");
-        } catch (e) {}
-
-        LOG("provider url = " + provider_url);
-
-        xhr.open("POST", provider_url, false);
-        
-        // set something so that we can strip cookies
-        xhr.channel.loadFlags = Ci.nsIChannel.LOAD_ANONYMOUS;
-            
-        xhr.onerror = function(req) {
-            LOG("onerror: " + req);
-        };
-
-        xhr.onload = function (req) {  
-
-            LOG("xhr onload...");
+        // Check to see if we have a new access token
+        let newAccessToken = response.access_token;
+        if (newAccessToken !== undefined)
+        {
+          let accessToken = "";
+          let accessTokenPrefName = "geo.wifi.access_token." + providerUrlBase;
+          try { accessToken = Services.prefs.getCharPref(accessTokenPrefName); } catch (e) {}
 
-            try { 
-                // if we get a bad response, we will throw and never report a location
-                var response;
-                switch (provider_protocol) {
-                    case 1:
-                        LOG("service returned: " + req.target.responseXML);
-                        response = HELD.decode(req.target.responseXML);
-                        break;
-                    case 0:
-                    default:
-                        LOG("service returned: " + req.target.responseText);
-                        response = JSON.parse(req.target.responseText);
-                }
-            } catch (e) {
-                LOG("Parse failed");
-                return;
-            }
-
-            // response looks something like:
-            // {"location":{"latitude":51.5090332,"longitude":-0.1212726,"accuracy":150.0},"access_token":"2:jVhRZJ-j6PiRchH_:RGMrR0W1BiwdZs12"}
-
-            // Check to see if we have a new access token
-            var newAccessToken = response.access_token;
-            if (newAccessToken != undefined)
-            {
-                var prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
-                var accessToken = "";
-                var accessTokenPrefName = "geo.wifi.access_token." + req.target.channel.URI.spec;
-                try { accessToken = prefService.getCharPref(accessTokenPrefName); } catch (e) {}
-
-                if (accessToken != newAccessToken) {
-                    // no match, lets cache
-                    LOG("New Access Token: " + newAccessToken + "\n" + accessTokenPrefName);
-                    
-                    try {
-                        prefService.setIntPref(accessTokenPrefName + ".time", nowInSeconds());
-                        prefService.setCharPref(accessTokenPrefName, newAccessToken);
-                    } catch (x) {
-                        // XXX temporary hack for bug 575346 to allow geolocation to function
-                    }
-                }
-            }
-
-            if (response.location) {
-                var newLocation = new WifiGeoPositionObject(response.location);
-
-                var update = Cc["@mozilla.org/geolocation/service;1"].getService(Ci.nsIGeolocationUpdate);
-                update.update(newLocation);
-            }
-        };
+          if (accessToken != newAccessToken) {
+            // no match, lets cache
+              LOG("New Access Token: " + newAccessToken + "\n" + accessTokenPrefName);
+              try {
+                Services.prefs.setIntPref(accessTokenPrefName + ".time", nowInSeconds());
+                Services.prefs.setCharPref(accessTokenPrefName, newAccessToken);
+              } catch (x) {
+                  // XXX temporary hack for bug 575346 to allow geolocation to function
+              }
+          }
+        }
+    };
 
-        var accessToken = this.getAccessTokenForURL(provider_url);
-
-        var request = {
-            version: "1.1.0",
-            request_address: true,
-        };
-
-        if (accessToken != "")
-            request.access_token = accessToken;
+    LOG("************************************* ------>>>> sending.");
+    xhr.send(null);
+  },
 
-        if (accessPoints != null) {
-            function filterBlankSSIDs(ap) ap.ssid != ""
-            function deconstruct(ap) ({
-                    mac_address: ap.mac,
-                        ssid: ap.ssid,
-                        signal_strength: ap.signal
-                        })
-            request.wifi_towers = accessPoints.filter(filterBlankSSIDs).map(deconstruct);
-        }
+  onError: function (code) {
+    LOG("wifi error: " + code);
+  },
 
-        var requestString;
-        switch (provider_protocol) {
-          case 1:
-              requestString = HELD.encode(request);
-              break;
-          case 0:
-          default:
-              requestString = JSON.stringify(request);
-        }
-        LOG("client sending: " + requestString);
- 
-        try {
-          xhr.send(requestString);
-        } catch (e) {}
-    },
-
-    onError: function (code) {
-        LOG("wifi error: " + code);
-    },
-
-    notify: function (timer) {
-        if (!gTestingEnabled) {
-            if (this.hasSeenWiFi == false)
-                this.onChange(null);
-            this.timer = null;
-            return;
-        }
-        // if we are testing, we need to hammer this.
+  notify: function (timer) {
+    if (gTestingEnabled) {
+      // if we are testing, timer is repeating
+      this.onChange(null);
+    }
+    else {
+      if (!this.hasSeenWiFi)
         this.onChange(null);
-    },
-
+      this.timer = null;
+    }
+  },
 };
 
-var NSGetFactory = XPCOMUtils.generateNSGetFactory([WifiGeoPositionProvider]);
+let NSGetFactory = XPCOMUtils.generateNSGetFactory([WifiGeoPositionProvider]);
--- a/dom/system/unix/Makefile.in
+++ b/dom/system/unix/Makefile.in
@@ -45,16 +45,18 @@ MODULE      = dom
 LIBRARY_NAME    = domsystemunix_s
 
 # we don't want the shared lib, but we want to force the creation of a static lib.
 LIBXUL_LIBRARY   = 1
 FORCE_STATIC_LIB = 1
 EXPORT_LIBRARY = 1
 
 include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
+
 
 CPPSRCS     = \
         nsDeviceMotionSystem.cpp \
         $(NULL)
 
 ifdef MOZ_MAEMO_LIBLOCATION
         CPPSRCS         += MaemoLocationProvider.cpp
         LOCAL_INCLUDES  += $(MOZ_PLATFORM_MAEMO_CFLAGS) \
@@ -62,14 +64,19 @@ ifdef MOZ_MAEMO_LIBLOCATION
                            $(NULL)
 endif
 
 ifdef MOZ_PLATFORM_MAEMO
 CPPSRCS += nsHapticFeedback.cpp
 LOCAL_INCLUDES  += $(MOZ_DBUS_CFLAGS) \
                    $(NULL)
 ifdef MOZ_ENABLE_QTMOBILITY
+MOCSRCS         += moc_QTMLocationProvider.cpp
+CPPSRCS         += $(MOCSRCS) \
+                   QTMLocationProvider.cpp \
+                   $(NULL)
 LOCAL_INCLUDES  += $(MOZ_QT_CFLAGS) \
+                   -I$(topsrcdir)/dom/src/geolocation \
                    $(NULL)
 endif
 endif
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/dom/system/unix/QTMLocationProvider.cpp
@@ -0,0 +1,118 @@
+/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Qt code.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Oleg Romashin <romaxa@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "QTMLocationProvider.h"
+#include "nsGeoPosition.h"
+#include <QFeedbackEffect>
+using namespace QtMobility;
+
+using namespace mozilla;
+
+NS_IMPL_ISUPPORTS1(QTMLocationProvider, nsIGeolocationProvider)
+
+QTMLocationProvider::QTMLocationProvider()
+{
+    mLocation = QGeoPositionInfoSource::createDefaultSource(this);
+    if (mLocation)
+        connect(mLocation, SIGNAL(positionUpdated(QGeoPositionInfo)), this, SLOT(positionUpdated(QGeoPositionInfo)));
+}
+
+QTMLocationProvider::~QTMLocationProvider()
+{
+    delete mLocation;
+}
+
+void
+QTMLocationProvider::positionUpdated(const QGeoPositionInfo &geoPosition)
+{
+    if (!geoPosition.isValid()) {
+        NS_WARNING("Invalida geoposition received");
+        return;
+    }
+
+    QGeoCoordinate coord = geoPosition.coordinate();
+    double latitude = coord.latitude();
+    double longitude = coord.longitude();
+    double altitude = coord.altitude();
+    double accuracy = geoPosition.attribute(QGeoPositionInfo::HorizontalAccuracy);
+    double altitudeAccuracy = geoPosition.attribute(QGeoPositionInfo::VerticalAccuracy);
+    double heading = geoPosition.attribute(QGeoPositionInfo::Direction);
+
+    bool providesSpeed = geoPosition.hasAttribute(QGeoPositionInfo::GroundSpeed);
+    double speed = geoPosition.attribute(QGeoPositionInfo::GroundSpeed);
+
+    nsRefPtr<nsGeoPosition> p =
+        new nsGeoPosition(latitude, longitude,
+                          altitude, accuracy,
+                          altitudeAccuracy, heading,
+                          speed, geoPosition.timestamp().toTime_t());
+    if (mCallback) {
+        mCallback->Update(p);
+    }
+}
+
+NS_IMETHODIMP
+QTMLocationProvider::Startup()
+{
+    if (!mLocation)
+        return NS_ERROR_NOT_IMPLEMENTED;
+
+    mLocation->startUpdates();
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+QTMLocationProvider::Watch(nsIGeolocationUpdate* aCallback)
+{
+    mCallback = aCallback;
+
+    return NS_OK;
+}
+
+NS_IMETHODIMP
+QTMLocationProvider::Shutdown()
+{
+    if (!mLocation)
+        return NS_ERROR_NOT_IMPLEMENTED;
+
+    mLocation->stopUpdates();
+    mCallback = nsnull;
+
+    return NS_OK;
+}
+
new file mode 100644
--- /dev/null
+++ b/dom/system/unix/QTMLocationProvider.h
@@ -0,0 +1,69 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Qt code.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Oleg Romashin <romaxa@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#ifndef QTMLocationProvider_h
+#define QTMLocationProvider_h
+
+#include <QGeoPositionInfoSource>
+#include "nsGeolocation.h"
+#include "nsIGeolocationProvider.h"
+#include "nsCOMPtr.h"
+
+using namespace QtMobility;
+
+class QTMLocationProvider : public QObject,
+                            public nsIGeolocationProvider
+{
+    Q_OBJECT
+
+public:
+    NS_DECL_ISUPPORTS
+    NS_DECL_NSIGEOLOCATIONPROVIDER
+
+    QTMLocationProvider();
+
+public Q_SLOTS:
+    // QGeoPositionInfoSource
+    void positionUpdated(const QGeoPositionInfo&);
+
+private:
+    ~QTMLocationProvider();
+
+    QtMobility::QGeoPositionInfoSource* mLocation;
+    nsCOMPtr<nsIGeolocationUpdate> mCallback;
+};
+
+#endif /* QTMLocationProvider_h */
--- a/dom/tests/mochitest/geolocation/geolocation_common.js
+++ b/dom/tests/mochitest/geolocation/geolocation_common.js
@@ -72,20 +72,20 @@ function check_geolocation(location) {
 
   // eventually, coords may be optional (eg, when civic addresses are supported)
   ok("coords" in location, "Check to see if this location has a coords");
 
   var coords = location.coords;
 
   ok("latitude" in coords, "Check to see if there is a latitude");
   ok("longitude" in coords, "Check to see if there is a longitude");
-  ok("altitude" in coords, "Check to see if there is a altitude");
   ok("accuracy" in coords, "Check to see if there is a accuracy");
-  ok("altitudeAccuracy" in coords, "Check to see if there is a alt accuracy");
-
+  
+  // optional ok("altitude" in coords, "Check to see if there is a altitude");
+  // optional ok("altitudeAccuracy" in coords, "Check to see if there is a alt accuracy");
   // optional ok("heading" in coords, "Check to see if there is a heading");
   // optional ok("speed" in coords, "Check to see if there is a speed");
 
   ok (location.coords.latitude  == 37.41857, "lat matches known value");
   ok (location.coords.longitude == -122.08769, "lon matches known value");
-  ok(location.coords.altitude == 42, "alt matches known value");
-  ok(location.coords.altitudeAccuracy == 42, "alt acc matches known value");
+  // optional  ok(location.coords.altitude == 42, "alt matches known value");
+  // optional  ok(location.coords.altitudeAccuracy == 42, "alt acc matches known value");
 }
--- a/dom/tests/mochitest/geolocation/network_geolocation.sjs
+++ b/dom/tests/mochitest/geolocation/network_geolocation.sjs
@@ -14,45 +14,26 @@ function parseQueryString(str)
     params[decodeURIComponent(match[1])] = decodeURIComponent(match[2]);
   }
 
   return params;
 }
 
 function getPosition(action)
 {  
-    // this isn't the w3c data structure, it is the network location provider structure.
-
-  var address = {
-      street_number: "street_number",
-      street: "street",
-      premises: "premises",
-      city: "city",
-      county: "county",
-      region: "region",
-      country: "country",
-      country_code: "country_code",
-      postal_code: "postal_code",
-  };
-
-
-  var coords = {
-    latitude: 37.41857,
-    longitude: -122.08769,
-
-    altitude: 42,
+  var response = {
+    status: "OK",
+    location: {
+      lat: 37.41857,
+      lng: -122.08769,
+    },
     accuracy: (action == "worse-accuracy") ? 100 : 42,
-    altitude_accuracy: 42,
   };
   
-  var geoposition = {
-    location: coords,
-  };
-
-  return JSON.stringify(geoposition);
+  return JSON.stringify(response);
 }
 
 function handleRequest(request, response)
 {
   var params = parseQueryString(request.queryString);
 
   if (params.action == "stop-responding") {
       return;
--- a/editor/composer/src/nsComposerCommands.cpp
+++ b/editor/composer/src/nsComposerCommands.cpp
@@ -426,17 +426,18 @@ NS_IMETHODIMP
 nsRemoveListCommand::IsCommandEnabled(const char * aCommandName,
                                       nsISupports *refCon,
                                       PRBool *outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
     {
       // It is enabled if we are in any list type
       PRBool bMixed;
       PRUnichar *tagStr;
       nsresult rv = GetListState(editor, &bMixed, &tagStr);
       NS_ENSURE_SUCCESS(rv, rv);
 
@@ -538,17 +539,18 @@ nsOutdentCommand::IsCommandEnabled(const
                                    nsISupports *refCon,
                                    PRBool *outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
   nsCOMPtr<nsIHTMLEditor> htmlEditor = do_QueryInterface(refCon);
   if (editor && htmlEditor)
   {
     PRBool canIndent, isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return htmlEditor->GetIndentState(&canIndent, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -1046,17 +1048,18 @@ nsAbsolutePositioningCommand::IsCommandE
                                                nsISupports *aCommandRefCon,
                                                PRBool *outCmdEnabled)
 {
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   nsCOMPtr<nsIHTMLAbsPosEditor> htmlEditor = do_QueryInterface(aCommandRefCon);
   if (htmlEditor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return htmlEditor->GetAbsolutePositioningEnabled(outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
--- a/editor/libeditor/base/nsEditorCommands.cpp
+++ b/editor/libeditor/base/nsEditorCommands.cpp
@@ -66,17 +66,18 @@ nsUndoCommand::IsCommandEnabled(const ch
                                 nsISupports *aCommandRefCon, 
                                 PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEnabled, isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanUndo(&isEnabled, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -114,17 +115,18 @@ nsRedoCommand::IsCommandEnabled(const ch
                                 nsISupports *aCommandRefCon,
                                 PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEnabled, isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanRedo(&isEnabled, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -210,17 +212,18 @@ nsCutCommand::IsCommandEnabled(const cha
                                nsISupports *aCommandRefCon,
                                PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanCut(outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -314,17 +317,18 @@ nsCopyCommand::IsCommandEnabled(const ch
                                 nsISupports *aCommandRefCon,
                                 PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanCopy(outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -417,17 +421,18 @@ nsPasteCommand::IsCommandEnabled(const c
                                  nsISupports *aCommandRefCon,
                                  PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanPaste(nsIClipboard::kGlobalClipboard, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -464,17 +469,18 @@ nsPasteTransferableCommand::IsCommandEna
                                              nsISupports *aCommandRefCon,
                                              PRBool *outCmdEnabled)
 {
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (editor)
   {
     PRBool isEditable = PR_FALSE;
-    NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+    nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+    NS_ENSURE_SUCCESS(rv, rv);
     if (isEditable)
       return editor->CanPasteTransferable(nsnull, outCmdEnabled);
   }
 
   *outCmdEnabled = PR_FALSE;
   return NS_OK;
 }
 
@@ -575,17 +581,18 @@ nsDeleteCommand::IsCommandEnabled(const 
   NS_ENSURE_ARG_POINTER(outCmdEnabled);
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   *outCmdEnabled = PR_FALSE;
 
   // we can delete when we can cut
   NS_ENSURE_TRUE(editor, NS_OK);
     
   PRBool isEditable = PR_FALSE;
-  NS_SUCCEEDED(editor->GetIsSelectionEditable(&isEditable));
+  nsresult rv = editor->GetIsSelectionEditable(&isEditable);
+  NS_ENSURE_SUCCESS(rv, rv);
 
   if (!isEditable)
     return NS_OK;
   else if (!nsCRT::strcmp(aCommandName,"cmd_delete"))
     return editor->CanCut(outCmdEnabled);
   else if (!nsCRT::strcmp(aCommandName,"cmd_deleteCharBackward"))
     *outCmdEnabled = PR_TRUE;
   else if (!nsCRT::strcmp(aCommandName,"cmd_deleteCharForward"))
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -121,88 +121,72 @@ nsEditorEventListener::Connect(nsEditor*
 nsresult
 nsEditorEventListener::InstallToEditor()
 {
   NS_PRECONDITION(mEditor, "The caller must set mEditor");
 
   nsCOMPtr<nsIDOMEventTarget> piTarget = mEditor->GetDOMEventTarget();
   NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE);
 
-  nsresult rv;
-
   // register the event listeners with the listener manager
   nsEventListenerManager* elmP = piTarget->GetListenerManager(PR_TRUE);
   NS_ENSURE_STATE(elmP);
 
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("keypress"),
-                                    NS_EVENT_FLAG_BUBBLE |
-                                    NS_PRIV_EVENT_UNTRUSTED_PERMITTED |
-                                    NS_EVENT_FLAG_SYSTEM_EVENT);
-  NS_ENSURE_SUCCESS(rv, rv);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("keypress"),
+                               NS_EVENT_FLAG_BUBBLE |
+                               NS_PRIV_EVENT_UNTRUSTED_PERMITTED |
+                               NS_EVENT_FLAG_SYSTEM_EVENT);
   // See bug 455215, we cannot use the standard dragstart event yet
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("draggesture"),
-                                    NS_EVENT_FLAG_BUBBLE |
-                                    NS_EVENT_FLAG_SYSTEM_EVENT);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("dragenter"),
-                                    NS_EVENT_FLAG_BUBBLE |
-                                    NS_EVENT_FLAG_SYSTEM_EVENT);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("dragover"),
-                                    NS_EVENT_FLAG_BUBBLE |
-                                    NS_EVENT_FLAG_SYSTEM_EVENT);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("dragexit"),
-                                    NS_EVENT_FLAG_BUBBLE |
-                                    NS_EVENT_FLAG_SYSTEM_EVENT);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("drop"),
-                                    NS_EVENT_FLAG_BUBBLE |
-                                    NS_EVENT_FLAG_SYSTEM_EVENT);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("mousedown"),
-                                    NS_EVENT_FLAG_CAPTURE);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("mouseup"),
-                                    NS_EVENT_FLAG_CAPTURE);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("click"),
-                                    NS_EVENT_FLAG_CAPTURE);
-  NS_ENSURE_SUCCESS(rv, rv);
-  // Focus event doesn't bubble so adding the listener to capturing phase.
-  // Make sure this works after bug 235441 gets fixed.
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("blur"),
-                                    NS_EVENT_FLAG_CAPTURE);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("focus"),
-                                    NS_EVENT_FLAG_CAPTURE);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("text"),
-                                    NS_EVENT_FLAG_BUBBLE);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("compositionstart"),
-                                    NS_EVENT_FLAG_BUBBLE);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(this,
-                                    NS_LITERAL_STRING("compositionend"),
-                                    NS_EVENT_FLAG_BUBBLE);
-  NS_ENSURE_SUCCESS(rv, rv);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("draggesture"),
+                               NS_EVENT_FLAG_BUBBLE |
+                               NS_EVENT_FLAG_SYSTEM_EVENT);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("dragenter"),
+                               NS_EVENT_FLAG_BUBBLE |
+                               NS_EVENT_FLAG_SYSTEM_EVENT);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("dragover"),
+                               NS_EVENT_FLAG_BUBBLE |
+                               NS_EVENT_FLAG_SYSTEM_EVENT);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("dragexit"),
+                               NS_EVENT_FLAG_BUBBLE |
+                               NS_EVENT_FLAG_SYSTEM_EVENT);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("drop"),
+                               NS_EVENT_FLAG_BUBBLE |
+                               NS_EVENT_FLAG_SYSTEM_EVENT);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("mousedown"),
+                               NS_EVENT_FLAG_CAPTURE);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("mouseup"),
+                               NS_EVENT_FLAG_CAPTURE);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("click"),
+                               NS_EVENT_FLAG_CAPTURE);
+// Focus event doesn't bubble so adding the listener to capturing phase.
+// Make sure this works after bug 235441 gets fixed.
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("blur"),
+                               NS_EVENT_FLAG_CAPTURE);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("focus"),
+                               NS_EVENT_FLAG_CAPTURE);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("text"),
+                               NS_EVENT_FLAG_BUBBLE);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("compositionstart"),
+                               NS_EVENT_FLAG_BUBBLE);
+  elmP->AddEventListenerByType(this,
+                               NS_LITERAL_STRING("compositionend"),
+                               NS_EVENT_FLAG_BUBBLE);
 
   return NS_OK;
 }
 
 void
 nsEditorEventListener::Disconnect()
 {
   if (!mEditor) {
@@ -400,16 +384,26 @@ nsEditorEventListener::MouseClick(nsIDOM
     // We're done if 'preventdefault' is true (see for example bug 70698).
     return rv;
   }
 
   // If we got a mouse down inside the editing area, we should force the 
   // IME to commit before we change the cursor position
   mEditor->ForceCompositionEnd();
 
+  nsCOMPtr<nsIDOMEventTarget> target;
+  aMouseEvent->GetTarget(getter_AddRefs(target));
+  nsCOMPtr<nsIDOMNode> node = do_QueryInterface(target);
+  NS_ENSURE_TRUE(node, NS_ERROR_FAILURE);
+
+  if (!mEditor->IsModifiableNode(node)) {
+    // We shouldn't handle the event for non-editable content.
+    return NS_OK;
+  }
+
   PRUint16 button = (PRUint16)-1;
   mouseEvent->GetButton(&button);
   // middle-mouse click (paste);
   if (button == 1)
   {
     if (Preferences::GetBool("middlemouse.paste", PR_FALSE))
     {
       // Set the selection to the point under the mouse cursor:
--- a/editor/libeditor/html/tests/Makefile.in
+++ b/editor/libeditor/html/tests/Makefile.in
@@ -79,16 +79,18 @@ include $(topsrcdir)/config/rules.mk
 		test_bug607584.html \
 		test_bug611182.html \
 		test_bug612447.html \
 		test_bug620906.html \
 		test_bug622371.html \
 		test_bug629845.html \
 		test_bug640321.html \
 		test_bug668599.html \
+		test_bug674770.html \
+		file_bug674770.html \
 		test_bug674861.html \
 		test_bug676401.html \
 		test_CF_HTML_clipboard.html \
 		test_contenteditable_focus.html \
 		test_htmleditor_keyevent_handling.html \
 		test_select_all_without_body.html \
 		file_select_all_without_body.html \
 		test_root_element_replacement.html \
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/html/tests/file_bug674770.html
@@ -0,0 +1,5 @@
+<!DOCTYPE>
+<script>
+  localStorage["clicked"] = "true";
+  close();
+</script>
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/html/tests/test_bug674770.html
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=674770
+-->
+<head>
+  <title>Test for Bug 674770</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=674770">Mozilla Bug 674770</a>
+<p id="display"></p>
+<div id="content">
+<a href="file_bug674770.html" id="link1">test</a>
+<div contenteditable>
+<a href="file_bug674770.html" id="link2">test</a>
+</div>
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 674770 **/
+SimpleTest.waitForExplicitFinish();
+SimpleTest.waitForFocus(function() {
+  SpecialPowers.setBoolPref("middlemouse.paste", true);
+  localStorage.removeItem("clicked");
+  window.linkWasClicked = false;
+
+  var link = document.querySelector("#link1");
+  addEventListener("storage", function(e) {
+    is(e.key, "clicked", "Correct event");
+    is(e.newValue, "true", "Correct value");
+    window.linkWasClicked = true;
+  }, false);
+  synthesizeMouseAtCenter(link, {button: 1});
+
+  hitEventLoop(function() {
+    ok(window.linkWasClicked, "The click operation worked successfully");
+    window.linkWasClicked = false;
+
+    link = document.querySelector("#link2");
+    localStorage.removeItem("clicked");
+    synthesizeMouseAtCenter(link, {button: 1});
+
+    hitEventLoop(function() {
+      ok(!window.linkWasClicked, "The click operation shouldn't work in the contenteditable area");
+
+      localStorage.removeItem("clicked");
+      SpecialPowers.clearUserPref("middlemouse.paste");
+      focus(); // reset focus
+      SimpleTest.finish();
+    }, 100);
+  }, 100);
+});
+
+function hitEventLoop(func, times) {
+  if (times > 0) {
+    setTimeout(hitEventLoop, 0, func, times - 1);
+  } else {
+    setTimeout(func, 0);
+  }
+}
+
+</script>
+</pre>
+</body>
+</html>
--- a/editor/libeditor/text/tests/test_bug597331.html
+++ b/editor/libeditor/text/tests/test_bug597331.html
@@ -19,17 +19,17 @@ line2
 line3
 </textarea>
 </div>
 <pre id="test">
 <script type="application/javascript">
 
 /** Test for Bug 597331 **/
 SimpleTest.waitForExplicitFinish();
-addLoadEvent(function() {
+SimpleTest.waitForFocus(function() {
   var t = document.querySelector("textarea");
   t.focus();
   t.selectionStart = 4;
   t.selectionEnd = 4;
   SimpleTest.executeSoon(function() {
     var before = snapshotWindow(window, true);
     t.selectionStart = 5;
     t.selectionEnd = 5;
--- a/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
+++ b/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp
@@ -882,25 +882,23 @@ nsDocShellTreeOwner::AddChromeListeners(
     }
   }
 
   // register dragover and drop event listeners with the listener manager
   nsCOMPtr<nsIDOMEventTarget> target;
   GetDOMEventTarget(mWebBrowser, getter_AddRefs(target));
 
   nsEventListenerManager* elmP = target->GetListenerManager(PR_TRUE);
-  if (elmP)
-  {
-    rv = elmP->AddEventListenerByType(this, NS_LITERAL_STRING("dragover"),
-                                      NS_EVENT_FLAG_BUBBLE |
-                                      NS_EVENT_FLAG_SYSTEM_EVENT);
-    NS_ENSURE_SUCCESS(rv, rv);
-    rv = elmP->AddEventListenerByType(this, NS_LITERAL_STRING("drop"),
-                                      NS_EVENT_FLAG_BUBBLE |
-                                      NS_EVENT_FLAG_SYSTEM_EVENT);
+  if (elmP) {
+    elmP->AddEventListenerByType(this, NS_LITERAL_STRING("dragover"),
+                                 NS_EVENT_FLAG_BUBBLE |
+                                 NS_EVENT_FLAG_SYSTEM_EVENT);
+    elmP->AddEventListenerByType(this, NS_LITERAL_STRING("drop"),
+                                 NS_EVENT_FLAG_BUBBLE |
+                                 NS_EVENT_FLAG_SYSTEM_EVENT);
   }
 
   return rv;
   
 } // AddChromeListeners
 
 
 NS_IMETHODIMP
--- a/gfx/src/nsRenderingContext.h
+++ b/gfx/src/nsRenderingContext.h
@@ -65,17 +65,17 @@ public:
     NS_INLINE_DECL_REFCOUNTING(nsRenderingContext)
 
     void Init(nsDeviceContext* aContext, gfxASurface* aThebesSurface);
     void Init(nsDeviceContext* aContext, gfxContext* aThebesContext);
 
     // These accessors will never return null.
     gfxContext *ThebesContext() { return mThebes; }
     nsDeviceContext *DeviceContext() { return mDeviceContext; }
-    PRUint32 AppUnitsPerDevPixel() { return mP2A; }
+    PRUint32 AppUnitsPerDevPixel() { return NSToIntRound(mP2A); }
 
     // Graphics state
 
     void PushState(void);
     void PopState(void);
     void IntersectClip(const nsRect& aRect);
     void SetClip(const nsIntRegion& aRegion);
     void SetLineStyle(nsLineStyle aLineStyle);
--- a/js/src/configure.in
+++ b/js/src/configure.in
@@ -3489,63 +3489,16 @@ then
 				CFLAGS="$CFLAGS -mt" 
 				CXXFLAGS="$CXXFLAGS -mt" 
 			fi
 			;;
 	esac
     LDFLAGS="${_PTHREAD_LDFLAGS} ${LDFLAGS}"
 fi
 
-dnl ========================================================
-dnl See if mmap sees writes
-dnl For cross compiling, just define it as no, which is a safe default
-dnl ========================================================
-AC_MSG_CHECKING(whether mmap() sees write()s)
-
-changequote(,)
-mmap_test_prog='
-    #include <stdlib.h>
-    #include <unistd.h>
-    #include <sys/mman.h>
-    #include <sys/types.h>
-    #include <sys/stat.h>
-    #include <fcntl.h>
-
-    char fname[] = "conftest.file";
-    char zbuff[1024]; /* Fractional page is probably worst case */
-
-    int main() {
-	char *map;
-	int fd;
-	int i;
-	unlink(fname);
-	fd = open(fname, O_RDWR | O_CREAT, 0660);
-	if(fd<0) return 1;
-	unlink(fname);
-	write(fd, zbuff, sizeof(zbuff));
-	lseek(fd, 0, SEEK_SET);
-	map = (char*)mmap(0, sizeof(zbuff), PROT_READ, MAP_SHARED, fd, 0);
-	if(map==(char*)-1) return 2;
-	for(i=0; fname[i]; i++) {
-	    int rc = write(fd, &fname[i], 1);
-	    if(map[i]!=fname[i]) return 4;
-	}
-	return 0;
-    }
-'
-changequote([,])
-
-AC_TRY_RUN($mmap_test_prog , result="yes", result="no", result="yes")
-
-AC_MSG_RESULT("$result")
-
-if test "$result" = "no"; then
-    AC_DEFINE(MMAP_MISSES_WRITES)
-fi
-
 
 dnl Checks for library functions.
 dnl ========================================================
 AC_PROG_GCC_TRADITIONAL
 AC_FUNC_MEMCMP
 AC_CHECK_FUNCS([fchmod flockfile getc_unlocked _getc_nolock getpagesize \
                 lchown localtime_r lstat64 memmove random rint sbrk snprintf \
                 stat64 statvfs statvfs64 strerror strtok_r truncate64])
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Object-deleteProperty-error-01.js
@@ -0,0 +1,16 @@
+// Don't crash when a scripted proxy handler throws Error.prototype.
+
+var g = newGlobal('new-compartment');
+var dbg = Debugger(g);
+dbg.onDebuggerStatement = function (frame) {
+    try {
+	frame.arguments[0].deleteProperty("x");
+    } catch (exc) {
+	return;
+    }
+    throw new Error("deleteProperty should throw");
+};
+
+g.eval("function h(x) { debugger; }");
+g.eval("h(Proxy.create({delete: function () { throw Error.prototype; }}));");
+
--- a/js/src/jsapi-tests/testLookup.cpp
+++ b/js/src/jsapi-tests/testLookup.cpp
@@ -21,17 +21,17 @@ BEGIN_TEST(testLookup_bug522590)
 
     // This lookup must not return an internal function object.
     jsvalRoot r(cx);
     CHECK(JS_LookupProperty(cx, xobj, "f", r.addr()));
     CHECK(JSVAL_IS_OBJECT(r));
     JSObject *funobj = JSVAL_TO_OBJECT(r);
     CHECK(funobj->isFunction());
     CHECK(!js::IsInternalFunctionObject(funobj));
-    CHECK(GET_FUNCTION_PRIVATE(cx, funobj) != (JSFunction *) funobj);
+    CHECK(funobj->getFunctionPrivate() != (JSFunction *) funobj);
 
     return true;
 }
 END_TEST(testLookup_bug522590)
 
 JSBool
 document_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
 {
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -338,17 +338,17 @@ JS_ConvertArgumentsVA(JSContext *cx, uin
             *sp = OBJECT_TO_JSVAL(obj);
             *va_arg(ap, JSObject **) = obj;
             break;
           case 'f':
             obj = js_ValueToFunctionObject(cx, Valueify(sp), 0);
             if (!obj)
                 return JS_FALSE;
             *sp = OBJECT_TO_JSVAL(obj);
-            *va_arg(ap, JSFunction **) = GET_FUNCTION_PRIVATE(cx, obj);
+            *va_arg(ap, JSFunction **) = obj->getFunctionPrivate();
             break;
           case 'v':
             *va_arg(ap, jsval *) = *sp;
             break;
           case '*':
             break;
           default:
             format--;
@@ -2265,20 +2265,20 @@ JS_PrintTraceThingInfo(char *buf, size_t
         bufsize--;
 
         switch (kind) {
           case JSTRACE_OBJECT:
           {
             JSObject  *obj = (JSObject *)thing;
             Class *clasp = obj->getClass();
             if (clasp == &js_FunctionClass) {
-                JSFunction *fun = GET_FUNCTION_PRIVATE(trc->context, obj);
+                JSFunction *fun = obj->getFunctionPrivate();
                 if (!fun) {
                     JS_snprintf(buf, bufsize, "<newborn>");
-                } else if (FUN_OBJECT(fun) != obj) {
+                } else if (fun != obj) {
                     JS_snprintf(buf, bufsize, "%p", fun);
                 } else {
                     if (fun->atom)
                         PutEscapedString(buf, bufsize, fun->atom, 0);
                 }
             } else if (clasp->flags & JSCLASS_HAS_PRIVATE) {
                 JS_snprintf(buf, bufsize, "%p", obj->getPrivate());
             } else {
@@ -4203,18 +4203,18 @@ JS_CloneFunctionObject(JSContext *cx, JS
          * We cannot clone this object, so fail (we used to return funobj, bad
          * idea, but we changed incompatibly to teach any abusers a lesson!).
          */
         Value v = ObjectValue(*funobj);
         js_ReportIsNotFunction(cx, &v, 0);
         return NULL;
     }
 
-    JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
-    if (!FUN_FLAT_CLOSURE(fun))
+    JSFunction *fun = funobj->getFunctionPrivate();
+    if (!fun->isFlatClosure())
         return CloneFunctionObject(cx, fun, parent);
 
     /*
      * A flat closure carries its own environment, so why clone it? In case
      * someone wants to mutate its fixed slots or add ad-hoc properties. API
      * compatibility suggests we not return funobj and let callers mutate the
      * returned object at will.
      *
@@ -4249,17 +4249,17 @@ JS_CloneFunctionObject(JSContext *cx, JS
     }
 
     return clone;
 }
 
 JS_PUBLIC_API(JSObject *)
 JS_GetFunctionObject(JSFunction *fun)
 {
-    return FUN_OBJECT(fun);
+    return fun;
 }
 
 JS_PUBLIC_API(JSString *)
 JS_GetFunctionId(JSFunction *fun)
 {
     return fun->atom;
 }
 
@@ -4352,17 +4352,17 @@ JS_DefineFunctions(JSContext *cx, JSObje
             if (!fun)
                 return JS_FALSE;
 
             /*
              * As jsapi.h notes, fs must point to storage that lives as long
              * as fun->object lives.
              */
             Value priv = PrivateValue(fs);
-            if (!js_SetReservedSlot(cx, FUN_OBJECT(fun), 0, priv))
+            if (!js_SetReservedSlot(cx, fun, 0, priv))
                 return JS_FALSE;
         }
 
         fun = JS_DefineFunction(cx, obj, fs->name, fs->call, fs->nargs, flags);
         if (!fun)
             return JS_FALSE;
     }
     return JS_TRUE;
@@ -4707,68 +4707,66 @@ CompileUCFunctionForPrincipalsCommon(JSC
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, obj, principals);
     if (!name) {
         funAtom = NULL;
     } else {
         funAtom = js_Atomize(cx, name, strlen(name));
         if (!funAtom) {
             fun = NULL;
-            goto out2;
+            goto out;
         }
     }
 
     fun = js_NewFunction(cx, NULL, NULL, 0, JSFUN_INTERPRETED, obj, funAtom);
     if (!fun)
-        goto out2;
+        goto out;
 
     {
         EmptyShape *emptyCallShape = EmptyShape::getEmptyCallShape(cx);
-        if (!emptyCallShape) {
+        if (!emptyCallShape)
             fun = NULL;
-            goto out2;
-        }
         AutoShapeRooter shapeRoot(cx, emptyCallShape);
 
-        AutoObjectRooter tvr(cx, FUN_OBJECT(fun));
-        MUST_FLOW_THROUGH("out");
+        AutoObjectRooter tvr(cx, fun);
 
         Bindings bindings(cx, emptyCallShape);
         AutoBindingsRooter root(cx, bindings);
         for (i = 0; i < nargs; i++) {
             argAtom = js_Atomize(cx, argnames[i], strlen(argnames[i]));
             if (!argAtom) {
                 fun = NULL;
-                goto out2;
+                goto out;
             }
 
             uint16 dummy;
             if (!bindings.addArgument(cx, argAtom, &dummy)) {
                 fun = NULL;
-                goto out2;
+                goto out;
             }
         }
 
         if (!Compiler::compileFunctionBody(cx, fun, principals, &bindings,
                                            chars, length, filename, lineno, version)) {
             fun = NULL;
-            goto out2;
+            goto out;
         }
 
         if (obj && funAtom &&
             !obj->defineProperty(cx, ATOM_TO_JSID(funAtom), ObjectValue(*fun),
                                  NULL, NULL, JSPROP_ENUMERATE)) {
             fun = NULL;
         }
     }
 
-  out2:
+  out:
     LAST_FRAME_CHECKS(cx, fun);
     return fun;
 }
+
 JS_PUBLIC_API(JSFunction *)
 JS_CompileUCFunctionForPrincipalsVersion(JSContext *cx, JSObject *obj,
                                          JSPrincipals *principals, const char *name,
                                          uintN nargs, const char **argnames,
                                          const jschar *chars, size_t length,
                                          const char *filename, uintN lineno,
                                          JSVersion version)
 {
--- a/js/src/jsbuiltins.cpp
+++ b/js/src/jsbuiltins.cpp
@@ -305,17 +305,17 @@ JS_DEFINE_CALLINFO_2(extern, STRING, js_
 JSObject* FASTCALL
 js_NewNullClosure(JSContext* cx, JSObject* funobj, JSObject* proto, JSObject* parent)
 {
     JS_ASSERT(funobj->isFunction());
     JS_ASSERT(proto->isFunction());
     JS_ASSERT(JS_ON_TRACE(cx));
 
     JSFunction *fun = (JSFunction*) funobj;
-    JS_ASSERT(GET_FUNCTION_PRIVATE(cx, funobj) == fun);
+    JS_ASSERT(funobj->getFunctionPrivate() == fun);
 
     JSObject* closure = js_NewGCObject(cx, gc::FINALIZE_OBJECT2);
     if (!closure)
         return NULL;
 
     if (!closure->initSharingEmptyShape(cx, &js_FunctionClass, proto, parent,
                                         fun, gc::FINALIZE_OBJECT2)) {
         return NULL;
--- a/js/src/jscntxt.cpp
+++ b/js/src/jscntxt.cpp
@@ -1078,17 +1078,17 @@ js_ReportMissingArg(JSContext *cx, const
 {
     char argbuf[11];
     char *bytes;
     JSAtom *atom;
 
     JS_snprintf(argbuf, sizeof argbuf, "%u", arg);
     bytes = NULL;
     if (IsFunctionObject(v)) {
-        atom = GET_FUNCTION_PRIVATE(cx, &v.toObject())->atom;
+        atom = v.toObject().getFunctionPrivate()->atom;
         bytes = DecompileValueGenerator(cx, JSDVG_SEARCH_STACK,
                                         v, atom);
         if (!bytes)
             return;
     }
     JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                          JSMSG_MISSING_FUN_ARG, argbuf,
                          bytes ? bytes : "");
--- a/js/src/jsdbgapi.cpp
+++ b/js/src/jsdbgapi.cpp
@@ -543,17 +543,17 @@ extern JS_PUBLIC_API(void)
 JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark)
 {
     JS_ARENA_RELEASE(&cx->tempPool, mark);
 }
 
 JS_PUBLIC_API(JSScript *)
 JS_GetFunctionScript(JSContext *cx, JSFunction *fun)
 {
-    return FUN_SCRIPT(fun);
+    return fun->maybeScript();
 }
 
 JS_PUBLIC_API(JSNative)
 JS_GetFunctionNative(JSContext *cx, JSFunction *fun)
 {
     return Jsvalify(fun->maybeNative());
 }
 
@@ -1090,18 +1090,18 @@ GetAtomTotalSize(JSContext *cx, JSAtom *
 }
 
 JS_PUBLIC_API(size_t)
 JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun)
 {
     size_t nbytes;
 
     nbytes = sizeof *fun;
-    nbytes += JS_GetObjectTotalSize(cx, FUN_OBJECT(fun));
-    if (FUN_INTERPRETED(fun))
+    nbytes += JS_GetObjectTotalSize(cx, fun);
+    if (fun->isInterpreted())
         nbytes += JS_GetScriptTotalSize(cx, fun->script());
     if (fun->atom)
         nbytes += GetAtomTotalSize(cx, fun->atom);
     return nbytes;
 }
 
 #include "jsemit.h"
 
--- a/js/src/jsemit.cpp
+++ b/js/src/jsemit.cpp
@@ -4810,32 +4810,32 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
         if (pn->pn_arity == PN_NULLARY) {
             if (js_Emit1(cx, cg, JSOP_GETFUNNS) < 0)
                 return JS_FALSE;
             break;
         }
 #endif
 
         fun = pn->pn_funbox->function();
-        JS_ASSERT(FUN_INTERPRETED(fun));
+        JS_ASSERT(fun->isInterpreted());
         if (fun->script()) {
             /*
              * This second pass is needed to emit JSOP_NOP with a source note
              * for the already-emitted function definition prolog opcode. See
              * comments in the TOK_LC case.
              */
             JS_ASSERT(pn->pn_op == JSOP_NOP);
             JS_ASSERT(cg->inFunction());
             if (!EmitFunctionDefNop(cx, cg, pn->pn_index))
                 return JS_FALSE;
             break;
         }
 
         JS_ASSERT_IF(pn->pn_funbox->tcflags & TCF_FUN_HEAVYWEIGHT,
-                     FUN_KIND(fun) == JSFUN_INTERPRETED);
+                     fun->kind() == JSFUN_INTERPRETED);
 
         /* Generate code for the function's body. */
         void *cg2mark = JS_ARENA_MARK(cg->codePool);
         void *cg2space;
         JS_ARENA_ALLOCATE_TYPE(cg2space, JSCodeGenerator, cg->codePool);
         if (!cg2space) {
             js_ReportOutOfMemory(cx);
             return JS_FALSE;
@@ -4908,17 +4908,17 @@ js_EmitTree(JSContext *cx, JSCodeGenerat
          * definitions can be scheduled before generating the rest of code.
          */
         if (!cg->inFunction()) {
             JS_ASSERT(!cg->topStmt);
             if (!BindGlobal(cx, cg, pn, fun->atom))
                 return false;
             if (pn->pn_cookie.isFree()) {
                 CG_SWITCH_TO_PROLOG(cg);
-                op = FUN_FLAT_CLOSURE(fun) ? JSOP_DEFFUN_FC : JSOP_DEFFUN;
+                op = fun->isFlatClosure() ? JSOP_DEFFUN_FC : JSOP_DEFFUN;
                 EMIT_INDEX_OP(op, index);
 
                 /* Make blockChain determination quicker. */
                 if (EmitBlockChain(cx, cg) < 0)
                     return JS_FALSE;
                 CG_SWITCH_TO_MAIN(cg);
             }
 
--- a/js/src/jsexn.cpp
+++ b/js/src/jsexn.cpp
@@ -523,49 +523,49 @@ js_ErrorFromException(JSContext *cx, jsv
         return NULL;
     priv = GetExnPrivate(obj);
     if (!priv)
         return NULL;
     return priv->errorReport;
 }
 
 static JSString *
-ValueToShortSource(JSContext *cx, jsval v)
+ValueToShortSource(JSContext *cx, const Value &v)
 {
     JSString *str;
 
     /* Avoid toSource bloat and fallibility for object types. */
-    if (JSVAL_IS_PRIMITIVE(v))
-        return js_ValueToSource(cx, Valueify(v));
+    if (!v.isObject())
+        return js_ValueToSource(cx, v);
 
-    AutoCompartment ac(cx, JSVAL_TO_OBJECT(v));
+    JSObject *obj = &v.toObject();
+    AutoCompartment ac(cx, obj);
     if (!ac.enter())
         return NULL;
 
-    if (VALUE_IS_FUNCTION(cx, v)) {
+    if (obj->isFunction()) {
         /*
          * XXX Avoid function decompilation bloat for now.
          */
-        str = JS_GetFunctionId(JS_ValueToFunction(cx, v));
-        if (!str && !(str = js_ValueToSource(cx, Valueify(v)))) {
+        str = JS_GetFunctionId(obj->getFunctionPrivate());
+        if (!str && !(str = js_ValueToSource(cx, v))) {
             /*
              * Continue to soldier on if the function couldn't be
              * converted into a string.
              */
             JS_ClearPendingException(cx);
             str = JS_NewStringCopyZ(cx, "[unknown function]");
         }
     } else {
         /*
          * XXX Avoid toString on objects, it takes too long and uses too much
          * memory, for too many classes (see Mozilla bug 166743).
          */
         char buf[100];
-        JS_snprintf(buf, sizeof buf, "[object %s]",
-                    JSVAL_TO_OBJECT(v)->getClass()->name);
+        JS_snprintf(buf, sizeof buf, "[object %s]", obj->getClass()->name);
         str = JS_NewStringCopyZ(cx, buf);
     }
 
     ac.leave();
 
     if (!str || !cx->compartment->wrap(cx, &str))
         return NULL;
     return str;
@@ -633,17 +633,17 @@ StackTraceToString(JSContext *cx, JSExnP
     elem = priv->stackElems;
     for (endElem = elem + priv->stackDepth; elem != endElem; elem++) {
         if (elem->funName) {
             APPEND_STRING_TO_STACK(elem->funName);
             APPEND_CHAR_TO_STACK('(');
             for (i = 0; i != elem->argc; i++, values++) {
                 if (i > 0)
                     APPEND_CHAR_TO_STACK(',');
-                str = ValueToShortSource(cx, *values);
+                str = ValueToShortSource(cx, Valueify(*values));
                 if (!str)
                     goto bad;
                 APPEND_STRING_TO_STACK(str);
             }
             APPEND_CHAR_TO_STACK(')');
         }
         APPEND_CHAR_TO_STACK('@');
         if (elem->filename) {
--- a/js/src/jsexn.h
+++ b/js/src/jsexn.h
@@ -97,14 +97,16 @@ js_ErrorFromException(JSContext *cx, jsv
 extern const JSErrorFormatString *
 js_GetLocalizedErrorMessage(JSContext* cx, void *userRef, const char *locale,
                             const uintN errorNumber);
 
 /*
  * Make a copy of errobj parented to scope.
  *
  * cx must be in the same compartment as scope. errobj may be in a different
- * compartment, but it must be an Error object (not a wrapper of one).
+ * compartment, but it must be an Error object (not a wrapper of one) and it
+ * must not be one of the prototype objects created by js_InitExceptionClasses
+ * (errobj->getPrivate() must not be NULL).
  */
 extern JSObject *
 js_CopyErrorObject(JSContext *cx, JSObject *errobj, JSObject *scope);
 
 #endif /* jsexn_h___ */
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -1246,18 +1246,19 @@ StackFrame::getValidCalleeObject(JSConte
                             return true;
                         }
 
                         if (shape->hasSlot()) {
                             Value v = thisp->getSlot(shape->slot);
                             JSObject *clone;
 
                             if (IsFunctionObject(v, &clone) &&
-                                GET_FUNCTION_PRIVATE(cx, clone) == fun &&
-                                clone->hasMethodObj(*thisp)) {
+                                clone->getFunctionPrivate() == fun &&
+                                clone->hasMethodObj(*thisp))
+                            {
                                 JS_ASSERT(clone != &funobj);
                                 *vp = v;
                                 overwriteCallee(*clone);
                                 return true;
                             }
                         }
                     }
 
@@ -1539,18 +1540,18 @@ js_XDRFunctionObject(JSXDRState *xdr, JS
     JSFunction *fun;
     uint32 firstword;           /* flag telling whether fun->atom is non-null,
                                    plus for fun->u.i.skipmin, fun->u.i.wrapper,
                                    and 14 bits reserved for future use */
     uint32 flagsword;           /* word for argument count and fun->flags */
 
     cx = xdr->cx;
     if (xdr->mode == JSXDR_ENCODE) {
-        fun = GET_FUNCTION_PRIVATE(cx, *objp);
-        if (!FUN_INTERPRETED(fun)) {
+        fun = (*objp)->getFunctionPrivate();
+        if (!fun->isInterpreted()) {
             JSAutoByteString funNameBytes;
             if (const char *name = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
                 JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NOT_SCRIPTED_FUNCTION,
                                      name);
             }
             return false;
         }
         if (fun->u.i.wrapper) {
@@ -1561,21 +1562,21 @@ js_XDRFunctionObject(JSXDRState *xdr, JS
         }
         JS_ASSERT((fun->u.i.wrapper & ~1U) == 0);
         firstword = (fun->u.i.skipmin << 2) | (fun->u.i.wrapper << 1) | !!fun->atom;
         flagsword = (fun->nargs << 16) | fun->flags;
     } else {
         fun = js_NewFunction(cx, NULL, NULL, 0, JSFUN_INTERPRETED, NULL, NULL);
         if (!fun)
             return false;
-        FUN_OBJECT(fun)->clearParent();
-        FUN_OBJECT(fun)->clearProto();
+        fun->clearParent();
+        fun->clearProto();
     }
 
-    AutoObjectRooter tvr(cx, FUN_OBJECT(fun));
+    AutoObjectRooter tvr(cx, fun);
 
     if (!JS_XDRUint32(xdr, &firstword))
         return false;
     if ((firstword & 1U) && !js_XDRAtom(xdr, &fun->atom))
         return false;
     if (!JS_XDRUint32(xdr, &flagsword))
         return false;
 
@@ -1592,17 +1593,17 @@ js_XDRFunctionObject(JSXDRState *xdr, JS
      * at the same time as we set the script's owner.
      */
     JSScript *script = fun->u.i.script;
     if (!js_XDRScript(xdr, &script))
         return false;
     fun->u.i.script = script;
 
     if (xdr->mode == JSXDR_DECODE) {
-        *objp = FUN_OBJECT(fun);
+        *objp = fun;
         fun->u.i.script->setOwnerObject(fun);
 #ifdef CHECK_SCRIPT_OWNER
         fun->script()->owner = NULL;
 #endif
         JS_ASSERT(fun->nargs == fun->script()->bindings.countArgs());
         js_CallNewScriptHook(cx, fun->script(), fun);
     }
 
@@ -1731,17 +1732,17 @@ fun_toStringHelper(JSContext *cx, JSObje
             return JSProxy::fun_toString(cx, obj, indent);
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
                              JSMSG_INCOMPATIBLE_PROTO,
                              js_Function_str, js_toString_str,
                              "object");
         return NULL;
     }
 
-    JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj);
+    JSFunction *fun = obj->getFunctionPrivate();
     if (!fun)
         return NULL;
 
     if (!indent && !cx->compartment->toSourceCache.empty()) {
         ToSourceCache::Ptr p = cx->compartment->toSourceCache.ref().lookup(fun);
         if (p)
             return p->value;
     }
@@ -2024,17 +2025,17 @@ static JSBool
 fun_isGenerator(JSContext *cx, uintN argc, Value *vp)
 {
     JSObject *funobj;
     if (!IsFunctionObject(vp[1], &funobj)) {
         JS_SET_RVAL(cx, vp, BooleanValue(false));
         return true;
     }
 
-    JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
+    JSFunction *fun = funobj->getFunctionPrivate();
 
     bool result = false;
     if (fun->isInterpreted()) {
         JSScript *script = fun->script();
         JS_ASSERT(script->length != 0);
         result = script->code[0] == JSOP_GENERATOR;
     }
 
@@ -2434,17 +2435,17 @@ js_NewFunction(JSContext *cx, JSObject *
             fun->u.n.native = native;
             fun->u.n.trcinfo = NULL;
         }
         JS_ASSERT(fun->u.n.native);
     }
     fun->atom = atom;
 
     /* Set private to self to indicate non-cloned fully initialized function. */
-    FUN_OBJECT(fun)->setPrivate(fun);
+    fun->setPrivate(fun);
     return fun;
 }
 
 JSObject * JS_FASTCALL
 js_CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent,
                        JSObject *proto)
 {
     JS_ASSERT(parent);
@@ -2648,17 +2649,17 @@ JS_STATIC_ASSERT((JSV2F_CONSTRUCT & JSV2
 JSFunction *
 js_ValueToFunction(JSContext *cx, const Value *vp, uintN flags)
 {
     JSObject *funobj;
     if (!IsFunctionObject(*vp, &funobj)) {
         js_ReportIsNotFunction(cx, vp, flags);
         return NULL;
     }
-    return GET_FUNCTION_PRIVATE(cx, funobj);
+    return funobj->getFunctionPrivate();
 }
 
 JSObject *
 js_ValueToFunctionObject(JSContext *cx, Value *vp, uintN flags)
 {
     JSObject *funobj;
     if (!IsFunctionObject(*vp, &funobj)) {
         js_ReportIsNotFunction(cx, vp, flags);
--- a/js/src/jsfun.h
+++ b/js/src/jsfun.h
@@ -55,38 +55,38 @@
  * or interpreted, and if interpreted, what kind of optimized closure form (if
  * any) it might be.
  *
  *   00   not interpreted
  *   01   interpreted, neither flat nor null closure
  *   10   interpreted, flat closure
  *   11   interpreted, null closure
  *
- * FUN_FLAT_CLOSURE implies FUN_INTERPRETED and u.i.script->upvarsOffset != 0.
- * FUN_NULL_CLOSURE implies FUN_INTERPRETED and u.i.script->upvarsOffset == 0.
+ * isFlatClosure() implies isInterpreted() and u.i.script->upvarsOffset != 0.
+ * isNullClosure() implies isInterpreted() and u.i.script->upvarsOffset == 0.
  *
- * FUN_INTERPRETED but not FUN_FLAT_CLOSURE and u.i.script->upvarsOffset != 0
+ * isInterpreted() but not isFlatClosure() and u.i.script->upvarsOffset != 0
  * is an Algol-like function expression or nested function, i.e., a function
  * that never escapes upward or downward (heapward), and is only ever called.
  *
- * Finally, FUN_INTERPRETED and u.i.script->upvarsOffset == 0 could be either
+ * Finally, isInterpreted() and u.i.script->upvarsOffset == 0 could be either
  * a non-closure (a global function definition, or any function that uses no
  * outer names), or a closure of an escaping function that uses outer names
  * whose values can't be snapshot (because the outer names could be reassigned
  * after the closure is formed, or because assignments could not be analyzed
  * due to with or eval).
  *
  * Such a hard-case function must use JSOP_NAME, etc., and reify outer function
  * activations' call objects, etc. if it's not a global function.
  *
  * NB: JSFUN_EXPR_CLOSURE reuses JSFUN_STUB_GSOPS, which is an API request flag
  * bit only, never stored in fun->flags.
  *
- * If we need more bits in the future, all flags for FUN_INTERPRETED functions
- * can move to u.i.script->flags. For now we use function flag bits to minimize
+ * If we need more bits in the future, all flags for interpreted functions can
+ * move to u.i.script->flags. For now we use function flag bits to minimize
  * pointer-chasing.
  */
 #define JSFUN_JOINABLE      0x0001  /* function is null closure that does not
                                        appear to call itself via its own name
                                        or arguments.callee */
 
 #define JSFUN_PROTOTYPE     0x0800  /* function is Function.prototype for some
                                        global object */
@@ -96,29 +96,16 @@
                                        JSFunctionSpec::call points to a
                                        JSNativeTraceInfo. */
 #define JSFUN_INTERPRETED   0x4000  /* use u.i if kind >= this value else u.n */
 #define JSFUN_FLAT_CLOSURE  0x8000  /* flat (aka "display") closure */
 #define JSFUN_NULL_CLOSURE  0xc000  /* null closure entrains no scope chain */
 #define JSFUN_KINDMASK      0xc000  /* encode interp vs. native and closure
                                        optimization level -- see above */
 
-#define FUN_OBJECT(fun)      (static_cast<JSObject *>(fun))
-#define FUN_KIND(fun)        ((fun)->flags & JSFUN_KINDMASK)
-#define FUN_SET_KIND(fun,k)  ((fun)->flags = ((fun)->flags & ~JSFUN_KINDMASK) | (k))
-#define FUN_INTERPRETED(fun) (FUN_KIND(fun) >= JSFUN_INTERPRETED)
-#define FUN_FLAT_CLOSURE(fun)(FUN_KIND(fun) == JSFUN_FLAT_CLOSURE)
-#define FUN_NULL_CLOSURE(fun)(FUN_KIND(fun) == JSFUN_NULL_CLOSURE)
-#define FUN_SCRIPT(fun)      (FUN_INTERPRETED(fun) ? (fun)->script() : NULL)
-#define FUN_CLASP(fun)       (JS_ASSERT(!FUN_INTERPRETED(fun)),               \
-                              fun->u.n.clasp)
-#define FUN_TRCINFO(fun)     (JS_ASSERT(!FUN_INTERPRETED(fun)),               \
-                              JS_ASSERT((fun)->flags & JSFUN_TRCINFO),        \
-                              fun->u.n.trcinfo)
-
 struct JSFunction : public JSObject_Slots2
 {
     /* Functions always have two fixed slots (FUN_CLASS_RESERVED_SLOTS). */
 
     uint16          nargs;        /* maximum number of specified arguments,
                                      reflected as f.length/f.arity */
     uint16          flags;        /* flags, see JSFUN_* below and in jsapi.h */
     union U {
@@ -140,26 +127,35 @@ struct JSFunction : public JSObject_Slot
                                      indirect eval; if true, then this function
                                      object's proto is the wrapped object */
             js::Shape   *names;   /* argument and variable names */
         } i;
         void            *nativeOrScript;
     } u;
     JSAtom          *atom;        /* name for diagnostics and decompiling */
 
-    bool optimizedClosure()  const { return FUN_KIND(this) > JSFUN_INTERPRETED; }
-    bool isInterpreted()     const { return FUN_INTERPRETED(this); }
-    bool isNative()          const { return !FUN_INTERPRETED(this); }
+    bool optimizedClosure()  const { return kind() > JSFUN_INTERPRETED; }
+    bool isInterpreted()     const { return kind() >= JSFUN_INTERPRETED; }
+    bool isNative()          const { return !isInterpreted(); }
     bool isConstructor()     const { return flags & JSFUN_CONSTRUCTOR; }
     bool isHeavyweight()     const { return JSFUN_HEAVYWEIGHT_TEST(flags); }
-    bool isFlatClosure()     const { return FUN_KIND(this) == JSFUN_FLAT_CLOSURE; }
+    bool isNullClosure()     const { return kind() == JSFUN_NULL_CLOSURE; }
+    bool isFlatClosure()     const { return kind() == JSFUN_FLAT_CLOSURE; }
     bool isFunctionPrototype() const { return flags & JSFUN_PROTOTYPE; }
     bool isInterpretedConstructor() const { return isInterpreted() && !isFunctionPrototype(); }
+
+    uint16 kind()            const { return flags & JSFUN_KINDMASK; }
+    void setKind(uint16 k) {
+        JS_ASSERT(!(k & ~JSFUN_KINDMASK));
+        flags = (flags & ~JSFUN_KINDMASK) | k;
+    }
+
     /* Returns the strictness of this function, which must be interpreted. */
     inline bool inStrictMode() const;
+
     void setArgCount(uint16 nargs) {
         JS_ASSERT(this->nargs == 0);
         this->nargs = nargs;
     }
 
     /* uint16 representation bounds number of call object dynamic slots. */
     enum { MAX_ARGS_AND_VARS = 2 * ((1U << 16) - 1) };
 
@@ -205,16 +201,20 @@ struct JSFunction : public JSObject_Slot
 
     inline void setMethodAtom(JSAtom *atom);
 
     JSScript *script() const {
         JS_ASSERT(isInterpreted());
         return u.i.script;
     }
 
+    JSScript * maybeScript() const {
+        return isInterpreted() ? script() : NULL;
+    }
+
     js::Native native() const {
         JS_ASSERT(isNative());
         return u.n.native;
     }
 
     js::Native maybeNative() const {
         return isInterpreted() ? NULL : native();
     }
@@ -222,16 +222,33 @@ struct JSFunction : public JSObject_Slot
     static uintN offsetOfNativeOrScript() {
         JS_STATIC_ASSERT(offsetof(U, n.native) == offsetof(U, i.script));
         JS_STATIC_ASSERT(offsetof(U, n.native) == offsetof(U, nativeOrScript));
         return offsetof(JSFunction, u.nativeOrScript);
     }
 
     /* Number of extra fixed function object slots. */
     static const uint32 CLASS_RESERVED_SLOTS = JSObject::FUN_CLASS_RESERVED_SLOTS;
+
+
+    js::Class *getConstructorClass() const {
+        JS_ASSERT(isNative());
+        return u.n.clasp;
+    }
+
+    void setConstructorClass(js::Class *clasp) {
+        JS_ASSERT(isNative());
+        u.n.clasp = clasp;
+    }
+
+    JSNativeTraceInfo *getTraceInfo() const {
+        JS_ASSERT(isNative());
+        JS_ASSERT(flags & JSFUN_TRCINFO);
+        return u.n.trcinfo;
+    }
 };
 
 /*
  * Trace-annotated native. This expands to a JSFunctionSpec initializer (like
  * JS_FN in jsapi.h). fastcall is a FastNative; trcinfo is a
  * JSNativeTraceInfo*.
  */
 #ifdef JS_TRACER
@@ -264,22 +281,16 @@ inline JSFunction *
 JSObject::getFunctionPrivate() const
 {
     JS_ASSERT(isFunction());
     return reinterpret_cast<JSFunction *>(getPrivate());
 }
 
 namespace js {
 
-/*
- * NB: jsapi.h and jsobj.h must be included before any call to this macro.
- */
-#define VALUE_IS_FUNCTION(cx, v)                                              \
-    (!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isFunction())
-
 static JS_ALWAYS_INLINE bool
 IsFunctionObject(const js::Value &v)
 {
     return v.isObject() && v.toObject().isFunction();
 }
 
 static JS_ALWAYS_INLINE bool
 IsFunctionObject(const js::Value &v, JSObject **funobj)
@@ -350,24 +361,16 @@ extern JS_ALWAYS_INLINE bool
 SameTraceType(const Value &lhs, const Value &rhs)
 {
     return SameType(lhs, rhs) &&
            (lhs.isPrimitive() ||
             lhs.toObject().isFunction() == rhs.toObject().isFunction());
 }
 
 /*
- * Macro to access the private slot of the function object after the slot is
- * initialized.
- */
-#define GET_FUNCTION_PRIVATE(cx, funobj)                                      \
-    (JS_ASSERT((funobj)->isFunction()),                                       \
-     (JSFunction *) (funobj)->getPrivate())
-
-/*
  * Return true if this is a compiler-created internal function accessed by
  * its own object. Such a function object must not be accessible to script
  * or embedding code.
  */
 inline bool
 IsInternalFunctionObject(JSObject *funobj)
 {
     JS_ASSERT(funobj->isFunction());
--- a/js/src/jsfuninlines.h
+++ b/js/src/jsfuninlines.h
@@ -47,17 +47,17 @@ inline bool
 JSFunction::inStrictMode() const
 {
     return script()->strictModeCode;
 }
 
 inline void
 JSFunction::setJoinable()
 {
-    JS_ASSERT(FUN_INTERPRETED(this));
+    JS_ASSERT(isInterpreted());
     setSlot(METHOD_ATOM_SLOT, js::NullValue());
     flags |= JSFUN_JOINABLE;
 }
 
 inline void
 JSFunction::setMethodAtom(JSAtom *atom)
 {
     JS_ASSERT(joinable());
--- a/js/src/jsinterp.cpp
+++ b/js/src/jsinterp.cpp
@@ -4585,20 +4585,20 @@ BEGIN_CASE(JSOP_DEFFUN)
     /*
      * A top-level function defined in Global or Eval code (see ECMA-262
      * Ed. 3), or else a SpiderMonkey extension: a named function statement in
      * a compound statement (not at the top statement level of global code, or
      * at the top level of a function body).
      */
     JSFunction *fun;
     LOAD_FUNCTION(0);
-    JSObject *obj = FUN_OBJECT(fun);
+    JSObject *obj = fun;
 
     JSObject *obj2;
-    if (FUN_NULL_CLOSURE(fun)) {
+    if (fun->isNullClosure()) {
         /*
          * Even a null closure needs a parent for principals finding.
          * FIXME: bug 476950, although debugger users may also demand some kind
          * of scope link for debugger-assisted eval-in-frame.
          */
         obj2 = &regs.fp()->scopeChain();
     } else {
         JS_ASSERT(!fun->isFlatClosure());
@@ -4725,20 +4725,20 @@ BEGIN_CASE(JSOP_DEFLOCALFUN)
      * function), parented by the current scope chain, stored in a local
      * variable slot that the compiler allocated.  This is an optimization over
      * JSOP_DEFFUN that avoids requiring a call object for the outer function's
      * activation.
      */
     JSFunction *fun;
     LOAD_FUNCTION(SLOTNO_LEN);
     JS_ASSERT(fun->isInterpreted());
-    JS_ASSERT(!FUN_FLAT_CLOSURE(fun));
-    JSObject *obj = FUN_OBJECT(fun);
-
-    if (FUN_NULL_CLOSURE(fun)) {
+    JS_ASSERT(!fun->isFlatClosure());
+    JSObject *obj = fun;
+
+    if (fun->isNullClosure()) {
         obj = CloneFunctionObject(cx, fun, &regs.fp()->scopeChain());
         if (!obj)
             goto error;
     } else {
         JSObject *parent = GetScopeChainFast(cx, regs.fp(), JSOP_DEFLOCALFUN,
                                              JSOP_DEFLOCALFUN_LENGTH);
         if (!parent)
             goto error;
@@ -4777,22 +4777,22 @@ BEGIN_CASE(JSOP_DEFLOCALFUN_FC)
 }
 END_CASE(JSOP_DEFLOCALFUN_FC)
 
 BEGIN_CASE(JSOP_LAMBDA)
 {
     /* Load the specified function object literal. */
     JSFunction *fun;
     LOAD_FUNCTION(0);
-    JSObject *obj = FUN_OBJECT(fun);
+    JSObject *obj = fun;
 
     /* do-while(0) so we can break instead of using a goto. */
     do {
         JSObject *parent;
-        if (FUN_NULL_CLOSURE(fun)) {
+        if (fun->isNullClosure()) {
             parent = &regs.fp()->scopeChain();
 
             if (obj->getParent() == parent) {
                 jsbytecode *pc2 = AdvanceOverBlockchainOp(regs.pc + JSOP_LAMBDA_LENGTH);
                 JSOp op2 = JSOp(*pc2);
 
                 /*
                  * Optimize var obj = {method: function () { ... }, ...},
@@ -4840,17 +4840,17 @@ BEGIN_CASE(JSOP_LAMBDA)
                          * Note that we have not yet pushed obj as the final argument,
                          * so regs.sp[1 - (iargc + 2)], and not regs.sp[-(iargc + 2)],
                          * is the callee for this JSOP_CALL.
                          */
                         const Value &cref = regs.sp[1 - (iargc + 2)];
                         JSObject *callee;
 
                         if (IsFunctionObject(cref, &callee)) {
-                            JSFunction *calleeFun = GET_FUNCTION_PRIVATE(cx, callee);
+                            JSFunction *calleeFun = callee->getFunctionPrivate();
                             if (Native native = calleeFun->maybeNative()) {
                                 if ((iargc == 1 && native == array_sort) ||
                                     (iargc == 2 && native == str_replace)) {
                                     break;
                                 }
                             }
                         }
                     } else if (op2 == JSOP_NULL) {
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -3914,29 +3914,29 @@ DefineConstructorAndPrototype(JSContext 
          * because the constructor currently must have |obj| as its parent.
          * (FIXME: remove this dependency on the exact identity of the parent,
          * perhaps as part of bug 638316.)
          */
         JSFunction *fun =
             js_NewFunction(cx, NULL, constructor, nargs, JSFUN_CONSTRUCTOR, obj, atom);
         if (!fun)
             goto bad;
-        FUN_CLASP(fun) = clasp;
+        fun->setConstructorClass(clasp);
 
         AutoValueRooter tvr2(cx, ObjectValue(*fun));
         if (!DefineStandardSlot(cx, obj, key, atom, tvr2.value(), 0, named))
             goto bad;
 
         /*
          * Optionally construct the prototype object, before the class has
          * been fully initialized.  Allow the ctor to replace proto with a
          * different object, as is done for operator new -- and as at least
          * XML support requires.
          */
-        ctor = FUN_OBJECT(fun);
+        ctor = fun;
         if (clasp->flags & JSCLASS_CONSTRUCT_PROTOTYPE) {
             Value rval;
             if (!InvokeConstructorWithGivenThis(cx, proto, ObjectOrNullValue(ctor),
                                                 0, NULL, &rval)) {
                 goto bad;
             }
             if (rval.isObject() && &rval.toObject() != proto)
                 proto = &rval.toObject();
@@ -4704,17 +4704,17 @@ DefineNativeProperty(JSContext *cx, JSOb
         /* Add a new property, or replace an existing one of the same id. */
         if (defineHow & DNP_SET_METHOD) {
             JS_ASSERT(clasp == &js_ObjectClass);
             JS_ASSERT(IsFunctionObject(value));
             JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
             JS_ASSERT(!getter && !setter);
 
             JSObject *funobj = &value.toObject();
-            if (FUN_OBJECT(GET_FUNCTION_PRIVATE(cx, funobj)) == funobj) {
+            if (funobj->getFunctionPrivate() == funobj) {
                 flags |= Shape::METHOD;
                 getter = CastAsPropertyOp(funobj);
             }
         }
 
         if (const Shape *existingShape = obj->nativeLookup(id)) {
             if (existingShape->hasSlot())
                 AbortRecordingIfUnexpectedGlobalWrite(cx, obj, existingShape->slot);
@@ -5657,17 +5657,17 @@ js_SetPropertyHelper(JSContext *cx, JSOb
          * Check for Object class here to avoid defining a method on a class
          * with magic resolve, addProperty, getProperty, etc. hooks.
          */
         if ((defineHow & DNP_SET_METHOD) && obj->canHaveMethodBarrier()) {
             JS_ASSERT(IsFunctionObject(*vp));
             JS_ASSERT(!(attrs & (JSPROP_GETTER | JSPROP_SETTER)));
 
             JSObject *funobj = &vp->toObject();
-            JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
+            JSFunction *fun = funobj->getFunctionPrivate();
             if (fun == funobj) {
                 flags |= Shape::METHOD;
                 getter = CastAsPropertyOp(funobj);
             }
         }
 
         shape = obj->putProperty(cx, id, getter, setter, SHAPE_INVALID_SLOT,
                                  attrs, flags, shortid);
@@ -5792,17 +5792,17 @@ js_DeleteProperty(JSContext *cx, JSObjec
          * We do not check suspended frames. They can't be reached via caller,
          * so the only way they could have the method's joined function object
          * as callee is through an API abusage. We break any such edge case.
          */
         if (obj->hasMethodBarrier()) {
             JSObject *funobj;
 
             if (IsFunctionObject(v, &funobj)) {
-                JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
+                JSFunction *fun = funobj->getFunctionPrivate();
 
                 if (fun != funobj) {
                     for (StackFrame *fp = cx->maybefp(); fp; fp = fp->prev()) {
                         if (fp->isFunctionFrame() &&
                             fp->callee() == fun->compiledFunObj() &&
                             fp->thisValue().isObject())
                         {
                             JSObject *tmp = &fp->thisValue().toObject();
@@ -6487,17 +6487,17 @@ dumpValue(const Value &v)
     else if (v.isInt32())
         fprintf(stderr, "%d", v.toInt32());
     else if (v.isDouble())
         fprintf(stderr, "%g", v.toDouble());
     else if (v.isString())
         dumpString(v.toString());
     else if (v.isObject() && v.toObject().isFunction()) {
         JSObject *funobj = &v.toObject();
-        JSFunction *fun = GET_FUNCTION_PRIVATE(cx, funobj);
+        JSFunction *fun = funobj->getFunctionPrivate();
         if (fun->atom) {
             fputs("<function ", stderr);
             FileEscapedString(stderr, fun->atom, 0);
         } else {
             fputs("<unnamed function", stderr);
         }
         if (fun->isInterpreted()) {
             JSScript *script = fun->script();
--- a/js/src/jsobjinlines.h
+++ b/js/src/jsobjinlines.h
@@ -213,17 +213,17 @@ JSObject::methodReadBarrier(JSContext *c
     JS_ASSERT(shape.writable());
     JS_ASSERT(shape.slot != SHAPE_INVALID_SLOT);
     JS_ASSERT(shape.hasDefaultSetter());
     JS_ASSERT(!isGlobal());  /* i.e. we are not changing the global shape */
 
     JSObject *funobj = &vp->toObject();
     JSFunction *fun = funobj->getFunctionPrivate();
     JS_ASSERT(fun == funobj);
-    JS_ASSERT(FUN_NULL_CLOSURE(fun));
+    JS_ASSERT(fun->isNullClosure());
 
     funobj = CloneFunctionObject(cx, fun, funobj->getParent());
     if (!funobj)
         return NULL;
     funobj->setMethodObj(*this);
 
     /*
      * Replace the method property with an ordinary data property. This is
@@ -545,17 +545,17 @@ JSObject::setFlatClosureUpvar(uint32 i, 
     JS_ASSERT(i < getFunctionPrivate()->script()->bindings.countUpvars());
     getFlatClosureUpvars()[i] = v;
 }
 
 inline void
 JSObject::setFlatClosureUpvars(js::Value *upvars)
 {
     JS_ASSERT(isFunction());
-    JS_ASSERT(FUN_FLAT_CLOSURE(getFunctionPrivate()));
+    JS_ASSERT(getFunctionPrivate()->isFlatClosure());
     setSlot(JSSLOT_FLAT_CLOSURE_UPVARS, PrivateValue(upvars));
 }
 
 inline bool
 JSObject::hasMethodObj(const JSObject& obj) const
 {
     return JSSLOT_FUN_METHOD_OBJ < numSlots() &&
            getSlot(JSSLOT_FUN_METHOD_OBJ).isObject() &&
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -391,17 +391,17 @@ ToDisassemblySource(JSContext *cx, jsval
             source = JS_sprintf_append(source, "}");
             if (!source)
                 return false;
             bytes->initBytes(source);
             return true;
         }
 
         if (clasp == &js_FunctionClass) {
-            JSFunction *fun = GET_FUNCTION_PRIVATE(cx, obj);
+            JSFunction *fun = obj->getFunctionPrivate();
             JSString *str = JS_DecompileFunction(cx, fun, JS_DONT_PRETTY_PRINT);
             if (!str)
                 return false;
             return bytes->encode(cx, str);
         }
 
         if (clasp == &js_RegExpClass) {
             AutoValueRooter tvr(cx);
@@ -4967,17 +4967,17 @@ static const char native_code_str[] = "\
 
 JSBool
 js_DecompileFunctionBody(JSPrinter *jp)
 {
     JSScript *script;
 
     JS_ASSERT(jp->fun);
     JS_ASSERT(!jp->script);
-    if (!FUN_INTERPRETED(jp->fun)) {
+    if (!jp->fun->isInterpreted()) {
         js_printf(jp, native_code_str);
         return JS_TRUE;
     }
 
     script = jp->fun->script();
     return DecompileBody(jp, script, script->code);
 }
 
@@ -5006,17 +5006,17 @@ js_DecompileFunction(JSPrinter *jp)
             js_puts(jp, "(");
     }
 
     js_printf(jp, "%s ", js_function_str);
     if (fun->atom && !QuoteString(&jp->sprinter, fun->atom, 0))
         return JS_FALSE;
     js_puts(jp, "(");
 
-    if (!FUN_INTERPRETED(fun)) {
+    if (!fun->isInterpreted()) {
         js_printf(jp, ") {\n");
         jp->indent += 4;
         js_printf(jp, native_code_str);
         jp->indent -= 4;
         js_printf(jp, "\t}");
     } else {
         JSScript *script = fun->script();
 #if JS_HAS_DESTRUCTURING
--- a/js/src/jsparse.cpp
+++ b/js/src/jsparse.cpp
@@ -308,17 +308,17 @@ Parser::newFunctionBox(JSObject *obj, JS
     if (tc->innermostWith)
         funbox->tcflags |= TCF_IN_WITH;
     return funbox;
 }
 
 bool
 JSFunctionBox::joinable() const
 {
-    return FUN_NULL_CLOSURE(function()) &&
+    return function()->isNullClosure() &&
            !(tcflags & (TCF_FUN_USES_ARGUMENTS | TCF_FUN_USES_OWN_NAME));
 }
 
 bool
 JSFunctionBox::inAnyDynamicScope() const
 {
     for (const JSFunctionBox *funbox = this; funbox; funbox = funbox->parent) {
         if (funbox->tcflags & (TCF_IN_WITH | TCF_FUN_CALLS_EVAL))
@@ -985,17 +985,17 @@ Compiler::compileScript(JSContext *cx, J
         }
 
         if (callerFrame && callerFrame->isFunctionFrame()) {
             /*
              * An eval script in a caller frame needs to have its enclosing
              * function captured in case it refers to an upvar, and someone
              * wishes to decompile it while it's running.
              */
-            JSObjectBox *funbox = parser.newObjectBox(FUN_OBJECT(callerFrame->fun()));
+            JSObjectBox *funbox = parser.newObjectBox(callerFrame->fun());
             if (!funbox)
                 goto out;
             funbox->emitLink = cg.objectList.lastbox;
             cg.objectList.lastbox = funbox;
             cg.objectList.length++;
 #ifdef DEBUG
             savedCallerFun = true;
 #endif
@@ -1973,18 +1973,18 @@ Parser::newFunction(JSTreeContext *tc, J
         tc = tc->parent;
     JSObject *parent = tc->inFunction() ? NULL : tc->scopeChain();
 
     JSFunction *fun =
         js_NewFunction(context, NULL, NULL, 0,
                        JSFUN_INTERPRETED | (kind == Expression ? JSFUN_LAMBDA : 0),
                        parent, atom);
     if (fun && !tc->compileAndGo()) {
-        FUN_OBJECT(fun)->clearParent();
-        FUN_OBJECT(fun)->clearProto();
+        fun->clearParent();
+        fun->clearProto();
     }
     return fun;
 }
 
 static JSBool
 MatchOrInsertSemicolon(JSContext *cx, TokenStream *ts)
 {
     TokenKind tt = ts->peekTokenSameLine(TSF_OPERAND);
@@ -2456,22 +2456,22 @@ Parser::setFunctionKinds(JSFunctionBox *
 
                 if (funbox->shouldUnbrand(methodSets, slowMethodSets))
                     funbox->tcflags |= TCF_FUN_UNBRAND_THIS;
             }
         }
 
         JSFunction *fun = funbox->function();
 
-        JS_ASSERT(FUN_KIND(fun) == JSFUN_INTERPRETED);
+        JS_ASSERT(fun->kind() == JSFUN_INTERPRETED);
 
         if (funbox->tcflags & TCF_FUN_HEAVYWEIGHT) {
             /* nothing to do */
         } else if (funbox->inAnyDynamicScope()) {
-            JS_ASSERT(!FUN_NULL_CLOSURE(fun));
+            JS_ASSERT(!fun->isNullClosure());
         } else if (pn->pn_type != TOK_UPVARS) {
             /*
              * No lexical dependencies => null closure, for best performance.
              * A null closure needs no scope chain, but alas we've coupled
              * principals-finding to scope (for good fundamental reasons, but
              * the implementation overloads the parent slot and we should fix
              * that). See, e.g., the JSOP_LAMBDA case in jsinterp.cpp.
              *
@@ -2479,17 +2479,17 @@ Parser::setFunctionKinds(JSFunctionBox *
              * "joined function objects", or not, at its discretion. But real-
              * world implementations always create unique function objects for
              * closures, and this can be detected via mutation. Open question:
              * do popular implementations create unique function objects for
              * null closures?
              *
              * FIXME: bug 476950.
              */
-            FUN_SET_KIND(fun, JSFUN_NULL_CLOSURE);
+            fun->setKind(JSFUN_NULL_CLOSURE);
         } else {
             AtomDefnMapPtr upvars = pn->pn_names;
             JS_ASSERT(!upvars->empty());
 
             if (!fn->isFunArg()) {
                 /*
                  * This function is Algol-like, it never escapes.
                  *
@@ -2507,17 +2507,17 @@ Parser::setFunctionKinds(JSFunctionBox *
 
                     if (!lexdep->isFreeVar()) {
                         JS_ASSERT(lexdep->frameLevel() <= funbox->level);
                         break;
                     }
                 }
 
                 if (r.empty())
-                    FUN_SET_KIND(fun, JSFUN_NULL_CLOSURE);
+                    fun->setKind(JSFUN_NULL_CLOSURE);
             } else {
                 uintN nupvars = 0, nflattened = 0;
 
                 /*
                  * For each lexical dependency from this closure to an outer
                  * binding, analyze whether it is safe to copy the binding's
                  * value into a flat closure slot when the closure is formed.
                  */
@@ -2545,23 +2545,23 @@ Parser::setFunctionKinds(JSFunctionBox *
                          * closure. This is safe because we leave fun's kind
                          * set to interpreted, so all functions holding its
                          * upvars will be flagged as heavyweight.
                          */
                     }
                 }
 
                 if (nupvars == 0) {
-                    FUN_SET_KIND(fun, JSFUN_NULL_CLOSURE);
+                    fun->setKind(JSFUN_NULL_CLOSURE);
                 } else if (nflattened == nupvars) {
                     /*
                      * We made it all the way through the upvar loop, so it's
                      * safe to optimize to a flat closure.
                      */
-                    FUN_SET_KIND(fun, JSFUN_FLAT_CLOSURE);
+                    fun->setKind(JSFUN_FLAT_CLOSURE);
                     switch (PN_OP(fn)) {
                       case JSOP_DEFFUN:
                         fn->pn_op = JSOP_DEFFUN_FC;
                         break;
                       case JSOP_DEFLOCALFUN:
                         fn->pn_op = JSOP_DEFLOCALFUN_FC;
                         break;
                       case JSOP_LAMBDA:
@@ -2570,17 +2570,17 @@ Parser::setFunctionKinds(JSFunctionBox *
                       default:
                         /* js_EmitTree's case TOK_FUNCTION: will select op. */
                         JS_ASSERT(PN_OP(fn) == JSOP_NOP);
                     }
                 }
             }
         }
 
-        if (FUN_KIND(fun) == JSFUN_INTERPRETED && pn->pn_type == TOK_UPVARS) {
+        if (fun->kind() == JSFUN_INTERPRETED && pn->pn_type == TOK_UPVARS) {
             /*
              * One or more upvars cannot be safely snapshot into a flat
              * closure's non-reserved slot (see JSOP_GETFCSLOT), so we loop
              * again over all upvars, and for each non-free upvar, ensure that
              * its containing function has been flagged as heavyweight.
              *
              * The emitter must see TCF_FUN_HEAVYWEIGHT accurately before
              * generating any code for a tree of nested functions.
@@ -2616,17 +2616,17 @@ Parser::setFunctionKinds(JSFunctionBox *
  * must have their OWN_SHAPE flags set; the comments for
  * js::Bindings::extensibleParents explain why.
  */
 void
 Parser::markExtensibleScopeDescendants(JSFunctionBox *funbox, bool hasExtensibleParent) 
 {
     for (; funbox; funbox = funbox->siblings) {
         /*
-         * It would be nice to use FUN_KIND(fun) here to recognize functions
+         * It would be nice to use fun->kind() here to recognize functions
          * that will never consult their parent chains, and thus don't need
          * their 'extensible parents' flag set. Filed as bug 619750. 
          */
 
         JS_ASSERT(!funbox->bindings.extensibleParents());
         if (hasExtensibleParent)
             funbox->bindings.setExtensibleParents();
 
@@ -2658,17 +2658,17 @@ EnterFunction(JSParseNode *fn, JSTreeCon
               FunctionSyntaxKind kind = Expression)
 {
     JSTreeContext *tc = funtc->parent;
     JSFunction *fun = tc->parser->newFunction(tc, funAtom, kind);
     if (!fun)
         return NULL;
 
     /* Create box for fun->object early to protect against last-ditch GC. */
-    JSFunctionBox *funbox = tc->parser->newFunctionBox(FUN_OBJECT(fun), fn, tc);
+    JSFunctionBox *funbox = tc->parser->newFunctionBox(fun, fn, tc);
     if (!funbox)
         return NULL;
 
     /* Initialize non-default members of funtc. */
     funtc->flags |= funbox->tcflags;
     funtc->blockidGen = tc->blockidGen;
     if (!GenerateBlockId(funtc, funtc->bodyid))
         return NULL;
--- a/js/src/jsprobes.cpp
+++ b/js/src/jsprobes.cpp
@@ -85,20 +85,20 @@ FunctionName(JSContext *cx, const JSFunc
     if (!atom)
         return Probes::anonymousName;
     return bytes->encode(cx, atom) ? bytes->ptr() : Probes::nullName;
 }
 
 static const char *
 FunctionClassname(const JSFunction *fun)
 {
-    if (!fun || FUN_INTERPRETED(fun))
+    if (!fun || fun->isInterpreted())
         return Probes::nullName;
-    if (!(fun->flags & JSFUN_TRCINFO) && FUN_CLASP(fun))
-        return (char *)FUN_CLASP(fun)->name;
+    if (!(fun->flags & JSFUN_TRCINFO) && fun->getConstructorClass())
+        return fun->getConstructorClass()->name;
     return Probes::nullName;
 }
 
 /*
  * These functions call the DTrace macros for the JavaScript USDT probes.
  * Originally this code was inlined in the JavaScript code; however since
  * a number of operations are called, these have been placed into functions
  * to reduce any negative compiler optimization effect that the addition of
--- a/js/src/jspropertycache.cpp
+++ b/js/src/jspropertycache.cpp
@@ -166,17 +166,17 @@ PropertyCache::fill(JSContext *cx, JSObj
                      * obj with a new shape and set the JSObject::BRANDED flag.
                      * Once this flag is set, any property assignment that
                      * changes the value from or to a different function object
                      * will result in shape being regenerated.
                      */
                     if (!pobj->branded()) {
                         PCMETER(brandfills++);
 #ifdef DEBUG_notme
-                        JSFunction *fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(v));
+                        JSFunction *fun = JSVAL_TO_OBJECT(v)->getFunctionPrivate();
                         JSAutoByteString funNameBytes;
                         if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
                             fprintf(stderr,
                                     "branding %p (%s) for funobj %p (%s), shape %lu\n",
                                     pobj, pobj->getClass()->name, JSVAL_TO_OBJECT(v), funName,
                                     obj->shape());
                         }
 #endif
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -1229,17 +1229,17 @@ JSScript::NewScriptFromCG(JSContext *cx,
     }
 
     script->bindings.transfer(cx, &cg->bindings);
 
     fun = NULL;
     if (cg->inFunction()) {
         /*
          * We initialize fun->u.i.script to be the script constructed above
-         * so that the debugger has a valid FUN_SCRIPT(fun).
+         * so that the debugger has a valid fun->script().
          */
         fun = cg->fun();
         JS_ASSERT(fun->isInterpreted());
         JS_ASSERT(!fun->script());
 #ifdef DEBUG
         if (JSScript::isValidOffset(script->upvarsOffset))
             JS_ASSERT(script->upvars()->length == script->bindings.countUpvars());
         else
--- a/js/src/jsscriptinlines.h
+++ b/js/src/jsscriptinlines.h
@@ -115,17 +115,17 @@ CurrentScriptFileAndLine(JSContext *cx, 
 
 inline JSFunction *
 JSScript::getFunction(size_t index)
 {
     JSObject *funobj = getObject(index);
     JS_ASSERT(funobj->isFunction());
     JS_ASSERT(funobj == (JSObject *) funobj->getPrivate());
     JSFunction *fun = (JSFunction *) funobj;
-    JS_ASSERT(FUN_INTERPRETED(fun));
+    JS_ASSERT(fun->isInterpreted());
     return fun;
 }
 
 inline JSFunction *
 JSScript::getCallerFunction()
 {
     JS_ASSERT(savedCallerFun);
     return getFunction(0);
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -2805,17 +2805,17 @@ ValueToNative(const Value &v, JSValueTyp
 
       case JSVAL_TYPE_MAGIC:
         JS_ASSERT(v.isMagic());
         debug_only_print0(LC_TMTracer, "hole ");
         return;
 
       case JSVAL_TYPE_FUNOBJ: {
         JS_ASSERT(IsFunctionObject(v));
-        JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &v.toObject());
+        JSFunction* fun = v.toObject().getFunctionPrivate();
 #if defined JS_JIT_SPEW
         if (LogController.lcbits & LC_TMTracer) {
             char funName[40];
             if (fun->atom)
                 JS_PutEscapedFlatString(funName, sizeof funName, fun->atom, 0);
             else
                 strcpy(funName, "unnamed");
             LogController.printf("function<%p:%s> ", (void*)*(JSObject **)slot, funName);
@@ -3104,17 +3104,17 @@ NativeToValue(JSContext* cx, Value& v, J
         break;
       case JSVAL_TYPE_MAGIC:
         debug_only_printf(LC_TMTracer, "magic<%d> ", v.whyMagic());
         break;
       case JSVAL_TYPE_FUNOBJ:
         JS_ASSERT(IsFunctionObject(v));
 #if defined JS_JIT_SPEW
         if (LogController.lcbits & LC_TMTracer) {
-            JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &v.toObject());
+            JSFunction* fun = v.toObject().getFunctionPrivate();
             char funName[40];
             if (fun->atom)
                 JS_PutEscapedFlatString(funName, sizeof funName, fun->atom, 0);
             else
                 strcpy(funName, "unnamed");
             LogController.printf("function<%p:%s> ", (void*) &v.toObject(), funName);
         }
 #endif
@@ -3380,17 +3380,17 @@ GetUpvarOnTrace(JSContext* cx, uint32 up
         FrameInfo* fi = *fip;
 
         /*
          * The loop starts aligned to the top of the stack, so move down to the first meaningful
          * callee. Then read the callee directly from the frame.
          */
         stackOffset -= fi->callerHeight;
         JSObject* callee = *(JSObject**)(&state->stackBase[stackOffset]);
-        JSFunction* fun = GET_FUNCTION_PRIVATE(cx, callee);
+        JSFunction* fun = callee->getFunctionPrivate();
         uintN calleeLevel = fun->script()->staticLevel;
         if (calleeLevel == upvarLevel) {
             /*
              * Now find the upvar's value in the native stack. stackOffset is
              * the offset of the start of the activation record corresponding
              * to *fip in the native stack.
              */
             uint32 native_slot = T::native_slot(fi->callerArgc, slot);
@@ -10536,17 +10536,17 @@ TraceRecorder::record_JSOP_LEAVEWITH()
 {
     return ARECORD_STOP;
 }
 
 static JSBool JS_FASTCALL
 functionProbe(JSContext *cx, JSFunction *fun, int enter)
 {
 #ifdef MOZ_TRACE_JSCALLS
-    JSScript *script = fun ? FUN_SCRIPT(fun) : NULL;
+    JSScript *script = fun ? fun->maybeScript() : NULL;
     if (enter > 0)
         Probes::enterJSFun(cx, fun, script, enter);
     else
         Probes::exitJSFun(cx, fun, script, enter);
 #endif
     return true;
 }
 
@@ -11006,17 +11006,17 @@ TraceRecorder::record_JSOP_OBJTOP()
     return ARECORD_CONTINUE;
 }
 
 RecordingStatus
 TraceRecorder::getClassPrototype(JSObject* ctor, LIns*& proto_ins)
 {
     // ctor must be a function created via js_InitClass.
 #ifdef DEBUG
-    Class *clasp = FUN_CLASP(GET_FUNCTION_PRIVATE(cx, ctor));
+    Class *clasp = ctor->getFunctionPrivate()->getConstructorClass();
     JS_ASSERT(clasp);
 
     TraceMonitor &localtm = *traceMonitor;
 #endif
 
     Value pval;
     if (!ctor->getProperty(cx, ATOM_TO_JSID(cx->runtime->atomState.classPrototypeAtom), &pval))
         RETURN_ERROR("error getting prototype from constructor");
@@ -11548,17 +11548,17 @@ TraceRecorder::callNative(uintN argc, JS
                 pendingSpecializedNative = IGNORE_NATIVE_CALL_COMPLETE_CALLBACK;
                 return RECORD_CONTINUE;
             }
         }
         break;
     }
 
     if (fun->flags & JSFUN_TRCINFO) {
-        JSNativeTraceInfo *trcinfo = FUN_TRCINFO(fun);
+        JSNativeTraceInfo *trcinfo = fun->getTraceInfo();
         JS_ASSERT(trcinfo && fun->u.n.native == trcinfo->native);
 
         /* Try to call a type specialized version of the native. */
         if (trcinfo->specializations) {
             RecordingStatus status = callSpecializedNative(trcinfo, argc, mode == JSOP_NEW);
             if (status != RECORD_STOP)
                 return status;
         }
@@ -11703,28 +11703,28 @@ TraceRecorder::functionCall(uintN argc, 
      * or JSOP_CALLPROP that callee is a *particular* function, since these hit
      * the property cache and guard on the object (this) in which the callee
      * was found. So it's sufficient to test here that the particular function
      * is interpreted, not guard on that condition.
      *
      * Bytecode sequences that push shapeless callees must guard on the callee
      * class being Function and the function being interpreted.
      */
-    JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &fval.toObject());
+    JSFunction* fun = fval.toObject().getFunctionPrivate();
 
     if (Probes::callTrackingActive(cx)) {
-        JSScript *script = FUN_SCRIPT(fun);
+        JSScript *script = fun->maybeScript();
         if (!script || !script->isEmpty()) {
             LIns* args[] = { w.immi(1), w.nameImmpNonGC(fun), cx_ins };
             LIns* call_ins = w.call(&functionProbe_ci, args);
             guard(false, w.eqi0(call_ins), MISMATCH_EXIT);
         }
     }
 
-    if (FUN_INTERPRETED(fun))
+    if (fun->isInterpreted())
         return interpretedFunctionCall(fval, fun, argc, mode == JSOP_NEW);
 
     Native native = fun->maybeNative();
     Value* argv = &tval + 1;
     if (native == js_Array)
         return newArray(&fval.toObject(), argc, argv, &fval);
     if (native == js_String && argc == 1) {
         if (mode == JSOP_NEW)
@@ -13612,17 +13612,18 @@ TraceRecorder::guardCallee(Value& callee
      * after, or vice versa. The function must escape, i.e., be a "funarg", or
      * else there's no need to guard callee parent at all. So once we know (by
      * static analysis) that a function may escape, we cannot avoid guarding on
      * either the private data of the Call object or the Call object itself, if
      * we wish to optimize for the particular deactivated stack frame (null
      * private data) case as noted above.
      */
     if (callee_fun->isInterpreted() &&
-        (!FUN_NULL_CLOSURE(callee_fun) || callee_fun->script()->bindings.hasUpvars())) {
+        (!callee_fun->isNullClosure() || callee_fun->script()->bindings.hasUpvars()))
+    {
         JSObject* parent = callee_obj.getParent();
 
         if (parent != globalObj) {
             if (!parent->isCall())
                 RETURN_STOP("closure scoped by neither the global object nor a Call object");
 
             guard(true,
                   w.eqp(w.ldpObjParent(callee_ins), w.immpObjGC(parent)),
@@ -13814,18 +13815,18 @@ TraceRecorder::record_JSOP_FUNAPPLY()
 
     JS_ASSERT(!cx->fp()->hasImacropc());
 
     if (!IsFunctionObject(vp[0]))
         return record_JSOP_CALL();
     RETURN_IF_XML_A(vp[0]);
 
     JSObject* obj = &vp[0].toObject();
-    JSFunction* fun = GET_FUNCTION_PRIVATE(cx, obj);
-    if (FUN_INTERPRETED(fun))
+    JSFunction* fun = obj->getFunctionPrivate();
+    if (fun->isInterpreted())
         return record_JSOP_CALL();
 
     bool apply = fun->u.n.native == js_fun_apply;
     if (!apply && fun->u.n.native != js_fun_call)
         return record_JSOP_CALL();
 
     /*
      * We don't trace apply and call with a primitive 'this', which is the
@@ -15417,44 +15418,44 @@ TraceRecorder::getFullIndex(ptrdiff_t pc
 }
 
 JS_REQUIRES_STACK AbortableRecordingStatus
 TraceRecorder::record_JSOP_LAMBDA()
 {
     JSFunction* fun;
     fun = cx->fp()->script()->getFunction(getFullIndex());
 
-    if (FUN_NULL_CLOSURE(fun) && FUN_OBJECT(fun)->getParent() != globalObj)
+    if (fun->isNullClosure() && fun->getParent() != globalObj)
         RETURN_STOP_A("Null closure function object parent must be global object");
 
     /*
      * Emit code to clone a null closure parented by this recorder's global
      * object, in order to preserve function object evaluation rules observable
      * via identity and mutation. But don't clone if our result is consumed by
      * JSOP_SETMETHOD or JSOP_INITMETHOD, since we optimize away the clone for
      * these combinations and clone only if the "method value" escapes.
      *
      * See jsinterp.cpp, the JSOP_LAMBDA null closure case. The JSOP_SETMETHOD and
      * JSOP_INITMETHOD logic governing the early ARECORD_CONTINUE returns below
      * must agree with the corresponding break-from-do-while(0) logic there.
      */
-    if (FUN_NULL_CLOSURE(fun) && FUN_OBJECT(fun)->getParent() == &cx->fp()->scopeChain()) {
+    if (fun->isNullClosure() && fun->getParent() == &cx->fp()->scopeChain()) {
         jsbytecode *pc2 = AdvanceOverBlockchainOp(cx->regs().pc + JSOP_LAMBDA_LENGTH);
         JSOp op2 = JSOp(*pc2);
 
         if (op2 == JSOP_INITMETHOD) {
-            stack(0, w.immpObjGC(FUN_OBJECT(fun)));
+            stack(0, w.immpObjGC(fun));
             return ARECORD_CONTINUE;
         }
 
         if (op2 == JSOP_SETMETHOD) {
             Value lval = stackval(-1);
 
             if (!lval.isPrimitive() && lval.toObject().canHaveMethodBarrier()) {
-                stack(0, w.immpObjGC(FUN_OBJECT(fun)));
+                stack(0, w.immpObjGC(fun));
                 return ARECORD_CONTINUE;
             }
         } else if (fun->joinable()) {
             if (op2 == JSOP_CALL) {
                 /*
                  * Array.prototype.sort and String.prototype.replace are
                  * optimized as if they are special form. We know that they
                  * won't leak the joined function object in obj, therefore
@@ -15472,36 +15473,39 @@ TraceRecorder::record_JSOP_LAMBDA()
                 JSObject *callee;
 
                 if (IsFunctionObject(cref, &callee)) {
                     JSFunction *calleeFun = callee->getFunctionPrivate();
                     Native native = calleeFun->maybeNative();
 
                     if ((iargc == 1 && native == array_sort) ||
                         (iargc == 2 && native == str_replace)) {
-                        stack(0, w.immpObjGC(FUN_OBJECT(fun)));
+                        stack(0, w.immpObjGC(fun));
                         return ARECORD_CONTINUE;
                     }
                 }
             } else if (op2 == JSOP_NULL) {
                 pc2 += JSOP_NULL_LENGTH;
                 op2 = JSOp(*pc2);
 
                 if (op2 == JSOP_CALL && GET_ARGC(pc2) == 0) {
-                    stack(0, w.immpObjGC(FUN_OBJECT(fun)));
+                    stack(0, w.immpObjGC(fun));
                     return ARECORD_CONTINUE;
                 }
             }
         }
 
         LIns *proto_ins;
         CHECK_STATUS_A(getClassPrototype(JSProto_Function, proto_ins));
 
         LIns* args[] = { w.immpObjGC(globalObj), proto_ins, w.immpFunGC(fun), cx_ins };
         LIns* x = w.call(&js_NewNullClosure_ci, args);
+        guard(false,
+              w.name(w.eqp0(x), "guard(js_NewNullClosure_ci)"),
+              OOM_EXIT);
         stack(0, x);
         return ARECORD_CONTINUE;
     }
 
     if (GetBlockChainFast(cx, cx->fp(), JSOP_LAMBDA, JSOP_LAMBDA_LENGTH))
         RETURN_STOP_A("Unable to trace creating lambda in let");
 
     LIns *proto_ins;
@@ -15519,17 +15523,17 @@ TraceRecorder::record_JSOP_LAMBDA()
 }
 
 JS_REQUIRES_STACK AbortableRecordingStatus
 TraceRecorder::record_JSOP_LAMBDA_FC()
 {
     JSFunction* fun;
     fun = cx->fp()->script()->getFunction(getFullIndex());
 
-    if (FUN_OBJECT(fun)->getParent() != globalObj)
+    if (fun->getParent() != globalObj)
         return ARECORD_STOP;
 
     if (GetBlockChainFast(cx, cx->fp(), JSOP_LAMBDA_FC, JSOP_LAMBDA_FC_LENGTH))
         RETURN_STOP_A("Unable to trace creating lambda in let");
 
     LIns* args[] = { scopeChain(), w.immpFunGC(fun), cx_ins };
     LIns* closure_ins = w.call(&js_AllocFlatClosure_ci, args);
     guard(false,
@@ -15667,19 +15671,19 @@ TraceRecorder::record_JSOP_ARGCNT()
     }
     stack(0, w.immd(fp->numActualArgs()));
     return ARECORD_CONTINUE;
 }
 
 JS_REQUIRES_STACK AbortableRecordingStatus
 TraceRecorder::record_DefLocalFunSetSlot(uint32 slot, JSObject* obj)
 {
-    JSFunction* fun = GET_FUNCTION_PRIVATE(cx, obj);
-
-    if (FUN_NULL_CLOSURE(fun) && FUN_OBJECT(fun)->getParent() == globalObj) {
+    JSFunction* fun = obj->getFunctionPrivate();
+
+    if (fun->isNullClosure() && fun->getParent() == globalObj) {
         LIns *proto_ins;
         CHECK_STATUS_A(getClassPrototype(JSProto_Function, proto_ins));
 
         LIns* args[] = { w.immpObjGC(globalObj), proto_ins, w.immpFunGC(fun), cx_ins };
         LIns* x = w.call(&js_NewNullClosure_ci, args);
         var(slot, x);
         return ARECORD_CONTINUE;
     }
@@ -16007,17 +16011,17 @@ TraceRecorder::record_JSOP_CALLPROP()
     PCVal pcval;
     CHECK_STATUS_A(test_property_cache(obj, obj_ins, obj2, pcval));
 
     if (pcval.isNull())
         RETURN_STOP_A("callprop of missing method");
 
     if (pcval.isFunObj()) {
         if (l.isPrimitive()) {
-            JSFunction* fun = GET_FUNCTION_PRIVATE(cx, &pcval.toFunObj());
+            JSFunction* fun = pcval.toFunObj().getFunctionPrivate();
             if (fun->isInterpreted() && !fun->inStrictMode())
                 RETURN_STOP_A("callee does not accept primitive |this|");
         }
         set(&l, w.immpObjGC(&pcval.toFunObj()));
     } else {
         if (l.isPrimitive())
             RETURN_STOP_A("callprop of primitive method");
         JS_ASSERT_IF(pcval.isShape(), !pcval.toShape()->isMethod());
--- a/js/src/jswrapper.cpp
+++ b/js/src/jswrapper.cpp
@@ -479,17 +479,17 @@ AutoCompartment::leave()
 ErrorCopier::~ErrorCopier()
 {
     JSContext *cx = ac.context;
     if (cx->compartment == ac.destination &&
         ac.origin != ac.destination &&
         cx->isExceptionPending())
     {
         Value exc = cx->getPendingException();
-        if (exc.isObject() && exc.toObject().isError()) {
+        if (exc.isObject() && exc.toObject().isError() && exc.toObject().getPrivate()) {
             cx->clearPendingException();
             ac.leave();
             JSObject *copyobj = js_CopyErrorObject(cx, &exc.toObject(), scope);
             if (copyobj)
                 cx->setPendingException(ObjectValue(*copyobj));
         }
     }
 }
--- a/js/src/jsxml.cpp
+++ b/js/src/jsxml.cpp
@@ -1638,17 +1638,17 @@ fail:
  */
 static JSBool
 GetXMLSetting(JSContext *cx, const char *name, jsval *vp)
 {
     jsval v;
 
     if (!js_FindClassObject(cx, NULL, JSProto_XML, Valueify(&v)))
         return JS_FALSE;
-    if (!VALUE_IS_FUNCTION(cx, v)) {
+    if (JSVAL_IS_PRIMITIVE(v) || !JSVAL_TO_OBJECT(v)->isFunction()) {
         *vp = JSVAL_VOID;
         return JS_TRUE;
     }
     return JS_GetProperty(cx, JSVAL_TO_OBJECT(v), name, vp);
 }
 
 static JSBool
 GetBooleanXMLSetting(JSContext *cx, const char *name, JSBool *bp)
@@ -5148,17 +5148,18 @@ JS_FRIEND_DATA(Class) js_XMLClass = {
 
 static JSXML *
 StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
 {
     JSXML *xml;
     JSFunction *fun;
     char numBuf[12];
 
-    JS_ASSERT(VALUE_IS_FUNCTION(cx, *vp));
+    JS_ASSERT(!JSVAL_IS_PRIMITIVE(*vp));
+    JS_ASSERT(JSVAL_TO_OBJECT(*vp)->isFunction());
 
     *objp = ToObject(cx, Valueify(&vp[1]));
     if (!*objp)
         return NULL;
     if (!(*objp)->isXML()) {
         ReportIncompatibleMethod(cx, Valueify(vp), &js_XMLClass);
         return NULL;
     }
@@ -5172,17 +5173,17 @@ StartNonListXMLMethod(JSContext *cx, jsv
             *objp = js_GetXMLObject(cx, xml);
             if (!*objp)
                 return NULL;
             vp[1] = OBJECT_TO_JSVAL(*objp);
             return xml;
         }
     }
 
-    fun = GET_FUNCTION_PRIVATE(cx, JSVAL_TO_OBJECT(*vp));
+    fun = JSVAL_TO_OBJECT(*vp)->getFunctionPrivate();
     JS_snprintf(numBuf, sizeof numBuf, "%u", xml->xml_kids.length);
     JSAutoByteString funNameBytes;
     if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_NON_LIST_XML_METHOD,
                              funName, numBuf);
     }
     return NULL;
 }
@@ -7495,17 +7496,17 @@ GetXMLFunction(JSContext *cx, JSObject *
      * See comments before xml_lookupProperty about the need for the proto
      * chain lookup.
      */
     JSObject *target = obj;
     AutoObjectRooter tvr(cx);
     for (;;) {
         if (!js_GetProperty(cx, target, id, Valueify(vp)))
             return false;
-        if (VALUE_IS_FUNCTION(cx, *vp))
+        if (!JSVAL_IS_PRIMITIVE(*vp) && JSVAL_TO_OBJECT(*vp)->isFunction())
             return true;
         target = target->getProto();
         if (target == NULL || !target->isNative())
             break;
         tvr.setObject(target);
     }
 
     JSXML *xml = (JSXML *) obj->getPrivate();
--- a/js/src/methodjit/InvokeHelpers.cpp
+++ b/js/src/methodjit/InvokeHelpers.cpp
@@ -414,17 +414,17 @@ stubs::UncachedCallHelper(VMFrame &f, ui
 {
     ucr->init();
 
     JSContext *cx = f.cx;
     CallArgs args = CallArgsFromSp(argc, f.regs.sp);
 
     if (IsFunctionObject(args.calleev(), &ucr->callee)) {
         ucr->callee = &args.callee();
-        ucr->fun = GET_FUNCTION_PRIVATE(cx, ucr->callee);
+        ucr->fun = ucr->callee->getFunctionPrivate();
 
         if (ucr->fun->isInterpreted()) {
             if (!UncachedInlineCall(f, NO_CONSTRUCT, &ucr->codeAddr, &ucr->unjittable, argc))
                 THROW();
             return;
         }
 
         if (ucr->fun->isNative()) {
--- a/js/src/methodjit/PolyIC.cpp
+++ b/js/src/methodjit/PolyIC.cpp
@@ -553,17 +553,17 @@ class SetPropCompiler : public PICStubCo
             uintN flags = 0;
             PropertyOp getter = clasp->getProperty;
 
             if (pic.kind == ic::PICInfo::SETMETHOD) {
                 if (!obj->canHaveMethodBarrier())
                     return disable("can't have method barrier");
 
                 JSObject *funobj = &f.regs.sp[-1].toObject();
-                if (funobj != GET_FUNCTION_PRIVATE(cx, funobj))
+                if (funobj != funobj->getFunctionPrivate())
                     return disable("mismatched function");
 
                 flags |= Shape::METHOD;
                 getter = CastAsPropertyOp(funobj);
             }
 
             /*
              * Define the property but do not set it yet. For setmethod,
--- a/js/src/methodjit/StubCalls.cpp
+++ b/js/src/methodjit/StubCalls.cpp
@@ -699,19 +699,19 @@ stubs::DefFun(VMFrame &f, JSFunction *fu
     StackFrame *fp = f.fp();
 
     /*
      * A top-level function defined in Global or Eval code (see ECMA-262
      * Ed. 3), or else a SpiderMonkey extension: a named function statement in
      * a compound statement (not at the top statement level of global code, or
      * at the top level of a function body).
      */
-    JSObject *obj = FUN_OBJECT(fun);
+    JSObject *obj = fun;
 
-    if (FUN_NULL_CLOSURE(fun)) {
+    if (fun->isNullClosure()) {
         /*
          * Even a null closure needs a parent for principals finding.
          * FIXME: bug 476950, although debugger users may also demand some kind
          * of scope link for debugger-assisted eval-in-frame.
          */
         obj2 = &fp->scopeChain();
     } else {
         JS_ASSERT(!fun->isFlatClosure());
@@ -1320,20 +1320,20 @@ stubs::DefLocalFun(VMFrame &f, JSFunctio
     /*
      * Define a local function (i.e., one nested at the top level of another
      * function), parented by the current scope chain, stored in a local
      * variable slot that the compiler allocated.  This is an optimization over
      * JSOP_DEFFUN that avoids requiring a call object for the outer function's
      * activation.
      */
     JS_ASSERT(fun->isInterpreted());
-    JS_ASSERT(!FUN_FLAT_CLOSURE(fun));
-    JSObject *obj = FUN_OBJECT(fun);
+    JS_ASSERT(!fun->isFlatClosure());
+    JSObject *obj = fun;
 
-    if (FUN_NULL_CLOSURE(fun)) {
+    if (fun->isNullClosure()) {
         obj = CloneFunctionObject(f.cx, fun, &f.fp()->scopeChain());
         if (!obj)
             THROWV(NULL);
     } else {
         JSObject *parent = GetScopeChainFast(f.cx, f.fp(), JSOP_DEFLOCALFUN,
                                              JSOP_DEFLOCALFUN_LENGTH);
         if (!parent)
             THROWV(NULL);
@@ -1376,43 +1376,43 @@ stubs::RegExp(VMFrame &f, JSObject *rege
     if (!obj)
         THROWV(NULL);
     return obj;
 }
 
 JSObject * JS_FASTCALL
 stubs::LambdaForInit(VMFrame &f, JSFunction *fun)
 {
-    JSObject *obj = FUN_OBJECT(fun);
-    if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) {
+    JSObject *obj = fun;
+    if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) {
         fun->setMethodAtom(f.fp()->script()->getAtom(GET_SLOTNO(f.regs.pc)));
         return obj;
     }
     return Lambda(f, fun);
 }
 
 JSObject * JS_FASTCALL
 stubs::LambdaForSet(VMFrame &f, JSFunction *fun)
 {
-    JSObject *obj = FUN_OBJECT(fun);
-    if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) {
+    JSObject *obj = fun;
+    if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) {
         const Value &lref = f.regs.sp[-1];
         if (lref.isObject() && lref.toObject().canHaveMethodBarrier()) {
             fun->setMethodAtom(f.fp()->script()->getAtom(GET_SLOTNO(f.regs.pc)));
             return obj;
         }
     }
     return Lambda(f, fun);
 }
 
 JSObject * JS_FASTCALL
 stubs::LambdaJoinableForCall(VMFrame &f, JSFunction *fun)
 {
-    JSObject *obj = FUN_OBJECT(fun);
-    if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) {
+    JSObject *obj = fun;
+    if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) {
         /*
          * Array.prototype.sort and String.prototype.replace are
          * optimized as if they are special form. We know that they
          * won't leak the joined function object in obj, therefore
          * we don't need to clone that compiler- created function
          * object for identity/mutation reasons.
          */
         int iargc = GET_ARGC(f.regs.pc);
@@ -1438,34 +1438,34 @@ stubs::LambdaJoinableForCall(VMFrame &f,
         }
     }
     return Lambda(f, fun);
 }
 
 JSObject * JS_FASTCALL
 stubs::LambdaJoinableForNull(VMFrame &f, JSFunction *fun)
 {
-    JSObject *obj = FUN_OBJECT(fun);
-    if (FUN_NULL_CLOSURE(fun) && obj->getParent() == &f.fp()->scopeChain()) {
+    JSObject *obj = fun;
+    if (fun->isNullClosure() && obj->getParent() == &f.fp()->scopeChain()) {
         jsbytecode *pc2 = f.regs.pc + JSOP_NULL_LENGTH;
         JSOp op2 = JSOp(*pc2);
 
         if (op2 == JSOP_CALL && GET_ARGC(pc2) == 0)
             return obj;
     }
     return Lambda(f, fun);
 }
 
 JSObject * JS_FASTCALL
 stubs::Lambda(VMFrame &f, JSFunction *fun)
 {
-    JSObject *obj = FUN_OBJECT(fun);
+    JSObject *obj = fun;
 
     JSObject *parent;
-    if (FUN_NULL_CLOSURE(fun)) {
+    if (fun->isNullClosure()) {
         parent = &f.fp()->scopeChain();
     } else {
         parent = GetScopeChainFast(f.cx, f.fp(), JSOP_LAMBDA, JSOP_LAMBDA_LENGTH);
         if (!parent)
             THROWV(NULL);
     }
 
     obj = CloneFunctionObject(f.cx, fun, parent);
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -1549,25 +1549,25 @@ ValueToScript(JSContext *cx, jsval v)
         JSObject *obj = JSVAL_TO_OBJECT(v);
         JSClass *clasp = JS_GET_CLASS(cx, obj);
 
         if (clasp == Jsvalify(&js_ScriptClass)) {
             script = (JSScript *) JS_GetPrivate(cx, obj);
         } else if (clasp == Jsvalify(&js_GeneratorClass)) {
             JSGenerator *gen = (JSGenerator *) JS_GetPrivate(cx, obj);
             fun = gen->floatingFrame()->fun();
-            script = FUN_SCRIPT(fun);
+            script = fun->script();
         }
     }
 
     if (!script) {
         fun = JS_ValueToFunction(cx, v);
         if (!fun)
             return NULL;
-        script = FUN_SCRIPT(fun);
+        script = fun->maybeScript();
         if (!script) {
             JS_ReportErrorNumber(cx, my_GetErrorMessage, NULL,
                                  JSSMSG_SCRIPTS_ONLY);
         }
     }
 
     return script;
 }
@@ -1987,35 +1987,35 @@ TryNotes(JSContext *cx, JSScript *script
 }
 
 static bool
 DisassembleValue(JSContext *cx, jsval v, bool lines, bool recursive, Sprinter *sp)
 {
     JSScript *script = ValueToScript(cx, v);
     if (!script)
         return false;
-    if (VALUE_IS_FUNCTION(cx, v)) {
+    if (!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isFunction()) {
         JSFunction *fun = JS_ValueToFunction(cx, v);
         if (fun && (fun->flags & ~7U)) {
             uint16 flags = fun->flags;
             Sprint(sp, "flags:");
 
 #define SHOW_FLAG(flag) if (flags & JSFUN_##flag) Sprint(sp, " " #flag);
 
             SHOW_FLAG(LAMBDA);
             SHOW_FLAG(HEAVYWEIGHT);
             SHOW_FLAG(EXPR_CLOSURE);
             SHOW_FLAG(TRCINFO);
 
 #undef SHOW_FLAG
 
-            if (FUN_INTERPRETED(fun)) {
-                if (FUN_NULL_CLOSURE(fun))
+            if (fun->isInterpreted()) {
+                if (fun->isNullClosure())
                     Sprint(sp, " NULL_CLOSURE");
-                else if (FUN_FLAT_CLOSURE(fun))
+                else if (fun->isFlatClosure())
                     Sprint(sp, " FLAT_CLOSURE");
 
                 JSScript *script = fun->script();
                 if (script->bindings.hasUpvars()) {
                     Sprint(sp, "\nupvars: {\n");
 
                     Vector<JSAtom *> localNames(cx);
                     if (!script->bindings.getLocalNameArray(cx, &localNames))
@@ -2693,17 +2693,17 @@ Clone(JSContext *cx, uintN argc, jsval *
         if (!JSVAL_IS_PRIMITIVE(argv[0]) &&
             JSVAL_TO_OBJECT(argv[0])->isCrossCompartmentWrapper())
         {
             JSObject *obj = JSVAL_TO_OBJECT(argv[0])->unwrap();
             if (!ac.enter(cx, obj))
                 return JS_FALSE;
             argv[0] = OBJECT_TO_JSVAL(obj);
         }
-        if (VALUE_IS_FUNCTION(cx, argv[0])) {
+        if (!JSVAL_IS_PRIMITIVE(argv[0]) && JSVAL_TO_OBJECT(argv[0])->isFunction()) {
             funobj = JSVAL_TO_OBJECT(argv[0]);
         } else {
             JSFunction *fun = JS_ValueToFunction(cx, argv[0]);
             if (!fun)
                 return JS_FALSE;
             funobj = JS_GetFunctionObject(fun);
         }
     }
--- a/js/src/vm/Debugger.cpp
+++ b/js/src/vm/Debugger.cpp
@@ -2998,16 +2998,17 @@ DebuggerObject_getOwnPropertyDescriptor(
 
     /* Bug: This can cause the debuggee to run! */
     AutoPropertyDescriptorRooter desc(cx);
     {
         AutoCompartment ac(cx, obj);
         if (!ac.enter() || !cx->compartment->wrapId(cx, &id))
             return false;
 
+        ErrorCopier ec(ac, dbg->toJSObject());
         if (!GetOwnPropertyDescriptor(cx, obj, id, &desc))
             return false;
     }
 
     if (desc.obj) {
         /* Rewrap the debuggee values in desc for the debugger. */
         if (!dbg->wrapDebuggeeValue(cx, &desc.value))
             return false;
@@ -3034,16 +3035,17 @@ DebuggerObject_getOwnPropertyNames(JSCon
     THIS_DEBUGOBJECT_OWNER_REFERENT(cx, argc, vp, "getOwnPropertyNames", args, dbg, obj);
 
     AutoIdVector keys(cx);
     {
         AutoCompartment ac(cx, obj);
         if (!ac.enter())
             return false;
 
+        ErrorCopier ec(ac, dbg->toJSObject());
         if (!GetPropertyNames(cx, obj, JSITER_OWNONLY | JSITER_HIDDEN, &keys))
             return false;
     }
 
     AutoValueVector vals(cx);
     if (!vals.resize(keys.length()))
         return false;
 
--- a/js/src/vm/GlobalObject.cpp
+++ b/js/src/vm/GlobalObject.cpp
@@ -209,17 +209,17 @@ GlobalObject::createConstructor(JSContex
     JSFunction *fun = js_NewFunction(cx, NULL, ctor, length, JSFUN_CONSTRUCTOR, this, name);
     if (!fun)
         return NULL;
 
     /*
      * Remember the class this function is a constructor for so that we know to
      * create an object of this class when we call the constructor.
      */
-    FUN_CLASP(fun) = clasp;
+    fun->setConstructorClass(clasp);
     return fun;
 }
 
 static JSObject *
 CreateBlankProto(JSContext *cx, Class *clasp, JSObject &proto, GlobalObject &global)
 {
     JS_ASSERT(clasp != &js_ObjectClass);
     JS_ASSERT(clasp != &js_FunctionClass);
--- a/js/src/xpconnect/src/xpcwrappednativejsops.cpp
+++ b/js/src/xpconnect/src/xpcwrappednativejsops.cpp
@@ -1571,17 +1571,17 @@ XPC_WN_CallMethod(JSContext *cx, uintN a
     JSObject* funobj = JSVAL_TO_OBJECT(JS_CALLEE(cx, vp));
 
     JSObject* obj = JS_THIS_OBJECT(cx, vp);
     if (!obj)
         return JS_FALSE;
 
 #ifdef DEBUG_slimwrappers
     {
-        JSFunction* fun = GET_FUNCTION_PRIVATE(cx, funobj);
+        JSFunction* fun = funobj->getFunctionPrivate();
         JSString *funid = JS_GetFunctionId(fun);
         JSAutoByteString bytes;
         const char *funname = !funid ? "" : bytes.encode(cx, funid) ? bytes.ptr() : "<error>";
         SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, funname);
     }
 #endif
     if(IS_SLIM_WRAPPER(obj) && !MorphSlimWrapper(cx, obj))
         return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
@@ -1610,17 +1610,17 @@ XPC_WN_GetterSetter(JSContext *cx, uintN
         return JS_FALSE;
 
 #ifdef DEBUG_slimwrappers
     {
         const char* funname = nsnull;
         JSAutoByteString bytes;
         if(JS_TypeOfValue(cx, JS_CALLEE(cx, vp)) == JSTYPE_FUNCTION)
         {
-            JSString *funid = JS_GetFunctionId(GET_FUNCTION_PRIVATE(cx, funobj));
+            JSString *funid = JS_GetFunctionId(funobj->getFunctionPrivate());
             funname = !funid ? "" : bytes.encode(cx, funid) ? bytes.ptr() : "<error>";
         }
         SLIM_LOG_WILL_MORPH_FOR_PROP(cx, obj, funname);
     }
 #endif
     if(IS_SLIM_WRAPPER(obj) && !MorphSlimWrapper(cx, obj))
         return Throw(NS_ERROR_XPC_BAD_OP_ON_WN_PROTO, cx);
 
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -62,17 +62,16 @@
 #include "nsIDOMHTMLTextAreaElement.h"
 #include "nsNodeInfoManager.h"
 #include "nsIURI.h"
 #include "nsGUIEvent.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsISupportsPrimitives.h"
 #include "nsAutoPtr.h"
 #include "nsPresState.h"
-#include "nsIGlobalHistory3.h"
 #include "nsDocShellCID.h"
 #include "nsIHTMLDocument.h"
 #include "nsEventDispatcher.h"
 #include "nsContentUtils.h"
 #include "nsLayoutUtils.h"
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
 #endif
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1103,16 +1103,21 @@ InitSystemMetrics()
     sSystemMetrics->AppendElement(nsGkAtoms::windows_default_theme);
   }
 
   rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MacGraphiteTheme, metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::mac_graphite_theme);
   }
 
+  rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MacLionTheme, metricResult);
+  if (NS_SUCCEEDED(rv) && metricResult) {
+    sSystemMetrics->AppendElement(nsGkAtoms::mac_lion_theme);
+  }
+
   rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_DWMCompositor, metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::windows_compositor);
   }
 
   rv = lookAndFeel->GetMetric(nsILookAndFeel::eMetric_WindowsClassic, metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::windows_classic);
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -517,16 +517,23 @@ nsMediaFeatures::features[] = {
     {
         &nsGkAtoms::_moz_mac_graphite_theme,
         nsMediaFeature::eMinMaxNotAllowed,
         nsMediaFeature::eBoolInteger,
         { &nsGkAtoms::mac_graphite_theme },
         GetSystemMetric
     },
     {
+        &nsGkAtoms::_moz_mac_lion_theme,
+        nsMediaFeature::eMinMaxNotAllowed,
+        nsMediaFeature::eBoolInteger,
+        { &nsGkAtoms::mac_lion_theme },
+        GetSystemMetric
+    },
+    {
         &nsGkAtoms::_moz_windows_compositor,
         nsMediaFeature::eMinMaxNotAllowed,
         nsMediaFeature::eBoolInteger,
         { &nsGkAtoms::windows_compositor },
         GetSystemMetric
     },
     {
         &nsGkAtoms::_moz_windows_classic,
--- a/layout/style/test/test_media_queries.html
+++ b/layout/style/test/test_media_queries.html
@@ -545,72 +545,77 @@ function run() {
   expression_should_be_parseable("-moz-scrollbar-start-forward");
   expression_should_be_parseable("-moz-scrollbar-end-backward");
   expression_should_be_parseable("-moz-scrollbar-end-forward");
   expression_should_be_parseable("-moz-scrollbar-thumb-proportional");
   expression_should_be_parseable("-moz-images-in-menus");
   expression_should_be_parseable("-moz-images-in-buttons");
   expression_should_be_parseable("-moz-windows-default-theme");
   expression_should_be_parseable("-moz-mac-graphite-theme");
+  expression_should_be_parseable("-moz-mac-lion-theme");
   expression_should_be_parseable("-moz-windows-compositor");
   expression_should_be_parseable("-moz-windows-classic");
   expression_should_be_parseable("-moz-touch-enabled");
   expression_should_be_parseable("-moz-maemo-classic");
 
   expression_should_be_parseable("-moz-scrollbar-start-backward: 0");
   expression_should_be_parseable("-moz-scrollbar-start-forward: 0");
   expression_should_be_parseable("-moz-scrollbar-end-backward: 0");
   expression_should_be_parseable("-moz-scrollbar-end-forward: 0");
   expression_should_be_parseable("-moz-scrollbar-thumb-proportional: 0");
   expression_should_be_parseable("-moz-images-in-menus: 0");
   expression_should_be_parseable("-moz-images-in-buttons: 0");
   expression_should_be_parseable("-moz-windows-default-theme: 0");
   expression_should_be_parseable("-moz-mac-graphite-theme: 0");
+  expression_should_be_parseable("-moz-mac-lion-theme: 0");
   expression_should_be_parseable("-moz-windows-compositor: 0");
   expression_should_be_parseable("-moz-windows-classic: 0");
   expression_should_be_parseable("-moz-touch-enabled: 0");
   expression_should_be_parseable("-moz-maemo-classic: 0");
 
   expression_should_be_parseable("-moz-scrollbar-start-backward: 1");
   expression_should_be_parseable("-moz-scrollbar-start-forward: 1");
   expression_should_be_parseable("-moz-scrollbar-end-backward: 1");
   expression_should_be_parseable("-moz-scrollbar-end-forward: 1");
   expression_should_be_parseable("-moz-scrollbar-thumb-proportional: 1");
   expression_should_be_parseable("-moz-images-in-menus: 1");
   expression_should_be_parseable("-moz-images-in-buttons: 1");
   expression_should_be_parseable("-moz-windows-default-theme: 1");
   expression_should_be_parseable("-moz-mac-graphite-theme: 1");
+  expression_should_be_parseable("-moz-mac-lion-theme: 1");
   expression_should_be_parseable("-moz-windows-compositor: 1");
   expression_should_be_parseable("-moz-windows-classic: 1");
   expression_should_be_parseable("-moz-touch-enabled: 1");
   expression_should_be_parseable("-moz-maemo-classic: 1");
 
   expression_should_not_be_parseable("-moz-scrollbar-start-backward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-start-forward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-end-backward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-end-forward: -1");
   expression_should_not_be_parseable("-moz-scrollbar-thumb-proportional: -1");
   expression_should_not_be_parseable("-moz-images-in-menus: -1");
   expression_should_not_be_parseable("-moz-images-in-buttons: -1");
   expression_should_not_be_parseable("-moz-windows-default-theme: -1");
   expression_should_not_be_parseable("-moz-mac-graphite-theme: -1");
+  expression_should_not_be_parseable("-moz-mac-lion-theme: -1");
   expression_should_not_be_parseable("-moz-windows-compositor: -1");
   expression_should_not_be_parseable("-moz-windows-classic: -1");
   expression_should_not_be_parseable("-moz-touch-enabled: -1");
   expression_should_not_be_parseable("-moz-maemo-classic: -1");
 
   expression_should_not_be_parseable("-moz-scrollbar-start-backward: true");
   expression_should_not_be_parseable("-moz-scrollbar-start-forward: true");
   expression_should_not_be_parseable("-moz-scrollbar-end-backward: true");
   expression_should_not_be_parseable("-moz-scrollbar-end-forward: true");
   expression_should_not_be_parseable("-moz-scrollbar-thumb-proportional: true");
   expression_should_not_be_parseable("-moz-images-in-menus: true");
   expression_should_not_be_parseable("-moz-images-in-buttons: true");
   expression_should_not_be_parseable("-moz-windows-default-theme: true");
   expression_should_not_be_parseable("-moz-mac-graphite-theme: true");
+  expression_should_not_be_parseable("-moz-mac-lion-theme: true");
   expression_should_not_be_parseable("-moz-windows-compositor: true");
   expression_should_not_be_parseable("-moz-windows-classic: true");
   expression_should_not_be_parseable("-moz-touch-enabled: true");
   expression_should_not_be_parseable("-moz-maemo-classic: true");
 
   // windows theme media queries
   expression_should_be_parseable("-moz-windows-theme: aero");
   expression_should_be_parseable("-moz-windows-theme: luna-blue");
--- a/mobile/app/mobile.js
+++ b/mobile/app/mobile.js
@@ -367,17 +367,17 @@ pref("privacy.item.syncAccount", true);
 #ifdef MOZ_PLATFORM_MAEMO
 pref("plugins.force.wmode", "opaque");
 #endif
 
 // URL to the Learn More link XXX this is the firefox one.  Bug 495578 fixes this.
 pref("browser.geolocation.warning.infoURL", "http://www.mozilla.com/%LOCALE%/firefox/geolocation/");
 
 // base url for the wifi geolocation network provider
-pref("geo.wifi.uri", "https://www.google.com/loc/json");
+pref("geo.wifi.uri", "https://maps.googleapis.com/maps/api/browserlocation/json");
 
 // enable geo
 pref("geo.enabled", true);
 
 // content sink control -- controls responsiveness during page load
 // see https://bugzilla.mozilla.org/show_bug.cgi?id=481566#c9
 pref("content.sink.enable_perf_mode",  2); // 0 - switch, 1 - interactive, 2 - perf
 pref("content.sink.pending_event_mode", 0);
--- a/mobile/installer/debian/fennec.aegis.in
+++ b/mobile/installer/debian/fennec.aegis.in
@@ -1,7 +1,10 @@
 <aegis>
   <request>
     <credential name="TrackerReadAccess" />
     <credential name="TrackerWriteAccess" />
+    <credential name="Location" />
+    <for path="@installdir@/@MOZ_APP_NAME@" />
+    <for path="@installdir@/plugin-container" />
   </request>
 </aegis>
 
--- a/modules/libreg/src/Makefile.in
+++ b/modules/libreg/src/Makefile.in
@@ -63,21 +63,16 @@ EXPORT_LIBRARY = 1
 
 USE_STATIC_LIBS = 1
 
 SDK_LIBRARY = $(LIBRARY)
 
 include $(topsrcdir)/config/config.mk
 
 DEFINES         += -DUSE_BUFFERED_REGISTRY_IO	
-# Memory mapped files are not supported under QNX, Neutrino, HP-UX and BeOS
-#ifeq (,$(filter BeOS HP-UX QNX,$(OS_ARCH)))
-#CSRCS		+= mmapio.c
-#DEFINES		+= -DUSE_MMAP_REGISTRY_IO
-#endif
 
 include $(topsrcdir)/config/rules.mk
 
 R_%.o: %.c
 	$(CC) $(OUTOPTION)$@ -c $(COMPILE_CFLAGS) -DSTANDALONE_REGISTRY $<
 
 ifdef _MSC_VER
 # Don't include directives about which CRT to use
deleted file mode 100644
--- a/modules/libreg/src/mmapio.c
+++ /dev/null
@@ -1,213 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator.
- *
- * The Initial Developer of the Original Code is
- * James L. Nance.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   James L. Nance <jim_nance@yahoo.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-#include <string.h>
-#include "mmapio.h"
-#include "prmem.h"
-#include "prlog.h"
-
-struct MmioFileStruct
-{
-    PRFileDesc *fd;
-    PRFileMap  *fileMap;
-    PRUint32   fsize; /* The size of the file */
-    PRUint32   msize; /* The size of the mmap()ed area */
-    PRInt32    pos;   /* Our logical position for doing I/O */
-    char       *addr; /* The base address of our mapping */
-    PRBool     needSeek; /* Do we need to seek to pos before doing a write() */
-};
-
-PRStatus mmio_FileSeek(MmioFile *mmio, PRInt32 offset, PRSeekWhence whence)
-{
-    mmio->needSeek = PR_TRUE;
-
-    switch(whence) {
-        case PR_SEEK_SET:
-            mmio->pos = offset;
-            break;
-        case PR_SEEK_END:
-            mmio->pos = mmio->fsize + offset;
-            break;
-        case PR_SEEK_CUR:
-            mmio->pos = mmio->pos + offset;
-            break;
-        default:
-            return PR_FAILURE;
-    }
-
-    if(mmio->pos<0) {
-        mmio->pos = 0;
-    }
-
-    return PR_SUCCESS;
-}
-
-PRInt32  mmio_FileRead(MmioFile *mmio, char *dest, PRInt32 count)
-{
-    static PRFileMapProtect prot = PR_PROT_READONLY;
-    static PRInt64 fsize_l;
-
-    /* First see if we are going to try and read past the end of the file
-     * and shorten count if we are.
-    */
-    if(mmio->pos+count > mmio->fsize) {
-        count = mmio->fsize - mmio->pos;
-    }
-
-    if(count<1) {
-        return 0;
-    }
-
-    /* Check to see if we need to remap for this read */
-    if(mmio->pos+count > mmio->msize) {
-        if(mmio->addr && mmio->msize) {
-            PR_ASSERT(mmio->fileMap);
-            PR_MemUnmap(mmio->addr, mmio->msize);
-            PR_CloseFileMap(mmio->fileMap);
-            mmio->addr  = NULL;
-            mmio->msize = 0;
-        }
-
-        LL_UI2L(fsize_l, mmio->fsize);
-        mmio->fileMap = PR_CreateFileMap(mmio->fd, fsize_l, prot);
-
-        if(!mmio->fileMap) {
-            return -1;
-        }
-
-        mmio->addr = PR_MemMap(mmio->fileMap, 0, fsize_l);
-
-        if(!mmio->addr) {
-            return -1;
-        }
-
-        mmio->msize = mmio->fsize;
-    }
-
-    memcpy(dest, mmio->addr+mmio->pos, count);
-
-    mmio->pos += count;
-    mmio->needSeek = PR_TRUE;
-
-    return count;
-}
-
-PRInt32  mmio_FileWrite(MmioFile *mmio, const char *src, PRInt32 count)
-{
-    PRInt32 wcode;
-
-    if(mmio->needSeek) {
-        PR_Seek(mmio->fd, mmio->pos, PR_SEEK_SET);
-        mmio->needSeek = PR_FALSE;
-    }
-
-    /* If this system does not keep mmap() and write() synchronized, we can
-    ** force it to by doing an munmap() when we do a write.  This will
-    ** obviously slow things down but fortunatly we do not do that many
-    ** writes from within mozilla.  Platforms which need this may want to
-    ** use the new USE_BUFFERED_REGISTRY_IO code instead of this code though.
-    */
-#if MMAP_MISSES_WRITES
-    if(mmio->addr && mmio->msize) {
-	PR_ASSERT(mmio->fileMap);
-	PR_MemUnmap(mmio->addr, mmio->msize);
-	PR_CloseFileMap(mmio->fileMap);
-	mmio->addr  = NULL;
-	mmio->msize = 0;
-    }
-#endif
-
-    wcode = PR_Write(mmio->fd, src, count);
-
-    if(wcode>0) {
-        mmio->pos += wcode;
-        if(mmio->pos>mmio->fsize) {
-            mmio->fsize=mmio->pos;
-        }
-    }
-
-    return wcode;
-}
-
-PRInt32  mmio_FileTell(MmioFile *mmio)
-{
-    return mmio->pos;
-}
-
-PRStatus mmio_FileClose(MmioFile *mmio)
-{
-    if(mmio->addr && mmio->msize) {
-        PR_ASSERT(mmio->fileMap);
-        PR_MemUnmap(mmio->addr, mmio->msize);
-        PR_CloseFileMap(mmio->fileMap);
-    }
-
-    PR_Close(mmio->fd);
-
-    memset(mmio, 0, sizeof(*mmio)); /* Catch people who try to keep using it */
-
-    PR_Free(mmio);
-
-    return PR_SUCCESS;
-}
-
-MmioFile *mmio_FileOpen(char *path, PRIntn flags, PRIntn mode)
-{
-    PRFileDesc *fd = PR_Open(path, flags, mode);
-    PRFileInfo info;
-    MmioFile   *mmio;
-
-    if(!fd) {
-        return NULL;
-    }
-
-    mmio = PR_MALLOC(sizeof(MmioFile));
-
-    if(!mmio || PR_FAILURE==PR_GetOpenFileInfo(fd, &info)) {
-        PR_Close(fd);
-        return NULL;
-    }
-
-    mmio->fd = fd;
-    mmio->fileMap = NULL;
-    mmio->fsize = info.size;
-    mmio->msize = 0;
-    mmio->pos   = 0;
-    mmio->addr  = NULL;
-    mmio->needSeek = PR_FALSE;
-
-    return mmio;
-}
deleted file mode 100644
--- a/modules/libreg/src/mmapio.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Communicator.
- *
- * The Initial Developer of the Original Code is
- * James L. Nance.
- * Portions created by the Initial Developer are Copyright (C) 1999
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   James L. Nance <jim_nance@yahoo.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "prio.h"
-
-typedef struct MmioFileStruct MmioFile;
-
-PRStatus mmio_FileSeek(MmioFile *file, PRInt32 offset, PRSeekWhence whence);
-PRInt32  mmio_FileRead(MmioFile *file, char *dest, PRInt32 count);
-PRInt32  mmio_FileWrite(MmioFile *file, const char *src, PRInt32 count);
-PRInt32  mmio_FileTell(MmioFile *file);
-PRStatus mmio_FileClose(MmioFile *file);
-MmioFile *mmio_FileOpen(char *path, PRIntn flags, PRIntn mode);
--- a/modules/libreg/src/vr_stubs.h
+++ b/modules/libreg/src/vr_stubs.h
@@ -132,36 +132,17 @@ typedef FILE          * XP_File;
 
 #else /* not standalone, use NSPR */
 
 
 /*-------------------------------------*/
 /* Alternate fileI/O function mappings */
 /*-------------------------------------*/
 
-#if USE_MMAP_REGISTRY_IO
-  /*-----------------------------------------------*/
-  /* NSPR mememory-mapped I/O (write through)      */
-  /* unfortunately this isn't supported on the Mac */
-  /*-----------------------------------------------*/
-#define USE_NSPR_MODES
-
-#include "mmapio.h"
-#define XP_FileSeek(file,offset,whence) mmio_FileSeek((file),(offset),(whence))
-#define XP_FileRead(dest,count,file)    mmio_FileRead((file), (dest), (count))
-#define XP_FileWrite(src,count,file)    mmio_FileWrite((file), (src), (count))
-#define XP_FileTell(file)               mmio_FileTell(file)
-#define XP_FileClose(file)              mmio_FileClose(file)
-#define XP_FileOpen(path, mode)         mmio_FileOpen((path), mode )
-#define XP_FileFlush(file)              ((void)1)
-#define XP_FileSetBufferSize(file, bufsize) (-1)
-
-typedef MmioFile* XP_File;
-
-#elif USE_BUFFERED_REGISTRY_IO
+#if USE_BUFFERED_REGISTRY_IO
   /*-----------------------------------------------*/
   /* home-grown XP buffering                       */
   /* writes are buffered too so use flush!         */
   /*-----------------------------------------------*/
 #define USE_STDIO_MODES
 
 #include "nr_bufio.h"
 #define XP_FileSeek(file,offset,whence) bufio_Seek((file),(offset),(whence))
--- a/netwerk/build/Makefile.in
+++ b/netwerk/build/Makefile.in
@@ -135,16 +135,13 @@ endif
 ifdef NECKO_WIFI
 SHARED_LIBRARY_LIBS += \
   ../wifi/$(LIB_PREFIX)neckowifi_s.$(LIB_SUFFIX) \
   $(NULL)
 LOCAL_INCLUDES += -I$(srcdir)/../wifi
 
 endif
 
-
-DEFINES += -DNECKO_OFFLINE_CACHE
-
 include $(topsrcdir)/config/config.mk
 include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -DIMPL_NS_NET
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -210,21 +210,19 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsNestedA
 #ifdef NS_BUILD_REFCNT_LOGGING
 #include "nsAboutBloat.h"
 #endif
 #include "nsAboutCache.h"
 #include "nsAboutCacheEntry.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAboutCacheEntry)
 #endif
 
-#ifdef NECKO_OFFLINE_CACHE
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsOfflineCacheDevice, nsOfflineCacheDevice::GetInstance)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsApplicationCacheNamespace)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsApplicationCache)
-#endif
 
 #ifdef NECKO_PROTOCOL_file
 // file
 #include "nsFileProtocolHandler.h"
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFileProtocolHandler, Init)
 #endif
 
 #ifdef NECKO_PROTOCOL_ftp
@@ -764,21 +762,19 @@ NS_DEFINE_NAMED_CID(NS_ABOUT_BLOAT_MODUL
 #endif
 NS_DEFINE_NAMED_CID(NS_ABOUT_CACHE_MODULE_CID);
 NS_DEFINE_NAMED_CID(NS_ABOUT_CACHE_ENTRY_MODULE_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_SOCKSSOCKETPROVIDER_CID);
 NS_DEFINE_NAMED_CID(NS_SOCKS4SOCKETPROVIDER_CID);
 NS_DEFINE_NAMED_CID(NS_UDPSOCKETPROVIDER_CID);
 NS_DEFINE_NAMED_CID(NS_CACHESERVICE_CID);
-#ifdef NECKO_OFFLINE_CACHE
 NS_DEFINE_NAMED_CID(NS_APPLICATIONCACHESERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_APPLICATIONCACHENAMESPACE_CID);
 NS_DEFINE_NAMED_CID(NS_APPLICATIONCACHE_CID);
-#endif
 #ifdef NECKO_COOKIES
 NS_DEFINE_NAMED_CID(NS_COOKIEMANAGER_CID);
 NS_DEFINE_NAMED_CID(NS_COOKIESERVICE_CID);
 #endif
 #ifdef NECKO_WIFI
 NS_DEFINE_NAMED_CID(NS_WIFI_MONITOR_COMPONENT_CID);
 #endif
 #ifdef NECKO_PROTOCOL_data
@@ -897,21 +893,19 @@ static const mozilla::Module::CIDEntry k
 #endif
     { &kNS_ABOUT_CACHE_MODULE_CID, false, NULL, nsAboutCache::Create },
     { &kNS_ABOUT_CACHE_ENTRY_MODULE_CID, false, NULL, nsAboutCacheEntryConstructor },
 #endif
     { &kNS_SOCKSSOCKETPROVIDER_CID, false, NULL, nsSOCKSSocketProvider::CreateV5 },
     { &kNS_SOCKS4SOCKETPROVIDER_CID, false, NULL, nsSOCKSSocketProvider::CreateV4 },
     { &kNS_UDPSOCKETPROVIDER_CID, false, NULL, nsUDPSocketProviderConstructor },
     { &kNS_CACHESERVICE_CID, false, NULL, nsCacheService::Create },
-#ifdef NECKO_OFFLINE_CACHE
     { &kNS_APPLICATIONCACHESERVICE_CID, false, NULL, nsOfflineCacheDeviceConstructor },
     { &kNS_APPLICATIONCACHENAMESPACE_CID, false, NULL, nsApplicationCacheNamespaceConstructor },
     { &kNS_APPLICATIONCACHE_CID, false, NULL, nsApplicationCacheConstructor },
-#endif
 #ifdef NECKO_COOKIES
     { &kNS_COOKIEMANAGER_CID, false, NULL, nsICookieServiceConstructor },
     { &kNS_COOKIESERVICE_CID, false, NULL, nsICookieServiceConstructor },
 #endif
 #ifdef NECKO_WIFI
     { &kNS_WIFI_MONITOR_COMPONENT_CID, false, NULL, nsWifiMonitorConstructor },
 #endif
 #ifdef NECKO_PROTOCOL_data
@@ -1039,21 +1033,19 @@ static const mozilla::Module::ContractID
 #endif
     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache", &kNS_ABOUT_CACHE_MODULE_CID },
     { NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache-entry", &kNS_ABOUT_CACHE_ENTRY_MODULE_CID },
 #endif
     { NS_NETWORK_SOCKET_CONTRACTID_PREFIX "socks", &kNS_SOCKSSOCKETPROVIDER_CID },
     { NS_NETWORK_SOCKET_CONTRACTID_PREFIX "socks4", &kNS_SOCKS4SOCKETPROVIDER_CID },
     { NS_NETWORK_SOCKET_CONTRACTID_PREFIX "udp", &kNS_UDPSOCKETPROVIDER_CID },
     { NS_CACHESERVICE_CONTRACTID, &kNS_CACHESERVICE_CID },
-#ifdef NECKO_OFFLINE_CACHE
     { NS_APPLICATIONCACHESERVICE_CONTRACTID, &kNS_APPLICATIONCACHESERVICE_CID },
     { NS_APPLICATIONCACHENAMESPACE_CONTRACTID, &kNS_APPLICATIONCACHENAMESPACE_CID },
     { NS_APPLICATIONCACHE_CONTRACTID, &kNS_APPLICATIONCACHE_CID },
-#endif
 #ifdef NECKO_COOKIES
     { NS_COOKIEMANAGER_CONTRACTID, &kNS_COOKIEMANAGER_CID },
     { NS_COOKIESERVICE_CONTRACTID, &kNS_COOKIESERVICE_CID },
 #endif
 #ifdef NECKO_WIFI
     { NS_WIFI_MONITOR_CONTRACTID, &kNS_WIFI_MONITOR_COMPONENT_CID },
 #endif
 #ifdef NECKO_PROTOCOL_data
--- a/netwerk/cache/Makefile.in
+++ b/netwerk/cache/Makefile.in
@@ -67,32 +67,25 @@ EXPORTS = \
 CPPSRCS = \
   nsCache.cpp \
   nsCacheEntry.cpp \
   nsCacheEntryDescriptor.cpp \
   nsCacheMetaData.cpp \
   nsCacheService.cpp \
   nsCacheSession.cpp \
   nsMemoryCacheDevice.cpp \
-  nsDiskCacheDeviceSQL.cpp \
-  $(NULL)
-
-ifdef NECKO_DISK_CACHE
-CPPSRCS += \
   nsDiskCacheBinding.cpp \
   nsDiskCacheBlockFile.cpp \
   nsDiskCacheDevice.cpp \
+  nsDiskCacheDeviceSQL.cpp \
   nsDiskCacheEntry.cpp \
   nsDiskCacheMap.cpp \
   nsDiskCacheStreams.cpp \
   nsDeleteDir.cpp \
   $(NULL)
-endif
-
-DEFINES += -DNECKO_OFFLINE_CACHE
 
 LOCAL_INCLUDES = \
   -I$(srcdir)/../base/src \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 DEFINES += -DIMPL_NS_NET
--- a/netwerk/cache/nsCacheService.cpp
+++ b/netwerk/cache/nsCacheService.cpp
@@ -47,20 +47,17 @@
 #include "nsCacheService.h"
 #include "nsCacheRequest.h"
 #include "nsCacheEntry.h"
 #include "nsCacheEntryDescriptor.h"
 #include "nsCacheDevice.h"
 #include "nsMemoryCacheDevice.h"
 #include "nsICacheVisitor.h"
 #include "nsDiskCacheDevice.h"
-
-#ifdef NECKO_OFFLINE_CACHE
 #include "nsDiskCacheDeviceSQL.h"
-#endif
 
 #include "nsIMemoryReporter.h"
 #include "nsIObserverService.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefBranch2.h"
 #include "nsILocalFile.h"
 #include "nsIOService.h"
@@ -107,28 +104,24 @@ using namespace mozilla;
 
 static const char * observerList[] = { 
     "profile-before-change",
     "profile-do-change",
     NS_XPCOM_SHUTDOWN_OBSERVER_ID,
     NS_PRIVATE_BROWSING_SWITCH_TOPIC
 };
 static const char * prefList[] = { 
-#ifdef NECKO_DISK_CACHE
     DISK_CACHE_ENABLE_PREF,
     DISK_CACHE_SMART_SIZE_ENABLED_PREF,
     DISK_CACHE_CAPACITY_PREF,
     DISK_CACHE_DIR_PREF,
     DISK_CACHE_MAX_ENTRY_SIZE_PREF,
-#endif
-#ifdef NECKO_OFFLINE_CACHE
     OFFLINE_CACHE_ENABLE_PREF,
     OFFLINE_CACHE_CAPACITY_PREF,
     OFFLINE_CACHE_DIR_PREF,
-#endif
     MEMORY_CACHE_ENABLE_PREF,
     MEMORY_CACHE_CAPACITY_PREF,
     MEMORY_CACHE_MAX_ENTRY_SIZE_PREF
 };
 
 // Cache sizes, in KB
 const PRInt32 DEFAULT_CACHE_SIZE = 250 * 1024;  // 250 MB
 const PRInt32 MIN_CACHE_SIZE = 50 * 1024;       //  50 MB
@@ -405,17 +398,16 @@ nsCacheProfilePrefObserver::Observe(nsIS
         // ignore pref changes until we're done switch profiles
         if (!mHaveProfile)  
             return NS_OK;
 
         nsCOMPtr<nsIPrefBranch> branch = do_QueryInterface(subject, &rv);
         if (NS_FAILED(rv))  
             return rv;
 
-#ifdef NECKO_DISK_CACHE
         // which preference changed?
         if (!strcmp(DISK_CACHE_ENABLE_PREF, data.get())) {
 
             if (!mInPrivateBrowsing) {
                 rv = branch->GetBoolPref(DISK_CACHE_ENABLE_PREF,
                                          &mDiskCacheEnabled);
                 if (NS_FAILED(rv))  
                     return rv;
@@ -473,20 +465,18 @@ nsCacheProfilePrefObserver::Observe(nsIS
           
 #if 0            
         } else if (!strcmp(DISK_CACHE_DIR_PREF, data.get())) {
             // XXX We probaby don't want to respond to this pref except after
             // XXX profile changes.  Ideally, there should be somekind of user
             // XXX notification that the pref change won't take effect until
             // XXX the next time the profile changes (browser launch)
 #endif            
-        } else 
-#endif // !NECKO_DISK_CACHE
-
-#ifdef NECKO_OFFLINE_CACHE
+        } else
+
         // which preference changed?
         if (!strcmp(OFFLINE_CACHE_ENABLE_PREF, data.get())) {
 
             if (!mInPrivateBrowsing) {
                 rv = branch->GetBoolPref(OFFLINE_CACHE_ENABLE_PREF,
                                          &mOfflineCacheEnabled);
                 if (NS_FAILED(rv))  return rv;
                 nsCacheService::SetOfflineCacheEnabled(OfflineCacheEnabled());
@@ -502,17 +492,16 @@ nsCacheProfilePrefObserver::Observe(nsIS
 #if 0
         } else if (!strcmp(OFFLINE_CACHE_DIR_PREF, data.get())) {
             // XXX We probaby don't want to respond to this pref except after
             // XXX profile changes.  Ideally, there should be some kind of user
             // XXX notification that the pref change won't take effect until
             // XXX the next time the profile changes (browser launch)
 #endif
         } else
-#endif // !NECKO_OFFLINE_CACHE
 
         if (!strcmp(MEMORY_CACHE_ENABLE_PREF, data.get())) {
 
             rv = branch->GetBoolPref(MEMORY_CACHE_ENABLE_PREF,
                                      &mMemoryCacheEnabled);
             if (NS_FAILED(rv))  
                 return rv;
             nsCacheService::SetMemoryCache();
@@ -534,49 +523,39 @@ nsCacheProfilePrefObserver::Observe(nsIS
             nsCacheService::SetMemoryCacheMaxEntrySize(mMemoryCacheMaxEntrySize);
         }
     } else if (!strcmp(NS_PRIVATE_BROWSING_SWITCH_TOPIC, topic)) {
         if (!strcmp(NS_PRIVATE_BROWSING_ENTER, data.get())) {
             mInPrivateBrowsing = PR_TRUE;
 
             nsCacheService::OnEnterExitPrivateBrowsing();
 
-#ifdef NECKO_DISK_CACHE
             mDiskCacheEnabled = PR_FALSE;
             nsCacheService::SetDiskCacheEnabled(DiskCacheEnabled());
-#endif // !NECKO_DISK_CACHE
-
-#ifdef NECKO_OFFLINE_CACHE
+
             mOfflineCacheEnabled = PR_FALSE;
             nsCacheService::SetOfflineCacheEnabled(OfflineCacheEnabled());
-#endif // !NECKO_OFFLINE_CACHE
         } else if (!strcmp(NS_PRIVATE_BROWSING_LEAVE, data.get())) {
             mInPrivateBrowsing = PR_FALSE;
 
             nsCacheService::OnEnterExitPrivateBrowsing();
 
-#if defined(NECKO_DISK_CACHE) || defined(NECKO_OFFLINE_CACHE)
             nsCOMPtr<nsIPrefBranch> branch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
             if (NS_FAILED(rv))  
                 return rv;
-#endif // !NECKO_DISK_CACHE && !NECKO_OFFLINE_CACHE
-
-#ifdef NECKO_DISK_CACHE
+
             mDiskCacheEnabled = PR_TRUE; // by default enabled
             (void) branch->GetBoolPref(DISK_CACHE_ENABLE_PREF,
                                        &mDiskCacheEnabled);
             nsCacheService::SetDiskCacheEnabled(DiskCacheEnabled());
-#endif // !NECKO_DISK_CACHE
-
-#ifdef NECKO_OFFLINE_CACHE
+
             mOfflineCacheEnabled = PR_TRUE; // by default enabled
             (void) branch->GetBoolPref(OFFLINE_CACHE_ENABLE_PREF,
                                        &mOfflineCacheEnabled);
             nsCacheService::SetOfflineCacheEnabled(OfflineCacheEnabled());
-#endif // !NECKO_OFFLINE_CACHE
         }
     }
     
     return NS_OK;
 }
 
  /* Computes our best guess for the default size of the user's disk cache, 
   * based on the amount of space they have free on their hard drive. 
@@ -669,17 +648,16 @@ nsCacheProfilePrefObserver::PermittedToS
 }
 
 
 nsresult
 nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch)
 {
     nsresult rv = NS_OK;
 
-#ifdef NECKO_DISK_CACHE
     // read disk cache device prefs
     if (!mInPrivateBrowsing) {
         mDiskCacheEnabled = PR_TRUE;  // presume disk cache is enabled
         (void) branch->GetBoolPref(DISK_CACHE_ENABLE_PREF, &mDiskCacheEnabled);
     }
 
     mDiskCacheCapacity = DISK_CACHE_CAPACITY;
     (void)branch->GetIntPref(DISK_CACHE_CAPACITY_PREF, &mDiskCacheCapacity);
@@ -765,19 +743,17 @@ nsCacheProfilePrefObserver::ReadPrefs(ns
         if (firstSmartSizeRun) {
             // It is no longer our first run
             rv = branch->SetBoolPref(DISK_CACHE_SMART_SIZE_FIRST_RUN_PREF, 
                                      PR_FALSE);
             if (NS_FAILED(rv)) 
                 NS_WARNING("Failed setting first_run pref in ReadPrefs.");
         }
     }
-#endif // !NECKO_DISK_CACHE
-
-#ifdef NECKO_OFFLINE_CACHE
+
     // read offline cache device prefs
     if (!mInPrivateBrowsing) {
         mOfflineCacheEnabled = PR_TRUE;  // presume offline cache is enabled
         (void) branch->GetBoolPref(OFFLINE_CACHE_ENABLE_PREF,
                                    &mOfflineCacheEnabled);
     }
 
     mOfflineCacheCapacity = OFFLINE_CACHE_CAPACITY;
@@ -810,18 +786,17 @@ nsCacheProfilePrefObserver::ReadPrefs(ns
             // use current process directory during development
             rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
                                         getter_AddRefs(directory));
         }
 #endif
         if (directory)
             mOfflineCacheParentDirectory = do_QueryInterface(directory, &rv);
     }
-#endif // !NECKO_OFFLINE_CACHE
-    
+
     // read memory cache device prefs
     (void) branch->GetBoolPref(MEMORY_CACHE_ENABLE_PREF, &mMemoryCacheEnabled);
 
     mMemoryCacheCapacity = -1;
     (void) branch->GetIntPref(MEMORY_CACHE_CAPACITY_PREF,
                               &mMemoryCacheCapacity);
 
     (void) branch->GetIntPref(MEMORY_CACHE_MAX_ENTRY_SIZE_PREF,
@@ -1116,26 +1091,22 @@ nsCacheService::Shutdown()
         // to be safe
         NS_UnregisterMemoryReporter(MemoryCacheReporter);
         MemoryCacheReporter = nsnull;
 
         // deallocate memory and disk caches
         delete mMemoryDevice;
         mMemoryDevice = nsnull;
 
-#ifdef NECKO_DISK_CACHE
         delete mDiskDevice;
         mDiskDevice = nsnull;
-#endif // !NECKO_DISK_CACHE
-
-#ifdef NECKO_OFFLINE_CACHE
+
         NS_IF_RELEASE(mOfflineDevice);
-#endif // !NECKO_OFFLINE_CACHE
-
-#if defined(NECKO_DISK_CACHE) && defined(PR_LOGGING)
+
+#ifdef PR_LOGGING
         LogCacheStatistics();
 #endif
 
         mCacheIOThread.swap(cacheIOThread);
     }
     } // lock
 
     if (cacheIOThread)
@@ -1216,44 +1187,40 @@ nsCacheService::EvictEntriesForClient(co
                                       NS_CACHESERVICE_EMPTYCACHE_TOPIC_ID,
                                       nsnull);
         }
     }
 
     nsCacheServiceAutoLock lock;
     nsresult res = NS_OK;
 
-#ifdef NECKO_DISK_CACHE
     if (storagePolicy == nsICache::STORE_ANYWHERE ||
         storagePolicy == nsICache::STORE_ON_DISK) {
 
         if (mEnableDiskDevice) {
             nsresult rv;
             if (!mDiskDevice)
                 rv = CreateDiskDevice();
             if (mDiskDevice)
                 rv = mDiskDevice->EvictEntries(clientID);
             if (NS_FAILED(rv)) res = rv;
         }
     }
-#endif // ! NECKO_DISK_CACHE
-
-#ifdef NECKO_OFFLINE_CACHE
+
     // Only clear the offline cache if it has been specifically asked for.
     if (storagePolicy == nsICache::STORE_OFFLINE) {
         if (mEnableOfflineDevice) {
             nsresult rv;
             if (!mOfflineDevice)
                 rv = CreateOfflineDevice();
             if (mOfflineDevice)
                 rv = mOfflineDevice->EvictEntries(clientID);
             if (NS_FAILED(rv)) res = rv;
         }
     }
-#endif // ! NECKO_OFFLINE_CACHE
 
     if (storagePolicy == nsICache::STORE_ANYWHERE ||
         storagePolicy == nsICache::STORE_IN_MEMORY) {
 
         // If there is no memory device, there is no need to evict it...
         if (mMemoryDevice) {
             nsresult rv;
             rv = mMemoryDevice->EvictEntries(clientID);
@@ -1313,37 +1280,33 @@ NS_IMETHODIMP nsCacheService::VisitEntri
     
     nsresult rv = NS_OK;
     // If there is no memory device, there are then also no entries to visit...
     if (mMemoryDevice) {
         rv = mMemoryDevice->Visit(visitor);
         if (NS_FAILED(rv)) return rv;
     }
 
-#ifdef NECKO_DISK_CACHE
     if (mEnableDiskDevice) {
         if (!mDiskDevice) {
             rv = CreateDiskDevice();
             if (NS_FAILED(rv)) return rv;
         }
         rv = mDiskDevice->Visit(visitor);
         if (NS_FAILED(rv)) return rv;
     }
-#endif // !NECKO_DISK_CACHE
-
-#ifdef NECKO_OFFLINE_CACHE
+
     if (mEnableOfflineDevice) {
         if (!mOfflineDevice) {
             rv = CreateOfflineDevice();
             if (NS_FAILED(rv)) return rv;
         }
         rv = mOfflineDevice->Visit(visitor);
         if (NS_FAILED(rv)) return rv;
     }
-#endif // !NECKO_OFFLINE_CACHE
 
     // XXX notify any shutdown process that visitation is complete for THIS visitor.
     // XXX keep queue of visitors
 
     return NS_OK;
 }
 
 
@@ -1364,17 +1327,16 @@ NS_IMETHODIMP nsCacheService::GetCacheIO
 }
 
 /**
  * Internal Methods
  */
 nsresult
 nsCacheService::CreateDiskDevice()
 {
-#ifdef NECKO_DISK_CACHE
     if (!mInitialized)      return NS_ERROR_NOT_AVAILABLE;
     if (!mEnableDiskDevice) return NS_ERROR_NOT_AVAILABLE;
     if (mDiskDevice)        return NS_OK;
 
     mDiskDevice = new nsDiskCacheDevice;
     if (!mDiskDevice)       return NS_ERROR_OUT_OF_MEMORY;
 
     // set the preferences
@@ -1390,26 +1352,21 @@ nsCacheService::CreateDiskDevice()
         printf("###    - disabling disk cache for this session.\n");
         printf("###\n");
 #endif        
         mEnableDiskDevice = PR_FALSE;
         delete mDiskDevice;
         mDiskDevice = nsnull;
     }
     return rv;
-#else // !NECKO_DISK_CACHE
-    NS_NOTREACHED("nsCacheService::CreateDiskDevice");
-    return NS_ERROR_NOT_IMPLEMENTED;
-#endif
 }
 
 nsresult
 nsCacheService::CreateOfflineDevice()
 {
-#ifdef NECKO_OFFLINE_CACHE
     CACHE_LOG_ALWAYS(("Creating offline device"));
 
     if (!mInitialized)         return NS_ERROR_NOT_AVAILABLE;
     if (!mEnableOfflineDevice) return NS_ERROR_NOT_AVAILABLE;
     if (mOfflineDevice)        return NS_OK;
 
     mOfflineDevice = new nsOfflineCacheDevice;
     if (!mOfflineDevice)       return NS_ERROR_OUT_OF_MEMORY;
@@ -1425,20 +1382,16 @@ nsCacheService::CreateOfflineDevice()
     if (NS_FAILED(rv)) {
         CACHE_LOG_DEBUG(("mOfflineDevice->Init() failed (0x%.8x)\n", rv));
         CACHE_LOG_DEBUG(("    - disabling offline cache for this session.\n"));
 
         mEnableOfflineDevice = PR_FALSE;
         NS_RELEASE(mOfflineDevice);
     }
     return rv;
-#else // !NECKO_DISK_CACHE
-    NS_NOTREACHED("nsCacheService::CreateOfflineDevice");
-    return NS_ERROR_NOT_IMPLEMENTED;
-#endif
 }
 
 nsresult
 nsCacheService::CreateMemoryDevice()
 {
     if (!mInitialized)        return NS_ERROR_NOT_AVAILABLE;
     if (!mEnableMemoryDevice) return NS_ERROR_NOT_AVAILABLE;
     if (mMemoryDevice)        return NS_OK;
@@ -1815,60 +1768,55 @@ nsCacheService::SearchCacheDevices(nsCSt
             CACHE_LOG_DEBUG(("Searching mMemoryDevice for key %s found: 0x%p, "
                              "collision: %d\n", key->get(), entry, collision));
         }
     }
 
     if (!entry && 
         ((policy == nsICache::STORE_ANYWHERE) || (policy == nsICache::STORE_ON_DISK))) {
 
-#ifdef NECKO_DISK_CACHE
         if (mEnableDiskDevice) {
             if (!mDiskDevice) {
                 nsresult rv = CreateDiskDevice();
                 if (NS_FAILED(rv))
                     return nsnull;
             }
             
             entry = mDiskDevice->FindEntry(key, collision);
         }
-#endif // !NECKO_DISK_CACHE
     }
 
     if (!entry && (policy == nsICache::STORE_OFFLINE ||
                    (policy == nsICache::STORE_ANYWHERE &&
                     gIOService->IsOffline()))) {
 
-#ifdef NECKO_OFFLINE_CACHE
         if (mEnableOfflineDevice) {
             if (!mOfflineDevice) {
                 nsresult rv = CreateOfflineDevice();
                 if (NS_FAILED(rv))
                     return nsnull;
             }
 
             entry = mOfflineDevice->FindEntry(key, collision);
         }
-#endif // !NECKO_OFFLINE_CACHE
     }
 
     return entry;
 }
 
 
 nsCacheDevice *
 nsCacheService::EnsureEntryHasDevice(nsCacheEntry * entry)
 {
     nsCacheDevice * device = entry->CacheDevice();
     // return device if found, possibly null if the entry is doomed i.e prevent
     // doomed entries to bind to a device (see e.g. bugs #548406 and #596443)
     if (device || entry->IsDoomed())  return device;
 
     PRInt64 predictedDataSize = entry->PredictedDataSize();
-#ifdef NECKO_DISK_CACHE
     if (entry->IsStreamData() && entry->IsAllowedOnDisk() && mEnableDiskDevice) {
         // this is the default
         if (!mDiskDevice) {
             (void)CreateDiskDevice();  // ignore the error (check for mDiskDevice instead)
         }
 
         if (mDiskDevice) {
             // Bypass the cache if Content-Length says the entry will be too big
@@ -1882,17 +1830,16 @@ nsCacheService::EnsureEntryHasDevice(nsC
 
             entry->MarkBinding();  // enter state of binding
             nsresult rv = mDiskDevice->BindEntry(entry);
             entry->ClearBinding(); // exit state of binding
             if (NS_SUCCEEDED(rv))
                 device = mDiskDevice;
         }
     }
-#endif // !NECKO_DISK_CACHE
 
     // if we can't use mDiskDevice, try mMemoryDevice
     if (!device && mEnableMemoryDevice && entry->IsAllowedInMemory()) {        
         if (!mMemoryDevice) {
             (void)CreateMemoryDevice();  // ignore the error (check for mMemoryDevice instead)
         }
         if (mMemoryDevice) {
             // Bypass the cache if Content-Length says entry will be too big
@@ -1906,32 +1853,30 @@ nsCacheService::EnsureEntryHasDevice(nsC
             entry->MarkBinding();  // enter state of binding
             nsresult rv = mMemoryDevice->BindEntry(entry);
             entry->ClearBinding(); // exit state of binding
             if (NS_SUCCEEDED(rv))
                 device = mMemoryDevice;
         }
     }
 
-#ifdef NECKO_OFFLINE_CACHE
     if (!device && entry->IsStreamData() &&
         entry->IsAllowedOffline() && mEnableOfflineDevice) {
         if (!mOfflineDevice) {
             (void)CreateOfflineDevice(); // ignore the error (check for mOfflineDevice instead)
         }
 
         if (mOfflineDevice) {
             entry->MarkBinding();
             nsresult rv = mOfflineDevice->BindEntry(entry);
             entry->ClearBinding();
             if (NS_SUCCEEDED(rv))
                 device = mOfflineDevice;
         }
     }
-#endif // ! NECKO_OFFLINE_CACHE
 
     if (device) 
         entry->SetCacheDevice(device);
     return device;
 }
 
 PRInt64
 nsCacheService::MemoryDeviceSize()
@@ -1999,35 +1944,31 @@ nsCacheService::OnProfileShutdown(PRBool
 
     gService->DoomActiveEntries();
     gService->ClearDoomList();
 
     // Make sure to wait for any pending cache-operations before
     // proceeding with destructive actions (bug #620660)
     (void) SyncWithCacheIOThread();
 
-#ifdef NECKO_DISK_CACHE
     if (gService->mDiskDevice && gService->mEnableDiskDevice) {
         if (cleanse)
             gService->mDiskDevice->EvictEntries(nsnull);
 
         gService->mDiskDevice->Shutdown();
     }
     gService->mEnableDiskDevice = PR_FALSE;
-#endif // !NECKO_DISK_CACHE
-
-#ifdef NECKO_OFFLINE_CACHE
+
     if (gService->mOfflineDevice && gService->mEnableOfflineDevice) {
         if (cleanse)
             gService->mOfflineDevice->EvictEntries(nsnull);
 
         gService->mOfflineDevice->Shutdown();
     }
     gService->mEnableOfflineDevice = PR_FALSE;
-#endif // !NECKO_OFFLINE_CACHE
 
     if (gService->mMemoryDevice) {
         // clear memory cache
         gService->mMemoryDevice->EvictEntries(nsnull);
     }
 
 }
 
@@ -2040,46 +1981,42 @@ nsCacheService::OnProfileChanged()
     CACHE_LOG_DEBUG(("nsCacheService::OnProfileChanged"));
  
     nsCacheServiceAutoLock lock;
     
     gService->mEnableDiskDevice    = gService->mObserver->DiskCacheEnabled();
     gService->mEnableOfflineDevice = gService->mObserver->OfflineCacheEnabled();
     gService->mEnableMemoryDevice  = gService->mObserver->MemoryCacheEnabled();
 
-#ifdef NECKO_DISK_CACHE
     if (gService->mDiskDevice) {
         gService->mDiskDevice->SetCacheParentDirectory(gService->mObserver->DiskCacheParentDirectory());
         gService->mDiskDevice->SetCapacity(gService->mObserver->DiskCacheCapacity());
 
         // XXX initialization of mDiskDevice could be made lazily, if mEnableDiskDevice is false
         nsresult rv = gService->mDiskDevice->Init();
         if (NS_FAILED(rv)) {
             NS_ERROR("nsCacheService::OnProfileChanged: Re-initializing disk device failed");
             gService->mEnableDiskDevice = PR_FALSE;
             // XXX delete mDiskDevice?
         }
     }
-#endif // !NECKO_DISK_CACHE
-
-#ifdef NECKO_OFFLINE_CACHE
+
     if (gService->mOfflineDevice) {
         gService->mOfflineDevice->SetCacheParentDirectory(gService->mObserver->OfflineCacheParentDirectory());
         gService->mOfflineDevice->SetCapacity(gService->mObserver->OfflineCacheCapacity());
 
         // XXX initialization of mOfflineDevice could be made lazily, if mEnableOfflineDevice is false
         nsresult rv = gService->mOfflineDevice->Init();
         if (NS_FAILED(rv)) {
             NS_ERROR("nsCacheService::OnProfileChanged: Re-initializing offline device failed");
             gService->mEnableOfflineDevice = PR_FALSE;
             // XXX delete mOfflineDevice?
         }
     }
-#endif // !NECKO_OFFLINE_CACHE
-    
+
     // If memoryDevice exists, reset its size to the new profile
     if (gService->mMemoryDevice) {
         if (gService->mEnableMemoryDevice) {
             // make sure that capacity is reset to the right value
             PRInt32 capacity = gService->mObserver->MemoryCacheCapacity();
             CACHE_LOG_DEBUG(("Resetting memory device capacity to %d\n",
                              capacity));
             gService->mMemoryDevice->SetCapacity(capacity);
@@ -2103,37 +2040,33 @@ nsCacheService::SetDiskCacheEnabled(PRBo
 
 
 void
 nsCacheService::SetDiskCacheCapacity(PRInt32  capacity)
 {
     if (!gService)  return;
     nsCacheServiceAutoLock lock;
 
-#ifdef NECKO_DISK_CACHE
     if (gService->mDiskDevice) {
         gService->mDiskDevice->SetCapacity(capacity);
     }
-#endif // !NECKO_DISK_CACHE
-    
+
     if (gService->mObserver)
         gService->mEnableDiskDevice = gService->mObserver->DiskCacheEnabled();
 }
 
 void
 nsCacheService::SetDiskCacheMaxEntrySize(PRInt32  maxSize)
 {
     if (!gService)  return;
     nsCacheServiceAutoLock lock;
 
-#ifdef NECKO_DISK_CACHE
     if (gService->mDiskDevice) {
         gService->mDiskDevice->SetMaxEntrySize(maxSize);
     }
-#endif // !NECKO_DISK_CACHE
 }
 
 void
 nsCacheService::SetMemoryCacheMaxEntrySize(PRInt32  maxSize)
 {
     if (!gService)  return;
     nsCacheServiceAutoLock lock;
 
@@ -2151,21 +2084,19 @@ nsCacheService::SetOfflineCacheEnabled(P
 }
 
 void
 nsCacheService::SetOfflineCacheCapacity(PRInt32  capacity)
 {
     if (!gService)  return;
     nsCacheServiceAutoLock lock;
 
-#ifdef NECKO_OFFLINE_CACHE
     if (gService->mOfflineDevice) {
         gService->mOfflineDevice->SetCapacity(capacity);
     }
-#endif // !NECKO_OFFLINE_CACHE
 
     gService->mEnableOfflineDevice = gService->mObserver->OfflineCacheEnabled();
 }
 
 
 void
 nsCacheService::SetMemoryCache()
 {
--- a/netwerk/necko-config.h.in
+++ b/netwerk/necko-config.h.in
@@ -32,18 +32,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _NECKO_CONFIG_H_
 #define _NECKO_CONFIG_H_
 
-#undef NECKO_DISK_CACHE
-
 #undef NECKO_COOKIES
 
 #undef NECKO_WIFI
 
 #undef NECKO_PROTOCOL_about
 #undef NECKO_PROTOCOL_data
 #undef NECKO_PROTOCOL_device
 #undef NECKO_PROTOCOL_file
--- a/security/manager/pki/resources/content/viewCertDetails.js
+++ b/security/manager/pki/resources/content/viewCertDetails.js
@@ -254,17 +254,17 @@ function DisplayVerificationData(cert, r
   } else if (verifystate == cert.ISSUER_UNKNOWN) {
     verifystr = bundle.GetStringFromName('certNotVerified_IssuerUnknown');
   } else if (verifystate == cert.INVALID_CA) {
     verifystr = bundle.GetStringFromName('certNotVerified_CAInvalid');
   } else { /* if (verifystate == cert.NOT_VERIFIED_UNKNOWN || == USAGE_NOT_ALLOWED) */
     verifystr = bundle.GetStringFromName('certNotVerified_Unknown');
   }
   var verified=document.getElementById('verified');
-  verified.setAttribute("value", verifystr);
+  verified.textContent = verifystr;
   if (count > 0) {
     var verifyInfoBox = document.getElementById('verify_info_box');
     for (var i=0; i<count; i++) {
       AddUsage(usageList[i],verifyInfoBox);
     }
   }
 }
 
--- a/storage/test/test_file_perms.cpp
+++ b/storage/test/test_file_perms.cpp
@@ -44,18 +44,17 @@
  * This file tests that the file permissions of the sqlite files match what
  * we request they be
  */
 
 void
 test_file_perms()
 {
   nsCOMPtr<nsIFile> profDir;
-  nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
-                                       getter_AddRefs(profDir));
+  (void)NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profDir));
   nsCOMPtr<nsILocalFile> sqlite_file = do_QueryInterface(profDir);
   sqlite_file->Append(NS_LITERAL_STRING("places.sqlite"));
   PRUint32 perms = 0;
   sqlite_file->GetPermissions(&perms);
 
   // This reflexts the permissions defined by SQLITE_DEFAULT_FILE_PERMISSIONS in
   // db/sqlite3/src/Makefile.in and must be kept in sync with that
 #ifdef ANDROID
--- a/toolkit/components/places/PlacesUtils.jsm
+++ b/toolkit/components/places/PlacesUtils.jsm
@@ -2161,20 +2161,16 @@ XPCOMUtils.defineLazyServiceGetter(Place
 XPCOMUtils.defineLazyGetter(PlacesUtils, "bhistory", function() {
   return PlacesUtils.history.QueryInterface(Ci.nsIBrowserHistory);
 });
 
 XPCOMUtils.defineLazyGetter(PlacesUtils, "ghistory2", function() {
   return PlacesUtils.history.QueryInterface(Ci.nsIGlobalHistory2);
 });
 
-XPCOMUtils.defineLazyGetter(PlacesUtils, "ghistory3", function() {
-  return PlacesUtils.history.QueryInterface(Ci.nsIGlobalHistory3);
-});
-
 XPCOMUtils.defineLazyServiceGetter(PlacesUtils, "favicons",
                                    "@mozilla.org/browser/favicon-service;1",
                                    "nsIFaviconService");
 
 XPCOMUtils.defineLazyServiceGetter(PlacesUtils, "bookmarks",
                                    "@mozilla.org/browser/nav-bookmarks-service;1",
                                    "nsINavBookmarksService");
 
--- a/toolkit/components/places/nsNavHistory.cpp
+++ b/toolkit/components/places/nsNavHistory.cpp
@@ -207,35 +207,33 @@ static const PRInt64 USECS_PER_DAY = LL_
 
 NS_IMPL_THREADSAFE_ADDREF(nsNavHistory)
 NS_IMPL_THREADSAFE_RELEASE(nsNavHistory)
 
 NS_IMPL_CLASSINFO(nsNavHistory, NULL, nsIClassInfo::SINGLETON,
                   NS_NAVHISTORYSERVICE_CID)
 NS_INTERFACE_MAP_BEGIN(nsNavHistory)
   NS_INTERFACE_MAP_ENTRY(nsINavHistoryService)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIGlobalHistory2, nsIGlobalHistory3)
-  NS_INTERFACE_MAP_ENTRY(nsIGlobalHistory3)
+  NS_INTERFACE_MAP_ENTRY(nsIGlobalHistory2)
   NS_INTERFACE_MAP_ENTRY(nsIDownloadHistory)
   NS_INTERFACE_MAP_ENTRY(nsIBrowserHistory)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsICharsetResolver)
   NS_INTERFACE_MAP_ENTRY(nsPIPlacesDatabase)
   NS_INTERFACE_MAP_ENTRY(nsPIPlacesHistoryListenersNotifier)
   NS_INTERFACE_MAP_ENTRY(mozIStorageVacuumParticipant)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsINavHistoryService)
   NS_IMPL_QUERY_CLASSINFO(nsNavHistory)
 NS_INTERFACE_MAP_END
 
 // We don't care about flattening everything
-NS_IMPL_CI_INTERFACE_GETTER5(
+NS_IMPL_CI_INTERFACE_GETTER4(
   nsNavHistory
 , nsINavHistoryService
-, nsIGlobalHistory3
 , nsIGlobalHistory2
 , nsIDownloadHistory
 , nsIBrowserHistory
 )
 
 namespace {
 
 static PRInt64 GetSimpleBookmarksQueryFolder(
@@ -466,18 +464,16 @@ nsNavHistory::Init()
 
   // recent events hash tables
   NS_ENSURE_TRUE(mRecentTyped.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE),
                  NS_ERROR_OUT_OF_MEMORY);
   NS_ENSURE_TRUE(mRecentLink.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE),
                  NS_ERROR_OUT_OF_MEMORY);
   NS_ENSURE_TRUE(mRecentBookmark.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE),
                  NS_ERROR_OUT_OF_MEMORY);
-  NS_ENSURE_TRUE(mRecentRedirects.Init(RECENT_EVENTS_INITIAL_CACHE_SIZE),
-                 NS_ERROR_OUT_OF_MEMORY);
 
   // Embed visits hash table.
   NS_ENSURE_TRUE(mEmbedVisits.Init(EMBED_VISITS_INITIAL_CACHE_SIZE),
                  NS_ERROR_OUT_OF_MEMORY);
 
   /*****************************************************************************
    *** IMPORTANT NOTICE!
    ***
@@ -2721,19 +2717,18 @@ nsNavHistory::AddVisit(nsIURI* aURI, PRT
   // FIXME bug 325241: make a way to observe hidden URLs
   if (!hidden) {
     NotifyOnVisit(aURI, *aVisitID, aTime, aSessionID, referringVisitID,
                   aTransitionType, guid);
   }
 
   // Normally docshell sends the link visited observer notification for us (this
   // will tell all the documents to update their visited link coloring).
-  // However, for redirects (since we implement nsIGlobalHistory3) and downloads
-  // (since we implement nsIDownloadHistory) this will not happen and we need to
-  // send it ourselves.
+  // However, for redirects and downloads (since we implement nsIDownloadHistory)
+  // this will not happen and we need to send it ourselves.
   if (newItem && (aIsRedirect || aTransitionType == TRANSITION_DOWNLOAD)) {
     nsCOMPtr<nsIObserverService> obsService =
       do_GetService(NS_OBSERVERSERVICE_CONTRACTID);
     if (obsService)
       obsService->NotifyObservers(aURI, NS_LINK_VISITED_EVENT_TOPIC, nsnull);
   }
 
   // Because we implement IHistory, we always have to notify about the visit.
@@ -4834,21 +4829,17 @@ nsNavHistory::AddURIInternal(nsIURI* aUR
 // nsNavHistory::AddVisitChain
 //
 //    This function is sits between AddURI (which is called when a page is
 //    visited) and AddVisit (which creates the DB entries) to figure out what
 //    we should add and what are the detailed parameters that should be used
 //    (like referring visit ID and typed/bookmarked state).
 //
 //    This function walks up the referring chain and recursively calls itself,
-//    each time calling InternalAdd to create a new history entry. (When we
-//    get notified of redirects, we don't actually add any history entries, just
-//    save them in mRecentRedirects. This function will add all of them for a
-//    given destination page when that page is actually visited.)
-//    See GetRedirectFor for more information about how redirects work.
+//    each time calling InternalAdd to create a new history entry.
 
 nsresult
 nsNavHistory::AddVisitChain(nsIURI* aURI,
                             PRTime aTime,
                             PRBool aToplevel,
                             PRBool aIsRedirect,
                             nsIURI* aReferrerURI,
                             PRInt64* aVisitID,
@@ -4864,62 +4855,20 @@ nsNavHistory::AddVisitChain(nsIURI* aURI
 
   // A visit is considered EMBED if it's in a frame and the page visit does not
   // come from a user's action (like clicking a link), otherwise is FRAMED_LINK.
   // An embed visit should not appear in history views.
   // See bug 381453 for details.
   PRBool isEmbedVisit = !aToplevel &&
                         !CheckIsRecentEvent(&mRecentLink, spec);
 
-  // Check if this visit came from a redirect.
   PRUint32 transitionType = 0;
-  PRTime redirectTime = 0;
-  nsCAutoString redirectSourceUrl;
-  if (GetRedirectFor(spec, redirectSourceUrl, &redirectTime, &transitionType)) {
-    // redirectSourceUrl redirected to aURL, at redirectTime, with
-    // a transitionType redirect.
-    nsCOMPtr<nsIURI> redirectSourceURI;
-    rv = NS_NewURI(getter_AddRefs(redirectSourceURI), redirectSourceUrl);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // Don't add a new visit if a page redirects to itself.
-    PRBool redirectIsSame;
-    if (NS_SUCCEEDED(aURI->Equals(redirectSourceURI, &redirectIsSame)) &&
-        redirectIsSame)
-      return NS_OK;
-
-    // Recusively call addVisitChain to walk up the chain till the first
-    // not-redirected URI.
-    // Ensure that the sources have a visit time smaller than aTime, otherwise
-    // visits would end up incorrectly ordered.
-    PRTime sourceTime = NS_MIN(redirectTime, aTime - 1);
-    PRInt64 sourceVisitId = 0;
-    rv = AddVisitChain(redirectSourceURI, sourceTime, aToplevel,
-                       PR_TRUE, // Is a redirect.
-                       aReferrerURI, // This one is the originating source.
-                       &sourceVisitId, // Get back the visit id of the source.
-                       aSessionID);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    // All the visits for preceding pages in the redirects chain have been
-    // added, now add the visit to aURI.
-    if (isEmbedVisit)
-      transitionType = nsINavHistoryService::TRANSITION_EMBED;
-    else if (!aToplevel)
-      transitionType = nsINavHistoryService::TRANSITION_FRAMED_LINK;
-
-    // This page is result of a redirect, save the source page in from_visit,
-    // to be able to walk up the chain.
-    // See bug 411966 and bug 428690 for details.
-    // TODO: Add a closure table with a chain id to easily reconstruct chains
-    // without having to recurse through the table.  See bug 468710.
-    fromVisitURI = redirectSourceURI;
-  }
-  else if (aReferrerURI) {
-    // This page does not come from a redirect and had a referrer.
+
+  if (aReferrerURI) {
+  // This page had a referrer.
 
     // Check if the referrer has a previous visit.
     PRTime lastVisitTime;
     PRInt64 referringVisitId;
     PRBool referrerHasPreviousVisit =
       FindLastVisit(aReferrerURI, &referringVisitId, &lastVisitTime, aSessionID);
 
     // Don't add a new visit if the referring site is the same as
@@ -5077,117 +5026,16 @@ nsNavHistory::GetPageTitle(nsIURI* aURI,
   }
 
   rv = stmt->GetString(nsNavHistory::kGetInfoIndex_Title, aTitle);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
-// nsNavHistory::GetURIGeckoFlags
-//
-//    FIXME: should we try to use annotations for this stuff?
-
-NS_IMETHODIMP
-nsNavHistory::GetURIGeckoFlags(nsIURI* aURI, PRUint32* aResult)
-{
-  NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
-  NS_ENSURE_ARG(aURI);
-  NS_ENSURE_ARG_POINTER(aResult);
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-
-// nsNavHistory::SetURIGeckoFlags
-//
-//    FIXME: should we try to use annotations for this stuff?
-
-NS_IMETHODIMP
-nsNavHistory::SetURIGeckoFlags(nsIURI* aURI, PRUint32 aFlags)
-{
-  NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
-  NS_ENSURE_ARG(aURI);
-
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
-
-// nsIGlobalHistory3 ***********************************************************
-
-// nsNavHistory::AddDocumentRedirect
-//
-//    This adds a redirect mapping from the destination of the redirect to the
-//    source, time, and type. This mapping is used by GetRedirectFor when we
-//    get a page added to reconstruct the redirects that happened when a page
-//    is visited. See GetRedirectFor for more information
-
-// this is the expiration callback function that deletes stale entries
-PLDHashOperator nsNavHistory::ExpireNonrecentRedirects(
-    nsCStringHashKey::KeyType aKey, RedirectInfo& aData, void* aUserArg)
-{
-  PRInt64* threshold = reinterpret_cast<PRInt64*>(aUserArg);
-  if (aData.mTimeCreated < *threshold)
-    return PL_DHASH_REMOVE;
-  return PL_DHASH_NEXT;
-}
-
-NS_IMETHODIMP
-nsNavHistory::AddDocumentRedirect(nsIChannel *aOldChannel,
-                                  nsIChannel *aNewChannel,
-                                  PRInt32 aFlags,
-                                  PRBool aToplevel)
-{
-  NS_ASSERTION(NS_IsMainThread(), "This can only be called on the main thread");
-  NS_ENSURE_ARG(aOldChannel);
-  NS_ENSURE_ARG(aNewChannel);
-
-  // Ignore internal redirects.
-  // These redirects are not initiated by the remote server, but specific to the
-  // channel implementation, so they are ignored.
-  if (aFlags & nsIChannelEventSink::REDIRECT_INTERNAL)
-    return NS_OK;
-
-  nsresult rv;
-  nsCOMPtr<nsIURI> oldURI, newURI;
-  rv = aOldChannel->GetURI(getter_AddRefs(oldURI));
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = aNewChannel->GetURI(getter_AddRefs(newURI));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  nsCString oldSpec, newSpec;
-  rv = oldURI->GetSpec(oldSpec);
-  NS_ENSURE_SUCCESS(rv, rv);
-  rv = newURI->GetSpec(newSpec);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (mRecentRedirects.Count() > RECENT_EVENT_QUEUE_MAX_LENGTH) {
-    // Expire outdated cached redirects.
-    PRInt64 threshold = PR_Now() - RECENT_EVENT_THRESHOLD;
-    mRecentRedirects.Enumerate(ExpireNonrecentRedirects,
-                               reinterpret_cast<void*>(&threshold));
-  }
-
-  RedirectInfo info;
-
-  // Remove any old entries for this redirect destination, since they are going
-  // to be replaced.
-  if (mRecentRedirects.Get(newSpec, &info))
-    mRecentRedirects.Remove(newSpec);
-  // Save the new redirect info.
-  info.mSourceURI = oldSpec;
-  info.mTimeCreated = PR_Now();
-  if (aFlags & nsIChannelEventSink::REDIRECT_TEMPORARY)
-    info.mType = TRANSITION_REDIRECT_TEMPORARY;
-  else
-    info.mType = TRANSITION_REDIRECT_PERMANENT;
-  mRecentRedirects.Put(newSpec, info);
-
-  return NS_OK;
-}
-
 
 ////////////////////////////////////////////////////////////////////////////////
 //// mozIStorageVacuumParticipant
 
 NS_IMETHODIMP
 nsNavHistory::GetDatabaseConnection(mozIStorageConnection** _DBConnection)
 {
   return GetDBConnection(_DBConnection);
@@ -6328,87 +6176,16 @@ void
 nsNavHistory::ExpireNonrecentEvents(RecentEventHash* hashTable)
 {
   PRInt64 threshold = GetNow() - RECENT_EVENT_THRESHOLD;
   hashTable->Enumerate(ExpireNonrecentEventsCallback,
                        reinterpret_cast<void*>(&threshold));
 }
 
 
-// nsNavHistory::GetRedirectFor
-//
-//    Given a destination URI, this finds a recent redirect that resulted in
-//    this URI. If it finds one, it will put the redirect source info into
-//    the out params and return true. If there is no matching redirect, it will
-//    return false.
-//
-//    @param aDestination The destination URI spec of the redirect to look for.
-//    @param aSource      Will be filled with the redirect source URI when a
-//                        redirect is found.
-//    @param aTime        Will be filled with the time the redirect happened
-//                         when a redirect is found.
-//    @param aRedirectType Will be filled with the redirect type when a redirect
-//                         is found. Will be either
-//                         TRANSITION_REDIRECT_PERMANENT or
-//                         TRANSITION_REDIRECT_TEMPORARY
-//    @returns True if the redirect is found.
-//
-//    HOW REDIRECT TRACKING WORKS
-//    ---------------------------
-//    When we get an AddDocumentRedirect message, we store the redirect in
-//    our mRecentRedirects which maps the destination URI to a source,time pair.
-//    When we get a new URI, we see if there were any redirects to this page
-//    in the hash table. If found, we know that the page came through the given
-//    redirect and add it.
-//
-//    Example: Page S redirects throught R1, then R2, to give page D. Page S
-//    will have been already added to history.
-//    - AddDocumentRedirect(R1, R2)
-//    - AddDocumentRedirect(R2, D)
-//    - AddURI(uri=D, referrer=S)
-//
-//    When we get the AddURI(D), we see the hash table has a value for D from R2.
-//    We have to recursively check that source since there could be more than
-//    one redirect, as in this case. Here we see there was a redirect to R2 from
-//    R1. The referrer for D is S, so we know S->R1->R2->D.
-//
-//    Alternatively, the user could have typed or followed a bookmark from S.
-//    In this case, with two redirects we'll get:
-//    - MarkPageAsTyped(S)
-//    - AddDocumentRedirect(S, R)
-//    - AddDocumentRedirect(R, D)
-//    - AddURI(uri=D, referrer=null)
-//    We need to be careful to add a visit to S in this case with an incoming
-//    transition of typed and an outgoing transition of redirect.
-//
-//    Note that this can get confused in some cases where you have a page
-//    open in more than one window loading at the same time. This should be rare,
-//    however, and should not affect much.
-
-PRBool
-nsNavHistory::GetRedirectFor(const nsACString& aDestination,
-                             nsACString& aSource,
-                             PRTime* aTime,
-                             PRUint32* aRedirectType)
-{
-  RedirectInfo info;
-  if (mRecentRedirects.Get(aDestination, &info)) {
-    // Consume the redirect entry, it's no longer useful.
-    mRecentRedirects.Remove(aDestination);
-    if (info.mTimeCreated < GetNow() - RECENT_EVENT_THRESHOLD)
-      return PR_FALSE; // too long ago, probably invalid
-    aSource = info.mSourceURI;
-    *aTime = info.mTimeCreated;
-    *aRedirectType = info.mType;
-    return PR_TRUE;
-  }
-  return PR_FALSE;
-}
-
-
 // nsNavHistory::RowToResult
 //
 //    Here, we just have a generic row. It could be a query, URL, visit,
 //    or full visit.
 
 nsresult
 nsNavHistory::RowToResult(mozIStorageValueArray* aRow,
                           nsNavHistoryQueryOptions* aOptions,
--- a/toolkit/components/places/nsNavHistory.h
+++ b/toolkit/components/places/nsNavHistory.h
@@ -42,17 +42,16 @@
 #ifndef nsNavHistory_h_
 #define nsNavHistory_h_
 
 #include "nsINavHistoryService.h"
 #include "nsPIPlacesDatabase.h"
 #include "nsPIPlacesHistoryListenersNotifier.h"
 #include "nsIBrowserHistory.h"
 #include "nsIGlobalHistory.h"
-#include "nsIGlobalHistory3.h"
 #include "nsIDownloadHistory.h"
 
 #include "nsIPrefService.h"
 #include "nsIPrefBranch2.h"
 #include "nsIObserverService.h"
 #include "nsICollation.h"
 #include "nsIStringBundle.h"
 #include "nsITimer.h"
@@ -96,19 +95,16 @@
 #ifdef MOZ_XUL
 // Fired after autocomplete feedback has been updated.
 #define TOPIC_AUTOCOMPLETE_FEEDBACK_UPDATED "places-autocomplete-feedback-updated"
 #endif
 
 // Fired after frecency has been updated.
 #define TOPIC_FRECENCY_UPDATED "places-frecency-updated"
 
-// Fired after frecency has been updated.
-#define TOPIC_FRECENCY_UPDATED "places-frecency-updated"
-
 // Fired when Places is shutting down.  Any code should stop accessing Places
 // APIs after this notification.  If you need to listen for Places shutdown
 // you should only use this notification, next ones are intended only for
 // internal Places use.
 #define TOPIC_PLACES_SHUTDOWN "places-shutdown"
 // For Internal use only.  Fired when connection is about to be closed, only
 // cleanup tasks should run at this stage, nothing should be added to the
 // database, nor APIs should be called.
@@ -166,33 +162,31 @@ class PlacesSQLQueryBuilder;
 class nsIAutoCompleteController;
 
 // nsNavHistory
 
 class nsNavHistory : public nsSupportsWeakReference
                    , public nsINavHistoryService
                    , public nsIObserver
                    , public nsIBrowserHistory
-                   , public nsIGlobalHistory3
                    , public nsIDownloadHistory
                    , public nsICharsetResolver
                    , public nsPIPlacesDatabase
                    , public nsPIPlacesHistoryListenersNotifier
                    , public mozIStorageVacuumParticipant
 {
   friend class PlacesSQLQueryBuilder;
 
 public:
   nsNavHistory();
 
   NS_DECL_ISUPPORTS
 
   NS_DECL_NSINAVHISTORYSERVICE
   NS_DECL_NSIGLOBALHISTORY2
-  NS_DECL_NSIGLOBALHISTORY3
   NS_DECL_NSIDOWNLOADHISTORY
   NS_DECL_NSIBROWSERHISTORY
   NS_DECL_NSIOBSERVER
   NS_DECL_NSPIPLACESDATABASE
   NS_DECL_NSPIPLACESHISTORYLISTENERSNOTIFIER
   NS_DECL_MOZISTORAGEVACUUMPARTICIPANT
 
 
@@ -845,29 +839,16 @@ protected:
   };
 
   nsTHashtable<VisitHashKey> mEmbedVisits;
 
   PRBool CheckIsRecentEvent(RecentEventHash* hashTable,
                             const nsACString& url);
   void ExpireNonrecentEvents(RecentEventHash* hashTable);
 
-  // redirect tracking. See GetRedirectFor for a description of how this works.
-  struct RedirectInfo {
-    nsCString mSourceURI;
-    PRTime mTimeCreated;
-    PRUint32 mType; // one of TRANSITION_REDIRECT_[TEMPORARY,PERMANENT]
-  };
-  typedef nsDataHashtable<nsCStringHashKey, RedirectInfo> RedirectHash;
-  RedirectHash mRecentRedirects;
-  static PLDHashOperator ExpireNonrecentRedirects(
-      nsCStringHashKey::KeyType aKey, RedirectInfo& aData, void* aUserArg);
-  PRBool GetRedirectFor(const nsACString& aDestination, nsACString& aSource,
-                        PRTime* aTime, PRUint32* aRedirectType);
-
   // Sessions tracking.
   PRInt64 mLastSessionID;
 
 #ifdef MOZ_XUL
   nsresult AutoCompleteFeedback(PRInt32 aIndex,
                                 nsIAutoCompleteController *aController);
 #endif
 
--- a/toolkit/components/places/tests/mochitest/bug_411966/redirect.js
+++ b/toolkit/components/places/tests/mochitest/bug_411966/redirect.js
@@ -48,18 +48,16 @@ ok(Cc != null, "Access Cc");
 var histsvc = Cc["@mozilla.org/browser/nav-history-service;1"].
               getService(Ci.nsINavHistoryService);
 ok(histsvc != null, "Could not get History Service");
 var bhist = histsvc.QueryInterface(Ci.nsIBrowserHistory);
 ok(bhist != null, "Could not get Browser History Service");
 var ghist = Cc["@mozilla.org/browser/global-history;2"].
             getService(Ci.nsIGlobalHistory2);
 ok(ghist != null, "Could not get Global History Service");
-var ghist3 = ghist.QueryInterface(Ci.nsIGlobalHistory3);
-ok(ghist3 != null, "Could not get Global History Service");
 var ios = Cc["@mozilla.org/network/io-service;1"].
           getService(Components.interfaces.nsIIOService);
 ok(ios != null, "Could not get IO Service");
 var storage = Cc["@mozilla.org/storage/service;1"].
               getService(Ci.mozIStorageService);
 ok(storage != null, "Could not get Storage Service");
 
 // Get database connection.
@@ -108,17 +106,16 @@ StreamListener.prototype = {
       throw("Could not get page.");
 
     this.mChannel = null;
   },
 
   // nsIChannelEventSink
   asyncOnChannelRedirect: function (aOldChannel, aNewChannel, aFlags, callback) {
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
-    ghist3.addDocumentRedirect(aOldChannel, aNewChannel, aFlags, true);
     // If redirecting, store the new channel
     this.mChannel = aNewChannel;
     callback.onRedirectVerifyCallback(Components.results.NS_OK);
   },
 
   // nsIInterfaceRequestor
   getInterface: function (aIID) {
     netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
--- a/toolkit/components/places/tests/network/test_history_redirects.js
+++ b/toolkit/components/places/tests/network/test_history_redirects.js
@@ -3,17 +3,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /* Tests history redirects handling */
 
 let hs = Cc["@mozilla.org/browser/nav-history-service;1"].
          getService(Ci.nsINavHistoryService);
 let bh = hs.QueryInterface(Ci.nsIBrowserHistory);
-let ghist3 = hs.QueryInterface(Ci.nsIGlobalHistory3);
 
 const PERMA_REDIR_PATH = "/permaredir";
 const TEMP_REDIR_PATH = "/tempredir";
 const FOUND_PATH = "/found";
 
 const HTTPSVR = new nsHttpServer();
 const PORT = 4444;
 HTTPSVR.registerPathHandler(PERMA_REDIR_PATH, permaRedirHandler);
@@ -176,23 +175,18 @@ ChannelListener.prototype = {
     do_log_info("onStopRequest");
     this._got_onstoprequest++;
     let success = Components.isSuccessCode(status);
     do_check_true(success);
     do_check_true(this._got_onstartrequest);
     do_check_true(this._got_onchannelredirect);
     do_check_true(this._buffer.length > 0);
 
-    // The referrer is wrong since it's the first element in the redirects
-    // chain, but this is good, since it will test a special path.
-    ghist3.addURI(uri(FOUND_URL), false, true, uri(PERMA_REDIR_URL));
-
     continue_test();
   },
 
   // nsIChannelEventSink
   asyncOnChannelRedirect: function (aOldChannel, aNewChannel, aFlags, callback) {
     do_log_info("onChannelRedirect");
     this._got_onchannelredirect = true;
-    ghist3.addDocumentRedirect(aOldChannel, aNewChannel, aFlags, true);
     callback.onRedirectVerifyCallback(Components.results.NS_OK);
   },
 };
--- a/toolkit/content/aboutSupport.js
+++ b/toolkit/content/aboutSupport.js
@@ -61,17 +61,16 @@ const PREFS_WHITELIST = [
   "browser.zoom.",
   "dom.",
   "extensions.checkCompatibility",
   "extensions.lastAppVersion",
   "font.",
   "general.useragent.",
   "gfx.",
   "html5.",
-  "mozilla.widget.render-mode",
   "layers.",
   "javascript.",
   "keyword.",
   "layout.css.dpi",
   "network.",
   "places.",
   "plugin.",
   "plugins.",
--- a/widget/public/nsILookAndFeel.h
+++ b/widget/public/nsILookAndFeel.h
@@ -245,16 +245,26 @@ public:
      * being used.
      *
      * The value of this metric is not used on other platforms. These platforms
      * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
      */
     eMetric_MacGraphiteTheme,
 
     /*
+     * A Boolean value to determine whether the Mac OS X Lion-specific theming
+     * should be used.
+     *
+     * The value of this metric is not used on non-Mac platforms. These
+     * platforms should return NS_ERROR_NOT_IMPLEMENTED when queried for this
+     * metric.
+     */
+    eMetric_MacLionTheme,
+
+    /*
      * A Boolean value to determine whether Mameo is using the new Fremantle
      * theme.
      *
      * The value of this metric is not used on other platforms. These platforms
      * should return NS_ERROR_NOT_IMPLEMENTED when queried for this metric.
      */
     eMetric_MaemoClassic,
 
--- a/widget/src/cocoa/nsClipboard.mm
+++ b/widget/src/cocoa/nsClipboard.mm
@@ -423,18 +423,23 @@ nsClipboard::PasteboardDictFromTransfera
     NSString *pboardType = nil;
 
     if (nsClipboard::IsStringType(flavorStr, &pboardType)) {
       void* data = nsnull;
       PRUint32 dataSize = 0;
       nsCOMPtr<nsISupports> genericDataWrapper;
       rv = aTransferable->GetTransferData(flavorStr, getter_AddRefs(genericDataWrapper), &dataSize);
       nsPrimitiveHelpers::CreateDataFromPrimitive(flavorStr, genericDataWrapper, &data, dataSize);
+
+      NSString* nativeString;
+      if (data)
+        nativeString = [NSString stringWithCharacters:(const unichar*)data length:(dataSize / sizeof(PRUnichar))];
+      else
+        nativeString = [NSString string];
       
-      NSString* nativeString = [NSString stringWithCharacters:(const unichar*)data length:(dataSize / sizeof(PRUnichar))];
       // be nice to Carbon apps, normalize the receiver's contents using Form C.
       nativeString = [nativeString precomposedStringWithCanonicalMapping];
 
       [pasteboardOutputDict setObject:nativeString forKey:pboardType];
       
       nsMemory::Free(data);
     }
     else if (flavorStr.EqualsLiteral(kPNGImageMime) || flavorStr.EqualsLiteral(kJPEGImageMime) ||
--- a/widget/src/cocoa/nsLookAndFeel.mm
+++ b/widget/src/cocoa/nsLookAndFeel.mm
@@ -384,16 +384,19 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
     case eMetric_MaemoClassic:
     case eMetric_WindowsThemeIdentifier:
       aMetric = 0;
       res = NS_ERROR_NOT_IMPLEMENTED;
       break;
     case eMetric_MacGraphiteTheme:
       aMetric = [NSColor currentControlTint] == NSGraphiteControlTint;
       break;
+    case eMetric_MacLionTheme:
+      aMetric = nsToolkit::OnLionOrLater();
+      break;
     case eMetric_TabFocusModel:
     {
       // we should probably cache this
       CFPropertyListRef fullKeyboardAccessProperty;
       fullKeyboardAccessProperty = ::CFPreferencesCopyValue(CFSTR("AppleKeyboardUIMode"),
                                                             kCFPreferencesAnyApplication,
                                                             kCFPreferencesCurrentUser,
                                                             kCFPreferencesAnyHost);
--- a/widget/src/gtk2/nsLookAndFeel.cpp
+++ b/widget/src/gtk2/nsLookAndFeel.cpp
@@ -544,16 +544,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
             }
         }
 #else
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
 #endif
         break;
     case eMetric_MacGraphiteTheme:
+    case eMetric_MacLionTheme:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_IMERawInputUnderlineStyle:
     case eMetric_IMEConvertedTextUnderlineStyle:
         aMetric = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
         break;
     case eMetric_IMESelectedRawTextUnderlineStyle:
--- a/widget/src/os2/nsLookAndFeel.cpp
+++ b/widget/src/os2/nsLookAndFeel.cpp
@@ -326,16 +326,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
     case eMetric_WindowsClassic:
     case eMetric_WindowsDefaultTheme:
     case eMetric_TouchEnabled:
     case eMetric_WindowsThemeIdentifier:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_MacGraphiteTheme:
+    case eMetric_MacLionTheme:
     case eMetric_MaemoClassic:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_IMERawInputUnderlineStyle:
     case eMetric_IMEConvertedTextUnderlineStyle:
         aMetric = NS_STYLE_TEXT_DECORATION_STYLE_SOLID;
         break;
--- a/widget/src/windows/nsLookAndFeel.cpp
+++ b/widget/src/windows/nsLookAndFeel.cpp
@@ -414,16 +414,17 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(c
         break;
     case eMetric_WindowsDefaultTheme:
         aMetric = nsUXThemeData::IsDefaultWindowTheme();
         break;
     case eMetric_WindowsThemeIdentifier:
         aMetric = nsUXThemeData::GetNativeThemeId();
         break;
     case eMetric_MacGraphiteTheme:
+    case eMetric_MacLionTheme:
     case eMetric_MaemoClassic:
         aMetric = 0;
         res = NS_ERROR_NOT_IMPLEMENTED;
         break;
     case eMetric_DWMCompositor:
         aMetric = nsUXThemeData::CheckForCompositor();
         break;
     case eMetric_AlertNotificationOrigin:
--- a/widget/tests/Makefile.in
+++ b/widget/tests/Makefile.in
@@ -105,16 +105,17 @@ ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
                test_platform_colors.xul \
                test_standalone_native_menu.xul \
                standalone_native_menu_window.xul \
                test_bug586713.xul \
                bug586713_window.xul \
                test_key_event_counts.xul \
                test_bug596600.xul \
                window_bug596600.xul \
+               test_bug673301.xul \
                $(NULL)
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 _CHROME_FILES  += taskbar_previews.xul \
 		window_state_windows.xul \
 		taskbar_progress.xul \
 		test_chrome_context_menus_win.xul \
new file mode 100644
--- /dev/null
+++ b/widget/tests/test_bug673301.xul
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
+                 type="text/css"?>
+
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+<script type="application/javascript" src="chrome://mochikit/content/MochiKit/packed.js"/>
+<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
+
+<body  xmlns="http://www.w3.org/1999/xhtml">
+<p id="display"></p>
+<div id="content" style="display: none"/>
+</body>
+
+<script type="application/javascript">
+var clipboard = Components.classes["@mozilla.org/widget/clipboard;1"]
+                          .getService(Components.interfaces.nsIClipboard);
+
+var transferable = Components.classes['@mozilla.org/widget/transferable;1']
+                             .createInstance(Components.interfaces.nsITransferable);
+
+transferable.addDataFlavor("text/unicode");
+transferable.setTransferData("text/unicode", document, 4);
+
+clipboard.setData(transferable, null, Components.interfaces.nsIClipboard.kGlobalClipboard);
+
+SimpleTest.ok(true, "Didn't crash setting non-text data for text/unicode type");
+</script>
+</window>
--- a/xpcom/base/FunctionTimer.h
+++ b/xpcom/base/FunctionTimer.h
@@ -128,32 +128,32 @@
 #define NS_TIME_FUNCTION_ELAPSED (0)
 #define NS_TIME_FUNCTION_ELAPSED_SINCE_MARK (0)
 #define NS_TIME_FUNCTION_LATEST (mozilla::TimeDuration(0))
 
 #endif
 
 namespace mozilla {
 
-class NS_COM FunctionTimerLog
+class FunctionTimerLog
 {
 public:
     FunctionTimerLog(const char *fname);
     ~FunctionTimerLog();
 
     void LogString(const char *str);
 
     TimeDuration LatestSinceStartup() const;
 
 private:
     void *mFile;
     TimeStamp mLatest;
 };
 
-class NS_COM FunctionTimer
+class FunctionTimer
 {
     static nsAutoPtr<FunctionTimerLog> sLog;
     static char *sBuf1;
     static char *sBuf2;
     static int sBufSize;
     static unsigned sDepth;
 
     enum { BUF_LOG_LENGTH = 1024 };
--- a/xpcom/base/nsCycleCollector.h
+++ b/xpcom/base/nsCycleCollector.h
@@ -59,18 +59,18 @@ struct nsCycleCollectionLanguageRuntime
     virtual nsCycleCollectionParticipant *ToParticipant(void *p) = 0;
 #ifdef DEBUG_CC
     virtual void PrintAllReferencesTo(void *p) = 0;
 #endif
 };
 
 nsresult nsCycleCollector_startup();
 // Returns the number of collected nodes.
-NS_COM PRUint32 nsCycleCollector_collect(nsICycleCollectorListener *aListener);
-NS_COM PRUint32 nsCycleCollector_suspectedCount();
+PRUint32 nsCycleCollector_collect(nsICycleCollectorListener *aListener);
+PRUint32 nsCycleCollector_suspectedCount();
 void nsCycleCollector_shutdownThreads();
 void nsCycleCollector_shutdown();
 
 // The JS runtime is special, it needs to call cycle collection during its GC.
 // If the JS runtime is registered nsCycleCollector_collect will call
 // nsCycleCollectionJSRuntime::Collect which will call
 // nsCycleCollector_doCollect, else nsCycleCollector_collect will call
 // nsCycleCollector_doCollect directly.
@@ -83,25 +83,25 @@ struct nsCycleCollectionJSRuntime : publ
 
     /**
      * Runs the JavaScript GC.
      */
     virtual void Collect() = 0;
 };
 
 #ifdef DEBUG
-NS_COM void nsCycleCollector_DEBUG_shouldBeFreed(nsISupports *n);
-NS_COM void nsCycleCollector_DEBUG_wasFreed(nsISupports *n);
+void nsCycleCollector_DEBUG_shouldBeFreed(nsISupports *n);
+void nsCycleCollector_DEBUG_wasFreed(nsISupports *n);
 #endif
 
 // Helpers for interacting with language-identified scripts
 
-NS_COM void nsCycleCollector_registerRuntime(PRUint32 langID, nsCycleCollectionLanguageRuntime *rt);
-NS_COM nsCycleCollectionLanguageRuntime * nsCycleCollector_getRuntime(PRUint32 langID);
-NS_COM void nsCycleCollector_forgetRuntime(PRUint32 langID);
+void nsCycleCollector_registerRuntime(PRUint32 langID, nsCycleCollectionLanguageRuntime *rt);
+nsCycleCollectionLanguageRuntime * nsCycleCollector_getRuntime(PRUint32 langID);
+void nsCycleCollector_forgetRuntime(PRUint32 langID);
 
 #define NS_CYCLE_COLLECTOR_LOGGER_CID \
 { 0x58be81b4, 0x39d2, 0x437c, \
 { 0x94, 0xea, 0xae, 0xde, 0x2c, 0x62, 0x08, 0xd3 } }
 
 extern nsresult
 nsCycleCollectorLoggerConstructor(nsISupports* outer,
                                   const nsIID& aIID,
--- a/xpcom/base/nsDebugImpl.cpp
+++ b/xpcom/base/nsDebugImpl.cpp
@@ -528,17 +528,17 @@ nsDebugImpl::Create(nsISupports* outer, 
   NS_ENSURE_NO_AGGREGATION(outer);
 
   return const_cast<nsDebugImpl*>(&kImpl)->
     QueryInterface(aIID, aInstancePtr);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-NS_COM nsresult
+nsresult
 NS_ErrorAccordingToNSPR()
 {
     PRErrorCode err = PR_GetError();
     switch (err) {
       case PR_OUT_OF_MEMORY_ERROR:              return NS_ERROR_OUT_OF_MEMORY;
       case PR_WOULD_BLOCK_ERROR:                return NS_BASE_STREAM_WOULD_BLOCK;
       case PR_FILE_NOT_FOUND_ERROR:             return NS_ERROR_FILE_NOT_FOUND;
       case PR_READ_ONLY_FILESYSTEM_ERROR:       return NS_ERROR_FILE_READ_ONLY;
@@ -554,16 +554,16 @@ NS_ErrorAccordingToNSPR()
       case PR_NO_ACCESS_RIGHTS_ERROR:           return NS_ERROR_FILE_ACCESS_DENIED;
       default:                                  return NS_ERROR_FAILURE;
     }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
 #ifdef XP_WIN
-NS_COM PRBool sXPCOMHasLoadedNewDLLs = PR_FALSE;
+PRBool sXPCOMHasLoadedNewDLLs = PR_FALSE;
 
 NS_EXPORT void
 NS_SetHasLoadedNewDLLs()
 {
   sXPCOMHasLoadedNewDLLs = PR_TRUE;
 }
 #endif
--- a/xpcom/base/nsError.h
+++ b/xpcom/base/nsError.h
@@ -322,23 +322,23 @@ inline int NS_SUCCEEDED(nsresult _nsresu
  /*
   * This will return the nsresult corresponding to the most recent NSPR failure
   * returned by PR_GetError.
   *
   ***********************************************************************
   *      Do not depend on this function. It will be going away!
   ***********************************************************************
   */
-extern NS_COM nsresult
+extern nsresult
 NS_ErrorAccordingToNSPR();
 
 
 #ifdef _MSC_VER
 #pragma warning(disable: 4251) /* 'nsCOMPtr<class nsIInputStream>' needs to have dll-interface to be used by clients of class 'nsInputStream' */
 #pragma warning(disable: 4275) /* non dll-interface class 'nsISupports' used as base for dll-interface class 'nsIRDFNode' */
 #endif
 
 #ifdef XP_WIN
-extern NS_COM PRBool sXPCOMHasLoadedNewDLLs;
+extern PRBool sXPCOMHasLoadedNewDLLs;
 NS_EXPORT void NS_SetHasLoadedNewDLLs();
 #endif
 
 #endif
--- a/xpcom/base/nsIMemoryReporter.idl
+++ b/xpcom/base/nsIMemoryReporter.idl
@@ -287,15 +287,15 @@ interface nsIMemoryReporterManager : nsI
 
 #define NS_MEMORY_REPORTER_IMPLEMENT(_c, _p, _k, _u, _a, _d) \
         NS_MEMORY_REPORTER_IMPLEMENT_HELPER(_c, _p, _k, _u, _a, _d, _)
 #define NS_THREADSAFE_MEMORY_REPORTER_IMPLEMENT(_c, _p, _k, _u, _a, _d) \
         NS_MEMORY_REPORTER_IMPLEMENT_HELPER(_c, _p, _k, _u, _a, _d, _THREADSAFE_)
 
 #define NS_MEMORY_REPORTER_NAME(_classname)  MemoryReporter_##_classname
 
-NS_COM nsresult NS_RegisterMemoryReporter (nsIMemoryReporter *reporter);
-NS_COM nsresult NS_RegisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter);
+nsresult NS_RegisterMemoryReporter (nsIMemoryReporter *reporter);
+nsresult NS_RegisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter);
 
-NS_COM nsresult NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter);
-NS_COM nsresult NS_UnregisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter);
+nsresult NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter);
+nsresult NS_UnregisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter);
 
 %}
--- a/xpcom/base/nsInterfaceRequestorAgg.h
+++ b/xpcom/base/nsInterfaceRequestorAgg.h
@@ -41,14 +41,14 @@
 
 /**
  * This function returns an instance of nsIInterfaceRequestor that aggregates
  * two nsIInterfaceRequestor instances.  Its GetInterface method queries
  * aFirst for the requested interface and will query aSecond only if aFirst
  * failed to supply the requested interface.  Both aFirst and aSecond may
  * be null.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_NewInterfaceRequestorAggregation(nsIInterfaceRequestor  *aFirst,
                                     nsIInterfaceRequestor  *aSecond,
                                     nsIInterfaceRequestor **aResult);
 
 #endif // !defined( nsInterfaceRequestorAgg_h__ )
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -741,44 +741,44 @@ NS_IMETHODIMP nsMemoryReporter::GetAmoun
 }
 
 NS_IMETHODIMP nsMemoryReporter::GetDescription(nsACString &aDescription)
 {
     aDescription.Assign(mDesc);
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_RegisterMemoryReporter (nsIMemoryReporter *reporter)
 {
     nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
     if (mgr == nsnull)
         return NS_ERROR_FAILURE;
     return mgr->RegisterReporter(reporter);
 }
 
-NS_COM nsresult
+nsresult
 NS_RegisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter)
 {
     nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
     if (mgr == nsnull)
         return NS_ERROR_FAILURE;
     return mgr->RegisterMultiReporter(reporter);
 }
 
-NS_COM nsresult
+nsresult
 NS_UnregisterMemoryReporter (nsIMemoryReporter *reporter)
 {
     nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
     if (mgr == nsnull)
         return NS_ERROR_FAILURE;
     return mgr->UnregisterReporter(reporter);
 }
 
-NS_COM nsresult
+nsresult
 NS_UnregisterMemoryMultiReporter (nsIMemoryMultiReporter *reporter)
 {
     nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
     if (mgr == nsnull)
         return NS_ERROR_FAILURE;
     return mgr->UnregisterMultiReporter(reporter);
 }
 
--- a/xpcom/base/nsTraceRefcntImpl.cpp
+++ b/xpcom/base/nsTraceRefcntImpl.cpp
@@ -68,17 +68,17 @@
 #include "mozilla/BlockingResourceBase.h"
 
 #ifdef HAVE_DLOPEN
 #include <dlfcn.h>
 #endif
 
 ////////////////////////////////////////////////////////////////////////////////
 
-NS_COM void
+void
 NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues,
                  double *meanResult, double *stdDevResult)
 {
   double mean = 0.0, var = 0.0, stdDev = 0.0;
   if (n > 0.0 && sumOfValues >= 0) {
     mean = sumOfValues / n;
     double temp = (n * sumOfSquaredValues) - (sumOfValues * sumOfValues);
     if (temp < 0.0 || n <= 1)
@@ -502,17 +502,17 @@ class nsDefaultComparator <BloatEntry*, 
     }
     PRBool LessThan(BloatEntry* const& aA, BloatEntry* const& aB) const {
       return PL_strcmp(aA->GetClassName(), aB->GetClassName()) < 0;
     }
 };
 
 #endif /* NS_IMPL_REFCNT_LOGGING */
 
-NS_COM nsresult
+nsresult
 nsTraceRefcntImpl::DumpStatistics(StatisticsType type, FILE* out)
 {
 #ifdef NS_IMPL_REFCNT_LOGGING
   if (gBloatLog == nsnull || gBloatView == nsnull) {
     return NS_ERROR_FAILURE;
   }
   if (out == nsnull) {
     out = gBloatLog;
@@ -565,17 +565,17 @@ nsTraceRefcntImpl::DumpStatistics(Statis
 
   gLogging = wasLogging;
   UNLOCK_TRACELOG();
 #endif
 
   return NS_OK;
 }
 
-NS_COM void
+void
 nsTraceRefcntImpl::ResetStatistics()
 {
 #ifdef NS_IMPL_REFCNT_LOGGING
   LOCK_TRACELOG();
   if (gBloatView) {
     PL_HashTableDestroy(gBloatView);
     gBloatView = nsnull;
   }
@@ -874,32 +874,32 @@ static void PrintStackFrame(void *aPC, v
 
   NS_DescribeCodeAddress(aPC, &details);
   NS_FormatCodeAddressDetails(aPC, &details, buf, sizeof(buf));
   fputs(buf, stream);
 }
 
 }
 
-NS_COM void
+void
 nsTraceRefcntImpl::WalkTheStack(FILE* aStream)
 {
   NS_StackWalk(PrintStackFrame, 2, aStream);
 }
 
 //----------------------------------------------------------------------
 
 // This thing is exported by libstdc++
 // Yes, this is a gcc only hack
 #if defined(MOZ_DEMANGLE_SYMBOLS)
 #include <cxxabi.h>
 #include <stdlib.h> // for free()
 #endif // MOZ_DEMANGLE_SYMBOLS
 
-NS_COM void
+void
 nsTraceRefcntImpl::DemangleSymbol(const char * aSymbol,
                               char * aBuffer,
                               int aBufLen)
 {
   NS_ASSERTION(nsnull != aSymbol,"null symbol");
   NS_ASSERTION(nsnull != aBuffer,"null buffer");
   NS_ASSERTION(aBufLen >= 32 ,"pulled 32 out of you know where");
 
@@ -1255,22 +1255,22 @@ NS_LogCOMPtrRelease(void* aCOMPtr, nsISu
       nsTraceRefcntImpl::WalkTheStack(gCOMPtrLog);
     }
 
     UNLOCK_TRACELOG();
   }
 #endif
 }
 
-NS_COM void
+void
 nsTraceRefcntImpl::Startup()
 {
 }
 
-NS_COM void
+void
 nsTraceRefcntImpl::Shutdown()
 {
 #ifdef NS_IMPL_REFCNT_LOGGING
 
   if (gBloatView) {
     PL_HashTableDestroy(gBloatView);
     gBloatView = nsnull;
   }
@@ -1304,17 +1304,17 @@ nsTraceRefcntImpl::Shutdown()
   }
   if (gCOMPtrLog) {
     fclose(gCOMPtrLog);
     gCOMPtrLog = nsnull;
   }
 #endif
 }
 
-NS_COM void
+void
 nsTraceRefcntImpl::SetActivityIsLegal(PRBool aLegal)
 {
 #ifdef NS_IMPL_REFCNT_LOGGING
   if (gActivityTLS == BAD_TLS_INDEX)
     PR_NewThreadPrivateIndex(&gActivityTLS, nsnull);
 
   PR_SetThreadPrivate(gActivityTLS, NS_INT32_TO_PTR(!aLegal));
 #endif
--- a/xpcom/base/nsTraceRefcntImpl.h
+++ b/xpcom/base/nsTraceRefcntImpl.h
@@ -43,40 +43,40 @@
 
 class nsTraceRefcntImpl : public nsITraceRefcnt
 {
 public:
   nsTraceRefcntImpl() {}
   NS_DECL_ISUPPORTS
   NS_DECL_NSITRACEREFCNT
 
-  static NS_COM void Startup();
-  static NS_COM void Shutdown();
+  static void Startup();
+  static void Shutdown();
 
   enum StatisticsType {
     ALL_STATS,
     NEW_STATS
   };
 
-  static NS_COM nsresult DumpStatistics(StatisticsType type = ALL_STATS,
+  static nsresult DumpStatistics(StatisticsType type = ALL_STATS,
                                         FILE* out = 0);
 
-  static NS_COM void ResetStatistics(void);
+  static void ResetStatistics(void);
 
-  static NS_COM void DemangleSymbol(const char * aSymbol,
+  static void DemangleSymbol(const char * aSymbol,
                                     char * aBuffer,
                                     int aBufLen);
 
-  static NS_COM void WalkTheStack(FILE* aStream);
+  static void WalkTheStack(FILE* aStream);
   /**
    * Tell nsTraceRefcnt whether refcounting, allocation, and destruction
    * activity is legal.  This is used to trigger assertions for any such
    * activity that occurs because of static constructors or destructors.
    */
-  static NS_COM void SetActivityIsLegal(PRBool aLegal);
+  static void SetActivityIsLegal(PRBool aLegal);
 
   static NS_METHOD Create(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
 };
 
 #define NS_TRACE_REFCNT_CONTRACTID "@mozilla.org/xpcom/trace-refcnt;1"
 #define NS_TRACE_REFCNT_CLASSNAME  "nsTraceRefcnt Interface"
 #define NS_TRACE_REFCNT_CID                          \
 { /* e3e7511e-a395-4924-94b1-d527861cded4 */         \
@@ -84,14 +84,14 @@ public:
     0xa395,                                          \
     0x4924,                                          \
     {0x94, 0xb1, 0xd5, 0x27, 0x86, 0x1c, 0xde, 0xd4} \
 }                                                    \
 
 ////////////////////////////////////////////////////////////////////////////////
 // And now for that utility that you've all been asking for...
 
-extern "C" NS_COM void
+extern "C" void
 NS_MeanAndStdDev(double n, double sumOfValues, double sumOfSquaredValues,
                  double *meanResult, double *stdDevResult);
 
 ////////////////////////////////////////////////////////////////////////////////
 #endif
--- a/xpcom/base/nscore.h
+++ b/xpcom/base/nscore.h
@@ -29,16 +29,17 @@
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
+
 #ifndef nscore_h___
 #define nscore_h___
 
 /**
  * Make sure that we have the proper platform specific
  * c++ definitions needed by nscore.h
  */
 #ifndef _XPCOM_CONFIG_H_
@@ -290,20 +291,18 @@
 #ifdef _IMPL_NS_COM
 #define XPCOM_API(type) EXPORT_XPCOM_API(type)
 #elif defined(XPCOM_GLUE)
 #define XPCOM_API(type) GLUE_XPCOM_API(type)
 #else
 #define XPCOM_API(type) IMPORT_XPCOM_API(type)
 #endif
 
-#define NS_COM
-
 #ifdef MOZILLA_INTERNAL_API
-#  define NS_COM_GLUE NS_COM
+#  define NS_COM_GLUE
    /*
      The frozen string API has different definitions of nsAC?String
      classes than the internal API. On systems that explicitly declare
      dllexport symbols this is not a problem, but on ELF systems
      internal symbols can accidentally "shine through"; we rename the
      internal classes to avoid symbol conflicts.
    */
 #  define nsAString nsAString_internal
--- a/xpcom/build/Services.cpp
+++ b/xpcom/build/Services.cpp
@@ -59,17 +59,17 @@ using namespace mozilla::services;
 
 /*
  * Define a global variable and a getter for every service in ServiceList.
  * eg. gIOService and GetIOService()
  */
 #define MOZ_SERVICE(NAME, TYPE, CONTRACT_ID)                            \
   static TYPE* g##NAME = nsnull;                                        \
                                                                         \
-  NS_COM already_AddRefed<TYPE>                                         \
+  already_AddRefed<TYPE>                                         \
   mozilla::services::Get##NAME()                                        \
   {                                                                     \
     if (!g##NAME) {                                                     \
       nsCOMPtr<TYPE> os = do_GetService(CONTRACT_ID);                   \
       g##NAME = os.forget().get();                                      \
     }                                                                   \
     NS_IF_ADDREF(g##NAME);                                              \
     return g##NAME;                                                     \
--- a/xpcom/build/Services.h
+++ b/xpcom/build/Services.h
@@ -47,16 +47,16 @@
 
 #include "ServiceList.h"
 #undef MOZ_SERVICE
 #undef MOZ_USE_NAMESPACE
 
 namespace mozilla {
 namespace services {
 
-#define MOZ_SERVICE(NAME, TYPE, SERVICE_CID) NS_COM already_AddRefed<TYPE> Get##NAME();
+#define MOZ_SERVICE(NAME, TYPE, SERVICE_CID) already_AddRefed<TYPE> Get##NAME();
 #include "ServiceList.h"
 #undef MOZ_SERVICE
 
 } // namespace services
 } // namespace mozilla
 
 #endif
--- a/xpcom/components/nsCategoryManager.cpp
+++ b/xpcom/components/nsCategoryManager.cpp
@@ -737,17 +737,17 @@ nsCategoryManager::SuppressNotifications
  * CreateServicesFromCategory()
  *
  * Given a category, this convenience functions enumerates the category and 
  * creates a service of every CID or ContractID registered under the category.
  * If observerTopic is non null and the service implements nsIObserver,
  * this will attempt to notify the observer with the origin, observerTopic string
  * as parameter.
  */
-NS_COM void
+void
 NS_CreateServicesFromCategory(const char *category,
                               nsISupports *origin,
                               const char *observerTopic)
 {
   NS_TIME_FUNCTION_FMT("NS_CreateServicesFromCategory: %s (%s)",
                        category, observerTopic ? observerTopic : "(no topic)");
 
   nsresult rv;
--- a/xpcom/components/nsCategoryManagerUtils.h
+++ b/xpcom/components/nsCategoryManagerUtils.h
@@ -35,14 +35,14 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsCategoryManagerUtils_h__
 #define nsCategoryManagerUtils_h__
 
 #include "nsICategoryManager.h"
 
-NS_COM void
+void
 NS_CreateServicesFromCategory(const char *category,
                               nsISupports *origin,
                               const char *observerTopic);
 
 #endif
--- a/xpcom/components/nsComponentManager.cpp
+++ b/xpcom/components/nsComponentManager.cpp
@@ -41,21 +41,23 @@
  * Corporation, 2000
  *
  * Modifications to Mozilla code or documentation
  * identified per MPL Section 3.3
  *
  * Date             Modified by     Description of modification
  * 04/20/2000       IBM Corp.      Added PR_CALLBACK for Optlink use in OS2
  */
+
 #include <stdlib.h>
 #include "nscore.h"
 #include "nsISupports.h"
 #include "nspr.h"
 #include "nsCRT.h" // for atoll
+
 // Arena used by component manager for storing contractid string, dll
 // location strings and small objects
 // CAUTION: Arena align mask needs to be defined before including plarena.h
 //          currently from nsComponentManager.h
 #define PL_ARENA_CONST_ALIGN_MASK 7
 #define NS_CM_BLOCK_SIZE (1024 * 8)
 
 #include "nsCategoryManager.h"
@@ -102,17 +104,17 @@
 #include "mozilla/Omnijar.h"
 #include "nsJAR.h"
 static NS_DEFINE_CID(kZipReaderCID, NS_ZIPREADER_CID);
 
 #include "prlog.h"
 
 using namespace mozilla;
 
-NS_COM PRLogModuleInfo* nsComponentManagerLog = nsnull;
+PRLogModuleInfo* nsComponentManagerLog = nsnull;
 
 #if 0 || defined (DEBUG_timeless)
  #define SHOW_DENIED_ON_SHUTDOWN
  #define SHOW_CI_ON_EXISTING_SERVICE
 #endif
 
 // Bloated registry buffer size to improve startup performance -- needs to
 // be big enough to fit the entire file into memory or it'll thrash.
@@ -1988,38 +1990,38 @@ nsFactoryEntry::GetFactory()
     NS_ADDREF(mFactory);
     return mFactory.get();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // Static Access Functions
 ////////////////////////////////////////////////////////////////////////////////
 
-NS_COM nsresult
+nsresult
 NS_GetComponentManager(nsIComponentManager* *result)
 {
     if (!nsComponentManagerImpl::gComponentManager)
         return NS_ERROR_NOT_INITIALIZED;
 
     NS_ADDREF(*result = nsComponentManagerImpl::gComponentManager);
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_GetServiceManager(nsIServiceManager* *result)
 {
     if (!nsComponentManagerImpl::gComponentManager)
         return NS_ERROR_NOT_INITIALIZED;
 
     NS_ADDREF(*result = nsComponentManagerImpl::gComponentManager);
     return NS_OK;
 }
 
 
-NS_COM nsresult
+nsresult
 NS_GetComponentRegistrar(nsIComponentRegistrar* *result)
 {
     if (!nsComponentManagerImpl::gComponentManager)
         return NS_ERROR_NOT_INITIALIZED;
 
     NS_ADDREF(*result = nsComponentManagerImpl::gComponentManager);
     return NS_OK;
 }
--- a/xpcom/ds/TimeStamp.h
+++ b/xpcom/ds/TimeStamp.h
@@ -52,17 +52,17 @@ class TimeStamp;
  * Negative durations are allowed, meaning the end is before the start.
  * 
  * Internally the duration is stored as a PRInt64 in units of
  * PR_TicksPerSecond() when building with NSPR interval timers, or a
  * system-dependent unit when building with system clocks.  The
  * system-dependent unit must be constant, otherwise the semantics of
  * this class would be broken.
  */
-class NS_COM TimeDuration
+class TimeDuration
 {
 public:
   // The default duration is 0.
   TimeDuration() : mValue(0) {}
   // Allow construction using '0' as the initial value, for readability,
   // but no other numbers (so we don't have any implicit unit conversions).
   struct _SomethingVeryRandomHere;
   TimeDuration(_SomethingVeryRandomHere* aZero) : mValue(0) {
@@ -181,17 +181,17 @@ private:
  * meaningless like add two TimeStamps.
  *
  * Internally this is implemented as either a wrapper around
  *   - high-resolution, monotonic, system clocks if they exist on this
  *     platform
  *   - PRIntervalTime otherwise.  We detect wraparounds of
  *     PRIntervalTime and work around them.
  */
-class NS_COM TimeStamp
+class TimeStamp
 {
 public:
   /**
    * Initialize to the "null" moment
    */
   TimeStamp() : mValue(0) {}
   // Default copy-constructor and assignment are OK
 
--- a/xpcom/ds/nsAtomTable.cpp
+++ b/xpcom/ds/nsAtomTable.cpp
@@ -414,17 +414,17 @@ class CheckStaticAtomSizes
                       offsetof(nsStringBuffer, mRefCount)) &&
                      (offsetof(nsFakeStringBuffer<1>, mSize) ==
                       offsetof(nsStringBuffer, mStorageSize)) &&
                      (offsetof(nsFakeStringBuffer<1>, mStringData) ==
                       sizeof(nsStringBuffer)));
   }
 };
 
-NS_COM nsresult
+nsresult
 NS_RegisterStaticAtoms(const nsStaticAtom* aAtoms, PRUint32 aAtomCount)
 {
   // this does three things:
   // 1) wraps each static atom in a wrapper, if necessary
   // 2) initializes the address pointed to by each mBits slot
   // 3) puts the atom into the static atom table as well
   
   if (!gStaticAtomTable && !gStaticAtomTableSealed) {
@@ -485,23 +485,23 @@ NS_RegisterStaticAtoms(const nsStaticAto
       gStaticAtomTable->Put(str, atom);
     }
 #endif
 
   }
   return NS_OK;
 }
 
-NS_COM nsIAtom*
+nsIAtom*
 NS_NewAtom(const char* aUTF8String)
 {
   return NS_NewAtom(nsDependentCString(aUTF8String));
 }
 
-NS_COM nsIAtom*
+nsIAtom*
 NS_NewAtom(const nsACString& aUTF8String)
 {
   AtomTableEntry *he = GetAtomHashEntry(aUTF8String.Data(),
                                         aUTF8String.Length());
 
   if (he->mAtom) {
     nsIAtom* atom;
     NS_ADDREF(atom = he->mAtom);
@@ -516,23 +516,23 @@ NS_NewAtom(const nsACString& aUTF8String
   AtomImpl* atom = new AtomImpl(str);
 
   he->mAtom = atom;
   NS_ADDREF(atom);
 
   return atom;
 }
 
-NS_COM nsIAtom*
+nsIAtom*
 NS_NewAtom(const PRUnichar* aUTF16String)
 {
   return NS_NewAtom(nsDependentString(aUTF16String));
 }
 
-NS_COM nsIAtom*
+nsIAtom*
 NS_NewAtom(const nsAString& aUTF16String)
 {
   AtomTableEntry *he = GetAtomHashEntry(aUTF16String.Data(),
                                         aUTF16String.Length());
 
   if (he->mAtom) {
     nsIAtom* atom;
     NS_ADDREF(atom = he->mAtom);
@@ -542,17 +542,17 @@ NS_NewAtom(const nsAString& aUTF16String
 
   AtomImpl* atom = new AtomImpl(aUTF16String);
   he->mAtom = atom;
   NS_ADDREF(atom);
 
   return atom;
 }
 
-NS_COM nsIAtom*
+nsIAtom*
 NS_NewPermanentAtom(const nsAString& aUTF16String)
 {
   AtomTableEntry *he = GetAtomHashEntry(aUTF16String.Data(),
                                         aUTF16String.Length());
 
   AtomImpl* atom = he->mAtom;
   if (atom) {
     if (!atom->IsPermanent()) {
@@ -563,31 +563,31 @@ NS_NewPermanentAtom(const nsAString& aUT
     atom = new PermanentAtomImpl(aUTF16String);
     he->mAtom = atom;
   }
 
   // No need to addref since permanent atoms aren't refcounted anyway
   return atom;
 }
 
-NS_COM nsrefcnt
+nsrefcnt
 NS_GetNumberOfAtoms(void)
 {
   return gAtomTable.entryCount;
 }
 
-NS_COM nsIAtom*
+nsIAtom*
 NS_GetStaticAtom(const nsAString& aUTF16String)
 {
   NS_PRECONDITION(gStaticAtomTable, "Static atom table not created yet.");
   NS_PRECONDITION(gStaticAtomTableSealed, "Static atom table not sealed yet.");
   nsIAtom* atom;
   if (!gStaticAtomTable->Get(aUTF16String, &atom)) {
     atom = nsnull;
   }
   return atom;
 }
 
-NS_COM void
+void
 NS_SealStaticAtomTable()
 {
   gStaticAtomTableSealed = PR_TRUE;
 }
--- a/xpcom/ds/nsByteBuffer.cpp
+++ b/xpcom/ds/nsByteBuffer.cpp
@@ -146,17 +146,17 @@ ByteBufferImpl::Fill(nsresult* aErrorCod
   if (NS_SUCCEEDED(*aErrorCode)) {
     mLength += nb;
   }
   else
     nb = 0;
   return nb;
 }
 
-NS_COM nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult,
+nsresult NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult,
                                   nsISupports* aOuter,
                                   PRUint32 aBufferSize)
 {
   nsresult rv;
   nsIByteBuffer* buf;
   rv = ByteBufferImpl::Create(aOuter, NS_GET_IID(nsIByteBuffer), (void**)&buf);
   if (NS_FAILED(rv)) return rv;
     
--- a/xpcom/ds/nsCRT.h
+++ b/xpcom/ds/nsCRT.h
@@ -90,17 +90,17 @@ extern const PRUnichar kIsoLatin1ToUCS2[
     ::operator delete(ptr);                             \
   }
 
 // Freeing helper
 #define CRTFREEIF(x) if (x) { nsCRT::free(x); x = 0; }
 
 /// This is a wrapper class around all the C runtime functions. 
 
-class NS_COM nsCRT {
+class nsCRT {
 public:
   enum {
     LF='\n'   /* Line Feed */,
     VTAB='\v' /* Vertical Tab */,
     CR='\r'   /* Carriage Return */
   };
 
   /***
--- a/xpcom/ds/nsCheapSets.h
+++ b/xpcom/ds/nsCheapSets.h
@@ -39,17 +39,17 @@
 #define __nsCheapSets_h__
 
 #include "nsHashSets.h"
 
 /**
  * A string set that takes up minimal size when there are 0 or 1 strings in the
  * set.  Use for cases where sizes of 0 and 1 are even slightly common.
  */
-class NS_COM nsCheapStringSet {
+class nsCheapStringSet {
 public:
   nsCheapStringSet() : mValOrHash(nsnull)
   {
   }
   ~nsCheapStringSet();
 
   /**
    * Put a string into the set
@@ -114,17 +114,17 @@ private:
   void* mValOrHash;
 };
 
 
 /**
  * An integer set that takes up only 4 bytes when there are 0 or 1 integers
  * in the set.  Use for cases where sizes of 0 and 1 are even slightly common.
  */
-class NS_COM nsCheapInt32Set {
+class nsCheapInt32Set {
 public:
   nsCheapInt32Set() : mValOrHash(nsnull)
   {
   }
   ~nsCheapInt32Set();
 
   /**
    * Put an int into the set
--- a/xpcom/ds/nsDoubleHashtable.h
+++ b/xpcom/ds/nsDoubleHashtable.h
@@ -393,17 +393,17 @@ void CLASSNAME::Remove(const KEY_TYPE aK
  *
  * XXX It could be advisable (unless COW strings ever happens) to have a
  * PLDHashDependentStringEntry
  */
 
 //
 // String-key entry
 //
-class NS_COM PLDHashStringEntry : public PLDHashEntryHdr
+class PLDHashStringEntry : public PLDHashEntryHdr
 {
 public:
   PLDHashStringEntry(const void* aKey) :
     mKey(*static_cast<const nsAString*>(aKey)) { }
   ~PLDHashStringEntry() { }
 
   static PLDHashNumber HashKey(const void* key) {
     return HashString(*static_cast<const nsAString*>(key));
@@ -413,17 +413,17 @@ public:
   }
 
   const nsString mKey;
 };
 
 //
 // CString-key entry
 //
-class NS_COM PLDHashCStringEntry : public PLDHashEntryHdr
+class PLDHashCStringEntry : public PLDHashEntryHdr
 {
 public:
   PLDHashCStringEntry(const void* aKey) :
     mKey(*static_cast<const nsACString*>(aKey)) { }
   ~PLDHashCStringEntry() { }
 
   static PLDHashNumber HashKey(const void* key) {
     return HashString(*static_cast<const nsACString*>(key));
@@ -433,17 +433,17 @@ public:
   }
 
   const nsCString mKey;
 };
 
 //
 // Int-key entry
 //
-class NS_COM PLDHashInt32Entry : public PLDHashEntryHdr
+class PLDHashInt32Entry : public PLDHashEntryHdr
 {
 public:
   PLDHashInt32Entry(const void* aKey) :
     mKey(*(static_cast<const PRInt32*>(aKey))) { }
   ~PLDHashInt32Entry() { }
 
   static PLDHashNumber HashKey(const void* key) {
     return *static_cast<const PRInt32*>(key);
@@ -454,17 +454,17 @@ public:
 
   const PRInt32 mKey;
 };
 
 
 //
 // Void-key entry
 //
-class NS_COM PLDHashVoidEntry : public PLDHashEntryHdr
+class PLDHashVoidEntry : public PLDHashEntryHdr
 {
 public:
   PLDHashVoidEntry(const void* aKey) :
     mKey(*(const void**)aKey) { }
   ~PLDHashVoidEntry() { }
 
   static PLDHashNumber HashKey(const void* key) {
     return PLDHashNumber(NS_PTR_TO_INT32(*(const void**)key)) >> 2;
--- a/xpcom/ds/nsFixedSizeAllocator.h
+++ b/xpcom/ds/nsFixedSizeAllocator.h
@@ -129,17 +129,17 @@
 #define nsFixedSizeAllocator_h__
 
 #include "nscore.h"
 #include "nsError.h"
 #include "plarena.h"
 
 #define NS_SIZE_IN_HEAP(_size) (_size)
 
-class NS_COM nsFixedSizeAllocator
+class nsFixedSizeAllocator
 {
 protected:
     PLArenaPool mPool;
 
     struct Bucket;
     struct FreeEntry;
   
     friend struct Bucket;
--- a/xpcom/ds/nsHashPropertyBag.h
+++ b/xpcom/ds/nsHashPropertyBag.h
@@ -43,22 +43,17 @@
 #include "nsCOMPtr.h"
 #include "nsCOMArray.h"
 
 #include "nsIVariant.h"
 #include "nsIWritablePropertyBag.h"
 #include "nsIWritablePropertyBag2.h"
 #include "nsInterfaceHashtable.h"
 
-// Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration
-// controls member method visibility.
-#undef  IMETHOD_VISIBILITY
-#define IMETHOD_VISIBILITY
-
-class NS_COM nsHashPropertyBag : public nsIWritablePropertyBag
+class nsHashPropertyBag : public nsIWritablePropertyBag
                                , public nsIWritablePropertyBag2
 {
 public:
     nsHashPropertyBag() { }
     virtual ~nsHashPropertyBag() {}
 
     nsresult Init();
 
@@ -77,12 +72,12 @@ protected:
     nsInterfaceHashtable<nsStringHashKey, nsIVariant> mPropertyHash;
 };
 
 #undef  IMETHOD_VISIBILITY
 #define IMETHOD_VISIBILITY NS_VISIBILITY_HIDDEN
 
 // Note: NS_NewHashPropertyBag returns a HPB that
 // uses a non-thread-safe internal hash
-extern "C" NS_COM nsresult
+extern "C" nsresult
 NS_NewHashPropertyBag(nsIWritablePropertyBag* *_retval);
 
 #endif /* nsHashPropertyBag_h___ */
--- a/xpcom/ds/nsHashSets.h
+++ b/xpcom/ds/nsHashSets.h
@@ -88,17 +88,17 @@ public:                                 
     return GetEntry(aKey) ? PR_TRUE : PR_FALSE;                               \
   }                                                                           \
 };
 
 #define DHASH_SET(CLASSNAME,ENTRY_CLASS,KEY_TYPE)                              \
 DHASH_WRAPPER(CLASSNAME##Super,ENTRY_CLASS,KEY_TYPE)
 
 #undef DHASH_EXPORT
-#define DHASH_EXPORT NS_COM
+#define DHASH_EXPORT
 
 DECL_DHASH_SET(nsStringHashSet, PLDHashStringEntry, nsAString&)
 DECL_DHASH_SET(nsCStringHashSet,PLDHashCStringEntry,nsACString&)
 DECL_DHASH_SET(nsInt32HashSet,  PLDHashInt32Entry,  PRInt32)
 DECL_DHASH_SET(nsVoidHashSet,   PLDHashVoidEntry,   void*)
 
 #undef DHASH_EXPORT
 #define DHASH_EXPORT
--- a/xpcom/ds/nsHashtable.h
+++ b/xpcom/ds/nsHashtable.h
@@ -61,17 +61,17 @@
 #include "nsTraceRefcnt.h"
 
 class nsIObjectInputStream;
 class nsIObjectOutputStream;
 
 class nsHashtable;
 class nsStringKey;
 
-class NS_COM nsHashKey {
+class nsHashKey {
   protected:
     nsHashKey(void) {
 #ifdef DEBUG
         mKeyType = UnknownKey;
 #endif
         MOZ_COUNT_CTOR(nsHashKey);
     }
 
@@ -123,17 +123,17 @@ typedef nsresult
 // NB: may be called with null aKey or aData, to free just one of the two.
 typedef void
 (* nsHashtableFreeEntryFunc)(nsIObjectInputStream *aStream, nsHashKey *aKey,
                              void *aData);
 
 typedef nsresult
 (* nsHashtableWriteDataFunc)(nsIObjectOutputStream *aStream, void *aData);
 
-class NS_COM nsHashtable {
+class nsHashtable {
   protected:
     // members  
     PRLock*         mLock;
     PLDHashTable    mHashtable;
     PRBool          mEnumerating;
 
   public:
     nsHashtable(PRUint32 aSize = 16, PRBool threadSafe = PR_FALSE);
@@ -158,17 +158,17 @@ class NS_COM nsHashtable {
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsObjectHashtable: an nsHashtable where the elements are C++ objects to be
 // deleted
 
 typedef void* (* nsHashtableCloneElementFunc)(nsHashKey *aKey, void *aData, void* aClosure);
 
-class NS_COM nsObjectHashtable : public nsHashtable {
+class nsObjectHashtable : public nsHashtable {
   public:
     nsObjectHashtable(nsHashtableCloneElementFunc cloneElementFun,
                       void* cloneElementClosure,
                       nsHashtableEnumFunc destroyElementFun,
                       void* destroyElementClosure,
                       PRUint32 aSize = 16, PRBool threadSafe = PR_FALSE);
     ~nsObjectHashtable();
 
@@ -187,17 +187,17 @@ class NS_COM nsObjectHashtable : public 
     void*                       mDestroyElementClosure;
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsSupportsHashtable: an nsHashtable where the elements are nsISupports*
 
 class nsISupports;
 
-class NS_COM nsSupportsHashtable
+class nsSupportsHashtable
   : private nsHashtable
 {
   public:
     typedef PRBool (* EnumFunc) (nsHashKey *aKey, void *aData, void* aClosure);
 
     nsSupportsHashtable(PRUint32 aSize = 16, PRBool threadSafe = PR_FALSE)
       : nsHashtable(aSize, threadSafe) {}
     ~nsSupportsHashtable();
@@ -226,17 +226,17 @@ class NS_COM nsSupportsHashtable
                                          PRUint32 i, void *arg);
 };
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsISupportsKey: Where keys are nsISupports objects that get refcounted.
 
 #include "nsISupports.h"
 
-class NS_COM nsISupportsKey : public nsHashKey {
+class nsISupportsKey : public nsHashKey {
   protected:
     nsISupports* mKey;
     
   public:
     nsISupportsKey(const nsISupportsKey& aKey) : mKey(aKey.mKey) {
 #ifdef DEBUG
         mKeyType = SupportsKey;
 #endif
@@ -332,17 +332,17 @@ class nsVoidKey : public nsHashKey {
     }
 
     void* GetValue() { return mKey; }
 };
 
 #include "nsString.h"
 
 // for null-terminated c-strings
-class NS_COM nsCStringKey : public nsHashKey {
+class nsCStringKey : public nsHashKey {
   public:
 
     // NB: when serializing, NEVER_OWN keys are deserialized as OWN.
     enum Ownership {
         NEVER_OWN,  // very long lived, even clones don't need to copy it.
         OWN_CLONE,  // as long lived as this key. But clones make a copy.
         OWN         // to be free'd in key dtor. Clones make their own copy.
     };
@@ -366,17 +366,17 @@ class NS_COM nsCStringKey : public nsHas
 
   protected:
     char*       mStr;
     PRUint32    mStrLen;
     Ownership   mOwnership;
 };
 
 // for null-terminated unicode strings
-class NS_COM nsStringKey : public nsHashKey {
+class nsStringKey : public nsHashKey {
   public:
 
     // NB: when serializing, NEVER_OWN keys are deserialized as OWN.
     enum Ownership {
         NEVER_OWN,  // very long lived, even clones don't need to copy it.
         OWN_CLONE,  // as long lived as this key. But clones make a copy.
         OWN         // to be free'd in key dtor. Clones make their own copy.
     };
--- a/xpcom/ds/nsIAtom.idl
+++ b/xpcom/ds/nsIAtom.idl
@@ -113,60 +113,60 @@ protected:
  * count, which requires locking and hurts performance.
  */
 
 
 /**
  * Find an atom that matches the given UTF-8 string.
  * The string is assumed to be zero terminated.
  */
-extern NS_COM nsIAtom* NS_NewAtom(const char* aUTF8String);
+extern nsIAtom* NS_NewAtom(const char* aUTF8String);
 
 inline already_AddRefed<nsIAtom> do_GetAtom(const char* aUTF8String)
     { return NS_NewAtom(aUTF8String); }
  
 /**
  * Find an atom that matches the given UTF-8 string.
  */
-extern NS_COM nsIAtom* NS_NewAtom(const nsACString& aUTF8String);
+extern nsIAtom* NS_NewAtom(const nsACString& aUTF8String);
 inline already_AddRefed<nsIAtom> do_GetAtom(const nsACString& aUTF8String)
     { return NS_NewAtom(aUTF8String); }
 
 /**
  * Find an atom that matches the given UTF-16 string.
  * The string is assumed to be zero terminated.
  */
-extern NS_COM nsIAtom* NS_NewAtom(const PRUnichar* aUTF16String);
+extern nsIAtom* NS_NewAtom(const PRUnichar* aUTF16String);
 inline already_AddRefed<nsIAtom> do_GetAtom(const PRUnichar* aUTF16String)
     { return NS_NewAtom(aUTF16String); }
 
 /**
  * Find an atom that matches the given UTF-16 string.
  */
-extern NS_COM nsIAtom* NS_NewAtom(const nsAString& aUTF16String);
-extern NS_COM nsIAtom* NS_NewPermanentAtom(const nsAString& aUTF16String);
+extern nsIAtom* NS_NewAtom(const nsAString& aUTF16String);
+extern nsIAtom* NS_NewPermanentAtom(const nsAString& aUTF16String);
 inline already_AddRefed<nsIAtom> do_GetAtom(const nsAString& aUTF16String)
     { return NS_NewAtom(aUTF16String); }
 
 /**
  * Return a count of the total number of atoms currently
  * alive in the system.
  */
-extern NS_COM nsrefcnt NS_GetNumberOfAtoms(void);
+extern nsrefcnt NS_GetNumberOfAtoms(void);
 
 /**
  * Return a pointer for a static atom for the string or null if there's 
  * no static atom for this string.
  */
-extern NS_COM nsIAtom* NS_GetStaticAtom(const nsAString& aUTF16String);
+extern nsIAtom* NS_GetStaticAtom(const nsAString& aUTF16String);
 
 /**
  * Seal the static atom table
  */
-extern NS_COM void NS_SealStaticAtomTable();
+extern void NS_SealStaticAtomTable();
 
 class nsAtomString : public nsString
 {
 public:
   nsAtomString(nsIAtom* aAtom)
   {
     aAtom->ToString(*this);
   }
--- a/xpcom/ds/nsIByteBuffer.h
+++ b/xpcom/ds/nsIByteBuffer.h
@@ -83,15 +83,15 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIByteBuf
 { /* a49d5280-0d6b-11d3-9331-00104ba0fd40 */         \
     0xa49d5280,                                      \
     0x0d6b,                                          \
     0x11d3,                                          \
     {0x93, 0x31, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
 }
 
 /** Create a new byte buffer using the given buffer size. */
-extern NS_COM nsresult 
+extern nsresult 
 NS_NewByteBuffer(nsIByteBuffer** aInstancePtrResult,
                  nsISupports* aOuter,
                  PRUint32 aBufferSize = 0);
 
 #endif /* nsIByteBuffer_h___ */
 
--- a/xpcom/ds/nsICollection.idl
+++ b/xpcom/ds/nsICollection.idl
@@ -58,17 +58,17 @@ interface nsICollection : nsISerializabl
 };
 
 %{C++
 
 #ifndef nsCOMPtr_h__
 #include "nsCOMPtr.h"
 #endif
 
-class NS_COM nsQueryElementAt : public nsCOMPtr_helper
+class nsQueryElementAt : public nsCOMPtr_helper
   {
     public:
       nsQueryElementAt( nsICollection* aCollection, PRUint32 aIndex, nsresult* aErrorPtr )
           : mCollection(aCollection),
             mIndex(aIndex),
             mErrorPtr(aErrorPtr)
         {
           // nothing else to do here
--- a/xpcom/ds/nsISupportsArray.idl
+++ b/xpcom/ds/nsISupportsArray.idl
@@ -62,17 +62,17 @@ class nsISupportsArray;
     {0x93, 0x31, 0x00, 0x10, 0x4b, 0xa0, 0xfd, 0x40} \
 }
 #define NS_SUPPORTSARRAY_CONTRACTID "@mozilla.org/supports-array;1"
 #define NS_SUPPORTSARRAY_CLASSNAME "Supports Array"
  
 // Enumerator callback function. Return PR_FALSE to stop
 typedef PRBool (*nsISupportsArrayEnumFunc)(nsISupports* aElement, void *aData);
  
-NS_COM nsresult
+nsresult
 NS_NewArrayEnumerator(nsISimpleEnumerator* *result NS_OUTPARAM,
                       nsISupportsArray* array);
 %}
 
 [scriptable, uuid(791eafa0-b9e6-11d1-8031-006008159b5a)]
 interface nsISupportsArray : nsICollection {
 
   [notxpcom] boolean Equals([const] in nsISupportsArray other);
@@ -126,18 +126,18 @@ interface nsISupportsArray : nsICollecti
 
   [notxpcom] boolean SizeTo(in long aSize);
   
 };
 
 %{C++
 
 // Construct and return a default implementation of nsISupportsArray:
-extern NS_COM nsresult
+extern nsresult
 NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult);
 
 // Construct and return a default implementation of an enumerator for nsISupportsArrays:
-extern NS_COM nsresult
+extern nsresult
 NS_NewISupportsArrayEnumerator(nsISupportsArray* array,
                                nsIBidirectionalEnumerator* *aInstancePtrResult);
 
 
 %}
--- a/xpcom/ds/nsIUnicharBuffer.h
+++ b/xpcom/ds/nsIUnicharBuffer.h
@@ -54,17 +54,17 @@ public:
   NS_IMETHOD_(PRInt32) GetBufferSize() const = 0;
   NS_IMETHOD_(PRUnichar*) GetBuffer() const = 0;
   NS_IMETHOD_(PRBool) Grow(PRInt32 aNewSize) = 0;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIUnicharBuffer, NS_IUNICHARBUFFER_IID)
 
 /// Factory method for nsIUnicharBuffer.
-extern NS_COM nsresult
+extern nsresult
 NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult,
                     nsISupports* aOuter,
                     PRUint32 aBufferSize = 0);
 
 #define NS_UNICHARBUFFER_CID                         \
 { /* c81fd8f0-0d6b-11d3-9331-00104ba0fd40 */         \
     0xc81fd8f0,                                      \
     0x0d6b,                                          \
--- a/xpcom/ds/nsRecyclingAllocator.h
+++ b/xpcom/ds/nsRecyclingAllocator.h
@@ -66,17 +66,17 @@
 #include "nsIRecyclingAllocator.h"
 
 #define NS_DEFAULT_RECYCLE_TIMEOUT 10  // secs
 #define NS_ALLOCATOR_OVERHEAD_BYTES (sizeof(PRSize)) // bytes
 
 class nsITimer;
 class nsIMemory;
 
-class NS_COM nsRecyclingAllocator {
+class nsRecyclingAllocator {
  protected:
     struct Block {
       PRSize bytes;
       Block *next;
     };
 
 #define DATA(block) ((void *)(((char *)block) + NS_ALLOCATOR_OVERHEAD_BYTES))
 #define DATA_TO_BLOCK(data) ((Block *)((char *)(data) - NS_ALLOCATOR_OVERHEAD_BYTES))
--- a/xpcom/ds/nsStaticAtom.h
+++ b/xpcom/ds/nsStaticAtom.h
@@ -72,12 +72,12 @@ struct nsStaticAtom {
 template <PRUint32 size>
 struct nsFakeStringBuffer {
     PRInt32 mRefCnt;
     PRUint32 mSize;
     nsStaticAtomStringType mStringData[size];
 };
 
 // Register static atoms with the atom table
-NS_COM nsresult
+nsresult
 NS_RegisterStaticAtoms(const nsStaticAtom*, PRUint32 aAtomCount);
 
 #endif
--- a/xpcom/ds/nsStaticNameTable.h
+++ b/xpcom/ds/nsStaticNameTable.h
@@ -54,17 +54,17 @@
  * - It is not an xpcom interface - meant for fast lookup in static tables.
  *
  * ***REQUIREMENTS***
  * - It *requires* that all entries in the table be lowercase only.
  * - It *requires* that the table of strings be in memory that lives at least
  *    as long as this table object - typically a static string array.
  */
 
-class NS_COM nsStaticCaseInsensitiveNameTable
+class nsStaticCaseInsensitiveNameTable
 {
 public:
   enum { NOT_FOUND = -1 };
 
   PRBool           Init(const char* const aNames[], PRInt32 Count);
   PRInt32          Lookup(const nsACString& aName);
   PRInt32          Lookup(const nsAString& aName);
   const nsAFlatCString& GetStringValue(PRInt32 index);
--- a/xpcom/ds/nsStringEnumerator.cpp
+++ b/xpcom/ds/nsStringEnumerator.cpp
@@ -186,74 +186,74 @@ StringEnumeratorTail(T** aResult NS_INPA
     NS_ADDREF(*aResult);
     return NS_OK;
 }
 
 //
 // constructors
 //
 
-NS_COM nsresult
+nsresult
 NS_NewStringEnumerator(nsIStringEnumerator** aResult,
                        const nsTArray<nsString>* aArray, nsISupports* aOwner)
 {
     NS_ENSURE_ARG_POINTER(aResult);
     NS_ENSURE_ARG_POINTER(aArray);
     
     *aResult = new nsStringEnumerator(aArray, aOwner);
     return StringEnumeratorTail(aResult);
 }
 
 
-NS_COM nsresult
+nsresult
 NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
                            const nsTArray<nsCString>* aArray, nsISupports* aOwner)
 {
     NS_ENSURE_ARG_POINTER(aResult);
     NS_ENSURE_ARG_POINTER(aArray);
     
     *aResult = new nsStringEnumerator(aArray, aOwner);
     return StringEnumeratorTail(aResult);
 }
 
-NS_COM nsresult
+nsresult
 NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult,
                                nsTArray<nsString>* aArray)
 {
     NS_ENSURE_ARG_POINTER(aResult);
     NS_ENSURE_ARG_POINTER(aArray);
     
     *aResult = new nsStringEnumerator(aArray, PR_TRUE);
     return StringEnumeratorTail(aResult);
 }
 
-NS_COM nsresult
+nsresult
 NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
                                    nsTArray<nsCString>* aArray)
 {
     NS_ENSURE_ARG_POINTER(aResult);
     NS_ENSURE_ARG_POINTER(aArray);
     
     *aResult = new nsStringEnumerator(aArray, PR_TRUE);
     return StringEnumeratorTail(aResult);
 }
 
 // const ones internally just forward to the non-const equivalents
-NS_COM nsresult
+nsresult
 NS_NewStringEnumerator(nsIStringEnumerator** aResult,
                        const nsTArray<nsString>* aArray)
 {
     NS_ENSURE_ARG_POINTER(aResult);
     NS_ENSURE_ARG_POINTER(aArray);
     
     *aResult = new nsStringEnumerator(aArray, PR_FALSE);
     return StringEnumeratorTail(aResult);
 }
 
-NS_COM nsresult
+nsresult
 NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
                            const nsTArray<nsCString>* aArray)
 {
     NS_ENSURE_ARG_POINTER(aResult);
     NS_ENSURE_ARG_POINTER(aArray);
     
     *aResult = new nsStringEnumerator(aArray, PR_FALSE);
     return StringEnumeratorTail(aResult);
--- a/xpcom/ds/nsStringEnumerator.h
+++ b/xpcom/ds/nsStringEnumerator.h
@@ -70,54 +70,54 @@
 // array.AppendCString("abc");
 // array.AppendCString("def");
 // NS_NewStringEnumerator(&enumerator, &array, PR_TRUE);
 //
 // // call some internal method which iterates the enumerator
 // InternalMethod(enumerator);
 // NS_RELEASE(enumerator);
 //
-NS_COM nsresult
+nsresult
 NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
                        const nsTArray<nsString>* aArray,
                        nsISupports* aOwner);
-NS_COM nsresult
+nsresult
 NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
                            const nsTArray<nsCString>* aArray);
 
-NS_COM nsresult
+nsresult
 NS_NewStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
                        const nsTArray<nsString>* aArray);
 
 // Adopting string enumerators assume ownership of the array and will
 // call |operator delete| on the array when the enumerator is destroyed
 // this is useful when the provider creates an array solely for the
 // purpose of creating the enumerator.
 // For example:
 //
 // nsTArray<nsCString>* array = new nsTArray<nsCString>;
 // array->AppendString("abcd");
 // NS_NewAdoptingStringEnumerator(&result, array);
-NS_COM nsresult
+nsresult
 NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult NS_OUTPARAM,
                                nsTArray<nsString>* aArray);
 
-NS_COM nsresult
+nsresult
 NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
                                    nsTArray<nsCString>* aArray);
 
 
 // these versions take a refcounted "owner" which will be addreffed
 // when the enumerator is created, and destroyed when the enumerator
 // is released. This allows providers to give non-owning pointers to
 // ns*StringArray member variables without worrying about lifetime
 // issues
 // For example:
 //
 // nsresult MyClass::Enumerate(nsIUTF8StringEnumerator** aResult) {
 //     mCategoryList->AppendString("abcd");
 //     return NS_NewStringEnumerator(aResult, mCategoryList, this);
 // }
 //
-NS_COM nsresult
+nsresult
 NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult NS_OUTPARAM,
                            const nsTArray<nsCString>* aArray,
                            nsISupports* aOwner);
--- a/xpcom/ds/nsSupportsArray.cpp
+++ b/xpcom/ds/nsSupportsArray.cpp
@@ -668,17 +668,17 @@ nsSupportsArray::Clone(nsISupportsArray*
   nsISupportsArray* newArray;
   rv = NS_NewISupportsArray(&newArray);
   PRBool ok = EnumerateForwards(CopyElement, newArray);
   if (!ok) return NS_ERROR_OUT_OF_MEMORY;
   *result = newArray;
   return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult)
 {
   nsresult rv;
   rv = nsSupportsArray::Create(NULL, NS_GET_IID(nsISupportsArray),
                                (void**)aInstancePtrResult);
   return rv;
 }
 
--- a/xpcom/ds/nsSupportsArray.h
+++ b/xpcom/ds/nsSupportsArray.h
@@ -39,22 +39,17 @@
 #define nsSupportsArray_h__
 
 //#define DEBUG_SUPPORTSARRAY 1
 
 #include "nsISupportsArray.h"
 
 static const PRUint32 kAutoArraySize = 8;
 
-// Set IMETHOD_VISIBILITY to empty so that the class-level NS_COM declaration
-// controls member method visibility.
-#undef  IMETHOD_VISIBILITY
-#define IMETHOD_VISIBILITY
-
-class NS_COM nsSupportsArray : public nsISupportsArray {
+class nsSupportsArray : public nsISupportsArray {
 public:
   nsSupportsArray(void);
   ~nsSupportsArray(void); // nonvirtual since we're not subclassed
 
   static nsresult
   Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
 
   NS_DECL_ISUPPORTS
--- a/xpcom/ds/nsSupportsArrayEnumerator.cpp
+++ b/xpcom/ds/nsSupportsArrayEnumerator.cpp
@@ -125,17 +125,17 @@ nsSupportsArrayEnumerator::Prev()
   if (mCursor >= 0)
     return NS_OK;
   else
     return NS_ERROR_FAILURE;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-NS_COM nsresult
+nsresult
 NS_NewISupportsArrayEnumerator(nsISupportsArray* array,
                                nsIBidirectionalEnumerator* *aInstancePtrResult)
 {
   if (aInstancePtrResult == 0)
     return NS_ERROR_NULL_POINTER;
   nsSupportsArrayEnumerator* e = new nsSupportsArrayEnumerator(array);
   if (e == 0)
     return NS_ERROR_OUT_OF_MEMORY;
--- a/xpcom/ds/nsUnicharBuffer.cpp
+++ b/xpcom/ds/nsUnicharBuffer.cpp
@@ -116,17 +116,17 @@ UnicharBufferImpl::Grow(PRInt32 aNewSize
     }
     delete[] mBuffer;
     mBuffer = newbuf;
     return PR_TRUE;
   }
   return PR_FALSE;
 }
 
-NS_COM nsresult
+nsresult
 NS_NewUnicharBuffer(nsIUnicharBuffer** aInstancePtrResult,
                     nsISupports* aOuter,
                     PRUint32 aBufferSize)
 {
   nsresult rv;
   nsIUnicharBuffer* buf;
   rv = UnicharBufferImpl::Create(aOuter, NS_GET_IID(nsIUnicharBuffer), 
                                  (void**)&buf);
--- a/xpcom/ds/nsVariant.h
+++ b/xpcom/ds/nsVariant.h
@@ -108,17 +108,17 @@ struct nsDiscriminatedUnion
  * these objects. They are created 'empty' and 'writable'. 
  *
  * nsIVariant users won't usually need to see this class.
  *
  * This class also has static helper methods that nsIVariant *implementors* can
  * use to help them do all the 'standard' nsIVariant data conversions.
  */
 
-class NS_COM nsVariant : public nsIWritableVariant
+class nsVariant : public nsIWritableVariant
 {
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSIVARIANT
     NS_DECL_NSIWRITABLEVARIANT
 
     nsVariant();
 
--- a/xpcom/ds/nsWindowsRegKey.h
+++ b/xpcom/ds/nsWindowsRegKey.h
@@ -48,17 +48,17 @@
  * via the XPCOM component manager.
  */
 #define NS_WINDOWSREGKEY_CONTRACTID "@mozilla.org/windows-registry-key;1"
 
 /**
  * This function may be used to instantiate a windows registry key object prior
  * to XPCOM being initialized.
  */
-extern "C" NS_COM nsresult
+extern "C" nsresult
 NS_NewWindowsRegKey(nsIWindowsRegKey **result);
 
 //-----------------------------------------------------------------------------
 
 #ifdef _IMPL_NS_COM
 
 #define NS_WINDOWSREGKEY_CLASSNAME "nsWindowsRegKey"
 
--- a/xpcom/glue/nsCycleCollectorUtils.h
+++ b/xpcom/glue/nsCycleCollectorUtils.h
@@ -38,17 +38,17 @@
 #define nsCycleCollectorUtils_h__
 
 #include "nscore.h"
 #include "mozilla/threads/nsThreadIDs.h"
 
 #if defined(MOZILLA_INTERNAL_API)
 #define NS_IsCycleCollectorThread NS_IsCycleCollectorThread_P
 #if defined(XP_WIN)
-NS_COM bool NS_IsCycleCollectorThread();
+bool NS_IsCycleCollectorThread();
 #elif defined(NS_TLS)
 // Defined in nsThreadManager.cpp.
 extern NS_TLS mozilla::threads::ID gTLSThreadID;
 inline bool NS_IsCycleCollectorThread()
 {
   return gTLSThreadID == mozilla::threads::CycleCollector;
 }
 #else
--- a/xpcom/glue/nsThreadUtils.h
+++ b/xpcom/glue/nsThreadUtils.h
@@ -100,17 +100,17 @@ NS_GetCurrentThread(nsIThread **result);
  *
  * @param result
  *   The resulting nsIThread object.
  */
 extern NS_COM_GLUE NS_METHOD
 NS_GetMainThread(nsIThread **result);
 
 #if defined(MOZILLA_INTERNAL_API) && defined(XP_WIN)
-NS_COM bool NS_IsMainThread();
+bool NS_IsMainThread();
 #elif defined(MOZILLA_INTERNAL_API) && defined(NS_TLS)
 // This is defined in nsThreadManager.cpp and initialized to `Main` for the
 // main thread by nsThreadManager::Init.
 extern NS_TLS mozilla::threads::ID gTLSThreadID;
 inline bool NS_IsMainThread()
 {
   return gTLSThreadID == mozilla::threads::Main;
 }
--- a/xpcom/io/SpecialSystemDirectory.cpp
+++ b/xpcom/io/SpecialSystemDirectory.cpp
@@ -100,31 +100,31 @@ typedef HRESULT (WINAPI* nsGetKnownFolde
                                                HANDLE hToken,
                                                PWSTR *ppszPath);
 
 static nsGetKnownFolderPath gGetKnownFolderPath = NULL;
 
 static HINSTANCE gShell32DLLInst = NULL;
 #endif
 
-NS_COM void StartupSpecialSystemDirectory()
+void StartupSpecialSystemDirectory()
 {
 #if defined (XP_WIN)
     // SHGetKnownFolderPath is only available on Windows Vista
     // so that we need to use GetProcAddress to get the pointer.
     gShell32DLLInst = LoadLibraryW(L"shell32.dll");
     if(gShell32DLLInst)
     {
         gGetKnownFolderPath = (nsGetKnownFolderPath)
             GetProcAddress(gShell32DLLInst, "SHGetKnownFolderPath");
     }
 #endif
 }
 
-NS_COM void ShutdownSpecialSystemDirectory()
+void ShutdownSpecialSystemDirectory()
 {
 #if defined (XP_WIN)
     if (gShell32DLLInst)
     {
         FreeLibrary(gShell32DLLInst);
         gShell32DLLInst = NULL;
         gGetKnownFolderPath = NULL;
     }
--- a/xpcom/io/SpecialSystemDirectory.h
+++ b/xpcom/io/SpecialSystemDirectory.h
@@ -45,19 +45,18 @@
 #include "nsILocalFile.h"
 
 #ifdef XP_MACOSX
 #include <Carbon/Carbon.h>
 #include "nsILocalFileMac.h"
 #include "prenv.h"
 #endif
 
-
-extern NS_COM void StartupSpecialSystemDirectory();
-extern NS_COM void ShutdownSpecialSystemDirectory();
+extern void StartupSpecialSystemDirectory();
+extern void ShutdownSpecialSystemDirectory();
 
 
 enum SystemDirectories {
   OS_DriveDirectory         =   1,   
   OS_TemporaryDirectory     =   2,   
   OS_CurrentProcessDirectory=   3,   
   OS_CurrentWorkingDirectory=   4,
   XPCOM_CurrentProcessComponentDirectory=   5,   
--- a/xpcom/io/nsEscape.cpp
+++ b/xpcom/io/nsEscape.cpp
@@ -151,34 +151,34 @@ static char* nsEscapeCount(
 
     *dst = '\0';     /* tack on eos */
 	if(out_len)
 		*out_len = dst - (unsigned char *) result;
     return result;
 }
 
 //----------------------------------------------------------------------------------------
-NS_COM char* nsEscape(const char * str, nsEscapeMask flags)
+char* nsEscape(const char * str, nsEscapeMask flags)
 //----------------------------------------------------------------------------------------
 {
     if(!str)
         return NULL;
     return nsEscapeCount(str, flags, NULL);
 }
 
 //----------------------------------------------------------------------------------------
-NS_COM char* nsUnescape(char * str)
+char* nsUnescape(char * str)
 //----------------------------------------------------------------------------------------
 {
 	nsUnescapeCount(str);
 	return str;
 }
 
 //----------------------------------------------------------------------------------------
-NS_COM PRInt32 nsUnescapeCount(char * str)
+PRInt32 nsUnescapeCount(char * str)
 //----------------------------------------------------------------------------------------
 {
     register char *src = str;
     register char *dst = str;
     static const char hexChars[] = "0123456789ABCDEFabcdef";
 
     char c1[] = " ";
     char c2[] = " ";
@@ -214,17 +214,17 @@ NS_COM PRInt32 nsUnescapeCount(char * st
     }
 
     *dst = 0;
     return (int)(dst - str);
 
 } /* NET_UnEscapeCnt */
 
 
-NS_COM char *
+char *
 nsEscapeHTML(const char * string)
 {
     char *rv = nsnull;
     /* XXX Hardcoded max entity len. The +1 is for the trailing null. */
     PRUint32 len = PL_strlen(string);
     if (len >= (PR_UINT32_MAX / 6))
       return nsnull;
 
@@ -280,17 +280,17 @@ nsEscapeHTML(const char * string)
               }
           }
         *ptr = '\0';
       }
 
     return(rv);
 }
 
-NS_COM PRUnichar *
+PRUnichar *
 nsEscapeHTML2(const PRUnichar *aSourceBuffer, PRInt32 aSourceBufferLen)
 {
   // if the caller didn't calculate the length
   if (aSourceBufferLen < 0) {
     aSourceBufferLen = nsCRT::strlen(aSourceBuffer); // ...then I will
   }
 
   /* XXX Hardcoded max entity len. */
@@ -386,17 +386,17 @@ const int EscapeChars[256] =
    that already look escaped, which means it already includes 
    a valid hexcode. This is done to avoid multiple escapes of
    a string. Use the following flags to force escaping of a 
    string:
  
    esc_Forced        =  1024
 */
 
-NS_COM PRBool NS_EscapeURL(const char *part,
+PRBool NS_EscapeURL(const char *part,
                            PRInt32 partLen,
                            PRUint32 flags,
                            nsACString &result)
 {
     if (!part) {
         NS_NOTREACHED("null pointer");
         return PR_FALSE;
     }
@@ -472,17 +472,17 @@ NS_COM PRBool NS_EscapeURL(const char *p
       tempBuffer[tempBufferPos] = '\0';
       result += tempBuffer;
     }
     return writing;
 }
 
 #define ISHEX(c) memchr(hexChars, c, sizeof(hexChars)-1)
 
-NS_COM PRBool NS_UnescapeURL(const char *str, PRInt32 len, PRUint32 flags, nsACString &result)
+PRBool NS_UnescapeURL(const char *str, PRInt32 len, PRUint32 flags, nsACString &result)
 {
     if (!str) {
         NS_NOTREACHED("null pointer");
         return PR_FALSE;
     }
 
     if (len < 0)
         len = strlen(str);
--- a/xpcom/io/nsEscape.h
+++ b/xpcom/io/nsEscape.h
@@ -63,33 +63,33 @@ extern "C" {
 
 /**
  * Escape the given string according to mask
  * @param str The string to escape
  * @param mask How to escape the string
  * @return A newly allocated escaped string that must be free'd with
  *         nsCRT::free, or null on failure
  */
-NS_COM char * nsEscape(const char * str, nsEscapeMask mask);
+char * nsEscape(const char * str, nsEscapeMask mask);
 
-NS_COM char * nsUnescape(char * str);
+char * nsUnescape(char * str);
 	/* decode % escaped hex codes into character values,
 	 * modifies the parameter, returns the same buffer
 	 */
 
-NS_COM PRInt32 nsUnescapeCount (char * str);
+PRInt32 nsUnescapeCount (char * str);
 	/* decode % escaped hex codes into character values,
 	 * modifies the parameter buffer, returns the length of the result
 	 * (result may contain \0's).
 	 */
 
-NS_COM char *
+char *
 nsEscapeHTML(const char * string);
 
-NS_COM PRUnichar *
+PRUnichar *
 nsEscapeHTML2(const PRUnichar *aSourceBuffer,
               PRInt32 aSourceBufferLen = -1);
  /*
   * Escape problem char's for HTML display 
   */
 
 
 #ifdef __cplusplus
@@ -137,33 +137,33 @@ enum EscapeMask {
  *
  * @param  str     url segment string
  * @param  len     url segment string length (-1 if unknown)
  * @param  flags   url segment type flag
  * @param  result  result buffer, untouched if part is already escaped
  *
  * @return TRUE if escaping was performed, FALSE otherwise.
  */
-NS_COM PRBool NS_EscapeURL(const char *str,
+PRBool NS_EscapeURL(const char *str,
                            PRInt32 len,
                            PRUint32 flags,
                            nsACString &result);
 
 /**
  * Expands URL escape sequences... beware embedded null bytes!
  *
  * @param  str     url string to unescape
  * @param  len     length of |str|
  * @param  flags   only esc_OnlyNonASCII, esc_SkipControl and esc_AlwaysCopy 
  *                 are recognized
  * @param  result  result buffer, untouched if |str| is already unescaped
  *
  * @return TRUE if unescaping was performed, FALSE otherwise.
  */
-NS_COM PRBool NS_UnescapeURL(const char *str,
+PRBool NS_UnescapeURL(const char *str,
                              PRInt32 len,
                              PRUint32 flags,
                              nsACString &result);
 
 /** returns resultant string length **/
 inline PRInt32 NS_UnescapeURL(char *str) {
     return nsUnescapeCount(str);
 }
--- a/xpcom/io/nsIInputStreamTee.idl
+++ b/xpcom/io/nsIInputStreamTee.idl
@@ -58,19 +58,19 @@ interface nsIInputStreamTee : nsIInputSt
      * storage-policy is STORE_ON_DISK_AS_FILE, copying to sink happens
      * synchronously while reading from the source.
      */
     attribute nsIEventTarget eventTarget;
 };
 
 %{C++
 // factory methods
-extern NS_COM nsresult
+extern nsresult
 NS_NewInputStreamTee(nsIInputStream **tee, // read from this input stream
                      nsIInputStream *source,
                      nsIOutputStream *sink);
                      
-extern NS_COM nsresult
+extern nsresult
 NS_NewInputStreamTeeAsync(nsIInputStream **tee, // read from this input stream
                      nsIInputStream *source,
                      nsIOutputStream *sink,
                      nsIEventTarget *eventTarget);
 %}
--- a/xpcom/io/nsIPipe.idl
+++ b/xpcom/io/nsIPipe.idl
@@ -156,17 +156,17 @@ interface nsISearchableInputStream : nsI
  *        specifies the max number of segments (pass 0 to use default value)
  *        passing PR_UINT32_MAX here causes the pipe to have "infinite" space.
  *        this mode can be useful in some cases, but should always be used with
  *        caution.  the default value for this parameter is a finite value.
  * @param segmentAlloc
  *        pass reference to nsIMemory to have all pipe allocations use this
  *        allocator (pass null to use the default allocator)
  */
-extern NS_COM nsresult
+extern nsresult
 NS_NewPipe2(nsIAsyncInputStream **pipeIn,
             nsIAsyncOutputStream **pipeOut,
             PRBool nonBlockingInput = PR_FALSE,
             PRBool nonBlockingOutput = PR_FALSE,
             PRUint32 segmentSize = 0,
             PRUint32 segmentCount = 0,
             nsIMemory *segmentAlloc = nsnull);
 
@@ -193,17 +193,17 @@ NS_NewPipe2(nsIAsyncInputStream **pipeIn
  * @param nonBlockingInput
  *        true specifies non-blocking input stream behavior
  * @param nonBlockingOutput
  *        true specifies non-blocking output stream behavior
  * @param segmentAlloc
  *        pass reference to nsIMemory to have all pipe allocations use this
  *        allocator (pass null to use the default allocator)
  */
-extern NS_COM nsresult
+extern nsresult
 NS_NewPipe(nsIInputStream **pipeIn,
            nsIOutputStream **pipeOut,
            PRUint32 segmentSize = 0,
            PRUint32 maxSize = 0,
            PRBool nonBlockingInput = PR_FALSE,
            PRBool nonBlockingOutput = PR_FALSE,
            nsIMemory *segmentAlloc = nsnull);
 
--- a/xpcom/io/nsIStorageStream.idl
+++ b/xpcom/io/nsIStorageStream.idl
@@ -97,11 +97,11 @@ interface nsIStorageStream : nsISupports
     /**
      * True, when output stream has not yet been Close'ed
      */
     readonly attribute boolean writeInProgress;
 };
 
 %{C++
 // Factory method
-NS_COM nsresult
+nsresult
 NS_NewStorageStream(PRUint32 segmentSize, PRUint32 maxSize, nsIStorageStream **result);
 %}
--- a/xpcom/io/nsInputStreamTee.cpp
+++ b/xpcom/io/nsInputStreamTee.cpp
@@ -333,17 +333,17 @@ nsInputStreamTee::SetEventTarget(nsIEven
 NS_IMETHODIMP
 nsInputStreamTee::GetEventTarget(nsIEventTarget **anEventTarget)
 {
     NS_IF_ADDREF(*anEventTarget = mEventTarget);
     return NS_OK;
 }
 
 
-NS_COM nsresult
+nsresult
 NS_NewInputStreamTeeAsync(nsIInputStream **result,
                           nsIInputStream *source,
                           nsIOutputStream *sink,
                           nsIEventTarget *anEventTarget)
 {
     nsresult rv;
     
     nsCOMPtr<nsIInputStreamTee> tee = new nsInputStreamTee();
@@ -358,15 +358,15 @@ NS_NewInputStreamTeeAsync(nsIInputStream
 
     rv = tee->SetEventTarget(anEventTarget);
     if (NS_FAILED(rv)) return rv;
 
     NS_ADDREF(*result = tee);
     return rv;
 }
 
-NS_COM nsresult
+nsresult
 NS_NewInputStreamTee(nsIInputStream **result,
                      nsIInputStream *source,
                      nsIOutputStream *sink)
 {
     return NS_NewInputStreamTeeAsync(result, source, sink, nsnull);
 }
--- a/xpcom/io/nsLinebreakConverter.h
+++ b/xpcom/io/nsLinebreakConverter.h
@@ -33,23 +33,22 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsLinebreakConverter_h_
 #define nsLinebreakConverter_h_
 
-
 #include "nscore.h"
 #include "nsString.h"
 
 // utility class for converting between different line breaks.
 
-class NS_COM nsLinebreakConverter
+class nsLinebreakConverter
 {
 public:
 
   // Note: enum must match char* array in GetLinebreakString
   typedef enum {
     eLinebreakAny,          // any kind of linebreak (i.e. "don't care" source)
     
     eLinebreakPlatform,     // platform linebreak
@@ -147,12 +146,9 @@ public:
    *              terminated string.
    * @param aOutLen: used to return character length of returned buffer, if not null.
    */
   static nsresult ConvertUnicharLineBreaksInSitu(PRUnichar **ioBuffer, ELinebreakType aSrcBreaks, ELinebreakType aDestBreaks,
                         PRInt32 aSrcLen = kIgnoreLen, PRInt32* aOutLen = nsnull);
     
 };
 
-
-
-
 #endif // nsLinebreakConverter_h_
--- a/xpcom/io/nsLocalFileOS2.h
+++ b/xpcom/io/nsLocalFileOS2.h
@@ -62,18 +62,18 @@
 #define INCL_DOSERRORS
 #define INCL_WINCOUNTRY
 #define INCL_WINWORKPLACE
 
 #include <os2.h>
 
 class TypeEaEnumerator;
 
-class NS_COM nsLocalFile : public nsILocalFileOS2,
-                                   public nsIHashable
+class nsLocalFile : public nsILocalFileOS2,
+                    public nsIHashable
 {
 public:
     NS_DEFINE_STATIC_CID_ACCESSOR(NS_LOCAL_FILE_CID)
 
     nsLocalFile();
 
     static nsresult nsLocalFileConstructor(nsISupports* outer, const nsIID& aIID, void* *aInstancePtr);
 
--- a/xpcom/io/nsLocalFileUnix.cpp
+++ b/xpcom/io/nsLocalFileUnix.cpp
@@ -127,17 +127,17 @@ static nsresult MacErrorMapper(OSErr inE
 
 #define CHECK_mPath()                           \
     PR_BEGIN_MACRO                              \
         if (mPath.IsEmpty())                    \
             return NS_ERROR_NOT_INITIALIZED;    \
     PR_END_MACRO
 
 /* directory enumerator */
-class NS_COM
+class
 nsDirEnumeratorUnix : public nsISimpleEnumerator,
                       public nsIDirectoryEnumerator
 {
     public:
     nsDirEnumeratorUnix();
 
     // nsISupports interface
     NS_DECL_ISUPPORTS
--- a/xpcom/io/nsLocalFileUnix.h
+++ b/xpcom/io/nsLocalFileUnix.h
@@ -103,17 +103,17 @@
     #define LSTAT lstat64
     #define HAVE_STATS64 1
 #else
     #define STAT stat
     #define LSTAT lstat
 #endif
 
 
-class NS_COM nsLocalFile :
+class nsLocalFile :
 #ifdef XP_MACOSX
                            public nsILocalFileMac,
 #else
                            public nsILocalFile,
 #endif
                            public nsIHashable
 {
 public:
--- a/xpcom/io/nsNativeCharsetUtils.cpp
+++ b/xpcom/io/nsNativeCharsetUtils.cpp
@@ -46,24 +46,24 @@
 // XP_MACOSX or ANDROID
 //-----------------------------------------------------------------------------
 #if defined(XP_MACOSX) || defined(ANDROID)
 
 #include "nsAString.h"
 #include "nsReadableUtils.h"
 #include "nsString.h"
 
-NS_COM nsresult
+nsresult
 NS_CopyNativeToUnicode(const nsACString &input, nsAString  &output)
 {
     CopyUTF8toUTF16(input, output);
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_CopyUnicodeToNative(const nsAString  &input, nsACString &output)
 {
     CopyUTF16toUTF8(input, output);
     return NS_OK;
 }
 
 void
 NS_StartupNativeCharsetUtils()
@@ -797,17 +797,17 @@ nsNativeCharsetConverter::IsNativeUTF8()
 }
 
 #endif // USE_STDCONV
 
 //-----------------------------------------------------------------------------
 // API implementation
 //-----------------------------------------------------------------------------
 
-NS_COM nsresult
+nsresult
 NS_CopyNativeToUnicode(const nsACString &input, nsAString &output)
 {
     output.Truncate();
 
     PRUint32 inputLen = input.Length();
 
     nsACString::const_iterator iter;
     input.BeginReading(iter);
@@ -834,17 +834,17 @@ NS_CopyNativeToUnicode(const nsACString 
     nsresult rv = conv.NativeToUnicode(&buf, &bufLeft, &result, &resultLeft);
     if (NS_SUCCEEDED(rv)) {
         NS_ASSERTION(bufLeft == 0, "did not consume entire input buffer");
         output.SetLength(inputLen - resultLeft);
     }
     return rv;
 }
 
-NS_COM nsresult
+nsresult
 NS_CopyUnicodeToNative(const nsAString &input, nsACString &output)
 {
     output.Truncate();
 
     nsAString::const_iterator iter, end;
     input.BeginReading(iter);
     input.EndReading(end);
 
@@ -863,17 +863,17 @@ NS_CopyUnicodeToNative(const nsAString &
         if (NS_FAILED(rv)) return rv;
 
         if (tempLeft < sizeof(temp))
             output.Append(temp, sizeof(temp) - tempLeft);
     }
     return NS_OK;
 }
 
-NS_COM PRBool
+PRBool
 NS_IsNativeUTF8()
 {
     return nsNativeCharsetConverter::IsNativeUTF8();
 }
 
 void
 NS_StartupNativeCharsetUtils()
 {
@@ -900,17 +900,17 @@ NS_ShutdownNativeCharsetUtils()
 // XP_WIN
 //-----------------------------------------------------------------------------
 #elif defined(XP_WIN)
 
 #include <windows.h>
 #include "nsAString.h"
 #include "nsReadableUtils.h"
 
-NS_COM nsresult
+nsresult
 NS_CopyNativeToUnicode(const nsACString &input, nsAString &output)
 {
     PRUint32 inputLen = input.Length();
 
     nsACString::const_iterator iter;
     input.BeginReading(iter);
 
     const char *buf = iter.get();
@@ -930,17 +930,17 @@ NS_CopyNativeToUnicode(const nsACString 
 
         PRUnichar *result = out_iter.get();
 
         ::MultiByteToWideChar(CP_ACP, 0, buf, inputLen, result, resultLen);
     }
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_CopyUnicodeToNative(const nsAString  &input, nsACString &output)
 {
     PRUint32 inputLen = input.Length();
 
     nsAString::const_iterator iter;
     input.BeginReading(iter);
 
     const PRUnichar *buf = iter.get();
@@ -967,23 +967,23 @@ NS_CopyUnicodeToNative(const nsAString  
 
         ::WideCharToMultiByte(CP_ACP, 0, buf, inputLen, result, resultLen,
                               &defaultChar, NULL);
     }
     return NS_OK;
 }
 
 // moved from widget/src/windows/nsToolkit.cpp
-NS_COM PRInt32 
+PRInt32 
 NS_ConvertAtoW(const char *aStrInA, int aBufferSize, PRUnichar *aStrOutW)
 {
     return MultiByteToWideChar(CP_ACP, 0, aStrInA, -1, aStrOutW, aBufferSize);
 }
 
-NS_COM PRInt32 
+PRInt32 
 NS_ConvertWtoA(const PRUnichar *aStrInW, int aBufferSizeOut,
                char *aStrOutA, const char *aDefault)
 {
     if ((!aStrInW) || (!aStrOutA) || (aBufferSizeOut <= 0))
         return 0;
 
     int numCharsConverted = WideCharToMultiByte(CP_ACP, 0, aStrInW, -1, 
                                                 aStrOutA, aBufferSizeOut,
@@ -1017,17 +1017,17 @@ NS_ConvertWtoA(const PRUnichar *aStrInW,
 #include <uconv.h>
 #include "nsAString.h"
 #include "nsReadableUtils.h"
 #include <ulserrno.h>
 #include "nsNativeCharsetUtils.h"
 
 static UconvObject UnicodeConverter = NULL;
 
-NS_COM nsresult
+nsresult
 NS_CopyNativeToUnicode(const nsACString &input, nsAString  &output)
 {
     PRUint32 inputLen = input.Length();
 
     nsACString::const_iterator iter;
     input.BeginReading(iter);
     const char *inputStr = iter.get();
 
@@ -1057,17 +1057,17 @@ NS_CopyNativeToUnicode(const nsACString 
     }
 
     // Need to update string length to reflect how many bytes were actually
     // written.
     output.Truncate(resultLen - resultLeft);
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_CopyUnicodeToNative(const nsAString &input, nsACString &output)
 {
     size_t inputLen = input.Length();
 
     nsAString::const_iterator iter;
     input.BeginReading(iter);
     UniChar* inputStr = (UniChar*) const_cast<PRUnichar*>(iter.get());
 
@@ -1131,24 +1131,24 @@ NS_ShutdownNativeCharsetUtils()
 {
     ::UniFreeUconvObject(UnicodeConverter);
 }
 
 #else
 
 #include "nsReadableUtils.h"
 
-NS_COM nsresult
+nsresult
 NS_CopyNativeToUnicode(const nsACString &input, nsAString  &output)
 {
     CopyASCIItoUTF16(input, output);
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_CopyUnicodeToNative(const nsAString  &input, nsACString &output)
 {
     LossyCopyUTF16toASCII(input, output);
     return NS_OK;
 }
 
 void
 NS_StartupNativeCharsetUtils()
--- a/xpcom/io/nsNativeCharsetUtils.h
+++ b/xpcom/io/nsNativeCharsetUtils.h
@@ -49,34 +49,34 @@
  *    for converting *FILENAMES* between native and unicode. They are not    *
  *    designed or tested for general encoding converter use.                 *
  *                                                                           *
 \*****************************************************************************/
 
 /**
  * thread-safe conversion routines that do not depend on uconv libraries.
  */
-NS_COM nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString  &output);
-NS_COM nsresult NS_CopyUnicodeToNative(const nsAString  &input, nsACString &output);
+nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString  &output);
+nsresult NS_CopyUnicodeToNative(const nsAString  &input, nsACString &output);
 
 /* 
  * This function indicates whether the character encoding used in the file
  * system (more exactly what's used for |GetNativeFoo| and |SetNativeFoo|
  * of |nsILocalFile|) is UTF-8 or not. Knowing that helps us avoid an 
  * unncessary encoding conversion in some cases. For instance, to get the leaf
  * name in UTF-8 out of nsILocalFile, we can just use |GetNativeLeafName| rather
  * than using |GetLeafName| and converting the result to UTF-8 if the file 
  * system  encoding is UTF-8.
  * On Unix (but not on Mac OS X), it depends on the locale and is not known
  * in advance (at the compilation time) so that this function needs to be 
  * a real function. On Mac OS X it's always UTF-8 while on Windows 
  * and other platforms (e.g. OS2), it's never UTF-8.  
  */
 #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(ANDROID)
-NS_COM PRBool NS_IsNativeUTF8();
+PRBool NS_IsNativeUTF8();
 #else
 inline PRBool NS_IsNativeUTF8()
 {
 #if defined(XP_MACOSX) || defined(ANDROID)
     return PR_TRUE;
 #else
     return PR_FALSE;
 #endif
--- a/xpcom/io/nsPipe3.cpp
+++ b/xpcom/io/nsPipe3.cpp
@@ -1253,17 +1253,17 @@ nsPipeOutputStream::AsyncWait(nsIOutputS
             mCallbackFlags = flags;
         }
     }
     return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 
-NS_COM nsresult
+nsresult
 NS_NewPipe(nsIInputStream **pipeIn,
            nsIOutputStream **pipeOut,
            PRUint32 segmentSize,
            PRUint32 maxSize,
            PRBool nonBlockingInput,
            PRBool nonBlockingOutput,
            nsIMemory *segmentAlloc)
 {
@@ -1283,17 +1283,17 @@ NS_NewPipe(nsIInputStream **pipeIn,
                               segmentSize, segmentCount, segmentAlloc);
     if (NS_FAILED(rv)) return rv;
 
     *pipeIn = in;
     *pipeOut = out;
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_NewPipe2(nsIAsyncInputStream **pipeIn,
             nsIAsyncOutputStream **pipeOut,
             PRBool nonBlockingInput,
             PRBool nonBlockingOutput,
             PRUint32 segmentSize,
             PRUint32 segmentCount,
             nsIMemory *segmentAlloc)
 {
--- a/xpcom/io/nsSegmentedBuffer.cpp
+++ b/xpcom/io/nsSegmentedBuffer.cpp
@@ -163,17 +163,17 @@ nsSegmentedBuffer::Empty()
         nsMemory::Free(mSegmentArray);
         mSegmentArray = nsnull;
     }
     mSegmentArrayCount = NS_SEGMENTARRAY_INITIAL_COUNT;
     mFirstSegmentIndex = mLastSegmentIndex = 0;
 }
 
 #if 0
-NS_COM void
+void
 TestSegmentedBuffer()
 {
     nsSegmentedBuffer* buf = new nsSegmentedBuffer();
     NS_ASSERTION(buf, "out of memory");
     buf->Init(4, 16);
     char* seg;
     PRBool empty;
     seg = buf->AppendNewSegment();
--- a/xpcom/io/nsSegmentedBuffer.h
+++ b/xpcom/io/nsSegmentedBuffer.h
@@ -51,32 +51,32 @@ public:
           mFirstSegmentIndex(0), mLastSegmentIndex(0) {}
 
     ~nsSegmentedBuffer() {
         Empty();
         NS_IF_RELEASE(mSegAllocator);
     }
 
 
-    NS_COM nsresult Init(PRUint32 segmentSize, PRUint32 maxSize,
+    nsresult Init(PRUint32 segmentSize, PRUint32 maxSize,
                   nsIMemory* allocator = nsnull);
 
-    NS_COM char* AppendNewSegment();   // pushes at end
+    char* AppendNewSegment();   // pushes at end
 
     // returns true if no more segments remain:
     PRBool DeleteFirstSegment();  // pops from beginning
 
     // returns true if no more segments remain:
     PRBool DeleteLastSegment();  // pops from beginning
 
     // Call Realloc() on last segment.  This is used to reduce memory
     // consumption when data is not an exact multiple of segment size.
     PRBool ReallocLastSegment(size_t newSize);
 
-    NS_COM void Empty();               // frees all segments
+    void Empty();               // frees all segments
 
     inline PRUint32 GetSegmentCount() {
         if (mFirstSegmentIndex <= mLastSegmentIndex)
             return mLastSegmentIndex - mFirstSegmentIndex;
         else 
             return mSegmentArrayCount + mLastSegmentIndex - mFirstSegmentIndex;
     }
 
--- a/xpcom/io/nsStorageStream.cpp
+++ b/xpcom/io/nsStorageStream.cpp
@@ -538,17 +538,17 @@ nsStorageInputStream::Seek(PRUint32 aPos
     mReadCursor = mStorageStream->mSegmentedBuffer->GetSegment(mSegmentNum) +
         segmentOffset;
     PRUint32 available = length - aPosition;
     mSegmentEnd = mReadCursor + NS_MIN(mSegmentSize - segmentOffset, available);
     mLogicalCursor = aPosition;
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_NewStorageStream(PRUint32 segmentSize, PRUint32 maxSize, nsIStorageStream **result)
 {
     NS_ENSURE_ARG(result);
 
     nsStorageStream* storageStream = new nsStorageStream();
     if (!storageStream) return NS_ERROR_OUT_OF_MEMORY;
     
     NS_ADDREF(storageStream);
--- a/xpcom/io/nsStreamUtils.cpp
+++ b/xpcom/io/nsStreamUtils.cpp
@@ -202,31 +202,31 @@ private:
     nsCOMPtr<nsIEventTarget>          mTarget;
 };
 
 NS_IMPL_THREADSAFE_ISUPPORTS2(nsOutputStreamReadyEvent, nsIRunnable,
                               nsIOutputStreamCallback)
 
 //-----------------------------------------------------------------------------
 
-NS_COM nsresult
+nsresult
 NS_NewInputStreamReadyEvent(nsIInputStreamCallback **event,
                             nsIInputStreamCallback *callback,
                             nsIEventTarget *target)
 {
     NS_ASSERTION(callback, "null callback");
     NS_ASSERTION(target, "null target");
     nsInputStreamReadyEvent *ev = new nsInputStreamReadyEvent(callback, target);
     if (!ev)
         return NS_ERROR_OUT_OF_MEMORY;
     NS_ADDREF(*event = ev);
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_NewOutputStreamReadyEvent(nsIOutputStreamCallback **event,
                              nsIOutputStreamCallback *callback,
                              nsIEventTarget *target)
 {
     NS_ASSERTION(callback, "null callback");
     NS_ASSERTION(target, "null target");
     nsOutputStreamReadyEvent *ev = new nsOutputStreamReadyEvent(callback, target);
     if (!ev)
@@ -579,17 +579,17 @@ public:
             mSink->WriteSegments(FillOutputBuffer, &state, mChunkSize, &n);
         *sourceCondition = state.mSourceCondition;
         return n;
     }
 };
 
 //-----------------------------------------------------------------------------
 
-NS_COM nsresult
+nsresult
 NS_AsyncCopy(nsIInputStream         *source,
              nsIOutputStream        *sink,
              nsIEventTarget         *target,
              nsAsyncCopyMode         mode,
              PRUint32                chunkSize,
              nsAsyncCopyCallbackFun  callback,
              void                   *closure,
              PRBool                  closeSource,
@@ -621,27 +621,27 @@ NS_AsyncCopy(nsIInputStream         *sou
     }
     NS_RELEASE(copier);
 
     return rv;
 }
 
 //-----------------------------------------------------------------------------
 
-NS_COM nsresult
+nsresult
 NS_CancelAsyncCopy(nsISupports *aCopierCtx, nsresult aReason)
 {
   nsAStreamCopier *copier = static_cast<nsAStreamCopier *>(
                             static_cast<nsIRunnable *>(aCopierCtx));
   return copier->Cancel(aReason);
 }
 
 //-----------------------------------------------------------------------------
 
-NS_COM nsresult
+nsresult
 NS_ConsumeStream(nsIInputStream *stream, PRUint32 maxCount, nsACString &result)
 {
     nsresult rv = NS_OK;
     result.Truncate();
 
     while (maxCount) {
         PRUint32 avail;
         rv = stream->Available(&avail);
@@ -686,17 +686,17 @@ TestInputStream(nsIInputStream *inStr,
                 PRUint32 count,
                 PRUint32 *countWritten)
 {
     PRBool *result = static_cast<PRBool *>(closure);
     *result = PR_TRUE;
     return NS_ERROR_ABORT;  // don't call me anymore
 }
 
-NS_COM PRBool
+PRBool
 NS_InputStreamIsBuffered(nsIInputStream *stream)
 {
     PRBool result = PR_FALSE;
     PRUint32 n;
     nsresult rv = stream->ReadSegments(TestInputStream,
                                        &result, 1, &n);
     return result || NS_SUCCEEDED(rv);
 }
@@ -709,28 +709,28 @@ TestOutputStream(nsIOutputStream *outStr
                  PRUint32 count,
                  PRUint32 *countRead)
 {
     PRBool *result = static_cast<PRBool *>(closure);
     *result = PR_TRUE;
     return NS_ERROR_ABORT;  // don't call me anymore
 }
 
-NS_COM PRBool
+PRBool
 NS_OutputStreamIsBuffered(nsIOutputStream *stream)
 {
     PRBool result = PR_FALSE;
     PRUint32 n;
     stream->WriteSegments(TestOutputStream, &result, 1, &n);
     return result;
 }
 
 //-----------------------------------------------------------------------------
 
-NS_COM NS_METHOD
+NS_METHOD
 NS_CopySegmentToStream(nsIInputStream *inStr,
                        void *closure,
                        const char *buffer,
                        PRUint32 offset,
                        PRUint32 count,
                        PRUint32 *countWritten)
 {
     nsIOutputStream *outStr = static_cast<nsIOutputStream *>(closure);
@@ -742,45 +742,45 @@ NS_CopySegmentToStream(nsIInputStream *i
             return rv;
         buffer += n;
         count -= n;
         *countWritten += n;
     }
     return NS_OK;
 }
 
-NS_COM NS_METHOD
+NS_METHOD
 NS_CopySegmentToBuffer(nsIInputStream *inStr,
                        void *closure,
                        const char *buffer,
                        PRUint32 offset,
                        PRUint32 count,
                        PRUint32 *countWritten)
 {
     char *toBuf = static_cast<char *>(closure);
     memcpy(&toBuf[offset], buffer, count);
     *countWritten = count;
     return NS_OK;
 }
 
-NS_COM NS_METHOD
+NS_METHOD
 NS_DiscardSegment(nsIInputStream *inStr,
                   void *closure,
                   const char *buffer,
                   PRUint32 offset,
                   PRUint32 count,
                   PRUint32 *countWritten)
 {
     *countWritten = count;
     return NS_OK;
 }
 
 //-----------------------------------------------------------------------------
 
-NS_COM NS_METHOD
+NS_METHOD
 NS_WriteSegmentThunk(nsIInputStream *inStr,
                      void *closure,
                      const char *buffer,
                      PRUint32 offset,
                      PRUint32 count,
                      PRUint32 *countWritten)
 {
     nsWriteSegmentThunk *thunk = static_cast<nsWriteSegmentThunk *>(closure);
--- a/xpcom/io/nsStreamUtils.h
+++ b/xpcom/io/nsStreamUtils.h
@@ -51,32 +51,32 @@ class nsIEventTarget;
  * proxy object's OnInputStreamReady function may only be called once!  The
  * proxy object ensures that the real notify object will be free'd on the
  * thread corresponding to the given event target regardless of what thread
  * the proxy object is destroyed on.
  *
  * This function is designed to be used to implement AsyncWait when the
  * aTarget parameter is non-null.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_NewInputStreamReadyEvent(nsIInputStreamCallback **aEvent,
                             nsIInputStreamCallback  *aNotify,
                             nsIEventTarget          *aTarget);
 
 /**
  * A "one-shot" proxy of the OnOutputStreamReady callback.  The resulting
  * proxy object's OnOutputStreamReady function may only be called once!  The
  * proxy object ensures that the real notify object will be free'd on the
  * thread corresponding to the given event target regardless of what thread 
  * the proxy object is destroyed on.
  *
  * This function is designed to be used to implement AsyncWait when the
  * aTarget parameter is non-null.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_NewOutputStreamReadyEvent(nsIOutputStreamCallback **aEvent,
                              nsIOutputStreamCallback  *aNotify,
                              nsIEventTarget           *aTarget);
 
 /* ------------------------------------------------------------------------- */
 
 enum nsAsyncCopyMode {
     NS_ASYNCCOPY_VIA_READSEGMENTS,
@@ -100,17 +100,17 @@ typedef void (* nsAsyncCopyCallbackFun)(
  * to determine when to resume copying.
  *
  * Source and sink are closed by default when copying finishes or when error
  * occurs. Caller can prevent closing source or sink by setting aCloseSource
  * or aCloseSink to PR_FALSE.
  *
  * Caller can obtain aCopierCtx to be able to cancel copying.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_AsyncCopy(nsIInputStream         *aSource,
              nsIOutputStream        *aSink,
              nsIEventTarget         *aTarget,
              nsAsyncCopyMode         aMode = NS_ASYNCCOPY_VIA_READSEGMENTS,
              PRUint32                aChunkSize = 4096,
              nsAsyncCopyCallbackFun  aCallbackFun = nsnull,
              void                   *aCallbackClosure = nsnull,
              PRBool                  aCloseSource = PR_TRUE,
@@ -121,17 +121,17 @@ NS_AsyncCopy(nsIInputStream         *aSo
  * This function cancels copying started by function NS_AsyncCopy.
  *
  * @param aCopierCtx
  *        Copier context returned by NS_AsyncCopy.
  * @param aReason
  *        A failure code indicating why the operation is being canceled.
  *        It is an error to pass a success code.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_CancelAsyncCopy(nsISupports *aCopierCtx, nsresult aReason);
 
 /**
  * This function copies all of the available data from the stream (up to at
  * most aMaxCount bytes) into the given buffer.  The buffer is truncated at
  * the start of the function.
  *
  * If an error occurs while reading from the stream or while attempting to
@@ -147,101 +147,101 @@ NS_CancelAsyncCopy(nsISupports *aCopierC
  *        The maximum number of bytes to consume from the stream.  Pass the
  *        value PR_UINT32_MAX to consume the entire stream.  The number of
  *        bytes actually read is given by the length of aBuffer upon return.
  * @param aBuffer
  *        The string object that will contain the stream data upon return.
  *        Note: The data copied to the string may contain null bytes and may
  *        contain non-ASCII values.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_ConsumeStream(nsIInputStream *aSource, PRUint32 aMaxCount,
                  nsACString &aBuffer);
 
 /**
  * This function tests whether or not the input stream is buffered.  A buffered
  * input stream is one that implements readSegments.  The test for this is to
  * simply call readSegments, without actually consuming any data from the
  * stream, to verify that it functions.
  *
  * NOTE: If the stream is non-blocking and has no data available yet, then this
  * test will fail.  In that case, we return false even though the test is not 
  * really conclusive.
  *
  * @param aInputStream
  *        The input stream to test.
  */
-extern NS_COM PRBool
+extern PRBool
 NS_InputStreamIsBuffered(nsIInputStream *aInputStream);
 
 /**
  * This function tests whether or not the output stream is buffered.  A
  * buffered output stream is one that implements writeSegments.  The test for
  * this is to simply call writeSegments, without actually writing any data into
  * the stream, to verify that it functions.
  *
  * NOTE: If the stream is non-blocking and has no available space yet, then
  * this test will fail.  In that case, we return false even though the test is
  * not really conclusive.
  *
  * @param aOutputStream
  *        The output stream to test.
  */
-extern NS_COM PRBool
+extern PRBool
 NS_OutputStreamIsBuffered(nsIOutputStream *aOutputStream);
 
 /**
  * This function is intended to be passed to nsIInputStream::ReadSegments to
  * copy data from the nsIInputStream into a nsIOutputStream passed as the
  * aClosure parameter to the ReadSegments function.
  *
  * @see nsIInputStream.idl for a description of this function's parameters.
  */
-extern NS_COM NS_METHOD
+extern NS_METHOD
 NS_CopySegmentToStream(nsIInputStream *aInputStream, void *aClosure,
                        const char *aFromSegment, PRUint32 aToOffset,
                        PRUint32 aCount, PRUint32 *aWriteCount);
 
 /**
  * This function is intended to be passed to nsIInputStream::ReadSegments to
  * copy data from the nsIInputStream into a character buffer passed as the
  * aClosure parameter to the ReadSegments function.  The character buffer
  * must be at least as large as the aCount parameter passed to ReadSegments.
  *
  * @see nsIInputStream.idl for a description of this function's parameters.
  */
-extern NS_COM NS_METHOD
+extern NS_METHOD
 NS_CopySegmentToBuffer(nsIInputStream *aInputStream, void *aClosure,
                        const char *aFromSegment, PRUint32 aToOffset,
                        PRUint32 aCount, PRUint32 *aWriteCount);
 
 /**
  * This function is intended to be passed to nsIInputStream::ReadSegments to
  * discard data from the nsIInputStream.  This can be used to efficiently read
  * data from the stream without actually copying any bytes.
  *
  * @see nsIInputStream.idl for a description of this function's parameters.
  */
-extern NS_COM NS_METHOD
+extern NS_METHOD
 NS_DiscardSegment(nsIInputStream *aInputStream, void *aClosure,
                   const char *aFromSegment, PRUint32 aToOffset,
                   PRUint32 aCount, PRUint32 *aWriteCount);
 
 /**
  * This function is intended to be passed to nsIInputStream::ReadSegments to
  * adjust the aInputStream parameter passed to a consumer's WriteSegmentFun.
  * The aClosure parameter must be a pointer to a nsWriteSegmentThunk object.
  * The mStream and mClosure members of that object will be passed to the mFun
  * function, with the remainder of the parameters being what are passed to
  * NS_WriteSegmentThunk.
  *
  * This function comes in handy when implementing ReadSegments in terms of an
  * inner stream's ReadSegments.
  */
-extern NS_COM NS_METHOD
+extern NS_METHOD
 NS_WriteSegmentThunk(nsIInputStream *aInputStream, void *aClosure,
                      const char *aFromSegment, PRUint32 aToOffset,
                      PRUint32 aCount, PRUint32 *aWriteCount);
 
 struct nsWriteSegmentThunk {
   nsIInputStream    *mStream;
   nsWriteSegmentFun  mFun;
   void              *mClosure;
--- a/xpcom/io/nsStringStream.cpp
+++ b/xpcom/io/nsStringStream.cpp
@@ -382,17 +382,17 @@ nsStringInputStream::Write(IPC::Message 
     using IPC::WriteParam;
 
     nsCAutoString value;
     GetData(value);
 
     WriteParam(aMsg, value);
 }
 
-NS_COM nsresult
+nsresult
 NS_NewByteInputStream(nsIInputStream** aStreamResult,
                       const char* aStringToRead, PRInt32 aLength,
                       nsAssignmentType aAssignment)
 {
     NS_PRECONDITION(aStreamResult, "null out ptr");
 
     nsStringInputStream* stream = new nsStringInputStream();
     if (! stream)
@@ -420,33 +420,33 @@ NS_NewByteInputStream(nsIInputStream** a
         NS_RELEASE(stream);
         return rv;
     }
     
     *aStreamResult = stream;
     return NS_OK;
 }
 
-NS_COM nsresult
+nsresult
 NS_NewStringInputStream(nsIInputStream** aStreamResult,
                         const nsAString& aStringToRead)
 {
     char* data = ToNewCString(aStringToRead);  // truncates high-order bytes
     if (!data)
         return NS_ERROR_OUT_OF_MEMORY;
 
     nsresult rv = NS_NewByteInputStream(aStreamResult, data,
                                         aStringToRead.Length(),
                                         NS_ASSIGNMENT_ADOPT);
     if (NS_FAILED(rv))
         NS_Free(data);
     return rv;
 }
 
-NS_COM nsresult
+nsresult
 NS_NewCStringInputStream(nsIInputStream** aStreamResult,
                          const nsACString& aStringToRead)
 {
     nsACString::const_iterator data;
     aStringToRead.BeginReading(data);
 
     return NS_NewByteInputStream(aStreamResult, data.get(), data.size_forward(),
                                  NS_ASSIGNMENT_COPY);
--- a/xpcom/io/nsStringStream.h
+++ b/xpcom/io/nsStringStream.h
@@ -75,34 +75,34 @@
  *
  * If aAssignment is NS_ASSIGNMENT_ADOPT, then the resulting stream refers
  * directly to the given buffer (aStringToRead) and will free aStringToRead
  * once the stream is closed.
  *
  * If aLength is less than zero, then the length of aStringToRead will be
  * determined by scanning the buffer for the first null byte.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_NewByteInputStream(nsIInputStream** aStreamResult,
                       const char* aStringToRead, PRInt32 aLength = -1,
                       nsAssignmentType aAssignment = NS_ASSIGNMENT_DEPEND);
 
 /**
  * Factory method to get an nsInputStream from an nsAString.  Result will
  * implement nsIStringInputStream and nsISeekableStream.
  *
  * The given string data will be converted to a single-byte data buffer via
  * truncation (i.e., the high-order byte of each character will be discarded).
  * This could result in data-loss, so be careful when using this function.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_NewStringInputStream(nsIInputStream** aStreamResult,
                         const nsAString& aStringToRead);
 
 /**
  * Factory method to get an nsInputStream from an nsACString.  Result will
  * implement nsIStringInputStream and nsISeekableStream.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_NewCStringInputStream(nsIInputStream** aStreamResult,
                          const nsACString& aStringToRead);
 
 #endif // nsStringStream_h__
--- a/xpcom/io/nsUnicharInputStream.h
+++ b/xpcom/io/nsUnicharInputStream.h
@@ -51,15 +51,15 @@ class nsSimpleUnicharStreamFactory :
   private nsISimpleUnicharStreamFactory
 {
 public:
   nsSimpleUnicharStreamFactory() {}
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_NSIFACTORY
   NS_DECL_NSISIMPLEUNICHARSTREAMFACTORY
 
-  static NS_COM nsSimpleUnicharStreamFactory* GetInstance();
+  static nsSimpleUnicharStreamFactory* GetInstance();
 
 private:
   static const nsSimpleUnicharStreamFactory kInstance;
 };
 
 #endif // nsUnicharInputStream_h__
--- a/xpcom/io/nsWildCard.cpp
+++ b/xpcom/io/nsWildCard.cpp
@@ -165,23 +165,23 @@ static int
 template<class T>
 int
 NS_WildCardValid_(const T *expr)
 {
     int x = ::_valid_subexp(expr, T('\0'), T('\0'));
     return (x < 0 ? x : VALID_SXP);
 }
 
-NS_COM int
+int
 NS_WildCardValid(const char *expr)
 {
     return NS_WildCardValid_(expr);
 }
 
-NS_COM int
+int
 NS_WildCardValid(const PRUnichar *expr)
 {
     return NS_WildCardValid_(expr);
 }
 
 /* ----------------------------- _shexp_match ----------------------------- */
 
 
@@ -439,33 +439,33 @@ ns_WildCardMatch(const T *str, const T *
     if (ret == MATCH)
         ret = ::_shexp_match(str, expr, case_insensitive, 0);
 
     NS_Free(expr);
     return ret;
 }
 
 template<class T>
-NS_COM int
+int
 NS_WildCardMatch_(const T *str, const T *expr, PRBool case_insensitive)
 {
     int is_valid = NS_WildCardValid(expr);
     switch(is_valid) {
         case INVALID_SXP:
             return -1;
         default:
             return ::ns_WildCardMatch(str, expr, case_insensitive);
     }
 }
 
-NS_COM int
+int
 NS_WildCardMatch(const char *str, const char *xp,
                  PRBool case_insensitive)
 {
     return NS_WildCardMatch_(str, xp, case_insensitive);
 }
 
-NS_COM int
+int
 NS_WildCardMatch(const PRUnichar *str, const PRUnichar *xp,
                  PRBool case_insensitive)
 {
     return NS_WildCardMatch_(str, xp, case_insensitive);
 }
--- a/xpcom/io/nsWildCard.h
+++ b/xpcom/io/nsWildCard.h
@@ -65,32 +65,32 @@
  *  INVALID_SXP  if exp is a shell expression, but invalid
  *  VALID_SXP    if exp is a valid shell expression
  */
 
 #define NON_SXP -1
 #define INVALID_SXP -2
 #define VALID_SXP 1
 
-NS_COM int NS_WildCardValid(const char *expr);
+int NS_WildCardValid(const char *expr);
 
-NS_COM int NS_WildCardValid(const PRUnichar *expr);
+int NS_WildCardValid(const PRUnichar *expr);
 
 /* return values for the search routines */
 #define MATCH 0
 #define NOMATCH 1
 #define ABORTED -1
 
 /*
  * NS_WildCardMatch
  *
  * Takes a prevalidated shell expression exp, and a string str.
  *
  * Returns 0 on match and 1 on non-match.
  */
 
-NS_COM int NS_WildCardMatch(const char *str, const char *expr,
+int NS_WildCardMatch(const char *str, const char *expr,
                             PRBool case_insensitive);
 
-NS_COM int NS_WildCardMatch(const PRUnichar *str, const PRUnichar *expr,
+int NS_WildCardMatch(const PRUnichar *str, const PRUnichar *expr,
                             PRBool case_insensitive);
 
 #endif /* nsWildCard_h__ */
--- a/xpcom/proxy/public/nsIProxyObjectManager.idl
+++ b/xpcom/proxy/public/nsIProxyObjectManager.idl
@@ -132,13 +132,13 @@ interface nsIProxyObjectManager : nsISup
 #ifdef MOZILLA_INTERNAL_API
 /**
  * Helper function for code that already has a link-time dependency on the
  * internal API (MOZILLA_INTERNAL_API) and needs to get proxies in a bunch of
  * different places.  This way, the caller isn't forced to get the proxy object
  * manager themselves every single time, thus making the calling code more
  * readable.  The parameters are the same as for GetProxyForObject.
  */
-extern NS_COM nsresult
+extern nsresult
 NS_GetProxyForObject(nsIEventTarget *target, REFNSIID iid, nsISupports* object,
                      PRInt32 proxyType, void** result);
 #endif
 %}
--- a/xpcom/proxy/src/nsProxyObjectManager.cpp
+++ b/xpcom/proxy/src/nsProxyObjectManager.cpp
@@ -321,17 +321,17 @@ nsProxyObjectManager::GetClass(REFNSIID 
 
 /**
  * Helper function for code that already has a link-time dependency on
  * libxpcom and needs to get proxies in a bunch of different places.
  * This way, the caller isn't forced to get the proxy object manager
  * themselves every single time, thus making the calling code more
  * readable.
  */
-NS_COM nsresult
+nsresult
 NS_GetProxyForObject(nsIEventTarget *target, 
                      REFNSIID aIID, 
                      nsISupports* aObj, 
                      PRInt32 proxyType, 
                      void** aProxyObject) 
 {
     static NS_DEFINE_CID(proxyObjMgrCID, NS_PROXYEVENT_MANAGER_CID);
 
--- a/xpcom/string/public/nsAString.h
+++ b/xpcom/string/public/nsAString.h
@@ -69,17 +69,17 @@
 #include "nsTSubstring.h"
 #include "string-template-undef.h"
 
 
   /**
    * ASCII case-insensitive comparator.  (for Unicode case-insensitive
    * comparision, see nsUnicharUtils.h)
    */
-class NS_COM nsCaseInsensitiveCStringComparator
+class nsCaseInsensitiveCStringComparator
     : public nsCStringComparator
   {
     public:
       nsCaseInsensitiveCStringComparator() {}
       typedef char char_type;
 
       virtual int operator()( const char_type*, const char_type*, PRUint32, PRUint32 ) const;
   };
--- a/xpcom/string/public/nsCharTraits.h
+++ b/xpcom/string/public/nsCharTraits.h
@@ -146,17 +146,17 @@ template <class CharT> struct nsCharTrai
 
 NS_SPECIALIZE_TEMPLATE
 struct nsCharTraits<PRUnichar>
   {
     typedef PRUnichar char_type;
     typedef PRUint16  unsigned_char_type;
     typedef char      incompatible_char_type;
 
-    NS_COM static char_type *sEmptyBuffer;
+    static char_type *sEmptyBuffer;
 
     static
     void
     assign( char_type& lhs, char_type rhs )
       {
         lhs = rhs;
       }
 
@@ -436,17 +436,17 @@ struct nsCharTraits<PRUnichar>
 
 NS_SPECIALIZE_TEMPLATE
 struct nsCharTraits<char>
   {
     typedef char           char_type;
     typedef unsigned char  unsigned_char_type;
     typedef PRUnichar      incompatible_char_type;
 
-    NS_COM static char_type *sEmptyBuffer;
+    static char_type *sEmptyBuffer;
 
     static
     void
     assign( char_type& lhs, char_type rhs )
       {
         lhs = rhs;
       }
 
--- a/xpcom/string/public/nsPrintfCString.h
+++ b/xpcom/string/public/nsPrintfCString.h
@@ -62,17 +62,17 @@
    * to get a wide version of your formatted data, you must, e.g.,
    *
    *   CopyASCIItoUTF16(nsPrintfCString("%f", 13.917"), myStr);
    *
    * That's another good reason to avoid this class for anything but numbers ... as strings can be
    * much more efficiently handled with |NS_LITERAL_[C]STRING| and |nsLiteral[C]String|.
    */
 
-class NS_COM nsPrintfCString : public nsCString
+class nsPrintfCString : public nsCString
   {
     typedef nsCString string_type;
 
     enum { kLocalBufferSize=15 };
       // ought to be large enough for most things ... a |long long| needs at most 20 (so you'd better ask)
       //  pinkerton suggests 7.  We should measure and decide what's appropriate
 
     public:
--- a/xpcom/string/public/nsReadableUtils.h
+++ b/xpcom/string/public/nsReadableUtils.h
@@ -54,189 +54,188 @@ inline size_t Distance( const nsReadingI
   {
     return end.get() - start.get();
   }
 inline size_t Distance( const nsReadingIterator<char>& start, const nsReadingIterator<char>& end )
   {
     return end.get() - start.get();
   }
 
-NS_COM void LossyCopyUTF16toASCII( const nsAString& aSource, nsACString& aDest NS_OUTPARAM );
-NS_COM void CopyASCIItoUTF16( const nsACString& aSource, nsAString& aDest NS_OUTPARAM );
+void LossyCopyUTF16toASCII( const nsAString& aSource, nsACString& aDest NS_OUTPARAM );
+void CopyASCIItoUTF16( const nsACString& aSource, nsAString& aDest NS_OUTPARAM );
 
-NS_COM void LossyCopyUTF16toASCII( const PRUnichar* aSource, nsACString& aDest NS_OUTPARAM );
-NS_COM void CopyASCIItoUTF16( const char* aSource, nsAString& aDest NS_OUTPARAM );
+void LossyCopyUTF16toASCII( const PRUnichar* aSource, nsACString& aDest NS_OUTPARAM );
+void CopyASCIItoUTF16( const char* aSource, nsAString& aDest NS_OUTPARAM );
 
-NS_COM void CopyUTF16toUTF8( const nsAString& aSource, nsACString& aDest NS_OUTPARAM );
-NS_COM void CopyUTF8toUTF16( const nsACString& aSource, nsAString& aDest NS_OUTPARAM );
+void CopyUTF16toUTF8( const nsAString& aSource, nsACString& aDest NS_OUTPARAM );
+void CopyUTF8toUTF16( const nsACString& aSource, nsAString& aDest NS_OUTPARAM );
 
-NS_COM void CopyUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest NS_OUTPARAM );
-NS_COM void CopyUTF8toUTF16( const char* aSource, nsAString& aDest NS_OUTPARAM );
+void CopyUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest NS_OUTPARAM );
+void CopyUTF8toUTF16( const char* aSource, nsAString& aDest NS_OUTPARAM );
 
-NS_COM void LossyAppendUTF16toASCII( const nsAString& aSource, nsACString& aDest );
-NS_COM void AppendASCIItoUTF16( const nsACString& aSource, nsAString& aDest );
+void LossyAppendUTF16toASCII( const nsAString& aSource, nsACString& aDest );
+void AppendASCIItoUTF16( const nsACString& aSource, nsAString& aDest );
 
-NS_COM void LossyAppendUTF16toASCII( const PRUnichar* aSource, nsACString& aDest );
-NS_COM void AppendASCIItoUTF16( const char* aSource, nsAString& aDest );
+void LossyAppendUTF16toASCII( const PRUnichar* aSource, nsACString& aDest );
+void AppendASCIItoUTF16( const char* aSource, nsAString& aDest );
 
-NS_COM void AppendUTF16toUTF8( const nsAString& aSource, nsACString& aDest );
-NS_COM void AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest );
+void AppendUTF16toUTF8( const nsAString& aSource, nsACString& aDest );
+void AppendUTF8toUTF16( const nsACString& aSource, nsAString& aDest );
 
-NS_COM void AppendUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest );
-NS_COM void AppendUTF8toUTF16( const char* aSource, nsAString& aDest );
+void AppendUTF16toUTF8( const PRUnichar* aSource, nsACString& aDest );
+void AppendUTF8toUTF16( const char* aSource, nsAString& aDest );
 
   /**
    * Returns a new |char| buffer containing a zero-terminated copy of |aSource|.
    *
    * Allocates and returns a new |char| buffer which you must free with |nsMemory::Free|.
    * Performs a lossy encoding conversion by chopping 16-bit wide characters down to 8-bits wide while copying |aSource| to your new buffer.
    * This conversion is not well defined; but it reproduces legacy string behavior.
    * The new buffer is zero-terminated, but that may not help you if |aSource| contains embedded nulls.
    *
    * @param aSource a 16-bit wide string
    * @return a new |char| buffer you must free with |nsMemory::Free|.
    */
-NS_COM char* ToNewCString( const nsAString& aSource );
+char* ToNewCString( const nsAString& aSource );
 
 
   /**
    * Returns a new |char| buffer containing a zero-terminated copy of |aSource|.
    *
    * Allocates and returns a new |char| buffer which you must free with |nsMemory::Free|.
    * The new buffer is zero-terminated, but that may not help you if |aSource| contains embedded nulls.
    *
    * @param aSource an 8-bit wide string
    * @return a new |char| buffer you must free with |nsMemory::Free|.
    */
-NS_COM char* ToNewCString( const nsACString& aSource );
+char* ToNewCString( const nsACString& aSource );
 
   /**
    * Returns a new |char| buffer containing a zero-terminated copy of |aSource|.
    *
    * Allocates and returns a new |char| buffer which you must free with 
    * |nsMemory::Free|.
    * Performs an encoding conversion from a UTF-16 string to a UTF-8 string
    * copying |aSource| to your new buffer.
    * The new buffer is zero-terminated, but that may not help you if |aSource| 
    * contains embedded nulls.
    *
    * @param aSource a UTF-16 string (made of PRUnichar's)
    * @param aUTF8Count the number of 8-bit units that was returned
    * @return a new |char| buffer you must free with |nsMemory::Free|.
    */
 
-NS_COM char* ToNewUTF8String( const nsAString& aSource, PRUint32 *aUTF8Count = nsnull );
+char* ToNewUTF8String( const nsAString& aSource, PRUint32 *aUTF8Count = nsnull );
 
 
   /**
    * Returns a new |PRUnichar| buffer containing a zero-terminated copy of 
    * |aSource|.
    *
    * Allocates and returns a new |PRUnichar| buffer which you must free with 
    * |nsMemory::Free|.
    * The new buffer is zero-terminated, but that may not help you if |aSource| 
    * contains embedded nulls.
    *
    * @param aSource a UTF-16 string
    * @return a new |PRUnichar| buffer you must free with |nsMemory::Free|.
    */
-NS_COM PRUnichar* ToNewUnicode( const nsAString& aSource );
+PRUnichar* ToNewUnicode( const nsAString& aSource );
 
 
   /**
    * Returns a new |PRUnichar| buffer containing a zero-terminated copy of |aSource|.
    *
    * Allocates and returns a new |PRUnichar| buffer which you must free with |nsMemory::Free|.
    * Performs an encoding conversion by 0-padding 8-bit wide characters up to 16-bits wide while copying |aSource| to your new buffer.
    * This conversion is not well defined; but it reproduces legacy string behavior.
    * The new buffer is zero-terminated, but that may not help you if |aSource| contains embedded nulls.
    *
    * @param aSource an 8-bit wide string (a C-string, NOT UTF-8)
    * @return a new |PRUnichar| buffer you must free with |nsMemory::Free|.
    */
-NS_COM PRUnichar* ToNewUnicode( const nsACString& aSource );
+PRUnichar* ToNewUnicode( const nsACString& aSource );
 
   /**
    * Returns a new |PRUnichar| buffer containing a zero-terminated copy
    * of |aSource|.
    *
    * Allocates and returns a new |char| buffer which you must free with
    * |nsMemory::Free|.  Performs an encoding conversion from UTF-8 to UTF-16 
    * while copying |aSource| to your new buffer.  This conversion is well defined
    * for a valid UTF-8 string.  The new buffer is zero-terminated, but that 
    * may not help you if |aSource| contains embedded nulls.
    *
    * @param aSource an 8-bit wide string, UTF-8 encoded
    * @param aUTF16Count the number of 16-bit units that was returned
    * @return a new |PRUnichar| buffer you must free with |nsMemory::Free|.
    *         (UTF-16 encoded)
    */
-NS_COM PRUnichar* UTF8ToNewUnicode( const nsACString& aSource, PRUint32 *aUTF16Count = nsnull );
+PRUnichar* UTF8ToNewUnicode( const nsACString& aSource, PRUint32 *aUTF16Count = nsnull );
 
   /**
    * Copies |aLength| 16-bit code units from the start of |aSource| to the
    * |PRUnichar| buffer |aDest|.
    *
    * After this operation |aDest| is not null terminated.
    *
    * @param aSource a UTF-16 string
    * @param aSrcOffset start offset in the source string
    * @param aDest a |PRUnichar| buffer
    * @param aLength the number of 16-bit code units to copy
    * @return pointer to destination buffer - identical to |aDest|
    */
-NS_COM PRUnichar* CopyUnicodeTo( const nsAString& aSource,
+PRUnichar* CopyUnicodeTo( const nsAString& aSource,
                                  PRUint32 aSrcOffset,
                                  PRUnichar* aDest,
                                  PRUint32 aLength );
 
 
   /**
    * Copies 16-bit characters between iterators |aSrcStart| and
    * |aSrcEnd| to the writable string |aDest|. Similar to the
    * |nsString::Mid| method.
    *
    * After this operation |aDest| is not null terminated.
    *
    * @param aSrcStart start source iterator
    * @param aSrcEnd end source iterator
    * @param aDest destination for the copy
    */
-NS_COM void CopyUnicodeTo( const nsAString::const_iterator& aSrcStart,
+void CopyUnicodeTo( const nsAString::const_iterator& aSrcStart,
                            const nsAString::const_iterator& aSrcEnd,
                            nsAString& aDest );
 
   /**
    * Appends 16-bit characters between iterators |aSrcStart| and
    * |aSrcEnd| to the writable string |aDest|. 
    *
    * After this operation |aDest| is not null terminated.
    *
    * @param aSrcStart start source iterator
    * @param aSrcEnd end source iterator
    * @param aDest destination for the copy
    */
-NS_COM void AppendUnicodeTo( const nsAString::const_iterator& aSrcStart,
+void AppendUnicodeTo( const nsAString::const_iterator& aSrcStart,
                              const nsAString::const_iterator& aSrcEnd,
                              nsAString& aDest );
 
   /**
    * Returns |PR_TRUE| if |aString| contains only ASCII characters, that is, characters in the range (0x00, 0x7F).
    *
    * @param aString a 16-bit wide string to scan
    */
-NS_COM PRBool IsASCII( const nsAString& aString );
+PRBool IsASCII( const nsAString& aString );
 
   /**
    * Returns |PR_TRUE| if |aString| contains only ASCII characters, that is, characters in the range (0x00, 0x7F).
    *
    * @param aString a 8-bit wide string to scan
    */
-NS_COM PRBool IsASCII( const nsACString& aString );
-
+PRBool IsASCII( const nsACString& aString );
 
   /**
    * Returns |PR_TRUE| if |aString| is a valid UTF-8 string.
    * XXX This is not bullet-proof and nor an all-purpose UTF-8 validator. 
    * It is mainly written to replace and roughly equivalent to
    *
    *    str.Equals(NS_ConvertUTF16toUTF8(NS_ConvertUTF8toUTF16(str)))
    *
@@ -246,51 +245,51 @@ NS_COM PRBool IsASCII( const nsACString&
    * of surrogate codepoints and non-characters ( 0xFFFE and 0xFFFF
    * in planes 0 through 16.) as well as overlong UTF-8 sequences. 
    * Also note that it regards UTF-8 sequences corresponding to 
    * codepoints above 0x10FFFF as invalid in accordance with 
    * http://www.ietf.org/internet-drafts/draft-yergeau-rfc2279bis-04.txt
    *
    * @param aString an 8-bit wide string to scan
    */
-NS_COM PRBool IsUTF8( const nsACString& aString );
+PRBool IsUTF8( const nsACString& aString );
 
-NS_COM PRBool ParseString(const nsACString& aAstring, char aDelimiter, 
+PRBool ParseString(const nsACString& aAstring, char aDelimiter, 
                           nsTArray<nsCString>& aArray);
 
   /**
    * Converts case in place in the argument string.
    */
-NS_COM void ToUpperCase( nsACString& );
+void ToUpperCase( nsACString& );
 
-NS_COM void ToLowerCase( nsACString& );
+void ToLowerCase( nsACString& );
 
-NS_COM void ToUpperCase( nsCSubstring& );
+void ToUpperCase( nsCSubstring& );
 
-NS_COM void ToLowerCase( nsCSubstring& );
+void ToLowerCase( nsCSubstring& );
 
   /**
    * Converts case from string aSource to aDest.
    */
-NS_COM void ToUpperCase( const nsACString& aSource, nsACString& aDest );
+void ToUpperCase( const nsACString& aSource, nsACString& aDest );
 
-NS_COM void ToLowerCase( const nsACString& aSource, nsACString& aDest );
+void ToLowerCase( const nsACString& aSource, nsACString& aDest );
 
   /**
    * Finds the leftmost occurrence of |aPattern|, if any in the range |aSearchStart|..|aSearchEnd|.
    *
    * Returns |PR_TRUE| if a match was found, and adjusts |aSearchStart| and |aSearchEnd| to
    * point to the match.  If no match was found, returns |PR_FALSE| and makes |aSearchStart == aSearchEnd|.
    *
    * Currently, this is equivalent to the O(m*n) implementation previously on |ns[C]String|.
    * If we need something faster, then we can implement that later.
    */
 
-NS_COM PRBool FindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
-NS_COM PRBool FindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
+PRBool FindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
+PRBool FindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
 
 /* sometimes we don't care about where the string was, just that we
  * found it or not */
 inline PRBool FindInReadable( const nsAString& aPattern, const nsAString& aSource, const nsStringComparator& compare = nsDefaultStringComparator() )
 {
   nsAString::const_iterator start, end;
   aSource.BeginReading(start);
   aSource.EndReading(end);
@@ -301,80 +300,79 @@ inline PRBool FindInReadable( const nsAC
 {
   nsACString::const_iterator start, end;
   aSource.BeginReading(start);
   aSource.EndReading(end);
   return FindInReadable(aPattern, start, end, compare);
 }
 
 
-NS_COM PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator& );
+PRBool CaseInsensitiveFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator& );
 
   /**
    * Finds the rightmost occurrence of |aPattern| 
    * Returns |PR_TRUE| if a match was found, and adjusts |aSearchStart| and |aSearchEnd| to
    * point to the match.  If no match was found, returns |PR_FALSE| and makes |aSearchStart == aSearchEnd|.
    *
    */
-NS_COM PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
-NS_COM PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
+PRBool RFindInReadable( const nsAString& aPattern, nsAString::const_iterator&, nsAString::const_iterator&, const nsStringComparator& = nsDefaultStringComparator() );
+PRBool RFindInReadable( const nsACString& aPattern, nsACString::const_iterator&, nsACString::const_iterator&, const nsCStringComparator& = nsDefaultCStringComparator() );
 
    /**
    * Finds the leftmost occurrence of |aChar|, if any in the range 
    * |aSearchStart|..|aSearchEnd|.
    *
    * Returns |PR_TRUE| if a match was found, and adjusts |aSearchStart| to
    * point to the match.  If no match was found, returns |PR_FALSE| and 
    * makes |aSearchStart == aSearchEnd|.
    */
-NS_COM PRBool FindCharInReadable( PRUnichar aChar, nsAString::const_iterator& aSearchStart, const nsAString::const_iterator& aSearchEnd );
-NS_COM PRBool FindCharInReadable( char aChar, nsACString::const_iterator& aSearchStart, const nsACString::const_iterator& aSearchEnd );
+PRBool FindCharInReadable( PRUnichar aChar, nsAString::const_iterator& aSearchStart, const nsAString::const_iterator& aSearchEnd );
+PRBool FindCharInReadable( char aChar, nsACString::const_iterator& aSearchStart, const nsACString::const_iterator& aSearchEnd );
 
     /**
     * Finds the number of occurences of |aChar| in the string |aStr|
     */
-NS_COM PRUint32 CountCharInReadable( const nsAString& aStr,
+PRUint32 CountCharInReadable( const nsAString& aStr,
                                      PRUnichar aChar );
-NS_COM PRUint32 CountCharInReadable( const nsACString& aStr,
+PRUint32 CountCharInReadable( const nsACString& aStr,
                                      char aChar );
 
-NS_COM PRBool
+PRBool
 StringBeginsWith( const nsAString& aSource, const nsAString& aSubstring,
                   const nsStringComparator& aComparator =
                                               nsDefaultStringComparator() );
-NS_COM PRBool
+PRBool
 StringBeginsWith( const nsACString& aSource, const nsACString& aSubstring,
                   const nsCStringComparator& aComparator =
                                                nsDefaultCStringComparator() );
-NS_COM PRBool
+PRBool
 StringEndsWith( const nsAString& aSource, const nsAString& aSubstring,
                 const nsStringComparator& aComparator =
                                             nsDefaultStringComparator() );
-NS_COM PRBool
+PRBool
 StringEndsWith( const nsACString& aSource, const nsACString& aSubstring,
                 const nsCStringComparator& aComparator =
                                              nsDefaultCStringComparator() );
 
-NS_COM const nsAFlatString& EmptyString();
-NS_COM const nsAFlatCString& EmptyCString();
-
+const nsAFlatString& EmptyString();
+const nsAFlatCString& EmptyCString();
 
    /**
    * Compare a UTF-8 string to an UTF-16 string.
    *
    * Returns 0 if the strings are equal, -1 if aUTF8String is less
    * than aUTF16Count, and 1 in the reverse case.  In case of fatal
    * error (eg the strings are not valid UTF8 and UTF16 respectively),
    * this method will return PR_INT32_MIN.
    */
-NS_COM PRInt32
+PRInt32
 CompareUTF8toUTF16(const nsASingleFragmentCString& aUTF8String,
                    const nsASingleFragmentString& aUTF16String);
 
-NS_COM void
+void
 AppendUCS4ToUTF16(const PRUint32 aSource, nsAString& aDest);
 
 template<class T>
 inline PRBool EnsureStringLength(T& aStr, PRUint32 aLen)
 {
     aStr.SetLength(aLen);
     return (aStr.Length() == aLen);
 }
--- a/xpcom/string/public/nsStringBuffer.h
+++ b/xpcom/string/public/nsStringBuffer.h
@@ -68,41 +68,41 @@ class nsStringBuffer
        * buffer by calling the Data method to fetch the raw data pointer.  Care
        * must be taken to properly null terminate the character array.  The
        * storage size can be greater than the length of the actual string
        * (i.e., it is not required that the null terminator appear in the last
        * storage unit of the string buffer's data).
        *
        * @return new string buffer or null if out of memory.
        */
-      NS_COM static nsStringBuffer* Alloc(size_t storageSize);
+      static nsStringBuffer* Alloc(size_t storageSize);
 
       /**
        * Resizes the given string buffer to the specified storage size.  This
        * method must not be called on a readonly string buffer.  Use this API
        * carefully!!
        *
        * This method behaves like the ANSI-C realloc function.  (i.e., If the
        * allocation fails, null will be returned and the given string buffer
        * will remain unmodified.)
        *
        * @see IsReadonly
        */
-      NS_COM static nsStringBuffer* Realloc(nsStringBuffer* buf, size_t storageSize);
+      static nsStringBuffer* Realloc(nsStringBuffer* buf, size_t storageSize);
 
       /**
        * Increment the reference count on this string buffer.
        */
-      NS_COM void NS_FASTCALL AddRef();
+      void NS_FASTCALL AddRef();
 
       /**
        * Decrement the reference count on this string buffer.  The string
        * buffer will be destroyed when its reference count reaches zero.
        */
-      NS_COM void NS_FASTCALL Release();
+      void NS_FASTCALL Release();
 
       /**
        * This method returns the string buffer corresponding to the given data
        * pointer.  The data pointer must have been returned previously by a
        * call to the nsStringBuffer::Data method.
        */
       static nsStringBuffer* FromData(void* data)
         {
@@ -143,32 +143,32 @@ class nsStringBuffer
       /**
        * The FromString methods return a string buffer for the given string 
        * object or null if the string object does not have a string buffer.
        * The reference count of the string buffer is NOT incremented by these
        * methods.  If the caller wishes to hold onto the returned value, then
        * the returned string buffer must have its reference count incremented
        * via a call to the AddRef method.
        */
-      NS_COM static nsStringBuffer* FromString(const nsAString &str);
-      NS_COM static nsStringBuffer* FromString(const nsACString &str);
+      static nsStringBuffer* FromString(const nsAString &str);
+      static nsStringBuffer* FromString(const nsACString &str);
 
       /**
        * The ToString methods assign this string buffer to a given string
        * object.  If the string object does not support sharable string
        * buffers, then its value will be set to a copy of the given string
        * buffer.  Otherwise, these methods increment the reference count of the
        * given string buffer.  It is important to specify the length (in
        * storage units) of the string contained in the string buffer since the
        * length of the string may be less than its storage size.  The string
        * must have a null terminator at the offset specified by |len|.
        *
        * NOTE: storage size is measured in bytes even for wide strings;
        *       however, string length is always measured in storage units
        *       (2-byte units for wide strings).
        */
-      NS_COM void ToString(PRUint32 len, nsAString &str,
+      void ToString(PRUint32 len, nsAString &str,
                            PRBool aMoveOwnership = PR_FALSE);
-      NS_COM void ToString(PRUint32 len, nsACString &str,
+      void ToString(PRUint32 len, nsACString &str,
                            PRBool aMoveOwnership = PR_FALSE);
   };
 
 #endif /* !defined(nsStringBuffer_h__ */
--- a/xpcom/string/public/nsTDependentString.h
+++ b/xpcom/string/public/nsTDependentString.h
@@ -112,17 +112,17 @@ class nsTDependentString_CharT : public 
          * allow this class to be bound to a different string...
          */
 
       void Rebind( const char_type* data )
         {
           Rebind(data, PRUint32(char_traits::length(data)));
         }
 
-      NS_COM void Rebind( const char_type* data, size_type length );
+      void Rebind( const char_type* data, size_type length );
 
       void Rebind( const char_type* start, const char_type* end )
         {
           Rebind(start, PRUint32(end - start));
         }
 
     private:
       
--- a/xpcom/string/public/nsTDependentSubstring.h
+++ b/xpcom/string/public/nsTDependentSubstring.h
@@ -52,19 +52,19 @@
 class nsTDependentSubstring_CharT : public nsTSubstring_CharT
   {
     public:
 
       typedef nsTDependentSubstring_CharT    self_type;
 
     public:
 
-      NS_COM void Rebind( const substring_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
+      void Rebind( const substring_type&, PRUint32 startPos, PRUint32 length = size_type(-1) );
 
-      NS_COM void Rebind( const char_type* start, const char_type* end );
+      void Rebind( const char_type* start, const char_type* end );
 
       nsTDependentSubstring_CharT( const substring_type& str, PRUint32 startPos, PRUint32 length = size_type(-1) )
         : substring_type()
         {
           Rebind(str, startPos, length);
         }
 
       nsTDependentSubstring_CharT( const char_type* start, const char_type* end )
--- a/xpcom/string/public/nsTPromiseFlatString.h
+++ b/xpcom/string/public/nsTPromiseFlatString.h
@@ -94,17 +94,17 @@
 class nsTPromiseFlatString_CharT : public nsTString_CharT
   {
     public:
 
       typedef nsTPromiseFlatString_CharT    self_type;
 
     private:
 
-      NS_COM void Init( const substring_type& );
+      void Init( const substring_type& );
 
         // NOT TO BE IMPLEMENTED
       void operator=( const self_type& );
 
         // NOT TO BE IMPLEMENTED
       nsTPromiseFlatString_CharT();
 
     public:
--- a/xpcom/string/public/nsTString.h
+++ b/xpcom/string/public/nsTString.h
@@ -145,137 +145,137 @@ class nsTString_CharT : public nsTSubstr
          *  @param   aString is substring to be sought in this
          *  @param   aIgnoreCase selects case sensitivity
          *  @param   aOffset tells us where in this string to start searching
          *  @param   aCount tells us how far from the offset we are to search. Use
          *           -1 to search the whole string.
          *  @return  offset in string, or kNotFound
          */
 
-      NS_COM PRInt32 Find( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
-      NS_COM PRInt32 Find( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
+      PRInt32 Find( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
+      PRInt32 Find( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
 
 #ifdef CharT_is_PRUnichar
-      NS_COM PRInt32 Find( const nsAFlatString& aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
-      NS_COM PRInt32 Find( const PRUnichar* aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
+      PRInt32 Find( const nsAFlatString& aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
+      PRInt32 Find( const PRUnichar* aString, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
 #endif
 
         
         /**
          * This methods scans the string backwards, looking for the given string
          *
          * @param   aString is substring to be sought in this
          * @param   aIgnoreCase tells us whether or not to do caseless compare
          * @param   aOffset tells us where in this string to start searching.
          *          Use -1 to search from the end of the string.
          * @param   aCount tells us how many iterations to make starting at the
          *          given offset.
          * @return  offset in string, or kNotFound
          */
 
-      NS_COM PRInt32 RFind( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
-      NS_COM PRInt32 RFind( const char* aCString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+      PRInt32 RFind( const nsCString& aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+      PRInt32 RFind( const char* aCString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
 
 #ifdef CharT_is_PRUnichar
-      NS_COM PRInt32 RFind( const nsAFlatString& aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
-      NS_COM PRInt32 RFind( const PRUnichar* aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+      PRInt32 RFind( const nsAFlatString& aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+      PRInt32 RFind( const PRUnichar* aString, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
 #endif
 
 
         /**
          *  Search for given char within this string
          *  
          *  @param   aChar is the character to search for
          *  @param   aOffset tells us where in this string to start searching
          *  @param   aCount tells us how far from the offset we are to search.
          *           Use -1 to search the whole string.
          *  @return  offset in string, or kNotFound
          */
 
       // PRInt32 FindChar( PRUnichar aChar, PRInt32 aOffset=0, PRInt32 aCount=-1 ) const;
-      NS_COM PRInt32 RFindChar( PRUnichar aChar, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
+      PRInt32 RFindChar( PRUnichar aChar, PRInt32 aOffset=-1, PRInt32 aCount=-1 ) const;
 
 
         /**
          * This method searches this string for the first character found in
          * the given string.
          *
          * @param aString contains set of chars to be found
          * @param aOffset tells us where in this string to start searching
          *        (counting from left)
          * @return offset in string, or kNotFound
          */
 
-      NS_COM PRInt32 FindCharInSet( const char* aString, PRInt32 aOffset=0 ) const;
+      PRInt32 FindCharInSet( const char* aString, PRInt32 aOffset=0 ) const;
       PRInt32 FindCharInSet( const self_type& aString, PRInt32 aOffset=0 ) const
         {
           return FindCharInSet(aString.get(), aOffset);
         }
 
 #ifdef CharT_is_PRUnichar
-      NS_COM PRInt32 FindCharInSet( const PRUnichar* aString, PRInt32 aOffset=0 ) const;
+      PRInt32 FindCharInSet( const PRUnichar* aString, PRInt32 aOffset=0 ) const;
 #endif
 
 
         /**
          * This method searches this string for the last character found in
          * the given string.
          *
          * @param aString contains set of chars to be found
          * @param aOffset tells us where in this string to start searching
          *        (counting from left)
          * @return offset in string, or kNotFound
          */
 
-      NS_COM PRInt32 RFindCharInSet( const char_type* aString, PRInt32 aOffset=-1 ) const;
+      PRInt32 RFindCharInSet( const char_type* aString, PRInt32 aOffset=-1 ) const;
       PRInt32 RFindCharInSet( const self_type& aString, PRInt32 aOffset=-1 ) const
         {
           return RFindCharInSet(aString.get(), aOffset);
         }
 
 
         /**
          * Compares a given string to this string. 
          *
          * @param   aString is the string to be compared
          * @param   aIgnoreCase tells us how to treat case
          * @param   aCount tells us how many chars to compare
          * @return  -1,0,1
          */
 
 #ifdef CharT_is_char
-      NS_COM PRInt32 Compare( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aCount=-1 ) const;
+      PRInt32 Compare( const char* aString, PRBool aIgnoreCase=PR_FALSE, PRInt32 aCount=-1 ) const;
 #endif
 
 
         /**
          * Equality check between given string and this string.
          *
          * @param   aString is the string to check
          * @param   aIgnoreCase tells us how to treat case
          * @param   aCount tells us how many chars to compare
          * @return  boolean
          */
 #ifdef CharT_is_char
       PRBool EqualsIgnoreCase( const char* aString, PRInt32 aCount=-1 ) const {
         return Compare(aString, PR_TRUE, aCount) == 0;
       }
 #else
-      NS_COM PRBool EqualsIgnoreCase( const char* aString, PRInt32 aCount=-1 ) const;
+      PRBool EqualsIgnoreCase( const char* aString, PRInt32 aCount=-1 ) const;
 
 
 #endif // !CharT_is_PRUnichar
 
         /**
          * Perform string to double-precision float conversion.
          *
          * @param   aErrorCode will contain error if one occurs
          * @return  double-precision float rep of string value
          */
-      NS_COM double ToDouble( PRInt32* aErrorCode ) const;
+      double ToDouble( PRInt32* aErrorCode ) const;
 
         /**
          * Perform string to single-precision float conversion.
          *
          * @param   aErrorCode will contain error if one occurs
          * @return  single-precision float rep of string value
          */
       float ToFloat( PRInt32* aErrorCode ) const {
@@ -284,17 +284,17 @@ class nsTString_CharT : public nsTSubstr
 
 
         /**
          * Perform string to int conversion.
          * @param   aErrorCode will contain error if one occurs
          * @param   aRadix tells us which radix to assume; kAutoDetect tells us to determine the radix for you.
          * @return  int rep of string value, and possible (out) error code
          */
-      NS_COM PRInt32 ToInteger( PRInt32* aErrorCode, PRUint32 aRadix=kRadix10 ) const;
+      PRInt32 ToInteger( PRInt32* aErrorCode, PRUint32 aRadix=kRadix10 ) const;
       PRInt32 ToInteger( nsresult* aErrorCode, PRUint32 aRadix=kRadix10 ) const {
         return ToInteger(reinterpret_cast<PRInt32*>(aErrorCode), aRadix);
       }
 
         /**
          * |Left|, |Mid|, and |Right| are annoying signatures that seem better almost
          * any _other_ way than they are now.  Consider these alternatives
          * 
@@ -306,17 +306,17 @@ class nsTString_CharT : public nsTSubstr
          * 
          * aReadable.Left(aWritable, 17);    // ...a member function that does the assignment
          * 
          * or maybe just stamping them out in favor of |Substring|, they are just duplicate functionality
          *         
          * aWritable = Substring(aReadable, 0, 17);
          */
 
-      NS_COM size_type Mid( self_type& aResult, PRUint32 aStartPos, PRUint32 aCount ) const;
+      size_type Mid( self_type& aResult, PRUint32 aStartPos, PRUint32 aCount ) const;
 
       size_type Left( self_type& aResult, size_type aCount ) const
         {
           return Mid(aResult, 0, aCount);
         }
 
       size_type Right( self_type& aResult, size_type aCount ) const
         {
@@ -328,76 +328,76 @@ class nsTString_CharT : public nsTSubstr
         /**
          * Set a char inside this string at given index
          *
          * @param aChar is the char you want to write into this string
          * @param anIndex is the ofs where you want to write the given char
          * @return TRUE if successful
          */
 
-      NS_COM PRBool SetCharAt( PRUnichar aChar, PRUint32 aIndex );
+      PRBool SetCharAt( PRUnichar aChar, PRUint32 aIndex );
 
 
         /**
          *  These methods are used to remove all occurrences of the
          *  characters found in aSet from this string.
          *  
          *  @param  aSet -- characters to be cut from this
          */
-      NS_COM void StripChars( const char* aSet );
+      void StripChars( const char* aSet );
 
 
         /**
          *  This method strips whitespace throughout the string.
          */
-      NS_COM void StripWhitespace();
+      void StripWhitespace();
 
 
         /**
          *  swaps occurence of 1 string for another
          */
 
-      NS_COM void ReplaceChar( char_type aOldChar, char_type aNewChar );
-      NS_COM void ReplaceChar( const char* aSet, char_type aNewChar );
-      NS_COM void ReplaceSubstring( const self_type& aTarget, const self_type& aNewValue);
-      NS_COM void ReplaceSubstring( const char_type* aTarget, const char_type* aNewValue);
+      void ReplaceChar( ch