Merge mozilla-inbound to mozilla-central. a=merge
authorAndreea Pavel <apavel@mozilla.com>
Sat, 22 Sep 2018 12:34:50 +0300
changeset 493527 f903cbfa3c01
parent 493495 5b433242973a (current diff)
parent 493526 3685d3c45f2d (diff)
child 493528 17b842daa4fa
child 493531 ff4f20dd4858
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone64.0a1
first release with
nightly linux32
f903cbfa3c01 / 64.0a1 / 20180922100157 / files
nightly linux64
f903cbfa3c01 / 64.0a1 / 20180922100157 / files
nightly mac
f903cbfa3c01 / 64.0a1 / 20180922100157 / files
nightly win32
f903cbfa3c01 / 64.0a1 / 20180922100157 / files
nightly win64
f903cbfa3c01 / 64.0a1 / 20180922100157 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge mozilla-inbound to mozilla-central. a=merge
modules/libpref/init/all.js
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1657,17 +1657,17 @@ dependencies = [
 
 [[package]]
 name = "pkg-config"
 version = "0.3.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "plane-split"
-version = "0.13.0"
+version = "0.13.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "binary-space-partition 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -2646,17 +2646,17 @@ dependencies = [
  "dwrote 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "euclid 0.19.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "freetype 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "fxhash 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "gleam 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "plane-split 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "plane-split 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ron 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
  "smallvec 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "thread_profiler 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "time 0.1.40 (registry+https://github.com/rust-lang/crates.io-index)",
  "webrender_api 0.57.2",
 ]
@@ -2969,17 +2969,17 @@ dependencies = [
 "checksum peeking_take_while 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
 "checksum percent-encoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de154f638187706bde41d9b4738748933d64e6b37bdbffc0b47a97d16a6ae356"
 "checksum petgraph 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)" = "7a7e5234c228fbfa874c86a77f685886127f82e0aef602ad1d48333fcac6ad61"
 "checksum phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "cb325642290f28ee14d8c6201159949a872f220c62af6e110a56ea914fbe42fc"
 "checksum phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "d62594c0bb54c464f633175d502038177e90309daf2e0158be42ed5f023ce88f"
 "checksum phf_generator 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "6b07ffcc532ccc85e3afc45865469bf5d9e4ef5bfcf9622e3cfe80c2d275ec03"
 "checksum phf_shared 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)" = "07e24b0ca9643bdecd0632f2b3da6b1b89bbb0030e0b992afc1113b23a7bc2f2"
 "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
-"checksum plane-split 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "64d766f38b15fe1337bdddfc869ef5c50437323f857aaaadc6490197db80a1b8"
+"checksum plane-split 0.13.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cd1ab9bf7197c31ac8004a487cd1ddc5cf420029fb53023fdcab0540b5fa1410"
 "checksum podio 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e5422a1ee1bc57cc47ae717b0137314258138f38fd5f3cea083f43a9725383a0"
 "checksum precomputed-hash 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
 "checksum proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "77997c53ae6edd6d187fec07ec41b207063b5ee6f33680e9fa86d405cdd313d4"
 "checksum proc-macro2 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "cccdc7557a98fe98453030f077df7f3a042052fae465bb61d2c2c41435cfd9b6"
 "checksum procedural-masquerade 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9f566249236c6ca4340f7ca78968271f0ed2b0f234007a61b66f9ecd0af09260"
 "checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4"
 "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
 "checksum quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9949cfe66888ffe1d53e6ec9d9f3b70714083854be20fd5e271b232a017401e8"
new file mode 100644
--- /dev/null
+++ b/accessible/android/SessionAccessibility.cpp
@@ -0,0 +1,36 @@
+/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
+ * 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 "SessionAccessibility.h"
+#include "AndroidUiThread.h"
+#include "nsThreadUtils.h"
+
+#ifdef DEBUG
+#include <android/log.h>
+#define AALOG(args...)                                                         \
+  __android_log_print(ANDROID_LOG_INFO, "GeckoAccessibilityNative", ##args)
+#else
+#define AALOG(args...)                                                         \
+  do {                                                                         \
+  } while (0)
+#endif
+
+template<>
+const char nsWindow::NativePtr<mozilla::a11y::SessionAccessibility>::sName[] =
+  "SessionAccessibility";
+
+using namespace mozilla::a11y;
+
+void
+SessionAccessibility::SetAttached(bool aAttached)
+{
+  if (RefPtr<nsThread> uiThread = GetAndroidUiThread()) {
+    uiThread->Dispatch(NS_NewRunnableFunction(
+      "SessionAccessibility::Attach",
+      [aAttached,
+       sa = java::SessionAccessibility::NativeProvider::GlobalRef(
+         mSessionAccessibility)] { sa->SetAttached(aAttached); }));
+  }
+}
new file mode 100644
--- /dev/null
+++ b/accessible/android/SessionAccessibility.h
@@ -0,0 +1,51 @@
+/* -*- 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_a11y_SessionAccessibility_h_
+#define mozilla_a11y_SessionAccessibility_h_
+
+#include "GeneratedJNINatives.h"
+#include "nsWindow.h"
+
+namespace mozilla {
+namespace a11y {
+
+class SessionAccessibility final
+  : public java::SessionAccessibility::NativeProvider::Natives<SessionAccessibility>
+{
+public:
+  typedef java::SessionAccessibility::NativeProvider::Natives<SessionAccessibility> Base;
+
+  SessionAccessibility(
+    nsWindow::NativePtr<SessionAccessibility>* aPtr,
+    nsWindow* aWindow,
+    java::SessionAccessibility::NativeProvider::Param aSessionAccessibility)
+    : mWindow(aPtr, aWindow)
+    , mSessionAccessibility(aSessionAccessibility)
+  {
+    SetAttached(true);
+  }
+
+  void OnDetach() { SetAttached(false); }
+
+  // Native implementations
+  using Base::AttachNative;
+  using Base::DisposeNative;
+
+  NS_INLINE_DECL_REFCOUNTING(SessionAccessibility)
+
+private:
+  ~SessionAccessibility() {}
+
+  void SetAttached(bool aAttached);
+
+  nsWindow::WindowPtr<SessionAccessibility> mWindow; // Parent only
+  java::SessionAccessibility::NativeProvider::GlobalRef mSessionAccessibility;
+};
+
+} // namespace a11y
+} // namespace mozilla
+
+#endif
--- a/accessible/android/moz.build
+++ b/accessible/android/moz.build
@@ -1,21 +1,23 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # 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/.
 
 EXPORTS.mozilla.a11y += ['AccessibleWrap.h',
     'HyperTextAccessibleWrap.h',
+    'SessionAccessibility.h',
 ]
 
 SOURCES += [
     'AccessibleWrap.cpp',
     'Platform.cpp',
+    'SessionAccessibility.cpp',
 ]
 
 LOCAL_INCLUDES += [
     '/accessible/base',
     '/accessible/generic',
     '/accessible/html',
     '/accessible/ipc',
     '/accessible/ipc/other',
--- a/accessible/base/AccGroupInfo.cpp
+++ b/accessible/base/AccGroupInfo.cpp
@@ -1,14 +1,15 @@
 /* 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 "AccGroupInfo.h"
 #include "nsAccUtils.h"
+#include "TableAccessible.h"
 
 #include "Role.h"
 #include "States.h"
 
 using namespace mozilla::a11y;
 
 AccGroupInfo::AccGroupInfo(const Accessible* aItem, role aRole) :
   mPosInSet(0), mSetSize(0), mParent(nullptr), mItem(aItem), mRole(aRole)
@@ -180,16 +181,85 @@ AccGroupInfo::FirstItemOf(const Accessib
   // Otherwise, it can be a direct child if the container is a list or tree.
   item = aContainer->FirstChild();
   if (ShouldReportRelations(item->Role(), containerRole))
     return item;
 
   return nullptr;
 }
 
+uint32_t
+AccGroupInfo::TotalItemCount(Accessible* aContainer, bool* aIsHierarchical)
+{
+  uint32_t itemCount = 0;
+  switch (aContainer->Role()) {
+    case roles::TABLE:
+      if (nsCoreUtils::GetUIntAttr(aContainer->GetContent(),
+                                   nsGkAtoms::aria_rowcount,
+                                   (int32_t*)&itemCount)) {
+        break;
+      }
+
+      if (TableAccessible* tableAcc = aContainer->AsTable()) {
+        return tableAcc->RowCount();
+      }
+
+      break;
+    case roles::ROW:
+      if (Accessible* table = nsAccUtils::TableFor(aContainer)) {
+        if (nsCoreUtils::GetUIntAttr(table->GetContent(),
+                                     nsGkAtoms::aria_colcount,
+                                     (int32_t*)&itemCount)) {
+          break;
+        }
+
+        if (TableAccessible* tableAcc = table->AsTable()) {
+          return tableAcc->ColCount();
+        }
+      }
+
+      break;
+    case roles::OUTLINE:
+    case roles::LIST:
+    case roles::MENUBAR:
+    case roles::MENUPOPUP:
+    case roles::COMBOBOX:
+    case roles::GROUPING:
+    case roles::TREE_TABLE:
+    case roles::COMBOBOX_LIST:
+    case roles::LISTBOX:
+    case roles::DEFINITION_LIST:
+    case roles::EDITCOMBOBOX:
+    case roles::RADIO_GROUP:
+    case roles::PAGETABLIST: {
+      Accessible* childItem = AccGroupInfo::FirstItemOf(aContainer);
+      if (!childItem) {
+        childItem = aContainer->FirstChild();
+        if (childItem->IsTextLeaf()) {
+          // First child can be a text leaf, check its sibling for an item.
+          childItem = childItem->NextSibling();
+        }
+      }
+
+      if (childItem) {
+        GroupPos groupPos = childItem->GroupPosition();
+        itemCount = groupPos.setSize;
+        if (groupPos.level && aIsHierarchical) {
+          *aIsHierarchical = true;
+        }
+      }
+      break;
+    }
+    default:
+      break;
+  }
+
+  return itemCount;
+}
+
 Accessible*
 AccGroupInfo::NextItemTo(Accessible* aItem)
 {
   AccGroupInfo* groupInfo = aItem->GetGroupInfo();
   if (!groupInfo)
     return nullptr;
 
   // If the item in middle of the group then search next item in siblings.
--- a/accessible/base/AccGroupInfo.h
+++ b/accessible/base/AccGroupInfo.h
@@ -65,16 +65,21 @@ public:
   }
 
   /**
    * Return a first item for the given container.
    */
   static Accessible* FirstItemOf(const Accessible* aContainer);
 
   /**
+   * Return total number of items in container, and if it is has nested collections.
+   */
+  static uint32_t TotalItemCount(Accessible* aContainer, bool* aIsHierarchical);
+
+  /**
    * Return next item of the same group to the given item.
    */
   static Accessible* NextItemTo(Accessible* aItem);
 
 protected:
   AccGroupInfo(const Accessible* aItem, a11y::role aRole);
 
 private:
--- a/accessible/generic/Accessible.cpp
+++ b/accessible/generic/Accessible.cpp
@@ -1043,16 +1043,30 @@ Accessible::NativeAttributes()
                                   NS_LITERAL_STRING("true"), unused);
   }
 
   // Group attributes (level/setsize/posinset)
   GroupPos groupPos = GroupPosition();
   nsAccUtils::SetAccGroupAttrs(attributes, groupPos.level,
                                groupPos.setSize, groupPos.posInSet);
 
+  bool hierarchical = false;
+  uint32_t itemCount = AccGroupInfo::TotalItemCount(this, &hierarchical);
+  if (itemCount) {
+    nsAutoString itemCountStr;
+    itemCountStr.AppendInt(itemCount);
+    attributes->SetStringProperty(NS_LITERAL_CSTRING("child-item-count"),
+      itemCountStr, unused);
+  }
+
+  if (hierarchical) {
+    attributes->SetStringProperty(NS_LITERAL_CSTRING("hierarchical"),
+      NS_LITERAL_STRING("true"), unused);
+  }
+
   // If the accessible doesn't have own content (such as list item bullet or
   // xul tree item) then don't calculate content based attributes.
   if (!HasOwnContent())
     return attributes.forget();
 
   nsEventShell::GetEventAttributes(GetNode(), attributes);
 
   // Get container-foo computed live region properties based on the closest
--- a/accessible/tests/mochitest/attributes.js
+++ b/accessible/tests/mochitest/attributes.js
@@ -21,16 +21,36 @@ function testAttrs(aAccOrElmOrID, aAttrs
  * @param aAbsentAttrs          [in] map of attributes that should not be
  *                              present (name/value pairs)
  */
 function testAbsentAttrs(aAccOrElmOrID, aAbsentAttrs) {
   testAttrsInternal(aAccOrElmOrID, {}, true, aAbsentAttrs);
 }
 
 /**
+ * Test object attributes that aren't right, but should be (todo)
+ *
+ * @param aAccOrElmOrID         [in] the accessible identifier
+ * @param aKey                  [in] attribute name
+ * @param aExpectedValue        [in] expected attribute value
+ */
+function todoAttr(aAccOrElmOrID, aKey, aExpectedValue) {
+  var accessible = getAccessible(aAccOrElmOrID);
+  if (!accessible)
+    return;
+
+  var attrs = null;
+  try {
+    attrs = accessible.attributes;
+  } catch (e) { }
+
+  todo_is(attrs.getStringProperty(aKey), aExpectedValue, "attributes match");
+}
+
+/**
  * Test CSS based object attributes.
  */
 function testCSSAttrs(aID) {
   var node = document.getElementById(aID);
   var computedStyle = document.defaultView.getComputedStyle(node);
 
   var attrs = {
     "display": computedStyle.display,
@@ -91,16 +111,26 @@ function testGroupAttrs(aAccOrElmOrID, a
     is(levelObj.value, aLevel,
        "Wrong group level for " + prettyName(aAccOrElmOrID));
 
     let attrs = { "level": String(aLevel) };
     testAttrs(aAccOrElmOrID, attrs, true);
   }
 }
 
+function testGroupParentAttrs(aAccOrElmOrID, aChildItemCount, aIsHierarchical) {
+  testAttrs(aAccOrElmOrID, { "child-item-count": String(aChildItemCount) }, true);
+
+  if (aIsHierarchical) {
+    testAttrs(aAccOrElmOrID, { "hierarchical": "true" }, true);
+  } else {
+    testAbsentAttrs(aAccOrElmOrID, { "hierarchical": "true" });
+  }
+}
+
 // //////////////////////////////////////////////////////////////////////////////
 // Text attributes.
 
 /**
  * Test text attributes.
  *
  * @param aID                   [in] the ID of DOM element having text
  *                              accessible
--- a/accessible/tests/mochitest/attributes/test_obj_group.html
+++ b/accessible/tests/mochitest/attributes/test_obj_group.html
@@ -19,16 +19,19 @@
     function doTest() {
       // ////////////////////////////////////////////////////////////////////////
       // HTML select with no size attribute.
       testGroupAttrs("opt1-nosize", 1, 4);
       testGroupAttrs("opt2-nosize", 2, 4);
       testGroupAttrs("opt3-nosize", 3, 4);
       testGroupAttrs("opt4-nosize", 4, 4);
 
+      // Container should have item count and not hierarchical
+      testGroupParentAttrs(getAccessible("opt1-nosize").parent, 4, false);
+
       // ////////////////////////////////////////////////////////////////////////
       // HTML select
       testGroupAttrs("opt1", 1, 2);
       testGroupAttrs("opt2", 2, 2);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML select with options
       // XXX bug 469123
@@ -53,162 +56,206 @@
       testGroupAttrs("radio5", 1, 1);
 
       // ////////////////////////////////////////////////////////////////////////
       // HTML ul/ol
       testGroupAttrs("li1", 1, 3);
       testGroupAttrs("li2", 2, 3);
       testGroupAttrs("li3", 3, 3);
 
+      // ul should have item count and not hierarchical
+      testGroupParentAttrs("ul", 3, false);
+
       // ////////////////////////////////////////////////////////////////////////
       // HTML ul/ol (nested lists)
 
       testGroupAttrs("li4", 1, 3, 1);
       testGroupAttrs("li5", 2, 3, 1);
       testGroupAttrs("li6", 3, 3, 1);
+      // ol with nested list should have 1st level item count and be hierarchical
+      testGroupParentAttrs("ol", 3, true);
 
       testGroupAttrs("n_li4", 1, 3, 2);
       testGroupAttrs("n_li5", 2, 3, 2);
       testGroupAttrs("n_li6", 3, 3, 2);
+      // nested ol should have item count and be hierarchical
+      testGroupParentAttrs("ol_nested", 3, true);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA list
       testGroupAttrs("li7", 1, 3);
       testGroupAttrs("li8", 2, 3);
       testGroupAttrs("li9", 3, 3);
+      // simple flat aria list
+      testGroupParentAttrs("aria-list_1", 3, false);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA list (nested lists: list -> listitem -> list -> listitem)
       testGroupAttrs("li10", 1, 3, 1);
       testGroupAttrs("li11", 2, 3, 1);
       testGroupAttrs("li12", 3, 3, 1);
+      // aria list with nested list
+      testGroupParentAttrs("aria-list_2", 3, true);
 
       testGroupAttrs("n_li10", 1, 3, 2);
       testGroupAttrs("n_li11", 2, 3, 2);
       testGroupAttrs("n_li12", 3, 3, 2);
+      // nested aria list.
+      testGroupParentAttrs("aria-list_2_1", 3, true);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA list (nested lists: list -> listitem -> group -> listitem)
       testGroupAttrs("lgt_li1", 1, 2, 1);
       testGroupAttrs("lgt_li1_nli1", 1, 2, 2);
       testGroupAttrs("lgt_li1_nli2", 2, 2, 2);
       testGroupAttrs("lgt_li2", 2, 2, 1);
       testGroupAttrs("lgt_li2_nli1", 1, 2, 2);
       testGroupAttrs("lgt_li2_nli2", 2, 2, 2);
+      // aria list with nested list
+      testGroupParentAttrs("aria-list_3", 2, true);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA menu (menuitem, separator, menuitemradio and menuitemcheckbox)
       testGroupAttrs("menu_item1", 1, 2);
       testGroupAttrs("menu_item2", 2, 2);
       testGroupAttrs("menu_item1.1", 1, 2);
       testGroupAttrs("menu_item1.2", 2, 2);
       testGroupAttrs("menu_item1.3", 1, 3);
       testGroupAttrs("menu_item1.4", 2, 3);
       testGroupAttrs("menu_item1.5", 3, 3);
+      // menu bar item count
+      testGroupParentAttrs("menubar", 2, false);
+      // Bug 1492529. Menu should have total number of items 5 from both sets,
+      // but only has the first 2 item set.
+      todoAttr("menu", "child-item-count", "5");
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA tab
       testGroupAttrs("tab_1", 1, 3);
       testGroupAttrs("tab_2", 2, 3);
       testGroupAttrs("tab_3", 3, 3);
+      // tab list tab count
+      testGroupParentAttrs("tablist_1", 3, false);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA radio
       testGroupAttrs("r1", 1, 3);
       testGroupAttrs("r2", 2, 3);
       testGroupAttrs("r3", 3, 3);
+      // explicit aria radio group
+      testGroupParentAttrs("rg1", 3, false);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA tree
       testGroupAttrs("ti1", 1, 3, 1);
       testGroupAttrs("ti2", 1, 2, 2);
       testGroupAttrs("ti3", 2, 2, 2);
       testGroupAttrs("ti4", 2, 3, 1);
       testGroupAttrs("ti5", 1, 3, 2);
       testGroupAttrs("ti6", 2, 3, 2);
       testGroupAttrs("ti7", 3, 3, 2);
       testGroupAttrs("ti8", 3, 3, 1);
+      testGroupParentAttrs("tree_1", 3, true);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA tree (tree -> treeitem -> group -> treeitem)
       testGroupAttrs("tree2_ti1", 1, 2, 1);
       testGroupAttrs("tree2_ti1a", 1, 2, 2);
       testGroupAttrs("tree2_ti1b", 2, 2, 2);
       testGroupAttrs("tree2_ti2", 2, 2, 1);
       testGroupAttrs("tree2_ti2a", 1, 2, 2);
       testGroupAttrs("tree2_ti2b", 2, 2, 2);
+      testGroupParentAttrs("tree_2", 2, true);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA tree (tree -> treeitem, group -> treeitem)
       testGroupAttrs("tree3_ti1", 1, 2, 1);
       testGroupAttrs("tree3_ti1a", 1, 2, 2);
       testGroupAttrs("tree3_ti1b", 2, 2, 2);
       testGroupAttrs("tree3_ti2", 2, 2, 1);
       testGroupAttrs("tree3_ti2a", 1, 2, 2);
       testGroupAttrs("tree3_ti2b", 2, 2, 2);
+      testGroupParentAttrs("tree_3", 2, true);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA grid
       testGroupAttrs("grid_row1", 1, 2);
       testAbsentAttrs("grid_cell1", {"posinset": "", "setsize": ""});
       testAbsentAttrs("grid_cell2", {"posinset": "", "setsize": ""});
 
       testGroupAttrs("grid_row2", 2, 2);
       testAbsentAttrs("grid_cell3", {"posinset": "", "setsize": ""});
       testAbsentAttrs("grid_cell4", {"posinset": "", "setsize": ""});
+      testGroupParentAttrs("grid", 2, false);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA treegrid
       testGroupAttrs("treegrid_row1", 1, 2, 1);
       testAbsentAttrs("treegrid_cell1", {"posinset": "", "setsize": ""});
       testAbsentAttrs("treegrid_cell2", {"posinset": "", "setsize": ""});
 
       testGroupAttrs("treegrid_row2", 1, 1, 2);
       testAbsentAttrs("treegrid_cell3", {"posinset": "", "setsize": ""});
       testAbsentAttrs("treegrid_cell4", {"posinset": "", "setsize": ""});
 
       testGroupAttrs("treegrid_row3", 2, 2, 1);
       testAbsentAttrs("treegrid_cell5", {"posinset": "", "setsize": ""});
       testAbsentAttrs("treegrid_cell6", {"posinset": "", "setsize": ""});
 
+      testGroupParentAttrs("treegrid", 2, true);
+      // row child item count provided by parent grid's aria-colcount
+      testGroupParentAttrs("treegrid_row1", 4, false);
+
       // ////////////////////////////////////////////////////////////////////////
       // HTML headings
       testGroupAttrs("h1", 0, 0, 1);
       testGroupAttrs("h2", 0, 0, 2);
       testGroupAttrs("h3", 0, 0, 3);
       testGroupAttrs("h4", 0, 0, 4);
       testGroupAttrs("h5", 0, 0, 5);
       testGroupAttrs("h6", 0, 0, 6);
+      // No child item counts or "hierarchical" flag for parent of headings
+      testAbsentAttrs("headings", {"child-item-count": "", "hierarchical": ""});
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA combobox
       testGroupAttrs("combo1_opt1", 1, 4);
       testGroupAttrs("combo1_opt2", 2, 4);
       testGroupAttrs("combo1_opt3", 3, 4);
       testGroupAttrs("combo1_opt4", 4, 4);
+      testGroupParentAttrs("combo1", 4, false);
 
       // ////////////////////////////////////////////////////////////////////////
       // ARIA table
       testGroupAttrs("table_cell", 3, 4);
       testGroupAttrs("table_row", 2, 2);
 
+      // grid child item count provided by aria-rowcount
+      testGroupParentAttrs("table", 2, false);
+      // row child item count provided by parent grid's aria-colcount
+      testGroupParentAttrs("table_row", 4, false);
+
       // ////////////////////////////////////////////////////////////////////////
       // ARIA list constructed by ARIA owns
       testGroupAttrs("t1_li1", 1, 3);
       testGroupAttrs("t1_li2", 2, 3);
       testGroupAttrs("t1_li3", 3, 3);
+      testGroupParentAttrs("aria-list_4", 3, false);
 
       // Test that group position information updates after deleting node.
       testGroupAttrs("tree4_ti1", 1, 2, 1);
       testGroupAttrs("tree4_ti2", 2, 2, 1);
+      testGroupParentAttrs("tree4", 2, true);
+
       var tree4element = document.getElementById("tree4_ti1");
       var tree4acc = getAccessible("tree4");
       tree4element.remove();
       waitForEvent(EVENT_REORDER, tree4acc, function() {
         testGroupAttrs("tree4_ti2", 1, 1, 1);
+        testGroupParentAttrs("tree4", 1, true);
         SimpleTest.finish();
       });
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 </head>
@@ -264,70 +311,70 @@
   <form>
     <input type="radio" id="radio1" name="group1"/>
     <input type="radio" id="radio2" name="group1"/>
   </form>
 
   <input type="radio" id="radio3" name="group2"/>
   <input type="radio" id="radio4" name="group2"/>
 
-  <ul>
+  <ul id="ul">
     <li id="li1">Oranges</li>
     <li id="li2">Apples</li>
     <li id="li3">Bananas</li>
   </ul>
 
-  <ol>
+  <ol id="ol">
     <li id="li4">Oranges</li>
     <li id="li5">Apples</li>
     <li id="li6">Bananas
-      <ul>
+      <ul id="ol_nested">
         <li id="n_li4">Oranges</li>
         <li id="n_li5">Apples</li>
         <li id="n_li6">Bananas</li>
       </ul>
     </li>
   </ol>
 
-  <span role="list">
+  <span role="list" id="aria-list_1">
     <span role="listitem" id="li7">Oranges</span>
     <span role="listitem" id="li8">Apples</span>
     <span role="listitem" id="li9">Bananas</span>
   </span>
 
-  <span role="list">
+  <span role="list" id="aria-list_2">
     <span role="listitem" id="li10">Oranges</span>
     <span role="listitem" id="li11">Apples</span>
     <span role="listitem" id="li12">Bananas
-      <span role="list">
+      <span role="list" id="aria-list_2_1">
         <span role="listitem" id="n_li10">Oranges</span>
         <span role="listitem" id="n_li11">Apples</span>
         <span role="listitem" id="n_li12">Bananas</span>
       </span>
     </span>
   </span>
 
-  <div role="list">
+  <div role="list" id="aria-list_3">
     <div role="listitem" id="lgt_li1">Item 1
       <div role="group">
         <div role="listitem" id="lgt_li1_nli1">Item 1A</div>
         <div role="listitem" id="lgt_li1_nli2">Item 1B</div>
       </div>
     </div>
     <div role="listitem" id="lgt_li2">Item 2
       <div role="group">
         <div role="listitem" id="lgt_li2_nli1">Item 2A</div>
         <div role="listitem" id="lgt_li2_nli2">Item 2B</div>
       </div>
     </div>
   </div>
 
-  <ul role="menubar">
+  <ul role="menubar" id="menubar">
     <li role="menuitem" aria-haspopup="true" id="menu_item1">File
-      <ul role="menu">
+      <ul role="menu" id="menu">
         <li role="menuitem" id="menu_item1.1">New</li>
         <li role="menuitem" id="menu_item1.2">Open…</li>
         <li role="separator">-----</li>
         <li role="menuitem" id="menu_item1.3">Item</li>
         <li role="menuitemradio" id="menu_item1.4">Radio</li>
         <li role="menuitemcheckbox" id="menu_item1.5">Checkbox</li>
       </ul>
     </li>
@@ -341,17 +388,17 @@
   </ul>
 
   <ul id="rg1" role="radiogroup">
     <li id="r1" role="radio" aria-checked="false">Thai</li>
     <li id="r2" role="radio" aria-checked="false">Subway</li>
     <li id="r3" role="radio" aria-checked="false">Jimmy Johns</li>
   </ul>
 
-  <table role="tree">
+  <table role="tree" id="tree_1">
     <tr role="presentation">
       <td role="treeitem" aria-expanded="true" aria-level="1"
           id="ti1">vegetables</td>
     </tr>
     <tr role="presentation">
       <td role="treeitem" aria-level="2" id="ti2">cucumber</td>
     </tr>
     <tr role="presentation">
@@ -370,32 +417,32 @@
     <tr role="presentation">
       <td role="treeitem" aria-level="2" id="ti7">Audi</td>
     </tr>
     <tr role="presentation">
       <td role="treeitem" aria-level="1" id="ti8">people</td>
     </tr>
   </table>
 
-  <ul role="tree">
+  <ul role="tree" id="tree_2">
     <li role="treeitem" id="tree2_ti1">Item 1
       <ul role="group">
         <li role="treeitem" id="tree2_ti1a">Item 1A</li>
         <li role="treeitem" id="tree2_ti1b">Item 1B</li>
       </ul>
     </li>
     <li role="treeitem" id="tree2_ti2">Item 2
       <ul role="group">
         <li role="treeitem" id="tree2_ti2a">Item 2A</li>
         <li role="treeitem" id="tree2_ti2b">Item 2B</li>
       </ul>
     </li>
   </div>
 
-  <div role="tree">
+  <div role="tree" id="tree_3">
     <div role="treeitem" id="tree3_ti1">Item 1</div>
     <div role="group">
       <li role="treeitem" id="tree3_ti1a">Item 1A</li>
       <li role="treeitem" id="tree3_ti1b">Item 1B</li>
     </div>
     <div role="treeitem" id="tree3_ti2">Item 2</div>
     <div role="group">
       <div role="treeitem" id="tree3_ti2a">Item 2A</div>
@@ -403,66 +450,68 @@
     </div>
   </div>
 
   <!-- IMPORTANT: Need to have no whitespace between elements in this tree. -->
   <div role="tree" id="tree4"><div role="treeitem"
     id="tree4_ti1">Item 1</div><div role="treeitem"
     id="tree4_ti2">Item 2</div></div>
 
-  <table role="grid">
+  <table role="grid" id="grid">
     <tr role="row" id="grid_row1">
       <td role="gridcell" id="grid_cell1">cell1</td>
       <td role="gridcell" id="grid_cell2">cell2</td>
     </tr>
     <tr role="row" id="grid_row2">
       <td role="gridcell" id="grid_cell3">cell3</td>
       <td role="gridcell" id="grid_cell4">cell4</td>
     </tr>
   </table>
 
-  <div role="treegrid">
+  <div role="treegrid" id="treegrid" aria-colcount="4">
     <div role="row" aria-level="1" id="treegrid_row1">
       <div role="gridcell" id="treegrid_cell1">cell1</div>
       <div role="gridcell" id="treegrid_cell2">cell2</div>
     </div>
     <div role="row" aria-level="2" id="treegrid_row2">
       <div role="gridcell" id="treegrid_cell3">cell1</div>
       <div role="gridcell" id="treegrid_cell4">cell2</div>
     </div>
     <div role="row" id="treegrid_row3">
       <div role="gridcell" id="treegrid_cell5">cell1</div>
       <div role="gridcell" id="treegrid_cell6">cell2</div>
     </div>
   </div>
 
-  <h1 id="h1">heading1</h1>
-  <h2 id="h2">heading2</h2>
-  <h3 id="h3">heading3</h3>
-  <h4 id="h4">heading4</h4>
-  <h5 id="h5">heading5</h5>
-  <h6 id="h6">heading6</h6>
+  <div id="headings">
+    <h1 id="h1">heading1</h1>
+    <h2 id="h2">heading2</h2>
+    <h3 id="h3">heading3</h3>
+    <h4 id="h4">heading4</h4>
+    <h5 id="h5">heading5</h5>
+    <h6 id="h6">heading6</h6>
+  </div>
 
   <ul id="combo1" role="combobox">Password
     <li id="combo1_opt1" role="option">Xyzzy</li>
     <li id="combo1_opt2" role="option">Plughs</li>
     <li id="combo1_opt3" role="option">Shazaam</li>
     <li id="combo1_opt4" role="option">JoeSentMe</li>
   </ul>
 
   <form>
     <input type="radio" style="display: none;" name="group3">
     <input type="radio" id="radio5" name="group3">
   </form>
 
-  <div role="table" aria-colcount="4" aria-rowcount="2">
+  <div role="table" aria-colcount="4" aria-rowcount="2" id="table">
     <div role="row" id="table_row" aria-rowindex="2">
       <div role="cell" id="table_cell" aria-colindex="3">cell</div>
     </div>
   </div>
 
-  <div role="list" aria-owns="t1_li1 t1_li2 t1_li3">
+  <div role="list" aria-owns="t1_li1 t1_li2 t1_li3" id="aria-list_4">
     <div role="listitem" id="t1_li2">Apples</div>
     <div role="listitem" id="t1_li1">Oranges</div>
   </span>
   <div role="listitem" id="t1_li3">Bananas</div>
 </body>
 </html>
--- a/dom/base/Attr.cpp
+++ b/dom/base/Attr.cpp
@@ -32,17 +32,17 @@ namespace mozilla {
 namespace dom {
 
 //----------------------------------------------------------------------
 bool Attr::sInitialized;
 
 Attr::Attr(nsDOMAttributeMap *aAttrMap,
            already_AddRefed<dom::NodeInfo>&& aNodeInfo,
            const nsAString& aValue)
-  : nsINode(aNodeInfo), mAttrMap(aAttrMap), mValue(aValue)
+  : nsINode(std::move(aNodeInfo)), mAttrMap(aAttrMap), mValue(aValue)
 {
   MOZ_ASSERT(mNodeInfo, "We must get a nodeinfo here!");
   MOZ_ASSERT(mNodeInfo->NodeType() == ATTRIBUTE_NODE,
              "Wrong nodeType");
 
   // We don't add a reference to our content. It will tell us
   // to drop our reference when it goes away.
 }
--- a/dom/base/CharacterData.cpp
+++ b/dom/base/CharacterData.cpp
@@ -36,29 +36,18 @@
 #include "PLDHashTable.h"
 #include "mozilla/Sprintf.h"
 #include "nsWindowSizes.h"
 #include "nsWrapperCacheInlines.h"
 
 namespace mozilla {
 namespace dom {
 
-CharacterData::CharacterData(already_AddRefed<dom::NodeInfo>& aNodeInfo)
-  : nsIContent(aNodeInfo)
-{
-  MOZ_ASSERT(mNodeInfo->NodeType() == TEXT_NODE ||
-             mNodeInfo->NodeType() == CDATA_SECTION_NODE ||
-             mNodeInfo->NodeType() == COMMENT_NODE ||
-             mNodeInfo->NodeType() == PROCESSING_INSTRUCTION_NODE ||
-             mNodeInfo->NodeType() == DOCUMENT_TYPE_NODE,
-             "Bad NodeType in aNodeInfo");
-}
-
 CharacterData::CharacterData(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
-  : nsIContent(aNodeInfo)
+  : nsIContent(std::move(aNodeInfo))
 {
   MOZ_ASSERT(mNodeInfo->NodeType() == TEXT_NODE ||
              mNodeInfo->NodeType() == CDATA_SECTION_NODE ||
              mNodeInfo->NodeType() == COMMENT_NODE ||
              mNodeInfo->NodeType() == PROCESSING_INSTRUCTION_NODE ||
              mNodeInfo->NodeType() == DOCUMENT_TYPE_NODE,
              "Bad NodeType in aNodeInfo");
 }
--- a/dom/base/CharacterData.h
+++ b/dom/base/CharacterData.h
@@ -80,17 +80,16 @@ public:
   // We want to avoid the overhead of extra function calls for
   // refcounting when we're not doing refcount logging, so we can't
   // NS_DECL_ISUPPORTS_INHERITED.
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
   NS_INLINE_DECL_REFCOUNTING_INHERITED(CharacterData, nsIContent);
 
   NS_DECL_ADDSIZEOFEXCLUDINGTHIS
 
-  explicit CharacterData(already_AddRefed<dom::NodeInfo>& aNodeInfo);
   explicit CharacterData(already_AddRefed<dom::NodeInfo>&& aNodeInfo);
 
   void MarkAsMaybeModifiedFrequently()
   {
     SetFlags(NS_MAYBE_MODIFIED_FREQUENTLY);
   }
 
   NS_IMPL_FROMNODE_HELPER(CharacterData, IsCharacterData())
--- a/dom/base/Comment.h
+++ b/dom/base/Comment.h
@@ -21,17 +21,17 @@ private:
     MOZ_ASSERT(mNodeInfo->NodeType() == COMMENT_NODE,
                "Bad NodeType in aNodeInfo");
   }
 
   virtual ~Comment();
 
 public:
   explicit Comment(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
-    : CharacterData(aNodeInfo)
+    : CharacterData(std::move(aNodeInfo))
   {
     Init();
   }
 
   explicit Comment(nsNodeInfoManager* aNodeInfoManager)
     : CharacterData(aNodeInfoManager->GetCommentNodeInfo())
   {
     Init();
--- a/dom/base/DocumentFragment.h
+++ b/dom/base/DocumentFragment.h
@@ -38,18 +38,18 @@ public:
   using nsINode::QuerySelectorAll;
   // Make sure bindings can see our superclass' protected GetElementById method.
   using nsINode::GetElementById;
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocumentFragment, FragmentOrElement)
 
-  explicit DocumentFragment(already_AddRefed<dom::NodeInfo>& aNodeInfo)
-    : FragmentOrElement(aNodeInfo), mHost(nullptr)
+  explicit DocumentFragment(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
+    : FragmentOrElement(std::move(aNodeInfo)), mHost(nullptr)
   {
     Init();
   }
 
   explicit DocumentFragment(nsNodeInfoManager* aNodeInfoManager)
     : FragmentOrElement(aNodeInfoManager->GetNodeInfo(
                                             nsGkAtoms::documentFragmentNodeName,
                                             nullptr, kNameSpaceID_None,
--- a/dom/base/DocumentType.cpp
+++ b/dom/base/DocumentType.cpp
@@ -22,40 +22,41 @@ already_AddRefed<mozilla::dom::DocumentT
 NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
                       nsAtom *aName,
                       const nsAString& aPublicId,
                       const nsAString& aSystemId,
                       const nsAString& aInternalSubset)
 {
   MOZ_ASSERT(aName, "Must have a name");
 
-  already_AddRefed<mozilla::dom::NodeInfo> ni =
+  RefPtr<mozilla::dom::NodeInfo> ni =
     aNodeInfoManager->GetNodeInfo(nsGkAtoms::documentTypeNodeName, nullptr,
                                   kNameSpaceID_None,
                                   nsINode::DOCUMENT_TYPE_NODE, aName);
 
   RefPtr<mozilla::dom::DocumentType> docType =
-    new mozilla::dom::DocumentType(ni, aPublicId, aSystemId, aInternalSubset);
+    new mozilla::dom::DocumentType(ni.forget(), aPublicId, aSystemId,
+                                   aInternalSubset);
   return docType.forget();
 }
 
 namespace mozilla {
 namespace dom {
 
 JSObject*
 DocumentType::WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
 {
   return DocumentType_Binding::Wrap(cx, this, aGivenProto);
 }
 
-DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+DocumentType::DocumentType(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                            const nsAString& aPublicId,
                            const nsAString& aSystemId,
                            const nsAString& aInternalSubset) :
-  CharacterData(aNodeInfo),
+  CharacterData(std::move(aNodeInfo)),
   mPublicId(aPublicId),
   mSystemId(aSystemId),
   mInternalSubset(aInternalSubset)
 {
   MOZ_ASSERT(mNodeInfo->NodeType() == DOCUMENT_TYPE_NODE,
              "Bad NodeType in aNodeInfo");
   MOZ_ASSERT(!IsCharacterData());
 }
@@ -96,15 +97,15 @@ void
 DocumentType::GetInternalSubset(nsAString& aInternalSubset) const
 {
   aInternalSubset = mInternalSubset;
 }
 
 already_AddRefed<CharacterData>
 DocumentType::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
 {
-  already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
-  return do_AddRef(new DocumentType(ni, mPublicId, mSystemId, mInternalSubset));
+  return do_AddRef(new DocumentType(do_AddRef(aNodeInfo), mPublicId, mSystemId,
+                                    mInternalSubset));
 }
 
 } // namespace dom
 } // namespace mozilla
 
--- a/dom/base/DocumentType.h
+++ b/dom/base/DocumentType.h
@@ -23,17 +23,17 @@ namespace dom {
 // XXX DocumentType is currently implemented by inheriting the generic
 // CharacterData object, even though DocumentType is not character
 // data. This is done simply for convenience and should be changed if
 // this restricts what should be done for character data.
 
 class DocumentType final : public CharacterData
 {
 public:
-  DocumentType(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  DocumentType(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                const nsAString& aPublicId,
                const nsAString& aSystemId,
                const nsAString& aInternalSubset);
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(DocumentType, CharacterData)
 
   // nsINode
--- a/dom/base/Element.h
+++ b/dom/base/Element.h
@@ -143,18 +143,18 @@ class Grid;
 #define NS_ELEMENT_IID \
 { 0xc67ed254, 0xfd3b, 0x4b10, \
   { 0x96, 0xa2, 0xc5, 0x8b, 0x7b, 0x64, 0x97, 0xd1 } }
 
 class Element : public FragmentOrElement
 {
 public:
 #ifdef MOZILLA_INTERNAL_API
-  explicit Element(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo) :
-    FragmentOrElement(aNodeInfo),
+  explicit Element(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo) :
+    FragmentOrElement(std::move(aNodeInfo)),
     mState(NS_EVENT_STATE_MOZ_READONLY | NS_EVENT_STATE_DEFINED)
   {
     MOZ_ASSERT(mNodeInfo->NodeType() == ELEMENT_NODE,
                "Bad NodeType in aNodeInfo");
     SetIsElement();
   }
 
   ~Element()
@@ -2096,19 +2096,18 @@ nsINode::GetNextElementSibling() const
  * Macros to implement Clone(). _elementName is the class for which to implement
  * Clone.
  */
 #define NS_IMPL_ELEMENT_CLONE(_elementName)                                 \
 nsresult                                                                    \
 _elementName::Clone(mozilla::dom::NodeInfo* aNodeInfo, nsINode** aResult) const \
 {                                                                           \
   *aResult = nullptr;                                                       \
-  already_AddRefed<mozilla::dom::NodeInfo> ni =                             \
-    RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();                     \
-  _elementName *it = new _elementName(ni);                                  \
+  RefPtr<mozilla::dom::NodeInfo> ni(aNodeInfo);                             \
+  _elementName *it = new _elementName(ni.forget());                         \
   if (!it) {                                                                \
     return NS_ERROR_OUT_OF_MEMORY;                                          \
   }                                                                         \
                                                                             \
   nsCOMPtr<nsINode> kungFuDeathGrip = it;                                   \
   nsresult rv = const_cast<_elementName*>(this)->CopyInnerTo(it);           \
   if (NS_SUCCEEDED(rv)) {                                                   \
     kungFuDeathGrip.swap(*aResult);                                         \
@@ -2119,19 +2118,18 @@ nsresult                                
 
 #define EXPAND(...) __VA_ARGS__
 #define NS_IMPL_ELEMENT_CLONE_WITH_INIT_HELPER(_elementName, extra_args_)   \
 nsresult                                                                    \
 _elementName::Clone(mozilla::dom::NodeInfo* aNodeInfo,                      \
                     nsINode** aResult) const                                \
 {                                                                           \
   *aResult = nullptr;                                                       \
-  already_AddRefed<mozilla::dom::NodeInfo> ni =                             \
-    RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();                     \
-  _elementName *it = new _elementName(ni EXPAND extra_args_);               \
+  RefPtr<mozilla::dom::NodeInfo> ni(aNodeInfo);                             \
+  _elementName *it = new _elementName(ni.forget() EXPAND extra_args_);      \
   if (!it) {                                                                \
     return NS_ERROR_OUT_OF_MEMORY;                                          \
   }                                                                         \
                                                                             \
   nsCOMPtr<nsINode> kungFuDeathGrip = it;                                   \
   nsresult rv = it->Init();                                                 \
   nsresult rv2 = const_cast<_elementName*>(this)->CopyInnerTo(it);          \
   if (NS_FAILED(rv2)) {                                                     \
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -852,23 +852,18 @@ FragmentOrElement::nsExtendedDOMSlots::S
 
   if (mCustomElementData) {
     n += mCustomElementData->SizeOfIncludingThis(aMallocSizeOf);
   }
 
   return n;
 }
 
-FragmentOrElement::FragmentOrElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsIContent(aNodeInfo)
-{
-}
-
 FragmentOrElement::FragmentOrElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
-  : nsIContent(aNodeInfo)
+  : nsIContent(std::move(aNodeInfo))
 {
 }
 
 FragmentOrElement::~FragmentOrElement()
 {
   MOZ_ASSERT(!IsInUncomposedDoc(),
              "Please remove this from the document properly");
   if (GetParent()) {
--- a/dom/base/GeneratedImageContent.cpp
+++ b/dom/base/GeneratedImageContent.cpp
@@ -23,24 +23,17 @@ GeneratedImageContent::Create(nsIDocumen
 {
   RefPtr<dom::NodeInfo> nodeInfo =
     aDocument.NodeInfoManager()->
       GetNodeInfo(nsGkAtoms::mozgeneratedcontentimage,
                   nullptr,
                   kNameSpaceID_XHTML,
                   nsINode::ELEMENT_NODE);
 
-  // Work around not being able to bind a non-const lvalue reference
-  // to an rvalue of non-reference type by just creating an rvalue
-  // reference.  And we can't change the constructor signature,
-  // because then the macro-generated Clone() method fails to compile.
-  already_AddRefed<dom::NodeInfo>&& rvalue = nodeInfo.forget();
-
-  auto image =
-    MakeRefPtr<GeneratedImageContent>(rvalue);
+  auto image = MakeRefPtr<GeneratedImageContent>(nodeInfo.forget());
   image->mIndex = aContentIndex;
   return image.forget();
 }
 
 JSObject*
 GeneratedImageContent::WrapNode(JSContext* aCx,
                                 JS::Handle<JSObject*> aGivenProto)
 {
--- a/dom/base/GeneratedImageContent.h
+++ b/dom/base/GeneratedImageContent.h
@@ -21,18 +21,18 @@ namespace dom {
 
 class GeneratedImageContent final
   : public nsGenericHTMLElement
 {
 public:
   static already_AddRefed<GeneratedImageContent>
     Create(nsIDocument&, uint32_t aContentIndex);
 
-  explicit GeneratedImageContent(already_AddRefed<dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit GeneratedImageContent(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
     MOZ_ASSERT(IsInNamespace(kNameSpaceID_XHTML), "Someone messed up our nodeinfo");
   }
 
   nsresult Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const final;
 
   nsresult CopyInnerTo(GeneratedImageContent* aDest)
   {
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -59,17 +59,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsIRadioGroupContainer)
 NS_INTERFACE_MAP_END_INHERITING(DocumentFragment)
 
 NS_IMPL_ADDREF_INHERITED(ShadowRoot, DocumentFragment)
 NS_IMPL_RELEASE_INHERITED(ShadowRoot, DocumentFragment)
 
 ShadowRoot::ShadowRoot(Element* aElement, ShadowRootMode aMode,
                        already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
-  : DocumentFragment(aNodeInfo)
+  : DocumentFragment(std::move(aNodeInfo))
   , DocumentOrShadowRoot(*this)
   , mMode(aMode)
   , mIsUAWidget(false)
 {
   SetHost(aElement);
 
   // Nodes in a shadow tree should never store a value
   // in the subtree root pointer, nodes in the shadow tree
--- a/dom/base/Text.h
+++ b/dom/base/Text.h
@@ -13,22 +13,18 @@
 namespace mozilla {
 namespace dom {
 
 class Text : public CharacterData
 {
 public:
   NS_IMPL_FROMNODE_HELPER(Text, IsText())
 
-  explicit Text(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : CharacterData(aNodeInfo)
-  {}
-
   explicit Text(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
-    : CharacterData(aNodeInfo)
+  : CharacterData(std::move(aNodeInfo))
   {}
 
   // WebIDL API
   already_AddRefed<Text> SplitText(uint32_t aOffset, ErrorResult& rv);
   void GetWholeText(nsAString& aWholeText, ErrorResult& rv);
 
   static already_AddRefed<Text>
   Constructor(const GlobalObject& aGlobal,
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1344,23 +1344,21 @@ struct nsIDocument::FrameRequest
   bool operator<(int32_t aHandle) const {
     return mHandle < aHandle;
   }
 
   RefPtr<FrameRequestCallback> mCallback;
   int32_t mHandle;
 };
 
-static already_AddRefed<mozilla::dom::NodeInfo> nullNodeInfo;
-
 // ==================================================================
 // =
 // ==================================================================
 nsIDocument::nsIDocument()
-  : nsINode(nullNodeInfo),
+  : nsINode(nullptr),
     DocumentOrShadowRoot(*this),
     mReferrerPolicySet(false),
     mReferrerPolicy(mozilla::net::RP_Unset),
     mBlockAllMixedContent(false),
     mBlockAllMixedContentPreloads(false),
     mUpgradeInsecureRequests(false),
     mUpgradeInsecurePreloads(false),
     mCharacterSet(WINDOWS_1252_ENCODING),
--- a/dom/base/nsIContent.h
+++ b/dom/base/nsIContent.h
@@ -56,18 +56,18 @@ public:
   typedef mozilla::widget::IMEState IMEState;
 
   void ConstructUbiNode(void* storage) override;
 
 #ifdef MOZILLA_INTERNAL_API
   // If you're using the external API, the only thing you can know about
   // nsIContent is that it exists with an IID
 
-  explicit nsIContent(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsINode(aNodeInfo)
+  explicit nsIContent(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsINode(std::move(aNodeInfo))
   {
     MOZ_ASSERT(mNodeInfo);
     SetNodeIsContent();
   }
 #endif // MOZILLA_INTERNAL_API
 
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICONTENT_IID)
 
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -147,18 +147,18 @@ nsINode::nsSlots::Unlink()
   if (mChildNodes) {
     mChildNodes->DropReference();
   }
 }
 
 //----------------------------------------------------------------------
 
 #ifdef MOZILLA_INTERNAL_API
-nsINode::nsINode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : mNodeInfo(aNodeInfo)
+nsINode::nsINode(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : mNodeInfo(std::move(aNodeInfo))
   , mParent(nullptr)
 #ifndef BOOL_FLAGS_ON_WRAPPER_CACHE
   , mBoolFlags(0)
 #endif
   , mChildCount(0)
   , mPreviousOrLastSibling(nullptr)
   , mSubtreeRoot(this)
   , mSlots(nullptr)
--- a/dom/base/nsINode.h
+++ b/dom/base/nsINode.h
@@ -365,17 +365,17 @@ public:
   void AddSizeOfIncludingThis(nsWindowSizes& aSizes, size_t* aNodeSize) const;
 
   friend class nsNodeUtils;
   friend class nsNodeWeakReference;
   friend class nsNodeSupportsWeakRefTearoff;
   friend class AttrArray;
 
 #ifdef MOZILLA_INTERNAL_API
-  explicit nsINode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit nsINode(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 #endif
 
   virtual ~nsINode();
 
   /**
    * Bit-flags to pass (or'ed together) to IsNodeOfType()
    */
   enum {
--- a/dom/base/nsMappedAttributeElement.h
+++ b/dom/base/nsMappedAttributeElement.h
@@ -27,18 +27,18 @@ typedef void (*nsMapRuleToAttributesFunc
 
 typedef nsStyledElement nsMappedAttributeElementBase;
 
 class nsMappedAttributeElement : public nsMappedAttributeElementBase
 {
 
 protected:
 
-  explicit nsMappedAttributeElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsMappedAttributeElementBase(aNodeInfo)
+  explicit nsMappedAttributeElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsMappedAttributeElementBase(std::move(aNodeInfo))
   {}
 
 public:
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const;
 
   static void MapNoAttributesInto(const nsMappedAttributes* aAttributes,
                                   mozilla::MappedDeclarations&);
 
--- a/dom/base/nsStyledElement.h
+++ b/dom/base/nsStyledElement.h
@@ -28,18 +28,18 @@ class DeclarationBlock;
 
 typedef mozilla::dom::Element nsStyledElementBase;
 
 class nsStyledElement : public nsStyledElementBase
 {
 
 protected:
 
-  inline explicit nsStyledElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsStyledElementBase(aNodeInfo)
+  inline explicit nsStyledElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsStyledElementBase(std::move(aNodeInfo))
   {}
 
 public:
   // We don't want to implement AddRef/Release because that would add an extra
   // function call for those on pretty much all elements.  But we do need QI, so
   // we can QI to nsStyledElement.
   NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
 
--- a/dom/base/nsTextNode.cpp
+++ b/dom/base/nsTextNode.cpp
@@ -29,20 +29,20 @@ using namespace mozilla::dom;
  * class used to implement attr() generated content
  */
 class nsAttributeTextNode final : public nsTextNode,
                                   public nsStubMutationObserver
 {
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
-  nsAttributeTextNode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  nsAttributeTextNode(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                       int32_t aNameSpaceID,
                       nsAtom* aAttrName) :
-    nsTextNode(aNodeInfo),
+    nsTextNode(std::move(aNodeInfo)),
     mGrandparent(nullptr),
     mNameSpaceID(aNameSpaceID),
     mAttrName(aAttrName)
   {
     NS_ASSERTION(mNameSpaceID != kNameSpaceID_Unknown, "Must know namespace");
     NS_ASSERTION(mAttrName, "Must have attr name");
   }
 
@@ -53,20 +53,18 @@ public:
 
   NS_DECL_NSIMUTATIONOBSERVER_ATTRIBUTECHANGED
   NS_DECL_NSIMUTATIONOBSERVER_NODEWILLBEDESTROYED
 
   virtual already_AddRefed<CharacterData>
     CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo,
                   bool aCloneText) const override
   {
-    already_AddRefed<mozilla::dom::NodeInfo> ni =
-      RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
     RefPtr<nsAttributeTextNode> it =
-      new nsAttributeTextNode(ni, mNameSpaceID, mAttrName);
+      new nsAttributeTextNode(do_AddRef(aNodeInfo), mNameSpaceID, mAttrName);
     if (aCloneText) {
       it->mText = mText;
     }
 
     return it.forget();
   }
 
   // Public method for the event to run
@@ -110,18 +108,17 @@ bool
 nsTextNode::IsNodeOfType(uint32_t aFlags) const
 {
   return false;
 }
 
 already_AddRefed<CharacterData>
 nsTextNode::CloneDataNode(mozilla::dom::NodeInfo *aNodeInfo, bool aCloneText) const
 {
-  already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
-  RefPtr<nsTextNode> it = new nsTextNode(ni);
+  RefPtr<nsTextNode> it = new nsTextNode(do_AddRef(aNodeInfo));
   if (aCloneText) {
     it->mText = mText;
   }
 
   return it.forget();
 }
 
 nsresult
@@ -214,22 +211,22 @@ NS_NewAttributeContent(nsNodeInfoManager
                        nsIContent** aResult)
 {
   MOZ_ASSERT(aNodeInfoManager, "Missing nodeInfoManager");
   MOZ_ASSERT(aAttrName, "Must have an attr name");
   MOZ_ASSERT(aNameSpaceID != kNameSpaceID_Unknown, "Must know namespace");
 
   *aResult = nullptr;
 
-  already_AddRefed<mozilla::dom::NodeInfo> ni = aNodeInfoManager->GetTextNodeInfo();
+  RefPtr<mozilla::dom::NodeInfo> ni = aNodeInfoManager->GetTextNodeInfo();
 
-  nsAttributeTextNode* textNode = new nsAttributeTextNode(ni,
-                                                          aNameSpaceID,
-                                                          aAttrName);
-  NS_ADDREF(*aResult = textNode);
+  RefPtr<nsAttributeTextNode> textNode = new nsAttributeTextNode(ni.forget(),
+                                                                 aNameSpaceID,
+                                                                 aAttrName);
+  textNode.forget(aResult);
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS_INHERITED(nsAttributeTextNode, nsTextNode,
                             nsIMutationObserver)
 
 nsresult
--- a/dom/base/nsTextNode.h
+++ b/dom/base/nsTextNode.h
@@ -25,18 +25,18 @@ class nsTextNode : public mozilla::dom::
 private:
   void Init()
   {
     MOZ_ASSERT(mNodeInfo->NodeType() == TEXT_NODE,
                "Bad NodeType in aNodeInfo");
   }
 
 public:
-  explicit nsTextNode(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : mozilla::dom::Text(aNodeInfo)
+  explicit nsTextNode(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : mozilla::dom::Text(std::move(aNodeInfo))
   {
     Init();
   }
 
   explicit nsTextNode(nsNodeInfoManager* aNodeInfoManager)
     : mozilla::dom::Text(aNodeInfoManager->GetTextNodeInfo())
   {
     Init();
--- a/dom/canvas/OffscreenCanvas.cpp
+++ b/dom/canvas/OffscreenCanvas.cpp
@@ -123,17 +123,17 @@ OffscreenCanvas::GetContext(JSContext* a
   if (!(contextType == CanvasContextType::WebGL1 ||
         contextType == CanvasContextType::WebGL2 ||
         contextType == CanvasContextType::ImageBitmap))
   {
     aRv.Throw(NS_ERROR_NOT_IMPLEMENTED);
     return nullptr;
   }
 
-  already_AddRefed<nsISupports> result =
+  RefPtr<nsISupports> result =
     CanvasRenderingContextHelper::GetContext(aCx,
                                              aContextId,
                                              aContextOptions,
                                              aRv);
 
   if (!mCurrentContext) {
     return nullptr;
   }
@@ -161,17 +161,17 @@ OffscreenCanvas::GetContext(JSContext* a
           gl::GLScreenBuffer::CreateFactory(gl, caps, forwarder, flags);
 
         if (factory)
           screen->Morph(std::move(factory));
       }
     }
   }
 
-  return result;
+  return result.forget();
 }
 
 already_AddRefed<nsICanvasRenderingContextInternal>
 OffscreenCanvas::CreateContext(CanvasContextType aContextType)
 {
   RefPtr<nsICanvasRenderingContextInternal> ret =
     CanvasRenderingContextHelper::CreateContext(aContextType);
 
--- a/dom/html/HTMLAnchorElement.h
+++ b/dom/html/HTMLAnchorElement.h
@@ -18,18 +18,18 @@ class EventChainPreVisitor;
 namespace dom {
 
 class HTMLAnchorElement final : public nsGenericHTMLElement,
                                 public Link
 {
 public:
   using Element::GetText;
 
-  explicit HTMLAnchorElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLAnchorElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
     , Link(this)
   {
   }
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // CC
--- a/dom/html/HTMLAreaElement.cpp
+++ b/dom/html/HTMLAreaElement.cpp
@@ -14,18 +14,18 @@
 #include "mozilla/MemoryReporting.h"
 #include "nsWindowSizes.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Area)
 
 namespace mozilla {
 namespace dom {
 
-HTMLAreaElement::HTMLAreaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLAreaElement::HTMLAreaElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
   , Link(this)
 {
 }
 
 HTMLAreaElement::~HTMLAreaElement()
 {
 }
 
--- a/dom/html/HTMLAreaElement.h
+++ b/dom/html/HTMLAreaElement.h
@@ -19,17 +19,17 @@ namespace mozilla {
 class EventChainPostVisitor;
 class EventChainPreVisitor;
 namespace dom {
 
 class HTMLAreaElement final : public nsGenericHTMLElement,
                               public Link
 {
 public:
-  explicit HTMLAreaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLAreaElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // CC
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLAreaElement,
                                            nsGenericHTMLElement)
 
--- a/dom/html/HTMLAudioElement.cpp
+++ b/dom/html/HTMLAudioElement.cpp
@@ -22,18 +22,18 @@
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Audio)
 
 namespace mozilla {
 namespace dom {
 
 NS_IMPL_ELEMENT_CLONE(HTMLAudioElement)
 
-HTMLAudioElement::HTMLAudioElement(already_AddRefed<NodeInfo>& aNodeInfo)
-  : HTMLMediaElement(aNodeInfo)
+HTMLAudioElement::HTMLAudioElement(already_AddRefed<NodeInfo>&& aNodeInfo)
+: HTMLMediaElement(std::move(aNodeInfo))
 {
   DecoderDoctorLogger::LogConstruction(this);
 }
 
 HTMLAudioElement::~HTMLAudioElement()
 {
   DecoderDoctorLogger::LogDestruction(this);
 }
@@ -52,22 +52,22 @@ HTMLAudioElement::Audio(const GlobalObje
 {
   nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
   nsIDocument* doc;
   if (!win || !(doc = win->GetExtantDoc())) {
     aRv.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  already_AddRefed<mozilla::dom::NodeInfo> nodeInfo =
+  RefPtr<mozilla::dom::NodeInfo> nodeInfo =
     doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::audio, nullptr,
                                         kNameSpaceID_XHTML,
                                         ELEMENT_NODE);
 
-  RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(nodeInfo);
+  RefPtr<HTMLAudioElement> audio = new HTMLAudioElement(nodeInfo.forget());
   audio->SetHTMLAttr(nsGkAtoms::preload, NS_LITERAL_STRING("auto"), aRv);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   if (aSrc.WasPassed()) {
     audio->SetSrc(aSrc.Value(), aRv);
   }
--- a/dom/html/HTMLAudioElement.h
+++ b/dom/html/HTMLAudioElement.h
@@ -18,17 +18,17 @@ namespace dom {
 
 class HTMLAudioElement final : public HTMLMediaElement
 {
 public:
   typedef mozilla::dom::NodeInfo NodeInfo;
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLAudioElement, audio)
 
-  explicit HTMLAudioElement(already_AddRefed<NodeInfo>& aNodeInfo);
+  explicit HTMLAudioElement(already_AddRefed<NodeInfo>&& aNodeInfo);
 
   // Element
   virtual bool IsInteractiveHTMLContent(bool aIgnoreTabindex) const override;
 
   // nsIDOMHTMLMediaElement
   using HTMLMediaElement::GetPaused;
 
   virtual nsresult Clone(NodeInfo*, nsINode** aResult) const override;
--- a/dom/html/HTMLBRElement.cpp
+++ b/dom/html/HTMLBRElement.cpp
@@ -12,18 +12,18 @@
 #include "nsMappedAttributes.h"
 
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(BR)
 
 namespace mozilla {
 namespace dom {
 
-HTMLBRElement::HTMLBRElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLBRElement::HTMLBRElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLBRElement::~HTMLBRElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLBRElement)
--- a/dom/html/HTMLBRElement.h
+++ b/dom/html/HTMLBRElement.h
@@ -12,17 +12,17 @@
 #include "nsGkAtoms.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLBRElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLBRElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLBRElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsAtom* aAttribute,
                                 const nsAString& aValue,
                                 nsIPrincipal* aMaybeScriptedPrincipal,
                                 nsAttrValue& aResult) override;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
   virtual nsMapRuleToAttributesFunc GetAttributeMappingFunction() const override;
--- a/dom/html/HTMLBodyElement.h
+++ b/dom/html/HTMLBodyElement.h
@@ -17,18 +17,18 @@ namespace dom {
 
 class OnBeforeUnloadEventHandlerNonNull;
 
 class HTMLBodyElement final : public nsGenericHTMLElement
 {
 public:
   using Element::GetText;
 
-  explicit HTMLBodyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLBodyElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLBodyElement, nsGenericHTMLElement)
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLBodyElement, body);
 
--- a/dom/html/HTMLButtonElement.cpp
+++ b/dom/html/HTMLButtonElement.cpp
@@ -48,19 +48,19 @@ static const nsAttrValue::EnumTable kBut
   { nullptr, 0 }
 };
 
 // Default type is 'submit'.
 static const nsAttrValue::EnumTable* kButtonDefaultType = &kButtonTypeTable[2];
 
 
 // Construction, destruction
-HTMLButtonElement::HTMLButtonElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLButtonElement::HTMLButtonElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                      FromParser aFromParser)
-  : nsGenericHTMLFormElementWithState(aNodeInfo, kButtonDefaultType->value),
+  : nsGenericHTMLFormElementWithState(std::move(aNodeInfo), kButtonDefaultType->value),
     mDisabledChanged(false),
     mInInternalActivate(false),
     mInhibitStateRestoration(!!(aFromParser & FROM_PARSER_FRAGMENT))
 {
   // Set up our default state: enabled
   AddStatesSilently(NS_EVENT_STATE_ENABLED);
 }
 
--- a/dom/html/HTMLButtonElement.h
+++ b/dom/html/HTMLButtonElement.h
@@ -17,17 +17,17 @@ class EventChainPreVisitor;
 namespace dom {
 
 class HTMLButtonElement final : public nsGenericHTMLFormElementWithState,
                                 public nsIConstraintValidation
 {
 public:
   using nsIConstraintValidation::GetValidationMessage;
 
-  explicit HTMLButtonElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  explicit HTMLButtonElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                              FromParser aFromParser = NOT_FROM_PARSER);
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLButtonElement,
                                            nsGenericHTMLFormElementWithState)
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
--- a/dom/html/HTMLCanvasElement.cpp
+++ b/dom/html/HTMLCanvasElement.cpp
@@ -388,18 +388,18 @@ HTMLCanvasElementObserver::HandleEvent(E
 
   return NS_OK;
 }
 
 NS_IMPL_ISUPPORTS(HTMLCanvasElementObserver, nsIObserver)
 
 // ---------------------------------------------------------------------------
 
-HTMLCanvasElement::HTMLCanvasElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo),
+HTMLCanvasElement::HTMLCanvasElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo)),
     mResetLayer(true) ,
     mWriteOnly(false)
 {}
 
 HTMLCanvasElement::~HTMLCanvasElement()
 {
   if (mContextObserver) {
     mContextObserver->Destroy();
--- a/dom/html/HTMLCanvasElement.h
+++ b/dom/html/HTMLCanvasElement.h
@@ -126,17 +126,17 @@ class HTMLCanvasElement final : public n
   typedef layers::AsyncCanvasRenderer AsyncCanvasRenderer;
   typedef layers::CanvasRenderer CanvasRenderer;
   typedef layers::CanvasLayer CanvasLayer;
   typedef layers::Layer Layer;
   typedef layers::LayerManager LayerManager;
   typedef layers::WebRenderCanvasData WebRenderCanvasData;
 
 public:
-  explicit HTMLCanvasElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLCanvasElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLCanvasElement, canvas)
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // CC
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLCanvasElement,
--- a/dom/html/HTMLDataElement.cpp
+++ b/dom/html/HTMLDataElement.cpp
@@ -8,18 +8,18 @@
 #include "mozilla/dom/HTMLDataElementBinding.h"
 #include "nsGenericHTMLElement.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Data)
 
 namespace mozilla {
 namespace dom {
 
-HTMLDataElement::HTMLDataElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLDataElement::HTMLDataElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLDataElement::~HTMLDataElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLDataElement)
--- a/dom/html/HTMLDataElement.h
+++ b/dom/html/HTMLDataElement.h
@@ -12,17 +12,17 @@
 #include "nsGkAtoms.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLDataElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLDataElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLDataElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // HTMLDataElement WebIDL
   void GetValue(DOMString& aValue)
   {
     GetHTMLAttr(nsGkAtoms::value, aValue);
   }
 
   void SetValue(const nsAString& aValue, ErrorResult& aError)
--- a/dom/html/HTMLDataListElement.h
+++ b/dom/html/HTMLDataListElement.h
@@ -11,18 +11,18 @@
 #include "nsContentList.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLDataListElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLDataListElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLDataListElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   nsContentList* Options()
   {
--- a/dom/html/HTMLDetailsElement.h
+++ b/dom/html/HTMLDetailsElement.h
@@ -19,18 +19,18 @@ namespace dom {
 // controls. Please see the spec for more information.
 // https://html.spec.whatwg.org/multipage/forms.html#the-details-element
 //
 class HTMLDetailsElement final : public nsGenericHTMLElement
 {
 public:
   using NodeInfo = mozilla::dom::NodeInfo;
 
-  explicit HTMLDetailsElement(already_AddRefed<NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLDetailsElement(already_AddRefed<NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLDetailsElement, details)
 
   nsIContent* GetFirstSummary() const;
 
   nsresult Clone(NodeInfo* aNodeInfo, nsINode** aResult) const override;
--- a/dom/html/HTMLDialogElement.cpp
+++ b/dom/html/HTMLDialogElement.cpp
@@ -10,20 +10,20 @@
 #include "mozilla/Preferences.h"
 
 // Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Dialog) with pref check
 nsGenericHTMLElement*
 NS_NewHTMLDialogElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                          mozilla::dom::FromParser aFromParser)
 {
   if (!mozilla::dom::HTMLDialogElement::IsDialogEnabled()) {
-    return new mozilla::dom::HTMLUnknownElement(aNodeInfo);
+    return new mozilla::dom::HTMLUnknownElement(std::move(aNodeInfo));
   }
 
-  return new mozilla::dom::HTMLDialogElement(aNodeInfo);
+  return new mozilla::dom::HTMLDialogElement(std::move(aNodeInfo));
 }
 
 namespace mozilla {
 namespace dom {
 
 HTMLDialogElement::~HTMLDialogElement()
 {
 }
--- a/dom/html/HTMLDialogElement.h
+++ b/dom/html/HTMLDialogElement.h
@@ -13,17 +13,18 @@
 #include "nsGkAtoms.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLDialogElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLDialogElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo) : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLDialogElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLDialogElement, dialog)
 
   nsresult Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const override;
 
   static bool IsDialogEnabled();
--- a/dom/html/HTMLDivElement.h
+++ b/dom/html/HTMLDivElement.h
@@ -10,18 +10,18 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLDivElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLDivElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLDivElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   void GetAlign(DOMString& aAlign)
   {
     GetHTMLAttr(nsGkAtoms::align, aAlign);
   }
   void SetAlign(const nsAString& aAlign, mozilla::ErrorResult& aError)
--- a/dom/html/HTMLElement.cpp
+++ b/dom/html/HTMLElement.cpp
@@ -9,27 +9,27 @@
 #include "nsContentUtils.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual ~HTMLElement();
 
   nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
 protected:
   JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 };
 
-HTMLElement::HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLElement::HTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
   if (NodeInfo()->Equals(nsGkAtoms::bdi)) {
     AddStatesSilently(NS_EVENT_STATE_DIR_ATTR_LIKE_AUTO);
   }
 }
 
 HTMLElement::~HTMLElement()
 {
@@ -47,19 +47,19 @@ HTMLElement::WrapNode(JSContext *aCx, JS
 } // namespace mozilla
 
 // Here, we expand 'NS_IMPL_NS_NEW_HTML_ELEMENT()' by hand.
 // (Calling the macro directly (with no args) produces compiler warnings.)
 nsGenericHTMLElement*
 NS_NewHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                   mozilla::dom::FromParser aFromParser)
 {
-  return new mozilla::dom::HTMLElement(aNodeInfo);
+  return new mozilla::dom::HTMLElement(std::move(aNodeInfo));
 }
 
 // Distinct from the above in order to have function pointer that compared unequal
 // to a function pointer to the above.
 nsGenericHTMLElement*
 NS_NewCustomElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                     mozilla::dom::FromParser aFromParser)
 {
-  return new mozilla::dom::HTMLElement(aNodeInfo);
+  return new mozilla::dom::HTMLElement(std::move(aNodeInfo));
 }
--- a/dom/html/HTMLEmbedElement.cpp
+++ b/dom/html/HTMLEmbedElement.cpp
@@ -22,19 +22,19 @@
 #include "mozilla/dom/HTMLObjectElement.h"
 
 
 NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Embed)
 
 namespace mozilla {
 namespace dom {
 
-HTMLEmbedElement::HTMLEmbedElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLEmbedElement::HTMLEmbedElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                    FromParser aFromParser)
-  : nsGenericHTMLElement(aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
   RegisterActivityObserver();
   SetIsNetworkCreated(aFromParser == FROM_PARSER_NETWORK);
 
   // By default we're in the loading state
   AddStatesSilently(NS_EVENT_STATE_LOADING);
 }
 
--- a/dom/html/HTMLEmbedElement.h
+++ b/dom/html/HTMLEmbedElement.h
@@ -15,17 +15,17 @@
 
 namespace mozilla {
 namespace dom {
 
 class HTMLEmbedElement final : public nsGenericHTMLElement
                              , public nsObjectLoadingContent
 {
 public:
-  explicit HTMLEmbedElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  explicit HTMLEmbedElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                             mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLEmbedElement, embed)
   virtual int32_t TabIndexDefault() override;
 
 #ifdef XP_MACOSX
--- a/dom/html/HTMLFieldSetElement.cpp
+++ b/dom/html/HTMLFieldSetElement.cpp
@@ -12,18 +12,18 @@
 #include "nsContentList.h"
 #include "nsQueryObject.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(FieldSet)
 
 namespace mozilla {
 namespace dom {
 
-HTMLFieldSetElement::HTMLFieldSetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLFormElement(aNodeInfo, NS_FORM_FIELDSET)
+HTMLFieldSetElement::HTMLFieldSetElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLFormElement(std::move(aNodeInfo), NS_FORM_FIELDSET)
   , mElements(nullptr)
   , mFirstLegend(nullptr)
   , mInvalidElementsCount(0)
 {
   // <fieldset> is always barred from constraint validation.
   SetBarredFromConstraintValidation(true);
 
   // We start out enabled and valid.
--- a/dom/html/HTMLFieldSetElement.h
+++ b/dom/html/HTMLFieldSetElement.h
@@ -20,17 +20,17 @@ namespace dom {
 class HTMLFieldSetElement final : public nsGenericHTMLFormElement,
                                   public nsIConstraintValidation
 {
 public:
   using nsGenericHTMLFormElement::GetForm;
   using nsIConstraintValidation::GetValidationMessage;
   using nsIConstraintValidation::SetCustomValidity;
 
-  explicit HTMLFieldSetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLFieldSetElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLFieldSetElement, fieldset)
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIContent
   void GetEventTargetParent(EventChainPreVisitor& aVisitor) override;
--- a/dom/html/HTMLFontElement.h
+++ b/dom/html/HTMLFontElement.h
@@ -10,18 +10,18 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLFontElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLFontElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLFontElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   void GetColor(DOMString& aColor)
   {
     GetHTMLAttr(nsGkAtoms::color, aColor);
   }
   void SetColor(const nsAString& aColor, ErrorResult& aError)
--- a/dom/html/HTMLFormElement.cpp
+++ b/dom/html/HTMLFormElement.cpp
@@ -90,18 +90,18 @@ static const nsAttrValue::EnumTable kFor
   { nullptr, 0 }
 };
 // Default autocomplete value is 'on'.
 static const nsAttrValue::EnumTable* kFormDefaultAutocomplete = &kFormAutocompleteTable[0];
 
 bool HTMLFormElement::gFirstFormSubmitted = false;
 bool HTMLFormElement::gPasswordManagerInitialized = false;
 
-HTMLFormElement::HTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo),
+HTMLFormElement::HTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo)),
     mControls(new HTMLFormControlsCollection(this)),
     mSelectedRadioButtons(2),
     mRequiredRadioButtonCounts(2),
     mValueMissingRadioGroups(2),
     mPendingSubmission(nullptr),
     mSubmittingRequest(nullptr),
     mDefaultSubmitElement(nullptr),
     mFirstSubmitInElements(nullptr),
--- a/dom/html/HTMLFormElement.h
+++ b/dom/html/HTMLFormElement.h
@@ -39,17 +39,17 @@ class HTMLFormElement final : public nsG
                               public nsIForm,
                               public nsIRadioGroupContainer
 {
   friend class HTMLFormControlsCollection;
 
 public:
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLFormElement, form)
 
-  explicit HTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   enum {
     FORM_CONTROL_LIST_HASHTABLE_LENGTH = 8
   };
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
--- a/dom/html/HTMLFrameElement.cpp
+++ b/dom/html/HTMLFrameElement.cpp
@@ -7,19 +7,19 @@
 #include "mozilla/dom/HTMLFrameElement.h"
 #include "mozilla/dom/HTMLFrameElementBinding.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Frame)
 
 namespace mozilla {
 namespace dom {
 
-HTMLFrameElement::HTMLFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLFrameElement::HTMLFrameElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                    FromParser aFromParser)
-  : nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
+  : nsGenericHTMLFrameElement(std::move(aNodeInfo), aFromParser)
 {
 }
 
 HTMLFrameElement::~HTMLFrameElement()
 {
 }
 
 
--- a/dom/html/HTMLFrameElement.h
+++ b/dom/html/HTMLFrameElement.h
@@ -14,17 +14,17 @@
 namespace mozilla {
 namespace dom {
 
 class HTMLFrameElement final : public nsGenericHTMLFrameElement
 {
 public:
   using nsGenericHTMLFrameElement::SwapFrameLoaders;
 
-  explicit HTMLFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  explicit HTMLFrameElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                             FromParser aFromParser = NOT_FROM_PARSER);
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLFrameElement,
                                        nsGenericHTMLFrameElement)
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLFrameElement, frame)
 
--- a/dom/html/HTMLFrameSetElement.h
+++ b/dom/html/HTMLFrameSetElement.h
@@ -41,18 +41,18 @@ struct nsFramesetSpec {
 namespace mozilla {
 namespace dom {
 
 class OnBeforeUnloadEventHandlerNonNull;
 
 class HTMLFrameSetElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLFrameSetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo),
+  explicit HTMLFrameSetElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo)),
       mNumRows(0),
       mNumCols(0),
       mCurrentRowColHint(NS_STYLE_HINT_REFLOW)
   {
     SetHasWeirdParserInsertionMode();
   }
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLFrameSetElement, frameset)
--- a/dom/html/HTMLHRElement.cpp
+++ b/dom/html/HTMLHRElement.cpp
@@ -9,18 +9,18 @@
 
 #include "nsCSSProps.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(HR)
 
 namespace mozilla {
 namespace dom {
 
-HTMLHRElement::HTMLHRElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLHRElement::HTMLHRElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLHRElement::~HTMLHRElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLHRElement)
--- a/dom/html/HTMLHRElement.h
+++ b/dom/html/HTMLHRElement.h
@@ -13,17 +13,17 @@
 #include "nsAttrValueInlines.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLHRElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLHRElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLHRElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLHRElement, nsGenericHTMLElement)
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                               nsAtom* aAttribute,
                               const nsAString& aValue,
                               nsIPrincipal* aMaybeScriptedPrincipal,
--- a/dom/html/HTMLHeadingElement.h
+++ b/dom/html/HTMLHeadingElement.h
@@ -11,18 +11,18 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLHeadingElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLHeadingElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLHeadingElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                               nsAtom* aAttribute,
                               const nsAString& aValue,
                               nsIPrincipal* aMaybeScriptedPrincipal,
                               nsAttrValue& aResult) override;
--- a/dom/html/HTMLIFrameElement.cpp
+++ b/dom/html/HTMLIFrameElement.cpp
@@ -22,19 +22,19 @@ namespace dom {
 // static
 const DOMTokenListSupportedToken HTMLIFrameElement::sSupportedSandboxTokens[] = {
 #define SANDBOX_KEYWORD(string, atom, flags) string,
 #include "IframeSandboxKeywordList.h"
 #undef SANDBOX_KEYWORD
   nullptr
 };
 
-HTMLIFrameElement::HTMLIFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLIFrameElement::HTMLIFrameElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                      FromParser aFromParser)
-  : nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
+  : nsGenericHTMLFrameElement(std::move(aNodeInfo), aFromParser)
 {
 }
 
 HTMLIFrameElement::~HTMLIFrameElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLIFrameElement)
--- a/dom/html/HTMLIFrameElement.h
+++ b/dom/html/HTMLIFrameElement.h
@@ -12,17 +12,17 @@
 #include "nsDOMTokenList.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLIFrameElement final : public nsGenericHTMLFrameElement
 {
 public:
-  explicit HTMLIFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  explicit HTMLIFrameElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                              FromParser aFromParser = NOT_FROM_PARSER);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLIFrameElement, iframe)
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLIFrameElement,
                                        nsGenericHTMLFrameElement)
 
--- a/dom/html/HTMLImageElement.cpp
+++ b/dom/html/HTMLImageElement.cpp
@@ -112,18 +112,18 @@ private:
   nsCOMPtr<nsIDocument> mDocument;
   bool mAlwaysLoad;
 
   // True if we want to set nsIClassOfService::UrgentStart to the channel to
   // get the response ASAP for better user responsiveness.
   bool mUseUrgentStartForChannel;
 };
 
-HTMLImageElement::HTMLImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLImageElement::HTMLImageElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
   , mForm(nullptr)
   , mInDocResponsiveContent(false)
   , mCurrentDensity(1.0)
 {
   // We start out broken
   AddStatesSilently(NS_EVENT_STATE_BROKEN);
 }
 
@@ -729,22 +729,22 @@ HTMLImageElement::Image(const GlobalObje
 {
   nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
   nsIDocument* doc;
   if (!win || !(doc = win->GetExtantDoc())) {
     aError.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  already_AddRefed<mozilla::dom::NodeInfo> nodeInfo =
+  RefPtr<mozilla::dom::NodeInfo> nodeInfo =
     doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::img, nullptr,
                                         kNameSpaceID_XHTML,
                                         ELEMENT_NODE);
 
-  RefPtr<HTMLImageElement> img = new HTMLImageElement(nodeInfo);
+  RefPtr<HTMLImageElement> img = new HTMLImageElement(nodeInfo.forget());
 
   if (aWidth.WasPassed()) {
     img->SetWidth(aWidth.Value(), aError);
     if (aError.Failed()) {
       return nullptr;
     }
 
     if (aHeight.WasPassed()) {
--- a/dom/html/HTMLImageElement.h
+++ b/dom/html/HTMLImageElement.h
@@ -22,17 +22,17 @@ class ImageLoadTask;
 class ResponsiveImageSelector;
 class HTMLImageElement final : public nsGenericHTMLElement,
                                public nsImageLoadingContent
 {
   friend class HTMLSourceElement;
   friend class HTMLPictureElement;
   friend class ImageLoadTask;
 public:
-  explicit HTMLImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLImageElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   static already_AddRefed<HTMLImageElement>
     Image(const GlobalObject& aGlobal,
           const Optional<uint32_t>& aWidth,
           const Optional<uint32_t>& aHeight,
           ErrorResult& aError);
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLImageElement,
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -984,19 +984,19 @@ HTMLInputElement::Shutdown()
   delete sCachedTextEditorState;
   sCachedTextEditorState = nullptr;
 }
 
 //
 // construction, destruction
 //
 
-HTMLInputElement::HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLInputElement::HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                    FromParser aFromParser, FromClone aFromClone)
-  : nsGenericHTMLFormElementWithState(aNodeInfo, kInputDefaultType->value)
+  : nsGenericHTMLFormElementWithState(std::move(aNodeInfo), kInputDefaultType->value)
   , mAutocompleteAttrState(nsContentUtils::eAutocompleteAttrState_Unknown)
   , mAutocompleteInfoState(nsContentUtils::eAutocompleteAttrState_Unknown)
   , mDisabledChanged(false)
   , mValueChanged(false)
   , mLastValueChangeWasInteractive(false)
   , mCheckedChanged(false)
   , mChecked(false)
   , mHandlingSelectEvent(false)
@@ -1126,18 +1126,18 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHER
 
 // nsINode
 
 nsresult
 HTMLInputElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const
 {
   *aResult = nullptr;
 
-  already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
-  RefPtr<HTMLInputElement> it = new HTMLInputElement(ni, NOT_FROM_PARSER,
+  RefPtr<HTMLInputElement> it = new HTMLInputElement(do_AddRef(aNodeInfo),
+                                                     NOT_FROM_PARSER,
                                                      FromClone::yes);
 
   nsresult rv = const_cast<HTMLInputElement*>(this)->CopyInnerTo(it);
   NS_ENSURE_SUCCESS(rv, rv);
 
   switch (GetValueMode()) {
     case VALUE_MODE_VALUE:
       if (mValueChanged) {
--- a/dom/html/HTMLInputElement.h
+++ b/dom/html/HTMLInputElement.h
@@ -132,17 +132,17 @@ class HTMLInputElement final : public ns
 
 public:
   using nsIConstraintValidation::GetValidationMessage;
   using nsGenericHTMLFormElementWithState::GetForm;
   using nsGenericHTMLFormElementWithState::GetFormAction;
 
   enum class FromClone { no, yes };
 
-  HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  HTMLInputElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                    mozilla::dom::FromParser aFromParser,
                    FromClone aFromClone = FromClone::no);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLInputElement, input)
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
--- a/dom/html/HTMLLIElement.h
+++ b/dom/html/HTMLLIElement.h
@@ -12,18 +12,18 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLLIElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLLIElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLLIElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLLIElement, nsGenericHTMLElement)
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsAtom* aAttribute,
--- a/dom/html/HTMLLabelElement.h
+++ b/dom/html/HTMLLabelElement.h
@@ -15,18 +15,18 @@
 
 namespace mozilla {
 class EventChainPostVisitor;
 namespace dom {
 
 class HTMLLabelElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLLabelElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo),
+  explicit HTMLLabelElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo)),
       mHandlingEvent(false)
   {
   }
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLLabelElement, label)
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLLabelElement, nsGenericHTMLElement)
--- a/dom/html/HTMLLegendElement.h
+++ b/dom/html/HTMLLegendElement.h
@@ -12,18 +12,18 @@
 #include "mozilla/dom/HTMLFormElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLLegendElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLLegendElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLLegendElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLLegendElement, legend)
 
   using nsGenericHTMLElement::Focus;
   virtual void Focus(ErrorResult& aError) override;
 
--- a/dom/html/HTMLLinkElement.cpp
+++ b/dom/html/HTMLLinkElement.cpp
@@ -53,18 +53,18 @@ enum {
 
 ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 2);
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Link)
 
 namespace mozilla {
 namespace dom {
 
-HTMLLinkElement::HTMLLinkElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLLinkElement::HTMLLinkElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
   , Link(this)
 {
 }
 
 HTMLLinkElement::~HTMLLinkElement()
 {
 }
 
--- a/dom/html/HTMLLinkElement.h
+++ b/dom/html/HTMLLinkElement.h
@@ -17,17 +17,17 @@ class EventChainPostVisitor;
 class EventChainPreVisitor;
 namespace dom {
 
 class HTMLLinkElement final : public nsGenericHTMLElement,
                               public nsStyleLinkElement,
                               public Link
 {
 public:
-  explicit HTMLLinkElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLLinkElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // CC
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLLinkElement,
                                            nsGenericHTMLElement)
 
--- a/dom/html/HTMLMapElement.cpp
+++ b/dom/html/HTMLMapElement.cpp
@@ -11,18 +11,18 @@
 #include "nsContentList.h"
 #include "nsCOMPtr.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Map)
 
 namespace mozilla {
 namespace dom {
 
-HTMLMapElement::HTMLMapElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLMapElement::HTMLMapElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLMapElement)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLMapElement,
                                                   nsGenericHTMLElement)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAreas)
--- a/dom/html/HTMLMapElement.h
+++ b/dom/html/HTMLMapElement.h
@@ -14,17 +14,17 @@
 class nsContentList;
 
 namespace mozilla {
 namespace dom {
 
 class HTMLMapElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLMapElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLMapElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(HTMLMapElement,
                                                      nsGenericHTMLElement)
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3865,18 +3865,18 @@ private:
   // Guaranteed to be valid by HTMLMediaElement.
   HTMLMediaElement* mWeak = nullptr;
   Phase mPhase = Phase::Init;
 };
 
 NS_IMPL_ISUPPORTS(HTMLMediaElement::ShutdownObserver, nsIObserver)
 
 HTMLMediaElement::HTMLMediaElement(
-  already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
   , mWatchManager(this, OwnerDoc()->AbstractMainThreadFor(TaskCategory::Other))
   , mMainThreadEventTarget(OwnerDoc()->EventTargetFor(TaskCategory::Other))
   , mAbstractMainThread(OwnerDoc()->AbstractMainThreadFor(TaskCategory::Other))
   , mShutdownObserver(new ShutdownObserver)
   , mPlayed(new TimeRanges(ToSupports(OwnerDoc())))
   , mPaused(true, "HTMLMediaElement::mPaused")
   , mErrorSink(new ErrorSink(this))
   , mAudioChannelWrapper(new AudioChannelAgentCallback(this))
--- a/dom/html/HTMLMediaElement.h
+++ b/dom/html/HTMLMediaElement.h
@@ -117,17 +117,17 @@ public:
 
   MOZ_DECLARE_WEAKREFERENCE_TYPENAME(HTMLMediaElement)
   NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
 
   CORSMode GetCORSMode() {
     return mCORSMode;
   }
 
-  explicit HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLMediaElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   void ReportCanPlayTelemetry();
 
   /**
    * This is used when the browser is constructing a video element to play
    * a channel that we've already started loading. The src attribute and
    * <source> children are ignored.
    * @param aChannel the channel to use
--- a/dom/html/HTMLMenuElement.cpp
+++ b/dom/html/HTMLMenuElement.cpp
@@ -41,18 +41,18 @@ enum SeparatorType
 {
   ST_TRUE_INIT = -1,
   ST_FALSE = 0,
   ST_TRUE = 1
 };
 
 
 
-HTMLMenuElement::HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo), mType(MENU_TYPE_TOOLBAR)
+HTMLMenuElement::HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo)), mType(MENU_TYPE_TOOLBAR)
 {
 }
 
 HTMLMenuElement::~HTMLMenuElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLMenuElement)
--- a/dom/html/HTMLMenuElement.h
+++ b/dom/html/HTMLMenuElement.h
@@ -13,17 +13,17 @@
 class nsIMenuBuilder;
 
 namespace mozilla {
 namespace dom {
 
 class HTMLMenuElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLMenuElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMenuElement, menu)
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMenuElement, nsGenericHTMLElement)
 
   virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
                                 const nsAttrValue* aValue,
--- a/dom/html/HTMLMenuItemElement.cpp
+++ b/dom/html/HTMLMenuItemElement.cpp
@@ -152,18 +152,18 @@ protected:
   Visitor* mVisitor1;
   Visitor* mVisitor2;
   bool mContinue1;
   bool mContinue2;
 };
 
 
 HTMLMenuItemElement::HTMLMenuItemElement(
-  already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo, FromParser aFromParser)
-  : nsGenericHTMLElement(aNodeInfo),
+  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, FromParser aFromParser)
+  : nsGenericHTMLElement(std::move(aNodeInfo)),
     mType(kMenuItemDefaultType->value),
     mParserCreating(false),
     mShouldInitChecked(false),
     mCheckedDirty(false),
     mChecked(false)
 {
   mParserCreating = aFromParser;
 }
@@ -174,19 +174,18 @@ HTMLMenuItemElement::~HTMLMenuItemElemen
 
 
 //NS_IMPL_ELEMENT_CLONE(HTMLMenuItemElement)
 
 nsresult
 HTMLMenuItemElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const
 {
   *aResult = nullptr;
-  already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
   RefPtr<HTMLMenuItemElement> it =
-    new HTMLMenuItemElement(ni, NOT_FROM_PARSER);
+    new HTMLMenuItemElement(do_AddRef(aNodeInfo), NOT_FROM_PARSER);
   nsresult rv = const_cast<HTMLMenuItemElement*>(this)->CopyInnerTo(it);
   if (NS_SUCCEEDED(rv)) {
     switch (mType) {
       case CMD_TYPE_CHECKBOX:
       case CMD_TYPE_RADIO:
         if (mCheckedDirty) {
           // We no longer have our original checked state.  Set our
           // checked state on the clone.
--- a/dom/html/HTMLMenuItemElement.h
+++ b/dom/html/HTMLMenuItemElement.h
@@ -18,17 +18,17 @@ namespace dom {
 
 class Visitor;
 
 class HTMLMenuItemElement final : public nsGenericHTMLElement
 {
 public:
   using mozilla::dom::Element::GetText;
 
-  HTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  HTMLMenuItemElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                       mozilla::dom::FromParser aFromParser);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLMenuItemElement, menuitem)
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMenuItemElement,
                                        nsGenericHTMLElement)
 
--- a/dom/html/HTMLMetaElement.cpp
+++ b/dom/html/HTMLMetaElement.cpp
@@ -17,18 +17,18 @@ static mozilla::LazyLogModule gMetaEleme
 #define LOG(msg) MOZ_LOG(gMetaElementLog, mozilla::LogLevel::Debug, msg)
 #define LOG_ENABLED() MOZ_LOG_TEST(gMetaElementLog, mozilla::LogLevel::Debug)
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Meta)
 
 namespace mozilla {
 namespace dom {
 
-HTMLMetaElement::HTMLMetaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLMetaElement::HTMLMetaElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLMetaElement::~HTMLMetaElement()
 {
 }
 
 
--- a/dom/html/HTMLMetaElement.h
+++ b/dom/html/HTMLMetaElement.h
@@ -11,17 +11,17 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLMetaElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLMetaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLMetaElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLMetaElement, nsGenericHTMLElement)
 
   virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                               nsIContent* aBindingParent) override;
   virtual void UnbindFromTree(bool aDeep = true,
                               bool aNullParent = true) override;
--- a/dom/html/HTMLMeterElement.cpp
+++ b/dom/html/HTMLMeterElement.cpp
@@ -13,18 +13,18 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Meter)
 namespace mozilla {
 namespace dom {
 
 const double HTMLMeterElement::kDefaultValue =  0.0;
 const double HTMLMeterElement::kDefaultMin   =  0.0;
 const double HTMLMeterElement::kDefaultMax   =  1.0;
 
 
-HTMLMeterElement::HTMLMeterElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLMeterElement::HTMLMeterElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLMeterElement::~HTMLMeterElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLMeterElement)
--- a/dom/html/HTMLMeterElement.h
+++ b/dom/html/HTMLMeterElement.h
@@ -15,17 +15,17 @@
 #include <algorithm>
 
 namespace mozilla {
 namespace dom {
 
 class HTMLMeterElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLMeterElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLMeterElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   virtual EventStates IntrinsicState() const override;
 
   nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
                               const nsAString& aValue,
                               nsIPrincipal* aMaybeScriptedPrincipal,
--- a/dom/html/HTMLModElement.cpp
+++ b/dom/html/HTMLModElement.cpp
@@ -8,18 +8,18 @@
 #include "mozilla/dom/HTMLModElementBinding.h"
 #include "nsStyleConsts.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Mod)
 
 namespace mozilla {
 namespace dom {
 
-HTMLModElement::HTMLModElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLModElement::HTMLModElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLModElement::~HTMLModElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLModElement)
--- a/dom/html/HTMLModElement.h
+++ b/dom/html/HTMLModElement.h
@@ -12,17 +12,17 @@
 #include "nsGkAtoms.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLModElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLModElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLModElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   void GetCite(nsString& aCite)
   {
     GetHTMLURIAttr(nsGkAtoms::cite, aCite);
   }
   void SetCite(const nsAString& aCite, ErrorResult& aRv)
--- a/dom/html/HTMLObjectElement.cpp
+++ b/dom/html/HTMLObjectElement.cpp
@@ -22,19 +22,19 @@
 #include "mozilla/EventDispatcher.h"
 #include "mozilla/dom/Event.h"
 #include "nsFocusManager.h"
 #endif
 
 namespace mozilla {
 namespace dom {
 
-HTMLObjectElement::HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLObjectElement::HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                      FromParser aFromParser)
-  : nsGenericHTMLFormElement(aNodeInfo, NS_FORM_OBJECT),
+  : nsGenericHTMLFormElement(std::move(aNodeInfo), NS_FORM_OBJECT),
     mIsDoneAddingChildren(!aFromParser)
 {
   RegisterActivityObserver();
   SetIsNetworkCreated(aFromParser == FROM_PARSER_NETWORK);
 
   // <object> is always barred from constraint validation.
   SetBarredFromConstraintValidation(true);
 
--- a/dom/html/HTMLObjectElement.h
+++ b/dom/html/HTMLObjectElement.h
@@ -17,17 +17,17 @@ namespace dom {
 
 class HTMLFormSubmission;
 
 class HTMLObjectElement final : public nsGenericHTMLFormElement
                               , public nsObjectLoadingContent
                               , public nsIConstraintValidation
 {
 public:
-  explicit HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  explicit HTMLObjectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                              FromParser aFromParser = NOT_FROM_PARSER);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLObjectElement, object)
   virtual int32_t TabIndexDefault() override;
 
--- a/dom/html/HTMLOptGroupElement.cpp
+++ b/dom/html/HTMLOptGroupElement.cpp
@@ -20,18 +20,18 @@ namespace mozilla {
 namespace dom {
 
 /**
  * The implementation of &lt;optgroup&gt;
  */
 
 
 
-HTMLOptGroupElement::HTMLOptGroupElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLOptGroupElement::HTMLOptGroupElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
   // We start off enabled
   AddStatesSilently(NS_EVENT_STATE_ENABLED);
 }
 
 HTMLOptGroupElement::~HTMLOptGroupElement()
 {
 }
--- a/dom/html/HTMLOptGroupElement.h
+++ b/dom/html/HTMLOptGroupElement.h
@@ -12,17 +12,17 @@
 
 namespace mozilla {
 class EventChainPreVisitor;
 namespace dom {
 
 class HTMLOptGroupElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLOptGroupElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLOptGroupElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLOptGroupElement, optgroup)
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLOptGroupElement,
                                        nsGenericHTMLElement)
 
   // nsINode
--- a/dom/html/HTMLOptionElement.cpp
+++ b/dom/html/HTMLOptionElement.cpp
@@ -27,18 +27,18 @@
  * Implementation of &lt;option&gt;
  */
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Option)
 
 namespace mozilla {
 namespace dom {
 
-HTMLOptionElement::HTMLOptionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo),
+HTMLOptionElement::HTMLOptionElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo)),
     mSelectedChanged(false),
     mIsSelected(false),
     mIsInSetDefaultSelected(false)
 {
   // We start off enabled
   AddStatesSilently(NS_EVENT_STATE_ENABLED);
 }
 
@@ -336,22 +336,22 @@ HTMLOptionElement::Option(const GlobalOb
 {
   nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports());
   nsIDocument* doc;
   if (!win || !(doc = win->GetExtantDoc())) {
     aError.Throw(NS_ERROR_FAILURE);
     return nullptr;
   }
 
-  already_AddRefed<mozilla::dom::NodeInfo> nodeInfo =
+  RefPtr<mozilla::dom::NodeInfo> nodeInfo =
     doc->NodeInfoManager()->GetNodeInfo(nsGkAtoms::option, nullptr,
                                         kNameSpaceID_XHTML,
                                         ELEMENT_NODE);
 
-  RefPtr<HTMLOptionElement> option = new HTMLOptionElement(nodeInfo);
+  RefPtr<HTMLOptionElement> option = new HTMLOptionElement(nodeInfo.forget());
 
   if (!aText.IsEmpty()) {
     // Create a new text node and append it to the option
     RefPtr<nsTextNode> textContent =
       new nsTextNode(option->NodeInfo()->NodeInfoManager());
 
     textContent->SetText(aText, false);
 
--- a/dom/html/HTMLOptionElement.h
+++ b/dom/html/HTMLOptionElement.h
@@ -14,17 +14,17 @@
 namespace mozilla {
 namespace dom {
 
 class HTMLSelectElement;
 
 class HTMLOptionElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLOptionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLOptionElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   static already_AddRefed<HTMLOptionElement>
     Option(const GlobalObject& aGlobal,
            const nsAString& aText,
            const Optional<nsAString>& aValue,
            bool aDefaultSelected,
            bool aSelected,
            ErrorResult& aError);
--- a/dom/html/HTMLOutputElement.cpp
+++ b/dom/html/HTMLOutputElement.cpp
@@ -14,19 +14,19 @@
 #include "nsContentUtils.h"
 #include "nsDOMTokenList.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Output)
 
 namespace mozilla {
 namespace dom {
 
-HTMLOutputElement::HTMLOutputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLOutputElement::HTMLOutputElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                      FromParser aFromParser)
-  : nsGenericHTMLFormElement(aNodeInfo, NS_FORM_OUTPUT)
+  : nsGenericHTMLFormElement(std::move(aNodeInfo), NS_FORM_OUTPUT)
   , mValueModeFlag(eModeDefault)
   , mIsDoneAddingChildren(!aFromParser)
 {
   AddMutationObserver(this);
 
   // We start out valid and ui-valid (since we have no form).
   AddStatesSilently(NS_EVENT_STATE_VALID | NS_EVENT_STATE_MOZ_UI_VALID);
 }
--- a/dom/html/HTMLOutputElement.h
+++ b/dom/html/HTMLOutputElement.h
@@ -19,17 +19,17 @@ class HTMLFormSubmission;
 
 class HTMLOutputElement final : public nsGenericHTMLFormElement,
                                 public nsStubMutationObserver,
                                 public nsIConstraintValidation
 {
 public:
   using nsIConstraintValidation::GetValidationMessage;
 
-  explicit HTMLOutputElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  explicit HTMLOutputElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                              FromParser aFromParser = NOT_FROM_PARSER);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // nsIFormControl
   NS_IMETHOD Reset() override;
   NS_IMETHOD SubmitNamesValues(HTMLFormSubmission* aFormSubmission) override;
--- a/dom/html/HTMLParagraphElement.h
+++ b/dom/html/HTMLParagraphElement.h
@@ -12,18 +12,18 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLParagraphElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLParagraphElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLParagraphElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLParagraphElement,
                                        nsGenericHTMLElement)
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
--- a/dom/html/HTMLPictureElement.cpp
+++ b/dom/html/HTMLPictureElement.cpp
@@ -8,24 +8,24 @@
 #include "mozilla/dom/HTMLPictureElementBinding.h"
 #include "mozilla/dom/HTMLImageElement.h"
 
 // Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Picture) to add pref check.
 nsGenericHTMLElement*
 NS_NewHTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                          mozilla::dom::FromParser aFromParser)
 {
-  return new mozilla::dom::HTMLPictureElement(aNodeInfo);
+  return new mozilla::dom::HTMLPictureElement(std::move(aNodeInfo));
 }
 
 namespace mozilla {
 namespace dom {
 
-HTMLPictureElement::HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLPictureElement::HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLPictureElement::~HTMLPictureElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLPictureElement)
--- a/dom/html/HTMLPictureElement.h
+++ b/dom/html/HTMLPictureElement.h
@@ -11,17 +11,17 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLPictureElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLPictureElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLPictureElement, nsGenericHTMLElement)
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
   virtual void RemoveChildNode(nsIContent* aKid, bool aNotify) override;
   virtual nsresult InsertChildBefore(nsIContent* aKid, nsIContent* aBeforeThis,
                                      bool aNotify) override;
--- a/dom/html/HTMLPreElement.h
+++ b/dom/html/HTMLPreElement.h
@@ -12,18 +12,18 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLPreElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLPreElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLPreElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLPreElement, nsGenericHTMLElement)
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsAtom* aAttribute,
--- a/dom/html/HTMLProgressElement.cpp
+++ b/dom/html/HTMLProgressElement.cpp
@@ -13,18 +13,18 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Progress)
 namespace mozilla {
 namespace dom {
 
 const double HTMLProgressElement::kIndeterminatePosition = -1.0;
 const double HTMLProgressElement::kDefaultValue          =  0.0;
 const double HTMLProgressElement::kDefaultMax            =  1.0;
 
 
-HTMLProgressElement::HTMLProgressElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLProgressElement::HTMLProgressElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
   // We start out indeterminate
   AddStatesSilently(NS_EVENT_STATE_INDETERMINATE);
 }
 
 HTMLProgressElement::~HTMLProgressElement()
 {
 }
--- a/dom/html/HTMLProgressElement.h
+++ b/dom/html/HTMLProgressElement.h
@@ -14,17 +14,17 @@
 #include <algorithm>
 
 namespace mozilla {
 namespace dom {
 
 class HTMLProgressElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLProgressElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLProgressElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   EventStates IntrinsicState() const override;
 
   nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,
                               const nsAString& aValue,
                               nsIPrincipal* aMaybeScriptedPrincipal,
--- a/dom/html/HTMLScriptElement.cpp
+++ b/dom/html/HTMLScriptElement.cpp
@@ -30,19 +30,19 @@ namespace mozilla {
 namespace dom {
 
 JSObject*
 HTMLScriptElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return HTMLScriptElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
-HTMLScriptElement::HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLScriptElement::HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                      FromParser aFromParser)
-  : nsGenericHTMLElement(aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
   , ScriptElement(aFromParser)
 {
   AddMutationObserver(this);
 }
 
 HTMLScriptElement::~HTMLScriptElement()
 {
 }
@@ -90,18 +90,18 @@ HTMLScriptElement::ParseAttribute(int32_
                                               aMaybeScriptedPrincipal, aResult);
 }
 
 nsresult
 HTMLScriptElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const
 {
   *aResult = nullptr;
 
-  already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
-  HTMLScriptElement* it = new HTMLScriptElement(ni, NOT_FROM_PARSER);
+  HTMLScriptElement* it = new HTMLScriptElement(do_AddRef(aNodeInfo),
+                                                NOT_FROM_PARSER);
 
   nsCOMPtr<nsINode> kungFuDeathGrip = it;
   nsresult rv = const_cast<HTMLScriptElement*>(this)->CopyInnerTo(it);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // The clone should be marked evaluated if we are.
   it->mAlreadyStarted = mAlreadyStarted;
   it->mLineNumber = mLineNumber;
--- a/dom/html/HTMLScriptElement.h
+++ b/dom/html/HTMLScriptElement.h
@@ -15,17 +15,17 @@ namespace mozilla {
 namespace dom {
 
 class HTMLScriptElement final : public nsGenericHTMLElement,
                                 public ScriptElement
 {
 public:
   using Element::GetText;
 
-  HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  HTMLScriptElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                     FromParser aFromParser);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   void GetInnerHTML(nsAString& aInnerHTML, OOMReporter& aError) override;
   virtual void SetInnerHTML(const nsAString& aInnerHTML,
                             nsIPrincipal* aSubjectPrincipal,
--- a/dom/html/HTMLSelectElement.cpp
+++ b/dom/html/HTMLSelectElement.cpp
@@ -108,19 +108,19 @@ SafeOptionListMutation::~SafeOptionListM
 //----------------------------------------------------------------------
 //
 // HTMLSelectElement
 //
 
 // construction, destruction
 
 
-HTMLSelectElement::HTMLSelectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLSelectElement::HTMLSelectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                      FromParser aFromParser)
-  : nsGenericHTMLFormElementWithState(aNodeInfo, NS_FORM_SELECT),
+  : nsGenericHTMLFormElementWithState(std::move(aNodeInfo), NS_FORM_SELECT),
     mOptions(new HTMLOptionsCollection(this)),
     mAutocompleteAttrState(nsContentUtils::eAutocompleteAttrState_Unknown),
     mAutocompleteInfoState(nsContentUtils::eAutocompleteAttrState_Unknown),
     mIsDoneAddingChildren(!aFromParser),
     mDisabledChanged(false),
     mMutating(false),
     mInhibitStateRestoration(!!(aFromParser & FROM_PARSER_FRAGMENT)),
     mSelectionHasChanged(false),
--- a/dom/html/HTMLSelectElement.h
+++ b/dom/html/HTMLSelectElement.h
@@ -97,17 +97,17 @@ public:
     CLEAR_ALL     = 1 << 1,
     SET_DISABLED  = 1 << 2,
     NOTIFY        = 1 << 3,
     NO_RESELECT   = 1 << 4
   };
 
   using nsIConstraintValidation::GetValidationMessage;
 
-  explicit HTMLSelectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  explicit HTMLSelectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                              FromParser aFromParser = NOT_FROM_PARSER);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLSelectElement, select)
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual int32_t TabIndexDefault() override;
--- a/dom/html/HTMLSharedElement.h
+++ b/dom/html/HTMLSharedElement.h
@@ -15,18 +15,18 @@
 #include "mozilla/Assertions.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLSharedElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLSharedElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLSharedElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
     if (mNodeInfo->Equals(nsGkAtoms::head) ||
         mNodeInfo->Equals(nsGkAtoms::html)) {
       SetHasWeirdParserInsertionMode();
     }
   }
 
   // nsIContent
--- a/dom/html/HTMLSharedListElement.h
+++ b/dom/html/HTMLSharedListElement.h
@@ -12,18 +12,18 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLSharedListElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLSharedListElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLSharedListElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual bool ParseAttribute(int32_t aNamespaceID,
                                 nsAtom* aAttribute,
--- a/dom/html/HTMLSlotElement.cpp
+++ b/dom/html/HTMLSlotElement.cpp
@@ -11,31 +11,29 @@
 #include "mozilla/dom/ShadowRoot.h"
 #include "nsGkAtoms.h"
 #include "nsDocument.h"
 
 nsGenericHTMLElement*
 NS_NewHTMLSlotElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                       mozilla::dom::FromParser aFromParser)
 {
-  RefPtr<mozilla::dom::NodeInfo> nodeInfo(aNodeInfo);
+  RefPtr<mozilla::dom::NodeInfo> nodeInfo(std::move(aNodeInfo));
   if (nsDocument::IsShadowDOMEnabled(nodeInfo->GetDocument())) {
-    already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
-    return new mozilla::dom::HTMLSlotElement(nodeInfoArg);
+    return new mozilla::dom::HTMLSlotElement(nodeInfo.forget());
   }
 
-  already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
-  return new mozilla::dom::HTMLUnknownElement(nodeInfoArg);
+  return new mozilla::dom::HTMLUnknownElement(nodeInfo.forget());
 }
 
 namespace mozilla {
 namespace dom {
 
-HTMLSlotElement::HTMLSlotElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLSlotElement::HTMLSlotElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLSlotElement::~HTMLSlotElement() = default;
 
 NS_IMPL_ADDREF_INHERITED(HTMLSlotElement, nsGenericHTMLElement)
 NS_IMPL_RELEASE_INHERITED(HTMLSlotElement, nsGenericHTMLElement)
 
--- a/dom/html/HTMLSlotElement.h
+++ b/dom/html/HTMLSlotElement.h
@@ -13,17 +13,17 @@
 namespace mozilla {
 namespace dom {
 
 struct AssignedNodesOptions;
 
 class HTMLSlotElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLSlotElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLSlotElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLSlotElement, slot)
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLSlotElement, nsGenericHTMLElement)
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   // nsIContent
   virtual nsresult BindToTree(nsIDocument* aDocument,
--- a/dom/html/HTMLSourceElement.cpp
+++ b/dom/html/HTMLSourceElement.cpp
@@ -18,18 +18,18 @@
 #include "mozilla/dom/BlobURLProtocolHandler.h"
 #include "mozilla/Preferences.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Source)
 
 namespace mozilla {
 namespace dom {
 
-HTMLSourceElement::HTMLSourceElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLSourceElement::HTMLSourceElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLSourceElement::~HTMLSourceElement()
 {
 }
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(HTMLSourceElement, nsGenericHTMLElement,
--- a/dom/html/HTMLSourceElement.h
+++ b/dom/html/HTMLSourceElement.h
@@ -16,17 +16,17 @@ class nsAttrValue;
 namespace mozilla {
 namespace dom {
 
 class MediaList;
 
 class HTMLSourceElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLSourceElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLSourceElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLSourceElement,
                                            nsGenericHTMLElement)
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLSourceElement, source)
 
--- a/dom/html/HTMLSpanElement.h
+++ b/dom/html/HTMLSpanElement.h
@@ -14,18 +14,18 @@
 #include "nsAtom.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLSpanElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLSpanElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLSpanElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
 protected:
   virtual ~HTMLSpanElement();
 
--- a/dom/html/HTMLStyleElement.cpp
+++ b/dom/html/HTMLStyleElement.cpp
@@ -13,18 +13,18 @@
 #include "nsContentUtils.h"
 #include "nsStubMutationObserver.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Style)
 
 namespace mozilla {
 namespace dom {
 
-HTMLStyleElement::HTMLStyleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLStyleElement::HTMLStyleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
   AddMutationObserver(this);
 }
 
 HTMLStyleElement::~HTMLStyleElement()
 {
 }
 
--- a/dom/html/HTMLStyleElement.h
+++ b/dom/html/HTMLStyleElement.h
@@ -17,17 +17,17 @@ class nsIDocument;
 namespace mozilla {
 namespace dom {
 
 class HTMLStyleElement final : public nsGenericHTMLElement,
                                public nsStyleLinkElement,
                                public nsStubMutationObserver
 {
 public:
-  explicit HTMLStyleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLStyleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   // CC
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLStyleElement,
                                            nsGenericHTMLElement)
 
--- a/dom/html/HTMLSummaryElement.h
+++ b/dom/html/HTMLSummaryElement.h
@@ -18,18 +18,18 @@ class HTMLDetailsElement;
 // or legend of the <details> tag. Please see the spec for more information.
 // https://html.spec.whatwg.org/multipage/forms.html#the-details-element
 //
 class HTMLSummaryElement final : public nsGenericHTMLElement
 {
 public:
   using NodeInfo = mozilla::dom::NodeInfo;
 
-  explicit HTMLSummaryElement(already_AddRefed<NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLSummaryElement(already_AddRefed<NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLSummaryElement, summary)
 
   nsresult Clone(NodeInfo*, nsINode** aResult) const override;
 
   nsresult PostHandleEvent(EventChainPostVisitor& aVisitor) override;
--- a/dom/html/HTMLTableCaptionElement.h
+++ b/dom/html/HTMLTableCaptionElement.h
@@ -10,18 +10,18 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLTableCaptionElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLTableCaptionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLTableCaptionElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
     SetHasWeirdParserInsertionMode();
   }
 
   void GetAlign(DOMString& aAlign)
   {
     GetHTMLAttr(nsGkAtoms::align, aAlign);
   }
--- a/dom/html/HTMLTableCellElement.h
+++ b/dom/html/HTMLTableCellElement.h
@@ -12,18 +12,18 @@
 namespace mozilla {
 namespace dom {
 
 class HTMLTableElement;
 
 class HTMLTableCellElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLTableCellElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLTableCellElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
     SetHasWeirdParserInsertionMode();
   }
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(HTMLTableCellElement,
                                        nsGenericHTMLElement)
 
--- a/dom/html/HTMLTableColElement.h
+++ b/dom/html/HTMLTableColElement.h
@@ -10,18 +10,18 @@
 #include "nsGenericHTMLElement.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLTableColElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLTableColElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLTableColElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
     SetHasWeirdParserInsertionMode();
   }
 
   uint32_t Span() const
   {
     return GetIntAttr(nsGkAtoms::span, 1);
   }
--- a/dom/html/HTMLTableElement.cpp
+++ b/dom/html/HTMLTableElement.cpp
@@ -534,18 +534,18 @@ TableRowsCollection::NodeWillBeDestroyed
   // observer, as we're going away. CleanUp() will reset mInitialized to true as
   // it returns.
   mInitialized = false;
   CleanUp();
 }
 
 /* --------------------------- HTMLTableElement ---------------------------- */
 
-HTMLTableElement::HTMLTableElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo),
+HTMLTableElement::HTMLTableElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo)),
     mTableInheritedAttributes(nullptr)
 {
   SetHasWeirdParserInsertionMode();
 }
 
 HTMLTableElement::~HTMLTableElement()
 {
   if (mRows) {
--- a/dom/html/HTMLTableElement.h
+++ b/dom/html/HTMLTableElement.h
@@ -14,17 +14,17 @@
 namespace mozilla {
 namespace dom {
 
 class TableRowsCollection;
 
 class HTMLTableElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLTableElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLTableElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLTableElement, table)
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   HTMLTableCaptionElement* GetCaption() const
   {
--- a/dom/html/HTMLTableRowElement.h
+++ b/dom/html/HTMLTableRowElement.h
@@ -14,18 +14,18 @@ class nsContentList;
 namespace mozilla {
 namespace dom {
 
 class HTMLTableSectionElement;
 
 class HTMLTableRowElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLTableRowElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLTableRowElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
     SetHasWeirdParserInsertionMode();
   }
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLTableRowElement, tr)
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
--- a/dom/html/HTMLTableSectionElement.h
+++ b/dom/html/HTMLTableSectionElement.h
@@ -11,18 +11,18 @@
 #include "nsContentList.h" // For ctor.
 
 namespace mozilla {
 namespace dom {
 
 class HTMLTableSectionElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLTableSectionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLTableSectionElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
     SetHasWeirdParserInsertionMode();
   }
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   nsIHTMLCollection* Rows();
--- a/dom/html/HTMLTemplateElement.cpp
+++ b/dom/html/HTMLTemplateElement.cpp
@@ -12,18 +12,18 @@
 #include "nsStyleConsts.h"
 #include "nsAtom.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Template)
 
 namespace mozilla {
 namespace dom {
 
-HTMLTemplateElement::HTMLTemplateElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLTemplateElement::HTMLTemplateElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
   SetHasWeirdParserInsertionMode();
 
   nsIDocument* contentsOwner = OwnerDoc()->GetTemplateContentsOwner();
   if (!contentsOwner) {
     MOZ_CRASH("There should always be a template contents owner.");
   }
 
--- a/dom/html/HTMLTemplateElement.h
+++ b/dom/html/HTMLTemplateElement.h
@@ -12,17 +12,17 @@
 #include "mozilla/dom/DocumentFragment.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLTemplateElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLTemplateElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLTemplateElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTemplateElement,
                                            nsGenericHTMLElement)
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
--- a/dom/html/HTMLTextAreaElement.cpp
+++ b/dom/html/HTMLTextAreaElement.cpp
@@ -45,19 +45,19 @@
 
 #define NS_NO_CONTENT_DISPATCH (1 << 0)
 
 NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(TextArea)
 
 namespace mozilla {
 namespace dom {
 
-HTMLTextAreaElement::HTMLTextAreaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+HTMLTextAreaElement::HTMLTextAreaElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                          FromParser aFromParser)
-  : nsGenericHTMLFormElementWithState(aNodeInfo, NS_FORM_TEXTAREA),
+  : nsGenericHTMLFormElementWithState(std::move(aNodeInfo), NS_FORM_TEXTAREA),
     mValueChanged(false),
     mLastValueChangeWasInteractive(false),
     mHandlingSelect(false),
     mDoneAddingChildren(!aFromParser),
     mInhibitStateRestoration(!!(aFromParser & FROM_PARSER_FRAGMENT)),
     mDisabledChanged(false),
     mCanShowInvalidUI(true),
     mCanShowValidUI(true),
@@ -91,19 +91,18 @@ NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHER
                                              nsIConstraintValidation)
 
 // nsIDOMHTMLTextAreaElement
 
 nsresult
 HTMLTextAreaElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const
 {
   *aResult = nullptr;
-  already_AddRefed<mozilla::dom::NodeInfo> ni =
-    RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
-  RefPtr<HTMLTextAreaElement> it = new HTMLTextAreaElement(ni);
+  RefPtr<HTMLTextAreaElement> it =
+    new HTMLTextAreaElement(do_AddRef(aNodeInfo));
 
   nsresult rv = const_cast<HTMLTextAreaElement*>(this)->CopyInnerTo(it);
   NS_ENSURE_SUCCESS(rv, rv);
 
   if (mValueChanged) {
     // Set our value on the clone.
     nsAutoString value;
     GetValueInternal(value, true);
--- a/dom/html/HTMLTextAreaElement.h
+++ b/dom/html/HTMLTextAreaElement.h
@@ -39,17 +39,17 @@ class HTMLFormSubmission;
 class HTMLTextAreaElement final : public nsGenericHTMLFormElementWithState,
                                   public nsITextControlElement,
                                   public nsStubMutationObserver,
                                   public nsIConstraintValidation
 {
 public:
   using nsIConstraintValidation::GetValidationMessage;
 
-  explicit HTMLTextAreaElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  explicit HTMLTextAreaElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                FromParser aFromParser = NOT_FROM_PARSER);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLTextAreaElement, textarea)
 
   virtual int32_t TabIndexDefault() override;
--- a/dom/html/HTMLTimeElement.cpp
+++ b/dom/html/HTMLTimeElement.cpp
@@ -10,18 +10,18 @@
 #include "nsVariant.h"
 #include "nsGkAtoms.h"
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Time)
 
 namespace mozilla {
 namespace dom {
 
-HTMLTimeElement::HTMLTimeElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLTimeElement::HTMLTimeElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
 }
 
 HTMLTimeElement::~HTMLTimeElement()
 {
 }
 
 NS_IMPL_ELEMENT_CLONE(HTMLTimeElement)
--- a/dom/html/HTMLTimeElement.h
+++ b/dom/html/HTMLTimeElement.h
@@ -12,17 +12,17 @@
 #include "nsGkAtoms.h"
 
 namespace mozilla {
 namespace dom {
 
 class HTMLTimeElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLTimeElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLTimeElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual ~HTMLTimeElement();
 
   // HTMLTimeElement WebIDL
   void GetDateTime(DOMString& aDateTime)
   {
     GetHTMLAttr(nsGkAtoms::datetime, aDateTime);
   }
 
--- a/dom/html/HTMLTitleElement.cpp
+++ b/dom/html/HTMLTitleElement.cpp
@@ -13,18 +13,18 @@
 #include "nsContentUtils.h"
 
 
 NS_IMPL_NS_NEW_HTML_ELEMENT(Title)
 
 namespace mozilla {
 namespace dom {
 
-HTMLTitleElement::HTMLTitleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLTitleElement::HTMLTitleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
 {
   AddMutationObserver(this);
 }
 
 HTMLTitleElement::~HTMLTitleElement()
 {
 }
 
--- a/dom/html/HTMLTitleElement.h
+++ b/dom/html/HTMLTitleElement.h
@@ -17,17 +17,17 @@ class ErrorResult;
 namespace dom {
 
 class HTMLTitleElement final : public nsGenericHTMLElement,
                                public nsStubMutationObserver
 {
 public:
   using Element::GetText;
 
-  explicit HTMLTitleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLTitleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
 
   //HTMLTitleElement
   void GetText(DOMString& aText, ErrorResult& aError);
   void SetText(const nsAString& aText, ErrorResult& aError);
 
--- a/dom/html/HTMLTrackElement.cpp
+++ b/dom/html/HTMLTrackElement.cpp
@@ -42,17 +42,17 @@ static mozilla::LazyLogModule gTrackElem
 #define LOG(type, msg) MOZ_LOG(gTrackElementLog, type, msg)
 
 // Replace the usual NS_IMPL_NS_NEW_HTML_ELEMENT(Track) so
 // we can return an UnknownElement instead when pref'd off.
 nsGenericHTMLElement*
 NS_NewHTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                        mozilla::dom::FromParser aFromParser)
 {
-  return new mozilla::dom::HTMLTrackElement(aNodeInfo);
+  return new mozilla::dom::HTMLTrackElement(std::move(aNodeInfo));
 }
 
 namespace mozilla {
 namespace dom {
 
 // Map html attribute string values to TextTrackKind enums.
 static constexpr nsAttrValue::EnumTable kKindTable[] = {
   { "subtitles", static_cast<int16_t>(TextTrackKind::Subtitles) },
@@ -115,18 +115,18 @@ public:
 private:
   ~WindowDestroyObserver() {};
   HTMLTrackElement* mTrackElement;
   uint64_t mInnerID;
 };
 NS_IMPL_ISUPPORTS(WindowDestroyObserver, nsIObserver);
 
 /** HTMLTrackElement */
-HTMLTrackElement::HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsGenericHTMLElement(aNodeInfo)
+HTMLTrackElement::HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
   , mLoadResourceDispatched(false)
   , mWindowDestroyObserver(nullptr)
 {
   nsISupports* parentObject = OwnerDoc()->GetParentObject();
   NS_ENSURE_TRUE_VOID(parentObject);
   nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(parentObject);
   if (window) {
     mWindowDestroyObserver = new WindowDestroyObserver(this, window->WindowID());
--- a/dom/html/HTMLTrackElement.h
+++ b/dom/html/HTMLTrackElement.h
@@ -22,17 +22,17 @@ namespace mozilla {
 namespace dom {
 
 class WebVTTListener;
 class WindowDestroyObserver;
 
 class HTMLTrackElement final : public nsGenericHTMLElement
 {
 public:
-  explicit HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit HTMLTrackElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   // nsISupports
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTrackElement,
                                            nsGenericHTMLElement)
 
   // HTMLTrackElement WebIDL
   void GetKind(DOMString& aKind) const;
--- a/dom/html/HTMLUnknownElement.h
+++ b/dom/html/HTMLUnknownElement.h
@@ -19,18 +19,18 @@ namespace dom {
 
 class HTMLUnknownElement final : public nsGenericHTMLElement
 {
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_HTMLUNKNOWNELEMENT_IID)
 
   NS_DECL_ISUPPORTS_INHERITED
 
-  explicit HTMLUnknownElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElement(aNodeInfo)
+  explicit HTMLUnknownElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
   {
   }
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
 protected:
   virtual ~HTMLUnknownElement() {}
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
--- a/dom/html/HTMLVideoElement.cpp
+++ b/dom/html/HTMLVideoElement.cpp
@@ -39,18 +39,18 @@ NS_IMPL_NS_NEW_HTML_ELEMENT(Video)
 
 namespace mozilla {
 namespace dom {
 
 static bool sVideoStatsEnabled;
 
 NS_IMPL_ELEMENT_CLONE(HTMLVideoElement)
 
-HTMLVideoElement::HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo)
-  : HTMLMediaElement(aNodeInfo)
+HTMLVideoElement::HTMLVideoElement(already_AddRefed<NodeInfo>&& aNodeInfo)
+  : HTMLMediaElement(std::move(aNodeInfo))
   , mIsOrientationLocked(false)
 {
   DecoderDoctorLogger::LogConstruction(this);
 }
 
 HTMLVideoElement::~HTMLVideoElement()
 {
   DecoderDoctorLogger::LogDestruction(this);
--- a/dom/html/HTMLVideoElement.h
+++ b/dom/html/HTMLVideoElement.h
@@ -20,17 +20,17 @@ namespace dom {
 class WakeLock;
 class VideoPlaybackQuality;
 
 class HTMLVideoElement final : public HTMLMediaElement
 {
 public:
   typedef mozilla::dom::NodeInfo NodeInfo;
 
-  explicit HTMLVideoElement(already_AddRefed<NodeInfo>& aNodeInfo);
+  explicit HTMLVideoElement(already_AddRefed<NodeInfo>&& aNodeInfo);
 
   NS_IMPL_FROMNODE_HTML_WITH_TAG(HTMLVideoElement, video)
 
   using HTMLMediaElement::GetPaused;
 
   virtual bool IsVideo() const override {
     return true;
   }
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -1615,19 +1615,19 @@ nsGenericHTMLElement::IsInteractiveHTMLC
 bool
 nsGenericHTMLElement::TouchEventsEnabled(JSContext* aCx, JSObject* aGlobal)
 {
   return TouchEvent::PrefEnabled(aCx, aGlobal);
 }
 
 //----------------------------------------------------------------------
 
-nsGenericHTMLFormElement::nsGenericHTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+nsGenericHTMLFormElement::nsGenericHTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                                    uint8_t aType)
-  : nsGenericHTMLElement(aNodeInfo)
+  : nsGenericHTMLElement(std::move(aNodeInfo))
   , nsIFormControl(aType)
   , mForm(nullptr)
   , mFieldSet(nullptr)
 {
   // We should add the NS_EVENT_STATE_ENABLED bit here as needed, but
   // that depends on our type, which is not initialized yet.  So we
   // have to do this in subclasses.
 }
@@ -2695,19 +2695,19 @@ nsGenericHTMLElement::ChangeEditableStat
   nsAutoScriptBlocker scriptBlocker;
   MakeContentDescendantsEditable(this, document);
 }
 
 
 //----------------------------------------------------------------------
 
 nsGenericHTMLFormElementWithState::nsGenericHTMLFormElementWithState(
-    already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo, uint8_t aType
+    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, uint8_t aType
   )
-  : nsGenericHTMLFormElement(aNodeInfo, aType)
+  : nsGenericHTMLFormElement(std::move(aNodeInfo), aType)
 {
   mStateKey.SetIsVoid(true);
 }
 
 nsresult
 nsGenericHTMLFormElementWithState::GenerateStateKey()
 {
   // Keep the key if already computed
@@ -3002,20 +3002,20 @@ nsGenericHTMLElement::SetInnerText(const
           new nsTextNode(NodeInfo()->NodeInfoManager());
         textContent->SetText(str, true);
         AppendChildTo(textContent, true);
       }
       if (s == end) {
         break;
       }
       str.Truncate();
-      already_AddRefed<mozilla::dom::NodeInfo> ni =
+      RefPtr<mozilla::dom::NodeInfo> ni =
         NodeInfo()->NodeInfoManager()->GetNodeInfo(nsGkAtoms::br,
           nullptr, kNameSpaceID_XHTML, ELEMENT_NODE);
-      RefPtr<HTMLBRElement> br = new HTMLBRElement(ni);
+      RefPtr<HTMLBRElement> br = new HTMLBRElement(ni.forget());
       AppendChildTo(br, true);
     } else {
       str.Append(*s);
     }
     ++s;
   }
 
   mb.NodesAdded();
--- a/dom/html/nsGenericHTMLElement.h
+++ b/dom/html/nsGenericHTMLElement.h
@@ -45,18 +45,18 @@ typedef nsMappedAttributeElement nsGener
 /**
  * A common superclass for HTML elements
  */
 class nsGenericHTMLElement : public nsGenericHTMLElementBase
 {
 public:
   using Element::SetTabIndex;
   using Element::Focus;
-  explicit nsGenericHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsGenericHTMLElementBase(aNodeInfo)
+  explicit nsGenericHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsGenericHTMLElementBase(std::move(aNodeInfo))
   {
     NS_ASSERTION(mNodeInfo->NamespaceID() == kNameSpaceID_XHTML,
                  "Unexpected namespace");
     AddStatesSilently(NS_EVENT_STATE_LTR);
     SetFlags(NODE_HAS_DIRECTION_LTR);
   }
 
   NS_INLINE_DECL_REFCOUNTING_INHERITED(nsGenericHTMLElement,
@@ -971,17 +971,17 @@ ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPE
 
 /**
  * A helper class for form elements that can contain children
  */
 class nsGenericHTMLFormElement : public nsGenericHTMLElement,
                                  public nsIFormControl
 {
 public:
-  nsGenericHTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  nsGenericHTMLFormElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                            uint8_t aType);
 
   NS_DECL_ISUPPORTS_INHERITED
 
   nsINode* GetScopeChainParent() const override;
 
   virtual bool IsNodeOfType(uint32_t aFlags) const override;
   virtual void SaveSubtreeState() override;
@@ -1154,17 +1154,17 @@ protected:
 
   /* This is a pointer to our closest fieldset parent if any */
   mozilla::dom::HTMLFieldSetElement* mFieldSet;
 };
 
 class nsGenericHTMLFormElementWithState : public nsGenericHTMLFormElement
 {
 public:
-  nsGenericHTMLFormElementWithState(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  nsGenericHTMLFormElementWithState(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                     uint8_t aType);
 
   /**
    * Get the presentation state for a piece of content, or create it if it does
    * not exist.  Generally used by SaveState().
    */
   mozilla::PresState* GetPrimaryPresState();
 
@@ -1241,25 +1241,25 @@ NS_NewHTML##_elementName##Element(alread
 /**
  * A macro to implement the NS_NewHTMLXXXElement() functions.
  */
 #define NS_IMPL_NS_NEW_HTML_ELEMENT(_elementName)                            \
 nsGenericHTMLElement*                                                        \
 NS_NewHTML##_elementName##Element(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, \
                                   mozilla::dom::FromParser aFromParser)      \
 {                                                                            \
-  return new mozilla::dom::HTML##_elementName##Element(aNodeInfo);           \
+  return new mozilla::dom::HTML##_elementName##Element(std::move(aNodeInfo)); \
 }
 
 #define NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(_elementName)               \
 nsGenericHTMLElement*                                                        \
 NS_NewHTML##_elementName##Element(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo, \
                                   mozilla::dom::FromParser aFromParser)      \
 {                                                                            \
-  return new mozilla::dom::HTML##_elementName##Element(aNodeInfo,            \
+  return new mozilla::dom::HTML##_elementName##Element(std::move(aNodeInfo), \
                                                        aFromParser);         \
 }
 
 // Here, we expand 'NS_DECLARE_NS_NEW_HTML_ELEMENT()' by hand.
 // (Calling the macro directly (with no args) produces compiler warnings.)
 nsGenericHTMLElement*
 NS_NewHTMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                   mozilla::dom::FromParser aFromParser = mozilla::dom::NOT_FROM_PARSER);
--- a/dom/html/nsGenericHTMLFrameElement.h
+++ b/dom/html/nsGenericHTMLFrameElement.h
@@ -31,19 +31,19 @@ class XULFrameElement;
  * A helper class for frame elements
  */
 class nsGenericHTMLFrameElement : public nsGenericHTMLElement,
                                   public nsIFrameLoaderOwner,
                                   public mozilla::nsBrowserElement,
                                   public nsIMozBrowserFrame
 {
 public:
-  nsGenericHTMLFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  nsGenericHTMLFrameElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                             mozilla::dom::FromParser aFromParser)
-    : nsGenericHTMLElement(aNodeInfo)
+    : nsGenericHTMLElement(std::move(aNodeInfo))
     , nsBrowserElement()
     , mSrcLoadHappened(false)
     , mNetworkCreated(aFromParser == mozilla::dom::FROM_PARSER_NETWORK)
     , mBrowserFrameListenersRegistered(false)
     , mFrameLoaderCreationDisallowed(false)
     , mReallyIsBrowser(false)
   {
   }
--- a/dom/indexedDB/test/test_third_party.html
+++ b/dom/indexedDB/test/test_third_party.html
@@ -57,22 +57,17 @@
     function setiframe() {
       let iframe = document.getElementById("iframe1");
 
       if (!testRunning) {
         testRunning = true;
         iframe.addEventListener("load", iframeLoaded);
       }
       SpecialPowers.pushPrefEnv({
-        "set": [
-          ["browser.contentblocking.enabled", true],
-          ["browser.contentblocking.ui.enabled", true],
-          ["browser.contentblocking.rejecttrackers.ui.enabled", true],
-          ["network.cookie.cookieBehavior", testData[testIndex].cookieBehavior],
-        ]
+        "set": [["network.cookie.cookieBehavior", testData[testIndex].cookieBehavior]]
       }, () => {
         iframe.src = testData[testIndex].host + iframe1Path;
       });
       // SpecialPowers.setIntPref("network.cookie.cookieBehavior", testData[testIndex].cookieBehavior);
     }
 
     function messageListener(event) {
       // eslint-disable-next-line no-eval
--- a/dom/mathml/nsMathMLElement.cpp
+++ b/dom/mathml/nsMathMLElement.cpp
@@ -72,24 +72,24 @@ ReportParseErrorNoTag(const nsString& aV
   return nsContentUtils::
          ReportToConsole(nsIScriptError::errorFlag,
                          NS_LITERAL_CSTRING("MathML"), aDocument,
                          nsContentUtils::eMATHML_PROPERTIES,
                          "AttributeParsingErrorNoTag", argv, 2);
 }
 
 nsMathMLElement::nsMathMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-: nsMathMLElementBase(aNodeInfo),
+: nsMathMLElementBase(std::move(aNodeInfo)),
   ALLOW_THIS_IN_INITIALIZER_LIST(Link(this)),
   mIncrementScriptLevel(false)
 {
 }
 
 nsMathMLElement::nsMathMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
-: nsMathMLElementBase(aNodeInfo),
+ : nsMathMLElementBase(std::move(aNodeInfo)),
   ALLOW_THIS_IN_INITIALIZER_LIST(Link(this)),
   mIncrementScriptLevel(false)
 {
 }
 
 nsresult
 nsMathMLElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                             nsIContent* aBindingParent)
--- a/dom/media/webaudio/PannerNode.cpp
+++ b/dom/media/webaudio/PannerNode.cpp
@@ -99,19 +99,19 @@ public:
 
   void CreateHRTFPanner()
   {
     MOZ_ASSERT(NS_IsMainThread());
     if (mHRTFPanner) {
       return;
     }
     // HRTFDatabaseLoader needs to be fetched on the main thread.
-    already_AddRefed<HRTFDatabaseLoader> loader =
+    RefPtr<HRTFDatabaseLoader> loader =
       HRTFDatabaseLoader::createAndLoadAsynchronouslyIfNecessary(NodeMainThread()->Context()->SampleRate());
-    mHRTFPanner = new HRTFPanner(NodeMainThread()->Context()->SampleRate(), std::move(loader));
+    mHRTFPanner = new HRTFPanner(NodeMainThread()->Context()->SampleRate(), loader.forget());
   }
 
   void SetInt32Parameter(uint32_t aIndex, int32_t aParam) override
   {
     switch (aIndex) {
     case PannerNode::PANNING_MODEL:
       switch (PanningModelType(aParam)) {
         case PanningModelType::Equalpower:
--- a/dom/serviceworkers/test/test_third_party_iframes.html
+++ b/dom/serviceworkers/test/test_third_party_iframes.html
@@ -79,19 +79,16 @@ function runTest(aExpectedResponses) {
     responsesIndex++;
   };
 }
 
 // Verify that we can register and intercept a 3rd party iframe with
 // the given cookie policy.
 function testShouldIntercept(behavior, lifetime, done) {
   SpecialPowers.pushPrefEnv({"set": [
-      ["browser.contentblocking.enabled", true],
-      ["browser.contentblocking.ui.enabled", true],
-      ["browser.contentblocking.rejecttrackers.ui.enabled", true],
       ["network.cookie.cookieBehavior", behavior],
       ["network.cookie.lifetimePolicy", lifetime],
   ]}, function() {
     runTest([{
       status: "ok"
     }, {
       status: "registrationdone",
       next: function() {
--- a/dom/svg/SVGAElement.cpp
+++ b/dom/svg/SVGAElement.cpp
@@ -54,18 +54,18 @@ NS_IMPL_CYCLE_COLLECTION_INHERITED(SVGAE
                                    mRelList)
 
 NS_IMPL_ADDREF_INHERITED(SVGAElement, SVGAElementBase)
 NS_IMPL_RELEASE_INHERITED(SVGAElement, SVGAElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGAElement::SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGAElementBase(aNodeInfo)
+SVGAElement::SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGAElementBase(std::move(aNodeInfo))
   , Link(this)
 {
 }
 
 SVGAElement::~SVGAElement()
 {
 }
 
--- a/dom/svg/SVGAElement.h
+++ b/dom/svg/SVGAElement.h
@@ -25,17 +25,17 @@ namespace dom {
 typedef SVGGraphicsElement SVGAElementBase;
 
 class SVGAElement final : public SVGAElementBase,
                           public Link
 {
 protected:
   using Element::GetText;
 
-  explicit SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGAElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   friend nsresult (::NS_NewSVGAElement(nsIContent **aResult,
                                        already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAElement, SVGAElementBase)
--- a/dom/svg/SVGAnimateElement.cpp
+++ b/dom/svg/SVGAnimateElement.cpp
@@ -16,18 +16,18 @@ JSObject*
 SVGAnimateElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGAnimateElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGAnimateElement::SVGAnimateElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGAnimationElement(aNodeInfo)
+SVGAnimateElement::SVGAnimateElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGAnimationElement(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGAnimateElement)
 
--- a/dom/svg/SVGAnimateElement.h
+++ b/dom/svg/SVGAnimateElement.h
@@ -15,17 +15,17 @@ nsresult NS_NewSVGAnimateElement(nsICont
                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
 namespace mozilla {
 namespace dom {
 
 class SVGAnimateElement final : public SVGAnimationElement
 {
 protected:
-  explicit SVGAnimateElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGAnimateElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   nsSMILAnimationFunction mAnimationFunction;
   friend nsresult
     (::NS_NewSVGAnimateElement(nsIContent **aResult,
                                already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
--- a/dom/svg/SVGAnimateMotionElement.cpp
+++ b/dom/svg/SVGAnimateMotionElement.cpp
@@ -16,18 +16,18 @@ JSObject*
 SVGAnimateMotionElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGAnimateMotionElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGAnimateMotionElement::SVGAnimateMotionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGAnimationElement(aNodeInfo)
+SVGAnimateMotionElement::SVGAnimateMotionElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGAnimationElement(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGAnimateMotionElement)
 
--- a/dom/svg/SVGAnimateMotionElement.h
+++ b/dom/svg/SVGAnimateMotionElement.h
@@ -15,17 +15,17 @@ nsresult NS_NewSVGAnimateMotionElement(n
                                        already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
 namespace mozilla {
 namespace dom {
 
 class SVGAnimateMotionElement final : public SVGAnimationElement
 {
 protected:
-  explicit SVGAnimateMotionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGAnimateMotionElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   SVGMotionSMILAnimationFunction mAnimationFunction;
   friend nsresult
     (::NS_NewSVGAnimateMotionElement(nsIContent **aResult,
                                      already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
--- a/dom/svg/SVGAnimateTransformElement.cpp
+++ b/dom/svg/SVGAnimateTransformElement.cpp
@@ -16,18 +16,18 @@ JSObject*
 SVGAnimateTransformElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGAnimateTransformElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGAnimateTransformElement::SVGAnimateTransformElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGAnimationElement(aNodeInfo)
+SVGAnimateTransformElement::SVGAnimateTransformElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGAnimationElement(std::move(aNodeInfo))
 {
 }
 
 bool
 SVGAnimateTransformElement::ParseAttribute(int32_t aNamespaceID,
                                            nsAtom* aAttribute,
                                            const nsAString& aValue,
                                            nsIPrincipal* aMaybeScriptedPrincipal,
--- a/dom/svg/SVGAnimateTransformElement.h
+++ b/dom/svg/SVGAnimateTransformElement.h
@@ -15,17 +15,17 @@ nsresult NS_NewSVGAnimateTransformElemen
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
 namespace mozilla {
 namespace dom {
 
 class SVGAnimateTransformElement final : public SVGAnimationElement
 {
 protected:
-  explicit SVGAnimateTransformElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGAnimateTransformElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   nsSMILAnimationFunction mAnimationFunction;
   friend nsresult
     (::NS_NewSVGAnimateTransformElement(nsIContent **aResult,
                                         already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
--- a/dom/svg/SVGAnimationElement.cpp
+++ b/dom/svg/SVGAnimationElement.cpp
@@ -30,18 +30,18 @@ NS_INTERFACE_MAP_END_INHERITING(SVGAnima
 
 NS_IMPL_CYCLE_COLLECTION_INHERITED(SVGAnimationElement,
                                    SVGAnimationElementBase,
                                    mHrefTarget, mTimedElement)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGAnimationElement::SVGAnimationElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGAnimationElementBase(aNodeInfo),
+SVGAnimationElement::SVGAnimationElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGAnimationElementBase(std::move(aNodeInfo)),
     mHrefTarget(this)
 {
 }
 
 SVGAnimationElement::~SVGAnimationElement()
 {
 }
 
--- a/dom/svg/SVGAnimationElement.h
+++ b/dom/svg/SVGAnimationElement.h
@@ -23,17 +23,17 @@ enum nsSMILTargetAttrType {
   eSMILTargetAttrType_CSS,
   eSMILTargetAttrType_XML
 };
 
 class SVGAnimationElement : public SVGAnimationElementBase,
                             public SVGTests
 {
 protected:
-  explicit SVGAnimationElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGAnimationElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   nsresult Init();
   virtual ~SVGAnimationElement();
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGAnimationElement,
--- a/dom/svg/SVGCircleElement.cpp
+++ b/dom/svg/SVGCircleElement.cpp
@@ -28,18 +28,18 @@ nsSVGElement::LengthInfo SVGCircleElemen
   { &nsGkAtoms::cx, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::cy, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::r, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::XY }
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGCircleElement::SVGCircleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGCircleElementBase(aNodeInfo)
+SVGCircleElement::SVGCircleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGCircleElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGCircleElement)
 
--- a/dom/svg/SVGCircleElement.h
+++ b/dom/svg/SVGCircleElement.h
@@ -16,17 +16,17 @@ nsresult NS_NewSVGCircleElement(nsIConte
 namespace mozilla {
 namespace dom {
 
 typedef SVGGeometryElement SVGCircleElementBase;
 
 class SVGCircleElement final : public SVGCircleElementBase
 {
 protected:
-  explicit SVGCircleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGCircleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGCircleElement(nsIContent **aResult,
                                             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 public:
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const override;
 
--- a/dom/svg/SVGClipPathElement.cpp
+++ b/dom/svg/SVGClipPathElement.cpp
@@ -30,18 +30,18 @@ nsSVGElement::EnumInfo SVGClipPathElemen
     sSVGUnitTypesMap,
     SVG_UNIT_TYPE_USERSPACEONUSE
   }
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGClipPathElement::SVGClipPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGClipPathElementBase(aNodeInfo)
+SVGClipPathElement::SVGClipPathElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGClipPathElementBase(std::move(aNodeInfo))
 {
 }
 
 already_AddRefed<SVGAnimatedEnumeration>
 SVGClipPathElement::ClipPathUnits()
 {
   return mEnumAttributes[CLIPPATHUNITS].ToDOMAnimatedEnum(this);
 }
--- a/dom/svg/SVGClipPathElement.h
+++ b/dom/svg/SVGClipPathElement.h
@@ -22,17 +22,17 @@ typedef SVGTransformableElement SVGClipP
 
 class SVGClipPathElement final : public SVGClipPathElementBase
 {
   friend class ::nsSVGClipPathFrame;
 
 protected:
   friend nsresult (::NS_NewSVGClipPathElement(nsIContent **aResult,
                                               already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGClipPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGClipPathElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   // WebIDL
   already_AddRefed<SVGAnimatedEnumeration> ClipPathUnits();
 
--- a/dom/svg/SVGComponentTransferFunctionElement.h
+++ b/dom/svg/SVGComponentTransferFunctionElement.h
@@ -23,18 +23,18 @@ class DOMSVGAnimatedNumberList;
 
 namespace dom {
 
 typedef SVGFEUnstyledElement SVGComponentTransferFunctionElementBase;
 
 class SVGComponentTransferFunctionElement : public SVGComponentTransferFunctionElementBase
 {
 protected:
-  explicit SVGComponentTransferFunctionElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGComponentTransferFunctionElementBase(aNodeInfo)
+  explicit SVGComponentTransferFunctionElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGComponentTransferFunctionElementBase(std::move(aNodeInfo))
   {
   }
 
   virtual ~SVGComponentTransferFunctionElement() {}
 
 public:
   typedef gfx::ComponentTransferAttributes ComponentTransferAttributes;
 
@@ -90,18 +90,18 @@ nsresult NS_NewSVGFEFuncRElement(
 namespace mozilla {
 namespace dom {
 
 class SVGFEFuncRElement : public SVGComponentTransferFunctionElement
 {
   friend nsresult (::NS_NewSVGFEFuncRElement(
     nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEFuncRElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGComponentTransferFunctionElement(aNodeInfo) {}
+  explicit SVGFEFuncRElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGComponentTransferFunctionElement(std::move(aNodeInfo)) {}
 
 public:
   virtual int32_t GetChannel() override { return 0; }
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 };
@@ -115,18 +115,18 @@ nsresult NS_NewSVGFEFuncGElement(
 namespace mozilla {
 namespace dom {
 
 class SVGFEFuncGElement : public SVGComponentTransferFunctionElement
 {
   friend nsresult (::NS_NewSVGFEFuncGElement(
     nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEFuncGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGComponentTransferFunctionElement(aNodeInfo) {}
+  explicit SVGFEFuncGElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGComponentTransferFunctionElement(std::move(aNodeInfo)) {}
 
 public:
   virtual int32_t GetChannel() override { return 1; }
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 };
@@ -140,18 +140,18 @@ nsresult NS_NewSVGFEFuncBElement(
 namespace mozilla {
 namespace dom {
 
 class SVGFEFuncBElement : public SVGComponentTransferFunctionElement
 {
   friend nsresult (::NS_NewSVGFEFuncBElement(
     nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEFuncBElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGComponentTransferFunctionElement(aNodeInfo) {}
+  explicit SVGFEFuncBElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGComponentTransferFunctionElement(std::move(aNodeInfo)) {}
 
 public:
   virtual int32_t GetChannel() override { return 2; }
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 };
@@ -165,18 +165,18 @@ nsresult NS_NewSVGFEFuncAElement(
 namespace mozilla {
 namespace dom {
 
 class SVGFEFuncAElement : public SVGComponentTransferFunctionElement
 {
   friend nsresult (::NS_NewSVGFEFuncAElement(
     nsIContent** aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEFuncAElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGComponentTransferFunctionElement(aNodeInfo) {}
+  explicit SVGFEFuncAElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGComponentTransferFunctionElement(std::move(aNodeInfo)) {}
 
 public:
   virtual int32_t GetChannel() override { return 3; }
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 };
--- a/dom/svg/SVGDefsElement.cpp
+++ b/dom/svg/SVGDefsElement.cpp
@@ -16,18 +16,18 @@ JSObject*
 SVGDefsElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGDefsElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGDefsElement::SVGDefsElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGGraphicsElement(aNodeInfo)
+SVGDefsElement::SVGDefsElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGGraphicsElement(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGDefsElement)
--- a/dom/svg/SVGDefsElement.h
+++ b/dom/svg/SVGDefsElement.h
@@ -15,17 +15,17 @@ nsresult NS_NewSVGDefsElement(nsIContent
 namespace mozilla {
 namespace dom {
 
 class SVGDefsElement final : public SVGGraphicsElement
 {
 protected:
   friend nsresult (::NS_NewSVGDefsElement(nsIContent **aResult,
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGDefsElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGDefsElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // nsIContent
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode **aResult) const override;
 };
--- a/dom/svg/SVGDescElement.cpp
+++ b/dom/svg/SVGDescElement.cpp
@@ -16,18 +16,18 @@ JSObject*
 SVGDescElement::WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGDescElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGDescElement::SVGDescElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGDescElementBase(aNodeInfo)
+SVGDescElement::SVGDescElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGDescElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGDescElement)
 
--- a/dom/svg/SVGDescElement.h
+++ b/dom/svg/SVGDescElement.h
@@ -18,17 +18,17 @@ typedef nsSVGElement SVGDescElementBase;
 namespace mozilla {
 namespace dom {
 
 class SVGDescElement final : public SVGDescElementBase
 {
 protected:
   friend nsresult (::NS_NewSVGDescElement(nsIContent **aResult,
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGDescElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGDescElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 };
 
 } // namespace dom
--- a/dom/svg/SVGEllipseElement.cpp
+++ b/dom/svg/SVGEllipseElement.cpp
@@ -30,18 +30,18 @@ nsSVGElement::LengthInfo SVGEllipseEleme
   { &nsGkAtoms::cy, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::rx, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::ry, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGEllipseElement::SVGEllipseElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGEllipseElementBase(aNodeInfo)
+SVGEllipseElement::SVGEllipseElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGEllipseElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGEllipseElement)
 
--- a/dom/svg/SVGEllipseElement.h
+++ b/dom/svg/SVGEllipseElement.h
@@ -16,17 +16,17 @@ nsresult NS_NewSVGEllipseElement(nsICont
 namespace mozilla {
 namespace dom {
 
 typedef SVGGeometryElement SVGEllipseElementBase;
 
 class SVGEllipseElement final : public SVGEllipseElementBase
 {
 protected:
-  explicit SVGEllipseElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGEllipseElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGEllipseElement(nsIContent **aResult,
                                              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 public:
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const override;
 
--- a/dom/svg/SVGFEBlendElement.h
+++ b/dom/svg/SVGFEBlendElement.h
@@ -17,18 +17,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFEBlendElementBase;
 
 class SVGFEBlendElement : public SVGFEBlendElementBase
 {
   friend nsresult (::NS_NewSVGFEBlendElement(nsIContent **aResult,
                                              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEBlendElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEBlendElementBase(aNodeInfo)
+  explicit SVGFEBlendElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEBlendElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEColorMatrixElement.h
+++ b/dom/svg/SVGFEColorMatrixElement.h
@@ -19,18 +19,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFEColorMatrixElementBase;
 
 class SVGFEColorMatrixElement : public SVGFEColorMatrixElementBase
 {
   friend nsresult (::NS_NewSVGFEColorMatrixElement(nsIContent **aResult,
                                                    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEColorMatrixElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEColorMatrixElementBase(aNodeInfo)
+  explicit SVGFEColorMatrixElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEColorMatrixElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEComponentTransferElement.h
+++ b/dom/svg/SVGFEComponentTransferElement.h
@@ -17,18 +17,18 @@ nsresult NS_NewSVGFEComponentTransferEle
 namespace mozilla {
 namespace dom {
 
 class SVGFEComponentTransferElement : public SVGFEComponentTransferElementBase
 {
   friend nsresult (::NS_NewSVGFEComponentTransferElement(nsIContent **aResult,
                                                          already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEComponentTransferElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEComponentTransferElementBase(aNodeInfo)
+  explicit SVGFEComponentTransferElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEComponentTransferElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFECompositeElement.h
+++ b/dom/svg/SVGFECompositeElement.h
@@ -19,18 +19,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFECompositeElementBase;
 
 class SVGFECompositeElement : public SVGFECompositeElementBase
 {
   friend nsresult (::NS_NewSVGFECompositeElement(nsIContent **aResult,
                                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFECompositeElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFECompositeElementBase(aNodeInfo)
+  explicit SVGFECompositeElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFECompositeElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEConvolveMatrixElement.h
+++ b/dom/svg/SVGFEConvolveMatrixElement.h
@@ -27,18 +27,18 @@ class SVGAnimatedBoolean;
 
 typedef nsSVGFE SVGFEConvolveMatrixElementBase;
 
 class SVGFEConvolveMatrixElement : public SVGFEConvolveMatrixElementBase
 {
   friend nsresult (::NS_NewSVGFEConvolveMatrixElement(nsIContent **aResult,
                                                       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEConvolveMatrixElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEConvolveMatrixElementBase(aNodeInfo)
+  explicit SVGFEConvolveMatrixElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEConvolveMatrixElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEDiffuseLightingElement.h
+++ b/dom/svg/SVGFEDiffuseLightingElement.h
@@ -17,18 +17,18 @@ namespace dom {
 
 typedef nsSVGFELightingElement SVGFEDiffuseLightingElementBase;
 
 class SVGFEDiffuseLightingElement : public SVGFEDiffuseLightingElementBase
 {
   friend nsresult (::NS_NewSVGFEDiffuseLightingElement(nsIContent **aResult,
                                                        already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEDiffuseLightingElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEDiffuseLightingElementBase(aNodeInfo)
+  explicit SVGFEDiffuseLightingElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEDiffuseLightingElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEDisplacementMapElement.h
+++ b/dom/svg/SVGFEDisplacementMapElement.h
@@ -18,18 +18,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFEDisplacementMapElementBase;
 
 class SVGFEDisplacementMapElement : public SVGFEDisplacementMapElementBase
 {
 protected:
   friend nsresult (::NS_NewSVGFEDisplacementMapElement(nsIContent **aResult,
                                                        already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGFEDisplacementMapElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEDisplacementMapElementBase(aNodeInfo)
+  explicit SVGFEDisplacementMapElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEDisplacementMapElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEDistantLightElement.h
+++ b/dom/svg/SVGFEDistantLightElement.h
@@ -18,18 +18,18 @@ namespace dom {
 
 typedef SVGFELightElement SVGFEDistantLightElementBase;
 
 class SVGFEDistantLightElement : public SVGFEDistantLightElementBase
 {
   friend nsresult (::NS_NewSVGFEDistantLightElement(nsIContent **aResult,
                                                     already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEDistantLightElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEDistantLightElementBase(aNodeInfo)
+  explicit SVGFEDistantLightElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEDistantLightElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
 
   virtual mozilla::gfx::LightType ComputeLightAttributes(nsSVGFilterInstance* aInstance,
                                                          nsTArray<float>& aFloatAttributes) override;
--- a/dom/svg/SVGFEDropShadowElement.h
+++ b/dom/svg/SVGFEDropShadowElement.h
@@ -20,18 +20,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFEDropShadowElementBase;
 
 class SVGFEDropShadowElement : public SVGFEDropShadowElementBase
 {
   friend nsresult (::NS_NewSVGFEDropShadowElement(nsIContent **aResult,
                                                   already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEDropShadowElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEDropShadowElementBase(aNodeInfo)
+  explicit SVGFEDropShadowElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEDropShadowElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEFloodElement.h
+++ b/dom/svg/SVGFEFloodElement.h
@@ -17,18 +17,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFEFloodElementBase;
 
 class SVGFEFloodElement : public SVGFEFloodElementBase
 {
   friend nsresult (::NS_NewSVGFEFloodElement(nsIContent **aResult,
                                              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEFloodElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEFloodElementBase(aNodeInfo)
+  explicit SVGFEFloodElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEFloodElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual bool SubregionIsUnionOfRegions() override { return false; }
 
   virtual FilterPrimitiveDescription
--- a/dom/svg/SVGFEGaussianBlurElement.h
+++ b/dom/svg/SVGFEGaussianBlurElement.h
@@ -19,18 +19,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFEGaussianBlurElementBase;
 
 class SVGFEGaussianBlurElement : public SVGFEGaussianBlurElementBase
 {
   friend nsresult (::NS_NewSVGFEGaussianBlurElement(nsIContent **aResult,
                                                     already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEGaussianBlurElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEGaussianBlurElementBase(aNodeInfo)
+  explicit SVGFEGaussianBlurElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEGaussianBlurElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEImageElement.cpp
+++ b/dom/svg/SVGFEImageElement.cpp
@@ -43,18 +43,18 @@ nsSVGElement::StringInfo SVGFEImageEleme
 // nsISupports methods
 
 NS_IMPL_ISUPPORTS_INHERITED(SVGFEImageElement, SVGFEImageElementBase,
                             imgINotificationObserver, nsIImageLoadingContent)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGFEImageElement::SVGFEImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGFEImageElementBase(aNodeInfo)
+SVGFEImageElement::SVGFEImageElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGFEImageElementBase(std::move(aNodeInfo))
 {
   // We start out broken
   AddStatesSilently(NS_EVENT_STATE_BROKEN);
 }
 
 SVGFEImageElement::~SVGFEImageElement()
 {
   DestroyImageLoadingContent();
--- a/dom/svg/SVGFEImageElement.h
+++ b/dom/svg/SVGFEImageElement.h
@@ -23,17 +23,17 @@ typedef nsSVGFE SVGFEImageElementBase;
 class SVGFEImageElement final : public SVGFEImageElementBase,
                                 public nsImageLoadingContent
 {
   friend class ::SVGFEImageFrame;
 
 protected:
   friend nsresult (::NS_NewSVGFEImageElement(nsIContent **aResult,
                                              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGFEImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGFEImageElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual ~SVGFEImageElement();
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual bool SubregionIsUnionOfRegions() override { return false; }
 
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
--- a/dom/svg/SVGFEMergeElement.h
+++ b/dom/svg/SVGFEMergeElement.h
@@ -17,18 +17,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFEMergeElementBase;
 
 class SVGFEMergeElement : public SVGFEMergeElementBase
 {
   friend nsresult (::NS_NewSVGFEMergeElement(nsIContent **aResult,
                                              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEMergeElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEMergeElementBase(aNodeInfo)
+  explicit SVGFEMergeElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEMergeElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEMergeNodeElement.h
+++ b/dom/svg/SVGFEMergeNodeElement.h
@@ -17,18 +17,18 @@ namespace dom {
 
 typedef SVGFEUnstyledElement SVGFEMergeNodeElementBase;
 
 class SVGFEMergeNodeElement : public SVGFEMergeNodeElementBase
 {
   friend nsresult (::NS_NewSVGFEMergeNodeElement(nsIContent **aResult,
                                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEMergeNodeElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEMergeNodeElementBase(aNodeInfo)
+  explicit SVGFEMergeNodeElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEMergeNodeElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   virtual bool AttributeAffectsRendering(
--- a/dom/svg/SVGFEMorphologyElement.h
+++ b/dom/svg/SVGFEMorphologyElement.h
@@ -20,18 +20,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFEMorphologyElementBase;
 
 class SVGFEMorphologyElement : public SVGFEMorphologyElementBase
 {
   friend nsresult (::NS_NewSVGFEMorphologyElement(nsIContent **aResult,
                                                   already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEMorphologyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEMorphologyElementBase(aNodeInfo)
+  explicit SVGFEMorphologyElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEMorphologyElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEOffsetElement.h
+++ b/dom/svg/SVGFEOffsetElement.h
@@ -19,18 +19,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFEOffsetElementBase;
 
 class SVGFEOffsetElement : public SVGFEOffsetElementBase
 {
   friend nsresult (::NS_NewSVGFEOffsetElement(nsIContent **aResult,
                                               already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEOffsetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEOffsetElementBase(aNodeInfo)
+  explicit SVGFEOffsetElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEOffsetElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual FilterPrimitiveDescription
     GetPrimitiveDescription(nsSVGFilterInstance* aInstance,
                             const IntRect& aFilterSubregion,
--- a/dom/svg/SVGFEPointLightElement.h
+++ b/dom/svg/SVGFEPointLightElement.h
@@ -18,18 +18,18 @@ namespace dom {
 
 typedef SVGFELightElement SVGFEPointLightElementBase;
 
 class SVGFEPointLightElement : public SVGFEPointLightElementBase
 {
   friend nsresult (::NS_NewSVGFEPointLightElement(nsIContent **aResult,
                                                   already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFEPointLightElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEPointLightElementBase(aNodeInfo)
+  explicit SVGFEPointLightElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEPointLightElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual mozilla::gfx::LightType ComputeLightAttributes(nsSVGFilterInstance* aInstance,
                                                          nsTArray<float>& aFloatAttributes) override;
   virtual bool AttributeAffectsRendering(
--- a/dom/svg/SVGFESpecularLightingElement.h
+++ b/dom/svg/SVGFESpecularLightingElement.h
@@ -19,18 +19,18 @@ namespace dom {
 
 typedef nsSVGFELightingElement SVGFESpecularLightingElementBase;
 
 class SVGFESpecularLightingElement : public SVGFESpecularLightingElementBase
 {
   friend nsresult (::NS_NewSVGFESpecularLightingElement(nsIContent **aResult,
                                                         already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFESpecularLightingElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFESpecularLightingElementBase(aNodeInfo)
+  explicit SVGFESpecularLightingElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFESpecularLightingElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   virtual FilterPrimitiveDescription
--- a/dom/svg/SVGFESpotLightElement.h
+++ b/dom/svg/SVGFESpotLightElement.h
@@ -19,18 +19,18 @@ namespace dom {
 typedef SVGFELightElement SVGFESpotLightElementBase;
 
 class SVGFESpotLightElement : public SVGFESpotLightElementBase
 {
   friend nsresult (::NS_NewSVGFESpotLightElement(nsIContent **aResult,
                                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
   friend class ::nsSVGFELightingElement;
 protected:
-  explicit SVGFESpotLightElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFESpotLightElementBase(aNodeInfo)
+  explicit SVGFESpotLightElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFESpotLightElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual mozilla::gfx::LightType ComputeLightAttributes(nsSVGFilterInstance* aInstance,
                                                          nsTArray<float>& aFloatAttributes) override;
   virtual bool AttributeAffectsRendering(
--- a/dom/svg/SVGFETileElement.h
+++ b/dom/svg/SVGFETileElement.h
@@ -17,18 +17,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFETileElementBase;
 
 class SVGFETileElement : public SVGFETileElementBase
 {
   friend nsresult (::NS_NewSVGFETileElement(nsIContent **aResult,
                                             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFETileElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFETileElementBase(aNodeInfo)
+  explicit SVGFETileElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFETileElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual bool SubregionIsUnionOfRegions() override { return false; }
 
   virtual FilterPrimitiveDescription
--- a/dom/svg/SVGFETurbulenceElement.h
+++ b/dom/svg/SVGFETurbulenceElement.h
@@ -21,18 +21,18 @@ namespace dom {
 
 typedef nsSVGFE SVGFETurbulenceElementBase;
 
 class SVGFETurbulenceElement : public SVGFETurbulenceElementBase
 {
   friend nsresult (::NS_NewSVGFETurbulenceElement(nsIContent **aResult,
                                                   already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 protected:
-  explicit SVGFETurbulenceElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFETurbulenceElementBase(aNodeInfo)
+  explicit SVGFETurbulenceElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFETurbulenceElementBase(std::move(aNodeInfo))
   {
   }
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual bool SubregionIsUnionOfRegions() override { return false; }
 
   virtual FilterPrimitiveDescription
--- a/dom/svg/SVGFilterElement.cpp
+++ b/dom/svg/SVGFilterElement.cpp
@@ -53,18 +53,18 @@ nsSVGElement::StringInfo SVGFilterElemen
 {
   { &nsGkAtoms::href, kNameSpaceID_None, true },
   { &nsGkAtoms::href, kNameSpaceID_XLink, true }
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGFilterElement::SVGFilterElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGFilterElementBase(aNodeInfo)
+SVGFilterElement::SVGFilterElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGFilterElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGFilterElement)
--- a/dom/svg/SVGFilterElement.h
+++ b/dom/svg/SVGFilterElement.h
@@ -28,17 +28,17 @@ class SVGAnimatedLength;
 class SVGFilterElement : public SVGFilterElementBase
 {
   friend class ::nsSVGFilterFrame;
   friend class ::nsSVGFilterInstance;
 
 protected:
   friend nsresult (::NS_NewSVGFilterElement(nsIContent **aResult,
                                             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGFilterElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGFilterElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // nsIContent
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
   // Invalidate users of this filter
--- a/dom/svg/SVGForeignObjectElement.cpp
+++ b/dom/svg/SVGForeignObjectElement.cpp
@@ -29,18 +29,18 @@ nsSVGElement::LengthInfo SVGForeignObjec
   { &nsGkAtoms::y, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::width, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::height, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGForeignObjectElement::SVGForeignObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGGraphicsElement(aNodeInfo)
+SVGForeignObjectElement::SVGForeignObjectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGGraphicsElement(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGForeignObjectElement)
 
--- a/dom/svg/SVGForeignObjectElement.h
+++ b/dom/svg/SVGForeignObjectElement.h
@@ -20,17 +20,17 @@ namespace dom {
 
 class SVGForeignObjectElement final : public SVGGraphicsElement
 {
   friend class ::nsSVGForeignObjectFrame;
 
 protected:
   friend nsresult (::NS_NewSVGForeignObjectElement(nsIContent **aResult,
                                                    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGForeignObjectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGForeignObjectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // nsSVGElement specializations:
   virtual gfxMatrix PrependLocalTransformsTo(
     const gfxMatrix &aMatrix,
     SVGTransformTypes aWhich = eAllTransforms) const override;
   virtual bool HasValidDimensions() const override;
--- a/dom/svg/SVGGElement.cpp
+++ b/dom/svg/SVGGElement.cpp
@@ -16,18 +16,18 @@ JSObject*
 SVGGElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGGElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGGElement::SVGGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGGraphicsElement(aNodeInfo)
+SVGGElement::SVGGElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGGraphicsElement(std::move(aNodeInfo))
 {
 }
 
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 
--- a/dom/svg/SVGGElement.h
+++ b/dom/svg/SVGGElement.h
@@ -13,17 +13,17 @@ nsresult NS_NewSVGGElement(nsIContent **
                            already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
 namespace mozilla {
 namespace dom {
 
 class SVGGElement final : public SVGGraphicsElement
 {
 protected:
-  explicit SVGGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGGElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGGElement(nsIContent **aResult,
                                        already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 public:
   // nsIContent
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
--- a/dom/svg/SVGGeometryElement.cpp
+++ b/dom/svg/SVGGeometryElement.cpp
@@ -20,18 +20,18 @@ using namespace mozilla::gfx;
 using namespace mozilla::dom;
 
 nsSVGElement::NumberInfo SVGGeometryElement::sNumberInfo =
 { &nsGkAtoms::pathLength, 0, false };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGGeometryElement::SVGGeometryElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGGeometryElementBase(aNodeInfo)
+SVGGeometryElement::SVGGeometryElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGGeometryElementBase(std::move(aNodeInfo))
 {
 }
 
 nsSVGElement::NumberAttributesInfo
 SVGGeometryElement::GetNumberInfo()
 {
   return NumberAttributesInfo(&mPathLength, &sNumberInfo, 1);
 }
--- a/dom/svg/SVGGeometryElement.h
+++ b/dom/svg/SVGGeometryElement.h
@@ -44,17 +44,17 @@ protected:
   typedef mozilla::gfx::Matrix Matrix;
   typedef mozilla::gfx::Path Path;
   typedef mozilla::gfx::Point Point;
   typedef mozilla::gfx::PathBuilder PathBuilder;
   typedef mozilla::gfx::Rect Rect;
   typedef mozilla::gfx::StrokeOptions StrokeOptions;
 
 public:
-  explicit SVGGeometryElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGGeometryElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
                                 const nsAttrValue* aValue,
                                 const nsAttrValue* aOldValue,
                                 nsIPrincipal* aSubjectPrincipal,
                                 bool aNotify) override;
   bool IsNodeOfType(uint32_t aFlags) const override;
 
--- a/dom/svg/SVGGradientElement.cpp
+++ b/dom/svg/SVGGradientElement.cpp
@@ -51,18 +51,18 @@ nsSVGElement::StringInfo SVGGradientElem
 {
   { &nsGkAtoms::href, kNameSpaceID_None, true },
   { &nsGkAtoms::href, kNameSpaceID_XLink, true }
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGGradientElement::SVGGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGGradientElementBase(aNodeInfo)
+SVGGradientElement::SVGGradientElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGGradientElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsSVGElement methods
 
 nsSVGElement::EnumAttributesInfo
 SVGGradientElement::GetEnumInfo()
@@ -136,18 +136,18 @@ nsSVGElement::LengthInfo SVGLinearGradie
   { &nsGkAtoms::y1, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
   { &nsGkAtoms::x2, 100, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
   { &nsGkAtoms::y2, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGLinearGradientElement::SVGLinearGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGLinearGradientElementBase(aNodeInfo)
+SVGLinearGradientElement::SVGLinearGradientElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGLinearGradientElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGLinearGradientElement)
 
@@ -212,18 +212,18 @@ nsSVGElement::LengthInfo SVGRadialGradie
   { &nsGkAtoms::fx, 50, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
   { &nsGkAtoms::fy, 50, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
   { &nsGkAtoms::fr, 0, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::XY },
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGRadialGradientElement::SVGRadialGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGRadialGradientElementBase(aNodeInfo)
+SVGRadialGradientElement::SVGRadialGradientElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGRadialGradientElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGRadialGradientElement)
 
--- a/dom/svg/SVGGradientElement.h
+++ b/dom/svg/SVGGradientElement.h
@@ -34,17 +34,17 @@ class SVGAnimatedTransformList;
 
 typedef nsSVGElement SVGGradientElementBase;
 
 class SVGGradientElement : public SVGGradientElementBase
 {
   friend class ::nsSVGGradientFrame;
 
 protected:
-  explicit SVGGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGGradientElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override = 0;
 
 public:
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override = 0;
 
   // nsIContent
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
@@ -84,17 +84,17 @@ typedef SVGGradientElement SVGLinearGrad
 class SVGLinearGradientElement : public SVGLinearGradientElementBase
 {
   friend class ::nsSVGLinearGradientFrame;
   friend nsresult
     (::NS_NewSVGLinearGradientElement(nsIContent** aResult,
                                       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 protected:
-  explicit SVGLinearGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGLinearGradientElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   // WebIDL
   already_AddRefed<SVGAnimatedLength> X1();
   already_AddRefed<SVGAnimatedLength> Y1();
@@ -117,17 +117,17 @@ typedef SVGGradientElement SVGRadialGrad
 class SVGRadialGradientElement : public SVGRadialGradientElementBase
 {
   friend class ::nsSVGRadialGradientFrame;
   friend nsresult
     (::NS_NewSVGRadialGradientElement(nsIContent** aResult,
                                       already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 protected:
-  explicit SVGRadialGradientElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGRadialGradientElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   // WebIDL
   already_AddRefed<SVGAnimatedLength> Cx();
   already_AddRefed<SVGAnimatedLength> Cy();
--- a/dom/svg/SVGGraphicsElement.cpp
+++ b/dom/svg/SVGGraphicsElement.cpp
@@ -17,18 +17,18 @@ NS_IMPL_RELEASE_INHERITED(SVGGraphicsEle
 
 NS_INTERFACE_MAP_BEGIN(SVGGraphicsElement)
   NS_INTERFACE_MAP_ENTRY(mozilla::dom::SVGTests)
 NS_INTERFACE_MAP_END_INHERITING(SVGGraphicsElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGGraphicsElement::SVGGraphicsElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGGraphicsElementBase(aNodeInfo)
+SVGGraphicsElement::SVGGraphicsElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+: SVGGraphicsElementBase(std::move(aNodeInfo))
 {
 }
 
 SVGGraphicsElement::~SVGGraphicsElement()
 {
 }
 
 } // namespace dom
--- a/dom/svg/SVGGraphicsElement.h
+++ b/dom/svg/SVGGraphicsElement.h
@@ -14,17 +14,17 @@ namespace mozilla {
 namespace dom {
 
 typedef SVGTransformableElement SVGGraphicsElementBase;
 
 class SVGGraphicsElement : public SVGGraphicsElementBase,
                            public SVGTests
 {
 protected:
-  explicit SVGGraphicsElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGGraphicsElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   ~SVGGraphicsElement();
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
 
   nsSVGElement* AsSVGElement() final { return this; }
 };
--- a/dom/svg/SVGImageElement.cpp
+++ b/dom/svg/SVGImageElement.cpp
@@ -50,18 +50,18 @@ nsSVGElement::StringInfo SVGImageElement
 
 NS_IMPL_ISUPPORTS_INHERITED(SVGImageElement, SVGImageElementBase,
                             imgINotificationObserver,
                             nsIImageLoadingContent)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGImageElement::SVGImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGImageElementBase(aNodeInfo)
+SVGImageElement::SVGImageElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGImageElementBase(std::move(aNodeInfo))
 {
   // We start out broken
   AddStatesSilently(NS_EVENT_STATE_BROKEN);
 }
 
 SVGImageElement::~SVGImageElement()
 {
   DestroyImageLoadingContent();
--- a/dom/svg/SVGImageElement.h
+++ b/dom/svg/SVGImageElement.h
@@ -25,17 +25,17 @@ class DOMSVGAnimatedPreserveAspectRatio;
 typedef SVGGeometryElement SVGImageElementBase;
 
 class SVGImageElement : public SVGImageElementBase,
                         public nsImageLoadingContent
 {
   friend class ::nsSVGImageFrame;
 
 protected:
-  explicit SVGImageElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGImageElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual ~SVGImageElement();
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGImageElement(nsIContent **aResult,
                                            already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 public:
   // interfaces:
 
--- a/dom/svg/SVGLineElement.cpp
+++ b/dom/svg/SVGLineElement.cpp
@@ -28,18 +28,18 @@ nsSVGElement::LengthInfo SVGLineElement:
   { &nsGkAtoms::y1, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::x2, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::y2, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGLineElement::SVGLineElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGLineElementBase(aNodeInfo)
+SVGLineElement::SVGLineElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGLineElementBase(std::move(aNodeInfo))
 {
 }
 
 void
 SVGLineElement::MaybeAdjustForZeroLength(float aX1, float aY1,
                                          float& aX2, float aY2)
 {
   if (aX1 == aX2 && aY1 == aY2) {
--- a/dom/svg/SVGLineElement.h
+++ b/dom/svg/SVGLineElement.h
@@ -16,17 +16,17 @@ nsresult NS_NewSVGLineElement(nsIContent
 namespace mozilla {
 namespace dom {
 
 typedef SVGGeometryElement SVGLineElementBase;
 
 class SVGLineElement final : public SVGLineElementBase
 {
 protected:
-  explicit SVGLineElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGLineElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGLineElement(nsIContent **aResult,
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
   // If the input line has length zero and linecaps aren't butt, adjust |aX2| by
   // a tiny amount to a barely-nonzero-length line that all of our draw targets
   // will render
   void MaybeAdjustForZeroLength(float aX1, float aY1, float& aX2, float aY2);
 
--- a/dom/svg/SVGMPathElement.cpp
+++ b/dom/svg/SVGMPathElement.cpp
@@ -47,18 +47,18 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 //----------------------------------------------------------------------
 // nsISupports methods
 
 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(SVGMPathElement,
                                              SVGMPathElementBase,
                                              nsIMutationObserver)
 
 // Constructor
-SVGMPathElement::SVGMPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGMPathElementBase(aNodeInfo)
+SVGMPathElement::SVGMPathElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGMPathElementBase(std::move(aNodeInfo))
   , mPathTracker(this)
 {
 }
 
 SVGMPathElement::~SVGMPathElement()
 {
   UnlinkHrefTarget(false);
 }
--- a/dom/svg/SVGMPathElement.h
+++ b/dom/svg/SVGMPathElement.h
@@ -22,17 +22,17 @@ namespace dom {
 class SVGPathElement;
 
 class SVGMPathElement final : public SVGMPathElementBase,
                               public nsStubMutationObserver
 {
 protected:
   friend nsresult (::NS_NewSVGMPathElement(nsIContent **aResult,
                                            already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGMPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGMPathElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   ~SVGMPathElement();
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
 
--- a/dom/svg/SVGMarkerElement.cpp
+++ b/dom/svg/SVGMarkerElement.cpp
@@ -88,18 +88,18 @@ nsSVGOrientType::SetBaseValue(uint16_t a
 already_AddRefed<SVGAnimatedEnumeration>
 nsSVGOrientType::ToDOMAnimatedEnum(nsSVGElement *aSVGElement)
 {
   RefPtr<SVGAnimatedEnumeration> toReturn =
     new DOMAnimatedEnum(this, aSVGElement);
   return toReturn.forget();
 }
 
-SVGMarkerElement::SVGMarkerElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGMarkerElementBase(aNodeInfo), mCoordCtx(nullptr)
+SVGMarkerElement::SVGMarkerElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGMarkerElementBase(std::move(aNodeInfo)), mCoordCtx(nullptr)
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMarkerElement)
 
--- a/dom/svg/SVGMarkerElement.h
+++ b/dom/svg/SVGMarkerElement.h
@@ -96,17 +96,17 @@ typedef nsSVGElement SVGMarkerElementBas
 
 class SVGMarkerElement : public SVGMarkerElementBase
 {
   friend class ::nsSVGMarkerFrame;
 
 protected:
   friend nsresult (::NS_NewSVGMarkerElement(nsIContent **aResult,
                                             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGMarkerElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGMarkerElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* name) const override;
 
   virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName,
                                 const nsAttrValue* aValue,
--- a/dom/svg/SVGMaskElement.cpp
+++ b/dom/svg/SVGMaskElement.cpp
@@ -46,18 +46,18 @@ nsSVGElement::EnumInfo SVGMaskElement::s
     sSVGUnitTypesMap,
     SVG_UNIT_TYPE_USERSPACEONUSE
   }
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGMaskElement::SVGMaskElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGMaskElementBase(aNodeInfo)
+SVGMaskElement::SVGMaskElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGMaskElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode method
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGMaskElement)
 
--- a/dom/svg/SVGMaskElement.h
+++ b/dom/svg/SVGMaskElement.h
@@ -25,17 +25,17 @@ typedef nsSVGElement SVGMaskElementBase;
 
 class SVGMaskElement final : public SVGMaskElementBase
 {
   friend class ::nsSVGMaskFrame;
 
 protected:
   friend nsresult (::NS_NewSVGMaskElement(nsIContent **aResult,
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGMaskElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGMaskElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // nsIContent interface
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
   // nsSVGSVGElement methods:
--- a/dom/svg/SVGMetadataElement.cpp
+++ b/dom/svg/SVGMetadataElement.cpp
@@ -16,18 +16,18 @@ JSObject*
 SVGMetadataElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGMetadataElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGMetadataElement::SVGMetadataElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGMetadataElementBase(aNodeInfo)
+SVGMetadataElement::SVGMetadataElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGMetadataElementBase(std::move(aNodeInfo))
 {
 }
 
 
 nsresult
 SVGMetadataElement::Init()
 {
   return NS_OK;
--- a/dom/svg/SVGMetadataElement.h
+++ b/dom/svg/SVGMetadataElement.h
@@ -18,17 +18,17 @@ typedef nsSVGElement SVGMetadataElementB
 namespace mozilla {
 namespace dom {
 
 class SVGMetadataElement final : public SVGMetadataElementBase
 {
 protected:
   friend nsresult (::NS_NewSVGMetadataElement(nsIContent **aResult,
                                               already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGMetadataElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGMetadataElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
   nsresult Init();
 
 public:
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 };
 
--- a/dom/svg/SVGPathElement.cpp
+++ b/dom/svg/SVGPathElement.cpp
@@ -34,18 +34,18 @@ JSObject*
 SVGPathElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGPathElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGPathElement::SVGPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGPathElementBase(aNodeInfo)
+SVGPathElement::SVGPathElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGPathElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // memory reporting methods
 
 void
 SVGPathElement::AddSizeOfExcludingThis(nsWindowSizes& aSizes,
--- a/dom/svg/SVGPathElement.h
+++ b/dom/svg/SVGPathElement.h
@@ -27,17 +27,17 @@ typedef SVGGeometryElement SVGPathElemen
 class SVGPathElement final : public SVGPathElementBase
 {
   typedef mozilla::gfx::Path Path;
 
 protected:
   friend nsresult (::NS_NewSVGPathElement(nsIContent **aResult,
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
-  explicit SVGPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGPathElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
 public:
   NS_DECL_ADDSIZEOFEXCLUDINGTHIS
 
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* name) const override;
 
   // nsSVGSVGElement methods:
--- a/dom/svg/SVGPatternElement.cpp
+++ b/dom/svg/SVGPatternElement.cpp
@@ -53,18 +53,18 @@ nsSVGElement::StringInfo SVGPatternEleme
 {
   { &nsGkAtoms::href, kNameSpaceID_None, true },
   { &nsGkAtoms::href, kNameSpaceID_XLink, true }
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGPatternElement::SVGPatternElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGPatternElementBase(aNodeInfo)
+SVGPatternElement::SVGPatternElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGPatternElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode method
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPatternElement)
 
--- a/dom/svg/SVGPatternElement.h
+++ b/dom/svg/SVGPatternElement.h
@@ -29,17 +29,17 @@ typedef nsSVGElement SVGPatternElementBa
 
 class SVGPatternElement final : public SVGPatternElementBase
 {
   friend class ::nsSVGPatternFrame;
 
 protected:
   friend nsresult (::NS_NewSVGPatternElement(nsIContent **aResult,
                                              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGPatternElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGPatternElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   typedef mozilla::SVGAnimatedPreserveAspectRatio SVGAnimatedPreserveAspectRatio;
 
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* name) const override;
 
--- a/dom/svg/SVGPolyElement.cpp
+++ b/dom/svg/SVGPolyElement.cpp
@@ -10,18 +10,18 @@
 #include "SVGContentUtils.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGPolyElement::SVGPolyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGPolyElementBase(aNodeInfo)
+SVGPolyElement::SVGPolyElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGPolyElementBase(std::move(aNodeInfo))
 {
 }
 
 SVGPolyElement::~SVGPolyElement()
 {
 }
 
 already_AddRefed<DOMSVGPointList>
--- a/dom/svg/SVGPolyElement.h
+++ b/dom/svg/SVGPolyElement.h
@@ -16,17 +16,17 @@ class DOMSVGPointList;
 
 namespace dom {
 
 typedef SVGGeometryElement SVGPolyElementBase;
 
 class SVGPolyElement : public SVGPolyElementBase
 {
 protected:
-  explicit SVGPolyElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGPolyElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   virtual ~SVGPolyElement();
 
 public:
   //interfaces
 
   NS_INLINE_DECL_REFCOUNTING_INHERITED(SVGPolyElement, SVGPolyElementBase)
 
--- a/dom/svg/SVGPolygonElement.cpp
+++ b/dom/svg/SVGPolygonElement.cpp
@@ -21,18 +21,18 @@ JSObject*
 SVGPolygonElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGPolygonElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGPolygonElement::SVGPolygonElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGPolygonElementBase(aNodeInfo)
+SVGPolygonElement::SVGPolygonElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGPolygonElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolygonElement)
 
--- a/dom/svg/SVGPolygonElement.h
+++ b/dom/svg/SVGPolygonElement.h
@@ -16,17 +16,17 @@ nsresult NS_NewSVGPolygonElement(nsICont
 namespace mozilla {
 namespace dom {
 
 typedef SVGPolyElement SVGPolygonElementBase;
 
 class SVGPolygonElement final : public SVGPolygonElementBase
 {
 protected:
-  explicit SVGPolygonElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGPolygonElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGPolygonElement(nsIContent **aResult,
                                              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 public:
   // SVGGeometryElement methods:
   virtual void GetMarkPoints(nsTArray<nsSVGMark> *aMarks) override;
   virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
--- a/dom/svg/SVGPolylineElement.cpp
+++ b/dom/svg/SVGPolylineElement.cpp
@@ -20,18 +20,18 @@ JSObject*
 SVGPolylineElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGPolylineElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGPolylineElement::SVGPolylineElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGPolylineElementBase(aNodeInfo)
+SVGPolylineElement::SVGPolylineElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGPolylineElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGPolylineElement)
 
--- a/dom/svg/SVGPolylineElement.h
+++ b/dom/svg/SVGPolylineElement.h
@@ -15,17 +15,17 @@ nsresult NS_NewSVGPolylineElement(nsICon
 namespace mozilla {
 namespace dom {
 
 typedef SVGPolyElement SVGPolylineElementBase;
 
 class SVGPolylineElement final : public SVGPolylineElementBase
 {
 protected:
-  explicit SVGPolylineElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGPolylineElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGPolylineElement(nsIContent **aResult,
                                               already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
   // SVGGeometryElement methods:
   virtual already_AddRefed<Path> BuildPath(PathBuilder* aBuilder) override;
 
 public:
--- a/dom/svg/SVGRectElement.cpp
+++ b/dom/svg/SVGRectElement.cpp
@@ -37,18 +37,18 @@ nsSVGElement::LengthInfo SVGRectElement:
   { &nsGkAtoms::height, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::rx, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::X },
   { &nsGkAtoms::ry, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y }
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGRectElement::SVGRectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGRectElementBase(aNodeInfo)
+SVGRectElement::SVGRectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGRectElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGRectElement)
 
--- a/dom/svg/SVGRectElement.h
+++ b/dom/svg/SVGRectElement.h
@@ -16,17 +16,17 @@ nsresult NS_NewSVGRectElement(nsIContent
 namespace mozilla {
 namespace dom {
 
 typedef SVGGeometryElement SVGRectElementBase;
 
 class SVGRectElement final : public SVGRectElementBase
 {
 protected:
-  explicit SVGRectElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGRectElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
   friend nsresult (::NS_NewSVGRectElement(nsIContent **aResult,
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 public:
   // nsSVGSVGElement methods:
   virtual bool HasValidDimensions() const override;
 
--- a/dom/svg/SVGSVGElement.cpp
+++ b/dom/svg/SVGSVGElement.cpp
@@ -132,19 +132,19 @@ SVGView::SVGView()
                    SVG_ZOOMANDPAN_MAGNIFY);
   mViewBox.Init();
   mPreserveAspectRatio.Init();
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGSVGElement::SVGSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+SVGSVGElement::SVGSVGElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                              FromParser aFromParser)
-  : SVGSVGElementBase(aNodeInfo),
+  : SVGSVGElementBase(std::move(aNodeInfo)),
     mCurrentTranslate(0.0f, 0.0f),
     mCurrentScale(1.0f),
     mPreviousTranslate(0.0f, 0.0f),
     mPreviousScale(1.0f),
     mStartAnimationOnBindToTree(aFromParser == NOT_FROM_PARSER ||
                                 aFromParser == FROM_PARSER_FRAGMENT ||
                                 aFromParser == FROM_PARSER_XSLT),
     mImageNeedsTransformInvalidation(false)
--- a/dom/svg/SVGSVGElement.h
+++ b/dom/svg/SVGSVGElement.h
@@ -73,17 +73,17 @@ class SVGSVGElement final : public SVGSV
 {
   friend class ::nsSVGOuterSVGFrame;
   friend class mozilla::SVGFragmentIdentifier;
   friend class mozilla::AutoSVGViewHandler;
   friend class mozilla::AutoPreserveAspectRatioOverride;
   friend class mozilla::dom::SVGView;
 
 protected:
-  SVGSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  SVGSVGElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                 FromParser aFromParser);
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   friend nsresult (::NS_NewSVGSVGElement(nsIContent **aResult,
                                          already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                          mozilla::dom::FromParser aFromParser));
 
   ~SVGSVGElement();
--- a/dom/svg/SVGScriptElement.cpp
+++ b/dom/svg/SVGScriptElement.cpp
@@ -33,19 +33,19 @@ nsSVGElement::StringInfo SVGScriptElemen
 
 NS_IMPL_ISUPPORTS_INHERITED(SVGScriptElement, SVGScriptElementBase,
                             nsIScriptLoaderObserver,
                             nsIScriptElement, nsIMutationObserver)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGScriptElement::SVGScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+SVGScriptElement::SVGScriptElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                    FromParser aFromParser)
-  : SVGScriptElementBase(aNodeInfo)
+  : SVGScriptElementBase(std::move(aNodeInfo))
   , ScriptElement(aFromParser)
 {
   AddMutationObserver(this);
 }
 
 SVGScriptElement::~SVGScriptElement()
 {
 }
@@ -53,18 +53,18 @@ SVGScriptElement::~SVGScriptElement()
 //----------------------------------------------------------------------
 // nsINode methods
 
 nsresult
 SVGScriptElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const
 {
   *aResult = nullptr;
 
-  already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
-  SVGScriptElement* it = new SVGScriptElement(ni, NOT_FROM_PARSER);
+  SVGScriptElement* it =
+    new SVGScriptElement(do_AddRef(aNodeInfo), NOT_FROM_PARSER);
 
   nsCOMPtr<nsINode> kungFuDeathGrip = it;
   nsresult rv1 = it->Init();
   nsresult rv2 = const_cast<SVGScriptElement*>(this)->CopyInnerTo(it);
   NS_ENSURE_SUCCESS(rv1, rv1);
   NS_ENSURE_SUCCESS(rv2, rv2);
 
   // The clone should be marked evaluated if we are.
--- a/dom/svg/SVGScriptElement.h
+++ b/dom/svg/SVGScriptElement.h
@@ -25,17 +25,17 @@ typedef nsSVGElement SVGScriptElementBas
 
 class SVGScriptElement final : public SVGScriptElementBase,
                                public ScriptElement
 {
 protected:
   friend nsresult (::NS_NewSVGScriptElement(nsIContent **aResult,
                                             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                                             mozilla::dom::FromParser aFromParser));
-  SVGScriptElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
+  SVGScriptElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
                    FromParser aFromParser);
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // interfaces:
 
   NS_DECL_ISUPPORTS_INHERITED
--- a/dom/svg/SVGSetElement.cpp
+++ b/dom/svg/SVGSetElement.cpp
@@ -16,18 +16,18 @@ JSObject*
 SVGSetElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGSetElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGSetElement::SVGSetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGAnimationElement(aNodeInfo)
+SVGSetElement::SVGSetElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGAnimationElement(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGSetElement)
 
--- a/dom/svg/SVGSetElement.h
+++ b/dom/svg/SVGSetElement.h
@@ -15,17 +15,17 @@ nsresult NS_NewSVGSetElement(nsIContent 
                              already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
 namespace mozilla {
 namespace dom {
 
 class SVGSetElement final : public SVGAnimationElement
 {
 protected:
-  explicit SVGSetElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGSetElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
   nsSMILSetAnimationFunction mAnimationFunction;
 
   friend nsresult (::NS_NewSVGSetElement(nsIContent **aResult,
                                          already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
--- a/dom/svg/SVGStopElement.cpp
+++ b/dom/svg/SVGStopElement.cpp
@@ -19,18 +19,18 @@ SVGStopElement::WrapNode(JSContext *aCx,
 }
 
 nsSVGElement::NumberInfo SVGStopElement::sNumberInfo =
 { &nsGkAtoms::offset, 0, true };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGStopElement::SVGStopElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGStopElementBase(aNodeInfo)
+SVGStopElement::SVGStopElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGStopElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGStopElement)
 
--- a/dom/svg/SVGStopElement.h
+++ b/dom/svg/SVGStopElement.h
@@ -18,17 +18,17 @@ typedef nsSVGElement SVGStopElementBase;
 namespace mozilla {
 namespace dom {
 
 class SVGStopElement final : public SVGStopElementBase
 {
 protected:
   friend nsresult (::NS_NewSVGStopElement(nsIContent **aResult,
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGStopElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGStopElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
--- a/dom/svg/SVGStyleElement.cpp
+++ b/dom/svg/SVGStyleElement.cpp
@@ -38,18 +38,18 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(SVGStyleElement,
                                                 SVGStyleElementBase)
   tmp->nsStyleLinkElement::Unlink();
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGStyleElement::SVGStyleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGStyleElementBase(aNodeInfo)
+SVGStyleElement::SVGStyleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGStyleElementBase(std::move(aNodeInfo))
 {
   AddMutationObserver(this);
 }
 
 SVGStyleElement::~SVGStyleElement()
 {
 }
 
--- a/dom/svg/SVGStyleElement.h
+++ b/dom/svg/SVGStyleElement.h
@@ -22,17 +22,17 @@ namespace dom {
 
 class SVGStyleElement final : public SVGStyleElementBase,
                               public nsStyleLinkElement,
                               public nsStubMutationObserver
 {
 protected:
   friend nsresult (::NS_NewSVGStyleElement(nsIContent **aResult,
                                            already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGStyleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGStyleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   ~SVGStyleElement();
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SVGStyleElement,
--- a/dom/svg/SVGSwitchElement.cpp
+++ b/dom/svg/SVGSwitchElement.cpp
@@ -34,18 +34,18 @@ NS_IMPL_ADDREF_INHERITED(SVGSwitchElemen
 NS_IMPL_RELEASE_INHERITED(SVGSwitchElement,SVGSwitchElementBase)
 
 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(SVGSwitchElement)
 NS_INTERFACE_MAP_END_INHERITING(SVGSwitchElementBase)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGSwitchElement::SVGSwitchElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGSwitchElementBase(aNodeInfo)
+SVGSwitchElement::SVGSwitchElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+: SVGSwitchElementBase(std::move(aNodeInfo))
 {
 }
 
 SVGSwitchElement::~SVGSwitchElement()
 {
 }
 
 void
--- a/dom/svg/SVGSwitchElement.h
+++ b/dom/svg/SVGSwitchElement.h
@@ -20,17 +20,17 @@ namespace dom {
 typedef SVGGraphicsElement SVGSwitchElementBase;
 
 class SVGSwitchElement final : public SVGSwitchElementBase
 {
   friend class ::nsSVGSwitchFrame;
 protected:
   friend nsresult (::NS_NewSVGSwitchElement(nsIContent **aResult,
                                             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGSwitchElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGSwitchElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   ~SVGSwitchElement();
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   nsIContent * GetActiveChild() const
   { return mActiveChild; }
   void MaybeInvalidate();
 
--- a/dom/svg/SVGSymbolElement.cpp
+++ b/dom/svg/SVGSymbolElement.cpp
@@ -22,18 +22,18 @@ SVGSymbolElement::WrapNode(JSContext *aC
 // nsISupports methods
 
 NS_IMPL_ISUPPORTS_INHERITED(SVGSymbolElement, SVGSymbolElementBase,
                             mozilla::dom::SVGTests)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGSymbolElement::SVGSymbolElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGSymbolElementBase(aNodeInfo)
+SVGSymbolElement::SVGSymbolElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGSymbolElementBase(std::move(aNodeInfo))
 {
 }
 
 SVGSymbolElement::~SVGSymbolElement()
 {
 }
 
 //----------------------------------------------------------------------
--- a/dom/svg/SVGSymbolElement.h
+++ b/dom/svg/SVGSymbolElement.h
@@ -17,17 +17,17 @@ namespace dom {
 
 typedef SVGViewportElement SVGSymbolElementBase;
 
 class SVGSymbolElement final : public SVGSymbolElementBase
 {
 protected:
   friend nsresult (::NS_NewSVGSymbolElement(nsIContent **aResult,
                                             already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGSymbolElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGSymbolElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   ~SVGSymbolElement();
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // interfaces:
   NS_DECL_ISUPPORTS_INHERITED
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
--- a/dom/svg/SVGTSpanElement.cpp
+++ b/dom/svg/SVGTSpanElement.cpp
@@ -17,18 +17,18 @@ SVGTSpanElement::WrapNode(JSContext *aCx
 {
   return SVGTSpanElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGTSpanElement::SVGTSpanElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGTSpanElementBase(aNodeInfo)
+SVGTSpanElement::SVGTSpanElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGTSpanElementBase(std::move(aNodeInfo))
 {
 }
 
 nsSVGElement::EnumAttributesInfo
 SVGTSpanElement::GetEnumInfo()
 {
   return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
                             ArrayLength(sEnumInfo));
--- a/dom/svg/SVGTSpanElement.h
+++ b/dom/svg/SVGTSpanElement.h
@@ -17,17 +17,17 @@ namespace dom {
 
 typedef SVGTextPositioningElement SVGTSpanElementBase;
 
 class SVGTSpanElement final : public SVGTSpanElementBase
 {
 protected:
   friend nsresult (::NS_NewSVGTSpanElement(nsIContent **aResult,
                                            already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGTSpanElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGTSpanElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
--- a/dom/svg/SVGTextContentElement.h
+++ b/dom/svg/SVGTextContentElement.h
@@ -44,18 +44,18 @@ public:
   already_AddRefed<nsISVGPoint> GetEndPositionOfChar(uint32_t charnum, ErrorResult& rv);
   MOZ_CAN_RUN_SCRIPT
   already_AddRefed<SVGIRect> GetExtentOfChar(uint32_t charnum, ErrorResult& rv);
   MOZ_CAN_RUN_SCRIPT float GetRotationOfChar(uint32_t charnum, ErrorResult& rv);
   MOZ_CAN_RUN_SCRIPT int32_t GetCharNumAtPosition(nsISVGPoint& point);
 
 protected:
 
-  explicit SVGTextContentElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGTextContentElementBase(aNodeInfo)
+  explicit SVGTextContentElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGTextContentElementBase(std::move(aNodeInfo))
   {}
 
   MOZ_CAN_RUN_SCRIPT SVGTextFrame* GetSVGTextFrame();
   MOZ_CAN_RUN_SCRIPT SVGTextFrame* GetSVGTextFrameForNonLayoutDependentQuery();
   MOZ_CAN_RUN_SCRIPT mozilla::Maybe<int32_t> GetNonLayoutDependentNumberOfChars();
 
   enum { LENGTHADJUST };
   virtual nsSVGEnum* EnumAttributes() = 0;
--- a/dom/svg/SVGTextElement.cpp
+++ b/dom/svg/SVGTextElement.cpp
@@ -16,18 +16,18 @@ JSObject*
 SVGTextElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return SVGTextElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGTextElement::SVGTextElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGTextElementBase(aNodeInfo)
+SVGTextElement::SVGTextElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGTextElementBase(std::move(aNodeInfo))
 {
 }
 
 nsSVGElement::EnumAttributesInfo
 SVGTextElement::GetEnumInfo()
 {
   return EnumAttributesInfo(mEnumAttributes, sEnumInfo,
                             ArrayLength(sEnumInfo));
--- a/dom/svg/SVGTextElement.h
+++ b/dom/svg/SVGTextElement.h
@@ -15,17 +15,17 @@ nsresult NS_NewSVGTextElement(nsIContent
 namespace mozilla {
 namespace dom {
 
 typedef SVGTextPositioningElement SVGTextElementBase;
 
 class SVGTextElement final : public SVGTextElementBase
 {
 protected:
-  explicit SVGTextElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGTextElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
   friend nsresult (::NS_NewSVGTextElement(nsIContent **aResult,
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
 
 public:
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
--- a/dom/svg/SVGTextPathElement.cpp
+++ b/dom/svg/SVGTextPathElement.cpp
@@ -80,18 +80,18 @@ nsSVGElement::StringInfo SVGTextPathElem
 {
   { &nsGkAtoms::href, kNameSpaceID_None, true },
   { &nsGkAtoms::href, kNameSpaceID_XLink, true }
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGTextPathElement::SVGTextPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGTextPathElementBase(aNodeInfo)
+SVGTextPathElement::SVGTextPathElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGTextPathElementBase(std::move(aNodeInfo))
 {
 }
 
 void
 SVGTextPathElement::HrefAsString(nsAString& aHref)
 {
   if (mStringAttributes[SVGTextPathElement::HREF].IsExplicitlySet()) {
     mStringAttributes[SVGTextPathElement::HREF]
--- a/dom/svg/SVGTextPathElement.h
+++ b/dom/svg/SVGTextPathElement.h
@@ -30,17 +30,17 @@ typedef SVGTextContentElement SVGTextPat
 
 class SVGTextPathElement final : public SVGTextPathElementBase
 {
 friend class ::SVGTextFrame;
 
 protected:
   friend nsresult (::NS_NewSVGTextPathElement(nsIContent **aResult,
                                               already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGTextPathElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGTextPathElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
--- a/dom/svg/SVGTextPositioningElement.h
+++ b/dom/svg/SVGTextPositioningElement.h
@@ -26,18 +26,18 @@ public:
   already_AddRefed<DOMSVGAnimatedLengthList> X();
   already_AddRefed<DOMSVGAnimatedLengthList> Y();
   already_AddRefed<DOMSVGAnimatedLengthList> Dx();
   already_AddRefed<DOMSVGAnimatedLengthList> Dy();
   already_AddRefed<DOMSVGAnimatedNumberList> Rotate();
 
 protected:
 
-  explicit SVGTextPositioningElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGTextPositioningElementBase(aNodeInfo)
+  explicit SVGTextPositioningElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGTextPositioningElementBase(std::move(aNodeInfo))
   {}
 
   virtual LengthListAttributesInfo GetLengthListInfo() override;
   virtual NumberListAttributesInfo GetNumberListInfo() override;
 
   enum { ATTR_X, ATTR_Y, ATTR_DX, ATTR_DY };
   SVGAnimatedLengthList mLengthListAttributes[4];
   static LengthListInfo sLengthListInfo[4];
--- a/dom/svg/SVGTitleElement.cpp
+++ b/dom/svg/SVGTitleElement.cpp
@@ -22,18 +22,18 @@ SVGTitleElement::WrapNode(JSContext *aCx
 // nsISupports methods
 
 NS_IMPL_ISUPPORTS_INHERITED(SVGTitleElement, SVGTitleElementBase,
                             nsIMutationObserver)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGTitleElement::SVGTitleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGTitleElementBase(aNodeInfo)
+SVGTitleElement::SVGTitleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGTitleElementBase(std::move(aNodeInfo))
 {
   AddMutationObserver(this);
 }
 
 SVGTitleElement::~SVGTitleElement()
 {
 }
 
--- a/dom/svg/SVGTitleElement.h
+++ b/dom/svg/SVGTitleElement.h
@@ -19,17 +19,17 @@ namespace mozilla {
 namespace dom {
 
 class SVGTitleElement final : public SVGTitleElementBase,
                               public nsStubMutationObserver
 {
 protected:
   friend nsresult (::NS_NewSVGTitleElement(nsIContent **aResult,
                                            already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGTitleElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGTitleElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   ~SVGTitleElement();
 
   virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   // interfaces:
 
   NS_DECL_ISUPPORTS_INHERITED
--- a/dom/svg/SVGTransformableElement.h
+++ b/dom/svg/SVGTransformableElement.h
@@ -21,18 +21,18 @@ class SVGAnimatedTransformList;
 class SVGGraphicsElement;
 class SVGMatrix;
 class SVGIRect;
 struct SVGBoundingBoxOptions;
 
 class SVGTransformableElement : public nsSVGElement
 {
 public:
-  explicit SVGTransformableElement(already_AddRefed<dom::NodeInfo>& aNodeInfo)
-    : nsSVGElement(aNodeInfo) {}
+  explicit SVGTransformableElement(already_AddRefed<dom::NodeInfo>&& aNodeInfo)
+    : nsSVGElement(std::move(aNodeInfo)) {}
   virtual ~SVGTransformableElement() {}
 
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override = 0;
 
   // WebIDL
   already_AddRefed<SVGAnimatedTransformList> Transform();
   nsSVGElement* GetNearestViewportElement();
   nsSVGElement* GetFarthestViewportElement();
--- a/dom/svg/SVGUseElement.cpp
+++ b/dom/svg/SVGUseElement.cpp
@@ -69,18 +69,18 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(SVGUseElement,
                                              SVGUseElementBase,
                                              nsIMutationObserver)
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGUseElement::SVGUseElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGUseElementBase(aNodeInfo)
+SVGUseElement::SVGUseElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGUseElementBase(std::move(aNodeInfo))
   , mReferencedElementTracker(this)
 {
 }
 
 SVGUseElement::~SVGUseElement()
 {
   UnlinkSource();
   MOZ_DIAGNOSTIC_ASSERT(
@@ -91,18 +91,17 @@ SVGUseElement::~SVGUseElement()
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 nsresult
 SVGUseElement::Clone(dom::NodeInfo* aNodeInfo, nsINode** aResult) const
 {
   *aResult = nullptr;
-  already_AddRefed<mozilla::dom::NodeInfo> ni = RefPtr<mozilla::dom::NodeInfo>(aNodeInfo).forget();
-  SVGUseElement *it = new SVGUseElement(ni);
+  SVGUseElement *it = new SVGUseElement(do_AddRef(aNodeInfo));
 
   nsCOMPtr<nsINode> kungFuDeathGrip(it);
   nsresult rv1 = it->Init();
   nsresult rv2 = const_cast<SVGUseElement*>(this)->CopyInnerTo(it);
 
   // SVGUseElement specific portion - record who we cloned from
   it->mOriginal = const_cast<SVGUseElement*>(this);
 
--- a/dom/svg/SVGUseElement.h
+++ b/dom/svg/SVGUseElement.h
@@ -34,17 +34,17 @@ typedef SVGGraphicsElement SVGUseElement
 
 class SVGUseElement final : public SVGUseElementBase,
                             public nsStubMutationObserver
 {
   friend class ::nsSVGUseFrame;
 protected:
   friend nsresult (::NS_NewSVGUseElement(nsIContent **aResult,
                                          already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
-  explicit SVGUseElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGUseElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   virtual ~SVGUseElement();
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   NS_IMPL_FROMNODE_WITH_TAG(SVGUseElement, kNameSpaceID_SVG, use)
 
   nsresult BindToTree(nsIDocument* aDocument,
                       nsIContent* aParent,
--- a/dom/svg/SVGViewElement.cpp
+++ b/dom/svg/SVGViewElement.cpp
@@ -32,18 +32,18 @@ nsSVGElement::EnumInfo SVGViewElement::s
     sZoomAndPanMap,
     SVG_ZOOMANDPAN_MAGNIFY
   }
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGViewElement::SVGViewElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGViewElementBase(aNodeInfo)
+SVGViewElement::SVGViewElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGViewElementBase(std::move(aNodeInfo))
 {
 }
 
 //----------------------------------------------------------------------
 // nsINode methods
 
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(SVGViewElement)
 
--- a/dom/svg/SVGViewElement.h
+++ b/dom/svg/SVGViewElement.h
@@ -28,17 +28,17 @@ class SVGViewportElement;
 
 class SVGViewElement : public SVGViewElementBase
 {
 protected:
   friend class mozilla::SVGFragmentIdentifier;
   friend class SVGSVGElement;
   friend class SVGViewportElement;
   friend class ::nsSVGOuterSVGFrame;
-  explicit SVGViewElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit SVGViewElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   friend nsresult (::NS_NewSVGViewElement(nsIContent **aResult,
                                           already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo));
   virtual JSObject* WrapNode(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
 public:
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
 
   // WebIDL
--- a/dom/svg/SVGViewportElement.cpp
+++ b/dom/svg/SVGViewportElement.cpp
@@ -44,18 +44,18 @@ nsSVGElement::LengthInfo SVGViewportElem
   { &nsGkAtoms::y, 0, SVGLength_Binding::SVG_LENGTHTYPE_NUMBER, SVGContentUtils::Y },
   { &nsGkAtoms::width, 100, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::X },
   { &nsGkAtoms::height, 100, SVGLength_Binding::SVG_LENGTHTYPE_PERCENTAGE, SVGContentUtils::Y },
 };
 
 //----------------------------------------------------------------------
 // Implementation
 
-SVGViewportElement::SVGViewportElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : SVGGraphicsElement(aNodeInfo),
+SVGViewportElement::SVGViewportElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : SVGGraphicsElement(std::move(aNodeInfo)),
     mViewportWidth(0),
     mViewportHeight(0),
     mHasChildrenOnlyTransform(false)
 {
 }
 
 SVGViewportElement::~SVGViewportElement()
 {
--- a/dom/svg/SVGViewportElement.h
+++ b/dom/svg/SVGViewportElement.h
@@ -48,17 +48,17 @@ public:
 
 class SVGViewportElement : public SVGGraphicsElement
 {
   friend class ::nsSVGOuterSVGFrame;
   friend class ::nsSVGViewportFrame;
 
 protected:
 
-  SVGViewportElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  SVGViewportElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   ~SVGViewportElement();
 
 public:
 
   // nsIContent interface
   NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override;
 
   // nsSVGElement specializations:
--- a/dom/svg/nsSVGElement.cpp
+++ b/dom/svg/nsSVGElement.cpp
@@ -65,17 +65,17 @@ using namespace mozilla::dom::SVGUnitTyp
 //   nsSVGElement::GetAnimated{Length,Number,Integer}Values
 // See bug 547964 for details:
 static_assert(sizeof(void*) == sizeof(nullptr),
               "nullptr should be the correct size");
 
 nsresult
 NS_NewSVGElement(Element **aResult, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
 {
-  RefPtr<nsSVGElement> it = new nsSVGElement(aNodeInfo);
+  RefPtr<nsSVGElement> it = new nsSVGElement(std::move(aNodeInfo));
   nsresult rv = it->Init();
 
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   it.forget(aResult);
   return rv;
@@ -84,18 +84,18 @@ NS_NewSVGElement(Element **aResult, alre
 NS_IMPL_ELEMENT_CLONE_WITH_INIT(nsSVGElement)
 
 nsSVGEnumMapping nsSVGElement::sSVGUnitTypesMap[] = {
   {&nsGkAtoms::userSpaceOnUse, SVG_UNIT_TYPE_USERSPACEONUSE},
   {&nsGkAtoms::objectBoundingBox, SVG_UNIT_TYPE_OBJECTBOUNDINGBOX},
   {nullptr, 0}
 };
 
-nsSVGElement::nsSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-  : nsSVGElementBase(aNodeInfo)
+nsSVGElement::nsSVGElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+  : nsSVGElementBase(std::move(aNodeInfo))
 {
 }
 
 nsSVGElement::~nsSVGElement()
 {
   OwnerDoc()->UnscheduleSVGForPresAttrEvaluation(this);
 }
 
--- a/dom/svg/nsSVGElement.h
+++ b/dom/svg/nsSVGElement.h
@@ -62,17 +62,17 @@ class DOMSVGStringList;
 
 struct nsSVGEnumMapping;
 
 typedef nsStyledElement nsSVGElementBase;
 
 class nsSVGElement : public nsSVGElementBase    // nsIContent
 {
 protected:
-  explicit nsSVGElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+  explicit nsSVGElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   friend nsresult NS_NewSVGElement(mozilla::dom::Element **aResult,
                                    already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
   nsresult Init();
   virtual ~nsSVGElement();
 
 public:
 
   virtual nsresult Clone(mozilla::dom::NodeInfo*, nsINode** aResult) const
@@ -636,18 +636,18 @@ private:
 /**
  * A macro to implement the NS_NewSVGXXXElement() functions.
  */
 #define NS_IMPL_NS_NEW_SVG_ELEMENT(_elementName)                             \
 nsresult                                                                     \
 NS_NewSVG##_elementName##Element(nsIContent **aResult,                       \
                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)  \
 {                                                                            \
-  RefPtr<nsSVG##_elementName##Element> it =                                \
-    new nsSVG##_elementName##Element(aNodeInfo);                             \
+  RefPtr<nsSVG##_elementName##Element> it =                                  \
+    new nsSVG##_elementName##Element(std::move(aNodeInfo));                  \
                                                                              \
   nsresult rv = it->Init();                                                  \
                                                                              \
   if (NS_FAILED(rv)) {                                                       \
     return rv;                                                               \
   }                                                                          \
                                                                              \
   it.forget(aResult);                                                        \
@@ -655,18 +655,18 @@ NS_NewSVG##_elementName##Element(nsICont
   return rv;                                                                 \
 }
 
 #define NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT(_elementName)                  \
 nsresult                                                                     \
 NS_NewSVG##_elementName##Element(nsIContent **aResult,                       \
                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)  \
 {                                                                            \
-  RefPtr<mozilla::dom::SVG##_elementName##Element> it =                    \
-    new mozilla::dom::SVG##_elementName##Element(aNodeInfo);                 \
+  RefPtr<mozilla::dom::SVG##_elementName##Element> it =                      \
+    new mozilla::dom::SVG##_elementName##Element(std::move(aNodeInfo));      \
                                                                              \
   nsresult rv = it->Init();                                                  \
                                                                              \
   if (NS_FAILED(rv)) {                                                       \
     return rv;                                                               \
   }                                                                          \
                                                                              \
   it.forget(aResult);                                                        \
@@ -675,18 +675,19 @@ NS_NewSVG##_elementName##Element(nsICont
 }
 
 #define NS_IMPL_NS_NEW_NAMESPACED_SVG_ELEMENT_CHECK_PARSER(_elementName)     \
 nsresult                                                                     \
 NS_NewSVG##_elementName##Element(nsIContent **aResult,                       \
                                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,  \
                                  mozilla::dom::FromParser aFromParser)       \
 {                                                                            \
-  RefPtr<mozilla::dom::SVG##_elementName##Element> it =                    \
-    new mozilla::dom::SVG##_elementName##Element(aNodeInfo, aFromParser);    \
+  RefPtr<mozilla::dom::SVG##_elementName##Element> it =                      \
+    new mozilla::dom::SVG##_elementName##Element(std::move(aNodeInfo),       \
+                                                 aFromParser);               \
                                                                              \
   nsresult rv = it->Init();                                                  \
                                                                              \
   if (NS_FAILED(rv)) {                                                       \
     return rv;                                                               \
   }                                                                          \
                                                                              \
   it.forget(aResult);                                                        \
--- a/dom/svg/nsSVGFilters.h
+++ b/dom/svg/nsSVGFilters.h
@@ -45,18 +45,18 @@ class nsSVGFE : public nsSVGFEBase
 
 protected:
   typedef mozilla::gfx::SourceSurface SourceSurface;
   typedef mozilla::gfx::Size Size;
   typedef mozilla::gfx::IntRect IntRect;
   typedef mozilla::gfx::ColorSpace ColorSpace;
   typedef mozilla::gfx::FilterPrimitiveDescription FilterPrimitiveDescription;
 
-  explicit nsSVGFE(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsSVGFEBase(aNodeInfo) {}
+  explicit nsSVGFE(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsSVGFEBase(std::move(aNodeInfo)) {}
   virtual ~nsSVGFE() {}
 
 public:
   typedef mozilla::gfx::PrimitiveAttributes PrimitiveAttributes;
 
   ColorSpace
   GetInputColorSpace(int32_t aInputIndex, ColorSpace aUnchangedInputColorSpace) {
     return OperatesOnSRGB(aInputIndex, aUnchangedInputColorSpace == ColorSpace::SRGB) ?
@@ -150,18 +150,18 @@ protected:
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsSVGFE, NS_SVG_FE_CID)
 
 typedef nsSVGElement SVGFEUnstyledElementBase;
 
 class SVGFEUnstyledElement : public SVGFEUnstyledElementBase
 {
 protected:
-  explicit SVGFEUnstyledElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFEUnstyledElementBase(aNodeInfo) {}
+  explicit SVGFEUnstyledElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFEUnstyledElementBase(std::move(aNodeInfo)) {}
 
 public:
   virtual nsresult Clone(mozilla::dom::NodeInfo*, nsINode** aResult) const override = 0;
 
   // returns true if changes to the attribute should cause us to
   // repaint the filter
   virtual bool AttributeAffectsRendering(
           int32_t aNameSpaceID, nsAtom* aAttribute) const = 0;
@@ -169,18 +169,18 @@ public:
 
 //------------------------------------------------------------
 
 typedef nsSVGFE nsSVGFELightingElementBase;
 
 class nsSVGFELightingElement : public nsSVGFELightingElementBase
 {
 protected:
-  explicit nsSVGFELightingElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsSVGFELightingElementBase(aNodeInfo) {}
+  explicit nsSVGFELightingElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsSVGFELightingElementBase(std::move(aNodeInfo)) {}
 
   virtual ~nsSVGFELightingElement() {}
 
 public:
   // interfaces:
   NS_INLINE_DECL_REFCOUNTING_INHERITED(nsSVGFELightingElement,
                                        nsSVGFELightingElementBase)
 
@@ -220,18 +220,18 @@ protected:
 namespace mozilla {
 namespace dom {
 
 typedef SVGFEUnstyledElement SVGFELightElementBase;
 
 class SVGFELightElement : public SVGFELightElementBase
 {
 protected:
-  explicit SVGFELightElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : SVGFELightElementBase(aNodeInfo) {}
+  explicit SVGFELightElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : SVGFELightElementBase(std::move(aNodeInfo)) {}
 
 public:
   typedef gfx::PrimitiveAttributes PrimitiveAttributes;
 
   virtual mozilla::gfx::LightType ComputeLightAttributes(nsSVGFilterInstance* aInstance,
                                                          nsTArray<float>& aFloatAttributes) = 0;
 };
 
--- a/dom/tests/mochitest/bugs/test_bug1171215.html
+++ b/dom/tests/mochitest/bugs/test_bug1171215.html
@@ -22,22 +22,18 @@ https://bugzilla.mozilla.org/show_bug.cg
     document.cookie = "a=b";
 
     // Set a cookie in example.org so we can test that we can't read it in
     // third-party cases.
     f.contentWindow.location =
         "http://example.org/tests/dom/tests/mochitest/bugs/file_prime_cookie.html";
     waitForLoad().then(function() {
         // Cookies are set up, disallow third-party cookies and start the test.
-        SpecialPowers.pushPrefEnv({ set: [
-            ["browser.contentblocking.enabled", true],
-            ["browser.contentblocking.ui.enabled", true],
-            ["browser.contentblocking.rejecttrackers.ui.enabled", true],
-            ["network.cookie.cookieBehavior", 1],
-          ]}, () => { continueTest(); });
+        SpecialPowers.pushPrefEnv({ set: [[ 'network.cookie.cookieBehavior', 1 ]] },
+                                  () => { continueTest(); });
     }).catch((e) => { ok(false, `Got exception: ${e}`) });
   }
 
   function waitForLoad() {
     return new Promise((resolve) => {
       window.addEventListener("message", function(msg) {
         info(`got message ${msg.data}`);
         resolve(msg.data);
--- a/dom/tests/mochitest/general/storagePermissionsUtils.js
+++ b/dom/tests/mochitest/general/storagePermissionsUtils.js
@@ -21,22 +21,17 @@ if (inFrame) {
   };
 } else {
   finishTest = function() {
     SimpleTest.finish();
   };
 }
 
 function setCookieBehavior(behavior) {
-  return SpecialPowers.pushPrefEnv({"set": [
-    ["browser.contentblocking.enabled", true],
-    ["browser.contentblocking.ui.enabled", true],
-    ["browser.contentblocking.rejecttrackers.ui.enabled", true],
-    [kPrefName, behavior],
-  ]});
+  return SpecialPowers.pushPrefEnv({"set": [[kPrefName, behavior]]});
 }
 
 function runIFrame(url) {
   return new Promise((resolve, reject) => {
     function onMessage(e)  {
       if (e.data == "done") {
         resolve();
         window.removeEventListener('message', onMessage);
--- a/dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html
+++ b/dom/tests/mochitest/localstorage/test_localStorageCookieSettings.html
@@ -10,22 +10,18 @@
 <body>
 <iframe></iframe>
 
 <script type="text/javascript">
 
 SimpleTest.waitForExplicitFinish();
 
 // Set cookies behavior to "always reject".
-SpecialPowers.pushPrefEnv({"set": [
-  ["browser.contentblocking.enabled", true],
-  ["browser.contentblocking.ui.enabled", true],
-  ["browser.contentblocking.rejecttrackers.ui.enabled", true],
-  ["network.cookie.cookieBehavior", 2],
-]}, test1);
+SpecialPowers.pushPrefEnv({"set": [["network.cookie.cookieBehavior", 2]]},
+                          test1);
 
 function test1() {
   try {
     localStorage.setItem("contentkey", "test-value");
     ok(false, "Setting localStorageItem should throw a security exception");
   }
   catch(ex) {
     is(ex.name, "SecurityError");
--- a/dom/workers/test/test_sharedWorker_thirdparty.html
+++ b/dom/workers/test/test_sharedWorker_thirdparty.html
@@ -42,19 +42,16 @@
     ]});
     let result = await testThirdPartyFrame('allowed');
     ok(result === 'allowed',
        'SharedWorker should be allowed when 3rd party iframes can access storage');
   });
 
   add_task(async function blocked() {
     await SpecialPowers.pushPrefEnv({ set: [
-      ["browser.contentblocking.enabled", true],
-      ["browser.contentblocking.ui.enabled", true],
-      ["browser.contentblocking.rejecttrackers.ui.enabled", true],
       ["network.cookie.cookieBehavior", COOKIE_BEHAVIOR_REJECTFOREIGN]
     ]});
     let result = await testThirdPartyFrame('blocked');
     ok(result === 'blocked',
        'SharedWorker should not be allowed when 3rd party iframes are denied storage');
   });
 
   </script>
--- a/dom/xbl/XBLChildrenElement.h
+++ b/dom/xbl/XBLChildrenElement.h
@@ -14,22 +14,18 @@
 class nsAnonymousContentList;
 
 namespace mozilla {
 namespace dom {
 
 class XBLChildrenElement : public nsXMLElement
 {
 public:
-  explicit XBLChildrenElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsXMLElement(aNodeInfo)
-  {
-  }
   explicit XBLChildrenElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
-    : nsXMLElement(aNodeInfo)
+    : nsXMLElement(std::move(aNodeInfo))
   {
   }
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(XBLChildrenElement, nsXMLElement)
 
   // nsINode interface methods
   virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override;
--- a/dom/xml/CDATASection.h
+++ b/dom/xml/CDATASection.h
@@ -20,18 +20,18 @@ private:
   {
     MOZ_ASSERT(mNodeInfo->NodeType() == CDATA_SECTION_NODE,
                "Bad NodeType in aNodeInfo");
   }
 
   virtual ~CDATASection();
 
 public:
-  explicit CDATASection(already_AddRefed<mozilla::dom::NodeInfo> aNodeInfo)
-    : Text(aNodeInfo)
+  explicit CDATASection(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : Text(std::move(aNodeInfo))
   {
     Init();
   }
 
   explicit CDATASection(nsNodeInfoManager* aNodeInfoManager)
     : Text(aNodeInfoManager->GetNodeInfo(nsGkAtoms::cdataTagName,
                                          nullptr, kNameSpaceID_None,
                                          CDATA_SECTION_NODE))
--- a/dom/xml/nsXMLElement.cpp
+++ b/dom/xml/nsXMLElement.cpp
@@ -11,18 +11,18 @@
 
 using namespace mozilla;
 using namespace mozilla::dom;
 
 nsresult
 NS_NewXMLElement(Element** aInstancePtrResult,
                  already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
 {
-  nsXMLElement* it = new nsXMLElement(aNodeInfo);
-  NS_ADDREF(*aInstancePtrResult = it);
+  RefPtr<nsXMLElement> it = new nsXMLElement(std::move(aNodeInfo));
+  it.forget(aInstancePtrResult);
   return NS_OK;
 }
 
 JSObject*
 nsXMLElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return Element_Binding::Wrap(aCx, this, aGivenProto);
 }
--- a/dom/xml/nsXMLElement.h
+++ b/dom/xml/nsXMLElement.h
@@ -9,18 +9,18 @@
 
 #include "mozilla/Attributes.h"
 #include "mozilla/dom/Element.h"
 #include "mozilla/dom/DOMRect.h"
 
 class nsXMLElement : public mozilla::dom::Element
 {
 public:
-  explicit nsXMLElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : mozilla::dom::Element(aNodeInfo)
+  explicit nsXMLElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : mozilla::dom::Element(std::move(aNodeInfo))
   {
   }
 
   // nsISupports
   NS_INLINE_DECL_REFCOUNTING_INHERITED(nsXMLElement, mozilla::dom::Element)
 
   // nsINode interface methods
   virtual nsresult Clone(mozilla::dom::NodeInfo*, nsINode **aResult) const override;
--- a/dom/xul/XULFrameElement.h
+++ b/dom/xul/XULFrameElement.h
@@ -20,18 +20,18 @@ class nsFrameLoader;
 
 namespace mozilla {
 namespace dom {
 
 class XULFrameElement final : public nsXULElement,
                               public nsIFrameLoaderOwner
 {
 public:
-  explicit XULFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsXULElement(aNodeInfo)
+  explicit XULFrameElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsXULElement(std::move(aNodeInfo))
   {
   }
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(XULFrameElement, nsXULElement)
 
   // XULFrameElement.webidl
   nsIDocShell* GetDocShell();
--- a/dom/xul/XULMenuElement.h
+++ b/dom/xul/XULMenuElement.h
@@ -13,18 +13,18 @@ namespace mozilla {
 namespace dom {
 
 class KeyboardEvent;
 
 class XULMenuElement final : public nsXULElement
 {
 public:
 
-  explicit XULMenuElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsXULElement(aNodeInfo)
+  explicit XULMenuElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsXULElement(std::move(aNodeInfo))
   {
   }
 
   MOZ_CAN_RUN_SCRIPT already_AddRefed<Element> GetActiveChild();
   MOZ_CAN_RUN_SCRIPT void SetActiveChild(Element* arg);
   MOZ_CAN_RUN_SCRIPT bool HandleKeyPress(KeyboardEvent& keyEvent);
   MOZ_CAN_RUN_SCRIPT bool OpenedWithKey();
 
--- a/dom/xul/XULPopupElement.cpp
+++ b/dom/xul/XULPopupElement.cpp
@@ -19,17 +19,17 @@
 #include "mozilla/dom/XULPopupElementBinding.h"
 
 namespace mozilla {
 namespace dom {
 
 nsXULElement*
 NS_NewXULPopupElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
 {
-  return new XULPopupElement(aNodeInfo);
+  return new XULPopupElement(std::move(aNodeInfo));
 }
 
 JSObject*
 XULPopupElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return XULPopupElement_Binding::Wrap(aCx, this, aGivenProto);
 }
 
--- a/dom/xul/XULPopupElement.h
+++ b/dom/xul/XULPopupElement.h
@@ -28,18 +28,18 @@ nsXULElement*
 NS_NewXULPopupElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
 class XULPopupElement final : public nsXULElement
 {
 private:
   nsIFrame* GetFrame(bool aFlushLayout);
 
 public:
-  explicit XULPopupElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsXULElement(aNodeInfo)
+  explicit XULPopupElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsXULElement(std::move(aNodeInfo))
   {
   }
 
   void GetLabel(DOMString& aValue) const
   {
       GetXULAttr(nsGkAtoms::label, aValue);
   }
   void SetLabel(const nsAString& aValue, ErrorResult& rv)
--- a/dom/xul/XULScrollElement.h
+++ b/dom/xul/XULScrollElement.h
@@ -12,17 +12,18 @@
 
 namespace mozilla {
 namespace dom {
 
 
 class XULScrollElement final : public nsXULElement
 {
 public:
-  explicit XULScrollElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo): nsXULElement(aNodeInfo)
+  explicit XULScrollElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsXULElement(std::move(aNodeInfo))
   {
   }
 
   MOZ_CAN_RUN_SCRIPT void ScrollByIndex(int32_t aIndex, ErrorResult& aRv);
   MOZ_CAN_RUN_SCRIPT void EnsureElementIsVisible(Element& aChild, ErrorResult& aRv);
   MOZ_CAN_RUN_SCRIPT void ScrollToElement(Element& child, ErrorResult& aRv);
 
 protected:
--- a/dom/xul/nsXULElement.cpp
+++ b/dom/xul/nsXULElement.cpp
@@ -98,18 +98,18 @@ uint32_t             nsXULPrototypeAttri
 #endif
 
 #define NS_DISPATCH_XUL_COMMAND     (1 << 0)
 
 //----------------------------------------------------------------------
 // nsXULElement
 //
 
-nsXULElement::nsXULElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
-    : nsStyledElement(aNodeInfo),
+nsXULElement::nsXULElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
+    : nsStyledElement(std::move(aNodeInfo)),
       mBindingParent(nullptr)
 {
     XUL_PROTOTYPE_ATTRIBUTE_METER(gNumElements);
 
     // We may be READWRITE by default; check.
     if (IsReadWriteTextElement()) {
         AddStatesSilently(NS_EVENT_STATE_MOZ_READWRITE);
         RemoveStatesSilently(NS_EVENT_STATE_MOZ_READONLY);
@@ -134,46 +134,43 @@ nsXULElement::MaybeUpdatePrivateLifetime
     if (docShell) {
         docShell->SetAffectPrivateSessionLifetime(false);
     }
 }
 
 /* static */
 nsXULElement* NS_NewBasicXULElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
 {
-  return new nsXULElement(aNodeInfo);
+    return new nsXULElement(std::move(aNodeInfo));
 }
 
  /* static */
 nsXULElement* nsXULElement::Construct(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo)
 {
   RefPtr<mozilla::dom::NodeInfo> nodeInfo = aNodeInfo;
   if (nodeInfo->Equals(nsGkAtoms::menupopup) ||
       nodeInfo->Equals(nsGkAtoms::popup) ||
       nodeInfo->Equals(nsGkAtoms::panel) ||
       nodeInfo->Equals(nsGkAtoms::tooltip)) {
     return NS_NewXULPopupElement(nodeInfo.forget());
   }
 
   if (nodeInfo->Equals(nsGkAtoms::iframe) ||
       nodeInfo->Equals(nsGkAtoms::browser) ||
       nodeInfo->Equals(nsGkAtoms::editor)) {
-    already_AddRefed<mozilla::dom::NodeInfo> frameni = nodeInfo.forget();
-    return new XULFrameElement(frameni);
+    return new XULFrameElement(nodeInfo.forget());
   }
 
   if (nodeInfo->Equals(nsGkAtoms::menu) ||
       nodeInfo->Equals(nsGkAtoms::menulist)) {
-    already_AddRefed<mozilla::dom::NodeInfo> menuni = nodeInfo.forget();
-    return new XULMenuElement(menuni);
+    return new XULMenuElement(nodeInfo.forget());
   }
 
   if (nodeInfo->Equals(nsGkAtoms::scrollbox)) {
-    already_AddRefed<mozilla::dom::NodeInfo> scrollni = nodeInfo.forget();
-    return new XULScrollElement(scrollni);
+    return new XULScrollElement(nodeInfo.forget());
   }
 
   return NS_NewBasicXULElement(nodeInfo.forget());
 }
 
 /* static */
 already_AddRefed<nsXULElement>
 nsXULElement::CreateFromPrototype(nsXULPrototypeElement* aPrototype,
--- a/dom/xul/nsXULElement.h
+++ b/dom/xul/nsXULElement.h
@@ -330,17 +330,17 @@ enum {
 ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 2);
 
 #undef XUL_ELEMENT_FLAG_BIT
 
 class nsXULElement : public nsStyledElement
 {
 protected:
     // Use Construct to construct elements instead of this constructor.
-    explicit nsXULElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
+    explicit nsXULElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo);
 
 public:
     using Element::Blur;
     using Element::Focus;
 
     static nsresult
     CreateFromPrototype(nsXULPrototypeElement* aPrototype,
                         nsIDocument* aDocument,
--- a/extensions/cookie/test/file_testcommon.js
+++ b/extensions/cookie/test/file_testcommon.js
@@ -8,22 +8,17 @@ var gPopup;
 var gScript;
 
 var gLoads = 0;
 
 function setupTest(uri, cookies, loads) {
   SimpleTest.waitForExplicitFinish();
 
   var prefSet = new Promise(resolve => {
-    SpecialPowers.pushPrefEnv({ set: [
-      ["browser.contentblocking.enabled", true],
-      ["browser.contentblocking.ui.enabled", true],
-      ["browser.contentblocking.rejecttrackers.ui.enabled", true],
-      ["network.cookie.cookieBehavior", 1],
-    ]}, resolve);
+    SpecialPowers.pushPrefEnv({ set: [["network.cookie.cookieBehavior", 1]] }, resolve);
   });
 
   gScript = SpecialPowers.loadChromeScript(SCRIPT_URL);
   gExpectedCookies = cookies;
   gExpectedLoads = loads;
 
   // Listen for MessageEvents.
   window.addEventListener("message", messageReceiver);
--- a/extensions/cookie/test/unit/test_cookies_thirdparty.js
+++ b/extensions/cookie/test/unit/test_cookies_thirdparty.js
@@ -1,21 +1,16 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // test third party cookie blocking, for the cases:
 // 1) with null channel
 // 2) with channel, but with no docshell parent
 
 function run_test() {
-  // Set the needed content blocking prefs
-  Services.prefs.setBoolPref("browser.contentblocking.enabled", true);
-  Services.prefs.setBoolPref("browser.contentblocking.ui.enabled", true);
-  Services.prefs.setBoolPref("browser.contentblocking.rejecttrackers.ui.enabled", true);
-
   // Create URIs and channels pointing to foo.com and bar.com.
   // We will use these to put foo.com into first and third party contexts.
   var spec1 = "http://foo.com/foo.html";
   var spec2 = "http://bar.com/bar.html";
   var uri1 = NetUtil.newURI(spec1);
   var uri2 = NetUtil.newURI(spec2);
   var channel1 = NetUtil.newChannel({uri: uri1, loadUsingSystemPrincipal: true});
   var channel2 = NetUtil.newChannel({uri: uri2, loadUsingSystemPrincipal: true});
--- a/gfx/layers/wr/StackingContextHelper.cpp
+++ b/gfx/layers/wr/StackingContextHelper.cpp
@@ -31,32 +31,32 @@ StackingContextHelper::StackingContextHe
                                              const float* aOpacityPtr,
                                              const gfx::Matrix4x4* aTransformPtr,
                                              const gfx::Matrix4x4* aPerspectivePtr,
                                              const gfx::CompositionOp& aMixBlendMode,
                                              bool aBackfaceVisible,
                                              bool aIsPreserve3D,
                                              const Maybe<nsDisplayTransform*>& aDeferredTransformItem,
                                              const wr::WrClipId* aClipNodeId,
-                                             bool aRasterizeLocally)
+                                             bool aAnimated)
   : mBuilder(&aBuilder)
   , mScale(1.0f, 1.0f)
   , mDeferredTransformItem(aDeferredTransformItem)
   , mIsPreserve3D(aIsPreserve3D)
-  , mRasterizeLocally(aRasterizeLocally || aParentSC.mRasterizeLocally)
+  , mRasterizeLocally(aAnimated || aParentSC.mRasterizeLocally)
 {
   // Compute scale for fallback rendering. We don't try to guess a scale for 3d
   // transformed items
   gfx::Matrix transform2d;
   if (aBoundTransform && aBoundTransform->CanDraw2D(&transform2d)
       && !aPerspectivePtr
       && !aParentSC.mIsPreserve3D) {
     mInheritedTransform = transform2d * aParentSC.mInheritedTransform;
     mScale = mInheritedTransform.ScaleFactors(true);
-    if (aAnimation) {
+    if (aAnimated) {
       mSnappingSurfaceTransform = gfx::Matrix::Scaling(mScale.width, mScale.height);
     } else {
       mSnappingSurfaceTransform = transform2d * aParentSC.mSnappingSurfaceTransform;
     }
   } else {
     mInheritedTransform = aParentSC.mInheritedTransform;
     mScale = aParentSC.mScale;
   }
--- a/gfx/layers/wr/StackingContextHelper.h
+++ b/gfx/layers/wr/StackingContextHelper.h
@@ -34,17 +34,17 @@ public:
                         const float* aOpacityPtr = nullptr,
                         const gfx::Matrix4x4* aTransformPtr = nullptr,
                         const gfx::Matrix4x4* aPerspectivePtr = nullptr,
                         const gfx::CompositionOp& aMixBlendMode = gfx::CompositionOp::OP_OVER,
                         bool aBackfaceVisible = true,
                         bool aIsPreserve3D = false,
                         const Maybe<nsDisplayTransform*>& aDeferredTransformItem = Nothing(),
                         const wr::WrClipId* aClipNodeId = nullptr,
-                        bool aRasterizeLocally = false);
+                        bool aAnimated = false);
   // This version of the constructor should only be used at the root level
   // of the tree, so that we have a StackingContextHelper to pass down into
   // the RenderLayer traversal, but don't actually want it to push a stacking
   // context on the display list builder.
   StackingContextHelper();
 
   // Pops the stacking context, if one was pushed during the constructor.
   ~StackingContextHelper();
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -850,25 +850,35 @@ Grouper::PaintContainerItem(DIGroup* aGr
         aContext->GetDrawTarget()->FlushItem(aItemBounds);
       } else {
         matrix = aContext->CurrentMatrix();
       }
 
       auto transformItem = static_cast<nsDisplayTransform*>(aItem);
       Matrix4x4Flagged trans = transformItem->GetTransform();
       Matrix trans2d;
-      MOZ_RELEASE_ASSERT(trans.Is2D(&trans2d));
-      aContext->Multiply(ThebesMatrix(trans2d));
-      aGroup->PaintItemRange(this, aChildren->GetBottom(), nullptr, aContext, aRecorder);
+      if (!trans.Is2D(&trans2d)) {
+        // We don't currently support doing invalidation inside 3d transforms.
+        // For now just paint it as a single item.
+        BlobItemData* data = GetBlobItemDataForGroup(aItem, aGroup);
+        if (data->mLayerManager->GetRoot()) {
+          data->mLayerManager->BeginTransaction();
+          data->mLayerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer, mDisplayListBuilder);
+          aContext->GetDrawTarget()->FlushItem(aItemBounds);
+        }
+      } else {
+        aContext->Multiply(ThebesMatrix(trans2d));
+        aGroup->PaintItemRange(this, aChildren->GetBottom(), nullptr, aContext, aRecorder);
 
-      if (currentClip.HasClip()) {
-        aContext->Restore();
-        aContext->GetDrawTarget()->FlushItem(aItemBounds);
-      } else {
-        aContext->SetMatrix(matrix);
+        if (currentClip.HasClip()) {
+          aContext->Restore();
+          aContext->GetDrawTarget()->FlushItem(aItemBounds);
+        } else {
+          aContext->SetMatrix(matrix);
+        }
       }
       break;
     }
     case DisplayItemType::TYPE_OPACITY: {
       auto opacityItem = static_cast<nsDisplayOpacity*>(aItem);
       float opacity = opacityItem->GetOpacity();
       if (opacity == 0.0f) {
         return;
@@ -892,26 +902,25 @@ Grouper::PaintContainerItem(DIGroup* aGr
       aGroup->PaintItemRange(this, aChildren->GetBottom(), nullptr, aContext, aRecorder);
       aContext->GetDrawTarget()->PopLayer();
       GP("endGroup %s %p-%d\n", aItem->Name(), aItem->Frame(), aItem->GetPerFrameKey());
       aContext->GetDrawTarget()->FlushItem(aItemBounds);
       break;
     }
     case DisplayItemType::TYPE_MASK: {
       GP("Paint Mask\n");
-      // We don't currently support doing invalidation inside nsDisplayMask
-      // for now just paint it as a single item
-      BlobItemData* data = GetBlobItemDataForGroup(aItem, aGroup);
-      if (data->mLayerManager->GetRoot()) {
-        data->mLayerManager->BeginTransaction();
-        static_cast<nsDisplayMask*>(aItem)->PaintAsLayer(mDisplayListBuilder,
-                                                       aContext, data->mLayerManager);
-        if (data->mLayerManager->InTransaction()) {
-          data->mLayerManager->AbortTransaction();
-        }
+      auto maskItem = static_cast<nsDisplayMask*>(aItem);
+      maskItem->SetPaintRect(maskItem->GetClippedBounds(mDisplayListBuilder));
+      if (maskItem->IsValidMask()) {
+        maskItem->PaintWithContentsPaintCallback(mDisplayListBuilder, aContext, [&] {
+          GP("beginGroup %s %p-%d\n", aItem->Name(), aItem->Frame(), aItem->GetPerFrameKey());
+          aContext->GetDrawTarget()->FlushItem(aItemBounds);
+          aGroup->PaintItemRange(this, aChildren->GetBottom(), nullptr, aContext, aRecorder);
+          GP("endGroup %s %p-%d\n", aItem->Name(), aItem->Frame(), aItem->GetPerFrameKey());
+          });
         aContext->GetDrawTarget()->FlushItem(aItemBounds);
       }
       break;
     }
     case DisplayItemType::TYPE_FILTER: {
       GP("Paint Filter\n");
       // We don't currently support doing invalidation inside nsDisplayFilter
       // for now just paint it as a single item
@@ -1095,37 +1104,42 @@ Grouper::ConstructItemInsideInactive(Web
                                      wr::DisplayListBuilder& aBuilder,
                                      wr::IpcResourceUpdateQueue& aResources,
                                      DIGroup* aGroup, nsDisplayItem* aItem,
                                      const StackingContextHelper& aSc)
 {
   nsDisplayList* children = aItem->GetChildren();
   BlobItemData* data = GetBlobItemDataForGroup(aItem, aGroup);
 
-  if (aItem->GetType() == DisplayItemType::TYPE_FILTER ||
-      aItem->GetType() == DisplayItemType::TYPE_MASK) {
+  if (aItem->GetType() == DisplayItemType::TYPE_FILTER) {
     gfx::Size scale(1, 1);
     // If ComputeDifferences finds any change, we invalidate the entire container item.
     // This is needed because blob merging requires the entire item to be within the invalid region.
     data->mInvalid = BuildLayer(aItem, data, mDisplayListBuilder, scale);
   } else if (aItem->GetType() == DisplayItemType::TYPE_TRANSFORM) {
     nsDisplayTransform* transformItem = static_cast<nsDisplayTransform*>(aItem);
     const Matrix4x4Flagged& t = transformItem->GetTransform();
     Matrix t2d;
     bool is2D = t.Is2D(&t2d);
-    MOZ_RELEASE_ASSERT(is2D, "Non-2D transforms should be treated as active");
-
-    Matrix m = mTransform;
+    if (!is2D) {
+      // We'll use BasicLayerManager to handle 3d transforms.
+      gfx::Size scale(1, 1);
+      // If ComputeDifferences finds any change, we invalidate the entire container item.
+      // This is needed because blob merging requires the entire item to be within the invalid region.
+      data->mInvalid = BuildLayer(aItem, data, mDisplayListBuilder, scale);
+    } else {
+      Matrix m = mTransform;
 
-    GP("t2d: %f %f\n", t2d._31, t2d._32);
-    mTransform.PreMultiply(t2d);
-    GP("mTransform: %f %f\n", mTransform._31, mTransform._32);
-    ConstructGroupInsideInactive(aCommandBuilder, aBuilder, aResources, aGroup, children, aSc);
+      GP("t2d: %f %f\n", t2d._31, t2d._32);
+      mTransform.PreMultiply(t2d);
+      GP("mTransform: %f %f\n", mTransform._31, mTransform._32);
+      ConstructGroupInsideInactive(aCommandBuilder, aBuilder, aResources, aGroup, children, aSc);
 
-    mTransform = m;
+      mTransform = m;
+    }
   } else if (children) {
     sIndent++;
     ConstructGroupInsideInactive(aCommandBuilder, aBuilder, aResources, aGroup, children, aSc);
     sIndent--;
   }
 
   GP("Including %s of %d\n", aItem->Name(), aGroup->mDisplayItems.Count());
 
--- a/gfx/thebes/gfxPlatform.cpp
+++ b/gfx/thebes/gfxPlatform.cpp
@@ -708,16 +708,19 @@ WebRenderMemoryReporter::CollectReports(
   manager->SendReportMemory(
     [=](wr::MemoryReport aReport) {
       helper.Report(aReport.primitive_stores, "primitive-stores");
       helper.Report(aReport.clip_stores, "clip-stores");
       helper.Report(aReport.gpu_cache_metadata, "gpu-cache/metadata");
       helper.Report(aReport.gpu_cache_cpu_mirror, "gpu-cache/cpu-mirror");
       helper.Report(aReport.render_tasks, "render-tasks");
       helper.Report(aReport.hit_testers, "hit-testers");
+      helper.Report(aReport.fonts, "resource-cache/font");
+      helper.Report(aReport.images, "resource-cache/images");
+      helper.Report(aReport.rasterized_blobs, "resource-cache/rasterized-blobs");
       FinishAsyncMemoryReport();
     },
     [](mozilla::ipc::ResponseRejectReason aReason) {
       FinishAsyncMemoryReport();
     }
   );
 
   return NS_OK;
--- a/gfx/webrender/Cargo.toml
+++ b/gfx/webrender/Cargo.toml
@@ -27,17 +27,17 @@ byteorder = "1.0"
 cfg-if = "0.1.2"
 euclid = "0.19"
 fxhash = "0.2.1"
 gleam = "0.6"
 image = { optional = true, version = "0.19" }
 lazy_static = "1"
 log = "0.4"
 num-traits = "0.2"
-plane-split = "0.13"
+plane-split = "0.13.1"
 png = { optional = true, version = "0.12" }
 rayon = "1"
 ron = { optional = true, version = "0.1.7" }
 serde = { optional = true, version = "1.0", features = ["serde_derive"] }
 serde_json = { optional = true, version = "1.0" }
 smallvec = "0.6"
 thread_profiler = "0.1.1"
 time = "0.1"
--- a/gfx/webrender/src/batch.rs
+++ b/gfx/webrender/src/batch.rs
@@ -698,19 +698,21 @@ impl AlphaBatchBuilder {
                             // since we determine the UVs by doing a bilerp with a factor
                             // from the original local rect.
                             let local_rect = prim_metadata.local_rect
                                                           .intersection(&prim_metadata.combined_local_clip_rect);
 
                             if let Some(local_rect) = local_rect {
                                 match transform.transform_kind() {
                                     TransformedRectKind::AxisAligned => {
-                                        let polygon = Polygon::from_transformed_rect(
+                                        let inv_transform = transforms.get_world_inv_transform(prim_metadata.spatial_node_index);
+                                        let polygon = Polygon::from_transformed_rect_with_inverse(
                                             local_rect.cast(),
-                                            transform.cast(),
+                                            &transform.cast(),
+                                            &inv_transform.cast(),
                                             prim_index.0,
                                         ).unwrap();
                                         splitter.add(polygon);
                                     }
                                     TransformedRectKind::Complex => {
                                         let mut clipper = Clipper::new();
                                         let matrix = transform.cast();
                                         let results = clipper.clip_transformed(
--- a/gfx/webrender/src/border.rs
+++ b/gfx/webrender/src/border.rs
@@ -3,16 +3,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 use api::{BorderRadius, BorderSide, BorderStyle, ColorF, ColorU, DeviceRect, DeviceSize};
 use api::{LayoutSideOffsets, LayoutSizeAu, LayoutPrimitiveInfo, LayoutToDeviceScale};
 use api::{DeviceVector2D, DevicePoint, DeviceIntSize, LayoutRect, LayoutSize, NormalBorder};
 use api::{AuHelpers};
 use app_units::Au;
 use ellipse::Ellipse;
+use euclid::SideOffsets2D;
 use display_list_flattener::DisplayListFlattener;
 use gpu_types::{BorderInstance, BorderSegment, BrushFlags};
 use prim_store::{BrushKind, BrushPrimitive, BrushSegment};
 use prim_store::{EdgeAaSegmentMask, PrimitiveContainer, ScrollNodeAndClipChain};
 use util::{lerp, RectHelpers};
 
 // Using 2048 as the maximum radius in device space before which we
 // start stretching is up for debate.
@@ -73,37 +74,16 @@ impl From<BorderRadiusAu> for BorderRadi
             bottom_left: LayoutSize::from_au(radius.bottom_left),
         }
     }
 }
 
 #[derive(Clone, Debug, Hash, PartialEq, Eq)]
 #[cfg_attr(feature = "capture", derive(Serialize))]
 #[cfg_attr(feature = "replay", derive(Deserialize))]
-pub struct BorderWidthsAu {
-    pub left: Au,
-    pub top: Au,
-    pub right: Au,
-    pub bottom: Au,
-}
-
-impl From<LayoutSideOffsets> for BorderWidthsAu {
-    fn from(widths: LayoutSideOffsets) -> Self {
-        BorderWidthsAu {
-            left: Au::from_f32_px(widths.left),
-            top: Au::from_f32_px(widths.top),
-            right: Au::from_f32_px(widths.right),
-            bottom: Au::from_f32_px(widths.bottom),
-        }
-    }
-}
-
-#[derive(Clone, Debug, Hash, PartialEq, Eq)]
-#[cfg_attr(feature = "capture", derive(Serialize))]
-#[cfg_attr(feature = "replay", derive(Deserialize))]
 pub struct BorderSideAu {
     pub color: ColorU,
     pub style: BorderStyle,
 }
 
 impl From<BorderSide> for BorderSideAu {
     fn from(side: BorderSide) -> Self {
         BorderSideAu {
@@ -117,28 +97,33 @@ impl From<BorderSide> for BorderSideAu {
 #[cfg_attr(feature = "capture", derive(Serialize))]
 #[cfg_attr(feature = "replay", derive(Deserialize))]
 pub struct BorderCacheKey {
     pub left: BorderSideAu,
     pub right: BorderSideAu,
     pub top: BorderSideAu,
     pub bottom: BorderSideAu,
     pub radius: BorderRadiusAu,
-    pub widths: BorderWidthsAu,
+    pub widths: SideOffsets2D<Au>,
     pub scale: Au,
 }
 
 impl BorderCacheKey {
     pub fn new(border: &NormalBorder, widths: &LayoutSideOffsets) -> Self {
         BorderCacheKey {
             left: border.left.into(),
             top: border.top.into(),
             right: border.right.into(),
             bottom: border.bottom.into(),
-            widths: (*widths).into(),
+            widths: SideOffsets2D::new(
+                Au::from_f32_px(widths.top),
+                Au::from_f32_px(widths.right),
+                Au::from_f32_px(widths.bottom),
+                Au::from_f32_px(widths.left),
+            ),
             radius: border.radius.into(),
             scale: Au(0),
         }
     }
 }
 
 pub fn ensure_no_corner_overlap(
     radius: &mut BorderRadius,
--- a/gfx/webrender/src/gpu_types.rs
+++ b/gfx/webrender/src/gpu_types.rs
@@ -1,14 +1,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/. */
 
-use api::{DevicePoint, DeviceSize, DeviceRect, LayoutRect, LayoutToWorldTransform, LayoutTransform};
-use api::{PremultipliedColorF, LayoutToPictureTransform, PictureToLayoutTransform, PicturePixel, WorldPixel};
+use api::{
+    DevicePoint, DeviceSize, DeviceRect, LayoutRect, LayoutToWorldTransform, LayoutTransform,
+    PremultipliedColorF, LayoutToPictureTransform, PictureToLayoutTransform, PicturePixel,
+    WorldPixel, WorldToLayoutTransform,
+};
 use clip_scroll_tree::{ClipScrollTree, ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex};
 use gpu_cache::{GpuCacheAddress, GpuDataRequest};
 use internal_types::FastHashMap;
 use prim_store::EdgeAaSegmentMask;
 use render_task::RenderTaskAddress;
 use util::{TransformedRectKind, MatrixHelpers};
 
 // Contains type that must exactly match the same structures declared in GLSL.
@@ -482,16 +485,25 @@ impl TransformPalette {
         &self,
         index: SpatialNodeIndex,
     ) -> LayoutToWorldTransform {
         self.transforms[index.0]
             .transform
             .with_destination::<WorldPixel>()
     }
 
+    pub fn get_world_inv_transform(
+        &self,
+        index: SpatialNodeIndex,
+    ) -> WorldToLayoutTransform {
+        self.transforms[index.0]
+            .inv_transform
+            .with_source::<WorldPixel>()
+    }
+
     // Get a transform palette id for the given spatial node.
     // TODO(gw): In the future, it will be possible to specify
     //           a coordinate system id here, to allow retrieving
     //           transforms in the local space of a given spatial node.
     pub fn get_id(
         &mut self,
         from_index: SpatialNodeIndex,
         to_index: SpatialNodeIndex,
--- a/gfx/webrender/src/render_backend.rs
+++ b/gfx/webrender/src/render_backend.rs
@@ -1185,27 +1185,29 @@ impl RenderBackend {
 
     fn size_of<T>(&self, ptr: *const T) -> usize {
         let op = self.size_of_op.as_ref().unwrap();
         unsafe { op(ptr as *const c_void) }
     }
 
     fn report_memory(&self) -> MemoryReport {
         let mut report = MemoryReport::default();
-        let op = self.size_of_op.as_ref().unwrap();
-        report.gpu_cache_metadata = self.gpu_cache.malloc_size_of(*op);
+        let op = self.size_of_op.unwrap();
+        report.gpu_cache_metadata = self.gpu_cache.malloc_size_of(op);
         for (_id, doc) in &self.documents {
             if let Some(ref fb) = doc.frame_builder {
                 report.primitive_stores += self.size_of(fb.prim_store.primitives.as_ptr());
-                report.clip_stores += fb.clip_store.malloc_size_of(*op);
+                report.clip_stores += fb.clip_store.malloc_size_of(op);
             }
             report.hit_testers +=
-                doc.hit_tester.as_ref().map_or(0, |ht| ht.malloc_size_of(*op));
+                doc.hit_tester.as_ref().map_or(0, |ht| ht.malloc_size_of(op));
         }
 
+        report += self.resource_cache.report_memory(op);
+
         report
     }
 }
 
 fn get_blob_image_updates(updates: &[ResourceUpdate]) -> Vec<ImageKey> {
     let mut requests = Vec::new();
     for update in updates {
         match *update {
--- a/gfx/webrender/src/resource_cache.rs
+++ b/gfx/webrender/src/resource_cache.rs
@@ -5,16 +5,17 @@
 use api::{AddFont, BlobImageResources, AsyncBlobImageRasterizer, ResourceUpdate};
 use api::{BlobImageDescriptor, BlobImageHandler, BlobImageRequest, RasterizedBlobImage};
 use api::{ClearCache, ColorF, DevicePoint, DeviceUintPoint, DeviceUintRect, DeviceUintSize};
 use api::{FontInstanceKey, FontKey, FontTemplate, GlyphIndex};
 use api::{ExternalImageData, ExternalImageType, BlobImageResult, BlobImageParams};
 use api::{FontInstanceData, FontInstanceOptions, FontInstancePlatformOptions, FontVariation};
 use api::{GlyphDimensions, IdNamespace};
 use api::{ImageData, ImageDescriptor, ImageKey, ImageRendering};
+use api::{MemoryReport, VoidPtrToSizeFn};
 use api::{TileOffset, TileSize, TileRange, NormalizedRect, BlobImageData};
 use app_units::Au;
 #[cfg(feature = "capture")]
 use capture::ExternalCaptureImage;
 #[cfg(feature = "replay")]
 use capture::PlainExternalImage;
 #[cfg(any(feature = "replay", feature = "png"))]
 use capture::CaptureConfig;
@@ -29,20 +30,21 @@ use gpu_types::UvRectKind;
 use image::{compute_tile_range, for_each_tile_in_range};
 use internal_types::{FastHashMap, FastHashSet, SourceTexture, TextureUpdateList};
 use profiler::{ResourceProfileCounters, TextureCacheProfileCounters};
 use render_backend::FrameId;
 use render_task::{RenderTaskCache, RenderTaskCacheKey, RenderTaskId};
 use render_task::{RenderTaskCacheEntry, RenderTaskCacheEntryHandle, RenderTaskTree};
 use smallvec::SmallVec;
 use std::collections::hash_map::Entry::{self, Occupied, Vacant};
-use std::collections::hash_map::ValuesMut;
+use std::collections::hash_map::IterMut;
 use std::{cmp, mem};
 use std::fmt::Debug;
 use std::hash::Hash;
+use std::os::raw::c_void;
 #[cfg(any(feature = "capture", feature = "replay"))]
 use std::path::PathBuf;
 use std::sync::{Arc, RwLock};
 use texture_cache::{TextureCache, TextureCacheHandle, Eviction};
 use tiling::SpecialRenderPasses;
 use util::drain_filter;
 
 const DEFAULT_TILE_SIZE: TileSize = 512;
@@ -240,18 +242,18 @@ where
     pub fn try_get_mut(&mut self, key: &K) -> Option<&mut V> {
         self.resources.get_mut(key)
     }
 
     pub fn entry(&mut self, key: K) -> Entry<K, V> {
         self.resources.entry(key)
     }
 
-    pub fn values_mut(&mut self) -> ValuesMut<K, V> {
-        self.resources.values_mut()
+    pub fn iter_mut(&mut self) -> IterMut<K, V> {
+        self.resources.iter_mut()
     }
 
     pub fn clear(&mut self) {
         self.resources.clear();
     }
 
     fn clear_keys<F>(&mut self, key_fun: F)
     where
@@ -374,16 +376,21 @@ impl BlobImageResources for Resources {
         self.image_templates
             .get(key)
             .map(|resource| (&resource.data, &resource.descriptor))
     }
 }
 
 pub type GlyphDimensionsCache = FastHashMap<(FontInstance, GlyphIndex), Option<GlyphDimensions>>;
 
+/// High-level container for resources managed by the `RenderBackend`.
+///
+/// This includes a variety of things, including images, fonts, and glyphs,
+/// which may be stored as memory buffers, GPU textures, or handles to resources
+/// managed by the OS or other parts of WebRender.
 pub struct ResourceCache {
     cached_glyphs: GlyphCache,
     cached_images: ImageCache,
     cached_render_tasks: RenderTaskCache,
 
     resources: Resources,
     state: State,
     current_frame_id: FrameId,
@@ -748,18 +755,31 @@ impl ResourceCache {
 
         // Each cache entry stores its own copy of the image's dirty rect. This allows them to be
         // updated independently.
         match self.cached_images.try_get_mut(&image_key) {
             Some(&mut ImageResult::UntiledAuto(ref mut entry)) => {
                 entry.dirty_rect = merge_dirty_rect(&entry.dirty_rect, &dirty_rect, &descriptor);
             }
             Some(&mut ImageResult::Multi(ref mut entries)) => {
-                for entry in entries.values_mut() {
-                    entry.dirty_rect = merge_dirty_rect(&entry.dirty_rect, &dirty_rect, &descriptor);
+                for (key, entry) in entries.iter_mut() {
+                    let merged_rect = merge_dirty_rect(&entry.dirty_rect, &dirty_rect, &descriptor);
+
+                    entry.dirty_rect = match (key.tile, merged_rect) {
+                        (Some(tile), Some(rect)) => {
+                            let tile_size = image.tiling.unwrap();
+                            let clipped_tile_size = compute_tile_size(&descriptor, tile_size, tile);
+
+                            rect.intersection(&DeviceUintRect::new(
+                                DeviceUintPoint::new(tile.x as u32, tile.y as u32) * tile_size as u32,
+                                clipped_tile_size,
+                            ))
+                        }
+                        _ => merged_rect,
+                    };
                 }
             }
             _ => {}
         }
 
         *image = ImageResource {
             descriptor,
             data,
@@ -1623,16 +1643,51 @@ impl ResourceCache {
             .retain(|key, _| key.0 != namespace);
         self.cached_glyphs
             .clear_fonts(|font| font.font_key.0 == namespace);
 
         if let Some(ref mut r) = self.blob_image_handler {
             r.clear_namespace(namespace);
         }
     }
+
+    /// Reports the CPU heap usage of this ResourceCache.
+    pub fn report_memory(&self, op: VoidPtrToSizeFn) -> MemoryReport {
+        let mut report = MemoryReport::default();
+
+        // Measure fonts. We only need the templates here, because the instances
+        // don't have big buffers.
+        for (_, font) in self.resources.font_templates.iter() {
+            if let FontTemplate::Raw(ref raw, _) = font {
+                report.fonts += unsafe { op(raw.as_ptr() as *const c_void) };
+            }
+        }
+
+        // Measure images.
+        for (_, image) in self.resources.image_templates.images.iter() {
+            report.images += match image.data {
+                ImageData::Raw(ref v) => unsafe { op(v.as_ptr() as *const c_void) },
+                ImageData::Blob(ref v) => unsafe { op(v.as_ptr() as *const c_void) },
+                ImageData::External(..) => 0,
+            }
+        }
+
+        // Mesure rasterized blobs.
+        for (_, image) in self.rasterized_blob_images.iter() {
+            let mut accumulate = |b: &RasterizedBlobImage| {
+                report.rasterized_blobs += unsafe { op(b.data.as_ptr() as *const c_void) };
+            };
+            match image {
+                RasterizedBlob::Tiled(map) => map.values().for_each(&mut accumulate),
+                RasterizedBlob::NonTiled(vec) => vec.iter().for_each(&mut accumulate),
+            };
+        }
+
+        report
+    }
 }
 
 pub fn get_blob_tiling(
     tiling: Option<TileSize>,
     descriptor: &ImageDescriptor,
     max_texture_size: u32,
 ) -> Option<TileSize> {
     if tiling.is_none() &&
--- a/gfx/webrender_api/src/api.rs
+++ b/gfx/webrender_api/src/api.rs
@@ -752,26 +752,32 @@ impl PipelineId {
 #[derive(Clone, Debug, Default, Deserialize, Serialize)]
 pub struct MemoryReport {
     pub primitive_stores: usize,
     pub clip_stores: usize,
     pub gpu_cache_metadata: usize,
     pub gpu_cache_cpu_mirror: usize,
     pub render_tasks: usize,
     pub hit_testers: usize,
+    pub fonts: usize,
+    pub images: usize,
+    pub rasterized_blobs: usize,
 }
 
 impl ::std::ops::AddAssign for MemoryReport {
     fn add_assign(&mut self, other: MemoryReport) {
         self.primitive_stores += other.primitive_stores;
         self.clip_stores += other.clip_stores;
         self.gpu_cache_metadata += other.gpu_cache_metadata;
         self.gpu_cache_cpu_mirror += other.gpu_cache_cpu_mirror;
         self.render_tasks += other.render_tasks;
         self.hit_testers += other.hit_testers;
+        self.fonts += other.fonts;
+        self.images += other.images;
+        self.rasterized_blobs += other.rasterized_blobs;
     }
 }
 
 /// A C function that takes a pointer to a heap allocation and returns its size.
 ///
 /// This is borrowed from the malloc_size_of crate, upon which we want to avoid
 /// a dependency from WebRender.
 pub type VoidPtrToSizeFn = unsafe extern "C" fn(ptr: *const c_void) -> usize;
--- a/gfx/webrender_api/src/font.rs
+++ b/gfx/webrender_api/src/font.rs
@@ -75,17 +75,23 @@ pub struct GlyphDimensions {
 pub struct FontKey(pub IdNamespace, pub u32);
 
 impl FontKey {
     pub fn new(namespace: IdNamespace, key: u32) -> FontKey {
         FontKey(namespace, key)
     }
 }
 
-
+/// Container for the raw data describing a font. This might be a stream of
+/// bytes corresponding to a downloaded font, or a handle to a native font from
+/// the operating system.
+///
+/// Note that fonts need to be instantiated before being used, which involves
+/// assigning size and various other options. The word 'template' here is
+/// intended to distinguish this data from instance-specific data.
 #[derive(Clone)]
 pub enum FontTemplate {
     Raw(Arc<Vec<u8>>, u32),
     Native(NativeFontHandle),
 }
 
 #[repr(u32)]
 #[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Serialize, Deserialize, Ord, PartialOrd)]
@@ -343,16 +349,20 @@ impl Default for FontInstancePlatformOpt
 pub struct FontInstanceKey(pub IdNamespace, pub u32);
 
 impl FontInstanceKey {
     pub fn new(namespace: IdNamespace, key: u32) -> FontInstanceKey {
         FontInstanceKey(namespace, key)
     }
 }
 
+/// Data corresponding to an instantiation of a font, with size and
+/// other options specified.
+///
+/// Note that the actual font is stored out-of-band in `FontTemplate`.
 #[derive(Clone)]
 pub struct FontInstanceData {
     pub font_key: FontKey,
     pub size: Au,
     pub options: Option<FontInstanceOptions>,
     pub platform_options: Option<FontInstancePlatformOptions>,
     pub variations: Vec<FontVariation>,
 }
--- a/gfx/webrender_bindings/revision.txt
+++ b/gfx/webrender_bindings/revision.txt
@@ -1,1 +1,1 @@
-a601f9c291cee83257241ef61aaf62353c613438
+97a3807ea8266c324feb3ecada2ac5fd78c80e9b
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -483,24 +483,30 @@ struct WrPipelineInfo {
 // Collection of heap sizes, in bytes.
 struct MemoryReport {
   uintptr_t primitive_stores;
   uintptr_t clip_stores;
   uintptr_t gpu_cache_metadata;
   uintptr_t gpu_cache_cpu_mirror;
   uintptr_t render_tasks;
   uintptr_t hit_testers;
+  uintptr_t fonts;
+  uintptr_t images;
+  uintptr_t rasterized_blobs;
 
   bool operator==(const MemoryReport& aOther) const {
     return primitive_stores == aOther.primitive_stores &&
            clip_stores == aOther.clip_stores &&
            gpu_cache_metadata == aOther.gpu_cache_metadata &&
            gpu_cache_cpu_mirror == aOther.gpu_cache_cpu_mirror &&
            render_tasks == aOther.render_tasks &&
-           hit_testers == aOther.hit_testers;
+           hit_testers == aOther.hit_testers &&
+           fonts == aOther.fonts &&
+           images == aOther.images &&
+           rasterized_blobs == aOther.rasterized_blobs;
   }
 };
 
 template<typename T, typename U>
 struct TypedSize2D {
   T width;
   T height;
 
--- a/ipc/ipdl/sync-messages.ini
+++ b/ipc/ipdl/sync-messages.ini
@@ -1044,18 +1044,16 @@ description = WebRender equivalent for P
 [PHal::GetCurrentBatteryInformation]
 description =
 [PHal::GetCurrentNetworkInformation]
 description =
 [PHal::GetWakeLockInfo]
 description =
 [PHal::LockScreenOrientation]
 description =
-[PCookieService::GetCookieString]
-description =
 [PPrinting::SavePrintSettings]
 description =
 [PHandlerService::FillHandlerInfo]
 description =
 [PHandlerService::ExistsForProtocol]
 description = bug 1382323
 [PHandlerService::Exists]
 description =
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -2500,20 +2500,18 @@ nsCSSFrameConstructor::ConstructDocEleme
     // function to this FrameConstructionData.
 
     // XXXbz on the other hand, if we converted this whole function to
     // FrameConstructionData/Item, then we'd need the right function
     // here... but would probably be able to get away with less code in this
     // function in general.
     // Use a null PendingBinding, since our binding is not in fact pending.
     static const FrameConstructionData rootSVGData = FCDATA_DECL(0, nullptr);
-    already_AddRefed<ComputedStyle> extraRef =
-      RefPtr<ComputedStyle>(computedStyle).forget();
     AutoFrameConstructionItem item(this, &rootSVGData, aDocElement,
-                                   nullptr, extraRef, true);
+                                   nullptr, do_AddRef(computedStyle), true);
 
     nsFrameItems frameItems;
     contentFrame = static_cast<nsContainerFrame*>(
       ConstructOuterSVG(state, item, mDocElementContainingBlock,
                         computedStyle->StyleDisplay(),
                         frameItems));
     newFrame = frameItems.FirstChild();
     NS_ASSERTION(frameItems.OnlyChild(), "multiple root element frames");
@@ -2550,20 +2548,18 @@ nsCSSFrameConstructor::ConstructDocEleme
     // function to this FrameConstructionData.
 
     // XXXbz on the other hand, if we converted this whole function to
     // FrameConstructionData/Item, then we'd need the right function
     // here... but would probably be able to get away with less code in this
     // function in general.
     // Use a null PendingBinding, since our binding is not in fact pending.
     static const FrameConstructionData rootTableData = FCDATA_DECL(0, nullptr);
-    already_AddRefed<ComputedStyle> extraRef =
-      RefPtr<ComputedStyle>(computedStyle).forget();
     AutoFrameConstructionItem item(this, &rootTableData, aDocElement,
-                                   nullptr, extraRef, true);
+                                   nullptr, do_AddRef(computedStyle), true);
 
     nsFrameItems frameItems;
     // if the document is a table then just populate it.
     contentFrame = static_cast<nsContainerFrame*>(
       ConstructTable(state, item, mDocElementContainingBlock,
                      computedStyle->StyleDisplay(),
                      frameItems));
     newFrame = frameItems.FirstChild();
@@ -5522,20 +5518,20 @@ nsCSSFrameConstructor::FindElementTagDat
     case kNameSpaceID_XUL:
       return FindXULTagData(aElement, aTag, aStyle);
     default:
       return nullptr;
   }
 }
 
 nsCSSFrameConstructor::XBLBindingLoadInfo::XBLBindingLoadInfo(
-  already_AddRefed<ComputedStyle> aStyle,
+  already_AddRefed<ComputedStyle>&& aStyle,
   mozilla::UniquePtr<PendingBinding> aPendingBinding,
   nsAtom* aTag)
-  : mStyle(aStyle)
+  : mStyle(std::move(aStyle))
   , mPendingBinding(std::move(aPendingBinding))
   , mTag(aTag)
 {
   MOZ_ASSERT(mTag);
   MOZ_ASSERT(mStyle);
 }
 
 nsCSSFrameConstructor::XBLBindingLoadInfo::XBLBindingLoadInfo(nsIContent& aContent,
@@ -9279,33 +9275,33 @@ nsCSSFrameConstructor::CreateNeededAnonF
 
     // Now, we create the anonymous flex or grid item to contain the children
     // between |iter| and |endIter|.
     nsAtom* pseudoType = (aParentFrame->IsFlexContainerFrame())
                             ? nsCSSAnonBoxes::anonymousFlexItem()
                             : nsCSSAnonBoxes::anonymousGridItem();
     ComputedStyle* parentStyle = aParentFrame->Style();
     nsIContent* parentContent = aParentFrame->GetContent();
-    already_AddRefed<ComputedStyle> wrapperStyle =
+    RefPtr<ComputedStyle> wrapperStyle =
       mPresShell->StyleSet()->ResolveInheritingAnonymousBoxStyle(pseudoType,
                                                                  parentStyle);
 
     static const FrameConstructionData sBlockFormattingContextFCData =
       FCDATA_DECL(FCDATA_SKIP_FRAMESET |
                   FCDATA_USE_CHILD_ITEMS |
                   FCDATA_IS_WRAPPER_ANON_BOX,
                   NS_NewBlockFormattingContext);
 
     FrameConstructionItem* newItem =
       new (this) FrameConstructionItem(&sBlockFormattingContextFCData,
                                 // Use the content of our parent frame
                                 parentContent,
                                 // no pending binding
                                 nullptr,
-                                wrapperStyle,
+                                wrapperStyle.forget(),
                                 true);
 
     newItem->mIsAllInline =
       newItem->mComputedStyle->StyleDisplay()->IsInlineOutsideStyle();
     newItem->mIsBlock = !newItem->mIsAllInline;
 
     MOZ_ASSERT(!newItem->mIsAllInline && newItem->mIsBlock,
                "expecting anonymous flex/grid items to be block-level "
@@ -9781,33 +9777,33 @@ nsCSSFrameConstructor::WrapItemsInPseudo
 
   if (pseudoType == nsCSSAnonBoxes::table() &&
       (parentDisplay == StyleDisplay::Inline ||
        parentDisplay == StyleDisplay::RubyBase ||
        parentDisplay == StyleDisplay::RubyText)) {
     pseudoType = nsCSSAnonBoxes::inlineTable();
   }
 
-  already_AddRefed<ComputedStyle> wrapperStyle;
+  RefPtr<ComputedStyle> wrapperStyle;
   if (pseudoData.mFCData.mBits & FCDATA_IS_WRAPPER_ANON_BOX) {
     wrapperStyle =
       mPresShell->StyleSet()->ResolveInheritingAnonymousBoxStyle(pseudoType,
                                                                  aParentStyle);
   } else {
     wrapperStyle =
       mPresShell->StyleSet()->ResolveNonInheritingAnonymousBoxStyle(pseudoType);
   }
 
   FrameConstructionItem* newItem =
     new (this) FrameConstructionItem(&pseudoData.mFCData,
                               // Use the content of our parent frame
                               aParentContent,
                               // no pending binding
                               nullptr,
-                              wrapperStyle,
+                              wrapperStyle.forget(),
                               true);
 
   const nsStyleDisplay* disp = newItem->mComputedStyle->StyleDisplay();
   // Here we're cheating a tad... technically, table-internal items should be
   // inline if aParentFrame is inline, but they'll get wrapped in an
   // inline-table in the end, so it'll all work out.  In any case, arguably
   // we don't need to maintain this state at this point... but it's better
   // to, I guess.
@@ -9852,26 +9848,26 @@ nsCSSFrameConstructor::CreateNeededPseud
   if (firstDisplay == StyleDisplay::RubyBaseContainer) {
     return;
   }
   NS_ASSERTION(firstDisplay == StyleDisplay::RubyTextContainer,
                "Child of ruby frame should either a rbc or a rtc");
 
   const PseudoParentData& pseudoData =
     sPseudoParentData[eTypeRubyBaseContainer];
-  already_AddRefed<ComputedStyle> pseudoStyle = mPresShell->StyleSet()->
+  RefPtr<ComputedStyle> pseudoStyle = mPresShell->StyleSet()->
     ResolveInheritingAnonymousBoxStyle(*pseudoData.mPseudoType,
                                        aParentFrame->Style());
   FrameConstructionItem* newItem =
     new (this) FrameConstructionItem(&pseudoData.mFCData,
                                      // Use the content of the parent frame
                                      aParentFrame->GetContent(),
                                      // no pending binding
                                      nullptr,
-                                     pseudoStyle,
+                                     pseudoStyle.forget(),
                                      true);
   newItem->mIsAllInline = true;
   newItem->mChildItems.SetParentHasNoXBLChildren(true);
   iter.InsertItem(newItem);
 }
 
 #ifdef DEBUG
 /**
--- a/layout/base/nsCSSFrameConstructor.h
+++ b/layout/base/nsCSSFrameConstructor.h
@@ -793,17 +793,17 @@ private:
     RefPtr<ComputedStyle> mStyle;
     mozilla::UniquePtr<PendingBinding> mPendingBinding;
     nsAtom* mTag = nullptr;
 
     // For the 'no binding loaded' case.
     XBLBindingLoadInfo(nsIContent&, ComputedStyle&);
 
     // For the case we actually load an XBL binding.
-    XBLBindingLoadInfo(already_AddRefed<ComputedStyle> aStyle,
+    XBLBindingLoadInfo(already_AddRefed<ComputedStyle>&& aStyle,
                        mozilla::UniquePtr<PendingBinding> aPendingBinding,
                        nsAtom* aTag);
 
     // For the error case.
     XBLBindingLoadInfo();
   };
 
   // Returns null mStyle / mTag members to signal an error.
@@ -896,17 +896,17 @@ private:
                                       const FrameConstructionData* aFCData,
                                       nsIContent* aContent,
                                       PendingBinding* aPendingBinding,
                                       already_AddRefed<ComputedStyle>&& aComputedStyle,
                                       bool aSuppressWhiteSpaceOptimizations)
     {
       FrameConstructionItem* item =
         new (aFCtor) FrameConstructionItem(aFCData, aContent,
-                                           aPendingBinding, aComputedStyle,
+                                           aPendingBinding, std::move(aComputedStyle),
                                            aSuppressWhiteSpaceOptimizations);
       mItems.insertBack(item);
       ++mItemCount;
       ++mDesiredParentCounts[item->DesiredParentType()];
       return item;
     }
 
     // Arguments are the same as AppendItem().
@@ -914,17 +914,17 @@ private:
                                        const FrameConstructionData* aFCData,
                                        nsIContent* aContent,
                                        PendingBinding* aPendingBinding,
                                        already_AddRefed<ComputedStyle>&& aComputedStyle,
                                        bool aSuppressWhiteSpaceOptimizations)
     {
       FrameConstructionItem* item =
         new (aFCtor) FrameConstructionItem(aFCData, aContent,
-                                           aPendingBinding, aComputedStyle,
+                                           aPendingBinding, std::move(aComputedStyle),
                                            aSuppressWhiteSpaceOptimizations);
       mItems.insertFront(item);
       ++mItemCount;
       ++mDesiredParentCounts[item->DesiredParentType()];
       return item;
     }
 
     void InlineItemAdded() { ++mInlineCount; }
@@ -1142,20 +1142,20 @@ private:
    * frame constructor state.  You probably want to use
    * AutoFrameConstructionItem instead of this struct. */
   struct FrameConstructionItem final
     : public mozilla::LinkedListElement<FrameConstructionItem>
   {
     FrameConstructionItem(const FrameConstructionData* aFCData,
                           nsIContent* aContent,
                           PendingBinding* aPendingBinding,
-                          already_AddRefed<ComputedStyle>& aComputedStyle,
+                          already_AddRefed<ComputedStyle>&& aComputedStyle,
                           bool aSuppressWhiteSpaceOptimizations)
     : mFCData(aFCData), mContent(aContent),
-      mPendingBinding(aPendingBinding), mComputedStyle(aComputedStyle),
+      mPendingBinding(aPendingBinding), mComputedStyle(std::move(aComputedStyle)),
       mSuppressWhiteSpaceOptimizations(aSuppressWhiteSpaceOptimizations),
       mIsText(false), mIsGeneratedContent(false),
       mIsAnonymousContentCreatorContent(false),
       mIsRootPopupgroup(false), mIsAllInline(false), mIsBlock(false),
       mIsPopup(false),
       mIsLineParticipant(false)
     {
       MOZ_COUNT_CTOR(FrameConstructionItem);
--- a/layout/generic/DetailsFrame.cpp
+++ b/layout/generic/DetailsFrame.cpp
@@ -96,20 +96,20 @@ DetailsFrame::CreateAnonymousContent(nsT
     return NS_OK;
   }
 
   // The <details> element lacks any direct <summary> child. Create a default
   // <summary> element as an anonymous content.
   nsNodeInfoManager* nodeInfoManager =
     GetContent()->NodeInfo()->NodeInfoManager();
 
-  already_AddRefed<NodeInfo> nodeInfo =
+  RefPtr<NodeInfo> nodeInfo =
     nodeInfoManager->GetNodeInfo(nsGkAtoms::summary, nullptr, kNameSpaceID_XHTML,
                                  nsINode::ELEMENT_NODE);
-  mDefaultSummary = new HTMLSummaryElement(nodeInfo);
+  mDefaultSummary = new HTMLSummaryElement(nodeInfo.forget());
 
   nsAutoString defaultSummaryText;
   nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
                                      "DefaultSummary", defaultSummaryText);
   RefPtr<nsTextNode> description = new nsTextNode(nodeInfoManager);
   description->SetText(defaultSummaryText, false);
   mDefaultSummary->AppendChildTo(description, false);
 
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -8747,34 +8747,34 @@ nsDisplayTransform::CreateWebRenderComma
     // we can just stash the transform on the StackingContextHelper and
     // apply it to any scroll data that are created inside this
     // nsDisplayTransform.
     deferredTransformItem = Some(this);
   }
 
   // If it looks like we're animated, we should rasterize in local space
   // (disabling subpixel-aa and global pixel snapping)
-  bool rasterizeLocally =
+  bool animated =
     ActiveLayerTracker::IsStyleMaybeAnimated(Frame(), eCSSProperty_transform);
 
   StackingContextHelper sc(aSc,
                            aBuilder,
                            filters,
                            LayoutDeviceRect(position, LayoutDeviceSize()),
                            &newTransformMatrix,
                            animationsId ? &prop : nullptr,
                            nullptr,
                            transformForSC,
                            nullptr,
                            gfx::CompositionOp::OP_OVER,
                            !BackfaceIsHidden(),
                            mFrame->Extend3DContext() && !mNoExtendContext,
                            deferredTransformItem,
                            nullptr,
-                           rasterizeLocally);
+                           animated);
 
   return mStoredList.CreateWebRenderCommands(
     aBuilder, aResources, sc, aManager, aDisplayListBuilder);
 }
 
 bool
 nsDisplayTransform::UpdateScrollData(
   mozilla::layers::WebRenderScrollData* aData,
@@ -9698,36 +9698,47 @@ nsDisplayMask::CanMerge(const nsDisplayI
       !HasSameContent(aItem)) {
     return false;
   }
 
   return CanMergeDisplayMaskFrame(mFrame) &&
          CanMergeDisplayMaskFrame(aItem->Frame());
 }
 
-already_AddRefed<Layer>
-nsDisplayMask::BuildLayer(nsDisplayListBuilder* aBuilder,
-                          LayerManager* aManager,
-                          const ContainerLayerParameters& aContainerParameters)
-{
+bool
+nsDisplayMask::IsValidMask() {
   if (!ValidateSVGFrame()) {
-    return nullptr;
+    return false;
   }
 
   if (mFrame->StyleEffects()->mOpacity == 0.0f && mHandleOpacity) {
-    return nullptr;
+    return false;
   }
 
   nsIFrame* firstFrame =
     nsLayoutUtils::FirstContinuationOrIBSplitSibling(mFrame);
   SVGObserverUtils::EffectProperties effectProperties =
     SVGObserverUtils::GetEffectProperties(firstFrame);
 
   if (effectProperties.HasInvalidClipPath() ||
       effectProperties.HasInvalidMask()) {
+    return false;
+  }
+
+  return true;
+}
+
+
+
+already_AddRefed<Layer>
+nsDisplayMask::BuildLayer(nsDisplayListBuilder* aBuilder,
+                          LayerManager* aManager,
+                          const ContainerLayerParameters& aContainerParameters)
+{
+  if (!IsValidMask()) {
     return nullptr;
   }
 
   RefPtr<ContainerLayer> container =
     aManager->GetLayerBuilder()->BuildContainerLayerFor(
       aBuilder, aManager, mFrame, this, &mList, aContainerParameters, nullptr);
 
   return container.forget();
@@ -9888,16 +9899,53 @@ nsDisplayMask::PaintAsLayer(nsDisplayLis
 
   nsSVGIntegrationUtils::PaintMaskAndClipPath(params);
 
   context->PopClip();
 
   nsDisplayMaskGeometry::UpdateDrawResult(this, imgParams.result);
 }
 
+void
+nsDisplayMask::PaintWithContentsPaintCallback(nsDisplayListBuilder* aBuilder,
+                                              gfxContext* aCtx,
+                                              const std::function<void()>& aPaintChildren)
+{
+  // Clip the drawing target by mVisibleRect, which contains the visible
+  // region of the target frame and its out-of-flow and inflow descendants.
+  gfxContext* context = aCtx;
+
+  Rect bounds =
+    NSRectToRect(GetPaintRect(), mFrame->PresContext()->AppUnitsPerDevPixel());
+  bounds.RoundOut();
+  context->Clip(bounds);
+
+  imgDrawingParams imgParams(aBuilder->ShouldSyncDecodeImages()
+                               ? imgIContainer::FLAG_SYNC_DECODE
+                               : imgIContainer::FLAG_SYNC_DECODE_IF_FAST);
+  nsRect borderArea = nsRect(ToReferenceFrame(), mFrame->GetSize());
+  nsSVGIntegrationUtils::PaintFramesParams params(*aCtx,
+                                                  mFrame,
+                                                  GetPaintRect(),
+                                                  borderArea,
+                                                  aBuilder,
+                                                  nullptr,
+                                                  mHandleOpacity,
+                                                  imgParams);
+
+  ComputeMaskGeometry(params);
+
+  nsSVGIntegrationUtils::PaintMaskAndClipPath(params, aPaintChildren);
+
+  context->PopClip();
+
+  nsDisplayMaskGeometry::UpdateDrawResult(this, imgParams.result);
+}
+
+
 bool
 nsDisplayMask::CreateWebRenderCommands(
   mozilla::wr::DisplayListBuilder& aBuilder,
   mozilla::wr::IpcResourceUpdateQueue& aResources,
   const StackingContextHelper& aSc,
   mozilla::layers::WebRenderLayerManager* aManager,
   nsDisplayListBuilder* aDisplayListBuilder)
 {
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -6779,20 +6779,27 @@ public:
 
   void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
                                  const nsDisplayItemGeometry* aGeometry,
                                  nsRegion* aInvalidRegion) const override;
 #ifdef MOZ_DUMP_PAINTING
   void PrintEffects(nsACString& aTo);
 #endif
 
+  bool IsValidMask();
+
   void PaintAsLayer(nsDisplayListBuilder* aBuilder,
                     gfxContext* aCtx,
                     LayerManager* aManager);
 
+  void PaintWithContentsPaintCallback(nsDisplayListBuilder* aBuilder,
+                                      gfxContext* aCtx,
+                                      const std::function<void()>& aPaintChildren);
+
+
   /*
    * Paint mask onto aMaskContext in mFrame's coordinate space and
    * return whether the mask layer was painted successfully.
    */
   bool PaintMask(nsDisplayListBuilder* aBuilder,
                  gfxContext* aMaskContext,
                  bool* aMaskPainted = nullptr);
 
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -2379,18 +2379,17 @@ Gecko_CSSValue_SetFontWeight(nsCSSValueB
                              float weight)
 {
   aCSSValue->SetFontWeight(mozilla::FontWeight(weight));
 }
 
 void
 Gecko_nsStyleFont_SetLang(nsStyleFont* aFont, nsAtom* aAtom)
 {
-  already_AddRefed<nsAtom> atom = already_AddRefed<nsAtom>(aAtom);
-  aFont->mLanguage = atom;
+  aFont->mLanguage = dont_AddRef(aAtom);
   aFont->mExplicitLanguage = true;
 }
 
 void
 Gecko_nsStyleFont_CopyLangFrom(nsStyleFont* aFont, const nsStyleFont* aSource)
 {
   aFont->mLanguage = aSource->mLanguage;
 }
--- a/layout/style/test/mochitest.ini
+++ b/layout/style/test/mochitest.ini
@@ -247,16 +247,19 @@ skip-if = toolkit == 'android'
 [test_initial_storage.html]
 [test_invalidation_basic.html]
 [test_keyframes_rules.html]
 [test_keyframes_vendor_prefix.html]
 [test_layout_css_xul_display_values_content_enabled.html]
 [test_load_events_on_stylesheets.html]
 support-files = slow_broken_sheet.sjs slow_ok_sheet.sjs
 [test_logical_properties.html]
+[test_mask_image_CORS.html]
+support-files =
+  support/blue-100x100.png
 [test_media_queries.html]
 skip-if = android_version == '18' #debug-only failure; timed out #Android 4.3 aws only; bug 1030419
 [test_media_queries_dynamic.html]
 [test_media_queries_dynamic_xbl.html]
 [test_media_query_list.html]
 [test_media_query_serialization.html]
 [test_mq_any_hover_and_any_pointer.html]
 [test_mq_hover_and_pointer.html]
new file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3b72d5ce53c07b68fe508bb57aa61a933dbda768
GIT binary patch
literal 40279
zc%1Fru`7gO9KiA4>*{d2$>7orRvDE4fKFU;Nw+A2B(u&97LkoI$s&VAHWMQw1NT3O
zEc_AYy}_VNy6(Q0@8|7#p0{Uu>f5_Ly@yMcxqNOk7ZLgLd}%pdH(FyLo6cLWr`2@H
zt}o1$qS<;b?ygSKox!d7mF<Y3;nqmv?7Wa}_Segcv;8lbLS}OG{qpHKVl2v~>FQ1r
zwf*D0B%;|2Vf1zT0Q$)wFb07!2#i5s3<6^i7=yqV1jZmR27xgMj6q-w0%H&ugTNRB
z#vm{Tf$51LjothD_g#Q)pQV#}BF=we5Ez5N7zD;3Fb07!2#i5s3<6^i7=yqV1jZmR
z27xgMj6q-w0%H&ugTNT1&2E#4qjuc|Fb<4CU<?9d5Ez5N7zD;3Fb07!2#i5s3<6^i
z7=yqV1jZmR27xgMj6q-w0%H)EP6ipsJ#PNT{{sA(Uki*uU<?9d5Ez5N7zD;3Fb07!
z2#i5s3<6^i7=yqV1jZmR27xgMj6q-w0%MTh)h@=15yhLX-UUdeij6l5!59R_ATS1j
zF$j!7U<?9d5Ez5N7zD;3Fb07!2#i5s3<6^i7=yqV1m>gC_wYHgdfs|3&sIv;GiwK5
DD)})y
new file mode 100644
--- /dev/null
+++ b/layout/style/test/test_mask_image_CORS.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Test mask-image CORS anonymous retrieval</title>
+<link rel="stylesheet" href="/tests/SimpleTest/test.css">
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<script src="/tests/SimpleTest/WindowSnapshot.js"></script>
+<style>
+.block100 {
+  width: 100px;
+  height: 100px;
+}
+#allow {
+  /*
+   * shape-outside is unnecessary for the mask, but using it ensures that the first frame
+   * of the image is decoded and reflow is called before onload is fired. Since the
+   * shape-outside uses the same url as the mask, this ensures that the css image resource
+   * is decoded and available for the repaint triggered by the call to snapshotRect.
+   */
+  shape-outside: url("support/blue-100x100.png");
+  mask-image: url("support/blue-100x100.png");
+  background-color: #00FF00
+}
+#refuse {
+  shape-outside: url("http://example.com/tests/layout/style/test/support/blue-100x100.png");
+  mask-image: url("http://example.com/tests/layout/style/test/support/blue-100x100.png");
+  background-color: #FF0000
+}
+</style>
+
+<script>
+SimpleTest.waitForExplicitFinish();
+
+function checkBothSquares() {
+  checkIsColor("allow", "0,255,0,255");
+  checkIsColor("refuse", "255,255,255,255");
+
+  SimpleTest.finish();
+}
+
+function checkIsColor(elementId, color) {
+  let e = document.getElementById(elementId);
+  let r = e.getBoundingClientRect();
+  info("Element " + elementId + " has rect " + r.top + ", " + r.left + ", " + r.width + ", " + r.height + ".");
+
+  let canvas = snapshotRect(window, r);
+  let context = canvas.getContext('2d');
+
+  // Only check the top left pixel.
+  let image = context.getImageData(0, 0, 1, 1);
+  let pixel = image.data.toString();
+  is(pixel, color, "Element " + elementId + " has expected color.");
+}
+</script>
+
+</head>
+<body onload="checkBothSquares()">
+  <p>There should be a green square, but no red square.</p>
+  <div id="allow" class="block100"></div>
+  <div id="refuse" class="block100"></div>
+</body>
+</html>
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -857,20 +857,20 @@ nsSVGIntegrationUtils::PaintMask(const P
     clipPathFrame->PaintClipMask(ctx, frame, cssPxToDevPxMatrix,
                                    &clipMaskTransform, maskSurface,
                                    ctx.CurrentMatrix());
   }
 
   return true;
 }
 
-void
-nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
+template<class T>
+void PaintMaskAndClipPathInternal(const PaintFramesParams& aParams, const T& aPaintChild)
 {
-  MOZ_ASSERT(UsingMaskOrClipPathForFrame(aParams.frame),
+  MOZ_ASSERT(nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(aParams.frame),
              "Should not use this method when no mask or clipPath effect"
              "on this frame");
 
   /* SVG defines the following rendering model:
    *
    *  1. Render geometry
    *  2. Apply filter
    *  3. Apply clipping, masking, group opacity
@@ -977,17 +977,17 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
       MOZ_ASSERT(maskUsage.opacity != 1.0f);
 
       matSR.SetContext(&context);
       MoveContextOriginToUserSpace(firstFrame, aParams);
       shouldPushMask = true;
     }
 
     if (shouldPushMask) {
-      if (aParams.layerManager->GetRoot()->GetContentFlags() &
+      if (aParams.layerManager && aParams.layerManager->GetRoot()->GetContentFlags() &
           Layer::CONTENT_COMPONENT_ALPHA) {
         context.PushGroupAndCopyBackground(gfxContentType::COLOR_ALPHA,
                                            opacityApplied
                                              ? 1.0
                                              : maskUsage.opacity,
                                            maskSurface, maskTransform);
       } else {
         context.PushGroupForBlendBack(gfxContentType::COLOR_ALPHA,
@@ -1011,22 +1011,17 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
       clipPathFrame->ApplyClipPath(context, frame, cssPxToDevPxMatrix);
     } else {
       nsCSSClipPathInstance::ApplyBasicShapeOrPathClip(context, frame);
     }
   }
 
   /* Paint the child */
   context.SetMatrix(matrixAutoSaveRestore.Matrix());
-  BasicLayerManager* basic = aParams.layerManager->AsBasicLayerManager();
-  RefPtr<gfxContext> oldCtx = basic->GetTarget();
-  basic->SetTarget(&context);
-  aParams.layerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer,
-                                       aParams.builder);
-  basic->SetTarget(oldCtx);
+  aPaintChild();
 
   if (gfxPrefs::DrawMaskLayer()) {
     gfxContextAutoSaveRestore saver(&context);
 
     context.NewPath();
     gfxRect drawingRect =
       nsLayoutUtils::RectToGfxRect(aParams.borderArea,
                                    frame->PresContext()->AppUnitsPerDevPixel());
@@ -1053,16 +1048,37 @@ nsSVGIntegrationUtils::PaintMaskAndClipP
   }
 
   if (shouldPushMask) {
     context.PopGroupAndBlend();
   }
 
 }
 
+
+void
+nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams)
+{
+  PaintMaskAndClipPathInternal(aParams, [&] {
+    gfxContext& context = aParams.ctx;
+    BasicLayerManager* basic = aParams.layerManager->AsBasicLayerManager();
+    RefPtr<gfxContext> oldCtx = basic->GetTarget();
+    basic->SetTarget(&context);
+    aParams.layerManager->EndTransaction(FrameLayerBuilder::DrawPaintedLayer,
+                                         aParams.builder);
+    basic->SetTarget(oldCtx);
+  });
+}
+
+void
+nsSVGIntegrationUtils::PaintMaskAndClipPath(const PaintFramesParams& aParams, const std::function<void()>& aPaintChild)
+{
+  PaintMaskAndClipPathInternal(aParams, aPaintChild);
+}
+
 void
 nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams)
 {
   MOZ_ASSERT(!aParams.builder->IsForGenerateGlyphMask(),
              "Filter effect is discarded while generating glyph mask.");
   MOZ_ASSERT(aParams.frame->StyleEffects()->HasFilters(),
              "Should not use this method when no filter effect on this frame");
 
--- a/layout/svg/nsSVGIntegrationUtils.h
+++ b/layout/svg/nsSVGIntegrationUtils.h
@@ -161,16 +161,21 @@ public:
   };
 
   /**
    * Paint non-SVG frame with mask, clipPath and opacity effect.
    */
   static void
   PaintMaskAndClipPath(const PaintFramesParams& aParams);
 
+  // This should use FunctionRef instead of std::function because we don't need
+  // to take ownership of the function. See bug 1490781.
+  static void
+  PaintMaskAndClipPath(const PaintFramesParams& aParams, const std::function<void()>& aPaintChild);
+
   /**
    * Paint mask of non-SVG frame onto a given context, aParams.ctx.
    * aParams.ctx must contain an A8 surface. Returns false if the mask
    * didn't get painted and should be ignored at the call site.
    */
   static bool
   PaintMask(const PaintFramesParams& aParams);
 
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/GeckoSession.java
@@ -703,16 +703,17 @@ public final class GeckoSession extends 
             }
             return mBinder;
         }
 
         // Create a new Gecko window and assign an initial set of Java session objects to it.
         @WrapForJNI(dispatchTo = "proxy")
         public static native void open(Window instance, NativeQueue queue,
                                        Compositor compositor, EventDispatcher dispatcher,
+                                       SessionAccessibility.NativeProvider sessionAccessibility,
                                        GeckoBundle initData, String id, String chromeUri,
                                        int screenId, boolean privateMode);
 
         @Override // JNIObject
         public void disposeNative() {
             if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
                 nativeDisposeNative();
             } else {
@@ -751,49 +752,56 @@ public final class GeckoSession extends 
         @WrapForJNI(dispatchTo = "proxy", stubName = "Close")
         private native void nativeClose();
 
         // Assign a new set of Java session objects to the underlying Gecko window.
         // This replaces previously assigned objects from open() or transfer() calls.
         public synchronized void transfer(final NativeQueue queue,
                                           final Compositor compositor,
                                           final EventDispatcher dispatcher,
+                                          final SessionAccessibility.NativeProvider sessionAccessibility,
                                           final GeckoBundle initData) {
             if (mNativeQueue == null) {
                 // Already closed.
                 return;
             }
 
             if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
-                nativeTransfer(queue, compositor, dispatcher, initData);
+                nativeTransfer(queue, compositor, dispatcher, sessionAccessibility, initData);
             } else {
                 GeckoThread.queueNativeCallUntil(GeckoThread.State.PROFILE_READY,
                         this, "nativeTransfer",
                         NativeQueue.class, queue,
                         Compositor.class, compositor,
                         EventDispatcher.class, dispatcher,
+                        SessionAccessibility.NativeProvider.class, sessionAccessibility,
                         GeckoBundle.class, initData);
             }
 
             if (mNativeQueue != queue) {
                 // Reset the old queue to prevent old events from affecting this window.
                 // Gecko will call onReady later with the new queue if needed.
                 mNativeQueue.reset(State.INITIAL);
                 mNativeQueue = queue;
             }
         }
 
         @WrapForJNI(dispatchTo = "proxy", stubName = "Transfer")
         private native void nativeTransfer(NativeQueue queue, Compositor compositor,
-                                           EventDispatcher dispatcher, GeckoBundle initData);
+                                           EventDispatcher dispatcher,
+                                           SessionAccessibility.NativeProvider sessionAccessibility,
+                                           GeckoBundle initData);
 
         @WrapForJNI(dispatchTo = "proxy")
         public native void attachEditable(IGeckoEditableParent parent,
                                           GeckoEditableChild child);
 
+        @WrapForJNI(dispatchTo = "proxy")
+        public native void attachAccessibility(SessionAccessibility.NativeProvider sessionAccessibility);
+
         @WrapForJNI(calledFrom = "gecko")
         private synchronized void onReady(final @Nullable NativeQueue queue) {
             // onReady is called the first time the Gecko window is ready, with a null queue
             // argument. In this case, we simply set the current queue to ready state.
             //
             // After the initial call, onReady is called again every time Window.transfer()
             // is called, with a non-null queue argument. In this case, we only set the
             // current queue to ready state _if_ the current queue matches the given queue,
@@ -871,17 +879,18 @@ public final class GeckoSession extends 
         }
 
         mWindow = window;
         mSettings = new GeckoSessionSettings(settings, this);
         mId = id;
 
         if (mWindow != null) {
             mWindow.transfer(mNativeQueue, mCompositor,
-                             mEventDispatcher, createInitData());
+                             mEventDispatcher, mAccessibility != null ? mAccessibility.nativeProvider : null,
+                             createInitData());
 
             onWindowChanged(WINDOW_TRANSFER_IN, /* inProgress */ false);
         }
     }
 
     /* package */ void transferFrom(final GeckoSession session) {
         final boolean changing = (session.mWindow != null);
         if (changing) {
@@ -998,25 +1007,28 @@ public final class GeckoSession extends 
         final boolean isPrivate = mSettings.getBoolean(GeckoSessionSettings.USE_PRIVATE_MODE);
 
         mWindow = new Window(runtime, mNativeQueue);
 
         onWindowChanged(WINDOW_OPEN, /* inProgress */ true);
 
         if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
             Window.open(mWindow, mNativeQueue, mCompositor, mEventDispatcher,
+                        mAccessibility != null ? mAccessibility.nativeProvider : null,
                         createInitData(), mId, chromeUri, screenId, isPrivate);
         } else {
             GeckoThread.queueNativeCallUntil(
                 GeckoThread.State.PROFILE_READY,
                 Window.class, "open",
                 Window.class, mWindow,
                 NativeQueue.class, mNativeQueue,
                 Compositor.class, mCompositor,
                 EventDispatcher.class, mEventDispatcher,
+                SessionAccessibility.NativeProvider.class,
+                mAccessibility != null ? mAccessibility.nativeProvider : null,
                 GeckoBundle.class, createInitData(),
                 String.class, mId,
                 String.class, chromeUri,
                 screenId, isPrivate);
         }
 
         onWindowChanged(WINDOW_OPEN, /* inProgress */ false);
     }
@@ -1071,18 +1083,28 @@ public final class GeckoSession extends 
     }
 
     /**
       * Get the SessionAccessibility instance for this session.
       *
       * @return SessionAccessibility instance.
       */
     public @NonNull SessionAccessibility getAccessibility() {
-        if (mAccessibility == null) {
-            mAccessibility = new SessionAccessibility(this);
+        ThreadUtils.assertOnUiThread();
+        if (mAccessibility != null) { return mAccessibility; }
+
+        mAccessibility = new SessionAccessibility(this);
+        if (mWindow != null) {
+            if (GeckoThread.isStateAtLeast(GeckoThread.State.PROFILE_READY)) {
+                mWindow.attachAccessibility(mAccessibility.nativeProvider);
+            } else {
+                GeckoThread.queueNativeCallUntil(GeckoThread.State.PROFILE_READY,
+                        mWindow, "attachAccessibility",
+                        SessionAccessibility.NativeProvider.class, mAccessibility.nativeProvider);
+            }
         }
         return mAccessibility;
     }
 
     @IntDef(flag = true,
             value = { LOAD_FLAGS_NONE, LOAD_FLAGS_BYPASS_CACHE, LOAD_FLAGS_BYPASS_PROXY,
                       LOAD_FLAGS_EXTERNAL, LOAD_FLAGS_ALLOW_POPUPS })
     /* package */ @interface LoadFlags {}
--- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionAccessibility.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/SessionAccessibility.java
@@ -1,21 +1,23 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * 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/. */
 
 package org.mozilla.geckoview;
 
+import org.mozilla.gecko.annotation.WrapForJNI;
 import org.mozilla.gecko.EventDispatcher;
 import org.mozilla.gecko.GeckoAppShell;
 import org.mozilla.gecko.PrefsHelper;
 import org.mozilla.gecko.util.BundleEventListener;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoBundle;
+import org.mozilla.gecko.mozglue.JNIObject;
 
 import android.content.Context;
 import android.graphics.Matrix;
 import android.graphics.Rect;
 import android.os.Build;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.annotation.Nullable;
@@ -227,25 +229,29 @@ public class SessionAccessibility {
             return mView.performAccessibilityAction(action, arguments);
         }
     };
 
     // Gecko session we are proxying
     /* package */  final GeckoSession mSession;
     // This is the view that delegates accessibility to us. We also sends event through it.
     private View mView;
+    // The native portion of the node provider.
+    /* package */ final NativeProvider nativeProvider = new NativeProvider();
     // Have we reached the last item in content?
     private boolean mLastItem;
     // Used to store the JSON message and populate the event later in the code path.
     private AccessibilityNodeInfo mVirtualContentNode;
     // Auto-fill nodes.
     private SparseArray<GeckoBundle> mAutoFillNodes;
     private SparseArray<EventCallback> mAutoFillRoots;
     private int mAutoFillFocusedId = View.NO_ID;
 
+    private boolean mAttached = false;
+
     /* package */ SessionAccessibility(final GeckoSession session) {
         mSession = session;
 
         Settings.updateAccessibilitySettings();
 
         session.getEventDispatcher().registerUiThreadListener(new BundleEventListener() {
                 @Override
                 public void handleMessage(final String event, final GeckoBundle message,
@@ -798,9 +804,25 @@ public class SessionAccessibility {
             if (DEBUG) {
                 Log.d(LOGTAG, "onWindowFocus()");
             }
             final AccessibilityEvent event = obtainEvent(
                     AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED, View.NO_ID);
             ((ViewParent) mView).requestSendAccessibilityEvent(mView, event);
         }
     }
+
+    /* package */ final class NativeProvider extends JNIObject {
+        @WrapForJNI(calledFrom = "ui")
+        private void setAttached(final boolean attached) {
+            if (attached) {
+                mAttached = true;
+            } else if (mAttached) {
+                mAttached = false;
+                disposeNative();
+            }
+        }
+
+        @WrapForJNI(calledFrom = "ui", dispatchTo = "gecko")
+        @Override
+        protected native void disposeNative();
+    }
 }
--- a/modules/libpref/init/all.js
+++ b/modules/libpref/init/all.js
@@ -2261,17 +2261,16 @@ pref("network.proxy.socks_remote_dns",  
 pref("network.proxy.proxy_over_tls",        true);
 pref("network.proxy.no_proxies_on",         "localhost, 127.0.0.1");
 pref("network.proxy.failover_timeout",      1800); // 30 minutes
 pref("network.online",                      true); //online/offline
 pref("network.cookie.thirdparty.sessionOnly", false);
 pref("network.cookie.thirdparty.nonsecureSessionOnly", false);
 pref("network.cookie.leave-secure-alone",   true);
 pref("network.cookie.same-site.enabled",    true); // Honor the SameSite cookie attribute
-pref("network.cookie.ipc.sync",             false);
 
 // Cookie lifetime policy. Possible values:
 // 0 - accept all cookies
 // 1 - deprecated. don't use it.
 // 2 - accept as session cookies
 // 3 - deprecated. don't use it.
 pref("network.cookie.lifetimePolicy",       0);
 
--- a/netwerk/base/AutoClose.h
+++ b/netwerk/base/AutoClose.h
@@ -33,35 +33,31 @@ public:
   already_AddRefed<T> forget()
   {
     MutexAutoLock lock(mMutex);
     return mPtr.forget();
   }
 
   void takeOver(nsCOMPtr<T> & rhs)
   {
-    already_AddRefed<T> other = rhs.forget();
-    TakeOverInternal(&other);
+    TakeOverInternal(rhs.forget());
   }
 
   void CloseAndRelease()
   {
     TakeOverInternal(nullptr);
   }
 
 private:
-  void TakeOverInternal(already_AddRefed<T> *aOther)
+  void TakeOverInternal(already_AddRefed<T>&& aOther)
   {
-    nsCOMPtr<T> ptr;
+    nsCOMPtr<T> ptr(std::move(aOther));
     {
       MutexAutoLock lock(mMutex);
       ptr.swap(mPtr);
-      if (aOther) {
-        mPtr = *aOther;
-      }
     }
 
     if (ptr) {
       ptr->Close();
     }
   }
 
   void operator=(const AutoClose<T> &) = delete;
--- a/netwerk/cookie/CookieServiceChild.cpp
+++ b/netwerk/cookie/CookieServiceChild.cpp
@@ -35,17 +35,16 @@ namespace mozilla {
 namespace net {
 
 // Pref string constants
 static const char kPrefCookieBehavior[] = "network.cookie.cookieBehavior";
 static const char kPrefThirdPartySession[] =
   "network.cookie.thirdparty.sessionOnly";
 static const char kPrefThirdPartyNonsecureSession[] =
   "network.cookie.thirdparty.nonsecureSessionOnly";
-static const char kPrefCookieIPCSync[] = "network.cookie.ipc.sync";
 static const char kCookieLeaveSecurityAlone[] = "network.cookie.leave-secure-alone";
 static const char kCookieMoveIntervalSecs[] = "network.cookie.move.interval_sec";
 
 static StaticRefPtr<CookieServiceChild> gCookieService;
 static uint32_t gMoveCookiesIntervalSeconds = 10;
 
 already_AddRefed<CookieServiceChild>
 CookieServiceChild::GetSingleton()
@@ -64,17 +63,16 @@ NS_IMPL_ISUPPORTS(CookieServiceChild,
                   nsITimerCallback,
                   nsISupportsWeakReference)
 
 CookieServiceChild::CookieServiceChild()
   : mCookieBehavior(nsICookieService::BEHAVIOR_ACCEPT)
   , mThirdPartySession(false)
   , mThirdPartyNonsecureSession(false)
   , mLeaveSecureAlone(true)
-  , mIPCSync(false)
   , mIPCOpen(false)
 {
   NS_ASSERTION(IsNeckoChild(), "not a child process");
 
   mozilla::dom::ContentChild* cc =
     static_cast<mozilla::dom::ContentChild*>(gNeckoChild->Manager());
   if (cc->IsShuttingDown()) {
     return;
@@ -96,17 +94,16 @@ CookieServiceChild::CookieServiceChild()
   // Init our prefs and observer.
   nsCOMPtr<nsIPrefBranch> prefBranch =
     do_GetService(NS_PREFSERVICE_CONTRACTID);
   NS_WARNING_ASSERTION(prefBranch, "no prefservice");
   if (prefBranch) {
     prefBranch->AddObserver(kPrefCookieBehavior, this, true);
     prefBranch->AddObserver(kPrefThirdPartySession, this, true);
     prefBranch->AddObserver(kPrefThirdPartyNonsecureSession, this, true);
-    prefBranch->AddObserver(kPrefCookieIPCSync, this, true);
     prefBranch->AddObserver(kCookieLeaveSecurityAlone, this, true);
     prefBranch->AddObserver(kCookieMoveIntervalSecs, this, true);
     PrefChanged(prefBranch);
   }
 
   nsCOMPtr<nsIObserverService> observerService
     = mozilla::services::GetObserverService();
   if (observerService) {
@@ -309,19 +306,16 @@ CookieServiceChild::PrefChanged(nsIPrefB
   bool boolval;
   if (NS_SUCCEEDED(aPrefBranch->GetBoolPref(kPrefThirdPartySession, &boolval)))
     mThirdPartySession = !!boolval;
 
   if (NS_SUCCEEDED(aPrefBranch->GetBoolPref(kPrefThirdPartyNonsecureSession,
                                             &boolval)))
     mThirdPartyNonsecureSession = boolval;
 
-  if (NS_SUCCEEDED(aPrefBranch->GetBoolPref(kPrefCookieIPCSync, &boolval)))
-    mIPCSync = !!boolval;
-
   if (NS_SUCCEEDED(aPrefBranch->GetBoolPref(kCookieLeaveSecurityAlone, &boolval)))
     mLeaveSecureAlone = !!boolval;
 
   if (!mThirdPartyUtil && RequireThirdPartyCheck()) {
     mThirdPartyUtil = do_GetService(THIRDPARTYUTIL_CONTRACTID);
     NS_ASSERTION(mThirdPartyUtil, "require ThirdPartyUtil service");
   }
 
@@ -435,34 +429,16 @@ CookieServiceChild::GetCookieStringFromC
         aCookieString.Append(cookie->Value().get());
       } else {
         aCookieString.Append(cookie->Value().get());
       }
     }
   }
 }
 
-void
-CookieServiceChild::GetCookieStringSyncIPC(nsIURI                 *aHostURI,
-                                           bool                   aIsForeign,
-                                           bool                   aIsTrackingResource,
-                                           bool                   aFirstPartyStorageAccessGranted,
-                                           bool                   aIsSafeTopLevelNav,
-                                           bool                   aIsSameSiteForeign,
-                                           const OriginAttributes &aAttrs,
-                                           nsAutoCString          &aCookieString)
-{
-  URIParams uriParams;
-  SerializeURI(aHostURI, uriParams);
-
-  SendGetCookieString(uriParams, aIsForeign, aIsTrackingResource,
-                      aFirstPartyStorageAccessGranted, aIsSafeTopLevelNav,
-                      aIsSameSiteForeign, aAttrs, &aCookieString);
-}
-
 uint32_t
 CookieServiceChild::CountCookiesFromHashTable(const nsCString &aBaseDomain,
                                               const OriginAttributes &aOriginAttrs)
 {
   CookiesList *cookiesList = nullptr;
 
   nsCString baseDomain;
   nsCookieKey key(aBaseDomain, aOriginAttrs);
@@ -596,28 +572,19 @@ CookieServiceChild::GetCookieStringInter
       firstPartyStorageAccessGranted = true;
     }
   }
 
   bool isSafeTopLevelNav = NS_IsSafeTopLevelNav(aChannel);
   bool isSameSiteForeign = NS_IsSameSiteForeign(aChannel, aHostURI);
 
   nsAutoCString result;
-  if (!mIPCSync) {
-    GetCookieStringFromCookieHashTable(aHostURI, isForeign, isTrackingResource,
-                                       firstPartyStorageAccessGranted, isSafeTopLevelNav,
-                                       isSameSiteForeign, attrs, result);
-  } else {
-    if (!mIPCOpen) {
-      return NS_ERROR_NOT_AVAILABLE;
-    }
-    GetCookieStringSyncIPC(aHostURI, isForeign, isTrackingResource,
-                           firstPartyStorageAccessGranted, isSafeTopLevelNav,
-                           isSameSiteForeign, attrs, result);
-  }
+  GetCookieStringFromCookieHashTable(aHostURI, isForeign, isTrackingResource,
+                                     firstPartyStorageAccessGranted, isSafeTopLevelNav,
+                                     isSameSiteForeign, attrs, result);
 
   if (!result.IsEmpty())
     *aCookieString = ToNewCString(result);
 
   return NS_OK;
 }
 
 nsresult
@@ -684,20 +651,16 @@ CookieServiceChild::SetCookieStringInter
   // Asynchronously call the parent.
   if (mIPCOpen) {
     SendSetCookieString(hostURIParams, channelURIParams,
                         isForeign, isTrackingResource,
                         firstPartyStorageAccessGranted, cookieString,
                         stringServerTime, attrs, aFromHttp);
   }
 
-  if (mIPCSync) {
-    return NS_OK;
-  }
-
   bool requireHostMatch;
   nsCString baseDomain;
   nsCookieService::
     GetBaseDomain(mTLDService, aHostURI, baseDomain, requireHostMatch);
 
   nsCOMPtr<nsICookiePermission> permissionService =
     nsCookiePermission::GetOrCreate();
 
--- a/netwerk/cookie/CookieServiceChild.h
+++ b/netwerk/cookie/CookieServiceChild.h
@@ -67,26 +67,16 @@ protected:
                                           bool aIsForeign,
                                           bool aIsTrackingResource,
                                           bool aFirstPartyStorageAccessGranted,
                                           bool aIsSafeTopLevelNav,
                                           bool aIsSameSiteForeign,
                                           const OriginAttributes &aAttrs,
                                           nsCString &aCookieString);
 
-  void
-  GetCookieStringSyncIPC(nsIURI                 *aHostURI,
-                         bool                    aIsForeign,
-                         bool                    aIsTrackingResource,
-                         bool                    aFirstPartyStorageAccessGranted,
-                         bool                    aIsSafeTopLevelNav,
-                         bool                    aIsSameSiteForeign,
-                         const OriginAttributes &aAttrs,
-                         nsAutoCString          &aCookieString);
-
   nsresult SetCookieStringInternal(nsIURI *aHostURI,
                                    nsIChannel *aChannel,
                                    const char *aCookieString,
                                    const char *aServerTime,
                                    bool aFromHttp);
 
   void
   RecordDocumentCookie(nsCookie *aCookie,
@@ -131,17 +121,16 @@ protected:
   CookiesMap mCookiesMap;
   nsCOMPtr<nsITimer> mCookieTimer;
   nsCOMPtr<mozIThirdPartyUtil> mThirdPartyUtil;
   nsCOMPtr<nsIEffectiveTLDService> mTLDService;
   uint8_t mCookieBehavior;
   bool mThirdPartySession;
   bool mThirdPartyNonsecureSession;
   bool mLeaveSecureAlone;
-  bool mIPCSync;
   bool mIPCOpen;
 };
 
 } // namespace net
 } // namespace mozilla
 
 #endif // mozilla_net_CookieServiceChild_h__
 
--- a/netwerk/cookie/CookieServiceParent.cpp
+++ b/netwerk/cookie/CookieServiceParent.cpp
@@ -229,40 +229,16 @@ CookieServiceParent::RecvPrepareCookieLi
 void
 CookieServiceParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   // Nothing needed here. Called right before destructor since this is a
   // non-refcounted class.
 }
 
 mozilla::ipc::IPCResult
-CookieServiceParent::RecvGetCookieString(const URIParams& aHost,
-                                         const bool& aIsForeign,
-                                         const bool& aIsTrackingResource,
-                                         const bool& aFirstPartyStorageAccessGranted,
-                                         const bool& aIsSafeTopLevelNav,
-                                         const bool& aIsSameSiteForeign,
-                                         const OriginAttributes& aAttrs,
-                                         nsCString* aResult)
-{
-  if (!mCookieService)
-    return IPC_OK();
-
-  // Deserialize URI. Having a host URI is mandatory and should always be
-  // provided by the child; thus we consider failure fatal.
-  nsCOMPtr<nsIURI> hostURI = DeserializeURI(aHost);
-  if (!hostURI)
-    return IPC_FAIL_NO_REASON(this);
-  mCookieService->GetCookieStringInternal(hostURI, aIsForeign, aIsTrackingResource,
-                                          aFirstPartyStorageAccessGranted, aIsSafeTopLevelNav,
-                                          aIsSameSiteForeign, false, aAttrs, *aResult);
-  return IPC_OK();
-}
-
-mozilla::ipc::IPCResult
 CookieServiceParent::RecvSetCookieString(const URIParams& aHost,
                                          const OptionalURIParams& aChannelURI,
                                          const bool& aIsForeign,
                                          const bool& aIsTrackingResource,
                                          const bool& aFirstPartyStorageAccessGranted,
                                          const nsCString& aCookieString,
                                          const nsCString& aServerTime,
                                          const OriginAttributes& aAttrs,
--- a/netwerk/cookie/CookieServiceParent.h
+++ b/netwerk/cookie/CookieServiceParent.h
@@ -35,25 +35,16 @@ public:
   // This will return true if the CookieServiceParent is currently processing
   // an update from the content process. This is used in ContentParent to make
   // sure that we are only forwarding those cookie updates to other content
   // processes, not the one they originated from.
   bool ProcessingCookie() { return mProcessingCookie; }
 protected:
   virtual void ActorDestroy(ActorDestroyReason aWhy) override;
 
-  virtual mozilla::ipc::IPCResult RecvGetCookieString(const URIParams& aHost,
-                                                      const bool& aIsForeign,
-                                                      const bool& aIsTrackingResource,
-                                                      const bool& aFirstPartyStorageAccessGranted,
-                                                      const bool& aIsSafeTopLevelNav,
-                                                      const bool& aIsSameSiteForeign,
-                                                      const OriginAttributes& aAttrs,
-                                                      nsCString* aResult) override;
-
   virtual mozilla::ipc::IPCResult RecvSetCookieString(const URIParams& aHost,
                                                       const OptionalURIParams& aChannelURI,
                                                       const bool& aIsForeign,
                                                       const bool& aIsTrackingResource,
                                                       const bool& aFirstPartyStorageAccessGranted,
                                                       const nsCString& aCookieString,
                                                       const nsCString& aServerTime,
                                                       const OriginAttributes& aAttrs,
--- a/netwerk/cookie/PCookieService.ipdl
+++ b/netwerk/cookie/PCookieService.ipdl
@@ -29,62 +29,16 @@ namespace net {
 
 nested(upto inside_cpow) sync protocol PCookieService
 {
   manager PNecko;
 
 parent:
 
   /*
-   * Get the complete cookie string associated with the URI. This is a sync
-   * call in order to avoid race conditions -- for instance, an HTTP response
-   * on the parent and script access on the child.
-   *
-   * @param host
-   *        Same as the 'aURI' argument to nsICookieService.getCookieString.
-   * @param isForeign
-   *        True if the the request is third party, for purposes of allowing
-   *        access to cookies. This should be obtained from
-   *        mozIThirdPartyUtil.isThirdPartyChannel. Third party requests may be
-   *        rejected depending on user preferences; if those checks are
-   *        disabled, this parameter is ignored.
-   * @param isTrackingResource
-   *        True if the request has been marked as tracking.
-   * @param firstPartyStorageAccessGranted
-   *        True if host has storage access granted. Note that the storage
-   *        access is automatically granted also if the channel is not marked as
-   *        tracking resource, or if it's not a 3rd party context.
-   * @param isSafeTopLevelNav
-   *        True for safe methods like e.g. GET.
-   * @param isSameSiteForeign
-   *        True if the same-site cookie originates from a cross-site context.
-   * @param fromHttp
-   *        Whether the result is for an HTTP request header. This should be
-   *        true for nsICookieService.getCookieStringFromHttp calls, false
-   *        otherwise.
-   * @param attrs
-   *        The origin attributes from the HTTP channel or document that the
-   *        cookie is being set on.
-   *
-   * @see nsICookieService.getCookieString
-   * @see nsICookieService.getCookieStringFromHttp
-   * @see mozIThirdPartyUtil.isThirdPartyChannel
-   *
-   * @return the resulting cookie string.
-   */
-  nested(inside_cpow) sync GetCookieString(URIParams host,
-                                           bool isForeign,
-                                           bool isTrackingResource,
-                                           bool firstPartyStorageAccessGranted,
-                                           bool isSafeTopLevelNav,
-                                           bool isSameSiteForeign,
-                                           OriginAttributes attrs)
-       returns (nsCString result);
-
-  /*
    * Set a cookie string.
    *
    * @param host
    *        Same as the 'aURI' argument to nsICookieService.setCookieString.
    * @param channelURI
    *        The URI of the request.
    * @param isForeign
    *        True if the the request is third party, for purposes of allowing
--- a/netwerk/protocol/http/HttpChannelParent.cpp
+++ b/netwerk/protocol/http/HttpChannelParent.cpp
@@ -729,20 +729,20 @@ HttpChannelParent::WaitForBgParent()
 
 
   nsCOMPtr<nsIBackgroundChannelRegistrar> registrar =
     do_GetService(NS_BACKGROUNDCHANNELREGISTRAR_CONTRACTID);
   MOZ_ASSERT(registrar);
   registrar->LinkHttpChannel(mChannel->ChannelId(), this);
 
   if (mBgParent) {
-    already_AddRefed<GenericPromise> promise = mPromise.Ensure(__func__);
+    RefPtr<GenericPromise> promise = mPromise.Ensure(__func__);
     // resolve promise immediatedly if bg channel is ready.
     mPromise.Resolve(true, __func__);
-    return promise;
+    return promise.forget();
   }
 
   return mPromise.Ensure(__func__);;
 }
 
 bool
 HttpChannelParent::ConnectChannel(const uint32_t& registrarId, const bool& shouldIntercept)
 {
--- a/netwerk/test/unit_ipc/test_bug528292_wrap.js
+++ b/netwerk/test/unit_ipc/test_bug528292_wrap.js
@@ -1,7 +1,6 @@
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 function run_test() {
-  Services.prefs.setBoolPref("network.cookie.ipc.sync", true);
   Services.prefs.setIntPref("network.cookie.cookieBehavior", 1);
   run_test_in_child("../unit/test_bug528292.js");
 }
--- a/netwerk/test/unit_ipc/test_multipart_streamconv_wrap.js
+++ b/netwerk/test/unit_ipc/test_multipart_streamconv_wrap.js
@@ -1,5 +1,4 @@
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 function run_test() {
-  Services.prefs.setBoolPref("network.cookie.ipc.sync", true);
   run_test_in_child("../unit/test_multipart_streamconv.js");
 }
--- a/servo/components/style/properties/longhands/svg.mako.rs
+++ b/servo/components/style/properties/longhands/svg.mako.rs
@@ -178,15 +178,16 @@
     spec="https://drafts.fxtf.org/css-masking/#propdef-mask-composite",
 )}
 
 ${helpers.predefined_type(
     "mask-image",
     "ImageLayer",
     "Either::First(None_)",
     initial_specified_value="Either::First(None_)",
+    parse_method="parse_with_cors_anonymous",
     spec="https://drafts.fxtf.org/css-masking/#propdef-mask-image",
     vector=True,
     products="gecko",
     extra_prefixes="webkit",
     animation_value_type="discrete",
     flags="CREATES_STACKING_CONTEXT",
 )}
--- a/servo/components/style/values/specified/image.rs
+++ b/servo/components/style/values/specified/image.rs
@@ -28,16 +28,30 @@ use values::generics::position::Position
 use values::specified::{Angle, Color, Length, LengthOrPercentage};
 use values::specified::{Number, NumberOrPercentage, Percentage};
 use values::specified::position::{LegacyPosition, Position, PositionComponent, Side, X, Y};
 use values::specified::url::SpecifiedImageUrl;
 
 /// A specified image layer.
 pub type ImageLayer = Either<None_, Image>;
 
+impl ImageLayer {
+    /// This is a specialization of Either with an alternative parse
+    /// method to provide anonymous CORS headers for the Image url fetch.
+    pub fn parse_with_cors_anonymous<'i, 't>(
+        context: &ParserContext,
+        input: &mut Parser<'i, 't>,
+    ) -> Result<Self, ParseError<'i>> {
+        if let Ok(v) = input.try(|i| None_::parse(context, i)) {
+            return Ok(Either::First(v));
+        }
+        Image::parse_with_cors_anonymous(context, input).map(Either::Second)
+    }
+}
+
 /// Specified values for an image according to CSS-IMAGES.
 /// <https://drafts.csswg.org/css-images/#image-values>
 pub type Image = generic::Image<Gradient, MozImageRect, SpecifiedImageUrl>;
 
 /// Specified values for a CSS gradient.
 /// <https://drafts.csswg.org/css-images/#gradients>
 #[cfg(not(feature = "gecko"))]
 pub type Gradient =
--- a/testing/marionette/action.js
+++ b/testing/marionette/action.js
@@ -968,36 +968,36 @@ action.Mouse = class {
  * This is done by creating a Promise for each tick that resolves once
  * all the Promises for individual tick-actions are resolved.  The next
  * tick's actions are not dispatched until the Promise for the current
  * tick is resolved.
  *
  * @param {action.Chain} chain
  *     Actions grouped by tick; each element in |chain| is a sequence of
  *     actions for one tick.
- * @param {WindowProxy} window
+ * @param {WindowProxy} win
  *     Current window global.
  * @param {boolean=} [specCompatPointerOrigin=true] specCompatPointerOrigin
  *     Flag to turn off the WebDriver spec conforming pointer origin
  *     calculation. It has to be kept until all Selenium bindings can
  *     successfully handle the WebDriver spec conforming Pointer Origin
  *     calculation. See https://bugzilla.mozilla.org/show_bug.cgi?id=1429338.
  *
  * @return {Promise}
  *     Promise for dispatching all actions in |chain|.
  */
-action.dispatch = function(chain, window, specCompatPointerOrigin = true) {
+action.dispatch = function(chain, win, specCompatPointerOrigin = true) {
   action.specCompatPointerOrigin = specCompatPointerOrigin;
 
   let chainEvents = (async () => {
     for (let tickActions of chain) {
       await action.dispatchTickActions(
           tickActions,
           action.computeTickDuration(tickActions),
-          window);
+          win);
     }
   })();
   return chainEvents;
 };
 
 /**
  * Dispatch sequence of actions for one tick.
  *
@@ -1008,24 +1008,24 @@ action.dispatch = function(chain, window
  *
  * Note that the tick-actions are dispatched in order, but they may have
  * different durations and therefore may not end in the same order.
  *
  * @param {Array.<action.Action>} tickActions
  *     List of actions for one tick.
  * @param {number} tickDuration
  *     Duration in milliseconds of this tick.
- * @param {WindowProxy} window
+ * @param {WindowProxy} win
  *     Current window global.
  *
  * @return {Promise}
  *     Promise for dispatching all tick-actions and pending DOM events.
  */
-action.dispatchTickActions = function(tickActions, tickDuration, window) {
-  let pendingEvents = tickActions.map(toEvents(tickDuration, window));
+action.dispatchTickActions = function(tickActions, tickDuration, win) {
+  let pendingEvents = tickActions.map(toEvents(tickDuration, win));
   return Promise.all(pendingEvents);
 };
 
 /**
  * Compute tick duration in milliseconds for a collection of actions.
  *
  * @param {Array.<action.Action>} tickActions
  *     List of actions for one tick.
@@ -1080,43 +1080,43 @@ action.computePointerDestination = funct
   return {"x": x, "y": y};
 };
 
 /**
  * Create a closure to use as a map from action definitions to Promise events.
  *
  * @param {number} tickDuration
  *     Duration in milliseconds of this tick.
- * @param {WindowProxy} window
+ * @param {WindowProxy} win
  *     Current window global.
  *
  * @return {function(action.Action): Promise}
  *     Function that takes an action and returns a Promise for dispatching
  *     the event that corresponds to that action.
  */
-function toEvents(tickDuration, window) {
+function toEvents(tickDuration, win) {
   return a => {
     let inputState = action.inputStateMap.get(a.id);
 
     switch (a.subtype) {
       case action.KeyUp:
-        return dispatchKeyUp(a, inputState, window);
+        return dispatchKeyUp(a, inputState, win);
 
       case action.KeyDown:
-        return dispatchKeyDown(a, inputState, window);
+        return dispatchKeyDown(a, inputState, win);
 
       case action.PointerDown:
-        return dispatchPointerDown(a, inputState, window);
+        return dispatchPointerDown(a, inputState, win);
 
       case action.PointerUp:
-        return dispatchPointerUp(a, inputState, window);
+        return dispatchPointerUp(a, inputState, win);
 
       case action.PointerMove:
         return dispatchPointerMove(
-            a, inputState, tickDuration, window);
+            a, inputState, tickDuration, win);
 
       case action.PointerCancel:
         throw new UnsupportedOperationError();
 
       case action.Pause:
         return dispatchPause(a, tickDuration);
     }
 
@@ -1126,89 +1126,89 @@ function toEvents(tickDuration, window) 
 
 /**
  * Dispatch a keyDown action equivalent to pressing a key on a keyboard.
  *
  * @param {action.Action} a
  *     Action to dispatch.
  * @param {action.InputState} inputState
  *     Input state for this action's input source.
- * @param {WindowProxy} window
+ * @param {WindowProxy} win
  *     Current window global.
  *
  * @return {Promise}
  *     Promise to dispatch at least a keydown event, and keypress if
  *     appropriate.
  */
-function dispatchKeyDown(a, inputState, window) {
+function dispatchKeyDown(a, inputState, win) {
   return new Promise(resolve => {
     let keyEvent = new action.Key(a.value);
     keyEvent.repeat = inputState.isPressed(keyEvent.key);
     inputState.press(keyEvent.key);
     if (keyEvent.key in MODIFIER_NAME_LOOKUP) {
       inputState.setModState(keyEvent.key, true);
     }
 
     // Append a copy of |a| with keyUp subtype
     action.inputsToCancel.push(Object.assign({}, a, {subtype: action.KeyUp}));
     keyEvent.update(inputState);
-    event.sendKeyDown(a.value, keyEvent, window);
+    event.sendKeyDown(a.value, keyEvent, win);
 
     resolve();
   });
 }
 
 /**
  * Dispatch a keyUp action equivalent to releasing a key on a keyboard.
  *
  * @param {action.Action} a
  *     Action to dispatch.
  * @param {action.InputState} inputState
  *     Input state for this action's input source.
- * @param {WindowProxy} window
+ * @param {WindowProxy} win
  *     Current window global.
  *
  * @return {Promise}
  *     Promise to dispatch a keyup event.
  */
-function dispatchKeyUp(a, inputState, window) {
+function dispatchKeyUp(a, inputState, win) {
   return new Promise(resolve => {
     let keyEvent = new action.Key(a.value);
 
     if (!inputState.isPressed(keyEvent.key)) {
       resolve();
       return;
     }
 
     if (keyEvent.key in MODIFIER_NAME_LOOKUP) {
       inputState.setModState(keyEvent.key, false);
     }
     inputState.release(keyEvent.key);
     keyEvent.update(inputState);
 
-    event.sendKeyUp(a.value, keyEvent, window);
+    event.sendKeyUp(a.value, keyEvent, win);
     resolve();
   });
 }
 
 /**
  * Dispatch a pointerDown action equivalent to pressing a pointer-device
  * button.
  *
  * @param {action.Action} a
  *     Action to dispatch.
  * @param {action.InputState} inputState
  *     Input state for this action's input source.
- * @param {WindowProxy} window
+ * @param {WindowProxy} win
  *     Current window global.
  *
  * @return {Promise}
  *     Promise to dispatch at least a pointerdown event.
  */
-function dispatchPointerDown(a, inputState, window) {
+function dispatchPointerDown(a, inputState, win) {
   return new Promise(resolve => {
     if (inputState.isPressed(a.button)) {
       resolve();
       return;
     }
 
     inputState.press(a.button);
     // Append a copy of |a| with pointerUp subtype
@@ -1227,26 +1227,26 @@ function dispatchPointerDown(a, inputSta
         } else if (event.DoubleClickTracker.isClicked()) {
           mouseEvent = Object.assign({},
               mouseEvent, {clickCount: 2});
         }
         event.synthesizeMouseAtPoint(
             inputState.x,
             inputState.y,
             mouseEvent,
-            window);
+            win);
         if (event.MouseButton.isSecondary(a.button) ||
             mouseEvent.ctrlKey && Services.appinfo.OS !== "WINNT") {
           let contextMenuEvent = Object.assign({},
               mouseEvent, {type: "contextmenu"});
           event.synthesizeMouseAtPoint(
               inputState.x,
               inputState.y,
               contextMenuEvent,
-              window);
+              win);
         }
         break;
 
       case action.PointerType.Pen:
       case action.PointerType.Touch:
         throw new UnsupportedOperationError("Only 'mouse' pointer type is supported");
 
       default:
@@ -1260,23 +1260,23 @@ function dispatchPointerDown(a, inputSta
 /**
  * Dispatch a pointerUp action equivalent to releasing a pointer-device
  * button.
  *
  * @param {action.Action} a
  *     Action to dispatch.
  * @param {action.InputState} inputState
  *     Input state for this action's input source.
- * @param {WindowProxy} window
+ * @param {WindowProxy} win
  *     Current window global.
  *
  * @return {Promise}
  *     Promise to dispatch at least a pointerup event.
  */
-function dispatchPointerUp(a, inputState, window) {
+function dispatchPointerUp(a, inputState, win) {
   return new Promise(resolve => {
     if (!inputState.isPressed(a.button)) {
       resolve();
       return;
     }
 
     inputState.release(a.button);
 
@@ -1284,17 +1284,17 @@ function dispatchPointerUp(a, inputState
       case action.PointerType.Mouse:
         let mouseEvent = new action.Mouse("mouseup", a.button);
         mouseEvent.update(inputState);
         if (event.DoubleClickTracker.isClicked()) {
           mouseEvent = Object.assign({},
               mouseEvent, {clickCount: 2});
         }
         event.synthesizeMouseAtPoint(
-            inputState.x, inputState.y, mouseEvent, window);
+            inputState.x, inputState.y, mouseEvent, win);
         break;
 
       case action.PointerType.Pen:
       case action.PointerType.Touch:
         throw new UnsupportedOperationError("Only 'mouse' pointer type is supported");
 
       default:
         throw new TypeError(`Unknown pointer type: ${inputState.subtype}`);
@@ -1312,47 +1312,47 @@ function dispatchPointerUp(a, inputState
  * target coordinates.  Otherwise, events are synthesized to mimic a
  * pointer travelling in a discontinuous, approximately straight line,
  * with the pointer coordinates being updated around 60 times per second.
  *
  * @param {action.Action} a
  *     Action to dispatch.
  * @param {action.InputState} inputState
  *     Input state for this action's input source.
- * @param {WindowProxy} window
+ * @param {WindowProxy} win
  *     Current window global.
  *
  * @return {Promise}
  *     Promise to dispatch at least one pointermove event, as well as
  *     mousemove events as appropriate.
  */
-function dispatchPointerMove(a, inputState, tickDuration, window) {
+function dispatchPointerMove(a, inputState, tickDuration, win) {
   const timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
   // interval between pointermove increments in ms, based on common vsync
   const fps60 = 17;
 
   return new Promise((resolve, reject) => {
     const start = Date.now();
     const [startX, startY] = [inputState.x, inputState.y];
 
-    let coords = getElementCenter(a.origin, window);
+    let coords = getElementCenter(a.origin, win);
     let target = action.computePointerDestination(a, inputState, coords);
     const [targetX, targetY] = [target.x, target.y];
 
-    if (!inViewPort(targetX, targetY, window)) {
+    if (!inViewPort(targetX, targetY, win)) {
       throw new MoveTargetOutOfBoundsError(
           `(${targetX}, ${targetY}) is out of bounds of viewport ` +
-          `width (${window.innerWidth}) ` +
-          `and height (${window.innerHeight})`);
+          `width (${win.innerWidth}) ` +
+          `and height (${win.innerHeight})`);
     }
 
     const duration = typeof a.duration == "undefined" ? tickDuration : a.duration;
     if (duration === 0) {
       // move pointer to destination in one step
-      performOnePointerMove(inputState, targetX, targetY, window);
+      performOnePointerMove(inputState, targetX, targetY, win);
       resolve();
       return;
     }
 
     const distanceX = targetX - startX;
     const distanceY = targetY - startY;
     const ONE_SHOT = Ci.nsITimer.TYPE_ONE_SHOT;
     let intermediatePointerEvents = (async () => {
@@ -1360,29 +1360,29 @@ function dispatchPointerMove(a, inputSta
       await new Promise(resolveTimer =>
           timer.initWithCallback(resolveTimer, fps60, ONE_SHOT));
 
       let durationRatio = Math.floor(Date.now() - start) / duration;
       const epsilon = fps60 / duration / 10;
       while ((1 - durationRatio) > epsilon) {
         let x = Math.floor(durationRatio * distanceX + startX);
         let y = Math.floor(durationRatio * distanceY + startY);
-        performOnePointerMove(inputState, x, y, window);
+        performOnePointerMove(inputState, x, y, win);
         // wait |fps60| ms before performing next pointer move
         await new Promise(resolveTimer =>
             timer.initWithCallback(resolveTimer, fps60, ONE_SHOT));
 
         durationRatio = Math.floor(Date.now() - start) / duration;
       }
     })();
 
     // perform last pointer move after all incremental moves are resolved and
     // durationRatio is close enough to 1
     intermediatePointerEvents.then(() => {
-      performOnePointerMove(inputState, targetX, targetY, window);
+      performOnePointerMove(inputState, targetX, targetY, win);
       resolve();
     }).catch(err => {
       reject(err);
     });
   });
 }
 
 function performOnePointerMove(inputState, targetX, targetY, win) {
@@ -1436,17 +1436,17 @@ function capitalize(str) {
 
 function inViewPort(x, y, win) {
   assert.number(x, `Expected x to be finite number`);
   assert.number(y, `Expected y to be finite number`);
   // Viewport includes scrollbars if rendered.
   return !(x < 0 || y < 0 || x > win.innerWidth || y > win.innerHeight);
 }
 
-function getElementCenter(el, window) {
+function getElementCenter(el, win) {
   if (element.isDOMElement(el)) {
     if (action.specCompatPointerOrigin) {
-      return element.getInViewCentrePoint(el.getClientRects()[0], window);
+      return element.getInViewCentrePoint(el.getClientRects()[0], win);
     }
     return element.coordinates(el);
   }
   return {};
 }
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -196,34 +196,34 @@ element.Store = class {
 
   /**
    * Retrieve a DOM {@link Element} or a {@link XULElement} by its
    * unique {@link WebElement} reference.
    *
    * @param {WebElement} webEl
    *     Web element reference to find the associated {@link Element}
    *     of.
-   * @param {WindowProxy} window
+   * @param {WindowProxy} win
    *     Current browsing context, which may differ from the associate
    *     browsing context of <var>el</var>.
    *
    * @returns {(Element|XULElement)}
    *     Element associated with reference.
    *
    * @throws {TypeError}
    *     If <var>webEl</var> is not a {@link WebElement}.
    * @throws {NoSuchElementError}
    *     If the web element reference <var>uuid</var> has not been
    *     seen before.
    * @throws {StaleElementReferenceError}
    *     If the element has gone stale, indicating it is no longer
    *     attached to the DOM, or its node document is no longer the
    *     active document.
    */
-  get(webEl, window) {
+  get(webEl, win) {
     if (!(webEl instanceof WebElement)) {
       throw new TypeError(
           pprint`Expected web element, got: ${webEl}`);
     }
     if (!this.has(webEl)) {
       throw new NoSuchElementError(
           "Web element reference not seen before: " + webEl.uuid);
     }
@@ -231,17 +231,17 @@ element.Store = class {
     let el;
     let ref = this.els[webEl.uuid];
     try {
       el = ref.get();
     } catch (e) {
       delete this.els[webEl.uuid];
     }
 
-    if (element.isStale(el, window)) {
+    if (element.isStale(el, win)) {
       throw new StaleElementReferenceError(
           pprint`The element reference of ${el || webEl.uuid} is stale; ` +
               "either the element is no longer attached to the DOM, " +
               "it is not in the current frame context, " +
               "or the document has been refreshed");
     }
 
     return el;
@@ -715,32 +715,32 @@ element.isCollection = function(seq) {
  * may differ from <var>el</var>'s associated context, an element is
  * considered stale even if it is connected to a living (not discarded)
  * browsing context such as an <tt>&lt;iframe&gt;</tt>.
  *
  * @param {Element=} el
  *     DOM element to check for staleness.  If null, which may be
  *     the case if the element has been unwrapped from a weak
  *     reference, it is always considered stale.
- * @param {WindowProxy=} window
+ * @param {WindowProxy=} win
  *     Current browsing context, which may differ from the associate
  *     browsing context of <var>el</var>.  When retrieving XUL
  *     elements, this is optional.
  *
  * @return {boolean}
  *     True if <var>el</var> is stale, false otherwise.
  */
-element.isStale = function(el, window = undefined) {
-  if (typeof window == "undefined") {
-    window = el.ownerGlobal;
+element.isStale = function(el, win = undefined) {
+  if (typeof win == "undefined") {
+    win = el.ownerGlobal;
   }
 
   if (el === null ||
       !el.ownerGlobal ||
-      el.ownerDocument !== window.document) {
+      el.ownerDocument !== win.document) {
     return true;
   }
 
   return !el.isConnected;
 };
 
 /**
  * Determine if <var>el</var> is selected or not.
@@ -1141,33 +1141,33 @@ element.isObscured = function(el) {
 // https://bugzil.la/1354578
 /**
  * Calculate the in-view centre point of the area of the given DOM client
  * rectangle that is inside the viewport.
  *
  * @param {DOMRect} rect
  *     Element off a DOMRect sequence produced by calling
  *     <code>getClientRects</code> on an {@link Element}.
- * @param {WindowProxy} window
+ * @param {WindowProxy} win
  *     Current window global.
  *
  * @return {Map.<string, number>}
  *     X and Y coordinates that denotes the in-view centre point of
  *     <var>rect</var>.
  */
-element.getInViewCentrePoint = function(rect, window) {
+element.getInViewCentrePoint = function(rect, win) {
   const {max, min} = Math;
 
   let x = {
     left: max(0, min(rect.x, rect.x + rect.width)),
-    right: min(window.innerWidth, max(rect.x, rect.x + rect.width)),
+    right: min(win.innerWidth, max(rect.x, rect.x + rect.width)),
   };
   let y = {
     top: max(0, min(rect.y, rect.y + rect.height)),
-    bottom: min(window.innerHeight, max(rect.y, rect.y + rect.height)),
+    bottom: min(win.innerHeight, max(rect.y, rect.y + rect.height)),
   };
 
   return {
     x: (x.left + x.right) / 2,
     y: (y.top + y.bottom) / 2,
   };
 };
 
--- a/testing/marionette/evaluate.js
+++ b/testing/marionette/evaluate.js
@@ -146,60 +146,60 @@ evaluate.sandbox = function(sb, script, 
  * Convert any web elements in arbitrary objects to DOM elements by
  * looking them up in the seen element store.
  *
  * @param {Object} obj
  *     Arbitrary object containing web elements.
  * @param {element.Store=} seenEls
  *     Known element store to look up web elements from.  If undefined,
  *     the web element references are returned instead.
- * @param {WindowProxy=} window
+ * @param {WindowProxy=} win
  *     Current browsing context, if `seenEls` is provided.
  *
  * @return {Object}
  *     Same object as provided by `obj` with the web elements
  *     replaced by DOM elements.
  *
  * @throws {NoSuchElementError}
  *     If `seenEls` is given and the web element reference has not
  *     been seen before.
  * @throws {StaleElementReferenceError}
  *     If `seenEls` is given and the element has gone stale, indicating
  *     it is no longer attached to the DOM, or its node document
  *     is no longer the active document.
  */
-evaluate.fromJSON = function(obj, seenEls = undefined, window = undefined) {
+evaluate.fromJSON = function(obj, seenEls = undefined, win = undefined) {
   switch (typeof obj) {
     case "boolean":
     case "number":
     case "string":
     default:
       return obj;
 
     case "object":
       if (obj === null) {
         return obj;
 
       // arrays
       } else if (Array.isArray(obj)) {
-        return obj.map(e => evaluate.fromJSON(e, seenEls, window));
+        return obj.map(e => evaluate.fromJSON(e, seenEls, win));
 
       // web elements
       } else if (WebElement.isReference(obj)) {
         let webEl = WebElement.fromJSON(obj);
         if (seenEls) {
-          return seenEls.get(webEl, window);
+          return seenEls.get(webEl, win);
         }
         return webEl;
       }
 
       // arbitrary objects
       let rv = {};
       for (let prop in obj) {
-        rv[prop] = evaluate.fromJSON(obj[prop], seenEls, window);
+        rv[prop] = evaluate.fromJSON(obj[prop], seenEls, win);
       }
       return rv;
   }
 };
 
 /**
  * Marshal arbitrary objects to JSON-safe primitives that can be
  * transported over the Marionette protocol.
@@ -413,63 +413,63 @@ sandbox.augment = function(sb, adapter) 
   }
 
   return sb;
 };
 
 /**
  * Creates a sandbox.
  *
- * @param {Window} window
+ * @param {Window} win
  *     The DOM Window object.
  * @param {nsIPrincipal=} principal
  *     An optional, custom principal to prefer over the Window.  Useful if
  *     you need elevated security permissions.
  *
  * @return {Sandbox}
  *     The created sandbox.
  */
-sandbox.create = function(window, principal = null, opts = {}) {
-  let p = principal || window;
+sandbox.create = function(win, principal = null, opts = {}) {
+  let p = principal || win;
   opts = Object.assign({
-    sameZoneAs: window,
-    sandboxPrototype: window,
+    sameZoneAs: win,
+    sandboxPrototype: win,
     wantComponents: true,
     wantXrays: true,
   }, opts);
   return new Cu.Sandbox(p, opts);
 };
 
 /**
  * Creates a mutable sandbox, where changes to the global scope
  * will have lasting side-effects.
  *
- * @param {Window} window
+ * @param {Window} win
  *     The DOM Window object.
  *
  * @return {Sandbox}
  *     The created sandbox.
  */
-sandbox.createMutable = function(window) {
+sandbox.createMutable = function(win) {
   let opts = {
     wantComponents: false,
     wantXrays: false,
   };
   // Note: We waive Xrays here to match potentially-accidental old behavior.
-  return Cu.waiveXrays(sandbox.create(window, null, opts));
+  return Cu.waiveXrays(sandbox.create(win, null, opts));
 };
 
-sandbox.createSystemPrincipal = function(window) {
+sandbox.createSystemPrincipal = function(win) {
   let principal = Cc["@mozilla.org/systemprincipal;1"]
       .createInstance(Ci.nsIPrincipal);
-  return sandbox.create(window, principal);
+  return sandbox.create(win, principal);
 };
 
-sandbox.createSimpleTest = function(window, harness) {
-  let sb = sandbox.create(window);
+sandbox.createSimpleTest = function(win, harness) {
+  let sb = sandbox.create(win);
   sb = sandbox.augment(sb, harness);
   sb[FINISH] = () => sb[COMPLETE](harness.generate_results());
   return sb;
 };
 
 /**
  * Sandbox storage.  When the user requests a sandbox by a specific name,
  * if one exists in the storage this will be used as long as its window
--- a/testing/marionette/event.js
+++ b/testing/marionette/event.js
@@ -17,25 +17,16 @@ const dblclickTimer = Cc["@mozilla.org/t
 //  Max interval between two clicks that should result in a dblclick (in ms)
 const DBLCLICK_INTERVAL = 640;
 
 this.EXPORTED_SYMBOLS = ["event"];
 
 // TODO(ato): Document!
 let seenEvent = false;
 
-function getDOMWindowUtils(win) {
-  if (!win) {
-    win = window;
-  }
-
-  // this assumes we are operating in chrome space
-  return win.windowUtils;
-}
-
 event.MouseEvents = {
   click: 0,
   dblclick: 1,
   mousedown: 2,
   mouseup: 3,
   mouseover: 4,
   mouseout: 5,
 };
@@ -78,129 +69,16 @@ event.DoubleClickTracker = {
     dblclickTimer.initWithCallback(event.DoubleClickTracker.resetClick,
         DBLCLICK_INTERVAL, Ci.nsITimer.TYPE_ONE_SHOT);
   },
   cancelTimer() {
     dblclickTimer.cancel();
   },
 };
 
-/**
- * Sends a mouse event to given target.
- *
- * @param {MouseEvent} mouseEvent
- *     Event to send.
- * @param {(DOMElement|string)} target
- *     Target of event.  Can either be an element or the ID of an element.
- * @param {Window=} window
- *     Window object.  Defaults to the current window.
- *
- * @throws {TypeError}
- *     If the event is unsupported.
- */
-event.sendMouseEvent = function(mouseEvent, target, window = undefined) {
-  if (!event.MouseEvents.hasOwnProperty(mouseEvent.type)) {
-    throw new TypeError("Unsupported event type: " + mouseEvent.type);
-  }
-
-  if (!target.nodeType && typeof target != "string") {
-    throw new TypeError(
-        "Target can only be a DOM element or a string: " + target);
-  }
-
-  if (!target.nodeType) {
-    target = window.document.getElementById(target);
-  } else {
-    window = window || target.ownerGlobal;
-  }
-
-  let ev = window.document.createEvent("MouseEvent");
-
-  let view = window;
-
-  let detail = mouseEvent.detail;
-  if (!detail) {
-    if (mouseEvent.type in ["click", "mousedown", "mouseup"]) {
-      detail = 1;
-    } else if (mouseEvent.type == "dblclick") {
-      detail = 2;
-    } else {
-      detail = 0;
-    }
-  }
-
-  let screenX = mouseEvent.screenX || 0;
-  let screenY = mouseEvent.screenY || 0;
-  let clientX = mouseEvent.clientX || 0;
-  let clientY = mouseEvent.clientY || 0;
-  let ctrlKey = mouseEvent.ctrlKey || false;
-  let altKey = mouseEvent.altKey || false;
-  let shiftKey = mouseEvent.shiftKey || false;
-  let metaKey = mouseEvent.metaKey || false;
-  let button = mouseEvent.button || 0;
-  let relatedTarget = mouseEvent.relatedTarget || null;
-
-  ev.initMouseEvent(
-      mouseEvent.type,
-      /* canBubble */ true,
-      /* cancelable */ true,
-      view,
-      detail,
-      screenX,
-      screenY,
-      clientX,
-      clientY,
-      ctrlKey,
-      altKey,
-      shiftKey,
-      metaKey,
-      button,
-      relatedTarget);
-};
-
-/**
- * Send character to the currently focused element.
- *
- * This function handles casing of characters (sends the right charcode,
- * and sends a shift key for uppercase chars).  No other modifiers are
- * handled at this point.
- *
- * For now this method only works for English letters (lower and upper
- * case) and the digits 0-9.
- */
-event.sendChar = function(char, window = undefined) {
-  // DOM event charcodes match ASCII (JS charcodes) for a-zA-Z0-9
-  let hasShift = (char == char.toUpperCase());
-  event.synthesizeKey(char, {shiftKey: hasShift}, window);
-};
-
-/**
- * Send string to the focused element.
- *
- * For now this method only works for English letters (lower and upper
- * case) and the digits 0-9.
- */
-event.sendString = function(string, window = undefined) {
-  for (let i = 0; i < string.length; ++i) {
-    event.sendChar(string.charAt(i), window);
-  }
-};
-
-/**
- * Send the non-character key to the focused element.
- *
- * The name of the key should be the part that comes after "DOM_VK_"
- * in the KeyboardEvent constant name for this key.  No modifiers are
- * handled at this point.
- */
-event.sendKey = function(key, window = undefined) {
-  let keyName = "VK_" + key.toUpperCase();
-  event.synthesizeKey(keyName, {shiftKey: false}, window);
-};
-
 // TODO(ato): Unexpose this when action.Chain#emitMouseEvent
 // no longer emits its own events
 event.parseModifiers_ = function(modifiers) {
   let mval = 0;
   if (modifiers.shiftKey) {
     mval |= Ci.nsIDOMWindowUtils.MODIFIER_SHIFT;
   }
   if (modifiers.ctrlKey) {
@@ -237,47 +115,44 @@ event.parseModifiers_ = function(modifie
  * @param {number} offsetX
  *     Horizontal offset to click from the target's bounding box.
  * @param {number} offsetY
  *     Vertical offset to click from the target's bounding box.
  * @param {Object.<string, ?>} opts
  *     Object which may contain the properties "shiftKey", "ctrlKey",
  *     "altKey", "metaKey", "accessKey", "clickCount", "button", and
  *     "type".
- * @param {Window=} window
- *     Window object.  Defaults to the current window.
+ * @param {Window} win
+ *     Window object.
  */
-event.synthesizeMouse = function(
-    element, offsetX, offsetY, opts, window = undefined) {
+event.synthesizeMouse = function(element, offsetX, offsetY, opts, win) {
   let rect = element.getBoundingClientRect();
   event.synthesizeMouseAtPoint(
-      rect.left + offsetX, rect.top + offsetY, opts, window);
+      rect.left + offsetX, rect.top + offsetY, opts, win);
 };
 
 /*
  * Synthesize a mouse event at a particular point in a window.
  *
  * If the type of the event is specified, a mouse event of that type is
  * fired. Otherwise, a mousedown followed by a mouse up is performed.
  *
  * @param {number} left
  *     CSS pixels from the left document margin.
  * @param {number} top
  *     CSS pixels from the top document margin.
  * @param {Object.<string, ?>} opts
  *     Object which may contain the properties "shiftKey", "ctrlKey",
  *     "altKey", "metaKey", "accessKey", "clickCount", "button", and
  *     "type".
- * @param {Window=} win
- *     Window object.  Defaults to the current window.
+ * @param {Window} win
+ *     Window object.
  */
-event.synthesizeMouseAtPoint = function(
-    left, top, opts, win = window) {
-
-  let domutils = getDOMWindowUtils(win);
+event.synthesizeMouseAtPoint = function(left, top, opts, win) {
+  let domutils = win.windowUtils;
 
   let button = opts.button || 0;
   let clickCount = opts.clickCount || 1;
   let modifiers = event.parseModifiers_(opts);
   let pressure = ("pressure" in opts) ? opts.pressure : 0;
   let inputSource = ("inputSource" in opts) ? opts.inputSource :
       win.MouseEvent.MOZ_SOURCE_MOUSE;
   let isDOMEventSynthesized =
@@ -334,32 +209,18 @@ event.synthesizeMouseAtPoint = function(
         pressure,
         inputSource,
         isDOMEventSynthesized,
         isWidgetEventSynthesized,
         buttons);
   }
 };
 
-/**
- * Call event.synthesizeMouse with coordinates at the centre of the
- * target.
- */
-event.synthesizeMouseAtCenter = function(element, event, window) {
-  let rect = element.getBoundingClientRect();
-  event.synthesizeMouse(
-      element,
-      rect.width / 2,
-      rect.height / 2,
-      event,
-      window);
-};
-
 /* eslint-disable */
-function computeKeyCodeFromChar_(char, win = window) {
+function computeKeyCodeFromChar_(char, win) {
   if (char.length != 1) {
     return 0;
   }
 
   let KeyboardEvent = getKeyboardEvent_(win);
 
   if (char in VIRTUAL_KEYCODE_LOOKUP) {
     return KeyboardEvent["DOM_" + VIRTUAL_KEYCODE_LOOKUP[char]];