Merge TM -> JM
authorBrian Hackett <bhackett1024@gmail.com>
Mon, 09 May 2011 09:49:48 -0700
changeset 75006 3f87f0e0954ee7e23824b8e8b959ce971bc1dcbc
parent 75005 24a2e5740ab8b1a018af6bee5fbc734bc5955f1a (current diff)
parent 69300 0c6254cb818d233f0e8a74dda503279a0169828d (diff)
child 75007 a3fe07737e6c708a356de4bd4b49f0e1cf341a39
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
milestone6.0a1
Merge TM -> JM
browser/base/content/browser.js
browser/base/content/extensionsManagerOverlay.xul
browser/locales/en-US/chrome/browser/sidebar/sidebar.properties
content/events/test/Makefile.in
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsJSEnvironment.cpp
dom/interfaces/css/nsIDOMViewCSS.idl
dom/interfaces/events/nsIDOMOrientationEvent.idl
dom/interfaces/views/Makefile.in
dom/interfaces/views/nsIDOMAbstractView.idl
dom/interfaces/views/nsIDOMDocumentView.idl
dom/system/windows/WinMobileLocationProvider.cpp
dom/system/windows/WinMobileLocationProvider.h
intl/locale/public/nsIWin32Locale.h
intl/locale/src/windows/nsIWin32LocaleImpl.cpp
intl/locale/src/windows/nsIwin32LocaleImpl.h
intl/uconv/tests/unit/test_bug381412.cp936.js
intl/uconv/ucvcn/nsCP936ToUnicode.cpp
intl/uconv/ucvcn/nsCP936ToUnicode.h
intl/uconv/ucvcn/nsUnicodeToCP936.cpp
intl/uconv/ucvcn/nsUnicodeToCP936.h
js/src/GlobalObject.cpp
js/src/GlobalObject.h
js/src/Makefile.in
js/src/configure.in
js/src/jit-test/tests/basic/testBug653396.js
js/src/jsanalyze.cpp
js/src/jsapi.cpp
js/src/jsarray.cpp
js/src/jsarray.h
js/src/jsbool.cpp
js/src/jscntxt.cpp
js/src/jscompartment.cpp
js/src/jscompartment.h
js/src/jsdbgapi.cpp
js/src/jsemit.cpp
js/src/jsfun.cpp
js/src/jsfun.h
js/src/jsgc.cpp
js/src/jsgc.h
js/src/jsgcinlines.h
js/src/jsgcmark.cpp
js/src/jshashtable.h
js/src/jsinfer.cpp
js/src/jsinterp.cpp
js/src/jsiter.cpp
js/src/jsnum.cpp
js/src/jsobj.cpp
js/src/jsobj.h
js/src/jsobjinlines.h
js/src/json.cpp
js/src/jsopcode.cpp
js/src/jsopcode.tbl
js/src/jsparse.cpp
js/src/jspropertycache.cpp
js/src/jsproxy.cpp
js/src/jspubtd.h
js/src/jsscope.cpp
js/src/jsscope.h
js/src/jsscopeinlines.h
js/src/jsscript.cpp
js/src/jsstr.cpp
js/src/jsstrinlines.h
js/src/jstracer.cpp
js/src/jstracer.h
js/src/jsvalue.h
js/src/jswrapper.h
js/src/jsxml.cpp
js/src/methodjit/Compiler.cpp
js/src/methodjit/Compiler.h
js/src/methodjit/InlineFrameAssembler.h
js/src/methodjit/MonoIC.cpp
js/src/methodjit/PolyIC.cpp
js/src/methodjit/StubCalls.cpp
js/src/methodjit/StubCalls.h
js/src/shell/js.cpp
js/src/tests/manifest.py
js/src/vm/GlobalObject.cpp
js/src/xpconnect/src/nsXPConnect.cpp
js/src/xpconnect/src/xpcjsruntime.cpp
js/src/xpconnect/src/xpcprivate.h
js/src/xpconnect/src/xpcwrappednative.cpp
layout/base/nsIImageMap.h
layout/base/tests/test_bug644768.html
layout/generic/nsIImageFrame.h
layout/html/tests/printer/js/change_while_in printdialog.html
layout/reftests/bidi/229367-1-ref.html
layout/reftests/bidi/229367-1.html
layout/reftests/bidi/229367-2-ref.html
layout/reftests/bidi/229367-2.html
layout/reftests/bidi/229367-3-ref.html
layout/reftests/bidi/229367-3.html
layout/reftests/bidi/263359-1-ref.html
layout/reftests/bidi/263359-1.html
layout/reftests/bidi/263359-1a.html
layout/reftests/bidi/263359-1b.html
layout/reftests/bidi/263359-2-ref.html
layout/reftests/bidi/263359-2.html
layout/reftests/bidi/263359-3-ref.html
layout/reftests/bidi/263359-3.html
layout/reftests/bidi/263359-4-ref.html
layout/reftests/bidi/263359-4.html
layout/reftests/bidi/613157-1-ref.html
layout/reftests/bidi/613157-1.html
layout/reftests/bidi/613157-2-ref.html
layout/reftests/bidi/613157-2.html
layout/reftests/svg/as-image/img-anim-1.html
modules/libpref/src/init/all.js
modules/plugin/base/public/Makefile.in
modules/plugin/base/public/npapi.h
modules/plugin/base/public/npfunctions.h
modules/plugin/base/public/npruntime.h
modules/plugin/base/public/nptypes.h
modules/plugin/base/public/nsIHTTPHeaderListener.idl
modules/plugin/base/public/nsIPlugin.idl
modules/plugin/base/public/nsIPluginDocument.idl
modules/plugin/base/public/nsIPluginHost.idl
modules/plugin/base/public/nsIPluginInputStream.idl
modules/plugin/base/public/nsIPluginInstance.idl
modules/plugin/base/public/nsIPluginInstanceOwner.idl
modules/plugin/base/public/nsIPluginStreamInfo.idl
modules/plugin/base/public/nsIPluginStreamListener.idl
modules/plugin/base/public/nsIPluginTag.idl
modules/plugin/base/public/nsIPluginTagInfo.idl
modules/plugin/base/public/nsPluginError.h
modules/plugin/base/public/nsPluginLogging.h
modules/plugin/base/public/nsPluginNativeWindow.h
modules/plugin/base/public/nsPluginsCID.h
modules/plugin/base/public/nspluginroot.idl
modules/plugin/base/src/Makefile.in
modules/plugin/base/src/PluginPRLibrary.cpp
modules/plugin/base/src/PluginPRLibrary.h
modules/plugin/base/src/nsJSNPRuntime.cpp
modules/plugin/base/src/nsJSNPRuntime.h
modules/plugin/base/src/nsNPAPIPlugin.cpp
modules/plugin/base/src/nsNPAPIPlugin.h
modules/plugin/base/src/nsNPAPIPluginInstance.cpp
modules/plugin/base/src/nsNPAPIPluginInstance.h
modules/plugin/base/src/nsNPAPIPluginStreamListener.cpp
modules/plugin/base/src/nsNPAPIPluginStreamListener.h
modules/plugin/base/src/nsPluginDirServiceProvider.cpp
modules/plugin/base/src/nsPluginDirServiceProvider.h
modules/plugin/base/src/nsPluginHost.cpp
modules/plugin/base/src/nsPluginHost.h
modules/plugin/base/src/nsPluginManifestLineReader.h
modules/plugin/base/src/nsPluginModule.cpp
modules/plugin/base/src/nsPluginNativeWindow.cpp
modules/plugin/base/src/nsPluginNativeWindowGtk2.cpp
modules/plugin/base/src/nsPluginNativeWindowOS2.cpp
modules/plugin/base/src/nsPluginNativeWindowQt.cpp
modules/plugin/base/src/nsPluginNativeWindowWin.cpp
modules/plugin/base/src/nsPluginSafety.h
modules/plugin/base/src/nsPluginStreamListenerPeer.cpp
modules/plugin/base/src/nsPluginStreamListenerPeer.h
modules/plugin/base/src/nsPluginTags.cpp
modules/plugin/base/src/nsPluginTags.h
modules/plugin/base/src/nsPluginsDir.h
modules/plugin/base/src/nsPluginsDirDarwin.cpp
modules/plugin/base/src/nsPluginsDirOS2.cpp
modules/plugin/base/src/nsPluginsDirUnix.cpp
modules/plugin/base/src/nsPluginsDirUtils.h
modules/plugin/base/src/nsPluginsDirWin.cpp
services/crypto/IWeaveCrypto.idl
toolkit/components/faststart/FastStartup.js
toolkit/components/faststart/FastStartup.manifest
toolkit/components/faststart/Makefile.in
toolkit/components/faststart/faststartstub.cpp
toolkit/components/places/nsIMicrosummaryService.idl
toolkit/components/places/nsMicrosummaryService.js
toolkit/components/url-classifier/nsUrlClassifierHashCompleter.cpp
toolkit/components/url-classifier/nsUrlClassifierHashCompleter.h
toolkit/mozapps/installer/wince/Makefile.in
toolkit/mozapps/installer/wince/ns7zipExtractor.cpp
toolkit/mozapps/installer/wince/ns7zipExtractor.h
toolkit/mozapps/installer/wince/nsArchiveExtractor.cpp
toolkit/mozapps/installer/wince/nsArchiveExtractor.h
toolkit/mozapps/installer/wince/nsInstaller.cpp
toolkit/mozapps/installer/wince/nsInstaller.h
toolkit/mozapps/installer/wince/nsInstallerDlg.cpp
toolkit/mozapps/installer/wince/nsInstallerDlg.h
toolkit/mozapps/installer/wince/nsInstallerppc.rc
toolkit/mozapps/installer/wince/nsInstallerppc.rc2
toolkit/mozapps/installer/wince/nsSetupStrings.cpp
toolkit/mozapps/installer/wince/nsSetupStrings.h
toolkit/mozapps/installer/wince/nsSetupStrings.inc
toolkit/mozapps/installer/wince/readme.txt
toolkit/mozapps/installer/wince/resourceppc.h
toolkit/mozapps/installer/wince/uninstall/Makefile.in
toolkit/mozapps/installer/wince/uninstall/Uninstall.cpp
toolkit/mozapps/installer/wince/uninstall/Uninstall.rc
toolkit/mozapps/installer/wince/uninstall/resource.h
toolkit/mozapps/installer/wince/xulrunnerinstaller.ico
toolkit/xre/nsSplashScreenWin.cpp
xpcom/reflect/xptcall/src/md/win32/xptcinvoke_asm_ce.asm
xpcom/reflect/xptcall/src/md/win32/xptcinvokece.cpp
xpcom/reflect/xptcall/src/md/win32/xptcstubs_asm_ce.asm
xpcom/reflect/xptcall/src/md/win32/xptcstubsce.cpp
new file mode 100644
--- /dev/null
+++ b/accessible/src/atk/AtkSocketAccessible.cpp
@@ -0,0 +1,203 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2:
+ */
+/* ***** 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.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell, Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Brad Taylor <brad@getcoded.net> (original author)
+ *
+ * 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 <atk/atk.h>
+#include "AtkSocketAccessible.h"
+#include "nsMai.h"
+#include "nsMaiInterfaceComponent.h"
+
+void (*AtkSocketAccessible::g_atk_socket_embed) (AtkSocket*, gchar*) = NULL;
+GType AtkSocketAccessible::g_atk_socket_type = G_TYPE_INVALID;
+const char* AtkSocketAccessible::sATKSocketEmbedSymbol = "atk_socket_embed";
+const char* AtkSocketAccessible::sATKSocketGetTypeSymbol = "atk_socket_get_type";
+
+bool AtkSocketAccessible::gCanEmbed = FALSE;
+
+/* MaiAtkSocket */
+
+#define MAI_TYPE_ATK_SOCKET              (mai_atk_socket_get_type ())
+#define MAI_ATK_SOCKET(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
+                                          MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
+#define MAI_IS_ATK_SOCKET(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
+                                          MAI_TYPE_ATK_SOCKET))
+#define MAI_ATK_SOCKET_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass),\
+                                          MAI_TYPE_ATK_SOCKET,\
+                                          MaiAtkSocketClass))
+#define MAI_IS_ATK_SOCKET_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass),\
+                                          MAI_TYPE_ATK_SOCKET))
+#define MAI_ATK_SOCKET_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj),\
+                                          MAI_TYPE_ATK_SOCKET,\
+                                          MaiAtkSocketClass))
+
+typedef struct _MaiAtkSocket             MaiAtkSocket;
+typedef struct _MaiAtkSocketClass        MaiAtkSocketClass;
+
+struct _MaiAtkSocket
+{
+  AtkSocket parent;
+
+  nsAccessibleWrap* accWrap;
+};
+
+struct _MaiAtkSocketClass
+{
+  AtkSocketClass parent_class;
+};
+
+G_BEGIN_DECLS
+
+GType mai_atk_socket_get_type(void);
+AtkObject* mai_atk_socket_new(nsAccessibleWrap* aAccWrap);
+
+void mai_atk_component_iface_init(AtkComponentIface* aIface);
+AtkObject* mai_atk_socket_ref_accessible_at_point(AtkComponent *aComponent,
+                                                  gint aAccX,
+                                                  gint aAccY,
+                                                  AtkCoordType aCoordType);
+void mai_atk_socket_get_extents(AtkComponent* aComponent,
+                                gint* aAccX,
+                                gint* aAccY,
+                                gint* aAccWidth,
+                                gint* aAccHeight,
+                                AtkCoordType aCoordType);
+
+G_END_DECLS
+
+G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
+                       AtkSocketAccessible::g_atk_socket_type, 0,
+                       G_IMPLEMENT_INTERFACE(ATK_TYPE_COMPONENT,
+                                             mai_atk_component_iface_init))
+
+void
+mai_atk_socket_class_init(MaiAtkSocketClass* aAcc)
+{
+}
+
+void
+mai_atk_socket_init(MaiAtkSocket* aAcc)
+{
+}
+
+AtkObject*
+mai_atk_socket_new(nsAccessibleWrap* aAccWrap)
+{
+  NS_ENSURE_TRUE(aAccWrap, NULL);
+
+  MaiAtkSocket* acc = nsnull;
+  acc = static_cast<MaiAtkSocket*>(g_object_new(MAI_TYPE_ATK_SOCKET, NULL));
+  NS_ENSURE_TRUE(acc, NULL);
+
+  acc->accWrap = aAccWrap;
+  return ATK_OBJECT(acc);
+}
+
+void
+mai_atk_component_iface_init(AtkComponentIface* aIface)
+{
+  NS_ASSERTION(aIface, "Invalid Interface");
+
+  aIface->ref_accessible_at_point = mai_atk_socket_ref_accessible_at_point;
+  aIface->get_extents = mai_atk_socket_get_extents;
+}
+
+AtkObject*
+mai_atk_socket_ref_accessible_at_point(AtkComponent* aComponent,
+                                       gint aX, gint aY,
+                                       AtkCoordType aCoordType)
+{
+  NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nsnull);
+
+  return refAccessibleAtPointHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
+                                    aX, aY, aCoordType);
+}
+
+void
+mai_atk_socket_get_extents(AtkComponent* aComponent,
+                           gint* aX, gint* aY, gint* aWidth, gint* aHeight,
+                           AtkCoordType aCoordType)
+{
+  *aX = *aY = *aWidth = *aHeight = 0;
+
+  if (!MAI_IS_ATK_SOCKET(aComponent))
+    return;
+
+  getExtentsHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
+                   aX, aY, aWidth, aHeight, aCoordType);
+}
+
+AtkSocketAccessible::AtkSocketAccessible(nsIContent* aContent,
+                                         nsIWeakReference* aShell,
+                                         const nsCString& aPlugId) :
+  nsAccessibleWrap(aContent, aShell)
+{
+  mAtkObject = mai_atk_socket_new(this);
+  if (!mAtkObject)
+    return;
+
+  // Embeds the children of an AtkPlug, specified by plugId, as the children of
+  // this socket.
+  // Using G_TYPE macros instead of ATK_SOCKET macros to avoid undefined
+  // symbols.
+  if (gCanEmbed && G_TYPE_CHECK_INSTANCE_TYPE(mAtkObject, g_atk_socket_type) &&
+      !aPlugId.IsVoid()) {
+    AtkSocket* accSocket =
+      G_TYPE_CHECK_INSTANCE_CAST(mAtkObject, g_atk_socket_type, AtkSocket);
+    g_atk_socket_embed(accSocket, (gchar*)aPlugId.get());
+  }
+}
+
+NS_IMETHODIMP
+AtkSocketAccessible::GetNativeInterface(void** aOutAccessible)
+{
+  *aOutAccessible = mAtkObject;
+  return NS_OK;
+}
+
+void
+AtkSocketAccessible::Shutdown()
+{
+  if (mAtkObject) {
+    if (MAI_IS_ATK_SOCKET(mAtkObject))
+      MAI_ATK_SOCKET(mAtkObject)->accWrap = nsnull;
+    g_object_unref(mAtkObject);
+    mAtkObject = nsnull;
+  }
+  nsAccessibleWrap::Shutdown();
+}
new file mode 100644
--- /dev/null
+++ b/accessible/src/atk/AtkSocketAccessible.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2:
+ */
+/* ***** 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.org code.
+ *
+ * The Initial Developer of the Original Code is
+ * Novell, Inc.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Brad Taylor <brad@getcoded.net> (original author)
+ *
+ * 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 _AtkSocketAccessible_H_
+#define _AtkSocketAccessible_H_
+
+#include "nsAccessibleWrap.h"
+
+// This file gets included by nsAccessibilityService.cpp, which can't include
+// atk.h (or glib.h), so we can't rely on it being included.
+#ifdef __ATK_H__
+typedef void (*AtkSocketEmbedType) (AtkSocket*, gchar*);
+#else
+typedef void (*AtkSocketEmbedType) (void*, void*);
+#endif
+
+/**
+ * Provides a nsAccessibleWrap wrapper around AtkSocket for out-of-process
+ * accessibles.
+ */
+class AtkSocketAccessible: public nsAccessibleWrap
+{
+public:
+
+  // Soft references to AtkSocket
+  static AtkSocketEmbedType g_atk_socket_embed;
+#ifdef __ATK_H__
+  static GType g_atk_socket_type;
+#endif
+  static const char* sATKSocketEmbedSymbol;
+  static const char* sATKSocketGetTypeSymbol;
+
+  /*
+   * True if the current Atk version supports AtkSocket and it was correctly
+   * loaded.
+   */
+  static bool gCanEmbed;
+
+  AtkSocketAccessible(nsIContent* aContent, nsIWeakReference* aShell,
+                      const nsCString& aPlugId);
+
+  // nsAccessNode
+  virtual void Shutdown();
+
+  // nsIAccessible
+  NS_IMETHODIMP GetNativeInterface(void** aOutAccessible);
+};
+
+#endif
--- a/accessible/src/atk/Makefile.in
+++ b/accessible/src/atk/Makefile.in
@@ -43,16 +43,17 @@ include $(DEPTH)/config/autoconf.mk
 
 MODULE = accessibility
 LIBRARY_NAME = accessibility_toolkit_s
 EXPORT_LIBRARY = ..
 LIBXUL_LIBRARY = 1
 
 
 CPPSRCS = \
+  AtkSocketAccessible.cpp \
   nsAccessNodeWrap.cpp \
   nsAccessibleWrap.cpp \
   nsDocAccessibleWrap.cpp \
   nsRootAccessibleWrap.cpp \
   nsApplicationAccessibleWrap.cpp \
   nsMaiInterfaceComponent.cpp \
   nsMaiInterfaceAction.cpp \
   nsMaiInterfaceText.cpp \
@@ -63,16 +64,17 @@ CPPSRCS = \
   nsMaiInterfaceHypertext.cpp \
   nsMaiInterfaceHyperlinkImpl.cpp \
   nsMaiInterfaceTable.cpp \
   nsMaiInterfaceDocument.cpp \
   nsMaiInterfaceImage.cpp \
   $(NULL)
 
 EXPORTS = \
+  AtkSocketAccessible.h \
   nsAccessNodeWrap.h \
   nsARIAGridAccessibleWrap.h \
   nsAccessibleWrap.h \
   nsDocAccessibleWrap.h \
   nsRootAccessibleWrap.h \
   nsTextAccessibleWrap.h \
   nsXULMenuAccessibleWrap.h \
   nsXULListboxAccessibleWrap.h \
--- a/accessible/src/atk/nsAccessNodeWrap.cpp
+++ b/accessible/src/atk/nsAccessNodeWrap.cpp
@@ -1,9 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsAccessNodeWrap.h
+++ b/accessible/src/atk/nsAccessNodeWrap.h
@@ -1,9 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsAccessibleRelationWrap.h
+++ b/accessible/src/atk/nsAccessibleRelationWrap.h
@@ -1,11 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:expandtab:shiftwidth=2:tabstop=2:
- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsAccessibleWrap.cpp
+++ b/accessible/src/atk/nsAccessibleWrap.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsAccessibleWrap.h
+++ b/accessible/src/atk/nsAccessibleWrap.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsApplicationAccessibleWrap.cpp
+++ b/accessible/src/atk/nsApplicationAccessibleWrap.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
@@ -44,16 +43,17 @@
 #include "nsCOMPtr.h"
 #include "nsMai.h"
 #include "prlink.h"
 #include "prenv.h"
 #include "nsIPrefBranch.h"
 #include "nsIServiceManager.h"
 #include "nsAutoPtr.h"
 #include "nsAccessibilityService.h"
+#include "AtkSocketAccessible.h"
 
 #include <gtk/gtk.h>
 #include <atk/atk.h>
 
 typedef GType (* AtkGetTypeType) (void);
 GType g_atk_hyperlink_impl_type = G_TYPE_INVALID;
 static PRBool sATKChecked = PR_FALSE;
 static PRLibrary *sATKLib = nsnull;
@@ -717,18 +717,33 @@ nsApplicationAccessibleWrap::RemoveChild
 
 void
 nsApplicationAccessibleWrap::PreCreate()
 {
     if (!sATKChecked) {
         sATKLib = PR_LoadLibrary(sATKLibName);
         if (sATKLib) {
             AtkGetTypeType pfn_atk_hyperlink_impl_get_type = (AtkGetTypeType) PR_FindFunctionSymbol(sATKLib, sATKHyperlinkImplGetTypeSymbol);
-            if (pfn_atk_hyperlink_impl_get_type) {
+            if (pfn_atk_hyperlink_impl_get_type)
                 g_atk_hyperlink_impl_type = pfn_atk_hyperlink_impl_get_type();
+
+            AtkGetTypeType pfn_atk_socket_get_type;
+            pfn_atk_socket_get_type = (AtkGetTypeType)
+                                      PR_FindFunctionSymbol(sATKLib,
+                                                            AtkSocketAccessible::sATKSocketGetTypeSymbol);
+            if (pfn_atk_socket_get_type) {
+                AtkSocketAccessible::g_atk_socket_type =
+                  pfn_atk_socket_get_type();
+                AtkSocketAccessible::g_atk_socket_embed = (AtkSocketEmbedType)
+                  PR_FindFunctionSymbol(sATKLib,
+                                        AtkSocketAccessible
+                                          ::sATKSocketEmbedSymbol);
+            AtkSocketAccessible::gCanEmbed =
+              AtkSocketAccessible::g_atk_socket_type != G_TYPE_INVALID &&
+              AtkSocketAccessible::g_atk_socket_embed;
             }
         }
         sATKChecked = PR_TRUE;
     }
 }
 
 static nsresult
 LoadGtkModule(GnomeAccessibilityModule& aModule)
--- a/accessible/src/atk/nsApplicationAccessibleWrap.h
+++ b/accessible/src/atk/nsApplicationAccessibleWrap.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsDocAccessibleWrap.cpp
+++ b/accessible/src/atk/nsDocAccessibleWrap.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsDocAccessibleWrap.h
+++ b/accessible/src/atk/nsDocAccessibleWrap.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsHyperTextAccessibleWrap.h
+++ b/accessible/src/atk/nsHyperTextAccessibleWrap.h
@@ -1,9 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMai.h
+++ b/accessible/src/atk/nsMai.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiHyperlink.cpp
+++ b/accessible/src/atk/nsMaiHyperlink.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiHyperlink.h
+++ b/accessible/src/atk/nsMaiHyperlink.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceAction.cpp
+++ b/accessible/src/atk/nsMaiInterfaceAction.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceAction.h
+++ b/accessible/src/atk/nsMaiInterfaceAction.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceComponent.cpp
+++ b/accessible/src/atk/nsMaiInterfaceComponent.cpp
@@ -1,10 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2:
  */
 /* ***** 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/
@@ -40,18 +40,16 @@
 
 #include "nsMaiInterfaceComponent.h"
 
 #include "nsAccessibleWrap.h"
 #include "nsAccUtils.h"
 #include "nsCoreUtils.h"
 
 #include "nsIDOMDocument.h"
-#include "nsIDOMDocumentView.h"
-#include "nsIDOMAbstractView.h"
 #include "nsIDOMWindowInternal.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIInterfaceRequestorUtils.h"
 
 void
 componentInterfaceInitCB(AtkComponentIface *aIface)
 {
     NS_ASSERTION(aIface, "Invalid Interface");
@@ -62,81 +60,89 @@ componentInterfaceInitCB(AtkComponentIfa
      * Use default implementation in atk for contains, get_position,
      * and get_size
      */
     aIface->ref_accessible_at_point = refAccessibleAtPointCB;
     aIface->get_extents = getExtentsCB;
     aIface->grab_focus = grabFocusCB;
 }
 
-AtkObject *
-refAccessibleAtPointCB(AtkComponent *aComponent,
-                       gint aAccX, gint aAccY,
+AtkObject*
+refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX, gint aAccY,
                        AtkCoordType aCoordType)
 {
-    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
-    if (!accWrap || nsAccUtils::MustPrune(accWrap))
-        return nsnull;
-
-    // nsIAccessible getChildAtPoint (x,y) is in screen pixels.
-    if (aCoordType == ATK_XY_WINDOW) {
-        nsIntPoint winCoords =
-          nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
-        aAccX += winCoords.x;
-        aAccY += winCoords.y;
-    }
-
-    nsCOMPtr<nsIAccessible> pointAcc;
-    accWrap->GetChildAtPoint(aAccX, aAccY, getter_AddRefs(pointAcc));
-    if (!pointAcc) {
-        return nsnull;
-    }
-
-    AtkObject *atkObj = nsAccessibleWrap::GetAtkObject(pointAcc);
-    if (atkObj) {
-        g_object_ref(atkObj);
-    }
-    return atkObj;
+  return refAccessibleAtPointHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
+                                    aAccX, aAccY, aCoordType);
 }
 
 void
-getExtentsCB(AtkComponent *aComponent,
-             gint *aAccX,
-             gint *aAccY,
-             gint *aAccWidth,
-             gint *aAccHeight,
-             AtkCoordType aCoordType)
+getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
+             gint* aWidth, gint* aHeight, AtkCoordType aCoordType)
 {
-    *aAccX = *aAccY = *aAccWidth = *aAccHeight = 0;
-
-    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
-    if (!accWrap)
-        return;
-
-    PRInt32 nsAccX, nsAccY, nsAccWidth, nsAccHeight;
-    // Returned in screen coordinates
-    nsresult rv = accWrap->GetBounds(&nsAccX, &nsAccY,
-                                     &nsAccWidth, &nsAccHeight);
-    if (NS_FAILED(rv))
-        return;
-    if (aCoordType == ATK_XY_WINDOW) {
-        nsIntPoint winCoords =
-          nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
-        nsAccX -= winCoords.x;
-        nsAccY -= winCoords.y;
-    }
-
-    *aAccX = nsAccX;
-    *aAccY = nsAccY;
-    *aAccWidth = nsAccWidth;
-    *aAccHeight = nsAccHeight;
+  getExtentsHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
+                   aX, aY, aWidth, aHeight, aCoordType);
 }
 
 gboolean
-grabFocusCB(AtkComponent *aComponent)
+grabFocusCB(AtkComponent* aComponent)
+{
+  nsAccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
+  if (!accWrap)
+    return FALSE;
+
+  nsresult rv = accWrap->TakeFocus();
+  return (NS_FAILED(rv)) ? FALSE : TRUE;
+}
+
+AtkObject*
+refAccessibleAtPointHelper(nsAccessibleWrap* aAccWrap, gint aX, gint aY,
+                           AtkCoordType aCoordType)
 {
-    nsAccessibleWrap *accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
-    if (!accWrap)
-        return FALSE;
+  if (!aAccWrap || aAccWrap->IsDefunct() || nsAccUtils::MustPrune(aAccWrap))
+    return nsnull;
+
+  // nsAccessible::GetChildAtPoint(x,y) is in screen pixels.
+  if (aCoordType == ATK_XY_WINDOW) {
+    nsIntPoint winCoords =
+      nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
+    aX += winCoords.x;
+    aY += winCoords.y;
+  }
+
+  nsAccessible* accAtPoint = aAccWrap->GetChildAtPoint(aX, aY,
+                                                       nsAccessible::eDirectChild);
+  if (!accAtPoint)
+    return nsnull;
+
+  AtkObject* atkObj = nsAccessibleWrap::GetAtkObject(accAtPoint);
+  if (atkObj)
+    g_object_ref(atkObj);
+  return atkObj;
+}
 
-    nsresult rv = accWrap->TakeFocus();
-    return (NS_FAILED(rv)) ? FALSE : TRUE;
+void
+getExtentsHelper(nsAccessibleWrap* aAccWrap,
+                 gint* aX, gint* aY, gint* aWidth, gint* aHeight,
+                 AtkCoordType aCoordType)
+{
+  *aX = *aY = *aWidth = *aHeight = 0;
+
+  if (!aAccWrap || aAccWrap->IsDefunct())
+    return;
+
+  PRInt32 x = 0, y = 0, width = 0, height = 0;
+  // Returned in screen coordinates
+  nsresult rv = aAccWrap->GetBounds(&x, &y, &width, &height);
+  if (NS_FAILED(rv))
+    return;
+
+  if (aCoordType == ATK_XY_WINDOW) {
+    nsIntPoint winCoords =
+      nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
+    x -= winCoords.x;
+    y -= winCoords.y;
+  }
+
+  *aX = x;
+  *aY = y;
+  *aWidth = width;
+  *aHeight = height;
 }
--- a/accessible/src/atk/nsMaiInterfaceComponent.h
+++ b/accessible/src/atk/nsMaiInterfaceComponent.h
@@ -1,10 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2:
  */
 /* ***** 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/
@@ -41,36 +41,40 @@
 #ifndef __MAI_INTERFACE_COMPONENT_H__
 #define __MAI_INTERFACE_COMPONENT_H__
 
 #include "nsMai.h"
 
 G_BEGIN_DECLS
 
 /* component interface callbacks */
-void componentInterfaceInitCB(AtkComponentIface *aIface);
-AtkObject *refAccessibleAtPointCB(AtkComponent *aComponent,
-                                  gint aAccX, gint aAccY,
+void componentInterfaceInitCB(AtkComponentIface* aIface);
+AtkObject* refAccessibleAtPointCB(AtkComponent* aComponent,
+                                  gint aX, gint aY,
                                   AtkCoordType aCoordType);
-void getExtentsCB(AtkComponent *aComponent,
-                  gint *aAccX, gint *aAccY,
-                  gint *aAccWidth, gint *aAccHeight,
+void getExtentsCB(AtkComponent* aComponent,
+                  gint* aX, gint* aY, gint* aWidth, gint* aHeight,
                   AtkCoordType aCoordType);
 /* the "contains", "get_position", "get_size" can take advantage of
  * "get_extents", there is no need to implement them now.
  */
-gboolean grabFocusCB(AtkComponent *aComponent);
+gboolean grabFocusCB(AtkComponent* aComponent);
 
-/* what are missing now for atk component */
-
-/* ==================================================
+/* what are missing now for atk component:
+ *
  * add_focus_handler
  * remove_focus_handler
  * set_extents
  * set_position
  * set_size
  * get_layer
  * get_mdi_zorder
- * ==================================================
  */
+
+AtkObject* refAccessibleAtPointHelper(nsAccessibleWrap* aAccWrap,
+                                      gint aX, gint aY, AtkCoordType aCoordType);
+void getExtentsHelper(nsAccessibleWrap* aAccWrap,
+                      gint* aX, gint* aY, gint* aWidth, gint* aHeight,
+                      AtkCoordType aCoordType);
+
 G_END_DECLS
 
 #endif /* __MAI_INTERFACE_COMPONENT_H__ */
--- a/accessible/src/atk/nsMaiInterfaceDocument.cpp
+++ b/accessible/src/atk/nsMaiInterfaceDocument.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceDocument.h
+++ b/accessible/src/atk/nsMaiInterfaceDocument.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceEditableText.cpp
+++ b/accessible/src/atk/nsMaiInterfaceEditableText.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceEditableText.h
+++ b/accessible/src/atk/nsMaiInterfaceEditableText.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp
+++ b/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.h
+++ b/accessible/src/atk/nsMaiInterfaceHyperlinkImpl.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceHypertext.cpp
+++ b/accessible/src/atk/nsMaiInterfaceHypertext.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceHypertext.h
+++ b/accessible/src/atk/nsMaiInterfaceHypertext.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceImage.cpp
+++ b/accessible/src/atk/nsMaiInterfaceImage.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceImage.h
+++ b/accessible/src/atk/nsMaiInterfaceImage.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceSelection.cpp
+++ b/accessible/src/atk/nsMaiInterfaceSelection.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceSelection.h
+++ b/accessible/src/atk/nsMaiInterfaceSelection.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceTable.cpp
+++ b/accessible/src/atk/nsMaiInterfaceTable.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceTable.h
+++ b/accessible/src/atk/nsMaiInterfaceTable.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceText.cpp
+++ b/accessible/src/atk/nsMaiInterfaceText.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceText.h
+++ b/accessible/src/atk/nsMaiInterfaceText.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceValue.cpp
+++ b/accessible/src/atk/nsMaiInterfaceValue.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsMaiInterfaceValue.h
+++ b/accessible/src/atk/nsMaiInterfaceValue.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsRoleMap.h
+++ b/accessible/src/atk/nsRoleMap.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsRootAccessibleWrap.cpp
+++ b/accessible/src/atk/nsRootAccessibleWrap.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsRootAccessibleWrap.h
+++ b/accessible/src/atk/nsRootAccessibleWrap.h
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* vim:expandtab:shiftwidth=4:tabstop=4:
- */
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsStateMap.h
+++ b/accessible/src/atk/nsStateMap.h
@@ -1,11 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim:expandtab:shiftwidth=2:tabstop=2:
- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsTextAccessibleWrap.h
+++ b/accessible/src/atk/nsTextAccessibleWrap.h
@@ -1,9 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsXULListboxAccessibleWrap.h
+++ b/accessible/src/atk/nsXULListboxAccessibleWrap.h
@@ -1,9 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsXULMenuAccessibleWrap.h
+++ b/accessible/src/atk/nsXULMenuAccessibleWrap.h
@@ -1,9 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/atk/nsXULTreeGridAccessibleWrap.h
+++ b/accessible/src/atk/nsXULTreeGridAccessibleWrap.h
@@ -1,9 +1,10 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=2:tabstop=2: */
 /* ***** 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/
  *
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -60,17 +60,17 @@
 #include "nsIDOMDocument.h"
 #include "nsIDOMHTMLAreaElement.h"
 #include "nsIDOMHTMLLegendElement.h"
 #include "nsIDOMHTMLObjectElement.h"
 #include "nsIDOMHTMLOptGroupElement.h"
 #include "nsIDOMHTMLOptionElement.h"
 #include "nsIDOMXULElement.h"
 #include "nsIHTMLDocument.h"
-#include "nsIImageFrame.h"
+#include "nsImageFrame.h"
 #include "nsILink.h"
 #include "nsIObserverService.h"
 #include "nsIPluginInstance.h"
 #include "nsISupportsUtils.h"
 #include "nsObjectFrame.h"
 #include "nsOuterDocAccessible.h"
 #include "nsRootAccessibleWrap.h"
 #include "nsTextFragment.h"
@@ -90,16 +90,21 @@
 #include "nsXULTreeGridAccessibleWrap.h"
 #endif
 
 // For native window support for object/embed/applet tags
 #ifdef XP_WIN
 #include "nsHTMLWin32ObjectAccessible.h"
 #endif
 
+// For embedding plugin accessibles
+#ifdef MOZ_ACCESSIBILITY_ATK
+#include "AtkSocketAccessible.h"
+#endif
+
 #ifndef DISABLE_XFORMS_HOOKS
 #include "nsXFormsFormControlsAccessible.h"
 #include "nsXFormsWidgetsAccessible.h"
 #endif
 
 #include "mozilla/FunctionTimer.h"
 #include "mozilla/dom/Element.h"
 #include "nsImageMapUtils.h"
@@ -334,30 +339,47 @@ nsAccessibilityService::CreateHTMLObject
   nsCOMPtr<nsIDOMHTMLObjectElement> obj(do_QueryInterface(aContent));
   if (obj) {
     nsCOMPtr<nsIDOMDocument> domDoc;
     obj->GetContentDocument(getter_AddRefs(domDoc));
     if (domDoc)
       return CreateOuterDocAccessible(aContent, aPresShell);
   }
 
-#ifdef XP_WIN
+#if defined(XP_WIN) || defined(MOZ_ACCESSIBILITY_ATK)
   // 2) for plugins
-  nsCOMPtr<nsIPluginInstance> pluginInstance ;
-  aFrame->GetPluginInstance(*getter_AddRefs(pluginInstance));
-  if (pluginInstance) {
+  nsCOMPtr<nsIPluginInstance> pluginInstance;
+  if (NS_SUCCEEDED(aFrame->GetPluginInstance(*getter_AddRefs(pluginInstance))) &&
+      pluginInstance) {
+#ifdef XP_WIN
     // Note: pluginPort will be null if windowless.
     HWND pluginPort = nsnull;
     aFrame->GetPluginPort(&pluginPort);
 
     nsAccessible* accessible = new nsHTMLWin32ObjectOwnerAccessible(aContent,
                                                                     weakShell,
                                                                     pluginPort);
     NS_IF_ADDREF(accessible);
     return accessible;
+
+#elif MOZ_ACCESSIBILITY_ATK
+    if (!AtkSocketAccessible::gCanEmbed)
+      return nsnull;
+
+    nsCString plugId;
+    nsresult rv = pluginInstance->GetValueFromPlugin(
+      NPPVpluginNativeAccessibleAtkPlugId, &plugId);
+    if (NS_SUCCEEDED(rv) && !plugId.IsVoid()) {
+      AtkSocketAccessible* socketAccessible =
+        new AtkSocketAccessible(aContent, weakShell, plugId);
+
+      NS_IF_ADDREF(socketAccessible);
+      return socketAccessible;
+    }
+#endif
   }
 #endif
 
   // 3) for images and imagemaps, or anything else with a child frame
   // we have the object frame, get the image frame
   nsIFrame* frame = aFrame->GetFirstChild(nsnull);
   return frame ? frame->CreateAccessible() : nsnull;
 }
@@ -1239,17 +1261,17 @@ nsAccessibilityService::HasUniversalAria
 
 nsAccessible*
 nsAccessibilityService::GetAreaAccessible(nsIFrame* aImageFrame,
                                           nsINode* aAreaNode,
                                           nsIWeakReference* aWeakShell,
                                           nsAccessible** aImageAccessible)
 {
   // Check if frame is an image frame, and content is <area>.
-  nsIImageFrame *imageFrame = do_QueryFrame(aImageFrame);
+  nsImageFrame *imageFrame = do_QueryFrame(aImageFrame);
   if (!imageFrame)
     return nsnull;
 
   nsCOMPtr<nsIDOMHTMLAreaElement> areaElmt = do_QueryInterface(aAreaNode);
   if (!areaElmt)
     return nsnull;
 
   // Try to get image map accessible from the global cache or create it
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -38,25 +38,22 @@
 
 #include "nsCoreUtils.h"
 
 #include "nsIAccessibleTypes.h"
 
 #include "nsAccessNode.h"
 
 #include "nsIDocument.h"
-#include "nsIDOMAbstractView.h"
 #include "nsIDOM3Node.h"
 #include "nsIDOMDocument.h"
-#include "nsIDOMDocumentView.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMRange.h"
-#include "nsIDOMViewCSS.h"
 #include "nsIDOMWindowInternal.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDocShell.h"
 #include "nsIContentViewer.h"
 #include "nsIEventListenerManager.h"
 #include "nsIPresShell.h"
 #include "nsPresContext.h"
 #include "nsIScrollableFrame.h"
@@ -420,23 +417,22 @@ nsCoreUtils::GetScreenCoordsForWindow(ns
   nsIntPoint coords(0, 0);
   nsCOMPtr<nsIDocShellTreeItem> treeItem(GetDocShellTreeItemFor(aNode));
   if (!treeItem)
     return coords;
 
   nsCOMPtr<nsIDocShellTreeItem> rootTreeItem;
   treeItem->GetRootTreeItem(getter_AddRefs(rootTreeItem));
   nsCOMPtr<nsIDOMDocument> domDoc = do_GetInterface(rootTreeItem);
-  nsCOMPtr<nsIDOMDocumentView> docView(do_QueryInterface(domDoc));
-  if (!docView)
+  if (!domDoc)
     return coords;
 
-  nsCOMPtr<nsIDOMAbstractView> abstractView;
-  docView->GetDefaultView(getter_AddRefs(abstractView));
-  nsCOMPtr<nsIDOMWindowInternal> windowInter(do_QueryInterface(abstractView));
+  nsCOMPtr<nsIDOMWindow> window;
+  domDoc->GetDefaultView(getter_AddRefs(window));
+  nsCOMPtr<nsIDOMWindowInternal> windowInter(do_QueryInterface(window));
   if (!windowInter)
     return coords;
 
   windowInter->GetScreenX(&coords.x);
   windowInter->GetScreenY(&coords.y);
   return coords;
 }
 
@@ -592,24 +588,24 @@ nsCoreUtils::GetComputedStyleDeclaration
   if (!content)
     return nsnull;
 
   // Returns number of items in style declaration
   nsIDocument* document = content->GetOwnerDoc();
   if (!document)
     return nsnull;
 
-  nsCOMPtr<nsIDOMViewCSS> viewCSS(do_QueryInterface(document->GetWindow()));
-  if (!viewCSS)
+  nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(document->GetWindow());
+  if (!window)
     return nsnull;
 
-  nsIDOMCSSStyleDeclaration* cssDecl = nsnull;
+  nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
   nsCOMPtr<nsIDOMElement> domElement(do_QueryInterface(content));
-  viewCSS->GetComputedStyle(domElement, aPseudoElt, &cssDecl);
-  return cssDecl;
+  window->GetComputedStyle(domElement, aPseudoElt, getter_AddRefs(cssDecl));
+  return cssDecl.forget();
 }
 
 already_AddRefed<nsIBoxObject>
 nsCoreUtils::GetTreeBodyBoxObject(nsITreeBoxObject *aTreeBoxObj)
 {
   nsCOMPtr<nsIDOMElement> tcElm;
   aTreeBoxObj->GetTreeBody(getter_AddRefs(tcElm));
   nsCOMPtr<nsIDOMXULElement> tcXULElm(do_QueryInterface(tcElm));
--- a/accessible/src/base/nsRootAccessible.cpp
+++ b/accessible/src/base/nsRootAccessible.cpp
@@ -188,44 +188,38 @@ PRUint32 nsRootAccessible::GetChromeFlag
 
 PRUint64
 nsRootAccessible::NativeState()
 {
   PRUint64 states = nsDocAccessibleWrap::NativeState();
 
 #ifdef MOZ_XUL
   PRUint32 chromeFlags = GetChromeFlags();
-  if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE) {
+  if (chromeFlags & nsIWebBrowserChrome::CHROME_WINDOW_RESIZE)
     states |= states::SIZEABLE;
-  }
-  if (chromeFlags & nsIWebBrowserChrome::CHROME_TITLEBAR) {
     // If it has a titlebar it's movable
     // XXX unless it's minimized or maximized, but not sure
     //     how to detect that
+  if (chromeFlags & nsIWebBrowserChrome::CHROME_TITLEBAR)
     states |= states::MOVEABLE;
-  }
+  if (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL)
+    states |= states::MODAL;
 #endif
 
   nsCOMPtr<nsIFocusManager> fm = do_GetService(FOCUSMANAGER_CONTRACTID);
   if (fm) {
     nsCOMPtr<nsIDOMWindow> rootWindow;
     GetWindow(getter_AddRefs(rootWindow));
 
     nsCOMPtr<nsIDOMWindow> activeWindow;
     fm->GetActiveWindow(getter_AddRefs(activeWindow));
     if (activeWindow == rootWindow)
       states |= states::ACTIVE;
   }
 
-#ifdef MOZ_XUL
-  if (GetChromeFlags() & nsIWebBrowserChrome::CHROME_MODAL) {
-    states |= states::MODAL;
-  }
-#endif
-
   return states;
 }
 
 const char* const docEvents[] = {
 #ifdef DEBUG_DRAGDROPSTART
   // Capture mouse over events and fire fake DRAGDROPSTART event to simplify
   // debugging a11y objects with event viewers
   "mouseover",
--- a/accessible/src/html/nsHTMLImageMapAccessible.cpp
+++ b/accessible/src/html/nsHTMLImageMapAccessible.cpp
@@ -42,18 +42,18 @@
 #include "nsAccUtils.h"
 #include "nsDocAccessible.h"
 
 #include "nsIDOMHTMLCollection.h"
 #include "nsIServiceManager.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLAreaElement.h"
 #include "nsIFrame.h"
-#include "nsIImageFrame.h"
-#include "nsIImageMap.h"
+#include "nsImageFrame.h"
+#include "nsImageMap.h"
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLImageMapAccessible
 ////////////////////////////////////////////////////////////////////////////////
 
 nsHTMLImageMapAccessible::
   nsHTMLImageMapAccessible(nsIContent *aContent, nsIWeakReference *aShell,
                            nsIDOMHTMLMapElement *aMapElm) :
@@ -198,37 +198,35 @@ nsHTMLAreaAccessible::GetBounds(PRInt32 
     return NS_ERROR_FAILURE;
 
   // Essentially this uses GetRect on mAreas of nsImageMap from nsImageFrame.
   nsPresContext *presContext = GetPresContext();
   NS_ENSURE_TRUE(presContext, NS_ERROR_FAILURE);
 
   nsIFrame *frame = GetFrame();
   NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
-  nsIImageFrame *imageFrame = do_QueryFrame(frame);
+  nsImageFrame *imageFrame = do_QueryFrame(frame);
 
-  nsCOMPtr<nsIImageMap> map;
-  imageFrame->GetImageMap(presContext, getter_AddRefs(map));
+  nsImageMap* map = imageFrame->GetImageMap(presContext);
   NS_ENSURE_TRUE(map, NS_ERROR_FAILURE);
 
   nsRect rect;
-  nsIntRect orgRectPixels;
   nsresult rv = map->GetBoundsForAreaContent(mContent, rect);
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aX = presContext->AppUnitsToDevPixels(rect.x);
   *aY = presContext->AppUnitsToDevPixels(rect.y);
 
   // XXX Areas are screwy; they return their rects as a pair of points, one pair
   // stored into the width and height.
   *aWidth  = presContext->AppUnitsToDevPixels(rect.width - rect.x);
   *aHeight = presContext->AppUnitsToDevPixels(rect.height - rect.y);
 
   // Put coords in absolute screen coords
-  orgRectPixels = frame->GetScreenRectExternal();
+  nsIntRect orgRectPixels = frame->GetScreenRectExternal();
   *aX += orgRectPixels.x;
   *aY += orgRectPixels.y;
 
   return NS_OK;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLAreaAccessible: nsAccessible public
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -42,21 +42,19 @@
 #include "States.h"
 #include "nsAccessibilityAtoms.h"
 #include "nsAccessibilityService.h"
 #include "nsAccUtils.h"
 #include "nsTextAttrs.h"
 
 #include "nsIClipboard.h"
 #include "nsContentCID.h"
-#include "nsIDOMAbstractView.h"
 #include "nsIDOMCharacterData.h"
 #include "nsIDOMDocument.h"
 #include "nsPIDOMWindow.h"        
-#include "nsIDOMDocumentView.h"
 #include "nsIDOMRange.h"
 #include "nsIDOMNSRange.h"
 #include "nsIDOMWindowInternal.h"
 #include "nsIDOMXULDocument.h"
 #include "nsIEditingSession.h"
 #include "nsIEditor.h"
 #include "nsIFrame.h"
 #include "nsFrameSelection.h"
--- a/accessible/src/msaa/nsAccessNodeWrap.cpp
+++ b/accessible/src/msaa/nsAccessNodeWrap.cpp
@@ -47,17 +47,16 @@
 #include "nsCoreUtils.h"
 #include "nsRootAccessible.h"
 #include "nsWinUtils.h"
 
 #include "nsAttrName.h"
 #include "nsIDocument.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMNSHTMLElement.h"
-#include "nsIDOMViewCSS.h"
 #include "nsIFrame.h"
 #include "nsINameSpaceManager.h"
 #include "nsIPrefService.h"
 #include "nsIPrefBranch.h"
 #include "nsPIDOMWindow.h"
 #include "nsIServiceManager.h"
 
 /// the accessible library and cached methods
--- a/browser/app/blocklist.xml
+++ b/browser/app/blocklist.xml
@@ -10,16 +10,22 @@
     </emItem>
     <emItem id="firefox@bandoo.com">
       <versionRange minVersion="5.0" maxVersion="5.0" severity="1">
         <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
            <versionRange minVersion="3.7a1pre" maxVersion="*"/>
         </targetApplication>
       </versionRange>
     </emItem>
+    <emItem id="krupa.raj+545@gmail.com">
+      <versionRange severity="2"/>
+    </emItem>
+    <emItem id="krups@krup12s.com">
+      <versionRange severity="3"/>
+    </emItem>
     <emItem id="langpack-vi-VN@firefox.mozilla.org">
       <versionRange minVersion="2.0" maxVersion="2.0"/>
     </emItem>
     <emItem id="masterfiler@gmail.com">
       <versionRange severity="3"/>
     </emItem>
     <emItem id="mozilla_cc@internetdownloadmanager.com">
       <versionRange minVersion=" " maxVersion="6.9.8">
@@ -31,26 +37,32 @@
         <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
            <versionRange minVersion="3.0a1" maxVersion="*"/>
         </targetApplication>
       </versionRange>
     </emItem>
     <emItem id="msntoolbar@msn.com">
       <versionRange minVersion=" " maxVersion="6.*"/>
     </emItem>
+    <emItem id="near799@wdios.com" os="Android">
+      <versionRange minVersion="0.8" maxVersion="1.0" severity="3"/>
+    </emItem>
     <emItem id="personas@christopher.beard">
       <versionRange minVersion="1.6" maxVersion="1.6">
         <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
            <versionRange minVersion="3.6" maxVersion="3.6.*"/>
         </targetApplication>
       </versionRange>
     </emItem>
     <emItem id="ShopperReports@ShopperReports.com">
       <versionRange minVersion="3.1.22.0" maxVersion="3.1.22.0"/>
     </emItem>
+    <emItem id="sidecar-test-addon20110103118@amazon.com" os="MACOSX, Windows, Linux">
+      <versionRange severity="3"/>
+    </emItem>
     <emItem id="support@daemon-tools.cc">
       <versionRange minVersion=" " maxVersion="1.0.0.5"/>
     </emItem>
     <emItem id="support@update-firefox.com"/>
     <emItem id="yslow@yahoo-inc.com">
       <versionRange minVersion="2.0.5" maxVersion="2.0.5">
         <targetApplication id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}">
            <versionRange minVersion="3.5.7" maxVersion="*"/>
@@ -179,10 +191,43 @@
   <gfxBlacklistEntry>
     <os>WINNT 5.1</os>
     <vendor>0x10de</vendor>
     <feature>DIRECT3D_9_LAYERS</feature>
     <featureStatus>BLOCKED_DRIVER_VERSION</featureStatus>
     <driverVersion>7.0.0.0</driverVersion>
     <driverVersionComparator>GREATER_THAN_OR_EQUAL</driverVersionComparator>
   </gfxBlacklistEntry>
+  <gfxBlacklistEntry>
+    <os>MAC OS X 10.5.8</os>
+    <vendor>0x10de</vendor>
+    <feature>DIRECT3D_9_LAYERS</feature>
+    <driverVersion>7.0.0.0</driverVersion>
+    <driverVersionComparator>GREATER_THAN_OR_EQUAL</driverVersionComparator>
+  </gfxBlacklistEntry>
+  <gfxBlacklistEntry>
+    <os>MAC OS X 10.5.8</os>
+    <vendor>0x10de</vendor>
+    <feature>DIRECT3D_9_LAYERS</feature>
+    <featureStatus>BLOCKED_DRIVER_VERSION</featureStatus>
+    <driverVersion>7.0.0.0</driverVersion>
+    <driverVersionComparator>GREATER_THAN_OR_EQUAL</driverVersionComparator>
+  </gfxBlacklistEntry>
+  <gfxBlacklistEntry>
+    <os>MAC OS X 10.6</os>
+    <vendor>0x10de</vendor>
+    <devices>
+      <device>0x0a6c</device>
+    </devices>
+    <feature>DIRECT3D_9_LAYERS</feature>
+    <featureStatus>BLOCKED_DRIVER_VERSION</featureStatus>
+    <driverVersion>8.17.12.5896</driverVersion>
+    <driverVersionComparator>LESS_THAN_OR_EQUAL</driverVersionComparator>
+  </gfxBlacklistEntry>
+  <gfxBlacklistEntry>
+    <os>MAC OS X 10.6</os>
+    <vendor>0x10de</vendor>
+    <feature>DIRECT3D_9_LAYERS</feature>
+    <driverVersion>7.0.0.0</driverVersion>
+    <driverVersionComparator>GREATER_THAN_OR_EQUAL</driverVersionComparator>
+  </gfxBlacklistEntry>
 </gfxItems>
 </blocklist>
--- a/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js
+++ b/browser/app/profile/extensions/testpilot@labs.mozilla.com/modules/setup.js
@@ -50,16 +50,17 @@ const VERSION_PREF ="extensions.testpilo
 const FIRST_RUN_PREF ="extensions.testpilot.firstRunUrl";
 const RUN_AT_ALL_PREF = "extensions.testpilot.runStudies";
 const POPUP_SHOW_ON_NEW = "extensions.testpilot.popup.showOnNewStudy";
 const POPUP_SHOW_ON_FINISH = "extensions.testpilot.popup.showOnStudyFinished";
 const POPUP_SHOW_ON_RESULTS = "extensions.testpilot.popup.showOnNewResults";
 const POPUP_CHECK_INTERVAL = "extensions.testpilot.popup.delayAfterStartup";
 const POPUP_REMINDER_INTERVAL = "extensions.testpilot.popup.timeBetweenChecks";
 const ALWAYS_SUBMIT_DATA = "extensions.testpilot.alwaysSubmitData";
+const UPDATE_CHANNEL_PREF = "app.update.channel";
 const LOG_FILE_NAME = "TestPilotErrorLog.log";
 const RANDOM_DEPLOY_PREFIX = "extensions.testpilot.deploymentRandomizer";
 
 let TestPilotSetup = {
   didReminderAfterStartup: false,
   startupComplete: false,
   _shortTimer: null,
   _longTimer: null,
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -71,20 +71,19 @@ pref("extensions.blocklist.level", 2);
 pref("extensions.blocklist.url", "https://addons.mozilla.org/blocklist/3/%APP_ID%/%APP_VERSION%/%PRODUCT%/%BUILD_ID%/%BUILD_TARGET%/%LOCALE%/%CHANNEL%/%OS_VERSION%/%DISTRIBUTION%/%DISTRIBUTION_VERSION%/%PING_COUNT%/%TOTAL_PING_COUNT%/%DAYS_SINCE_LAST_PING%/");
 pref("extensions.blocklist.detailsURL", "https://www.mozilla.com/%LOCALE%/blocklist/");
 
 pref("extensions.update.autoUpdateDefault", true);
 
 // Dictionary download preference
 pref("browser.dictionaries.download.url", "https://addons.mozilla.org/%LOCALE%/%APP%/dictionaries/");
 
-// Update Timer Manager preferences
-// Interval: When all registered timers should be checked (in milliseconds)
-//           default=10 minutes
-pref("app.update.timer", 600000);
+// The minimum delay in seconds for the timer to fire.
+// default=2 minutes
+pref("app.update.timerMinimumDelay", 120);
 
 // App-specific update preferences
 
 // The interval to check for updates (app.update.interval) is defined in
 // firefox-branding.js
 
 // Alternative windowtype for an application update user interface window. When
 // a window with this windowtype is open the application update service won't
@@ -342,20 +341,16 @@ pref("browser.search.openintab", false);
 pref("browser.search.update", true);
 
 // disable logging for the search service update system by default
 pref("browser.search.update.log", false);
 
 // Check whether we need to perform engine updates every 6 hours
 pref("browser.search.update.interval", 21600);
 
-// Whether or not microsummary and generator updates are enabled
-pref("browser.microsummary.enabled", true);
-pref("browser.microsummary.updateGenerators", true);
-
 // enable search suggestions by default
 pref("browser.search.suggest.enabled", true);
 
 pref("browser.sessionhistory.max_entries", 50);
 
 // handle links targeting new windows
 // 0=default window, 1=current window/tab, 2=new window, 3=new tab in most recent window
 pref("browser.link.open_newwindow", 3);
--- a/browser/base/content/aboutDialog.js
+++ b/browser/base/content/aboutDialog.js
@@ -592,16 +592,18 @@ var gChannelSelector = {
       this.setChannelLabel(this.channelValue);
       this.setChannelMenuitem(this.channelValue);
     }
   },
 
   selectChannel: function(aSelectedItem) {
     document.getElementById("channelDescriptionDeck").selectedPanel =
       document.getElementById(aSelectedItem.value + "Description");
+    document.getElementById("channelMenulist").setAttribute("aria-describedby",
+      aSelectedItem.value + "Description");
   },
 
   cancel: function() {
     this.setChannelMenuitem(this.channelValue);
     this.hide();
   },
 
   apply: function() {
--- a/browser/base/content/aboutDialog.xul
+++ b/browser/base/content/aboutDialog.xul
@@ -62,32 +62,33 @@
 #ifdef MOZ_UPDATER
         onunload="onUnload(event);"
 #endif
 #ifdef XP_MACOSX
         inwindowmenu="false"
 #else
         title="&aboutDialog.title;"
 #endif
+        aria-describedby="version distribution distributionId"
         >
 
   <script type="application/javascript" src="chrome://browser/content/aboutDialog.js"/>
 
   <vbox id="aboutDialogContainer">
     <hbox id="clientBox">
       <vbox id="leftBox" flex="1"/>
       <vbox id="rightBox" flex="1">
 #expand <label id="version" value="__MOZ_APP_VERSION__"/>
         <label id="distribution" class="text-blurb"/>
         <label id="distributionId" class="text-blurb"/>
 
         <!-- Make sure the selectedIndex attribute is always set so that the CSS
              selectors for transitions work -->        
         <deck id="contentDeck" selectedIndex="0">
-          <vbox id="detailsBox">
+          <vbox id="detailsBox" aria-describedby="communityDesc contributeDesc">
             <vbox id="updateBox">
 #ifdef MOZ_UPDATER
               <deck id="updateDeck" orient="vertical">
                 <hbox id="updateButtonBox" align="center">
                   <button id="updateButton" align="start"
                           oncommand="gAppUpdater.buttonOnCommand();"/>
                   <spacer flex="1"/>
                 </hbox>
@@ -114,36 +115,36 @@
                 </hbox>
               </deck>
 #endif
             </vbox>
 
             <description class="text-blurb" id="currentChannelText" hidden="true">
               &channel.description.start;<label id="currentChannel"/>&channel.description.end;<label id="channelChangeLink" class="text-link" onclick="gChannelSelector.show();">&channel.change;</label>
             </description>
-            <description class="text-blurb">
+            <description class="text-blurb" id="communityDesc">
               &community.start2;<label class="text-link" href="http://www.mozilla.org/">&community.mozillaLink;</label>&community.middle2;<label class="text-link" href="about:credits">&community.creditsLink;</label>&community.end2;
             </description>
-            <description class="text-blurb">
+            <description class="text-blurb" id="contributeDesc">
               &contribute.start;<label class="text-link" href="http://www.mozilla.org/contribute/">&contribute.getInvolvedLink;</label>&contribute.end;
             </description>
           </vbox>
 
           <vbox id="channelSelector">
             <hbox pack="start" align="center">
               <label id="channelSelectorStart">&channel.selector.start;</label>
-              <menulist id="channelMenulist" onselect="gChannelSelector.selectChannel(this.selectedItem);">
+              <menulist id="channelMenulist" onselect="gChannelSelector.selectChannel(this.selectedItem);" aria-labelledby="channelSelectorStart channelMenulist channelSelectorEnd">
                 <menupopup>
                   <menuitem id="releaseMenuitem" label="Release" value="release"/>
                   <menuitem id="betaMenuitem" label="Beta" value="beta"/>
                   <menuseparator/>
                   <menuitem id="auroraMenuitem" label="Aurora" value="aurora"/>
                 </menupopup>
               </menulist>
-              <label>&channel.selector.end;</label>
+              <label id="channelSelectorEnd">&channel.selector.end;</label>
             </hbox>
 
             <deck id="channelDescriptionDeck" selectedIndex="0">
               <description id="releaseDescription" class="channel-description">&channel.release.description;</description>
               <description id="betaDescription" class="channel-description">&channel.beta.description;</description>
               <description id="auroraDescription" class="channel-description">&channel.aurora.description;</description>
             </deck>
 
--- a/browser/base/content/browser-menubar.inc
+++ b/browser/base/content/browser-menubar.inc
@@ -17,16 +17,17 @@
 # The Initial Developer of the Original Code is
 # Netscape Communications Corporation.
 # Portions created by the Initial Developer are Copyright (C) 2001
 # the Initial Developer. All Rights Reserved.
 #
 # Contributor(s):
 #   Ehsan Akhgari <ehsan.akhgari@gmail.com>
 #   Rob Campbell <rcampbell@mozilla.com>
+#   Steffen Wilberg <steffen.wilberg@web.de>
 #
 # 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
@@ -374,26 +375,25 @@
                           command="Browser:ForwardOrForwardDuplicate"
                           onclick="checkForMiddleClick(this, event);"/>
                 <menuitem id="historyMenuHome"
                           class="show-only-for-keyboard"
                           label="&historyHomeCmd.label;"
                           oncommand="BrowserGoHome(event);"
                           onclick="checkForMiddleClick(this, event);"
                           key="goHome"/>
+                <menuseparator id="historyMenuHomeSeparator"
+                               class="show-only-for-keyboard"/>
                 <menuitem id="menu_showAllHistory"
                           label="&showAllHistoryCmd2.label;"
 #ifndef XP_MACOSX
                           key="showAllHistoryKb"
 #endif
                           command="Browser:ShowAllHistory"/>
-                <menuseparator id="startHistorySeparator"/>
-                <menuseparator id="endHistorySeparator"
-                               class="hide-if-empty-places-result"
-                               builder="end"/>
+                <menuseparator id="showAllHistorySeparator"/>
 #ifdef MOZ_SERVICES_SYNC
                 <menuitem id="sync-tabs-menuitem"
                           label="&syncTabsMenu.label;"
                           oncommand="BrowserOpenSyncTabs();"
                           disabled="true"/>
 #endif
                 <menuitem id="historyRestoreLastSession"
                           class="restoreLastSession"
@@ -415,16 +415,18 @@
                       label="&historyUndoWindowMenu.label;"
                       disabled="true">
                   <menupopup id="historyUndoWindowPopup"
 #ifndef XP_MACOSX
                              placespopup="true"
 #endif
                              onpopupshowing="document.getElementById('history-menu')._placesView.populateUndoWindowSubmenu();"/>
                 </menu>
+                <menuseparator id="startHistorySeparator"
+                               class="hide-if-empty-places-result"/>
               </menupopup>
             </menu>
 
   <menu id="bookmarksMenu"
         label="&bookmarksMenu.label;"
         accesskey="&bookmarksMenu.accesskey;"
         ondragenter="PlacesMenuDNDHandler.onDragEnter(event);"
         ondragover="PlacesMenuDNDHandler.onDragOver(event);"
@@ -436,16 +438,21 @@
                context="placesContext"
                openInTabs="children"
                oncommand="BookmarksEventHandler.onCommand(event, this.parentNode._placesView);"
                onclick="BookmarksEventHandler.onClick(event, this.parentNode._placesView);"
                onpopupshowing="PlacesCommandHook.updateBookmarkAllTabsCommand();
                                if (!this.parentNode._placesView)
                                  new PlacesMenu(event, 'place:folder=BOOKMARKS_MENU');"
                tooltip="bhTooltip" popupsinherittooltip="true">
+      <menuitem id="bookmarksShowAll"
+                label="&showAllBookmarks2.label;"
+                command="Browser:ShowAllBookmarks"
+                key="manBookmarkKb"/>
+      <menuseparator id="organizeBookmarksSeparator"/>
       <menuitem id="menu_bookmarkThisPage"
                 label="&bookmarkThisPageCmd.label;"
                 command="Browser:AddBookmarkAs"
                 key="addBookmarkAsKb"/>
       <menuitem id="subscribeToPageMenuitem"
 #ifndef XP_MACOSX
                 class="menuitem-iconic"
 #endif
@@ -464,34 +471,36 @@
                    oncommand="return FeedHandler.subscribeToFeed(null, event);"
                    onclick="checkForMiddleClick(this, event);"/>
       </menu>
       <menuitem id="menu_bookmarkAllTabs"
                 label="&addCurPagesCmd.label;"
                 class="show-only-for-keyboard"
                 command="Browser:BookmarkAllTabs"
                 key="bookmarkAllTabsKb"/>
-      <menuitem id="bookmarksShowAll"
-                label="&showAllBookmarks2.label;"
-                command="Browser:ShowAllBookmarks"
-                key="manBookmarkKb"/>
-      <menuseparator id="organizeBookmarksSeparator"/>
+      <menuseparator id="bookmarksToolbarSeparator"/>
       <menu id="bookmarksToolbarFolderMenu"
             class="menu-iconic bookmark-item"
             label="&personalbarCmd.label;"
             container="true">
-        <menupopup id="bookmarksToolbarFolderPopup"  
+        <menupopup id="bookmarksToolbarFolderPopup"
 #ifndef XP_MACOSX
                    placespopup="true"
 #endif
                    context="placesContext"
                    onpopupshowing="if (!this.parentNode._placesView)
                                      new PlacesMenu(event, 'place:folder=TOOLBAR');"/>
       </menu>
-      <menuseparator/>
+      <menuseparator id="bookmarksMenuItemsSeparator"/>
+      <!-- Bookmarks menu items -->
+      <menuseparator builder="end"
+                     class="hide-if-empty-places-result"/>
+      <menuitem id="menu_unsortedBookmarks"
+                label="&unsortedBookmarksCmd.label;"
+                oncommand="PlacesCommandHook.showPlacesOrganizer('UnfiledBookmarks');"/>
     </menupopup>
   </menu>
 
             <menu id="tools-menu"
                   label="&toolsMenu.label;"
                   accesskey="&toolsMenu.accesskey;">
               <menupopup id="menu_ToolsPopup"
 #ifdef MOZ_SERVICES_SYNC
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -484,17 +484,17 @@ function HistoryMenu(aPopupShowingEvent)
   // views definitions, and we don't need them there.
   // Defining the prototype inheritance in the prototype itself would cause
   // browser.js to halt on "PlacesMenu is not defined" error.
   this.__proto__.__proto__ = PlacesMenu.prototype;
   XPCOMUtils.defineLazyServiceGetter(this, "_ss",
                                      "@mozilla.org/browser/sessionstore;1",
                                      "nsISessionStore");
   PlacesMenu.call(this, aPopupShowingEvent,
-                  "place:redirectsMode=2&sort=4&maxResults=10");
+                  "place:redirectsMode=2&sort=4&maxResults=15");
 }
 
 HistoryMenu.prototype = {
   toggleRecentlyClosedTabs: function HM_toggleRecentlyClosedTabs() {
     // enable/disable the Recently Closed Tabs sub menu
     var undoMenu = this._rootElt.getElementsByClassName("recentlyClosedTabsMenu")[0];
 
     // no restorable tabs, so disable menu
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -79,16 +79,18 @@ const nsIWebNavigation = Ci.nsIWebNaviga
 var gCharsetMenu = null;
 var gLastBrowserCharset = null;
 var gPrevCharset = null;
 var gProxyFavIcon = null;
 var gLastValidURLStr = "";
 var gInPrintPreviewMode = false;
 var gDownloadMgr = null;
 var gContextMenu = null; // nsContextMenu instance
+var gDelayedStartupTimeoutId;
+var gStartupRan = false;
 
 #ifndef XP_MACOSX
 var gEditUIVisible = true;
 #endif
 
 [
   ["gBrowser",            "content"],
   ["gNavToolbox",         "navigator-toolbox"],
@@ -1327,17 +1329,18 @@ function BrowserStartup() {
   BookmarksMenuButton.init();
 
   TabsInTitlebar.init();
 
   gPrivateBrowsingUI.init();
 
   retrieveToolbarIconsizesFromTheme();
 
-  setTimeout(delayedStartup, 0, isLoadingBlank, mustLoadSidebar);
+  gDelayedStartupTimeoutId = setTimeout(delayedStartup, 0, isLoadingBlank, mustLoadSidebar);
+  gStartupRan = true;
 }
 
 function HandleAppCommandEvent(evt) {
   evt.stopPropagation();
   switch (evt.command) {
   case "Back":
     BrowserBack();
     break;
@@ -1447,16 +1450,18 @@ function prepareForStartup() {
   gBrowser.addEventListener("MozApplicationManifest",
                             OfflineApps, false);
 
   // setup simple gestures support
   gGestureSupport.init(true);
 }
 
 function delayedStartup(isLoadingBlank, mustLoadSidebar) {
+  gDelayedStartupTimeoutId = null;
+
   Services.obs.addObserver(gSessionHistoryObserver, "browser:purge-session-history", false);
   Services.obs.addObserver(gXPInstallObserver, "addon-install-disabled", false);
   Services.obs.addObserver(gXPInstallObserver, "addon-install-started", false);
   Services.obs.addObserver(gXPInstallObserver, "addon-install-blocked", false);
   Services.obs.addObserver(gXPInstallObserver, "addon-install-failed", false);
   Services.obs.addObserver(gXPInstallObserver, "addon-install-complete", false);
   Services.obs.addObserver(gFormSubmitObserver, "invalidformsubmit", false);
 
@@ -1572,32 +1577,20 @@ function delayedStartup(isLoadingBlank, 
   }
 
   PlacesToolbarHelper.init();
 
   ctrlTab.readPref();
   gPrefService.addObserver(ctrlTab.prefName, ctrlTab, false);
   gPrefService.addObserver(allTabs.prefName, allTabs, false);
 
-  // Initialize the microsummary service by retrieving it, prompting its factory
-  // to create its singleton, whose constructor initializes the service.
-  // Started 4 seconds after delayedStartup (before the livemarks service below).
-  setTimeout(function() {
-    try {
-      Cc["@mozilla.org/microsummary/service;1"].getService(Ci.nsIMicrosummaryService);
-    } catch (ex) {
-      Components.utils.reportError("Failed to init microsummary service:\n" + ex);
-    }
-  }, 4000);
-
   // Delayed initialization of the livemarks update timer.
   // Livemark updates don't need to start until after bookmark UI
   // such as the toolbar has initialized. Starting 5 seconds after
-  // delayedStartup in order to stagger this after the microsummary
-  // service (see above) and before the download manager starts (see below).
+  // delayedStartup in order to stagger this before the download manager starts.
   setTimeout(function() PlacesUtils.livemarks.start(), 5000);
 
   // Initialize the download manager some time after the app starts so that
   // auto-resume downloads begin (such as after crashing or quitting with
   // active downloads) and speeds up the first-load of the download manager UI.
   // If the user manually opens the download manager before the timeout, the
   // downloads will start right away, and getting the service again won't hurt.
   setTimeout(function() {
@@ -1667,119 +1660,133 @@ function delayedStartup(isLoadingBlank, 
   if ("true" != gPrefService.getComplexValue("browser.menu.showCharacterEncoding",
                                              Ci.nsIPrefLocalizedString).data)
     document.getElementById("appmenu_charsetMenu").hidden = true;
 #endif
 
   Services.obs.notifyObservers(window, "browser-delayed-startup-finished", "");
 }
 
-function BrowserShutdown()
-{
-  if (Win7Features)
-    Win7Features.onCloseWindow();
-
-  gPrefService.removeObserver(ctrlTab.prefName, ctrlTab);
-  gPrefService.removeObserver(allTabs.prefName, allTabs);
-  ctrlTab.uninit();
+function BrowserShutdown() {
+  // In certain scenarios it's possible for unload to be fired before onload,
+  // (e.g. if the window is being closed after browser.js loads but before the
+  // load completes). In that case, there's nothing to do here.
+  if (!gStartupRan)
+    return;
+
+  // First clean up services initialized in BrowserStartup (or those whose
+  // uninit methods don't depend on the services having been initialized).
   allTabs.uninit();
-  TabView.uninit();
 
   CombinedStopReload.uninit();
 
   gGestureSupport.init(false);
 
   FullScreen.cleanup();
 
-  try {
-    FullZoom.destroy();
-  }
-  catch(ex) {
-    Components.utils.reportError(ex);
-  }
-
-  Services.obs.removeObserver(gSessionHistoryObserver, "browser:purge-session-history");
-  Services.obs.removeObserver(gXPInstallObserver, "addon-install-disabled");
-  Services.obs.removeObserver(gXPInstallObserver, "addon-install-started");
-  Services.obs.removeObserver(gXPInstallObserver, "addon-install-blocked");
-  Services.obs.removeObserver(gXPInstallObserver, "addon-install-failed");
-  Services.obs.removeObserver(gXPInstallObserver, "addon-install-complete");
   Services.obs.removeObserver(gPluginHandler.pluginCrashed, "plugin-crashed");
-  Services.obs.removeObserver(gFormSubmitObserver, "invalidformsubmit");
 
   try {
     gBrowser.removeProgressListener(window.XULBrowserWindow);
     gBrowser.removeTabsProgressListener(window.TabsProgressListener);
   } catch (ex) {
   }
 
   PlacesStarButton.uninit();
 
-  try {
-    gPrefService.removeObserver(gHomeButton.prefDomain, gHomeButton);
-  } catch (ex) {
-    Components.utils.reportError(ex);
-  }
-
-  BrowserOffline.uninit();
-  OfflineApps.uninit();
   gPrivateBrowsingUI.uninit();
-  IndexedDBPromptHelper.uninit();
-  AddonManager.removeAddonListener(AddonsMgrListener);
+
   TabsInTitlebar.uninit();
 
   var enumerator = Services.wm.getEnumerator(null);
   enumerator.getNext();
   if (!enumerator.hasMoreElements()) {
     document.persist("sidebar-box", "sidebarcommand");
     document.persist("sidebar-box", "width");
     document.persist("sidebar-box", "src");
     document.persist("sidebar-title", "value");
   }
 
+  // Now either cancel delayedStartup, or clean up the services initialized from
+  // it.
+  if (gDelayedStartupTimeoutId) {
+    clearTimeout(gDelayedStartupTimeoutId);
+  } else {
+    if (Win7Features)
+      Win7Features.onCloseWindow();
+
+    gPrefService.removeObserver(ctrlTab.prefName, ctrlTab);
+    gPrefService.removeObserver(allTabs.prefName, allTabs);
+    ctrlTab.uninit();
+    TabView.uninit();
+
+    try {
+      FullZoom.destroy();
+    }
+    catch(ex) {
+      Components.utils.reportError(ex);
+    }
+
+    Services.obs.removeObserver(gSessionHistoryObserver, "browser:purge-session-history");
+    Services.obs.removeObserver(gXPInstallObserver, "addon-install-disabled");
+    Services.obs.removeObserver(gXPInstallObserver, "addon-install-started");
+    Services.obs.removeObserver(gXPInstallObserver, "addon-install-blocked");
+    Services.obs.removeObserver(gXPInstallObserver, "addon-install-failed");
+    Services.obs.removeObserver(gXPInstallObserver, "addon-install-complete");
+    Services.obs.removeObserver(gFormSubmitObserver, "invalidformsubmit");
+
+    try {
+      gPrefService.removeObserver(gHomeButton.prefDomain, gHomeButton);
+    } catch (ex) {
+      Components.utils.reportError(ex);
+    }
+
+    BrowserOffline.uninit();
+    OfflineApps.uninit();
+    IndexedDBPromptHelper.uninit();
+    AddonManager.removeAddonListener(AddonsMgrListener);
+  }
+
+  // Final window teardown, do this last.
   window.XULBrowserWindow.destroy();
   window.XULBrowserWindow = null;
   window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
         .getInterface(Components.interfaces.nsIWebNavigation)
         .QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
         .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
         .getInterface(Components.interfaces.nsIXULWindow)
         .XULBrowserWindow = null;
   window.QueryInterface(Ci.nsIDOMChromeWindow).browserDOMWindow = null;
 }
 
 #ifdef XP_MACOSX
 // nonBrowserWindowStartup(), nonBrowserWindowDelayedStartup(), and
 // nonBrowserWindowShutdown() are used for non-browser windows in
 // macBrowserOverlay
-function nonBrowserWindowStartup()
-{
+function nonBrowserWindowStartup() {
   // Disable inappropriate commands / submenus
   var disabledItems = ['Browser:SavePage',
                        'Browser:SendLink', 'cmd_pageSetup', 'cmd_print', 'cmd_find', 'cmd_findAgain',
                        'viewToolbarsMenu', 'viewSidebarMenuMenu', 'Browser:Reload',
                        'viewFullZoomMenu', 'pageStyleMenu', 'charsetMenu', 'View:PageSource', 'View:FullScreen',
                        'viewHistorySidebar', 'Browser:AddBookmarkAs', 'Browser:BookmarkAllTabs',
                        'View:PageInfo', 'Tasks:InspectPage', 'Browser:ToggleTabView', ];
   var element;
 
-  for (var id in disabledItems)
-  {
+  for (var id in disabledItems) {
     element = document.getElementById(disabledItems[id]);
     if (element)
       element.setAttribute("disabled", "true");
   }
 
   // If no windows are active (i.e. we're the hidden window), disable the close, minimize
   // and zoom menu commands as well
-  if (window.location.href == "chrome://browser/content/hiddenWindow.xul")
-  {
+  if (window.location.href == "chrome://browser/content/hiddenWindow.xul") {
     var hiddenWindowDisabledItems = ['cmd_close', 'minimizeWindow', 'zoomWindow'];
-    for (var id in hiddenWindowDisabledItems)
-    {
+    for (var id in hiddenWindowDisabledItems) {
       element = document.getElementById(hiddenWindowDisabledItems[id]);
       if (element)
         element.setAttribute("disabled", "true");
     }
 
     // also hide the window-list separator
     element = document.getElementById("sep-window-list");
     element.setAttribute("hidden", "true");
@@ -1797,39 +1804,47 @@ function nonBrowserWindowStartup()
                           .getService(Ci.nsIMacDockSupport);
         dockSupport.dockMenu = nativeMenu;
       }
       catch (e) {
       }
     }
   }
 
-
-  setTimeout(nonBrowserWindowDelayedStartup, 0);
-}
-
-function nonBrowserWindowDelayedStartup()
-{
+  gDelayedStartupTimeoutId = setTimeout(nonBrowserWindowDelayedStartup, 0);
+}
+
+function nonBrowserWindowDelayedStartup() {
+  gDelayedStartupTimeoutId = null;
+
   // initialise the offline listener
   BrowserOffline.init();
 
   // Set up Sanitize Item
   initializeSanitizer();
 
   // initialize the private browsing UI
   gPrivateBrowsingUI.init();
 
 #ifdef MOZ_SERVICES_SYNC
   // initialize the sync UI
   gSyncUI.init();
 #endif
-}
-
-function nonBrowserWindowShutdown()
-{
+
+  gStartupRan = true;
+}
+
+function nonBrowserWindowShutdown() {
+  // If nonBrowserWindowDelayedStartup hasn't run yet, we have no work to do -
+  // just cancel the pending timeout and return;
+  if (gDelayedStartupTimeoutId) {
+    clearTimeout(gDelayedStartupTimeoutId);
+    return;
+  }
+
   BrowserOffline.uninit();
 
   gPrivateBrowsingUI.uninit();
 }
 #endif
 
 function initializeSanitizer()
 {
@@ -2253,19 +2268,25 @@ function getShortcutOrURI(aURL, aPostDat
       // Try to get the saved character-set.
       try {
         // makeURI throws if URI is invalid.
         // Will return an empty string if character-set is not found.
         charset = PlacesUtils.history.getCharsetForURI(makeURI(shortcutURL));
       } catch (e) {}
     }
 
+    // encodeURIComponent produces UTF-8, and cannot be used for other charsets.
+    // escape() works in those cases, but it doesn't uri-encode +, @, and /.
+    // Therefore we need to manually replace these ASCII characters by their
+    // encodeURIComponent result, to match the behavior of nsEscape() with
+    // url_XPAlphas
     var encodedParam = "";
-    if (charset)
-      encodedParam = escape(convertFromUnicode(charset, param));
+    if (charset && charset != "UTF-8")
+      encodedParam = escape(convertFromUnicode(charset, param)).
+                     replace(/[+@\/]+/g, encodeURIComponent);
     else // Default charset is UTF-8
       encodedParam = encodeURIComponent(param);
 
     shortcutURL = shortcutURL.replace(/%s/g, encodedParam).replace(/%S/g, param);
 
     if (/%s/i.test(postData)) // POST keyword
       aPostDataRef.value = getPostDataStream(postData, param, encodedParam,
                                              "application/x-www-form-urlencoded");
deleted file mode 100644
--- a/browser/base/content/extensionsManagerOverlay.xul
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.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.org code.
-#
-# The Initial Developer of the Original Code is Asaf Romano
-# Portions created by the Initial Developer are Copyright (C) 2005
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#   Asaf Romano <mozilla.mano@sent.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 *****
-
-<?xul-overlay href="chrome://browser/content/macBrowserOverlay.xul"?>
-
-<overlay id="extensionsManagerOverlay"
-         xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-
-<window id="extensionsManager">
-
-#include browserMountPoints.inc
-
-</window>
-
-</overlay>
--- a/browser/base/content/syncKey.xhtml
+++ b/browser/base/content/syncKey.xhtml
@@ -39,33 +39,35 @@
 
 <!DOCTYPE html [
   <!ENTITY % htmlDTD PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
   %htmlDTD;
   <!ENTITY % syncBrandDTD SYSTEM "chrome://browser/locale/syncBrand.dtd">
   %syncBrandDTD;
   <!ENTITY % syncKeyDTD SYSTEM "chrome://browser/locale/syncKey.dtd">
   %syncKeyDTD;
+  <!ENTITY % globalDTD SYSTEM "chrome://global/locale/global.dtd" >
+  %globalDTD;
 ]>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <title>&syncKey.page.title;</title>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
   <style type="text/css">
     #synckey { font-size: 150% }
     footer { font-size: 70% }
 # Bug 575675: Need to have an a:visited rule in a chrome document.
     a:visited { color: purple; }
   </style>
 </head>
 
-<body>
+<body dir="&locale.dir;">
 <h1>&syncKey.page.title;</h1>
 
-<p id="synckey">SYNCKEY</p>
+<p id="synckey" dir="ltr">SYNCKEY</p>
 
 <p>&syncKey.page.description;</p>
 
 <div id="column1">
   <h2>&syncKey.keepItSecret.heading;</h2>
   <p>&syncKey.keepItSecret.description;</p>
 </div>
 
--- a/browser/base/content/tabview/groupitems.js
+++ b/browser/base/content/tabview/groupitems.js
@@ -73,17 +73,16 @@ function GroupItem(listOfEls, options) {
   this._inited = false;
   this._uninited = false;
   this._children = []; // an array of Items
   this.defaultSize = new Point(TabItems.tabWidth * 1.5, TabItems.tabHeight * 1.5);
   this.isAGroupItem = true;
   this.id = options.id || GroupItems.getNextID();
   this._isStacked = false;
   this.expanded = null;
-  this.topChild = null;
   this.hidden = false;
   this.fadeAwayUndoButtonDelay = 15000;
   this.fadeAwayUndoButtonDuration = 300;
 
   this.keepProportional = false;
   this._frozenItemSizeData = {};
 
   // Double click tracker
@@ -298,16 +297,17 @@ GroupItem.prototype = Utils.extend(new I
   // Function: setActiveTab
   // Sets the active <TabItem> for this groupItem; can be null, but only
   // if there are no children.
   setActiveTab: function GroupItem_setActiveTab(tab) {
     Utils.assertThrow((!tab && this._children.length == 0) || tab.isATabItem,
         "tab must be null (if no children) or a TabItem");
 
     this._activeTab = tab;
+    this.arrange({immediately: true});
   },
 
   // -----------
   // Function: getActiveTab
   // Gets the active <TabItem> for this groupItem; can be null, but only
   // if there are no children.
   getActiveTab: function GroupItem_getActiveTab() {
     return this._activeTab;
@@ -345,18 +345,17 @@ GroupItem.prototype = Utils.extend(new I
   },
 
   // ----------
   // Function: isTopOfStack
   // Returns true if the item is showing on top of this group's stack,
   // determined by whether the tab is this group's topChild, or
   // if it doesn't have one, its first child.
   isTopOfStack: function GroupItem_isTopOfStack(item) {
-    return this.isStacked() && ((this.topChild == item) ||
-      (!this.topChild && this.getChild(0) == item));
+    return this.isStacked() && item == this.getTopChild();
   },
 
   // ----------
   // Function: save
   // Saves this groupItem to persistent storage.
   save: function GroupItem_save() {
     if (!this._inited || this._uninited) // too soon/late to save
       return;
@@ -613,17 +612,17 @@ GroupItem.prototype = Utils.extend(new I
     iQ(this.container).css({zIndex: value});
 
     var count = this._children.length;
     if (count) {
       var topZIndex = value + count + 1;
       var zIndex = topZIndex;
       var self = this;
       this._children.forEach(function(child) {
-        if (child == self.topChild)
+        if (child == self.getTopChild())
           child.setZ(topZIndex + 1);
         else {
           child.setZ(zIndex);
           zIndex--;
         }
       });
     }
   },
@@ -1431,21 +1430,22 @@ GroupItem.prototype = Utils.extend(new I
     // y is the vertical margin
     var x = (bb.width - size.x) / 2;
     var y = Math.min(size.x, (bb.height - size.y) / 2);
     var box = new Rect(bb.left + x, bb.top + y, size.x, size.y);
 
     var self = this;
     var children = [];
 
-    // ensure this.topChild is the first item in childrenToArrange
-    let topChildPos = childrenToArrange.indexOf(this.topChild);
+    // ensure topChild is the first item in childrenToArrange
+    let topChild = this.getTopChild();
+    let topChildPos = childrenToArrange.indexOf(topChild);
     if (topChildPos > 0) {
       childrenToArrange.splice(topChildPos, 1);
-      childrenToArrange.unshift(this.topChild);
+      childrenToArrange.unshift(topChild);
     }
 
     childrenToArrange.forEach(function GroupItem__stackArrange_order(child) {
       // Children are still considered stacked even if they're hidden later.
       child.addClass("stacked");
       child.isStacked = true;
       if (numInPile-- > 0) {
         children.push(child);
@@ -1490,17 +1490,16 @@ GroupItem.prototype = Utils.extend(new I
   _gridArrange: function GroupItem__gridArrange(childrenToArrange, box, options) {
     let arrangeOptions;
     if (this.expanded) {
       // if we're expanded, we actually want to use the expanded tray's bounds.
       box = new Rect(this.expanded.bounds);
       box.inset(8, 8);
       arrangeOptions = Utils.extend({}, options, {z: 99999});
     } else {
-      this.topChild = null;
       this._isStacked = false;
       arrangeOptions = Utils.extend({}, options, {
         columns: this._columns
       });
 
       childrenToArrange.forEach(function(child) {
         child.removeClass("stacked");
         child.isStacked = false;
@@ -1536,18 +1535,17 @@ GroupItem.prototype = Utils.extend(new I
 
     return dropIndex;
   },
 
   expand: function GroupItem_expand() {
     var self = this;
     // ___ we're stacked, and command is held down so expand
     GroupItems.setActiveGroupItem(self);
-    let activeTab = this.topChild || this.getChildren()[0];
-    UI.setActiveTab(activeTab);
+    UI.setActiveTab(this.getTopChild());
     
     var startBounds = this.getChild(0).getBounds();
     var $tray = iQ("<div>").css({
       top: startBounds.top,
       left: startBounds.left,
       width: startBounds.width,
       height: startBounds.height,
       position: "absolute",
@@ -1853,23 +1851,24 @@ GroupItem.prototype = Utils.extend(new I
       if (!targetRange.contains(tab._tPos)) {
         gBrowser.moveTabTo(tab, start);
         indices = null;
       }
     });
   },
 
   // ----------
-  // Function: setTopChild
-  // Sets the <Item> that should be displayed on top when in stack mode.
-  setTopChild: function GroupItem_setTopChild(topChild) {
-    this.topChild = topChild;
+  // Function: getTopChild
+  // Gets the <Item> that should be displayed on top when in stack mode.
+  getTopChild: function GroupItem_getTopChild() {
+    if (!this.getChildren().length) {
+      return null;
+    }
 
-    this.arrange({animate: false});
-    // this.arrange calls this.save for us
+    return this.getActiveTab() || this.getChild(0);
   },
 
   // ----------
   // Function: getChild
   // Returns the nth child tab or null if index is out of range.
   //
   // Parameters:
   //  index - the index of the child tab to return, use negative
--- a/browser/base/content/tabview/tabitems.js
+++ b/browser/base/content/tabview/tabitems.js
@@ -714,21 +714,16 @@ TabItem.prototype = Utils.extend(new Ite
         complete();
     };
 
     UI.setActiveTab(this);
     TabItems._update(this.tab, {force: true});
 
     $tab.addClass("front");
 
-    // If we're in a stacked group, make sure we become the
-    // topChild now so that we show the zoom animation correctly.
-    if (this.parent && this.parent.isStacked())
-      this.parent.setTopChild(this);
-
     let animateZoom = gPrefBranch.getBoolPref("animate_zoom");
     if (animateZoom) {
       // The scaleCheat of 2 here is a clever way to speed up the zoom-out
       // code. See getZoomTransform() below.
       let transform = this.getZoomTransform(2);
       TabItems.pausePainting();
 
       $canvas.css({
@@ -1138,19 +1133,25 @@ let TabItems = {
   // ----------
   // Function: _checkHeartbeat
   // This periodically checks for tabs waiting to be updated, and calls
   // _update on them.
   // Should only be called by startHeartbeat and resumePainting.
   _checkHeartbeat: function TabItems__checkHeartbeat() {
     this._heartbeat = null;
 
-    if (this.isPaintingPaused() || !UI.isIdle)
+    if (this.isPaintingPaused())
       return;
 
+    // restart the heartbeat to update all waiting tabs once the UI becomes idle
+    if (!UI.isIdle()) {
+      this.startHeartbeat();
+      return;
+    }
+
     let accumTime = 0;
     let items = this._tabsWaitingForUpdate.getItems();
     // Do as many updates as we can fit into a "perceived" amount
     // of time, which is tunable.
     while (accumTime < this._maxTimeForUpdating && items.length) {
       let updateBegin = Date.now();
       this._update(items.pop());
       let updateEnd = Date.now();
--- a/browser/base/content/tabview/ui.js
+++ b/browser/base/content/tabview/ui.js
@@ -492,19 +492,16 @@ let UI = {
 
       // Zoom out!
       item.zoomOut(function() {
         if (!currentTab._tabViewTabItem) // if the tab's been destroyed
           item = null;
 
         self.setActiveTab(item);
 
-        if (activeGroupItem && item.parent)
-          activeGroupItem.setTopChild(item);
-
         self._resize(true);
         dispatchEvent(event);
 
         // Flush pending updates
         GroupItems.flushAppTabUpdates();
 
         TabItems.resumePainting();
       });
--- a/browser/base/content/test/browser_getshortcutoruri.js
+++ b/browser/base/content/test/browser_getshortcutoruri.js
@@ -69,16 +69,24 @@ var testData = [
 
   // Test escaping (%s = escaped, %S = raw)
   // UTF-8 default
   [new bmKeywordData("bmget-escaping", "http://bmget/?esc=%s&raw=%S", null, "foé"),
    new keywordResult("http://bmget/?esc=fo%C3%A9&raw=foé", null)],
   // Explicitly-defined ISO-8859-1
   [new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "foé"),
    new keywordResult("http://bmget/?esc=fo%E9&raw=foé", null)],
+
+  // Bug 359809: Test escaping +, /, and @
+  // UTF-8 default
+  [new bmKeywordData("bmget-escaping", "http://bmget/?esc=%s&raw=%S", null, "+/@"),
+   new keywordResult("http://bmget/?esc=%2B%2F%40&raw=+/@", null)],
+  // Explicitly-defined ISO-8859-1
+  [new bmKeywordData("bmget-escaping2", "http://bmget/?esc=%s&raw=%S&mozcharset=ISO-8859-1", null, "+/@"),
+   new keywordResult("http://bmget/?esc=%2B%2F%40&raw=+/@", null)],
 ];
 
 function test() {
   setupKeywords();
 
   for each (var item in testData) {
     var [data, result] = item;
 
--- a/browser/base/content/test/tabview/Makefile.in
+++ b/browser/base/content/test/tabview/Makefile.in
@@ -123,18 +123,20 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug633788.js \
                  browser_tabview_bug634077.js \
                  browser_tabview_bug634085.js \
                  browser_tabview_bug634158.js \
                  browser_tabview_bug634672.js \
                  browser_tabview_bug635696.js \
                  browser_tabview_bug640765.js \
                  browser_tabview_bug641802.js \
+                 browser_tabview_bug642793.js \
                  browser_tabview_bug644097.js \
                  browser_tabview_bug645653.js \
+                 browser_tabview_bug648882.js \
                  browser_tabview_bug649006.js \
                  browser_tabview_bug649307.js \
                  browser_tabview_bug651311.js \
                  browser_tabview_dragdrop.js \
                  browser_tabview_exit_button.js \
                  browser_tabview_expander.js \
                  browser_tabview_firstrun_pref.js \
                  browser_tabview_group.js \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug642793.js
@@ -0,0 +1,27 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  waitForExplicitFinish();
+  newWindowWithTabView(testTopOfStack, loadTabs);
+}
+
+function loadTabs (win) {
+  for (let i = 0; i < 4; i++)
+    win.gBrowser.loadOneTab('about:blank', {inBackground: false});
+  win.gBrowser.selectedTab = win.gBrowser.tabs[2];
+}
+
+function testTopOfStack(win) {
+  registerCleanupFunction(function () { win.close(); });
+  let cw = win.TabView.getContentWindow();
+  groupItem = cw.GroupItems.getActiveGroupItem();
+  ok(!groupItem.isStacked(), 'groupItem is not stacked');
+  groupItem.setSize(150, 150);
+  groupItem.setUserSize();
+  ok(groupItem.isStacked(), 'groupItem is now stacked');
+  ok(groupItem.isTopOfStack(groupItem.getChild(2)),
+    'the third tab is on top of stack');
+  finish();
+}
+
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug648882.js
@@ -0,0 +1,33 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  waitForExplicitFinish();
+
+  newWindowWithTabView(function (win) {
+    registerCleanupFunction(function () win.close());
+
+    let cw = win.TabView.getContentWindow();
+    let tab = win.gBrowser.tabs[0];
+    let tabItem = tab._tabViewTabItem;
+    let isIdle = false;
+
+    // We replace UI.isIdle() here to not rely on setTimeout(). While this
+    // function returns false (busy) we expect no tabItem updates to happen.
+    let busyCount = 5;
+    cw.UI.isIdle = function () {
+      return isIdle = (0 > --busyCount);
+    };
+
+    cw.TabItems.pausePainting();
+
+    tabItem.addSubscriber(tabItem, "updated", function () {
+      tabItem.removeSubscriber(tabItem, "updated");
+      ok(isIdle, "tabItem is updated only when UI is idle");
+      finish();
+    });
+
+    cw.TabItems.update(tab);
+    cw.TabItems.resumePainting();
+  });
+}
--- a/browser/base/content/test/tabview/browser_tabview_expander.js
+++ b/browser/base/content/test/tabview/browser_tabview_expander.js
@@ -116,24 +116,24 @@ function onTabViewWindowLoaded(win) {
       win.removeEventListener("tabviewshown", stage2shown, false);
       ok(!group.expanded, "The group is not expanded.");
       isnot(expander[0].style.display, "none", "The expander is visible!");
       let expanderBounds = expander.bounds();
       ok(group.getBounds().contains(expanderBounds), "The expander still lies in the group.");
       let stackCenter = children[0].getBounds().center();
       ok(stackCenter.y < expanderBounds.center().y, "The expander is below the stack.");
 
-      is(group.topChild, children[1], "The top child in the stack is the second tab item");
+      is(group.getTopChild(), children[1], "The top child in the stack is the second tab item");
       let topChildzIndex = children[1].zIndex;
       // the second tab item should have the largest z-index.
       // only check the first 6 tabs as the stack only contains 6 tab items.
       for (let i = 0; i < 6; i++) {
         if (i != 1)
           ok(children[i].zIndex < topChildzIndex,
-            "The child[" + i + "] has smaller zIndex than second dhild");
+            "The child[" + i + "] has smaller zIndex than second child");
       }
 
       // okay, expand this group one last time
       group.addSubscriber("test stage 3", "expanded", stage3expanded);
       EventUtils.sendMouseEvent({ type: "click" }, expander[0], contentWindow);
     }
 
     // STAGE 3:
@@ -155,17 +155,17 @@ function onTabViewWindowLoaded(win) {
       group.removeSubscriber("test stage 3", "collapsed", stage3collapsed);
 
       ok(!group.expanded, "The group is no longer expanded.");
       isnot(expander[0].style.display, "none", "The expander is visible!");
 
       let stackCenter = children[0].getBounds().center();
       ok(stackCenter.y < expanderBounds.center().y, "The expander is below the stack.");
 
-      is(group.topChild, children[1], 
+      is(group.getTopChild(), children[1], 
          "The top child in the stack is still the second tab item");
       let topChildzIndex = children[1].zIndex;
       // the second tab item should have the largest z-index.
       // only check the first 6 tabs as the stack only contains 6 tab items.
       for (let i = 0; i < 6; i++) {
         if (i != 1)
           ok(children[i].zIndex < topChildzIndex,
             "The child[" + i + "] has smaller zIndex than second dhild after a collapse.");
--- a/browser/base/jar.mn
+++ b/browser/base/jar.mn
@@ -1,13 +1,12 @@
 browser.jar:
 %  content browser %content/browser/ contentaccessible=yes
 #ifdef XP_MACOSX
 %  overlay chrome://mozapps/content/downloads/downloads.xul chrome://browser/content/downloadManagerOverlay.xul
-%  overlay chrome://mozapps/content/extensions/extensions.xul chrome://browser/content/extensionsManagerOverlay.xul
 %  overlay chrome://global/content/console.xul chrome://browser/content/jsConsoleOverlay.xul
 %  overlay chrome://mozapps/content/update/updates.xul chrome://browser/content/softwareUpdateOverlay.xul
 #endif
 #ifdef XP_WIN
 %  overlay chrome://browser/content/browser.xul chrome://browser/content/win6BrowserOverlay.xul os=WINNT osversion>=6
 #endif
 %  overlay chrome://global/content/viewSource.xul chrome://browser/content/viewSourceOverlay.xul
 %  overlay chrome://global/content/viewPartialSource.xul chrome://browser/content/viewSourceOverlay.xul
@@ -74,17 +73,16 @@ browser.jar:
         content/browser/syncQuota.js                  (content/syncQuota.js)
         content/browser/syncUtils.js                  (content/syncUtils.js)
 #endif
 # XXX: We should exclude this one as well (bug 71895)
 *       content/browser/hiddenWindow.xul              (content/hiddenWindow.xul)
 #ifdef XP_MACOSX
 *       content/browser/macBrowserOverlay.xul         (content/macBrowserOverlay.xul)
 *       content/browser/downloadManagerOverlay.xul    (content/downloadManagerOverlay.xul)
-*       content/browser/extensionsManagerOverlay.xul  (content/extensionsManagerOverlay.xul)
 *       content/browser/jsConsoleOverlay.xul          (content/jsConsoleOverlay.xul)
 *       content/browser/softwareUpdateOverlay.xul  (content/softwareUpdateOverlay.xul)
 #endif
 *       content/browser/viewSourceOverlay.xul         (content/viewSourceOverlay.xul)
 #ifdef XP_WIN
 *       content/browser/win6BrowserOverlay.xul        (content/win6BrowserOverlay.xul)
 #endif
 # the following files are browser-specific overrides
--- a/browser/components/nsBrowserGlue.js
+++ b/browser/components/nsBrowserGlue.js
@@ -57,17 +57,16 @@ XPCOMUtils.defineLazyGetter(this, "NetUt
   return NetUtil;
 });
 
 XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
   Cu.import("resource://gre/modules/PlacesUtils.jsm");
   return PlacesUtils;
 });
 
-const PREF_EM_NEW_ADDONS_LIST = "extensions.newAddons";
 const PREF_PLUGINS_NOTIFYUSER = "plugins.update.notifyUser";
 const PREF_PLUGINS_UPDATEURL  = "plugins.update.url";
 
 // We try to backup bookmarks at idle times, to avoid doing that at shutdown.
 // Number of idle seconds before trying to backup bookmarks.  15 minutes.
 const BOOKMARKS_BACKUP_IDLE_TIME = 15 * 60;
 // Minimum interval in milliseconds between backups.
 const BOOKMARKS_BACKUP_INTERVAL = 86400 * 1000;
@@ -392,34 +391,16 @@ BrowserGlue.prototype = {
     // Show about:rights notification, if needed.
     if (this._shouldShowRights())
       this._showRightsNotification();
 
     // Show update notification, if needed.
     if (Services.prefs.prefHasUserValue("app.update.postupdate"))
       this._showUpdateNotification();
 
-    // If new add-ons were installed during startup open the add-ons manager.
-    if (Services.prefs.prefHasUserValue(PREF_EM_NEW_ADDONS_LIST)) {
-      var args = Cc["@mozilla.org/supports-array;1"].
-                 createInstance(Ci.nsISupportsArray);
-      var str = Cc["@mozilla.org/supports-string;1"].
-                createInstance(Ci.nsISupportsString);
-      str.data = "";
-      args.AppendElement(str);
-      var str = Cc["@mozilla.org/supports-string;1"].
-                createInstance(Ci.nsISupportsString);
-      str.data = Services.prefs.getCharPref(PREF_EM_NEW_ADDONS_LIST);
-      args.AppendElement(str);
-      const EMURL = "chrome://mozapps/content/extensions/extensions.xul";
-      const EMFEATURES = "chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
-      Services.ww.openWindow(null, EMURL, "_blank", EMFEATURES, args);
-      Services.prefs.clearUserPref(PREF_EM_NEW_ADDONS_LIST);
-    }
-
     // Load the "more info" page for a locked places.sqlite
     // This property is set earlier by places-database-locked topic.
     if (this._isPlacesDatabaseLocked) {
       this._showPlacesLockedNotificationBox();
     }
 
     // If there are plugins installed that are outdated, and the user hasn't
     // been warned about them yet, open the plugins update page.
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -198,20 +198,16 @@ PlacesController.prototype = {
                  Ci.nsINavHistoryQueryOptions.SORT_BY_NONE;
     case "placesCmd_show:info":
       var selectedNode = this._view.selectedNode;
       if (selectedNode &&
           PlacesUtils.getConcreteItemId(selectedNode) != -1  &&
           !PlacesUtils.nodeIsLivemarkItem(selectedNode))
         return true;
       return false;
-    case "placesCmd_reloadMicrosummary":
-      var selectedNode = this._view.selectedNode;
-      return selectedNode && PlacesUtils.nodeIsBookmark(selectedNode) &&
-             PlacesUtils.microsummaries.hasMicrosummary(selectedNode.itemId);
     case "placesCmd_reload":
       // Livemark containers
       var selectedNode = this._view.selectedNode;
       return selectedNode && PlacesUtils.nodeIsLivemarkContainer(selectedNode);
     case "placesCmd_sortBy:name":
       var selectedNode = this._view.selectedNode;
       return selectedNode &&
              PlacesUtils.nodeIsFolder(selectedNode) &&
@@ -288,19 +284,16 @@ PlacesController.prototype = {
       this.showBookmarkPropertiesForSelection();
       break;
     case "placesCmd_moveBookmarks":
       this.moveSelectedBookmarks();
       break;
     case "placesCmd_reload":
       this.reloadSelectedLivemark();
       break;
-    case "placesCmd_reloadMicrosummary":
-      this.reloadSelectedMicrosummary();
-      break;
     case "placesCmd_sortBy:name":
       this.sortFolderByName();
       break;
     case "placesCmd_createBookmark":
       let node = this._view.selectedNode;
       PlacesUIUtils.showBookmarkDialog({ action: "add"
                                        , type: "bookmark"
                                        , hiddenRows: [ "description"
@@ -500,19 +493,16 @@ PlacesController.prototype = {
         case Ci.nsINavHistoryResultNode.RESULT_TYPE_URI:
         case Ci.nsINavHistoryResultNode.RESULT_TYPE_VISIT:
         case Ci.nsINavHistoryResultNode.RESULT_TYPE_FULL_VISIT:
           nodeData["link"] = true;
           uri = PlacesUtils._uri(node.uri);
           if (PlacesUtils.nodeIsBookmark(node)) {
             nodeData["bookmark"] = true;
             PlacesUtils.nodeIsTagQuery(node.parent)
-            var mss = PlacesUtils.microsummaries;
-            if (mss.hasMicrosummary(node.itemId))
-              nodeData["microsummary"] = true;
 
             var parentNode = node.parent;
             if (parentNode) {
               if (PlacesUtils.nodeIsTagQuery(parentNode))
                 nodeData["tagChild"] = true;
               else if (PlacesUtils.nodeIsLivemarkContainer(parentNode))
                 nodeData["livemarkChild"] = true;
             }
@@ -737,26 +727,16 @@ PlacesController.prototype = {
    */
   reloadSelectedLivemark: function PC_reloadSelectedLivemark() {
     var selectedNode = this._view.selectedNode;
     if (selectedNode && PlacesUtils.nodeIsLivemarkContainer(selectedNode))
       PlacesUtils.livemarks.reloadLivemarkFolder(selectedNode.itemId);
   },
 
   /**
-   * Reload the microsummary associated with the selection
-   */
-  reloadSelectedMicrosummary: function PC_reloadSelectedMicrosummary() {
-    var selectedNode = this._view.selectedNode;
-    var mss = PlacesUtils.microsummaries;
-    if (mss.hasMicrosummary(selectedNode.itemId))
-      mss.refreshMicrosummary(selectedNode.itemId);
-  },
-
-  /**
    * Opens the links in the selected folder, or the selected links in new tabs.
    */
   openSelectionInTabs: function PC_openLinksInTabs(aEvent) {
     var node = this._view.selectedNode;
     if (node && PlacesUtils.nodeIsContainer(node))
       PlacesUIUtils.openContainerNodeInTabs(this._view.selectedNode, aEvent, this._view);
     else
       PlacesUIUtils.openURINodesInTabs(this._view.selectedNodes, aEvent, this._view);
@@ -1569,17 +1549,16 @@ function goUpdatePlacesCommands() {
   updatePlacesCommand("placesCmd_open:tab");
   updatePlacesCommand("placesCmd_new:folder");
   updatePlacesCommand("placesCmd_new:bookmark");
   updatePlacesCommand("placesCmd_new:livemark");
   updatePlacesCommand("placesCmd_new:separator");
   updatePlacesCommand("placesCmd_show:info");
   updatePlacesCommand("placesCmd_moveBookmarks");
   updatePlacesCommand("placesCmd_reload");
-  updatePlacesCommand("placesCmd_reloadMicrosummary");
   updatePlacesCommand("placesCmd_sortBy:name");
   updatePlacesCommand("placesCmd_cut");
   updatePlacesCommand("placesCmd_copy");
   updatePlacesCommand("placesCmd_paste");
   updatePlacesCommand("placesCmd_delete");
 }
 
 function doGetPlacesControllerForCommand(aCommand)
--- a/browser/components/places/content/editBookmarkOverlay.js
+++ b/browser/components/places/content/editBookmarkOverlay.js
@@ -31,30 +31,28 @@
  * 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 ***** */
 
 const LAST_USED_ANNO = "bookmarkPropertiesDialog/folderLastUsed";
-const STATIC_TITLE_ANNO = "bookmarks/staticTitle";
 const MAX_FOLDER_ITEM_IN_MENU_LIST = 5;
 
 var gEditItemOverlay = {
   _uri: null,
   _itemId: -1,
   _itemIds: [],
   _uris: [],
   _tags: [],
   _allTags: [],
   _multiEdit: false,
   _itemType: -1,
   _readOnly: false,
-  _microsummaries: null,
   _hiddenRows: [],
   _observersAdded: false,
   _staticFoldersListBuilt: false,
   _initialized: false,
 
   // the first field which was edited after this panel was initialized for
   // a certain item
   _firstEditedField: "",
@@ -362,173 +360,46 @@ var gEditItemOverlay = {
                                       this._folderMenuList.selectedIndex);
 
     // Hide the folders-separator if no folder is annotated as recently-used
     this._element("foldersSeparator").hidden = (menupopup.childNodes.length <= 6);
     this._folderMenuList.disabled = this._readOnly;
   },
 
   QueryInterface: function EIO_QueryInterface(aIID) {
-    if (aIID.equals(Ci.nsIMicrosummaryObserver) ||
-        aIID.equals(Ci.nsIDOMEventListener) ||
+    if (aIID.equals(Ci.nsIDOMEventListener) ||
         aIID.equals(Ci.nsINavBookmarkObserver) ||
         aIID.equals(Ci.nsISupports))
       return this;
 
     throw Cr.NS_ERROR_NO_INTERFACE;
   },
 
   _element: function EIO__element(aID) {
     return document.getElementById("editBMPanel_" + aID);
   },
 
-  _createMicrosummaryMenuItem:
-  function EIO__createMicrosummaryMenuItem(aMicrosummary) {
-    var menuItem = document.createElement("menuitem");
-
-    // Store a reference to the microsummary in the menu item, so we know
-    // which microsummary this menu item represents when it's time to
-    // save changes or load its content.
-    menuItem.microsummary = aMicrosummary;
-
-    // Content may have to be generated asynchronously; we don't necessarily
-    // have it now.  If we do, great; otherwise, fall back to the generator
-    // name, then the URI, and we trigger a microsummary content update. Once
-    // the update completes, the microsummary will notify our observer to
-    // update the corresponding menu-item.
-    // XXX Instead of just showing the generator name or (heaven forbid)
-    // its URI when we don't have content, we should tell the user that
-    // we're loading the microsummary, perhaps with some throbbing to let
-    // her know it is in progress.
-    if (aMicrosummary.content)
-      menuItem.setAttribute("label", aMicrosummary.content);
-    else {
-      menuItem.setAttribute("label", aMicrosummary.generator.name ||
-                                     aMicrosummary.generator.uri.spec);
-      aMicrosummary.update();
-    }
-
-    return menuItem;
-  },
-
   _getItemStaticTitle: function EIO__getItemStaticTitle() {
     if (this._itemId == -1)
       return PlacesUtils.history.getPageTitle(this._uri);
 
-    const annos = PlacesUtils.annotations;
-    if (annos.itemHasAnnotation(this._itemId, STATIC_TITLE_ANNO))
-      return annos.getItemAnnotation(this._itemId, STATIC_TITLE_ANNO);
-
     return PlacesUtils.bookmarks.getItemTitle(this._itemId);
   },
 
   _initNamePicker: function EIO_initNamePicker() {
-    var userEnteredNameField = this._element("userEnteredName");
     var namePicker = this._element("namePicker");
-    var droppable = false;
-
-    userEnteredNameField.label = this._getItemStaticTitle();
-
-    // clean up old entries
-    var menupopup = namePicker.menupopup;
-    while (menupopup.childNodes.length > 2)
-      menupopup.removeChild(menupopup.lastChild);
-
-    if (this._microsummaries) {
-      this._microsummaries.removeObserver(this);
-      this._microsummaries = null;
-    }
-
-    var itemToSelect = userEnteredNameField;
-    try {
-      if (this._itemId != -1 &&
-          this._itemType == Ci.nsINavBookmarksService.TYPE_BOOKMARK &&
-          !this._readOnly)
-        this._microsummaries = PlacesUtils.microsummaries
-                                          .getMicrosummaries(this._uri, -1);
-    }
-    catch(ex) {
-      // getMicrosummaries will throw an exception in at least two cases:
-      // 1. the bookmarked URI contains a scheme that the service won't
-      //    download for security reasons (currently it only handles http,
-      //    https, and file);
-      // 2. the page to which the URI refers isn't HTML or XML (the only two
-      //    content types the service knows how to summarize).
-      this._microsummaries = null;
-    }
-
-    if (this._microsummaries) {
-      var enumerator = this._microsummaries.Enumerate();
-
-      if (enumerator.hasMoreElements()) {
-        // Show the drop marker if there are microsummaries
-        droppable = true;
-        while (enumerator.hasMoreElements()) {
-          var microsummary = enumerator.getNext()
-                                       .QueryInterface(Ci.nsIMicrosummary);
-          var menuItem = this._createMicrosummaryMenuItem(microsummary);
-          if (PlacesUtils.microsummaries
-                         .isMicrosummary(this._itemId, microsummary))
-            itemToSelect = menuItem;
-
-          menupopup.appendChild(menuItem);
-        }
-      }
-
-      this._microsummaries.addObserver(this);
-    }
-
-    if (namePicker.selectedItem == itemToSelect)
-      namePicker.value = itemToSelect.label;
-    else
-      namePicker.selectedItem = itemToSelect;
-
-    namePicker.setAttribute("droppable", droppable);
+    namePicker.value = this._getItemStaticTitle();
     namePicker.readOnly = this._readOnly;
 
     // clear the undo stack
     var editor = namePicker.editor;
     if (editor)
       editor.transactionManager.clear();
   },
 
-  // nsIMicrosummaryObserver
-  onContentLoaded: function EIO_onContentLoaded(aMicrosummary) {
-    var namePicker = this._element("namePicker");
-    var childNodes = namePicker.menupopup.childNodes;
-
-    // 0: user-entered item; 1: separator
-    for (var i = 2; i < childNodes.length; i++) {
-      if (childNodes[i].microsummary == aMicrosummary) {
-        var newLabel = aMicrosummary.content;
-        // XXXmano: non-editable menulist would do this for us, see bug 360220
-        // We should fix editable-menulists to set the DOMAttrModified handler
-        // as well.
-        //
-        // Also note the order importance: if the label of the menu-item is
-        // set to something different than the menulist's current value,
-        // the menulist no longer has selectedItem set
-        if (namePicker.selectedItem == childNodes[i])
-          namePicker.value = newLabel;
-
-        childNodes[i].label = newLabel;
-        return;
-      }
-    }
-  },
-
-  onElementAppended: function EIO_onElementAppended(aMicrosummary) {
-    var namePicker = this._element("namePicker");
-    namePicker.menupopup
-              .appendChild(this._createMicrosummaryMenuItem(aMicrosummary));
-
-    // Make sure the drop-marker is shown
-    namePicker.setAttribute("droppable", "true");
-  },
-
   uninitPanel: function EIO_uninitPanel(aHideCollapsibleElements) {
     if (aHideCollapsibleElements) {
       // hide the folder tree if it was previously visible
       var folderTreeRow = this._element("folderTreeRow");
       if (!folderTreeRow.collapsed)
         this.toggleFolderTreeVisibility();
 
       // hide the tag selector if it was previously visible
@@ -538,20 +409,17 @@ var gEditItemOverlay = {
     }
 
     if (this._observersAdded) {
       if (this._itemId != -1 || this._uri || this._multiEdit)
         PlacesUtils.bookmarks.removeObserver(this);
 
       this._observersAdded = false;
     }
-    if (this._microsummaries) {
-      this._microsummaries.removeObserver(this);
-      this._microsummaries = null;
-    }
+
     this._itemId = -1;
     this._uri = null;
     this._uris = [];
     this._tags = [];
     this._allTags = [];
     this._itemIds = [];
     this._multiEdit = false;
     this._firstEditedField = "";
@@ -668,64 +536,34 @@ var gEditItemOverlay = {
         // Ensure the tagsField is in sync, clean it up from empty tags
         this._initTextField("tagsField", tags, false);
         return true;
       }
     }
     return false;
   },
 
-  onNamePickerInput: function EIO_onNamePickerInput() {
-    var title = this._element("namePicker").value;
-    this._element("userEnteredName").label = title;
-  },
-
   onNamePickerChange: function EIO_onNamePickerChange() {
     if (this._itemId == -1)
       return;
 
     var namePicker = this._element("namePicker")
     var txns = [];
     const ptm = PlacesUIUtils.ptm;
 
     // Here we update either the item title or its cached static title
-    var newTitle = this._element("userEnteredName").label;
+    var newTitle = namePicker.value;
     if (!newTitle &&
         PlacesUtils.bookmarks.getFolderIdForItem(this._itemId) == PlacesUtils.tagsFolderId) {
       // We don't allow setting an empty title for a tag, restore the old one.
       this._initNamePicker();
     }
     else if (this._getItemStaticTitle() != newTitle) {
       this._mayUpdateFirstEditField("namePicker");
-      if (PlacesUtils.microsummaries.hasMicrosummary(this._itemId)) {
-        // Note: this implicitly also takes care of the microsummary->static
-        // title case, the removeMicorosummary method in the service will set
-        // the item-title to the value of this annotation.
-        //
-        // XXXmano: use a transaction
-        PlacesUtils.setAnnotationsForItem(this._itemId,
-                                          [{name: STATIC_TITLE_ANNO,
-                                            value: newTitle}]);
-      }
-      else
-        txns.push(ptm.editItemTitle(this._itemId, newTitle));
-    }
-
-    var newMicrosummary = namePicker.selectedItem.microsummary;
-
-    // Only add a microsummary update to the transaction if the microsummary
-    // has actually changed, i.e. the user selected no microsummary, but the
-    // bookmark previously had one, or the user selected a microsummary which
-    // is not the one the bookmark previously had
-    if ((newMicrosummary == null &&
-         PlacesUtils.microsummaries.hasMicrosummary(this._itemId)) ||
-        (newMicrosummary != null &&
-         !PlacesUtils.microsummaries
-                     .isMicrosummary(this._itemId, newMicrosummary))) {
-      txns.push(ptm.editBookmarkMicrosummary(this._itemId, newMicrosummary));
+      txns.push(ptm.editItemTitle(this._itemId, newTitle));
     }
 
     var aggregate = ptm.aggregateTransactions("Edit Item Title", txns);
     ptm.doTransaction(aggregate);
   },
 
   onDescriptionFieldBlur: function EIO_onDescriptionFieldBlur() {
     var description = this._element("descriptionField").value;
@@ -1116,40 +954,31 @@ var gEditItemOverlay = {
         }
       }
 
       return;
     }
 
     switch (aProperty) {
     case "title":
-      if (PlacesUtils.annotations.itemHasAnnotation(this._itemId,
-                                                    STATIC_TITLE_ANNO))
-        return;  // onContentLoaded updates microsummary-items
-
-      var userEnteredNameField = this._element("userEnteredName");
-      if (userEnteredNameField.value != aValue) {
-        userEnteredNameField.value = aValue;
-        var namePicker = this._element("namePicker");
-        if (namePicker.selectedItem == userEnteredNameField) {
-          namePicker.label = aValue;
-
-          // clear undo stack
-          namePicker.editor.transactionManager.clear();
-        }
+      var namePicker = this._element("namePicker");
+      if (namePicker.value != aValue) {
+        namePicker.value = aValue;
+        // clear undo stack
+        namePicker.editor.transactionManager.clear();
       }
       break;
     case "uri":
       var locationField = this._element("locationField");
       if (locationField.value != aValue) {
         this._uri = Cc["@mozilla.org/network/io-service;1"].
                     getService(Ci.nsIIOService).
                     newURI(aValue, null, null);
         this._initTextField("locationField", this._uri.spec);
-        this._initNamePicker(); // for microsummaries
+        this._initNamePicker();
         this._initTextField("tagsField",
                              PlacesUtils.tagging
                                         .getTagsForURI(this._uri).join(", "),
                             false);
         this._rebuildTagsSelectorList();
       }
       break;
     case "keyword":
--- a/browser/components/places/content/editBookmarkOverlay.xul
+++ b/browser/components/places/content/editBookmarkOverlay.xul
@@ -60,32 +60,19 @@
       </columns>
       <rows id="editBMPanel_rows">
         <row align="center" id="editBMPanel_nameRow">
           <label value="&editBookmarkOverlay.name.label;"
                  class="editBMPanel_rowLabel"
                  accesskey="&editBookmarkOverlay.name.accesskey;"
                  control="editBMPanel_namePicker"
                  observes="paneElementsBroadcaster"/>
-          <menulist id="editBMPanel_namePicker"
-                    flex="1"
-                    editable="true"
-                    droppable="false"
-                    oninput="gEditItemOverlay.onNamePickerInput();"
-                    onblur="gEditItemOverlay.onNamePickerChange();"
-                    oncommand="gEditItemOverlay.onNamePickerChange();"
-                    observes="paneElementsBroadcaster">
-            <menupopup>
-              <menuitem id="editBMPanel_userEnteredName"/>
-              <menuitem disabled="true">
-                <menuseparator flex="1"/>
-                <label value="&editBookmarkOverlay.liveTitlesSeparator.label;"/>
-              </menuitem>
-            </menupopup>
-          </menulist>
+          <textbox id="editBMPanel_namePicker"
+                   onblur="gEditItemOverlay.onNamePickerChange();"
+                   observes="paneElementsBroadcaster"/>
         </row>
 
         <row align="center" id="editBMPanel_locationRow">
           <label value="&editBookmarkOverlay.location.label;"
                  class="editBMPanel_rowLabel"
                  accesskey="&editBookmarkOverlay.location.accesskey;"
                  control="editBMPanel_locationField"
                  observes="paneElementsBroadcaster"/>
--- a/browser/components/places/content/placesOverlay.xul
+++ b/browser/components/places/content/placesOverlay.xul
@@ -96,18 +96,16 @@
              oncommand="goDoPlacesCommand('placesCmd_new:separator');"/>
     <command id="placesCmd_show:info" 
              oncommand="goDoPlacesCommand('placesCmd_show:info');"/>
     <command id="placesCmd_rename"
              oncommand="goDoPlacesCommand('placesCmd_show:info');"
              observes="placesCmd_show:info"/>
     <command id="placesCmd_reload"
              oncommand="goDoPlacesCommand('placesCmd_reload');"/>
-    <command id="placesCmd_reloadMicrosummary"
-             oncommand="goDoPlacesCommand('placesCmd_reloadMicrosummary');"/>
     <command id="placesCmd_sortBy:name"
              oncommand="goDoPlacesCommand('placesCmd_sortBy:name');"/>
     <command id="placesCmd_moveBookmarks"
              oncommand="goDoPlacesCommand('placesCmd_moveBookmarks');"/>
     <command id="placesCmd_deleteDataHost"
              oncommand="goDoPlacesCommand('placesCmd_deleteDataHost');"/>
     <command id="placesCmd_createBookmark"
              oncommand="goDoPlacesCommand('placesCmd_createBookmark');"/>
@@ -234,22 +232,16 @@
               forcehideselection="bookmark"/>
     <menuseparator id="placesContext_deleteSeparator"/>
     <menuitem id="placesContext_reload"
               command="placesCmd_reload"
               label="&cmd.reloadLivebookmark.label;"
               accesskey="&cmd.reloadLivebookmark.accesskey;"
               closemenu="single"
               selection="livemark/feedURI"/>
-    <menuitem id="placesContext_reloadMicrosummary"
-              command="placesCmd_reloadMicrosummary"
-              label="&cmd.reloadMicrosummary.label;"
-              accesskey="&cmd.reloadMicrosummary.accesskey;"
-              closemenu="single"
-              selection="microsummary"/>
     <menuitem id="placesContext_sortBy:name"
               command="placesCmd_sortBy:name"
               label="&cmd.sortby_name.label;"
               accesskey="&cmd.context_sortby_name.accesskey;"
               closemenu="single"
               selection="folder"/>
     <menuseparator id="placesContext_sortSeparator"/>
     <menuitem id="placesContext_show:info"
--- a/browser/components/places/src/PlacesUIUtils.jsm
+++ b/browser/components/places/src/PlacesUIUtils.jsm
@@ -315,18 +315,18 @@ var PlacesUIUtils = {
     }
     return null;
   },
 
   _reportDeprecatedAddBookmarkMethod:
   function PUIU__reportDeprecatedAddBookmarkMethod() {
     // Removes "PUIU_".
     let oldFuncName = arguments.callee.caller.name.slice(5);
-    Cu.reportError(oldFuncName + " is deprecated and will be removed in a \
-                   future release.  Use showBookmarkDialog instead");
+    Cu.reportError(oldFuncName + " is deprecated and will be removed in a " +
+                   "future release. Use showBookmarkDialog instead.");
   },
 
   /**
    * This is here for compatibility reasons, use ShowBookmarkDialog instead.
    */
   showAddBookmarkUI: function PUIU_showAddBookmarkUI(
     aURI, aTitle, aDescription, aDefaultInsertionPoint, aShowPicker,
     aLoadInSidebar, aKeyword, aPostData, aCharSet) {
@@ -805,26 +805,26 @@ var PlacesUIUtils = {
 
       return Cu.getGlobalForObject(aView);
     }
 
     let caller = arguments.callee.caller;
 
     // If a view wasn't expected, the method should have got a window.
     if (aView === null) {
-      Components.utils.reportError("The api has changed. A window should be \
-                                    passed to " + caller.name + ".  Not \
-                                    passing a window will throw in a future \
-                                    release.");
+      Components.utils.reportError("The api has changed. A window should be " +
+                                   "passed to " + caller.name + ".  Not " +
+                                   "passing a window will throw in a future " +
+                                   "release.");
     }
     else {
-      Components.utils.reportError("The api has changed. A places view \
-                                    should be passed to " + caller.name + ".  \
-                                    Not passing a view will throw in a future \
-                                    release.");
+      Components.utils.reportError("The api has changed. A places view " +
+                                   "should be passed to " + caller.name + ". " +
+                                   "Not passing a view will throw in a future " +
+                                   "release.");
     }
 
     // This could certainly break in some edge cases (like bug 562998), but
     // that's the best we should do for those extreme backwards-compatibility cases.
     let topBrowserWin = this._getTopBrowserWin();
     return topBrowserWin ? topBrowserWin : focusManager.focusedWindow;
   },
 
@@ -1319,19 +1319,16 @@ XPCOMUtils.defineLazyGetter(PlacesUIUtil
       new PlacesEditBookmarkPostDataTransaction(aItemId, aPostData),
 
     editLivemarkSiteURI: function(aLivemarkId, aSiteURI)
       new PlacesEditLivemarkSiteURITransaction(aLivemarkId, aSiteURI),
 
     editLivemarkFeedURI: function(aLivemarkId, aFeedURI)
       new PlacesEditLivemarkFeedURITransaction(aLivemarkId, aFeedURI),
 
-    editBookmarkMicrosummary: function(aItemId, aNewMicrosummary)
-      new PlacesEditBookmarkMicrosummaryTransaction(aItemId, aNewMicrosummary),
-
     editItemDateAdded: function(aItemId, aNewDateAdded)
       new PlacesEditItemDateAddedTransaction(aItemId, aNewDateAdded),
 
     editItemLastModified: function(aItemId, aNewLastModified)
       new PlacesEditItemLastModifiedTransaction(aItemId, aNewLastModified),
 
     sortFolderByName: function(aFolderId)
       new PlacesSortFolderByNameTransaction(aFolderId),
--- a/browser/components/places/tests/browser/browser_bookmarksProperties.js
+++ b/browser/components/places/tests/browser/browser_bookmarksProperties.js
@@ -308,28 +308,26 @@ gTests.push({
     tree.selectItems([itemId]);
     this.selectedNode = tree.selectedNode;
   },
 
   run: function() {
     this._itemId = this.window.gEditItemOverlay._itemId;
     // Change folder name
     var namePicker = this.window.document.getElementById("editBMPanel_namePicker");
-    var userEnteredName = this.window.document.getElementById("editBMPanel_userEnteredName");
     var self = this;
 
     this.window.addEventListener("unload", function(event) {
       self.window.removeEventListener("unload", arguments.callee, false);
       executeSoon(function () {
         self.finish();
       });
     }, false);
 
     namePicker.value = "n";
-    userEnteredName.label = "n";
     info("About to focus the namePicker field");
     namePicker.focus();
     EventUtils.synthesizeKey("VK_RETURN", {}, this.window);
   },
 
   finish: function() {
     // Window is already closed.
     toggleSidebar(this.sidebar, false);
--- a/browser/components/places/tests/unit/bookmarks.preplaces.html
+++ b/browser/components/places/tests/unit/bookmarks.preplaces.html
@@ -14,20 +14,16 @@
         <DT><A HREF="http://en-US.www.mozilla.com/en-US/firefox/community/" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" ID="rdf:#$42iCK1">Get Involved</A>
         <DT><A HREF="http://en-US.www.mozilla.com/en-US/about/" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAHWSURBVHjaYvz//z8DJQAggJiQOe/fv2fv7Oz8rays/N+VkfG/iYnJfyD/1+rVq7ffu3dPFpsBAAHEAHIBCJ85c8bN2Nj4vwsDw/8zQLwKiO8CcRoQu0DxqlWrdsHUwzBAAIGJmTNnPgYa9j8UqhFElwPxf2MIDeIrKSn9FwSJoRkAEEAM0DD4DzMAyPi/G+QKY4hh5WAXGf8PDQ0FGwJ22d27CjADAAIIrLmjo+MXA9R2kAHvGBA2wwx6B8W7od6CeQcggKCmCEL8bgwxYCbUIGTDVkHDBia+CuotgACCueD3TDQN75D4xmAvCoK9ARMHBzAw0AECiBHkAlC0Mdy7x9ABNA3obAZXIAa6iKEcGlMVQHwWyjYuL2d4v2cPg8vZswx7gHyAAAK7AOif7SAbOqCmn4Ha3AHFsIDtgPq/vLz8P4MSkJ2W9h8ggBjevXvHDo4FQUQg/kdypqCg4H8lUIACnQ/SOBMYI8bAsAJFPcj1AAEEjwVQqLpAbXmH5BJjqI0gi9DTAAgDBBCcAVLkgmQ7yKCZxpCQxqUZhAECCJ4XgMl493ug21ZD+aDAXH0WLM4A9MZPXJkJIIAwTAR5pQMalaCABQUULttBGCCAGCnNzgABBgAMJ5THwGvJLAAAAABJRU5ErkJggg==" ID="rdf:#$52iCK1">About Us</A>
     </DL><p>
     <DT><H3 ADD_DATE="1177541020" LAST_MODIFIED="1177541050" ID="rdf:#$74Gpx2">test</H3>
 <DD>folder test comment
     <DL><p>
         <DT><A HREF="http://test/post" ADD_DATE="1177375336" LAST_MODIFIED="1177375423" SHORTCUTURL="test" WEB_PANEL="true" POST_DATA="hidden1%3Dbar&amp;text1%3D%25s" LAST_CHARSET="ISO-8859-1" ID="rdf:#$pYFe7">test post keyword</A>
 <DD>item description
-<!-- XXX Bug 380468
-        <DT><A HREF="http://test/micsum" ADD_DATE="1177375377" LAST_MODIFIED="1177541023" LAST_CHARSET="ISO-8859-1" MICSUM_GEN_URI="urn:source:http://dietrich.ganx4.com/mozilla/test-microsummary.xml" MICSUM_EXPIRATION="1177542823620" GENERATED_TITLE="id:462fd9a2e5b66" ID="rdf:#$qYFe7">test microsummary</A>
-<DD>test microsummary
--->
     </DL>
     <DT><H3 UNFILED_BOOKMARKS_FOLDER="true">Unsorted Bookmarks</H3>
     <DL><p>
         <DT><A HREF="http://example.tld">Example.tld</A>
     </DL><p>
     <DT><H3 LAST_MODIFIED="1177541040" PERSONAL_TOOLBAR_FOLDER="true" ID="rdf:#$FvPhC3">Bookmarks Toolbar Folder</H3>
 <DD>Add bookmarks to this folder to see them displayed on the Bookmarks Toolbar
     <DL><p>
--- a/browser/components/places/tests/unit/test_384370.js
+++ b/browser/components/places/tests/unit/test_384370.js
@@ -218,34 +218,16 @@ function testCanonicalBookmarks() {
 
   // description 
   do_check_true(PlacesUtils.annotations.itemHasAnnotation(testBookmark1.itemId,
                                                           DESCRIPTION_ANNO));
   do_check_eq("item description",
               PlacesUtils.annotations.getItemAnnotation(testBookmark1.itemId,
                                                         DESCRIPTION_ANNO));
 
-  /*
-  // XXX Bug 380468
-  // test bookmark 2
-  var testBookmark2 = testFolder.getChild(1);
-  // url
-  do_check_eq("http://test/micsum", testBookmark2.uri);
-  // title
-  do_check_eq("test microsummary", testBookmark2.title);
-  // check that it's a microsummary
-  var micsum = mssvc.getMicrosummary(testBookmark2.itemId);
-  if (!micsum)
-    do_throw("Could not import microsummary");
-  // check generator uri
-  var generator = micsum.generator;
-  do_check_eq("urn:source:http://dietrich.ganx4.com/mozilla/test-microsummary.xml", generator.uri.spec);
-  // expiration and generated title can change, so don't test them
-  */
-
   // clean up
   testFolder.containerOpen = false;
   rootNode.containerOpen = false;
 }
 
 function testToolbarFolder() {
   var query = PlacesUtils.history.getNewQuery();
   query.setFolders([PlacesUtils.bookmarks.toolbarFolder], 1);
--- a/browser/components/places/tests/unit/test_bookmarks_html.js
+++ b/browser/components/places/tests/unit/test_bookmarks_html.js
@@ -66,23 +66,16 @@ try {
 
 // Get favicon service
 try {
   var iconsvc = Cc["@mozilla.org/browser/favicon-service;1"].getService(Ci.nsIFaviconService);
 } catch(ex) {
   do_throw("Could not get favicon service\n");
 } 
 
-// Get microsummary service
-try {
-  var mssvc = Cc["@mozilla.org/microsummary/service;1"].getService(Ci.nsIMicrosummaryService);
-} catch(ex) {
-  do_throw("Could not get microsummary service\n");
-}
-
 // Get io service
 try {
   var iosvc = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
 } catch (ex) {
   do_throw("Could not get io service\n");
 }
 
 const DESCRIPTION_ANNO = "bookmarkProperties/description";
@@ -261,33 +254,16 @@ function testCanonicalBookmarks(aFolder)
 
   // description
   do_check_true(annosvc.itemHasAnnotation(testBookmark1.itemId,
                                           DESCRIPTION_ANNO));
   do_check_eq("item description",
               annosvc.getItemAnnotation(testBookmark1.itemId,
                                         DESCRIPTION_ANNO));
 
-  /*
-  // XXX Bug 380468
-  // test bookmark 2
-  var testBookmark2 = testFolder.getChild(1);
-  // url
-  do_check_eq("http://test/micsum", testBookmark2.uri);
-  // title
-  do_check_eq("test microsummary", testBookmark2.title);
-  // check that it's a microsummary
-  var micsum = mssvc.getMicrosummary(testBookmark2.itemId);
-  if (!micsum)
-    do_throw("Could not import microsummary");
-  // check generator uri
-  var generator = micsum.generator;
-  do_check_eq("urn:source:http://dietrich.ganx4.com/mozilla/test-microsummary.xml", generator.uri.spec);
-  // expiration and generated title can change, so don't test them
-  */
   // clean up
   testFolder.containerOpen = false;
   rootNode.containerOpen = false;
 
   query.setFolders([bmsvc.toolbarFolder], 1);
   result = histsvc.executeQuery(query, histsvc.getNewQueryOptions());
   // bookmarks toolbar
   var toolbar = result.root;
--- a/browser/components/places/tests/unit/test_placesTxn.js
+++ b/browser/components/places/tests/unit/test_placesTxn.js
@@ -35,17 +35,16 @@
  * 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 ***** */
 
 var bmsvc = PlacesUtils.bookmarks;
 var lmsvc = PlacesUtils.livemarks;
-var mss = PlacesUtils.microsummaries;
 var ptSvc = PlacesUIUtils.ptm;
 var tagssvc = PlacesUtils.tagging;
 var annosvc = PlacesUtils.annotations;
 
 // create and add bookmarks observer
 var observer = {
   onBeginUpdateBatch: function() {
     this._beginUpdateBatch = true;
@@ -575,32 +574,16 @@ function run_test() {
   do_check_eq(2, bmsvc.getItemIndex(b1));
   do_check_eq(1, bmsvc.getItemIndex(b2));
   do_check_eq(0, bmsvc.getItemIndex(b3));
   txn17.undoTransaction();
   do_check_eq(0, bmsvc.getItemIndex(b1));
   do_check_eq(1, bmsvc.getItemIndex(b2));
   do_check_eq(2, bmsvc.getItemIndex(b3));
 
-  // editBookmarkMicrosummary
-  var tmpMs = mss.createMicrosummary(uri("http://testmicro.com"), 
-                                     uri("http://dietrich.ganx4.com/mozilla/test-microsummary.xml"));
-  ptSvc.doTransaction(
-  ptSvc.createItem(uri("http://dietrich.ganx4.com/mozilla/test-microsummary-content.php"),
-                   root, -1, "micro test", null, null, null));
-  var bId = (bmsvc.getBookmarkIdsForURI(uri("http://dietrich.ganx4.com/mozilla/test-microsummary-content.php")))[0];
-  do_check_true(!mss.hasMicrosummary(bId));
-  var txn18 = ptSvc.editBookmarkMicrosummary(bId, tmpMs);
-  txn18.doTransaction();
-  do_check_eq(observer._itemChangedId, bId);
-  do_check_true(mss.hasMicrosummary(bId));
-  txn18.undoTransaction();
-  do_check_eq(observer._itemChangedId, bId);
-  do_check_true(!mss.hasMicrosummary(bId));
-
   // Testing edit Post Data
   const POST_DATA_ANNO = "bookmarkProperties/POSTData";
   var postData = "foo";
   var postDataURI = uri("http://foo.com");
   ptSvc.doTransaction(
     ptSvc.createItem(postDataURI, root, -1, "postdata test", null, null, null));
   var postDataId = (bmsvc.getBookmarkIdsForURI(postDataURI))[0];
   var postDataTxn = ptSvc.editBookmarkPostData(postDataId, postData);
--- a/browser/components/sessionstore/test/browser/browser_600545.js
+++ b/browser/components/sessionstore/test/browser/browser_600545.js
@@ -92,16 +92,25 @@ function testBug600545() {
 }
 
 function done() {
   // Reset the pref
   try {
     Services.prefs.clearUserPref("browser.sessionstore.resume_from_crash");
   } catch (e) {}
 
+  // Enumerate windows and close everything but our primary window. We can't
+  // use waitForFocus() because apparently it's buggy. See bug 599253.
+  let windowsEnum = Services.wm.getEnumerator("navigator:browser");
+  while (windowsEnum.hasMoreElements()) {
+    let currentWindow = windowsEnum.getNext();
+    if (currentWindow != window)
+      currentWindow.close();
+  }
+
   ss.setBrowserState(stateBackup);
   executeSoon(finish);
 }
 
 // Count up the number of tabs in the state data
 function getStateTabCount(aState) {
   let tabCount = 0;
   for (let i in aState.windows)
--- a/browser/components/sidebar/src/nsSidebar.js
+++ b/browser/components/sidebar/src/nsSidebar.js
@@ -226,41 +226,16 @@ function (aDescriptionURL)
 // http://msdn.microsoft.com/en-us/library/aa342526%28VS.85%29.aspx .
 // XXX Implement this!
 nsSidebar.prototype.IsSearchProviderInstalled =
 function (aSearchURL)
 {
   return 0;
 }
 
-nsSidebar.prototype.addMicrosummaryGenerator =
-function (generatorURL)
-{
-    debug("addMicrosummaryGenerator(" + generatorURL + ")");
-
-    if (!/^https?:/i.test(generatorURL))
-      return;
-
-    var stringBundle = srGetStrBundle("chrome://browser/locale/sidebar/sidebar.properties");
-    var titleMessage = stringBundle.GetStringFromName("addMicsumGenConfirmTitle");
-    var dialogMessage = stringBundle.formatStringFromName("addMicsumGenConfirmText", [generatorURL], 1);
-      
-    if (!this.promptService.confirm(null, titleMessage, dialogMessage))
-        return;
-
-    var ioService = Components.classes["@mozilla.org/network/io-service;1"].
-                    getService(Components.interfaces.nsIIOService);
-    var generatorURI = ioService.newURI(generatorURL, null, null);
-
-    var microsummaryService = Components.classes["@mozilla.org/microsummary/service;1"].
-                              getService(Components.interfaces.nsIMicrosummaryService);
-    if (microsummaryService)
-      microsummaryService.addGenerator(generatorURI);
-}
-
 // property of nsIClassInfo
 nsSidebar.prototype.flags = nsIClassInfo.DOM_OBJECT;
 
 // property of nsIClassInfo
 nsSidebar.prototype.classDescription = "Sidebar";
 
 // method of nsIClassInfo
 nsSidebar.prototype.getInterfaces = function(count) {
--- a/browser/installer/package-manifest.in
+++ b/browser/installer/package-manifest.in
@@ -386,16 +386,17 @@
 
 ; Modules
 @BINPATH@/modules/*
 
 ; Safe Browsing
 @BINPATH@/components/nsSafebrowsingApplication.manifest
 @BINPATH@/components/nsSafebrowsingApplication.js
 @BINPATH@/components/nsURLClassifier.manifest
+@BINPATH@/components/nsUrlClassifierHashCompleter.js
 @BINPATH@/components/nsUrlClassifierListManager.js
 @BINPATH@/components/nsUrlClassifierLib.js
 @BINPATH@/components/url-classifier.xpt
 
 ; GNOME hooks
 #ifdef MOZ_ENABLE_GNOME_COMPONENT
 @BINPATH@/components/@DLL_PREFIX@mozgnome@DLL_SUFFIX@
 #endif
--- a/browser/installer/removed-files.in
+++ b/browser/installer/removed-files.in
@@ -72,16 +72,17 @@ components/nsXmlRpcClient.js
 components/pluginGlue.js
 components/sidebar.xpt
 components/WeaveCrypto.js
 components/WeaveCrypto.manifest
 components/xmlextras.xpt
 components/xpcom.xpt
 components/xpti.dat
 components/xptitemp.dat
+components/nsMicrosummaryService.js
 defaults/pref/all.js
 defaults/pref/bug259708.js
 defaults/pref/bug307259.js
 defaults/pref/reporter.js
 defaults/pref/security-prefs.js
 defaults/pref/winpref.js
 defaults/pref/xpinstall.js
 defaults/profile/US/
@@ -870,17 +871,16 @@ xpicleanup@BIN_SUFFIX@
   components/nsFormHistory.js
   components/nsHandlerService.js
   components/nsHelperAppDlg.js
   components/nsINIProcessor.js
   components/nsLivemarkService.js
   components/nsLoginInfo.js
   components/nsLoginManager.js
   components/nsLoginManagerPrompter.js
-  components/nsMicrosummaryService.js
   components/nsPlacesAutoComplete.js
   components/nsPlacesDBFlush.js
   components/nsPlacesExpiration.js
   components/nsPrivateBrowsingService.js
   components/nsPrompter.js
   components/nsProxyAutoConfig.js
   components/nsSafebrowsingApplication.js
   components/nsSearchService.js
--- a/browser/locales/en-US/chrome/browser/browser.dtd
+++ b/browser/locales/en-US/chrome/browser/browser.dtd
@@ -99,17 +99,17 @@ can reach it easily. -->
 <!ENTITY bookmarksMenu.label "Bookmarks">
 <!ENTITY bookmarksMenu.accesskey "B">
 <!ENTITY bookmarkThisPageCmd.label "Bookmark This Page">
 <!ENTITY bookmarkThisPageCmd.commandkey "d">
 <!ENTITY subscribeToPageMenupopup.label "Subscribe to This Page">
 <!ENTITY subscribeToPageMenuitem.label "Subscribe to This Pageā€¦">
 <!ENTITY addCurPagesCmd.label "Bookmark All Tabsā€¦">
 <!ENTITY showAllBookmarks2.label "Show All Bookmarks">
-<!ENTITY bookmarkAllCmd.label "Bookmark All Tabsā€¦">
+<!ENTITY unsortedBookmarksCmd.label "Unsorted Bookmarks">
 <!ENTITY bookmarksToolbarChevron.tooltip "Show more bookmarks">
 
 <!ENTITY backCmd.label                "Back">
 <!ENTITY backCmd.accesskey            "B">
 <!ENTITY backButton.tooltip           "Go back one page">
 <!ENTITY forwardCmd.label             "Forward">
 <!ENTITY forwardCmd.accesskey         "F">
 <!ENTITY forwardButton.tooltip        "Go forward one page">
--- a/browser/locales/en-US/chrome/browser/places/editBookmarkOverlay.dtd
+++ b/browser/locales/en-US/chrome/browser/places/editBookmarkOverlay.dtd
@@ -1,17 +1,16 @@
 <!ENTITY editBookmarkOverlay.name.label                      "Name:">
 <!ENTITY editBookmarkOverlay.name.accesskey                  "N">
 <!ENTITY editBookmarkOverlay.location.label                  "Location:">
 <!ENTITY editBookmarkOverlay.location.accesskey              "L">
 <!ENTITY editBookmarkOverlay.feedLocation.label              "Feed Location:">
 <!ENTITY editBookmarkOverlay.feedLocation.accesskey          "F">
 <!ENTITY editBookmarkOverlay.siteLocation.label              "Site Location:">
 <!ENTITY editBookmarkOverlay.siteLocation.accesskey          "S">
-<!ENTITY editBookmarkOverlay.liveTitlesSeparator.label       "Live Titles">
 <!ENTITY editBookmarkOverlay.folder.label                    "Folder:">
 <!ENTITY editBookmarkOverlay.foldersExpanderDown.tooltip     "Show all the bookmarks folders">
 <!ENTITY editBookmarkOverlay.expanderUp.tooltip              "Hide">
 <!ENTITY editBookmarkOverlay.tags.label                      "Tags:">
 <!ENTITY editBookmarkOverlay.tags.accesskey                  "T">
 <!ENTITY editBookmarkOverlay.tagsEmptyDesc.label             "Separate tags with commas">
 <!ENTITY editBookmarkOverlay.description.label               "Description:">
 <!ENTITY editBookmarkOverlay.description.accesskey           "D">
--- a/browser/locales/en-US/chrome/browser/places/places.dtd
+++ b/browser/locales/en-US/chrome/browser/places/places.dtd
@@ -71,18 +71,16 @@
 <!ENTITY cmd.new_folder.label              "New Folderā€¦">
 <!ENTITY cmd.new_folder.accesskey          "o">
 <!ENTITY cmd.context_new_folder.accesskey  "F">
 <!ENTITY cmd.new_separator.label           "New Separator">
 <!ENTITY cmd.new_separator.accesskey       "S">
 
 <!ENTITY cmd.reloadLivebookmark.label      "Reload Live Bookmark">
 <!ENTITY cmd.reloadLivebookmark.accesskey  "R">
-<!ENTITY cmd.reloadMicrosummary.label      "Reload Live Title">
-<!ENTITY cmd.reloadMicrosummary.accesskey  "R">
 
 <!ENTITY cmd.moveBookmarks.label                  "Moveā€¦">
 <!ENTITY cmd.moveBookmarks.accesskey              "M">
 
 <!ENTITY col.name.label          "Name">
 <!ENTITY col.tags.label          "Tags">
 <!ENTITY col.url.label           "Location">
 <!ENTITY col.lastvisit.label     "Visit Date">
deleted file mode 100644
--- a/browser/locales/en-US/chrome/browser/sidebar/sidebar.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-addMicsumGenConfirmTitle=Add Microsummary Generator
-addMicsumGenConfirmText=Add the following microsummary generator?\n\nSource: %S
--- a/browser/locales/jar.mn
+++ b/browser/locales/jar.mn
@@ -62,17 +62,16 @@
     locale/browser/preferences/preferences.dtd        (%chrome/browser/preferences/preferences.dtd)
     locale/browser/preferences/preferences.properties (%chrome/browser/preferences/preferences.properties)
     locale/browser/preferences/privacy.dtd            (%chrome/browser/preferences/privacy.dtd)
     locale/browser/preferences/security.dtd           (%chrome/browser/preferences/security.dtd)
 #ifdef MOZ_SERVICES_SYNC
     locale/browser/preferences/sync.dtd               (%chrome/browser/preferences/sync.dtd)
 #endif
     locale/browser/preferences/tabs.dtd               (%chrome/browser/preferences/tabs.dtd)
-    locale/browser/sidebar/sidebar.properties      (%chrome/browser/sidebar/sidebar.properties)
 #ifdef MOZ_SERVICES_SYNC
     locale/browser/syncBrand.dtd                (%chrome/browser/syncBrand.dtd)
     locale/browser/syncSetup.dtd                (%chrome/browser/syncSetup.dtd)
     locale/browser/syncSetup.properties         (%chrome/browser/syncSetup.properties)
     locale/browser/syncGenericChange.properties         (%chrome/browser/syncGenericChange.properties)
     locale/browser/syncKey.dtd                  (%chrome/browser/syncKey.dtd)
     locale/browser/syncQuota.dtd                (%chrome/browser/syncQuota.dtd)
     locale/browser/syncQuota.properties         (%chrome/browser/syncQuota.properties)
--- a/browser/themes/gnomestripe/browser/browser.css
+++ b/browser/themes/gnomestripe/browser/browser.css
@@ -400,17 +400,16 @@ menuitem:not([type]):not(.menuitem-toolt
 
 #menu_stop[disabled],
 #context-stop[disabled] {
   list-style-image: url("moz-icon://stock/gtk-stop?size=menu&state=disabled");
 }
 
 #menu_reload,
 #placesContext_reload,
-#placesContext_reloadMicrosummary,
 #context-reload,
 #context-reloadframe {
   list-style-image: url("moz-icon://stock/gtk-refresh?size=menu");
 }
 
 #menu_reload[disabled],
 #context-reload[disabled] {
   list-style-image: url("moz-icon://stock/gtk-refresh?size=menu&state=disabled");
--- a/browser/themes/gnomestripe/browser/places/editBookmarkOverlay.css
+++ b/browser/themes/gnomestripe/browser/places/editBookmarkOverlay.css
@@ -72,46 +72,16 @@
   min-width: 23em;
 }
 
 #editBMPanel_folderTree {
   margin-top: 2px;
   margin-bottom: 2px;
 }
 
-/**** name picker ****/
-
-/* Make the microsummary picker look like a regular textbox instead of 
- * an editable menulist when no microsummaries are available.
- */
-#editBMPanel_namePicker[droppable="false"] {
-  /* These rules come from the textbox element in textbox.css. */
-  -moz-appearance: textfield; /* Normal editable menulists set this to "none". */
-  cursor: text;
-  border: 2px solid;
-  -moz-border-top-colors: ThreeDShadow ThreeDDarkShadow;
-  -moz-border-right-colors: ThreeDHighlight ThreeDLightShadow;
-  -moz-border-bottom-colors: ThreeDHighlight ThreeDLightShadow;
-  -moz-border-left-colors: ThreeDShadow ThreeDDarkShadow;
-  padding: 2px 2px 3px;
-  -moz-padding-start: 4px;
-  background-color: -moz-Field;
-  color: -moz-FieldText;
-}
-
-#editBMPanel_namePicker[droppable="false"] > .menulist-editable-box {
-  -moz-appearance: none; /* Normal editable menulists set this to "menulist-textfield". */
-  padding: 0;
-}
-
-#editBMPanel_namePicker[droppable="false"] > .menulist-dropmarker,
-#editBMPanel_namePicker[droppable="false"] > menupopup {
-  display: none;
-}
-
 /* Hide the value column of the tag autocomplete popup
  * leaving only the comment column visible. This is
  * so that only the tag being edited is shown in the
  * popup.
  */
 #editBMPanel_tagsField #treecolAutoCompleteValue {
   visibility: collapse;
 }
--- a/browser/themes/gnomestripe/browser/places/places.css
+++ b/browser/themes/gnomestripe/browser/places/places.css
@@ -193,12 +193,11 @@ menuitem[command="placesCmd_open:tab"] {
   -moz-image-region: rect(0px 64px 16px 48px);
 }
 
 #placesContext_show\:info,
 menuitem[command="placesCmd_show:info"] {
   list-style-image: url("moz-icon://stock/gtk-properties?size=menu");
 }
 
-#placesContext_reload,
-#placesContext_reloadMicrosummary {
+#placesContext_reload {
   list-style-image: url("moz-icon://stock/gtk-refresh?size=menu");
 }
--- a/browser/themes/pinstripe/browser/browser.css
+++ b/browser/themes/pinstripe/browser/browser.css
@@ -1362,51 +1362,39 @@ richlistitem[type~="action"][actiontype=
 #editBookmarkPanel .expander-up {
   list-style-image: url("chrome://browser/skin/hud-style-expander-open.png");
 }
 
 #editBookmarkPanel .expander-down {
   list-style-image: url("chrome://browser/skin/hud-style-expander-closed.png");
 }
 
-/**** name picker ****/
-
-#editBMPanel_tagsField,
-#editBMPanel_namePicker[droppable="false"] > .menulist-editable-box {
+#editBMPanel_tagsField {
   -moz-appearance: none !important;
   -moz-padding-start: 3px !important;
   margin: 2px !important;
   border: 1px solid rgba(0,0,0,.5) !important;
   box-shadow: inset 0 1px 0 rgba(0,0,0,.3);
   background-color: #666 !important;
   background-clip: padding-box;
   background-origin: padding-box;
   color: #fff !important;
   min-height: 20px;
 }
 
-#editBMPanel_namePicker[droppable="false"] > .menulist-editable-box > html|*.menulist-editable-input {
-  color: inherit;
-}
-
 #editBMPanel_tagsField > .autocomplete-textbox-container > .textbox-input-box > html|*.textbox-input:-moz-placeholder {
   color: #bbb;
 }
 
-#editBMPanel_tagsField[focused="true"],
-#editBMPanel_namePicker[droppable="false"][focused="true"] > .menulist-editable-box {
+#editBMPanel_tagsField[focused="true"] {
   @hudButtonFocused@
   background-color: #eee !important;
   color: #000 !important;
 }
 
-#editBMPanel_namePicker[droppable="false"][disabled="true"] > .menulist-editable-box {
-  color: #fff !important;
-}
-
 .editBMPanel_rowLabel {
   text-align: end;
 }
 
 /* ----- SIDEBAR ELEMENTS ----- */
 
 #sidebar,
 sidebarheader {
--- a/browser/themes/pinstripe/browser/places/editBookmarkOverlay.css
+++ b/browser/themes/pinstripe/browser/places/editBookmarkOverlay.css
@@ -87,80 +87,16 @@
 #editBookmarkPanelContent {
   min-width: 23em;
 }
 
 #editBMPanel_folderTree {
   margin: 6px 4px 0 4px;
 }
 
-/**** name picker ****/
-
-/* Make the microsummary picker look like a regular textbox instead of 
- * an editable menulist when no microsummaries are available.
- */
-#editBMPanel_namePicker[droppable="false"] {
-  -moz-appearance: none;
-  margin: 0px;
-  border: none;
-  padding: 0px;
-  height: auto !important;
-}
-
-#editBMPanel_namePicker[droppable="false"] > .menulist-dropmarker {
-  display: none;
-}
-
-#editBMPanel_namePicker[droppable="false"] > .menulist-editable-box {
-  /* These rules are duplicates of the rules for the textbox element
-   * in textbox.css and should track changes in that file.
-   */
-  -moz-appearance: textfield;
-  cursor: text;
-  margin: 4px 4px;
-  border: 3px solid;
-  -moz-border-top-colors: transparent #888888 #000000;
-  -moz-border-right-colors: transparent #FFFFFF #000000;
-  -moz-border-bottom-colors: transparent #FFFFFF #000000;
-  -moz-border-left-colors: transparent #888888 #000000;
-  border-top-right-radius: 2px;
-  border-bottom-left-radius: 2px;
-  padding: 0;
-  background-color: -moz-Field;
-  color: -moz-FieldText;
-}
-
-#editBMPanel_namePicker[droppable="false"][disabled="true"] > .menulist-editable-box {
-  cursor: default;
-  -moz-border-top-colors: transparent ThreeDShadow -moz-Dialog;
-  -moz-border-right-colors: transparent ThreeDShadow -moz-Dialog;
-  -moz-border-bottom-colors: transparent ThreeDShadow -moz-Dialog;
-  -moz-border-left-colors: transparent ThreeDShadow -moz-Dialog;
-  color: GrayText;
-}
-
-#editBMPanel_namePicker[droppable="false"] > .menulist-editable-box > html|*.textbox-input {
-  margin: 0px !important;
-  border: none !important;
-  padding: 0px !important;
-  background-color: inherit;
-  color: inherit;
-  font: inherit;
-}
-
-/* Hide the drop marker and the popup. */
-
-#editBMPanel_namePicker[droppable="false"] > .menulist-dropmarker {
-  display: none;
-}
-
-#editBMPanel_namePicker[droppable="false"] > menupopup {
-  display: none;
-}
-
 /* Hide the value column of the tag autocomplete popup
  * leaving only the comment column visible. This is
  * so that only the tag being edited is shown in the
  * popup.
  */
 #editBMPanel_tagsField #treecolAutoCompleteValue {
   visibility: collapse;
 }
--- a/browser/themes/winstripe/browser/places/editBookmarkOverlay.css
+++ b/browser/themes/winstripe/browser/places/editBookmarkOverlay.css
@@ -77,45 +77,16 @@
   min-width: 23em;
 }
 
 #editBMPanel_folderTree {
   margin-top: 2px;
   margin-bottom: 2px;
 }
 
-/**** name picker ****/
-
-/* Make the microsummary picker look like a regular textbox instead of 
- * an editable menulist when no microsummaries are available.
- */
-#editBMPanel_namePicker[droppable="false"] {
-  /* These rules come from the textbox element in textbox.css. */
-  -moz-appearance: textfield; /* Normal editable menulists set this to "menulist". */
-  cursor: text;
-  border: 2px solid;
-  -moz-border-top-colors: ThreeDShadow ThreeDDarkShadow;
-  -moz-border-right-colors: ThreeDHighlight ThreeDLightShadow;
-  -moz-border-bottom-colors: ThreeDHighlight ThreeDLightShadow;
-  -moz-border-left-colors: ThreeDShadow ThreeDDarkShadow;
-  padding: 2px 2px 3px;
-  -moz-padding-start: 4px;
-  background-color: -moz-Field;
-  color: -moz-FieldText;
-}
-
-#editBMPanel_namePicker[droppable="false"] > .menulist-editable-box {
-  padding: 0;
-}
-
-#editBMPanel_namePicker[droppable="false"] > .menulist-dropmarker,
-#editBMPanel_namePicker[droppable="false"] > menupopup {
-  display: none;
-}
-
 /* Hide the value column of the tag autocomplete popup
  * leaving only the comment column visible. This is
  * so that only the tag being edited is shown in the
  * popup.
  */
 #editBMPanel_tagsField #treecolAutoCompleteValue {
   visibility: collapse;
 }
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -140,17 +140,16 @@ XPC_IDISPATCH_SUPPORT = @XPC_IDISPATCH_S
 NS_ENABLE_TSF = @NS_ENABLE_TSF@
 MOZ_SPELLCHECK = @MOZ_SPELLCHECK@
 MOZ_PROFILELOCKING = @MOZ_PROFILELOCKING@
 MOZ_FEEDS = @MOZ_FEEDS@
 MOZ_TOOLKIT_SEARCH = @MOZ_TOOLKIT_SEARCH@
 MOZ_PLACES = @MOZ_PLACES@
 MOZ_STORAGE = @MOZ_STORAGE@
 MOZ_SAFE_BROWSING = @MOZ_SAFE_BROWSING@
-MOZ_FASTSTART = @MOZ_FASTSTART@
 MOZ_URL_CLASSIFIER = @MOZ_URL_CLASSIFIER@
 MOZ_ZIPWRITER = @MOZ_ZIPWRITER@
 MOZ_MORK = @MOZ_MORK@
 MOZ_MORKREADER = @MOZ_MORKREADER@
 MOZ_NO_FAST_LOAD = @MOZ_NO_FAST_LOAD@
 MOZ_OGG = @MOZ_OGG@
 MOZ_RAW = @MOZ_RAW@
 MOZ_SYDNEYAUDIO = @MOZ_SYDNEYAUDIO@
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -86,27 +86,30 @@ endif
 
 # Add $(DIST)/lib to VPATH so that -lfoo dependencies are followed
 VPATH += $(DIST)/lib
 ifdef LIBXUL_SDK
 VPATH += $(LIBXUL_SDK)/lib
 endif
 
 # EXPAND_LIBNAME - $(call EXPAND_LIBNAME,foo)
-# expands to foo.lib on platforms with import libs and -lfoo otherwise
+# expands to $(LIB_PREFIX)foo.$(LIB_SUFFIX) or -lfoo, depending on linker
+# arguments syntax. Should only be used for system libraries
 
 # EXPAND_LIBNAME_PATH - $(call EXPAND_LIBNAME_PATH,foo,dir)
-# expands to dir/foo.lib on platforms with import libs and
-# -Ldir -lfoo otherwise
+# expands to dir/$(LIB_PREFIX)foo.$(LIB_SUFFIX)
 
 # EXPAND_MOZLIBNAME - $(call EXPAND_MOZLIBNAME,foo)
-# expands to $(DIST)/lib/foo.lib on platforms with import libs and
-# -lfoo otherwise
+# expands to $(DIST)/lib/$(LIB_PREFIX)foo.$(LIB_SUFFIX)
 
+ifdef GNU_CC
+EXPAND_LIBNAME = $(addprefix -l,$(1))
+else
 EXPAND_LIBNAME = $(foreach lib,$(1),$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
+endif
 EXPAND_LIBNAME_PATH = $(foreach lib,$(1),$(2)/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 EXPAND_MOZLIBNAME = $(foreach lib,$(1),$(DIST)/lib/$(LIB_PREFIX)$(lib).$(LIB_SUFFIX))
 
 ifdef EXTRA_DSO_LIBS
 EXTRA_DSO_LIBS	:= $(call EXPAND_MOZLIBNAME,$(EXTRA_DSO_LIBS))
 endif
 
 ################################################################################
--- a/configure.in
+++ b/configure.in
@@ -2183,19 +2183,19 @@ ia64*-hpux*)
         GCC_VERSION=`$CC -v 2>&1 | awk '/^gcc version/ { print $3 }'`
         case $GCC_VERSION in
         4.1.*|4.2.*|4.5.*)
             # -Os is broken on gcc 4.1.x 4.2.x, 4.5.x we need to tweak it to get good results.
             MOZ_OPTIMIZE_SIZE_TWEAK="-finline-limit=50"
         esac
         # If we're building with --enable-profiling, we need a frame pointer.
         if test -z "$MOZ_PROFILING"; then
-            MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fomit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK"
+            MOZ_OPTIMIZE_FLAGS="-O3 -fomit-frame-pointer"
         else
-            MOZ_OPTIMIZE_FLAGS="-Os -freorder-blocks -fno-omit-frame-pointer $MOZ_OPTIMIZE_SIZE_TWEAK"
+            MOZ_OPTIMIZE_FLAGS="-O3 -fno-omit-frame-pointer"
         fi
         MOZ_DEBUG_FLAGS="-g"
     fi
 
     TARGET_NSPR_MDCPUCFG='\"md/_linux.cfg\"'
 
     MOZ_MEMORY=1
 
@@ -3173,17 +3173,17 @@ if test "$GNU_CC"; then
   fi
 fi
 AC_SUBST(HAVE_GCC_ALIGN_ARG_POINTER)
 
 dnl Checks for header files.
 dnl ========================================================
 AC_HEADER_DIRENT
 case "$target_os" in
-freebsd*)
+freebsd*|openbsd*)
 # for stuff like -lXshm
     CPPFLAGS="${CPPFLAGS} ${X_CFLAGS}"
     ;;
 esac
 MOZ_CHECK_HEADERS(sys/byteorder.h compat.h getopt.h)
 MOZ_CHECK_HEADERS(sys/bitypes.h memory.h unistd.h)
 MOZ_CHECK_HEADERS(gnu/libc-version.h nl_types.h)
 MOZ_CHECK_HEADERS(malloc.h)
@@ -3339,21 +3339,16 @@ else
         ;;
     esac
 
     dnl ========================================================
     dnl = Check for XShm
     dnl ========================================================
     AC_CHECK_LIB(Xext, XShmCreateImage, _HAVE_XSHM_XEXT=1,,
         $XLIBS $XEXT_LIBS)
-    MOZ_CHECK_HEADER(X11/extensions/XShm.h)
-    if test "$ac_cv_header_X11_extensions_XShm_h" = "yes" &&
-        test -n "$_HAVE_XSHM_XEXT"; then
-        AC_DEFINE(HAVE_XSHM)
-    fi
 
     dnl ========================================================
     dnl = Check for Xss
     dnl ========================================================
     MOZ_CHECK_HEADER(X11/extensions/scrnsaver.h,
         AC_CHECK_LIB(Xss, XScreenSaverQueryInfo,
             [XSS_LIBS="-lXss $XEXT_LIBS $XLIBS"
              AC_DEFINE(HAVE_LIBXSS)],, $XEXT_LIBS $XLIBS))
@@ -4797,17 +4792,16 @@ MOZ_PANGO=1
 MOZ_PERMISSIONS=1
 MOZ_PLACES=1
 MOZ_PREF_EXTENSIONS=1
 MOZ_PROFILELOCKING=1
 MOZ_PSM=1
 MOZ_RDF=1
 MOZ_REFLOW_PERF=
 MOZ_SAFE_BROWSING=
-MOZ_FASTSTART=
 MOZ_HELP_VIEWER=
 MOZ_SPELLCHECK=1
 MOZ_SPLASHSCREEN=
 MOZ_STORAGE=1
 MOZ_SVG=1
 MOZ_THUMB2=
 MOZ_TIMELINE=
 MOZ_TOOLKIT_SEARCH=1
@@ -6767,28 +6761,16 @@ MOZ_ARG_ENABLE_BOOL(safe-browsing,
     MOZ_SAFE_BROWSING=1,
     MOZ_SAFE_BROWSING= )
 if test -n "$MOZ_SAFE_BROWSING"; then
     AC_DEFINE(MOZ_SAFE_BROWSING)
 fi
 AC_SUBST(MOZ_SAFE_BROWSING)
 
 dnl ========================================================
-dnl = Enable faststart component
-dnl ========================================================
-MOZ_ARG_ENABLE_BOOL(faststart,
-[  --enable-faststart      Enable the faststart component],
-    MOZ_FASTSTART=1,
-    MOZ_FASTSTART= )
-if test -n "$MOZ_FASTSTART"; then
-    AC_DEFINE(MOZ_FASTSTART)
-fi
-AC_SUBST(MOZ_FASTSTART)
-
-dnl ========================================================
 dnl = Enable url-classifier
 dnl ========================================================
 dnl Implicitly enabled by default if building with safe-browsing
 if test -n "$MOZ_SAFE_BROWSING"; then
     MOZ_URL_CLASSIFIER=1
 fi
 MOZ_ARG_ENABLE_BOOL(url-classifier,
 [  --enable-url-classifier Enable url classifier module],
@@ -9036,16 +9018,17 @@ if test "$MOZ_X11"; then
     dnl ====================================================
     _SAVE_CFLAGS=$CFLAGS
     CFLAGS="$CFLAGS $XCFLAGS"
     AC_TRY_COMPILE([
         #include <stdio.h>
         #include <stdlib.h>
         #include <X11/Xlib.h>
         #include <X11/Intrinsic.h>
+        #include <X11/extensions/XShm.h>
     ],
     [
         Display *dpy = 0;
         if ((dpy = XOpenDisplay(NULL)) == NULL) {
             fprintf(stderr, ": can't open %s\n", XDisplayName(NULL));
             exit(1);
         }
     ], [], 
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -560,17 +560,17 @@ public:
   /**
    * Determine whether aContent is in some way associated with aForm.  If the
    * form is a container the only elements that are considered to be associated
    * with a form are the elements that are contained within the form. If the
    * form is a leaf element then all elements will be accepted into this list,
    * since this can happen due to content fixup when a form spans table rows or
    * table cells.
    */
-  static PRBool BelongsInForm(nsIDOMHTMLFormElement *aForm,
+  static PRBool BelongsInForm(nsIContent *aForm,
                               nsIContent *aContent);
 
   static nsresult CheckQName(const nsAString& aQualifiedName,
                              PRBool aNamespaceAware = PR_TRUE);
 
   static nsresult SplitQName(const nsIContent* aNamespaceResolver,
                              const nsAFlatString& aQName,
                              PRInt32 *aNamespace, nsIAtom **aLocalName);
@@ -1167,16 +1167,22 @@ public:
   static void DestroyMatchString(void* aData)
   {
     if (aData) {
       nsString* matchString = static_cast<nsString*>(aData);
       delete matchString;
     }
   }
 
+  static void DropScriptObject(PRUint32 aLangID, void *aObject,
+                               const char *name, void *aClosure)
+  {
+    DropScriptObject(aLangID, aObject, aClosure);
+  }
+
   /**
    * Unbinds the content from the tree and nulls it out if it's not null.
    */
   static void DestroyAnonymousContent(nsCOMPtr<nsIContent>* aContent);
 
   /**
    * Keep script object aNewObject, held by aScriptObjectHolder, alive.
    *
@@ -1273,17 +1279,17 @@ public:
     }
   }
   static void TraceWrapper(nsWrapperCache* aCache, TraceCallback aCallback,
                            void *aClosure)
   {
     if (aCache->PreservingWrapper()) {
       aCallback(nsIProgrammingLanguage::JAVASCRIPT,
                 aCache->GetWrapperPreserveColor(),
-                aClosure);
+                "Preserved wrapper", aClosure);
     }
   }
 
   /**
    * Convert nsIContent::IME_STATUS_* to nsIWidget::IME_STATUS_*
    */
   static PRUint32 GetWidgetStatusFromIMEStatus(PRUint32 aState);
 
@@ -1767,16 +1773,35 @@ public:
       TYPE_UNKNOWN
   };
 
   static already_AddRefed<nsIDocumentLoaderFactory>
   FindInternalContentViewer(const char* aType,
                             ContentViewerType* aLoaderType = nsnull);
 
   /**
+   * This helper method returns true if the aPattern pattern matches aValue.
+   * aPattern should not contain leading and trailing slashes (/).
+   * The pattern has to match the entire value not just a subset.
+   * aDocument must be a valid pointer (not null).
+   *
+   * This is following the HTML5 specification:
+   * http://dev.w3.org/html5/spec/forms.html#attr-input-pattern
+   *
+   * WARNING: This method mutates aPattern and aValue!
+   *
+   * @param aValue    the string to check.
+   * @param aPattern  the string defining the pattern.
+   * @param aDocument the owner document of the element.
+   * @result          whether the given string is matches the pattern.
+   */
+  static PRBool IsPatternMatching(nsAString& aValue, nsAString& aPattern,
+                                  nsIDocument* aDocument);
+
+  /**
    * Calling this adds support for
    * ontouch* event handler DOM attributes.
    */
   static void InitializeTouchEventTable();
 private:
   static PRBool InitializeEventTable();
 
   static nsresult EnsureStringBundle(PropertiesFile aFile);
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -1116,16 +1116,48 @@ public:
         return nsnull;
       }
       cur = parent;
     }
     NS_NOTREACHED("How did we get here?");
   }
 
   /**
+   * Get the previous nsIContent in the pre-order tree traversal of the DOM.  If
+   * aRoot is non-null, then it must be an ancestor of |this|
+   * (possibly equal to |this|) and only nsIContents that are descendants of
+   * aRoot, including aRoot itself, will be returned.  Returns
+   * null if there are no more nsIContents to traverse.
+   */
+  nsIContent* GetPreviousContent(const nsINode* aRoot = nsnull) const
+  {
+      // Can't use nsContentUtils::ContentIsDescendantOf here, since we
+      // can't include it here.
+#ifdef DEBUG
+      if (aRoot) {
+        const nsINode* cur = this;
+        for (; cur; cur = cur->GetNodeParent())
+          if (cur == aRoot) break;
+        NS_ASSERTION(cur, "aRoot not an ancestor of |this|?");
+      }
+#endif
+
+    if (this == aRoot) {
+      return nsnull;
+    }
+    nsIContent* cur = this->GetParent();
+    nsIContent* iter = this->GetPreviousSibling();
+    while (iter) {
+      cur = iter;
+      iter = reinterpret_cast<nsINode*>(iter)->GetLastChild();
+    }
+    return cur;
+  }
+
+  /**
    * Boolean flags
    */
 private:
   enum BooleanFlag {
     // Set if we're being used from -moz-element
     NodeHasRenderingObservers,
     // Set if our parent chain (including this node itself) terminates
     // in a document
--- a/content/base/public/nsINodeList.h
+++ b/content/base/public/nsINodeList.h
@@ -34,43 +34,51 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsINodeList_h___
 #define nsINodeList_h___
 
 #include "nsIDOMNodeList.h"
+#include "nsWrapperCache.h"
 
+class nsINode;
 class nsIContent;
 
 // IID for the nsINodeList interface
 #define NS_INODELIST_IID \
-{ 0x57ac9ea2, 0xe95f, 0x4856, \
- { 0xbb, 0xac, 0x82, 0x2d, 0x65, 0xb1, 0x92, 0x57 } }
+{ 0xa842c1b5, 0x9a6f, 0x4afa, \
+ { 0x9c, 0x1c, 0xf5, 0xf7, 0xdc, 0x70, 0x82, 0xd9 } }
 
 /**
  * An internal interface that allows QI-less getting of nodes from
  * node lists and reasonably fast indexOf.
  */
-class nsINodeList : public nsIDOMNodeList
+class nsINodeList : public nsIDOMNodeList,
+                    public nsWrapperCache
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_INODELIST_IID)
 
   /**
    * Get the node at the index.  Returns null if the index is out of bounds
    */
   virtual nsIContent* GetNodeAt(PRUint32 aIndex) = 0;
 
   /**
    * Get the index of the given node in the list.  Will return -1 if the node
    * is not in the list.
    */
   virtual PRInt32 IndexOf(nsIContent* aContent) = 0;
+
+  /**
+   * Get the root node for this nodelist.
+   */
+  virtual nsINode* GetParentObject() = 0;
 };
 
 #define NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                  \
   NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINodeList)
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsINodeList, NS_INODELIST_IID)
 
 #endif /* nsINodeList_h___ */
--- a/content/base/src/nsContentAreaDragDrop.cpp
+++ b/content/base/src/nsContentAreaDragDrop.cpp
@@ -49,17 +49,16 @@
 #include "nsIDOMNSUIEvent.h"
 #include "nsIDOMUIEvent.h"
 #include "nsISelection.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIDOMDragEvent.h"
-#include "nsIDOMAbstractView.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentRange.h"
 #include "nsIDOMRange.h"
 #include "nsIFormControl.h"
 #include "nsIDOMHTMLAreaElement.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsITransferable.h"
--- a/content/base/src/nsContentList.cpp
+++ b/content/base/src/nsContentList.cpp
@@ -85,16 +85,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 #define NS_CONTENT_LIST_INTERFACES(_class)                                    \
     NS_INTERFACE_TABLE_ENTRY(_class, nsINodeList)                             \
     NS_INTERFACE_TABLE_ENTRY(_class, nsIDOMNodeList)
 
 DOMCI_DATA(NodeList, nsBaseContentList)
 
 // QueryInterface implementation for nsBaseContentList
 NS_INTERFACE_TABLE_HEAD(nsBaseContentList)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsBaseContentList)
     NS_CONTENT_LIST_INTERFACES(nsBaseContentList)
   NS_OFFSET_AND_INTERFACE_TABLE_END
   NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsBaseContentList)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(NodeList)
 NS_INTERFACE_MAP_END
 
@@ -155,27 +156,44 @@ void nsBaseContentList::RemoveElement(ns
 }
 
 void nsBaseContentList::InsertElementAt(nsIContent* aContent, PRInt32 aIndex)
 {
   NS_ASSERTION(aContent, "Element to insert must not be null");
   mElements.InsertObjectAt(aContent, aIndex);
 }
 
+
+NS_IMPL_CYCLE_COLLECTION_CLASS(nsSimpleContentList)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsSimpleContentList,
+                                                  nsBaseContentList)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mRoot)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsSimpleContentList,
+                                                nsBaseContentList)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mRoot)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsSimpleContentList)
+NS_INTERFACE_MAP_END_INHERITING(nsBaseContentList)
+
+
+NS_IMPL_ADDREF_INHERITED(nsSimpleContentList, nsBaseContentList)
+NS_IMPL_RELEASE_INHERITED(nsSimpleContentList, nsBaseContentList)
+
 // nsFormContentList
 
-nsFormContentList::nsFormContentList(nsIDOMHTMLFormElement *aForm,
+nsFormContentList::nsFormContentList(nsIContent *aForm,
                                      nsBaseContentList& aContentList)
-  : nsBaseContentList()
+  : nsSimpleContentList(aForm)
 {
 
   // move elements that belong to mForm into this content list
 
   PRUint32 i, length = 0;
-
   aContentList.GetLength(&length);
 
   for (i = 0; i < length; i++) {
     nsIContent *c = aContentList.GetNodeAt(i);
     if (c && nsContentUtils::BelongsInForm(aForm, c)) {
       AppendElement(c);
     }
   }
@@ -470,17 +488,16 @@ nsContentList::~nsContentList()
     (*mDestroyFunc)(mData);
   }
 }
 
 DOMCI_DATA(ContentList, nsContentList)
 
 // QueryInterface implementation for nsContentList
 NS_INTERFACE_TABLE_HEAD(nsContentList)
-  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
   NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(nsContentList)
     NS_CONTENT_LIST_INTERFACES(nsContentList)
     NS_INTERFACE_TABLE_ENTRY(nsContentList, nsIHTMLCollection)
     NS_INTERFACE_TABLE_ENTRY(nsContentList, nsIDOMHTMLCollection)
     NS_INTERFACE_TABLE_ENTRY(nsContentList, nsIMutationObserver)
   NS_OFFSET_AND_INTERFACE_TABLE_END
   NS_OFFSET_AND_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(ContentList)
--- a/content/base/src/nsContentList.h
+++ b/content/base/src/nsContentList.h
@@ -69,17 +69,16 @@
 typedef PRBool (*nsContentListMatchFunc)(nsIContent* aContent,
                                          PRInt32 aNamespaceID,
                                          nsIAtom* aAtom,
                                          void* aData);
 
 typedef void (*nsContentListDestroyFunc)(void* aData);
 
 class nsIDocument;
-class nsIDOMHTMLFormElement;
 
 
 class nsBaseContentList : public nsINodeList
 {
 public:
   virtual ~nsBaseContentList();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@@ -121,23 +120,45 @@ public:
 
   virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush);
 
 protected:
   nsCOMArray<nsIContent> mElements;
 };
 
 
+class nsSimpleContentList : public nsBaseContentList
+{
+public:
+  nsSimpleContentList(nsINode *aRoot) : nsBaseContentList(),
+                                        mRoot(aRoot)
+  {
+  }
+
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsSimpleContentList,
+                                           nsBaseContentList)
+
+  virtual nsINode* GetParentObject()
+  {
+    return mRoot;
+  }
+
+private:
+  // This has to be a strong reference, the root might go away before the list.
+  nsCOMPtr<nsINode> mRoot;
+};
+
 // This class is used only by form element code and this is a static
 // list of elements. NOTE! This list holds strong references to
 // the elements in the list.
-class nsFormContentList : public nsBaseContentList
+class nsFormContentList : public nsSimpleContentList
 {
 public:
-  nsFormContentList(nsIDOMHTMLFormElement *aForm,
+  nsFormContentList(nsIContent *aForm,
                     nsBaseContentList& aContentList);
 };
 
 /**
  * Class that's used as the key to hash nsContentList implementations
  * for fast retrieval
  */
 struct nsContentListKey
@@ -192,18 +213,17 @@ struct nsContentListKey
 #define LIST_LAZY 2
 
 /**
  * Class that implements a live NodeList that matches Elements in the
  * tree based on some criterion.
  */
 class nsContentList : public nsBaseContentList,
                       public nsIHTMLCollection,
-                      public nsStubMutationObserver,
-                      public nsWrapperCache
+                      public nsStubMutationObserver
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   /**
    * @param aRootNode The node under which to limit our search.
    * @param aMatchAtom An atom whose meaning depends on aMatchNameSpaceId.
    *                   The special value "*" always matches whatever aMatchAtom
@@ -253,24 +273,27 @@ public:
 
   // nsIDOMHTMLCollection
   NS_DECL_NSIDOMHTMLCOLLECTION
 
   // nsBaseContentList overrides
   virtual PRInt32 IndexOf(nsIContent *aContent, PRBool aDoFlush);
   virtual nsIContent* GetNodeAt(PRUint32 aIndex);
   virtual PRInt32 IndexOf(nsIContent* aContent);
+  virtual nsINode* GetParentObject()
+  {
+    return mRootNode;
+  }
 
   // nsIHTMLCollection
   // GetNodeAt already declared as part of nsINodeList
   virtual nsISupports* GetNamedItem(const nsAString& aName,
                                     nsWrapperCache** aCache);
 
   // nsContentList public methods
-  NS_HIDDEN_(nsINode*) GetParentObject() { return mRootNode; }
   NS_HIDDEN_(PRUint32) Length(PRBool aDoFlush);
   NS_HIDDEN_(nsIContent*) Item(PRUint32 aIndex, PRBool aDoFlush);
   NS_HIDDEN_(nsIContent*) NamedItem(const nsAString& aName, PRBool aDoFlush);
 
   // nsIMutationObserver
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -163,17 +163,16 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_
 #include "nsIChannelEventSink.h"
 #include "nsIAsyncVerifyRedirectCallback.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsCPrefetchService.h"
 #include "nsIChromeRegistry.h"
 #include "nsIMIMEHeaderParam.h"
 #include "nsIDOMXULCommandEvent.h"
-#include "nsIDOMAbstractView.h"
 #include "nsIDOMDragEvent.h"
 #include "nsDOMDataTransfer.h"
 #include "nsHtml5Module.h"
 #include "nsPresContext.h"
 #include "nsLayoutStatics.h"
 #include "nsLayoutUtils.h"
 #include "nsFrameManager.h"
 #include "BasicLayers.h"
@@ -2208,68 +2207,60 @@ nsContentUtils::NewURIWithDocumentCharse
 {
   return NS_NewURI(aResult, aSpec,
                    aDocument ? aDocument->GetDocumentCharacterSet().get() : nsnull,
                    aBaseURI, sIOService);
 }
 
 // static
 PRBool
-nsContentUtils::BelongsInForm(nsIDOMHTMLFormElement *aForm,
+nsContentUtils::BelongsInForm(nsIContent *aForm,
                               nsIContent *aContent)
 {
   NS_PRECONDITION(aForm, "Must have a form");
   NS_PRECONDITION(aContent, "Must have a content node");
 
-  nsCOMPtr<nsIContent> form(do_QueryInterface(aForm));
-
-  if (!form) {
-    NS_ERROR("This should not happen, form is not an nsIContent!");
-
-    return PR_TRUE;
-  }
-
-  if (form == aContent) {
+  if (aForm == aContent) {
     // A form does not belong inside itself, so we return false here
 
     return PR_FALSE;
   }
 
   nsIContent* content = aContent->GetParent();
 
   while (content) {
-    if (content == form) {
+    if (content == aForm) {
       // aContent is contained within the form so we return true.
 
       return PR_TRUE;
     }
 
     if (content->Tag() == nsGkAtoms::form &&
         content->IsHTML()) {
       // The child is contained within a form, but not the right form
       // so we ignore it.
 
       return PR_FALSE;
     }
 
     content = content->GetParent();
   }
 
-  if (form->GetChildCount() > 0) {
+  if (aForm->GetChildCount() > 0) {
     // The form is a container but aContent wasn't inside the form,
     // return false
 
     return PR_FALSE;
   }
 
   // The form is a leaf and aContent wasn't inside any other form so
   // we check whether the content comes after the form.  If it does,
   // return true.  If it does not, then it couldn't have been inside
   // the form in the HTML.
-  if (PositionIsBefore(form, aContent)) {
+  if (PositionIsBefore(aForm, aContent)) {
     // We could be in this form!
     // In the future, we may want to get document.forms, look at the
     // form after aForm, and if aContent is after that form after
     // aForm return false here....
     return PR_TRUE;
   }
 
   return PR_FALSE;
@@ -5526,19 +5517,18 @@ nsContentUtils::DispatchXULCommand(nsICo
   nsCOMPtr<nsIDOMDocumentEvent> docEvent = do_QueryInterface(doc);
   NS_ENSURE_STATE(docEvent);
   nsCOMPtr<nsIDOMEvent> event;
   docEvent->CreateEvent(NS_LITERAL_STRING("xulcommandevent"),
                         getter_AddRefs(event));
   nsCOMPtr<nsIDOMXULCommandEvent> xulCommand = do_QueryInterface(event);
   nsCOMPtr<nsIPrivateDOMEvent> pEvent = do_QueryInterface(xulCommand);
   NS_ENSURE_STATE(pEvent);
-  nsCOMPtr<nsIDOMAbstractView> view = do_QueryInterface(doc->GetWindow());
   nsresult rv = xulCommand->InitCommandEvent(NS_LITERAL_STRING("command"),
-                                             PR_TRUE, PR_TRUE, view,
+                                             PR_TRUE, PR_TRUE, doc->GetWindow(),
                                              0, aCtrl, aAlt, aShift, aMeta,
                                              aSourceEvent);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (aShell) {
     nsEventStatus status = nsEventStatus_eIgnore;
     nsCOMPtr<nsIPresShell> kungFuDeathGrip = aShell;
     return aShell->HandleDOMEventWithTarget(aTarget, event, &status);
@@ -6235,17 +6225,18 @@ public:
 
   PRBool mFound;
 
 private:
   void* mWrapper;
 };
 
 static void
-DebugWrapperTraceCallback(PRUint32 langID, void *p, void *closure)
+DebugWrapperTraceCallback(PRUint32 langID, void *p, const char *name,
+                          void *closure)
 {
   DebugWrapperTraversalCallback* callback =
     static_cast<DebugWrapperTraversalCallback*>(closure);
   callback->NoteScriptChild(langID, p);
 }
 
 // static
 void
@@ -6554,8 +6545,42 @@ nsContentUtils::FindInternalContentViewe
       }
     }
   }
 #endif
 #endif // MOZ_MEDIA
 
   return NULL;
 }
+
+// static
+PRBool
+nsContentUtils::IsPatternMatching(nsAString& aValue, nsAString& aPattern,
+                                  nsIDocument* aDocument)
+{
+  NS_ASSERTION(aDocument, "aDocument should be a valid pointer (not null)");
+  NS_ENSURE_TRUE(aDocument->GetScriptGlobalObject(), PR_TRUE);
+
+  JSContext* ctx = (JSContext*) aDocument->GetScriptGlobalObject()->
+                                  GetContext()->GetNativeContext();
+  NS_ENSURE_TRUE(ctx, PR_TRUE);
+
+  JSAutoRequest ar(ctx);
+
+  // The pattern has to match the entire value.
+  aPattern.Insert(NS_LITERAL_STRING("^(?:"), 0);
+  aPattern.Append(NS_LITERAL_STRING(")$"));
+
+  JSObject* re = JS_NewUCRegExpObjectNoStatics(ctx, reinterpret_cast<jschar*>
+                                                 (aPattern.BeginWriting()),
+                                                aPattern.Length(), 0);
+  NS_ENSURE_TRUE(re, PR_TRUE);
+
+  jsval rval = JSVAL_NULL;
+  size_t idx = 0;
+  JSBool res;
+
+  res = JS_ExecuteRegExpNoStatics(ctx, re, reinterpret_cast<jschar*>
+                                    (aValue.BeginWriting()),
+                                  aValue.Length(), &idx, JS_TRUE, &rval);
+
+  return res == JS_FALSE || rval != JSVAL_NULL;
+}
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -70,18 +70,16 @@
 
 #include "nsGUIEvent.h"
 #include "nsPLDOMEvent.h"
 
 #include "nsIDOMStyleSheet.h"
 #include "nsDOMAttribute.h"
 #include "nsIDOMDOMStringList.h"
 #include "nsIDOMDOMImplementation.h"
-#include "nsIDOMDocumentView.h"
-#include "nsIDOMAbstractView.h"
 #include "nsIDOMDocumentXBL.h"
 #include "mozilla/FunctionTimer.h"
 #include "nsGenericElement.h"
 #include "nsGenericHTMLElement.h"
 #include "nsIDOMEventGroup.h"
 #include "nsIDOMCDATASection.h"
 #include "nsIDOMProcessingInstruction.h"
 #include "nsDOMString.h"
@@ -210,17 +208,17 @@ using namespace mozilla::dom;
 typedef nsTArray<Link*> LinkArray;
 
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo* gDocumentLeakPRLog;
 static PRLogModuleInfo* gCspPRLog;
 #endif
 
-#define NAME_NOT_VALID ((nsBaseContentList*)1)
+#define NAME_NOT_VALID ((nsSimpleContentList*)1)
 
 nsIdentifierMapEntry::~nsIdentifierMapEntry()
 {
 }
 
 void
 nsIdentifierMapEntry::Traverse(nsCycleCollectionTraversalCallback* aCallback)
 {
@@ -418,20 +416,20 @@ nsIdentifierMapEntry::SetImageElement(El
   mImageElement = aElement;
   Element* newElement = GetImageIdElement();
   if (oldElement != newElement) {
     FireChangeCallbacks(oldElement, newElement, PR_TRUE);
   }
 }
 
 void
-nsIdentifierMapEntry::AddNameElement(Element* aElement)
+nsIdentifierMapEntry::AddNameElement(nsIDocument* aDocument, Element* aElement)
 {
   if (!mNameContentList) {
-    mNameContentList = new nsBaseContentList();
+    mNameContentList = new nsSimpleContentList(aDocument);
   }
 
   mNameContentList->AppendElement(aElement);
 }
 
 void
 nsIdentifierMapEntry::RemoveNameElement(Element* aElement)
 {
@@ -1591,16 +1589,22 @@ nsDocument::~nsDocument()
 
   // Clear mObservers to keep it in sync with the mutationobserver list
   mObservers.Clear();
 
   if (mStyleSheetSetList) {
     mStyleSheetSetList->Disconnect();
   }
 
+#ifdef MOZ_SMIL
+  if (mAnimationController) {
+    mAnimationController->Disconnect();
+  }
+#endif // MOZ_SMIL
+
   mParentDocument = nsnull;
 
   // Kill the subdocument map, doing this will release its strong
   // references, if any.
   if (mSubDocuments) {
     PL_DHashTableDestroy(mSubDocuments);
 
     mSubDocuments = nsnull;
@@ -2554,17 +2558,17 @@ nsDocument::GetLastModified(nsAString& a
 void
 nsDocument::AddToNameTable(Element *aElement, nsIAtom* aName)
 {
   nsIdentifierMapEntry *entry =
     mIdentifierMap.PutEntry(nsDependentAtomString(aName));
 
   // Null for out-of-memory
   if (entry) {
-    entry->AddNameElement(aElement);
+    entry->AddNameElement(this, aElement);
   }
 }
 
 void
 nsDocument::RemoveFromNameTable(Element *aElement, nsIAtom* aName)
 {
   // Speed up document teardown
   if (mIdentifierMap.Count() == 0)
@@ -2841,17 +2845,17 @@ nsDocument::NodesFromRectHelper(float aX
                                 float aTopSize, float aRightSize,
                                 float aBottomSize, float aLeftSize,
                                 PRBool aIgnoreRootScrollFrame,
                                 PRBool aFlushLayout,
                                 nsIDOMNodeList** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   
-  nsBaseContentList* elements = new nsBaseContentList();
+  nsSimpleContentList* elements = new nsSimpleContentList(this);
   NS_ADDREF(elements);
   *aReturn = elements;
 
   // Following the same behavior of elementFromPoint,
   // we don't return anything if either coord is negative
   if (!aIgnoreRootScrollFrame && (aX < 0 || aY < 0))
     return NS_OK;
 
@@ -5066,26 +5070,24 @@ nsDocument::CreateTreeWalker(nsIDOMNode 
 
   NS_ADDREF(*_retval = walker);
 
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsDocument::GetDefaultView(nsIDOMAbstractView** aDefaultView)
-{
+nsDocument::GetDefaultView(nsIDOMWindow** aDefaultView)
+{
+  *aDefaultView = nsnull;
   nsPIDOMWindow* win = GetWindow();
-  if (win) {
-    return CallQueryInterface(win, aDefaultView);
-  }
-
-  *aDefaultView = nsnull;
-
-  return NS_OK;
+  if (!win) {
+    return NS_OK;
+  }
+  return CallQueryInterface(win, aDefaultView);
 }
 
 NS_IMETHODIMP
 nsDocument::GetLocation(nsIDOMLocation **_retval)
 {
   NS_ENSURE_ARG_POINTER(_retval);
   *_retval = nsnull;
 
@@ -5522,17 +5524,17 @@ nsDocument::GetAnimationController()
   // one and only SVG documents and the like will call this
   if (mAnimationController)
     return mAnimationController;
   // Refuse to create an Animation Controller if SMIL is disabled, and also
   // for data documents.
   if (!NS_SMILEnabled() || mLoadedAsData || mLoadedAsInteractiveData)
     return nsnull;
 
-  mAnimationController = NS_NewSMILAnimationController(this);
+  mAnimationController = new nsSMILAnimationController(this);
   
   // If there's a presContext then check the animation mode and pause if
   // necessary.
   nsIPresShell *shell = GetShell();
   if (mAnimationController && shell) {
     nsPresContext *context = shell->GetPresContext();
     if (context &&
         context->ImageAnimationMode() == imgIContainer::kDontAnimMode) {
@@ -8320,74 +8322,74 @@ nsDocument::SetImagesNeedAnimating(PRBoo
                                          : DecrementAnimationEnumerator,
                               nsnull);
 
   // Update state.
   mAnimatingImages = aAnimating;
 }
 
 NS_IMETHODIMP
-nsDocument::CreateTouch(nsIDOMAbstractView* aView,
+nsDocument::CreateTouch(nsIDOMWindow* aView,
                         nsIDOMEventTarget* aTarget,
                         PRInt32 aIdentifier,
                         PRInt32 aPageX,
                         PRInt32 aPageY,
                         PRInt32 aScreenX,
                         PRInt32 aScreenY,
                         PRInt32 aClientX,
                         PRInt32 aClientY,
                         PRInt32 aRadiusX,
                         PRInt32 aRadiusY,
                         float aRotationAngle,
                         float aForce,
-                        nsIDOMTouchPoint** aRetVal)
-{
-  NS_ADDREF(*aRetVal = new nsDOMTouchPoint(aTarget,
-                                           aIdentifier,
-                                           aPageX,
-                                           aPageY,
-                                           aScreenX,
-                                           aScreenY,
-                                           aClientX,
-                                           aClientY,
-                                           aRadiusX,
-                                           aRadiusY,
-                                           aRotationAngle,
-                                           aForce));
-  return NS_OK;;
+                        nsIDOMTouch** aRetVal)
+{
+  NS_ADDREF(*aRetVal = new nsDOMTouch(aTarget,
+                                      aIdentifier,
+                                      aPageX,
+                                      aPageY,
+                                      aScreenX,
+                                      aScreenY,
+                                      aClientX,
+                                      aClientY,
+                                      aRadiusX,
+                                      aRadiusY,
+                                      aRotationAngle,
+                                      aForce));
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::CreateTouchList(nsIVariant* aPoints,
                             nsIDOMTouchList** aRetVal)
 {
   nsRefPtr<nsDOMTouchList> retval = new nsDOMTouchList();
   if (aPoints) {
     PRUint16 type;
     aPoints->GetDataType(&type);
     if (type == nsIDataType::VTYPE_INTERFACE ||
         type == nsIDataType::VTYPE_INTERFACE_IS) {
       nsCOMPtr<nsISupports> data;
       aPoints->GetAsISupports(getter_AddRefs(data));
-      nsCOMPtr<nsIDOMTouchPoint> point = do_QueryInterface(data);
+      nsCOMPtr<nsIDOMTouch> point = do_QueryInterface(data);
       if (point) {
         retval->Append(point);
       }
     } else if (type == nsIDataType::VTYPE_ARRAY) {
       PRUint16 valueType;
       nsIID iid;
       PRUint32 valueCount;
       void* rawArray;
       aPoints->GetAsArray(&valueType, &iid, &valueCount, &rawArray);
       if (valueType == nsIDataType::VTYPE_INTERFACE ||
           valueType == nsIDataType::VTYPE_INTERFACE_IS) {
         nsISupports** values = static_cast<nsISupports**>(rawArray);
         for (PRUint32 i = 0; i < valueCount; ++i) {
           nsCOMPtr<nsISupports> supports = dont_AddRef(values[i]);
-          nsCOMPtr<nsIDOMTouchPoint> point = do_QueryInterface(supports);
+          nsCOMPtr<nsIDOMTouch> point = do_QueryInterface(supports);
           if (point) {
             retval->Append(point);
           }
         }
       }
       nsMemory::Free(rawArray);
     }
   }
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -47,17 +47,16 @@
 #include "nsCRT.h"
 #include "nsIDocument.h"
 #include "nsWeakReference.h"
 #include "nsWeakPtr.h"
 #include "nsVoidArray.h"
 #include "nsTArray.h"
 #include "nsHashSets.h"
 #include "nsIDOMXMLDocument.h"
-#include "nsIDOMDocumentView.h"
 #include "nsIDOMDocumentXBL.h"
 #include "nsIDOMNSDocument.h"
 #include "nsIDOMNSDocumentStyle.h"
 #include "nsIDOMDocumentRange.h"
 #include "nsIDOMDocumentTraversal.h"
 #include "nsStubDocumentObserver.h"
 #include "nsIDOM3EventTarget.h"
 #include "nsIDOMNSEventTarget.h"
@@ -162,17 +161,17 @@ public:
     nsStringHashKey(&aOther.GetKey())
   {
     NS_ERROR("Should never be called");
   }
   ~nsIdentifierMapEntry();
 
   void SetInvalidName();
   PRBool IsInvalidName();
-  void AddNameElement(Element* aElement);
+  void AddNameElement(nsIDocument* aDocument, Element* aElement);
   void RemoveNameElement(Element* aElement);
   PRBool IsEmpty();
   nsBaseContentList* GetNameContentList() {
     return mNameContentList;
   }
 
   /**
    * Returns the element if we know the element associated with this
@@ -494,17 +493,16 @@ protected:
 // nsIDOMXMLDocument unless someone writes a real implementation of
 // the interface.
 class nsDocument : public nsIDocument,
                    public nsIDOMXMLDocument, // inherits nsIDOMDocument
                    public nsIDOMNSDocument,
                    public nsIDOMDocumentEvent,
                    public nsIDOM3DocumentEvent,
                    public nsIDOMNSDocumentStyle,
-                   public nsIDOMDocumentView,
                    public nsIDOMDocumentRange,
                    public nsIDOMDocumentTraversal,
                    public nsIDOMDocumentXBL,
                    public nsSupportsWeakReference,
                    public nsIDOMEventTarget,
                    public nsIDOM3EventTarget,
                    public nsIDOMNSEventTarget,
                    public nsIScriptObjectPrincipal,
@@ -811,19 +809,16 @@ public:
   NS_DECL_NSIDOM3DOCUMENTEVENT
 
   // nsIDOMDocumentStyle
   NS_DECL_NSIDOMDOCUMENTSTYLE
 
   // nsIDOMNSDocumentStyle
   NS_DECL_NSIDOMNSDOCUMENTSTYLE
 
-  // nsIDOMDocumentView
-  NS_DECL_NSIDOMDOCUMENTVIEW
-
   // nsIDOMDocumentRange
   NS_DECL_NSIDOMDOCUMENTRANGE
 
   // nsIDOMDocumentTraversal
   NS_DECL_NSIDOMDOCUMENTTRAVERSAL
 
   // nsIDOMDocumentXBL
   NS_DECL_NSIDOMDOCUMENTXBL
@@ -1263,15 +1258,14 @@ protected:
 #endif
 };
 
 #define NS_DOCUMENT_INTERFACE_TABLE_BEGIN(_class)                             \
   NS_NODE_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                            \
   NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocument, nsDocument)      \
   NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNSDocument, nsDocument)    \
   NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentEvent, nsDocument) \
-  NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentView, nsDocument)  \
   NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMDocumentTraversal,         \
                                      nsDocument)                              \
   NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMEventTarget, nsDocument)   \
   NS_INTERFACE_TABLE_ENTRY_AMBIGUOUS(_class, nsIDOMNode, nsDocument)
 
 #endif /* nsDocument_h___ */
--- a/content/base/src/nsGenericElement.cpp
+++ b/content/base/src/nsGenericElement.cpp
@@ -87,17 +87,16 @@
 #ifdef MOZ_XUL
 #include "nsXULElement.h"
 #endif /* MOZ_XUL */
 #include "nsFrameManager.h"
 #include "nsFrameSelection.h"
 
 #include "nsBindingManager.h"
 #include "nsXBLBinding.h"
-#include "nsIDOMViewCSS.h"
 #include "nsIXBLService.h"
 #include "nsPIDOMWindow.h"
 #include "nsIBoxObject.h"
 #include "nsPIBoxObject.h"
 #include "nsIDOMNSDocument.h"
 #include "nsIDOMNSElement.h"
 #include "nsClientRect.h"
 #ifdef MOZ_SVG
@@ -2278,28 +2277,25 @@ nsGenericElement::InternalIsSupported(ns
         PL_strcmp(v, "2.0") == 0) {
       *aReturn = PR_TRUE;
     }
   } else if (PL_strcasecmp(f, "XPath") == 0) {
     if (aVersion.IsEmpty() ||
         PL_strcmp(v, "3.0") == 0) {
       *aReturn = PR_TRUE;
     }
-  }
-#ifdef MOZ_SVG
-  else if (PL_strcasecmp(f, "SVGEvents") == 0 ||
-           PL_strcasecmp(f, "SVGZoomEvents") == 0 ||
-           nsSVGFeatures::HaveFeature(aFeature)) {
+  } else if (PL_strcasecmp(f, "SVGEvents") == 0 ||
+             PL_strcasecmp(f, "SVGZoomEvents") == 0 ||
+             nsSVGFeatures::HaveFeature(aObject, aFeature)) {
     if (aVersion.IsEmpty() ||
         PL_strcmp(v, "1.0") == 0 ||
         PL_strcmp(v, "1.1") == 0) {
       *aReturn = PR_TRUE;
     }
   }
-#endif /* MOZ_SVG */
 #ifdef MOZ_SMIL
   else if (NS_SMILEnabled() && PL_strcasecmp(f, "TimeControl") == 0) {
     if (aVersion.IsEmpty() || PL_strcmp(v, "1.0") == 0) {
       *aReturn = PR_TRUE;
     }
   }
 #endif /* MOZ_SMIL */
   else {
@@ -3074,17 +3070,17 @@ nsGenericElement::UnbindFromTree(PRBool 
   }
 
   nsNodeUtils::ParentChainChanged(this);
 }
 
 already_AddRefed<nsINodeList>
 nsGenericElement::GetChildren(PRUint32 aFilter)
 {
-  nsRefPtr<nsBaseContentList> list = new nsBaseContentList();
+  nsRefPtr<nsSimpleContentList> list = new nsSimpleContentList(this);
   if (!list) {
     return nsnull;
   }
 
   nsIFrame *frame = GetPrimaryFrame();
 
   // Append :before generated content.
   if (frame) {
@@ -5523,17 +5519,17 @@ nsGenericElement::doQuerySelector(nsINod
 /* static */
 nsresult
 nsGenericElement::doQuerySelectorAll(nsINode* aRoot,
                                      const nsAString& aSelector,
                                      nsIDOMNodeList **aReturn)
 {
   NS_PRECONDITION(aReturn, "Null out param?");
 
-  nsBaseContentList* contentList = new nsBaseContentList();
+  nsSimpleContentList* contentList = new nsSimpleContentList(aRoot);
   NS_ENSURE_TRUE(contentList, NS_ERROR_OUT_OF_MEMORY);
   NS_ADDREF(*aReturn = contentList);
   
   nsAutoPtr<nsCSSSelectorList> selectorList;
   nsresult rv = ParseSelectorList(aRoot, aSelector,
                                   getter_Transfers(selectorList));
   NS_ENSURE_SUCCESS(rv, rv);
 
--- a/content/base/src/nsGenericElement.h
+++ b/content/base/src/nsGenericElement.h
@@ -90,18 +90,17 @@ struct nsRect;
 typedef PRUptrdiff PtrBits;
 
 /**
  * Class that implements the nsIDOMNodeList interface (a list of children of
  * the content), by holding a reference to the content and delegating GetLength
  * and Item to its existing child list.
  * @see nsIDOMNodeList
  */
-class nsChildContentList : public nsINodeList,
-                           public nsWrapperCache
+class nsChildContentList : public nsINodeList
 {
 public:
   nsChildContentList(nsINode* aNode)
     : mNode(aNode)
   {
   }
 
   NS_DECL_ISUPPORTS
@@ -113,37 +112,21 @@ public:
   virtual nsIContent* GetNodeAt(PRUint32 aIndex);
   virtual PRInt32 IndexOf(nsIContent* aContent);
 
   void DropReference()
   {
     mNode = nsnull;
   }
 
-  nsINode* GetParentObject()
+  virtual nsINode* GetParentObject()
   {
     return mNode;
   }
 
-  static nsChildContentList* FromSupports(nsISupports* aSupports)
-  {
-    nsINodeList* list = static_cast<nsINodeList*>(aSupports);
-#ifdef DEBUG
-    {
-      nsCOMPtr<nsINodeList> list_qi = do_QueryInterface(aSupports);
-
-      // If this assertion fires the QI implementation for the object in
-      // question doesn't use the nsINodeList pointer as the nsISupports
-      // pointer. That must be fixed, or we'll crash...
-      NS_ASSERTION(list_qi == list, "Uh, fix QI!");
-    }
-#endif
-    return static_cast<nsChildContentList*>(list);
-  }
-
 private:
   // The node whose children make up the list (weak reference)
   nsINode* mNode;
 };
 
 /**
  * A tearoff class for nsGenericElement to implement additional interfaces
  */
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -1693,17 +1693,17 @@ GK_ATOM(onMozTapGesture, "onMozTapGestur
 GK_ATOM(onMozPressTapGesture, "onMozPressTapGesture")
 
 // Touch events
 GK_ATOM(onMozTouchDown, "onMozTouchDown")
 GK_ATOM(onMozTouchMove, "onMozTouchMove")
 GK_ATOM(onMozTouchUp, "onMozTouchUp")
 
 // orientation support
-GK_ATOM(onMozOrientation, "onMozOrientation")
+GK_ATOM(ondeviceorientation, "ondeviceorientation")
 
 //---------------------------------------------------------------------------
 // Special atoms
 //---------------------------------------------------------------------------
 
 // Node types
 GK_ATOM(cdataTagName, "#cdata-section")
 GK_ATOM(commentTagName, "#comment")
@@ -1718,16 +1718,17 @@ GK_ATOM(bcTableCellFrame, "BCTableCellFr
 GK_ATOM(blockFrame, "BlockFrame")
 GK_ATOM(boxFrame, "BoxFrame")
 GK_ATOM(brFrame, "BRFrame")
 GK_ATOM(bulletFrame, "BulletFrame")
 GK_ATOM(columnSetFrame, "ColumnSetFrame")
 GK_ATOM(comboboxControlFrame, "ComboboxControlFrame")
 GK_ATOM(comboboxDisplayFrame, "ComboboxDisplayFrame")
 GK_ATOM(deckFrame, "DeckFrame")
+GK_ATOM(directionalFrame, "DirectionalFrame")
 GK_ATOM(fieldSetFrame, "FieldSetFrame")
 GK_ATOM(frameSetFrame, "FrameSetFrame")
 GK_ATOM(gfxButtonControlFrame, "gfxButtonControlFrame")
 GK_ATOM(HTMLButtonControlFrame, "HTMLButtonControlFrame")
 GK_ATOM(HTMLCanvasFrame, "HTMLCanvasFrame")
 GK_ATOM(subDocumentFrame, "subDocumentFrame")
 GK_ATOM(imageBoxFrame, "ImageBoxFrame")
 GK_ATOM(imageFrame, "ImageFrame")
--- a/content/canvas/src/nsCanvasRenderingContext2D.cpp
+++ b/content/canvas/src/nsCanvasRenderingContext2D.cpp
@@ -98,17 +98,16 @@
 #include "gfxPlatform.h"
 #include "gfxFont.h"
 #include "gfxTextRunCache.h"
 #include "gfxBlur.h"
 #include "gfxUtils.h"
 
 #include "nsFrameManager.h"
 #include "nsFrameLoader.h"
-#include "nsBidi.h"
 #include "nsBidiPresUtils.h"
 #include "Layers.h"
 #include "CanvasUtils.h"
 #include "nsIMemoryReporter.h"
 #include "nsStyleUtil.h"
 #include "CanvasImageCache.h"
 
 #include <algorithm>
@@ -2648,16 +2647,20 @@ nsCanvasRenderingContext2D::DrawOrMeasur
     }
 
     nsIPresShell* presShell = GetPresShell();
     if (!presShell)
         return NS_ERROR_FAILURE;
 
     nsIDocument* document = presShell->GetDocument();
 
+    nsBidiPresUtils* bidiUtils = presShell->GetPresContext()->GetBidiUtils();
+    if (!bidiUtils)
+        return NS_ERROR_FAILURE;
+
     // replace all the whitespace characters with U+0020 SPACE
     nsAutoString textToDraw(aRawText);
     TextReplaceWhitespaceCharacters(textToDraw);
 
     // for now, default to ltr if not in doc
     PRBool isRTL = PR_FALSE;
 
     if (content && content->IsInDoc()) {
@@ -2693,27 +2696,25 @@ nsCanvasRenderingContext2D::DrawOrMeasur
 
     processor.mFontgrp = GetCurrentFontStyle();
     NS_ASSERTION(processor.mFontgrp, "font group is null");
 
     nscoord totalWidth;
 
     // calls bidi algo twice since it needs the full text width and the
     // bounding boxes before rendering anything
-    nsBidi bidiEngine;
-    rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
-                                      textToDraw.Length(),
-                                      isRTL ? NSBIDI_RTL : NSBIDI_LTR,
-                                      presShell->GetPresContext(),
-                                      processor,
-                                      nsBidiPresUtils::MODE_MEASURE,
-                                      nsnull,
-                                      0,
-                                      &totalWidth,
-                                      &bidiEngine);
+    rv = bidiUtils->ProcessText(textToDraw.get(),
+                                textToDraw.Length(),
+                                isRTL ? NSBIDI_RTL : NSBIDI_LTR,
+                                presShell->GetPresContext(),
+                                processor,
+                                nsBidiPresUtils::MODE_MEASURE,
+                                nsnull,
+                                0,
+                                &totalWidth);
     if (NS_FAILED(rv))
         return rv;
 
     if (aWidth)
         *aWidth = static_cast<float>(totalWidth);
 
     // if only measuring, don't need to do any more work
     if (aOp==TEXT_DRAW_OPERATION_MEASURE)
@@ -2801,26 +2802,25 @@ nsCanvasRenderingContext2D::DrawOrMeasur
 
         gfxContext* ctx = ShadowInitialize(drawExtents, blur);
 
         if (ctx) {
             CopyContext(ctx, mThebes);
             ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
             processor.mThebes = ctx;
 
-            rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
-                                              textToDraw.Length(),
-                                              isRTL ? NSBIDI_RTL : NSBIDI_LTR,
-                                              presShell->GetPresContext(),
-                                              processor,
-                                              nsBidiPresUtils::MODE_DRAW,
-                                              nsnull,
-                                              0,
-                                              nsnull,
-                                              &bidiEngine);
+            rv = bidiUtils->ProcessText(textToDraw.get(),
+                                        textToDraw.Length(),
+                                        isRTL ? NSBIDI_RTL : NSBIDI_LTR,
+                                        presShell->GetPresContext(),
+                                        processor,
+                                        nsBidiPresUtils::MODE_DRAW,
+                                        nsnull,
+                                        0,
+                                        nsnull);
             if (NS_FAILED(rv))
                 return rv;
 
             ShadowFinalize(blur);
         }
 
         processor.mThebes = mThebes;
     }
@@ -2839,26 +2839,25 @@ nsCanvasRenderingContext2D::DrawOrMeasur
 
             // don't want operators to be applied twice
             mThebes->SetOperator(gfxContext::OPERATOR_SOURCE);
         }
 
         ApplyStyle(STYLE_FILL);
     }
 
-    rv = nsBidiPresUtils::ProcessText(textToDraw.get(),
-                                      textToDraw.Length(),
-                                      isRTL ? NSBIDI_RTL : NSBIDI_LTR,
-                                      presShell->GetPresContext(),
-                                      processor,
-                                      nsBidiPresUtils::MODE_DRAW,
-                                      nsnull,
-                                      0,
-                                      nsnull,
-                                      &bidiEngine);
+    rv = bidiUtils->ProcessText(textToDraw.get(),
+                                textToDraw.Length(),
+                                isRTL ? NSBIDI_RTL : NSBIDI_LTR,
+                                presShell->GetPresContext(),
+                                processor,
+                                nsBidiPresUtils::MODE_DRAW,
+                                nsnull,
+                                0,
+                                nsnull);
 
     // this needs to be restored before function can return
     if (doUseIntermediateSurface) {
         mThebes->PopGroupToSource();
         DirtyAllStyles();
     }
 
     if (NS_FAILED(rv))
--- a/content/events/public/nsIPrivateDOMEvent.h
+++ b/content/events/public/nsIPrivateDOMEvent.h
@@ -85,17 +85,17 @@ nsresult
 NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsDragEvent *aEvent);
 nsresult
 NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult, nsPresContext* aPresContext, class nsKeyEvent *aEvent);
 nsresult
 NS_NewDOMMutationEvent(nsIDOMEvent** aResult NS_OUTPARAM, nsPresContext* aPresContext, class nsMutationEvent* aEvent);
 nsresult
 NS_NewDOMPopupBlockedEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
-NS_NewDOMOrientationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
+NS_NewDOMDeviceOrientationEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMTextEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, class nsTextEvent* aEvent);
 nsresult
 NS_NewDOMBeforeUnloadEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
 nsresult
 NS_NewDOMPageTransitionEvent(nsIDOMEvent** aResult, nsPresContext* aPresContext, nsEvent* aEvent);
 #ifdef MOZ_SVG
 nsresult
--- a/content/events/src/nsDOMDragEvent.cpp
+++ b/content/events/src/nsDOMDragEvent.cpp
@@ -75,17 +75,17 @@ DOMCI_DATA(DragEvent, nsDOMDragEvent)
 NS_INTERFACE_MAP_BEGIN(nsDOMDragEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMDragEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DragEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
 
 NS_IMETHODIMP
 nsDOMDragEvent::InitDragEvent(const nsAString & aType,
                               PRBool aCanBubble, PRBool aCancelable,
-                              nsIDOMAbstractView* aView, PRInt32 aDetail,
+                              nsIDOMWindow* aView, PRInt32 aDetail,
                               PRInt32 aScreenX, PRInt32 aScreenY,
                               PRInt32 aClientX, PRInt32 aClientY, 
                               PRBool aCtrlKey, PRBool aAltKey, PRBool aShiftKey,
                               PRBool aMetaKey, PRUint16 aButton,
                               nsIDOMEventTarget *aRelatedTarget,
                               nsIDOMDataTransfer* aDataTransfer)
 {
   nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
@@ -127,12 +127,10 @@ nsDOMDragEvent::GetDataTransfer(nsIDOMDa
   return NS_OK;
 }
 
 nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
                             nsPresContext* aPresContext,
                             nsDragEvent *aEvent) 
 {
   nsDOMDragEvent* event = new nsDOMDragEvent(aPresContext, aEvent);
-  NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
-
   return CallQueryInterface(event, aInstancePtrResult);
 }
--- a/content/events/src/nsDOMKeyboardEvent.cpp
+++ b/content/events/src/nsDOMKeyboardEvent.cpp
@@ -170,17 +170,17 @@ nsDOMKeyboardEvent::GetWhich(PRUint32* a
       break;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMKeyboardEvent::InitKeyEvent(const nsAString& aType, PRBool aCanBubble, PRBool aCancelable,
-                                 nsIDOMAbstractView* aView, PRBool aCtrlKey, PRBool aAltKey,
+                                 nsIDOMWindow* aView, PRBool aCtrlKey, PRBool aAltKey,
                                  PRBool aShiftKey, PRBool aMetaKey,
                                  PRUint32 aKeyCode, PRUint32 aCharCode)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsKeyEvent* keyEvent = static_cast<nsKeyEvent*>(mEvent);
   keyEvent->isControl = aCtrlKey;
@@ -193,14 +193,10 @@ nsDOMKeyboardEvent::InitKeyEvent(const n
   return NS_OK;
 }
 
 nsresult NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
                                 nsPresContext* aPresContext,
                                 nsKeyEvent *aEvent)
 {
   nsDOMKeyboardEvent* it = new nsDOMKeyboardEvent(aPresContext, aEvent);
-  if (nsnull == it) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/content/events/src/nsDOMMouseEvent.cpp
+++ b/content/events/src/nsDOMMouseEvent.cpp
@@ -99,17 +99,17 @@ DOMCI_DATA(MouseEvent, nsDOMMouseEvent)
 NS_INTERFACE_MAP_BEGIN(nsDOMMouseEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMouseEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNSMouseEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MouseEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
 
 NS_IMETHODIMP
 nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, PRBool aCanBubble, PRBool aCancelable,
-                                nsIDOMAbstractView *aView, PRInt32 aDetail, PRInt32 aScreenX, 
+                                nsIDOMWindow* aView, PRInt32 aDetail, PRInt32 aScreenX, 
                                 PRInt32 aScreenY, PRInt32 aClientX, PRInt32 aClientY, 
                                 PRBool aCtrlKey, PRBool aAltKey, PRBool aShiftKey, 
                                 PRBool aMetaKey, PRUint16 aButton, nsIDOMEventTarget *aRelatedTarget)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
 
   switch(mEvent->eventStructType)
@@ -142,17 +142,17 @@ nsDOMMouseEvent::InitMouseEvent(const ns
        break;
   }
 
   return NS_OK;
 }   
 
 NS_IMETHODIMP
 nsDOMMouseEvent::InitNSMouseEvent(const nsAString & aType, PRBool aCanBubble, PRBool aCancelable,
-                                  nsIDOMAbstractView *aView, PRInt32 aDetail, PRInt32 aScreenX,
+                                  nsIDOMWindow *aView, PRInt32 aDetail, PRInt32 aScreenX,
                                   PRInt32 aScreenY, PRInt32 aClientX, PRInt32 aClientY,
                                   PRBool aCtrlKey, PRBool aAltKey, PRBool aShiftKey,
                                   PRBool aMetaKey, PRUint16 aButton, nsIDOMEventTarget *aRelatedTarget,
                                   float aPressure, PRUint16 aInputSource)
 {
   nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
                                                 aView, aDetail, aScreenX, aScreenY,
                                                 aClientX, aClientY, aCtrlKey, aAltKey, aShiftKey,
@@ -308,14 +308,10 @@ nsDOMMouseEvent::GetMozInputSource(PRUin
   return NS_OK;
 }
 
 nsresult NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult,
                              nsPresContext* aPresContext,
                              nsInputEvent *aEvent) 
 {
   nsDOMMouseEvent* it = new nsDOMMouseEvent(aPresContext, aEvent);
-  if (nsnull == it) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/content/events/src/nsDOMMouseScrollEvent.cpp
+++ b/content/events/src/nsDOMMouseScrollEvent.cpp
@@ -83,17 +83,17 @@ DOMCI_DATA(MouseScrollEvent, nsDOMMouseS
 
 NS_INTERFACE_MAP_BEGIN(nsDOMMouseScrollEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMouseScrollEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(MouseScrollEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
 
 NS_IMETHODIMP
 nsDOMMouseScrollEvent::InitMouseScrollEvent(const nsAString & aType, PRBool aCanBubble, PRBool aCancelable,
-                                nsIDOMAbstractView *aView, PRInt32 aDetail, PRInt32 aScreenX, 
+                                nsIDOMWindow *aView, PRInt32 aDetail, PRInt32 aScreenX, 
                                 PRInt32 aScreenY, PRInt32 aClientX, PRInt32 aClientY, 
                                 PRBool aCtrlKey, PRBool aAltKey, PRBool aShiftKey, 
                                 PRBool aMetaKey, PRUint16 aButton, nsIDOMEventTarget *aRelatedTarget,
                                 PRInt32 aAxis)
 {
   nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
                                                 aScreenX, aScreenY, aClientX, aClientY, aCtrlKey,
                                                 aAltKey, aShiftKey, aMetaKey, aButton, aRelatedTarget);
@@ -124,14 +124,10 @@ nsDOMMouseScrollEvent::GetAxis(PRInt32* 
   return NS_OK;
 }
 
 nsresult NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
                                    nsPresContext* aPresContext,
                                    nsInputEvent *aEvent) 
 {
   nsDOMMouseScrollEvent* it = new nsDOMMouseScrollEvent(aPresContext, aEvent);
-  if (nsnull == it) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/content/events/src/nsDOMMozTouchEvent.cpp
+++ b/content/events/src/nsDOMMozTouchEvent.cpp
@@ -80,17 +80,17 @@ nsDOMMozTouchEvent::GetStreamId(PRUint32
   *aStreamId = static_cast<nsMozTouchEvent*>(mEvent)->streamId;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMozTouchEvent::InitMozTouchEvent(const nsAString& aTypeArg,
                                       PRBool aCanBubbleArg,
                                       PRBool aCancelableArg,
-                                      nsIDOMAbstractView* aViewArg,
+                                      nsIDOMWindow* aViewArg,
                                       PRInt32 aDetailArg,
                                       PRInt32 aScreenX,
                                       PRInt32 aScreenY,
                                       PRInt32 aClientX,
                                       PRInt32 aClientY,
                                       PRBool aCtrlKeyArg,
                                       PRBool aAltKeyArg,
                                       PRBool aShiftKeyArg,
@@ -122,13 +122,10 @@ nsDOMMozTouchEvent::InitMozTouchEvent(co
   return NS_OK;
 }
 
 nsresult NS_NewDOMMozTouchEvent(nsIDOMEvent** aInstancePtrResult,
                                      nsPresContext* aPresContext,
                                      nsMozTouchEvent *aEvent)
 {
   nsDOMMozTouchEvent *it = new nsDOMMozTouchEvent(aPresContext, aEvent);
-  if (nsnull == it) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/content/events/src/nsDOMOrientationEvent.cpp
+++ b/content/events/src/nsDOMOrientationEvent.cpp
@@ -35,69 +35,85 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsDOMOrientationEvent.h"
 #include "nsContentUtils.h"
 
 NS_IMPL_ADDREF_INHERITED(nsDOMOrientationEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMOrientationEvent, nsDOMEvent)
 
-DOMCI_DATA(OrientationEvent, nsDOMOrientationEvent)
+DOMCI_DATA(DeviceOrientationEvent, nsDOMOrientationEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMOrientationEvent)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMOrientationEvent)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(OrientationEvent)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMDeviceOrientationEvent)
+  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DeviceOrientationEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
-NS_IMETHODIMP nsDOMOrientationEvent::InitOrientationEvent(const nsAString & eventTypeArg,
-                                                          PRBool canBubbleArg,
-                                                          PRBool cancelableArg,
-                                                          double x,
-                                                          double y,
-                                                          double z)
+NS_IMETHODIMP nsDOMOrientationEvent::InitDeviceOrientationEvent(const nsAString & aEventTypeArg,
+                                                                PRBool aCanBubbleArg,
+                                                                PRBool aCancelableArg,
+                                                                double aAlpha,
+                                                                double aBeta,
+                                                                double aGamma,
+                                                                PRBool aAbsolute)
 {
-  nsresult rv = nsDOMEvent::InitEvent(eventTypeArg, canBubbleArg, cancelableArg);
+  nsresult rv = nsDOMEvent::InitEvent(aEventTypeArg, aCanBubbleArg, aCancelableArg);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  mX = x;
-  mY = y;
-  mZ = z;
+  mAlpha = aAlpha;
+  mBeta = aBeta;
+  mGamma = aGamma;
+  mAbsolute = aAbsolute;
 
   return NS_OK;
 }
 
-
-NS_IMETHODIMP nsDOMOrientationEvent::GetX(double *aX)
+NS_IMETHODIMP nsDOMOrientationEvent::GetAlpha(double *aAlpha)
 {
-  NS_ENSURE_ARG_POINTER(aX);
+  NS_ENSURE_ARG_POINTER(aAlpha);
+
+  *aAlpha = mAlpha;
+  return NS_OK;
+}
 
-  *aX = mX;
+NS_IMETHODIMP nsDOMOrientationEvent::GetBeta(double *aBeta)
+{
+  NS_ENSURE_ARG_POINTER(aBeta);
+
+  *aBeta = mBeta;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsDOMOrientationEvent::GetY(double *aY)
+NS_IMETHODIMP nsDOMOrientationEvent::GetGamma(double *aGamma)
 {
-  NS_ENSURE_ARG_POINTER(aY);
+  NS_ENSURE_ARG_POINTER(aGamma);
 
-  *aY = mY;
+  *aGamma = mGamma;
   return NS_OK;
 }
 
-NS_IMETHODIMP nsDOMOrientationEvent::GetZ(double *aZ)
+NS_IMETHODIMP nsDOMOrientationEvent::GetAbsolute(PRBool *aAbsolute)
 {
-  NS_ENSURE_ARG_POINTER(aZ);
+  NS_ENSURE_ARG_POINTER(aAbsolute);
 
-  *aZ = mZ;
+  *aAbsolute = mAbsolute;
   return NS_OK;
 }
 
+NS_IMETHODIMP nsDOMOrientationEvent::GetCompassCalibrated(PRBool *aCompassCalibrated)
+{
+  NS_ENSURE_ARG_POINTER(aCompassCalibrated);
 
-nsresult NS_NewDOMOrientationEvent(nsIDOMEvent** aInstancePtrResult,
-                                   nsPresContext* aPresContext,
-                                   nsEvent *aEvent) 
+  *aCompassCalibrated = PR_TRUE;
+  return NS_OK;
+}
+
+nsresult NS_NewDOMDeviceOrientationEvent(nsIDOMEvent** aInstancePtrResult,
+                                         nsPresContext* aPresContext,
+                                         nsEvent *aEvent) 
 {
   NS_ENSURE_ARG_POINTER(aInstancePtrResult);
 
   nsDOMOrientationEvent* it = new nsDOMOrientationEvent(aPresContext, aEvent);
   if (nsnull == it) {
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
--- a/content/events/src/nsDOMOrientationEvent.h
+++ b/content/events/src/nsDOMOrientationEvent.h
@@ -32,35 +32,37 @@
  * 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 nsDOMOrientationEvent_h__
 #define nsDOMOrientationEvent_h__
 
-#include "nsIDOMOrientationEvent.h"
+#include "nsIDOMDeviceOrientationEvent.h"
 #include "nsDOMEvent.h"
 
 class nsDOMOrientationEvent : public nsDOMEvent,
-                              public nsIDOMOrientationEvent
+                              public nsIDOMDeviceOrientationEvent
 {
 public:
 
   nsDOMOrientationEvent(nsPresContext* aPresContext, nsEvent* aEvent)
   : nsDOMEvent(aPresContext, aEvent),
-    mX(0),
-    mY(0),
-    mZ(0) {}
+    mAlpha(0),
+    mBeta(0),
+    mGamma(0),
+    mAbsolute(PR_TRUE) {}
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Forward to nsDOMEvent
   NS_FORWARD_TO_NSDOMEVENT
 
   // nsIDOMOrientationEvent Interface
-  NS_DECL_NSIDOMORIENTATIONEVENT
+  NS_DECL_NSIDOMDEVICEORIENTATIONEVENT
 
 protected:
-  double mX, mY, mZ;
+  double mAlpha, mBeta, mGamma;
+  PRBool mAbsolute;
 };
 
 #endif
--- a/content/events/src/nsDOMScrollAreaEvent.cpp
+++ b/content/events/src/nsDOMScrollAreaEvent.cpp
@@ -96,17 +96,17 @@ nsDOMScrollAreaEvent::GetHeight(float *a
 {
   return mClientArea.GetHeight(aHeight);
 }
 
 NS_IMETHODIMP
 nsDOMScrollAreaEvent::InitScrollAreaEvent(const nsAString &aEventType,
                                           PRBool aCanBubble,
                                           PRBool aCancelable,
-                                          nsIDOMAbstractView *aView,
+                                          nsIDOMWindow *aView,
                                           PRInt32 aDetail,
                                           float aX, float aY,
                                           float aWidth, float aHeight)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aEventType, aCanBubble, aCancelable, aView, aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mClientArea.SetRect(aX, aY, aWidth, aHeight);
@@ -151,15 +151,10 @@ nsDOMScrollAreaEvent::Deserialize(const 
 }
 
 nsresult
 NS_NewDOMScrollAreaEvent(nsIDOMEvent **aInstancePtrResult,
                          nsPresContext *aPresContext,
                          nsScrollAreaEvent *aEvent)
 {
   nsDOMScrollAreaEvent *ev = new nsDOMScrollAreaEvent(aPresContext, aEvent);
-
-  if (!ev) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   return CallQueryInterface(ev, aInstancePtrResult);
 }
--- a/content/events/src/nsDOMSimpleGestureEvent.cpp
+++ b/content/events/src/nsDOMSimpleGestureEvent.cpp
@@ -90,17 +90,17 @@ nsDOMSimpleGestureEvent::GetDelta(PRFloa
   *aDelta = static_cast<nsSimpleGestureEvent*>(mEvent)->delta;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
                                                 PRBool aCanBubbleArg,
                                                 PRBool aCancelableArg,
-                                                nsIDOMAbstractView* aViewArg,
+                                                nsIDOMWindow* aViewArg,
                                                 PRInt32 aDetailArg,
                                                 PRInt32 aScreenX, 
                                                 PRInt32 aScreenY,
                                                 PRInt32 aClientX,
                                                 PRInt32 aClientY,
                                                 PRBool aCtrlKeyArg,
                                                 PRBool aAltKeyArg,
                                                 PRBool aShiftKeyArg,
--- a/content/events/src/nsDOMTouchEvent.cpp
+++ b/content/events/src/nsDOMTouchEvent.cpp
@@ -1,9 +1,9 @@
-                     /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
+/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
 /* ***** 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/
  *
@@ -37,108 +37,108 @@
 
 #include "nsDOMTouchEvent.h"
 #include "nsGUIEvent.h"
 #include "nsDOMClassInfoID.h"
 #include "nsIClassInfo.h"
 #include "nsIXPCScriptable.h"
 #include "nsContentUtils.h"
 
-DOMCI_DATA(TouchPoint, nsDOMTouchPoint)
+DOMCI_DATA(Touch, nsDOMTouch)
 
-NS_IMPL_CYCLE_COLLECTION_1(nsDOMTouchPoint, mTarget)
+NS_IMPL_CYCLE_COLLECTION_1(nsDOMTouch, mTarget)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMTouchPoint)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMTouchPoint)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMTouchPoint)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TouchPoint)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMTouch)
+  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMTouch)
+  NS_INTERFACE_MAP_ENTRY(nsIDOMTouch)
+  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Touch)
 NS_INTERFACE_MAP_END
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMTouchPoint)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMTouchPoint)
+NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMTouch)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMTouch)
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetIdentifier(PRInt32* aIdentifier)
+nsDOMTouch::GetIdentifier(PRInt32* aIdentifier)
 {
   *aIdentifier = mIdentifier;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetTarget(nsIDOMEventTarget** aTarget)
+nsDOMTouch::GetTarget(nsIDOMEventTarget** aTarget)
 {
   NS_IF_ADDREF(*aTarget = mTarget);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetScreenX(PRInt32* aScreenX)
+nsDOMTouch::GetScreenX(PRInt32* aScreenX)
 {
   *aScreenX = mScreenX;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetScreenY(PRInt32* aScreenY)
+nsDOMTouch::GetScreenY(PRInt32* aScreenY)
 {
   *aScreenY = mScreenY;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetClientX(PRInt32* aClientX)
+nsDOMTouch::GetClientX(PRInt32* aClientX)
 {
   *aClientX = mClientX;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetClientY(PRInt32* aClientY)
+nsDOMTouch::GetClientY(PRInt32* aClientY)
 {
   *aClientY = mClientY;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetPageX(PRInt32* aPageX)
+nsDOMTouch::GetPageX(PRInt32* aPageX)
 {
   *aPageX = mPageX;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetPageY(PRInt32* aPageY)
+nsDOMTouch::GetPageY(PRInt32* aPageY)
 {
   *aPageY = mPageY;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetRadiusX(PRInt32* aRadiusX)
+nsDOMTouch::GetRadiusX(PRInt32* aRadiusX)
 {
   *aRadiusX = mRadiusX;
   return NS_OK;
 }
                                              
 NS_IMETHODIMP
-nsDOMTouchPoint::GetRadiusY(PRInt32* aRadiusY)
+nsDOMTouch::GetRadiusY(PRInt32* aRadiusY)
 {
   *aRadiusY = mRadiusY;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetRotationAngle(float* aRotationAngle)
+nsDOMTouch::GetRotationAngle(float* aRotationAngle)
 {
   *aRotationAngle = mRotationAngle;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchPoint::GetForce(float* aForce)
+nsDOMTouch::GetForce(float* aForce)
 {
   *aForce = mForce;
   return NS_OK;
 }
 
 // TouchList
 
 DOMCI_DATA(TouchList, nsDOMTouchList)
@@ -165,27 +165,28 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMTo
 NS_IMETHODIMP
 nsDOMTouchList::GetLength(PRUint32* aLength)
 {
   *aLength = mPoints.Count();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchList::Item(PRUint32 aIndex, nsIDOMTouchPoint** aRetVal)
+nsDOMTouchList::Item(PRUint32 aIndex, nsIDOMTouch** aRetVal)
 {
   NS_IF_ADDREF(*aRetVal = mPoints.SafeObjectAt(aIndex));
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMTouchList::IdentifiedPoint(PRInt32 aIdentifier, nsIDOMTouchPoint** aRetVal)
+nsDOMTouchList::IdentifiedTouch(PRInt32 aIdentifier, nsIDOMTouch** aRetVal)
 {
+  *aRetVal = nsnull;
   for (PRInt32 i = 0; i < mPoints.Count(); ++i) {
-    nsCOMPtr<nsIDOMTouchPoint> point = mPoints[i];
+    nsCOMPtr<nsIDOMTouch> point = mPoints[i];
     PRInt32 identifier;
     if (point && NS_SUCCEEDED(point->GetIdentifier(&identifier)) &&
         aIdentifier == identifier) {
       point.swap(*aRetVal);
       break;
     }
   }
   return NS_OK;
@@ -238,17 +239,17 @@ NS_INTERFACE_MAP_END_INHERITING(nsDOMUIE
 NS_IMPL_ADDREF_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMTouchEvent, nsDOMUIEvent)
 
 
 NS_IMETHODIMP
 nsDOMTouchEvent::InitTouchEvent(const nsAString& aType,
                                 PRBool aCanBubble,
                                 PRBool aCancelable,
-                                nsIDOMAbstractView* aView,
+                                nsIDOMWindow* aView,
                                 PRInt32 aDetail,
                                 PRBool aCtrlKey,
                                 PRBool aAltKey,
                                 PRBool aShiftKey,
                                 PRBool aMetaKey,
                                 nsIDOMTouchList* aTouches,
                                 nsIDOMTouchList* aTargetTouches,
                                 nsIDOMTouchList* aChangedTouches)
--- a/content/events/src/nsDOMTouchEvent.h
+++ b/content/events/src/nsDOMTouchEvent.h
@@ -37,47 +37,47 @@
 #ifndef nsDOMTouchEvent_h_
 #define nsDOMTouchEvent_h_
 
 #include "nsDOMUIEvent.h"
 #include "nsIDOMTouchEvent.h"
 #include "nsString.h"
 #include "nsCOMArray.h"
 
-class nsDOMTouchPoint : public nsIDOMTouchPoint
+class nsDOMTouch : public nsIDOMTouch
 {
 public:
-  nsDOMTouchPoint(nsIDOMEventTarget* aTarget,
-                  PRInt32 aIdentifier,
-                  PRInt32 aPageX,
-                  PRInt32 aPageY,
-                  PRInt32 aScreenX,
-                  PRInt32 aScreenY,
-                  PRInt32 aClientX,
-                  PRInt32 aClientY,
-                  PRInt32 aRadiusX,
-                  PRInt32 aRadiusY,
-                  float aRotationAngle,
-                  float aForce)
+  nsDOMTouch(nsIDOMEventTarget* aTarget,
+             PRInt32 aIdentifier,
+             PRInt32 aPageX,
+             PRInt32 aPageY,
+             PRInt32 aScreenX,
+             PRInt32 aScreenY,
+             PRInt32 aClientX,
+             PRInt32 aClientY,
+             PRInt32 aRadiusX,
+             PRInt32 aRadiusY,
+             float aRotationAngle,
+             float aForce)
   : mTarget(aTarget),
     mIdentifier(aIdentifier),
     mPageX(aPageX),
     mPageY(aPageY),
     mScreenX(aScreenX),
     mScreenY(aScreenY),
     mClientX(aClientX),
     mClientY(aClientY),
     mRadiusX(aRadiusX),
     mRadiusY(aRadiusY),
     mRotationAngle(aRotationAngle),
     mForce(aForce)
     {}
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMTouchPoint)
-  NS_DECL_NSIDOMTOUCHPOINT
+  NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMTouch)
+  NS_DECL_NSIDOMTOUCH
 protected:
   nsCOMPtr<nsIDOMEventTarget> mTarget;
   PRInt32 mIdentifier;
   PRInt32 mPageX;
   PRInt32 mPageY;
   PRInt32 mScreenX;
   PRInt32 mScreenY;
   PRInt32 mClientX;
@@ -90,27 +90,27 @@ protected:
 
 class nsDOMTouchList : public nsIDOMTouchList
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMTouchList)
   NS_DECL_NSIDOMTOUCHLIST
   
-  void Append(nsIDOMTouchPoint* aPoint)
+  void Append(nsIDOMTouch* aPoint)
   {
     mPoints.AppendObject(aPoint);
   }
 
-  nsIDOMTouchPoint* GetItemAt(PRUint32 aIndex)
+  nsIDOMTouch* GetItemAt(PRUint32 aIndex)
   {
     return mPoints.SafeObjectAt(aIndex);
   }
 protected:
-  nsCOMArray<nsIDOMTouchPoint> mPoints;
+  nsCOMArray<nsIDOMTouch> mPoints;
 };
 
 class nsDOMTouchEvent : public nsDOMUIEvent,
                         public nsIDOMTouchEvent
 {
 public:
   nsDOMTouchEvent(nsPresContext* aPresContext, nsInputEvent* aEvent);
   virtual ~nsDOMTouchEvent();
--- a/content/events/src/nsDOMUIEvent.cpp
+++ b/content/events/src/nsDOMUIEvent.cpp
@@ -171,32 +171,36 @@ nsDOMUIEvent::GetClientPoint()
   if (rootFrame)
     pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mEvent, rootFrame);
 
   return nsIntPoint(nsPresContext::AppUnitsToIntCSSPixels(pt.x),
                     nsPresContext::AppUnitsToIntCSSPixels(pt.y));
 }
 
 NS_IMETHODIMP
-nsDOMUIEvent::GetView(nsIDOMAbstractView** aView)
+nsDOMUIEvent::GetView(nsIDOMWindow** aView)
 {
   *aView = mView;
   NS_IF_ADDREF(*aView);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMUIEvent::GetDetail(PRInt32* aDetail)
 {
   *aDetail = mDetail;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMUIEvent::InitUIEvent(const nsAString & typeArg, PRBool canBubbleArg, PRBool cancelableArg, nsIDOMAbstractView *viewArg, PRInt32 detailArg)
+nsDOMUIEvent::InitUIEvent(const nsAString& typeArg,
+                          PRBool canBubbleArg,
+                          PRBool cancelableArg,
+                          nsIDOMWindow* viewArg,
+                          PRInt32 detailArg)
 {
   nsresult rv = nsDOMEvent::InitEvent(typeArg, canBubbleArg, cancelableArg);
   NS_ENSURE_SUCCESS(rv, rv);
   
   mDetail = detailArg;
   mView = viewArg;
 
   return NS_OK;
@@ -413,14 +417,10 @@ nsDOMUIEvent::Deserialize(const IPC::Mes
   return PR_TRUE;
 }
 
 nsresult NS_NewDOMUIEvent(nsIDOMEvent** aInstancePtrResult,
                           nsPresContext* aPresContext,
                           nsGUIEvent *aEvent) 
 {
   nsDOMUIEvent* it = new nsDOMUIEvent(aPresContext, aEvent);
-  if (nsnull == it) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/content/events/src/nsDOMUIEvent.h
+++ b/content/events/src/nsDOMUIEvent.h
@@ -31,22 +31,21 @@
  * 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 nsDOMUIEvent_h__
-#define nsDOMUIEvent_h__
+#ifndef nsDOMUIEvent_h
+#define nsDOMUIEvent_h
 
 #include "nsIDOMUIEvent.h"
 #include "nsIDOMNSUIEvent.h"
-#include "nsIDOMAbstractView.h"
 #include "nsDOMEvent.h"
 
 class nsDOMUIEvent : public nsDOMEvent,
                      public nsIDOMUIEvent,
                      public nsIDOMNSUIEvent
 {
 public:
   nsDOMUIEvent(nsPresContext* aPresContext, nsGUIEvent* aEvent);
@@ -73,21 +72,21 @@ protected:
 
   // Internal helper functions
   nsIntPoint GetClientPoint();
   nsIntPoint GetScreenPoint();
   nsIntPoint GetLayerPoint();
   nsIntPoint GetPagePoint();
   
 protected:
-  nsCOMPtr<nsIDOMAbstractView> mView;
+  nsCOMPtr<nsIDOMWindow> mView;
   PRInt32 mDetail;
   nsIntPoint mClientPoint;
   // Screenpoint is mEvent->refPoint.
   nsIntPoint mLayerPoint;
   nsIntPoint mPagePoint;
 };
 
 #define NS_FORWARD_TO_NSDOMUIEVENT \
   NS_FORWARD_NSIDOMUIEVENT(nsDOMUIEvent::) \
   NS_FORWARD_TO_NSDOMEVENT
 
-#endif // nsDOMUIEvent_h__
+#endif // nsDOMUIEvent_h
--- a/content/events/src/nsDOMXULCommandEvent.cpp
+++ b/content/events/src/nsDOMXULCommandEvent.cpp
@@ -113,17 +113,17 @@ nsDOMXULCommandEvent::GetSourceEvent(nsI
   NS_ENSURE_ARG_POINTER(aSourceEvent);
   NS_IF_ADDREF(*aSourceEvent = mSourceEvent);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMXULCommandEvent::InitCommandEvent(const nsAString& aType,
                                        PRBool aCanBubble, PRBool aCancelable,
-                                       nsIDOMAbstractView *aView,
+                                       nsIDOMWindow* aView,
                                        PRInt32 aDetail,
                                        PRBool aCtrlKey, PRBool aAltKey,
                                        PRBool aShiftKey, PRBool aMetaKey,
                                        nsIDOMEvent* aSourceEvent)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable,
                                           aView, aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
@@ -139,14 +139,10 @@ nsDOMXULCommandEvent::InitCommandEvent(c
 }
 
 
 nsresult NS_NewDOMXULCommandEvent(nsIDOMEvent** aInstancePtrResult,
                                   nsPresContext* aPresContext,
                                   nsInputEvent *aEvent) 
 {
   nsDOMXULCommandEvent* it = new nsDOMXULCommandEvent(aPresContext, aEvent);
-  if (nsnull == it) {
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
-
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -807,18 +807,18 @@ nsEventDispatcher::CreateEvent(nsPresCon
   if (aEventType.LowerCaseEqualsLiteral("mutationevent") ||
         aEventType.LowerCaseEqualsLiteral("mutationevents"))
     return NS_NewDOMMutationEvent(aDOMEvent, aPresContext, nsnull);
   if (aEventType.LowerCaseEqualsLiteral("textevent") ||
       aEventType.LowerCaseEqualsLiteral("textevents"))
     return NS_NewDOMTextEvent(aDOMEvent, aPresContext, nsnull);
   if (aEventType.LowerCaseEqualsLiteral("popupblockedevents"))
     return NS_NewDOMPopupBlockedEvent(aDOMEvent, aPresContext, nsnull);
-  if (aEventType.LowerCaseEqualsLiteral("orientation"))
-    return NS_NewDOMOrientationEvent(aDOMEvent, aPresContext, nsnull);
+  if (aEventType.LowerCaseEqualsLiteral("deviceorientationevent"))
+    return NS_NewDOMDeviceOrientationEvent(aDOMEvent, aPresContext, nsnull);
   if (aEventType.LowerCaseEqualsLiteral("uievent") ||
       aEventType.LowerCaseEqualsLiteral("uievents"))
     return NS_NewDOMUIEvent(aDOMEvent, aPresContext, nsnull);
   if (aEventType.LowerCaseEqualsLiteral("event") ||
       aEventType.LowerCaseEqualsLiteral("events") ||
       aEventType.LowerCaseEqualsLiteral("htmlevents"))
     return NS_NewDOMEvent(aDOMEvent, aPresContext, nsnull);
 #ifdef MOZ_SVG
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -498,17 +498,17 @@ nsEventListenerManager::AddEventListener
     nsPIDOMWindow* window = GetInnerWindowForTarget();
     if (window) {
       // If aType is NS_MUTATION_SUBTREEMODIFIED, we need to listen all
       // mutations. nsContentUtils::HasMutationListeners relies on this.
       window->SetMutationListeners((aType == NS_MUTATION_SUBTREEMODIFIED) ?
                                    kAllMutationBits :
                                    MutationBitForEventType(aType));
     }
-  } else if (aTypeAtom == nsGkAtoms::onMozOrientation) {
+  } else if (aTypeAtom == nsGkAtoms::ondeviceorientation) {
     nsPIDOMWindow* window = GetInnerWindowForTarget();
     if (window)
       window->SetHasOrientationEventListener();
   } else if ((aType >= NS_MOZTOUCH_DOWN && aType <= NS_MOZTOUCH_UP) ||
              (aTypeAtom == nsGkAtoms::ontouchstart ||
               aTypeAtom == nsGkAtoms::ontouchend ||
               aTypeAtom == nsGkAtoms::ontouchmove ||
               aTypeAtom == nsGkAtoms::ontouchenter ||
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -113,17 +113,16 @@
 #include "nsIObserverService.h"
 #include "nsIDocShell.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIDOMDocumentRange.h"
 #include "nsIDOMDocumentEvent.h"
 #include "nsIDOMMouseScrollEvent.h"
 #include "nsIDOMDragEvent.h"
 #include "nsIDOMEventTarget.h"
-#include "nsIDOMDocumentView.h"
 #include "nsIDOMNSUIEvent.h"
 #include "nsDOMDragEvent.h"
 #include "nsIDOMNSEditableElement.h"
 
 #include "nsIDOMRange.h"
 #include "nsCaret.h"
 #include "nsILookAndFeel.h"
 #include "nsWidgetsCID.h"
--- a/content/events/test/Makefile.in
+++ b/content/events/test/Makefile.in
@@ -96,16 +96,17 @@ include $(topsrcdir)/config/rules.mk
 		test_clickevent_on_input.html \
 		test_bug593959.html \
 		test_bug591815.html \
 		test_bug605242.html \
 		test_bug607464.html \
 		test_bug624127.html \
 		test_bug641477.html \
 		test_bug648573.html \
+		test_bug615597.html \
 		$(NULL)
 
 #bug 585630
 ifneq (mobile,$(MOZ_BUILD_APP))
 _TEST_FILES += \
 		test_dragstart.html \
 		$(NULL)
 endif
new file mode 100644
--- /dev/null
+++ b/content/events/test/test_bug615597.html
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=615597
+-->
+<head>
+  <title>Test for Bug 615597</title>
+  <script type="application/javascript" src="/MochiKit/packed.js"></script>
+  <script type="application/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=615597">Mozilla Bug 615597</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 615597 **/
+
+window.addEventListener("deviceorientation", function(event) {
+  is(event.alpha, 1.5);
+  is(event.beta, 2.25);
+  is(event.gamma, 3.667);
+  is(event.absolute, true);
+  is(event.compassCalibrated, true);
+  SimpleTest.finish();
+}, true);
+
+var event = DeviceOrientationEvent;
+ok(!!event, "Should have seen DeviceOrientationEvent!");
+
+event = document.createEvent("DeviceOrientationEvent");
+event.initDeviceOrientationEvent('deviceorientation', true, true, 1.5, 2.25, 3.667, true);
+window.dispatchEvent(event);
+SimpleTest.waitForExplicitFinish();
+
+</script>
+</pre>
+</body>
+</html>
--- a/content/html/content/src/nsHTMLFormElement.cpp
+++ b/content/html/content/src/nsHTMLFormElement.cpp
@@ -2382,17 +2382,17 @@ nsFormControlList::AddElementToTable(nsG
       // happen if a form control has both a name and an id with the same
       // value
       if (content == aChild) {
         return NS_OK;
       }
 
       // Found an element, create a list, add the element to the list and put
       // the list in the hash
-      nsBaseContentList *list = new nsBaseContentList();
+      nsSimpleContentList *list = new nsSimpleContentList(mForm);
       NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
 
       NS_ASSERTION(content->GetParent(), "Item in list without parent");
 
       // Determine the ordering between the new and old element.
       PRBool newFirst = nsContentUtils::PositionIsBefore(aChild, content);
 
       list->AppendElement(newFirst ? aChild : content);
@@ -2406,17 +2406,17 @@ nsFormControlList::AddElementToTable(nsG
       NS_ENSURE_TRUE(mNameLookupTable.Put(aName, listSupports),
                      NS_ERROR_FAILURE);
     } else {
       // There's already a list in the hash, add the child to the list
       nsCOMPtr<nsIDOMNodeList> nodeList(do_QueryInterface(supports));
       NS_ENSURE_TRUE(nodeList, NS_ERROR_FAILURE);
 
       // Upcast, uggly, but it works!
-      nsBaseContentList *list = static_cast<nsBaseContentList *>
+      nsSimpleContentList *list = static_cast<nsSimpleContentList *>
                                            ((nsIDOMNodeList *)nodeList.get());
 
       NS_ASSERTION(list->Length() > 1,
                    "List should have been converted back to a single element");
 
       // Fast-path appends; this check is ok even if the child is
       // already in the list, since if it tests true the child would
       // have come at the end of the list, and the PositionIsBefore
--- a/content/html/content/src/nsHTMLInputElement.cpp
+++ b/content/html/content/src/nsHTMLInputElement.cpp
@@ -3808,17 +3808,17 @@ nsHTMLInputElement::HasPatternMismatch()
     return PR_FALSE;
   }
 
   nsIDocument* doc = GetOwnerDoc();
   if (!doc) {
     return PR_FALSE;
   }
 
-  return !IsPatternMatching(value, pattern, doc);
+  return !nsContentUtils::IsPatternMatching(value, pattern, doc);
 }
 
 void
 nsHTMLInputElement::UpdateTooLongValidityState()
 {
   // TODO: this code will be re-enabled with bug 613016 and bug 613019.
 #if 0
   SetValidityState(VALIDITY_STATE_TOO_LONG, IsTooLong());
@@ -4090,50 +4090,16 @@ nsHTMLInputElement::IsValidEmailAddress(
       // The domain characters have to be in this list to be valid.
       return PR_FALSE;
     }
   }
 
   return PR_TRUE;
 }
 
-//static
-PRBool
-nsHTMLInputElement::IsPatternMatching(nsAString& aValue, nsAString& aPattern,
-                                      nsIDocument* aDocument)
-{
-  NS_ASSERTION(aDocument, "aDocument should be a valid pointer (not null)");
-  NS_ENSURE_TRUE(aDocument->GetScriptGlobalObject(), PR_TRUE);
-
-  JSContext* ctx = (JSContext*) aDocument->GetScriptGlobalObject()->
-                                  GetContext()->GetNativeContext();
-  NS_ENSURE_TRUE(ctx, PR_TRUE);
-
-  JSAutoRequest ar(ctx);
-
-  // The pattern has to match the entire value.
-  aPattern.Insert(NS_LITERAL_STRING("^(?:"), 0);
-  aPattern.Append(NS_LITERAL_STRING(")$"));
-
-  JSObject* re = JS_NewUCRegExpObjectNoStatics(ctx, reinterpret_cast<jschar*>
-                                                 (aPattern.BeginWriting()),
-                                                aPattern.Length(), 0);
-  NS_ENSURE_TRUE(re, PR_TRUE);
-
-  jsval rval = JSVAL_NULL;
-  size_t idx = 0;
-  JSBool res;
-
-  res = JS_ExecuteRegExpNoStatics(ctx, re, reinterpret_cast<jschar*>
-                                    (aValue.BeginWriting()),
-                                  aValue.Length(), &idx, JS_TRUE, &rval);
-
-  return res == JS_FALSE || rval != JSVAL_NULL;
-}
-
 NS_IMETHODIMP_(PRBool)
 nsHTMLInputElement::IsSingleLineTextControl() const
 {
   return IsSingleLineTextControl(PR_FALSE);
 }
 
 NS_IMETHODIMP_(PRBool)
 nsHTMLInputElement::IsTextArea() const
--- a/content/html/content/src/nsHTMLInputElement.h
+++ b/content/html/content/src/nsHTMLInputElement.h
@@ -363,33 +363,16 @@ protected:
    * This is following the HTML5 specification:
    * http://dev.w3.org/html5/spec/forms.html#valid-e-mail-address-list
    *
    * @param aValue  the email address list to check.
    * @result        whether the given string is a valid email address list.
    */
   static PRBool IsValidEmailAddressList(const nsAString& aValue);
 
-  /**
-   * This helper method returns true if the aPattern pattern matches aValue.
-   * aPattern should not contain leading and trailing slashes (/).
-   * The pattern has to match the entire value not just a subset.
-   * aDocument must be a valid pointer (not null).
-   *
-   * This is following the HTML5 specification:
-   * http://dev.w3.org/html5/spec/forms.html#attr-input-pattern
-   *
-   * @param aValue    the string to check.
-   * @param aPattern  the string defining the pattern.
-   * @param aDocument the owner document of the element.
-   * @result          whether the given string is matches the pattern.
-   */
-  static PRBool IsPatternMatching(nsAString& aValue, nsAString& aPattern,
-                                  nsIDocument* aDocument);
-
   // Helper method
   nsresult SetValueInternal(const nsAString& aValue,
                             PRBool aUserInput,
                             PRBool aSetValueChanged);
 
   nsresult GetValueInternal(nsAString& aValue) const;
 
   /**
--- a/content/html/content/src/nsHTMLMediaElement.cpp
+++ b/content/html/content/src/nsHTMLMediaElement.cpp
@@ -366,21 +366,23 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaL
 NS_IMPL_ADDREF_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement)
 NS_IMPL_RELEASE_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement)
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsHTMLMediaElement)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSourcePointer)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mLoadBlockedDoc)
+  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSourceLoadCandidate)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsHTMLMediaElement, nsGenericHTMLElement)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSourcePointer)
   NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mLoadBlockedDoc)
+  NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSourceLoadCandidate)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsHTMLMediaElement)
   NS_INTERFACE_MAP_ENTRY(nsIObserver)
 NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
 
 // nsIDOMHTMLMediaElement
 NS_IMPL_URI_ATTR(nsHTMLMediaElement, Src, src)
@@ -680,20 +682,21 @@ void nsHTMLMediaElement::SelectResource(
   mIsRunningSelectResource = PR_FALSE;
 }
 
 void nsHTMLMediaElement::NotifyLoadError()
 {
   if (!mIsLoadingFromSourceChildren) {
     LOG(PR_LOG_DEBUG, ("NotifyLoadError(), no supported media error"));
     NoSupportedMediaSourceError();
-  } else {
-    NS_ASSERTION(mSourceLoadCandidate, "Must know the source we were loading from!");
+  } else if (mSourceLoadCandidate) {
     DispatchAsyncSourceError(mSourceLoadCandidate);
     QueueLoadFromSourceTask();
+  } else {
+    NS_WARNING("Should know the source we were loading from!");
   }
 }
 
 void nsHTMLMediaElement::NotifyAudioAvailable(float* aFrameBuffer,
                                               PRUint32 aFrameBufferLength,
                                               float aTime)
 {
   // Auto manage the memory for the frame buffer, so that if we add an early
@@ -1972,24 +1975,27 @@ void nsHTMLMediaElement::ResourceLoaded(
 void nsHTMLMediaElement::NetworkError()
 {
   Error(nsIDOMMediaError::MEDIA_ERR_NETWORK);
 }
 
 void nsHTMLMediaElement::DecodeError()
 {
   if (mIsLoadingFromSourceChildren) {
-    NS_ASSERTION(mSourceLoadCandidate, "Must know the source we were loading from!");
     if (mDecoder) {
       mDecoder->Shutdown();
       mDecoder = nsnull;
     }
     mError = nsnull;
-    DispatchAsyncSourceError(mSourceLoadCandidate);
-    QueueLoadFromSourceTask();
+    if (mSourceLoadCandidate) {
+      DispatchAsyncSourceError(mSourceLoadCandidate);
+      QueueLoadFromSourceTask();
+    } else {
+      NS_WARNING("Should know the source we were loading from!");
+    }
   } else {
     Error(nsIDOMMediaError::MEDIA_ERR_DECODE);
   }
 }
 
 void nsHTMLMediaElement::LoadAborted()
 {
   Error(nsIDOMMediaError::MEDIA_ERR_ABORTED);
--- a/content/html/content/test/test_bug386496.html
+++ b/content/html/content/test/test_bug386496.html
@@ -1,56 +1,54 @@
 <!DOCTYPE HTML>
 <html>
 <!--
 https://bugzilla.mozilla.org/show_bug.cgi?id=386496
 -->
 <head>
   <title>Test for Bug 386496</title>
   <script type="text/javascript" src="/MochiKit/packed.js"></script>
-  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
-  <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>        
+  <script type="text/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=386496">Mozilla Bug 386496</a>
 <p id="display"></p>
 <div id="content">
-  <div id="frameContent">
-    <a id="a" href="http://a.invalid/">Link</a>
-  </div>
-  <iframe id="testIframe"></iframe>
+  <iframe style='display: block;' id="testIframe"
+    src="data:text/html,<div><a id='a' href='http://a.invalid/'>Link</a></div>">
+  </iframe>
 </div>
 <pre id="test">
 <script class="testbody" type="text/javascript">
 
 /** Test for Bug 386496 **/
 
 var frame = document.getElementById("testIframe");
 
-function finishTest() {
-  is(frame.contentWindow.location, "about:blank");
-  SimpleTest.finish();
-}
-
 function testDesignMode() {
-  frame.style.display = 'block';
-  var frameContent = frame.contentDocument.adoptNode(document.getElementById("frameContent"));
-  frame.contentDocument.body.appendChild(frameContent);
+  var unloadRequested = false;
 
   frame.contentDocument.designMode = "on";
 
-  netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
-  var event = frame.contentDocument.createEvent('MouseEvent');
-  event.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0, false, false,
-                       false, false, 0, null);
-  frame.contentDocument.getElementById("a").dispatchEvent(event);
+  frame.contentWindow.addEventListener("beforeunload", function() {
+    unloadRequested = true;
+  }, false);
+
+  synthesizeMouseAtCenter(frame.contentDocument.getElementById("a"), {},
+                          frame.contentWindow);
 
-  setTimeout(finishTest, 100);
+  // The click has been sent. If 'beforeunload' event has been caught when we go
+  // back from the event loop that means the link has been activated.
+  setTimeout(function() {
+    ok(!unloadRequested, "The link should not be activated in designMode");
+    SimpleTest.finish();
+  }, 0);
 }
 
 SimpleTest.waitForExplicitFinish();
-addLoadEvent(testDesignMode);
+SimpleTest.waitForFocus(testDesignMode);
 
 </script>
 </pre>
 </body>
 </html>
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -1383,16 +1383,22 @@ nsHTMLDocument::AdoptNode(nsIDOMNode* aS
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::NormalizeDocument()
 {
   return nsDocument::NormalizeDocument();
 }
 
+NS_IMETHODIMP
+nsHTMLDocument::GetDefaultView(nsIDOMWindow** aWindow)
+{
+  return nsDocument::GetDefaultView(aWindow);
+}
+
 //
 // nsIDOMHTMLDocument interface implementation
 //
 NS_IMETHODIMP
 nsHTMLDocument::GetTitle(nsAString& aTitle)
 {
   return nsDocument::GetTitle(aTitle);
 }
@@ -2517,17 +2523,17 @@ nsHTMLDocument::GetPlugins(nsIDOMHTMLCol
 {
   *aPlugins = nsnull;
 
   return GetEmbeds(aPlugins);
 }
 
 nsresult
 nsHTMLDocument::ResolveName(const nsAString& aName,
-                            nsIDOMHTMLFormElement *aForm,
+                            nsIContent *aForm,
                             nsISupports **aResult,
                             nsWrapperCache **aCache)
 {
   *aResult = nsnull;
   *aCache = nsnull;
 
   nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aName);
   if (!entry) {
--- a/content/html/document/src/nsHTMLDocument.h
+++ b/content/html/document/src/nsHTMLDocument.h
@@ -163,17 +163,17 @@ public:
     return NS_GetFuncStringContentList(this, MatchNameAttribute, nsnull,
                                        UseExistingNameString, aName);
   }
 
   // nsIDOMNSHTMLDocument interface
   NS_DECL_NSIDOMNSHTMLDOCUMENT
 
   virtual nsresult ResolveName(const nsAString& aName,
-                               nsIDOMHTMLFormElement *aForm,
+                               nsIContent *aForm,
                                nsISupports **aResult,
                                nsWrapperCache **aCache);
 
   virtual void ScriptLoading(nsIScriptElement *aScript);
   virtual void ScriptExecuted(nsIScriptElement *aScript);
 
   virtual void AddedForm();
   virtual void RemovedForm();
--- a/content/html/document/src/nsIHTMLDocument.h
+++ b/content/html/document/src/nsIHTMLDocument.h
@@ -50,18 +50,18 @@ class nsWrapperCache;
 
 namespace mozilla {
 namespace dom {
 class Element;
 } // namespace dom
 } // namespace mozilla
 
 #define NS_IHTMLDOCUMENT_IID \
-{ 0xe43a4bfd, 0xff5a, 0x40b0, \
-  { 0x8c, 0x31, 0x24, 0xac, 0xe8, 0x15, 0xda, 0xf2 } }
+{ 0x8cc90664, 0xb0fe, 0x4cdb, \
+ { 0xa2, 0xdd, 0x25, 0xcd, 0x8c, 0x2b, 0xfd, 0x08 } }
 
 
 /**
  * HTML document extensions to nsIDocument.
  */
 class nsIHTMLDocument : public nsISupports
 {
 public:
@@ -70,17 +70,17 @@ public:
   virtual mozilla::dom::Element* GetImageMap(const nsAString& aMapName) = 0;
 
   /**
    * Set compatibility mode for this document
    */
   virtual void SetCompatibilityMode(nsCompatibility aMode) = 0;
 
   virtual nsresult ResolveName(const nsAString& aName,
-                               nsIDOMHTMLFormElement *aForm,
+                               nsIContent *aForm,
                                nsISupports **aResult,
                                nsWrapperCache **aCache) = 0;
 
   /**
    * Called from the script loader to notify this document that a new
    * script is being loaded.
    */
   virtual void ScriptLoading(nsIScriptElement *aScript) = 0;
--- a/content/media/VideoUtils.h
+++ b/content/media/VideoUtils.h
@@ -34,17 +34,17 @@
  * 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 VideoUtils_h
 #define VideoUtils_h
 
-#include "mozilla/Monitor.h"
+#include "mozilla/ReentrantMonitor.h"
 
 // This file contains stuff we'd rather put elsewhere, but which is
 // dependent on other changes which we don't want to wait for. We plan to
 // remove this file in the near future.
 
 
 // This belongs in prtypes.h
 /************************************************************************
@@ -59,56 +59,55 @@
 #define PR_INT64_MIN (-PR_INT64_MAX - 1)
 #define PR_UINT64_MAX (~(PRUint64)(0))
 
 // This belongs in xpcom/monitor/Monitor.h, once we've made
 // mozilla::Monitor non-reentrant.
 namespace mozilla {
 
 /**
- * MonitorAutoExit
- * Exit the Monitor when it enters scope, and enters it when it leaves 
+ * ReentrantMonitorAutoExit
+ * Exit the ReentrantMonitor when it enters scope, and enters it when it leaves 
  * scope.
  *
- * MUCH PREFERRED to bare calls to Monitor.Exit and Enter.
+ * MUCH PREFERRED to bare calls to ReentrantMonitor.Exit and Enter.
  */ 
-class NS_STACK_CLASS MonitorAutoExit
+class NS_STACK_CLASS ReentrantMonitorAutoExit
 {
 public:
     /**
      * Constructor
      * The constructor releases the given lock.  The destructor
      * acquires the lock. The lock must be held before constructing
      * this object!
      * 
-     * @param aMonitor A valid mozilla::Monitor* returned by 
-     *                 mozilla::Monitor::NewMonitor. It must be
-     *                 already locked.
+     * @param aReentrantMonitor A valid mozilla::ReentrantMonitor*. It
+     *                 must be already locked.
      **/
-    MonitorAutoExit(mozilla::Monitor &aMonitor) :
-        mMonitor(&aMonitor)
+    ReentrantMonitorAutoExit(ReentrantMonitor& aReentrantMonitor) :
+        mReentrantMonitor(&aReentrantMonitor)
     {
-        NS_ASSERTION(mMonitor, "null monitor");
-        mMonitor->AssertCurrentThreadIn();
-        mMonitor->Exit();
+        NS_ASSERTION(mReentrantMonitor, "null monitor");
+        mReentrantMonitor->AssertCurrentThreadIn();
+        mReentrantMonitor->Exit();
     }
     
-    ~MonitorAutoExit(void)
+    ~ReentrantMonitorAutoExit(void)
     {
-        mMonitor->Enter();
+        mReentrantMonitor->Enter();
     }
  
 private:
-    MonitorAutoExit();
-    MonitorAutoExit(const MonitorAutoExit&);
-    MonitorAutoExit& operator =(const MonitorAutoExit&);
+    ReentrantMonitorAutoExit();
+    ReentrantMonitorAutoExit(const ReentrantMonitorAutoExit&);
+    ReentrantMonitorAutoExit& operator =(const ReentrantMonitorAutoExit&);
     static void* operator new(size_t) CPP_THROW_NEW;
     static void operator delete(void*);
 
-    mozilla::Monitor* mMonitor;
+    ReentrantMonitor* mReentrantMonitor;
 };
 
 } // namespace mozilla
 
 // Adds two 32bit unsigned numbers, retuns PR_TRUE if addition succeeded,
 // or PR_FALSE the if addition would result in an overflow.
 PRBool AddOverflow32(PRUint32 a, PRUint32 b, PRUint32& aResult);
  
--- a/content/media/nsAudioAvailableEventManager.cpp
+++ b/content/media/nsAudioAvailableEventManager.cpp
@@ -79,17 +79,17 @@ public:
 
 
 nsAudioAvailableEventManager::nsAudioAvailableEventManager(nsBuiltinDecoder* aDecoder) :
   mDecoder(aDecoder),
   mSignalBuffer(new float[mDecoder->GetFrameBufferLength()]),
   mSignalBufferLength(mDecoder->GetFrameBufferLength()),
   mNewSignalBufferLength(mSignalBufferLength),
   mSignalBufferPosition(0),
-  mMonitor("media.audioavailableeventmanager")
+  mReentrantMonitor("media.audioavailableeventmanager")
 {
   MOZ_COUNT_CTOR(nsAudioAvailableEventManager);
 }
 
 nsAudioAvailableEventManager::~nsAudioAvailableEventManager()
 {
   MOZ_COUNT_DTOR(nsAudioAvailableEventManager);
 }
@@ -97,17 +97,17 @@ nsAudioAvailableEventManager::~nsAudioAv
 void nsAudioAvailableEventManager::Init(PRUint32 aChannels, PRUint32 aRate)
 {
   NS_ASSERTION(aChannels != 0 && aRate != 0, "Audio metadata not known.");
   mSamplesPerSecond = static_cast<float>(aChannels * aRate);
 }
 
 void nsAudioAvailableEventManager::DispatchPendingEvents(PRUint64 aCurrentTime)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   while (mPendingEvents.Length() > 0) {
     nsAudioAvailableEventRunner* e =
       (nsAudioAvailableEventRunner*)mPendingEvents[0].get();
     if (e->mTime * USECS_PER_S > aCurrentTime) {
       break;
     }
     nsCOMPtr<nsIRunnable> event = mPendingEvents[0];
@@ -115,17 +115,17 @@ void nsAudioAvailableEventManager::Dispa
     NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
   }
 }
 
 void nsAudioAvailableEventManager::QueueWrittenAudioData(SoundDataValue* aAudioData,
                                                          PRUint32 aAudioDataLength,
                                                          PRUint64 aEndTimeSampleOffset)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   PRUint32 currentBufferSize = mNewSignalBufferLength;
   if (currentBufferSize == 0) {
     NS_WARNING("Decoder framebuffer length not set.");
     return;
   }
 
   if (!mSignalBuffer ||
@@ -197,25 +197,25 @@ void nsAudioAvailableEventManager::Queue
       signalBuffer[i] = MOZ_CONVERT_SOUND_SAMPLE(audioData[i]);
     }
     mSignalBufferPosition += audioDataLength;
   }
 }
 
 void nsAudioAvailableEventManager::Clear()
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   mPendingEvents.Clear();
   mSignalBufferPosition = 0;
 }
 
 void nsAudioAvailableEventManager::Drain(PRUint64 aEndTime)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   // Force all pending events to go now.
   for (PRUint32 i = 0; i < mPendingEvents.Length(); ++i) {
     nsCOMPtr<nsIRunnable> event = mPendingEvents[i];
     NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
   }
   mPendingEvents.Clear();
 
@@ -235,13 +235,13 @@ void nsAudioAvailableEventManager::Drain
                                     mSignalBufferLength, time);
   NS_DispatchToMainThread(lastEvent, NS_DISPATCH_NORMAL);
 
   mSignalBufferPosition = 0;
 }
 
 void nsAudioAvailableEventManager::SetSignalBufferLength(PRUint32 aLength)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   mNewSignalBufferLength = aLength;
 }
 
--- a/content/media/nsAudioAvailableEventManager.h
+++ b/content/media/nsAudioAvailableEventManager.h
@@ -100,13 +100,14 @@ private:
 
   // The position of the first available item in mSignalBuffer
   PRUint32 mSignalBufferPosition;
 
   // The MozAudioAvailable events to be dispatched.  This queue is shared
   // between the state machine and audio threads.
   nsTArray< nsCOMPtr<nsIRunnable> > mPendingEvents;
 
-  // Monitor for shared access to mPendingEvents queue or buffer length.
-  Monitor mMonitor;
+  // ReentrantMonitor for shared access to mPendingEvents queue or
+  // buffer length.
+  ReentrantMonitor mReentrantMonitor;
 };
 
 #endif
--- a/content/media/nsAudioStream.cpp
+++ b/content/media/nsAudioStream.cpp
@@ -35,17 +35,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 ***** */
 
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/PAudioChild.h"
 #include "mozilla/dom/AudioChild.h"
-#include "mozilla/Monitor.h"
 #include "nsXULAppAPI.h"
 using namespace mozilla::dom;
 
 #include <stdio.h>
 #include <math.h>
 #include "prlog.h"
 #include "prmem.h"
 #include "nsAutoPtr.h"
--- a/content/media/nsBuiltinDecoder.cpp
+++ b/content/media/nsBuiltinDecoder.cpp
@@ -56,17 +56,17 @@ PRLogModuleInfo* gBuiltinDecoderLog;
 #define LOG(type, msg)
 #endif
 
 NS_IMPL_THREADSAFE_ISUPPORTS1(nsBuiltinDecoder, nsIObserver)
 
 void nsBuiltinDecoder::Pause() 
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   if (mPlayState == PLAY_STATE_SEEKING || mPlayState == PLAY_STATE_ENDED) {
     mNextState = PLAY_STATE_PAUSED;
     return;
   }
 
   ChangeState(PLAY_STATE_PAUSED);
 }
 
@@ -91,17 +91,17 @@ double nsBuiltinDecoder::GetDuration()
 nsBuiltinDecoder::nsBuiltinDecoder() :
   mDecoderPosition(0),
   mPlaybackPosition(0),
   mCurrentTime(0.0),
   mInitialVolume(0.0),
   mRequestedSeekTime(-1.0),
   mDuration(-1),
   mSeekable(PR_TRUE),
-  mMonitor("media.decoder"),
+  mReentrantMonitor("media.decoder"),
   mPlayState(PLAY_STATE_PAUSED),
   mNextState(PLAY_STATE_PAUSED),
   mResourceLoaded(PR_FALSE),
   mIgnoreProgressData(PR_FALSE)
 {
   MOZ_COUNT_CTOR(nsBuiltinDecoder);
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
 #ifdef PR_LOGGING
@@ -190,17 +190,17 @@ nsresult nsBuiltinDecoder::Load(nsMediaS
   if (aStreamListener) {
     *aStreamListener = nsnull;
   }
 
   {
     // Hold the lock while we do this to set proper lock ordering
     // expectations for dynamic deadlock detectors: decoder lock(s)
     // should be grabbed before the cache lock
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
     nsresult rv = aStream->Open(aStreamListener);
     if (NS_FAILED(rv)) {
       delete aStream;
       return rv;
     }
 
     mStream = aStream;
@@ -212,17 +212,17 @@ nsresult nsBuiltinDecoder::Load(nsMediaS
   }
 
   nsBuiltinDecoder* cloneDonor = static_cast<nsBuiltinDecoder*>(aCloneDonor);
   if (NS_FAILED(mDecoderStateMachine->Init(cloneDonor ?
                                            cloneDonor->mDecoderStateMachine : nsnull))) {
     return NS_ERROR_FAILURE;
   }
   {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mDecoderStateMachine->SetSeekable(mSeekable);
     mDecoderStateMachine->SetDuration(mDuration);
     
     if (mFrameBufferLength > 0) {
       // The valid mFrameBufferLength value was specified earlier
       mDecoderStateMachine->SetFrameBufferLength(mFrameBufferLength);
     }
   }
@@ -232,17 +232,17 @@ nsresult nsBuiltinDecoder::Load(nsMediaS
   return StartStateMachineThread();
 }
 
 nsresult nsBuiltinDecoder::RequestFrameBufferLength(PRUint32 aLength)
 {
   nsresult res = nsMediaDecoder::RequestFrameBufferLength(aLength);
   NS_ENSURE_SUCCESS(res,res);
 
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   if (mDecoderStateMachine) {
       mDecoderStateMachine->SetFrameBufferLength(aLength);
   }
   return res;
 }
 
 nsresult nsBuiltinDecoder::StartStateMachineThread()
 {
@@ -254,34 +254,34 @@ nsresult nsBuiltinDecoder::StartStateMac
   nsresult rv = NS_NewThread(getter_AddRefs(mStateMachineThread));
   NS_ENSURE_SUCCESS(rv, rv);
   return mStateMachineThread->Dispatch(mDecoderStateMachine, NS_DISPATCH_NORMAL);
 }
 
 nsresult nsBuiltinDecoder::Play()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   nsresult res = StartStateMachineThread();
   NS_ENSURE_SUCCESS(res,res);
   if (mPlayState == PLAY_STATE_SEEKING) {
     mNextState = PLAY_STATE_PLAYING;
     return NS_OK;
   }
   if (mPlayState == PLAY_STATE_ENDED)
     return Seek(0);
 
   ChangeState(PLAY_STATE_PLAYING);
   return NS_OK;
 }
 
 nsresult nsBuiltinDecoder::Seek(double aTime)
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   if (aTime < 0.0)
     return NS_ERROR_FAILURE;
 
   mRequestedSeekTime = aTime;
   mCurrentTime = aTime;
 
   // If we are already in the seeking state, then setting mRequestedSeekTime
@@ -351,17 +351,17 @@ void nsBuiltinDecoder::MetadataLoaded(PR
   if (mShuttingDown) {
     return;
   }
 
   // Only inform the element of MetadataLoaded if not doing a load() in order
   // to fulfill a seek, otherwise we'll get multiple metadataloaded events.
   PRBool notifyElement = PR_TRUE;
   {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mDuration = mDecoderStateMachine ? mDecoderStateMachine->GetDuration() : -1;
     // Duration has changed so we should recompute playback rate
     UpdatePlaybackRate();
 
     notifyElement = mNextState != PLAY_STATE_SEEKING;
   }
 
   if (mElement && notifyElement) {
@@ -377,17 +377,17 @@ void nsBuiltinDecoder::MetadataLoaded(PR
   else if (mElement) {
     // Resource was loaded during metadata loading, when progress
     // events are being ignored. Fire the final progress event.
     mElement->DispatchAsyncEvent(NS_LITERAL_STRING("progress"));
   }
 
   // Only inform the element of FirstFrameLoaded if not doing a load() in order
   // to fulfill a seek, otherwise we'll get multiple loadedfirstframe events.
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   PRBool resourceIsLoaded = !mResourceLoaded && mStream &&
     mStream->IsDataCachedToEndOfStream(mDecoderPosition);
   if (mElement && notifyElement) {
     mElement->FirstFrameLoaded(resourceIsLoaded);
   }
 
   // The element can run javascript via events
   // before reaching here, so only change the
@@ -416,17 +416,17 @@ void nsBuiltinDecoder::ResourceLoaded()
   // that the seek results in reaching end of file, we get a bogus call
   // to ResourceLoaded).
   if (mShuttingDown)
     return;
 
   {
     // If we are seeking or loading then the resource loaded notification we get
     // should be ignored, since it represents the end of the seek request.
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     if (mIgnoreProgressData || mResourceLoaded || mPlayState == PLAY_STATE_LOADING)
       return;
 
     Progress(PR_FALSE);
 
     mResourceLoaded = PR_TRUE;
     StopProgress();
   }
@@ -499,17 +499,17 @@ NS_IMETHODIMP nsBuiltinDecoder::Observe(
 
 nsMediaDecoder::Statistics
 nsBuiltinDecoder::GetStatistics()
 {
   NS_ASSERTION(NS_IsMainThread() || OnStateMachineThread(),
                "Should be on main or state machine thread.");
   Statistics result;
 
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   if (mStream) {
     result.mDownloadRate = 
       mStream->GetDownloadRate(&result.mDownloadRateReliable);
     result.mDownloadPosition =
       mStream->GetCachedDataEnd(mDecoderPosition);
     result.mTotalBytes = mStream->GetLength();
     result.mPlaybackRate = ComputePlaybackRate(&result.mPlaybackRateReliable);
     result.mDecoderPosition = mDecoderPosition;
@@ -526,33 +526,33 @@ nsBuiltinDecoder::GetStatistics()
     result.mTotalBytes = 0;
   }
 
   return result;
 }
 
 double nsBuiltinDecoder::ComputePlaybackRate(PRPackedBool* aReliable)
 {
-  GetMonitor().AssertCurrentThreadIn();
+  GetReentrantMonitor().AssertCurrentThreadIn();
   NS_ASSERTION(NS_IsMainThread() || IsCurrentThread(mStateMachineThread),
                "Should be on main or state machine thread.");
 
   PRInt64 length = mStream ? mStream->GetLength() : -1;
   if (mDuration >= 0 && length >= 0) {
     *aReliable = PR_TRUE;
     return length * static_cast<double>(USECS_PER_S) / mDuration;
   }
   return mPlaybackStatistics.GetRateAtLastStop(aReliable);
 }
 
 void nsBuiltinDecoder::UpdatePlaybackRate()
 {
   NS_ASSERTION(NS_IsMainThread() || IsCurrentThread(mStateMachineThread),
                "Should be on main or state machine thread.");
-  GetMonitor().AssertCurrentThreadIn();
+  GetReentrantMonitor().AssertCurrentThreadIn();
   if (!mStream)
     return;
   PRPackedBool reliable;
   PRUint32 rate = PRUint32(ComputePlaybackRate(&reliable));
   if (reliable) {
     // Avoid passing a zero rate
     rate = NS_MAX(rate, 1u);
   }
@@ -589,32 +589,32 @@ void nsBuiltinDecoder::NotifyDownloadEnd
 
   if (aStatus == NS_BINDING_ABORTED) {
     // Download has been cancelled by user.
     mElement->LoadAborted();
     return;
   }
 
   {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     UpdatePlaybackRate();
   }
 
   if (NS_SUCCEEDED(aStatus)) {
     ResourceLoaded();
   }
   else if (aStatus != NS_BASE_STREAM_CLOSED) {
     NetworkError();
   }
   UpdateReadyStateForData();
 }
 
 void nsBuiltinDecoder::NotifyBytesConsumed(PRInt64 aBytes)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(OnStateMachineThread() || mDecoderStateMachine->OnDecodeThread(),
                "Should be on play state machine or decode thread.");
   if (!mIgnoreProgressData) {
     mDecoderPosition += aBytes;
     mPlaybackStatistics.AddBytes(aBytes);
   }
 }
 
@@ -658,17 +658,17 @@ void nsBuiltinDecoder::SeekingStopped()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
 
   if (mShuttingDown)
     return;
 
   PRBool seekWasAborted = PR_FALSE;
   {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
     // An additional seek was requested while the current seek was
     // in operation.
     if (mRequestedSeekTime >= 0.0) {
       ChangeState(PLAY_STATE_SEEKING);
       seekWasAborted = PR_TRUE;
     } else {
       UnpinForSeek();
@@ -691,17 +691,17 @@ void nsBuiltinDecoder::SeekingStoppedAtE
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
 
   if (mShuttingDown)
     return;
 
   PRBool fireEnded = PR_FALSE;
   PRBool seekWasAborted = PR_FALSE;
   {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
     // An additional seek was requested while the current seek was
     // in operation.
     if (mRequestedSeekTime >= 0.0) {
       ChangeState(PLAY_STATE_SEEKING);
       seekWasAborted = PR_TRUE;
     } else {
       UnpinForSeek();
@@ -731,24 +731,24 @@ void nsBuiltinDecoder::SeekingStarted()
     UpdateReadyStateForData();
     mElement->SeekStarted();
   }
 }
 
 void nsBuiltinDecoder::ChangeState(PlayState aState)
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");   
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   if (mNextState == aState) {
     mNextState = PLAY_STATE_PAUSED;
   }
 
   if (mPlayState == PLAY_STATE_SHUTDOWN) {
-    mMonitor.NotifyAll();
+    mReentrantMonitor.NotifyAll();
     return;
   }
 
   mPlayState = aState;
   switch (aState) {
   case PLAY_STATE_PAUSED:
     /* No action needed */
     break;
@@ -767,31 +767,31 @@ void nsBuiltinDecoder::ChangeState(PlayS
     break;
   case PLAY_STATE_ENDED:
     /* No action needed */
     break;
   case PLAY_STATE_SHUTDOWN:
     /* No action needed */
     break;
   }
-  mMonitor.NotifyAll();
+  mReentrantMonitor.NotifyAll();
 }
 
 void nsBuiltinDecoder::PlaybackPositionChanged()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   if (mShuttingDown)
     return;
 
   double lastTime = mCurrentTime;
 
   // Control the scope of the monitor so it is not
   // held while the timeupdate and the invalidate is run.
   {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     if (mDecoderStateMachine) {
       mCurrentTime = mDecoderStateMachine->GetCurrentTime();
       mDecoderStateMachine->ClearPositionChangeFlag();
     }
   }
 
   // Invalidate the frame so any video data is displayed.
   // Do this before the timeupdate event so that if that
@@ -802,48 +802,48 @@ void nsBuiltinDecoder::PlaybackPositionC
   if (mElement && lastTime != mCurrentTime) {
     FireTimeUpdate();
   }
 }
 
 void nsBuiltinDecoder::DurationChanged()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   PRInt64 oldDuration = mDuration;
   mDuration = mDecoderStateMachine ? mDecoderStateMachine->GetDuration() : -1;
   // Duration has changed so we should recompute playback rate
   UpdatePlaybackRate();
 
   if (mElement && oldDuration != mDuration) {
     LOG(PR_LOG_DEBUG, ("%p duration changed to %lld", this, mDuration));
     mElement->DispatchEvent(NS_LITERAL_STRING("durationchange"));
   }
 }
 
 void nsBuiltinDecoder::SetDuration(double aDuration)
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   mDuration = static_cast<PRInt64>(NS_round(aDuration * static_cast<double>(USECS_PER_S)));
 
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   if (mDecoderStateMachine) {
     mDecoderStateMachine->SetDuration(mDuration);
   }
 
   // Duration has changed so we should recompute playback rate
   UpdatePlaybackRate();
 }
 
 void nsBuiltinDecoder::SetSeekable(PRBool aSeekable)
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   mSeekable = aSeekable;
   if (mDecoderStateMachine) {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mDecoderStateMachine->SetSeekable(aSeekable);
   }
 }
 
 PRBool nsBuiltinDecoder::GetSeekable()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   return mSeekable;
@@ -859,17 +859,17 @@ void nsBuiltinDecoder::Suspend()
 
 void nsBuiltinDecoder::Resume(PRBool aForceBuffering)
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   if (mStream) {
     mStream->Resume();
   }
   if (aForceBuffering) {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mDecoderStateMachine->StartBuffering();
   }
 }
 
 void nsBuiltinDecoder::StopProgressUpdates()
 {
   NS_ASSERTION(IsCurrentThread(mStateMachineThread), "Should be on state machine thread.");
   mIgnoreProgressData = PR_TRUE;
@@ -893,11 +893,11 @@ void nsBuiltinDecoder::MoveLoadsToBackgr
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   if (mStream) {
     mStream->MoveLoadsToBackground();
   }
 }
 
 void nsBuiltinDecoder::UpdatePlaybackOffset(PRInt64 aOffset)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   mPlaybackPosition = NS_MAX(aOffset, mPlaybackPosition);
 }
--- a/content/media/nsBuiltinDecoder.h
+++ b/content/media/nsBuiltinDecoder.h
@@ -207,17 +207,17 @@ Shutdown when destroying the nsBuiltinDe
 #include "nsAutoPtr.h"
 #include "nsSize.h"
 #include "prlog.h"
 #include "gfxContext.h"
 #include "gfxRect.h"
 #include "nsMediaStream.h"
 #include "nsMediaDecoder.h"
 #include "nsHTMLMediaElement.h"
-#include "mozilla/Monitor.h"
+#include "mozilla/ReentrantMonitor.h"
 
 class nsAudioStream;
 
 static inline PRBool IsCurrentThread(nsIThread* aThread) {
   return NS_GetCurrentThread() == aThread;
 }
 
 // Decoder backends must implement this class to perform the codec
@@ -314,17 +314,17 @@ class nsBuiltinDecoder : public nsMediaD
 {
   // ISupports
   NS_DECL_ISUPPORTS
 
   // nsIObserver
   NS_DECL_NSIOBSERVER
 
  public:
-  typedef mozilla::Monitor Monitor;
+  typedef mozilla::ReentrantMonitor ReentrantMonitor;
 
   // Enumeration for the valid play states (see mPlayState)
   enum PlayState {
     PLAY_STATE_START,
     PLAY_STATE_LOADING,
     PLAY_STATE_PAUSED,
     PLAY_STATE_PLAYING,
     PLAY_STATE_SEEKING,
@@ -429,18 +429,18 @@ class nsBuiltinDecoder : public nsMediaD
   }
 
   PRBool OnDecodeThread() const {
     return mDecoderStateMachine->OnDecodeThread();
   }
 
   // Returns the monitor for other threads to synchronise access to
   // state.
-  Monitor& GetMonitor() { 
-    return mMonitor; 
+  ReentrantMonitor& GetReentrantMonitor() { 
+    return mReentrantMonitor; 
   }
 
   // Constructs the time ranges representing what segments of the media
   // are buffered and playable.
   virtual nsresult GetBuffered(nsTimeRanges* aBuffered) {
     if (mDecoderStateMachine) {
       return mDecoderStateMachine->GetBuffered(aBuffered);
     }
@@ -589,17 +589,17 @@ public:
   double mCurrentTime;
 
   // Volume that playback should start at.  0.0 = muted. 1.0 = full
   // volume.  Readable/Writeable from the main thread.
   double mInitialVolume;
 
   // Position to seek to when the seek notification is received by the
   // decode thread. Written by the main thread and read via the
-  // decode thread. Synchronised using mMonitor. If the
+  // decode thread. Synchronised using mReentrantMonitor. If the
   // value is negative then no seek has been requested. When a seek is
   // started this is reset to negative.
   double mRequestedSeekTime;
 
   // Duration of the media resource. Set to -1 if unknown.
   // Set when the metadata is loaded. Accessed on the main thread
   // only.
   PRInt64 mDuration;
@@ -617,23 +617,23 @@ public:
   // is synchronised on a monitor. The lifetime of this object is
   // after mPlayState is LOADING and before mPlayState is SHUTDOWN. It
   // is safe to access it during this period.
   nsCOMPtr<nsDecoderStateMachine> mDecoderStateMachine;
 
   // Stream of media data.
   nsAutoPtr<nsMediaStream> mStream;
 
-  // Monitor for detecting when the video play state changes. A call
+  // ReentrantMonitor for detecting when the video play state changes. A call
   // to Wait on this monitor will block the thread until the next
   // state change.
-  Monitor mMonitor;
+  ReentrantMonitor mReentrantMonitor;
 
   // Set to one of the valid play states. It is protected by the
-  // monitor mMonitor. This monitor must be acquired when reading or
+  // monitor mReentrantMonitor. This monitor must be acquired when reading or
   // writing the state. Any change to the state on the main thread
   // must call NotifyAll on the monitor so the decode thread can wake up.
   PlayState mPlayState;
 
   // The state to change to after a seek or load operation. It must only
   // be changed from the main thread. The decoder monitor must be acquired
   // when writing to the state, or when reading from a non-main thread.
   // Any change to the state must call NotifyAll on the monitor.
--- a/content/media/nsBuiltinDecoderReader.cpp
+++ b/content/media/nsBuiltinDecoderReader.cpp
@@ -202,17 +202,17 @@ VideoData* VideoData::Create(nsVideoInfo
   data.mPicSize = picSize;
   data.mStereoMode = aInfo.mStereoMode;
 
   videoImage->SetData(data); // Copies buffer
   return v.forget();
 }
 
 nsBuiltinDecoderReader::nsBuiltinDecoderReader(nsBuiltinDecoder* aDecoder)
-  : mMonitor("media.decoderreader"),
+  : mReentrantMonitor("media.decoderreader"),
     mDecoder(aDecoder)
 {
   MOZ_COUNT_CTOR(nsBuiltinDecoderReader);
 }
 
 nsBuiltinDecoderReader::~nsBuiltinDecoderReader()
 {
   ResetDecode();
@@ -274,17 +274,17 @@ PRInt64 nsBuiltinDecoderReader::FindEndT
 
 template<class Data>
 Data* nsBuiltinDecoderReader::DecodeToFirstData(DecodeFn aDecodeFn,
                                                 MediaQueue<Data>& aQueue)
 {
   PRBool eof = PR_FALSE;
   while (!eof && aQueue.GetSize() == 0) {
     {
-      MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
       if (mDecoder->GetDecodeState() == nsDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
         return nsnull;
       }
     }
     eof = !(this->*aDecodeFn)();
   }
   Data* d = nsnull;
   return (d = aQueue.PeekFront()) ? d : nsnull;
@@ -296,18 +296,18 @@ nsresult nsBuiltinDecoderReader::DecodeT
   if (HasVideo()) {
     PRBool eof = PR_FALSE;
     PRInt64 startTime = -1;
     while (HasVideo() && !eof) {
       while (mVideoQueue.GetSize() == 0 && !eof) {
         PRBool skip = PR_FALSE;
         eof = !DecodeVideoFrame(skip, 0);
         {
-          MonitorAutoExit exitReaderMon(mMonitor);
-          MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
+          ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
+          ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
           if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
             return NS_ERROR_FAILURE;
           }
         }
       }
       if (mVideoQueue.GetSize() == 0) {
         break;
       }
@@ -321,34 +321,34 @@ nsresult nsBuiltinDecoderReader::DecodeT
         mVideoQueue.PopFront();
         video = nsnull;
       } else {
         video.forget();
         break;
       }
     }
     {
-      MonitorAutoExit exitReaderMon(mMonitor);
-      MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
+      ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
       if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
         return NS_ERROR_FAILURE;
       }
     }
     LOG(PR_LOG_DEBUG, ("First video frame after decode is %lld", startTime));
   }
 
   if (HasAudio()) {
     // Decode audio forward to the seek target.
     PRBool eof = PR_FALSE;
     while (HasAudio() && !eof) {
       while (!eof && mAudioQueue.GetSize() == 0) {
         eof = !DecodeAudioData();
         {
-          MonitorAutoExit exitReaderMon(mMonitor);
-          MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
+          ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
+          ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
           if (mDecoder->GetDecodeState() == nsBuiltinDecoderStateMachine::DECODER_STATE_SHUTDOWN) {
             return NS_ERROR_FAILURE;
           }
         }
       }
       nsAutoPtr<SoundData> audio(mAudioQueue.PeekFront());
       if (audio && audio->mTime + audio->mDuration <= aTarget) {
         mAudioQueue.PopFront();
--- a/content/media/nsBuiltinDecoderReader.h
+++ b/content/media/nsBuiltinDecoderReader.h
@@ -41,17 +41,17 @@
 
 #include <nsDeque.h>
 #include "Layers.h"
 #include "ImageLayers.h"
 #include "nsClassHashtable.h"
 #include "mozilla/TimeStamp.h"
 #include "nsSize.h"
 #include "nsRect.h"
-#include "mozilla/Monitor.h"
+#include "mozilla/ReentrantMonitor.h"
 
 class nsBuiltinDecoderStateMachine;
 
 // Stores info relevant to presenting media samples.
 class nsVideoInfo {
 public:
   nsVideoInfo()
     : mPixelAspectRatio(1.0),
@@ -292,131 +292,131 @@ class MediaQueueDeallocator : public nsD
   virtual void* operator() (void* anObject) {
     delete static_cast<T*>(anObject);
     return nsnull;
   }
 };
 
 template <class T> class MediaQueue : private nsDeque {
  public:
-   typedef mozilla::MonitorAutoEnter MonitorAutoEnter;
-   typedef mozilla::Monitor Monitor;
+   typedef mozilla::ReentrantMonitorAutoEnter ReentrantMonitorAutoEnter;
+   typedef mozilla::ReentrantMonitor ReentrantMonitor;
 
    MediaQueue()
      : nsDeque(new MediaQueueDeallocator<T>()),
-       mMonitor("mediaqueue"),
+       mReentrantMonitor("mediaqueue"),
        mEndOfStream(0)
    {}
   
   ~MediaQueue() {
     Reset();
   }
 
   inline PRInt32 GetSize() { 
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return nsDeque::GetSize();
   }
   
   inline void Push(T* aItem) {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     nsDeque::Push(aItem);
   }
   
   inline void PushFront(T* aItem) {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     nsDeque::PushFront(aItem);
   }
   
   inline T* Pop() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return static_cast<T*>(nsDeque::Pop());
   }
 
   inline T* PopFront() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return static_cast<T*>(nsDeque::PopFront());
   }
   
   inline T* Peek() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return static_cast<T*>(nsDeque::Peek());
   }
   
   inline T* PeekFront() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return static_cast<T*>(nsDeque::PeekFront());
   }
 
   inline void Empty() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     nsDeque::Empty();
   }
 
   inline void Erase() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     nsDeque::Erase();
   }
 
   void Reset() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     while (GetSize() > 0) {
       T* x = PopFront();
       delete x;
     }
     mEndOfStream = PR_FALSE;
   }
 
   PRBool AtEndOfStream() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return GetSize() == 0 && mEndOfStream;    
   }
 
   // Returns PR_TRUE if the media queue has had it last sample added to it.
   // This happens when the media stream has been completely decoded. Note this
   // does not mean that the corresponding stream has finished playback.
   PRBool IsFinished() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return mEndOfStream;    
   }
 
   // Informs the media queue that it won't be receiving any more samples.
   void Finish() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mEndOfStream = PR_TRUE;    
   }
 
   // Returns the approximate number of microseconds of samples in the queue.
   PRInt64 Duration() {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     if (GetSize() < 2) {
       return 0;
     }
     T* last = Peek();
     T* first = PeekFront();
     return last->mTime - first->mTime;
   }
 
 private:
-  Monitor mMonitor;
+  ReentrantMonitor mReentrantMonitor;
 
   // PR_TRUE when we've decoded the last frame of data in the
   // bitstream for which we're queueing sample-data.
   PRBool mEndOfStream;
 };
 
 // Encapsulates the decoding and reading of media data. Reading can be done
 // on either the state machine thread (when loading and seeking) or on
 // the reader thread (when it's reading and decoding). The reader encapsulates
 // the reading state and maintains it's own monitor to ensure thread safety
 // and correctness. Never hold the nsBuiltinDecoder's monitor when calling into
 // this class.
 class nsBuiltinDecoderReader : public nsRunnable {
 public:
-  typedef mozilla::Monitor Monitor;
-  typedef mozilla::MonitorAutoEnter MonitorAutoEnter;
+  typedef mozilla::ReentrantMonitor ReentrantMonitor;
+  typedef mozilla::ReentrantMonitorAutoEnter ReentrantMonitorAutoEnter;
 
   nsBuiltinDecoderReader(nsBuiltinDecoder* aDecoder);
   ~nsBuiltinDecoderReader();
 
   // Initializes the reader, returns NS_OK on success, or NS_ERROR_FAILURE
   // on failure.
   virtual nsresult Init(nsBuiltinDecoderReader* aCloneDonor) = 0;
 
@@ -498,17 +498,17 @@ protected:
   // DecodeToFirstData().
   PRBool DecodeVideoFrame() {
     PRBool f = PR_FALSE;
     return DecodeVideoFrame(f, 0);
   }
 
   // The lock which we hold whenever we read or decode. This ensures the thread
   // safety of the reader and its data fields.
-  Monitor mMonitor;
+  ReentrantMonitor mReentrantMonitor;
 
   // Reference to the owning decoder object. Do not hold the
   // reader's monitor when accessing this.
   nsBuiltinDecoder* mDecoder;
 
   // Stores presentation info required for playback. The reader's monitor
   // must be held when accessing this.
   nsVideoInfo mInfo;
--- a/content/media/nsBuiltinDecoderStateMachine.cpp
+++ b/content/media/nsBuiltinDecoderStateMachine.cpp
@@ -170,17 +170,17 @@ public:
   const PRUint32 mChannels;
   const PRUint32 mRate;
 };
 
 nsBuiltinDecoderStateMachine::nsBuiltinDecoderStateMachine(nsBuiltinDecoder* aDecoder,
                                                            nsBuiltinDecoderReader* aReader) :
   mDecoder(aDecoder),
   mState(DECODER_STATE_DECODING_METADATA),
-  mAudioMonitor("media.audiostream"),
+  mAudioReentrantMonitor("media.audiostream"),
   mCbCrSize(0),
   mPlayDuration(0),
   mStartTime(-1),
   mEndTime(-1),
   mSeekTime(0),
   mReader(aReader),
   mCurrentFrameTime(0),
   mAudioStartTime(-1),
@@ -199,36 +199,36 @@ nsBuiltinDecoderStateMachine::nsBuiltinD
 }
 
 nsBuiltinDecoderStateMachine::~nsBuiltinDecoderStateMachine()
 {
   MOZ_COUNT_DTOR(nsBuiltinDecoderStateMachine);
 }
 
 PRBool nsBuiltinDecoderStateMachine::HasFutureAudio() const {
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   NS_ASSERTION(HasAudio(), "Should only call HasFutureAudio() when we have audio");
   // We've got audio ready to play if:
   // 1. We've not completed playback of audio, and
   // 2. we either have more than the threshold of decoded audio available, or
   //    we've completely decoded all audio (but not finished playing it yet
   //    as per 1).
   return !mAudioCompleted &&
          (AudioDecodedUsecs() > LOW_AUDIO_USECS || mReader->mAudioQueue.IsFinished());
 }
 
 PRBool nsBuiltinDecoderStateMachine::HaveNextFrameData() const {
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   return (!HasAudio() || HasFutureAudio()) &&
          (!HasVideo() || mReader->mVideoQueue.GetSize() > 0);
 }
 
 PRInt64 nsBuiltinDecoderStateMachine::GetDecodedAudioDuration() {
   NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   PRInt64 audioDecoded = mReader->mAudioQueue.Duration();
   if (mAudioEndTime != -1) {
     audioDecoded += mAudioEndTime - GetMediaTime();
   }
   return audioDecoded;
 }
 
 void nsBuiltinDecoderStateMachine::DecodeLoop()
@@ -262,17 +262,17 @@ void nsBuiltinDecoderStateMachine::Decod
   // Our local ample audio threshold. If we increase lowAudioThreshold, we'll
   // also increase this too appropriately (we don't want lowAudioThreshold to
   // be greater than ampleAudioThreshold, else we'd stop decoding!).
   PRInt64 ampleAudioThreshold = AMPLE_AUDIO_USECS;
 
   MediaQueue<VideoData>& videoQueue = mReader->mVideoQueue;
   MediaQueue<SoundData>& audioQueue = mReader->mAudioQueue;
 
-  MonitorAutoEnter mon(mDecoder->GetMonitor());
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
 
   PRBool videoPlaying = HasVideo();
   PRBool audioPlaying = HasAudio();
 
   // Main decode loop.
   while (mState != DECODER_STATE_SHUTDOWN &&
          !mStopDecodeThreads &&
          (videoPlaying || audioPlaying))
@@ -318,17 +318,17 @@ void nsBuiltinDecoderStateMachine::Decod
         static_cast<PRUint32>(videoQueue.GetSize()) < AMPLE_VIDEO_FRAMES)
     {
       // Time the video decode, so that if it's slow, we can increase our low
       // audio threshold to reduce the chance of an audio underrun while we're
       // waiting for a video decode to complete.
       TimeDuration decodeTime;
       {
         PRInt64 currentTime = GetMediaTime();
-        MonitorAutoExit exitMon(mDecoder->GetMonitor());
+        ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
         TimeStamp start = TimeStamp::Now();
         videoPlaying = mReader->DecodeVideoFrame(skipToNextKeyframe, currentTime);
         decodeTime = TimeStamp::Now() - start;
       }
       if (THRESHOLD_FACTOR * DurationToUsecs(decodeTime) > lowAudioThreshold &&
           !HasLowUndecodedData())
       {
         lowAudioThreshold =
@@ -340,23 +340,23 @@ void nsBuiltinDecoderStateMachine::Decod
              lowAudioThreshold, ampleAudioThreshold));
       }
     }
 
     // Audio decode.
     if (audioPlaying &&
         (GetDecodedAudioDuration() < ampleAudioThreshold || audioQueue.GetSize() == 0))
     {
-      MonitorAutoExit exitMon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
       audioPlaying = mReader->DecodeAudioData();
     }
     
     // Notify to ensure that the AudioLoop() is not waiting, in case it was
     // waiting for more audio to be decoded.
-    mDecoder->GetMonitor().NotifyAll();
+    mDecoder->GetReentrantMonitor().NotifyAll();
 
     if (!IsPlaying()) {
       // Update the ready state, so that the play DOM events fire. We only
       // need to do this if we're not playing; if we're playing the playback
       // code will do an update whenever it advances a frame.
       UpdateReadyState();
     }
 
@@ -382,54 +382,54 @@ void nsBuiltinDecoderStateMachine::Decod
 
   } // End decode loop.
 
   if (!mStopDecodeThreads &&
       mState != DECODER_STATE_SHUTDOWN &&
       mState != DECODER_STATE_SEEKING)
   {
     mState = DECODER_STATE_COMPLETED;
-    mDecoder->GetMonitor().NotifyAll();
+    mDecoder->GetReentrantMonitor().NotifyAll();
   }
 
   LOG(PR_LOG_DEBUG, ("Shutting down DecodeLoop this=%p", this));
 }
 
 PRBool nsBuiltinDecoderStateMachine::IsPlaying()
 {
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   return !mPlayStartTime.IsNull();
 }
 
 void nsBuiltinDecoderStateMachine::AudioLoop()
 {
   NS_ASSERTION(OnAudioThread(), "Should be on audio thread.");
   LOG(PR_LOG_DEBUG, ("Begun audio thread/loop"));
   PRInt64 audioDuration = 0;
   PRInt64 audioStartTime = -1;
   PRUint32 channels, rate;
   double volume = -1;
   PRBool setVolume;
   PRInt32 minWriteSamples = -1;
   PRInt64 samplesAtLastSleep = 0;
   {
-    MonitorAutoEnter mon(mDecoder->GetMonitor());
+    ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     mAudioCompleted = PR_FALSE;
     audioStartTime = mAudioStartTime;
     channels = mInfo.mAudioChannels;
     rate = mInfo.mAudioRate;
     NS_ASSERTION(audioStartTime != -1, "Should have audio start time by now");
   }
   while (1) {
 
     // Wait while we're not playing, and we're not shutting down, or we're
     // playing and we've got no audio to play.
     {
-      MonitorAutoEnter mon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
       NS_ASSERTION(mState != DECODER_STATE_DECODING_METADATA,
                    "Should have meta data before audio started playing.");
       while (mState != DECODER_STATE_SHUTDOWN &&
              !mStopDecodeThreads &&
              (!IsPlaying() ||
               mState == DECODER_STATE_BUFFERING ||
               (mReader->mAudioQueue.GetSize() == 0 &&
                !mReader->mAudioQueue.AtEndOfStream())))
@@ -450,17 +450,17 @@ void nsBuiltinDecoderStateMachine::Audio
       // changing the volume if it's the first time we've entered the loop
       // (as we must sync the volume in case it's changed since the
       // nsAudioStream was created) or if the volume has changed.
       setVolume = volume != mVolume;
       volume = mVolume;
     }
 
     if (setVolume || minWriteSamples == -1) {
-      MonitorAutoEnter audioMon(mAudioMonitor);
+      ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
       if (mAudioStream) {
         if (setVolume) {
           mAudioStream->SetVolume(volume);
         }
         if (minWriteSamples == -1) {
           minWriteSamples = mAudioStream->GetMinWriteSamples();
         }
       }
@@ -503,17 +503,17 @@ void nsBuiltinDecoderStateMachine::Audio
       // time.
       missingSamples = NS_MIN(static_cast<PRInt64>(PR_UINT32_MAX), missingSamples);
       audioDuration += PlaySilence(static_cast<PRUint32>(missingSamples),
                                    channels, playedSamples);
     } else {
       audioDuration += PlayFromAudioQueue(sampleTime, channels);
     }
     {
-      MonitorAutoEnter mon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
       PRInt64 playedUsecs;
       if (!SamplesToUsecs(audioDuration, rate, playedUsecs)) {
         NS_WARNING("Int overflow calculating playedUsecs");
         break;
       }
       if (!AddOverflow(audioStartTime, playedUsecs, mAudioEndTime)) {
         NS_WARNING("Int overflow calculating audio end time");
         break;
@@ -540,24 +540,24 @@ void nsBuiltinDecoderStateMachine::Audio
     }
   }
   if (mReader->mAudioQueue.AtEndOfStream() &&
       mState != DECODER_STATE_SHUTDOWN &&
       !mStopDecodeThreads)
   {
     // Last sample pushed to audio hardware, wait for the audio to finish,
     // before the audio thread terminates.
-    MonitorAutoEnter audioMon(mAudioMonitor);
+    ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
     if (mAudioStream) {
       PRBool seeking = PR_FALSE;
       PRInt64 oldPosition = -1;
 
       {
-        MonitorAutoExit audioExit(mAudioMonitor);
-        MonitorAutoEnter mon(mDecoder->GetMonitor());
+        ReentrantMonitorAutoExit audioExit(mAudioReentrantMonitor);
+        ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
         PRInt64 position = GetMediaTime();
         while (oldPosition != position &&
                mAudioEndTime - position > 0 &&
                mState != DECODER_STATE_SEEKING &&
                mState != DECODER_STATE_SHUTDOWN)
         {
           const PRInt64 DRAIN_BLOCK_USECS = 100000;
           Wait(NS_MIN(mAudioEndTime - position, DRAIN_BLOCK_USECS));
@@ -574,32 +574,32 @@ void nsBuiltinDecoderStateMachine::Audio
 
         // Fire one last event for any extra samples that didn't fill a framebuffer.
         mEventManager.Drain(mAudioEndTime);
       }
     }
     LOG(PR_LOG_DEBUG, ("%p Reached audio stream end.", mDecoder));
   }
   {
-    MonitorAutoEnter mon(mDecoder->GetMonitor());
+    ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     mAudioCompleted = PR_TRUE;
     UpdateReadyState();
     // Kick the decode and state machine threads; they may be sleeping waiting
     // for this to finish.
-    mDecoder->GetMonitor().NotifyAll();
+    mDecoder->GetReentrantMonitor().NotifyAll();
   }
   LOG(PR_LOG_DEBUG, ("Audio stream finished playing, audio thread exit"));
 }
 
 PRUint32 nsBuiltinDecoderStateMachine::PlaySilence(PRUint32 aSamples,
                                                    PRUint32 aChannels,
                                                    PRUint64 aSampleOffset)
 
 {
-  MonitorAutoEnter audioMon(mAudioMonitor);
+  ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
   if (!mAudioStream || mAudioStream->IsPaused()) {
     // The state machine has paused since we've released the decoder
     // monitor and acquired the audio monitor. Don't write any audio.
     return 0;
   }
   PRUint32 maxSamples = SILENCE_BYTES_CHUNK / aChannels;
   PRUint32 samples = NS_MIN(aSamples, maxSamples);
   PRUint32 numValues = samples * aChannels;
@@ -612,26 +612,26 @@ PRUint32 nsBuiltinDecoderStateMachine::P
   return samples;
 }
 
 PRUint32 nsBuiltinDecoderStateMachine::PlayFromAudioQueue(PRUint64 aSampleOffset,
                                                           PRUint32 aChannels)
 {
   nsAutoPtr<SoundData> sound(mReader->mAudioQueue.PopFront());
   {
-    MonitorAutoEnter mon(mDecoder->GetMonitor());
+    ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     NS_WARN_IF_FALSE(IsPlaying(), "Should be playing");
     // Awaken the decode loop if it's waiting for space to free up in the
     // audio queue.
-    mDecoder->GetMonitor().NotifyAll();
+    mDecoder->GetReentrantMonitor().NotifyAll();
   }
   PRInt64 offset = -1;
   PRUint32 samples = 0;
   {
-    MonitorAutoEnter audioMon(mAudioMonitor);
+    ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
     if (!mAudioStream) {
       return 0;
     }
     // The state machine could have paused since we've released the decoder
     // monitor and acquired the audio monitor. Rather than acquire both
     // monitors, the audio stream also maintains whether its paused or not.
     // This prevents us from doing a blocking write while holding the audio
     // monitor while paused; we would block, and the state machine won't be
@@ -668,32 +668,32 @@ nsresult nsBuiltinDecoderStateMachine::I
   }
   return mReader->Init(cloneReader);
 }
 
 void nsBuiltinDecoderStateMachine::StopPlayback(eStopMode aMode)
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
                "Should be on state machine thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   mDecoder->mPlaybackStatistics.Stop(TimeStamp::Now());
 
   // Reset mPlayStartTime before we pause/shutdown the nsAudioStream. This is
   // so that if the audio loop is about to write audio, it will have the chance
   // to check to see if we're paused and not write the audio. If not, the
   // audio thread can block in the write, and we deadlock trying to acquire
   // the audio monitor upon resume playback.
   if (IsPlaying()) {
     mPlayDuration += DurationToUsecs(TimeStamp::Now() - mPlayStartTime);
     mPlayStartTime = TimeStamp();
   }
   if (HasAudio()) {
-    MonitorAutoExit exitMon(mDecoder->GetMonitor());
-    MonitorAutoEnter audioMon(mAudioMonitor);
+    ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
+    ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
     if (mAudioStream) {
       if (aMode == AUDIO_PAUSE) {
         mAudioStream->Pause();
       } else if (aMode == AUDIO_SHUTDOWN) {
         mAudioStream->Shutdown();
         mAudioStream = nsnull;
         mEventManager.Clear();
       }
@@ -701,47 +701,47 @@ void nsBuiltinDecoderStateMachine::StopP
   }
 }
 
 void nsBuiltinDecoderStateMachine::StartPlayback()
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
                "Should be on state machine thread.");
   NS_ASSERTION(!IsPlaying(), "Shouldn't be playing when StartPlayback() is called");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   LOG(PR_LOG_DEBUG, ("%p StartPlayback", mDecoder));
   mDecoder->mPlaybackStatistics.Start(TimeStamp::Now());
   if (HasAudio()) {
     PRInt32 rate = mInfo.mAudioRate;
     PRInt32 channels = mInfo.mAudioChannels;
 
     {
-      MonitorAutoExit exitMon(mDecoder->GetMonitor());
-      MonitorAutoEnter audioMon(mAudioMonitor);
+      ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
+      ReentrantMonitorAutoEnter audioMon(mAudioReentrantMonitor);
       if (mAudioStream) {
         // We have an audiostream, so it must have been paused the last time
         // StopPlayback() was called.
         mAudioStream->Resume();
       } else {
         // No audiostream, create one.
         mAudioStream = nsAudioStream::AllocateStream();
         mAudioStream->Init(channels, rate, MOZ_SOUND_DATA_FORMAT);
         mAudioStream->SetVolume(mVolume);
       }
     }
   }
   mPlayStartTime = TimeStamp::Now();
-  mDecoder->GetMonitor().NotifyAll();
+  mDecoder->GetReentrantMonitor().NotifyAll();
 }
 
 void nsBuiltinDecoderStateMachine::UpdatePlaybackPositionInternal(PRInt64 aTime)
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
                "Should be on state machine thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   NS_ASSERTION(mStartTime >= 0, "Should have positive mStartTime");
   mCurrentFrameTime = aTime - mStartTime;
   NS_ASSERTION(mCurrentFrameTime >= 0, "CurrentTime should be positive!");
   if (aTime > mEndTime) {
     NS_ASSERTION(mCurrentFrameTime > GetDuration(),
                  "CurrentTime must be after duration if aTime > endTime!");
     mEndTime = aTime;
@@ -764,134 +764,134 @@ void nsBuiltinDecoderStateMachine::Updat
 
   // Notify DOM of any queued up audioavailable events
   mEventManager.DispatchPendingEvents(GetMediaTime());
 }
 
 void nsBuiltinDecoderStateMachine::ClearPositionChangeFlag()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   mPositionChangeQueued = PR_FALSE;
 }
 
 nsHTMLMediaElement::NextFrameStatus nsBuiltinDecoderStateMachine::GetNextFrameStatus()
 {
-  MonitorAutoEnter mon(mDecoder->GetMonitor());
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   if (IsBuffering() || IsSeeking()) {
     return nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE_BUFFERING;
   } else if (HaveNextFrameData()) {
     return nsHTMLMediaElement::NEXT_FRAME_AVAILABLE;
   }
   return nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE;
 }
 
 void nsBuiltinDecoderStateMachine::SetVolume(double volume)
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-  MonitorAutoEnter mon(mDecoder->GetMonitor());
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   mVolume = volume;
 }
 
 double nsBuiltinDecoderStateMachine::GetCurrentTime() const
 {
   NS_ASSERTION(NS_IsMainThread() ||
                mDecoder->OnStateMachineThread() ||
                OnDecodeThread(),
                "Should be on main, decode, or state machine thread.");
 
   return static_cast<double>(mCurrentFrameTime) / static_cast<double>(USECS_PER_S);
 }
 
 PRInt64 nsBuiltinDecoderStateMachine::GetDuration()
 {
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   if (mEndTime == -1 || mStartTime == -1)
     return -1;
   return mEndTime - mStartTime;
 }
 
 void nsBuiltinDecoderStateMachine::SetDuration(PRInt64 aDuration)
 {
   NS_ASSERTION(NS_IsMainThread() || mDecoder->OnStateMachineThread(),
     "Should be on main or state machine thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   if (mStartTime != -1) {
     mEndTime = mStartTime + aDuration;
   } else {
     mStartTime = 0;
     mEndTime = aDuration;
   }
 }
 
 void nsBuiltinDecoderStateMachine::SetSeekable(PRBool aSeekable)
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   mSeekable = aSeekable;
 }
 
 void nsBuiltinDecoderStateMachine::Shutdown()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
 
   // Once we've entered the shutdown state here there's no going back.
-  MonitorAutoEnter mon(mDecoder->GetMonitor());
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
 
   // Change state before issuing shutdown request to threads so those
   // threads can start exiting cleanly during the Shutdown call.
   LOG(PR_LOG_DEBUG, ("%p Changed state to SHUTDOWN", mDecoder));
   mState = DECODER_STATE_SHUTDOWN;
-  mDecoder->GetMonitor().NotifyAll();
+  mDecoder->GetReentrantMonitor().NotifyAll();
 }
 
 void nsBuiltinDecoderStateMachine::StartDecoding()
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
                "Should be on state machine thread.");
-  MonitorAutoEnter mon(mDecoder->GetMonitor());
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   if (mState != DECODER_STATE_DECODING) {
     mDecodeStartTime = TimeStamp::Now();
   }
   mState = DECODER_STATE_DECODING;
 }
 
 void nsBuiltinDecoderStateMachine::Play()
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
   // When asked to play, switch to decoding state only if
   // we are currently buffering. In other cases, we'll start playing anyway
   // when the state machine notices the decoder's state change to PLAYING.
-  MonitorAutoEnter mon(mDecoder->GetMonitor());
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   if (mState == DECODER_STATE_BUFFERING) {
     LOG(PR_LOG_DEBUG, ("%p Changed state from BUFFERING to DECODING", mDecoder));
     mState = DECODER_STATE_DECODING;
     mDecodeStartTime = TimeStamp::Now();
-    mDecoder->GetMonitor().NotifyAll();
+    mDecoder->GetReentrantMonitor().NotifyAll();
   }
 }
 
 void nsBuiltinDecoderStateMachine::ResetPlayback()
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
                "Should be on state machine thread.");
   mVideoFrameEndTime = -1;
   mAudioStartTime = -1;
   mAudioEndTime = -1;
   mAudioCompleted = PR_FALSE;
 }
 
 void nsBuiltinDecoderStateMachine::Seek(double aTime)
 {
   NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
-  MonitorAutoEnter mon(mDecoder->GetMonitor());
+  ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
   // nsBuiltinDecoder::mPlayState should be SEEKING while we seek, and
   // in that case nsBuiltinDecoder shouldn't be calling us.
   NS_ASSERTION(mState != DECODER_STATE_SEEKING,
                "We shouldn't already be seeking");
   NS_ASSERTION(mState >= DECODER_STATE_DECODING,
                "We should have loaded metadata");
   double t = aTime * static_cast<double>(USECS_PER_S);
   if (t > PR_INT64_MAX) {
@@ -911,41 +911,41 @@ void nsBuiltinDecoderStateMachine::Seek(
   LOG(PR_LOG_DEBUG, ("%p Changed state to SEEKING (to %f)", mDecoder, aTime));
   mState = DECODER_STATE_SEEKING;
 }
 
 void nsBuiltinDecoderStateMachine::StopDecodeThreads()
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
                "Should be on state machine thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   mStopDecodeThreads = PR_TRUE;
-  mDecoder->GetMonitor().NotifyAll();
+  mDecoder->GetReentrantMonitor().NotifyAll();
   if (mDecodeThread) {
     {
-      MonitorAutoExit exitMon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
       mDecodeThread->Shutdown();
     }
     mDecodeThread = nsnull;
   }
   if (mAudioThread) {
     {
-      MonitorAutoExit exitMon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
       mAudioThread->Shutdown();
     }
     mAudioThread = nsnull;
   }
 }
 
 nsresult
 nsBuiltinDecoderStateMachine::StartDecodeThreads()
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
                "Should be on state machine thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   mStopDecodeThreads = PR_FALSE;
   if (!mDecodeThread && mState < DECODER_STATE_COMPLETED) {
     nsresult rv = NS_NewThread(getter_AddRefs(mDecodeThread));
     if (NS_FAILED(rv)) {
       mState = DECODER_STATE_SHUTDOWN;
       return rv;
     }
     nsCOMPtr<nsIRunnable> event =
@@ -973,17 +973,17 @@ PRInt64 nsBuiltinDecoderStateMachine::Au
   // already decoded and pushed to the hardware, plus the amount of audio
   // data waiting to be pushed to the hardware.
   PRInt64 pushed = (mAudioEndTime != -1) ? (mAudioEndTime - GetMediaTime()) : 0;
   return pushed + mReader->mAudioQueue.Duration();
 }
 
 PRBool nsBuiltinDecoderStateMachine::HasLowDecodedData(PRInt64 aAudioUsecs) const
 {
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   // We consider ourselves low on decoded data if we're low on audio,
   // provided we've not decoded to the end of the audio stream, or
   // if we're only playing video and we're low on video frames, provided
   // we've not decoded to the end of the video stream.
   return ((HasAudio() &&
            !mReader->mAudioQueue.IsFinished() &&
            AudioDecodedUsecs() < aAudioUsecs)
           ||
@@ -995,17 +995,17 @@ PRBool nsBuiltinDecoderStateMachine::Has
 
 PRBool nsBuiltinDecoderStateMachine::HasLowUndecodedData() const
 {
   return GetUndecodedData() < LOW_DATA_THRESHOLD_USECS;
 }
 
 PRInt64 nsBuiltinDecoderStateMachine::GetUndecodedData() const
 {
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   NS_ASSERTION(mState > DECODER_STATE_DECODING_METADATA,
                "Must have loaded metadata for GetBuffered() to work");
   nsTimeRanges buffered;
   
   nsresult res = mDecoder->GetBuffered(&buffered);
   NS_ENSURE_SUCCESS(res, 0);
   double currentTime = GetCurrentTime();
 
@@ -1028,29 +1028,29 @@ PRInt64 nsBuiltinDecoderStateMachine::Ge
   }
   return 0;
 }
 
 void nsBuiltinDecoderStateMachine::SetFrameBufferLength(PRUint32 aLength)
 {
   NS_ASSERTION(aLength >= 512 && aLength <= 16384,
                "The length must be between 512 and 16384");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   mEventManager.SetSignalBufferLength(aLength);
 }
 
 nsresult nsBuiltinDecoderStateMachine::Run()
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
                "Should be on state machine thread.");
   nsMediaStream* stream = mDecoder->GetCurrentStream();
   NS_ENSURE_TRUE(stream, NS_ERROR_NULL_POINTER);
 
   while (PR_TRUE) {
-    MonitorAutoEnter mon(mDecoder->GetMonitor());
+    ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor());
     switch (mState) {
     case DECODER_STATE_SHUTDOWN:
       if (IsPlaying()) {
         StopPlayback(AUDIO_SHUTDOWN);
       }
       StopDecodeThreads();
       NS_ASSERTION(mState == DECODER_STATE_SHUTDOWN,
                    "How did we escape from the shutdown state???");
@@ -1063,17 +1063,17 @@ nsresult nsBuiltinDecoderStateMachine::R
           continue;
         }
 
         VideoData* videoData = FindStartTime();
         if (videoData) {
           nsIntSize display = mInfo.mDisplay;
           float aspect = mInfo.mPixelAspectRatio;
           {
-            MonitorAutoExit exitMon(mDecoder->GetMonitor());
+            ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
             RenderVideoFrame(videoData, TimeStamp::Now(), display, aspect);
           }
         }
 
         // Start the decode threads, so that we can pre buffer the streams.
         // and calculate the start time in order to determine the duration.
         if (NS_FAILED(StartDecodeThreads())) {
           continue;
@@ -1152,32 +1152,32 @@ nsresult nsBuiltinDecoderStateMachine::R
           currentTimeChanged = true;
           UpdatePlaybackPositionInternal(seekTime);
         }
 
         // SeekingStarted will do a UpdateReadyStateForData which will
         // inform the element and its users that we have no frames
         // to display
         {
-          MonitorAutoExit exitMon(mDecoder->GetMonitor());
+          ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
           nsCOMPtr<nsIRunnable> startEvent =
             NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::SeekingStarted);
           NS_DispatchToMainThread(startEvent, NS_DISPATCH_SYNC);
         }
 
         if (currentTimeChanged) {
           // The seek target is different than the current playback position,
           // we'll need to seek the playback position, so shutdown our decode
           // and audio threads.
           StopPlayback(AUDIO_SHUTDOWN);
           StopDecodeThreads();
           ResetPlayback();
           nsresult res;
           {
-            MonitorAutoExit exitMon(mDecoder->GetMonitor());
+            ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
             // Now perform the seek. We must not hold the state machine monitor
             // while we seek, since the seek decodes.
             res = mReader->Seek(seekTime,
                                 mStartTime,
                                 mEndTime,
                                 mediaTime);
           }
           if (NS_SUCCEEDED(res)){
@@ -1191,17 +1191,17 @@ nsresult nsBuiltinDecoderStateMachine::R
             if (HasVideo()) {
               nsAutoPtr<VideoData> video(mReader->mVideoQueue.PeekFront());
               if (video) {
                 NS_ASSERTION(video->mTime <= seekTime && seekTime <= video->mEndTime,
                              "Seek target should lie inside the first frame after seek");
                 nsIntSize display = mInfo.mDisplay;
                 float aspect = mInfo.mPixelAspectRatio;
                 {
-                  MonitorAutoExit exitMon(mDecoder->GetMonitor());
+                  ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
                   RenderVideoFrame(video, TimeStamp::Now(), display, aspect);
                 }
                 mReader->mVideoQueue.PopFront();
                 nsCOMPtr<nsIRunnable> event =
                   NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::Invalidate);
                 NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
               }
             }
@@ -1225,35 +1225,35 @@ nsresult nsBuiltinDecoderStateMachine::R
           stopEvent = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::SeekingStoppedAtEnd);
           mState = DECODER_STATE_COMPLETED;
         } else {
           LOG(PR_LOG_DEBUG, ("%p Changed state from SEEKING (to %lld) to DECODING",
                              mDecoder, seekTime));
           stopEvent = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::SeekingStopped);
           StartDecoding();
         }
-        mDecoder->GetMonitor().NotifyAll();
+        mDecoder->GetReentrantMonitor().NotifyAll();
 
         {
-          MonitorAutoExit exitMon(mDecoder->GetMonitor());
+          ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
           NS_DispatchToMainThread(stopEvent, NS_DISPATCH_SYNC);
         }
 
         // Reset quick buffering status. This ensures that if we began the
         // seek while quick-buffering, we won't bypass quick buffering mode
         // if we need to buffer after the seek.
         mQuickBuffering = PR_FALSE;
       }
       break;
 
     case DECODER_STATE_BUFFERING:
       {
         if (IsPlaying()) {
           StopPlayback(AUDIO_PAUSE);
-          mDecoder->GetMonitor().NotifyAll();
+          mDecoder->GetReentrantMonitor().NotifyAll();
         }
 
         TimeStamp now = TimeStamp::Now();
         NS_ASSERTION(!mBufferingStart.IsNull(), "Must know buffering start time.");
 
         // We will remain in the buffering state if we've not decoded enough
         // data to begin playback, or if we've not downloaded a reasonable
         // amount of data inside our buffering time.
@@ -1280,17 +1280,17 @@ nsresult nsBuiltinDecoderStateMachine::R
           LOG(PR_LOG_DEBUG, ("%p Buffered for %.3lfs",
                              mDecoder,
                              (now - mBufferingStart).ToSeconds()));
           StartDecoding();
         }
 
         if (mState != DECODER_STATE_BUFFERING) {
           // Notify to allow blocked decoder thread to continue
-          mDecoder->GetMonitor().NotifyAll();
+          mDecoder->GetReentrantMonitor().NotifyAll();
           UpdateReadyState();
           if (mDecoder->GetState() == nsBuiltinDecoder::PLAY_STATE_PLAYING) {
             if (!IsPlaying()) {
               StartPlayback();
             }
           }
         }
         break;
@@ -1324,17 +1324,17 @@ nsresult nsBuiltinDecoderStateMachine::R
         LOG(PR_LOG_DEBUG, ("Shutting down the state machine thread"));
         StopDecodeThreads();
 
         if (mDecoder->GetState() == nsBuiltinDecoder::PLAY_STATE_PLAYING) {
           PRInt64 videoTime = HasVideo() ? mVideoFrameEndTime : 0;
           PRInt64 clockTime = NS_MAX(mEndTime, NS_MAX(videoTime, GetAudioClock()));
           UpdatePlaybackPosition(clockTime);
           {
-            MonitorAutoExit exitMon(mDecoder->GetMonitor());
+            ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
             nsCOMPtr<nsIRunnable> event =
               NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::PlaybackEnded);
             NS_DispatchToMainThread(event, NS_DISPATCH_SYNC);
           }
         }
 
         if (mState == DECODER_STATE_COMPLETED) {
           // We've finished playback. Shutdown the state machine thread, 
@@ -1354,17 +1354,17 @@ nsresult nsBuiltinDecoderStateMachine::R
 }
 
 void nsBuiltinDecoderStateMachine::RenderVideoFrame(VideoData* aData,
                                                     TimeStamp aTarget,
                                                     nsIntSize aDisplaySize,
                                                     float aAspectRatio)
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread), "Should be on state machine thread.");
-  mDecoder->GetMonitor().AssertNotCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertNotCurrentThreadIn();
 
   if (aData->mDuplicate) {
     return;
   }
 
   nsRefPtr<Image> image = aData->mImage;
   if (image) {
     mDecoder->SetVideoData(gfxIntSize(aDisplaySize.width, aDisplaySize.height),
@@ -1380,17 +1380,17 @@ nsBuiltinDecoderStateMachine::GetAudioCl
     return -1;
   PRInt64 t = mAudioStream->GetPosition();
   return (t == -1) ? -1 : t + mAudioStartTime;
 }
 
 void nsBuiltinDecoderStateMachine::AdvanceFrame()
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread), "Should be on state machine thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   // When it's time to display a frame, decode the frame and display it.
   if (mDecoder->GetState() == nsBuiltinDecoder::PLAY_STATE_PLAYING) {
     if (HasAudio() && mAudioStartTime == -1 && !mAudioCompleted) {
       // We've got audio (so we should sync off the audio clock), but we've not
       // played a sample on the audio thread, so we can't get a time from the
       // audio clock. Just wait and then return, to give the audio clock time
       // to tick.  This should really wait for a specific signal from the audio
@@ -1464,43 +1464,43 @@ void nsBuiltinDecoderStateMachine::Advan
       StartBuffering();
       return;
     }
 
     // We've got enough data to keep playing until at least the next frame.
     // Start playing now if need be.
     if (!IsPlaying()) {
       StartPlayback();
-      mDecoder->GetMonitor().NotifyAll();
+      mDecoder->GetReentrantMonitor().NotifyAll();
     }
 
     if (currentFrame) {
       // Decode one frame and display it.
       TimeStamp presTime = mPlayStartTime - UsecsToDuration(mPlayDuration) +
                            UsecsToDuration(currentFrame->mTime - mStartTime);
       NS_ASSERTION(currentFrame->mTime >= mStartTime, "Should have positive frame time");
       {
         nsIntSize display = mInfo.mDisplay;
         float aspect = mInfo.mPixelAspectRatio;
         {
-          MonitorAutoExit exitMon(mDecoder->GetMonitor());
+          ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
           // If we have video, we want to increment the clock in steps of the frame
           // duration.
           RenderVideoFrame(currentFrame, presTime, display, aspect);
         }
       }
       mDecoder->GetFrameStatistics().NotifyPresentedFrame();
       PRInt64 now = DurationToUsecs(TimeStamp::Now() - mPlayStartTime) + mPlayDuration;
       remainingTime = currentFrame->mEndTime - mStartTime - now;
       currentFrame = nsnull;
     }
 
     // Kick the decode thread in case it filled its buffers and put itself
     // to sleep.
-    mDecoder->GetMonitor().NotifyAll();
+    mDecoder->GetReentrantMonitor().NotifyAll();
 
     // Cap the current time to the larger of the audio and video end time.
     // This ensures that if we're running off the system clock, we don't
     // advance the clock to after the media end time.
     if (mVideoFrameEndTime != -1 || mAudioEndTime != -1) {
       // These will be non -1 if we've displayed a video frame, or played an audio sample.
       clock_time = NS_MIN(clock_time, NS_MAX(mVideoFrameEndTime, mAudioEndTime));
       if (clock_time > GetMediaTime()) {
@@ -1519,51 +1519,51 @@ void nsBuiltinDecoderStateMachine::Advan
     UpdateReadyState();
 
     if (remainingTime > 0) {
       Wait(remainingTime);
     }
   } else {
     if (IsPlaying()) {
       StopPlayback(AUDIO_PAUSE);
-      mDecoder->GetMonitor().NotifyAll();
+      mDecoder->GetReentrantMonitor().NotifyAll();
     }
 
     if (mState == DECODER_STATE_DECODING ||
         mState == DECODER_STATE_COMPLETED) {
-      mDecoder->GetMonitor().Wait();
+      mDecoder->GetReentrantMonitor().Wait();
     }
   }
 }
 
 void nsBuiltinDecoderStateMachine::Wait(PRInt64 aUsecs) {
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   TimeStamp end = TimeStamp::Now() + UsecsToDuration(aUsecs);
   TimeStamp now;
   while ((now = TimeStamp::Now()) < end &&
          mState != DECODER_STATE_SHUTDOWN &&
          mState != DECODER_STATE_SEEKING)
   {
     PRInt64 ms = static_cast<PRInt64>(NS_round((end - now).ToSeconds() * 1000));
     if (ms == 0 || ms > PR_UINT32_MAX) {
       break;
     }
-    mDecoder->GetMonitor().Wait(PR_MillisecondsToInterval(static_cast<PRUint32>(ms)));
+    mDecoder->GetReentrantMonitor().Wait(PR_MillisecondsToInterval(static_cast<PRUint32>(ms)));
   }
 }
 
 VideoData* nsBuiltinDecoderStateMachine::FindStartTime()
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread), "Should be on state machine thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
   PRInt64 startTime = 0;
   mStartTime = 0;
   VideoData* v = nsnull;
   {
-    MonitorAutoExit exitMon(mDecoder->GetMonitor());
+    ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
     v = mReader->FindStartTime(0, startTime);
   }
   if (startTime != 0) {
     mStartTime = startTime;
     if (mGotDurationFromMetaData) {
       NS_ASSERTION(mEndTime != -1,
                    "We should have mEndTime as supplied duration here");
       // We were specified a duration from a Content-Duration HTTP header.
@@ -1578,39 +1578,39 @@ VideoData* nsBuiltinDecoderStateMachine:
   mAudioStartTime = mStartTime;
   LOG(PR_LOG_DEBUG, ("%p Media start time is %lld", mDecoder, mStartTime));
   return v;
 }
 
 void nsBuiltinDecoderStateMachine::FindEndTime() 
 {
   NS_ASSERTION(OnStateMachineThread(), "Should be on state machine thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   nsMediaStream* stream = mDecoder->GetCurrentStream();
 
   // Seek to the end of file to find the length and duration.
   PRInt64 length = stream->GetLength();
   NS_ASSERTION(length > 0, "Must have a content length to get end time");
 
   mEndTime = 0;
   PRInt64 endTime = 0;
   {
-    MonitorAutoExit exitMon(mDecoder->GetMonitor());
+    ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
     endTime = mReader->FindEndTime(length);
   }
   if (endTime != -1) {
     mEndTime = endTime;
   }
 
   LOG(PR_LOG_DEBUG, ("%p Media end time is %lld", mDecoder, mEndTime));   
 }
 
 void nsBuiltinDecoderStateMachine::UpdateReadyState() {
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   nsCOMPtr<nsIRunnable> event;
   switch (GetNextFrameStatus()) {
     case nsHTMLMediaElement::NEXT_FRAME_UNAVAILABLE_BUFFERING:
       event = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::NextFrameUnavailableBuffering);
       break;
     case nsHTMLMediaElement::NEXT_FRAME_AVAILABLE:
       event = NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::NextFrameAvailable);
@@ -1624,23 +1624,23 @@ void nsBuiltinDecoderStateMachine::Updat
 
   NS_DispatchToMainThread(event, NS_DISPATCH_NORMAL);
 }
 
 void nsBuiltinDecoderStateMachine::LoadMetadata()
 {
   NS_ASSERTION(IsCurrentThread(mDecoder->mStateMachineThread),
                "Should be on state machine thread.");
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   LOG(PR_LOG_DEBUG, ("Loading Media Headers"));
   nsresult res;
   nsVideoInfo info;