Merge inbound to m-c.
authorRyan VanderMeulen <ryanvm@gmail.com>
Thu, 27 Feb 2014 16:55:18 -0500
changeset 171431 82508f3c208869844bf1bb0861d84fd0a1b8b198
parent 171430 229b675b810bd0ef7dca69ab41aa5b4072bfa1fb (current diff)
parent 171338 c483fb963fe112b54c30230a69b9b1a89a7b55b1 (diff)
child 171445 c3ce3b51c881501b62527439ddd70016c7ed133c
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
milestone30.0a1
Merge inbound to m-c.
browser/app/profile/firefox.js
content/base/src/nsDOMLists.cpp
content/base/src/nsDOMLists.h
dom/events/MutationEvent.h
dom/events/nsDOMDeviceMotionEvent.cpp
dom/events/nsDOMDeviceMotionEvent.h
dom/events/nsDOMDragEvent.cpp
dom/events/nsDOMDragEvent.h
dom/events/nsDOMFocusEvent.cpp
dom/events/nsDOMFocusEvent.h
dom/events/nsDOMKeyboardEvent.cpp
dom/events/nsDOMKeyboardEvent.h
dom/events/nsDOMMessageEvent.cpp
dom/events/nsDOMMessageEvent.h
dom/events/nsDOMMouseEvent.cpp
dom/events/nsDOMMouseEvent.h
dom/events/nsDOMMouseScrollEvent.cpp
dom/events/nsDOMMouseScrollEvent.h
dom/events/nsDOMMutationEvent.cpp
dom/events/nsDOMMutationEvent.h
dom/events/nsDOMSimpleGestureEvent.cpp
dom/events/nsDOMSimpleGestureEvent.h
dom/interfaces/core/nsIDOMDOMStringList.idl
js/src/jit-test/tests/ion/testFloat32-trigo.js
toolkit/themes/osx/global/icons/question-mark.png
--- a/accessible/public/nsIAccessible.idl
+++ b/accessible/public/nsIAccessible.idl
@@ -3,17 +3,16 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 #include "nsIArray.idl"
 
 interface nsIPersistentProperties;
 interface nsIDOMCSSPrimitiveValue;
-interface nsIDOMDOMStringList;
 interface nsIDOMNode;
 interface nsIAccessibleDocument;
 interface nsIAccessibleRelation;
 
 /**
  * A cross-platform interface that supports platform-specific 
  * accessibility APIs like MSAA and ATK. Contains the sum of what's needed
  * to support IAccessible as well as ATK's generic accessibility objects.
--- a/accessible/public/nsIAccessibleRetrieval.idl
+++ b/accessible/public/nsIAccessibleRetrieval.idl
@@ -5,17 +5,16 @@
 
 #include "nsISupports.idl"
 
 interface nsIDOMNode;
 interface nsIAccessible;
 interface nsIWeakReference;
 interface nsIPresShell;
 interface nsIDOMWindow;
-interface nsIDOMDOMStringList;
 interface nsIAccessiblePivot;
 
 /**
  * An interface for in-process accessibility clients wishing to get an
  * nsIAccessible for a given DOM node.  More documentation at:
  *   http://www.mozilla.org/projects/ui/accessibility
  */
 [scriptable, uuid(17f86615-1a3d-4021-b227-3a2ef5cbffd8)]
@@ -43,18 +42,18 @@ interface nsIAccessibleRetrieval : nsISu
   AString getStringRole(in unsigned long aRole);
 
    /**
     * Returns list which contains accessible states as a strings.
     *
     * @param aStates - accessible states.
     * @param aExtraStates - accessible extra states.
     */
-  nsIDOMDOMStringList getStringStates(in unsigned long aStates,
-                                      in unsigned long aExtraStates);
+  nsISupports getStringStates(in unsigned long aStates,
+                              in unsigned long aExtraStates);
 
   /**
    * Get the type of accessible event as a string.
    *
    * @param aEventType - the accessible event type constant
    * @return - accessible event type presented as human readable string
    */
   AString getStringEventType(in unsigned long aEventType);
--- a/accessible/src/base/nsAccessibilityService.cpp
+++ b/accessible/src/base/nsAccessibilityService.cpp
@@ -59,16 +59,17 @@
 #include "nsObjectFrame.h"
 #include "nsSVGPathGeometryFrame.h"
 #include "nsTreeBodyFrame.h"
 #include "nsTreeColumns.h"
 #include "nsTreeUtils.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsXBLBinding.h"
 #include "mozilla/ArrayUtils.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
 #include "nsDeckFrame.h"
 
 #ifdef MOZ_XUL
 #include "XULAlertAccessible.h"
 #include "XULColorPickerAccessible.h"
 #include "XULComboboxAccessible.h"
@@ -82,16 +83,17 @@
 #endif
 
 #if defined(XP_WIN) || defined(MOZ_ACCESSIBILITY_ATK)
 #include "nsNPAPIPluginInstance.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::a11y;
+using namespace mozilla::dom;
 
 ////////////////////////////////////////////////////////////////////////////////
 // Statics
 ////////////////////////////////////////////////////////////////////////////////
 
 /**
  * Return true if the element must be accessible.
  */
@@ -570,20 +572,19 @@ nsAccessibilityService::GetStringRole(ui
       return NS_OK;
   }
 
 #undef ROLE
 }
 
 NS_IMETHODIMP
 nsAccessibilityService::GetStringStates(uint32_t aState, uint32_t aExtraState,
-                                        nsIDOMDOMStringList **aStringStates)
+                                        nsISupports **aStringStates)
 {
-  nsAccessibleDOMStringList* stringStates = new nsAccessibleDOMStringList();
-  NS_ENSURE_TRUE(stringStates, NS_ERROR_OUT_OF_MEMORY);
+  nsRefPtr<DOMStringList> stringStates = new DOMStringList();
 
   uint64_t state = nsAccUtils::To64State(aState, aExtraState);
 
   // states
   if (state & states::UNAVAILABLE)
     stringStates->Add(NS_LITERAL_STRING("unavailable"));
   if (state & states::SELECTED)
     stringStates->Add(NS_LITERAL_STRING("selected"));
@@ -676,22 +677,20 @@ nsAccessibilityService::GetStringStates(
   if (state & states::ENABLED)
     stringStates->Add(NS_LITERAL_STRING("enabled"));
   if (state & states::SENSITIVE)
     stringStates->Add(NS_LITERAL_STRING("sensitive"));
   if (state & states::EXPANDABLE)
     stringStates->Add(NS_LITERAL_STRING("expandable"));
 
   //unknown states
-  uint32_t stringStatesLength = 0;
-  stringStates->GetLength(&stringStatesLength);
-  if (!stringStatesLength)
+  if (!stringStates->Length())
     stringStates->Add(NS_LITERAL_STRING("unknown"));
 
-  NS_ADDREF(*aStringStates = stringStates);
+  stringStates.forget(aStringStates);
   return NS_OK;
 }
 
 // nsIAccessibleRetrieval::getStringEventType()
 NS_IMETHODIMP
 nsAccessibilityService::GetStringEventType(uint32_t aEventType,
                                            nsAString& aString)
 {
--- a/accessible/src/base/nsCoreUtils.cpp
+++ b/accessible/src/base/nsCoreUtils.cpp
@@ -644,43 +644,8 @@ nsCoreUtils::IsWhitespaceString(const ns
   aString.BeginReading(iterBegin);
   aString.EndReading(iterEnd);
 
   while (iterBegin != iterEnd && IsWhitespace(*iterBegin))
     ++iterBegin;
 
   return iterBegin == iterEnd;
 }
-
-
-////////////////////////////////////////////////////////////////////////////////
-// nsAccessibleDOMStringList
-////////////////////////////////////////////////////////////////////////////////
-
-NS_IMPL_ISUPPORTS1(nsAccessibleDOMStringList, nsIDOMDOMStringList)
-
-NS_IMETHODIMP
-nsAccessibleDOMStringList::Item(uint32_t aIndex, nsAString& aResult)
-{
-  if (aIndex >= mNames.Length())
-    SetDOMStringToNull(aResult);
-  else
-    aResult = mNames.ElementAt(aIndex);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAccessibleDOMStringList::GetLength(uint32_t* aLength)
-{
-  *aLength = mNames.Length();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAccessibleDOMStringList::Contains(const nsAString& aString, bool* aResult)
-{
-  *aResult = mNames.Contains(aString);
-
-  return NS_OK;
-}
-
--- a/accessible/src/base/nsCoreUtils.h
+++ b/accessible/src/base/nsCoreUtils.h
@@ -5,17 +5,16 @@
 
 #ifndef nsCoreUtils_h_
 #define nsCoreUtils_h_
 
 #include "nsIContent.h"
 #include "nsIDocument.h"
 #include "nsIPresShell.h"
 
-#include "nsIDOMDOMStringList.h"
 #include "nsPoint.h"
 #include "nsTArray.h"
 
 class nsRange;
 class nsIBoxObject;
 class nsIFrame;
 class nsIDocShell;
 class nsITreeColumn;
@@ -309,31 +308,10 @@ public:
    */
   static bool IsWhitespace(char16_t aChar)
   {
     return aChar == ' ' || aChar == '\n' ||
       aChar == '\r' || aChar == '\t' || aChar == 0xa0;
   }
 };
 
-
-/**
- * nsIDOMDOMStringList implementation.
- */
-class nsAccessibleDOMStringList : public nsIDOMDOMStringList
-{
-public:
-  nsAccessibleDOMStringList() {}
-  virtual ~nsAccessibleDOMStringList() {}
-
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOMDOMSTRINGLIST
-
-  bool Add(const nsAString& aName) {
-    return mNames.AppendElement(aName) != nullptr;
-  }
-
-private:
-  nsTArray<nsString> mNames;
-};
-
 #endif
 
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -1675,17 +1675,17 @@ double
 Accessible::MinValue() const
 {
   return AttrNumericValue(nsGkAtoms::aria_valuemin);
 }
 
 double
 Accessible::Step() const
 {
-  return UnspecifiedNaN(); // no mimimum increment (step) in ARIA.
+  return UnspecifiedNaN<double>(); // no mimimum increment (step) in ARIA.
 }
 
 double
 Accessible::CurValue() const
 {
   return AttrNumericValue(nsGkAtoms::aria_valuenow);
 }
 
@@ -3079,25 +3079,25 @@ Accessible::GetSiblingAtOffset(int32_t a
 
   return child;
 }
 
 double
 Accessible::AttrNumericValue(nsIAtom* aAttr) const
 {
   if (!mRoleMapEntry || mRoleMapEntry->valueRule == eNoValue)
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
 
   nsAutoString attrValue;
   if (!mContent->GetAttr(kNameSpaceID_None, aAttr, attrValue))
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
 
   nsresult error = NS_OK;
   double value = attrValue.ToDouble(&error);
-  return NS_FAILED(error) ? UnspecifiedNaN() : value;
+  return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
 }
 
 uint32_t
 Accessible::GetActionRule()
 {
   if (!HasOwnContent() || (InteractiveState() & states::UNAVAILABLE))
     return eNoAction;
 
--- a/accessible/src/generic/FormControlAccessible.cpp
+++ b/accessible/src/generic/FormControlAccessible.cpp
@@ -139,21 +139,21 @@ double
 ProgressMeterAccessible<Max>::CurValue() const
 {
   double value = LeafAccessible::CurValue();
   if (!IsNaN(value))
     return value;
 
   nsAutoString attrValue;
   if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value, attrValue))
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
 
   nsresult error = NS_OK;
   value = attrValue.ToDouble(&error);
-  return NS_FAILED(error) ? UnspecifiedNaN() : value;
+  return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
 }
 
 template<int Max>
 bool
 ProgressMeterAccessible<Max>::SetCurValue(double aValue)
 {
   return false; // progress meters are readonly.
 }
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -192,18 +192,19 @@ this.AccessFu = {
       else
         this._disable();
     } catch (x) {
       dump('Error ' + x.message + ' ' + x.fileName + ':' + x.lineNumber);
     }
   },
 
   receiveMessage: function receiveMessage(aMessage) {
-    if (Logger.logLevel >= Logger.DEBUG)
-      Logger.debug('Recieved', aMessage.name, JSON.stringify(aMessage.json));
+    Logger.debug(() => {
+      return ['Recieved', aMessage.name, JSON.stringify(aMessage.json)];
+    });
 
     switch (aMessage.name) {
       case 'AccessFu:Ready':
         let mm = Utils.getMessageManager(aMessage.target);
         if (this._enabled) {
           mm.sendAsyncMessage('AccessFu:Start',
                               {method: 'start', buildApp: Utils.MozBuildApp});
         }
--- a/accessible/src/jsat/EventManager.jsm
+++ b/accessible/src/jsat/EventManager.jsm
@@ -84,16 +84,20 @@ this.EventManager.prototype = {
     } catch (x) {
       // contentScope is dead.
     } finally {
       this._started = false;
     }
   },
 
   handleEvent: function handleEvent(aEvent) {
+    Logger.debug(() => {
+      return ['DOMEvent', aEvent.type];
+    });
+
     try {
       switch (aEvent.type) {
       case 'wheel':
       {
         let attempts = 0;
         let vc = Utils.getVirtualCursor(this.contentScope.content.document);
         let intervalId = this.contentScope.content.setInterval(() => {
           if (!Utils.isAliveAndVisible(vc.position, true)) {
@@ -124,19 +128,20 @@ this.EventManager.prototype = {
       }
       }
     } catch (x) {
       Logger.logException(x, 'Error handling DOM event');
     }
   },
 
   handleAccEvent: function handleAccEvent(aEvent) {
-    if (Logger.logLevel >= Logger.DEBUG)
-      Logger.debug('A11yEvent', Logger.eventToString(aEvent),
-                   Logger.accessibleToString(aEvent.accessible));
+    Logger.debug(() => {
+      return ['A11yEvent', Logger.eventToString(aEvent),
+              Logger.accessibleToString(aEvent.accessible)];
+    });
 
     // Don't bother with non-content events in firefox.
     if (Utils.MozBuildApp == 'browser' &&
         aEvent.eventType != Events.VIRTUALCURSOR_CHANGED &&
         // XXX Bug 442005 results in DocAccessible::getDocType returning
         // NS_ERROR_FAILURE. Checking for aEvent.accessibleDocument.docType ==
         // 'window' does not currently work.
         (aEvent.accessibleDocument.DOMDocument.doctype &&
--- a/accessible/src/jsat/Utils.jsm
+++ b/accessible/src/jsat/Utils.jsm
@@ -346,17 +346,18 @@ this.Logger = {
   logLevel: 1, // INFO;
 
   test: false,
 
   log: function log(aLogLevel) {
     if (aLogLevel < this.logLevel)
       return;
 
-    let message = Array.prototype.slice.call(arguments, 1).join(' ');
+    let args = Array.prototype.slice.call(arguments, 1);
+    let message = (typeof(args[0]) === 'function' ? args[0]() : args).join(' ');
     message = '[' + Utils.ScriptName + '] ' + this._LEVEL_NAMES[aLogLevel] +
       ' ' + message + '\n';
     dump(message);
     // Note: used for testing purposes. If |this.test| is true, also log to
     // the console service.
     if (this.test) {
       try {
         Services.console.logStringMessage(message);
--- a/accessible/src/jsat/content-script.js
+++ b/accessible/src/jsat/content-script.js
@@ -111,19 +111,19 @@ function moveToPoint(aMessage) {
     vc.moveToPoint(rule, details.x * dpr, details.y * dpr, true);
     forwardToChild(aMessage, moveToPoint, vc.position);
   } catch (x) {
     Logger.logException(x, 'Failed move to point');
   }
 }
 
 function showCurrent(aMessage) {
-  if (Logger.logLevel >= Logger.DEBUG) {
-    Logger.debug(aMessage.name, JSON.stringify(aMessage.json, null, ' '));
-  }
+  Logger.debug(() => {
+    return [aMessage.name, JSON.stringify(aMessage.json, null, ' ')];
+  });
 
   let vc = Utils.getVirtualCursor(content.document);
 
   if (!forwardToChild(vc, showCurrent, aMessage)) {
     if (!vc.position && aMessage.json.move) {
       vc.moveFirst(TraversalRules.Simple);
     } else {
       sendAsyncMessage('AccessFu:Present', Presentation.pivotChanged(
@@ -142,20 +142,20 @@ function forwardToParent(aMessage) {
 
 function forwardToChild(aMessage, aListener, aVCPosition) {
   let acc = aVCPosition || Utils.getVirtualCursor(content.document).position;
 
   if (!Utils.isAliveAndVisible(acc) || acc.role != Roles.INTERNAL_FRAME) {
     return false;
   }
 
-  if (Logger.logLevel >= Logger.DEBUG) {
-    Logger.debug('forwardToChild', Logger.accessibleToString(acc),
-                 aMessage.name, JSON.stringify(aMessage.json, null, '  '));
-  }
+  Logger.debug(() => {
+    return ['forwardToChild', Logger.accessibleToString(acc),
+            aMessage.name, JSON.stringify(aMessage.json, null, '  ')];
+  });
 
   let mm = Utils.getMessageManager(acc.DOMNode);
 
   if (aListener) {
     mm.addMessageListener(aMessage.name, aListener);
   }
 
   // XXX: This is a silly way to make a deep copy
--- a/accessible/src/xul/XULSliderAccessible.cpp
+++ b/accessible/src/xul/XULSliderAccessible.cpp
@@ -73,17 +73,17 @@ XULSliderAccessible::ActionCount()
 
 NS_IMETHODIMP
 XULSliderAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
 {
   aName.Truncate();
 
   NS_ENSURE_ARG(aIndex == 0);
 
-  aName.AssignLiteral("activate"); 
+  aName.AssignLiteral("activate");
   return NS_OK;
 }
 
 NS_IMETHODIMP
 XULSliderAccessible::DoAction(uint8_t aIndex)
 {
   NS_ENSURE_ARG(aIndex == 0);
 
@@ -182,21 +182,21 @@ XULSliderAccessible::SetSliderAttr(nsIAt
 }
 
 double
 XULSliderAccessible::GetSliderAttr(nsIAtom* aName) const
 {
   nsAutoString attrValue;
   nsresult rv = GetSliderAttr(aName, attrValue);
   if (NS_FAILED(rv))
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
 
   nsresult error = NS_OK;
   double value = attrValue.ToDouble(&error);
-  return NS_FAILED(error) ? UnspecifiedNaN() : value;
+  return NS_FAILED(error) ? UnspecifiedNaN<double>() : value;
 }
 
 bool
 XULSliderAccessible::SetSliderAttr(nsIAtom* aName, double aValue)
 {
   nsAutoString value;
   value.AppendFloat(aValue);
 
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -799,17 +799,17 @@ pref("browser.safebrowsing.gethashURL", 
 pref("browser.safebrowsing.reportURL", "https://safebrowsing.google.com/safebrowsing/report?");
 pref("browser.safebrowsing.reportGenericURL", "http://%LOCALE%.phish-generic.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportErrorURL", "http://%LOCALE%.phish-error.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportPhishURL", "http://%LOCALE%.phish-report.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportMalwareURL", "http://%LOCALE%.malware-report.mozilla.com/?hl=%LOCALE%");
 pref("browser.safebrowsing.reportMalwareErrorURL", "http://%LOCALE%.malware-error.mozilla.com/?hl=%LOCALE%");
 
 pref("browser.safebrowsing.malware.reportURL", "https://safebrowsing.google.com/safebrowsing/diagnostic?client=%NAME%&hl=%LOCALE%&site=");
-pref("browser.safebrowsing.appRepURL", "https://sb-ssl.google.com/safebrowsing/clientreport/download&key=%GOOGLE_API_KEY%");
+pref("browser.safebrowsing.appRepURL", "https://sb-ssl.google.com/safebrowsing/clientreport/download?key=%GOOGLE_API_KEY%");
 
 #ifdef MOZILLA_OFFICIAL
 // Normally the "client ID" sent in updates is appinfo.name, but for
 // official Firefox releases from Mozilla we use a special identifier.
 pref("browser.safebrowsing.id", "navclient-auto-ffox");
 #endif
 
 // Name of the about: page contributed by safebrowsing to handle display of error
--- a/browser/components/places/content/controller.js
+++ b/browser/components/places/content/controller.js
@@ -1356,17 +1356,17 @@ let PlacesControllerDragHelper = {
    */
   getSession: function PCDH__getSession() {
     return this.dragService.getCurrentSession();
   },
 
   /**
    * Extract the first accepted flavor from a list of flavors.
    * @param aFlavors
-   *        The flavors list of type nsIDOMDOMStringList.
+   *        The flavors list of type DOMStringList.
    */
   getFirstValidFlavor: function PCDH_getFirstValidFlavor(aFlavors) {
     for (let i = 0; i < aFlavors.length; i++) {
       if (this.GENERIC_VIEW_DROP_TYPES.indexOf(aFlavors[i]) != -1)
         return aFlavors[i];
     }
 
     // If no supported flavor is found, check if data includes text/plain 
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -630,17 +630,17 @@ public:
   }
   void ReleaseCapture()
   {
     if (nsIPresShell::GetCapturingContent() == this) {
       nsIPresShell::SetCapturingContent(nullptr, 0);
     }
   }
   void MozRequestFullScreen();
-  inline void MozRequestPointerLock();
+  void MozRequestPointerLock();
   Attr* GetAttributeNode(const nsAString& aName);
   already_AddRefed<Attr> SetAttributeNode(Attr& aNewAttr,
                                           ErrorResult& aError);
   already_AddRefed<Attr> RemoveAttributeNode(Attr& aOldAttr,
                                              ErrorResult& aError);
   Attr* GetAttributeNodeNS(const nsAString& aNamespaceURI,
                            const nsAString& aLocalName);
   already_AddRefed<Attr> SetAttributeNodeNS(Attr& aNewAttr,
--- a/content/base/public/ElementInlines.h
+++ b/content/base/public/ElementInlines.h
@@ -9,22 +9,16 @@
 
 #include "mozilla/dom/Element.h"
 #include "nsIDocument.h"
 
 namespace mozilla {
 namespace dom {
 
 inline void
-Element::MozRequestPointerLock()
-{
-  OwnerDoc()->RequestPointerLock(this);
-}
-
-inline void
 Element::RegisterFreezableElement()
 {
   OwnerDoc()->RegisterFreezableElement(this);
 }
 
 inline void
 Element::UnregisterFreezableElement()
 {
--- a/content/base/public/nsIAttribute.h
+++ b/content/base/public/nsIAttribute.h
@@ -38,16 +38,17 @@ public:
    */
   virtual nsresult SetOwnerDocument(nsIDocument* aDocument) = 0;
 
 protected:
 #ifdef MOZILLA_INTERNAL_API
   nsIAttribute(nsDOMAttributeMap *aAttrMap, already_AddRefed<nsINodeInfo> aNodeInfo,
                bool aNsAware);
 #endif //MOZILLA_INTERNAL_API
+  virtual ~nsIAttribute();
 
   nsRefPtr<nsDOMAttributeMap> mAttrMap;
   bool mNsAware;
 };
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsIAttribute, NS_IATTRIBUTE_IID)
 
 #endif /* nsIAttribute_h___ */
--- a/content/base/public/nsIDocument.h
+++ b/content/base/public/nsIDocument.h
@@ -95,16 +95,17 @@ class ImageLoader;
 namespace dom {
 class Attr;
 class CDATASection;
 class Comment;
 struct CustomElementDefinition;
 class DocumentFragment;
 class DocumentType;
 class DOMImplementation;
+class DOMStringList;
 class Element;
 struct ElementRegistrationOptions;
 class EventTarget;
 class FrameRequestCallback;
 class HTMLBodyElement;
 struct LifecycleCallbackArgs;
 class Link;
 class GlobalObject;
@@ -119,18 +120,18 @@ template<typename> class OwningNonNull;
 template<typename> class Sequence;
 
 template<typename, typename> class CallbackObjectHolder;
 typedef CallbackObjectHolder<NodeFilter, nsIDOMNodeFilter> NodeFilterHolder;
 } // namespace dom
 } // namespace mozilla
 
 #define NS_IDOCUMENT_IID \
-{ 0x595492bc, 0xa26d, 0x46a9, \
-  { 0xa9, 0x35, 0x0c, 0x40, 0xdd, 0xc2, 0x77, 0x51 } }
+{ 0x94629cb0, 0xfe8a, 0x4627, \
+  { 0x8e, 0x59, 0xab, 0x1a, 0xaf, 0xdc, 0x99, 0x56 } }
 
 // Flag for AddStyleSheet().
 #define NS_STYLESHEET_FROM_CATALOG                (1 << 0)
 
 // Enum for requesting a particular type of document when creating a doc
 enum DocumentFlavor {
   DocumentFlavorLegacyGuess, // compat with old code until made HTML5-compliant
   DocumentFlavorHTML, // HTMLDocument with HTMLness bit set to true
@@ -2154,17 +2155,17 @@ public:
     WarnOnceAbout(ePrefixedVisibilityAPI);
     return VisibilityState();
   }
   virtual nsIDOMStyleSheetList* StyleSheets() = 0;
   void GetSelectedStyleSheetSet(nsAString& aSheetSet);
   virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) = 0;
   virtual void GetLastStyleSheetSet(nsString& aSheetSet) = 0;
   void GetPreferredStyleSheetSet(nsAString& aSheetSet);
-  virtual nsIDOMDOMStringList* StyleSheetSets() = 0;
+  virtual mozilla::dom::DOMStringList* StyleSheetSets() = 0;
   virtual void EnableStyleSheetsForSet(const nsAString& aSheetSet) = 0;
   Element* ElementFromPoint(float aX, float aY);
 
   /**
    * Retrieve the location of the caret position (DOM node and character
    * offset within that node), given a point.
    *
    * @param aX Horizontal point at which to determine the caret position, in
--- a/content/base/public/nsIMessageManager.idl
+++ b/content/base/public/nsIMessageManager.idl
@@ -1,16 +1,15 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsISupports.idl"
 
-interface nsIDOMDOMStringList;
 interface nsIDOMWindow;
 interface nsIDocShell;
 interface nsIContent;
 interface nsIPrincipal;
 
 /**
  * Message managers provide a way for chrome-privileged JS code to
  * communicate with each other, even across process boundaries.
--- a/content/base/src/Attr.cpp
+++ b/content/base/src/Attr.cpp
@@ -5,17 +5,17 @@
 
 /*
  * Implementation of DOM Core's nsIDOMAttr node.
  */
 
 #include "mozilla/dom/Attr.h"
 #include "mozilla/dom/AttrBinding.h"
 #include "mozilla/dom/Element.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsINameSpaceManager.h"
 #include "nsError.h"
 #include "nsUnicharUtils.h"
 #include "nsDOMString.h"
 #include "nsIContentInlines.h"
 #include "nsIDocument.h"
 #include "nsIDOMUserDataHandler.h"
@@ -31,16 +31,20 @@
 
 nsIAttribute::nsIAttribute(nsDOMAttributeMap* aAttrMap,
                            already_AddRefed<nsINodeInfo> aNodeInfo,
                            bool aNsAware)
 : nsINode(aNodeInfo), mAttrMap(aAttrMap), mNsAware(aNsAware)
 {
 }
 
+nsIAttribute::~nsIAttribute()
+{
+}
+
 namespace mozilla {
 namespace dom {
 
 //----------------------------------------------------------------------
 bool Attr::sInitialized;
 
 Attr::Attr(nsDOMAttributeMap *aAttrMap,
            already_AddRefed<nsINodeInfo> aNodeInfo,
--- a/content/base/src/Attr.h
+++ b/content/base/src/Attr.h
@@ -15,16 +15,17 @@
 #include "nsIDOMAttr.h"
 #include "nsIDOMText.h"
 #include "nsIDOMNodeList.h"
 #include "nsString.h"
 #include "nsCOMPtr.h"
 #include "nsINodeInfo.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsStubMutationObserver.h"
+#include "nsIDocument.h"
 
 namespace mozilla {
 namespace dom {
 
 // Attribute helper class used to wrap up an attribute with a dom
 // object that implements nsIDOMAttr and nsIDOMNode
 class Attr MOZ_FINAL : public nsIAttribute,
                        public nsIDOMAttr
rename from content/base/src/nsDOMLists.cpp
rename to content/base/src/DOMStringList.cpp
--- a/content/base/src/nsDOMLists.cpp
+++ b/content/base/src/DOMStringList.cpp
@@ -1,59 +1,33 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/*
- * Implementation of nsIDOMDOMStringList, used by various DOM stuff.
- */
+#include "mozilla/dom/DOMStringList.h"
+#include "mozilla/dom/DOMStringListBinding.h"
+#include "nsContentUtils.h"
+
+namespace mozilla {
+namespace dom {
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(DOMStringList)
 
-#include "nsDOMLists.h"
-#include "nsError.h"
-#include "nsDOMClassInfoID.h"
-#include "nsINode.h"
+NS_IMPL_CYCLE_COLLECTING_ADDREF(DOMStringList)
+NS_IMPL_CYCLE_COLLECTING_RELEASE(DOMStringList)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(DOMStringList)
+  NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
 
-nsDOMStringList::nsDOMStringList()
-{
-}
-
-nsDOMStringList::~nsDOMStringList()
+DOMStringList::~DOMStringList()
 {
 }
 
-DOMCI_DATA(DOMStringList, nsDOMStringList)
-
-NS_IMPL_ADDREF(nsDOMStringList)
-NS_IMPL_RELEASE(nsDOMStringList)
-NS_INTERFACE_TABLE_HEAD(nsDOMStringList)
-  NS_INTERFACE_TABLE1(nsDOMStringList, nsIDOMDOMStringList)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMStringList)
-NS_INTERFACE_MAP_END
-
-NS_IMETHODIMP
-nsDOMStringList::Item(uint32_t aIndex, nsAString& aResult)
+JSObject*
+DOMStringList::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
-  if (aIndex >= mNames.Length()) {
-    SetDOMStringToNull(aResult);
-  } else {
-    aResult = mNames[aIndex];
-  }
-
-  return NS_OK;
+  return DOMStringListBinding::Wrap(aCx, aScope, this);
 }
 
-NS_IMETHODIMP
-nsDOMStringList::GetLength(uint32_t *aLength)
-{
-  *aLength = mNames.Length();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMStringList::Contains(const nsAString& aString, bool *aResult)
-{
-  *aResult = mNames.Contains(aString);
-
-  return NS_OK;
-}
+} // namespace dom
+} // namespace mozilla
rename from content/base/src/nsDOMLists.h
rename to content/base/src/DOMStringList.h
--- a/content/base/src/nsDOMLists.h
+++ b/content/base/src/DOMStringList.h
@@ -1,45 +1,106 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/*
- * Implementation of nsIDOMDOMStringList, used by various DOM stuff.
- */
+#ifndef mozilla_dom_DOMStringList_h
+#define mozilla_dom_DOMStringList_h
 
-#ifndef nsDOMLists_h___
-#define nsDOMLists_h___
-
-#include "nsIDOMDOMStringList.h"
+#include "nsISupports.h"
 #include "nsTArray.h"
+#include "nsWrapperCache.h"
 #include "nsString.h"
 
-class nsDOMStringList : public nsIDOMDOMStringList
+namespace mozilla {
+namespace dom {
+
+class DOMStringList : public nsISupports,
+                      public nsWrapperCache
 {
 public:
-  nsDOMStringList();
-  virtual ~nsDOMStringList();
+  DOMStringList()
+  {
+    SetIsDOMBinding();
+  }
+  virtual ~DOMStringList();
+
+  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMStringList)
+
+  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
+  nsISupports* GetParentObject()
+  {
+    return nullptr;
+  }
 
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOMDOMSTRINGLIST
+  void IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aResult)
+  {
+    EnsureFresh();
+    if (aIndex < mNames.Length()) {
+      aFound = true;
+      aResult = mNames[aIndex];
+    } else {
+      aFound = false;
+    }
+  }
+
+  void Item(uint32_t aIndex, nsAString& aResult)
+  {
+    EnsureFresh();
+    if (aIndex < mNames.Length()) {
+      aResult = mNames[aIndex];
+    } else {
+      aResult.SetIsVoid(true);
+    }
+  }
+
+  uint32_t Length()
+  {
+    EnsureFresh();
+    return mNames.Length();
+  }
+
+  bool Contains(const nsAString& aString)
+  {
+    EnsureFresh();
+    return mNames.Contains(aString);
+  }
 
   bool Add(const nsAString& aName)
   {
+    // XXXbz mNames should really be a fallible array; otherwise this
+    // return value is meaningless.
     return mNames.AppendElement(aName) != nullptr;
   }
 
   void Clear()
   {
     mNames.Clear();
   }
 
+  nsTArray<nsString>& StringArray()
+  {
+    return mNames;
+  }
+
   void CopyList(nsTArray<nsString>& aNames)
   {
     aNames = mNames;
   }
 
-private:
+protected:
+  // A method that subclasses can override to modify mNames as needed
+  // before we index into it or return its length or whatnot.
+  virtual void EnsureFresh()
+  {
+  }
+
+  // XXXbz we really want this to be a fallible array, but we end up passing it
+  // to consumers who declare themselves as taking and nsTArray.  :(
   nsTArray<nsString> mNames;
 };
 
-#endif /* nsDOMLists_h___ */
+} // namespace dom
+} // namespace mozilla
+
+#endif /* mozilla_dom_DOMStringList_h */
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -45,18 +45,18 @@
 #include "nsContentList.h"
 #include "nsDOMTokenList.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsError.h"
 #include "nsDOMString.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIDOMMutationEvent.h"
 #include "mozilla/ContentEvents.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/TextEvents.h"
 #include "nsNodeUtils.h"
 #include "mozilla/dom/DirectionalityUtils.h"
 #include "nsDocument.h"
 #include "nsAttrValueOrString.h"
 #include "nsAttrValueInlines.h"
 #ifdef MOZ_XUL
 #include "nsXULElement.h"
@@ -2590,16 +2590,22 @@ Element::MozRequestFullScreen()
     return;
   }
 
   OwnerDoc()->AsyncRequestFullScreen(this);
 
   return;
 }
 
+void
+Element::MozRequestPointerLock()
+{
+  OwnerDoc()->RequestPointerLock(this);
+}
+
 NS_IMETHODIMP
 Element::GetInnerHTML(nsAString& aInnerHTML)
 {
   GetMarkup(false, aInnerHTML);
   return NS_OK;
 }
 
 void
--- a/content/base/src/EventSource.cpp
+++ b/content/base/src/EventSource.cpp
@@ -3,21 +3,21 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/EventSource.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/EventSourceBinding.h"
+#include "mozilla/dom/MessageEvent.h"
 
 #include "js/OldDebugAPI.h"
 #include "nsNetUtil.h"
 #include "nsMimeTypes.h"
-#include "nsDOMMessageEvent.h"
 #include "nsIPromptFactory.h"
 #include "nsIWindowWatcher.h"
 #include "nsPresContext.h"
 #include "nsContentPolicyUtils.h"
 #include "nsIStringBundle.h"
 #include "nsIConsoleService.h"
 #include "nsIObserverService.h"
 #include "nsIScriptObjectPrincipal.h"
--- a/content/base/src/FragmentOrElement.cpp
+++ b/content/base/src/FragmentOrElement.cpp
@@ -47,18 +47,18 @@
 #include "nsINameSpaceManager.h"
 #include "nsContentList.h"
 #include "nsDOMTokenList.h"
 #include "nsXBLPrototypeBinding.h"
 #include "nsError.h"
 #include "nsDOMString.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIDOMMutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "nsNodeUtils.h"
 #include "nsDocument.h"
 #include "nsAttrValueOrString.h"
 #ifdef MOZ_XUL
 #include "nsXULElement.h"
 #endif /* MOZ_XUL */
 #include "nsFrameManager.h"
 #include "nsFrameSelection.h"
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -31,17 +31,16 @@
 #include "nsIConsoleService.h"
 #include "nsIDOMCloseEvent.h"
 #include "nsICryptoHash.h"
 #include "nsJSUtils.h"
 #include "nsIScriptError.h"
 #include "nsNetUtil.h"
 #include "nsILoadGroup.h"
 #include "mozilla/Preferences.h"
-#include "nsDOMLists.h"
 #include "xpcpublic.h"
 #include "nsContentPolicyUtils.h"
 #include "nsDOMFile.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsIObserverService.h"
 #include "nsIWebSocketChannel.h"
 #include "GeneratedEvents.h"
--- a/content/base/src/moz.build
+++ b/content/base/src/moz.build
@@ -57,16 +57,17 @@ if CONFIG['INTEL_ARCHITECTURE']:
 EXPORTS.mozilla.dom += [
     'Attr.h',
     'Comment.h',
     'DocumentFragment.h',
     'DocumentType.h',
     'DOMImplementation.h',
     'DOMParser.h',
     'DOMRect.h',
+    'DOMStringList.h',
     'EventSource.h',
     'Link.h',
     'NodeIterator.h',
     'ShadowRoot.h',
     'Text.h',
     'TreeWalker.h',
 ]
 
@@ -75,16 +76,17 @@ UNIFIED_SOURCES += [
     'ChildIterator.cpp',
     'Comment.cpp',
     'DirectionalityUtils.cpp',
     'DocumentFragment.cpp',
     'DocumentType.cpp',
     'DOMImplementation.cpp',
     'DOMParser.cpp',
     'DOMRect.cpp',
+    'DOMStringList.cpp',
     'Element.cpp',
     'EventSource.cpp',
     'FileIOObject.cpp',
     'FragmentOrElement.cpp',
     'Link.cpp',
     'NodeIterator.cpp',
     'nsAtomListUtils.cpp',
     'nsAttrAndChildArray.cpp',
@@ -102,17 +104,16 @@ UNIFIED_SOURCES += [
     'nsCSPService.cpp',
     'nsDataDocumentContentPolicy.cpp',
     'nsDocumentEncoder.cpp',
     'nsDOMAttributeMap.cpp',
     'nsDOMBlobBuilder.cpp',
     'nsDOMCaretPosition.cpp',
     'nsDOMFile.cpp',
     'nsDOMFileReader.cpp',
-    'nsDOMLists.cpp',
     'nsDOMMutationObserver.cpp',
     'nsDOMSerializer.cpp',
     'nsDOMSettableTokenList.cpp',
     'nsDOMTokenList.cpp',
     'nsFormData.cpp',
     'nsFrameLoader.cpp',
     'nsFrameMessageManager.cpp',
     'nsGenConImageContent.cpp',
--- a/content/base/src/nsContentSink.cpp
+++ b/content/base/src/nsContentSink.cpp
@@ -670,32 +670,32 @@ nsContentSink::ProcessLink(const nsSubst
   // The link relation may apply to a different resource, specified
   // in the anchor parameter. For the link relations supported so far,
   // we simply abort if the link applies to a resource different to the
   // one we've loaded
   if (!LinkContextIsOurDocument(aAnchor)) {
     return NS_OK;
   }
   
-  bool hasPrefetch = linkTypes & PREFETCH;
+  bool hasPrefetch = linkTypes & nsStyleLinkElement::ePREFETCH;
   // prefetch href if relation is "next" or "prefetch"
-  if (hasPrefetch || (linkTypes & NEXT)) {
+  if (hasPrefetch || (linkTypes & nsStyleLinkElement::eNEXT)) {
     PrefetchHref(aHref, mDocument, hasPrefetch);
   }
 
-  if (!aHref.IsEmpty() && (linkTypes & DNS_PREFETCH)) {
+  if (!aHref.IsEmpty() && (linkTypes & nsStyleLinkElement::eDNS_PREFETCH)) {
     PrefetchDNS(aHref);
   }
 
   // is it a stylesheet link?
-  if (!(linkTypes & STYLESHEET)) {
+  if (!(linkTypes & nsStyleLinkElement::eSTYLESHEET)) {
     return NS_OK;
   }
 
-  bool isAlternate = linkTypes & ALTERNATE;
+  bool isAlternate = linkTypes & nsStyleLinkElement::eALTERNATE;
   return ProcessStyleLink(nullptr, aHref, isAlternate, aTitle, aType,
                           aMedia);
 }
 
 nsresult
 nsContentSink::ProcessStyleLink(nsIContent* aElement,
                                 const nsSubstring& aHref,
                                 bool aAlternate,
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -35,19 +35,19 @@
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/DocumentFragment.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/HTMLMediaElement.h"
 #include "mozilla/dom/HTMLTemplateElement.h"
 #include "mozilla/dom/HTMLContentElement.h"
 #include "mozilla/dom/TextDecoder.h"
 #include "mozilla/dom/ShadowRoot.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Selection.h"
 #include "mozilla/TextEvents.h"
 #include "nsAString.h"
 #include "nsAttrName.h"
 #include "nsAttrValue.h"
 #include "nsAttrValueInlines.h"
 #include "nsBindingManager.h"
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -41,17 +41,16 @@
 #include "nsCxPusher.h"
 
 #include "mozilla/BasicEvents.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsIDOMNodeFilter.h"
 
 #include "nsIDOMStyleSheet.h"
 #include "mozilla/dom/Attr.h"
-#include "nsIDOMDOMStringList.h"
 #include "nsIDOMDOMImplementation.h"
 #include "nsIDOMDocumentXBL.h"
 #include "mozilla/dom/Element.h"
 #include "nsGenericHTMLElement.h"
 #include "mozilla/dom/CDATASection.h"
 #include "mozilla/dom/ProcessingInstruction.h"
 #include "nsDOMString.h"
 #include "nsNodeUtils.h"
@@ -116,17 +115,17 @@
 #include "nsCharsetAlias.h"
 #include "nsCharsetSource.h"
 #include "nsIParser.h"
 #include "nsIContentSink.h"
 
 #include "nsDateTimeFormatCID.h"
 #include "nsIDateTimeFormat.h"
 #include "nsEventDispatcher.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsDOMCID.h"
 
 #include "jsapi.h"
 #include "nsIXPConnect.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsIContentPolicy.h"
 #include "nsContentPolicyUtils.h"
 #include "nsICategoryManager.h"
@@ -216,16 +215,17 @@
 #include "nsIHttpChannelInternal.h"
 #include "nsISecurityConsoleMessage.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "mozilla/dom/XPathEvaluator.h"
 #include "nsIDocumentEncoder.h"
 #include "nsIStructuredCloneContainer.h"
 #include "nsIMutableArray.h"
 #include "nsContentPermissionHelper.h"
+#include "mozilla/dom/DOMStringList.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 typedef nsTArray<Link*> LinkArray;
 
 #ifdef PR_LOGGING
 static PRLogModuleInfo* gDocumentLeakPRLog;
@@ -1302,115 +1302,61 @@ nsExternalResourceMap::ExternalResource:
   }
 }
 
 // ==================================================================
 // =
 // ==================================================================
 
 // If we ever have an nsIDocumentObserver notification for stylesheet title
-// changes, we could make this inherit from nsDOMStringList instead of
-// reimplementing nsIDOMDOMStringList.
-class nsDOMStyleSheetSetList MOZ_FINAL : public nsIDOMDOMStringList
+// changes we should update the list from that instead of overriding
+// EnsureFresh.
+class nsDOMStyleSheetSetList MOZ_FINAL : public DOMStringList
 {
 public:
-  NS_DECL_ISUPPORTS
-
-  NS_DECL_NSIDOMDOMSTRINGLIST
-
   nsDOMStyleSheetSetList(nsIDocument* aDocument);
 
   void Disconnect()
   {
     mDocument = nullptr;
   }
 
+  virtual void EnsureFresh() MOZ_OVERRIDE;
+
 protected:
-  // Rebuild our list of style sets
-  nsresult GetSets(nsTArray<nsString>& aStyleSets);
-
   nsIDocument* mDocument;  // Our document; weak ref.  It'll let us know if it
                            // dies.
 };
 
-NS_IMPL_ADDREF(nsDOMStyleSheetSetList)
-NS_IMPL_RELEASE(nsDOMStyleSheetSetList)
-NS_INTERFACE_TABLE_HEAD(nsDOMStyleSheetSetList)
-  NS_INTERFACE_TABLE1(nsDOMStyleSheetSetList, nsIDOMDOMStringList)
-  NS_INTERFACE_TABLE_TO_MAP_SEGUE
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMStringList)
-NS_INTERFACE_MAP_END
-
 nsDOMStyleSheetSetList::nsDOMStyleSheetSetList(nsIDocument* aDocument)
   : mDocument(aDocument)
 {
   NS_ASSERTION(mDocument, "Must have document!");
 }
 
-NS_IMETHODIMP
-nsDOMStyleSheetSetList::Item(uint32_t aIndex, nsAString& aResult)
-{
-  nsTArray<nsString> styleSets;
-  nsresult rv = GetSets(styleSets);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (aIndex >= styleSets.Length()) {
-    SetDOMStringToNull(aResult);
-  } else {
-    aResult = styleSets[aIndex];
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMStyleSheetSetList::GetLength(uint32_t *aLength)
-{
-  nsTArray<nsString> styleSets;
-  nsresult rv = GetSets(styleSets);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aLength = styleSets.Length();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDOMStyleSheetSetList::Contains(const nsAString& aString, bool *aResult)
-{
-  nsTArray<nsString> styleSets;
-  nsresult rv = GetSets(styleSets);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  *aResult = styleSets.Contains(aString);
-
-  return NS_OK;
-}
-
-nsresult
-nsDOMStyleSheetSetList::GetSets(nsTArray<nsString>& aStyleSets)
-{
+void
+nsDOMStyleSheetSetList::EnsureFresh()
+{
+  mNames.Clear();
+
   if (!mDocument) {
-    return NS_OK; // Spec says "no exceptions", and we have no style sets if we
-                  // have no document, for sure
+    return; // Spec says "no exceptions", and we have no style sets if we have
+            // no document, for sure
   }
 
   int32_t count = mDocument->GetNumberOfStyleSheets();
   nsAutoString title;
   for (int32_t index = 0; index < count; index++) {
     nsIStyleSheet* sheet = mDocument->GetStyleSheetAt(index);
     NS_ASSERTION(sheet, "Null sheet in sheet list!");
     sheet->GetTitle(title);
-    if (!title.IsEmpty() && !aStyleSets.Contains(title) &&
-        !aStyleSets.AppendElement(title)) {
-      return NS_ERROR_OUT_OF_MEMORY;
-    }
-  }
-
-  return NS_OK;
+    if (!title.IsEmpty() && !mNames.Contains(title) && !Add(title)) {
+      return;
+    }
+  }
 }
 
 // ==================================================================
 nsIDocument::SelectorCache::SelectorCache()
   : nsExpirationTracker<SelectorCacheKey, 4>(1000) { }
 
 // CacheList takes ownership of aSelectorList.
 void nsIDocument::SelectorCache::CacheList(const nsAString& aSelector,
@@ -6168,23 +6114,23 @@ nsDocument::GetPreferredStyleSheetSet(ns
 
 void
 nsIDocument::GetPreferredStyleSheetSet(nsAString& aSheetSet)
 {
   GetHeaderData(nsGkAtoms::headerDefaultStyle, aSheetSet);
 }
 
 NS_IMETHODIMP
-nsDocument::GetStyleSheetSets(nsIDOMDOMStringList** aList)
+nsDocument::GetStyleSheetSets(nsISupports** aList)
 {
   NS_ADDREF(*aList = StyleSheetSets());
   return NS_OK;
 }
 
-nsIDOMDOMStringList*
+DOMStringList*
 nsDocument::StyleSheetSets()
 {
   if (!mStyleSheetSetList) {
     mStyleSheetSetList = new nsDOMStyleSheetSetList(this);
   }
   return mStyleSheetSetList;
 }
 
--- a/content/base/src/nsDocument.h
+++ b/content/base/src/nsDocument.h
@@ -1190,17 +1190,17 @@ public:
     GetImplementation(mozilla::ErrorResult& rv) MOZ_OVERRIDE;
   virtual JSObject*
     RegisterElement(JSContext* aCx, const nsAString& aName,
                     const mozilla::dom::ElementRegistrationOptions& aOptions,
                     mozilla::ErrorResult& rv) MOZ_OVERRIDE;
   virtual nsIDOMStyleSheetList* StyleSheets() MOZ_OVERRIDE;
   virtual void SetSelectedStyleSheetSet(const nsAString& aSheetSet) MOZ_OVERRIDE;
   virtual void GetLastStyleSheetSet(nsString& aSheetSet) MOZ_OVERRIDE;
-  virtual nsIDOMDOMStringList* StyleSheetSets() MOZ_OVERRIDE;
+  virtual mozilla::dom::DOMStringList* StyleSheetSets() MOZ_OVERRIDE;
   virtual void EnableStyleSheetsForSet(const nsAString& aSheetSet) MOZ_OVERRIDE;
   using nsIDocument::CreateElement;
   using nsIDocument::CreateElementNS;
   virtual already_AddRefed<Element> CreateElement(const nsAString& aTagName,
                                                   const nsAString& aTypeExtension,
                                                   mozilla::ErrorResult& rv) MOZ_OVERRIDE;
   virtual already_AddRefed<Element> CreateElementNS(const nsAString& aNamespaceURI,
                                                     const nsAString& aQualifiedName,
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -28,17 +28,17 @@
 #include "nsIJSRuntimeService.h"
 #include "nsIDOMClassInfo.h"
 #include "nsIDOMFile.h"
 #include "xpcpublic.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/StructuredCloneUtils.h"
 #include "JavaScriptChild.h"
 #include "JavaScriptParent.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsPrintfCString.h"
 #include <algorithm>
 
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 #ifdef XP_WIN
 #include <windows.h>
--- a/content/base/src/nsGenericDOMDataNode.cpp
+++ b/content/base/src/nsGenericDOMDataNode.cpp
@@ -13,17 +13,17 @@
 #include "nsGenericDOMDataNode.h"
 #include "mozilla/MemoryReporting.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/ShadowRoot.h"
 #include "nsIDocument.h"
 #include "nsEventListenerManager.h"
 #include "nsIDOMDocument.h"
 #include "nsReadableUtils.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsINameSpaceManager.h"
 #include "nsIURI.h"
 #include "nsIDOMEvent.h"
 #include "nsIDOMText.h"
 #include "nsCOMPtr.h"
 #include "nsDOMString.h"
 #include "nsIDOMUserDataHandler.h"
 #include "nsChangeHint.h"
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -9,19 +9,19 @@
  */
 
 #include "nsINode.h"
 
 #include "AccessCheck.h"
 #include "jsapi.h"
 #include "mozAutoDocUpdate.h"
 #include "mozilla/CORSMode.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/Likely.h"
 #include "mozilla/MemoryReporting.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/Telemetry.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsAttrValueOrString.h"
 #include "nsBindingManager.h"
 #include "nsCCUncollectableMarker.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentList.h"
 #include "nsContentUtils.h"
--- a/content/base/src/nsStyleLinkElement.cpp
+++ b/content/base/src/nsStyleLinkElement.cpp
@@ -115,28 +115,28 @@ nsStyleLinkElement::OverrideBaseURI(nsIU
 }
 
 /* virtual */ void
 nsStyleLinkElement::SetLineNumber(uint32_t aLineNumber)
 {
   mLineNumber = aLineNumber;
 }
 
-uint32_t ToLinkMask(const nsAString& aLink)
+static uint32_t ToLinkMask(const nsAString& aLink)
 { 
   if (aLink.EqualsLiteral("prefetch"))
-     return PREFETCH;
+    return nsStyleLinkElement::ePREFETCH;
   else if (aLink.EqualsLiteral("dns-prefetch"))
-     return DNS_PREFETCH;
+    return nsStyleLinkElement::eDNS_PREFETCH;
   else if (aLink.EqualsLiteral("stylesheet"))
-    return STYLESHEET;
+    return nsStyleLinkElement::eSTYLESHEET;
   else if (aLink.EqualsLiteral("next"))
-    return NEXT;
+    return nsStyleLinkElement::eNEXT;
   else if (aLink.EqualsLiteral("alternate"))
-    return ALTERNATE;
+    return nsStyleLinkElement::eALTERNATE;
   else 
     return 0;
 }
 
 uint32_t nsStyleLinkElement::ParseLinkTypes(const nsAString& aTypes)
 {
   uint32_t linkMask = 0;
   nsAString::const_iterator start, done;
--- a/content/base/src/nsStyleLinkElement.h
+++ b/content/base/src/nsStyleLinkElement.h
@@ -15,22 +15,16 @@
 
 #include "mozilla/Attributes.h"
 #include "nsCOMPtr.h"
 #include "nsIStyleSheetLinkingElement.h"
 #include "nsCSSStyleSheet.h"
 #include "nsTArray.h"
 #include "mozilla/CORSMode.h"
 
-#define PREFETCH      0x00000001
-#define DNS_PREFETCH  0x00000002
-#define STYLESHEET    0x00000004
-#define NEXT          0x00000008
-#define ALTERNATE     0x00000010
-
 class nsIDocument;
 class nsIURI;
 
 namespace mozilla {
 namespace dom {
 class ShadowRoot;
 } // namespace dom
 } // namespace mozilla
@@ -53,16 +47,25 @@ public:
                               bool* aWillNotify,
                               bool* aIsAlternate) MOZ_OVERRIDE;
   NS_IMETHOD SetEnableUpdates(bool aEnableUpdates) MOZ_OVERRIDE;
   NS_IMETHOD GetCharset(nsAString& aCharset) MOZ_OVERRIDE;
 
   virtual void OverrideBaseURI(nsIURI* aNewBaseURI) MOZ_OVERRIDE;
   virtual void SetLineNumber(uint32_t aLineNumber) MOZ_OVERRIDE;
 
+  enum RelValue {
+    ePREFETCH =     0x00000001,
+    eDNS_PREFETCH = 0x00000002,
+    eSTYLESHEET =   0x00000004,
+    eNEXT =         0x00000008,
+    eALTERNATE =    0x00000010,
+  };
+
+  // The return value is a bitwise or of 0 or more RelValues
   static uint32_t ParseLinkTypes(const nsAString& aTypes);
 
   void UpdateStyleSheetInternal()
   {
     UpdateStyleSheetInternal(nullptr, nullptr);
   }
 protected:
   /**
--- a/content/base/src/nsStyledElement.cpp
+++ b/content/base/src/nsStyledElement.cpp
@@ -4,17 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsStyledElement.h"
 #include "nsGkAtoms.h"
 #include "nsAttrValue.h"
 #include "nsAttrValueInlines.h"
 #include "mozilla/dom/ElementInlines.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsDOMCSSDeclaration.h"
 #include "nsDOMCSSAttrDeclaration.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIDocument.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsCSSParser.h"
 #include "mozilla/css/Loader.h"
 #include "nsIDOMMutationEvent.h"
--- a/content/base/test/mochitest.ini
+++ b/content/base/test/mochitest.ini
@@ -448,16 +448,17 @@ skip-if = toolkit == 'android' #bug 6870
 [test_bug622117.html]
 [test_bug622246.html]
 [test_bug625722.html]
 [test_bug626262.html]
 [test_bug628938.html]
 [test_bug631615.html]
 [test_bug638112.html]
 [test_bug647518.html]
+[test_bug650001.html]
 [test_bug656283.html]
 [test_bug664916.html]
 [test_bug666604.html]
 [test_bug675121.html]
 [test_bug675166.html]
 [test_bug682463.html]
 [test_bug682554.html]
 [test_bug682592.html]
new file mode 100644
--- /dev/null
+++ b/content/base/test/test_bug650001.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=650001
+-->
+<head>
+  <title>Test for Bug 650001</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=650001">Mozilla Bug 650001</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 650001 **/
+
+var svg = '<svg><style xml:lang="en" xlink:href="foo" xmlns="bar" xmlns:link="qux">&lt;&gt;</style><script>&lt;&gt;<\/script></svg>';
+var div = document.getElementById("content");
+div.innerHTML = svg;
+is(div.innerHTML, svg, "Unexpected serialization.");
+
+</script>
+</pre>
+</body>
+</html>
--- a/content/html/content/src/HTMLInputElement.cpp
+++ b/content/html/content/src/HTMLInputElement.cpp
@@ -56,17 +56,17 @@
 #include "nsLinebreakConverter.h" //to strip out carriage returns
 #include "nsReadableUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsEventDispatcher.h"
 #include "nsLayoutUtils.h"
 
 #include "nsIDOMMutationEvent.h"
 #include "mozilla/ContentEvents.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "nsEventListenerManager.h"
 
 #include "nsRuleData.h"
 #include <algorithm>
 
 // input type=radio
--- a/content/html/content/src/HTMLInputElement.h
+++ b/content/html/content/src/HTMLInputElement.h
@@ -606,17 +606,17 @@ public:
 
   Nullable<Date> GetValueAsDate(ErrorResult& aRv);
 
   void SetValueAsDate(Nullable<Date>, ErrorResult& aRv);
 
   double ValueAsNumber() const
   {
     return DoesValueAsNumberApply() ? GetValueAsDecimal().toDouble()
-                                    : UnspecifiedNaN();
+                                    : UnspecifiedNaN<double>();
   }
 
   void SetValueAsNumber(double aValue, ErrorResult& aRv);
 
   uint32_t Width();
 
   void SetWidth(uint32_t aValue, ErrorResult& aRv)
   {
--- a/content/html/content/src/HTMLLinkElement.cpp
+++ b/content/html/content/src/HTMLLinkElement.cpp
@@ -1,8 +1,9 @@
+
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/HTMLLinkElement.h"
 
 #include "mozilla/Attributes.h"
@@ -250,17 +251,17 @@ HTMLLinkElement::SetAttr(int32_t aNameSp
       (aName == nsGkAtoms::href ||
        aName == nsGkAtoms::rel ||
        aName == nsGkAtoms::title ||
        aName == nsGkAtoms::media ||
        aName == nsGkAtoms::type)) {
     bool dropSheet = false;
     if (aName == nsGkAtoms::rel && GetSheet()) {
       uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(aValue);
-      dropSheet = !(linkTypes & STYLESHEET);          
+      dropSheet = !(linkTypes & nsStyleLinkElement::eSTYLESHEET);
     }
     
     UpdateStyleSheetInternal(nullptr, nullptr,
                              dropSheet ||
                              (aName == nsGkAtoms::title ||
                               aName == nsGkAtoms::media ||
                               aName == nsGkAtoms::type));
   }
@@ -355,27 +356,27 @@ HTMLLinkElement::GetStyleSheetInfo(nsASt
   aMedia.Truncate();
   *aIsScoped = false;
   *aIsAlternate = false;
 
   nsAutoString rel;
   GetAttr(kNameSpaceID_None, nsGkAtoms::rel, rel);
   uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(rel);
   // Is it a stylesheet link?
-  if (!(linkTypes & STYLESHEET)) {
+  if (!(linkTypes & nsStyleLinkElement::eSTYLESHEET)) {
     return;
   }
 
   nsAutoString title;
   GetAttr(kNameSpaceID_None, nsGkAtoms::title, title);
   title.CompressWhitespace();
   aTitle.Assign(title);
 
   // If alternate, does it have title?
-  if (linkTypes & ALTERNATE) {
+  if (linkTypes & nsStyleLinkElement::eALTERNATE) {
     if (aTitle.IsEmpty()) { // alternates must have title
       return;
     } else {
       *aIsAlternate = true;
     }
   }
 
   GetAttr(kNameSpaceID_None, nsGkAtoms::media, aMedia);
--- a/content/html/content/src/HTMLPropertiesCollection.cpp
+++ b/content/html/content/src/HTMLPropertiesCollection.cpp
@@ -218,17 +218,16 @@ HTMLPropertiesCollection::EnsureFresh()
   mProperties.Sort(comparator);
 
   // Create the names DOMStringList
   uint32_t count = mProperties.Length();
   for (uint32_t i = 0; i < count; ++i) {
     const nsAttrValue* attr = mProperties.ElementAt(i)->GetParsedAttr(nsGkAtoms::itemprop); 
     for (uint32_t i = 0; i < attr->GetAtomCount(); i++) {
       nsDependentAtomString propName(attr->AtomAt(i));
-      // ContainsInternal must not call EnsureFresh
       bool contains = mNames->ContainsInternal(propName);
       if (!contains) {
         mNames->Add(propName);
       }
     }
   }
 }
 
@@ -487,55 +486,36 @@ PropertyNodeList::EnsureFresh()
     const nsAttrValue* attr = element->GetParsedAttr(nsGkAtoms::itemprop);
     if (attr->Contains(mName)) {
       AppendElement(element);
     }
   }
 }
 
 PropertyStringList::PropertyStringList(HTMLPropertiesCollection* aCollection)
-  : nsDOMStringList()
+  : DOMStringList()
   , mCollection(aCollection)
 { }
 
-NS_IMPL_CYCLE_COLLECTION_1(PropertyStringList, mCollection)
+NS_IMPL_CYCLE_COLLECTION_INHERITED_1(PropertyStringList, DOMStringList,
+                                     mCollection)
 
-NS_IMPL_CYCLE_COLLECTING_ADDREF(PropertyStringList)
-NS_IMPL_CYCLE_COLLECTING_RELEASE(PropertyStringList)
+NS_IMPL_ADDREF_INHERITED(PropertyStringList, DOMStringList)
+NS_IMPL_RELEASE_INHERITED(PropertyStringList, DOMStringList)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PropertyStringList)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMDOMStringList)
-  NS_INTERFACE_MAP_ENTRY(nsISupports)
-  NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMStringList)
-NS_INTERFACE_MAP_END
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(PropertyStringList)
+NS_INTERFACE_MAP_END_INHERITING(DOMStringList)
 
-NS_IMETHODIMP
-PropertyStringList::Item(uint32_t aIndex, nsAString& aResult)
+void
+PropertyStringList::EnsureFresh()
 {
   mCollection->EnsureFresh();
-  return nsDOMStringList::Item(aIndex, aResult);
-}
-
-NS_IMETHODIMP
-PropertyStringList::GetLength(uint32_t* aLength)
-{
-  mCollection->EnsureFresh();
-  return nsDOMStringList::GetLength(aLength);
-}
-
-NS_IMETHODIMP
-PropertyStringList::Contains(const nsAString& aString, bool* aResult)
-{
-  mCollection->EnsureFresh();
-  return nsDOMStringList::Contains(aString, aResult);
 }
 
 bool
 PropertyStringList::ContainsInternal(const nsAString& aString)
 {
   // This method should not call EnsureFresh, otherwise we may become stuck in an infinite loop.
-  bool result;
-  nsDOMStringList::Contains(aString, &result);
-  return result;
+  return mNames.Contains(aString);
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/HTMLPropertiesCollection.h
+++ b/content/html/content/src/HTMLPropertiesCollection.h
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef HTMLPropertiesCollection_h_
 #define HTMLPropertiesCollection_h_
 
 #include "mozilla/Attributes.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 #include "nsIMutationObserver.h"
 #include "nsStubMutationObserver.h"
 #include "nsBaseHashtable.h"
 #include "nsINodeList.h"
 #include "nsIHTMLCollection.h"
@@ -26,27 +26,28 @@ class nsINode;
 
 namespace mozilla {
 namespace dom {
 
 class HTMLPropertiesCollection;
 class PropertyNodeList;
 class Element;
 
-class PropertyStringList : public nsDOMStringList
+class PropertyStringList : public DOMStringList
 {
 public:
   PropertyStringList(HTMLPropertiesCollection* aCollection);
-  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
-  NS_DECL_CYCLE_COLLECTION_CLASS(PropertyStringList)
-  NS_DECL_NSIDOMDOMSTRINGLIST
+  NS_DECL_ISUPPORTS_INHERITED
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(PropertyStringList, DOMStringList)
 
   bool ContainsInternal(const nsAString& aString);
 
 protected:
+  virtual void EnsureFresh() MOZ_OVERRIDE;
+
   nsRefPtr<HTMLPropertiesCollection> mCollection;
 };
 
 class HTMLPropertiesCollection : public nsIHTMLCollection,
                                  public nsStubMutationObserver,
                                  public nsWrapperCache
 {
   friend class PropertyNodeList;
@@ -81,17 +82,17 @@ public:
     return nullptr;
   }
   PropertyNodeList* NamedItem(const nsAString& aName);
   PropertyNodeList* NamedGetter(const nsAString& aName, bool& aFound)
   {
     aFound = IsSupportedNamedProperty(aName);
     return aFound ? NamedItem(aName) : nullptr;
   }
-  nsDOMStringList* Names()
+  DOMStringList* Names()
   {
     EnsureFresh();
     return mNames;
   }
   virtual void GetSupportedNames(nsTArray<nsString>& aNames) MOZ_OVERRIDE;
 
   NS_DECL_NSIDOMHTMLCOLLECTION
 
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -65,17 +65,17 @@
 #include "nsITextControlFrame.h"
 #include "nsIForm.h"
 #include "nsIFormControl.h"
 #include "nsIDOMHTMLFormElement.h"
 #include "mozilla/dom/HTMLFormElement.h"
 #include "nsFocusManager.h"
 #include "nsAttrValueOrString.h"
 
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsDOMStringMap.h"
 
 #include "nsIEditor.h"
 #include "nsIEditorIMESupport.h"
 #include "nsEventDispatcher.h"
 #include "nsLayoutUtils.h"
 #include "mozAutoDocUpdate.h"
 #include "nsHtml5Module.h"
--- a/content/media/mediasource/MediaSource.cpp
+++ b/content/media/mediasource/MediaSource.cpp
@@ -75,17 +75,17 @@ MediaSource::ReadyState()
 {
   return mReadyState;
 }
 
 double
 MediaSource::Duration()
 {
   if (mReadyState == MediaSourceReadyState::Closed) {
-    return UnspecifiedNaN();
+    return UnspecifiedNaN<double>();
   }
   return mDuration;
 }
 
 void
 MediaSource::SetDuration(double aDuration, ErrorResult& aRv)
 {
   if (aDuration < 0 || IsNaN(aDuration)) {
@@ -192,25 +192,25 @@ MediaSource::Attach(MediaSourceDecoder* 
 
 void
 MediaSource::Detach()
 {
   LOG(PR_LOG_DEBUG, ("%p Detaching decoder %p owner %p", this, mDecoder.get(), mDecoder->GetOwner()));
   MOZ_ASSERT(mDecoder);
   mDecoder->DetachMediaSource();
   mDecoder = nullptr;
-  mDuration = UnspecifiedNaN();
+  mDuration = UnspecifiedNaN<double>();
   mActiveSourceBuffers->Clear();
   mSourceBuffers->Clear();
   SetReadyState(MediaSourceReadyState::Closed);
 }
 
 MediaSource::MediaSource(nsPIDOMWindow* aWindow)
   : nsDOMEventTargetHelper(aWindow)
-  , mDuration(UnspecifiedNaN())
+  , mDuration(UnspecifiedNaN<double>())
   , mDecoder(nullptr)
   , mReadyState(MediaSourceReadyState::Closed)
 {
   mSourceBuffers = new SourceBufferList(this);
   mActiveSourceBuffers = new SourceBufferList(this);
 
 #ifdef PR_LOGGING
   if (!gMediaSourceLog) {
--- a/content/media/mediasource/SourceBuffer.cpp
+++ b/content/media/mediasource/SourceBuffer.cpp
@@ -195,17 +195,17 @@ SourceBuffer::Abort(ErrorResult& aRv)
     return;
   }
   if (mUpdating) {
     // TODO: Abort segment parser loop, buffer append, and stream append loop algorithms.
     AbortUpdating();
   }
   // TODO: Run reset parser algorithm.
   mAppendWindowStart = 0;
-  mAppendWindowEnd = PositiveInfinity();
+  mAppendWindowEnd = PositiveInfinity<double>();
 }
 
 void
 SourceBuffer::Remove(double aStart, double aEnd, ErrorResult& aRv)
 {
   if (!IsAttached() || mUpdating ||
       mMediaSource->ReadyState() != MediaSourceReadyState::Open) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
@@ -234,17 +234,17 @@ SourceBuffer::Ended()
 {
   mDecoder->GetResource()->Ended();
 }
 
 SourceBuffer::SourceBuffer(MediaSource* aMediaSource, const nsACString& aType)
   : nsDOMEventTargetHelper(aMediaSource->GetParentObject())
   , mMediaSource(aMediaSource)
   , mAppendWindowStart(0)
-  , mAppendWindowEnd(PositiveInfinity())
+  , mAppendWindowEnd(PositiveInfinity<double>())
   , mTimestampOffset(0)
   , mAppendMode(SourceBufferAppendMode::Segments)
   , mUpdating(false)
 {
   MOZ_ASSERT(aMediaSource);
   MediaSourceDecoder* parentDecoder = aMediaSource->GetDecoder();
   mDecoder = parentDecoder->CreateSubDecoder(aType);
   MOZ_ASSERT(mDecoder);
--- a/content/media/webaudio/AnalyserNode.cpp
+++ b/content/media/webaudio/AnalyserNode.cpp
@@ -176,16 +176,27 @@ AnalyserNode::GetByteFrequencyData(const
     // scale down the value to the range of [0, UCHAR_MAX]
     const double scaled = std::max(0.0, std::min(double(UCHAR_MAX),
                                                  UCHAR_MAX * (decibels - mMinDecibels) * rangeScaleFactor));
     buffer[i] = static_cast<unsigned char>(scaled);
   }
 }
 
 void
+AnalyserNode::GetFloatTimeDomainData(const Float32Array& aArray)
+{
+  float* buffer = aArray.Data();
+  uint32_t length = std::min(aArray.Length(), mBuffer.Length());
+
+  for (uint32_t i = 0; i < length; ++i) {
+    buffer[i] = mBuffer[(i + mWriteIndex) % mBuffer.Length()];;
+  }
+}
+
+void
 AnalyserNode::GetByteTimeDomainData(const Uint8Array& aArray)
 {
   unsigned char* buffer = aArray.Data();
   uint32_t length = std::min(aArray.Length(), mBuffer.Length());
 
   for (uint32_t i = 0; i < length; ++i) {
     const float value = mBuffer[(i + mWriteIndex) % mBuffer.Length()];
     // scale the value to the range of [0, UCHAR_MAX]
--- a/content/media/webaudio/AnalyserNode.h
+++ b/content/media/webaudio/AnalyserNode.h
@@ -22,16 +22,17 @@ public:
 
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
   void GetFloatFrequencyData(const Float32Array& aArray);
   void GetByteFrequencyData(const Uint8Array& aArray);
+  void GetFloatTimeDomainData(const Float32Array& aArray);
   void GetByteTimeDomainData(const Uint8Array& aArray);
   uint32_t FftSize() const
   {
     return mAnalysisBlock.FFTSize();
   }
   void SetFftSize(uint32_t aValue, ErrorResult& aRv);
   uint32_t FrequencyBinCount() const
   {
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -9,17 +9,17 @@
 #include "nsSVGElement.h"
 
 #include "mozilla/dom/SVGSVGElement.h"
 #include "mozilla/dom/SVGTests.h"
 #include "nsContentUtils.h"
 #include "nsICSSDeclaration.h"
 #include "nsIDocument.h"
 #include "nsIDOMMutationEvent.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsError.h"
 #include "nsIPresShell.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/xml/document/src/nsXMLContentSink.cpp
+++ b/content/xml/document/src/nsXMLContentSink.cpp
@@ -601,25 +601,25 @@ nsXMLContentSink::CloseElement(nsIConten
     }
     // Look for <link rel="dns-prefetch" href="hostname">
     // and look for <link rel="next" href="hostname"> like in HTML sink
     if (nodeInfo->Equals(nsGkAtoms::link, kNameSpaceID_XHTML)) {
       nsAutoString relVal;
       aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::rel, relVal);
       if (!relVal.IsEmpty()) {
         uint32_t linkTypes = nsStyleLinkElement::ParseLinkTypes(relVal);
-        bool hasPrefetch = linkTypes & PREFETCH;
-        if (hasPrefetch || (linkTypes & NEXT)) {
+        bool hasPrefetch = linkTypes & nsStyleLinkElement::ePREFETCH;
+        if (hasPrefetch || (linkTypes & nsStyleLinkElement::eNEXT)) {
           nsAutoString hrefVal;
           aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
           if (!hrefVal.IsEmpty()) {
             PrefetchHref(hrefVal, aContent, hasPrefetch);
           }
         }
-        if (linkTypes & DNS_PREFETCH) {
+        if (linkTypes & nsStyleLinkElement::eDNS_PREFETCH) {
           nsAutoString hrefVal;
           aContent->GetAttr(kNameSpaceID_None, nsGkAtoms::href, hrefVal);
           if (!hrefVal.IsEmpty()) {
             PrefetchDNS(hrefVal);
           }
         }
       }
     }
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -68,18 +68,18 @@
 #include "XULDocument.h"
 #include "nsXULPopupListener.h"
 #include "nsRuleWalker.h"
 #include "nsIDOMCSSStyleDeclaration.h"
 #include "nsCSSParser.h"
 #include "nsIListBoxObject.h"
 #include "nsContentUtils.h"
 #include "nsContentList.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "nsAsyncDOMEvent.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsPIDOMWindow.h"
 #include "nsJSPrincipals.h"
 #include "nsDOMAttributeMap.h"
 #include "nsGkAtoms.h"
 #include "nsXULContentUtils.h"
 #include "nsNodeUtils.h"
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -69,17 +69,16 @@
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMJSWindow.h"
 #include "nsIDOMChromeWindow.h"
 #include "nsIDOMConstructor.h"
 
 // DOM core includes
 #include "nsError.h"
-#include "nsIDOMDOMStringList.h"
 #include "nsIDOMUserDataHandler.h"
 #include "nsIDOMXPathNamespace.h"
 #include "nsIDOMXULButtonElement.h"
 #include "nsIDOMXULCheckboxElement.h"
 #include "nsIDOMXULPopupElement.h"
 
 // Event related includes
 #include "nsIDOMEventTarget.h"
@@ -351,19 +350,16 @@ static nsDOMClassInfoData sClassInfoData
 #ifdef MOZ_XUL
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULTemplateBuilder, nsDOMGenericSH,
                                       DEFAULT_SCRIPTABLE_FLAGS)
 
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(XULTreeBuilder, nsDOMGenericSH,
                                       DEFAULT_SCRIPTABLE_FLAGS)
 #endif
 
-  NS_DEFINE_CLASSINFO_DATA(DOMStringList, nsStringListSH,
-                           ARRAY_SCRIPTABLE_FLAGS)
-
 #ifdef MOZ_XUL
   NS_DEFINE_CHROME_XBL_CLASSINFO_DATA(TreeColumn, nsDOMGenericSH,
                                       DEFAULT_SCRIPTABLE_FLAGS)
 #endif
 
   NS_DEFINE_CLASSINFO_DATA(CSSMozDocumentRule, nsDOMGenericSH,
                            DOM_DEFAULT_SCRIPTABLE_FLAGS)
 
@@ -1009,20 +1005,16 @@ nsDOMClassInfo::Init()
 
   DOM_CLASSINFO_MAP_BEGIN(XULTreeBuilder, nsIXULTreeBuilder)
     DOM_CLASSINFO_MAP_ENTRY(nsIXULTreeBuilder)
     DOM_CLASSINFO_MAP_ENTRY(nsIXULTemplateBuilder)
     DOM_CLASSINFO_MAP_ENTRY(nsITreeView)
   DOM_CLASSINFO_MAP_END
 #endif
 
-  DOM_CLASSINFO_MAP_BEGIN(DOMStringList, nsIDOMDOMStringList)
-    DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMStringList)
-  DOM_CLASSINFO_MAP_END
-
 #ifdef MOZ_XUL
   DOM_CLASSINFO_MAP_BEGIN(TreeColumn, nsITreeColumn)
     DOM_CLASSINFO_MAP_ENTRY(nsITreeColumn)
   DOM_CLASSINFO_MAP_END
 #endif
 
   DOM_CLASSINFO_MAP_BEGIN(CSSMozDocumentRule, nsIDOMCSSMozDocumentRule)
     DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSMozDocumentRule)
@@ -3695,71 +3687,16 @@ nsArraySH::GetProperty(nsIXPConnectWrapp
       rv = NS_SUCCESS_I_DID_SOMETHING;
     }
   }
 
   return rv;
 }
 
 
-// StringList scriptable helper
-
-nsresult
-nsStringListSH::GetStringAt(nsISupports *aNative, int32_t aIndex,
-                            nsAString& aResult)
-{
-  nsCOMPtr<nsIDOMDOMStringList> list(do_QueryInterface(aNative));
-  NS_ENSURE_TRUE(list, NS_ERROR_UNEXPECTED);
-
-  nsresult rv = list->Item(aIndex, aResult);
-#ifdef DEBUG
-  if (DOMStringIsNull(aResult)) {
-    uint32_t length = 0;
-    list->GetLength(&length);
-    NS_ASSERTION(uint32_t(aIndex) >= length, "Item should only return null for out-of-bounds access");
-  }
-#endif
-  return rv;
-}
-
-
-// StringArray helper
-
-NS_IMETHODIMP
-nsStringArraySH::GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
-                             JSObject *aObj, jsid aId, jsval *vp,
-                             bool *_retval)
-{
-  JS::Rooted<JSObject*> obj(cx, aObj);
-  JS::Rooted<jsid> id(cx, aId);
-  bool is_number = false;
-  int32_t n = GetArrayIndexFromId(cx, id, &is_number);
-
-  if (!is_number) {
-    return NS_OK;
-  }
-
-  nsAutoString val;
-
-  nsresult rv = GetStringAt(GetNative(wrapper, obj), n, val);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (DOMStringIsNull(val)) {
-    *vp = JSVAL_VOID;
-    return NS_SUCCESS_I_DID_SOMETHING;
-  }
-
-  JS::Rooted<JS::Value> rval(cx);
-  NS_ENSURE_TRUE(xpc::NonVoidStringToJsval(cx, val, &rval),
-                 NS_ERROR_OUT_OF_MEMORY);
-  *vp = rval;
-  return NS_SUCCESS_I_DID_SOMETHING;
-}
-
-
 // StyleSheetList helper
 
 nsISupports*
 nsStyleSheetListSH::GetItemAt(nsISupports *aNative, uint32_t aIndex,
                               nsWrapperCache **aCache, nsresult *rv)
 {
   nsIDOMStyleSheetList* list = static_cast<nsIDOMStyleSheetList*>(aNative);
   nsCOMPtr<nsIDOMStyleSheet> sheet;
--- a/dom/base/nsDOMClassInfo.h
+++ b/dom/base/nsDOMClassInfo.h
@@ -369,64 +369,16 @@ public:
                          JSObject *obj, jsid id, JS::Value *vp, bool *_retval) MOZ_OVERRIDE;
 
 private:
   // Not implemented, nothing should create an instance of this class.
   static nsIClassInfo *doCreate(nsDOMClassInfoData* aData);
 };
 
 
-// String array helper
-
-class nsStringArraySH : public nsGenericArraySH
-{
-protected:
-  nsStringArraySH(nsDOMClassInfoData* aData) : nsGenericArraySH(aData)
-  {
-  }
-
-  virtual ~nsStringArraySH()
-  {
-  }
-
-  virtual nsresult GetStringAt(nsISupports *aNative, int32_t aIndex,
-                               nsAString& aResult) = 0;
-
-public:
-  NS_IMETHOD GetProperty(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
-                         JSObject *obj, jsid id, JS::Value *vp, bool *_retval) MOZ_OVERRIDE;
-};
-
-
-// StringList scriptable helper
-
-class nsStringListSH : public nsStringArraySH
-{
-protected:
-  nsStringListSH(nsDOMClassInfoData* aData) : nsStringArraySH(aData)
-  {
-  }
-
-  virtual ~nsStringListSH()
-  {
-  }
-
-  virtual nsresult GetStringAt(nsISupports *aNative, int32_t aIndex,
-                               nsAString& aResult) MOZ_OVERRIDE;
-
-public:
-  // Inherit GetProperty, Enumerate from nsStringArraySH
-  
-  static nsIClassInfo *doCreate(nsDOMClassInfoData* aData)
-  {
-    return new nsStringListSH(aData);
-  }
-};
-
-
 // StyleSheetList helper
 
 class nsStyleSheetListSH : public nsArraySH
 {
 protected:
   nsStyleSheetListSH(nsDOMClassInfoData* aData) : nsArraySH(aData)
   {
   }
--- a/dom/base/nsDOMClassInfoClasses.h
+++ b/dom/base/nsDOMClassInfoClasses.h
@@ -33,19 +33,16 @@ DOMCI_CLASS(TreeContentView)
 // DOM Chrome Window class, almost identical to Window
 DOMCI_CLASS(ChromeWindow)
 
 #ifdef MOZ_XUL
 DOMCI_CLASS(XULTemplateBuilder)
 DOMCI_CLASS(XULTreeBuilder)
 #endif
 
-// DOMStringList object
-DOMCI_CLASS(DOMStringList)
-
 #ifdef MOZ_XUL
 DOMCI_CLASS(TreeColumn)
 #endif
 
 DOMCI_CLASS(CSSMozDocumentRule)
 DOMCI_CLASS(CSSSupportsRule)
 
 // other SVG classes
--- a/dom/base/nsDOMClassInfoID.h
+++ b/dom/base/nsDOMClassInfoID.h
@@ -57,31 +57,33 @@ DOMCI_CASTABLE_NODECL_INTERFACE(mozilla:
 DOMCI_CASTABLE_INTERFACE(nsDOMEvent, nsIDOMEvent, 3, _extra)                  \
 DOMCI_CASTABLE_INTERFACE(nsIDocument, nsIDocument, 4, _extra)                 \
 DOMCI_CASTABLE_INTERFACE(nsDocument, nsIDocument, 5, _extra)                  \
 DOMCI_CASTABLE_INTERFACE(nsGenericHTMLElement, nsIContent, 6, _extra)         \
 DOMCI_CASTABLE_INTERFACE(nsHTMLDocument, nsIDocument, 7, _extra)              \
 DOMCI_CASTABLE_INTERFACE(nsStyledElement, nsStyledElement, 8, _extra)         \
 DOMCI_CASTABLE_INTERFACE(nsSVGElement, nsIContent, 9, _extra)                 \
 /* NOTE: When removing the casts below, remove the nsDOMEventBase class */    \
-DOMCI_CASTABLE_INTERFACE(nsDOMMouseEvent, nsDOMEventBase, 10, _extra)         \
+DOMCI_CASTABLE_NODECL_INTERFACE(mozilla::dom::MouseEvent,                     \
+                                nsDOMEventBase, 10, _extra)                   \
 DOMCI_CASTABLE_INTERFACE(nsDOMUIEvent, nsDOMEventBase, 11, _extra)            \
 DOMCI_CASTABLE_INTERFACE(nsGlobalWindow, nsIDOMEventTarget, 12, _extra)
 
 // Make sure all classes mentioned in DOMCI_CASTABLE_INTERFACES
 // have been declared.
 #define DOMCI_CASTABLE_NODECL_INTERFACE(_interface, _u1, _u2, _u3) /* Nothing */
 #define DOMCI_CASTABLE_INTERFACE(_interface, _u1, _u2, _u3) class _interface;
 DOMCI_CASTABLE_INTERFACES(unused)
 #undef DOMCI_CASTABLE_INTERFACE
 #undef DOMCI_CASTABLE_NODECL_INTERFACE
 namespace mozilla {
 namespace dom {
 class Element;
 class EventTarget;
+class MouseEvent;
 } // namespace dom
 } // namespace mozilla
 
 #define DOMCI_CASTABLE_NODECL_INTERFACE DOMCI_CASTABLE_INTERFACE
 
 #ifdef MOZILLA_INTERNAL_API
 
 #define DOMCI_CLASS(_dom_class)                                               \
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -308,27 +308,21 @@ DOMInterfaces = {
     'workers': True,
 },
 
 'DelayNode': {
     'resultNotAddRefed': [ 'delayTime' ],
 },
 
 'DeviceAcceleration': {
-    'nativeType': 'nsDOMDeviceAcceleration',
-    'headerFile': 'nsDOMDeviceMotionEvent.h',
-},
-
-'DeviceMotionEvent': {
-    'nativeType': 'nsDOMDeviceMotionEvent',
+    'headerFile': 'mozilla/dom/DeviceMotionEvent.h',
 },
 
 'DeviceRotationRate': {
-    'nativeType': 'nsDOMDeviceRotationRate',
-    'headerFile': 'nsDOMDeviceMotionEvent.h',
+    'headerFile': 'mozilla/dom/DeviceMotionEvent.h',
 },
 
 'DeviceStorage': {
     'nativeType': 'nsDOMDeviceStorage',
     'headerFile': 'DeviceStorage.h',
 },
 
 'Document': [
@@ -366,20 +360,16 @@ DOMInterfaces = {
 'DOMStringMap': {
     'nativeType': 'nsDOMStringMap'
 },
 
 'DOMTokenList': {
     'nativeType': 'nsDOMTokenList',
 },
 
-'DragEvent': {
-    'nativeType': 'nsDOMDragEvent',
-},
-
 'DummyInterface': {
     'skipGen': True,
     'register': False,
 },
 
 'DummyInterfaceWorkers': {
     'skipGen': True,
     'register': False,
@@ -449,20 +439,16 @@ DOMInterfaces = {
     'nativeType': 'nsFormData'
 },
 {
     'workers': True,
     'skipGen': True,
     'nativeType': 'JSObject'
 }],
 
-'FocusEvent': {
-    'nativeType': 'nsDOMFocusEvent',
-},
-
 'GainNode': {
     'resultNotAddRefed': [ 'gain' ],
 },
 
 'Geolocation': {
     'headerFile': 'nsGeolocation.h'
 },
 
@@ -690,20 +676,16 @@ DOMInterfaces = {
 {
     'nativeType': 'nsIInputStream',
     'notflattened': True
 },
 {
     'workers': True,
 }],
 
-'KeyboardEvent': {
-    'nativeType': 'nsDOMKeyboardEvent',
-},
-
 'KeyEvent': {
     'concrete': False
 },
 
 'LocalMediaStream': {
     'headerFile': 'DOMMediaStream.h',
     'nativeType': 'mozilla::DOMLocalMediaStream'
 },
@@ -755,20 +737,16 @@ DOMInterfaces = {
     'concrete': False
 },
 
 'MediaRecorder': {
     'headerFile': 'MediaRecorder.h',
     'resultNotAddRefed': [ 'stream' ]
 },
 
-'MessageEvent': {
-    'nativeType': 'nsDOMMessageEvent',
-},
-
 'MessagePort': {
     'nativeType': 'mozilla::dom::MessagePortBase',
     'headerFile': 'mozilla/dom/MessagePort.h',
     'binaryNames': {
         'postMessage': 'postMessageMoz',
     },
 },
 
@@ -778,24 +756,16 @@ DOMInterfaces = {
     'resultNotAddRefed': [ 'enabledPlugin' ]
 },
 
 'MimeTypeArray': {
     'nativeType': 'nsMimeTypeArray',
     'resultNotAddRefed': [ 'item', 'namedItem' ]
 },
 
-'MouseEvent': {
-    'nativeType': 'nsDOMMouseEvent',
-},
-
-'MouseScrollEvent': {
-    'nativeType': 'nsDOMMouseScrollEvent',
-},
-
 'MozCanvasPrintState': {
     'headerFile': 'mozilla/dom/HTMLCanvasElement.h',
     'nativeType': 'mozilla::dom::HTMLCanvasPrintState',
 },
 
 'MozChannel': [
 {
     'nativeType': 'nsIChannel',
@@ -842,20 +812,16 @@ DOMInterfaces = {
 'MozTimeManager': {
     'nativeType': 'mozilla::dom::time::TimeManager',
 },
 
 'MozVoicemail': {
     'nativeType': 'mozilla::dom::Voicemail',
 },
 
-'MutationEvent': {
-    'nativeType': 'nsDOMMutationEvent',
-},
-
 'MutationObserver': {
     'nativeType': 'nsDOMMutationObserver',
 },
 
 'MutationRecord': {
     'nativeType': 'nsDOMMutationRecord',
     'headerFile': 'nsDOMMutationObserver.h',
     'resultNotAddRefed': [ 'target', 'addedNodes', 'removedNodes',
@@ -1015,20 +981,16 @@ DOMInterfaces = {
     'implicitJSContext': [ 'constructor' ],
 },
 
 'SharedWorkerGlobalScope': {
     'headerFile': 'mozilla/dom/WorkerScope.h',
     'workers': True,
 },
 
-'SimpleGestureEvent': {
-    'nativeType': 'nsDOMSimpleGestureEvent',
-},
-
 'SourceBufferList': {
     'resultNotAddRefed': [ '__indexedGetter' ],
 },
 
 'StyleSheet': {
     'nativeType': 'nsCSSStyleSheet',
 },
 
@@ -1905,17 +1867,16 @@ def addExternalIface(iface, nativeType=N
 
 addExternalIface('ApplicationCache', nativeType='nsIDOMOfflineResourceList')
 addExternalIface('ActivityOptions', nativeType='nsIDOMMozActivityOptions',
                  headerFile='nsIDOMActivityOptions.h')
 addExternalIface('Counter')
 addExternalIface('CSSRule')
 addExternalIface('mozIDOMApplication', nativeType='mozIDOMApplication', headerFile='nsIDOMApplicationRegistry.h')
 addExternalIface('CSSRuleList')
-addExternalIface('DOMStringList')
 addExternalIface('RTCDataChannel', nativeType='nsIDOMDataChannel')
 addExternalIface('File')
 addExternalIface('HitRegionOptions', nativeType='nsISupports')
 addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
 addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)
 addExternalIface('LockedFile')
 addExternalIface('MenuBuilder', nativeType='nsIMenuBuilder', notflattened=True)
 addExternalIface('MozBoxObject', nativeType='nsIBoxObject')
--- a/dom/bindings/Codegen.py
+++ b/dom/bindings/Codegen.py
@@ -2625,22 +2625,23 @@ numericSuffixes = {
     IDLType.Tags.float: 'F',
     IDLType.Tags.unrestricted_double: '',
     IDLType.Tags.double: ''
 }
 
 def numericValue(t, v):
     if (t == IDLType.Tags.unrestricted_double or
         t == IDLType.Tags.unrestricted_float):
+        typeName = builtinNames[t]
         if v == float("inf"):
-            return "mozilla::PositiveInfinity()"
+            return "mozilla::PositiveInfinity<%s>()" % typeName
         if v == float("-inf"):
-            return "mozilla::NegativeInfinity()"
+            return "mozilla::NegativeInfinity<%s>()" % typeName
         if math.isnan(v):
-            return "mozilla::UnspecifiedNaN()"
+            return "mozilla::UnspecifiedNaN<%s>()" % typeName
     return "%s%s" % (v, numericSuffixes[t])
 
 class CastableObjectUnwrapper():
     """
     A class for unwrapping an object named by the "source" argument
     based on the passed-in descriptor and storing it in a variable
     called by the name in the "target" argument.
 
@@ -5446,36 +5447,42 @@ class CGMethodCall(CGThing):
                     CGWrapper(CGIndenter(CGGeneric(code)), pre="\n", post="\n"))
             return
 
         # Need to find the right overload
         maxArgCount = method.maxArgCount
         allowedArgCounts = method.allowedArgCounts
 
         argCountCases = []
-        for argCount in allowedArgCounts:
+        for (argCountIdx, argCount) in enumerate(allowedArgCounts):
             possibleSignatures = method.signaturesForArgCount(argCount)
+
+            # Try to optimize away cases when the next argCount in the list
+            # will have the same code as us; if it does, we can fall through to
+            # that case.
+            if argCountIdx+1 < len(allowedArgCounts):
+                nextPossibleSignatures = \
+                    method.signaturesForArgCount(allowedArgCounts[argCountIdx+1])
+            else:
+                nextPossibleSignatures = None
+            if possibleSignatures == nextPossibleSignatures:
+                # Same set of signatures means we better have the same
+                # distinguishing index.  So we can in fact just fall through to
+                # the next case here.
+                assert (len(possibleSignatures) == 1 or
+                        (method.distinguishingIndexForArgCount(argCount) ==
+                         method.distinguishingIndexForArgCount(allowedArgCounts[argCountIdx+1])))
+                argCountCases.append(CGCase(str(argCount), None, True))
+                continue
+
             if len(possibleSignatures) == 1:
                 # easy case!
                 signature = possibleSignatures[0]
-
-                # (possibly) important optimization: if signature[1] has >
-                # argCount arguments and signature[1][argCount] is optional and
-                # there is only one signature for argCount+1, then the
-                # signature for argCount+1 is just ourselves and we can fall
-                # through.
-                if (len(signature[1]) > argCount and
-                    signature[1][argCount].optional and
-                    (argCount+1) in allowedArgCounts and
-                    len(method.signaturesForArgCount(argCount+1)) == 1):
-                    argCountCases.append(
-                        CGCase(str(argCount), None, True))
-                else:
-                    argCountCases.append(
-                        CGCase(str(argCount), getPerSignatureCall(signature)))
+                argCountCases.append(
+                    CGCase(str(argCount), getPerSignatureCall(signature)))
                 continue
 
             distinguishingIndex = method.distinguishingIndexForArgCount(argCount)
 
             def distinguishingArgument(signature):
                 args = signature[1]
                 if distinguishingIndex < len(args):
                     return args[distinguishingIndex]
--- a/dom/bindings/Date.cpp
+++ b/dom/bindings/Date.cpp
@@ -12,17 +12,17 @@
 #include "js/Value.h" // for Value
 #include "jswrapper.h" // for CheckedUnwrap
 #include "mozilla/FloatingPoint.h" // for IsNaN, UnspecifiedNaN
 
 namespace mozilla {
 namespace dom {
 
 Date::Date()
-  : mMsecSinceEpoch(UnspecifiedNaN())
+  : mMsecSinceEpoch(UnspecifiedNaN<double>())
 {
 }
 
 bool
 Date::IsUndefined() const
 {
   return IsNaN(mMsecSinceEpoch);
 }
--- a/dom/browser-element/BrowserElementParent.cpp
+++ b/dom/browser-element/BrowserElementParent.cpp
@@ -234,22 +234,21 @@ BrowserElementParent::OpenWindowInProces
   // out-of-process, so we couldn't touch it if we tried.)
   //
   // GetScriptableTop gets us the <iframe mozbrowser>'s window; we'll use its
   // frame element, rather than aOpenerWindow's frame element, as our "opener
   // frame element" below.
   nsCOMPtr<nsIDOMWindow> topWindow;
   aOpenerWindow->GetScriptableTop(getter_AddRefs(topWindow));
 
-  nsCOMPtr<nsIDOMElement> openerFrameDOMElement;
-  topWindow->GetFrameElement(getter_AddRefs(openerFrameDOMElement));
-  NS_ENSURE_TRUE(openerFrameDOMElement, BrowserElementParent::OPEN_WINDOW_IGNORED);
+  nsCOMPtr<nsPIDOMWindow> win = do_QueryInterface(topWindow);
 
-  nsCOMPtr<Element> openerFrameElement =
-    do_QueryInterface(openerFrameDOMElement);
+  nsCOMPtr<Element> openerFrameElement = win->GetFrameElementInternal();
+  NS_ENSURE_TRUE(openerFrameElement, BrowserElementParent::OPEN_WINDOW_IGNORED);
+
 
   nsRefPtr<HTMLIFrameElement> popupFrameElement =
     CreateIframe(openerFrameElement, aName, /* aRemote = */ false);
   NS_ENSURE_TRUE(popupFrameElement, BrowserElementParent::OPEN_WINDOW_IGNORED);
 
   nsAutoCString spec;
   if (aURI) {
     aURI->GetSpec(spec);
--- a/dom/camera/DOMCameraCapabilities.h
+++ b/dom/camera/DOMCameraCapabilities.h
@@ -9,16 +9,17 @@
 
 #include "nsString.h"
 #include "nsAutoPtr.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/ErrorResult.h"
 #include "mozilla/dom/CameraManagerBinding.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsWrapperCache.h"
+#include "nsPIDOMWindow.h"
 
 struct JSContext;
 class nsPIDOMWindow;
 
 namespace mozilla {
 
 class ICameraControl;
 class RecorderProfileManager;
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -8,17 +8,17 @@
 #include "mozilla/BasicEvents.h"
 
 #include "DataTransfer.h"
 
 #include "nsIDOMDocument.h"
 #include "nsIVariant.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsError.h"
 #include "nsIDragService.h"
 #include "nsIClipboard.h"
 #include "nsContentUtils.h"
 #include "nsIContent.h"
 #include "nsCRT.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptContext.h"
@@ -319,37 +319,42 @@ DataTransfer::GetFiles(ErrorResult& aRv)
 NS_IMETHODIMP
 DataTransfer::GetFiles(nsIDOMFileList** aFileList)
 {
   ErrorResult rv;
   *aFileList = GetFiles(rv);
   return rv.ErrorCode();
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 DataTransfer::Types()
 {
-  nsRefPtr<nsDOMStringList> types = new nsDOMStringList();
+  nsRefPtr<DOMStringList> types = new DOMStringList();
   if (mItems.Length()) {
+    bool addFile = false;
     const nsTArray<TransferItem>& item = mItems[0];
-    for (uint32_t i = 0; i < item.Length(); i++)
-      types->Add(item[i].mFormat);
+    for (uint32_t i = 0; i < item.Length(); i++) {
+      const nsString& format = item[i].mFormat;
+      types->Add(format);
+      if (!addFile) {
+        addFile = format.EqualsASCII(kFileMime) ||
+                  format.EqualsASCII("application/x-moz-file-promise");
+      }
+    }
 
-    bool filePresent, filePromisePresent;
-    types->Contains(NS_LITERAL_STRING(kFileMime), &filePresent);
-    types->Contains(NS_LITERAL_STRING("application/x-moz-file-promise"), &filePromisePresent);
-    if (filePresent || filePromisePresent)
+    if (addFile) {
       types->Add(NS_LITERAL_STRING("Files"));
+    }
   }
 
   return types.forget();
 }
 
 NS_IMETHODIMP
-DataTransfer::GetTypes(nsIDOMDOMStringList** aTypes)
+DataTransfer::GetTypes(nsISupports** aTypes)
 {
   *aTypes = Types().get();
 
   return NS_OK;
 }
 
 void
 DataTransfer::GetData(const nsAString& aFormat, nsAString& aData,
@@ -516,39 +521,39 @@ DataTransfer::GetMozSourceNode(nsIDOMNod
   if (!sourceNode) {
     *aSourceNode = nullptr;
     return NS_OK;
   }
 
   return CallQueryInterface(sourceNode, aSourceNode);
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 DataTransfer::MozTypesAt(uint32_t aIndex, ErrorResult& aRv)
 {
   // Only the first item is valid for clipboard events
   if (aIndex > 0 &&
       (mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) {
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return nullptr;
   }
 
-  nsRefPtr<nsDOMStringList> types = new nsDOMStringList();
+  nsRefPtr<DOMStringList> types = new DOMStringList();
   if (aIndex < mItems.Length()) {
     // note that you can retrieve the types regardless of their principal
     nsTArray<TransferItem>& item = mItems[aIndex];
     for (uint32_t i = 0; i < item.Length(); i++)
       types->Add(item[i].mFormat);
   }
 
   return types.forget();
 }
 
 NS_IMETHODIMP
-DataTransfer::MozTypesAt(uint32_t aIndex, nsIDOMDOMStringList** aTypes)
+DataTransfer::MozTypesAt(uint32_t aIndex, nsISupports** aTypes)
 {
   ErrorResult rv;
   *aTypes = MozTypesAt(aIndex, rv).get();
   return rv.ErrorCode();
 }
 
 NS_IMETHODIMP
 DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
--- a/dom/events/DataTransfer.h
+++ b/dom/events/DataTransfer.h
@@ -23,16 +23,17 @@ class nsEventStateManager;
 class nsINode;
 class nsITransferable;
 class nsISupportsArray;
 class nsILoadContext;
 
 namespace mozilla {
 namespace dom {
 
+class DOMStringList;
 class Element;
 template<typename T> class Optional;
 
 /**
  * TransferItem is used to hold data for a particular format. Each piece of
  * data has a principal set from the caller which added it. This allows a
  * caller that wishes to retrieve the data to only be able to access the data
  * it is allowed to, yet still allow a chrome caller to retrieve any of the
@@ -129,17 +130,17 @@ public:
     if (mEffectAllowed == nsIDragService::DRAGDROP_ACTION_UNINITIALIZED) {
       aEffectAllowed.AssignLiteral("uninitialized");
     } else {
       aEffectAllowed.AssignASCII(sEffects[mEffectAllowed]);
     }
   }
   void SetDragImage(Element& aElement, int32_t aX, int32_t aY,
                     ErrorResult& aRv);
-  already_AddRefed<nsIDOMDOMStringList> Types();
+  already_AddRefed<DOMStringList> Types();
   void GetData(const nsAString& aFormat, nsAString& aData, ErrorResult& aRv);
   void SetData(const nsAString& aFormat, const nsAString& aData,
                ErrorResult& aRv);
   void ClearData(const mozilla::dom::Optional<nsAString>& aFormat,
                  mozilla::ErrorResult& aRv);
   nsDOMFileList* GetFiles(mozilla::ErrorResult& aRv);
   void AddElement(Element& aElement, mozilla::ErrorResult& aRv);
   uint32_t MozItemCount()
@@ -149,18 +150,18 @@ public:
   void GetMozCursor(nsString& aCursor)
   {
     if (mCursorState) {
       aCursor.AssignLiteral("default");
     } else {
       aCursor.AssignLiteral("auto");
     }
   }
-  already_AddRefed<nsIDOMDOMStringList> MozTypesAt(uint32_t aIndex,
-                                                   mozilla::ErrorResult& aRv);
+  already_AddRefed<DOMStringList> MozTypesAt(uint32_t aIndex,
+                                             mozilla::ErrorResult& aRv);
   void MozClearDataAt(const nsAString& aFormat, uint32_t aIndex,
                       mozilla::ErrorResult& aRv);
   void MozSetDataAt(JSContext* aCx, const nsAString& aFormat,
                     JS::Handle<JS::Value> aData, uint32_t aIndex,
                     mozilla::ErrorResult& aRv);
   JS::Value MozGetDataAt(JSContext* aCx, const nsAString& aFormat,
                          uint32_t aIndex, mozilla::ErrorResult& aRv);
   bool MozUserCancelled()
rename from dom/events/nsDOMDeviceMotionEvent.cpp
rename to dom/events/DeviceMotionEvent.cpp
--- a/dom/events/nsDOMDeviceMotionEvent.cpp
+++ b/dom/events/DeviceMotionEvent.cpp
@@ -1,141 +1,160 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsDOMDeviceMotionEvent.h"
+#include "mozilla/dom/DeviceMotionEvent.h"
 #include "nsContentUtils.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_INHERITED_3(nsDOMDeviceMotionEvent, nsDOMEvent,
+/******************************************************************************
+ * DeviceMotionEvent
+ *****************************************************************************/
+
+NS_IMPL_CYCLE_COLLECTION_INHERITED_3(DeviceMotionEvent, nsDOMEvent,
                                      mAcceleration,
                                      mAccelerationIncludingGravity,
                                      mRotationRate)
 
-NS_IMPL_ADDREF_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
+NS_IMPL_ADDREF_INHERITED(DeviceMotionEvent, nsDOMEvent)
+NS_IMPL_RELEASE_INHERITED(DeviceMotionEvent, nsDOMEvent)
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMDeviceMotionEvent)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(DeviceMotionEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
 void
-nsDOMDeviceMotionEvent::InitDeviceMotionEvent(const nsAString& aType,
-                                              bool aCanBubble,
-                                              bool aCancelable,
-                                              const DeviceAccelerationInit& aAcceleration,
-                                              const DeviceAccelerationInit& aAccelerationIncludingGravity,
-                                              const DeviceRotationRateInit& aRotationRate,
-                                              Nullable<double> aInterval,
-                                              ErrorResult& aRv)
+DeviceMotionEvent::InitDeviceMotionEvent(
+                     const nsAString& aType,
+                     bool aCanBubble,
+                     bool aCancelable,
+                     const DeviceAccelerationInit& aAcceleration,
+                     const DeviceAccelerationInit& aAccelIncludingGravity,
+                     const DeviceRotationRateInit& aRotationRate,
+                     Nullable<double> aInterval,
+                     ErrorResult& aRv)
 {
   aRv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
   if (aRv.Failed()) {
     return;
   }
 
-  mAcceleration = new nsDOMDeviceAcceleration(this, aAcceleration.mX,
-                                              aAcceleration.mY,
-                                              aAcceleration.mZ);
+  mAcceleration = new DeviceAcceleration(this, aAcceleration.mX,
+                                         aAcceleration.mY,
+                                         aAcceleration.mZ);
 
   mAccelerationIncludingGravity =
-    new nsDOMDeviceAcceleration(this, aAccelerationIncludingGravity.mX,
-                                aAccelerationIncludingGravity.mY,
-                                aAccelerationIncludingGravity.mZ);
+    new DeviceAcceleration(this, aAccelIncludingGravity.mX,
+                           aAccelIncludingGravity.mY,
+                           aAccelIncludingGravity.mZ);
 
-  mRotationRate = new nsDOMDeviceRotationRate(this, aRotationRate.mAlpha,
-                                              aRotationRate.mBeta,
-                                              aRotationRate.mGamma);
+  mRotationRate = new DeviceRotationRate(this, aRotationRate.mAlpha,
+                                         aRotationRate.mBeta,
+                                         aRotationRate.mGamma);
   mInterval = aInterval;
 }
 
-already_AddRefed<nsDOMDeviceMotionEvent>
-nsDOMDeviceMotionEvent::Constructor(const GlobalObject& aGlobal,
-                                    const nsAString& aType,
-                                    const DeviceMotionEventInit& aEventInitDict,
-                                    ErrorResult& aRv)
+already_AddRefed<DeviceMotionEvent>
+DeviceMotionEvent::Constructor(const GlobalObject& aGlobal,
+                               const nsAString& aType,
+                               const DeviceMotionEventInit& aEventInitDict,
+                               ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t =
-    do_QueryInterface(aGlobal.GetAsSupports());
-  nsRefPtr<nsDOMDeviceMotionEvent> e =
-    new nsDOMDeviceMotionEvent(t, nullptr, nullptr);
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<DeviceMotionEvent> e = new DeviceMotionEvent(t, nullptr, nullptr);
   aRv = e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
   if (aRv.Failed()) {
     return nullptr;
   }
   bool trusted = e->Init(t);
 
-  e->mAcceleration = new nsDOMDeviceAcceleration(e,
+  e->mAcceleration = new DeviceAcceleration(e,
     aEventInitDict.mAcceleration.mX,
     aEventInitDict.mAcceleration.mY,
     aEventInitDict.mAcceleration.mZ);
 
-  e->mAccelerationIncludingGravity = new nsDOMDeviceAcceleration(e,
+  e->mAccelerationIncludingGravity = new DeviceAcceleration(e,
     aEventInitDict.mAccelerationIncludingGravity.mX,
     aEventInitDict.mAccelerationIncludingGravity.mY,
     aEventInitDict.mAccelerationIncludingGravity.mZ);
 
-  e->mRotationRate = new nsDOMDeviceRotationRate(e,
+  e->mRotationRate = new DeviceRotationRate(e,
     aEventInitDict.mRotationRate.mAlpha,
     aEventInitDict.mRotationRate.mBeta,
     aEventInitDict.mRotationRate.mGamma);
 
   e->mInterval = aEventInitDict.mInterval;
   e->SetTrusted(trusted);
 
   return e.forget();
 }
 
+/******************************************************************************
+ * DeviceAcceleration
+ *****************************************************************************/
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DeviceAcceleration, mOwner)
+
+NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DeviceAcceleration, AddRef)
+NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DeviceAcceleration, Release)
+
+DeviceAcceleration::DeviceAcceleration(DeviceMotionEvent* aOwner,
+                                       Nullable<double> aX,
+                                       Nullable<double> aY,
+                                       Nullable<double> aZ)
+  : mOwner(aOwner)
+  , mX(aX)
+  , mY(aY)
+  , mZ(aZ)
+{
+  SetIsDOMBinding();
+}
+
+DeviceAcceleration::~DeviceAcceleration()
+{
+}
+
+/******************************************************************************
+ * DeviceRotationRate
+ *****************************************************************************/
+
+NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(DeviceRotationRate, mOwner)
+
+NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DeviceRotationRate, AddRef)
+NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DeviceRotationRate, Release)
+
+DeviceRotationRate::DeviceRotationRate(DeviceMotionEvent* aOwner,
+                                       Nullable<double> aAlpha,
+                                       Nullable<double> aBeta,
+                                       Nullable<double> aGamma)
+  : mOwner(aOwner)
+  , mAlpha(aAlpha)
+  , mBeta(aBeta)
+  , mGamma(aGamma)
+{
+  SetIsDOMBinding();
+}
+
+DeviceRotationRate::~DeviceRotationRate()
+{
+}
+
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
 
 nsresult
 NS_NewDOMDeviceMotionEvent(nsIDOMEvent** aInstancePtrResult,
-                           mozilla::dom::EventTarget* aOwner,
+                           EventTarget* aOwner,
                            nsPresContext* aPresContext,
                            WidgetEvent* aEvent) 
 {
   NS_ENSURE_ARG_POINTER(aInstancePtrResult);
 
-  nsDOMDeviceMotionEvent* it =
-    new nsDOMDeviceMotionEvent(aOwner, aPresContext, aEvent);
+  DeviceMotionEvent* it = new DeviceMotionEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
-
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsDOMDeviceAcceleration, mOwner)
-
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsDOMDeviceAcceleration, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsDOMDeviceAcceleration, Release)
-
-nsDOMDeviceAcceleration::nsDOMDeviceAcceleration(nsDOMDeviceMotionEvent* aOwner,
-                                                 Nullable<double> aX,
-                                                 Nullable<double> aY,
-                                                 Nullable<double> aZ)
-: mOwner(aOwner), mX(aX), mY(aY), mZ(aZ)
-{
-  SetIsDOMBinding();
-}
-
-nsDOMDeviceAcceleration::~nsDOMDeviceAcceleration()
-{
-}
-
-
-NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(nsDOMDeviceRotationRate, mOwner)
-
-NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(nsDOMDeviceRotationRate, AddRef)
-NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(nsDOMDeviceRotationRate, Release)
-
-nsDOMDeviceRotationRate::nsDOMDeviceRotationRate(nsDOMDeviceMotionEvent* aOwner,
-                                                 Nullable<double> aAlpha,
-                                                 Nullable<double> aBeta,
-                                                 Nullable<double> aGamma)
-: mOwner(aOwner), mAlpha(aAlpha), mBeta(aBeta), mGamma(aGamma)
-{
-  SetIsDOMBinding();
-}
-
-nsDOMDeviceRotationRate::~nsDOMDeviceRotationRate()
-{
-}
rename from dom/events/nsDOMDeviceMotionEvent.h
rename to dom/events/DeviceMotionEvent.h
--- a/dom/events/nsDOMDeviceMotionEvent.h
+++ b/dom/events/DeviceMotionEvent.h
@@ -1,156 +1,161 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsDOMDeviceMotionEvent_h__
-#define nsDOMDeviceMotionEvent_h__
+#ifndef mozilla_dom_DeviceMotionEvent_h_
+#define mozilla_dom_DeviceMotionEvent_h_
 
 #include "nsDOMEvent.h"
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/DeviceMotionEventBinding.h"
 
-class nsDOMDeviceRotationRate MOZ_FINAL : public nsWrapperCache
+namespace mozilla {
+namespace dom {
+
+class DeviceRotationRate MOZ_FINAL : public nsWrapperCache
 {
 public:
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsDOMDeviceRotationRate)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsDOMDeviceRotationRate)
+  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceRotationRate)
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceRotationRate)
 
-  nsDOMDeviceRotationRate(nsDOMDeviceMotionEvent* aOwner,
-                          Nullable<double> aAlpha, Nullable<double> aBeta,
-                          Nullable<double> aGamma);
-  nsDOMDeviceRotationRate(double aAlpha, double aBeta, double aGamma)
+  DeviceRotationRate(DeviceMotionEvent* aOwner,
+                     Nullable<double> aAlpha, Nullable<double> aBeta,
+                     Nullable<double> aGamma);
+  DeviceRotationRate(double aAlpha, double aBeta, double aGamma)
   {
-    nsDOMDeviceRotationRate(nullptr, Nullable<double>(aAlpha),
-                            Nullable<double>(aBeta), Nullable<double>(aGamma));
+    DeviceRotationRate(nullptr, Nullable<double>(aAlpha),
+                       Nullable<double>(aBeta), Nullable<double>(aGamma));
   }
 
-  nsDOMDeviceMotionEvent* GetParentObject() const
+  DeviceMotionEvent* GetParentObject() const
   {
     return mOwner;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::DeviceRotationRateBinding::Wrap(aCx, aScope, this);
+    return DeviceRotationRateBinding::Wrap(aCx, aScope, this);
   }
 
   Nullable<double> GetAlpha() const { return mAlpha; }
   Nullable<double> GetBeta() const { return mBeta; }
   Nullable<double> GetGamma() const { return mGamma; }
 
 private:
-  ~nsDOMDeviceRotationRate();
+  ~DeviceRotationRate();
 
 protected:
-  nsRefPtr<nsDOMDeviceMotionEvent> mOwner;
+  nsRefPtr<DeviceMotionEvent> mOwner;
   Nullable<double> mAlpha, mBeta, mGamma;
 };
 
-class nsDOMDeviceAcceleration MOZ_FINAL : public nsWrapperCache
+class DeviceAcceleration MOZ_FINAL : public nsWrapperCache
 {
 public:
-  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(nsDOMDeviceAcceleration)
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(nsDOMDeviceAcceleration)
+  NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DeviceAcceleration)
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(DeviceAcceleration)
 
-  nsDOMDeviceAcceleration(nsDOMDeviceMotionEvent* aOwner,
-                          Nullable<double> aX, Nullable<double> aY,
-                          Nullable<double> aZ);
-  nsDOMDeviceAcceleration(double aX, double aY, double aZ)
+  DeviceAcceleration(DeviceMotionEvent* aOwner,
+                     Nullable<double> aX, Nullable<double> aY,
+                     Nullable<double> aZ);
+  DeviceAcceleration(double aX, double aY, double aZ)
   {
-    nsDOMDeviceAcceleration(nullptr, Nullable<double>(aX),
-                            Nullable<double>(aY), Nullable<double>(aZ));
+    DeviceAcceleration(nullptr, Nullable<double>(aX),
+                       Nullable<double>(aY), Nullable<double>(aZ));
   }
 
-  nsDOMDeviceMotionEvent* GetParentObject() const
+  DeviceMotionEvent* GetParentObject() const
   {
     return mOwner;
   }
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::DeviceAccelerationBinding::Wrap(aCx, aScope, this);
+    return DeviceAccelerationBinding::Wrap(aCx, aScope, this);
   }
 
   Nullable<double> GetX() const { return mX; }
   Nullable<double> GetY() const { return mY; }
   Nullable<double> GetZ() const { return mZ; }
 
 private:
-  ~nsDOMDeviceAcceleration();
+  ~DeviceAcceleration();
 
 protected:
-  nsRefPtr<nsDOMDeviceMotionEvent> mOwner;
+  nsRefPtr<DeviceMotionEvent> mOwner;
   Nullable<double> mX, mY, mZ;
 };
 
-class nsDOMDeviceMotionEvent MOZ_FINAL : public nsDOMEvent
+class DeviceMotionEvent MOZ_FINAL : public nsDOMEvent
 {
-  typedef mozilla::dom::DeviceAccelerationInit DeviceAccelerationInit;
-  typedef mozilla::dom::DeviceRotationRateInit DeviceRotationRateInit;
 public:
 
-  nsDOMDeviceMotionEvent(mozilla::dom::EventTarget* aOwner,
-                         nsPresContext* aPresContext,
-                         mozilla::WidgetEvent* aEvent)
-  : nsDOMEvent(aOwner, aPresContext, aEvent)
+  DeviceMotionEvent(EventTarget* aOwner,
+                    nsPresContext* aPresContext,
+                    WidgetEvent* aEvent)
+    : nsDOMEvent(aOwner, aPresContext, aEvent)
   {
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // Forward to nsDOMEvent
   NS_FORWARD_TO_NSDOMEVENT
 
-  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
+  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DeviceMotionEvent, nsDOMEvent)
 
   virtual JSObject* WrapObject(JSContext* aCx,
-			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::DeviceMotionEventBinding::Wrap(aCx, aScope, this);
+    return DeviceMotionEventBinding::Wrap(aCx, aScope, this);
   }
 
-  nsDOMDeviceAcceleration* GetAcceleration() const
+  DeviceAcceleration* GetAcceleration() const
   {
     return mAcceleration;
   }
 
-  nsDOMDeviceAcceleration* GetAccelerationIncludingGravity() const
+  DeviceAcceleration* GetAccelerationIncludingGravity() const
   {
     return mAccelerationIncludingGravity;
   }
 
-  nsDOMDeviceRotationRate* GetRotationRate() const
+  DeviceRotationRate* GetRotationRate() const
   {
     return mRotationRate;
   }
 
   Nullable<double> GetInterval() const
   {
     return mInterval;
   }
 
-  void InitDeviceMotionEvent(const nsAString& aType,
-                             bool aCanBubble,
-                             bool aCancelable,
-                             const DeviceAccelerationInit& aAcceleration,
-                             const DeviceAccelerationInit& aAccelerationIncludingGravity,
-                             const DeviceRotationRateInit& aRotationRate,
-                             Nullable<double> aInterval,
-                             mozilla::ErrorResult& aRv);
+  void InitDeviceMotionEvent(
+         const nsAString& aType,
+         bool aCanBubble,
+         bool aCancelable,
+         const DeviceAccelerationInit& aAcceleration,
+         const DeviceAccelerationInit& aAccelerationIncludingGravity,
+         const DeviceRotationRateInit& aRotationRate,
+         Nullable<double> aInterval,
+         ErrorResult& aRv);
 
-  static already_AddRefed<nsDOMDeviceMotionEvent>
-  Constructor(const mozilla::dom::GlobalObject& aGlobal,
+  static already_AddRefed<DeviceMotionEvent>
+  Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
-              const mozilla::dom::DeviceMotionEventInit& aEventInitDict,
-              mozilla::ErrorResult& aRv);
+              const DeviceMotionEventInit& aEventInitDict,
+              ErrorResult& aRv);
 
 protected:
-  nsRefPtr<nsDOMDeviceAcceleration> mAcceleration;
-  nsRefPtr<nsDOMDeviceAcceleration> mAccelerationIncludingGravity;
-  nsRefPtr<nsDOMDeviceRotationRate> mRotationRate;
+  nsRefPtr<DeviceAcceleration> mAcceleration;
+  nsRefPtr<DeviceAcceleration> mAccelerationIncludingGravity;
+  nsRefPtr<DeviceRotationRate> mRotationRate;
   Nullable<double> mInterval;
 };
 
-#endif
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_DeviceMotionEvent_h_
rename from dom/events/nsDOMDragEvent.cpp
rename to dom/events/DragEvent.cpp
--- a/dom/events/nsDOMDragEvent.cpp
+++ b/dom/events/DragEvent.cpp
@@ -1,106 +1,122 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsDOMDragEvent.h"
+#include "mozilla/dom/DragEvent.h"
+#include "mozilla/MouseEvents.h"
 #include "nsContentUtils.h"
 #include "prtime.h"
-#include "mozilla/MouseEvents.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
-nsDOMDragEvent::nsDOMDragEvent(EventTarget* aOwner,
-                               nsPresContext* aPresContext,
-                               WidgetDragEvent* aEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext, aEvent ? aEvent :
-                    new WidgetDragEvent(false, 0, nullptr))
+DragEvent::DragEvent(EventTarget* aOwner,
+                     nsPresContext* aPresContext,
+                     WidgetDragEvent* aEvent)
+  : MouseEvent(aOwner, aPresContext,
+               aEvent ? aEvent : new WidgetDragEvent(false, 0, nullptr))
 {
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
     mEvent->AsMouseEvent()->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMDragEvent, nsDOMMouseEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMDragEvent, nsDOMMouseEvent)
+NS_IMPL_ADDREF_INHERITED(DragEvent, MouseEvent)
+NS_IMPL_RELEASE_INHERITED(DragEvent, MouseEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMDragEvent)
+NS_INTERFACE_MAP_BEGIN(DragEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMDragEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
+NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
 
 void
-nsDOMDragEvent::InitDragEvent(const nsAString& aType, bool aCanBubble,
-                              bool aCancelable, nsIDOMWindow* aView,
-                              int32_t aDetail, int32_t aScreenX,
-                              int32_t aScreenY, int32_t aClientX,
-                              int32_t aClientY, bool aCtrlKey, bool aAltKey,
-                              bool aShiftKey, bool aMetaKey, uint16_t aButton,
-                              EventTarget* aRelatedTarget,
-                              DataTransfer* aDataTransfer, ErrorResult& aError)
+DragEvent::InitDragEvent(const nsAString& aType,
+                         bool aCanBubble,
+                         bool aCancelable,
+                         nsIDOMWindow* aView,
+                         int32_t aDetail,
+                         int32_t aScreenX,
+                         int32_t aScreenY,
+                         int32_t aClientX,
+                         int32_t aClientY,
+                         bool aCtrlKey,
+                         bool aAltKey,
+                         bool aShiftKey,
+                         bool aMetaKey,
+                         uint16_t aButton,
+                         EventTarget* aRelatedTarget,
+                         DataTransfer* aDataTransfer,
+                         ErrorResult& aError)
 {
   aError =
-    nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
-                                    aView, aDetail, aScreenX, aScreenY,
-                                    aClientX, aClientY, aCtrlKey, aAltKey,
-                                    aShiftKey, aMetaKey, aButton,
-                                    aRelatedTarget);
+    MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
+                               aView, aDetail, aScreenX, aScreenY,
+                               aClientX, aClientY, aCtrlKey, aAltKey,
+                               aShiftKey, aMetaKey, aButton, aRelatedTarget);
   if (aError.Failed()) {
     return;
   }
 
   if (mEventIsInternal && mEvent) {
     mEvent->AsDragEvent()->dataTransfer = aDataTransfer;
   }
 }
 
 NS_IMETHODIMP
-nsDOMDragEvent::InitDragEvent(const nsAString & aType,
-                              bool aCanBubble, bool aCancelable,
-                              nsIDOMWindow* aView, int32_t aDetail,
-                              int32_t aScreenX, int32_t aScreenY,
-                              int32_t aClientX, int32_t aClientY, 
-                              bool aCtrlKey, bool aAltKey, bool aShiftKey,
-                              bool aMetaKey, uint16_t aButton,
-                              nsIDOMEventTarget *aRelatedTarget,
-                              nsIDOMDataTransfer* aDataTransfer)
+DragEvent::InitDragEvent(const nsAString& aType,
+                         bool aCanBubble,
+                         bool aCancelable,
+                         nsIDOMWindow* aView,
+                         int32_t aDetail,
+                         int32_t aScreenX,
+                         int32_t aScreenY,
+                         int32_t aClientX,
+                         int32_t aClientY,
+                         bool aCtrlKey,
+                         bool aAltKey,
+                         bool aShiftKey,
+                         bool aMetaKey,
+                         uint16_t aButton,
+                         nsIDOMEventTarget* aRelatedTarget,
+                         nsIDOMDataTransfer* aDataTransfer)
 {
   nsCOMPtr<DataTransfer> dataTransfer = do_QueryInterface(aDataTransfer);
   NS_ENSURE_ARG(dataTransfer);
 
-  nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
-                  aView, aDetail, aScreenX, aScreenY, aClientX, aClientY,
-                  aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
-                  aRelatedTarget);
+  nsresult rv =
+    MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
+                               aScreenX, aScreenY, aClientX, aClientY,
+                               aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
+                               aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (mEventIsInternal && mEvent) {
     mEvent->AsDragEvent()->dataTransfer = dataTransfer;
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMDragEvent::GetDataTransfer(nsIDOMDataTransfer** aDataTransfer)
+DragEvent::GetDataTransfer(nsIDOMDataTransfer** aDataTransfer)
 {
   NS_IF_ADDREF(*aDataTransfer = GetDataTransfer());
   return NS_OK;
 }
 
 DataTransfer*
-nsDOMDragEvent::GetDataTransfer()
+DragEvent::GetDataTransfer()
 {
   // the dataTransfer field of the event caches the DataTransfer associated
   // with the drag. It is initialized when an attempt is made to retrieve it
   // rather that when the event is created to avoid duplicating the data when
   // no listener ever uses it.
   if (!mEvent || mEvent->eventStructType != NS_DRAG_EVENT) {
     NS_WARNING("Tried to get dataTransfer from non-drag event!");
     return nullptr;
@@ -111,16 +127,23 @@ nsDOMDragEvent::GetDataTransfer()
   if (!mEventIsInternal) {
     nsresult rv = nsContentUtils::SetDataTransferInEvent(dragEvent);
     NS_ENSURE_SUCCESS(rv, nullptr);
   }
 
   return dragEvent->dataTransfer;
 }
 
-nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
-                            EventTarget* aOwner,
-                            nsPresContext* aPresContext,
-                            WidgetDragEvent* aEvent) 
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
+                   EventTarget* aOwner,
+                   nsPresContext* aPresContext,
+                   WidgetDragEvent* aEvent) 
 {
-  nsDOMDragEvent* event = new nsDOMDragEvent(aOwner, aPresContext, aEvent);
+  DragEvent* event = new DragEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(event, aInstancePtrResult);
 }
rename from dom/events/nsDOMDragEvent.h
rename to dom/events/DragEvent.h
--- a/dom/events/nsDOMDragEvent.h
+++ b/dom/events/DragEvent.h
@@ -1,59 +1,56 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsDOMDragEvent_h__
-#define nsDOMDragEvent_h__
+#ifndef mozilla_dom_DragEvent_h_
+#define mozilla_dom_DragEvent_h_
 
 #include "nsIDOMDragEvent.h"
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
 #include "mozilla/dom/DragEventBinding.h"
 #include "mozilla/EventForwards.h"
 
 namespace mozilla {
 namespace dom {
+
 class DataTransfer;
-}
-}
 
-class nsDOMDragEvent : public nsDOMMouseEvent,
-                       public nsIDOMDragEvent
+class DragEvent : public MouseEvent,
+                  public nsIDOMDragEvent
 {
 public:
-  nsDOMDragEvent(mozilla::dom::EventTarget* aOwner,
-                 nsPresContext* aPresContext,
-                 mozilla::WidgetDragEvent* aEvent);
+  DragEvent(EventTarget* aOwner,
+            nsPresContext* aPresContext,
+            WidgetDragEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMDRAGEVENT
-  
-  NS_FORWARD_TO_NSDOMMOUSEEVENT
+
+  NS_FORWARD_TO_MOUSEEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::DragEventBinding::Wrap(aCx, aScope, this);
+    return DragEventBinding::Wrap(aCx, aScope, this);
   }
 
-  mozilla::dom::DataTransfer* GetDataTransfer();
+  DataTransfer* GetDataTransfer();
 
   void InitDragEvent(const nsAString& aType,
                      bool aCanBubble, bool aCancelable,
                      nsIDOMWindow* aView, int32_t aDetail,
                      int32_t aScreenX, int32_t aScreenY,
                      int32_t aClientX, int32_t aClientY,
                      bool aCtrlKey, bool aAltKey, bool aShiftKey,
                      bool aMetaKey, uint16_t aButton,
-                     mozilla::dom::EventTarget* aRelatedTarget,
-                     mozilla::dom::DataTransfer* aDataTransfer,
-                     mozilla::ErrorResult& aError);
+                     EventTarget* aRelatedTarget,
+                     DataTransfer* aDataTransfer,
+                     ErrorResult& aError);
 };
 
-nsresult NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
-                            mozilla::dom::EventTarget* aOwner,
-                            nsPresContext* aPresContext,
-                            mozilla::WidgetDragEvent* aEvent);
+} // namespace dom
+} // namespace mozilla
 
-#endif // nsDOMDragEvent_h__
+#endif // mozilla_dom_DragEvent_h_
rename from dom/events/nsDOMFocusEvent.cpp
rename to dom/events/FocusEvent.cpp
--- a/dom/events/nsDOMFocusEvent.cpp
+++ b/dom/events/FocusEvent.cpp
@@ -1,81 +1,88 @@
 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsDOMFocusEvent.h"
+#include "mozilla/dom/FocusEvent.h"
+#include "mozilla/ContentEvents.h"
 #include "prtime.h"
-#include "mozilla/ContentEvents.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
-NS_IMPL_ISUPPORTS_INHERITED1(nsDOMFocusEvent, nsDOMUIEvent, nsIDOMFocusEvent)
+NS_IMPL_ISUPPORTS_INHERITED1(FocusEvent, nsDOMUIEvent, nsIDOMFocusEvent)
 
-nsDOMFocusEvent::nsDOMFocusEvent(mozilla::dom::EventTarget* aOwner,
-                                 nsPresContext* aPresContext,
-                                 InternalFocusEvent* aEvent)
+FocusEvent::FocusEvent(EventTarget* aOwner,
+                       nsPresContext* aPresContext,
+                       InternalFocusEvent* aEvent)
   : nsDOMUIEvent(aOwner, aPresContext,
                  aEvent ? aEvent :
                           new InternalFocusEvent(false, NS_FOCUS_CONTENT))
 {
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
   }
 }
 
 /* readonly attribute nsIDOMEventTarget relatedTarget; */
 NS_IMETHODIMP
-nsDOMFocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
+FocusEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
 {
   NS_ENSURE_ARG_POINTER(aRelatedTarget);
   NS_IF_ADDREF(*aRelatedTarget = GetRelatedTarget());
   return NS_OK;
 }
 
-mozilla::dom::EventTarget*
-nsDOMFocusEvent::GetRelatedTarget()
+EventTarget*
+FocusEvent::GetRelatedTarget()
 {
   return mEvent->AsFocusEvent()->relatedTarget;
 }
 
 nsresult
-nsDOMFocusEvent::InitFocusEvent(const nsAString& aType,
-                                bool aCanBubble,
-                                bool aCancelable,
-                                nsIDOMWindow* aView,
-                                int32_t aDetail,
-                                mozilla::dom::EventTarget* aRelatedTarget)
+FocusEvent::InitFocusEvent(const nsAString& aType,
+                           bool aCanBubble,
+                           bool aCancelable,
+                           nsIDOMWindow* aView,
+                           int32_t aDetail,
+                           EventTarget* aRelatedTarget)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
   mEvent->AsFocusEvent()->relatedTarget = aRelatedTarget;
   return NS_OK;
 }
 
-already_AddRefed<nsDOMFocusEvent>
-nsDOMFocusEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                             const nsAString& aType,
-                             const mozilla::dom::FocusEventInit& aParam,
-                             mozilla::ErrorResult& aRv)
+already_AddRefed<FocusEvent>
+FocusEvent::Constructor(const GlobalObject& aGlobal,
+                        const nsAString& aType,
+                        const FocusEventInit& aParam,
+                        ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
-  nsRefPtr<nsDOMFocusEvent> e = new nsDOMFocusEvent(t, nullptr, nullptr);
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<FocusEvent> e = new FocusEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
   aRv = e->InitFocusEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
                           aParam.mDetail, aParam.mRelatedTarget);
   e->SetTrusted(trusted);
   return e.forget();
 }
 
-nsresult NS_NewDOMFocusEvent(nsIDOMEvent** aInstancePtrResult,
-                             mozilla::dom::EventTarget* aOwner,
-                             nsPresContext* aPresContext,
-                             InternalFocusEvent* aEvent)
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMFocusEvent(nsIDOMEvent** aInstancePtrResult,
+                    EventTarget* aOwner,
+                    nsPresContext* aPresContext,
+                    InternalFocusEvent* aEvent)
 {
-  nsDOMFocusEvent* it = new nsDOMFocusEvent(aOwner, aPresContext, aEvent);
+  FocusEvent* it = new FocusEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMFocusEvent.h
rename to dom/events/FocusEvent.h
--- a/dom/events/nsDOMFocusEvent.h
+++ b/dom/events/FocusEvent.h
@@ -1,48 +1,54 @@
 /* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-#ifndef nsDOMFocusEvent_h_
-#define nsDOMFocusEvent_h_
+#ifndef mozilla_dom_FocusEvent_h_
+#define mozilla_dom_FocusEvent_h_
 
 #include "nsDOMUIEvent.h"
 #include "nsIDOMFocusEvent.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/FocusEventBinding.h"
 
-class nsDOMFocusEvent : public nsDOMUIEvent,
-                        public nsIDOMFocusEvent
+namespace mozilla {
+namespace dom {
+
+class FocusEvent : public nsDOMUIEvent,
+                   public nsIDOMFocusEvent
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMFOCUSEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::FocusEventBinding::Wrap(aCx, aScope, this);
+    return FocusEventBinding::Wrap(aCx, aScope, this);
   }
 
-  nsDOMFocusEvent(mozilla::dom::EventTarget* aOwner,
-                  nsPresContext* aPresContext,
-                  mozilla::InternalFocusEvent* aEvent);
+  FocusEvent(EventTarget* aOwner,
+             nsPresContext* aPresContext,
+             InternalFocusEvent* aEvent);
 
-  mozilla::dom::EventTarget* GetRelatedTarget();
+  EventTarget* GetRelatedTarget();
 
-  static already_AddRefed<nsDOMFocusEvent> Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                                                       const nsAString& aType,
-                                                       const mozilla::dom::FocusEventInit& aParam,
-                                                       mozilla::ErrorResult& aRv);
+  static already_AddRefed<FocusEvent> Constructor(const GlobalObject& aGlobal,
+                                                  const nsAString& aType,
+                                                  const FocusEventInit& aParam,
+                                                  ErrorResult& aRv);
 protected:
   nsresult InitFocusEvent(const nsAString& aType,
                           bool aCanBubble,
                           bool aCancelable,
                           nsIDOMWindow* aView,
                           int32_t aDetail,
-                          mozilla::dom::EventTarget* aRelatedTarget);
+                          EventTarget* aRelatedTarget);
 };
 
-#endif /* !defined(nsDOMFocusEvent_h_) */
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_FocusEvent_h_
copy from dom/events/MutationEvent.h
copy to dom/events/InternalMutationEvent.h
rename from dom/events/nsDOMKeyboardEvent.cpp
rename to dom/events/KeyboardEvent.cpp
--- a/dom/events/nsDOMKeyboardEvent.cpp
+++ b/dom/events/KeyboardEvent.cpp
@@ -1,174 +1,175 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsDOMKeyboardEvent.h"
+#include "mozilla/dom/KeyboardEvent.h"
+#include "mozilla/TextEvents.h"
 #include "prtime.h"
-#include "mozilla/TextEvents.h"
 
-using namespace mozilla;
+namespace mozilla {
+namespace dom {
 
-nsDOMKeyboardEvent::nsDOMKeyboardEvent(mozilla::dom::EventTarget* aOwner,
-                                       nsPresContext* aPresContext,
-                                       WidgetKeyboardEvent* aEvent)
+KeyboardEvent::KeyboardEvent(EventTarget* aOwner,
+                             nsPresContext* aPresContext,
+                             WidgetKeyboardEvent* aEvent)
   : nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent :
                  new WidgetKeyboardEvent(false, 0, nullptr))
 {
   NS_ASSERTION(mEvent->eventStructType == NS_KEY_EVENT, "event type mismatch");
 
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->AsKeyboardEvent()->mKeyNameIndex = KEY_NAME_INDEX_USE_STRING;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMKeyboardEvent, nsDOMUIEvent)
+NS_IMPL_ADDREF_INHERITED(KeyboardEvent, nsDOMUIEvent)
+NS_IMPL_RELEASE_INHERITED(KeyboardEvent, nsDOMUIEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMKeyboardEvent)
+NS_INTERFACE_MAP_BEGIN(KeyboardEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMKeyEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
 
 bool
-nsDOMKeyboardEvent::AltKey()
+KeyboardEvent::AltKey()
 {
   return mEvent->AsKeyboardEvent()->IsAlt();
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetAltKey(bool* aIsDown)
+KeyboardEvent::GetAltKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = AltKey();
   return NS_OK;
 }
 
 bool
-nsDOMKeyboardEvent::CtrlKey()
+KeyboardEvent::CtrlKey()
 {
   return mEvent->AsKeyboardEvent()->IsControl();
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetCtrlKey(bool* aIsDown)
+KeyboardEvent::GetCtrlKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = CtrlKey();
   return NS_OK;
 }
 
 bool
-nsDOMKeyboardEvent::ShiftKey()
+KeyboardEvent::ShiftKey()
 {
   return mEvent->AsKeyboardEvent()->IsShift();
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetShiftKey(bool* aIsDown)
+KeyboardEvent::GetShiftKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = ShiftKey();
   return NS_OK;
 }
 
 bool
-nsDOMKeyboardEvent::MetaKey()
+KeyboardEvent::MetaKey()
 {
   return mEvent->AsKeyboardEvent()->IsMeta();
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetMetaKey(bool* aIsDown)
+KeyboardEvent::GetMetaKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = MetaKey();
   return NS_OK;
 }
 
 bool
-nsDOMKeyboardEvent::Repeat()
+KeyboardEvent::Repeat()
 {
   return mEvent->AsKeyboardEvent()->mIsRepeat;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetRepeat(bool* aIsRepeat)
+KeyboardEvent::GetRepeat(bool* aIsRepeat)
 {
   NS_ENSURE_ARG_POINTER(aIsRepeat);
   *aIsRepeat = Repeat();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetModifierState(const nsAString& aKey,
-                                     bool* aState)
+KeyboardEvent::GetModifierState(const nsAString& aKey,
+                                bool* aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
 
   *aState = GetModifierState(aKey);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetKey(nsAString& aKeyName)
+KeyboardEvent::GetKey(nsAString& aKeyName)
 {
   mEvent->AsKeyboardEvent()->GetDOMKeyName(aKeyName);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetCharCode(uint32_t* aCharCode)
+KeyboardEvent::GetCharCode(uint32_t* aCharCode)
 {
   NS_ENSURE_ARG_POINTER(aCharCode);
   *aCharCode = CharCode();
   return NS_OK;
 }
 
 uint32_t
-nsDOMKeyboardEvent::CharCode()
+KeyboardEvent::CharCode()
 {
   switch (mEvent->message) {
   case NS_KEY_UP:
   case NS_KEY_DOWN:
     return 0;
   case NS_KEY_PRESS:
     return mEvent->AsKeyboardEvent()->charCode;
   }
   return 0;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetKeyCode(uint32_t* aKeyCode)
+KeyboardEvent::GetKeyCode(uint32_t* aKeyCode)
 {
   NS_ENSURE_ARG_POINTER(aKeyCode);
   *aKeyCode = KeyCode();
   return NS_OK;
 }
 
 uint32_t
-nsDOMKeyboardEvent::KeyCode()
+KeyboardEvent::KeyCode()
 {
   switch (mEvent->message) {
   case NS_KEY_UP:
   case NS_KEY_PRESS:
   case NS_KEY_DOWN:
     return mEvent->AsKeyboardEvent()->keyCode;
   }
   return 0;
 }
 
 uint32_t
-nsDOMKeyboardEvent::Which()
+KeyboardEvent::Which()
 {
   switch (mEvent->message) {
     case NS_KEY_UP:
     case NS_KEY_DOWN:
       return KeyCode();
     case NS_KEY_PRESS:
       //Special case for 4xp bug 62878.  Try to make value of which
       //more closely mirror the values that 4.x gave for RETURN and BACKSPACE
@@ -180,47 +181,60 @@ nsDOMKeyboardEvent::Which()
         return CharCode();
       }
   }
 
   return 0;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::GetLocation(uint32_t* aLocation)
+KeyboardEvent::GetLocation(uint32_t* aLocation)
 {
   NS_ENSURE_ARG_POINTER(aLocation);
 
   *aLocation = Location();
   return NS_OK;
 }
 
 uint32_t
-nsDOMKeyboardEvent::Location()
+KeyboardEvent::Location()
 {
   return mEvent->AsKeyboardEvent()->location;
 }
 
 NS_IMETHODIMP
-nsDOMKeyboardEvent::InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
-                                 nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,
-                                 bool aShiftKey, bool aMetaKey,
-                                 uint32_t aKeyCode, uint32_t aCharCode)
+KeyboardEvent::InitKeyEvent(const nsAString& aType,
+                            bool aCanBubble,
+                            bool aCancelable,
+                            nsIDOMWindow* aView,
+                            bool aCtrlKey,
+                            bool aAltKey,
+                            bool aShiftKey,
+                            bool aMetaKey,
+                            uint32_t aKeyCode,
+                            uint32_t aCharCode)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, 0);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WidgetKeyboardEvent* keyEvent = mEvent->AsKeyboardEvent();
   keyEvent->InitBasicModifiers(aCtrlKey, aAltKey, aShiftKey, aMetaKey);
   keyEvent->keyCode = aKeyCode;
   keyEvent->charCode = aCharCode;
 
   return NS_OK;
 }
 
-nsresult NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
-                                mozilla::dom::EventTarget* aOwner,
-                                nsPresContext* aPresContext,
-                                WidgetKeyboardEvent* aEvent)
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
+                       EventTarget* aOwner,
+                       nsPresContext* aPresContext,
+                       WidgetKeyboardEvent* aEvent)
 {
-  nsDOMKeyboardEvent* it = new nsDOMKeyboardEvent(aOwner, aPresContext, aEvent);
+  KeyboardEvent* it = new KeyboardEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMKeyboardEvent.h
rename to dom/events/KeyboardEvent.h
--- a/dom/events/nsDOMKeyboardEvent.h
+++ b/dom/events/KeyboardEvent.h
@@ -1,41 +1,44 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsDOMKeyboardEvent_h__
-#define nsDOMKeyboardEvent_h__
+#ifndef mozilla_dom_KeyboardEvent_h_
+#define mozilla_dom_KeyboardEvent_h_
 
 #include "nsIDOMKeyEvent.h"
 #include "nsDOMUIEvent.h"
 #include "mozilla/EventForwards.h"
 #include "mozilla/dom/KeyboardEventBinding.h"
 
-class nsDOMKeyboardEvent : public nsDOMUIEvent,
-                           public nsIDOMKeyEvent
+namespace mozilla {
+namespace dom {
+
+class KeyboardEvent : public nsDOMUIEvent,
+                      public nsIDOMKeyEvent
 {
 public:
-  nsDOMKeyboardEvent(mozilla::dom::EventTarget* aOwner,
-                     nsPresContext* aPresContext,
-                     mozilla::WidgetKeyboardEvent* aEvent);
+  KeyboardEvent(EventTarget* aOwner,
+                nsPresContext* aPresContext,
+                WidgetKeyboardEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMKeyEvent Interface
   NS_DECL_NSIDOMKEYEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::KeyboardEventBinding::Wrap(aCx, aScope, this);
+    return KeyboardEventBinding::Wrap(aCx, aScope, this);
   }
 
   bool AltKey();
   bool CtrlKey();
   bool ShiftKey();
   bool MetaKey();
 
   bool GetModifierState(const nsAString& aKey)
@@ -48,18 +51,20 @@ public:
   uint32_t KeyCode();
   virtual uint32_t Which() MOZ_OVERRIDE;
   uint32_t Location();
 
   void InitKeyEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
                     nsIDOMWindow* aView, bool aCtrlKey, bool aAltKey,
                     bool aShiftKey, bool aMetaKey,
                     uint32_t aKeyCode, uint32_t aCharCode,
-                    mozilla::ErrorResult& aRv)
+                    ErrorResult& aRv)
   {
     aRv = InitKeyEvent(aType, aCanBubble, aCancelable, aView,
                        aCtrlKey, aAltKey, aShiftKey,aMetaKey,
                        aKeyCode, aCharCode);
   }
 };
 
+} // namespace dom
+} // namespace mozilla
 
-#endif // nsDOMKeyboardEvent_h__
+#endif // mozilla_dom_KeyboardEvent_h_
rename from dom/events/nsDOMMessageEvent.cpp
rename to dom/events/MessageEvent.cpp
--- a/dom/events/nsDOMMessageEvent.cpp
+++ b/dom/events/MessageEvent.cpp
@@ -1,131 +1,129 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsDOMMessageEvent.h"
+#include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/MessagePort.h"
 #include "mozilla/dom/MessagePortBinding.h"
 #include "mozilla/dom/MessagePortList.h"
 #include "mozilla/dom/UnionTypes.h"
 
 #include "mozilla/HoldDropJSObjects.h"
 #include "jsapi.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMessageEvent)
+NS_IMPL_CYCLE_COLLECTION_CLASS(MessageEvent)
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MessageEvent, nsDOMEvent)
   tmp->mData = JSVAL_VOID;
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindowSource)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPortSource)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPorts)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MessageEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindowSource)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPortSource)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPorts)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MessageEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mData)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMMessageEvent)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MessageEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMessageEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
-NS_IMPL_ADDREF_INHERITED(nsDOMMessageEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_ADDREF_INHERITED(MessageEvent, nsDOMEvent)
+NS_IMPL_RELEASE_INHERITED(MessageEvent, nsDOMEvent)
 
-nsDOMMessageEvent::nsDOMMessageEvent(mozilla::dom::EventTarget* aOwner,
-                                     nsPresContext* aPresContext,
-                                     WidgetEvent* aEvent)
-  : nsDOMEvent(aOwner, aPresContext, aEvent),
-    mData(JSVAL_VOID)
+MessageEvent::MessageEvent(EventTarget* aOwner,
+                           nsPresContext* aPresContext,
+                           WidgetEvent* aEvent)
+  : nsDOMEvent(aOwner, aPresContext, aEvent)
+  , mData(JSVAL_VOID)
 {
 }
 
-nsDOMMessageEvent::~nsDOMMessageEvent()
+MessageEvent::~MessageEvent()
 {
   mData = JSVAL_VOID;
-  mozilla::DropJSObjects(this);
+  DropJSObjects(this);
 }
 
 JSObject*
-nsDOMMessageEvent::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
+MessageEvent::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return mozilla::dom::MessageEventBinding::Wrap(aCx, aScope, this);
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
+MessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
 {
   ErrorResult rv;
   aData.set(GetData(aCx, rv));
   return rv.ErrorCode();
 }
 
 JS::Value
-nsDOMMessageEvent::GetData(JSContext* aCx, ErrorResult& aRv)
+MessageEvent::GetData(JSContext* aCx, ErrorResult& aRv)
 {
   JS::Rooted<JS::Value> data(aCx, mData);
   if (!JS_WrapValue(aCx, &data)) {
     aRv.Throw(NS_ERROR_FAILURE);
   }
   return data;
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetOrigin(nsAString& aOrigin)
+MessageEvent::GetOrigin(nsAString& aOrigin)
 {
   aOrigin = mOrigin;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetLastEventId(nsAString& aLastEventId)
+MessageEvent::GetLastEventId(nsAString& aLastEventId)
 {
   aLastEventId = mLastEventId;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetSource(nsIDOMWindow** aSource)
+MessageEvent::GetSource(nsIDOMWindow** aSource)
 {
   NS_IF_ADDREF(*aSource = mWindowSource);
   return NS_OK;
 }
 
 void
-nsDOMMessageEvent::GetSource(Nullable<mozilla::dom::OwningWindowProxyOrMessagePort>& aValue) const
+MessageEvent::GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const
 {
   if (mWindowSource) {
     aValue.SetValue().SetAsWindowProxy() = mWindowSource;
   } else if (mPortSource) {
     aValue.SetValue().SetAsMessagePort() = mPortSource;
   }
 }
 
-/* static */ already_AddRefed<nsDOMMessageEvent>
-nsDOMMessageEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                               JSContext* aCx, const nsAString& aType,
-                               const mozilla::dom::MessageEventInit& aParam,
-                               mozilla::ErrorResult& aRv)
+/* static */ already_AddRefed<MessageEvent>
+MessageEvent::Constructor(const GlobalObject& aGlobal,
+                          JSContext* aCx, const nsAString& aType,
+                          const MessageEventInit& aParam,
+                          ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t =
-    do_QueryInterface(aGlobal.GetAsSupports());
-  nsRefPtr<nsDOMMessageEvent> event =
-    new nsDOMMessageEvent(t, nullptr, nullptr);
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<MessageEvent> event = new MessageEvent(t, nullptr, nullptr);
 
   aRv = event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   bool trusted = event->Init(t);
   event->SetTrusted(trusted);
@@ -161,45 +159,50 @@ nsDOMMessageEvent::Constructor(const moz
     event->mPorts = new MessagePortList(static_cast<nsDOMEventBase*>(event),
                                         ports);
   }
 
   return event.forget();
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::InitMessageEvent(const nsAString& aType,
-                                    bool aCanBubble,
-                                    bool aCancelable,
-                                    JS::Handle<JS::Value> aData,
-                                    const nsAString& aOrigin,
-                                    const nsAString& aLastEventId,
-                                    nsIDOMWindow* aSource)
+MessageEvent::InitMessageEvent(const nsAString& aType,
+                               bool aCanBubble,
+                               bool aCancelable,
+                               JS::Handle<JS::Value> aData,
+                               const nsAString& aOrigin,
+                               const nsAString& aLastEventId,
+                               nsIDOMWindow* aSource)
 {
   nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mData = aData;
   mozilla::HoldJSObjects(this);
   mOrigin = aOrigin;
   mLastEventId = aLastEventId;
   mWindowSource = aSource;
 
   return NS_OK;
 }
 
 void
-nsDOMMessageEvent::SetPorts(mozilla::dom::MessagePortList* aPorts)
+MessageEvent::SetPorts(MessagePortList* aPorts)
 {
   MOZ_ASSERT(!mPorts && aPorts);
   mPorts = aPorts;
 }
 
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
 nsresult
 NS_NewDOMMessageEvent(nsIDOMEvent** aInstancePtrResult,
-                      mozilla::dom::EventTarget* aOwner,
+                      EventTarget* aOwner,
                       nsPresContext* aPresContext,
                       WidgetEvent* aEvent) 
 {
-  nsDOMMessageEvent* it = new nsDOMMessageEvent(aOwner, aPresContext, aEvent);
-
+  MessageEvent* it = new MessageEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMMessageEvent.h
rename to dom/events/MessageEvent.h
--- a/dom/events/nsDOMMessageEvent.h
+++ b/dom/events/MessageEvent.h
@@ -1,77 +1,79 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsDOMMessageEvent_h__
-#define nsDOMMessageEvent_h__
+#ifndef mozilla_dom_MessageEvent_h_
+#define mozilla_dom_MessageEvent_h_
 
 #include "nsIDOMMessageEvent.h"
 #include "nsDOMEvent.h"
 #include "nsCycleCollectionParticipant.h"
 
 namespace mozilla {
 namespace dom {
+
 class MessageEventInit;
 class MessagePort;
 class MessagePortBase;
 class MessagePortList;
 class OwningWindowProxyOrMessagePort;
-}
-}
 
 /**
  * Implements the MessageEvent event, used for cross-document messaging and
  * server-sent events.
  *
  * See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for
  * further details.
  */
-class nsDOMMessageEvent : public nsDOMEvent,
-                          public nsIDOMMessageEvent
+class MessageEvent : public nsDOMEvent,
+                     public nsIDOMMessageEvent
 {
 public:
-  nsDOMMessageEvent(mozilla::dom::EventTarget* aOwner,
-                    nsPresContext* aPresContext,
-                    mozilla::WidgetEvent* aEvent);
-  ~nsDOMMessageEvent();
+  MessageEvent(EventTarget* aOwner,
+               nsPresContext* aPresContext,
+               WidgetEvent* aEvent);
+  ~MessageEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMMessageEvent,
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent,
                                                          nsDOMEvent)
 
   NS_DECL_NSIDOMMESSAGEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
-  JS::Value GetData(JSContext* aCx, mozilla::ErrorResult& aRv);
+  JS::Value GetData(JSContext* aCx, ErrorResult& aRv);
 
-  void GetSource(Nullable<mozilla::dom::OwningWindowProxyOrMessagePort>& aValue) const;
+  void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;
 
-  mozilla::dom::MessagePortList* GetPorts()
+  MessagePortList* GetPorts()
   {
     return mPorts;
   }
 
-  void SetPorts(mozilla::dom::MessagePortList* aPorts);
+  void SetPorts(MessagePortList* aPorts);
 
-  static already_AddRefed<nsDOMMessageEvent>
-  Constructor(const mozilla::dom::GlobalObject& aGlobal, JSContext* aCx,
+  static already_AddRefed<MessageEvent>
+  Constructor(const GlobalObject& aGlobal, JSContext* aCx,
               const nsAString& aType,
-              const mozilla::dom::MessageEventInit& aEventInit,
-              mozilla::ErrorResult& aRv);
+              const MessageEventInit& aEventInit,
+              ErrorResult& aRv);
 
 private:
   JS::Heap<JS::Value> mData;
   nsString mOrigin;
   nsString mLastEventId;
   nsCOMPtr<nsIDOMWindow> mWindowSource;
-  nsRefPtr<mozilla::dom::MessagePortBase> mPortSource;
-  nsRefPtr<mozilla::dom::MessagePortList> mPorts;
+  nsRefPtr<MessagePortBase> mPortSource;
+  nsRefPtr<MessagePortList> mPorts;
 };
 
-#endif // nsDOMMessageEvent_h__
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_MessageEvent_h_
rename from dom/events/nsDOMMouseEvent.cpp
rename to dom/events/MouseEvent.cpp
--- a/dom/events/nsDOMMouseEvent.cpp
+++ b/dom/events/MouseEvent.cpp
@@ -1,24 +1,25 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsDOMMouseEvent.h"
-#include "nsIContent.h"
+#include "mozilla/dom/MouseEvent.h"
+#include "mozilla/MouseEvents.h"
 #include "nsContentUtils.h"
+#include "nsIContent.h"
 #include "prtime.h"
-#include "mozilla/MouseEvents.h"
 
-using namespace mozilla;
+namespace mozilla {
+namespace dom {
 
-nsDOMMouseEvent::nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
-                                 nsPresContext* aPresContext,
-                                 WidgetMouseEventBase* aEvent)
+MouseEvent::MouseEvent(EventTarget* aOwner,
+                       nsPresContext* aPresContext,
+                       WidgetMouseEventBase* aEvent)
   : nsDOMUIEvent(aOwner, aPresContext, aEvent ? aEvent :
                  new WidgetMouseEvent(false, 0, nullptr,
                                       WidgetMouseEvent::eReal))
 {
   // There's no way to make this class' ctor allocate an WidgetMouseScrollEvent.
   // It's not that important, though, since a scroll event is not a real
   // DOM event.
 
@@ -35,29 +36,39 @@ nsDOMMouseEvent::nsDOMMouseEvent(mozilla
 
   if (mouseEvent) {
     MOZ_ASSERT(mouseEvent->reason != WidgetMouseEvent::eSynthesized,
                "Don't dispatch DOM events from synthesized mouse events");
     mDetail = mouseEvent->clickCount;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMMouseEvent, nsDOMUIEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMouseEvent, nsDOMUIEvent)
+NS_IMPL_ADDREF_INHERITED(MouseEvent, nsDOMUIEvent)
+NS_IMPL_RELEASE_INHERITED(MouseEvent, nsDOMUIEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMMouseEvent)
+NS_INTERFACE_MAP_BEGIN(MouseEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMouseEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMUIEvent)
 
 NS_IMETHODIMP
-nsDOMMouseEvent::InitMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
-                                nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX, 
-                                int32_t aScreenY, int32_t aClientX, int32_t aClientY, 
-                                bool aCtrlKey, bool aAltKey, bool aShiftKey, 
-                                bool aMetaKey, uint16_t aButton, nsIDOMEventTarget *aRelatedTarget)
+MouseEvent::InitMouseEvent(const nsAString& aType,
+                           bool aCanBubble,
+                           bool aCancelable,
+                           nsIDOMWindow* aView,
+                           int32_t aDetail,
+                           int32_t aScreenX,
+                           int32_t aScreenY,
+                           int32_t aClientX,
+                           int32_t aClientY, 
+                           bool aCtrlKey,
+                           bool aAltKey,
+                           bool aShiftKey,
+                           bool aMetaKey,
+                           uint16_t aButton,
+                           nsIDOMEventTarget* aRelatedTarget)
 {
   nsresult rv = nsDOMUIEvent::InitUIEvent(aType, aCanBubble, aCancelable, aView, aDetail);
   NS_ENSURE_SUCCESS(rv, rv);
 
   switch(mEvent->eventStructType) {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_WHEEL_EVENT:
@@ -82,28 +93,28 @@ nsDOMMouseEvent::InitMouseEvent(const ns
     default:
        break;
   }
 
   return NS_OK;
 }   
 
 nsresult
-nsDOMMouseEvent::InitMouseEvent(const nsAString& aType,
-                                bool aCanBubble,
-                                bool aCancelable,
-                                nsIDOMWindow* aView,
-                                int32_t aDetail,
-                                int32_t aScreenX,
-                                int32_t aScreenY,
-                                int32_t aClientX,
-                                int32_t aClientY,
-                                int16_t aButton,
-                                nsIDOMEventTarget *aRelatedTarget,
-                                const nsAString& aModifiersList)
+MouseEvent::InitMouseEvent(const nsAString& aType,
+                           bool aCanBubble,
+                           bool aCancelable,
+                           nsIDOMWindow* aView,
+                           int32_t aDetail,
+                           int32_t aScreenX,
+                           int32_t aScreenY,
+                           int32_t aClientX,
+                           int32_t aClientY,
+                           int16_t aButton,
+                           nsIDOMEventTarget* aRelatedTarget,
+                           const nsAString& aModifiersList)
 {
   Modifiers modifiers = ComputeModifierState(aModifiersList);
 
   nsresult rv = InitMouseEvent(aType, aCanBubble, aCancelable, aView,
                                aDetail, aScreenX, aScreenY, aClientX, aClientY,
                                (modifiers & MODIFIER_CONTROL) != 0,
                                (modifiers & MODIFIER_ALT) != 0,
                                (modifiers & MODIFIER_SHIFT) != 0,
@@ -120,24 +131,24 @@ nsDOMMouseEvent::InitMouseEvent(const ns
     case NS_SIMPLE_GESTURE_EVENT:
       mEvent->AsInputEvent()->modifiers = modifiers;
       return NS_OK;
     default:
       MOZ_CRASH("There is no space to store the modifiers");
   }
 }
 
-already_AddRefed<nsDOMMouseEvent>
-nsDOMMouseEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                             const nsAString& aType,
-                             const mozilla::dom::MouseEventInit& aParam,
-                             mozilla::ErrorResult& aRv)
+already_AddRefed<MouseEvent>
+MouseEvent::Constructor(const GlobalObject& aGlobal,
+                        const nsAString& aType,
+                        const MouseEventInit& aParam,
+                        ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
-  nsRefPtr<nsDOMMouseEvent> e = new nsDOMMouseEvent(t, nullptr, nullptr);
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<MouseEvent> e = new MouseEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
   e->InitMouseEvent(aType, aParam.mBubbles, aParam.mCancelable,
                     aParam.mView, aParam.mDetail, aParam.mScreenX,
                     aParam.mScreenY, aParam.mClientX, aParam.mClientY,
                     aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey,
                     aParam.mMetaKey, aParam.mButton, aParam.mRelatedTarget,
                     aRv);
   e->SetTrusted(trusted);
@@ -154,45 +165,57 @@ nsDOMMouseEvent::Constructor(const mozil
     default:
       break;
   }
 
   return e.forget();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::InitNSMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
-                                  nsIDOMWindow *aView, int32_t aDetail, int32_t aScreenX,
-                                  int32_t aScreenY, int32_t aClientX, int32_t aClientY,
-                                  bool aCtrlKey, bool aAltKey, bool aShiftKey,
-                                  bool aMetaKey, uint16_t aButton, nsIDOMEventTarget *aRelatedTarget,
-                                  float aPressure, uint16_t aInputSource)
+MouseEvent::InitNSMouseEvent(const nsAString& aType,
+                             bool aCanBubble,
+                             bool aCancelable,
+                             nsIDOMWindow* aView,
+                             int32_t aDetail,
+                             int32_t aScreenX,
+                             int32_t aScreenY,
+                             int32_t aClientX,
+                             int32_t aClientY,
+                             bool aCtrlKey,
+                             bool aAltKey,
+                             bool aShiftKey,
+                             bool aMetaKey,
+                             uint16_t aButton,
+                             nsIDOMEventTarget* aRelatedTarget,
+                             float aPressure,
+                             uint16_t aInputSource)
 {
-  nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
-                                                aView, aDetail, aScreenX, aScreenY,
-                                                aClientX, aClientY, aCtrlKey, aAltKey, aShiftKey,
-                                                aMetaKey, aButton, aRelatedTarget);
+  nsresult rv = MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable,
+                                           aView, aDetail, aScreenX, aScreenY,
+                                           aClientX, aClientY,
+                                           aCtrlKey, aAltKey, aShiftKey,
+                                           aMetaKey, aButton, aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WidgetMouseEventBase* mouseEventBase = mEvent->AsMouseEventBase();
   mouseEventBase->pressure = aPressure;
   mouseEventBase->inputSource = aInputSource;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetButton(int16_t* aButton)
+MouseEvent::GetButton(int16_t* aButton)
 {
   NS_ENSURE_ARG_POINTER(aButton);
   *aButton = Button();
   return NS_OK;
 }
 
 int16_t
-nsDOMMouseEvent::Button()
+MouseEvent::Button()
 {
   switch(mEvent->eventStructType)
   {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_WHEEL_EVENT:
     case NS_DRAG_EVENT:
     case NS_POINTER_EVENT:
@@ -200,52 +223,52 @@ nsDOMMouseEvent::Button()
       return mEvent->AsMouseEventBase()->button;
     default:
       NS_WARNING("Tried to get mouse button for non-mouse event!");
       return WidgetMouseEvent::eLeftButton;
   }
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetButtons(uint16_t* aButtons)
+MouseEvent::GetButtons(uint16_t* aButtons)
 {
   NS_ENSURE_ARG_POINTER(aButtons);
   *aButtons = Buttons();
   return NS_OK;
 }
 
 uint16_t
-nsDOMMouseEvent::Buttons()
+MouseEvent::Buttons()
 {
   switch(mEvent->eventStructType)
   {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_WHEEL_EVENT:
     case NS_DRAG_EVENT:
     case NS_POINTER_EVENT:
     case NS_SIMPLE_GESTURE_EVENT:
       return mEvent->AsMouseEventBase()->buttons;
     default:
       MOZ_CRASH("Tried to get mouse buttons for non-mouse event!");
   }
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
+MouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
 {
   NS_ENSURE_ARG_POINTER(aRelatedTarget);
   *aRelatedTarget = GetRelatedTarget().get();
   return NS_OK;
 }
 
-already_AddRefed<mozilla::dom::EventTarget>
-nsDOMMouseEvent::GetRelatedTarget()
+already_AddRefed<EventTarget>
+MouseEvent::GetRelatedTarget()
 {
-  nsCOMPtr<mozilla::dom::EventTarget> relatedTarget;
+  nsCOMPtr<EventTarget> relatedTarget;
   switch(mEvent->eventStructType)
   {
     case NS_MOUSE_EVENT:
     case NS_MOUSE_SCROLL_EVENT:
     case NS_WHEEL_EVENT:
     case NS_DRAG_EVENT:
     case NS_POINTER_EVENT:
     case NS_SIMPLE_GESTURE_EVENT:
@@ -267,192 +290,201 @@ nsDOMMouseEvent::GetRelatedTarget()
       relatedTarget = relatedTarget->GetTargetForDOMEvent();
     }
     return relatedTarget.forget();
   }
   return nullptr;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMozMovementX(int32_t* aMovementX)
+MouseEvent::GetMozMovementX(int32_t* aMovementX)
 {
   NS_ENSURE_ARG_POINTER(aMovementX);
   *aMovementX = MozMovementX();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMozMovementY(int32_t* aMovementY)
+MouseEvent::GetMozMovementY(int32_t* aMovementY)
 {
   NS_ENSURE_ARG_POINTER(aMovementY);
   *aMovementY = MozMovementY();
 
   return NS_OK;
 }
 
-NS_METHOD nsDOMMouseEvent::GetScreenX(int32_t* aScreenX)
+NS_IMETHODIMP
+MouseEvent::GetScreenX(int32_t* aScreenX)
 {
   NS_ENSURE_ARG_POINTER(aScreenX);
   *aScreenX = ScreenX();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseEvent::ScreenX()
+MouseEvent::ScreenX()
 {
   return nsDOMEvent::GetScreenCoords(mPresContext,
                                      mEvent,
                                      mEvent->refPoint).x;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetScreenY(int32_t* aScreenY)
+MouseEvent::GetScreenY(int32_t* aScreenY)
 {
   NS_ENSURE_ARG_POINTER(aScreenY);
   *aScreenY = ScreenY();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseEvent::ScreenY()
+MouseEvent::ScreenY()
 {
   return nsDOMEvent::GetScreenCoords(mPresContext,
                                      mEvent,
                                      mEvent->refPoint).y;
 }
 
 
-NS_METHOD nsDOMMouseEvent::GetClientX(int32_t* aClientX)
+NS_IMETHODIMP
+MouseEvent::GetClientX(int32_t* aClientX)
 {
   NS_ENSURE_ARG_POINTER(aClientX);
   *aClientX = ClientX();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseEvent::ClientX()
+MouseEvent::ClientX()
 {
   return nsDOMEvent::GetClientCoords(mPresContext,
                                      mEvent,
                                      mEvent->refPoint,
                                      mClientPoint).x;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetClientY(int32_t* aClientY)
+MouseEvent::GetClientY(int32_t* aClientY)
 {
   NS_ENSURE_ARG_POINTER(aClientY);
   *aClientY = ClientY();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseEvent::ClientY()
+MouseEvent::ClientY()
 {
   return nsDOMEvent::GetClientCoords(mPresContext,
                                      mEvent,
                                      mEvent->refPoint,
                                      mClientPoint).y;
 }
 
 bool
-nsDOMMouseEvent::AltKey()
+MouseEvent::AltKey()
 {
   return mEvent->AsInputEvent()->IsAlt();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetAltKey(bool* aIsDown)
+MouseEvent::GetAltKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = AltKey();
   return NS_OK;
 }
 
 bool
-nsDOMMouseEvent::CtrlKey()
+MouseEvent::CtrlKey()
 {
   return mEvent->AsInputEvent()->IsControl();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetCtrlKey(bool* aIsDown)
+MouseEvent::GetCtrlKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = CtrlKey();
   return NS_OK;
 }
 
 bool
-nsDOMMouseEvent::ShiftKey()
+MouseEvent::ShiftKey()
 {
   return mEvent->AsInputEvent()->IsShift();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetShiftKey(bool* aIsDown)
+MouseEvent::GetShiftKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = ShiftKey();
   return NS_OK;
 }
 
 bool
-nsDOMMouseEvent::MetaKey()
+MouseEvent::MetaKey()
 {
   return mEvent->AsInputEvent()->IsMeta();
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMetaKey(bool* aIsDown)
+MouseEvent::GetMetaKey(bool* aIsDown)
 {
   NS_ENSURE_ARG_POINTER(aIsDown);
   *aIsDown = MetaKey();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetModifierState(const nsAString& aKey,
+MouseEvent::GetModifierState(const nsAString& aKey,
                                   bool* aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
 
   *aState = GetModifierState(aKey);
   return NS_OK;
 }
 
 float
-nsDOMMouseEvent::MozPressure() const
+MouseEvent::MozPressure() const
 {
   return mEvent->AsMouseEventBase()->pressure;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMozPressure(float* aPressure)
+MouseEvent::GetMozPressure(float* aPressure)
 {
   NS_ENSURE_ARG_POINTER(aPressure);
   *aPressure = MozPressure();
   return NS_OK;
 }
 
 uint16_t
-nsDOMMouseEvent::MozInputSource() const
+MouseEvent::MozInputSource() const
 {
   return mEvent->AsMouseEventBase()->inputSource;
 }
 
 NS_IMETHODIMP
-nsDOMMouseEvent::GetMozInputSource(uint16_t* aInputSource)
+MouseEvent::GetMozInputSource(uint16_t* aInputSource)
 {
   NS_ENSURE_ARG_POINTER(aInputSource);
   *aInputSource = MozInputSource();
   return NS_OK;
 }
 
-nsresult NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult,
-                             mozilla::dom::EventTarget* aOwner,
-                             nsPresContext* aPresContext,
-                             WidgetMouseEvent* aEvent)
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMMouseEvent(nsIDOMEvent** aInstancePtrResult,
+                    EventTarget* aOwner,
+                    nsPresContext* aPresContext,
+                    WidgetMouseEvent* aEvent)
 {
-  nsDOMMouseEvent* it = new nsDOMMouseEvent(aOwner, aPresContext, aEvent);
+  MouseEvent* it = new MouseEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMMouseEvent.h
rename to dom/events/MouseEvent.h
--- a/dom/events/nsDOMMouseEvent.h
+++ b/dom/events/MouseEvent.h
@@ -1,41 +1,44 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsDOMMouseEvent_h__
-#define nsDOMMouseEvent_h__
+#ifndef mozilla_dom_MouseEvent_h_
+#define mozilla_dom_MouseEvent_h_
 
 #include "nsIDOMMouseEvent.h"
 #include "nsDOMUIEvent.h"
 #include "mozilla/dom/MouseEventBinding.h"
 #include "mozilla/EventForwards.h"
 
-class nsDOMMouseEvent : public nsDOMUIEvent,
-                        public nsIDOMMouseEvent
+namespace mozilla {
+namespace dom {
+
+class MouseEvent : public nsDOMUIEvent,
+                   public nsIDOMMouseEvent
 {
 public:
-  nsDOMMouseEvent(mozilla::dom::EventTarget* aOwner,
-                  nsPresContext* aPresContext,
-                  mozilla::WidgetMouseEventBase* aEvent);
+  MouseEvent(EventTarget* aOwner,
+             nsPresContext* aPresContext,
+             WidgetMouseEventBase* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMMouseEvent Interface
   NS_DECL_NSIDOMMOUSEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMUIEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::MouseEventBinding::Wrap(aCx, aScope, this);
+    return MouseEventBinding::Wrap(aCx, aScope, this);
   }
 
   // Web IDL binding methods
   virtual uint32_t Which() MOZ_OVERRIDE
   {
     return Button() + 1;
   }
 
@@ -44,57 +47,57 @@ public:
   int32_t ClientX();
   int32_t ClientY();
   bool CtrlKey();
   bool ShiftKey();
   bool AltKey();
   bool MetaKey();
   int16_t Button();
   uint16_t Buttons();
-  already_AddRefed<mozilla::dom::EventTarget> GetRelatedTarget();
-  void InitMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
+  already_AddRefed<EventTarget> GetRelatedTarget();
+  void InitMouseEvent(const nsAString& aType, bool aCanBubble, bool aCancelable,
                       nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX,
                       int32_t aScreenY, int32_t aClientX, int32_t aClientY,
                       bool aCtrlKey, bool aAltKey, bool aShiftKey,
                       bool aMetaKey, uint16_t aButton,
-                      mozilla::dom::EventTarget *aRelatedTarget,
-                      mozilla::ErrorResult& aRv)
+                      EventTarget* aRelatedTarget, ErrorResult& aRv)
   {
     aRv = InitMouseEvent(aType, aCanBubble, aCancelable,
                          aView, aDetail, aScreenX, aScreenY,
                          aClientX, aClientY, aCtrlKey, aAltKey,
                          aShiftKey, aMetaKey, aButton,
                          aRelatedTarget);
   }
   bool GetModifierState(const nsAString& aKeyArg)
   {
     return GetModifierStateInternal(aKeyArg);
   }
-  static already_AddRefed<nsDOMMouseEvent> Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                                                       const nsAString& aType,
-                                                       const mozilla::dom::MouseEventInit& aParam,
-                                                       mozilla::ErrorResult& aRv);
+  static already_AddRefed<MouseEvent> Constructor(const GlobalObject& aGlobal,
+                                                  const nsAString& aType,
+                                                  const MouseEventInit& aParam,
+                                                  ErrorResult& aRv);
   int32_t MozMovementX()
   {
     return GetMovementPoint().x;
   }
   int32_t MozMovementY()
   {
     return GetMovementPoint().y;
   }
   float MozPressure() const;
   uint16_t MozInputSource() const;
-  void InitNSMouseEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
-                        nsIDOMWindow *aView, int32_t aDetail, int32_t aScreenX,
+  void InitNSMouseEvent(const nsAString& aType,
+                        bool aCanBubble, bool aCancelable,
+                        nsIDOMWindow* aView, int32_t aDetail, int32_t aScreenX,
                         int32_t aScreenY, int32_t aClientX, int32_t aClientY,
                         bool aCtrlKey, bool aAltKey, bool aShiftKey,
                         bool aMetaKey, uint16_t aButton,
-                        mozilla::dom::EventTarget *aRelatedTarget,
+                        EventTarget* aRelatedTarget,
                         float aPressure, uint16_t aInputSource,
-                        mozilla::ErrorResult& aRv)
+                        ErrorResult& aRv)
   {
     aRv = InitNSMouseEvent(aType, aCanBubble, aCancelable,
                            aView, aDetail, aScreenX, aScreenY,
                            aClientX, aClientY, aCtrlKey, aAltKey,
                            aShiftKey, aMetaKey, aButton,
                            aRelatedTarget, aPressure, aInputSource);
   }
 
@@ -104,17 +107,20 @@ protected:
                           bool aCancelable,
                           nsIDOMWindow* aView,
                           int32_t aDetail,
                           int32_t aScreenX,
                           int32_t aScreenY,
                           int32_t aClientX,
                           int32_t aClientY,
                           int16_t aButton,
-                          nsIDOMEventTarget *aRelatedTarget,
+                          nsIDOMEventTarget* aRelatedTarget,
                           const nsAString& aModifiersList);
 };
 
-#define NS_FORWARD_TO_NSDOMMOUSEEVENT         \
-  NS_FORWARD_NSIDOMMOUSEEVENT(nsDOMMouseEvent::) \
+} // namespace dom
+} // namespace mozilla
+
+#define NS_FORWARD_TO_MOUSEEVENT \
+  NS_FORWARD_NSIDOMMOUSEEVENT(MouseEvent::) \
   NS_FORWARD_TO_NSDOMUIEVENT
 
-#endif // nsDOMMouseEvent_h__
+#endif // mozilla_dom_MouseEvent_h_
rename from dom/events/nsDOMMouseScrollEvent.cpp
rename to dom/events/MouseScrollEvent.cpp
--- a/dom/events/nsDOMMouseScrollEvent.cpp
+++ b/dom/events/MouseScrollEvent.cpp
@@ -1,80 +1,98 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsDOMMouseScrollEvent.h"
-#include "prtime.h"
+#include "mozilla/dom/MouseScrollEvent.h"
 #include "mozilla/MouseEvents.h"
-
-using namespace mozilla;
+#include "prtime.h"
 
-nsDOMMouseScrollEvent::nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner,
-                                             nsPresContext* aPresContext,
-                                             WidgetMouseScrollEvent* aEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext,
-                    aEvent ? aEvent :
-                             new WidgetMouseScrollEvent(false, 0, nullptr))
+namespace mozilla {
+namespace dom {
+
+MouseScrollEvent::MouseScrollEvent(EventTarget* aOwner,
+                                   nsPresContext* aPresContext,
+                                   WidgetMouseScrollEvent* aEvent)
+  : MouseEvent(aOwner, aPresContext,
+               aEvent ? aEvent : new WidgetMouseScrollEvent(false, 0, nullptr))
 {
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
     static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
       nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 
   mDetail = mEvent->AsMouseScrollEvent()->delta;
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMMouseScrollEvent, nsDOMMouseEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMouseScrollEvent, nsDOMMouseEvent)
+NS_IMPL_ADDREF_INHERITED(MouseScrollEvent, MouseEvent)
+NS_IMPL_RELEASE_INHERITED(MouseScrollEvent, MouseEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMMouseScrollEvent)
+NS_INTERFACE_MAP_BEGIN(MouseScrollEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMouseScrollEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
+NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
 
 NS_IMETHODIMP
-nsDOMMouseScrollEvent::InitMouseScrollEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
-                                nsIDOMWindow *aView, int32_t aDetail, int32_t aScreenX, 
-                                int32_t aScreenY, int32_t aClientX, int32_t aClientY, 
-                                bool aCtrlKey, bool aAltKey, bool aShiftKey, 
-                                bool aMetaKey, uint16_t aButton, nsIDOMEventTarget *aRelatedTarget,
-                                int32_t aAxis)
+MouseScrollEvent::InitMouseScrollEvent(const nsAString& aType,
+                                       bool aCanBubble,
+                                       bool aCancelable,
+                                       nsIDOMWindow* aView,
+                                       int32_t aDetail,
+                                       int32_t aScreenX,
+                                       int32_t aScreenY,
+                                       int32_t aClientX,
+                                       int32_t aClientY,
+                                       bool aCtrlKey,
+                                       bool aAltKey,
+                                       bool aShiftKey,
+                                       bool aMetaKey,
+                                       uint16_t aButton,
+                                       nsIDOMEventTarget* aRelatedTarget,
+                                       int32_t aAxis)
 {
-  nsresult rv = nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
-                                                aScreenX, aScreenY, aClientX, aClientY, aCtrlKey,
-                                                aAltKey, aShiftKey, aMetaKey, aButton, aRelatedTarget);
+  nsresult rv =
+    MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
+                               aScreenX, aScreenY, aClientX, aClientY,
+                               aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
+                               aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
   mEvent->AsMouseScrollEvent()->isHorizontal = (aAxis == HORIZONTAL_AXIS);
   return NS_OK;
 }
 
 
 NS_IMETHODIMP
-nsDOMMouseScrollEvent::GetAxis(int32_t* aResult)
+MouseScrollEvent::GetAxis(int32_t* aResult)
 {
   NS_ENSURE_ARG_POINTER(aResult);
   *aResult = Axis();
   return NS_OK;
 }
 
 int32_t
-nsDOMMouseScrollEvent::Axis()
+MouseScrollEvent::Axis()
 {
   return mEvent->AsMouseScrollEvent()->isHorizontal ?
            static_cast<int32_t>(HORIZONTAL_AXIS) :
            static_cast<int32_t>(VERTICAL_AXIS);
 }
 
-nsresult NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
-                                   mozilla::dom::EventTarget* aOwner,
-                                   nsPresContext* aPresContext,
-                                   WidgetMouseScrollEvent* aEvent) 
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace dom;
+
+nsresult
+NS_NewDOMMouseScrollEvent(nsIDOMEvent** aInstancePtrResult,
+                          EventTarget* aOwner,
+                          nsPresContext* aPresContext,
+                          WidgetMouseScrollEvent* aEvent)
 {
-  nsDOMMouseScrollEvent* it =
-    new nsDOMMouseScrollEvent(aOwner, aPresContext, aEvent);
+  MouseScrollEvent* it = new MouseScrollEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMMouseScrollEvent.h
rename to dom/events/MouseScrollEvent.h
--- a/dom/events/nsDOMMouseScrollEvent.h
+++ b/dom/events/MouseScrollEvent.h
@@ -1,53 +1,59 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsDOMMouseScrollEvent_h__
-#define nsDOMMouseScrollEvent_h__
+#ifndef mozilla_dom_MouseScrollEvent_h_
+#define mozilla_dom_MouseScrollEvent_h_
 
 #include "nsIDOMMouseScrollEvent.h"
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
 #include "mozilla/dom/MouseScrollEventBinding.h"
 
-class nsDOMMouseScrollEvent : public nsDOMMouseEvent,
-                              public nsIDOMMouseScrollEvent
+namespace mozilla {
+namespace dom {
+
+class MouseScrollEvent : public MouseEvent,
+                         public nsIDOMMouseScrollEvent
 {
 public:
-  nsDOMMouseScrollEvent(mozilla::dom::EventTarget* aOwner,
-                        nsPresContext* aPresContext,
-                        mozilla::WidgetMouseScrollEvent* aEvent);
+  MouseScrollEvent(EventTarget* aOwner,
+                   nsPresContext* aPresContext,
+                   WidgetMouseScrollEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMMouseScrollEvent Interface
   NS_DECL_NSIDOMMOUSESCROLLEVENT
-  
+
   // Forward to base class
-  NS_FORWARD_TO_NSDOMMOUSEEVENT
+  NS_FORWARD_TO_MOUSEEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::MouseScrollEventBinding::Wrap(aCx, aScope, this);
+    return MouseScrollEventBinding::Wrap(aCx, aScope, this);
   }
 
   int32_t Axis();
 
   void InitMouseScrollEvent(const nsAString& aType, bool aCanBubble,
                             bool aCancelable, nsIDOMWindow* aView,
                             int32_t aDetail, int32_t aScreenX, int32_t aScreenY,
                             int32_t aClientX, int32_t aClientY,
                             bool aCtrlKey, bool aAltKey, bool aShiftKey,
                             bool aMetaKey, uint16_t aButton,
                             nsIDOMEventTarget* aRelatedTarget, int32_t aAxis,
-                            mozilla::ErrorResult& aRv)
+                            ErrorResult& aRv)
   {
     aRv = InitMouseScrollEvent(aType, aCanBubble, aCancelable, aView,
                                aDetail, aScreenX, aScreenY, aClientX, aClientY,
                                aCtrlKey, aAltKey, aShiftKey, aMetaKey, aButton,
                                aRelatedTarget, aAxis);
   }
 };
 
-#endif // nsDOMMouseScrollEvent_h__
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_MouseScrollEvent_h_
rename from dom/events/nsDOMMutationEvent.cpp
rename to dom/events/MutationEvent.cpp
--- a/dom/events/nsDOMMutationEvent.cpp
+++ b/dom/events/MutationEvent.cpp
@@ -1,96 +1,104 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsCOMPtr.h"
-#include "nsDOMMutationEvent.h"
-#include "mozilla/MutationEvent.h"
-
-using namespace mozilla;
+#include "mozilla/dom/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 
 class nsPresContext;
 
-nsDOMMutationEvent::nsDOMMutationEvent(mozilla::dom::EventTarget* aOwner,
-                                       nsPresContext* aPresContext,
-                                       InternalMutationEvent* aEvent)
+namespace mozilla {
+namespace dom {
+
+MutationEvent::MutationEvent(EventTarget* aOwner,
+                             nsPresContext* aPresContext,
+                             InternalMutationEvent* aEvent)
   : nsDOMEvent(aOwner, aPresContext,
                aEvent ? aEvent : new InternalMutationEvent(false, 0))
 {
   mEventIsInternal = (aEvent == nullptr);
 }
 
-NS_INTERFACE_MAP_BEGIN(nsDOMMutationEvent)
+NS_INTERFACE_MAP_BEGIN(MutationEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMutationEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
-NS_IMPL_ADDREF_INHERITED(nsDOMMutationEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMutationEvent, nsDOMEvent)
+NS_IMPL_ADDREF_INHERITED(MutationEvent, nsDOMEvent)
+NS_IMPL_RELEASE_INHERITED(MutationEvent, nsDOMEvent)
 
 already_AddRefed<nsINode>
-nsDOMMutationEvent::GetRelatedNode()
+MutationEvent::GetRelatedNode()
 {
   nsCOMPtr<nsINode> n =
     do_QueryInterface(mEvent->AsMutationEvent()->mRelatedNode);
   return n.forget();
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
+MutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
 {
   nsCOMPtr<nsINode> relatedNode = GetRelatedNode();
   nsCOMPtr<nsIDOMNode> relatedDOMNode = relatedNode ? relatedNode->AsDOMNode() : nullptr;
   relatedDOMNode.forget(aRelatedNode);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetPrevValue(nsAString& aPrevValue)
+MutationEvent::GetPrevValue(nsAString& aPrevValue)
 {
   InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   if (mutation->mPrevAttrValue)
     mutation->mPrevAttrValue->ToString(aPrevValue);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetNewValue(nsAString& aNewValue)
+MutationEvent::GetNewValue(nsAString& aNewValue)
 {
   InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   if (mutation->mNewAttrValue)
       mutation->mNewAttrValue->ToString(aNewValue);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetAttrName(nsAString& aAttrName)
+MutationEvent::GetAttrName(nsAString& aAttrName)
 {
   InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   if (mutation->mAttrName)
       mutation->mAttrName->ToString(aAttrName);
   return NS_OK;
 }
 
 uint16_t
-nsDOMMutationEvent::AttrChange()
+MutationEvent::AttrChange()
 {
   return mEvent->AsMutationEvent()->mAttrChange;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::GetAttrChange(uint16_t* aAttrChange)
+MutationEvent::GetAttrChange(uint16_t* aAttrChange)
 {
   *aAttrChange = AttrChange();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMutationEvent::InitMutationEvent(const nsAString& aTypeArg, bool aCanBubbleArg, bool aCancelableArg, nsIDOMNode* aRelatedNodeArg, const nsAString& aPrevValueArg, const nsAString& aNewValueArg, const nsAString& aAttrNameArg, uint16_t aAttrChangeArg)
+MutationEvent::InitMutationEvent(const nsAString& aTypeArg,
+                                 bool aCanBubbleArg,
+                                 bool aCancelableArg,
+                                 nsIDOMNode* aRelatedNodeArg,
+                                 const nsAString& aPrevValueArg,
+                                 const nsAString& aNewValueArg,
+                                 const nsAString& aAttrNameArg,
+                                 uint16_t aAttrChangeArg)
 {
   nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
   NS_ENSURE_SUCCESS(rv, rv);
 
   InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   mutation->mRelatedNode = aRelatedNodeArg;
   if (!aPrevValueArg.IsEmpty())
     mutation->mPrevAttrValue = do_GetAtom(aPrevValueArg);
@@ -99,17 +107,23 @@ nsDOMMutationEvent::InitMutationEvent(co
   if (!aAttrNameArg.IsEmpty()) {
     mutation->mAttrName = do_GetAtom(aAttrNameArg);
   }
   mutation->mAttrChange = aAttrChangeArg;
     
   return NS_OK;
 }
 
-nsresult NS_NewDOMMutationEvent(nsIDOMEvent** aInstancePtrResult,
-                                mozilla::dom::EventTarget* aOwner,
-                                nsPresContext* aPresContext,
-                                InternalMutationEvent* aEvent) 
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMMutationEvent(nsIDOMEvent** aInstancePtrResult,
+                       EventTarget* aOwner,
+                       nsPresContext* aPresContext,
+                       InternalMutationEvent* aEvent) 
 {
-  nsDOMMutationEvent* it = new nsDOMMutationEvent(aOwner, aPresContext, aEvent);
-
+  MutationEvent* it = new MutationEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/dom/events/MutationEvent.h
+++ b/dom/events/MutationEvent.h
@@ -1,70 +1,65 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef mozilla_MutationEvent_h__
-#define mozilla_MutationEvent_h__
+#ifndef mozilla_dom_MutationEvent_h_
+#define mozilla_dom_MutationEvent_h_
 
-#include "mozilla/BasicEvents.h"
-#include "nsCOMPtr.h"
-#include "nsIAtom.h"
-#include "nsIDOMNode.h"
+#include "nsIDOMMutationEvent.h"
+#include "nsINode.h"
+#include "nsDOMEvent.h"
+#include "mozilla/dom/MutationEventBinding.h"
+#include "mozilla/EventForwards.h"
 
 namespace mozilla {
+namespace dom {
 
-class InternalMutationEvent : public WidgetEvent
+class MutationEvent : public nsDOMEvent,
+                      public nsIDOMMutationEvent
 {
 public:
-  virtual InternalMutationEvent* AsMutationEvent() MOZ_OVERRIDE { return this; }
+  MutationEvent(EventTarget* aOwner,
+                nsPresContext* aPresContext,
+                InternalMutationEvent* aEvent);
+
+  NS_DECL_ISUPPORTS_INHERITED
+
+  NS_DECL_NSIDOMMUTATIONEVENT
 
-  InternalMutationEvent(bool aIsTrusted, uint32_t aMessage) :
-    WidgetEvent(aIsTrusted, aMessage, NS_MUTATION_EVENT),
-    mAttrChange(0)
+  // Forward to base class
+  NS_FORWARD_TO_NSDOMEVENT
+
+  virtual JSObject* WrapObject(JSContext* aCx,
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    mFlags.mCancelable = false;
+    return MutationEventBinding::Wrap(aCx, aScope, this);
   }
 
-  virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
-  {
-    MOZ_ASSERT(eventStructType == NS_MUTATION_EVENT,
-               "Duplicate() must be overridden by sub class");
-    InternalMutationEvent* result = new InternalMutationEvent(false, message);
-    result->AssignMutationEventData(*this, true);
-    result->mFlags = mFlags;
-    return result;
-  }
+  // xpidl implementation
+  // GetPrevValue(nsAString& aPrevValue);
+  // GetNewValue(nsAString& aNewValue);
+  // GetAttrName(nsAString& aAttrName);
+
+  already_AddRefed<nsINode> GetRelatedNode();
+
+  uint16_t AttrChange();
 
-  nsCOMPtr<nsIDOMNode> mRelatedNode;
-  nsCOMPtr<nsIAtom>    mAttrName;
-  nsCOMPtr<nsIAtom>    mPrevAttrValue;
-  nsCOMPtr<nsIAtom>    mNewAttrValue;
-  unsigned short       mAttrChange;
-
-  void AssignMutationEventData(const InternalMutationEvent& aEvent,
-                               bool aCopyTargets)
+  void InitMutationEvent(const nsAString& aType,
+                         bool& aCanBubble, bool& aCancelable,
+                         nsINode* aRelatedNode,
+                         const nsAString& aPrevValue,
+                         const nsAString& aNewValue,
+                         const nsAString& aAttrName,
+                         uint16_t& aAttrChange, ErrorResult& aRv)
   {
-    AssignEventData(aEvent, aCopyTargets);
-
-    mRelatedNode = aEvent.mRelatedNode;
-    mAttrName = aEvent.mAttrName;
-    mPrevAttrValue = aEvent.mPrevAttrValue;
-    mNewAttrValue = aEvent.mNewAttrValue;
-    mAttrChange = aEvent.mAttrChange;
+    aRv = InitMutationEvent(aType, aCanBubble, aCancelable,
+                            aRelatedNode ? aRelatedNode->AsDOMNode() : nullptr,
+                            aPrevValue, aNewValue, aAttrName, aAttrChange);
   }
 };
 
-// Bits are actually checked to optimize mutation event firing.
-// That's why I don't number from 0x00.  The first event should
-// always be 0x01.
-#define NS_EVENT_BITS_MUTATION_SUBTREEMODIFIED                0x01
-#define NS_EVENT_BITS_MUTATION_NODEINSERTED                   0x02
-#define NS_EVENT_BITS_MUTATION_NODEREMOVED                    0x04
-#define NS_EVENT_BITS_MUTATION_NODEREMOVEDFROMDOCUMENT        0x08
-#define NS_EVENT_BITS_MUTATION_NODEINSERTEDINTODOCUMENT       0x10
-#define NS_EVENT_BITS_MUTATION_ATTRMODIFIED                   0x20
-#define NS_EVENT_BITS_MUTATION_CHARACTERDATAMODIFIED          0x40
-
+} // namespace dom
 } // namespace mozilla
 
-#endif // mozilla_MutationEvent_h__
+#endif // mozilla_dom_MutationEvent_h_
--- a/dom/events/PointerEvent.cpp
+++ b/dom/events/PointerEvent.cpp
@@ -1,28 +1,30 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * Portions Copyright 2013 Microsoft Open Technologies, Inc. */
 
-#include "PointerEvent.h"
+#include "mozilla/dom/PointerEvent.h"
 #include "mozilla/MouseEvents.h"
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 PointerEvent::PointerEvent(EventTarget* aOwner,
                            nsPresContext* aPresContext,
                            WidgetPointerEvent* aEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext, aEvent ? aEvent : new WidgetPointerEvent(false, 0, nullptr))
+  : MouseEvent(aOwner, aPresContext,
+               aEvent ? aEvent : new WidgetPointerEvent(false, 0, nullptr))
 {
-  NS_ASSERTION(mEvent->eventStructType == NS_POINTER_EVENT, "event type mismatch NS_POINTER_EVENT");
+  NS_ASSERTION(mEvent->eventStructType == NS_POINTER_EVENT,
+               "event type mismatch NS_POINTER_EVENT");
 
   WidgetMouseEvent* mouseEvent = mEvent->AsMouseEvent();
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
@@ -43,30 +45,31 @@ ConvertStringToPointerType(const nsAStri
     return nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
   }
 
   return nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
 }
 
 //static
 already_AddRefed<PointerEvent>
-PointerEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
+PointerEvent::Constructor(const GlobalObject& aGlobal,
                           const nsAString& aType,
-                          const mozilla::dom::PointerEventInit& aParam,
-                          mozilla::ErrorResult& aRv)
+                          const PointerEventInit& aParam,
+                          ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
   nsRefPtr<PointerEvent> e = new PointerEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
 
   aRv = e->InitMouseEvent(aType, aParam.mBubbles, aParam.mCancelable,
                           aParam.mView, aParam.mDetail, aParam.mScreenX,
                           aParam.mScreenY, aParam.mClientX, aParam.mClientY,
                           aParam.mCtrlKey, aParam.mAltKey, aParam.mShiftKey,
-                          aParam.mMetaKey, aParam.mButton, aParam.mRelatedTarget);
+                          aParam.mMetaKey, aParam.mButton,
+                          aParam.mRelatedTarget);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   WidgetPointerEvent* widgetEvent = e->mEvent->AsPointerEvent();
   widgetEvent->pointerId = aParam.mPointerId;
   widgetEvent->width = aParam.mWidth;
   widgetEvent->height = aParam.mHeight;
@@ -95,56 +98,65 @@ PointerEvent::GetPointerType(nsAString& 
       aPointerType.AssignLiteral("touch");
       break;
     case nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN:
       aPointerType.AssignLiteral("");
       break;
   }
 }
 
-int32_t PointerEvent::PointerId()
+int32_t
+PointerEvent::PointerId()
 {
   return mEvent->AsPointerEvent()->pointerId;
 }
 
-int32_t PointerEvent::Width()
+int32_t
+PointerEvent::Width()
 {
   return mEvent->AsPointerEvent()->width;
 }
 
-int32_t PointerEvent::Height()
+int32_t
+PointerEvent::Height()
 {
   return mEvent->AsPointerEvent()->height;
 }
 
-float PointerEvent::Pressure()
+float
+PointerEvent::Pressure()
 {
   return mEvent->AsPointerEvent()->pressure;
 }
 
-int32_t PointerEvent::TiltX()
+int32_t
+PointerEvent::TiltX()
 {
   return mEvent->AsPointerEvent()->tiltX;
 }
 
-int32_t PointerEvent::TiltY()
+int32_t
+PointerEvent::TiltY()
 {
   return mEvent->AsPointerEvent()->tiltY;
 }
 
-bool PointerEvent::IsPrimary()
+bool
+PointerEvent::IsPrimary()
 {
   return mEvent->AsPointerEvent()->isPrimary;
 }
 
 } // namespace dom
 } // namespace mozilla
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
-nsresult NS_NewDOMPointerEvent(nsIDOMEvent** aInstancePtrResult,
-                               dom::EventTarget* aOwner,
-                               nsPresContext* aPresContext,
-                               WidgetPointerEvent *aEvent)
+nsresult
+NS_NewDOMPointerEvent(nsIDOMEvent** aInstancePtrResult,
+                      EventTarget* aOwner,
+                      nsPresContext* aPresContext,
+                      WidgetPointerEvent *aEvent)
 {
-  dom::PointerEvent *it = new dom::PointerEvent(aOwner, aPresContext, aEvent);
+  PointerEvent *it = new PointerEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/dom/events/PointerEvent.h
+++ b/dom/events/PointerEvent.h
@@ -1,50 +1,50 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * Portions Copyright 2013 Microsoft Open Technologies, Inc. */
 
-#ifndef PointerEvent_h__
-#define PointerEvent_h__
+#ifndef mozilla_dom_PointerEvent_h_
+#define mozilla_dom_PointerEvent_h_
 
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
 #include "mozilla/dom/PointerEventBinding.h"
 
 class nsPresContext;
 
 namespace mozilla {
 namespace dom {
 
-class PointerEvent : public nsDOMMouseEvent
+class PointerEvent : public MouseEvent
 {
 public:
   PointerEvent(EventTarget* aOwner,
                nsPresContext* aPresContext,
                WidgetPointerEvent* aEvent);
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::PointerEventBinding::Wrap(aCx, aScope, this);
+    return PointerEventBinding::Wrap(aCx, aScope, this);
   }
 
   static already_AddRefed<PointerEvent>
   Constructor(const GlobalObject& aGlobal,
               const nsAString& aType,
               const PointerEventInit& aParam,
-              mozilla::ErrorResult& aRv);
+              ErrorResult& aRv);
 
   int32_t PointerId();
   int32_t Width();
   int32_t Height();
   float Pressure();
   int32_t TiltX();
   int32_t TiltY();
   bool IsPrimary();
   void GetPointerType(nsAString& aPointerType);
 };
 
 } // namespace dom
 } // namespace mozilla
 
-#endif
+#endif // mozilla_dom_PointerEvent_h_
rename from dom/events/nsDOMSimpleGestureEvent.cpp
rename to dom/events/SimpleGestureEvent.cpp
--- a/dom/events/nsDOMSimpleGestureEvent.cpp
+++ b/dom/events/SimpleGestureEvent.cpp
@@ -1,161 +1,159 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsDOMSimpleGestureEvent.h"
-#include "prtime.h"
+#include "mozilla/dom/SimpleGestureEvent.h"
 #include "mozilla/TouchEvents.h"
+#include "prtime.h"
 
-using namespace mozilla;
+namespace mozilla {
+namespace dom {
 
-nsDOMSimpleGestureEvent::nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwner,
-                                                 nsPresContext* aPresContext,
-                                                 WidgetSimpleGestureEvent* aEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext,
-                    aEvent ? aEvent :
-                             new WidgetSimpleGestureEvent(false, 0, nullptr))
+SimpleGestureEvent::SimpleGestureEvent(EventTarget* aOwner,
+                                       nsPresContext* aPresContext,
+                                       WidgetSimpleGestureEvent* aEvent)
+  : MouseEvent(aOwner, aPresContext,
+               aEvent ? aEvent :
+                        new WidgetSimpleGestureEvent(false, 0, nullptr))
 {
   NS_ASSERTION(mEvent->eventStructType == NS_SIMPLE_GESTURE_EVENT, "event type mismatch");
 
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
     static_cast<WidgetMouseEventBase*>(mEvent)->inputSource =
       nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMSimpleGestureEvent, nsDOMUIEvent)
+NS_IMPL_ADDREF_INHERITED(SimpleGestureEvent, MouseEvent)
+NS_IMPL_RELEASE_INHERITED(SimpleGestureEvent, MouseEvent)
 
-NS_INTERFACE_MAP_BEGIN(nsDOMSimpleGestureEvent)
+NS_INTERFACE_MAP_BEGIN(SimpleGestureEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMSimpleGestureEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
+NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
 
 /* attribute unsigned long allowedDirections; */
 uint32_t
-nsDOMSimpleGestureEvent::AllowedDirections()
+SimpleGestureEvent::AllowedDirections()
 {
   return mEvent->AsSimpleGestureEvent()->allowedDirections;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::GetAllowedDirections(uint32_t *aAllowedDirections)
+SimpleGestureEvent::GetAllowedDirections(uint32_t* aAllowedDirections)
 {
   NS_ENSURE_ARG_POINTER(aAllowedDirections);
   *aAllowedDirections = AllowedDirections();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
+SimpleGestureEvent::SetAllowedDirections(uint32_t aAllowedDirections)
 {
   mEvent->AsSimpleGestureEvent()->allowedDirections = aAllowedDirections;
   return NS_OK;
 }
 
 /* readonly attribute unsigned long direction; */
 uint32_t
-nsDOMSimpleGestureEvent::Direction()
+SimpleGestureEvent::Direction()
 {
   return mEvent->AsSimpleGestureEvent()->direction;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::GetDirection(uint32_t *aDirection)
+SimpleGestureEvent::GetDirection(uint32_t* aDirection)
 {
   NS_ENSURE_ARG_POINTER(aDirection);
   *aDirection = Direction();
   return NS_OK;
 }
 
 /* readonly attribute float delta; */
 double
-nsDOMSimpleGestureEvent::Delta()
+SimpleGestureEvent::Delta()
 {
   return mEvent->AsSimpleGestureEvent()->delta;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::GetDelta(double *aDelta)
+SimpleGestureEvent::GetDelta(double* aDelta)
 {
   NS_ENSURE_ARG_POINTER(aDelta);
   *aDelta = Delta();
   return NS_OK;
 }
 
 /* readonly attribute unsigned long clickCount; */
 uint32_t
-nsDOMSimpleGestureEvent::ClickCount()
+SimpleGestureEvent::ClickCount()
 {
   return mEvent->AsSimpleGestureEvent()->clickCount;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::GetClickCount(uint32_t *aClickCount)
+SimpleGestureEvent::GetClickCount(uint32_t* aClickCount)
 {
   NS_ENSURE_ARG_POINTER(aClickCount);
   *aClickCount = ClickCount();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMSimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
-                                                bool aCanBubbleArg,
-                                                bool aCancelableArg,
-                                                nsIDOMWindow* aViewArg,
-                                                int32_t aDetailArg,
-                                                int32_t aScreenX, 
-                                                int32_t aScreenY,
-                                                int32_t aClientX,
-                                                int32_t aClientY,
-                                                bool aCtrlKeyArg,
-                                                bool aAltKeyArg,
-                                                bool aShiftKeyArg,
-                                                bool aMetaKeyArg,
-                                                uint16_t aButton,
-                                                nsIDOMEventTarget* aRelatedTarget,
-                                                uint32_t aAllowedDirectionsArg,
-                                                uint32_t aDirectionArg,
-                                                double aDeltaArg,
-                                                uint32_t aClickCountArg)
+SimpleGestureEvent::InitSimpleGestureEvent(const nsAString& aTypeArg,
+                                           bool aCanBubbleArg,
+                                           bool aCancelableArg,
+                                           nsIDOMWindow* aViewArg,
+                                           int32_t aDetailArg,
+                                           int32_t aScreenX, 
+                                           int32_t aScreenY,
+                                           int32_t aClientX,
+                                           int32_t aClientY,
+                                           bool aCtrlKeyArg,
+                                           bool aAltKeyArg,
+                                           bool aShiftKeyArg,
+                                           bool aMetaKeyArg,
+                                           uint16_t aButton,
+                                           nsIDOMEventTarget* aRelatedTarget,
+                                           uint32_t aAllowedDirectionsArg,
+                                           uint32_t aDirectionArg,
+                                           double aDeltaArg,
+                                           uint32_t aClickCountArg)
 {
-  nsresult rv = nsDOMMouseEvent::InitMouseEvent(aTypeArg,
-                                                aCanBubbleArg,
-                                                aCancelableArg,
-                                                aViewArg,
-                                                aDetailArg,
-                                                aScreenX, 
-                                                aScreenY,
-                                                aClientX,
-                                                aClientY,
-                                                aCtrlKeyArg,
-                                                aAltKeyArg,
-                                                aShiftKeyArg,
-                                                aMetaKeyArg,
-                                                aButton,
-                                                aRelatedTarget);
+  nsresult rv =
+    MouseEvent::InitMouseEvent(aTypeArg, aCanBubbleArg, aCancelableArg,
+                               aViewArg, aDetailArg,
+                               aScreenX, aScreenY, aClientX, aClientY,
+                               aCtrlKeyArg, aAltKeyArg, aShiftKeyArg,
+                               aMetaKeyArg, aButton, aRelatedTarget);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WidgetSimpleGestureEvent* simpleGestureEvent = mEvent->AsSimpleGestureEvent();
   simpleGestureEvent->allowedDirections = aAllowedDirectionsArg;
   simpleGestureEvent->direction = aDirectionArg;
   simpleGestureEvent->delta = aDeltaArg;
   simpleGestureEvent->clickCount = aClickCountArg;
 
   return NS_OK;
 }
 
-nsresult NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
-                                     mozilla::dom::EventTarget* aOwner,
-                                     nsPresContext* aPresContext,
-                                     WidgetSimpleGestureEvent* aEvent)
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
+nsresult
+NS_NewDOMSimpleGestureEvent(nsIDOMEvent** aInstancePtrResult,
+                            EventTarget* aOwner,
+                            nsPresContext* aPresContext,
+                            WidgetSimpleGestureEvent* aEvent)
 {
-  nsDOMSimpleGestureEvent* it =
-    new nsDOMSimpleGestureEvent(aOwner, aPresContext, aEvent);
+  SimpleGestureEvent* it = new SimpleGestureEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMSimpleGestureEvent.h
rename to dom/events/SimpleGestureEvent.h
--- a/dom/events/nsDOMSimpleGestureEvent.h
+++ b/dom/events/SimpleGestureEvent.h
@@ -1,40 +1,44 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsDOMSimpleGestureEvent_h__
-#define nsDOMSimpleGestureEvent_h__
+#ifndef mozilla_dom_SimpleGestureEvent_h_
+#define mozilla_dom_SimpleGestureEvent_h_
 
 #include "nsIDOMSimpleGestureEvent.h"
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
+#include "mozilla/dom/SimpleGestureEventBinding.h"
 #include "mozilla/EventForwards.h"
-#include "mozilla/dom/SimpleGestureEventBinding.h"
 
 class nsPresContext;
 
-class nsDOMSimpleGestureEvent : public nsDOMMouseEvent,
-                                public nsIDOMSimpleGestureEvent
+namespace mozilla {
+namespace dom {
+
+class SimpleGestureEvent : public MouseEvent,
+                           public nsIDOMSimpleGestureEvent
 {
 public:
-  nsDOMSimpleGestureEvent(mozilla::dom::EventTarget* aOwner,
-                          nsPresContext*, mozilla::WidgetSimpleGestureEvent*);
+  SimpleGestureEvent(EventTarget* aOwner,
+                     nsPresContext* aPresContext,
+                     WidgetSimpleGestureEvent* aEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMSIMPLEGESTUREEVENT
 
   // Forward to base class
-  NS_FORWARD_TO_NSDOMMOUSEEVENT
+  NS_FORWARD_TO_MOUSEEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
-			       JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
+                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
   {
-    return mozilla::dom::SimpleGestureEventBinding::Wrap(aCx, aScope, this);
+    return SimpleGestureEventBinding::Wrap(aCx, aScope, this);
   }
 
   uint32_t AllowedDirections();
   uint32_t Direction();
   double Delta();
   uint32_t ClickCount();
 
   void InitSimpleGestureEvent(const nsAString& aType,
@@ -46,25 +50,28 @@ public:
                               int32_t aScreenY,
                               int32_t aClientX,
                               int32_t aClientY,
                               bool aCtrlKey,
                               bool aAltKey,
                               bool aShiftKey,
                               bool aMetaKey,
                               uint16_t aButton,
-                              mozilla::dom::EventTarget* aRelatedTarget,
+                              EventTarget* aRelatedTarget,
                               uint32_t aAllowedDirections,
                               uint32_t aDirection,
                               double aDelta,
                               uint32_t aClickCount,
-                              mozilla::ErrorResult& aRv)
+                              ErrorResult& aRv)
   {
     aRv = InitSimpleGestureEvent(aType, aCanBubble, aCancelable,
                                  aView, aDetail, aScreenX, aScreenY,
                                  aClientX, aClientY, aCtrlKey, aAltKey,
                                  aShiftKey, aMetaKey, aButton,
                                  aRelatedTarget, aAllowedDirections,
                                  aDirection, aDelta, aClickCount);
   }
 };
 
-#endif
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_SimpleGestureEvent_h_
--- a/dom/events/WheelEvent.cpp
+++ b/dom/events/WheelEvent.cpp
@@ -9,36 +9,36 @@
 #include "prtime.h"
 
 namespace mozilla {
 namespace dom {
 
 WheelEvent::WheelEvent(EventTarget* aOwner,
                        nsPresContext* aPresContext,
                        WidgetWheelEvent* aWheelEvent)
-  : nsDOMMouseEvent(aOwner, aPresContext,
-                    aWheelEvent ? aWheelEvent :
-                                  new WidgetWheelEvent(false, 0, nullptr))
+  : MouseEvent(aOwner, aPresContext,
+               aWheelEvent ? aWheelEvent :
+                             new WidgetWheelEvent(false, 0, nullptr))
 {
   if (aWheelEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
     mEvent->refPoint.x = mEvent->refPoint.y = 0;
     mEvent->AsWheelEvent()->inputSource = nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN;
   }
 }
 
-NS_IMPL_ADDREF_INHERITED(WheelEvent, nsDOMMouseEvent)
-NS_IMPL_RELEASE_INHERITED(WheelEvent, nsDOMMouseEvent)
+NS_IMPL_ADDREF_INHERITED(WheelEvent, MouseEvent)
+NS_IMPL_RELEASE_INHERITED(WheelEvent, MouseEvent)
 
 NS_INTERFACE_MAP_BEGIN(WheelEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMWheelEvent)
-NS_INTERFACE_MAP_END_INHERITING(nsDOMMouseEvent)
+NS_INTERFACE_MAP_END_INHERITING(MouseEvent)
 
 NS_IMETHODIMP
 WheelEvent::InitWheelEvent(const nsAString& aType,
                            bool aCanBubble,
                            bool aCancelable,
                            nsIDOMWindow* aView,
                            int32_t aDetail,
                            int32_t aScreenX,
@@ -49,20 +49,19 @@ WheelEvent::InitWheelEvent(const nsAStri
                            nsIDOMEventTarget* aRelatedTarget,
                            const nsAString& aModifiersList,
                            double aDeltaX,
                            double aDeltaY,
                            double aDeltaZ,
                            uint32_t aDeltaMode)
 {
   nsresult rv =
-    nsDOMMouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView,
-                                    aDetail, aScreenX, aScreenY,
-                                    aClientX, aClientY, aButton,
-                                    aRelatedTarget, aModifiersList);
+    MouseEvent::InitMouseEvent(aType, aCanBubble, aCancelable, aView, aDetail,
+                               aScreenX, aScreenY, aClientX, aClientY, aButton,
+                               aRelatedTarget, aModifiersList);
   NS_ENSURE_SUCCESS(rv, rv);
 
   WidgetWheelEvent* wheelEvent = mEvent->AsWheelEvent();
   wheelEvent->deltaX = aDeltaX;
   wheelEvent->deltaY = aDeltaY;
   wheelEvent->deltaZ = aDeltaZ;
   wheelEvent->deltaMode = aDeltaMode;
 
--- a/dom/events/WheelEvent.h
+++ b/dom/events/WheelEvent.h
@@ -3,38 +3,38 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_WheelEvent_h_
 #define mozilla_dom_WheelEvent_h_
 
 #include "nsIDOMWheelEvent.h"
-#include "nsDOMMouseEvent.h"
+#include "mozilla/dom/MouseEvent.h"
+#include "mozilla/dom/WheelEventBinding.h"
 #include "mozilla/EventForwards.h"
-#include "mozilla/dom/WheelEventBinding.h"
 
 namespace mozilla {
 namespace dom {
 
-class WheelEvent : public nsDOMMouseEvent,
+class WheelEvent : public MouseEvent,
                    public nsIDOMWheelEvent
 {
 public:
   WheelEvent(EventTarget* aOwner,
              nsPresContext* aPresContext,
              WidgetWheelEvent* aWheelEvent);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIDOMWheelEvent Interface
   NS_DECL_NSIDOMWHEELEVENT
   
   // Forward to base class
-  NS_FORWARD_TO_NSDOMMOUSEEVENT
+  NS_FORWARD_TO_MOUSEEVENT
 
   static
   already_AddRefed<WheelEvent> Constructor(const GlobalObject& aGlobal,
                                            const nsAString& aType,
                                            const WheelEventInit& aParam,
                                            ErrorResult& aRv);
 
   virtual JSObject* WrapObject(JSContext* aCx,
--- a/dom/events/moz.build
+++ b/dom/events/moz.build
@@ -27,69 +27,78 @@ EXPORTS += [
     'nsEventStates.h',
     'nsIJSEventListener.h',
     'nsIPrivateTextEvent.h',
     'nsIPrivateTextRange.h',
     'nsVKList.h',
 ]
 
 EXPORTS.mozilla += [
-    'MutationEvent.h',
+    'InternalMutationEvent.h',
 ]
 
 EXPORTS.mozilla.dom += [
     'AnimationEvent.h',
     'BeforeUnloadEvent.h',
     'ClipboardEvent.h',
     'CommandEvent.h',
     'CompositionEvent.h',
     'DataContainerEvent.h',
     'DataTransfer.h',
+    'DeviceMotionEvent.h',
+    'DragEvent.h',
     'EventTarget.h',
+    'FocusEvent.h',
+    'KeyboardEvent.h',
+    'MessageEvent.h',
+    'MouseEvent.h',
+    'MouseScrollEvent.h',
+    'MutationEvent.h',
     'PointerEvent.h',
+    'SimpleGestureEvent.h',
     'Touch.h',
     'WheelEvent.h',
 ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     EXPORTS.mozilla.dom += ['SpeechRecognitionError.h']
 
 UNIFIED_SOURCES += [
     'AnimationEvent.cpp',
     'BeforeUnloadEvent.cpp',
     'ClipboardEvent.cpp',
     'CommandEvent.cpp',
     'CompositionEvent.cpp',
     'DataContainerEvent.cpp',
     'DataTransfer.cpp',
+    'DeviceMotionEvent.cpp',
+    'DragEvent.cpp',
     'EventTarget.cpp',
+    'FocusEvent.cpp',
+    'KeyboardEvent.cpp',
+    'MessageEvent.cpp',
+    'MouseEvent.cpp',
+    'MouseScrollEvent.cpp',
+    'MutationEvent.cpp',
     'nsAsyncDOMEvent.cpp',
     'nsContentEventHandler.cpp',
-    'nsDOMDeviceMotionEvent.cpp',
-    'nsDOMDragEvent.cpp',
     'nsDOMEventTargetHelper.cpp',
-    'nsDOMFocusEvent.cpp',
-    'nsDOMKeyboardEvent.cpp',
-    'nsDOMMessageEvent.cpp',
-    'nsDOMMouseEvent.cpp',
-    'nsDOMMouseScrollEvent.cpp',
-    'nsDOMMutationEvent.cpp',
     'nsDOMNotifyAudioAvailableEvent.cpp',
-    'nsDOMSimpleGestureEvent.cpp',
     'nsDOMTextEvent.cpp',
     'nsDOMTouchEvent.cpp',
     'nsDOMTransitionEvent.cpp',
     'nsDOMXULCommandEvent.cpp',
     'nsEventDispatcher.cpp',
     'nsEventListenerService.cpp',
     'nsIMEStateManager.cpp',
     'nsJSEventListener.cpp',
     'nsPaintRequest.cpp',
     'nsPrivateTextRange.cpp',
     'PointerEvent.cpp',
+    'SimpleGestureEvent.cpp',
     'TextComposition.cpp',
     'Touch.cpp',
     'WheelEvent.cpp',
 ]
 
 SOURCES += [
     # nsDOMEvent.cpp should be built separately because it includes
     # ipc/IPCMessageUtils.h, which on Windows includes windows.h.
--- a/dom/events/nsDOMEvent.cpp
+++ b/dom/events/nsDOMEvent.cpp
@@ -11,19 +11,19 @@
 #include "nsError.h"
 #include "nsDOMEvent.h"
 #include "nsEventStateManager.h"
 #include "nsIFrame.h"
 #include "nsIContent.h"
 #include "nsIPresShell.h"
 #include "nsIDocument.h"
 #include "mozilla/ContentEvents.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "nsContentUtils.h"
 #include "nsJSEnvironment.h"
 #include "mozilla/Preferences.h"
 #include "nsLayoutUtils.h"
 #include "nsIScrollableFrame.h"
 #include "nsDOMEventTargetHelper.h"
deleted file mode 100644
--- a/dom/events/nsDOMMutationEvent.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef nsDOMMutationEvent_h__
-#define nsDOMMutationEvent_h__
-
-#include "nsIDOMMutationEvent.h"
-#include "nsINode.h"
-#include "nsDOMEvent.h"
-#include "mozilla/dom/MutationEventBinding.h"
-#include "mozilla/EventForwards.h"
-
-class nsDOMMutationEvent : public nsDOMEvent,
-                           public nsIDOMMutationEvent
-{
-public:
-  nsDOMMutationEvent(mozilla::dom::EventTarget* aOwner,
-                     nsPresContext* aPresContext,
-                     mozilla::InternalMutationEvent* aEvent);
-
-  NS_DECL_ISUPPORTS_INHERITED
-
-  NS_DECL_NSIDOMMUTATIONEVENT
-
-  // Forward to base class
-  NS_FORWARD_TO_NSDOMEVENT
-
-  virtual JSObject* WrapObject(JSContext* aCx,
-                               JS::Handle<JSObject*> aScope) MOZ_OVERRIDE
-  {
-    return mozilla::dom::MutationEventBinding::Wrap(aCx, aScope, this);
-  }
-
-  // xpidl implementation
-  // GetPrevValue(nsAString& aPrevValue);
-  // GetNewValue(nsAString& aNewValue);
-  // GetAttrName(nsAString& aAttrName);
-
-  already_AddRefed<nsINode> GetRelatedNode();
-
-  uint16_t AttrChange();
-
-  void InitMutationEvent(const nsAString& aType,
-                         bool& aCanBubble, bool& aCancelable,
-                         nsINode* aRelatedNode,
-                         const nsAString& aPrevValue,
-                         const nsAString& aNewValue,
-                         const nsAString& aAttrName,
-                         uint16_t& aAttrChange, mozilla::ErrorResult& aRv)
-  {
-    aRv = InitMutationEvent(aType, aCanBubble, aCancelable,
-                            aRelatedNode ? aRelatedNode->AsDOMNode() : nullptr,
-                            aPrevValue, aNewValue, aAttrName, aAttrChange);
-  }
-};
-
-#endif // nsDOMMutationEvent_h__
--- a/dom/events/nsEventDispatcher.cpp
+++ b/dom/events/nsEventDispatcher.cpp
@@ -14,19 +14,19 @@
 #include "nsIDocument.h"
 #include "nsINode.h"
 #include "nsPIDOMWindow.h"
 #include "nsDOMTouchEvent.h"
 #include "GeckoProfiler.h"
 #include "GeneratedEvents.h"
 #include "mozilla/ContentEvents.h"
 #include "mozilla/dom/EventTarget.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "mozilla/MiscEvents.h"
 #include "mozilla/MouseEvents.h"
-#include "mozilla/MutationEvent.h"
 #include "mozilla/TextEvents.h"
 #include "mozilla/TouchEvents.h"
 #include "mozilla/unused.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 class ELMCreationDetector
--- a/dom/events/nsEventListenerManager.cpp
+++ b/dom/events/nsEventListenerManager.cpp
@@ -21,17 +21,17 @@
 #include "nsIJSEventListener.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsINameSpaceManager.h"
 #include "nsIContent.h"
 #include "mozilla/MemoryReporting.h"
 #include "nsCOMPtr.h"
 #include "nsError.h"
 #include "nsIDocument.h"
-#include "mozilla/MutationEvent.h"
+#include "mozilla/InternalMutationEvent.h"
 #include "nsIXPConnect.h"
 #include "nsDOMCID.h"
 #include "nsContentUtils.h"
 #include "nsJSUtils.h"
 #include "nsEventDispatcher.h"
 #include "nsCOMArray.h"
 #include "nsEventListenerService.h"
 #include "nsIContentSecurityPolicy.h"
--- a/dom/events/nsEventStateManager.cpp
+++ b/dom/events/nsEventStateManager.cpp
@@ -45,17 +45,17 @@
 #include "nsIDOMXULElement.h"
 #include "nsIDOMKeyEvent.h"
 #include "nsIObserverService.h"
 #include "nsIDocShell.h"
 #include "nsIMarkupDocumentViewer.h"
 #include "nsIDOMWheelEvent.h"
 #include "nsIDOMDragEvent.h"
 #include "nsIDOMUIEvent.h"
-#include "nsDOMDragEvent.h"
+#include "nsDOMUIEvent.h"
 #include "nsIMozBrowserFrame.h"
 
 #include "nsSubDocumentFrame.h"
 #include "nsLayoutUtils.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsUnicharUtils.h"
 #include "nsContentUtils.h"
 
@@ -3561,17 +3561,17 @@ nsEventStateManager::PostHandleEvent(nsP
           dataTransfer = do_QueryInterface(dragEvent->dataTransfer);
           dataTransfer->GetDropEffectInt(&dropEffect);
         }
         else {
           // if dragEvent->dataTransfer is null, it means that no attempt was
           // made to access the dataTransfer during the event, yet the event
           // was cancelled. Instead, use the initial data transfer available
           // from the drag session. The drop effect would not have been
-          // initialized (which is done in nsDOMDragEvent::GetDataTransfer),
+          // initialized (which is done in DragEvent::GetDataTransfer),
           // so set it from the drag action. We'll still want to filter it
           // based on the effectAllowed below.
           dataTransfer = initialDataTransfer;
 
           uint32_t action;
           dragSession->GetDragAction(&action);
 
           // filter the drop effect based on the action. Use UNINITIALIZED as
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -7,19 +7,20 @@
 #include "base/basictypes.h"
 
 #include "IDBDatabase.h"
 
 #include "DictionaryHelpers.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/storage.h"
 #include "mozilla/dom/ContentParent.h"
+#include "mozilla/dom/DOMStringList.h"
+#include "mozilla/dom/DOMStringListBinding.h"
 #include "mozilla/dom/quota/Client.h"
 #include "mozilla/dom/quota/QuotaManager.h"
-#include "nsDOMLists.h"
 #include "nsJSUtils.h"
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 
 #include "AsyncConnectionHelper.h"
 #include "DatabaseInfo.h"
 #include "IDBEvents.h"
 #include "IDBFactory.h"
@@ -489,40 +490,30 @@ IDBDatabase::WrapObject(JSContext* aCx, 
 uint64_t
 IDBDatabase::Version() const
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
   DatabaseInfo* info = Info();
   return info->version;
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 IDBDatabase::GetObjectStoreNames(ErrorResult& aRv) const
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   DatabaseInfo* info = Info();
 
-  nsAutoTArray<nsString, 10> objectStoreNames;
-  if (!info->GetObjectStoreNames(objectStoreNames)) {
+  nsRefPtr<DOMStringList> list(new DOMStringList());
+  if (!info->GetObjectStoreNames(list->StringArray())) {
     IDB_WARNING("Couldn't get names!");
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
     return nullptr;
   }
 
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
-  uint32_t count = objectStoreNames.Length();
-  for (uint32_t index = 0; index < count; index++) {
-    if (!list->Add(objectStoreNames[index])) {
-      IDB_WARNING("Failed to add element");
-      aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
-      return nullptr;
-    }
-  }
-
   return list.forget();
 }
 
 already_AddRefed<IDBObjectStore>
 IDBDatabase::CreateObjectStore(
                             JSContext* aCx, const nsAString& aName,
                             const IDBObjectStoreParameters& aOptionalParameters,
                             ErrorResult& aRv)
--- a/dom/indexedDB/IDBDatabase.h
+++ b/dom/indexedDB/IDBDatabase.h
@@ -184,17 +184,17 @@ public:
   {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     aName.Assign(mName);
   }
 
   uint64_t
   Version() const;
 
-  already_AddRefed<nsIDOMDOMStringList>
+  already_AddRefed<mozilla::dom::DOMStringList>
   GetObjectStoreNames(ErrorResult& aRv) const;
 
   already_AddRefed<IDBObjectStore>
   CreateObjectStore(JSContext* aCx, const nsAString& aName,
                     const IDBObjectStoreParameters& aOptionalParameters,
                     ErrorResult& aRv);
 
   void
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -19,17 +19,17 @@
 #include "mozilla/dom/StructuredCloneTags.h"
 #include "mozilla/dom/ipc/Blob.h"
 #include "mozilla/dom/quota/FileStreams.h"
 #include "mozilla/Endian.h"
 #include "mozilla/storage.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsDOMFile.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsEventDispatcher.h"
 #include "nsJSUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "snappy/snappy.h"
 
 #include "AsyncConnectionHelper.h"
 #include "IDBCursor.h"
@@ -2632,39 +2632,31 @@ IDBObjectStore::GetKeyPath(JSContext* aC
   if (JSVAL_IS_GCTHING(mCachedKeyPath)) {
     mozilla::HoldJSObjects(this);
     mRooted = true;
   }
 
   return mCachedKeyPath;
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 IDBObjectStore::GetIndexNames(ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
-
-  nsAutoTArray<nsString, 10> names;
+  nsRefPtr<DOMStringList> list(new DOMStringList());
+
+  nsTArray<nsString>& names = list->StringArray();
   uint32_t count = mInfo->indexes.Length();
   names.SetCapacity(count);
 
   for (uint32_t index = 0; index < count; index++) {
     names.InsertElementSorted(mInfo->indexes[index].name);
   }
 
-  for (uint32_t index = 0; index < count; index++) {
-    if (!list->Add(names[index])) {
-      IDB_WARNING("Failed to add element!");
-      aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
-      return nullptr;
-    }
-  }
-
   return list.forget();
 }
 
 already_AddRefed<IDBRequest>
 IDBObjectStore::Get(JSContext* aCx, JS::Handle<JS::Value> aKey,
                     ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
--- a/dom/indexedDB/IDBObjectStore.h
+++ b/dom/indexedDB/IDBObjectStore.h
@@ -280,17 +280,17 @@ public:
   {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     aName.Assign(mName);
   }
 
   JS::Value
   GetKeyPath(JSContext* aCx, ErrorResult& aRv);
 
-  already_AddRefed<nsIDOMDOMStringList>
+  already_AddRefed<DOMStringList>
   GetIndexNames(ErrorResult& aRv);
 
   IDBTransaction*
   Transaction() const
   {
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     return mTransaction;
   }
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -9,17 +9,17 @@
 #include "IDBTransaction.h"
 
 #include "nsIAppShell.h"
 #include "nsIScriptContext.h"
 
 #include "mozilla/dom/quota/QuotaManager.h"
 #include "mozilla/storage.h"
 #include "nsDOMClassInfoID.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsEventDispatcher.h"
 #include "nsPIDOMWindow.h"
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 #include "nsWidgetsCID.h"
 
 #include "AsyncConnectionHelper.h"
 #include "DatabaseInfo.h"
@@ -666,42 +666,28 @@ IDBTransaction::GetError(ErrorResult& aR
   if (IsOpen()) {
     aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
     return nullptr;
   }
 
   return mError;
 }
 
-already_AddRefed<nsIDOMDOMStringList>
+already_AddRefed<DOMStringList>
 IDBTransaction::GetObjectStoreNames(ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
-
-  nsAutoTArray<nsString, 10> stackArray;
-  nsTArray<nsString>* arrayOfNames;
+  nsRefPtr<DOMStringList> list(new DOMStringList());
 
   if (mMode == IDBTransaction::VERSION_CHANGE) {
-    mDatabaseInfo->GetObjectStoreNames(stackArray);
-
-    arrayOfNames = &stackArray;
+    mDatabaseInfo->GetObjectStoreNames(list->StringArray());
   }
   else {
-    arrayOfNames = &mObjectStoreNames;
-  }
-
-  uint32_t count = arrayOfNames->Length();
-  for (uint32_t index = 0; index < count; index++) {
-    if (!list->Add(arrayOfNames->ElementAt(index))) {
-      IDB_WARNING("Failed to add element!");
-      aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
-      return nullptr;
-    }
+    list->StringArray() = mObjectStoreNames;
   }
 
   return list.forget();
 }
 
 already_AddRefed<IDBObjectStore>
 IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv)
 {
--- a/dom/indexedDB/IDBTransaction.h
+++ b/dom/indexedDB/IDBTransaction.h
@@ -249,17 +249,17 @@ public:
     NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
     aRv = AbortInternal(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR, nullptr);
   }
 
   IMPL_EVENT_HANDLER(abort)
   IMPL_EVENT_HANDLER(complete)
   IMPL_EVENT_HANDLER(error)
 
-  already_AddRefed<nsIDOMDOMStringList>
+  already_AddRefed<DOMStringList>
   GetObjectStoreNames(ErrorResult& aRv);
 
 private:
   nsresult
   AbortInternal(nsresult aAbortCode,
                 already_AddRefed<mozilla::dom::DOMError> aError);
 
   // Should only be called directly through IndexedDBDatabaseChild.
--- a/dom/interfaces/base/domstubs.idl
+++ b/dom/interfaces/base/domstubs.idl
@@ -23,17 +23,16 @@ interface nsIDOMDOMImplementation;
 interface nsIDOMDocument;
 interface nsIDOMDocumentFragment;
 interface nsIDOMDocumentType;
 interface nsIDOMElement;
 interface nsIDOMNode;
 interface nsIDOMNodeList;
 interface nsIDOMProcessingInstruction;
 interface nsIDOMText;
-interface nsIDOMDOMStringList;
 interface nsIDOMClientRect;
 interface nsIDOMClientRectList;
 
 // Needed for raises() in our IDL
 interface DOMException;
 
 // Style Sheets
 interface nsIDOMStyleSheetList;
--- a/dom/interfaces/core/moz.build
+++ b/dom/interfaces/core/moz.build
@@ -9,17 +9,16 @@ XPIDL_SOURCES += [
     'nsIDOMCDATASection.idl',
     'nsIDOMCharacterData.idl',
     'nsIDOMComment.idl',
     'nsIDOMDocument.idl',
     'nsIDOMDocumentFragment.idl',
     'nsIDOMDocumentType.idl',
     'nsIDOMDOMException.idl',
     'nsIDOMDOMImplementation.idl',
-    'nsIDOMDOMStringList.idl',
     'nsIDOMElement.idl',
     'nsIDOMMozNamedAttrMap.idl',
     'nsIDOMNode.idl',
     'nsIDOMNodeList.idl',
     'nsIDOMNSEditableElement.idl',
     'nsIDOMProcessingInstruction.idl',
     'nsIDOMText.idl',
     'nsIDOMUserDataHandler.idl',
deleted file mode 100644
--- a/dom/interfaces/core/nsIDOMDOMStringList.idl
+++ /dev/null
@@ -1,18 +0,0 @@
-/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Corresponds to http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407
- */
-
-#include "domstubs.idl"
-
-[scriptable, uuid(0bbae65c-1dde-11d9-8c46-000a95dc234c)]
-interface nsIDOMDOMStringList : nsISupports
-{
-  DOMString          item(in unsigned long index);
-  readonly attribute unsigned long   length;
-  boolean            contains(in DOMString str);
-};
--- a/dom/interfaces/core/nsIDOMDocument.idl
+++ b/dom/interfaces/core/nsIDOMDocument.idl
@@ -27,17 +27,17 @@ interface nsIDOMLocation;
  * 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(aa4b59de-462a-4f61-abd9-4232fef3dacc)]
+[scriptable, uuid(d24d1118-a527-4d5a-9c4e-fb07dfc2fc27)]
 interface nsIDOMDocument : nsIDOMNode
 {
   readonly attribute nsIDOMDocumentType         doctype;
   readonly attribute nsIDOMDOMImplementation    implementation;
   readonly attribute nsIDOMElement              documentElement;
   nsIDOMElement                 createElement([Null(Stringify)] in DOMString tagName)
                                   raises(DOMException);
   nsIDOMDocumentFragment        createDocumentFragment();
@@ -223,17 +223,17 @@ interface nsIDOMDocument : nsIDOMNode
    * this document available to the implementation, in the order they are
    * listed in the styleSheets attribute, adding the title of each style sheet
    * with a title to the list, avoiding duplicates by dropping titles that
    * match (case-sensitively) titles that have already been added to the
    * list.
    *
    * @see <http://dev.w3.org/csswg/cssom/#dom-document-styleSheetSets>
    */
-  readonly attribute nsIDOMDOMStringList styleSheetSets;
+  readonly attribute nsISupports styleSheetSets;
 
   /**
    * Calling this method must change the disabled attribute on each StyleSheet
    * object with a title attribute with a length greater than 0 in the
    * styleSheets attribute, so that all those whose title matches the name
    * argument are enabled, and all others are disabled. Title matches must be
    * case-sensitive. Calling this method with the empty string disables all
    * alternate and preferred style sheets (but does not change the state of
--- a/dom/interfaces/core/nsIDOMXMLDocument.idl
+++ b/dom/interfaces/core/nsIDOMXMLDocument.idl
@@ -1,16 +1,16 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsIDOMDocument.idl"
 
-[scriptable, uuid(90903f50-7611-42c1-a13c-dac4e735bee2)]
+[scriptable, uuid(ebf9f390-7cd2-4456-bc53-4869019370ea)]
 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/events/nsIDOMDataTransfer.idl
+++ b/dom/interfaces/events/nsIDOMDataTransfer.idl
@@ -3,17 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "domstubs.idl"
 
 interface nsIVariant;
 interface nsIDOMFileList;
 
-[scriptable, builtinclass, uuid(4ba241dd-a964-4077-bc30-515a657772e4)]
+[scriptable, builtinclass, uuid(c71180e3-298b-4fbb-9ccb-82c822474741)]
 interface nsIDOMDataTransfer : nsISupports
 {
   /**
    * The actual effect that will be used, and should always be one of the
    * possible values of effectAllowed.
    *
    * For dragstart, drag and dragleave events, the dropEffect is initialized
    * to none. Any value assigned to the dropEffect will be set, but the value
@@ -66,17 +66,17 @@ interface nsIDOMDataTransfer : nsISuppor
    */
   readonly attribute nsIDOMFileList files;
 
   /**
    * Holds a list of the format types of the data that is stored for the first
    * item, in the same order the data was added. An empty list will be
    * returned if no data was added.
    */
-  readonly attribute nsIDOMDOMStringList types;
+  readonly attribute nsISupports types;
 
   /**
    * Remove the data associated with a given format. If format is empty or not
    * specified, the data associated with all formats is removed. If data for
    * the specified format does not exist, or the data transfer contains no
    * data, this method will have no effect.
    */
   void clearData([optional] in DOMString format);
@@ -148,17 +148,17 @@ interface nsIDOMDataTransfer : nsISuppor
    */
   attribute DOMString mozCursor;
 
   /**
    * Holds a list of the format types of the data that is stored for an item
    * at the specified index. If the index is not in the range from 0 to
    * itemCount - 1, an empty string list is returned.
    */
-  nsIDOMDOMStringList mozTypesAt(in unsigned long index);
+  nsISupports mozTypesAt(in unsigned long index);
 
   /**
    * Remove the data associated with the given format for an item at the
    * specified index. The index is in the range from zero to itemCount - 1.
    *
    * If the last format for the item is removed, the entire item is removed,
    * reducing the itemCount by one.
    *
--- a/dom/interfaces/html/nsIDOMHTMLDocument.idl
+++ b/dom/interfaces/html/nsIDOMHTMLDocument.idl
@@ -8,17 +8,17 @@
 /**
  * The nsIDOMHTMLDocument interface is the interface to a [X]HTML
  * document object.
  *
  * @see <http://www.whatwg.org/html/>
  */
 interface nsISelection;
 
-[scriptable, uuid(7147c7ea-393e-454f-8de8-e356861bd9a7)]
+[scriptable, uuid(b73be9dd-bcc8-44df-8b01-3389e277427f)]
 interface nsIDOMHTMLDocument : nsIDOMDocument
 {
            attribute DOMString            domain;
            attribute DOMString            cookie;
 
   readonly attribute nsIDOMHTMLHeadElement head;
            attribute nsIDOMHTMLElement    body;
 
--- a/dom/interfaces/offline/nsIDOMOfflineResourceList.idl
+++ b/dom/interfaces/offline/nsIDOMOfflineResourceList.idl
@@ -1,24 +1,22 @@
 /* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "domstubs.idl"
 
-interface nsIDOMDOMStringList;
-
-[scriptable, uuid(c105fe6f-5603-40b2-b3d0-84cb51fab9f4)]
+[scriptable, uuid(6044702d-e4a9-420c-b711-558b7d6a3b9f)]
 interface nsIDOMOfflineResourceList : nsISupports
 {
   /**
    * Get the list of dynamically-managed entries.
    */
-  readonly attribute nsIDOMDOMStringList mozItems;
+  readonly attribute nsISupports mozItems;
 
   /**
    * Check that an entry exists in the list of dynamically-managed entries.
    *
    * @param uri
    *        The resource to check.
    */
   boolean mozHasItem(in DOMString uri);
--- a/dom/interfaces/xul/nsIDOMXULDocument.idl
+++ b/dom/interfaces/xul/nsIDOMXULDocument.idl
@@ -5,17 +5,17 @@
 
 #include "domstubs.idl"
 #include "nsIDOMDocument.idl"
 
 interface nsIDOMXULCommandDispatcher;
 interface nsIObserver;
 interface nsIBoxObject;
 
-[scriptable, uuid(e057a0ef-4be3-4d60-b45a-6cb9d35d8563)]
+[scriptable, uuid(efdb94fb-642f-4a79-ae20-9a5f7cb7f736)]
 interface nsIDOMXULDocument : nsIDOMDocument
 {
   attribute nsIDOMNode                          popupNode;
 
   /**
    * These attributes correspond to trustedGetPopupNode().rangeOffset and
    * rangeParent. They will help you find where in the DOM the popup is
    * happening. Can be accessed from chrome only, and only during a popup
--- a/dom/src/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/src/offline/nsDOMOfflineResourceList.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMOfflineResourceList.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsError.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsIPrefetchService.h"
 #include "nsCPrefetchService.h"
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
 #include "nsICacheSession.h"
 #include "nsICacheService.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsAutoPtr.h"
@@ -176,51 +176,61 @@ nsDOMOfflineResourceList::Disconnect()
     mListenerManager = nullptr;
   }
 }
 
 //
 // nsDOMOfflineResourceList::nsIDOMOfflineResourceList
 //
 
-NS_IMETHODIMP
-nsDOMOfflineResourceList::GetMozItems(nsIDOMDOMStringList **aItems)
+already_AddRefed<DOMStringList>
+nsDOMOfflineResourceList::GetMozItems(ErrorResult& aRv)
 {
-  if (IS_CHILD_PROCESS()) 
-    return NS_ERROR_NOT_IMPLEMENTED;
+  if (IS_CHILD_PROCESS()) {
+    aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
+    return nullptr;
+  }
 
-  *aItems = nullptr;
-
-  nsRefPtr<nsDOMStringList> items = new nsDOMStringList();
+  nsRefPtr<DOMStringList> items = new DOMStringList();
 
   // If we are not associated with an application cache, return an
   // empty list.
   nsCOMPtr<nsIApplicationCache> appCache = GetDocumentAppCache();
   if (!appCache) {
-    NS_ADDREF(*aItems = items);
-    return NS_OK;
+    return items.forget();
   }
 
-  nsresult rv = Init();
-  NS_ENSURE_SUCCESS(rv, rv);
+  aRv = Init();
+  if (aRv.Failed()) {
+    return nullptr;
+  }
 
   uint32_t length;
   char **keys;
-  rv = appCache->GatherEntries(nsIApplicationCache::ITEM_DYNAMIC,
-                               &length, &keys);
-  NS_ENSURE_SUCCESS(rv, rv);
+  aRv = appCache->GatherEntries(nsIApplicationCache::ITEM_DYNAMIC,
+                                &length, &keys);
+  if (aRv.Failed()) {
+    return nullptr;
+  }
 
   for (uint32_t i = 0; i < length; i++) {
     items->Add(NS_ConvertUTF8toUTF16(keys[i]));
   }
 
   NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(length, keys);
 
-  NS_ADDREF(*aItems = items);
-  return NS_OK;
+  return items.forget();
+}
+
+NS_IMETHODIMP
+nsDOMOfflineResourceList::GetMozItems(nsISupports** aItems)
+{
+  ErrorResult rv;
+  *aItems = GetMozItems(rv).get();
+  return rv.ErrorCode();
 }
 
 NS_IMETHODIMP
 nsDOMOfflineResourceList::MozHasItem(const nsAString& aURI, bool* aExists)
 {
   if (IS_CHILD_PROCESS()) 
     return NS_ERROR_NOT_IMPLEMENTED;
 
--- a/dom/src/offline/nsDOMOfflineResourceList.h
+++ b/dom/src/offline/nsDOMOfflineResourceList.h
@@ -21,20 +21,25 @@
 #include "nsIDOMEventListener.h"
 #include "nsDOMEvent.h"
 #include "nsIObserver.h"
 #include "nsIScriptContext.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsPIDOMWindow.h"
 #include "nsDOMEventTargetHelper.h"
 #include "mozilla/ErrorResult.h"
-#include "nsIDOMDOMStringList.h"
 
 class nsIDOMWindow;
 
+namespace mozilla {
+namespace dom {
+class DOMStringList;
+} // namespace dom
+} // namespace mozilla
+
 class nsDOMOfflineResourceList : public nsDOMEventTargetHelper,
                                  public nsIDOMOfflineResourceList,
                                  public nsIObserver,
                                  public nsIOfflineCacheUpdateObserver,
                                  public nsSupportsWeakReference
 {
   typedef mozilla::ErrorResult ErrorResult;
 
@@ -83,22 +88,17 @@ public:
   IMPL_EVENT_HANDLER(error)
   IMPL_EVENT_HANDLER(noupdate)
   IMPL_EVENT_HANDLER(downloading)
   IMPL_EVENT_HANDLER(progress)
   IMPL_EVENT_HANDLER(cached)
   IMPL_EVENT_HANDLER(updateready)
   IMPL_EVENT_HANDLER(obsolete)
 
-  already_AddRefed<nsIDOMDOMStringList> GetMozItems(ErrorResult& aRv)
-  {
-    nsCOMPtr<nsIDOMDOMStringList> items;
-    aRv = GetMozItems(getter_AddRefs(items));
-    return items.forget();
-  }
+  already_AddRefed<mozilla::dom::DOMStringList> GetMozItems(ErrorResult& aRv);
   bool MozHasItem(const nsAString& aURI, ErrorResult& aRv)
   {
     bool hasItem = false;
     aRv = MozHasItem(aURI, &hasItem);
     return hasItem;
   }
   uint32_t GetMozLength(ErrorResult& aRv)
   {
--- a/dom/system/nsDeviceSensors.cpp
+++ b/dom/system/nsDeviceSensors.cpp
@@ -387,17 +387,17 @@ nsDeviceSensors::FireDOMMotionEvent(nsID
              mLastAccelerationIncluduingGravity.empty() ||
              mLastRotationRate.empty()) {
     return;
   }
 
   nsCOMPtr<nsIDOMEvent> event;
   domdoc->CreateEvent(NS_LITERAL_STRING("DeviceMotionEvent"), getter_AddRefs(event));
 
-  nsDOMDeviceMotionEvent* me = static_cast<nsDOMDeviceMotionEvent*>(event.get());
+  DeviceMotionEvent* me = static_cast<DeviceMotionEvent*>(event.get());
 
   ErrorResult rv;
   me->InitDeviceMotionEvent(NS_LITERAL_STRING("devicemotion"),
                             true,
                             false,
                             mLastAcceleration.ref(),
                             mLastAccelerationIncluduingGravity.ref(),
                             mLastRotationRate.ref(),
--- a/dom/system/nsDeviceSensors.h
+++ b/dom/system/nsDeviceSensors.h
@@ -6,17 +6,17 @@
 #define nsDeviceSensors_h
 
 #include "nsIDeviceSensors.h"
 #include "nsCOMArray.h"
 #include "nsTArray.h"
 #include "nsCOMPtr.h"
 #include "nsITimer.h"
 #include "nsIDOMDeviceOrientationEvent.h"
-#include "nsDOMDeviceMotionEvent.h"
+#include "mozilla/dom/DeviceMotionEvent.h"
 #include "mozilla/TimeStamp.h"
 #include "mozilla/HalSensor.h"
 #include "nsDataHashtable.h"
 
 class nsIDOMWindow;
 
 namespace mozilla {
 namespace dom {
--- a/dom/webidl/AnalyserNode.webidl
+++ b/dom/webidl/AnalyserNode.webidl
@@ -7,21 +7,22 @@
  * https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
 interface AnalyserNode : AudioNode {
 
-    // Real-time frequency-domain data 
+    // Real-time frequency-domain data
     void getFloatFrequencyData(Float32Array array);
     void getByteFrequencyData(Uint8Array array);
 
-    // Real-time waveform data 
+    // Real-time waveform data
+    void getFloatTimeDomainData(Float32Array array);
     void getByteTimeDomainData(Uint8Array array);
 
     [SetterThrows, Pure]
     attribute unsigned long fftSize;
     [Pure]
     readonly attribute unsigned long frequencyBinCount;
 
     [SetterThrows, Pure]
--- a/dom/webidl/HTMLPropertiesCollection.webidl
+++ b/dom/webidl/HTMLPropertiesCollection.webidl
@@ -5,18 +5,16 @@
  *
  * The origin of this IDL file is
  * http://www.whatwg.org/specs/web-apps/current-work/
  *
  * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
  * liability, trademark and document use rules apply.
  */
 
-interface DOMStringList;
-
 interface HTMLPropertiesCollection : HTMLCollection {
   // inherits length and item()
   getter PropertyNodeList? namedItem(DOMString name); // overrides inherited namedItem()
   readonly attribute DOMStringList names;
 };
 
 typedef sequence<any> PropertyValueArray;
 
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -80,16 +80,17 @@ WEBIDL_FILES = [
     'DOMException.webidl',
     'DOMImplementation.webidl',
     'DOMMMIError.webidl',
     'DOMParser.webidl',
     'DOMRect.webidl',
     'DOMRectList.webidl',
     'DOMRequest.webidl',
     'DOMSettableTokenList.webidl',
+    'DOMStringList.webidl',
     'DOMStringMap.webidl',
     'DOMTokenList.webidl',
     'DOMTransaction.webidl',
     'Downloads.webidl',
     'DragEvent.webidl',
     'DummyBinding.webidl',
     'DynamicsCompressorNode.webidl',
     'Element.webidl',
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -38,26 +38,26 @@
 #include "mozilla/Likely.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/ErrorEvent.h"
 #include "mozilla/dom/ErrorEventBinding.h"
 #include "mozilla/dom/Exceptions.h"
 #include "mozilla/dom/FunctionBinding.h"
 #include "mozilla/dom/ImageData.h"
 #include "mozilla/dom/ImageDataBinding.h"
+#include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/MessagePortList.h"
 #include "mozilla/dom/WorkerBinding.h"
 #include "mozilla/Preferences.h"
 #include "nsAlgorithm.h"
 #include "nsContentUtils.h"
 #include "nsCxPusher.h"
 #include "nsError.h"
 #include "nsEventDispatcher.h"
-#include "nsDOMMessageEvent.h"
 #include "nsDOMJSUtils.h"
 #include "nsHostObjectProtocolHandler.h"
 #include "nsJSEnvironment.h"
 #include "nsJSUtils.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
 #include "nsProxyRelease.h"
 #include "nsSandboxFlags.h"
@@ -976,18 +976,17 @@ public:
 
     JS::Rooted<JS::Value> messageData(aCx);
     if (!mBuffer.read(aCx, &messageData,
                       workers::WorkerStructuredCloneCallbacks(aIsMainThread))) {
       xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR);
       return false;
     }
 
-    nsRefPtr<nsDOMMessageEvent> event =
-      new nsDOMMessageEvent(aTarget, nullptr, nullptr);
+    nsRefPtr<MessageEvent> event = new MessageEvent(aTarget, nullptr, nullptr);
     nsresult rv =
       event->InitMessageEvent(NS_LITERAL_STRING("message"),
                               false /* non-bubbling */,
                               true /* cancelable */,
                               messageData,
                               EmptyString(),
                               EmptyString(),
                               nullptr);
@@ -2788,19 +2787,17 @@ WorkerPrivateParent<Derived>::DispatchMe
 
   JS::Rooted<JS::Value> data(cx);
   if (!buffer.read(cx, &data, WorkerStructuredCloneCallbacks(true))) {
     return false;
   }
 
   buffer.clear();
 
-  nsRefPtr<nsDOMMessageEvent> event =
-    new nsDOMMessageEvent(port, nullptr, nullptr);
-
+  nsRefPtr<MessageEvent> event = new MessageEvent(port, nullptr, nullptr);
   nsresult rv =
     event->InitMessageEvent(NS_LITERAL_STRING("message"), false, false, data,
                             EmptyString(), EmptyString(), nullptr);
   if (NS_FAILED(rv)) {
     xpc::Throw(cx, rv);
     return false;
   }
 
@@ -5733,19 +5730,19 @@ WorkerPrivate::ConnectMessagePort(JSCont
 
   RootedDictionary<MessageEventInit> init(aCx);
   init.mBubbles = false;
   init.mCancelable = false;
   init.mSource.SetValue().SetAsMessagePort() = port;
 
   ErrorResult rv;
 
-  nsRefPtr<nsDOMMessageEvent> event =
-    nsDOMMessageEvent::Constructor(globalObject, aCx,
-                                   NS_LITERAL_STRING("connect"), init, rv);
+  nsRefPtr<MessageEvent> event =
+    MessageEvent::Constructor(globalObject, aCx,
+                              NS_LITERAL_STRING("connect"), init, rv);
 
   event->SetTrusted(true);
 
   nsTArray<nsRefPtr<MessagePortBase>> ports;
   ports.AppendElement(port);
 
   nsRefPtr<MessagePortList> portList =
     new MessagePortList(static_cast<nsIDOMEventTarget*>(globalScope), ports);
--- a/dom/xslt/base/txDouble.cpp
+++ b/dom/xslt/base/txDouble.cpp
@@ -100,17 +100,17 @@ public:
         }
     }
 
     double
     getDouble()
     {
         if (mState == eIllegal || mBuffer.IsEmpty() ||
             (mBuffer.Length() == 1 && mBuffer[0] == '.')) {
-            return mozilla::UnspecifiedNaN();
+            return mozilla::UnspecifiedNaN<double>();
         }
         return mSign*PR_strtod(mBuffer.get(), 0);
     }
 private:
     nsAutoCString mBuffer;
     enum {
         eWhitestart,
         eDecimal,
--- a/dom/xslt/xpath/txNumberExpr.cpp
+++ b/dom/xslt/xpath/txNumberExpr.cpp
@@ -35,33 +35,33 @@ txNumberExpr::evaluate(txIEvalContext* a
             result = leftDbl - rightDbl;
             break;
 
         case DIVIDE:
             if (rightDbl == 0) {
 #if defined(XP_WIN)
                 /* XXX MSVC miscompiles such that (NaN == 0) */
                 if (mozilla::IsNaN(rightDbl))
-                    result = mozilla::UnspecifiedNaN();
+                    result = mozilla::UnspecifiedNaN<double>();
                 else
 #endif
                 if (leftDbl == 0 || mozilla::IsNaN(leftDbl))
-                    result = mozilla::UnspecifiedNaN();
+                    result = mozilla::UnspecifiedNaN<double>();
                 else if (mozilla::IsNegative(leftDbl) != mozilla::IsNegative(rightDbl))
-                    result = mozilla::NegativeInfinity();
+                    result = mozilla::NegativeInfinity<double>();
                 else
-                    result = mozilla::PositiveInfinity();
+                    result = mozilla::PositiveInfinity<double>();
             }
             else
                 result = leftDbl / rightDbl;
             break;
 
         case MODULUS:
             if (rightDbl == 0) {
-                result = mozilla::UnspecifiedNaN();
+                result = mozilla::UnspecifiedNaN<double>();
             }
             else {
 #if defined(XP_WIN)
                 /* Workaround MS fmod bug where 42 % (1/0) => NaN, not 42. */
                 if (!mozilla::IsInfinite(leftDbl) && mozilla::IsInfinite(rightDbl))
                     result = leftDbl;
                 else
 #endif
--- a/dom/xslt/xpath/txUnionNodeTest.cpp
+++ b/dom/xslt/xpath/txUnionNodeTest.cpp
@@ -23,17 +23,17 @@ txUnionNodeTest::matches(const txXPathNo
 
     return false;
 }
 
 double
 txUnionNodeTest::getDefaultPriority()
 {
     NS_ERROR("Don't call getDefaultPriority on txUnionPattern");
-    return mozilla::UnspecifiedNaN();
+    return mozilla::UnspecifiedNaN<double>();
 }
 
 bool
 txUnionNodeTest::isSensitiveTo(Expr::ContextSensitivity aContext)
 {
     uint32_t i, len = mNodeTests.Length();
     for (i = 0; i < len; ++i) {
         if (mNodeTests[i]->isSensitiveTo(aContext)) {
--- a/dom/xslt/xslt/txEXSLTFunctions.cpp
+++ b/dom/xslt/xslt/txEXSLTFunctions.cpp
@@ -562,30 +562,30 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
         {
             nsRefPtr<txNodeSet> nodes;
             rv = evaluateToNodeSet(mParams[0], aContext,
                                    getter_AddRefs(nodes));
             NS_ENSURE_SUCCESS(rv, rv);
 
             if (nodes->isEmpty()) {
                 return aContext->recycler()->
-                    getNumberResult(UnspecifiedNaN(), aResult);
+                    getNumberResult(UnspecifiedNaN<double>(), aResult);
             }
 
             bool findMax = mType == MAX;
 
-            double res = findMax ? mozilla::NegativeInfinity() :
-                                   mozilla::PositiveInfinity();
+            double res = findMax ? mozilla::NegativeInfinity<double>() :
+                                   mozilla::PositiveInfinity<double>();
             int32_t i, len = nodes->size();
             for (i = 0; i < len; ++i) {
                 nsAutoString str;
                 txXPathNodeUtils::appendNodeValue(nodes->get(i), str);
                 double val = txDouble::toDouble(str);
                 if (mozilla::IsNaN(val)) {
-                    res = UnspecifiedNaN();
+                    res = UnspecifiedNaN<double>();
                     break;
                 }
 
                 if (findMax ? (val > res) : (val < res)) {
                     res = val;
                 }
             }
 
@@ -605,18 +605,18 @@ txEXSLTFunctionCall::evaluate(txIEvalCon
                 return NS_OK;
             }
 
             nsRefPtr<txNodeSet> resultSet;
             rv = aContext->recycler()->getNodeSet(getter_AddRefs(resultSet));
             NS_ENSURE_SUCCESS(rv, rv);
 
             bool findMax = mType == HIGHEST;
-            double res = findMax ? mozilla::NegativeInfinity() :
-                                   mozilla::PositiveInfinity();
+            double res = findMax ? mozilla::NegativeInfinity<double>() :
+                                   mozilla::PositiveInfinity<double>();
             int32_t i, len = nodes->size();
             for (i = 0; i < len; ++i) {
                 nsAutoString str;
                 const txXPathNode& node = nodes->get(i);
                 txXPathNodeUtils::appendNodeValue(node, str);
                 double val = txDouble::toDouble(str);
                 if (mozilla::IsNaN(val)) {
                     resultSet->clear();
--- a/dom/xslt/xslt/txFormatNumberFunctionCall.cpp
+++ b/dom/xslt/xslt/txFormatNumberFunctionCall.cpp
@@ -80,28 +80,28 @@ txFormatNumberFunctionCall::evaluate(txI
         return NS_ERROR_XPATH_INVALID_ARG;
     }
 
     // Special cases
     if (mozilla::IsNaN(value)) {
         return aContext->recycler()->getStringResult(format->mNaN, aResult);
     }
 
-    if (value == mozilla::PositiveInfinity()) {
+    if (value == mozilla::PositiveInfinity<double>()) {
         return aContext->recycler()->getStringResult(format->mInfinity,
                                                      aResult);
     }
 
-    if (value == mozilla::NegativeInfinity()) {
+    if (value == mozilla::NegativeInfinity<double>()) {
         nsAutoString res;
         res.Append(format->mMinusSign);
         res.Append(format->mInfinity);
         return aContext->recycler()->getStringResult(res, aResult);
     }
-    
+
     // Value is a normal finite number
     nsAutoString prefix;
     nsAutoString suffix;
     int minIntegerSize=0;
     int minFractionSize=0;
     int maxFractionSize=0;
     int multiplier=1;
     int groupSize=-1;
@@ -357,17 +357,17 @@ txFormatNumberFunctionCall::evaluate(txI
     }
 
     if (carry) {
         if (i%groupSize == 0) {
             res.Insert(format->mGroupingSeparator, resPos + 1);
         }
         res.Insert((char16_t)(1 + format->mZeroDigit), resPos + 1);
     }
-    
+
     if (!hasFraction && !intDigits && !carry) {
         // If we havn't added any characters we add a '0'
         // This can only happen for formats like '##.##'
         res.Append(format->mZeroDigit);
     }
 
     delete [] buf;
 
--- a/dom/xslt/xslt/txStylesheetCompileHandlers.cpp
+++ b/dom/xslt/xslt/txStylesheetCompileHandlers.cpp
@@ -266,17 +266,17 @@ getPatternAttr(txStylesheetAttr* aAttrib
 static nsresult
 getNumberAttr(txStylesheetAttr* aAttributes,
               int32_t aAttrCount,
               nsIAtom* aName,
               bool aRequired,
               txStylesheetCompilerState& aState,
               double& aNumber)
 {
-    aNumber = UnspecifiedNaN();
+    aNumber = UnspecifiedNaN<double>();
     txStylesheetAttr* attr = nullptr;
     nsresult rv = getStyleAttr(aAttributes, aAttrCount, kNameSpaceID_None,
                                aName, aRequired, &attr);
     if (!attr) {
         return rv;
     }
 
     aNumber = txDouble::toDouble(attr->mValue);
@@ -515,17 +515,17 @@ txFnStartLREStylesheet(int32_t aNamespac
                        txStylesheetCompilerState& aState)
 {
     txStylesheetAttr* attr;
     nsresult rv = getStyleAttr(aAttributes, aAttrCount, kNameSpaceID_XSLT,
                                nsGkAtoms::version, true, &attr);
     NS_ENSURE_SUCCESS(rv, rv);
 
     txExpandedName nullExpr;
-    double prio = UnspecifiedNaN();
+    double prio = UnspecifiedNaN<double>();
 
     nsAutoPtr<txPattern> match(new txRootPattern());
     NS_ENSURE_TRUE(match, NS_ERROR_OUT_OF_MEMORY);
 
     nsAutoPtr<txTemplateItem> templ(new txTemplateItem(match, nullExpr,
                                                        nullExpr, prio));
     NS_ENSURE_TRUE(templ, NS_ERROR_OUT_OF_MEMORY);
 
@@ -1108,17 +1108,17 @@ txFnStartTemplate(int32_t aNamespaceID,
                       aState, name);
     NS_ENSURE_SUCCESS(rv, rv);
 
     txExpandedName mode;
     rv = getQNameAttr(aAttributes, aAttrCount, nsGkAtoms::mode, false,
                       aState, mode);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    double prio = UnspecifiedNaN();
+    double prio = UnspecifiedNaN<double>();
     rv = getNumberAttr(aAttributes, aAttrCount, nsGkAtoms::priority,
                        false, aState, prio);
     NS_ENSURE_SUCCESS(rv, rv);
 
     nsAutoPtr<txPattern> match;
     rv = getPatternAttr(aAttributes, aAttrCount, nsGkAtoms::match,
                         name.isNull(), aState, match);
     NS_ENSURE_SUCCESS(rv, rv);
--- a/dom/xslt/xslt/txXSLTPatterns.cpp
+++ b/dom/xslt/xslt/txXSLTPatterns.cpp
@@ -18,17 +18,17 @@
 /*
  * Returns the default priority of this Pattern.
  * UnionPatterns don't like this.
  * This should be called on the simple patterns.
  */
 double txUnionPattern::getDefaultPriority()
 {
     NS_ERROR("Don't call getDefaultPriority on txUnionPattern");
-    return mozilla::UnspecifiedNaN();
+    return mozilla::UnspecifiedNaN<double>();
 }
 
 /*
  * Determines whether this Pattern matches the given node within
  * the given context
  * This should be called on the simple patterns for xsl:template,
  * but is fine for xsl:key and xsl:number
  */
--- a/editor/libeditor/base/nsEditor.h
+++ b/editor/libeditor/base/nsEditor.h
@@ -67,16 +67,17 @@ class nsRange;
 class nsString;
 class nsTransactionManager;
 
 namespace mozilla {
 class Selection;
 class TextComposition;
 
 namespace dom {
+class DataTransfer;
 class Element;
 class EventTarget;
 }  // namespace dom
 }  // namespace mozilla
 
 namespace mozilla {
 namespace widget {
 struct IMEState;
@@ -803,17 +804,17 @@ public:
   // This method has to be called by nsEditorEventListener::Focus.
   // All actions that have to be done when the editor is focused needs to be
   // added here.
   void OnFocus(nsIDOMEventTarget* aFocusEventTarget);
 
   // Used to insert content from a data transfer into the editable area.
   // This is called for each item in the data transfer, with the index of
   // each item passed as aIndex.
-  virtual nsresult InsertFromDataTransfer(nsIDOMDataTransfer *aDataTransfer,
+  virtual nsresult InsertFromDataTransfer(mozilla::dom::DataTransfer *aDataTransfer,
                                           int32_t aIndex,
                                           nsIDOMDocument *aSourceDoc,
                                           nsIDOMNode *aDestinationNode,
                                           int32_t aDestOffset,
                                           bool aDoDeleteSelection) = 0;
 
   virtual nsresult InsertFromDrop(nsIDOMEvent* aDropEvent) = 0;
 
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -15,17 +15,17 @@
 #include "nsEditorEventListener.h"
 #include "nsEventListenerManager.h"     // for nsEventListenerManager
 #include "nsFocusManager.h"             // for nsFocusManager
 #include "nsGkAtoms.h"                  // for nsGkAtoms, nsGkAtoms::input
 #include "nsIClipboard.h"               // for nsIClipboard, etc
 #include "nsIContent.h"                 // for nsIContent
 #include "nsIController.h"              // for nsIController
 #include "nsID.h"
-#include "nsIDOMDOMStringList.h"        // for nsIDOMDOMStringList
+#include "mozilla/dom/DOMStringList.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "nsIDOMDocument.h"             // for nsIDOMDocument
 #include "nsIDOMDragEvent.h"            // for nsIDOMDragEvent
 #include "nsIDOMElement.h"              // for nsIDOMElement
 #include "nsIDOMEvent.h"                // for nsIDOMEvent
 #include "nsIDOMEventTarget.h"          // for nsIDOMEventTarget
 #include "nsIDOMKeyEvent.h"             // for nsIDOMKeyEvent
 #include "nsIDOMMouseEvent.h"           // for nsIDOMMouseEvent
@@ -54,17 +54,17 @@
 #ifdef HANDLE_NATIVE_TEXT_DIRECTION_SWITCH
 #include "nsContentUtils.h"             // for nsContentUtils, etc
 #include "nsIBidiKeyboard.h"            // for nsIBidiKeyboard
 #endif
 
 class nsPresContext;
 
 using namespace mozilla;
-using mozilla::dom::EventTarget;
+using namespace mozilla::dom;
 
 static nsINativeKeyBindings *sNativeEditorBindings = nullptr;
 
 static nsINativeKeyBindings*
 GetEditorKeyBindings()
 {
   static bool noBindings = false;
   if (!sNativeEditorBindings && !noBindings) {
@@ -800,40 +800,33 @@ nsEditorEventListener::Drop(nsIDOMDragEv
 bool
 nsEditorEventListener::CanDrop(nsIDOMDragEvent* aEvent)
 {
   // if the target doc is read-only, we can't drop
   if (mEditor->IsReadonly() || mEditor->IsDisabled()) {
     return false;
   }
 
-  nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
-  aEvent->GetDataTransfer(getter_AddRefs(dataTransfer));
+  nsCOMPtr<nsIDOMDataTransfer> domDataTransfer;
+  aEvent->GetDataTransfer(getter_AddRefs(domDataTransfer));
+  nsCOMPtr<DataTransfer> dataTransfer = do_QueryInterface(domDataTransfer);
   NS_ENSURE_TRUE(dataTransfer, false);
 
-  nsCOMPtr<nsIDOMDOMStringList> types;
-  dataTransfer->GetTypes(getter_AddRefs(types));
-  NS_ENSURE_TRUE(types, false);
+  nsRefPtr<DOMStringList> types = dataTransfer->Types();
 
   // Plaintext editors only support dropping text. Otherwise, HTML and files
   // can be dropped as well.
-  bool typeSupported;
-  types->Contains(NS_LITERAL_STRING(kTextMime), &typeSupported);
-  if (!typeSupported) {
-    types->Contains(NS_LITERAL_STRING(kMozTextInternal), &typeSupported);
-    if (!typeSupported && !mEditor->IsPlaintextEditor()) {
-      types->Contains(NS_LITERAL_STRING(kHTMLMime), &typeSupported);
-      if (!typeSupported) {
-        types->Contains(NS_LITERAL_STRING(kFileMime), &typeSupported);
-      }
-    }
+  if (!types->Contains(NS_LITERAL_STRING(kTextMime)) &&
+      !types->Contains(NS_LITERAL_STRING(kMozTextInternal)) &&
+      (mEditor->IsPlaintextEditor() ||
+       (!types->Contains(NS_LITERAL_STRING(kHTMLMime)) &&
+        !types->Contains(NS_LITERAL_STRING(kFileMime))))) {
+    return false;
   }
 
-  NS_ENSURE_TRUE(typeSupported, false);
-
   // If there is no source node, this is probably an external drag and the
   // drop is allowed. The later checks rely on checking if the drag target
   // is the same as the drag source.
   nsCOMPtr<nsIDOMNode> sourceNode;
   dataTransfer->GetMozSourceNode(getter_AddRefs(sourceNode));
   if (!sourceNode)
     return true;
 
--- a/editor/libeditor/html/nsHTMLDataTransfer.cpp
+++ b/editor/libeditor/html/nsHTMLDataTransfer.cpp
@@ -29,17 +29,17 @@
 #include "nsError.h"
 #include "nsGkAtoms.h"
 #include "nsHTMLEditUtils.h"
 #include "nsHTMLEditor.h"
 #include "nsIClipboard.h"
 #include "nsIContent.h"
 #include "nsIContentFilter.h"
 #include "nsIDOMComment.h"
-#include "nsIDOMDOMStringList.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMDocumentFragment.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMHTMLAnchorElement.h"
 #include "nsIDOMHTMLEmbedElement.h"
 #include "nsIDOMHTMLFrameElement.h"
 #include "nsIDOMHTMLIFrameElement.h"
@@ -1226,34 +1226,35 @@ GetStringFromDataTransfer(nsIDOMDataTran
                           int32_t aIndex, nsAString& aOutputString)
 {
   nsCOMPtr<nsIVariant> variant;
   aDataTransfer->MozGetDataAt(aType, aIndex, getter_AddRefs(variant));
   if (variant)
     variant->GetAsAString(aOutputString);
 }
 
-nsresult nsHTMLEditor::InsertFromDataTransfer(nsIDOMDataTransfer *aDataTransfer,
+nsresult nsHTMLEditor::InsertFromDataTransfer(DataTransfer *aDataTransfer,
                                               int32_t aIndex,
                                               nsIDOMDocument *aSourceDoc,
                                               nsIDOMNode *aDestinationNode,
                                               int32_t aDestOffset,
                                               bool aDoDeleteSelection)
 {
-  nsCOMPtr<nsIDOMDOMStringList> types;
-  aDataTransfer->MozTypesAt(aIndex, getter_AddRefs(types));
+  ErrorResult rv;
+  nsRefPtr<DOMStringList> types = aDataTransfer->MozTypesAt(aIndex, rv);
+  if (rv.Failed()) {
+    return rv.ErrorCode();
+  }
 
-  bool hasPrivateHTMLFlavor;
-  types->Contains(NS_LITERAL_STRING(kHTMLContext), &hasPrivateHTMLFlavor);
+  bool hasPrivateHTMLFlavor = types->Contains(NS_LITERAL_STRING(kHTMLContext));
 
   bool isText = IsPlaintextEditor();
   bool isSafe = IsSafeToInsertData(aSourceDoc);
 
-  uint32_t length;
-  types->GetLength(&length);
+  uint32_t length = types->Length();
   for (uint32_t t = 0; t < length; t++) {
     nsAutoString type;
     types->Item(t, type);
 
     if (!isText) {
       if (type.EqualsLiteral(kFileMime) ||
           type.EqualsLiteral(kJPEGImageMime) ||
           type.EqualsLiteral(kJPGImageMime) ||
--- a/editor/libeditor/html/nsHTMLEditor.h
+++ b/editor/libeditor/html/nsHTMLEditor.h
@@ -541,17 +541,17 @@ protected:
   NS_IMETHOD PrepareHTMLTransferable(nsITransferable **transferable, bool havePrivFlavor);
   NS_IMETHOD InsertFromTransferable(nsITransferable *transferable, 
                                     nsIDOMDocument *aSourceDoc,
                                     const nsAString & aContextStr,
                                     const nsAString & aInfoStr,
                                     nsIDOMNode *aDestinationNode,
                                     int32_t aDestinationOffset,
                                     bool aDoDeleteSelection);
-  nsresult InsertFromDataTransfer(nsIDOMDataTransfer *aDataTransfer,
+  nsresult InsertFromDataTransfer(mozilla::dom::DataTransfer *aDataTransfer,
                                   int32_t aIndex,
                                   nsIDOMDocument *aSourceDoc,
                                   nsIDOMNode *aDestinationNode,
                                   int32_t aDestOffset,
                                   bool aDoDeleteSelection);
   bool HavePrivateHTMLFlavor( nsIClipboard *clipboard );
   nsresult   ParseCFHTML(nsCString & aCfhtml, char16_t **aStuffToPaste, char16_t **aCfcontext);
   nsresult   DoContentFilterCallback(const nsAString &aFlavor,
--- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp
+++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp
@@ -44,16 +44,17 @@
 #include "nsString.h"
 #include "nsXPCOM.h"
 #include "nscore.h"
 
 class nsILoadContext;
 class nsISupports;
 
 using namespace mozilla;
+using namespace mozilla::dom;
 
 NS_IMETHODIMP nsPlaintextEditor::PrepareTransferable(nsITransferable **transferable)
 {
   // Create generic Transferable for getting the data
   nsresult rv = CallCreateInstance("@mozilla.org/widget/transferable;1", transferable);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Get the nsITransferable interface for getting the data from the clipboard
@@ -132,17 +133,17 @@ NS_IMETHODIMP nsPlaintextEditor::InsertT
   // Try to scroll the selection into view if the paste/drop succeeded
 
   if (NS_SUCCEEDED(rv))
     ScrollSelectionIntoView(false);
 
   return rv;
 }
 
-nsresult nsPlaintextEditor::InsertFromDataTransfer(nsIDOMDataTransfer *aDataTransfer,
+nsresult nsPlaintextEditor::InsertFromDataTransfer(DataTransfer *aDataTransfer,
                                                    int32_t aIndex,
                                                    nsIDOMDocument *aSourceDoc,
                                                    nsIDOMNode *aDestinationNode,
                                                    int32_t aDestOffset,
                                                    bool aDoDeleteSelection)
 {
   nsCOMPtr<nsIVariant> data;
   aDataTransfer->MozGetDataAt(NS_LITERAL_STRING("text/plain"), aIndex,
@@ -161,19 +162,20 @@ nsresult nsPlaintextEditor::InsertFromDa
 
 nsresult nsPlaintextEditor::InsertFromDrop(nsIDOMEvent* aDropEvent)
 {
   ForceCompositionEnd();
 
   nsCOMPtr<nsIDOMDragEvent> dragEvent(do_QueryInterface(aDropEvent));
   NS_ENSURE_TRUE(dragEvent, NS_ERROR_FAILURE);
 
-  nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
-  nsresult rv = dragEvent->GetDataTransfer(getter_AddRefs(dataTransfer));
-  NS_ENSURE_SUCCESS(rv, rv);
+  nsCOMPtr<nsIDOMDataTransfer> domDataTransfer;
+  dragEvent->GetDataTransfer(getter_AddRefs(domDataTransfer));
+  nsCOMPtr<DataTransfer> dataTransfer = do_QueryInterface(domDataTransfer);
+  NS_ENSURE_TRUE(dataTransfer, NS_ERROR_FAILURE);
 
   nsCOMPtr<nsIDragSession> dragSession = nsContentUtils::GetDragSession();
   NS_ASSERTION(dragSession, "No drag session");
 
   nsCOMPtr<nsIDOMNode> sourceNode;
   dataTransfer->GetMozSourceNode(getter_AddRefs(sourceNode));
 
   nsCOMPtr<nsIDOMDocument> srcdomdoc;
@@ -190,17 +192,17 @@ nsresult nsPlaintextEditor::InsertFromDr
       return NS_OK;
   }
 
   // Current doc is destination
   nsCOMPtr<nsIDOMDocument> destdomdoc = GetDOMDocument();
   NS_ENSURE_TRUE(destdomdoc, NS_ERROR_NOT_INITIALIZED);
 
   uint32_t numItems = 0;
-  rv = dataTransfer->GetMozItemCount(&numItems);
+  nsresult rv = dataTransfer->GetMozItemCount(&numItems);
   NS_ENSURE_SUCCESS(rv, rv);
   if (numItems < 1) return NS_ERROR_FAILURE;  // nothing to drop?
 
   // Combine any deletion and drop insertion into one transaction
   nsAutoEditBatch beginBatching(this);
 
   bool deleteSelection = false;
 
--- a/editor/libeditor/text/nsPlaintextEditor.h
+++ b/editor/libeditor/text/nsPlaintextEditor.h
@@ -130,17 +130,17 @@ public:
   /* ------------ Utility Routines, not part of public API -------------- */
   NS_IMETHOD TypedText(const nsAString& aString, ETypingAction aAction);
 
   nsresult InsertTextAt(const nsAString &aStringToInsert,
                         nsIDOMNode *aDestinationNode,
                         int32_t aDestOffset,
                         bool aDoDeleteSelection);
 
-  virtual nsresult InsertFromDataTransfer(nsIDOMDataTransfer *aDataTransfer,
+  virtual nsresult InsertFromDataTransfer(mozilla::dom::DataTransfer *aDataTransfer,
                                           int32_t aIndex,
                                           nsIDOMDocument *aSourceDoc,
                                           nsIDOMNode *aDestinationNode,
                                           int32_t aDestOffset,
                                           bool aDoDeleteSelection);
 
   virtual nsresult InsertFromDrop(nsIDOMEvent* aDropEvent);
 
--- a/gfx/2d/BaseRect.h
+++ b/gfx/2d/BaseRect.h
@@ -1,20 +1,22 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef MOZILLA_GFX_BASERECT_H_
 #define MOZILLA_GFX_BASERECT_H_
 
+#include <algorithm>
 #include <cmath>
-#include <mozilla/Assertions.h>
-#include <mozilla/FloatingPoint.h>
-#include <algorithm>
+
+#include "mozilla/Assertions.h"
+#include "mozilla/FloatingPoint.h"
+#include "mozilla/TypeTraits.h"
 
 namespace mozilla {
 namespace gfx {
 
 /**
  * Rectangles have two interpretations: a set of (zero-size) points,
  * and a rectangular area of the plane. Most rectangle operations behave
  * the same no matter what interpretation is being used, but some operations
@@ -55,20 +57,21 @@ struct BaseRect {
   // Emptiness. An empty rect is one that has no area, i.e. its height or width
   // is <= 0
   bool IsEmpty() const { return height <= 0 || width <= 0; }
   void SetEmpty() { width = height = 0; }
 
   // "Finite" means not inf and not NaN
   bool IsFinite() const
   {
-    return (mozilla::IsFinite(x) &&
-            mozilla::IsFinite(y) &&
-            mozilla::IsFinite(width) &&
-            mozilla::IsFinite(height));
+    typedef typename mozilla::Conditional<mozilla::IsSame<T, float>::value, float, double>::Type FloatType;
+    return (mozilla::IsFinite(FloatType(x)) &&
+            mozilla::IsFinite(FloatType(y)) &&
+            mozilla::IsFinite(FloatType(width)) &&
+            mozilla::IsFinite(FloatType(height)));
   }
 
   // Returns true if this rectangle contains the interior of aRect. Always
   // returns true if aRect is empty, and always returns false is aRect is
   // nonempty but this rect is empty.
   bool Contains(const Sub& aRect) const
   {
     return aRect.IsEmpty() ||
--- a/gfx/2d/DrawTargetCairo.cpp
+++ b/gfx/2d/DrawTargetCairo.cpp
@@ -953,16 +953,18 @@ DrawTargetCairo::MaskSurface(const Patte
 
   cairo_surface_t* surf = GetCairoSurfaceForSourceSurface(aMask);
   cairo_pattern_t* mask = cairo_pattern_create_for_surface(surf);
   cairo_matrix_t matrix;
 
   cairo_matrix_init_translate (&matrix, -aOffset.x, -aOffset.y);
   cairo_pattern_set_matrix (mask, &matrix);
 
+  cairo_set_operator(mContext, GfxOpToCairoOp(aOptions.mCompositionOp));
+
   cairo_mask(mContext, mask);
 
   cairo_surface_destroy(surf);
   cairo_pattern_destroy(mask);
   cairo_pattern_destroy(pat);
 }
 
 void
--- a/gfx/layers/basic/BasicCanvasLayer.cpp
+++ b/gfx/layers/basic/BasicCanvasLayer.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "BasicCanvasLayer.h"
 #include "basic/BasicLayers.h"          // for BasicLayerManager
+#include "basic/BasicLayersImpl.h"      // for GetEffectiveOperator
 #include "mozilla/mozalloc.h"           // for operator new
 #include "nsAutoPtr.h"                  // for nsRefPtr
 #include "nsCOMPtr.h"                   // for already_AddRefed
 #include "nsISupportsImpl.h"            // for Layer::AddRef, etc
 #include "gfx2DGlue.h"
 
 class gfxContext;
 
@@ -24,21 +25,20 @@ BasicCanvasLayer::Paint(DrawTarget* aTar
 {
   if (IsHidden())
     return;
 
   FirePreTransactionCallback();
   UpdateTarget();
   FireDidTransactionCallback();
 
-  CompositionOp mixBlendMode = GetEffectiveMixBlendMode();
   PaintWithOpacity(aTarget,
                    GetEffectiveOpacity(),
                    aMaskSurface,
-                   mixBlendMode != CompositionOp::OP_OVER ? mixBlendMode : GetOperator());
+                   GetEffectiveOperator(this));
 }
 
 void
 BasicCanvasLayer::DeprecatedPaint(gfxContext* aContext, Layer* aMaskLayer)
 {
   if (IsHidden())
     return;
 
--- a/gfx/layers/basic/BasicColorLayer.cpp
+++ b/gfx/layers/basic/BasicColorLayer.cpp
@@ -43,19 +43,18 @@ public:
     ColorLayer::SetVisibleRegion(aRegion);
   }
 
   virtual void Paint(DrawTarget* aTarget, SourceSurface* aMaskSurface)
   {
     if (IsHidden()) {
       return;
     }
-    CompositionOp mixBlendMode = GetEffectiveMixBlendMode();
-    CompositionOp op =
-      mixBlendMode != CompositionOp::OP_OVER ? mixBlendMode : GetOperator();
+
+    CompositionOp op = GetEffectiveOperator(this);
 
     DrawOptions opts = DrawOptions();
     opts.mCompositionOp = op;
     ColorPattern pattern(ToColor(mColor));
     aTarget->MaskSurface(pattern,
                          aMaskSurface,
                          ToIntRect(GetBounds()).TopLeft(),
                          opts);
--- a/gfx/layers/basic/BasicImageLayer.cpp
+++ b/gfx/layers/basic/BasicImageLayer.cpp
@@ -124,19 +124,17 @@ BasicImageLayer::GetAndPaintCurrentImage
   if (!surf) {
     return;
   }
 
   if (aTarget) {
     // The visible region can extend outside the image, so just draw
     // within the image bounds.
     SurfacePattern pat(surf, ExtendMode::CLAMP, Matrix(), ToFilter(mFilter));
-    CompositionOp mixBlendMode = GetEffectiveMixBlendMode();
-    CompositionOp op =
-    mixBlendMode != CompositionOp::OP_OVER ? mixBlendMode : GetOperator();
+    CompositionOp op = GetEffectiveOperator(this);
     DrawOptions opts(aOpacity, op);
 
     aTarget->MaskSurface(pat, aMaskSurface, Point(0, 0), opts);
 
     GetContainer()->NotifyPaintedImage(image);
   }
 
   mContainer->UnlockCurrentImage();
@@ -166,19 +164,17 @@ BasicImageLayer::DeprecatedGetAndPaintCu
     return nullptr;
   }
 
   pat->SetFilter(mFilter);
 
   // The visible region can extend outside the image, so just draw
   // within the image bounds.
   if (aContext) {
-    CompositionOp mixBlendMode = GetEffectiveMixBlendMode();
-    CompositionOp op =
-      mixBlendMode != CompositionOp::OP_OVER ? mixBlendMode : GetOperator();
+    CompositionOp op = GetEffectiveOperator(this);
     AutoSetOperator setOptimizedOperator(aContext, ThebesOp(op));
 
     DeprecatedPaintContext(pat,
                  nsIntRegion(nsIntRect(0, 0, size.width, size.height)),
                  aOpacity, aContext, aMaskLayer);
 
     GetContainer()->NotifyPaintedImage(image);
   }
--- a/gfx/layers/basic/BasicLayerManager.cpp
+++ b/gfx/layers/basic/BasicLayerManager.cpp
@@ -856,19 +856,20 @@ BasicLayerManager::FlushGroup(PaintLayer
   // intersect any other leaf layers, so if the transaction is not yet marked
   // incomplete, the contents of this container layer are the final contents
   // for the window.
   if (!mTransactionIncomplete) {
     if (aNeedsClipToVisibleRegion) {
       gfxUtils::ClipToRegion(aPaintContext.mTarget,
                              aPaintContext.mLayer->GetEffectiveVisibleRegion());
     }
-    BasicContainerLayer* container = static_cast<BasicContainerLayer*>(aPaintContext.mLayer);
-    AutoSetOperator setOperator(aPaintContext.mTarget,
-                                ThebesOp(container->GetOperator()));
+
+    CompositionOp op = GetEffectiveOperator(aPaintContext.mLayer);
+    AutoSetOperator setOperator(aPaintContext.mTarget, ThebesOp(op));
+
     PaintWithMask(aPaintContext.mTarget, aPaintContext.mLayer->GetEffectiveOpacity(),
                   aPaintContext.mLayer->GetMaskLayer());
   }
 }
 
 void
 BasicLayerManager::PaintLayer(gfxContext* aTarget,
                               Layer* aLayer,
--- a/gfx/layers/basic/BasicLayersImpl.cpp
+++ b/gfx/layers/basic/BasicLayersImpl.cpp
@@ -130,16 +130,28 @@ FillWithMask(gfxContext* aContext, float
 }
 
 BasicImplData*
 ToData(Layer* aLayer)
 {
   return static_cast<BasicImplData*>(aLayer->ImplData());
 }
 
+gfx::CompositionOp
+GetEffectiveOperator(Layer* aLayer)
+{
+  CompositionOp op = aLayer->GetEffectiveMixBlendMode();
+
+  if (op != CompositionOp::OP_OVER) {
+    return op;
+  }
+
+  return ToData(aLayer)->GetOperator();
+}
+
 ShadowableLayer*
 ToShadowable(Layer* aLayer)
 {
   return aLayer->AsShadowableLayer();
 }
 
 bool
 ShouldShadow(Layer* aLayer)
--- a/gfx/layers/basic/BasicLayersImpl.h
+++ b/gfx/layers/basic/BasicLayersImpl.h
@@ -89,12 +89,27 @@ PaintWithMask(gfxContext* aContext, floa
 // Fill the current path with the current source, using a
 // mask and opacity, if present
 void
 FillWithMask(gfxContext* aContext, float aOpacity, Layer* aMaskLayer);
 
 BasicImplData*
 ToData(Layer* aLayer);
 
+/**
+ * Returns the operator to be used when blending and compositing this layer.
+ * Currently there is no way to specify both a blending and a compositing
+ * operator other than normal and source over respectively.
+ *
+ * If the layer has
+ * an effective blend mode operator other than normal, as returned by
+ * GetEffectiveMixBlendMode, this operator is used for blending, and source
+ * over is used for compositing.
+ * If the blend mode for this layer is normal, the compositing operator
+ * returned by GetOperator is used.
+ */
+gfx::CompositionOp
+GetEffectiveOperator(Layer* aLayer);
+
 }
 }
 
 #endif
--- a/gfx/layers/basic/BasicThebesLayer.cpp
+++ b/gfx/layers/basic/BasicThebesLayer.cpp
@@ -57,17 +57,17 @@ BasicThebesLayer::PaintThebes(gfxContext
                "Can only draw in drawing phase");
 
   nsTArray<ReadbackProcessor::Update> readbackUpdates;
   if (aReadback && UsedForReadback()) {
     aReadback->GetThebesLayerUpdates(this, &readbackUpdates);
   }
 
   float opacity = GetEffectiveOpacity();
-  CompositionOp mixBlendMode = GetEffectiveMixBlendMode();
+  CompositionOp effectiveOperator = GetEffectiveOperator(this);
 
   if (!BasicManager()->IsRetained()) {
     NS_ASSERTION(readbackUpdates.IsEmpty(), "Can't do readback for non-retained layer");
 
     mValidRegion.SetEmpty();
     mContentClient->Clear();
 
     nsIntRegion toDraw = IntersectWithClip(GetEffectiveVisibleRegion(), aContext);
@@ -79,41 +79,37 @@ BasicThebesLayer::PaintThebes(gfxContext
         BasicManager()->SetTransactionIncomplete();
         return;
       }
 
       aContext->Save();
 
       bool needsClipToVisibleRegion = GetClipToVisibleRegion();
       bool needsGroup = opacity != 1.0 ||
-                        GetOperator() != CompositionOp::OP_OVER ||
-                        mixBlendMode != CompositionOp::OP_OVER ||
+                        effectiveOperator != CompositionOp::OP_OVER ||
                         aMaskLayer;
       nsRefPtr<gfxContext> groupContext;
       if (needsGroup) {
         groupContext =
           BasicManager()->PushGroupForLayer(aContext, this, toDraw,
                                             &needsClipToVisibleRegion);
-        if (GetOperator() != CompositionOp::OP_OVER ||
-            mixBlendMode != CompositionOp::OP_OVER) {
+        if (effectiveOperator != CompositionOp::OP_OVER) {
           needsClipToVisibleRegion = true;
         }
       } else {
         groupContext = aContext;
       }
       SetAntialiasingFlags(this, groupContext);
       aCallback(this, groupContext, toDraw, DrawRegionClip::CLIP_NONE, nsIntRegion(), aCallbackData);
       if (needsGroup) {
         BasicManager()->PopGroupToSourceWithCachedSurface(aContext, groupContext);
         if (needsClipToVisibleRegion) {
           gfxUtils::ClipToRegion(aContext, toDraw);
         }
-        CompositionOp op =
-          mixBlendMode != CompositionOp::OP_OVER ? mixBlendMode : GetOperator();
-        AutoSetOperator setOptimizedOperator(aContext, ThebesOp(op));
+        AutoSetOperator setOptimizedOperator(aContext, ThebesOp(effectiveOperator));
         PaintWithMask(aContext, opacity, aMaskLayer);
       }
 
       aContext->Restore();
     }
 
     RenderTraceInvalidateEnd(this, "FFFF00");
     return;
--- a/gfx/layers/ipc/AsyncPanZoomController.cpp
+++ b/gfx/layers/ipc/AsyncPanZoomController.cpp
@@ -1971,17 +1971,17 @@ void AsyncPanZoomController::SetContentR
 void AsyncPanZoomController::TimeoutContentResponse() {
   mContentResponseTimeoutTask = nullptr;
   ContentReceivedTouch(false);
 }
 
 void AsyncPanZoomController::UpdateZoomConstraints(const ZoomConstraints& aConstraints) {
   APZC_LOG("%p updating zoom constraints to %d %d %f %f\n", this, aConstraints.mAllowZoom,
     aConstraints.mAllowDoubleTapZoom, aConstraints.mMinZoom.scale, aConstraints.mMaxZoom.scale);
-  if (IsFloatNaN(aConstraints.mMinZoom.scale) || IsFloatNaN(aConstraints.mMaxZoom.scale)) {
+  if (IsNaN(aConstraints.mMinZoom.scale) || IsNaN(aConstraints.mMaxZoom.scale)) {
     NS_WARNING("APZC received zoom constraints with NaN values; dropping...\n");
     return;
   }
   // inf float values and other bad cases should be sanitized by the code below.
   mZoomConstraints.mAllowZoom = aConstraints.mAllowZoom;
   mZoomConstraints.mAllowDoubleTapZoom = aConstraints.mAllowDoubleTapZoom;
   mZoomConstraints.mMinZoom = (MIN_ZOOM > aConstraints.mMinZoom ? MIN_ZOOM : aConstraints.mMinZoom);
   mZoomConstraints.mMaxZoom = (MAX_ZOOM > aConstraints.mMaxZoom ? aConstraints.mMaxZoom : MAX_ZOOM);
--- a/gfx/src/nsThemeConstants.h
+++ b/gfx/src/nsThemeConstants.h
@@ -251,16 +251,19 @@
 #define NS_THEME_WIN_COMMUNICATIONS_TOOLBOX                221
 #define NS_THEME_WIN_MEDIA_TOOLBOX                         222
 #define NS_THEME_WIN_BROWSER_TAB_BAR_TOOLBOX               223
 
 // Unified toolbar and titlebar elements on the Mac
 #define NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR                   224
 #define NS_THEME_MOZ_MAC_FULLSCREEN_BUTTON                 226
 
+// Mac help button
+#define NS_THEME_MOZ_MAC_HELP_BUTTON                       227
+
 // Vista glass
 #define NS_THEME_WIN_BORDERLESS_GLASS                      229
 #define NS_THEME_WIN_GLASS                                 230
 
 // Windows themed window frame elements
 #define NS_THEME_WINDOW_TITLEBAR                           231
 #define NS_THEME_WINDOW_TITLEBAR_MAXIMIZED                 232
 #define NS_THEME_WINDOW_FRAME_LEFT                         233
--- a/js/public/Value.h
+++ b/js/public/Value.h
@@ -854,17 +854,17 @@ static inline JS_VALUE_CONSTEXPR JS::Val
  * Returns a generic quiet NaN value, with all payload bits set to zero.
  *
  * Among other properties, this NaN's bit pattern conforms to JS::Value's
  * bit pattern restrictions.
  */
 static MOZ_ALWAYS_INLINE double
 GenericNaN()
 {
-  return mozilla::SpecificNaN(0, 0x8000000000000ULL);
+  return mozilla::SpecificNaN<double>(0, 0x8000000000000ULL);
 }
 
 static inline double
 CanonicalizeNaN(double d)
 {
     if (MOZ_UNLIKELY(mozilla::IsNaN(d)))
         return GenericNaN();
     return d;
@@ -974,17 +974,17 @@ class Value
         } else {
             setInt32((int32_t)ui);
             return true;
         }
     }
 
     bool setNumber(double d) {
         int32_t i;
-        if (mozilla::DoubleIsInt32(d, &i)) {
+        if (mozilla::NumberIsInt32(d, &i)) {
             setInt32(i);
             return true;
         }
 
         setDouble(d);
         return false;
     }
 
@@ -1627,17 +1627,17 @@ class HeapBase<JS::Value> : public Value
         } else {
             setInt32((int32_t)ui);
             return true;
         }
     }
 
     bool setNumber(double d) {
         int32_t i;
-        if (mozilla::DoubleIsInt32(d, &i)) {
+        if (mozilla::NumberIsInt32(d, &i)) {
             setInt32(i);
             return true;
         }
 
         setDouble(d);
         return false;
     }
 
--- a/js/src/builtin/MapObject.cpp
+++ b/js/src/builtin/MapObject.cpp
@@ -16,17 +16,17 @@
 #include "js/Utility.h"
 #include "vm/GlobalObject.h"
 #include "vm/Interpreter.h"
 
 #include "jsobjinlines.h"
 
 using namespace js;
 
-using mozilla::DoubleEqualsInt32;
+using mozilla::NumberEqualsInt32;
 using mozilla::Forward;
 using mozilla::IsNaN;
 using mozilla::Move;
 using mozilla::ArrayLength;
 using JS::DoubleNaNValue;
 using JS::ForOfIterator;
 
 
@@ -779,17 +779,17 @@ HashableValue::setValue(JSContext *cx, H
         // Atomize so that hash() and operator==() are fast and infallible.
         JSString *str = AtomizeString(cx, v.toString(), DoNotInternAtom);
         if (!str)
             return false;
         value = StringValue(str);
     } else if (v.isDouble()) {
         double d = v.toDouble();
         int32_t i;
-        if (DoubleEqualsInt32(d, &i)) {
+        if (NumberEqualsInt32(d, &i)) {
             // Normalize int32_t-valued doubles to int32_t for faster hashing and testing.
             value = Int32Value(i);
         } else if (IsNaN(d)) {
             // NaNs with different bits must hash and test identically.
             value = DoubleNaNValue();
         } else {
             value = v;
         }
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -39,17 +39,17 @@
 #include "frontend/ParseNode-inl.h"
 #include "vm/ScopeObject-inl.h"
 
 using namespace js;
 using namespace js::gc;
 using namespace js::frontend;
 
 using mozilla::DebugOnly;
-using mozilla::DoubleIsInt32;
+using mozilla::NumberIsInt32;
 using mozilla::PodCopy;
 
 static bool
 SetSrcNoteOffset(ExclusiveContext *cx, BytecodeEmitter *bce, unsigned index, unsigned which, ptrdiff_t offset);
 
 struct frontend::StmtInfoBCE : public StmtInfoBase
 {
     StmtInfoBCE     *down;          /* info for enclosing statement */
@@ -2378,17 +2378,17 @@ EmitElemIncDec(ExclusiveContext *cx, Par
 static bool
 EmitNumberOp(ExclusiveContext *cx, double dval, BytecodeEmitter *bce)
 {
     int32_t ival;
     uint32_t u;
     ptrdiff_t off;
     jsbytecode *pc;
 
-    if (DoubleIsInt32(dval, &ival)) {
+    if (NumberIsInt32(dval, &ival)) {
         if (ival == 0)
             return Emit1(cx, bce, JSOP_ZERO) >= 0;
         if (ival == 1)
             return Emit1(cx, bce, JSOP_ONE) >= 0;
         if ((int)(int8_t)ival == ival)
             return Emit2(cx, bce, JSOP_INT8, (jsbytecode)(int8_t)ival) >= 0;
 
         u = (uint32_t)ival;
@@ -2558,17 +2558,17 @@ EmitSwitch(ExclusiveContext *cx, Bytecod
             pn4 = pn3->pn_left;
 
             if (pn4->getKind() != PNK_NUMBER) {
                 switchOp = JSOP_CONDSWITCH;
                 continue;
             }
 
             int32_t i;
-            if (!DoubleIsInt32(pn4->pn_dval, &i)) {
+            if (!NumberIsInt32(pn4->pn_dval, &i)) {
                 switchOp = JSOP_CONDSWITCH;
                 continue;
             }
 
             if ((unsigned)(i + (int)JS_BIT(15)) >= (unsigned)JS_BIT(16)) {
                 switchOp = JSOP_CONDSWITCH;
                 continue;
             }
@@ -5870,17 +5870,17 @@ EmitObject(ExclusiveContext *cx, Bytecod
 
     /*
      * Try to construct the shape of the object as we go, so we can emit a
      * JSOP_NEWOBJECT with the final shape instead.
      */
     RootedObject obj(cx);
     if (bce->script->compileAndGo()) {
         gc::AllocKind kind = GuessObjectGCKind(pn->pn_count);
-        obj = NewBuiltinClassInstance(cx, &JSObject::class_, kind);
+        obj = NewBuiltinClassInstance(cx, &JSObject::class_, kind, TenuredObject);
         if (!obj)
             return false;
     }
 
     for (ParseNode *pn2 = pn->pn_head; pn2; pn2 = pn2->pn_next) {
         /* Emit an index for t[2] for later consumption by JSOP_INITELEM. */
         ParseNode *pn3 = pn2->pn_left;
         bool isIndex = false;
--- a/js/src/frontend/FoldConstants.cpp
+++ b/js/src/frontend/FoldConstants.cpp
@@ -154,19 +154,19 @@ FoldBinaryNumeric(ExclusiveContext *cx, 
             /* XXX MSVC miscompiles such that (NaN == 0) */
             if (IsNaN(d2))
                 d = GenericNaN();
             else
 #endif
             if (d == 0 || IsNaN(d))
                 d = GenericNaN();
             else if (IsNegative(d) != IsNegative(d2))
-                d = NegativeInfinity();
+                d = NegativeInfinity<double>();
             else
-                d = PositiveInfinity();
+                d = PositiveInfinity<double>();
         } else {
             d /= d2;
         }
         break;
 
       case JSOP_MOD:
         if (d2 == 0) {
             d = GenericNaN();
--- a/js/src/jit-test/tests/asm.js/testFloat32.js
+++ b/js/src/jit-test/tests/asm.js/testFloat32.js
@@ -127,32 +127,39 @@ assertEq(asmLink(asmCompile('glob', USE_
 assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var sqrt = glob.Math.sqrt; function f() {var x = toF(1.5); return +sqrt(x);} return f");
 assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var sqrt = glob.Math.sqrt; function f() {var x = toF(1.5); return sqrt(x) | 0;} return f");
 assertEq(asmLink(asmCompile('glob', USE_ASM + TO_FLOAT32 + "var sqrt = glob.Math.sqrt; function f() {var x = toF(2.25); return toF(sqrt(x))} return f"), this)(), Math.fround(1.5));
 assertEq(asmLink(asmCompile('glob', USE_ASM + TO_FLOAT32 + "var sqrt = glob.Math.sqrt; function f() {var x = toF(-1.); return toF(sqrt(x))} return f"), this)(), NaN);
 assertEq(asmLink(asmCompile('glob', USE_ASM + TO_FLOAT32 + "var sqrt = glob.Math.sqrt; var inf = glob.Infinity; function f() {var x = toF(0.); x = toF(inf); return toF(sqrt(x))} return f"), this)(), Infinity);
 
 // float?s
 assertEq(asmLink(asmCompile('glob', 'ffi', 'heap', USE_ASM + HEAP32 + TO_FLOAT32 + "var sqrt = glob.Math.sqrt; function f(x) { x = toF(x); f32[0] = x; return toF(sqrt(f32[0])) } return f"), this, null, heap)(64), Math.fround(8));
-assertEq(asmLink(asmCompile('glob', 'ffi', 'heap', USE_ASM + HEAP32 + TO_FLOAT32 + "var cos = glob.Math.cos; function f(x) { x = toF(x); f32[0] = x; return toF(cos(f32[0])) } return f"), this, null, heap)(3.141592653), -1);
+
+// The only other Math functions that can receive float32 as arguments and that strictly commute are floor and ceil (see
+// also bug 969203).
+var floorModule = asmLink(asmCompile('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.floor; function f(x) {x = toF(x); return toF(g(x))} return f"), this);
+for (v of [-10.5, -1.2345, -1, 0, 1, 3.141592653, 13.37, Math.Infinity, NaN])
+    assertEq(floorModule(v), Math.fround(Math.floor(Math.fround(v))));
+assertEq(asmLink(asmCompile('glob', 'ffi', 'heap', USE_ASM + HEAP32 + TO_FLOAT32 + "var floor = glob.Math.floor; function f(x) { x = toF(x); f32[0] = x; return toF(floor(f32[0])) } return f"), this, null, heap)(13.37), 13);
 
-// All Math functions with arity 1 behave like cos and sin
-var cosModule = asmLink(asmCompile('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.cos; function f(x) {x = toF(x); return toF(g(x))} return f"), this);
-for (v of [0, 3.141592653, Math.Infinity, NaN])
-    assertEq(cosModule(v), Math.fround(Math.cos(Math.fround(v))));
+var ceilModule = asmLink(asmCompile('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.ceil; function f(x) {x = toF(x); return toF(g(x))} return f"), this);
+for (v of [-10.5, -1.2345, -1, 0, 1, 3.141592653, 13.37, Math.Infinity, NaN])
+    assertEq(ceilModule(v), Math.fround(Math.ceil(Math.fround(v))));
+assertEq(asmLink(asmCompile('glob', 'ffi', 'heap', USE_ASM + HEAP32 + TO_FLOAT32 + "var ceil = glob.Math.ceil; function f(x) { x = toF(x); f32[0] = x; return toF(ceil(f32[0])) } return f"), this, null, heap)(13.37), 14);
 
-var sinModule = asmLink(asmCompile('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.sin; function f(x) {x = toF(x); return toF(g(x))} return f"), this);
-for (v of [0, 3.141592653, Math.Infinity, NaN])
-    assertEq(sinModule(v), Math.fround(Math.sin(Math.fround(v))));
+assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.cos; function f(x) {x = toF(x); return toF(g(x))} return f");
+assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.cos; function f(x) {x = +x; return toF(g(+x))} return f");
 
 assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.cos; function f(x) {x = toF(x); return +(g(x))} return f");
 assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.cos; function f(x) {x = +x; return toF(g(x))} return f");
 assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.cos; function f(x) {x = x|0; return toF(g(x))} return f");
 assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.cos; function f(x) {x = toF(x); return g(x) | 0} return f");
 
+assertEq(asmLink(asmCompile('glob', 'ffi', 'heap', USE_ASM + HEAP32 + TO_FLOAT32 + "var g = glob.Math.cos; function f(x) { x = toF(x); return toF(+g(+x)) } return f"), this, null, heap)(3.14159265358), -1);
+
 // Math functions with arity of two are not specialized for floats, so we shouldn't feed them with floats arguments or
 // return type
 assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.pow; function f(x) {x = toF(x); return toF(g(x, 2.))} return f");
 assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.pow; function f(x) {x = toF(x); return +g(x, 2.)} return f");
 assertAsmTypeFail('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.pow; function f(x) {x = toF(x); return toF(g(+x, 2.))} return f");
 assertEq(asmLink(asmCompile('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.pow; function f(x) {x = toF(x); return +g(+x, 2.)} return f"), this)(3), 9);
 assertEq(asmLink(asmCompile('glob', USE_ASM + TO_FLOAT32 + "var g = glob.Math.pow; function f(x) {x = toF(x); return toF(+g(+x, 2.))} return f"), this)(3), 9);
 
--- a/js/src/jit-test/tests/basic/regexp-match-limit.js
+++ b/js/src/jit-test/tests/basic/regexp-match-limit.js
@@ -1,9 +1,9 @@
 // See bug 953013
 
 load(libdir + "asserts.js");
 
 function test() {
-    var input = Array(999999+1).join('a');
+    var input = Array(2499999+1).join('a');
     var result = /^([\w])+$/.test(input);
 }
 assertThrowsInstanceOf(test, InternalError);
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/ion/bug969203.js
@@ -0,0 +1,4 @@
+var f = function (x) {
+    return Math.tan(Math.fround(Math.log(Math.fround(Math.exp(x)))));
+}
+assertEq(f(1), f(1));
deleted file mode 100644
--- a/js/src/jit-test/tests/ion/testFloat32-trigo.js
+++ /dev/null
@@ -1,346 +0,0 @@
-// These tests have been separated, for several reasons:
-// - If we try to run them in a loop (i.e. running through all values in the array),
-// it doesn't get Ion compiled because of the size of the overall function.
-// - If we try to make, for each Math function, a closure that tests all values, the
-// order of running functions has an influence on whether the tests pass or fail (due
-// to bailouts).
-//
-// These tests have been generated by a Python script.
-//
-setJitCompilerOption("ion.usecount.trigger", 50);
-
-// MMath
-function repeat(f) {
-    for (var i = 200; i; i--) {
-        f();
-    }
-}
-
-function assertNear(a, b) {
-    var r = (a != a && b != b) || Math.abs(a-b) < 1e-7 || a === b;
-    if (!r) {
-        print('Precision error: ');
-        print(new Error().stack);
-        print('Got', a, ', expected near', b);
-        assertEq(false, true);
-    }
-}
-
-var trigoInputs = [0, Math.PI / 3, Math.PI, Math.PI * 3 / 4, 1, 1/3, -.5, NaN];
-var f32 = new Float32Array(8);
-for(var i = 0; i < trigoInputs.length; i++) {
-    f32[i] = trigoInputs[i];
-}
-
-function testcos () {
-        var r32, r64;
-
-        r32 = Math.fround(Math.cos(f32[0]));
-        assertFloat32(r32, true);
-        r64 = Math.cos(f32[0]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.cos(f32[1]));
-        assertFloat32(r32, true);
-        r64 = Math.cos(f32[1]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.cos(f32[2]));
-        assertFloat32(r32, true);
-        r64 = Math.cos(f32[2]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.cos(f32[3]));
-        assertFloat32(r32, true);
-        r64 = Math.cos(f32[3]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.cos(f32[4]));
-        assertFloat32(r32, true);
-        r64 = Math.cos(f32[4]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.cos(f32[5]));
-        assertFloat32(r32, true);
-        r64 = Math.cos(f32[5]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.cos(f32[6]));
-        assertFloat32(r32, true);
-        r64 = Math.cos(f32[6]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.cos(f32[7]));
-        assertFloat32(r32, true);
-        r64 = Math.cos(f32[7]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-}
-repeat(testcos);
-function testacos () {
-        var r32, r64;
-
-        r32 = Math.fround(Math.acos(f32[0]));
-        assertFloat32(r32, true);
-        r64 = Math.acos(f32[0]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.acos(f32[1]));
-        assertFloat32(r32, true);
-        r64 = Math.acos(f32[1]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.acos(f32[2]));
-        assertFloat32(r32, true);
-        r64 = Math.acos(f32[2]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.acos(f32[3]));
-        assertFloat32(r32, true);
-        r64 = Math.acos(f32[3]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.acos(f32[4]));
-        assertFloat32(r32, true);
-        r64 = Math.acos(f32[4]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.acos(f32[5]));
-        assertFloat32(r32, true);
-        r64 = Math.acos(f32[5]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.acos(f32[6]));
-        assertFloat32(r32, true);
-        r64 = Math.acos(f32[6]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.acos(f32[7]));
-        assertFloat32(r32, true);
-        r64 = Math.acos(f32[7]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-}
-repeat(testacos);
-function testsin () {
-        var r32, r64;
-
-        r32 = Math.fround(Math.sin(f32[0]));
-        assertFloat32(r32, true);
-        r64 = Math.sin(f32[0]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.sin(f32[1]));
-        assertFloat32(r32, true);
-        r64 = Math.sin(f32[1]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.sin(f32[2]));
-        assertFloat32(r32, true);
-        r64 = Math.sin(f32[2]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.sin(f32[3]));
-        assertFloat32(r32, true);
-        r64 = Math.sin(f32[3]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.sin(f32[4]));
-        assertFloat32(r32, true);
-        r64 = Math.sin(f32[4]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.sin(f32[5]));
-        assertFloat32(r32, true);
-        r64 = Math.sin(f32[5]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.sin(f32[6]));
-        assertFloat32(r32, true);
-        r64 = Math.sin(f32[6]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.sin(f32[7]));
-        assertFloat32(r32, true);
-        r64 = Math.sin(f32[7]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-}
-repeat(testsin);
-function testasin () {
-        var r32, r64;
-
-        r32 = Math.fround(Math.asin(f32[0]));
-        assertFloat32(r32, true);
-        r64 = Math.asin(f32[0]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.asin(f32[1]));
-        assertFloat32(r32, true);
-        r64 = Math.asin(f32[1]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.asin(f32[2]));
-        assertFloat32(r32, true);
-        r64 = Math.asin(f32[2]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.asin(f32[3]));
-        assertFloat32(r32, true);
-        r64 = Math.asin(f32[3]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.asin(f32[4]));
-        assertFloat32(r32, true);
-        r64 = Math.asin(f32[4]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.asin(f32[5]));
-        assertFloat32(r32, true);
-        r64 = Math.asin(f32[5]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.asin(f32[6]));
-        assertFloat32(r32, true);
-        r64 = Math.asin(f32[6]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.asin(f32[7]));
-        assertFloat32(r32, true);
-        r64 = Math.asin(f32[7]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-}
-repeat(testasin);
-function testtan () {
-        var r32, r64;
-
-        r32 = Math.fround(Math.tan(f32[0]));
-        assertFloat32(r32, true);
-        r64 = Math.tan(f32[0]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.tan(f32[1]));
-        assertFloat32(r32, true);
-        r64 = Math.tan(f32[1]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.tan(f32[2]));
-        assertFloat32(r32, true);
-        r64 = Math.tan(f32[2]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.tan(f32[3]));
-        assertFloat32(r32, true);
-        r64 = Math.tan(f32[3]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.tan(f32[4]));
-        assertFloat32(r32, true);
-        r64 = Math.tan(f32[4]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.tan(f32[5]));
-        assertFloat32(r32, true);
-        r64 = Math.tan(f32[5]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.tan(f32[6]));
-        assertFloat32(r32, true);
-        r64 = Math.tan(f32[6]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.tan(f32[7]));
-        assertFloat32(r32, true);
-        r64 = Math.tan(f32[7]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-}
-repeat(testtan);
-function testatan () {
-        var r32, r64;
-
-        r32 = Math.fround(Math.atan(f32[0]));
-        assertFloat32(r32, true);
-        r64 = Math.atan(f32[0]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.atan(f32[1]));
-        assertFloat32(r32, true);
-        r64 = Math.atan(f32[1]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.atan(f32[2]));
-        assertFloat32(r32, true);
-        r64 = Math.atan(f32[2]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.atan(f32[3]));
-        assertFloat32(r32, true);
-        r64 = Math.atan(f32[3]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.atan(f32[4]));
-        assertFloat32(r32, true);
-        r64 = Math.atan(f32[4]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.atan(f32[5]));
-        assertFloat32(r32, true);
-        r64 = Math.atan(f32[5]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.atan(f32[6]));
-        assertFloat32(r32, true);
-        r64 = Math.atan(f32[6]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-
-        r32 = Math.fround(Math.atan(f32[7]));
-        assertFloat32(r32, true);
-        r64 = Math.atan(f32[7]);
-        assertFloat32(r64, false);
-        assertNear(r32, r64);
-}
-repeat(testatan);
--- a/js/src/jit-test/tests/ion/testFloat32.js
+++ b/js/src/jit-test/tests/ion/testFloat32.js
@@ -159,42 +159,42 @@ test(acceptAbs);
 
 function refuseAbs() {
     var res = Math.abs(f32[0]);
     assertFloat32(res, false);
     f64[0] = res + 1;
 }
 test(refuseAbs);
 
-function acceptTrigo() {
+function refuseTrigo() {
     var res = Math.cos(f32[0]);
     f32[0] = res;
-    assertFloat32(res, true);
+    assertFloat32(res, false);
 
     var res = Math.sin(f32[0]);
     f32[0] = res;
-    assertFloat32(res, true);
+    assertFloat32(res, false);
 
     var res = Math.tan(f32[0]);
     f32[0] = res;
-    assertFloat32(res, true);
+    assertFloat32(res, false);
 
     var res = Math.acos(f32[0]);
     f32[0] = res;
-    assertFloat32(res, true);
+    assertFloat32(res, false);
 
     var res = Math.asin(f32[0]);
     f32[0] = res;
-    assertFloat32(res, true);
+    assertFloat32(res, false);
 
     res = Math.atan(f32[0]);
     f32[0] = res;
-    assertFloat32(res, true);
+    assertFloat32(res, false);
 }
-test(acceptTrigo);
+test(refuseTrigo);
 
 function refuseMath() {
     var res = Math.log10(f32[0]);
     f32[0] = res;
     assertFloat32(res, false);
 
     res = Math.log2(f32[0]);
     f32[0] = res;
@@ -293,17 +293,17 @@ function alternateCond(n) {
 function phiTest(n) {
     var x = (f32[0]);
     var y = n;
     if (n > 0) {
         x = x + 2;
         assertFloat32(x, true);
     } else {
         if (n < -10) {
-            x = Math.fround(Math.cos(y));
+            x = Math.fround(Math.sqrt(y));
             assertFloat32(x, true);
         } else {
             x = x - 1;
             assertFloat32(x, true);
         }
     }
     assertFloat32(x, true);
     f32[0] = x;
@@ -318,17 +318,17 @@ function phiTest(n) {
 function mixedPhiTest(n) {
     var x = (f32[0]);
     var y = n;
     if (n > 0) {
         x = x + 2; // non consumer because of (1)
         assertFloat32(x, false);
     } else {
         if (n < -10) {
-            x = Math.fround(Math.cos(y)); // new producer
+            x = Math.fround(Math.sqrt(y)); // new producer
             assertFloat32(x, true);
         } else {
             x = x - 1; // non consumer because of (1)
             assertFloat32(x, false);
         }
     }
     assertFloat32(x, false);
     x = x + 1; // (1) non consumer
--- a/js/src/jit-test/tests/xdr/trivial.js
+++ b/js/src/jit-test/tests/xdr/trivial.js
@@ -27,8 +27,12 @@ evalWithCache(test, { assertEqBytecode: 
 
 // code a function which is used.
 test = "function f() { return 1; }; f();";
 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
 
 // code a function which is not used.
 test = "function f() { return 1; }; 1;";
 evalWithCache(test, { assertEqBytecode: true, assertEqResult : true });
+
+// code a function which has an object literal.
+test = "function f() { return { x: 2 }; }; f();";
+evalWithCache(test, { assertEqBytecode: true });
--- a/js/src/jit/AsmJS.cpp
+++ b/js/src/jit/AsmJS.cpp
@@ -3168,17 +3168,17 @@ CheckGlobalDotImport(ModuleCompiler &m, 
         }
         MOZ_ASSUME_UNREACHABLE("unexpected or uninitialized math builtin type");
     }
 
     if (IsUseOfName(base, m.module().globalArgumentName())) {
         if (field == m.cx()->names().NaN)
             return m.addGlobalConstant(varName, GenericNaN(), field);
         if (field == m.cx()->names().Infinity)
-            return m.addGlobalConstant(varName, PositiveInfinity(), field);
+            return m.addGlobalConstant(varName, PositiveInfinity<double>(), field);
         return m.failName(initNode, "'%s' is not a standard global constant", field);
     }
 
     if (IsUseOfName(base, m.module().importArgumentName()))
         return m.addFFI(varName, field);
 
     return m.fail(initNode, "expecting c.y where c is either the global or foreign parameter");
 }
@@ -4131,27 +4131,27 @@ CheckMathBuiltinCall(FunctionCompiler &f
     AsmJSImmKind doubleCallee, floatCallee;
     switch (func) {
       case AsmJSMathBuiltin_imul:   return CheckMathIMul(f, callNode, retType, def, type);
       case AsmJSMathBuiltin_abs:    return CheckMathAbs(f, callNode, retType, def, type);
       case AsmJSMathBuiltin_sqrt:   return CheckMathSqrt(f, callNode, retType, def, type);
       case AsmJSMathBuiltin_fround: return CheckMathFRound(f, callNode, retType, def, type);
       case AsmJSMathBuiltin_min:    return CheckMathMinMax(f, callNode, retType, def, type, /* isMax = */ false);
       case AsmJSMathBuiltin_max:    return CheckMathMinMax(f, callNode, retType, def, type, /* isMax = */ true);
-      case AsmJSMathBuiltin_sin:    arity = 1; doubleCallee = AsmJSImm_SinD; floatCallee = AsmJSImm_SinF;      break;
-      case AsmJSMathBuiltin_cos:    arity = 1; doubleCallee = AsmJSImm_CosD; floatCallee = AsmJSImm_CosF;      break;
-      case AsmJSMathBuiltin_tan:    arity = 1; doubleCallee = AsmJSImm_TanD; floatCallee = AsmJSImm_TanF;      break;
-      case AsmJSMathBuiltin_asin:   arity = 1; doubleCallee = AsmJSImm_ASinD; floatCallee = AsmJSImm_ASinF;    break;
-      case AsmJSMathBuiltin_acos:   arity = 1; doubleCallee = AsmJSImm_ACosD; floatCallee = AsmJSImm_ACosF;    break;
-      case AsmJSMathBuiltin_atan:   arity = 1; doubleCallee = AsmJSImm_ATanD; floatCallee = AsmJSImm_ATanF;    break;
-      case AsmJSMathBuiltin_ceil:   arity = 1; doubleCallee = AsmJSImm_CeilD; floatCallee = AsmJSImm_CeilF;    break;
+      case AsmJSMathBuiltin_ceil:   arity = 1; doubleCallee = AsmJSImm_CeilD;  floatCallee = AsmJSImm_CeilF;   break;
       case AsmJSMathBuiltin_floor:  arity = 1; doubleCallee = AsmJSImm_FloorD; floatCallee = AsmJSImm_FloorF;  break;
-      case AsmJSMathBuiltin_exp:    arity = 1; doubleCallee = AsmJSImm_ExpD; floatCallee = AsmJSImm_ExpF;      break;
-      case AsmJSMathBuiltin_log:    arity = 1; doubleCallee = AsmJSImm_LogD; floatCallee = AsmJSImm_LogF;      break;
-      case AsmJSMathBuiltin_pow:    arity = 2; doubleCallee = AsmJSImm_PowD; floatCallee = AsmJSImm_Invalid;   break;
+      case AsmJSMathBuiltin_sin:    arity = 1; doubleCallee = AsmJSImm_SinD;   floatCallee = AsmJSImm_Invalid; break;
+      case AsmJSMathBuiltin_cos:    arity = 1; doubleCallee = AsmJSImm_CosD;   floatCallee = AsmJSImm_Invalid; break;
+      case AsmJSMathBuiltin_tan:    arity = 1; doubleCallee = AsmJSImm_TanD;   floatCallee = AsmJSImm_Invalid; break;
+      case AsmJSMathBuiltin_asin:   arity = 1; doubleCallee = AsmJSImm_ASinD;  floatCallee = AsmJSImm_Invalid; break;
+      case AsmJSMathBuiltin_acos:   arity = 1; doubleCallee = AsmJSImm_ACosD;  floatCallee = AsmJSImm_Invalid; break;
+      case AsmJSMathBuiltin_atan:   arity = 1; doubleCallee = AsmJSImm_ATanD;  floatCallee = AsmJSImm_Invalid; break;
+      case AsmJSMathBuiltin_exp:    arity = 1; doubleCallee = AsmJSImm_ExpD;   floatCallee = AsmJSImm_Invalid; break;
+      case AsmJSMathBuiltin_log:    arity = 1; doubleCallee = AsmJSImm_LogD;   floatCallee = AsmJSImm_Invalid; break;
+      case AsmJSMathBuiltin_pow:    arity = 2; doubleCallee = AsmJSImm_PowD;   floatCallee = AsmJSImm_Invalid; break;
       case AsmJSMathBuiltin_atan2:  arity = 2; doubleCallee = AsmJSImm_ATan2D; floatCallee = AsmJSImm_Invalid; break;
       default: MOZ_ASSUME_UNREACHABLE("unexpected mathBuiltin function");
     }
 
     if (retType == RetType::Float && floatCallee == AsmJSImm_Invalid)
         return f.fail(callNode, "math builtin cannot be used as float");
     if (retType != RetType::Double && retType != RetType::Float)
         return f.failf(callNode, "return type of math function is double or float, used as %s", retType.toType().toChars());
--- a/js/src/jit/AsmJSModule.cpp
+++ b/js/src/jit/AsmJSModule.cpp
@@ -243,54 +243,38 @@ AddressOf(AsmJSImmKind kind, ExclusiveCo
         return RedirectCall(FuncCast(__aeabi_idivmod), Args_General2);
       case AsmJSImm_aeabi_uidivmod:
         return RedirectCall(FuncCast(__aeabi_uidivmod), Args_General2);
 #endif
       case AsmJSImm_ModD:
         return RedirectCall(FuncCast(NumberMod), Args_Double_DoubleDouble);
       case AsmJSImm_SinD:
         return RedirectCall(FuncCast<double (double)>(sin), Args_Double_Double);
-      case AsmJSImm_SinF:
-        return RedirectCall(FuncCast<float (float)>(sinf), Args_Float32_Float32);
       case AsmJSImm_CosD:
         return RedirectCall(FuncCast<double (double)>(cos), Args_Double_Double);
-      case AsmJSImm_CosF:
-        return RedirectCall(FuncCast<float (float)>(cosf), Args_Float32_Float32);
       case AsmJSImm_TanD:
         return RedirectCall(FuncCast<double (double)>(tan), Args_Double_Double);
-      case AsmJSImm_TanF:
-        return RedirectCall(FuncCast<float (float)>(tanf), Args_Float32_Float32);
       case AsmJSImm_ASinD:
         return RedirectCall(FuncCast<double (double)>(asin), Args_Double_Double);
-      case AsmJSImm_ASinF:
-        return RedirectCall(FuncCast<float (float)>(asinf), Args_Float32_Float32);
       case AsmJSImm_ACosD:
         return RedirectCall(FuncCast<double (double)>(acos), Args_Double_Double);
-      case AsmJSImm_ACosF:
-        return RedirectCall(FuncCast<float (float)>(acosf), Args_Float32_Float32);
       case AsmJSImm_ATanD:
         return RedirectCall(FuncCast<double (double)>(atan), Args_Double_Double);
-      case AsmJSImm_ATanF:
-        return RedirectCall(FuncCast<float (float)>(atanf), Args_Float32_Float32);
       case AsmJSImm_CeilD:
         return RedirectCall(FuncCast<double (double)>(ceil), Args_Double_Double);
       case AsmJSImm_CeilF:
         return RedirectCall(FuncCast<float (float)>(ceilf), Args_Float32_Float32);
       case AsmJSImm_FloorD:
         return RedirectCall(FuncCast<double (double)>(floor), Args_Double_Double);
       case AsmJSImm_FloorF:
         return RedirectCall(FuncCast<float (float)>(floorf), Args_Float32_Float32);
       case AsmJSImm_ExpD:
         return RedirectCall(FuncCast<double (double)>(exp), Args_Double_Double);
-      case AsmJSImm_ExpF:
-        return RedirectCall(FuncCast<float (float)>(expf), Args_Float32_Float32);
       case AsmJSImm_LogD:
         return RedirectCall(FuncCast<double (double)>(log), Args_Double_Double);
-      case AsmJSImm_LogF:
-        return RedirectCall(FuncCast<float (float)>(logf), Args_Float32_Float32);
       case AsmJSImm_PowD:
         return RedirectCall(FuncCast(ecmaPow), Args_Double_DoubleDouble);
       case AsmJSImm_ATan2D:
         return RedirectCall(FuncCast(ecmaAtan2), Args_Double_DoubleDouble);
       case AsmJSImm_Invalid:
         break;
     }
 
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -35,17 +35,17 @@
 
 #include "jit/shared/CodeGenerator-shared-inl.h"
 #include "vm/Interpreter-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
 using mozilla::DebugOnly;
-using mozilla::DoubleExponentBias;
+using mozilla::FloatingPoint;
 using mozilla::Maybe;
 using mozilla::NegativeInfinity;
 using mozilla::PositiveInfinity;
 using JS::GenericNaN;
 
 namespace js {
 namespace jit {
 
@@ -4323,24 +4323,16 @@ CodeGenerator::visitMathFunctionF(LMathF
     FloatRegister input = ToFloatRegister(ins->input());
     JS_ASSERT(ToFloatRegister(ins->output()) == ReturnFloatReg);
 
     masm.setupUnalignedABICall(1, temp);
     masm.passABIArg(input, MoveOp::FLOAT32);
 
     void *funptr = nullptr;
     switch (ins->mir()->function()) {
-      case MMathFunction::Log:   funptr = JS_FUNC_TO_DATA_PTR(void *, logf);   break;
-      case MMathFunction::Sin:   funptr = JS_FUNC_TO_DATA_PTR(void *, sinf);   break;
-      case MMathFunction::Cos:   funptr = JS_FUNC_TO_DATA_PTR(void *, cosf);   break;
-      case MMathFunction::Exp:   funptr = JS_FUNC_TO_DATA_PTR(void *, expf);   break;
-      case MMathFunction::Tan:   funptr = JS_FUNC_TO_DATA_PTR(void *, tanf);   break;
-      case MMathFunction::ATan:  funptr = JS_FUNC_TO_DATA_PTR(void *, atanf);  break;
-      case MMathFunction::ASin:  funptr = JS_FUNC_TO_DATA_PTR(void *, asinf);  break;
-      case MMathFunction::ACos:  funptr = JS_FUNC_TO_DATA_PTR(void *, acosf);  break;
       case MMathFunction::Floor: funptr = JS_FUNC_TO_DATA_PTR(void *, floorf); break;
       case MMathFunction::Ceil:  funptr = JS_FUNC_TO_DATA_PTR(void *, ceilf);  break;
       default:
         MOZ_ASSUME_UNREACHABLE("Unknown or unsupported float32 math function");
     }
 
     masm.callWithABI(funptr, MoveOp::FLOAT32);
     return true;
@@ -8155,17 +8147,19 @@ CodeGenerator::emitAssertRangeD(const Ra
         masm.branchDouble(Assembler::DoubleLessThanOrEqual, input, temp, &success);
         masm.assumeUnreachable("Double input should be lower or equal than Upperbound.");
         masm.bind(&success);
     }
 
     // This code does not yet check r->canHaveFractionalPart(). This would require new
     // assembler interfaces to make rounding instructions available.
 
-    if (!r->hasInt32Bounds() && !r->canBeInfiniteOrNaN() && r->exponent() < DoubleExponentBias) {
+    if (!r->hasInt32Bounds() && !r->canBeInfiniteOrNaN() &&
+        r->exponent() < FloatingPoint<double>::ExponentBias)
+    {
         // Check the bounds implied by the maximum exponent.
         Label exponentLoOk;
         masm.loadConstantDouble(pow(2.0, r->exponent() + 1), temp);
         masm.branchDouble(Assembler::DoubleUnordered, input, input, &exponentLoOk);
         masm.branchDouble(Assembler::DoubleLessThanOrEqual, input, temp, &exponentLoOk);
         masm.assumeUnreachable("Check for exponent failed.");
         masm.bind(&exponentLoOk);
 
@@ -8180,23 +8174,23 @@ CodeGenerator::emitAssertRangeD(const Ra
         Label notnan;
         masm.branchDouble(Assembler::DoubleOrdered, input, input, &notnan);
         masm.assumeUnreachable("Input shouldn't be NaN.");
         masm.bind(&notnan);
 
         // If we think the value also can't be an infinity, check that it isn't.
         if (!r->canBeInfiniteOrNaN()) {
             Label notposinf;
-            masm.loadConstantDouble(PositiveInfinity(), temp);
+            masm.loadConstantDouble(PositiveInfinity<double>(), temp);
             masm.branchDouble(Assembler::DoubleLessThan, input, temp, &notposinf);
             masm.assumeUnreachable("Input shouldn't be +Inf.");
             masm.bind(&notposinf);
 
             Label notneginf;
-            masm.loadConstantDouble(NegativeInfinity(), temp);
+            masm.loadConstantDouble(NegativeInfinity<double>(), temp);
             masm.branchDouble(Assembler::DoubleGreaterThan, input, temp, &notneginf);
             masm.assumeUnreachable("Input shouldn't be -Inf.");
             masm.bind(&notneginf);
         }
     }
 
     return true;
 }
--- a/js/src/jit/IonMacroAssembler.cpp
+++ b/js/src/jit/IonMacroAssembler.cpp
@@ -1671,17 +1671,17 @@ MacroAssembler::convertValueToInt(JSCont
         else if (!StringToNumber(cx, v.toString(), &d))
             return false;
 
         switch (behavior) {
           case IntConversion_Normal:
           case IntConversion_NegativeZeroCheck: {
             // -0 is checked anyways if we have a constant value.
             int i;
-            if (mozilla::DoubleIsInt32(d, &i))
+            if (mozilla::NumberIsInt32(d, &i))
                 move32(Imm32(i), output);
             else
                 jump(fail);
             break;
           }
           case IntConversion_Truncate:
             move32(Imm32(js::ToInt32(d)), output);
             break;
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -21,17 +21,17 @@
 
 #include "jsatominlines.h"
 #include "jsinferinlines.h"
 #include "jsobjinlines.h"
 
 using namespace js;
 using namespace js::jit;
 
-using mozilla::DoublesAreIdentical;
+using mozilla::NumbersAreIdentical;
 using mozilla::IsFloat32Representable;
 using mozilla::Maybe;
 
 template<size_t Op> static void
 ConvertDefinitionToDouble(TempAllocator &alloc, MDefinition *def, MInstruction *consumer)
 {
     MInstruction *replace = MToDouble::New(alloc, def);
     consumer->replaceOperand(Op, replace);
@@ -1150,17 +1150,17 @@ MBitNot::infer()
 }
 
 static inline bool
 IsConstant(MDefinition *def, double v)
 {
     if (!def->isConstant())
         return false;
 
-    return DoublesAreIdentical(def->toConstant()->value().toNumber(), v);
+    return NumbersAreIdentical(def->toConstant()->value().toNumber(), v);
 }
 
 MDefinition *
 MBinaryBitwiseInstruction::foldsTo(TempAllocator &alloc, bool useValueNumbers)
 {
     if (specialization_ != MIRType_Int32)
         return this;
 
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -3925,20 +3925,17 @@ class MMathFunction
         return true;
     }
 
     void printOpcode(FILE *fp) const;
 
     static const char *FunctionName(Function function);
 
     bool isFloat32Commutative() const {
-        return function_ == Log || function_ == Sin || function_ == Cos
-               || function_ == Exp || function_ == Tan || function_ == ATan
-               || function_ == ASin || function_ == ACos || function_ == Floor
-               || function_ == Ceil;
+        return function_ == Floor || function_ == Ceil;
     }
     void trySpecializeFloat32(TempAllocator &alloc);
     void computeRange(TempAllocator &alloc);
 };
 
 class MAdd : public MBinaryArithInstruction
 {
     // Is this instruction really an int at heart?
--- a/js/src/jit/RangeAnalysis.cpp
+++ b/js/src/jit/RangeAnalysis.cpp
@@ -20,17 +20,17 @@
 
 #include "jsopcodeinlines.h"
 
 using namespace js;
 using namespace js::jit;
 
 using mozilla::Abs;
 using mozilla::CountLeadingZeroes32;
-using mozilla::DoubleEqualsInt32;
+using mozilla::NumberEqualsInt32;
 using mozilla::ExponentComponent;
 using mozilla::FloorLog2;
 using mozilla::IsInfinite;
 using mozilla::IsFinite;
 using mozilla::IsNaN;
 using mozilla::IsNegative;
 using mozilla::NegativeInfinity;
 using mozilla::PositiveInfinity;
@@ -157,18 +157,18 @@ RangeAnalysis::addBetaNodes()
 
         // TODO: support unsigned comparisons
         if (compare->compareType() == MCompare::Compare_UInt32)
             continue;
 
         MDefinition *left = compare->getOperand(0);
         MDefinition *right = compare->getOperand(1);
         double bound;
-        double conservativeLower = NegativeInfinity();
-        double conservativeUpper = PositiveInfinity();
+        double conservativeLower = NegativeInfinity<double>();
+        double conservativeUpper = PositiveInfinity<double>();
         MDefinition *val = nullptr;
 
         JSOp jsop = compare->jsop();
 
         if (branch_dir == FALSE_BRANCH) {
             jsop = NegateCompareOp(jsop);
             conservativeLower = GenericNaN();
             conservativeUpper = GenericNaN();
@@ -217,29 +217,29 @@ RangeAnalysis::addBetaNodes()
         switch (jsop) {
           case JSOP_LE:
             comp.setDouble(conservativeLower, bound);
             break;
           case JSOP_LT:
             // For integers, if x < c, the upper bound of x is c-1.
             if (val->type() == MIRType_Int32) {
                 int32_t intbound;
-                if (DoubleEqualsInt32(bound, &intbound) && SafeSub(intbound, 1, &intbound))
+                if (NumberEqualsInt32(bound, &intbound) && SafeSub(intbound, 1, &intbound))
                     bound = intbound;
             }
             comp.setDouble(conservativeLower, bound);
             break;
           case JSOP_GE:
             comp.setDouble(bound, conservativeUpper);
             break;
           case JSOP_GT:
             // For integers, if x > c, the lower bound of x is c+1.
             if (val->type() == MIRType_Int32) {
                 int32_t intbound;
-                if (DoubleEqualsInt32(bound, &intbound) && SafeAdd(intbound, 1, &intbound))
+                if (NumberEqualsInt32(bound, &intbound) && SafeAdd(intbound, 1, &intbound))
                     bound = intbound;
             }
             comp.setDouble(bound, conservativeUpper);
             break;
           case JSOP_EQ:
             comp.setDouble(bound, bound);
             break;
           default:
--- a/js/src/jit/RangeAnalysis.h
+++ b/js/src/jit/RangeAnalysis.h
@@ -116,20 +116,20 @@ class Range : public TempObject {
 
     // UInt32 are unsigned. UINT32_MAX is pow(2,32)-1, so it's the greatest
     // value that has an exponent of 31.
     static const uint16_t MaxUInt32Exponent = 31;
 
     // Maximal exponenent under which we have no precission loss on double
     // operations. Double has 52 bits of mantissa, so 2^52+1 cannot be
     // represented without loss.
-    static const uint16_t MaxTruncatableExponent = mozilla::DoubleExponentShift;
+    static const uint16_t MaxTruncatableExponent = mozilla::FloatingPoint<double>::ExponentShift;
 
     // Maximum exponent for finite values.
-    static const uint16_t MaxFiniteExponent = mozilla::DoubleExponentBias;
+    static const uint16_t MaxFiniteExponent = mozilla::FloatingPoint<double>::ExponentBias;
 
     // An special exponent value representing all non-NaN values. This
     // includes finite values and the infinities.
     static const uint16_t IncludesInfinity = MaxFiniteExponent + 1;
 
     // An special exponent value representing all possible double-precision
     // values. This includes finite values, the infinities, and NaNs.
     static const uint16_t IncludesInfinityAndNaN = UINT16_MAX;
--- a/js/src/jit/arm/CodeGenerator-arm.cpp
+++ b/js/src/jit/arm/CodeGenerator-arm.cpp
@@ -1011,17 +1011,17 @@ bool
 CodeGeneratorARM::visitPowHalfD(LPowHalfD *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
     FloatRegister output = ToFloatRegister(ins->output());
 
     Label done;
 
     // Masm.pow(-Infinity, 0.5) == Infinity.
-    masm.ma_vimm(NegativeInfinity(), ScratchFloatReg);
+    masm.ma_vimm(NegativeInfinity<double>(), ScratchFloatReg);
     masm.compareDouble(input, ScratchFloatReg);
     masm.ma_vneg(ScratchFloatReg, output, Assembler::Equal);
     masm.ma_b(&done, Assembler::Equal);
 
     // Math.pow(-0, 0.5) == 0 == Math.pow(0, 0.5). Adding 0 converts any -0 to 0.
     masm.ma_vimm(0.0, ScratchFloatReg);
     masm.ma_vadd(ScratchFloatReg, input, output);
     masm.ma_vsqrt(output, output);
--- a/js/src/jit/shared/Assembler-shared.h
+++ b/js/src/jit/shared/Assembler-shared.h
@@ -686,35 +686,27 @@ enum AsmJSImmKind
     AsmJSImm_EnableActivationFromAsmJS,
     AsmJSImm_DisableActivationFromAsmJS,
 #if defined(JS_CODEGEN_ARM)
     AsmJSImm_aeabi_idivmod,
     AsmJSImm_aeabi_uidivmod,
 #endif
     AsmJSImm_ModD,
     AsmJSImm_SinD,
-    AsmJSImm_SinF,
     AsmJSImm_CosD,
-    AsmJSImm_CosF,
     AsmJSImm_TanD,
-    AsmJSImm_TanF,
     AsmJSImm_ASinD,
-    AsmJSImm_ASinF,
     AsmJSImm_ACosD,
-    AsmJSImm_ACosF,
     AsmJSImm_ATanD,
-    AsmJSImm_ATanF,
     AsmJSImm_CeilD,
     AsmJSImm_CeilF,
     AsmJSImm_FloorD,
     AsmJSImm_FloorF,
     AsmJSImm_ExpD,
-    AsmJSImm_ExpF,
     AsmJSImm_LogD,
-    AsmJSImm_LogF,
     AsmJSImm_PowD,
     AsmJSImm_ATan2D,
     AsmJSImm_Invalid
 };
 
 // Pointer to be embedded as an immediate in asm.js code.
 class AsmJSImmPtr
 {
--- a/js/src/jit/shared/CodeGenerator-x86-shared.cpp
+++ b/js/src/jit/shared/CodeGenerator-x86-shared.cpp
@@ -16,22 +16,20 @@
 #include "jit/JitCompartment.h"
 #include "jit/RangeAnalysis.h"
 
 #include "jit/shared/CodeGenerator-shared-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
-using mozilla::DoubleSignificandBits;
-using mozilla::FloatSignificandBits;
+using mozilla::FloatingPoint;
 using mozilla::FloorLog2;
 using mozilla::NegativeInfinity;
 using mozilla::SpecificNaN;
-using mozilla::SpecificFloatNaN;
 
 namespace js {
 namespace jit {
 
 CodeGeneratorX86Shared::CodeGeneratorX86Shared(MIRGenerator *gen, LIRGraph *graph, MacroAssembler *masm)
   : CodeGeneratorShared(gen, graph, masm)
 {
 }
@@ -507,28 +505,30 @@ CodeGeneratorX86Shared::visitMinMaxD(LMi
 }
 
 bool
 CodeGeneratorX86Shared::visitAbsD(LAbsD *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
     JS_ASSERT(input == ToFloatRegister(ins->output()));
     // Load a value which is all ones except for the sign bit.
-    masm.loadConstantDouble(SpecificNaN(0, DoubleSignificandBits), ScratchFloatReg);
+    masm.loadConstantDouble(SpecificNaN<double>(0, FloatingPoint<double>::SignificandBits),
+                            ScratchFloatReg);
     masm.andpd(ScratchFloatReg, input);
     return true;
 }
 
 bool
 CodeGeneratorX86Shared::visitAbsF(LAbsF *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
     JS_ASSERT(input == ToFloatRegister(ins->output()));
     // Same trick as visitAbsD above.
-    masm.loadConstantFloat32(SpecificFloatNaN(0, FloatSignificandBits), ScratchFloatReg);
+    masm.loadConstantFloat32(SpecificNaN<float>(0, FloatingPoint<float>::SignificandBits),
+                             ScratchFloatReg);
     masm.andps(ScratchFloatReg, input);
     return true;
 }
 
 bool
 CodeGeneratorX86Shared::visitSqrtD(LSqrtD *ins)
 {
     FloatRegister input = ToFloatRegister(ins->input());
@@ -551,17 +551,17 @@ CodeGeneratorX86Shared::visitPowHalfD(LP
 {
     FloatRegister input = ToFloatRegister(ins->input());
     JS_ASSERT(input == ToFloatRegister(ins->output()));
 
     Label done, sqrt;
 
     if (!ins->mir()->operandIsNeverNegativeInfinity()) {
         // Branch if not -Infinity.
-        masm.loadConstantDouble(NegativeInfinity(), ScratchFloatReg);
+        masm.loadConstantDouble(NegativeInfinity<double>(), ScratchFloatReg);
 
         Assembler::DoubleCondition cond = Assembler::DoubleNotEqualOrUnordered;
         if (ins->mir()->operandIsNeverNaN())
             cond = Assembler::DoubleNotEqual;
         masm.branchDouble(cond, input, ScratchFloatReg, &sqrt);
 
         // Math.pow(-Infinity, 0.5) == Infinity.
         masm.xorpd(input, input);
--- a/js/src/jit/x86/CodeGenerator-x86.cpp
+++ b/js/src/jit/x86/CodeGenerator-x86.cpp
@@ -19,21 +19,17 @@
 #include "jsscriptinlines.h"
 
 #include "jit/shared/CodeGenerator-shared-inl.h"
 
 using namespace js;
 using namespace js::jit;
 
 using mozilla::DebugOnly;
-using mozilla::DoubleExponentBias;
-using mozilla::DoubleExponentShift;
-using mozilla::FloatExponentBias;
-using mozilla::FloatExponentShift;
-using mozilla::FloatExponentBits;
+using mozilla::FloatingPoint;
 using JS::GenericNaN;
 
 CodeGeneratorX86::CodeGeneratorX86(MIRGenerator *gen, LIRGraph *graph, MacroAssembler *masm)
   : CodeGeneratorX86Shared(gen, graph, masm)
 {
 }
 
 static const uint32_t FrameSizes[] = { 128, 256, 512, 1024 };
@@ -836,18 +832,19 @@ CodeGeneratorX86::visitOutOfLineTruncate
     Label fail;
 
     if (Assembler::HasSSE3()) {
         // Push double.
         masm.subl(Imm32(sizeof(double)), esp);
         masm.storeDouble(input, Operand(esp, 0));
 
         static const uint32_t EXPONENT_MASK = 0x7ff00000;
-        static const uint32_t EXPONENT_SHIFT = DoubleExponentShift - 32;
-        static const uint32_t TOO_BIG_EXPONENT = (DoubleExponentBias + 63) << EXPONENT_SHIFT;
+        static const uint32_t EXPONENT_SHIFT = FloatingPoint<double>::ExponentShift - 32;
+        static const uint32_t TOO_BIG_EXPONENT = (FloatingPoint<double>::ExponentBias + 63)
+                                                 << EXPONENT_SHIFT;
 
         // Check exponent to avoid fp exceptions.
         Label failPopDouble;
         masm.load32(Address(esp, 4), output);
         masm.and32(Imm32(EXPONENT_MASK), output);
         masm.branch32(Assembler::GreaterThanOrEqual, output, Imm32(TOO_BIG_EXPONENT), &failPopDouble);
 
         // Load double, perform 64-bit truncation.
@@ -923,20 +920,21 @@ CodeGeneratorX86::visitOutOfLineTruncate
 
     Label fail;
 
     if (Assembler::HasSSE3()) {
         // Push float32, but subtracts 64 bits so that the value popped by fisttp fits
         masm.subl(Imm32(sizeof(uint64_t)), esp);
         masm.storeFloat32(input, Operand(esp, 0));
 
-        static const uint32_t EXPONENT_MASK = FloatExponentBits;
-        static const uint32_t EXPONENT_SHIFT = FloatExponentShift;
+        static const uint32_t EXPONENT_MASK = FloatingPoint<float>::ExponentBits;
+        static const uint32_t EXPONENT_SHIFT = FloatingPoint<float>::ExponentShift;
         // Integers are still 64 bits long, so we can still test for an exponent > 63.
-        static const uint32_t TOO_BIG_EXPONENT = (FloatExponentBias + 63) << EXPONENT_SHIFT;
+        static const uint32_t TOO_BIG_EXPONENT = (FloatingPoint<float>::ExponentBias + 63)
+                                                 << EXPONENT_SHIFT;
 
         // Check exponent to avoid fp exceptions.
         Label failPopFloat;
         masm.movl(Operand(esp, 0), output);
         masm.and32(Imm32(EXPONENT_MASK), output);
         masm.branch32(Assembler::GreaterThanOrEqual, output, Imm32(TOO_BIG_EXPONENT), &failPopFloat);
 
         // Load float, perform 32-bit truncation.
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -416,17 +416,17 @@ JS_ValueToSource(JSContext *cx, HandleVa
     CHECK_REQUEST(cx);
     assertSameCompartment(cx, value);
     return ValueToSource(cx, value);
 }
 
 JS_PUBLIC_API(bool)
 JS_DoubleIsInt32(double d, int32_t *ip)
 {
-    return mozilla::DoubleIsInt32(d, ip);
+    return mozilla::NumberIsInt32(d, ip);
 }
 
 JS_PUBLIC_API(int32_t)
 JS_DoubleToInt32(double d)
 {
     return ToInt32(d);
 }
 
@@ -6200,18 +6200,17 @@ GetScriptedCallerGlobal(JSContext *cx)
 }
 
 JS_PUBLIC_API(void)
 HideScriptedCaller(JSContext *cx)
 {
     MOZ_ASSERT(cx);
 
     // If there's no accessible activation on the stack, we'll return null from
-    // JS_DescribeScriptedCaller anyway, so there's no need to annotate
-    // anything.
+    // DescribeScriptedCaller anyway, so there's no need to annotate anything.
     Activation *act = cx->runtime()->mainThread.activation();
     if (!act)
         return;
     act->hideScriptedCaller();
 }
 
 JS_PUBLIC_API(void)
 UnhideScriptedCaller(JSContext *cx)
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -847,17 +847,17 @@ typedef void
 
 /************************************************************************/
 
 static MOZ_ALWAYS_INLINE jsval
 JS_NumberValue(double d)
 {
     int32_t i;
     d = JS::CanonicalizeNaN(d);
-    if (mozilla::DoubleIsInt32(d, &i))
+    if (mozilla::NumberIsInt32(d, &i))
         return INT_TO_JSVAL(i);
     return DOUBLE_TO_JSVAL(d);
 }
 
 /************************************************************************/
 
 JS_PUBLIC_API(bool)
 JS_StringHasBeenInterned(JSContext *cx, JSString *str);
@@ -4782,18 +4782,18 @@ DescribeScriptedCaller(JSContext *cx, Au
 
 extern JS_PUBLIC_API(JSObject *)
 GetScriptedCallerGlobal(JSContext *cx);
 
 /*
  * Informs the JS engine that the scripted caller should be hidden. This can be
  * used by the embedding to maintain an override of the scripted caller in its
  * calculations, by hiding the scripted caller in the JS engine and pushing data
- * onto a separate stack, which it inspects when JS_DescribeScriptedCaller
- * returns null.
+ * onto a separate stack, which it inspects when DescribeScriptedCaller returns
+ * null.
  *
  * We maintain a counter on each activation record. Add() increments the counter
  * of the topmost activation, and Remove() decrements it. The count may never
  * drop below zero, and must always be exactly zero when the activation is
  * popped from the stack.
  */
 extern JS_PUBLIC_API(void)
 HideScriptedCaller(JSContext *cx);
--- a/js/src/jslibmath.h
+++ b/js/src/jslibmath.h
@@ -52,25 +52,25 @@ NumberDiv(double a, double b)
         if (a == 0 || mozilla::IsNaN(a)
 #ifdef XP_WIN
             || mozilla::IsNaN(b) /* XXX MSVC miscompiles such that (NaN == 0) */
 #endif
         )
             return JS::GenericNaN();
 
         if (mozilla::IsNegative(a) != mozilla::IsNegative(b))
-            return mozilla::NegativeInfinity();
-        return mozilla::PositiveInfinity();
+            return mozilla::NegativeInfinity<double>();
+        return mozilla::PositiveInfinity<double>();
     }
 
     return a / b;
 }
 
 inline double
 NumberMod(double a, double b) {
-    if (b == 0) 
+    if (b == 0)
         return JS::GenericNaN();
     return js_fmod(a, b);
 }
 
 }
 
 #endif /* jslibmath_h */
--- a/js/src/jsmath.cpp
+++ b/js/src/jsmath.cpp
@@ -30,18 +30,18 @@
 #include "jstypes.h"
 #include "prmjtime.h"
 
 #include "jsobjinlines.h"
 
 using namespace js;
 
 using mozilla::Abs;
-using mozilla::DoubleEqualsInt32;
-using mozilla::DoubleIsInt32;
+using mozilla::NumberEqualsInt32;
+using mozilla::NumberIsInt32;
 using mozilla::ExponentComponent;
 using mozilla::IsFinite;
 using mozilla::IsInfinite;
 using mozilla::IsNaN;
 using mozilla::IsNegative;
 using mozilla::IsNegativeZero;
 using mozilla::PositiveInfinity;
 using mozilla::NegativeInfinity;
@@ -342,19 +342,19 @@ js::math_cos(JSContext *cx, unsigned arg
     double z = math_cos_impl(mathCache, x);
     args.rval().setDouble(z);
     return true;
 }
 
 #ifdef _WIN32
 #define EXP_IF_OUT_OF_RANGE(x)                  \
     if (!IsNaN(x)) {                            \
-        if (x == PositiveInfinity())            \
-            return PositiveInfinity();          \
-        if (x == NegativeInfinity())            \
+        if (x == PositiveInfinity<double>())    \
+            return PositiveInfinity<double>();  \
+        if (x == NegativeInfinity<double>())    \
             return 0.0;                         \
     }
 #else
 #define EXP_IF_OUT_OF_RANGE(x)
 #endif
 
 double
 js::math_exp_impl(MathCache *cache, double x)
@@ -511,17 +511,17 @@ js::math_log(JSContext *cx, unsigned arg
     return true;
 }
 
 bool
 js_math_max(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
-    double maxval = NegativeInfinity();
+    double maxval = NegativeInfinity<double>();
     for (unsigned i = 0; i < args.length(); i++) {
         double x;
         if (!ToNumber(cx, args[i], &x))
             return false;
         // Math.max(num, NaN) => NaN, Math.max(-0, +0) => +0
         if (x > maxval || IsNaN(x) || (x == maxval && IsNegative(maxval)))
             maxval = x;
     }
@@ -529,17 +529,17 @@ js_math_max(JSContext *cx, unsigned argc
     return true;
 }
 
 bool
 js_math_min(JSContext *cx, unsigned argc, Value *vp)
 {
     CallArgs args = CallArgsFromVp(argc, vp);
 
-    double minval = PositiveInfinity();
+    double minval = PositiveInfinity<double>();
     for (unsigned i = 0; i < args.length(); i++) {
         double x;
         if (!ToNumber(cx, args[i], &x))
             return false;
         // Math.min(num, NaN) => NaN, Math.min(-0, +0) => -0
         if (x < minval || IsNaN(x) || (x == minval && IsNegativeZero(x)))
             minval = x;
     }
@@ -589,17 +589,17 @@ js::powi(double x, int y)
 double
 js::ecmaPow(double x, double y)
 {
     /*
      * Use powi if the exponent is an integer-valued double. We don't have to
      * check for NaN since a comparison with NaN is always false.
      */
     int32_t yi;
-    if (DoubleEqualsInt32(y, &yi))
+    if (NumberEqualsInt32(y, &yi))
         return powi(x, yi);
 
     /*
      * Because C99 and ECMA specify different behavior for pow(),
      * we need to wrap the libm call to make it ECMA compliant.
      */
     if (!IsFinite(y) && (x == 1.0 || x == -1.0))
         return GenericNaN();
@@ -741,17 +741,17 @@ js_math_random(JSContext *cx, unsigned a
     args.rval().setDouble(z);
     return true;
 }
 
 double
 js::math_round_impl(double x)
 {
     int32_t i;
-    if (DoubleIsInt32(x, &i))
+    if (NumberIsInt32(x, &i))
         return double(i);
 
     /* Some numbers are so big that adding 0.5 would give the wrong number. */
     if (ExponentComponent(x) >= 52)
         return x;
 
     return js_copysign(floor(x + 0.5), x);
 }
@@ -1250,17 +1250,17 @@ double
 js::ecmaHypot(double x, double y)
 {
 #ifdef XP_WIN
     /*
      * Workaround MS hypot bug, where hypot(Infinity, NaN or Math.MIN_VALUE)
      * is NaN, not Infinity.
      */
     if (mozilla::IsInfinite(x) || mozilla::IsInfinite(y)) {
-        return mozilla::PositiveInfinity();
+        return mozilla::PositiveInfinity<double>();
     }
 #endif
     return hypot(x, y);
 }
 
 bool
 js::math_hypot(JSContext *cx, unsigned argc, Value *vp)
 {
@@ -1299,17 +1299,17 @@ js::math_hypot(JSContext *cx, unsigned a
         if (scale < xabs) {
             sumsq = 1 + sumsq * (scale / xabs) * (scale / xabs);
             scale = xabs;
         } else if (scale != 0) {
             sumsq += (xabs / scale) * (xabs / scale);
         }
     }
 
-    double result = isInfinite ? PositiveInfinity() :
+    double result = isInfinite ? PositiveInfinity<double>() :
                     isNaN ? GenericNaN() :
                     scale * sqrt(sumsq);
     args.rval().setNumber(result);
     return true;
 }
 
 #if !HAVE_TRUNC
 double trunc(double x)
--- a/js/src/jsnum.cpp
+++ b/js/src/jsnum.cpp
@@ -36,17 +36,17 @@
 
 #include "vm/NumberObject-inl.h"
 #include "vm/String-inl.h"
 
 using namespace js;
 using namespace js::types;
 
 using mozilla::Abs;
-using mozilla::MinDoubleValue;
+using mozilla::MinNumberValue;
 using mozilla::NegativeInfinity;
 using mozilla::PodCopy;
 using mozilla::PositiveInfinity;
 using mozilla::RangedPtr;
 using JS::GenericNaN;
 
 /*
  * If we're accumulating a decimal number and the number is >= 2^53, then the
@@ -1127,20 +1127,20 @@ js::InitRuntimeNumberState(JSRuntime *rt
     FIX_FPU();
 
     /*
      * Our NaN must be one particular canonical value, because we rely on NaN
      * encoding for our value representation.  See Value.h.
      */
     number_constants[NC_NaN].dval = GenericNaN();
 
-    number_constants[NC_POSITIVE_INFINITY].dval = mozilla::PositiveInfinity();
-    number_constants[NC_NEGATIVE_INFINITY].dval = mozilla::NegativeInfinity();
+    number_constants[NC_POSITIVE_INFINITY].dval = mozilla::PositiveInfinity<double>();
+    number_constants[NC_NEGATIVE_INFINITY].dval = mozilla::NegativeInfinity<double>();
 
-    number_constants[NC_MIN_VALUE].dval = MinDoubleValue();
+    number_constants[NC_MIN_VALUE].dval = MinNumberValue<double>();
 
     // XXX If EXPOSE_INTL_API becomes true all the time at some point,
     //     js::InitRuntimeNumberState is no longer fallible, and we should
     //     change its return type.
 #if !EXPOSE_INTL_API
     /* Copy locale-specific separators into the runtime strings. */
     const char *thousandsSeparator, *decimalPoint, *grouping;
 #ifdef HAVE_LOCALECONV
@@ -1258,17 +1258,17 @@ js_InitNumberClass(JSContext *cx, Handle
 }
 
 static char *
 FracNumberToCString(ThreadSafeContext *cx, ToCStringBuf *cbuf, double d, int base = 10)
 {
 #ifdef DEBUG
     {
         int32_t _;
-        JS_ASSERT(!mozilla::DoubleIsInt32(d, &_));
+        JS_ASSERT(!mozilla::NumberIsInt32(d, &_));
     }
 #endif
 
     char* numStr;
     if (base == 10) {
         /*
          * This is V8's implementation of the algorithm described in the
          * following paper:
@@ -1287,17 +1287,17 @@ FracNumberToCString(ThreadSafeContext *c
     return numStr;
 }
 
 char *
 js::NumberToCString(JSContext *cx, ToCStringBuf *cbuf, double d, int base/* = 10*/)
 {
     int32_t i;
     size_t len;
-    return mozilla::DoubleIsInt32(d, &i)
+    return mozilla::NumberIsInt32(d, &i)
            ? Int32ToCString(cbuf, i, &len, base)
            : FracNumberToCString(cx, cbuf, d, base);
 }
 
 template <AllowGC allowGC>
 static JSString * JS_FASTCALL
 js_NumberToStringWithBase(ThreadSafeContext *cx, double d, int base)
 {
@@ -1312,17 +1312,17 @@ js_NumberToStringWithBase(ThreadSafeCont
     if (base < 2 || base > 36)
         return nullptr;
 
     JSCompartment *comp = cx->isExclusiveContext()
                           ? cx->asExclusiveContext()->compartment()
                           : nullptr;
 
     int32_t i;
-    if (mozilla::DoubleIsInt32(d, &i)) {
+    if (mozilla::NumberIsInt32(d, &i)) {
         if (base == 10 && StaticStrings::hasInt(i))
             return cx->staticStrings().getInt(i);
         if (unsigned(i) < unsigned(base)) {
             if (i < 10)
                 return cx->staticStrings().getInt(i);
             jschar c = 'a' + i - 10;
             JS_ASSERT(StaticStrings::hasUnit(c));
             return cx->staticStrings().getUnit(c);
@@ -1373,17 +1373,17 @@ js::NumberToString<CanGC>(ThreadSafeCont
 
 template JSString *
 js::NumberToString<NoGC>(ThreadSafeContext *cx, double d);
 
 JSAtom *
 js::NumberToAtom(ExclusiveContext *cx, double d)
 {
     int32_t si;
-    if (mozilla::DoubleIsInt32(d, &si))
+    if (mozilla::NumberIsInt32(d, &si))
         return Int32ToAtom(cx, si);
 
     if (JSFlatString *str = LookupDtoaCache(cx, d))
         return AtomizeString(cx, str);
 
     ToCStringBuf cbuf;
     char *numStr = FracNumberToCString(cx, &cbuf, d);
     if (!numStr) {
@@ -1777,17 +1777,17 @@ js_strtod(ThreadSafeContext *cx, const j
         cstr[i] = (char)s1[i];
     }
     cstr[i] = 0;
 
     istr = cstr;
     if ((negative = (*istr == '-')) != 0 || *istr == '+')
         istr++;
     if (*istr == 'I' && !strncmp(istr, "Infinity", 8)) {
-        d = negative ? NegativeInfinity() : PositiveInfinity();
+        d = negative ? NegativeInfinity<double>() : PositiveInfinity<double>();
         estr = istr + 8;
     } else {
         int err;
         d = js_strtod_harder(cx->dtoaState(), cstr, &estr, &err);
     }
 
     i = estr - cstr;
     if (cstr != cbuf)
--- a/js/src/jsnum.h
+++ b/js/src/jsnum.h
@@ -195,17 +195,17 @@ namespace js {
 
 static MOZ_ALWAYS_INLINE bool
 ValueFitsInInt32(const Value &v, int32_t *pi)
 {
     if (v.isInt32()) {
         *pi = v.toInt32();
         return true;
     }
-    return v.isDouble() && mozilla::DoubleIsInt32(v.toDouble(), pi);
+    return v.isDouble() && mozilla::NumberIsInt32(v.toDouble(), pi);
 }
 
 /*
  * Returns true if the given value is definitely an index: that is, the value
  * is a number that's an unsigned 32-bit integer.
  *
  * This method prioritizes common-case speed over accuracy in every case.  It
  * can produce false negatives (but not false positives): some values which are
@@ -216,17 +216,17 @@ static MOZ_ALWAYS_INLINE bool
 IsDefinitelyIndex(const Value &v, uint32_t *indexp)
 {
     if (v.isInt32() && v.toInt32() >= 0) {
         *indexp = v.toInt32();
         return true;
     }
 
     int32_t i;
-    if (v.isDouble() && mozilla::DoubleIsInt32(v.toDouble(), &i) && i >= 0) {
+    if (v.isDouble() && mozilla::NumberIsInt32(v.toDouble(), &i) && i >= 0) {
         *indexp = uint32_t(i);
         return true;
     }
 
     return false;
 }
 
 /* ES5 9.4 ToInteger. */
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -81,17 +81,17 @@
 #else
 # include <libgen.h>
 #endif
 
 using namespace js;
 using namespace js::cli;
 
 using mozilla::ArrayLength;
-using mozilla::DoubleEqualsInt32;
+using mozilla::NumberEqualsInt32;
 using mozilla::Maybe;
 using mozilla::PodCopy;
 
 enum JSShellExitCode {
     EXITCODE_RUNTIME_ERROR      = 3,
     EXITCODE_FILE_NOT_FOUND     = 4,
     EXITCODE_OUT_OF_MEMORY      = 5,
     EXITCODE_TIMEOUT            = 6
@@ -558,17 +558,17 @@ Version(JSContext *cx, unsigned argc, js
     } else {
         /* Set version. */
         int32_t v = -1;
         if (args[0].isInt32()) {
             v = args[0].toInt32();
         } else if (args[0].isDouble()) {
             double fv = args[0].toDouble();
             int32_t fvi;
-            if (DoubleEqualsInt32(fv, &fvi))
+            if (NumberEqualsInt32(fv, &fvi))
                 v = fvi;
         }
         if (v < 0 || v > JSVERSION_LATEST) {
             JS_ReportErrorNumber(cx, my_GetErrorMessage, nullptr, JSSMSG_INVALID_ARGS, "version");
             return false;
         }
         JS_SetVersionForCompartment(js::GetContextCompartment(cx), JSVersion(v));
         args.rval().setInt32(origVersion);
@@ -4827,84 +4827,16 @@ my_ErrorReporter(JSContext *cx, const ch
         if (report->errorNumber == JSMSG_OUT_OF_MEMORY) {
             gExitCode = EXITCODE_OUT_OF_MEMORY;
         } else {
             gExitCode = EXITCODE_RUNTIME_ERROR;
         }
     }
 }
 
-#if defined(SHELL_HACK) && defined(DEBUG) && defined(XP_UNIX)
-static bool
-Exec(JSContext *cx, unsigned argc, jsval *vp)
-{
-    CallArgs args = CallArgsFromVp(argc, vp);
-
-    JSFunction *fun;
-    const char *name, **nargv;
-    unsigned i, nargc;
-    JSString *str;
-    bool ok;
-    pid_t pid;
-    int status;
-
-    JS_SET_RVAL(cx, vp, UndefinedValue());
-
-    RootedValue arg(cx, vp[0]);
-    fun = JS_ValueToFunction(cx, arg);
-    if (!fun)
-        return false;
-    if (!fun->atom)
-        return true;
-
-    nargc = 1 + argc;
-
-    /* nargc + 1 accounts for the terminating nullptr. */
-    nargv = new (char *)[nargc + 1];
-    if (!nargv)
-        return false;
-    memset(nargv, 0, sizeof(nargv[0]) * (nargc + 1));
-    nargv[0] = name;
-    jsval *argv = JS_ARGV(cx, vp);
-    for (i = 0; i < nargc; i++) {
-        str = (i == 0) ? fun->atom : JS::ToString(cx, args[i-1]);
-        if (!str) {
-            ok = false;
-            goto done;
-        }
-        nargv[i] = JSStringToUTF8(cx, str);
-        if (!nargv[i]) {
-            ok = false;
-            goto done;
-        }
-    }
-    pid = fork();
-    switch (pid) {
-      case -1:
-        perror("js");
-        break;
-      case 0:
-        (void) execvp(name, (char **)nargv);
-        perror("js");
-        exit(127);
-      default:
-        while (waitpid(pid, &status, 0) < 0 && errno == EINTR)
-            continue;
-        break;
-    }
-    ok = true;
-
-  done:
-    for (i = 0; i < nargc; i++)
-        JS_free(cx, nargv[i]);
-    delete[] nargv;
-    return ok;
-}
-#endif
-
 static bool
 global_enumerate(JSContext *cx, HandleObject obj)
 {
 #ifdef LAZY_STANDARD_CLASSES
     return JS_EnumerateStandardClasses(cx, obj);
 #else
     return true;
 #endif
@@ -4920,66 +4852,17 @@ global_resolve(JSContext *cx, HandleObje
     if (!JS_ResolveStandardClass(cx, obj, id, &resolved))
         return false;
     if (resolved) {
         objp.set(obj);
         return true;
     }
 #endif
 
-#if defined(SHELL_HACK) && defined(DEBUG) && defined(XP_UNIX)
-    /*
-     * Do this expensive hack only for unoptimized Unix builds, which are
-     * not used for benchmarking.
-     */
-    char *path, *comp, *full;
-    const char *name;
-    bool ok, found;
-    JSFunction *fun;
-
-    if (!JSVAL_IS_STRING(id))
-        return true;
-    path = getenv("PATH");
-    if (!path)
-        return true;
-    path = JS_strdup(cx, path);
-    if (!path)
-        return false;
-    JSAutoByteString name(cx, JSVAL_TO_STRING(id));
-    if (!name)
-        return false;
-    ok = true;
-    for (comp = strtok(path, ":"); comp; comp = strtok(nullptr, ":")) {
-        if (*comp != '\0') {
-            full = JS_smprintf("%s/%s", comp, name.ptr());
-            if (!full) {
-                JS_ReportOutOfMemory(cx);
-                ok = false;
-                break;
-            }
-        } else {
-            full = (char *)name;
-        }
-        found = (access(full, X_OK) == 0);
-        if (*comp != '\0')
-            free(full);
-        if (found) {
-            fun = JS_DefineFunction(cx, obj, name, Exec, 0,
-                                    JSPROP_ENUMERATE);
-            ok = (fun != nullptr);
-            if (ok)
-                objp.set(obj);
-            break;
-        }
-    }
-    JS_free(cx, path);
-    return ok;
-#else
     return true;
-#endif
 }
 
 static const JSClass global_class = {
     "global", JSCLASS_NEW_RESOLVE | JSCLASS_GLOBAL_FLAGS,
     JS_PropertyStub,  JS_DeletePropertyStub,
     JS_PropertyStub,  JS_StrictPropertyStub,
     global_enumerate, (JSResolveOp) global_resolve,
     JS_ConvertStub,   nullptr
--- a/js/src/vm/DateTime.cpp
+++ b/js/src/vm/DateTime.cpp
@@ -159,17 +159,17 @@ js::DateTimeInfo::updateTimeZoneAdjustme
  * positive, we can initialize the range at construction time with large
  * negative numbers to ensure the first computation is always a cache miss and
  * doesn't return a bogus offset.
  */
 js::DateTimeInfo::DateTimeInfo()
 {
     // Set to a totally impossible TZA so that the comparison above will fail
     // and all fields will be properly initialized.
-    localTZA_ = UnspecifiedNaN();
+    localTZA_ = UnspecifiedNaN<double>();
     updateTimeZoneAdjustment();
 }
 
 int64_t
 js::DateTimeInfo::computeDSTOffsetMilliseconds(int64_t utcSeconds)
 {
     MOZ_ASSERT(utcSeconds >= 0);
     MOZ_ASSERT(utcSeconds <= MaxUnixTimeT);
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -52,17 +52,17 @@
 #include "vm/ScopeObject-inl.h"
 #include "vm/Stack-inl.h"
 
 using namespace js;
 using namespace js::gc;
 using namespace js::types;
 
 using mozilla::DebugOnly;
-using mozilla::DoubleEqualsInt32;
+using mozilla::NumberEqualsInt32;
 using mozilla::PodCopy;
 using JS::ForOfIterator;
 
 /*
  * Note: when Clang 3.2 (32-bit) inlines the two functions below in Interpret,
  * the conservative stack scanner leaks a ton of memory and this negatively
  * influences performance. The MOZ_NEVER_INLINE is a temporary workaround until
  * we can remove the conservative scanner. See bug 849526 for more info.
@@ -2835,18 +2835,18 @@ CASE(JSOP_TABLESWITCH)
      * default case if the discriminant isn't already an int jsval.  (This
      * opcode is emitted only for dense int-domain switches.)
      */
     const Value &rref = *--REGS.sp;
     int32_t i;
     if (rref.isInt32()) {
         i = rref.toInt32();
     } else {
-        /* Use mozilla::DoubleEqualsInt32 to treat -0 (double) as 0. */
-        if (!rref.isDouble() || !DoubleEqualsInt32(rref.toDouble(), &i))
+        /* Use mozilla::NumberEqualsInt32 to treat -0 (double) as 0. */
+        if (!rref.isDouble() || !NumberEqualsInt32(rref.toDouble(), &i))
             ADVANCE_AND_DISPATCH(len);
     }
 
     pc2 += JUMP_OFFSET_LEN;
     int32_t low = GET_JUMP_OFFSET(pc2);
     pc2 += JUMP_OFFSET_LEN;
     int32_t high = GET_JUMP_OFFSET(pc2);
 
--- a/js/src/vm/NumericConversions.h
+++ b/js/src/vm/NumericConversions.h
@@ -34,48 +34,49 @@ namespace detail {
 template<typename ResultType>
 inline ResultType
 ToUintWidth(double d)
 {
     static_assert(mozilla::IsUnsigned<ResultType>::value,
                   "ResultType must be an unsigned type");
 
     uint64_t bits = mozilla::BitwiseCast<uint64_t>(d);
+    unsigned DoubleExponentShift = mozilla::FloatingPoint<double>::ExponentShift;
 
     // Extract the exponent component.  (Be careful here!  It's not technically
     // the exponent in NaN, infinities, and subnormals.)
     int_fast16_t exp =
-        int_fast16_t((bits & mozilla::DoubleExponentBits) >> mozilla::DoubleExponentShift) -
-        int_fast16_t(mozilla::DoubleExponentBias);
+        int_fast16_t((bits & mozilla::FloatingPoint<double>::ExponentBits) >> DoubleExponentShift) -
+        int_fast16_t(mozilla::FloatingPoint<double>::ExponentBias);
 
     // If the exponent's less than zero, abs(d) < 1, so the result is 0.  (This
     // also handles subnormals.)
     if (exp < 0)
         return 0;
 
     uint_fast16_t exponent = mozilla::SafeCast<uint_fast16_t>(exp);
 
     // If the exponent is greater than or equal to the bits of precision of a
     // double plus ResultType's width, the number is either infinite, NaN, or
     // too large to have lower-order bits in the congruent value.  (Example:
     // 2**84 is exactly representable as a double.  The next exact double is
     // 2**84 + 2**32.  Thus if ResultType is int32_t, an exponent >= 84 implies
     // floor(abs(d)) == 0 mod 2**32.)  Return 0 in all these cases.
     const size_t ResultWidth = CHAR_BIT * sizeof(ResultType);
-    if (exponent >= mozilla::DoubleExponentShift + ResultWidth)
+    if (exponent >= DoubleExponentShift + ResultWidth)
         return 0;
 
     // The significand contains the bits that will determine the final result.
     // Shift those bits left or right, according to the exponent, to their
     // locations in the unsigned binary representation of floor(abs(d)).
     static_assert(sizeof(ResultType) <= sizeof(uint64_t),
                   "Left-shifting below would lose upper bits");
-    ResultType result = (exponent > mozilla::DoubleExponentShift)
-                        ? ResultType(bits << (exponent - mozilla::DoubleExponentShift))
-                        : ResultType(bits >> (mozilla::DoubleExponentShift - exponent));
+    ResultType result = (exponent > DoubleExponentShift)
+                        ? ResultType(bits << (exponent - DoubleExponentShift))
+                        : ResultType(bits >> (DoubleExponentShift - exponent));
 
     // Two further complications remain.  First, |result| may contain bogus
     // sign/exponent bits.  Second, IEEE-754 numbers' significands (excluding
     // subnormals, but we already handled those) have an implicit leading 1
     // which may affect the final result.
     //
     // It may appear that there's complexity here depending on how ResultWidth
     // and DoubleExponentShift relate, but it turns out there's not.
@@ -98,17 +99,17 @@ ToUintWidth(double d)
     //   again, |exponent < ResultWidth|.
     if (exponent < ResultWidth) {
         ResultType implicitOne = ResultType(1) << exponent;
         result &= implicitOne - 1; // remove bogus bits
         result += implicitOne; // add the implicit bit
     }
 
     // Compute the congruent value in the signed range.
-    return (bits & mozilla::DoubleSignBit) ? ~result + 1 : result;
+    return (bits & mozilla::FloatingPoint<double>::SignBit) ? ~result + 1 : result;
 }
 
 template<typename ResultType>
 inline ResultType
 ToIntWidth(double d)
 {
     static_assert(mozilla::IsSigned<ResultType>::value,
                   "ResultType must be a signed type");
--- a/js/src/vm/Runtime.cpp
+++ b/js/src/vm/Runtime.cpp
@@ -240,18 +240,18 @@ JSRuntime::JSRuntime(JSRuntime *parentRu
     gcFinalizeCallback(nullptr),
     gcMallocBytes(0),
     gcMallocGCTriggered(false),
 #ifdef JS_ARM_SIMULATOR
     simulatorRuntime_(nullptr),
 #endif
     scriptAndCountsVector(nullptr),
     NaNValue(DoubleNaNValue()),
-    negativeInfinityValue(DoubleValue(NegativeInfinity())),
-    positiveInfinityValue(DoubleValue(PositiveInfinity())),
+    negativeInfinityValue(DoubleValue(NegativeInfinity<double>())),
+    positiveInfinityValue(DoubleValue(PositiveInfinity<double>())),
     emptyString(nullptr),
     debugMode(false),
     spsProfiler(thisFromCtor()),
     profilingScripts(false),
     alwaysPreserveCode(false),
     hadOutOfMemory(false),
     haveCreatedContext(false),
     data(nullptr),
--- a/js/src/vm/Stack.h
+++ b/js/src/vm/Stack.h
@@ -1134,17 +1134,17 @@ class Activation
     // Counter incremented by JS_SaveFrameChain on the top-most activation and
     // decremented by JS_RestoreFrameChain. If > 0, ScriptFrameIter should stop
     // iterating when it reaches this activation (if GO_THROUGH_SAVED is not
     // set).
     size_t savedFrameChain_;
 
     // Counter incremented by JS::HideScriptedCaller and decremented by
     // JS::UnhideScriptedCaller. If > 0 for the top activation,
-    // JS_DescribeScriptedCaller will return null instead of querying that
+    // DescribeScriptedCaller will return null instead of querying that
     // activation, which should prompt the caller to consult embedding-specific
     // data structures instead.
     size_t hideScriptedCallerCount_;
 
     enum Kind { Interpreter, Jit, ForkJoin };
     Kind kind_;
 
     inline Activation(JSContext *cx, Kind kind_);
--- a/js/src/yarr/Yarr.h
+++ b/js/src/yarr/Yarr.h
@@ -46,17 +46,17 @@ namespace JSC { namespace Yarr {
 #define YarrStackSpaceForBackTrackInfoParentheses 2
 
 static const unsigned quantifyInfinite = UINT_MAX;
 static const unsigned offsetNoMatch = (unsigned)-1;
 static const unsigned offsetError = (unsigned)-2;
 
 // The below limit restricts the number of "recursive" match calls in order to
 // avoid spending exponential time on complex regular expressions.
-static const unsigned matchLimit = 1000000;
+static const unsigned matchLimit = 2500000;
 
 enum JSRegExpResult {
     JSRegExpMatch = 1,
     JSRegExpNoMatch = 0,
     JSRegExpErrorNoMatch = -1,
     JSRegExpErrorHitLimit = -2,
     JSRegExpErrorNoMemory = -3,
     JSRegExpErrorInternal = -4
--- a/js/xpconnect/src/dictionary_helper_gen.py
+++ b/js/xpconnect/src/dictionary_helper_gen.py
@@ -229,19 +229,19 @@ def init_value(attribute):
             return "false"
         if realtype.count("nsAString"):
             return ""
         if realtype.count("nsACString"):
             return ""
         return "0"
     else:
         if realtype.count("double") and attribute.defvalue == "Infinity":
-            return "mozilla::PositiveInfinity()"
+            return "mozilla::PositiveInfinity<double>()"
         if realtype.count("double") and attribute.defvalue == "-Infinity":
-            return "mozilla::NegativeInfinity()"
+            return "mozilla::NegativeInfinity<double>()"
         if realtype.count("nsAString"):
             return "NS_LITERAL_STRING(\"%s\")" % attribute.defvalue
         if realtype.count("nsACString"):
             return "NS_LITERAL_CSTRING(\"%s\")" % attribute.defvalue
         raise xpidl.IDLError("Default value of %s is not supported for type %s" %
                              (attribute.defvalue, realtype), attribute.location)
 
 def write_header(iface, fd):
--- a/js/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/xpconnect/src/dom_quickstubs.qsconf
@@ -27,19 +27,16 @@ members = [
     #
     # (And nsIDOMModalContentWindow.returnValue is an attribute of type
     # nsIVariant, which qsgen.py can't handle.)
     #
     # nsLocationSH has ~ALLOW_PROP_MODS_TO_PROTOTYPE, so don't try.
     #'nsIDOMLocation.hostname',
     #'nsIDOMLocation.href',
 
-    # dom/interfaces/core
-    'nsIDOMDOMStringList.*',
-
     # dom/interfaces/storage
     'nsIDOMToString.toString',
     'nsIDOMStorage.setItem',
     'nsIDOMStorage.length',
     'nsIDOMStorage.getItem',
     'nsIDOMStorage.key',
     'nsIDOMStorage.removeItem',
     'nsIDOMStorage.clear',
--- a/js/xpconnect/src/nsDOMQS.h
+++ b/js/xpconnect/src/nsDOMQS.h
@@ -12,18 +12,18 @@
 #include "mozilla/dom/HTMLImageElement.h"
 #include "mozilla/dom/HTMLOptionElement.h"
 #include "HTMLOptGroupElement.h"
 #include "mozilla/dom/HTMLVideoElement.h"
 #include "nsHTMLDocument.h"
 #include "nsICSSDeclaration.h"
 #include "nsSVGElement.h"
 #include "nsDOMEvent.h"
-#include "nsDOMMouseEvent.h"
 #include "nsDOMUIEvent.h"
+#include "mozilla/dom/MouseEvent.h"
 #include "mozilla/dom/EventTargetBinding.h"
 #include "mozilla/dom/NodeBinding.h"
 #include "mozilla/dom/ElementBinding.h"
 #include "mozilla/dom/HTMLElementBinding.h"
 #include "mozilla/dom/DocumentBinding.h"
 #include "mozilla/dom/SVGElementBinding.h"
 #include "mozilla/dom/HTMLDocumentBinding.h"
 #include "XPCQuickStubs.h"
@@ -53,18 +53,18 @@ NEW_BINDING(mozilla::dom::EventTarget, E
 NEW_BINDING(nsINode, Node);
 NEW_BINDING(mozilla::dom::Element, Element);
 NEW_BINDING(nsGenericHTMLElement, HTMLElement);
 NEW_BINDING(nsIDocument, Document);
 NEW_BINDING(nsDocument, Document);
 NEW_BINDING(nsHTMLDocument, HTMLDocument);
 NEW_BINDING(nsSVGElement, SVGElement);
 NEW_BINDING(nsDOMEvent, Event);
-NEW_BINDING(nsDOMMouseEvent, MouseEvent);
 NEW_BINDING(nsDOMUIEvent, UIEvent);
+NEW_BINDING(mozilla::dom::MouseEvent, MouseEvent);
 
 #define DEFINE_UNWRAP_CAST(_interface, _base, _bit)                           \
 template <>                                                                   \
 MOZ_ALWAYS_INLINE bool                                                        \
 xpc_qsUnwrapThis<_interface>(JSContext *cx,                                   \
                              JS::HandleObject obj,                            \
                              _interface **ppThis,                             \
                              nsISupports **pThisRef,                          \
--- a/js/xpconnect/src/nsXPConnect.cpp
+++ b/js/xpconnect/src/nsXPConnect.cpp
@@ -180,17 +180,17 @@ nsXPConnect::IsISupportsDescendant(nsIIn
     if (info)
         info->HasAncestor(&NS_GET_IID(nsISupports), &found);
     return found;
 }
 
 void
 xpc::SystemErrorReporter(JSContext *cx, const char *message, JSErrorReport *rep)
 {
-    // It would be nice to assert !JS_DescribeScriptedCaller here, to be sure
+    // It would be nice to assert !DescribeScriptedCaller here, to be sure
     // that there isn't any script running that could catch the exception. But
     // the JS engine invokes the error reporter directly if someone reports an
     // ErrorReport that it doesn't know how to turn into an exception. Arguably
     // it should just learn how to throw everything. But either way, if the
     // exception is ending here, it's not going to get propagated to a caller,
     // so it's up to us to make it known.
 
     nsresult rv;
--- a/layout/forms/nsFileControlFrame.cpp
+++ b/layout/forms/nsFileControlFrame.cpp
@@ -12,18 +12,17 @@
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/DataTransfer.h"
 #include "mozilla/dom/HTMLButtonElement.h"
 #include "mozilla/dom/HTMLInputElement.h"
 #include "nsNodeInfoManager.h"
 #include "nsContentCreatorFunctions.h"
 #include "nsContentUtils.h"
 #include "nsEventStates.h"
-#include "nsIDOMDataTransfer.h"
-#include "nsIDOMDOMStringList.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsIDOMDragEvent.h"
 #include "nsIDOMFileList.h"
 #include "nsContentList.h"
 #include "nsIDOMMutationEvent.h"
 #include "nsTextNode.h"
 
 using namespace mozilla;
 using namespace mozilla::dom;
@@ -218,28 +217,24 @@ nsFileControlFrame::DnDListener::HandleE
   }
 
   return NS_OK;
 }
 
 /* static */ bool
 nsFileControlFrame::DnDListener::IsValidDropData(nsIDOMDragEvent* aEvent)
 {
-  nsCOMPtr<nsIDOMDataTransfer> dataTransfer;
-  aEvent->GetDataTransfer(getter_AddRefs(dataTransfer));
+  nsCOMPtr<nsIDOMDataTransfer> domDataTransfer;
+  aEvent->GetDataTransfer(getter_AddRefs(domDataTransfer));
+  nsCOMPtr<DataTransfer> dataTransfer = do_QueryInterface(domDataTransfer);
   NS_ENSURE_TRUE(dataTransfer, false);
 
-  nsCOMPtr<nsIDOMDOMStringList> types;
-  dataTransfer->GetTypes(getter_AddRefs(types));
-  NS_ENSURE_TRUE(types, false);
-
   // We only support dropping files onto a file upload control
-  bool typeSupported;
-  types->Contains(NS_LITERAL_STRING("Files"), &typeSupported);
-  return typeSupported;
+  nsRefPtr<DOMStringList> types = dataTransfer->Types();
+  return types->Contains(NS_LITERAL_STRING("Files"));
 }
 
 nscoord
 nsFileControlFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
 {
   nscoord result;
   DISPLAY_MIN_WIDTH(this, result);
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-blending/mix-blend-mode-952051-ref.html
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML>
+<head>
+	<style>
+		.parent {
+		  width: 200px;
+		  height: 200px;
+		  overflow: hidden;
+			border-radius: 0px 0px 20px 0px;
+
+			position: absolute;
+			z-index: 0;
+			background-color: #00ff00;
+		}
+
+		.child {
+		  width: 300px;
+		  height: 300px;
+		  margin-left: 100px;
+		  background-color: #ffff00;
+		}
+
+		body {
+			margin: 0;
+		}
+
+	</style>
+</head>
+<body>
+	<div class="parent">
+	    <div class="child"></div>
+	</div>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-blending/mix-blend-mode-952051.html
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML>
+<head>
+	<style>
+		.parent {
+		  width: 200px;
+		  height: 200px;
+		  overflow: hidden;
+			border-radius: 0px 0px 20px 0px;
+			position: absolute;
+			z-index: 0;
+			background-color: #00ff00;
+		}
+
+		.child {
+		  width: 300px;
+		  height: 300px;
+		  margin-left: 100px;
+		  background-color: #ff0000;
+		  mix-blend-mode: difference;
+		}
+
+		body {
+			margin: 0;
+		}
+
+	</style>
+	<!-- Rounded rect clipping seems to not yield the same results when clipping
+	the parent and child elements individually. The reference rendering will show
+	some of the parent green color around the child's clipped corner.
+	The reftests, on the other hand, shows some gray pixels around the same area. 
+	This may somehow be related to antialiasing. -->
+</head>
+<body>
+	<div class="parent">
+	    <div class="child"></div>
+	</div>
+</body>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-blending/mix-blend-mode-child-of-blended-has-opacity-ref.html
@@ -0,0 +1,40 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>CSS Reftest Reference</title>
+		<link rel="author" title="Mirela Budăeș" href="mailto:mbudaes@adobe.com">
+		<style>
+			.parent {
+				opacity: 0.9;
+				background: yellow;/*rgb(255,255,0);*/
+				margin: 30px;
+				width: 120px;
+				height: 120px;
+				display: inline-block;
+			}
+			.blended {
+				width: 100px;
+				height: 100px;
+				background: aqua;/*rgb(0,255,255);*/
+				display: inline-block;
+				margin-top: 10px;
+				margin-left: 10px;
+			}
+			.childBlended {
+				background: lime;/*rgb(0,255,0);*/
+				width: 80px;
+				height: 80px;
+				margin-top: 10px;
+				margin-left: 10px;
+				opacity: 0.99;
+			}
+		</style>
+	</head>
+	<body>
+		<div class="parent">
+			<div class="blended">
+				<div class="childBlended"></div>
+			</div>
+		</div>
+	</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/css-blending/mix-blend-mode-child-of-blended-has-opacity.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>CSS Test: blending between an element and the child with opacity</title>
+		<link rel="author" title="Mirela Budăeș" href="mailto:mbudaes@adobe.com">
+		<link rel="help" href="http://dev.w3.org/fxtf/compositing-1/#mix-blend-mode">
+		<meta name="flags" content="">
+		<meta name="assert" content="Test checks that an element with mix-blend-mode and his child with opacity blends as a group(no blending between the element with mix-blend-mode and the child element)">
+		<link rel="match" href="reference/mix-blend-mode-child-of-blended-has-opacity-ref.html">
+		<style>
+			.parent {
+				opacity: 0.9;
+				background: yellow;/*rgb(255,255,0);*/
+				margin: 30px;
+				width: 120px;
+				height: 120px;
+				display: inline-block;
+			}
+			.blended {
+				width: 100px;
+				height: 100px;
+				background: fuchsia; /* rgb(255, 0, 255);*/
+				display: inline-block;
+				mix-blend-mode: difference;
+				margin-top: 10px;
+				margin-left: 10px;
+			}
+			.childBlended {
+				background: red;/*rgb(255,0,0);*/
+				width: 80px;
+				height: 80px;
+				margin-top: 10px;