Bug 1415677 part 2. Remove nsIDOMHTMLCollection::Item. r=qdot
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 13 Nov 2017 10:39:02 -0500
changeset 436037 08cfdc174ee00429948f48e120f49e76587d2f95
parent 436036 fc56f1bc49b2d15ee229009bc11a46f041fc9e42
child 436038 dc91935b16b56684471e3b74196f76a960005221
push id117
push userfmarier@mozilla.com
push dateTue, 28 Nov 2017 20:17:16 +0000
reviewersqdot
bugs1415677
milestone59.0a1
Bug 1415677 part 2. Remove nsIDOMHTMLCollection::Item. r=qdot MozReview-Commit-ID: AQUjBQhXLHE
dom/base/nsContentList.cpp
dom/base/nsContentList.h
dom/base/nsDocument.cpp
dom/html/HTMLFormControlsCollection.cpp
dom/html/HTMLOptionsCollection.cpp
dom/html/HTMLTableElement.cpp
dom/html/nsIHTMLCollection.h
dom/interfaces/html/nsIDOMHTMLCollection.idl
--- a/dom/base/nsContentList.cpp
+++ b/dom/base/nsContentList.cpp
@@ -73,20 +73,16 @@ NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_END
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_BEGIN(nsBaseContentList)
   return nsCCUncollectableMarker::sGeneration && tmp->HasKnownLiveWrapper();
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_IN_CC_END
 
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_BEGIN(nsBaseContentList)
   return nsCCUncollectableMarker::sGeneration && tmp->HasKnownLiveWrapper();
 NS_IMPL_CYCLE_COLLECTION_CAN_SKIP_THIS_END
 
-#define NS_CONTENT_LIST_INTERFACES(_class)                                    \
-    NS_INTERFACE_TABLE_ENTRY(_class, nsINodeList)                             \
-    NS_INTERFACE_TABLE_ENTRY(_class, nsIDOMNodeList)
-
 // QueryInterface implementation for nsBaseContentList
 NS_INTERFACE_TABLE_HEAD(nsBaseContentList)
   NS_WRAPPERCACHE_INTERFACE_TABLE_ENTRY
   NS_INTERFACE_TABLE(nsBaseContentList, nsINodeList, nsIDOMNodeList)
   NS_INTERFACE_TABLE_TO_MAP_SEGUE_CYCLE_COLLECTION(nsBaseContentList)
 NS_INTERFACE_MAP_END
 
 
--- a/dom/base/nsContentList.h
+++ b/dom/base/nsContentList.h
@@ -150,16 +150,18 @@ public:
   {
   }
 
   // nsIDOMHTMLCollection
   NS_DECL_ISUPPORTS_INHERITED
   NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsEmptyContentList,
                                            nsBaseContentList)
   NS_DECL_NSIDOMHTMLCOLLECTION
+  // Need Item because we also implement nsIDOMNodeList.
+  NS_IMETHOD Item(uint32_t aIndex, nsIDOMNode** aReturn);
 
   virtual nsINode* GetParentObject() override
   {
     return mRoot;
   }
 
   virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
 
@@ -328,16 +330,18 @@ protected:
   virtual void PreserveWrapperInternal(nsISupports* aScriptObjectHolder) override
   {
     nsWrapperCache::PreserveWrapper(aScriptObjectHolder);
   }
 public:
 
   // nsIDOMHTMLCollection
   NS_DECL_NSIDOMHTMLCOLLECTION
+  // Need Item because we also implement nsIDOMNodeList.
+  NS_IMETHOD Item(uint32_t aIndex, nsIDOMNode** aReturn);
 
   // nsBaseContentList overrides
   virtual int32_t IndexOf(nsIContent *aContent, bool aDoFlush) override;
   virtual int32_t IndexOf(nsIContent* aContent) override;
   virtual nsINode* GetParentObject() override
   {
     return mRootNode;
   }
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -669,24 +669,16 @@ NS_IMPL_ISUPPORTS_INHERITED(SimpleHTMLCo
 
 NS_IMETHODIMP
 SimpleHTMLCollection::GetLength(uint32_t* aLength)
 {
   *aLength = Length();
   return NS_OK;
 }
 
-NS_IMETHODIMP
-SimpleHTMLCollection::Item(uint32_t aIdx, nsIDOMNode** aRetVal)
-{
-  nsCOMPtr<nsIDOMNode> retVal = Item(aIdx)->AsDOMNode();
-  retVal.forget(aRetVal);
-  return NS_OK;
-}
-
 } // namespace dom
 } // namespace mozilla
 
 void
 nsIdentifierMapEntry::AddNameElement(nsINode* aNode, Element* aElement)
 {
   if (!mNameContentList) {
     mNameContentList = new SimpleHTMLCollection(aNode);
--- a/dom/html/HTMLFormControlsCollection.cpp
+++ b/dom/html/HTMLFormControlsCollection.cpp
@@ -158,29 +158,16 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(HTMLFor
 NS_IMETHODIMP
 HTMLFormControlsCollection::GetLength(uint32_t* aLength)
 {
   FlushPendingNotifications();
   *aLength = mElements.Length();
   return NS_OK;
 }
 
-NS_IMETHODIMP
-HTMLFormControlsCollection::Item(uint32_t aIndex, nsIDOMNode** aReturn)
-{
-  nsISupports* item = GetElementAt(aIndex);
-  if (!item) {
-    *aReturn = nullptr;
-
-    return NS_OK;
-  }
-
-  return CallQueryInterface(item, aReturn);
-}
-
 nsISupports*
 HTMLFormControlsCollection::NamedItemInternal(const nsAString& aName,
                                               bool aFlushContent)
 {
   if (aFlushContent) {
     FlushPendingNotifications();
   }
 
--- a/dom/html/HTMLOptionsCollection.cpp
+++ b/dom/html/HTMLOptionsCollection.cpp
@@ -196,29 +196,16 @@ HTMLOptionsCollection::SetSelectedIndex(
   if (!mSelect) {
     aError.Throw(NS_ERROR_UNEXPECTED);
     return;
   }
 
   mSelect->SetSelectedIndex(aSelectedIndex, aError);
 }
 
-NS_IMETHODIMP
-HTMLOptionsCollection::Item(uint32_t aIndex, nsIDOMNode** aReturn)
-{
-  nsISupports* item = GetElementAt(aIndex);
-  if (!item) {
-    *aReturn = nullptr;
-
-    return NS_OK;
-  }
-
-  return CallQueryInterface(item, aReturn);
-}
-
 Element*
 HTMLOptionsCollection::GetElementAt(uint32_t aIndex)
 {
   return ItemAsOption(aIndex);
 }
 
 HTMLOptionElement*
 HTMLOptionsCollection::NamedGetter(const nsAString& aName, bool& aFound)
--- a/dom/html/HTMLTableElement.cpp
+++ b/dom/html/HTMLTableElement.cpp
@@ -235,29 +235,16 @@ TableRowsCollection::GetElementAt(uint32
 {
   EnsureInitialized();
   if (aIndex < mRows.Length()) {
     return mRows[aIndex]->AsElement();
   }
   return nullptr;
 }
 
-NS_IMETHODIMP
-TableRowsCollection::Item(uint32_t aIndex, nsIDOMNode** aReturn)
-{
-  nsISupports* node = GetElementAt(aIndex);
-  if (!node) {
-    *aReturn = nullptr;
-
-    return NS_OK;
-  }
-
-  return CallQueryInterface(node, aReturn);
-}
-
 Element*
 TableRowsCollection::GetFirstNamedElement(const nsAString& aName, bool& aFound)
 {
   EnsureInitialized();
   aFound = false;
   RefPtr<nsAtom> nameAtom = NS_Atomize(aName);
   NS_ENSURE_TRUE(nameAtom, nullptr);
 
--- a/dom/html/nsIHTMLCollection.h
+++ b/dom/html/nsIHTMLCollection.h
@@ -35,18 +35,16 @@ class nsIHTMLCollection : public nsIDOMH
 public:
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_IHTMLCOLLECTION_IID)
 
   /**
    * Get the root node for this HTML collection.
    */
   virtual nsINode* GetParentObject() = 0;
 
-  using nsIDOMHTMLCollection::Item;
-
   uint32_t Length()
   {
     uint32_t length;
     GetLength(&length);
     return length;
   }
   virtual mozilla::dom::Element* GetElementAt(uint32_t index) = 0;
   mozilla::dom::Element* Item(uint32_t index)
--- a/dom/interfaces/html/nsIDOMHTMLCollection.idl
+++ b/dom/interfaces/html/nsIDOMHTMLCollection.idl
@@ -15,11 +15,9 @@
  * with changes from the work-in-progress WHATWG HTML specification:
  * http://www.whatwg.org/specs/web-apps/current-work/
  */
 
 [uuid(bb07f567-5b37-4172-92aa-7d00ceed4809)]
 interface nsIDOMHTMLCollection : nsISupports
 {
   readonly attribute unsigned long    length;
-
-  nsIDOMNode item(in unsigned long index);
 };