Bug 1447392 - Remove all members from nsIDOMNodeList. r=bz
authorAdrian Wielgosik <adrian.wielgosik@gmail.com>
Tue, 20 Mar 2018 19:02:08 +0100
changeset 462736 65c41f6478ab7c7fedd1d9591cf6464ada2c0372
parent 462735 cc460b46ffccf4e4a4d25c629f19ed29cb260dbd
child 462737 654321c182e98e4ae5c79240438033b134723970
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1447392
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1447392 - Remove all members from nsIDOMNodeList. r=bz MozReview-Commit-ID: 68xF7CTMpKB
accessible/xul/XULListboxAccessible.cpp
dom/base/Element.cpp
dom/base/FragmentOrElement.cpp
dom/base/IDTracker.cpp
dom/base/nsChildContentList.h
dom/base/nsContentList.cpp
dom/base/nsContentList.h
dom/base/nsDocument.cpp
dom/base/nsINodeList.h
dom/html/HTMLFormElement.cpp
dom/interfaces/core/nsIDOMNodeList.idl
dom/xbl/XBLChildrenElement.cpp
dom/xbl/XBLChildrenElement.h
dom/xslt/xslt/txMozillaXSLTProcessor.cpp
layout/base/PresShell.cpp
--- a/accessible/xul/XULListboxAccessible.cpp
+++ b/accessible/xul/XULListboxAccessible.cpp
@@ -271,19 +271,19 @@ XULListboxAccessible::SelectedCellCount(
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
   nsCOMPtr<nsIDOMNodeList> selectedItems;
   control->GetSelectedItems(getter_AddRefs(selectedItems));
   if (!selectedItems)
     return 0;
 
-  uint32_t selectedItemsCount = 0;
-  nsresult rv = selectedItems->GetLength(&selectedItemsCount);
-  NS_ENSURE_SUCCESS(rv, 0);
+  nsINodeList* list = nsINodeList::FromDOMNodeList(selectedItems);
+
+  uint32_t selectedItemsCount = list->Length();
 
   return selectedItemsCount * ColCount();
 }
 
 uint32_t
 XULListboxAccessible::SelectedColCount()
 {
   nsCOMPtr<nsIDOMXULMultiSelectControlElement> control =
@@ -321,25 +321,22 @@ XULListboxAccessible::SelectedCells(nsTA
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
   nsCOMPtr<nsIDOMNodeList> selectedItems;
   control->GetSelectedItems(getter_AddRefs(selectedItems));
   if (!selectedItems)
     return;
+  nsINodeList* list = nsINodeList::FromDOMNodeList(selectedItems);
 
-  uint32_t selectedItemsCount = 0;
-  DebugOnly<nsresult> rv = selectedItems->GetLength(&selectedItemsCount);
-  NS_ASSERTION(NS_SUCCEEDED(rv), "GetLength() Shouldn't fail!");
+  uint32_t selectedItemsCount = list->Length();
 
   for (uint32_t index = 0; index < selectedItemsCount; index++) {
-    nsCOMPtr<nsIDOMNode> itemNode;
-    selectedItems->Item(index, getter_AddRefs(itemNode));
-    nsCOMPtr<nsIContent> itemContent(do_QueryInterface(itemNode));
+    nsIContent* itemContent = list->Item(index);
     Accessible* item = mDoc->GetAccessible(itemContent);
 
     if (item) {
       uint32_t cellCount = item->ChildCount();
       for (uint32_t cellIdx = 0; cellIdx < cellCount; cellIdx++) {
         Accessible* cell = mChildren[cellIdx];
         if (cell->Role() == roles::CELL)
           aCells->AppendElement(cell);
@@ -355,32 +352,30 @@ XULListboxAccessible::SelectedCellIndice
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
   nsCOMPtr<nsIDOMNodeList> selectedItems;
   control->GetSelectedItems(getter_AddRefs(selectedItems));
   if (!selectedItems)
     return;
+  nsINodeList* list = nsINodeList::FromDOMNodeList(selectedItems);
 
-  uint32_t selectedItemsCount = 0;
-  DebugOnly<nsresult> rv = selectedItems->GetLength(&selectedItemsCount);
-  NS_ASSERTION(NS_SUCCEEDED(rv), "GetLength() Shouldn't fail!");
+  uint32_t selectedItemsCount = list->Length();
 
   uint32_t colCount = ColCount();
   aCells->SetCapacity(selectedItemsCount * colCount);
   aCells->AppendElements(selectedItemsCount * colCount);
 
   for (uint32_t selItemsIdx = 0, cellsIdx = 0;
        selItemsIdx < selectedItemsCount; selItemsIdx++) {
 
-    nsCOMPtr<nsIDOMNode> itemNode;
-    selectedItems->Item(selItemsIdx, getter_AddRefs(itemNode));
+    nsIContent* itemContent = list->Item(selItemsIdx);
     nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
-      do_QueryInterface(itemNode);
+      do_QueryInterface(itemContent);
 
     if (item) {
       int32_t itemIdx = -1;
       control->GetIndexOfItem(item, &itemIdx);
       if (itemIdx >= 0)
         for (uint32_t colIdx = 0; colIdx < colCount; colIdx++, cellsIdx++)
           aCells->ElementAt(cellsIdx) = itemIdx * colCount + colIdx;
     }
@@ -404,32 +399,30 @@ XULListboxAccessible::SelectedRowIndices
     do_QueryInterface(mContent);
   NS_ASSERTION(control,
                "Doesn't implement nsIDOMXULMultiSelectControlElement.");
 
   nsCOMPtr<nsIDOMNodeList> selectedItems;
   control->GetSelectedItems(getter_AddRefs(selectedItems));
   if (!selectedItems)
     return;
+  nsINodeList* list = nsINodeList::FromDOMNodeList(selectedItems);
 
-  uint32_t rowCount = 0;
-  DebugOnly<nsresult> rv = selectedItems->GetLength(&rowCount);
-  NS_ASSERTION(NS_SUCCEEDED(rv), "GetLength() Shouldn't fail!");
+  uint32_t rowCount = list->Length();
 
   if (!rowCount)
     return;
 
   aRows->SetCapacity(rowCount);
   aRows->AppendElements(rowCount);
 
   for (uint32_t rowIdx = 0; rowIdx < rowCount; rowIdx++) {
-    nsCOMPtr<nsIDOMNode> itemNode;
-    selectedItems->Item(rowIdx, getter_AddRefs(itemNode));
+    nsIContent* itemContent = list->Item(rowIdx);
     nsCOMPtr<nsIDOMXULSelectControlItemElement> item =
-      do_QueryInterface(itemNode);
+      do_QueryInterface(itemContent);
 
     if (item) {
       int32_t itemIdx = -1;
       control->GetIndexOfItem(item, &itemIdx);
       if (itemIdx >= 0)
         aRows->ElementAt(rowIdx) = itemIdx;
     }
   }
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -3137,31 +3137,27 @@ Element::List(FILE* out, int32_t aIndent
   Element* nonConstThis = const_cast<Element*>(this);
 
   // XXX sXBL/XBL2 issue! Owner or current document?
   nsIDocument *document = OwnerDoc();
 
   // Note: not listing nsIAnonymousContentCreator-created content...
 
   nsBindingManager* bindingManager = document->BindingManager();
-  nsCOMPtr<nsIDOMNodeList> anonymousChildren;
-  bindingManager->GetAnonymousNodesFor(nonConstThis,
-                                       getter_AddRefs(anonymousChildren));
+  nsINodeList* anonymousChildren =
+    bindingManager->GetAnonymousNodesFor(nonConstThis);
 
   if (anonymousChildren) {
-    uint32_t length = 0;
-    anonymousChildren->GetLength(&length);
+    uint32_t length = anonymousChildren->Length();
 
     for (indent = aIndent; --indent >= 0; ) fputs("  ", out);
     fputs("anonymous-children<\n", out);
 
     for (uint32_t i = 0; i < length; ++i) {
-      nsCOMPtr<nsIDOMNode> node;
-      anonymousChildren->Item(i, getter_AddRefs(node));
-      nsCOMPtr<nsIContent> child = do_QueryInterface(node);
+      nsIContent* child = anonymousChildren->Item(i);
       child->List(out, aIndent + 1);
     }
 
     for (indent = aIndent; --indent >= 0; ) fputs("  ", out);
     fputs(">\n", out);
 
     bool outHeader = false;
     ExplicitChildIterator iter(nonConstThis);
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -476,35 +476,20 @@ NS_INTERFACE_MAP_END
 
 JSObject*
 nsAttrChildContentList::WrapObject(JSContext *cx,
                                    JS::Handle<JSObject*> aGivenProto)
 {
   return NodeListBinding::Wrap(cx, this, aGivenProto);
 }
 
-NS_IMETHODIMP
-nsAttrChildContentList::GetLength(uint32_t* aLength)
+uint32_t
+nsAttrChildContentList::Length()
 {
-  *aLength = mNode ? mNode->GetChildCount() : 0;
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAttrChildContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
-{
-  nsINode* node = Item(aIndex);
-  if (!node) {
-    *aReturn = nullptr;
-
-    return NS_OK;
-  }
-
-  return CallQueryInterface(node, aReturn);
+  return mNode ? mNode->GetChildCount() : 0;
 }
 
 nsIContent*
 nsAttrChildContentList::Item(uint32_t aIndex)
 {
   if (mNode) {
     return mNode->GetChildAt_Deprecated(aIndex);
   }
@@ -518,40 +503,26 @@ nsAttrChildContentList::IndexOf(nsIConte
   if (mNode) {
     return mNode->ComputeIndexOf(aContent);
   }
 
   return -1;
 }
 
 //----------------------------------------------------------------------
-NS_IMETHODIMP
-nsParentNodeChildContentList::GetLength(uint32_t* aLength)
+uint32_t
+nsParentNodeChildContentList::Length()
 {
   if (!mIsCacheValid && !ValidateCache()) {
-    *aLength = 0;
-    return NS_OK;
+    return 0;
   }
 
   MOZ_ASSERT(mIsCacheValid);
 
-  *aLength = mCachedChildArray.Length();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsParentNodeChildContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
-{
-  nsINode* node = Item(aIndex);
-  if (!node) {
-    *aReturn = nullptr;
-    return NS_OK;
-  }
-
-  return CallQueryInterface(node, aReturn);
+  return mCachedChildArray.Length();
 }
 
 nsIContent*
 nsParentNodeChildContentList::Item(uint32_t aIndex)
 {
   if (!mIsCacheValid && !ValidateCache()) {
     return nullptr;
   }
--- a/dom/base/IDTracker.cpp
+++ b/dom/base/IDTracker.cpp
@@ -78,18 +78,17 @@ IDTracker::Reset(nsIContent* aFromConten
         // the binding document should resolve to the copy of the target
         // element that has been inserted into the bound document.
         // If the URI points to a different document we don't need this
         // restriction.
         nsINodeList* anonymousChildren =
           doc->BindingManager()->GetAnonymousNodesFor(bindingParent);
 
         if (anonymousChildren) {
-          uint32_t length;
-          anonymousChildren->GetLength(&length);
+          uint32_t length = anonymousChildren->Length();
           for (uint32_t i = 0; i < length && !mElement; ++i) {
             mElement =
               nsContentUtils::MatchElementId(anonymousChildren->Item(i), ref);
           }
         }
 
         // We don't have watching working yet for XBL, so bail out here.
         return;
--- a/dom/base/nsChildContentList.h
+++ b/dom/base/nsChildContentList.h
@@ -10,42 +10,40 @@
 #include "nsISupportsImpl.h"
 #include "nsINodeList.h"      // base class
 #include "js/TypeDecls.h"     // for Handle, Value, JSObject, JSContext
 
 class nsIContent;
 class nsINode;
 
 /**
- * Class that implements the nsIDOMNodeList interface (a list of children of
- * the content), by holding a reference to the content and delegating GetLength
+ * Class that implements the nsINodeList interface (a list of children of
+ * the content), by holding a reference to the content and delegating Length
  * and Item to its existing child list.
- * @see nsIDOMNodeList
+ * @see nsINodeList
  */
 class nsAttrChildContentList : public nsINodeList
 {
 public:
   explicit nsAttrChildContentList(nsINode* aNode)
     : mNode(aNode)
   {
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(nsAttrChildContentList)
 
   // nsWrapperCache
   virtual JSObject* WrapObject(JSContext *cx,
                                JS::Handle<JSObject*> aGivenProto) override;
 
-  // nsIDOMNodeList interface
-  NS_DECL_NSIDOMNODELIST
-
   // nsINodeList interface
   virtual int32_t IndexOf(nsIContent* aContent) override;
   virtual nsIContent* Item(uint32_t aIndex) override;
+  uint32_t Length() override;
 
   virtual void DropReference()
   {
     mNode = nullptr;
   }
 
   virtual nsINode* GetParentObject() override
   {
@@ -67,22 +65,20 @@ class nsParentNodeChildContentList final
 public:
   explicit nsParentNodeChildContentList(nsINode* aNode)
     : nsAttrChildContentList(aNode)
     , mIsCacheValid(false)
   {
     ValidateCache();
   }
 
-  // nsIDOMNodeList interface
-  NS_DECL_NSIDOMNODELIST
-
   // nsINodeList interface
   virtual int32_t IndexOf(nsIContent* aContent) override;
   virtual nsIContent* Item(uint32_t aIndex) override;
+  uint32_t Length() override;
 
   void DropReference() override
   {
     InvalidateCache();
     nsAttrChildContentList::DropReference();
   }
 
   void InvalidateCache()
--- a/dom/base/nsContentList.cpp
+++ b/dom/base/nsContentList.cpp
@@ -82,39 +82,16 @@ NS_INTERFACE_TABLE_HEAD(nsBaseContentLis
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsBaseContentList)
 NS_INTERFACE_MAP_END
 
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsBaseContentList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE_WITH_LAST_RELEASE(nsBaseContentList,
                                                    LastRelease())
 
-
-NS_IMETHODIMP
-nsBaseContentList::GetLength(uint32_t* aLength)
-{
-  *aLength = mElements.Length();
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsBaseContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
-{
-  nsISupports *tmp = Item(aIndex);
-
-  if (!tmp) {
-    *aReturn = nullptr;
-
-    return NS_OK;
-  }
-
-  return CallQueryInterface(tmp, aReturn);
-}
-
 nsIContent*
 nsBaseContentList::Item(uint32_t aIndex)
 {
   return mElements.SafeElementAt(aIndex);
 }
 
 
 int32_t
@@ -156,31 +133,16 @@ NS_IMPL_ADDREF_INHERITED(nsEmptyContentL
 NS_IMPL_RELEASE_INHERITED(nsEmptyContentList, nsBaseContentList)
 
 JSObject*
 nsEmptyContentList::WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto)
 {
   return HTMLCollectionBinding::Wrap(cx, this, aGivenProto);
 }
 
-NS_IMETHODIMP
-nsEmptyContentList::GetLength(uint32_t* aLength)
-{
-  *aLength = 0;
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsEmptyContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
-{
-  *aReturn = nullptr;
-  return NS_OK;
-}
-
 mozilla::dom::Element*
 nsEmptyContentList::GetElementAt(uint32_t index)
 {
   return nullptr;
 }
 
 mozilla::dom::Element*
 nsEmptyContentList::GetFirstNamedElement(const nsAString& aName, bool& aFound)
@@ -642,38 +604,16 @@ nsContentList::LastRelease()
   RemoveFromCaches();
   if (mIsLiveList && mRootNode) {
     mRootNode->RemoveMutationObserver(this);
     mRootNode = nullptr;
   }
   SetDirty();
 }
 
-NS_IMETHODIMP
-nsContentList::GetLength(uint32_t* aLength)
-{
-  *aLength = Length(true);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
-{
-  nsINode* node = Item(aIndex);
-
-  if (node) {
-    return CallQueryInterface(node, aReturn);
-  }
-
-  *aReturn = nullptr;
-
-  return NS_OK;
-}
-
 Element*
 nsContentList::GetElementAt(uint32_t aIndex)
 {
   return static_cast<Element*>(Item(aIndex, true));
 }
 
 nsIContent*
 nsContentList::Item(uint32_t aIndex)
--- a/dom/base/nsContentList.h
+++ b/dom/base/nsContentList.h
@@ -37,24 +37,21 @@ class Element;
 } // namespace mozilla
 
 
 class nsBaseContentList : public nsINodeList
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
-  // nsIDOMNodeList
-  NS_DECL_NSIDOMNODELIST
-
   // nsINodeList
   virtual int32_t IndexOf(nsIContent* aContent) override;
   virtual nsIContent* Item(uint32_t aIndex) override;
 
-  uint32_t Length() const {
+  uint32_t Length() override {
     return mElements.Length();
   }
 
   NS_DECL_CYCLE_COLLECTION_SKIPPABLE_SCRIPT_HOLDER_CLASS(nsBaseContentList)
 
   void AppendElement(nsIContent *aContent)
   {
     mElements.AppendElement(aContent);
@@ -148,18 +145,16 @@ public:
   explicit nsEmptyContentList(nsINode* aRoot) : nsBaseContentList(),
                                                 mRoot(aRoot)
   {
   }
 
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsEmptyContentList,
                                            nsBaseContentList)
-  // nsIDOMNodeList, which we also implement.
-  NS_DECL_NSIDOMNODELIST
 
   virtual nsINode* GetParentObject() override
   {
     return mRoot;
   }
 
   virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
@@ -330,32 +325,29 @@ protected:
     return nsWrapperCache::GetWrapperPreserveColor();
   }
   virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) override
   {
     nsWrapperCache::PreserveWrapper(aScriptObjectHolder);
   }
 public:
 
-  // nsIDOMNodeList, which we also implement.
-  NS_DECL_NSIDOMNODELIST
-
   // nsBaseContentList overrides
   virtual int32_t IndexOf(nsIContent *aContent, bool aDoFlush) override;
   virtual int32_t IndexOf(nsIContent* aContent) override;
   virtual nsINode* GetParentObject() override
   {
     return mRootNode;
   }
 
   uint32_t Length() final
   {
     return Length(true);
   }
-  virtual nsIContent* Item(uint32_t aIndex) override;
+  nsIContent* Item(uint32_t aIndex) final;
   virtual mozilla::dom::Element* GetElementAt(uint32_t index) override;
   virtual mozilla::dom::Element*
   GetFirstNamedElement(const nsAString& aName, bool& aFound) override
   {
     mozilla::dom::Element* item = NamedItem(aName, true);
     aFound = !!item;
     return item;
   }
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -6165,18 +6165,17 @@ Element*
 nsIDocument::GetAnonymousElementByAttribute(nsIContent* aElement,
                                             nsAtom* aAttrName,
                                             const nsAString& aAttrValue) const
 {
   nsINodeList* nodeList = BindingManager()->GetAnonymousNodesFor(aElement);
   if (!nodeList)
     return nullptr;
 
-  uint32_t length = 0;
-  nodeList->GetLength(&length);
+  uint32_t length = nodeList->Length();
 
   bool universalMatch = aAttrValue.EqualsLiteral("*");
 
   for (uint32_t i = 0; i < length; ++i) {
     nsIContent* current = nodeList->Item(i);
     if (!current->IsElement()) {
       continue;
     }
--- a/dom/base/nsINodeList.h
+++ b/dom/base/nsINodeList.h
@@ -34,31 +34,27 @@ public:
    */
   virtual int32_t IndexOf(nsIContent* aContent) = 0;
 
   /**
    * Get the root node for this nodelist.
    */
   virtual nsINode* GetParentObject() = 0;
 
-  using nsIDOMNodeList::Item;
-
-  uint32_t Length()
-  {
-    uint32_t length;
-    GetLength(&length);
-    return length;
-  }
+  virtual uint32_t Length() = 0;
   virtual nsIContent* Item(uint32_t aIndex) = 0;
   nsIContent* IndexedGetter(uint32_t aIndex, bool& aFound)
   {
     nsIContent* item = Item(aIndex);
     aFound = !!item;
     return item;
   }
-};
 
-#define NS_NODELIST_OFFSET_AND_INTERFACE_TABLE_BEGIN(_class)                  \
-  NS_OFFSET_AND_INTERFACE_TABLE_BEGIN_AMBIGUOUS(_class, nsINodeList)
+  static nsINodeList* FromDOMNodeList(nsIDOMNodeList *list)
+  {
+    return static_cast<nsINodeList*>(list);
+  }
+
+};
 
 NS_DEFINE_STATIC_IID_ACCESSOR(nsINodeList, NS_INODELIST_IID)
 
 #endif /* nsINodeList_h___ */
--- a/dom/html/HTMLFormElement.cpp
+++ b/dom/html/HTMLFormElement.cpp
@@ -1444,18 +1444,17 @@ HTMLFormElement::RemoveElementFromTableI
   }
 
   // If it's not a content node then it must be a RadioNodeList.
   MOZ_ASSERT(nsCOMPtr<RadioNodeList>(do_QueryInterface(entry.Data())));
   auto* list = static_cast<RadioNodeList*>(entry.Data().get());
 
   list->RemoveElement(aChild);
 
-  uint32_t length = 0;
-  list->GetLength(&length);
+  uint32_t length = list->Length();
 
   if (!length) {
     // If the list is empty we remove if from our hash, this shouldn't
     // happen tho
     entry.Remove();
     ++mExpandoAndGeneration.generation;
   } else if (length == 1) {
     // Only one element left, replace the list in the hash with the
@@ -2184,18 +2183,17 @@ HTMLFormElement::GetNextRadioButton(cons
     return NS_ERROR_FAILURE;
   }
 
   int32_t index = radioGroup->IndexOf(currentRadio);
   if (index < 0) {
     return NS_ERROR_FAILURE;
   }
 
-  uint32_t numRadios;
-  radioGroup->GetLength(&numRadios);
+  uint32_t numRadios = radioGroup->Length();
   RefPtr<HTMLInputElement> radio;
 
   bool isRadio = false;
   do {
     if (aPrevious) {
       if (--index < 0) {
         index = numRadios -1;
       }
@@ -2255,25 +2253,23 @@ HTMLFormElement::WalkRadioGroup(const ns
   nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(item);
   if (formControl) {
     if (formControl->ControlType() == NS_FORM_INPUT_RADIO) {
       aVisitor->Visit(formControl);
     }
     return NS_OK;
   }
 
-  nsCOMPtr<nsIDOMNodeList> nodeList = do_QueryInterface(item);
+  nsCOMPtr<nsINodeList> nodeList = do_QueryInterface(item);
   if (!nodeList) {
     return NS_OK;
   }
-  uint32_t length = 0;
-  nodeList->GetLength(&length);
+  uint32_t length = nodeList->Length();
   for (uint32_t i = 0; i < length; i++) {
-    nsCOMPtr<nsIDOMNode> node;
-    nodeList->Item(i, getter_AddRefs(node));
+    nsIContent* node = nodeList->Item(i);
     nsCOMPtr<nsIFormControl> formControl = do_QueryInterface(node);
     if (formControl && formControl->ControlType() == NS_FORM_INPUT_RADIO &&
         !aVisitor->Visit(formControl)) {
       break;
     }
   }
   return NS_OK;
 }
--- a/dom/interfaces/core/nsIDOMNodeList.idl
+++ b/dom/interfaces/core/nsIDOMNodeList.idl
@@ -13,11 +13,9 @@
  *
  * For more information on this interface please see 
  * http://www.w3.org/TR/DOM-Level-2-Core/
  */
 
 [uuid(450cf0ba-de90-4f86-85bf-e10cc8b8713f)]
 interface nsIDOMNodeList : nsISupports
 {
-  nsIDOMNode    item(in unsigned long index);
-  readonly attribute unsigned long          length;
 };
--- a/dom/xbl/XBLChildrenElement.cpp
+++ b/dom/xbl/XBLChildrenElement.cpp
@@ -55,22 +55,21 @@ NS_IMPL_CYCLE_COLLECTING_ADDREF(nsAnonym
 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsAnonymousContentList)
 
 NS_INTERFACE_TABLE_HEAD(nsAnonymousContentList)
   NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
   NS_INTERFACE_TABLE(nsAnonymousContentList, nsINodeList, nsIDOMNodeList)
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsAnonymousContentList)
 NS_INTERFACE_MAP_END
 
-NS_IMETHODIMP
-nsAnonymousContentList::GetLength(uint32_t* aLength)
+uint32_t
+nsAnonymousContentList::Length()
 {
   if (!mParent) {
-    *aLength = 0;
-    return NS_OK;
+    return 0;
   }
 
   uint32_t count = 0;
   for (nsIContent* child = mParent->GetFirstChild();
        child;
        child = child->GetNextSibling()) {
     if (child->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
       XBLChildrenElement* point = static_cast<XBLChildrenElement*>(child);
@@ -81,30 +80,17 @@ nsAnonymousContentList::GetLength(uint32
         count += point->GetChildCount();
       }
     }
     else {
       ++count;
     }
   }
 
-  *aLength = count;
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsAnonymousContentList::Item(uint32_t aIndex, nsIDOMNode** aReturn)
-{
-  nsIContent* item = Item(aIndex);
-  if (!item) {
-    return NS_ERROR_FAILURE;
-  }
-
-  return CallQueryInterface(item, aReturn);
+  return count;
 }
 
 nsIContent*
 nsAnonymousContentList::Item(uint32_t aIndex)
 {
   if (!mParent) {
     return nullptr;
   }
--- a/dom/xbl/XBLChildrenElement.h
+++ b/dom/xbl/XBLChildrenElement.h
@@ -146,33 +146,32 @@ protected:
 private:
   nsTArray<nsIContent*> mInsertedChildren; // WEAK
   nsTArray<RefPtr<nsAtom> > mIncludes;
 };
 
 } // namespace dom
 } // namespace mozilla
 
-class nsAnonymousContentList : public nsINodeList
+class nsAnonymousContentList final : public nsINodeList
 {
 public:
   explicit nsAnonymousContentList(nsIContent* aParent)
     : mParent(aParent)
   {
   }
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsAnonymousContentList)
-  // nsIDOMNodeList interface
-  NS_DECL_NSIDOMNODELIST
 
   // nsINodeList interface
   virtual int32_t IndexOf(nsIContent* aContent) override;
   virtual nsINode* GetParentObject() override { return mParent; }
   virtual nsIContent* Item(uint32_t aIndex) override;
+  uint32_t Length() override;
 
   virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
   bool IsListFor(nsIContent* aContent) {
     return mParent == aContent;
   }
 
 private:
--- a/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
+++ b/dom/xslt/xslt/txMozillaXSLTProcessor.cpp
@@ -863,27 +863,23 @@ txMozillaXSLTProcessor::SetParameter(con
                 rv = variant->SetAsISupports(clone);
                 NS_ENSURE_SUCCESS(rv, rv);
 
                 value = variant;
 
                 break;
             }
 
-            nsCOMPtr<nsIDOMNodeList> nodeList = do_QueryInterface(supports);
+            nsCOMPtr<nsINodeList> nodeList = do_QueryInterface(supports);
             if (nodeList) {
-                uint32_t length;
-                nodeList->GetLength(&length);
+                uint32_t length = nodeList->Length();
 
-                nsCOMPtr<nsIDOMNode> node;
                 uint32_t i;
                 for (i = 0; i < length; ++i) {
-                    nodeList->Item(i, getter_AddRefs(node));
-
-                    if (!nsContentUtils::CanCallerAccess(node)) {
+                    if (!nsContentUtils::CanCallerAccess(nodeList->Item(i))) {
                         return NS_ERROR_DOM_SECURITY_ERR;
                     }
                 }
 
                 break;
             }
 
             // Random JS Objects will be converted to a string.
@@ -1428,33 +1424,29 @@ txVariable::Convert(nsIVariant *aValue, 
                 return NS_OK;
             }
 
             nsCOMPtr<nsIXPathResult> xpathResult = do_QueryInterface(supports);
             if (xpathResult) {
                 return xpathResult->GetExprResult(aResult);
             }
 
-            nsCOMPtr<nsIDOMNodeList> nodeList = do_QueryInterface(supports);
+            nsCOMPtr<nsINodeList> nodeList = do_QueryInterface(supports);
             if (nodeList) {
                 RefPtr<txNodeSet> nodeSet = new txNodeSet(nullptr);
                 if (!nodeSet) {
                     return NS_ERROR_OUT_OF_MEMORY;
                 }
 
-                uint32_t length;
-                nodeList->GetLength(&length);
+                uint32_t length = nodeList->Length();
 
-                nsCOMPtr<nsIDOMNode> node;
                 uint32_t i;
                 for (i = 0; i < length; ++i) {
-                    nodeList->Item(i, getter_AddRefs(node));
-
                     nsAutoPtr<txXPathNode> xpathNode(
-                        txXPathNativeNode::createXPathNode(node));
+                        txXPathNativeNode::createXPathNode(nodeList->Item(i)));
                     if (!xpathNode) {
                         return NS_ERROR_FAILURE;
                     }
 
                     nodeSet->add(*xpathNode);
                 }
 
                 NS_ADDREF(*aResult = nodeSet);
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -3112,34 +3112,26 @@ PresShell::GoToAnchor(const nsAString& a
   // Search for an element with a matching "id" attribute
   if (mDocument) {
     content = mDocument->GetElementById(aAnchorName);
   }
 
   // Search for an anchor element with a matching "name" attribute
   if (!content && mDocument->IsHTMLDocument()) {
     // Find a matching list of named nodes
-    nsCOMPtr<nsIDOMNodeList> list = mDocument->GetElementsByName(aAnchorName);
+    nsCOMPtr<nsINodeList> list = mDocument->GetElementsByName(aAnchorName);
     if (list) {
-      uint32_t i;
       // Loop through the named nodes looking for the first anchor
-      for (i = 0; true; i++) {
-        nsCOMPtr<nsIDOMNode> node;
-        rv = list->Item(i, getter_AddRefs(node));
-        if (!node) {  // End of list
+      uint32_t length = list->Length();
+      for (uint32_t i = 0; i < length; i++) {
+        nsIContent* node = list->Item(i);
+        if (node->IsHTMLElement(nsGkAtoms::a)) {
+          content = node;
           break;
         }
-        // Ensure it's an anchor element
-        content = do_QueryInterface(node);
-        if (content) {
-          if (content->IsHTMLElement(nsGkAtoms::a)) {
-            break;
-          }
-          content = nullptr;
-        }
       }
     }
   }
 
   // Search for anchor in the HTML namespace with a matching name
   if (!content && !mDocument->IsHTMLDocument())
   {
     NS_NAMED_LITERAL_STRING(nameSpace, "http://www.w3.org/1999/xhtml");