merge m-c to devtools
authorRob Campbell <rcampbell@mozilla.com>
Mon, 02 May 2011 16:15:53 -0300
changeset 69432 5afb32b8ce584aea9a472cd5523f683d73bc6b58
parent 69431 bc1cd5fc588510323c630f5e1d68a0896fb37114 (current diff)
parent 69100 bf1db7f2968633df8cebd1b0a81e5f5ed65a3ca2 (diff)
child 69433 7a6e57bf1b85b013bec64deee512796ffa0d2727
push id76
push userbzbarsky@mozilla.com
push dateTue, 05 Jul 2011 17:00:57 +0000
treeherdermozilla-beta@d3a2732c35f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone6.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
merge m-c to devtools
browser/app/profile/firefox.js
browser/base/content/browser-menubar.inc
browser/base/content/browser.js
browser/locales/en-US/chrome/browser/browser.dtd
browser/locales/en-US/chrome/browser/sidebar/sidebar.properties
browser/locales/jar.mn
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
layout/base/nsIImageMap.h
layout/generic/nsIImageFrame.h
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
toolkit/components/places/nsIMicrosummaryService.idl
toolkit/components/places/nsMicrosummaryService.js
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
--- a/accessible/src/atk/nsMaiInterfaceComponent.cpp
+++ b/accessible/src/atk/nsMaiInterfaceComponent.cpp
@@ -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");
--- 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"
@@ -1261,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/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
@@ -341,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
@@ -1578,32 +1578,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() {
--- 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/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/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/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
@@ -64,17 +64,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/configure.in
+++ b/configure.in
@@ -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))
@@ -9023,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/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/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/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"
@@ -5518,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);
--- 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"
@@ -1591,19 +1589,21 @@ 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);
 
@@ -5070,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;
 
@@ -8324,17 +8322,17 @@ 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,
--- 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"
@@ -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 {
--- 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")
--- 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/
  *
@@ -239,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/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/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);
 }
--- 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;
   {
-    MonitorAutoExit exitMon(mDecoder->GetMonitor());
+    ReentrantMonitorAutoExit exitMon(mDecoder->GetReentrantMonitor());
     res = mReader->ReadMetadata(&info);
   }
   mInfo = info;
 
   if (NS_FAILED(res) || (!info.mHasVideo && !info.mHasAudio)) {
     mState = DECODER_STATE_SHUTDOWN;      
     nsCOMPtr<nsIRunnable> event =
       NS_NewRunnableMethod(mDecoder, &nsBuiltinDecoder::DecodeError);
@@ -1655,17 +1655,17 @@ PRBool nsBuiltinDecoderStateMachine::Jus
 {
   return !mDecodeStartTime.IsNull() &&
     mQuickBuffering &&
     (TimeStamp::Now() - mDecodeStartTime) < TimeDuration::FromSeconds(QUICK_BUFFER_THRESHOLD_USECS);
 }
 
 void nsBuiltinDecoderStateMachine::StartBuffering()
 {
-  mDecoder->GetMonitor().AssertCurrentThreadIn();
+  mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
   TimeDuration decodeDuration = TimeStamp::Now() - mDecodeStartTime;
   // Go into quick buffering mode provided we've not just left buffering using
   // a "quick exit". This stops us flip-flopping between playing and buffering
   // when the download speed is similar to the decode speed.
   mQuickBuffering =
     !JustExitedQuickBuffering() &&
     decodeDuration < UsecsToDuration(QUICK_BUFFER_THRESHOLD_USECS);
--- a/content/media/nsBuiltinDecoderStateMachine.h
+++ b/content/media/nsBuiltinDecoderStateMachine.h
@@ -113,17 +113,17 @@ not yet time to display the next frame.
 #define nsBuiltinDecoderStateMachine_h__
 
 #include "prmem.h"
 #include "nsThreadUtils.h"
 #include "nsBuiltinDecoder.h"
 #include "nsBuiltinDecoderReader.h"
 #include "nsAudioAvailableEventManager.h"
 #include "nsHTMLMediaElement.h"
-#include "mozilla/Monitor.h"
+#include "mozilla/ReentrantMonitor.h"
 
 /*
   The playback state machine class. This manages the decoding in the
   nsBuiltinDecoderReader on the decode thread, seeking and in-sync-playback on the
   state machine thread, and controls the audio "push" thread.
 
   All internal state is synchronised via the decoder monitor. NotifyAll
   on the monitor is called when the state of the state machine is changed
@@ -135,28 +135,28 @@ not yet time to display the next frame.
     Frame decoded
     data pushed or popped from the video and audio queues
 
   See nsBuiltinDecoder.h for more details.
 */
 class nsBuiltinDecoderStateMachine : public nsDecoderStateMachine
 {
 public:
-  typedef mozilla::Monitor Monitor;
+  typedef mozilla::ReentrantMonitor ReentrantMonitor;
   typedef mozilla::TimeStamp TimeStamp;
   typedef mozilla::TimeDuration TimeDuration;
 
   nsBuiltinDecoderStateMachine(nsBuiltinDecoder* aDecoder, nsBuiltinDecoderReader* aReader);
   ~nsBuiltinDecoderStateMachine();
 
   // nsDecoderStateMachine interface
   virtual nsresult Init(nsDecoderStateMachine* aCloneDonor);
   State GetState()
   { 
-    mDecoder->GetMonitor().AssertCurrentThreadIn();
+    mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
     return mState; 
   }
   virtual void SetVolume(double aVolume);
   virtual void Shutdown();
   virtual PRInt64 GetDuration();
   virtual void SetDuration(PRInt64 aDuration);
   virtual PRBool OnDecodeThread() const {
     return IsCurrentThread(mDecodeThread);
@@ -178,40 +178,40 @@ public:
 
   // State machine thread run function. Polls the state, sends frames to be
   // displayed at appropriate times, and generally manages the decode.
   NS_IMETHOD Run();
 
   // This is called on the state machine thread and audio thread.
   // The decoder monitor must be obtained before calling this.
   PRBool HasAudio() const {
-    mDecoder->GetMonitor().AssertCurrentThreadIn();
+    mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
     return mInfo.mHasAudio;
   }
 
   // This is called on the state machine thread and audio thread.
   // The decoder monitor must be obtained before calling this.
   PRBool HasVideo() const {
-    mDecoder->GetMonitor().AssertCurrentThreadIn();
+    mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
     return mInfo.mHasVideo;
   }
 
   // Should be called by main thread.
   PRBool HaveNextFrameData() const;
 
   // Must be called with the decode monitor held.
   PRBool IsBuffering() const {
-    mDecoder->GetMonitor().AssertCurrentThreadIn();
+    mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
     return mState == nsBuiltinDecoderStateMachine::DECODER_STATE_BUFFERING;
   }
 
   // Must be called with the decode monitor held.
   PRBool IsSeeking() const {
-    mDecoder->GetMonitor().AssertCurrentThreadIn();
+    mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
 
     return mState == nsBuiltinDecoderStateMachine::DECODER_STATE_SEEKING;
   }
 
   // Functions used by assertions to ensure we're calling things
   // on the appropriate threads.
   PRBool OnAudioThread() {
     return IsCurrentThread(mAudioThread);
@@ -238,17 +238,17 @@ public:
   nsresult GetBuffered(nsTimeRanges* aBuffered);
 
   void NotifyDataArrived(const char* aBuffer, PRUint32 aLength, PRUint32 aOffset) {
     NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
     mReader->NotifyDataArrived(aBuffer, aLength, aOffset);
   }
 
   PRInt64 GetEndMediaTime() const {
-    mDecoder->GetMonitor().AssertCurrentThreadIn();
+    mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
     return mEndTime;
   }
 
   // Sets the current frame buffer length for the MozAudioAvailable event.
   // Accessed on the main and state machine threads.
   virtual void SetFrameBufferLength(PRUint32 aLength);
 
 protected:
@@ -273,17 +273,17 @@ protected:
 
   // Returns PR_TRUE when there's decoded audio waiting to play.
   // The decoder monitor must be held.
   PRBool HasFutureAudio() const;
 
   // Returns PR_TRUE if we recently exited "quick buffering" mode.
   PRBool JustExitedQuickBuffering();
 
-  // Waits on the decoder Monitor for aUsecs microseconds. If the decoder
+  // Waits on the decoder ReentrantMonitor for aUsecs microseconds. If the decoder
   // monitor is awoken by a Notify() call, we'll continue waiting, unless
   // we've moved into shutdown state. This enables us to ensure that we
   // wait for a specified time, and that the myriad of Notify()s we do an
   // the decoder monitor don't cause the audio thread to be starved. The
   // decoder monitor must be locked.
   void Wait(PRInt64 aUsecs);
 
   // Dispatches an asynchronous event to update the media element's ready state.
@@ -384,34 +384,34 @@ protected:
   PRBool IsPlaying();
 
   // Returns the "media time". This is the absolute time which the media
   // playback has reached. i.e. this returns values in the range
   // [mStartTime, mEndTime], and mStartTime will not be 0 if the media does
   // not start at 0. Note this is different to the value returned
   // by GetCurrentTime(), which is in the range [0,duration].
   PRInt64 GetMediaTime() const {
-    mDecoder->GetMonitor().AssertCurrentThreadIn();
+    mDecoder->GetReentrantMonitor().AssertCurrentThreadIn();
     return mStartTime + mCurrentFrameTime;
   }
 
   // Returns an upper bound on the number of microseconds of audio that is
   // decoded and playable. This is the sum of the number of usecs of audio which
   // is decoded and in the reader's audio queue, and the usecs of unplayed audio
   // which has been pushed to the audio hardware for playback. Note that after
   // calling this, the audio hardware may play some of the audio pushed to
   // hardware, so this can only be used as a upper bound. The decoder monitor
   // must be held when calling this. Called on the decoder thread.
   PRInt64 GetDecodedAudioDuration();
 
-  // Monitor on mAudioStream. This monitor must be held in order to delete
-  // or use the audio stream. This stops us destroying the audio stream
-  // while it's being used on another thread (typically when it's being
-  // written to on the audio thread).
-  Monitor mAudioMonitor;
+  // ReentrantMonitor on mAudioStream. This monitor must be held in
+  // order to delete or use the audio stream. This stops us destroying
+  // the audio stream while it's being used on another thread
+  // (typically when it's being written to on the audio thread).
+  ReentrantMonitor mAudioReentrantMonitor;
 
   // The size of the decoded YCbCr frame.
   // Accessed on state machine thread.
   PRUint32 mCbCrSize;
 
   // Accessed on state machine thread.
   nsAutoArrayPtr<unsigned char> mCbCrBuffer;
 
@@ -449,19 +449,19 @@ protected:
   // machine and main thread. Access controlled by decoder monitor.
   PRInt64 mEndTime;
 
   // Position to seek to in microseconds when the seek state transition occurs.
   // The decoder monitor lock must be obtained before reading or writing
   // this value. Accessed on main and state machine thread.
   PRInt64 mSeekTime;
 
-  // The audio stream resource. Used on the state machine, audio, and main
-  // threads. You must hold the mAudioMonitor, and must NOT hold the decoder
-  // monitor when using the audio stream!
+  // The audio stream resource. Used on the state machine, audio, and
+  // main threads. You must hold the mAudioReentrantMonitor, and must
+  // NOT hold the decoder monitor when using the audio stream!
   nsRefPtr<nsAudioStream> mAudioStream;
 
   // The reader, don't call its methods with the decoder monitor held.
   // This is created in the play state machine's constructor, and destroyed
   // in the play state machine's destructor.
   nsAutoPtr<nsBuiltinDecoderReader> mReader;
 
   // The time of the current frame in microseconds. This is referenced from
--- a/content/media/nsMediaCache.cpp
+++ b/content/media/nsMediaCache.cpp
@@ -31,17 +31,17 @@
  * 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 "mozilla/Monitor.h"
+#include "mozilla/ReentrantMonitor.h"
 #include "mozilla/XPCOM.h"
 
 #include "nsMediaCache.h"
 #include "nsContentUtils.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsNetUtil.h"
 #include "prio.h"
@@ -129,17 +129,17 @@ class nsMediaCache {
 public:
   friend class nsMediaCacheStream::BlockList;
   typedef nsMediaCacheStream::BlockList BlockList;
   enum {
     BLOCK_SIZE = nsMediaCacheStream::BLOCK_SIZE
   };
 
   nsMediaCache() : mNextResourceID(1),
-    mMonitor("nsMediaCache.mMonitor"),
+    mReentrantMonitor("nsMediaCache.mReentrantMonitor"),
     mFD(nsnull), mFDCurrentPos(0), mUpdateQueued(PR_FALSE)
 #ifdef DEBUG
     , mInUpdate(PR_FALSE)
 #endif
   {
     MOZ_COUNT_CTOR(nsMediaCache);
   }
   ~nsMediaCache() {
@@ -163,39 +163,39 @@ public:
   // shutting it down cleans things up and releases disk space.
   static void MaybeShutdown();
 
   // Brutally flush the cache contents. Main thread only.
   static void Flush();
   void FlushInternal();
 
   // Cache-file access methods. These are the lowest-level cache methods.
-  // mMonitor must be held; these can be called on any thread.
+  // mReentrantMonitor must be held; these can be called on any thread.
   // This can return partial reads.
   nsresult ReadCacheFile(PRInt64 aOffset, void* aData, PRInt32 aLength,
                          PRInt32* aBytes);
   // This will fail if all aLength bytes are not read
   nsresult ReadCacheFileAllBytes(PRInt64 aOffset, void* aData, PRInt32 aLength);
   // This will fail if all aLength bytes are not written
   nsresult WriteCacheFile(PRInt64 aOffset, const void* aData, PRInt32 aLength);
 
-  // mMonitor must be held, called on main thread.
+  // mReentrantMonitor must be held, called on main thread.
   // These methods are used by the stream to set up and tear down streams,
   // and to handle reads and writes.
   // Add aStream to the list of streams.
   void OpenStream(nsMediaCacheStream* aStream);
   // Remove aStream from the list of streams.
   void ReleaseStream(nsMediaCacheStream* aStream);
   // Free all blocks belonging to aStream.
   void ReleaseStreamBlocks(nsMediaCacheStream* aStream);
   // Find a cache entry for this data, and write the data into it
   void AllocateAndWriteBlock(nsMediaCacheStream* aStream, const void* aData,
                              nsMediaCacheStream::ReadMode aMode);
 
-  // mMonitor must be held; can be called on any thread
+  // mReentrantMonitor must be held; can be called on any thread
   // Notify the cache that a seek has been requested. Some blocks may
   // need to change their class between PLAYED_BLOCK and READAHEAD_BLOCK.
   // This does not trigger channel seeks directly, the next Update()
   // will do that if necessary. The caller will call QueueUpdate().
   void NoteSeek(nsMediaCacheStream* aStream, PRInt64 aOldOffset);
   // Notify the cache that a block has been read from. This is used
   // to update last-use times. The block may not actually have a
   // cache entry yet since Read can read data from a stream's
@@ -222,17 +222,17 @@ public:
 
 #ifdef DEBUG_VERIFY_CACHE
   // Verify invariants, especially block list invariants
   void Verify();
 #else
   void Verify() {}
 #endif
 
-  Monitor& GetMonitor() { return mMonitor; }
+  ReentrantMonitor& GetReentrantMonitor() { return mReentrantMonitor; }
 
   /**
    * An iterator that makes it easy to iterate through all streams that
    * have a given resource ID and are not closed.
    */
   class ResourceStreamIterator {
   public:
     ResourceStreamIterator(PRInt64 aResourceID) :
@@ -345,17 +345,17 @@ protected:
   // resource IDs to streams.
   PRInt64                       mNextResourceID;
   // This member is main-thread only. It contains all the streams.
   nsTArray<nsMediaCacheStream*> mStreams;
 
   // The monitor protects all the data members here. Also, off-main-thread
   // readers that need to block will Wait() on this monitor. When new
   // data becomes available in the cache, we NotifyAll() on this monitor.
-  Monitor         mMonitor;
+  ReentrantMonitor         mReentrantMonitor;
   // The Blocks describing the cache entries.
   nsTArray<Block> mIndex;
   // The file descriptor of the cache file. The file will be deleted
   // by the operating system when this is closed.
   PRFileDesc*     mFD;
   // The current file offset in the cache file.
   PRInt64         mFDCurrentPos;
   // The list of free blocks; they are not ordered.
@@ -603,17 +603,17 @@ nsMediaCache::Flush()
     return;
 
   gMediaCache->FlushInternal();
 }
 
 void
 nsMediaCache::FlushInternal()
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   for (PRUint32 blockIndex = 0; blockIndex < mIndex.Length(); ++blockIndex) {
     FreeBlock(blockIndex);
   }
 
   // Truncate file, close it, and reopen
   Truncate();
   NS_ASSERTION(mIndex.Length() == 0, "Blocks leaked?");
@@ -658,17 +658,17 @@ InitMediaCache()
     gMediaCache = nsnull;
   }
 }
 
 nsresult
 nsMediaCache::ReadCacheFile(PRInt64 aOffset, void* aData, PRInt32 aLength,
                             PRInt32* aBytes)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   if (!mFD)
     return NS_ERROR_FAILURE;
 
   if (mFDCurrentPos != aOffset) {
     PROffset64 offset = PR_Seek64(mFD, aOffset, PR_SEEK_SET);
     if (offset != aOffset)
       return NS_ERROR_FAILURE;
@@ -680,17 +680,17 @@ nsMediaCache::ReadCacheFile(PRInt64 aOff
   mFDCurrentPos += amount;
   *aBytes = amount;
   return NS_OK;
 }
 
 nsresult
 nsMediaCache::ReadCacheFileAllBytes(PRInt64 aOffset, void* aData, PRInt32 aLength)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   PRInt64 offset = aOffset;
   PRInt32 count = aLength;
   // Cast to char* so we can do byte-wise pointer arithmetic
   char* data = static_cast<char*>(aData);
   while (count > 0) {
     PRInt32 bytes;
     nsresult rv = ReadCacheFile(offset, data, count, &bytes);
@@ -703,17 +703,17 @@ nsMediaCache::ReadCacheFileAllBytes(PRIn
     offset += bytes;
   }
   return NS_OK;
 }
 
 nsresult
 nsMediaCache::WriteCacheFile(PRInt64 aOffset, const void* aData, PRInt32 aLength)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   if (!mFD)
     return NS_ERROR_FAILURE;
 
   if (mFDCurrentPos != aOffset) {
     PROffset64 offset = PR_Seek64(mFD, aOffset, PR_SEEK_SET);
     if (offset != aOffset)
       return NS_ERROR_FAILURE;
@@ -744,17 +744,17 @@ static PRInt32 GetMaxBlocks()
   maxBlocks = PR_MAX(maxBlocks, 1);
   return PRInt32(PR_MIN(maxBlocks, PR_INT32_MAX));
 }
 
 PRInt32
 nsMediaCache::FindBlockForIncomingData(TimeStamp aNow,
                                        nsMediaCacheStream* aStream)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   PRInt32 blockIndex = FindReusableBlock(aNow, aStream,
       aStream->mChannelOffset/BLOCK_SIZE, PR_INT32_MAX);
 
   if (blockIndex < 0 || !IsBlockFree(blockIndex)) {
     // The block returned is already allocated.
     // Don't reuse it if a) there's room to expand the cache or
     // b) the data we're going to store in the free block is not higher
@@ -787,17 +787,17 @@ nsMediaCache::BlockIsReusable(PRInt32 aB
   return PR_TRUE;
 }
 
 void
 nsMediaCache::AppendMostReusableBlock(BlockList* aBlockList,
                                       nsTArray<PRUint32>* aResult,
                                       PRInt32 aBlockIndexLimit)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   PRInt32 blockIndex = aBlockList->GetLastBlock();
   if (blockIndex < 0)
     return;
   do {
     // Don't consider blocks for pinned streams, or blocks that are
     // beyond the specified limit, or a block that contains a stream's
     // current read position (such a block contains both played data
@@ -811,17 +811,17 @@ nsMediaCache::AppendMostReusableBlock(Bl
 }
 
 PRInt32
 nsMediaCache::FindReusableBlock(TimeStamp aNow,
                                 nsMediaCacheStream* aForStream,
                                 PRInt32 aForStreamBlock,
                                 PRInt32 aMaxSearchBlockIndex)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   PRUint32 length = PR_MIN(PRUint32(aMaxSearchBlockIndex), mIndex.Length());
 
   if (aForStream && aForStreamBlock > 0 &&
       PRUint32(aForStreamBlock) <= aForStream->mBlocks.Length()) {
     PRInt32 prevCacheBlock = aForStream->mBlocks[aForStreamBlock - 1];
     if (prevCacheBlock >= 0) {
       PRUint32 freeBlockScanEnd =
@@ -905,17 +905,17 @@ nsMediaCache::GetBlockOwner(PRInt32 aBlo
       return &block->mOwners[i];
   }
   return nsnull;
 }
 
 void
 nsMediaCache::SwapBlocks(PRInt32 aBlockIndex1, PRInt32 aBlockIndex2)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   Block* block1 = &mIndex[aBlockIndex1];
   Block* block2 = &mIndex[aBlockIndex2];
 
   block1->mOwners.SwapElements(block2->mOwners);
 
   // Now all references to block1 have to be replaced with block2 and
   // vice versa.
@@ -985,17 +985,17 @@ nsMediaCache::AddBlockOwnerAsReadahead(P
   aStream->mBlocks[aStreamBlockIndex] = aBlockIndex;
   bo->mClass = READAHEAD_BLOCK;
   InsertReadaheadBlock(bo, aBlockIndex);
 }
 
 void
 nsMediaCache::FreeBlock(PRInt32 aBlock)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   Block* block = &mIndex[aBlock];
   if (block->mOwners.IsEmpty()) {
     // already free
     return;
   }
 
   LOG(PR_LOG_DEBUG, ("Released block %d", aBlock));
@@ -1008,17 +1008,17 @@ nsMediaCache::FreeBlock(PRInt32 aBlock)
   block->mOwners.Clear();
   mFreeBlocks.AddFirstBlock(aBlock);
   Verify();
 }
 
 TimeDuration
 nsMediaCache::PredictNextUse(TimeStamp aNow, PRInt32 aBlock)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
   NS_ASSERTION(!IsBlockFree(aBlock), "aBlock is free");
 
   Block* block = &mIndex[aBlock];
   // Blocks can be belong to multiple streams. The predicted next use
   // time is the earliest time predicted by any of the streams.
   TimeDuration result;
   for (PRUint32 i = 0; i < block->mOwners.Length(); ++i) {
     BlockOwner* bo = &block->mOwners[i];
@@ -1058,17 +1058,17 @@ nsMediaCache::PredictNextUse(TimeStamp a
     }
   }
   return result;
 }
 
 TimeDuration
 nsMediaCache::PredictNextUseForIncomingData(nsMediaCacheStream* aStream)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   PRInt64 bytesAhead = aStream->mChannelOffset - aStream->mStreamOffset;
   if (bytesAhead <= -BLOCK_SIZE) {
     // Hmm, no idea when data behind us will be used. Guess 24 hours.
     return TimeDuration::FromSeconds(24*60*60);
   }
   if (bytesAhead <= 0)
     return TimeDuration(0);
@@ -1086,17 +1086,17 @@ nsMediaCache::Update()
 
   // The action to use for each stream. We store these so we can make
   // decisions while holding the cache lock but implement those decisions
   // without holding the cache lock, since we need to call out to
   // stream, decoder and element code.
   nsAutoTArray<StreamAction,10> actions;
 
   {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     mUpdateQueued = PR_FALSE;
 #ifdef DEBUG
     mInUpdate = PR_TRUE;
 #endif
 
     PRInt32 maxBlocks = GetMaxBlocks();
     TimeStamp now = TimeStamp::Now();
 
@@ -1368,17 +1368,17 @@ nsMediaCache::Update()
     default:
       break;
     }
 
     if (NS_FAILED(rv)) {
       // Close the streams that failed due to error. This will cause all
       // client Read and Seek operations on those streams to fail. Blocked
       // Reads will also be woken up.
-      MonitorAutoEnter mon(mMonitor);
+      ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       stream->CloseInternal(mon);
     }
   }
 }
 
 class UpdateEvent : public nsRunnable
 {
 public:
@@ -1389,34 +1389,34 @@ public:
     }
     return NS_OK;
   }
 };
 
 void
 nsMediaCache::QueueUpdate()
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   // Queuing an update while we're in an update raises a high risk of
   // triggering endless events
   NS_ASSERTION(!mInUpdate,
                "Queuing an update while we're in an update");
   if (mUpdateQueued)
     return;
   mUpdateQueued = PR_TRUE;
   nsCOMPtr<nsIRunnable> event = new UpdateEvent();
   NS_DispatchToMainThread(event);
 }
 
 #ifdef DEBUG_VERIFY_CACHE
 void
 nsMediaCache::Verify()
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   mFreeBlocks.Verify();
   for (PRUint32 i = 0; i < mStreams.Length(); ++i) {
     nsMediaCacheStream* stream = mStreams[i];
     stream->mReadaheadBlocks.Verify();
     stream->mPlayedBlocks.Verify();
     stream->mMetadataBlocks.Verify();
 
@@ -1438,17 +1438,17 @@ nsMediaCache::Verify()
   }
 }
 #endif
 
 void
 nsMediaCache::InsertReadaheadBlock(BlockOwner* aBlockOwner,
                                    PRInt32 aBlockIndex)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   // Find the last block whose stream block is before aBlockIndex's
   // stream block, and insert after it
   nsMediaCacheStream* stream = aBlockOwner->mStream;
   PRInt32 readaheadIndex = stream->mReadaheadBlocks.GetLastBlock();
   while (readaheadIndex >= 0) {
     BlockOwner* bo = GetBlockOwner(readaheadIndex, stream);
     NS_ASSERTION(bo, "stream must own its blocks");
@@ -1464,17 +1464,17 @@ nsMediaCache::InsertReadaheadBlock(Block
   stream->mReadaheadBlocks.AddFirstBlock(aBlockIndex);
   Verify();
 }
 
 void
 nsMediaCache::AllocateAndWriteBlock(nsMediaCacheStream* aStream, const void* aData,
                                     nsMediaCacheStream::ReadMode aMode)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   PRInt32 streamBlockIndex = aStream->mChannelOffset/BLOCK_SIZE;
 
   // Remove all cached copies of this block
   ResourceStreamIterator iter(aStream->mResourceID);
   while (nsMediaCacheStream* stream = iter.Next()) {
     while (streamBlockIndex >= PRInt32(stream->mBlocks.Length())) {
       stream->mBlocks.AppendElement(-1);
@@ -1542,39 +1542,39 @@ nsMediaCache::AllocateAndWriteBlock(nsMe
   QueueUpdate();
 }
 
 void
 nsMediaCache::OpenStream(nsMediaCacheStream* aStream)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   LOG(PR_LOG_DEBUG, ("Stream %p opened", aStream));
   mStreams.AppendElement(aStream);
   aStream->mResourceID = mNextResourceID++;
 
   // Queue an update since a new stream has been opened.
   gMediaCache->QueueUpdate();
 }
 
 void
 nsMediaCache::ReleaseStream(nsMediaCacheStream* aStream)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   LOG(PR_LOG_DEBUG, ("Stream %p closed", aStream));
   mStreams.RemoveElement(aStream);
 }
 
 void
 nsMediaCache::ReleaseStreamBlocks(nsMediaCacheStream* aStream)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   // XXX scanning the entire stream doesn't seem great, if not much of it
   // is cached, but the only easy alternative is to scan the entire cache
   // which isn't better
   PRUint32 length = aStream->mBlocks.Length();
   for (PRUint32 i = 0; i < length; ++i) {
     PRInt32 blockIndex = aStream->mBlocks[i];
     if (blockIndex >= 0) {
@@ -1604,17 +1604,17 @@ nsMediaCache::Truncate()
   }
 }
 
 void
 nsMediaCache::NoteBlockUsage(nsMediaCacheStream* aStream, PRInt32 aBlockIndex,
                              nsMediaCacheStream::ReadMode aMode,
                              TimeStamp aNow)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   if (aBlockIndex < 0) {
     // this block is not in the cache yet
     return;
   }
 
   BlockOwner* bo = GetBlockOwner(aBlockIndex, aStream);
   if (!bo) {
@@ -1636,17 +1636,17 @@ nsMediaCache::NoteBlockUsage(nsMediaCach
   GetListForBlock(bo)->AddFirstBlock(aBlockIndex);
   bo->mLastUseTime = aNow;
   Verify();
 }
 
 void
 nsMediaCache::NoteSeek(nsMediaCacheStream* aStream, PRInt64 aOldOffset)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   if (aOldOffset < aStream->mStreamOffset) {
     // We seeked forward. Convert blocks from readahead to played.
     // Any readahead block that intersects the seeked-over range must
     // be converted.
     PRInt32 blockIndex = aOldOffset/BLOCK_SIZE;
     PRInt32 endIndex =
       PR_MIN((aStream->mStreamOffset + BLOCK_SIZE - 1)/BLOCK_SIZE,
@@ -1692,26 +1692,26 @@ nsMediaCache::NoteSeek(nsMediaCacheStrea
   }
 }
 
 void
 nsMediaCacheStream::NotifyDataLength(PRInt64 aLength)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   mStreamLength = aLength;
 }
 
 void
 nsMediaCacheStream::NotifyDataStarted(PRInt64 aOffset)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   NS_WARN_IF_FALSE(aOffset == mChannelOffset,
                    "Server is giving us unexpected offset");
   mChannelOffset = aOffset;
   if (mStreamLength >= 0) {
     // If we started reading at a certain offset, then for sure
     // the stream is at least that long.
     mStreamLength = PR_MAX(mStreamLength, mChannelOffset);
   }
@@ -1752,17 +1752,17 @@ nsMediaCacheStream::UpdatePrincipal(nsIP
 }
 
 void
 nsMediaCacheStream::NotifyDataReceived(PRInt64 aSize, const char* aData,
     nsIPrincipal* aPrincipal)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   PRInt64 size = aSize;
   const char* data = aData;
 
   LOG(PR_LOG_DEBUG, ("Stream %p DataReceived at %lld count=%lld",
       this, (long long)mChannelOffset, (long long)aSize));
 
   // We process the data one block (or part of a block) at a time
   while (size > 0) {
@@ -1821,17 +1821,17 @@ nsMediaCacheStream::NotifyDataReceived(P
   mon.NotifyAll();
 }
 
 void
 nsMediaCacheStream::NotifyDataEnded(nsresult aStatus)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
 
   PRInt32 blockOffset = PRInt32(mChannelOffset%BLOCK_SIZE);
   if (blockOffset > 0) {
     // Write back the partial block
     memset(reinterpret_cast<char*>(mPartialBlockBuffer) + blockOffset, 0,
            BLOCK_SIZE - blockOffset);
     gMediaCache->AllocateAndWriteBlock(this, mPartialBlockBuffer,
         mMetadataInPartialBlockBuffer ? MODE_METADATA : MODE_PLAYBACK);
@@ -1859,113 +1859,113 @@ nsMediaCacheStream::~nsMediaCacheStream(
     gMediaCache->ReleaseStream(this);
     nsMediaCache::MaybeShutdown();
   }
 }
 
 void
 nsMediaCacheStream::SetSeekable(PRBool aIsSeekable)
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   NS_ASSERTION(mIsSeekable || aIsSeekable ||
                mChannelOffset == 0, "channel offset must be zero when we become non-seekable");
   mIsSeekable = aIsSeekable;
   // Queue an Update since we may change our strategy for dealing
   // with this stream
   gMediaCache->QueueUpdate();
 }
 
 PRBool
 nsMediaCacheStream::IsSeekable()
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   return mIsSeekable;
 }
 
 void
 nsMediaCacheStream::Close()
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   CloseInternal(mon);
   // Queue an Update since we may have created more free space. Don't do
   // it from CloseInternal since that gets called by Update() itself
   // sometimes, and we try to not to queue updates from Update().
   gMediaCache->QueueUpdate();
 }
 
 void
-nsMediaCacheStream::CloseInternal(MonitorAutoEnter& aMonitor)
+nsMediaCacheStream::CloseInternal(ReentrantMonitorAutoEnter& aReentrantMonitor)
 {
   NS_ASSERTION(NS_IsMainThread(), "Only call on main thread");
 
   if (mClosed)
     return;
   mClosed = PR_TRUE;
   gMediaCache->ReleaseStreamBlocks(this);
   // Wake up any blocked readers
-  aMonitor.NotifyAll();
+  aReentrantMonitor.NotifyAll();
 }
 
 void
 nsMediaCacheStream::Pin()
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   ++mPinCount;
   // Queue an Update since we may no longer want to read more into the
   // cache, if this stream's block have become non-evictable
   gMediaCache->QueueUpdate();
 }
 
 void
 nsMediaCacheStream::Unpin()
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   NS_ASSERTION(mPinCount > 0, "Unbalanced Unpin");
   --mPinCount;
   // Queue an Update since we may be able to read more into the
   // cache, if this stream's block have become evictable
   gMediaCache->QueueUpdate();
 }
 
 PRInt64
 nsMediaCacheStream::GetLength()
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   return mStreamLength;
 }
 
 PRInt64
 nsMediaCacheStream::GetNextCachedData(PRInt64 aOffset)
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   return GetNextCachedDataInternal(aOffset);
 }
 
 PRInt64
 nsMediaCacheStream::GetCachedDataEnd(PRInt64 aOffset)
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   return GetCachedDataEndInternal(aOffset);
 }
 
 PRBool
 nsMediaCacheStream::IsDataCachedToEndOfStream(PRInt64 aOffset)
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   if (mStreamLength < 0)
     return PR_FALSE;
   return GetCachedDataEndInternal(aOffset) >= mStreamLength;
 }
 
 PRInt64
 nsMediaCacheStream::GetCachedDataEndInternal(PRInt64 aOffset)
 {
-  gMediaCache->GetMonitor().AssertCurrentThreadIn();
+  gMediaCache->GetReentrantMonitor().AssertCurrentThreadIn();
   PRUint32 startBlockIndex = aOffset/BLOCK_SIZE;
   PRUint32 blockIndex = startBlockIndex;
   while (blockIndex < mBlocks.Length() && mBlocks[blockIndex] != -1) {
     ++blockIndex;
   }
   PRInt64 result = blockIndex*BLOCK_SIZE;
   if (blockIndex == mChannelOffset/BLOCK_SIZE) {
     // The block containing mChannelOffset may be partially read but not
@@ -1978,17 +1978,17 @@ nsMediaCacheStream::GetCachedDataEndInte
     result = PR_MIN(result, mStreamLength);
   }
   return PR_MAX(result, aOffset);
 }
 
 PRInt64
 nsMediaCacheStream::GetNextCachedDataInternal(PRInt64 aOffset)
 {
-  gMediaCache->GetMonitor().AssertCurrentThreadIn();
+  gMediaCache->GetReentrantMonitor().AssertCurrentThreadIn();
   if (aOffset == mStreamLength)
     return -1;
 
   PRUint32 startBlockIndex = aOffset/BLOCK_SIZE;
   PRUint32 channelBlockIndex = mChannelOffset/BLOCK_SIZE;
 
   if (startBlockIndex == channelBlockIndex &&
       aOffset < mChannelOffset) {
@@ -2025,40 +2025,40 @@ nsMediaCacheStream::GetNextCachedDataInt
 
   NS_NOTREACHED("Should return in loop");
   return -1;
 }
 
 void
 nsMediaCacheStream::SetReadMode(ReadMode aMode)
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   if (aMode == mCurrentMode)
     return;
   mCurrentMode = aMode;
   gMediaCache->QueueUpdate();
 }
 
 void
 nsMediaCacheStream::SetPlaybackRate(PRUint32 aBytesPerSecond)
 {
   NS_ASSERTION(aBytesPerSecond > 0, "Zero playback rate not allowed");
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   if (aBytesPerSecond == mPlaybackBytesPerSecond)
     return;
   mPlaybackBytesPerSecond = aBytesPerSecond;
   gMediaCache->QueueUpdate();
 }
 
 nsresult
 nsMediaCacheStream::Seek(PRInt32 aWhence, PRInt64 aOffset)
 {
   NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
 
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   if (mClosed)
     return NS_ERROR_FAILURE;
 
   PRInt64 oldOffset = mStreamOffset;
   switch (aWhence) {
   case PR_SEEK_END:
     if (mStreamLength < 0)
       return NS_ERROR_FAILURE;
@@ -2082,26 +2082,26 @@ nsMediaCacheStream::Seek(PRInt32 aWhence
   return NS_OK;
 }
 
 PRInt64
 nsMediaCacheStream::Tell()
 {
   NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
 
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   return mStreamOffset;
 }
 
 nsresult
 nsMediaCacheStream::Read(char* aBuffer, PRUint32 aCount, PRUint32* aBytes)
 {
   NS_ASSERTION(!NS_IsMainThread(), "Don't call on main thread");
 
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   if (mClosed)
     return NS_ERROR_FAILURE;
 
   PRUint32 count = 0;
   // Read one block (or part of a block) at a time
   while (count < aCount) {
     PRUint32 streamBlock = PRUint32(mStreamOffset/BLOCK_SIZE);
     PRUint32 offsetInStreamBlock =
@@ -2176,17 +2176,17 @@ nsMediaCacheStream::Read(char* aBuffer, 
   return NS_OK;
 }
 
 nsresult
 nsMediaCacheStream::ReadFromCache(char* aBuffer,
                                   PRInt64 aOffset,
                                   PRInt64 aCount)
 {
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
   if (mClosed)
     return NS_ERROR_FAILURE;
 
   // Read one block (or part of a block) at a time
   PRUint32 count = 0;
   PRInt64 streamOffset = aOffset;
   while (count < aCount) {
     PRUint32 streamBlock = PRUint32(streamOffset/BLOCK_SIZE);
@@ -2254,17 +2254,17 @@ nsMediaCacheStream::InitAsClone(nsMediaC
     return NS_OK;
 
   nsresult rv = Init();
   if (NS_FAILED(rv))
     return rv;
   mResourceID = aOriginal->mResourceID;
 
   // Grab cache blocks from aOriginal as readahead blocks for our stream
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
 
   mPrincipal = aOriginal->mPrincipal;
   mStreamLength = aOriginal->mStreamLength;
   mIsSeekable = aOriginal->mIsSeekable;
 
   // Cloned streams are initially suspended, since there is no channel open
   // initially for a clone.
   mCacheSuspended = PR_TRUE;
@@ -2284,17 +2284,17 @@ nsMediaCacheStream::InitAsClone(nsMediaC
 
   return NS_OK;
 }
 
 nsresult nsMediaCacheStream::GetCachedRanges(nsTArray<nsByteRange>& aRanges)
 {
   // Take the monitor, so that the cached data ranges can't grow while we're
   // trying to loop over them.
-  MonitorAutoEnter mon(gMediaCache->GetMonitor());
+  ReentrantMonitorAutoEnter mon(gMediaCache->GetReentrantMonitor());
 
   // We must be pinned while running this, otherwise the cached data ranges may
   // shrink while we're trying to loop over them.
   NS_ASSERTION(mPinCount > 0, "Must be pinned");
 
   PRInt64 startOffset = GetNextCachedData(0);
   while (startOffset >= 0) {
     PRInt64 endOffset = GetCachedDataEnd(startOffset);
--- a/content/media/nsMediaCache.h
+++ b/content/media/nsMediaCache.h
@@ -40,17 +40,17 @@
 #define nsMediaCache_h_
 
 #include "nsTArray.h"
 #include "nsIPrincipal.h"
 #include "nsCOMPtr.h"
 
 class nsByteRange;
 namespace mozilla {
-class MonitorAutoEnter;
+class ReentrantMonitorAutoEnter;
 }
 
 /**
  * Media applications want fast, "on demand" random access to media data,
  * for pausing, seeking, etc. But we are primarily interested
  * in transporting media data using HTTP over the Internet, which has
  * high latency to open a connection, requires a new connection for every
  * seek, may not even support seeking on some connections (especially
@@ -206,17 +206,17 @@ class nsMediaChannelStream;
 
 /**
  * If the cache fails to initialize then Init will fail, so nonstatic
  * methods of this class can assume gMediaCache is non-null.
  * 
  * This class can be directly embedded as a value.
  */
 class nsMediaCacheStream {
-  typedef mozilla::MonitorAutoEnter MonitorAutoEnter;
+  typedef mozilla::ReentrantMonitorAutoEnter ReentrantMonitorAutoEnter;
 
 public:
   enum {
     // This needs to be a power of two
     BLOCK_SIZE = 32768
   };
   enum ReadMode {
     MODE_METADATA,
@@ -425,20 +425,20 @@ private:
   PRInt64 GetCachedDataEndInternal(PRInt64 aOffset);
   // Returns the offset of the first byte of cached data at or after aOffset,
   // or -1 if there is no such cached data.
   // This method assumes that the cache monitor is held and can be called on
   // any thread.
   PRInt64 GetNextCachedDataInternal(PRInt64 aOffset);
   // A helper function to do the work of closing the stream. Assumes
   // that the cache monitor is held. Main thread only.
-  // aMonitor is the nsAutoMonitor wrapper holding the cache monitor.
+  // aReentrantMonitor is the nsAutoReentrantMonitor wrapper holding the cache monitor.
   // This is used to NotifyAll to wake up threads that might be
   // blocked on reading from this stream.
-  void CloseInternal(MonitorAutoEnter& aMonitor);
+  void CloseInternal(ReentrantMonitorAutoEnter& aReentrantMonitor);
   // Update mPrincipal given that data has been received from aPrincipal
   void UpdatePrincipal(nsIPrincipal* aPrincipal);
 
   // These fields are main-thread-only.
   nsMediaChannelStream*  mClient;
   nsCOMPtr<nsIPrincipal> mPrincipal;
   // This is a unique ID representing the resource we're loading.
   // All streams with the same mResourceID are loading the same
--- a/content/media/nsMediaDecoder.h
+++ b/content/media/nsMediaDecoder.h
@@ -42,17 +42,17 @@
 
 #include "nsIPrincipal.h"
 #include "nsSize.h"
 #include "prlog.h"
 #include "gfxContext.h"
 #include "gfxRect.h"
 #include "nsITimer.h"
 #include "ImageLayers.h"
-#include "mozilla/Monitor.h"
+#include "mozilla/ReentrantMonitor.h"
 #include "mozilla/Mutex.h"
 
 class nsHTMLMediaElement;
 class nsMediaStream;
 class nsIStreamListener;
 class nsTimeRanges;
 
 // The size to use for audio data frames in MozAudioAvailable events.
@@ -84,17 +84,17 @@ private:
 // which can be called from any thread.
 class nsMediaDecoder : public nsIObserver
 {
 public:
   typedef mozilla::TimeStamp TimeStamp;
   typedef mozilla::TimeDuration TimeDuration;
   typedef mozilla::layers::ImageContainer ImageContainer;
   typedef mozilla::layers::Image Image;
-  typedef mozilla::Monitor Monitor;
+  typedef mozilla::ReentrantMonitor ReentrantMonitor;
   typedef mozilla::Mutex Mutex;
 
   nsMediaDecoder();
   virtual ~nsMediaDecoder();
 
   // Create a new decoder of the same type as this one.
   virtual nsMediaDecoder* Clone() = 0;
 
@@ -185,75 +185,75 @@ public:
   };
 
   // Frame decoding/painting related performance counters.
   // Threadsafe.
   class FrameStatistics {
   public:
     
     FrameStatistics() :
-        mMonitor("nsMediaDecoder::FrameStats"),
+        mReentrantMonitor("nsMediaDecoder::FrameStats"),
         mParsedFrames(0),
         mDecodedFrames(0),
         mPresentedFrames(0) {}
 
     // Returns number of frames which have been parsed from the media.
     // Can be called on any thread.
     PRUint32 GetParsedFrames() {
-      mozilla::MonitorAutoEnter mon(mMonitor);
+      mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       return mParsedFrames;
     }
 
     // Returns the number of parsed frames which have been decoded.
     // Can be called on any thread.
     PRUint32 GetDecodedFrames() {
-      mozilla::MonitorAutoEnter mon(mMonitor);
+      mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       return mDecodedFrames;
     }
 
     // Returns the number of decoded frames which have been sent to the rendering
     // pipeline for painting ("presented").
     // Can be called on any thread.
     PRUint32 GetPresentedFrames() {
-      mozilla::MonitorAutoEnter mon(mMonitor);
+      mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       return mPresentedFrames;
     }
 
     // Increments the parsed and decoded frame counters by the passed in counts.
     // Can be called on any thread.
     void NotifyDecodedFrames(PRUint32 aParsed, PRUint32 aDecoded) {
       if (aParsed == 0 && aDecoded == 0)
         return;
-      mozilla::MonitorAutoEnter mon(mMonitor);
+      mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       mParsedFrames += aParsed;
       mDecodedFrames += aDecoded;
     }
 
     // Increments the presented frame counters.
     // Can be called on any thread.
     void NotifyPresentedFrame() {
-      mozilla::MonitorAutoEnter mon(mMonitor);
+      mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
       ++mPresentedFrames;
     }
 
   private:
 
-    // Monitor to protect access of playback statistics.
-    Monitor mMonitor;
+    // ReentrantMonitor to protect access of playback statistics.
+    ReentrantMonitor mReentrantMonitor;
 
     // Number of frames parsed and demuxed from media.
-    // Access protected by mStatsMonitor.
+    // Access protected by mStatsReentrantMonitor.
     PRUint32 mParsedFrames;
 
     // Number of parsed frames which were actually decoded.
-    // Access protected by mStatsMonitor.
+    // Access protected by mStatsReentrantMonitor.
     PRUint32 mDecodedFrames;
 
     // Number of decoded frames which were actually sent down the rendering
-    // pipeline to be painted ("presented"). Access protected by mStatsMonitor.
+    // pipeline to be painted ("presented"). Access protected by mStatsReentrantMonitor.
     PRUint32 mPresentedFrames;
   };
 
   // Stack based class to assist in notifying the frame statistics of
   // parsed and decoded frames. Use inside video demux & decode functions
   // to ensure all parsed and decoded frames are reported on all return paths.
   class AutoNotifyDecoded {
   public:
--- a/content/media/ogg/nsOggReader.cpp
+++ b/content/media/ogg/nsOggReader.cpp
@@ -139,17 +139,17 @@ nsresult nsOggReader::ResetDecode()
   mTheoraGranulepos = -1;
   mVorbisGranulepos = -1;
 
   if (NS_FAILED(nsBuiltinDecoderReader::ResetDecode())) {
     res = NS_ERROR_FAILURE;
   }
 
   {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
     // Discard any previously buffered packets/pages.
     ogg_sync_reset(&mOggState);
     if (mVorbisState && NS_FAILED(mVorbisState->Reset())) {
       res = NS_ERROR_FAILURE;
     }
     if (mTheoraState && NS_FAILED(mTheoraState->Reset())) {
       res = NS_ERROR_FAILURE;
@@ -168,17 +168,17 @@ static PRBool DoneReadingHeaders(nsTArra
     }
   }
   return PR_TRUE;
 }
 
 nsresult nsOggReader::ReadMetadata(nsVideoInfo* aInfo)
 {
   NS_ASSERTION(mDecoder->OnStateMachineThread(), "Should be on play state machine thread.");
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   // We read packets until all bitstreams have read all their header packets.
   // We record the offset of the first non-header page so that we know
   // what page to seek to when seeking to the media start.
 
   ogg_page page;
   PRInt64 pageOffset;
   nsAutoTArray<nsOggCodecState*,4> bitstreams;
@@ -333,18 +333,18 @@ nsresult nsOggReader::ReadMetadata(nsVid
     if (HasVideo()) {
       tracks.AppendElement(mTheoraState->mSerial);
     }
     if (HasAudio()) {
       tracks.AppendElement(mVorbisState->mSerial);
     }
     PRInt64 duration = 0;
     if (NS_SUCCEEDED(mSkeletonState->GetDuration(tracks, duration))) {
-      MonitorAutoExit exitReaderMon(mMonitor);
-      MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
+      ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
       mDecoder->GetStateMachine()->SetDuration(duration);
       LOG(PR_LOG_DEBUG, ("Got duration from Skeleton index %lld", duration));
     }
   }
 
   // Copy Vorbis and Theora info data for time computations on other threads.
   if (mVorbisState) {
     memcpy(&mVorbisInfo, &mVorbisState->mInfo, sizeof(mVorbisInfo));
@@ -407,17 +407,17 @@ nsresult nsOggReader::DecodeVorbis(nsTAr
       return NS_ERROR_FAILURE;
     }
   }
   return NS_OK;
 }
 
 PRBool nsOggReader::DecodeAudioData()
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
                "Should be on playback or decode thread.");
   NS_ASSERTION(mVorbisState!=0, "Need Vorbis state to decode audio");
   ogg_packet packet;
   packet.granulepos = -1;
 
   PRBool endOfStream = PR_FALSE;
 
@@ -563,17 +563,17 @@ nsresult nsOggReader::DecodeTheora(nsTAr
       b.mPlanes[i].mData = buffer[i].data;
       b.mPlanes[i].mHeight = buffer[i].height;
       b.mPlanes[i].mWidth = buffer[i].width;
       b.mPlanes[i].mStride = buffer[i].stride;
     }
 
     // Need the monitor to be held to be able to use mInfo. This
     // is held by our caller.
-    mMonitor.AssertCurrentThreadIn();
+    mReentrantMonitor.AssertCurrentThreadIn();
     VideoData *v = VideoData::Create(mInfo,
                                      mDecoder->GetImageContainer(),
                                      mPageOffset,
                                      time,
                                      endTime,
                                      b,
                                      isKeyframe,
                                      aPacket->granulepos);
@@ -588,17 +588,17 @@ nsresult nsOggReader::DecodeTheora(nsTAr
     }
   }
   return NS_OK;
 }
 
 PRBool nsOggReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
                                      PRInt64 aTimeThreshold)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
                "Should be on state machine or AV thread.");
 
   // Record number of frames decoded and parsed. Automatically update the
   // stats counters using the AutoNotifyDecoded stack-based class.
   PRUint32 parsed = 0, decoded = 0;
   nsMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
 
@@ -796,17 +796,17 @@ PRBool nsOggReader::DecodeVideoFrame(PRB
 
   return !endOfStream;
 }
 
 PRInt64 nsOggReader::ReadOggPage(ogg_page* aPage)
 {
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
                "Should be on play state machine or decode thread.");
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   int ret = 0;
   while((ret = ogg_sync_pageseek(&mOggState, aPage)) <= 0) {
     if (ret < 0) {
       // Lost page sync, have to skip up to next page.
       mPageOffset += -ret;
       continue;
     }
@@ -837,17 +837,17 @@ PRInt64 nsOggReader::ReadOggPage(ogg_pag
   return offset;
 }
 
 PRBool nsOggReader::ReadOggPacket(nsOggCodecState* aCodecState,
                                   ogg_packet* aPacket)
 {
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
                "Should be on play state machine or decode thread.");
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   if (!aCodecState || !aCodecState->mActive) {
     return PR_FALSE;
   }
 
   int ret = 0;
   while ((ret = ogg_stream_packetout(&aCodecState->mState, aPacket)) != 1) {
     ogg_page page;
@@ -912,17 +912,17 @@ VideoData* nsOggReader::FindStartTime(PR
   PRInt64 offset = NS_MAX(mDataOffset, aOffset);
   nsresult res = stream->Seek(nsISeekableStream::NS_SEEK_SET, offset);
   NS_ENSURE_SUCCESS(res, nsnull);
   return nsBuiltinDecoderReader::FindStartTime(offset, aOutStartTime);
 }
 
 PRInt64 nsOggReader::FindEndTime(PRInt64 aEndOffset)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread(),
                "Should be on state machine thread.");
   NS_ASSERTION(mDataOffset > 0,
                "Should have offset of first non-header page");
   PRInt64 offset = NS_MAX(mDataOffset, aEndOffset);
   PRInt64 endTime = FindEndTime(mDataOffset, offset, PR_FALSE, &mOggState);
   // Reset read head to start of media data.
   nsMediaStream* stream = mDecoder->GetCurrentStream();
@@ -1051,17 +1051,17 @@ PRInt64 nsOggReader::FindEndTime(PRInt64
 
   return endTime;
 }
 
 nsresult nsOggReader::GetSeekRanges(nsTArray<SeekRange>& aRanges)
 {
   NS_ASSERTION(mDecoder->OnStateMachineThread(),
                "Should be on state machine thread.");
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
   nsTArray<nsByteRange> cached;
   nsresult res = mDecoder->GetCurrentStream()->GetCachedRanges(cached);
   NS_ENSURE_SUCCESS(res, res);
 
   for (PRUint32 index = 0; index < cached.Length(); index++) {
     nsByteRange& range = cached[index];
     PRInt64 startTime = -1;
     PRInt64 endTime = -1;
@@ -1231,18 +1231,18 @@ nsresult nsOggReader::SeekInBufferedRang
 
   // We have an active Theora bitstream. Decode the next Theora frame, and
   // extract its keyframe's time.
   PRBool eof;
   do {
     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;
       }
     }
   } while (!eof &&
            mVideoQueue.GetSize() == 0);
 
   VideoData* video = mVideoQueue.PeekFront();
@@ -1311,17 +1311,17 @@ nsresult nsOggReader::SeekInUnbuffered(P
   return res;
 }
 
 nsresult nsOggReader::Seek(PRInt64 aTarget,
                            PRInt64 aStartTime,
                            PRInt64 aEndTime,
                            PRInt64 aCurrentTime)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread(),
                "Should be on state machine thread.");
   LOG(PR_LOG_DEBUG, ("%p About to seek to %lldms", mDecoder, aTarget));
   nsresult res;
   nsMediaStream* stream = mDecoder->GetCurrentStream();
   NS_ENSURE_TRUE(stream != nsnull, NS_ERROR_FAILURE);
 
   if (aTarget == aStartTime) {
@@ -1331,18 +1331,18 @@ nsresult nsOggReader::Seek(PRInt64 aTarg
     NS_ENSURE_SUCCESS(res,res);
 
     mPageOffset = mDataOffset;
     res = ResetDecode();
     NS_ENSURE_SUCCESS(res,res);
 
     NS_ASSERTION(aStartTime != -1, "mStartTime should be known");
     {
-      MonitorAutoExit exitReaderMon(mMonitor);
-      MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
+      ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
       mDecoder->UpdatePlaybackPosition(aStartTime);
     }
   } else if (CanDecodeToTarget(aTarget, aCurrentTime)) {
     LOG(PR_LOG_DEBUG, ("%p Seek target (%lld) is close to current time (%lld), "
         "will just decode to it", mDecoder, aCurrentTime, aTarget));
   } else {
     IndexedSeekResult sres = SeekToKeyframeUsingIndex(aTarget);
     NS_ENSURE_TRUE(sres != SEEK_FATAL_ERROR, NS_ERROR_FAILURE);
--- a/content/media/ogg/nsOggReader.h
+++ b/content/media/ogg/nsOggReader.h
@@ -75,35 +75,35 @@ public:
                                    PRInt64& aOutStartTime);
 
   // Get the end time of aEndOffset. This is the playback position we'd reach
   // after playback finished at aEndOffset.
   virtual PRInt64 FindEndTime(PRInt64 aEndOffset);
 
   virtual PRBool HasAudio()
   {
-    mozilla::MonitorAutoEnter mon(mMonitor);
+    mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return mVorbisState != 0 && mVorbisState->mActive;
   }
 
   virtual PRBool HasVideo()
   {
-    mozilla::MonitorAutoEnter mon(mMonitor);
+    mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return mTheoraState != 0 && mTheoraState->mActive;
   }
 
   virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
   virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
   virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);
 
 private:
 
   PRBool HasSkeleton()
   {
-    MonitorAutoEnter mon(mMonitor);
+    ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return mSkeletonState != 0 && mSkeletonState->mActive;
   }
 
   // Returns PR_TRUE if we should decode up to the seek target rather than
   // seeking to the target using a bisection search or index-assisted seek.
   // We should do this if the seek target (aTarget, in usecs), lies not too far
   // ahead of the current playback position (aCurrentTime, in usecs).
   PRBool CanDecodeToTarget(PRInt64 aTarget,
--- a/content/media/wave/nsWaveReader.cpp
+++ b/content/media/wave/nsWaveReader.cpp
@@ -148,42 +148,42 @@ nsWaveReader::~nsWaveReader()
 nsresult nsWaveReader::Init(nsBuiltinDecoderReader* aCloneDonor)
 {
   return NS_OK;
 }
 
 nsresult nsWaveReader::ReadMetadata(nsVideoInfo* aInfo)
 {
   NS_ASSERTION(mDecoder->OnStateMachineThread(), "Should be on state machine thread.");
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   PRBool loaded = LoadRIFFChunk() && LoadFormatChunk() && FindDataOffset();
   if (!loaded) {
     return NS_ERROR_FAILURE;
   }
 
   mInfo.mHasAudio = PR_TRUE;
   mInfo.mHasVideo = PR_FALSE;
   mInfo.mAudioRate = mSampleRate;
   mInfo.mAudioChannels = mChannels;
 
   *aInfo = mInfo;
 
-  MonitorAutoExit exitReaderMon(mMonitor);
-  MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
+  ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
+  ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
 
   mDecoder->GetStateMachine()->SetDuration(
     static_cast<PRInt64>(BytesToTime(GetDataLength()) * USECS_PER_S));
 
   return NS_OK;
 }
 
 PRBool nsWaveReader::DecodeAudioData()
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
                "Should be on state machine thread or decode thread.");
 
   PRInt64 pos = GetPosition() - mWavePCMOffset;
   PRInt64 len = GetDataLength();
   PRInt64 remaining = len - pos;
   NS_ASSERTION(remaining >= 0, "Current wave position is greater than wave file length");
 
@@ -241,26 +241,26 @@ PRBool nsWaveReader::DecodeAudioData()
                                  mChannels));
 
   return PR_TRUE;
 }
 
 PRBool nsWaveReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
                                       PRInt64 aTimeThreshold)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
                "Should be on state machine or decode thread.");
 
   return PR_FALSE;
 }
 
 nsresult nsWaveReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread(),
                "Should be on state machine thread.");
   LOG(PR_LOG_DEBUG, ("%p About to seek to %lld", mDecoder, aTarget));
   if (NS_FAILED(ResetDecode())) {
     return NS_ERROR_FAILURE;
   }
   double d = BytesToTime(GetDataLength());
   NS_ASSERTION(d < PR_INT64_MAX / USECS_PER_S, "Duration overflow"); 
@@ -472,17 +472,17 @@ nsWaveReader::LoadFormatChunk()
   if (rate < 100 || rate > 96000 ||
       channels < 1 || channels > MAX_CHANNELS ||
       (sampleSize != 1 && sampleSize != 2 && sampleSize != 4) ||
       (sampleFormat != 8 && sampleFormat != 16)) {
     NS_WARNING("Invalid WAVE metadata");
     return PR_FALSE;
   }
 
-  MonitorAutoEnter monitor(mDecoder->GetMonitor());
+  ReentrantMonitorAutoEnter monitor(mDecoder->GetReentrantMonitor());
   mSampleRate = rate;
   mChannels = channels;
   mSampleSize = sampleSize;
   if (sampleFormat == 8) {
     mSampleFormat = nsAudioStream::FORMAT_U8;
   } else {
     mSampleFormat = nsAudioStream::FORMAT_S16_LE;
   }
@@ -504,17 +504,17 @@ nsWaveReader::FindDataOffset()
   }
 
   PRInt64 offset = mDecoder->GetCurrentStream()->Tell();
   if (offset <= 0 || offset > PR_UINT32_MAX) {
     NS_WARNING("PCM data offset out of range");
     return PR_FALSE;
   }
 
-  MonitorAutoEnter monitor(mDecoder->GetMonitor());
+  ReentrantMonitorAutoEnter monitor(mDecoder->GetReentrantMonitor());
   mWaveLength = length;
   mWavePCMOffset = PRUint32(offset);
   return PR_TRUE;
 }
 
 double
 nsWaveReader::BytesToTime(PRInt64 aBytes) const
 {
--- a/content/media/webm/nsWebMBufferedParser.cpp
+++ b/content/media/webm/nsWebMBufferedParser.cpp
@@ -36,17 +36,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsAlgorithm.h"
 #include "nsWebMBufferedParser.h"
 #include "nsTimeRanges.h"
 #include "nsThreadUtils.h"
 
-using mozilla::MonitorAutoEnter;
+using mozilla::ReentrantMonitorAutoEnter;
 
 static const double NS_PER_S = 1e9;
 
 static PRUint32
 VIntLength(unsigned char aFirstByte, PRUint32* aMask)
 {
   PRUint32 count = 1;
   PRUint32 mask = 1 << 7;
@@ -61,17 +61,17 @@ VIntLength(unsigned char aFirstByte, PRU
     *aMask = mask;
   }
   NS_ASSERTION(count >= 1 && count <= 8, "Insane VInt length.");
   return count;
 }
 
 void nsWebMBufferedParser::Append(const unsigned char* aBuffer, PRUint32 aLength,
                                   nsTArray<nsWebMTimeDataOffset>& aMapping,
-                                  Monitor& aMonitor)
+                                  ReentrantMonitor& aReentrantMonitor)
 {
   static const unsigned char CLUSTER_ID[] = { 0x1f, 0x43, 0xb6, 0x75 };
   static const unsigned char TIMECODE_ID = 0xe7;
   static const unsigned char BLOCKGROUP_ID = 0xa0;
   static const unsigned char BLOCK_ID = 0xa1;
   static const unsigned char SIMPLEBLOCK_ID = 0xa3;
 
   const unsigned char* p = aBuffer;
@@ -166,17 +166,17 @@ void nsWebMBufferedParser::Append(const 
       if (mBlockTimecodeLength) {
         mBlockTimecode <<= 8;
         mBlockTimecode |= *p++;
         mBlockTimecodeLength -= 1;
       } else {
         // It's possible we've parsed this data before, so avoid inserting
         // duplicate nsWebMTimeDataOffset entries.
         {
-          MonitorAutoEnter mon(aMonitor);
+          ReentrantMonitorAutoEnter mon(aReentrantMonitor);
           PRUint32 idx;
           if (!aMapping.GreatestIndexLtEq(mBlockOffset, idx)) {
             nsWebMTimeDataOffset entry(mBlockOffset, mClusterTimecode + mBlockTimecode);
             aMapping.InsertElementAt(idx, entry);
           }
         }
 
         // Skip rest of block header and the block's payload.
@@ -209,17 +209,17 @@ void nsWebMBufferedParser::Append(const 
   mCurrentOffset += aLength;
 }
 
 void nsWebMBufferedState::CalculateBufferedForRange(nsTimeRanges* aBuffered,
                                                     PRInt64 aStartOffset, PRInt64 aEndOffset,
                                                     PRUint64 aTimecodeScale,
                                                     PRInt64 aStartTimeOffsetNS)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   // Find the first nsWebMTimeDataOffset at or after aStartOffset.
   PRUint32 start;
   mTimeMapping.GreatestIndexLtEq(aStartOffset, start);
   if (start == mTimeMapping.Length()) {
     return;
   }
 
@@ -281,17 +281,17 @@ void nsWebMBufferedState::NotifyDataArri
     } else {
       mRangeParsers.InsertElementAt(idx, nsWebMBufferedParser(aOffset));
     }
   }
 
   mRangeParsers[idx].Append(reinterpret_cast<const unsigned char*>(aBuffer),
                             aLength,
                             mTimeMapping,
-                            mMonitor);
+                            mReentrantMonitor);
 
   // Merge parsers with overlapping regions and clean up the remnants.
   PRUint32 i = 0;
   while (i + 1 < mRangeParsers.Length()) {
     if (mRangeParsers[i].mCurrentOffset >= mRangeParsers[i + 1].mStartOffset) {
       mRangeParsers[i + 1].mStartOffset = mRangeParsers[i].mStartOffset;
       mRangeParsers.RemoveElementAt(i);
     } else {
--- a/content/media/webm/nsWebMBufferedParser.h
+++ b/content/media/webm/nsWebMBufferedParser.h
@@ -35,20 +35,20 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #if !defined(nsWebMBufferedParser_h_)
 #define nsWebMBufferedParser_h_
 
 #include "nsISupportsImpl.h"
 #include "nsTArray.h"
-#include "mozilla/Monitor.h"
+#include "mozilla/ReentrantMonitor.h"
 
 class nsTimeRanges;
-using mozilla::Monitor;
+using mozilla::ReentrantMonitor;
 
 // Stores a stream byte offset and the scaled timecode of the block at
 // that offset.  The timecode must be scaled by the stream's timecode
 // scale before use.
 struct nsWebMTimeDataOffset
 {
   nsWebMTimeDataOffset(PRInt64 aOffset, PRUint64 aTimecode)
     : mOffset(aOffset), mTimecode(aTimecode)
@@ -75,20 +75,20 @@ struct nsWebMTimeDataOffset
 struct nsWebMBufferedParser
 {
   nsWebMBufferedParser(PRInt64 aOffset)
     : mStartOffset(aOffset), mCurrentOffset(aOffset), mState(CLUSTER_SYNC), mClusterIDPos(0)
   {}
 
   // Steps the parser through aLength bytes of data.  Always consumes
   // aLength bytes.  Updates mCurrentOffset before returning.  Acquires
-  // aMonitor before using aMapping.
+  // aReentrantMonitor before using aMapping.
   void Append(const unsigned char* aBuffer, PRUint32 aLength,
               nsTArray<nsWebMTimeDataOffset>& aMapping,
-              Monitor& aMonitor);
+              ReentrantMonitor& aReentrantMonitor);
 
   bool operator==(PRInt64 aOffset) const {
     return mCurrentOffset == aOffset;
   }
 
   bool operator<(PRInt64 aOffset) const {
     return mCurrentOffset < aOffset;
   }
@@ -211,33 +211,33 @@ private:
   PRUint32 mSkipBytes;
 };
 
 class nsWebMBufferedState
 {
   NS_INLINE_DECL_REFCOUNTING(nsWebMBufferedState)
 
 public:
-  nsWebMBufferedState() : mMonitor("nsWebMBufferedState") {
+  nsWebMBufferedState() : mReentrantMonitor("nsWebMBufferedState") {
     MOZ_COUNT_CTOR(nsWebMBufferedState);
   }
 
   ~nsWebMBufferedState() {
     MOZ_COUNT_DTOR(nsWebMBufferedState);
   }
 
   void NotifyDataArrived(const char* aBuffer, PRUint32 aLength, PRUint32 aOffset);
   void CalculateBufferedForRange(nsTimeRanges* aBuffered,
                                  PRInt64 aStartOffset, PRInt64 aEndOffset,
                                  PRUint64 aTimecodeScale,
                                  PRInt64 aStartTimeOffsetNS);
 
 private:
   // Synchronizes access to the mTimeMapping array.
-  Monitor mMonitor;
+  ReentrantMonitor mReentrantMonitor;
 
   // Sorted (by offset) map of data offsets to timecodes.  Populated
   // on the main thread as data is received and parsed by nsWebMBufferedParsers.
   nsTArray<nsWebMTimeDataOffset> mTimeMapping;
 
   // Sorted (by offset) live parser instances.  Main thread only.
   nsTArray<nsWebMBufferedParser> mRangeParsers;
 };
--- a/content/media/webm/nsWebMReader.cpp
+++ b/content/media/webm/nsWebMReader.cpp
@@ -206,33 +206,33 @@ void nsWebMReader::Cleanup()
     nestegg_destroy(mContext);
     mContext = nsnull;
   }
 }
 
 nsresult nsWebMReader::ReadMetadata(nsVideoInfo* aInfo)
 {
   NS_ASSERTION(mDecoder->OnStateMachineThread(), "Should be on state machine thread.");
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
 
   nestegg_io io;
   io.read = webm_read;
   io.seek = webm_seek;
   io.tell = webm_tell;
   io.userdata = static_cast<nsBuiltinDecoder*>(mDecoder);
   int r = nestegg_init(&mContext, io, NULL);
   if (r == -1) {
     return NS_ERROR_FAILURE;
   }
 
   uint64_t duration = 0;
   r = nestegg_duration(mContext, &duration);
   if (r == 0) {
-    MonitorAutoExit exitReaderMon(mMonitor);
-    MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
+    ReentrantMonitorAutoExit exitReaderMon(mReentrantMonitor);
+    ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
     mDecoder->GetStateMachine()->SetDuration(duration / NS_PER_USEC);
   }
 
   unsigned int ntracks = 0;
   r = nestegg_track_count(mContext, &ntracks);
   if (r == -1) {
     Cleanup();
     return NS_ERROR_FAILURE;
@@ -408,17 +408,17 @@ ogg_packet nsWebMReader::InitOggPacket(u
   packet.e_o_s = aEOS;
   packet.granulepos = aGranulepos;
   packet.packetno = mPacketCount++;
   return packet;
 }
  
 PRBool nsWebMReader::DecodeAudioPacket(nestegg_packet* aPacket, PRInt64 aOffset)
 {
-  mMonitor.AssertCurrentThreadIn();
+  mReentrantMonitor.AssertCurrentThreadIn();
 
   int r = 0;
   unsigned int count = 0;
   r = nestegg_packet_count(aPacket, &count);
   if (r == -1) {
     return PR_FALSE;
   }
 
@@ -586,32 +586,32 @@ nsReturnRef<NesteggPacketHolder> nsWebMR
     } while (PR_TRUE);
   }
 
   return holder.out();
 }
 
 PRBool nsWebMReader::DecodeAudioData()
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
     "Should be on state machine thread or decode thread.");
   nsAutoRef<NesteggPacketHolder> holder(NextPacket(AUDIO));
   if (!holder) {
     mAudioQueue.Finish();
     return PR_FALSE;
   }
 
   return DecodeAudioPacket(holder->mPacket, holder->mOffset);
 }
 
 PRBool nsWebMReader::DecodeVideoFrame(PRBool &aKeyframeSkip,
                                       PRInt64 aTimeThreshold)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread() || mDecoder->OnDecodeThread(),
                "Should be on state machine or decode thread.");
 
   // Record number of frames decoded and parsed. Automatically update the
   // stats counters using the AutoNotifyDecoded stack-based class.
   PRUint32 parsed = 0, decoded = 0;
   nsMediaDecoder::AutoNotifyDecoded autoNotify(mDecoder, parsed, decoded);
 
@@ -649,18 +649,18 @@ PRBool nsWebMReader::DecodeVideoFrame(PR
     nsAutoRef<NesteggPacketHolder> next_holder(NextPacket(VIDEO));
     if (next_holder) {
       r = nestegg_packet_tstamp(next_holder->mPacket, &next_tstamp);
       if (r == -1) {
         return PR_FALSE;
       }
       mVideoPackets.PushFront(next_holder.disown());
     } else {
-      MonitorAutoExit exitMon(mMonitor);
-      MonitorAutoEnter decoderMon(mDecoder->GetMonitor());
+      ReentrantMonitorAutoExit exitMon(mReentrantMonitor);
+      ReentrantMonitorAutoEnter decoderMon(mDecoder->GetReentrantMonitor());
       nsBuiltinDecoderStateMachine* s =
         static_cast<nsBuiltinDecoderStateMachine*>(mDecoder->GetStateMachine());
       PRInt64 endTime = s->GetEndMediaTime();
       if (endTime == -1) {
         return PR_FALSE;
       }
       next_tstamp = endTime * NS_PER_USEC;
     }
@@ -751,17 +751,17 @@ PRBool nsWebMReader::CanDecodeToTarget(P
 {
   return aTarget >= aCurrentTime &&
          aTarget - aCurrentTime < SEEK_DECODE_MARGIN;
 }
 
 nsresult nsWebMReader::Seek(PRInt64 aTarget, PRInt64 aStartTime, PRInt64 aEndTime,
                             PRInt64 aCurrentTime)
 {
-  MonitorAutoEnter mon(mMonitor);
+  ReentrantMonitorAutoEnter mon(mReentrantMonitor);
   NS_ASSERTION(mDecoder->OnStateMachineThread(),
                "Should be on state machine thread.");
   LOG(PR_LOG_DEBUG, ("%p About to seek to %lldms", mDecoder, aTarget));
   if (CanDecodeToTarget(aTarget, aCurrentTime)) {
     LOG(PR_LOG_DEBUG, ("%p Seek target (%lld) is close to current time (%lld), "
                        "will just decode to it", mDecoder, aCurrentTime, aTarget));
   } else {
     if (NS_FAILED(ResetDecode())) {
--- a/content/media/webm/nsWebMReader.h
+++ b/content/media/webm/nsWebMReader.h
@@ -138,23 +138,23 @@ public:
   // If the Theora granulepos has not been captured, it may read several packets
   // until one with a granulepos has been captured, to ensure that all packets
   // read have valid time info.  
   virtual PRBool DecodeVideoFrame(PRBool &aKeyframeSkip,
                                   PRInt64 aTimeThreshold);
 
   virtual PRBool HasAudio()
   {
-    mozilla::MonitorAutoEnter mon(mMonitor);
+    mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return mHasAudio;
   }
 
   virtual PRBool HasVideo()
   {
-    mozilla::MonitorAutoEnter mon(mMonitor);
+    mozilla::ReentrantMonitorAutoEnter mon(mReentrantMonitor);
     return mHasVideo;
   }
 
   virtual nsresult ReadMetadata(nsVideoInfo* aInfo);
   virtual nsresult Seek(PRInt64 aTime, PRInt64 aStartTime, PRInt64 aEndTime, PRInt64 aCurrentTime);
   virtual nsresult GetBuffered(nsTimeRanges* aBuffered, PRInt64 aStartTime);
   virtual void NotifyDataArrived(const char* aBuffer, PRUint32 aLength, PRUint32 aOffset);
 
--- a/content/smil/nsDOMTimeEvent.cpp
+++ b/content/smil/nsDOMTimeEvent.cpp
@@ -34,17 +34,16 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsDOMTimeEvent.h"
 #include "nsGUIEvent.h"
 #include "nsPresContext.h"
 #include "nsIInterfaceRequestorUtils.h"
-#include "nsIDOMAbstractView.h"
 
 nsDOMTimeEvent::nsDOMTimeEvent(nsPresContext* aPresContext, nsEvent* aEvent)
   : nsDOMEvent(aPresContext, aEvent ? aEvent : new nsUIEvent(PR_FALSE, 0, 0)),
     mDetail(0)
 {
   if (aEvent) {
     mEventIsInternal = PR_FALSE;
   } else {
@@ -87,33 +86,33 @@ NS_IMPL_RELEASE_INHERITED(nsDOMTimeEvent
 DOMCI_DATA(TimeEvent, nsDOMTimeEvent)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMTimeEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMTimeEvent)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TimeEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
 NS_IMETHODIMP
-nsDOMTimeEvent::GetView(nsIDOMAbstractView** aView)
+nsDOMTimeEvent::GetView(nsIDOMWindow** aView)
 {
   *aView = mView;
   NS_IF_ADDREF(*aView);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMTimeEvent::GetDetail(PRInt32* aDetail)
 {
   *aDetail = mDetail;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMTimeEvent::InitTimeEvent(const nsAString& aTypeArg,
-                              nsIDOMAbstractView* aViewArg,
+                              nsIDOMWindow* aViewArg,
                               PRInt32 aDetailArg)
 {
   nsresult rv = nsDOMEvent::InitEvent(aTypeArg, PR_FALSE /*doesn't bubble*/,
                                                 PR_FALSE /*can't cancel*/);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mDetail = aDetailArg;
   mView = aViewArg;
--- a/content/smil/nsDOMTimeEvent.h
+++ b/content/smil/nsDOMTimeEvent.h
@@ -53,13 +53,13 @@ public:
 
   // nsIDOMTimeEvent interface:
   NS_DECL_NSIDOMTIMEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
 
 private:
-  nsCOMPtr<nsIDOMAbstractView> mView;
-  PRInt32                      mDetail;
+  nsCOMPtr<nsIDOMWindow> mView;
+  PRInt32 mDetail;
 };
 
 #endif // NS_DOMTIMEEVENT_H_
--- a/content/svg/content/src/SVGLengthList.h
+++ b/content/svg/content/src/SVGLengthList.h
@@ -35,16 +35,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef MOZILLA_SVGLENGTHLIST_H__
 #define MOZILLA_SVGLENGTHLIST_H__
 
 #include "SVGLength.h"
 #include "nsTArray.h"
 #include "nsSVGElement.h"
+#include "nsIWeakReferenceUtils.h"
 
 namespace mozilla {
 
 /**
  * ATTENTION! WARNING! WATCH OUT!!
  *
  * Consumers that modify objects of this type absolutely MUST keep the DOM
  * wrappers for those lists (if any) in sync!! That's why this class is so
@@ -201,29 +202,30 @@ public:
 
   SVGLengthListAndInfo()
     : mElement(nsnull)
     , mAxis(0)
     , mCanZeroPadList(PR_FALSE)
   {}
 
   SVGLengthListAndInfo(nsSVGElement *aElement, PRUint8 aAxis, PRBool aCanZeroPadList)
-    : mElement(aElement)
+    : mElement(do_GetWeakReference(static_cast<nsINode*>(aElement)))
     , mAxis(aAxis)
     , mCanZeroPadList(aCanZeroPadList)
   {}
 
   void SetInfo(nsSVGElement *aElement, PRUint8 aAxis, PRBool aCanZeroPadList) {
-    mElement = aElement;
+    mElement = do_GetWeakReference(static_cast<nsINode*>(aElement));
     mAxis = aAxis;
     mCanZeroPadList = aCanZeroPadList;
   }
 
   nsSVGElement* Element() const {
-    return mElement; // .get();
+    nsCOMPtr<nsIContent> e = do_QueryReferent(mElement);
+    return static_cast<nsSVGElement*>(e.get());
   }
 
   PRUint8 Axis() const {
     NS_ABORT_IF_FALSE(mElement, "Axis() isn't valid");
     return mAxis;
   }
 
   /**
@@ -286,20 +288,21 @@ public:
   SVGLength& operator[](PRUint32 aIndex) {
     return SVGLengthList::operator[](aIndex);
   }
   PRBool SetLength(PRUint32 aNumberOfItems) {
     return SVGLengthList::SetLength(aNumberOfItems);
   }
 
 private:
-  // We must keep a strong reference to our element because we may belong to a
+  // We must keep a weak reference to our element because we may belong to a
   // cached baseVal nsSMILValue. See the comments starting at:
   // https://bugzilla.mozilla.org/show_bug.cgi?id=515116#c15
-  nsRefPtr<nsSVGElement> mElement;
+  // See also https://bugzilla.mozilla.org/show_bug.cgi?id=653497
+  nsWeakPtr mElement;
   PRUint8 mAxis;
   PRPackedBool mCanZeroPadList;
 };
 
 
 /**
  * This class wraps SVGLengthList objects to allow frame consumers to process
  * SVGLengthList objects as if they were simply a list of float values in user
--- a/content/svg/content/src/SVGPathData.h
+++ b/content/svg/content/src/SVGPathData.h
@@ -35,16 +35,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef MOZILLA_SVGPATHDATA_H__
 #define MOZILLA_SVGPATHDATA_H__
 
 #include "SVGPathSegUtils.h"
 #include "nsTArray.h"
 #include "nsSVGElement.h"
+#include "nsIWeakReferenceUtils.h"
 
 class gfxContext;
 struct gfxMatrix;
 class gfxFlattenedPath;
 class nsSVGPathDataParserToInternal;
 struct nsSVGMark;
 
 namespace mozilla {
@@ -240,25 +241,26 @@ protected:
  * Instances of this class do not have DOM wrappers that need to be kept in
  * sync, so we can safely expose any protected base class methods required by
  * the SMIL code.
  */
 class SVGPathDataAndOwner : public SVGPathData
 {
 public:
   SVGPathDataAndOwner(nsSVGElement *aElement = nsnull)
-    : mElement(aElement)
+    : mElement(do_GetWeakReference(static_cast<nsINode*>(aElement)))
   {}
 
   void SetElement(nsSVGElement *aElement) {
-    mElement = aElement;
+    mElement = do_GetWeakReference(static_cast<nsINode*>(aElement));
   }
 
   nsSVGElement* Element() const {
-    return mElement;
+    nsCOMPtr<nsIContent> e = do_QueryReferent(mElement);
+    return static_cast<nsSVGElement*>(e.get());
   }
 
   nsresult CopyFrom(const SVGPathDataAndOwner& rhs) {
     mElement = rhs.mElement;
     return SVGPathData::CopyFrom(rhs);
   }
 
   PRBool IsIdentity() const {
@@ -279,17 +281,18 @@ public:
   // Exposed since SVGPathData objects can be modified.
   using SVGPathData::iterator;
   using SVGPathData::operator[];
   using SVGPathData::SetLength;
   using SVGPathData::begin;
   using SVGPathData::end;
 
 private:
-  // We must keep a strong reference to our element because we may belong to a
+  // We must keep a weak reference to our element because we may belong to a
   // cached baseVal nsSMILValue. See the comments starting at:
   // https://bugzilla.mozilla.org/show_bug.cgi?id=515116#c15
-  nsRefPtr<nsSVGElement> mElement;
+  // See also https://bugzilla.mozilla.org/show_bug.cgi?id=653497
+  nsWeakPtr mElement;
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGPATHDATA_H__
--- a/content/svg/content/src/SVGPointList.h
+++ b/content/svg/content/src/SVGPointList.h
@@ -35,16 +35,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef MOZILLA_SVGPOINTLIST_H__
 #define MOZILLA_SVGPOINTLIST_H__
 
 #include "SVGPoint.h"
 #include "nsTArray.h"
 #include "nsSVGElement.h"
+#include "nsIWeakReferenceUtils.h"
 
 namespace mozilla {
 
 /**
  * ATTENTION! WARNING! WATCH OUT!!
  *
  * Consumers that modify objects of this type absolutely MUST keep the DOM
  * wrappers for those lists (if any) in sync!! That's why this class is so
@@ -179,25 +180,26 @@ protected:
  * Holding a strong reference to the element here prevents the element from
  * disappearing out from under the SMIL code unexpectedly.
  */
 class SVGPointListAndInfo : public SVGPointList
 {
 public:
 
   SVGPointListAndInfo(nsSVGElement *aElement = nsnull)
-    : mElement(aElement)
+    : mElement(do_GetWeakReference(static_cast<nsINode*>(aElement)))
   {}
 
   void SetInfo(nsSVGElement *aElement) {
-    mElement = aElement;
+    mElement = do_GetWeakReference(static_cast<nsINode*>(aElement));
   }
 
   nsSVGElement* Element() const {
-    return mElement;
+    nsCOMPtr<nsIContent> e = do_QueryReferent(mElement);
+    return static_cast<nsSVGElement*>(e.get());
   }
 
   nsresult CopyFrom(const SVGPointListAndInfo& rhs) {
     mElement = rhs.mElement;
     return SVGPointList::CopyFrom(rhs);
   }
 
   /**
@@ -214,17 +216,18 @@ public:
   SVGPoint& operator[](PRUint32 aIndex) {
     return SVGPointList::operator[](aIndex);
   }
   PRBool SetLength(PRUint32 aNumberOfItems) {
     return SVGPointList::SetLength(aNumberOfItems);
   }
 
 private:
-  // We must keep a strong reference to our element because we may belong to a
+  // We must keep a weak reference to our element because we may belong to a
   // cached baseVal nsSMILValue. See the comments starting at:
   // https://bugzilla.mozilla.org/show_bug.cgi?id=515116#c15
-  nsRefPtr<nsSVGElement> mElement;
+  // See also https://bugzilla.mozilla.org/show_bug.cgi?id=653497
+  nsWeakPtr mElement;
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGPOINTLIST_H__
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -46,18 +46,16 @@
 #include "nsIDOMMutationEvent.h"
 #include "nsMutationEvent.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsBindingManager.h"
 #include "nsXBLBinding.h"
 #include "nsStyleConsts.h"
 #include "nsDOMError.h"
 #include "nsIPresShell.h"
-#include "nsIDOMViewCSS.h"
-#include "nsIDOMCSSStyleDeclaration.h"
 #include "nsIServiceManager.h"
 #include "nsIXBLService.h"
 #include "nsGkAtoms.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsRuleWalker.h"
 #include "mozilla/css/Declaration.h"
 #include "nsCSSProps.h"
 #include "nsCSSParser.h"
--- a/content/svg/content/src/nsSVGFeatures.cpp
+++ b/content/svg/content/src/nsSVGFeatures.cpp
@@ -49,44 +49,64 @@
 #include "nsSVGFeatures.h"
 #include "nsGkAtoms.h"
 #include "nsIContent.h"
 #include "nsContentUtils.h"
 #include "nsWhitespaceTokenizer.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsStyleUtil.h"
 #include "nsSVGUtils.h"
+#include "nsServiceManagerUtils.h"
+#include "nsIPrefService.h"
 
 /*static*/ PRBool
-nsSVGFeatures::HaveFeature(const nsAString& aFeature)
+nsSVGFeatures::HaveFeature(nsISupports* aObject, const nsAString& aFeature)
 {
-#define SVG_SUPPORTED_FEATURE(str) if (aFeature.Equals(NS_LITERAL_STRING(str).get())) return PR_TRUE;
+  if (aFeature.EqualsLiteral("http://www.w3.org/TR/SVG11/feature#Script")) {
+    nsCOMPtr<nsIContent> content(do_QueryInterface(aObject));
+    if (content) {
+      nsIDocument *doc = content->GetCurrentDoc();
+      if (doc && doc->IsResourceDoc()) {
+        // no scripting in SVG images or external resource documents
+        return PR_FALSE;
+      }
+    }
+    nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
+    if (prefs) {
+      PRBool js;
+      if (NS_SUCCEEDED(prefs->GetBoolPref("javascript.enabled", &js))) {
+        return js;
+      }
+    }
+    return PR_FALSE;
+  }
+#define SVG_SUPPORTED_FEATURE(str) if (aFeature.EqualsLiteral(str)) return PR_TRUE;
 #define SVG_UNSUPPORTED_FEATURE(str)
 #include "nsSVGFeaturesList.h"
 #undef SVG_SUPPORTED_FEATURE
 #undef SVG_UNSUPPORTED_FEATURE
   return PR_FALSE;
 }
 
 /*static*/ PRBool
-nsSVGFeatures::HaveFeatures(const nsSubstring& aFeatures)
+nsSVGFeatures::HaveFeatures(nsISupports* aObject, const nsSubstring& aFeatures)
 {
   nsWhitespaceTokenizer tokenizer(aFeatures);
   while (tokenizer.hasMoreTokens()) {
-    if (!HaveFeature(tokenizer.nextToken())) {
+    if (!HaveFeature(aObject, tokenizer.nextToken())) {
       return PR_FALSE;
     }
   }
   return PR_TRUE;
 }
 
 /*static*/ PRBool
 nsSVGFeatures::HaveExtension(const nsAString& aExtension)
 {
-#define SVG_SUPPORTED_EXTENSION(str) if (aExtension.Equals(NS_LITERAL_STRING(str).get())) return PR_TRUE;
+#define SVG_SUPPORTED_EXTENSION(str) if (aExtension.EqualsLiteral(str)) return PR_TRUE;
   SVG_SUPPORTED_EXTENSION("http://www.w3.org/1999/xhtml")
 #ifdef MOZ_MATHML
   SVG_SUPPORTED_EXTENSION("http://www.w3.org/1998/Math/MathML")
 #endif
 #undef SVG_SUPPORTED_EXTENSION
 
   return PR_FALSE;
 }
@@ -181,17 +201,17 @@ nsSVGFeatures::PassesConditionalProcessi
 
   if (!ElementSupportsAttributes(aContent->Tag(), ATTRS_CONDITIONAL)) {
     return PR_TRUE;
   }
 
   // Required Features
   nsAutoString value;
   if (aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::requiredFeatures, value)) {
-    if (value.IsEmpty() || !HaveFeatures(value)) {
+    if (value.IsEmpty() || !HaveFeatures(aContent, value)) {
       return PR_FALSE;
     }
   }
 
   // Required Extensions
   //
   // The requiredExtensions  attribute defines a list of required language
   // extensions. Language extensions are capabilities within a user agent that
--- a/content/svg/content/src/nsSVGFeatures.h
+++ b/content/svg/content/src/nsSVGFeatures.h
@@ -45,21 +45,23 @@ class nsIContent;
 class nsIAtom;
 
 class nsSVGFeatures
 {
 public:
   /**
    * Check whether we support the given feature string.
    *
+   * @param aObject the object, which should support the feature,
+   *        for example nsIDOMNode or nsIDOMDOMImplementation
    * @param aFeature one of the feature strings specified at
    *    http://www.w3.org/TR/SVG11/feature.html
    */
   static PRBool
-  HaveFeature(const nsAString& aFeature);
+  HaveFeature(nsISupports* aObject, const nsAString& aFeature);
 
   /**
    * Compare the language name(s) in a systemLanguage attribute to the
    * user's language preferences, as defined in
    * http://www.w3.org/TR/SVG11/struct.html#SystemLanguageAttribute
    * We have a match if a language name in the users language preferences
    * exactly equals one of the language names or exactly equals a prefix of
    * one of the language names in the systemLanguage attribute.
@@ -92,21 +94,23 @@ public:
   static PRBool
   PassesConditionalProcessingTests(nsIContent *aContent,
                                    const nsString *aAcceptLangs = nsnull);
 
 private:
   /**
    * Check whether we support the given list of feature strings.
    *
+   * @param aObject the object, which should support the feature,
+   *        for example nsIDOMNode or nsIDOMDOMImplementation
    * @param aFeatures a whitespace separated list containing one or more of the
    *   feature strings specified at http://www.w3.org/TR/SVG11/feature.html
    */
   static PRBool
-  HaveFeatures(const nsSubstring& aFeatures);
+  HaveFeatures(nsISupports* aObject, const nsSubstring& aFeatures);
 
   /**
    * Check whether we support the given extension string.
    *
    * @param aExtension the URI of an extension. Known extensions are
    *   "http://www.w3.org/1999/xhtml" and "http://www.w3.org/1998/Math/MathML"
    */
   static PRBool
--- a/content/svg/content/src/nsSVGFeaturesList.h
+++ b/content/svg/content/src/nsSVGFeaturesList.h
@@ -76,17 +76,16 @@ SVG_UNSUPPORTED_FEATURE("http://www.w3.o
 SVG_SUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#DocumentEventsAttribute")
 SVG_SUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#GraphicalEventsAttribute")
 SVG_SUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#AnimationEventsAttribute")
 SVG_UNSUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#Cursor")
 SVG_SUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#Hyperlinking")
 SVG_SUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#XlinkAttribute")
 SVG_UNSUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#ExternalResourcesRequired")
 SVG_UNSUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#View")
-SVG_SUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#Script")
 SVG_UNSUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#Font")
 SVG_UNSUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#BasicFont")
 SVG_SUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#Extensibility")
 
 // Feature groups (SVG 1.1 style)
 SVG_UNSUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#SVG")
 SVG_UNSUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#SVGDOM")
 SVG_UNSUPPORTED_FEATURE("http://www.w3.org/TR/SVG11/feature#SVG-static")
--- a/content/svg/content/src/nsSVGNumber2.cpp
+++ b/content/svg/content/src/nsSVGNumber2.cpp
@@ -122,16 +122,17 @@ nsSVGNumber2::SetBaseValueString(const n
   nsresult rv = GetValueFromString(
     aValueAsString, aSVGElement->NumberAttrAllowsPercentage(mAttrEnum), &val);
 
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   mBaseVal = val;
+  mIsBaseSet = PR_TRUE;
   if (!mIsAnimated) {
     mAnimVal = mBaseVal;
   }
 #ifdef MOZ_SMIL
   else {
     aSVGElement->AnimationNeedsResample();
   }
 #endif
@@ -150,16 +151,17 @@ nsSVGNumber2::GetBaseValueString(nsAStri
 }
 
 void
 nsSVGNumber2::SetBaseValue(float aValue,
                            nsSVGElement *aSVGElement,
                            PRBool aDoSetAttr)
 {
   mBaseVal = aValue;
+  mIsBaseSet = PR_TRUE;
   if (!mIsAnimated) {
     mAnimVal = mBaseVal;
   }
 #ifdef MOZ_SMIL
   else {
     aSVGElement->AnimationNeedsResample();
   }
 #endif
--- a/content/svg/content/src/nsSVGNumber2.h
+++ b/content/svg/content/src/nsSVGNumber2.h
@@ -51,43 +51,53 @@ class nsISMILType;
 class nsSVGNumber2
 {
 
 public:
   void Init(PRUint8 aAttrEnum = 0xff, float aValue = 0) {
     mAnimVal = mBaseVal = aValue;
     mAttrEnum = aAttrEnum;
     mIsAnimated = PR_FALSE;
+    mIsBaseSet = PR_FALSE;
   }
 
   nsresult SetBaseValueString(const nsAString& aValue,
                               nsSVGElement *aSVGElement,
                               PRBool aDoSetAttr);
   void GetBaseValueString(nsAString& aValue);
 
   void SetBaseValue(float aValue, nsSVGElement *aSVGElement, PRBool aDoSetAttr);
   float GetBaseValue() const
     { return mBaseVal; }
   void SetAnimValue(float aValue, nsSVGElement *aSVGElement);
   float GetAnimValue() const
     { return mAnimVal; }
 
+  // Returns PR_TRUE if the animated value of this number has been explicitly
+  // set (either by animation, or by taking on the base value which has been
+  // explicitly set by markup or a DOM call), PR_FALSE otherwise.
+  // If this returns PR_FALSE, the animated value is still valid, that is,
+  // useable, and represents the default base value of the attribute.
+  PRBool IsExplicitlySet() const
+    { return mIsAnimated || mIsBaseSet; }
+
   nsresult ToDOMAnimatedNumber(nsIDOMSVGAnimatedNumber **aResult,
                                nsSVGElement* aSVGElement);
 #ifdef MOZ_SMIL
   // Returns a new nsISMILAttr object that the caller must delete
   nsISMILAttr* ToSMILAttr(nsSVGElement* aSVGElement);
 #endif // MOZ_SMIL
 
 private:
 
   float mAnimVal;
   float mBaseVal;
   PRUint8 mAttrEnum; // element specified tracking for attribute
   PRPackedBool mIsAnimated;
+  PRPackedBool mIsBaseSet;
 
 public:
   struct DOMAnimatedNumber : public nsIDOMSVGAnimatedNumber
   {
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_CLASS(DOMAnimatedNumber)
 
     DOMAnimatedNumber(nsSVGNumber2* aVal, nsSVGElement *aSVGElement)
--- a/content/svg/content/src/nsSVGPathElement.cpp
+++ b/content/svg/content/src/nsSVGPathElement.cpp
@@ -117,18 +117,21 @@ nsSVGPathElement::GetPointAtLength(float
 {
   NS_ENSURE_FINITE(distance, NS_ERROR_ILLEGAL_VALUE);
 
   nsRefPtr<gfxFlattenedPath> flat = GetFlattenedPath(gfxMatrix());
   if (!flat)
     return NS_ERROR_FAILURE;
 
   float totalLength = flat->GetLength();
-  if (HasAttr(kNameSpaceID_None, nsGkAtoms::pathLength)) {
+  if (mPathLength.IsExplicitlySet()) {
     float pathLength = mPathLength.GetAnimValue();
+    if (pathLength <= 0) {
+      return NS_ERROR_FAILURE;
+    }
     distance *= totalLength / pathLength;
   }
   distance = NS_MAX(0.f,         distance);
   distance = NS_MIN(totalLength, distance);
 
   NS_ADDREF(*_retval = new DOMSVGPoint(flat->FindPoint(gfxPoint(distance, 0))));
   return NS_OK;
 }
@@ -395,21 +398,18 @@ nsSVGPathElement::GetFlattenedPath(const
 }
 
 //----------------------------------------------------------------------
 // nsSVGPathGeometryElement methods
 
 PRBool
 nsSVGPathElement::AttributeDefinesGeometry(const nsIAtom *aName)
 {
-  if (aName == nsGkAtoms::d ||
-      aName == nsGkAtoms::pathLength)
-    return PR_TRUE;
-
-  return PR_FALSE;
+  return aName == nsGkAtoms::d ||
+         aName == nsGkAtoms::pathLength;
 }
 
 PRBool
 nsSVGPathElement::IsMarkable()
 {
   return PR_TRUE;
 }
 
@@ -420,8 +420,23 @@ nsSVGPathElement::GetMarkPoints(nsTArray
 }
 
 void
 nsSVGPathElement::ConstructPath(gfxContext *aCtx)
 {
   mD.GetAnimValue().ConstructPath(aCtx);
 }
 
+gfxFloat
+nsSVGPathElement::GetScale()
+{
+  if (mPathLength.IsExplicitlySet()) {
+
+    nsRefPtr<gfxFlattenedPath> flat =
+      GetFlattenedPath(PrependLocalTransformTo(gfxMatrix()));
+    float pathLength = mPathLength.GetAnimValue();
+
+    if (flat && pathLength != 0) {
+      return flat->GetLength() / pathLength;
+    }
+  }
+  return 1.0;
+}
--- a/content/svg/content/src/nsSVGPathElement.h
+++ b/content/svg/content/src/nsSVGPathElement.h
@@ -50,17 +50,16 @@ class gfxContext;
 
 typedef nsSVGPathGeometryElement nsSVGPathElementBase;
 
 class nsSVGPathElement : public nsSVGPathElementBase,
                          public nsIDOMSVGPathElement,
                          public nsIDOMSVGAnimatedPathData
 {
 friend class nsSVGPathFrame;
-friend class nsSVGTextPathFrame;
 
 protected:
   friend nsresult NS_NewSVGPathElement(nsIContent **aResult,
                                        already_AddRefed<nsINodeInfo> aNodeInfo);
   nsSVGPathElement(already_AddRefed<nsINodeInfo> aNodeInfo);
 
 public:
   typedef mozilla::SVGAnimatedPathSegList SVGAnimatedPathSegList;
@@ -94,16 +93,18 @@ public:
   virtual SVGAnimatedPathSegList* GetAnimPathSegList() {
     return &mD;
   }
 
   virtual nsIAtom* GetPathDataAttrName() const {
     return nsGkAtoms::d;
   }
 
+  gfxFloat GetScale();
+
 protected:
 
   // nsSVGElement method
   virtual NumberAttributesInfo GetNumberInfo();
 
   SVGAnimatedPathSegList mD;
   nsSVGNumber2 mPathLength;
   static NumberInfo sNumberInfo;
--- a/content/svg/content/test/Makefile.in
+++ b/content/svg/content/test/Makefile.in
@@ -68,16 +68,17 @@ include $(topsrcdir)/config/rules.mk
 		getCTM-helper.svg \
 		test_getCTM.html \
 		test_getSubStringLength.xhtml \
 		getSubStringLength-helper.svg \
 		test_isSupported.xhtml \
 		test_nonAnimStrings.xhtml \
 		test_pathAnimInterpolation.xhtml \
 		test_pathSeg.xhtml \
+		test_pointAtLength.xhtml \
 		test_pointer-events.xhtml \
 		test_pointer-events-2.xhtml \
 		test_scientific.html \
 		scientific-helper.svg \
 		test_SVGAnimatedImageSMILDisabled.html \
 		animated-svg-image-helper.html \
 		animated-svg-image-helper.svg \
 		test_stroke-linecap-hit-testing.xhtml \
new file mode 100644
--- /dev/null
+++ b/content/svg/content/test/test_pointAtLength.xhtml
@@ -0,0 +1,50 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=643419
+-->
+<head>
+  <title>Test getPointAtLength</title>
+  <script type="text/javascript" src="/MochiKit/packed.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<script class="testbody" type="text/javascript">
+<![CDATA[
+
+SimpleTest.waitForExplicitFinish();
+
+function run()
+{
+  var p1 = document.getElementById("p1");
+  var point = p1.getPointAtLength(200);
+  is(point.x, 200);
+  is(point.y, 50);
+
+  // set the pathLength to twice its actual length
+  p1.setAttribute("pathLength", "800");
+  var point = p1.getPointAtLength(200);
+  is(point.x, 100);
+  is(point.y, 50);
+
+  SimpleTest.finish();
+}
+
+window.addEventListener("load", run, false);
+]]>
+</script>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=643419">Mozilla Bug 643419</a>
+<p id="display"></p>
+<div id="content">
+
+  <svg xmlns="http://www.w3.org/2000/svg" width="750">
+    <defs>
+      <path id="p1" d="M 0 50 h 400"/>
+    </defs>
+  </svg>
+
+</div>
+<pre id="test">
+</pre>
+</body>
+</html>
--- a/content/xbl/src/nsXBLService.cpp
+++ b/content/xbl/src/nsXBLService.cpp
@@ -877,17 +877,17 @@ nsXBLService::GetBinding(nsIContent* aBo
   if (!docInfo)
     return NS_ERROR_FAILURE;
 
   // Get our doc info and determine our script access.
   nsCOMPtr<nsIDocument> doc = docInfo->GetDocument();
 
   nsXBLPrototypeBinding* protoBinding = docInfo->GetPrototypeBinding(ref);
 
-  NS_ASSERTION(protoBinding, "Unable to locate an XBL binding.");
+  NS_WARN_IF_FALSE(protoBinding, "Unable to locate an XBL binding");
   if (!protoBinding)
     return NS_ERROR_FAILURE;
 
   NS_ENSURE_TRUE(aDontExtendURIs.AppendElement(protoBinding->BindingURI()),
                  NS_ERROR_OUT_OF_MEMORY);
   nsCOMPtr<nsIURI> altBindingURI = protoBinding->AlternateBindingURI();
   if (altBindingURI) {
     NS_ENSURE_TRUE(aDontExtendURIs.AppendElement(altBindingURI),
--- a/content/xml/document/src/nsXMLPrettyPrinter.cpp
+++ b/content/xml/document/src/nsXMLPrettyPrinter.cpp
@@ -33,20 +33,17 @@
  * 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 "nsXMLPrettyPrinter.h"
 #include "nsContentUtils.h"
-#include "nsIDOMDocumentView.h"
-#include "nsIDOMAbstractView.h"
 #include "nsIDOMCSSStyleDeclaration.h"
-#include "nsIDOMViewCSS.h"
 #include "nsIDOMDocumentXBL.h"
 #include "nsIObserver.h"
 #include "nsIXSLTProcessor.h"
 #include "nsSyncLoadService.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMDocument.h"
 #include "nsIServiceManager.h"
@@ -90,26 +87,23 @@ nsXMLPrettyPrinter::PrettyPrint(nsIDocum
     if (internalWin) {
         internalWin->GetFrameElement(getter_AddRefs(frameElem));
     }
 
     if (frameElem) {
         nsCOMPtr<nsIDOMCSSStyleDeclaration> computedStyle;
         nsCOMPtr<nsIDOMDocument> frameOwnerDoc;
         frameElem->GetOwnerDocument(getter_AddRefs(frameOwnerDoc));
-        nsCOMPtr<nsIDOMDocumentView> docView = do_QueryInterface(frameOwnerDoc);
-        if (docView) {
-            nsCOMPtr<nsIDOMAbstractView> defaultView;
-            docView->GetDefaultView(getter_AddRefs(defaultView));
-            nsCOMPtr<nsIDOMViewCSS> defaultCSSView =
-                do_QueryInterface(defaultView);
-            if (defaultCSSView) {
-                defaultCSSView->GetComputedStyle(frameElem,
-                                                 EmptyString(),
-                                                 getter_AddRefs(computedStyle));
+        if (frameOwnerDoc) {
+            nsCOMPtr<nsIDOMWindow> window;
+            frameOwnerDoc->GetDefaultView(getter_AddRefs(window));
+            if (window) {
+                window->GetComputedStyle(frameElem,
+                                         EmptyString(),
+                                         getter_AddRefs(computedStyle));
             }
         }
 
         if (computedStyle) {
             nsAutoString visibility;
             computedStyle->GetPropertyValue(NS_LITERAL_STRING("visibility"),
                                             visibility);
             if (!visibility.EqualsLiteral("visible")) {
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -1,11 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- *
- * ***** BEGIN LICENSE BLOCK *****
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
@@ -114,17 +113,16 @@
 #include "nsStyleConsts.h"
 #include "nsXPIDLString.h"
 #include "nsXULControllers.h"
 #include "nsIBoxObject.h"
 #include "nsPIBoxObject.h"
 #include "nsXULDocument.h"
 #include "nsXULPopupListener.h"
 #include "nsRuleWalker.h"
-#include "nsIDOMViewCSS.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsCSSParser.h"
 #include "nsIListBoxObject.h"
 #include "nsContentUtils.h"
 #include "nsContentList.h"
 #include "nsMutationEvent.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsPIDOMWindow.h"
--- a/dom/Makefile.in
+++ b/dom/Makefile.in
@@ -45,17 +45,16 @@ include $(DEPTH)/config/autoconf.mk
 MODULE		= dom
 DIRS = \
   interfaces/base \
   interfaces/canvas \
   interfaces/core \
   interfaces/html \
   interfaces/events \
   interfaces/stylesheets \
-  interfaces/views \
   interfaces/sidebar \
   interfaces/css \
   interfaces/traversal \
   interfaces/range \
   interfaces/xbl \
   interfaces/xpath \
   interfaces/load-save \
   interfaces/xul \
@@ -75,16 +74,17 @@ ifdef MOZ_SMIL
 DIRS += interfaces/smil
 endif
 
 DIRS += \
   public/coreEvents \
   base \
   src \
   locales \
+  plugins/base \
   plugins/ipc \
   indexedDB \
   system \
   ipc \
   $(NULL)
 
 ifdef ENABLE_TESTS
 DIRS += tests
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -187,17 +187,16 @@
 #include "nsDOMCSSAttrDeclaration.h"
 
 // XBL related includes.
 #include "nsIXBLService.h"
 #include "nsXBLBinding.h"
 #include "nsBindingManager.h"
 #include "nsIFrame.h"
 #include "nsIPresShell.h"
-#include "nsIDOMViewCSS.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsStyleSet.h"
 #include "nsStyleContext.h"
 #include "nsAutoPtr.h"
 #include "nsMemory.h"
 
 // Tranformiix
@@ -248,17 +247,16 @@
 #include "nsIDOMTransitionEvent.h"
 #ifdef MOZ_CSS_ANIMATIONS
 #include "nsIDOMAnimationEvent.h"
 #endif
 #include "nsIDOMNSDocumentStyle.h"
 #include "nsIDOMDocumentRange.h"
 #include "nsIDOMDocumentTraversal.h"
 #include "nsIDOMDocumentXBL.h"
-#include "nsIDOMDocumentView.h"
 #include "nsIDOMElementCSSInlineStyle.h"
 #include "nsIDOMLinkStyle.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMNSHTMLDocument.h"
 #include "nsIDOMHTMLElement.h"
 #include "nsIDOMNSHTMLElement.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsIDOMHTMLAppletElement.h"
@@ -333,17 +331,17 @@
 #ifdef MOZ_CSS_ANIMATIONS
 #include "nsIDOMMozCSSKeyframeRule.h"
 #include "nsIDOMMozCSSKeyframesRule.h"
 #endif
 #include "nsIDOMCSSPrimitiveValue.h"
 #include "nsIDOMCSSStyleRule.h"
 #include "nsIDOMCSSStyleSheet.h"
 #include "nsDOMCSSValueList.h"
-#include "nsIDOMOrientationEvent.h"
+#include "nsIDOMDeviceOrientationEvent.h"
 #include "nsIDOMRange.h"
 #include "nsIDOMNSRange.h"
 #include "nsIDOMRangeException.h"
 #include "nsIDOMNodeIterator.h"
 #include "nsIDOMTreeWalker.h"
 #include "nsIDOMXULDocument.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDOMXULCommandDispatcher.h"
@@ -743,17 +741,17 @@ static nsDOMClassInfoData sClassInfoData
   NS_DEFINE_CLASSINFO_DATA(MouseScrollEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(DragEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(KeyboardEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(PopupBlockedEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
-  NS_DEFINE_CLASSINFO_DATA(OrientationEvent, nsDOMGenericSH,
+  NS_DEFINE_CLASSINFO_DATA(DeviceOrientationEvent, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
   // Misc HTML classes
   NS_DEFINE_CLASSINFO_DATA(HTMLDocument, nsHTMLDocumentSH,
                            DOCUMENT_SCRIPTABLE_FLAGS)
   NS_DEFINE_CLASSINFO_DATA(HTMLOptionsCollection,
                            nsHTMLOptionsCollectionSH,
                            ARRAY_SCRIPTABLE_FLAGS |
@@ -2298,17 +2296,16 @@ nsDOMClassInfo::RegisterExternalClasses(
     d.mInterfaces = interface_list;                                           \
   }
 
 #define DOM_CLASSINFO_DOCUMENT_MAP_ENTRIES                                    \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSDocument)                                 \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentEvent)                              \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentStyle)                              \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSDocumentStyle)                            \
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentView)                               \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentRange)                              \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentTraversal)                          \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDocumentXBL)                                \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)                              \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)                                \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOM3Node)                                      \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMXPathEvaluator)                             \
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNodeSelector)
@@ -2375,31 +2372,27 @@ nsDOMClassInfo::Init()
 
   if (nsGlobalWindow::HasIndexedDBSupport()) {
     DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
-      DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
-      DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
     DOM_CLASSINFO_MAP_END
   } else {
     DOM_CLASSINFO_MAP_BEGIN(Window, nsIDOMWindow)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
-      DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
-      DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
       DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
     DOM_CLASSINFO_MAP_END
   }
 
   DOM_CLASSINFO_MAP_BEGIN(WindowUtils, nsIDOMWindowUtils)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowUtils)
   DOM_CLASSINFO_MAP_END
@@ -2569,18 +2562,18 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(PopupBlockedEvent, nsIDOMPopupBlockedEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMPopupBlockedEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
-  DOM_CLASSINFO_MAP_BEGIN(OrientationEvent, nsIDOMOrientationEvent)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMOrientationEvent)
+  DOM_CLASSINFO_MAP_BEGIN(DeviceOrientationEvent, nsIDOMDeviceOrientationEvent)
+    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDeviceOrientationEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(SmartCardEvent, nsIDOMSmartCardEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMSmartCardEvent)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(PageTransitionEvent, nsIDOMPageTransitionEvent)
@@ -3123,18 +3116,16 @@ nsDOMClassInfo::Init()
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMChromeWindow)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(RangeException, nsIDOMRangeException)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMRangeException)
     DOM_CLASSINFO_MAP_ENTRY(nsIException)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ContentList, nsIDOMHTMLCollection)
@@ -4018,18 +4009,16 @@ nsDOMClassInfo::Init()
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ModalContentWindow, nsIDOMWindow)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindow)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSWindow)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMWindowInternal)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSEventTarget)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMViewCSS)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMAbstractView)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageWindow)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMStorageIndexedDB)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMModalContentWindow)
   DOM_CLASSINFO_MAP_END
 
   DOM_CLASSINFO_MAP_BEGIN(DataContainerEvent, nsIDOMDataContainerEvent)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMDataContainerEvent)
     DOM_CLASSINFO_EVENT_MAP_ENTRIES
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -71,17 +71,17 @@ DOMCI_CLASS(NamedNodeMap)
 DOMCI_CLASS(Event)
 DOMCI_CLASS(MutationEvent)
 DOMCI_CLASS(UIEvent)
 DOMCI_CLASS(MouseEvent)
 DOMCI_CLASS(MouseScrollEvent)
 DOMCI_CLASS(DragEvent)
 DOMCI_CLASS(KeyboardEvent)
 DOMCI_CLASS(PopupBlockedEvent)
-DOMCI_CLASS(OrientationEvent)
+DOMCI_CLASS(DeviceOrientationEvent)
 
 // HTML classes
 DOMCI_CLASS(HTMLDocument)
 DOMCI_CLASS(HTMLOptionsCollection)
 DOMCI_CLASS(HTMLCollection)
 
 // HTML element classes
 DOMCI_CLASS(HTMLElement)
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -75,17 +75,16 @@
 #include "nsWidgetsCID.h"
 #include "nsILookAndFeel.h"
 #include "nsIWidget.h"
 #include "nsIBaseWindow.h"
 #include "nsIViewManager.h"
 #include "nsFrameSelection.h"
 #include "nsXULPopupManager.h"
 #include "nsImageMapUtils.h"
-#include "nsTreeWalker.h"
 #include "nsIDOMNodeFilter.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIPrincipal.h"
 #include "mozilla/dom/Element.h"
 #include "mozAutoDocUpdate.h"
 
 #ifdef MOZ_XUL
 #include "nsIDOMXULTextboxElement.h"
@@ -2598,28 +2597,22 @@ nsFocusManager::GetNextTabbableContent(n
     nsIFrame* startFrame = iterStartContent->GetPrimaryFrame();
     // if there is no frame, look for another content node that has a frame
     if (!startFrame) {
       // if the root content doesn't have a frame, just return
       if (iterStartContent == aRootContent)
         return NS_OK;
 
       // look for the next or previous content node in tree order
-      nsTreeWalker walker(aRootContent, nsIDOMNodeFilter::SHOW_ALL, nsnull, PR_TRUE);
-      nsCOMPtr<nsIDOMNode> nextNode = do_QueryInterface(iterStartContent);
-      walker.SetCurrentNode(nextNode);
-      if (NS_SUCCEEDED(aForward ? walker.NextNode(getter_AddRefs(nextNode)) :
-                                  walker.PreviousNode(getter_AddRefs(nextNode)))) {
-        iterStartContent = do_QueryInterface(nextNode);
-        // we've already skipped over the initial focused content, so we
-        // don't want to traverse frames.
-        getNextFrame = PR_FALSE;
-        if (iterStartContent)
-          continue;
-      }
+      iterStartContent = aForward ? iterStartContent->GetNextNode() : iterStartContent->GetPreviousContent();
+      // we've already skipped over the initial focused content, so we
+      // don't want to traverse frames.
+      getNextFrame = PR_FALSE;
+      if (iterStartContent)
+        continue;
 
       // otherwise, as a last attempt, just look at the root content
       iterStartContent = aRootContent;
       continue;
     }
 
     nsCOMPtr<nsIFrameEnumerator> frameTraversal;
     nsresult rv = NS_NewFrameTraversal(getter_AddRefs(frameTraversal),
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -106,17 +106,16 @@
 #include "nsIHTMLDocument.h"
 #include "nsIDOMHTMLDocument.h"
 #include "nsIDOMHTMLElement.h"
 #ifndef MOZ_DISABLE_DOMCRYPTO
 #include "nsIDOMCrypto.h"
 #endif
 #include "nsIDOMDocument.h"
 #include "nsIDOMNSDocument.h"
-#include "nsIDOMDocumentView.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMDocumentEvent.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIDOMMessageEvent.h"
 #include "nsIDOMPopupBlockedEvent.h"
 #include "nsIDOMPopStateEvent.h"
@@ -1329,18 +1328,16 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsIDOMJSWindow)
   NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject)
   NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
   NS_INTERFACE_MAP_ENTRY(nsPIDOMEventTarget)
   NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
   NS_INTERFACE_MAP_ENTRY(nsIDOM3EventTarget)
   NS_INTERFACE_MAP_ENTRY(nsIDOMNSEventTarget)
   NS_INTERFACE_MAP_ENTRY(nsPIDOMWindow)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMViewCSS)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMAbstractView)
   NS_INTERFACE_MAP_ENTRY(nsIDOMStorageWindow)
   NS_INTERFACE_MAP_ENTRY(nsIDOMStorageIndexedDB)
   NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
   NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
   NS_INTERFACE_MAP_ENTRY(nsIDOMWindow_2_0_BRANCH)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Window)
   OUTER_WINDOW_ONLY
     NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
@@ -7883,20 +7880,16 @@ nsGlobalWindow::UpdateCanvasFocus(PRBool
           nsCanvasFrame* canvasFrame = FindCanvasFrame(frame);
           if (canvasFrame) {
               canvasFrame->SetHasFocus(PR_FALSE);
           }
       }      
   }
 }
 
-//*****************************************************************************
-// nsGlobalWindow::nsIDOMViewCSS
-//*****************************************************************************
-
 NS_IMETHODIMP
 nsGlobalWindow::GetComputedStyle(nsIDOMElement* aElt,
                                  const nsAString& aPseudoElt,
                                  nsIDOMCSSStyleDeclaration** aReturn)
 {
   FORWARD_TO_OUTER(GetComputedStyle, (aElt, aPseudoElt, aReturn),
                    NS_ERROR_NOT_INITIALIZED);
 
@@ -7924,37 +7917,16 @@ nsGlobalWindow::GetComputedStyle(nsIDOME
   NS_ENSURE_SUCCESS(rv, rv);
 
   *aReturn = compStyle.forget().get();
 
   return NS_OK;
 }
 
 //*****************************************************************************
-// nsGlobalWindow::nsIDOMAbstractView
-//*****************************************************************************
-
-NS_IMETHODIMP
-nsGlobalWindow::GetDocument(nsIDOMDocumentView ** aDocumentView)
-{
-  NS_ENSURE_ARG_POINTER(aDocumentView);
-
-  nsresult rv = NS_OK;
-
-  if (mDocument) {
-    rv = CallQueryInterface(mDocument, aDocumentView);
-  }
-  else {
-    *aDocumentView = nsnull;
-  }
-
-  return rv;
-}
-
-//*****************************************************************************
 // nsGlobalWindow::nsIDOMStorageWindow
 //*****************************************************************************
 
 NS_IMETHODIMP
 nsGlobalWindow::GetSessionStorage(nsIDOMStorage ** aSessionStorage)
 {
   FORWARD_TO_INNER(GetSessionStorage, (aSessionStorage), NS_ERROR_UNEXPECTED);
 
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -57,17 +57,16 @@
 
 // Interfaces Needed
 #include "nsDOMWindowList.h"
 #include "nsIBaseWindow.h"
 #include "nsIBrowserDOMWindow.h"
 #include "nsIDocShellTreeOwner.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDOMClientInformation.h"
-#include "nsIDOMViewCSS.h"
 #include "nsIDOMEventTarget.h"
 #include "nsIDOM3EventTarget.h"
 #include "nsIDOMNSEventTarget.h"
 #include "nsIDOMNavigator.h"
 #include "nsIDOMNavigatorGeolocation.h"
 #include "nsIDOMNavigatorDesktopNotification.h"
 #include "nsIDOMLocation.h"
 #include "nsIDOMWindowInternal.h"
@@ -275,17 +274,16 @@ JSObject *NS_NewOuterWindowProxy(JSConte
 class nsGlobalWindow : public nsPIDOMWindow,
                        public nsIScriptGlobalObject,
                        public nsIDOMJSWindow,
                        public nsIScriptObjectPrincipal,
                        public nsIDOMEventTarget,
                        public nsPIDOMEventTarget,
                        public nsIDOM3EventTarget,
                        public nsIDOMNSEventTarget,
-                       public nsIDOMViewCSS,
                        public nsIDOMStorageWindow,
                        public nsIDOMStorageIndexedDB,
                        public nsSupportsWeakReference,
                        public nsIInterfaceRequestor,
                        public nsIDOMWindow_2_0_BRANCH,
                        public nsWrapperCache,
                        public PRCListStr
 {
@@ -414,22 +412,16 @@ public:
 
   virtual NS_HIDDEN_(PRBool) CanClose();
   virtual NS_HIDDEN_(nsresult) ForceClose();
 
   virtual NS_HIDDEN_(void) SetHasOrientationEventListener();
   virtual NS_HIDDEN_(void) MaybeUpdateTouchState();
   virtual NS_HIDDEN_(void) UpdateTouchState();
 
-  // nsIDOMViewCSS
-  NS_DECL_NSIDOMVIEWCSS
-
-  // nsIDOMAbstractView
-  NS_DECL_NSIDOMABSTRACTVIEW
-
   // nsIDOMStorageWindow
   NS_DECL_NSIDOMSTORAGEWINDOW
 
   // nsIInterfaceRequestor
   NS_DECL_NSIINTERFACEREQUESTOR
 
   // Object Management
   nsGlobalWindow(nsGlobalWindow *aOuterWindow);
--- a/dom/base/nsJSEnvironment.cpp
+++ b/dom/base/nsJSEnvironment.cpp
@@ -118,21 +118,19 @@
 
 const size_t gStackSize = 8192;
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo* gJSDiagnostics;
 #endif
 
 // Thank you Microsoft!
-#ifndef WINCE
 #ifdef CompareString
 #undef CompareString
 #endif
-#endif // WINCE
 
 // The amount of time we wait between a request to GC (due to leaving
 // a page) and doing the actual GC.
 #define NS_GC_DELAY                 4000 // ms
 
 // The amount of time we wait from the first request to GC to actually
 // doing the first GC.
 #define NS_FIRST_GC_DELAY           10000 // ms
--- a/dom/indexedDB/CheckPermissionsHelper.cpp
+++ b/dom/indexedDB/CheckPermissionsHelper.cpp
@@ -115,17 +115,22 @@ CheckPermissionsHelper::Run()
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   PRUint32 permission = mHasPrompted ?
                         mPromptResult :
                         GetIndexedDBPermissions(mASCIIOrigin, mWindow);
 
   nsresult rv;
   if (mHasPrompted) {
-    if (permission != nsIPermissionManager::UNKNOWN_ACTION) {
+    // Add permissions to the database, but only if we are in the parent
+    // process (if we are in the child process, we have already
+    // set the permission when the prompt was shown in the parent, as
+    // we cannot set the permission from the child).
+    if (permission != nsIPermissionManager::UNKNOWN_ACTION &&
+        XRE_GetProcessType() == GeckoProcessType_Default) {
       nsCOMPtr<nsIURI> uri;
       rv = NS_NewURI(getter_AddRefs(uri), mASCIIOrigin);
       NS_ENSURE_SUCCESS(rv, rv);
   
       nsCOMPtr<nsIPermissionManager> permissionManager =
         do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
       NS_ENSURE_STATE(permissionManager);
   
--- a/dom/indexedDB/CheckQuotaHelper.cpp
+++ b/dom/indexedDB/CheckQuotaHelper.cpp
@@ -40,16 +40,17 @@
 #include "CheckQuotaHelper.h"
 
 #include "nsIDOMWindow.h"
 #include "nsIObserverService.h"
 #include "nsIPermissionManager.h"
 #include "nsIPrincipal.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIURI.h"
+#include "nsXULAppAPI.h"
 
 #include "nsContentUtils.h"
 #include "nsNetUtil.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Services.h"
 
 #include "IDBFactory.h"
 
@@ -175,17 +176,22 @@ CheckQuotaHelper::Run()
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (!mHasPrompted) {
     mPromptResult = GetQuotaPermissions(mOrigin, mWindow);
   }
 
   nsresult rv;
   if (mHasPrompted) {
-    if (mPromptResult != nsIPermissionManager::UNKNOWN_ACTION) {
+    // Add permissions to the database, but only if we are in the parent
+    // process (if we are in the child process, we have already
+    // set the permission when the prompt was shown in the parent, as
+    // we cannot set the permission from the child).
+    if (mPromptResult != nsIPermissionManager::UNKNOWN_ACTION &&
+        XRE_GetProcessType() == GeckoProcessType_Default) {
       nsCOMPtr<nsIURI> uri;
       rv = NS_NewURI(getter_AddRefs(uri), mOrigin);
       NS_ENSURE_SUCCESS(rv, rv);
   
       nsCOMPtr<nsIPermissionManager> permissionManager =
         do_GetService(NS_PERMISSIONMANAGER_CONTRACTID);
       NS_ENSURE_STATE(permissionManager);
   
--- a/dom/indexedDB/IDBFactory.cpp
+++ b/dom/indexedDB/IDBFactory.cpp
@@ -32,55 +32,62 @@
  * 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 "base/basictypes.h"
+
 #include "IDBFactory.h"
 
 #include "nsILocalFile.h"
 #include "nsIScriptContext.h"
 
 #include "mozilla/storage.h"
+#include "mozilla/dom/ContentChild.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsComponentManagerUtils.h"
 #include "nsContentUtils.h"
 #include "nsDirectoryServiceUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsEscape.h"
 #include "nsHashKeys.h"
 #include "nsPIDOMWindow.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "nsXPCOMCID.h"
+#include "nsXULAppAPI.h"
 
 #include "AsyncConnectionHelper.h"
 #include "CheckPermissionsHelper.h"
 #include "DatabaseInfo.h"
 #include "IDBDatabase.h"
 #include "IDBKeyRange.h"
 #include "IndexedDatabaseManager.h"
 #include "LazyIdleThread.h"
+#include "nsIObserverService.h"
 
 #define PREF_INDEXEDDB_QUOTA "dom.indexedDB.warningQuota"
 
 // megabytes
 #define DEFAULT_QUOTA 50
 
 #define BAD_TLS_INDEX (PRUintn)-1
 
 #define DB_SCHEMA_VERSION 4
 
 USING_INDEXEDDB_NAMESPACE
 
 namespace {
 
+GeckoProcessType gAllowedProcessType = GeckoProcessType_Invalid;
+
 PRUintn gCurrentDatabaseIndex = BAD_TLS_INDEX;
 
 PRInt32 gIndexedDBQuota = DEFAULT_QUOTA;
 
 class QuotaCallback : public mozIStorageQuotaCallback
 {
 public:
   NS_DECL_ISUPPORTS
@@ -352,22 +359,17 @@ CreateDatabaseConnection(const nsACStrin
                          mozIStorageConnection** aConnection)
 {
   NS_ASSERTION(!NS_IsMainThread(), "Wrong thread!");
   NS_ASSERTION(!aASCIIOrigin.IsEmpty() && !aName.IsEmpty(), "Bad arguments!");
 
   aDatabaseFilePath.Truncate();
 
   nsCOMPtr<nsIFile> dbDirectory;
-  nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
-                                       getter_AddRefs(dbDirectory));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = dbDirectory->Append(NS_LITERAL_STRING("indexedDB"));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsresult rv = IDBFactory::GetDirectory(getter_AddRefs(dbDirectory));
 
   PRBool exists;
   rv = dbDirectory->Exists(&exists);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (exists) {
     PRBool isDirectory;
     rv = dbDirectory->IsDirectory(&isDirectory);
@@ -504,16 +506,21 @@ CreateDatabaseConnection(const nsACStrin
   NS_ENSURE_SUCCESS(rv, rv);
 
   connection.forget(aConnection);
   return NS_OK;
 }
 
 } // anonyomous namespace
 
+IDBFactory::IDBFactory()
+{
+  IDBFactory::NoteUsedByProcessType(XRE_GetProcessType());
+}
+
 // static
 already_AddRefed<nsIIDBFactory>
 IDBFactory::Create(nsPIDOMWindow* aWindow)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   NS_ASSERTION(aWindow, "Must have a window!");
 
   if (aWindow->IsOuterWindow()) {
@@ -616,26 +623,54 @@ IDBFactory::SetCurrentDatabase(IDBDataba
 // static
 PRUint32
 IDBFactory::GetIndexedDBQuota()
 {
   return PRUint32(PR_MAX(gIndexedDBQuota, 0));
 }
 
 // static
+void
+IDBFactory::NoteUsedByProcessType(GeckoProcessType aProcessType)
+{
+  if (gAllowedProcessType == GeckoProcessType_Invalid) {
+    gAllowedProcessType = aProcessType;
+  } else if (aProcessType != gAllowedProcessType) {
+    NS_RUNTIMEABORT("More than one process type is accessing IndexedDB!");
+  }
+}
+
+// static
+nsresult
+IDBFactory::GetDirectory(nsIFile** aDirectory)
+{
+  nsresult rv;
+  if (XRE_GetProcessType() == GeckoProcessType_Default) {
+    rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, aDirectory);
+    NS_ENSURE_SUCCESS(rv, rv);
+    rv = (*aDirectory)->Append(NS_LITERAL_STRING("indexedDB"));
+    NS_ENSURE_SUCCESS(rv, rv);
+  } else {
+    nsCOMPtr<nsILocalFile> localDirectory =
+      do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
+    rv = localDirectory->InitWithPath(
+      ContentChild::GetSingleton()->GetIndexedDBPath());
+    NS_ENSURE_SUCCESS(rv, rv);
+    localDirectory.forget((nsILocalFile**)aDirectory);
+  }
+  return NS_OK;
+}
+
+// static
 nsresult
 IDBFactory::GetDirectoryForOrigin(const nsACString& aASCIIOrigin,
                                   nsIFile** aDirectory)
 {
   nsCOMPtr<nsIFile> directory;
-  nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR,
-                                       getter_AddRefs(directory));
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = directory->Append(NS_LITERAL_STRING("indexedDB"));
+  nsresult rv = GetDirectory(getter_AddRefs(directory));
   NS_ENSURE_SUCCESS(rv, rv);
 
   NS_ConvertASCIItoUTF16 originSanitized(aASCIIOrigin);
   originSanitized.ReplaceChar(":/", '+');
 
   rv = directory->Append(originSanitized);
   NS_ENSURE_SUCCESS(rv, rv);
 
@@ -815,16 +850,24 @@ DOMCI_DATA(IDBFactory, IDBFactory)
 
 NS_IMETHODIMP
 IDBFactory::Open(const nsAString& aName,
                  JSContext* aCx,
                  nsIIDBRequest** _retval)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
+  if (XRE_GetProcessType() == GeckoProcessType_Content) {
+    // Force ContentChild to cache the path from the parent, so that
+    // we do not end up in a side thread that asks for the path (which
+    // would make ContentChild try to send a message in a thread other
+    // than the main one).
+    ContentChild::GetSingleton()->GetIndexedDBPath();
+  }
+
   if (aName.IsEmpty()) {
     return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
   }
 
   nsCOMPtr<nsPIDOMWindow> window = do_QueryReferent(mWindow);
   NS_ENSURE_TRUE(window, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
 
   nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(window);
--- a/dom/indexedDB/IDBFactory.h
+++ b/dom/indexedDB/IDBFactory.h
@@ -41,16 +41,17 @@
 #define mozilla_dom_indexeddb_idbfactory_h__
 
 #include "mozilla/dom/indexedDB/IndexedDatabase.h"
 
 #include "mozIStorageConnection.h"
 #include "nsIIDBFactory.h"
 
 #include "nsIWeakReferenceUtils.h"
+#include "nsXULAppAPI.h"
 
 class nsPIDOMWindow;
 
 BEGIN_INDEXEDDB_NAMESPACE
 
 struct DatabaseInfo;
 class IDBDatabase;
 struct ObjectStoreInfo;
@@ -68,33 +69,43 @@ public:
   GetConnection(const nsAString& aDatabaseFilePath);
 
   static bool
   SetCurrentDatabase(IDBDatabase* aDatabase);
 
   static PRUint32
   GetIndexedDBQuota();
 
+  // Called when a process uses an IndexedDB factory. We only allow
+  // a single process type to use IndexedDB - the chrome/single process
+  // in Firefox, and the child process in Fennec - so access by more
+  // than one process type is a very serious error.
+  static void
+  NoteUsedByProcessType(GeckoProcessType aProcessType);
+
+  static nsresult
+  GetDirectory(nsIFile** aDirectory);
+
   static nsresult
   GetDirectoryForOrigin(const nsACString& aASCIIOrigin,
                         nsIFile** aDirectory);
 
   static nsresult
   LoadDatabaseInformation(mozIStorageConnection* aConnection,
                           PRUint32 aDatabaseId,
                           nsAString& aVersion,
                           ObjectStoreInfoArray& aObjectStores);
 
   static nsresult
   UpdateDatabaseMetadata(DatabaseInfo* aDatabaseInfo,
                          const nsAString& aVersion,
                          ObjectStoreInfoArray& aObjectStores);
 
 private:
-  IDBFactory() { }
+  IDBFactory();
   ~IDBFactory() { }
 
   nsCOMPtr<nsIWeakReference> mWindow;
 };
 
 END_INDEXEDDB_NAMESPACE
 
 #endif // mozilla_dom_indexeddb_idbfactory_h__
--- a/dom/indexedDB/Makefile.in
+++ b/dom/indexedDB/Makefile.in
@@ -113,9 +113,11 @@ XPIDLSRCS = \
   nsIIDBVersionChangeRequest.idl \
   nsIIndexedDatabaseManager.idl \
   $(NULL)
 
 ifdef ENABLE_TESTS
 DIRS += test
 endif
 
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -72,20 +72,16 @@ interface DOMException;
 interface RangeException;
 
 // Style Sheets
 interface nsIDOMStyleSheetList;
 interface nsIDOMLinkStyle;
 interface nsIDOMStyleSheet;
 interface nsIDOMMediaList;
 
-// Views
-interface nsIDOMAbstractView;
-interface nsIDOMDocumentView;
-
 // Base
 interface nsIDOMWindow;
 interface nsIDOMWindowInternal;
 interface nsIDOMWindowCollection;
 interface nsIDOMPlugin;
 interface nsIDOMPluginArray;
 interface nsIDOMMimeType;
 interface nsIDOMMimeTypeArray;
@@ -125,9 +121,8 @@ interface nsIDOMHTMLTableSectionElement;
 
 // Range
 interface nsIDOMRange;
 
 // Crypto
 interface nsIDOMCRMFObject;
 interface nsIDOMCrypto;
 interface nsIDOMPkcs11;
-
--- a/dom/interfaces/base/nsIDOMWindow.idl
+++ b/dom/interfaces/base/nsIDOMWindow.idl
@@ -42,21 +42,20 @@
 interface nsISelection;
 
 /**
  * The nsIDOMWindow interface is the primary interface for a DOM
  * window object. It represents a single window object that may
  * contain child windows if the document in the window contains a
  * HTML frameset document or if the document contains iframe elements.
  *
- * This interface is not officially defined by any standard bodies, it
- * originates from the defacto DOM Level 0 standard.
+ * @see <http://www.whatwg.org/html/#window>
  */
 
-[scriptable, uuid(a6cf906b-15b3-11d2-932e-00805f8add32)]
+[scriptable, uuid(ff7d278f-93db-4078-b89a-058c8e1270b4)]
 interface nsIDOMWindow : nsISupports
 {
   /**
    * Accessor for the document in this window.
    */
   readonly attribute nsIDOMDocument                     document;
 
   /**
@@ -145,9 +144,15 @@ interface nsIDOMWindow : nsISupports
    * Method for scrolling this window by a number of pages.
    */
   void                      scrollByPages(in long numPages);
 
   /**
    * Method for sizing this window to the content in the window.
    */
   void                      sizeToContent();
+
+  /**
+   * @see <http://dev.w3.org/csswg/cssom/#dom-window-getcomputedstyle>
+   */
+  nsIDOMCSSStyleDeclaration getComputedStyle(in nsIDOMElement elt, 
+                                             [optional] in DOMString pseudoElt);
 };
--- a/dom/interfaces/base/nsIDOMWindow2.idl
+++ b/dom/interfaces/base/nsIDOMWindow2.idl
@@ -35,17 +35,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMWindow.idl"
 
 interface nsIDOMOfflineResourceList;
 interface nsIDOMBlob;
 
-[scriptable, uuid(efff0d88-3b94-4375-bdeb-676a847ecd7d)]
+[scriptable, uuid(e2796e00-14de-4ce0-acfe-0374bc0e715d)]
 interface nsIDOMWindow2 : nsIDOMWindow
 {
   /**
    * Get the window root for this window. This is useful for hooking
    * up event listeners to this window and every other window nested
    * in the window root.
    */
   [noscript] readonly attribute nsIDOMEventTarget windowRoot;
--- a/dom/interfaces/base/nsIDOMWindowInternal.idl
+++ b/dom/interfaces/base/nsIDOMWindowInternal.idl
@@ -41,17 +41,17 @@
 
 interface nsIPrompt;
 interface nsIControllers;
 interface nsIDOMLocation;
 interface nsIVariant;
 interface nsIAnimationFrameListener;
 interface nsIDOMMediaQueryList;
 
-[scriptable, uuid(04eafa93-efbe-4254-9d65-91c344fa7ff2)]
+[scriptable, uuid(4d95736f-8130-43cb-a276-5bc554eca80a)]
 interface nsIDOMWindowInternal : nsIDOMWindow2
 {
   readonly attribute nsIDOMWindowInternal        window;
 
   /* [replaceable] self */
   readonly attribute nsIDOMWindowInternal        self;
 
   readonly attribute nsIDOMNavigator             navigator;
--- a/dom/interfaces/core/nsIDOMDocument.idl
+++ b/dom/interfaces/core/nsIDOMDocument.idl
@@ -47,17 +47,17 @@
  * cannot exist outside the context of a Document, the nsIDOMDocument 
  * interface also contains the factory methods needed to create these 
  * objects.
  *
  * For more information on this interface please see 
  * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
  */
 
-[scriptable, uuid(2d305b95-a030-4d24-a12c-7fabf61a8c3c)]
+[scriptable, uuid(d12f0ecf-434a-4b5c-81ad-354e3b9037b9)]
 interface nsIDOMDocument : nsIDOMNode
 {
   readonly attribute nsIDOMDocumentType         doctype;
   readonly attribute nsIDOMDOMImplementation    implementation;
   readonly attribute nsIDOMElement              documentElement;
   nsIDOMElement                 createElement(in DOMString tagName)
                                   raises(DOMException);
   nsIDOMDocumentFragment        createDocumentFragment();
@@ -103,9 +103,16 @@ interface nsIDOMDocument : nsIDOMNode
                                         // raises(DOMException) on setting
   // Introduced in DOM Level 3:
            attribute DOMString       documentURI;
   // Introduced in DOM Level 3:
   nsIDOMNode         adoptNode(in nsIDOMNode source)
                                         raises(DOMException);
   // Introduced in DOM Level 3:
   void               normalizeDocument();
+
+  /**
+   * The window associated with this document.
+   *
+   * @see http://www.whatwg.org/html/#dom-document-defaultview
+   */
+  readonly attribute nsIDOMWindow    defaultView;
 };
--- a/dom/interfaces/core/nsIDOMXMLDocument.idl
+++ b/dom/interfaces/core/nsIDOMXMLDocument.idl
@@ -33,17 +33,17 @@
  * 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 "nsIDOMDocument.idl"
 
-[scriptable, uuid(f493687c-ea80-471b-965b-11467ebea24b)]
+[scriptable, uuid(68e4448c-eb64-48ea-801a-0c83008d2607)]
 interface nsIDOMXMLDocument : nsIDOMDocument
 {
   // DOM Level 3 Load & Save, DocumentLS
   // http://www.w3.org/TR/DOM-Level-3-LS/load-save.html#LS-DocumentLS
   /**
    * Whether to load synchronously or asynchronously.
    * The default is async==true.
    */
--- a/dom/interfaces/css/Makefile.in
+++ b/dom/interfaces/css/Makefile.in
@@ -66,17 +66,16 @@ XPIDLSRCS =					\
 	nsIDOMCSSMozDocumentRule.idl		\
 	nsIDOMCSSPageRule.idl			\
 	nsIDOMCSSStyleRule.idl			\
 	nsIDOMCSSUnknownRule.idl		\
 	nsIDOMCounter.idl			\
 	nsIDOMDocumentCSS.idl			\
 	nsIDOMRGBColor.idl			\
 	nsIDOMRect.idl				\
-	nsIDOMViewCSS.idl			\
 	nsIDOMNSRGBAColor.idl			\
 	$(NULL)
 
 ifdef MOZ_CSS_ANIMATIONS
 XPIDLSRCS +=					\
 	nsIDOMMozCSSKeyframeRule.idl		\
 	nsIDOMMozCSSKeyframesRule.idl		\
 	$(NULL)
deleted file mode 100644
--- a/dom/interfaces/css/nsIDOMViewCSS.idl
+++ /dev/null
@@ -1,49 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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
- * Netscape Communications Corporation.
- * Portions created by the Initial Developer are Copyright (C) 2000
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Johnny Stenback <jst@netscape.com> (original author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of 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 "nsIDOMAbstractView.idl"
-
-[scriptable, uuid(0b9341f3-95d4-4fa4-adcd-e119e0db2889)]
-interface nsIDOMViewCSS : nsIDOMAbstractView
-{
-  /**
-   * @see <http://dev.w3.org/csswg/cssom/#dom-window-getcomputedstyle>
-   */
-  nsIDOMCSSStyleDeclaration getComputedStyle(in nsIDOMElement elt, 
-                                             [optional] in DOMString pseudoElt);
-};
--- a/dom/interfaces/events/Makefile.in
+++ b/dom/interfaces/events/Makefile.in
@@ -77,17 +77,17 @@ XPIDLSRCS =					\
 	nsIDOMMessageEvent.idl			\
 	nsIDOMNotifyPaintEvent.idl              \
 	nsIDOMNotifyAudioAvailableEvent.idl     \
 	nsIDOMPaintRequest.idl			\
 	nsIDOMPaintRequestList.idl		\
 	nsIDOMSimpleGestureEvent.idl		\
 	nsIDOMNSMouseEvent.idl			\
 	nsIDOMMozTouchEvent.idl			\
-	nsIDOMOrientationEvent.idl              \
+	nsIDOMDeviceOrientationEvent.idl			\
 	nsIDOMScrollAreaEvent.idl		\
 	nsIDOMTransitionEvent.idl		\
 	nsIDOMPopStateEvent.idl			\
 	nsIDOMCloseEvent.idl			\
 	nsIDOMEventException.idl		\
 	nsIDOMTouchEvent.idl			\
 	nsIDOMHashChangeEvent.idl		\
 	$(NULL)
new file mode 100644
--- /dev/null
+++ b/dom/interfaces/events/nsIDOMDeviceOrientationEvent.idl
@@ -0,0 +1,76 @@
+/* ***** 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
+ * Mozilla Foundation
+ * Portions created by the Initial Developer are Copyright (C) 2011
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * 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 "nsIDOMEvent.idl"
+
+[scriptable, uuid(daf2d570-0ecc-4aa0-aba4-26f60dfcba6a)]
+interface nsIDOMDeviceOrientationEvent : nsIDOMEvent
+{
+  void initDeviceOrientationEvent(in DOMString eventTypeArg,
+                                  in boolean canBubbleArg,
+                                  in boolean cancelableArg,
+                                  in double alpha,
+                                  in double beta,
+                                  in double gamma,
+                                  in boolean absolute);
+
+  /*
+   * W3C specification values: http://dev.w3.org/geo/api/spec-source-orientation.html
+   *
+   * Alpha, beta and gamma are Tait-Bryan angles (Z-X'-Y''), that is they correspond to
+   * yaw, pitch and roll in flight coordinates. More specifically, assume the device
+   * is resting face up on a flat surface (its screen is pointing straight up). Then
+   * the X axis points to the right when looking at the screen, the Y axis points up
+   * when looking at the screen, and the Z axis points toward you when looking at
+   * the screen. Alpha/beta/gamma then define the device's orientation by applying
+   * the following rotations to the device in order:
+   *
+   * 1) Rotate it by alpha degrees around its Z axis (like a compass, or like changing
+   *    the yaw of an aircraft, assuming the Y axis is the nose of the craft); alpha
+   *    is in [0,360).
+   * 2) Rotate it by beta degrees around its X axis (tilting the top of the device
+   *    towards or away from you, like pitching an aircraft); beta is in [-180,180).
+   * 3) Rotate it by gamma degrees around its Y axis (tilting it sideways, like
+   *    rolling an aircraft); gamma is in [-90,90).
+   */
+
+  readonly attribute double alpha;
+  readonly attribute double beta;
+  readonly attribute double gamma;
+  readonly attribute boolean absolute;
+  readonly attribute boolean compassCalibrated;
+};
+
--- a/dom/interfaces/events/nsIDOMDragEvent.idl
+++ b/dom/interfaces/events/nsIDOMDragEvent.idl
@@ -33,28 +33,27 @@
  * 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 "domstubs.idl"
 #include "nsIDOMMouseEvent.idl"
 
-interface nsIDOMAbstractView;
 interface nsIDOMDataTransfer;
 
-[scriptable, uuid(98351627-62d7-4b07-bbf3-78009b20764b)]
+[scriptable, uuid(0f4fef03-c0e9-406c-a754-c01148e431ae)]
 interface nsIDOMDragEvent : nsIDOMMouseEvent
 {
   readonly attribute nsIDOMDataTransfer dataTransfer;
 
   void initDragEvent(in DOMString typeArg,
                      in boolean canBubbleArg,
                      in boolean cancelableArg,
-                     in nsIDOMAbstractView aView,
+                     in nsIDOMWindow aView,
                      in long aDetail,
                      in long aScreenX,
                      in long aScreenY,
                      in long aClientX,
                      in long aClientY,
                      in boolean aCtrlKey,
                      in boolean aAltKey,
                      in boolean aShiftKey,
--- a/dom/interfaces/events/nsIDOMKeyEvent.idl
+++ b/dom/interfaces/events/nsIDOMKeyEvent.idl
@@ -34,17 +34,17 @@
  * 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 "nsIDOMUIEvent.idl"
 
-[scriptable, uuid(028e0e6e-8b01-11d3-aae7-0010838a3123)]
+[scriptable, uuid(e44d7977-20f2-442e-bc13-0f2f52992a4c)]
 interface nsIDOMKeyEvent : nsIDOMUIEvent
 {
   const unsigned long DOM_VK_CANCEL         = 0x03;
   const unsigned long DOM_VK_HELP           = 0x06;
   const unsigned long DOM_VK_BACK_SPACE     = 0x08;
   const unsigned long DOM_VK_TAB            = 0x09;
   const unsigned long DOM_VK_CLEAR          = 0x0C;
   const unsigned long DOM_VK_RETURN         = 0x0D;
@@ -188,16 +188,16 @@ interface nsIDOMKeyEvent : nsIDOMUIEvent
   readonly attribute boolean          altKey;
   readonly attribute boolean          ctrlKey;
   readonly attribute boolean          shiftKey;
   readonly attribute boolean          metaKey;
 
   void                      initKeyEvent(in DOMString typeArg,
                                          in boolean canBubbleArg,
                                          in boolean cancelableArg,
-                                         in nsIDOMAbstractView viewArg,
+                                         in nsIDOMWindow viewArg,
                                          in boolean ctrlKeyArg,
                                          in boolean altKeyArg,
                                          in boolean shiftKeyArg,
                                          in boolean metaKeyArg,
                                          in unsigned long keyCodeArg,
                                          in unsigned long charCodeArg);
 };
--- a/dom/interfaces/events/nsIDOMMouseEvent.idl
+++ b/dom/interfaces/events/nsIDOMMouseEvent.idl
@@ -42,17 +42,17 @@
 /**
  * The nsIDOMMouseEvent interface is the datatype for all mouse events
  * in the Document Object Model.
  *
  * For more information on this interface please see
  * http://www.w3.org/TR/DOM-Level-2-Events/
  */
 
-[scriptable, uuid(ff751edc-8b02-aae7-0010-8301838a3123)]
+[scriptable, uuid(73558605-f479-493e-86d1-9794cd117fef)]
 interface nsIDOMMouseEvent : nsIDOMUIEvent
 {
   readonly attribute long               screenX;
   readonly attribute long               screenY;
 
   readonly attribute long               clientX;
   readonly attribute long               clientY;
 
@@ -62,17 +62,17 @@ interface nsIDOMMouseEvent : nsIDOMUIEve
   readonly attribute boolean            metaKey;
 
   readonly attribute unsigned short     button;
   readonly attribute nsIDOMEventTarget  relatedTarget;
 
   void                      initMouseEvent(in DOMString typeArg,
                                            in boolean canBubbleArg,
                                            in boolean cancelableArg,
-                                           in nsIDOMAbstractView viewArg,
+                                           in nsIDOMWindow viewArg,
                                            in long detailArg,
                                            in long screenXArg,
                                            in long screenYArg,
                                            in long clientXArg,
                                            in long clientYArg,
                                            in boolean ctrlKeyArg,
                                            in boolean altKeyArg,
                                            in boolean shiftKeyArg,
--- a/dom/interfaces/events/nsIDOMMouseScrollEvent.idl
+++ b/dom/interfaces/events/nsIDOMMouseScrollEvent.idl
@@ -33,28 +33,28 @@
  * 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 "nsIDOMMouseEvent.idl"
 
-[scriptable, uuid(ba8d1a7e-b475-4542-8d32-01e7ea7b8091)]
+[scriptable, uuid(af08bce0-6821-4bac-8964-0fcee4be549a)]
 interface nsIDOMMouseScrollEvent : nsIDOMMouseEvent
 {
   const long HORIZONTAL_AXIS = 1;
   const long VERTICAL_AXIS = 2;
 
   readonly attribute long axis;
 
   void                initMouseScrollEvent(in DOMString typeArg,
                                            in boolean canBubbleArg,
                                            in boolean cancelableArg,
-                                           in nsIDOMAbstractView viewArg,
+                                           in nsIDOMWindow viewArg,
                                            in long detailArg,
                                            in long screenXArg,
                                            in long screenYArg,
                                            in long clientXArg,
                                            in long clientYArg,
                                            in boolean ctrlKeyArg,
                                            in boolean altKeyArg,
                                            in boolean shiftKeyArg,
--- a/dom/interfaces/events/nsIDOMMozTouchEvent.idl
+++ b/dom/interfaces/events/nsIDOMMozTouchEvent.idl
@@ -35,25 +35,25 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 
 #include "nsIDOMMouseEvent.idl"
 
 
-[scriptable, uuid(9b454391-0190-4313-a070-1e26e9bf6f31)]
+[scriptable, uuid(e9ed248b-1995-482f-8407-33ae7744bb9c)]
 interface nsIDOMMozTouchEvent : nsIDOMMouseEvent
 {
   readonly attribute unsigned long streamId;
 
   void initMozTouchEvent(in DOMString typeArg,
                          in boolean canBubbleArg,
                          in boolean cancelableArg,
-                         in nsIDOMAbstractView viewArg,
+                         in nsIDOMWindow viewArg,
                          in long detailArg,
                          in long screenXArg,
                          in long screenYArg,
                          in long clientXArg,
                          in long clientYArg,
                          in boolean ctrlKeyArg,
                          in boolean altKeyArg,
                          in boolean shiftKeyArg,
--- a/dom/interfaces/events/nsIDOMNSMouseEvent.idl
+++ b/dom/interfaces/events/nsIDOMNSMouseEvent.idl
@@ -38,17 +38,17 @@
 
 #include "nsIDOMMouseEvent.idl"
 
 /**
  * The nsIDOMNSMouseEvent interface extends nsIDOMMouseEvent
  * by providing various information related to the mouse event.
  */
 
-[scriptable, uuid(f5dd5fbb-f4ff-4277-819c-f31aa1dafc32)]
+[scriptable, uuid(8418a402-3c9b-431a-80a7-a59b23ed57a0)]
 interface nsIDOMNSMouseEvent : nsIDOMMouseEvent
 {
   // Finger or touch pressure event value
   // ranges between 0.0 and 1.0
   readonly attribute float mozPressure;
 
   const unsigned short    MOZ_SOURCE_UNKNOWN    = 0;
   const unsigned short    MOZ_SOURCE_MOUSE      = 1;
@@ -58,17 +58,17 @@ interface nsIDOMNSMouseEvent : nsIDOMMou
   const unsigned short    MOZ_SOURCE_TOUCH      = 5;
   const unsigned short    MOZ_SOURCE_KEYBOARD   = 6;
 
   readonly attribute unsigned short mozInputSource;
 
   void                initNSMouseEvent(in DOMString typeArg,
                                        in boolean canBubbleArg,
                                        in boolean cancelableArg,
-                                       in nsIDOMAbstractView viewArg,
+                                       in nsIDOMWindow viewArg,
                                        in long detailArg,
                                        in long screenXArg,
                                        in long screenYArg,
                                        in long clientXArg,
                                        in long clientYArg,
                                        in boolean ctrlKeyArg,
                                        in boolean altKeyArg,
                                        in boolean shiftKeyArg,
deleted file mode 100644
--- a/dom/interfaces/events/nsIDOMOrientationEvent.idl
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * Doug Turner <dougt@dougt.org>
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *
- * 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 "nsIDOMEvent.idl"
-
-[scriptable, uuid(1618546a-c176-40a2-9086-2d973acceeb1)]
-interface nsIDOMOrientationEvent : nsIDOMEvent
-{
-  void                      initOrientationEvent(in DOMString eventTypeArg,
-                                                 in boolean canBubbleArg,
-                                                 in boolean cancelableArg,
-                                                 in double x,
-                                                 in double y,
-                                                 in double z);
-  /*
-   * Axis values are between -1 to 1 where 0 is the balance point.
-   *
-   * For example, x = 0 would mean that the device, along the x axis, is parallel to the earth
-   *              x decreasing would mean that the device is undergoing a counterclock-wise rotation on the x axis
-   *              x increasing would mean that the device is undergoing a clock-wise rotation on the x axis.
-   */
-
-  readonly attribute double x;
-  readonly attribute double y;
-  readonly attribute double z;
-};
--- a/dom/interfaces/events/nsIDOMScrollAreaEvent.idl
+++ b/dom/interfaces/events/nsIDOMScrollAreaEvent.idl
@@ -32,27 +32,27 @@
  * 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 "nsIDOMUIEvent.idl"
 
-[scriptable, uuid(b2f49035-4a2f-4e62-8fb0-deb68b0de4d9)]
+[scriptable, uuid(911c3352-6690-421c-9bbe-6bd34f1600dc)]
 interface nsIDOMScrollAreaEvent : nsIDOMUIEvent
 {
   // Scroll area client rect
   readonly attribute float x;
   readonly attribute float y;
   readonly attribute float width;
   readonly attribute float height;
 
   void initScrollAreaEvent(in DOMString aEventType,
                            in boolean aCanBubble,
                            in boolean aCancelable,
-                           in nsIDOMAbstractView aView,
+                           in nsIDOMWindow aView,
                            in long aDetail,
                            in float x,
                            in float y,
                            in float width,
                            in float height);
 };
--- a/dom/interfaces/events/nsIDOMSimpleGestureEvent.idl
+++ b/dom/interfaces/events/nsIDOMSimpleGestureEvent.idl
@@ -92,17 +92,17 @@
  * Default behavior:
  *
  * Some operating systems support default behaviors for gesture events
  * when they are not handled by the application. Consumers should
  * use event.preventDefault() to prevent default behavior when
  * consuming events.
  */
 
-[scriptable, uuid(cb68e879-f710-415d-a871-9a550860df01)]
+[scriptable, uuid(fe6b7df3-be7c-4a0b-99a2-da84e956e2f5)]
 interface nsIDOMSimpleGestureEvent : nsIDOMMouseEvent
 {
   /* Swipe direction constants */
   const unsigned long DIRECTION_UP = 1;
   const unsigned long DIRECTION_DOWN = 2;
   const unsigned long DIRECTION_LEFT = 4;
   const unsigned long DIRECTION_RIGHT = 8;
   
@@ -143,17 +143,17 @@ interface nsIDOMSimpleGestureEvent : nsI
    * and current/final width between the two touch points on the input
    * device and are measured in pixels.
    */
   readonly attribute double delta;
 
   void initSimpleGestureEvent(in DOMString typeArg,
                               in boolean canBubbleArg,
                               in boolean cancelableArg,
-                              in nsIDOMAbstractView viewArg,
+                              in nsIDOMWindow viewArg,
                               in long detailArg,
                               in long screenXArg,
                               in long screenYArg,
                               in long clientXArg,
                               in long clientYArg,
                               in boolean ctrlKeyArg,
                               in boolean altKeyArg,
                               in boolean shiftKeyArg,
--- a/dom/interfaces/events/nsIDOMTouchEvent.idl
+++ b/dom/interfaces/events/nsIDOMTouchEvent.idl
@@ -72,30 +72,30 @@ interface nsIDOMTouchEvent : nsIDOMUIEve
   readonly attribute nsIDOMTouchList changedTouches;
   readonly attribute boolean         altKey;
   readonly attribute boolean         metaKey;
   readonly attribute boolean         ctrlKey;
   readonly attribute boolean         shiftKey;
   void initTouchEvent(in DOMString type,
                       in boolean canBubble,
                       in boolean cancelable,
-                      in nsIDOMAbstractView view,
+                      in nsIDOMWindow view,
                       in long detail,
                       in boolean ctrlKey,
                       in boolean altKey,
                       in boolean shiftKey,
                       in boolean metaKey,
                       in nsIDOMTouchList touches,
                       in nsIDOMTouchList targetTouches,
                       in nsIDOMTouchList changedTouches);
 };
 
-[scriptable, uuid(922e0f11-28b9-4560-9fb8-869fe143845f)]
+[scriptable, uuid(804a3851-ea2e-4e5f-bedd-315f37f31ab1)]
 interface nsIDOMDocumentTouch : nsISupports {
-  nsIDOMTouch createTouch([optional] in nsIDOMAbstractView view,
+  nsIDOMTouch createTouch([optional] in nsIDOMWindow view,
                           [optional] in nsIDOMEventTarget target,
                           [optional] in long identifier,
                           [optional] in long pageX,
                           [optional] in long pageY,
                           [optional] in long screenX,
                           [optional] in long screenY,
                           [optional] in long clientX,
                           [optional] in long clientY,
--- a/dom/interfaces/events/nsIDOMUIEvent.idl
+++ b/dom/interfaces/events/nsIDOMUIEvent.idl
@@ -42,19 +42,19 @@
 /**
  * The nsIDOMUIEvent interface is the datatype for all UI events in the
  * Document Object Model.
  *
  * For more information on this interface please see
  * http://www.w3.org/TR/DOM-Level-2-Events/
  */
 
-[scriptable, uuid(a6cf90c3-15b3-11d2-932e-00805f8add32)]
+[scriptable, uuid(25f28689-3f78-47e8-8d76-15b936faf8c1)]
 interface nsIDOMUIEvent : nsIDOMEvent
 {
-  readonly attribute nsIDOMAbstractView view;
+  readonly attribute nsIDOMWindow       view;
   readonly attribute long               detail;
   void                      initUIEvent(in DOMString typeArg,
                                         in boolean canBubbleArg,
                                         in boolean cancelableArg,
-                                        in nsIDOMAbstractView viewArg,
+                                        in nsIDOMWindow viewArg,
                                         in long detailArg);
 };
--- a/dom/interfaces/html/nsIDOMHTMLDocument.idl
+++ b/dom/interfaces/html/nsIDOMHTMLDocument.idl
@@ -45,17 +45,17 @@
  *
  * This interface is trying to follow the DOM Level 2 HTML specification:
  * http://www.w3.org/TR/DOM-Level-2-HTML/
  *
  * with changes from the work-in-progress WHATWG HTML specification:
  * http://www.whatwg.org/specs/web-apps/current-work/
  */
 
-[scriptable, uuid(2d7a0f2e-6b1c-4e93-bbea-122eb0a8a513)]
+[scriptable, uuid(42bb545e-be46-4f4f-8c0a-6c948ea0c1d4)]
 interface nsIDOMHTMLDocument : nsIDOMDocument
 {
            attribute DOMString            title;
   readonly attribute DOMString            referrer;
   // domain is readonly per spec, but it's settable in
   // nsIDOMNSHTMLDocument
   [noscript] readonly attribute DOMString domain;
   readonly attribute DOMString            URL;
--- a/dom/interfaces/sidebar/nsISidebar.idl
+++ b/dom/interfaces/sidebar/nsISidebar.idl
@@ -39,26 +39,25 @@
 /*
 
   The Sidebar API for 3rd parties
 
 */
 
 #include "nsISupports.idl"
 
-[scriptable, uuid(67cf6231-c303-4f7e-b9b1-a0e87772ecfd)]
+[scriptable, uuid(41a22fb6-39e2-45e1-95c5-7e8cea36575d)]
 interface nsISidebar : nsISupports
 {
     void addPanel(in wstring aTitle, in string aContentURL,
                   in string aCustomizeURL);
     void addPersistentPanel(in wstring aTitle, in string aContentURL,
                             in string aCustomizeURL);
     void addSearchEngine(in string engineURL, in string iconURL,
                          in wstring suggestedTitle, in wstring suggestedCategory);
-    void addMicrosummaryGenerator(in string generatorURL);
 };
 
 [scriptable, uuid(4350fb73-9305-41df-a669-11d26222d420)]
 interface nsISidebarExternal : nsISupports
 {
     void AddSearchProvider(in string aDescriptionURL);
 		unsigned long IsSearchProviderInstalled(in string aSearchURL);
 };
--- a/dom/interfaces/smil/nsIDOMTimeEvent.idl
+++ b/dom/interfaces/smil/nsIDOMTimeEvent.idl
@@ -40,18 +40,18 @@
 /**
  * The SMIL TimeEvent interface.
  *
  * For more information please refer to:
  * http://www.w3.org/TR/SMIL/smil-timing.html#Events-TimeEvent
  * http://www.w3.org/TR/SVG/animate.html#InterfaceTimeEvent
  */
 
-[scriptable, uuid(0d309c26-ddbb-44cb-9af1-3008972349e3)]
+[scriptable, uuid(873785cc-d8be-48af-8b30-5c566e3f4e6e)]
 interface nsIDOMTimeEvent : nsIDOMEvent
 {
   readonly attribute long detail;
-  readonly attribute nsIDOMAbstractView view;
+  readonly attribute nsIDOMWindow view;
   
   void initTimeEvent(in DOMString typeArg,
-                     in nsIDOMAbstractView viewArg,
+                     in nsIDOMWindow viewArg,
                      in long detailArg);
 };
--- a/dom/interfaces/svg/nsIDOMSVGDocument.idl
+++ b/dom/interfaces/svg/nsIDOMSVGDocument.idl
@@ -34,17 +34,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsIDOMDocument.idl"
 
 interface nsIDOMSVGSVGElement;
 
-[scriptable, uuid(dcac0765-b258-4e0b-9862-6470eb9876ba)]
+[scriptable, uuid(907f1ada-5ace-4789-8c25-0c79f251044d)]
 interface nsIDOMSVGDocument : nsIDOMDocument
                          /* , nsIDOMDocumentEvent */
 {
   readonly attribute DOMString title;
   readonly attribute DOMString referrer;
   readonly attribute DOMString domain;
   readonly attribute DOMString URL;
   readonly attribute nsIDOMSVGSVGElement rootElement;
--- a/dom/interfaces/svg/nsIDOMSVGZoomEvent.idl
+++ b/dom/interfaces/svg/nsIDOMSVGZoomEvent.idl
@@ -40,17 +40,17 @@
 /**
  * For more information on this interface please see
  * http://www.w3.org/TR/SVG11/script.html#InterfaceSVGZoomEvent
  */
 
 interface nsIDOMSVGRect;
 interface nsIDOMSVGPoint;
 
-[scriptable, uuid(339a8c7a-552e-4cbc-8d96-8370a3939358)]
+[scriptable, uuid(7298880d-127d-470d-a8ac-e5a8e5969270)]
 interface nsIDOMSVGZoomEvent : nsIDOMUIEvent
 {
   readonly attribute nsIDOMSVGRect  zoomRectScreen;
   readonly attribute float          previousScale;
   readonly attribute nsIDOMSVGPoint previousTranslate;
   readonly attribute float          newScale;
   readonly attribute nsIDOMSVGPoint newTranslate;
 };
deleted file mode 100644
--- a/dom/interfaces/views/Makefile.in
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# ***** BEGIN LICENSE BLOCK *****
-# Version: MPL 1.1/GPL 2.0/LGPL 2.1
-#
-# The contents of this file are subject to the Mozilla Public License Version
-# 1.1 (the "License"); you may not use this file except in compliance with
-# the License. You may obtain a copy of the License at
-# http://www.mozilla.org/MPL/
-#
-# Software distributed under the License is distributed on an "AS IS" basis,
-# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
-# for the specific language governing rights and limitations under the
-# License.
-#
-# The Original Code is mozilla.org code.
-#
-# The Initial Developer of the Original Code is
-# Netscape Communications Corporation.
-# Portions created by the Initial Developer are Copyright (C) 1998
-# the Initial Developer. All Rights Reserved.
-#
-# Contributor(s):
-#
-# Alternatively, the contents of this file may be used under the terms of
-# either of 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 *****
-
-DEPTH		= ../../..
-topsrcdir	= @top_srcdir@
-srcdir		= @srcdir@
-VPATH		= @srcdir@
-