Bug 1431964 part 5. Remove nsIDOMMozNamedAttrMap::Item. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Sat, 20 Jan 2018 18:48:36 -0500
changeset 454453 3d7a4d867c9513c8380c5520696062ce9a241e30
parent 454452 f42ff3c796bfd00e72507e959d2c06265a2ca684
child 454454 c8a113c0c9c2c5ca0844cbac5b05fd94c719d2b4
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1431964
milestone59.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 1431964 part 5. Remove nsIDOMMozNamedAttrMap::Item. r=mccr8 MozReview-Commit-ID: GnrOUhx9nTQ
dom/base/nsDOMAttributeMap.cpp
dom/interfaces/core/nsIDOMMozNamedAttrMap.idl
editor/libeditor/HTMLURIRefObject.cpp
editor/libeditor/HTMLURIRefObject.h
layout/inspector/inDOMView.cpp
layout/inspector/inDOMView.h
layout/xul/nsBox.cpp
--- a/dom/base/nsDOMAttributeMap.cpp
+++ b/dom/base/nsDOMAttributeMap.cpp
@@ -370,23 +370,16 @@ nsDOMAttributeMap::IndexedGetter(uint32_
 
 Attr*
 nsDOMAttributeMap::Item(uint32_t aIndex)
 {
   bool dummy;
   return IndexedGetter(aIndex, dummy);
 }
 
-NS_IMETHODIMP
-nsDOMAttributeMap::Item(uint32_t aIndex, nsIDOMAttr** aReturn)
-{
-  NS_IF_ADDREF(*aReturn = Item(aIndex));
-  return NS_OK;
-}
-
 uint32_t
 nsDOMAttributeMap::Length() const
 {
   NS_ENSURE_TRUE(mContent, 0);
 
   return mContent->GetAttrCount();
 }
 
--- a/dom/interfaces/core/nsIDOMMozNamedAttrMap.idl
+++ b/dom/interfaces/core/nsIDOMMozNamedAttrMap.idl
@@ -12,17 +12,16 @@
 
 [uuid(cb5564cd-26ec-418f-a6d6-1d57cd2c971c)]
 interface nsIDOMMozNamedAttrMap : nsISupports
 {
   nsIDOMAttr                setNamedItem(in nsIDOMAttr arg)
                                   raises(DOMException);
   nsIDOMAttr                removeNamedItem(in DOMString name)
                                   raises(DOMException);
-  nsIDOMAttr                item(in unsigned long index);
   readonly attribute  unsigned long        length;
   // Introduced in DOM Level 2:
   nsIDOMAttr                setNamedItemNS(in nsIDOMAttr arg)
                                   raises(DOMException);
   // Introduced in DOM Level 2:
   nsIDOMAttr                removeNamedItemNS(in DOMString namespaceURI, 
                                               in DOMString localName)
                                   raises(DOMException);
--- a/editor/libeditor/HTMLURIRefObject.cpp
+++ b/editor/libeditor/HTMLURIRefObject.cpp
@@ -37,23 +37,24 @@
     del:    cite
     ins:    cite
     q:      cite
  */
 
 #include "HTMLURIRefObject.h"
 
 #include "mozilla/mozalloc.h"
+#include "mozilla/dom/Attr.h"
+#include "mozilla/dom/Element.h"
 #include "nsAString.h"
 #include "nsDebug.h"
+#include "nsDOMAttributeMap.h"
 #include "nsError.h"
 #include "nsID.h"
-#include "nsIDOMAttr.h"
 #include "nsIDOMElement.h"
-#include "nsIDOMMozNamedAttrMap.h"
 #include "nsIDOMNode.h"
 #include "nsISupportsUtils.h"
 #include "nsString.h"
 
 namespace mozilla {
 
 // String classes change too often and I can't keep up.
 // Set this macro to this week's approved case-insensitive compare routine.
@@ -86,33 +87,27 @@ HTMLURIRefObject::GetNextURI(nsAString& 
 
   // XXX Why don't you use nsAtom for comparing the tag name a lot?
   nsAutoString tagName;
   nsresult rv = mNode->GetNodeName(tagName);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // Loop over attribute list:
   if (!mAttributes) {
-    nsCOMPtr<nsIDOMElement> element (do_QueryInterface(mNode));
+    nsCOMPtr<dom::Element> element(do_QueryInterface(mNode));
     NS_ENSURE_TRUE(element, NS_ERROR_INVALID_ARG);
 
-    mCurAttrIndex = 0;
-    element->GetAttributes(getter_AddRefs(mAttributes));
-    NS_ENSURE_TRUE(mAttributes, NS_ERROR_NOT_INITIALIZED);
-
-    rv = mAttributes->GetLength(&mAttributeCnt);
-    NS_ENSURE_SUCCESS(rv, rv);
+    mAttributes = element->Attributes();
+    mAttributeCnt = mAttributes->Length();
     NS_ENSURE_TRUE(mAttributeCnt, NS_ERROR_FAILURE);
     mCurAttrIndex = 0;
   }
 
   while (mCurAttrIndex < mAttributeCnt) {
-    nsCOMPtr<nsIDOMAttr> attrNode;
-    rv = mAttributes->Item(mCurAttrIndex++, getter_AddRefs(attrNode));
-    NS_ENSURE_SUCCESS(rv, rv);
+    RefPtr<dom::Attr> attrNode = mAttributes->Item(mCurAttrIndex++);
     NS_ENSURE_ARG_POINTER(attrNode);
     nsString curAttr;
     rv = attrNode->GetName(curAttr);
     NS_ENSURE_SUCCESS(rv, rv);
 
     // href >> A, AREA, BASE, LINK
     if (MATCHES(curAttr, "href")) {
       if (!MATCHES(tagName, "a") && !MATCHES(tagName, "area") &&
--- a/editor/libeditor/HTMLURIRefObject.h
+++ b/editor/libeditor/HTMLURIRefObject.h
@@ -5,24 +5,25 @@
 
 #ifndef HTMLURIRefObject_h
 #define HTMLURIRefObject_h
 
 #include "nsCOMPtr.h"
 #include "nsISupportsImpl.h"
 #include "nsIURIRefObject.h"
 #include "nscore.h"
+#include "mozilla/RefPtr.h"
 
 #define NS_URI_REF_OBJECT_CID                          \
 { /* {bdd79df6-1dd1-11b2-b29c-c3d63a58f1d2} */         \
     0xbdd79df6, 0x1dd1, 0x11b2,                        \
     { 0xb2, 0x9c, 0xc3, 0xd6, 0x3a, 0x58, 0xf1, 0xd2 } \
 }
 
-class nsIDOMMozNamedAttrMap;
+class nsDOMAttributeMap;
 class nsIDOMNode;
 
 namespace mozilla {
 
 class HTMLURIRefObject final : public nsIURIRefObject
 {
 public:
   HTMLURIRefObject();
@@ -31,17 +32,17 @@ public:
   NS_DECL_ISUPPORTS
 
   NS_DECL_NSIURIREFOBJECT
 
 protected:
   virtual ~HTMLURIRefObject();
 
   nsCOMPtr<nsIDOMNode> mNode;
-  nsCOMPtr<nsIDOMMozNamedAttrMap> mAttributes;
+  RefPtr<nsDOMAttributeMap> mAttributes;
   uint32_t mCurAttrIndex;
   uint32_t mAttributeCnt;
 };
 
 } // namespace mozilla
 
 nsresult NS_NewHTMLURIRefObject(nsIURIRefObject** aResult, nsIDOMNode* aNode);
 
--- a/layout/inspector/inDOMView.cpp
+++ b/layout/inspector/inDOMView.cpp
@@ -1166,23 +1166,19 @@ inDOMView::GetLastDescendantOf(inDOMView
 //////// DOM UTILITIES
 
 nsresult
 inDOMView::GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult)
 {
   NS_ENSURE_ARG(aNode);
   // attribute nodes
   if (mWhatToShow & nsIDOMNodeFilter::SHOW_ATTRIBUTE) {
-    nsCOMPtr<nsIDOMElement> element = do_QueryInterface(aNode);
+    nsCOMPtr<dom::Element> element = do_QueryInterface(aNode);
     if (element) {
-      nsCOMPtr<nsIDOMMozNamedAttrMap> attrs;
-      element->GetAttributes(getter_AddRefs(attrs));
-      if (attrs) {
-        AppendAttrsToArray(attrs, aResult);
-      }
+      AppendAttrsToArray(element->Attributes(), aResult);
     }
   }
 
   if (mWhatToShow & nsIDOMNodeFilter::SHOW_ELEMENT) {
     nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
     MOZ_ASSERT(node);
 
     nsCOMPtr<nsINodeList> kids =
@@ -1207,17 +1203,17 @@ nsresult
 inDOMView::GetRealPreviousSibling(nsIDOMNode* aNode, nsIDOMNode* aRealParent, nsIDOMNode** aSibling)
 {
   // XXXjrh: This won't work for some cases during some situations where XBL insertion points
   // are involved.  Fix me!
   aNode->GetPreviousSibling(aSibling);
   return NS_OK;
 }
 
-nsresult
+void
 inDOMView::AppendKidsToArray(nsINodeList* aKids,
                              nsCOMArray<nsIDOMNode>& aArray)
 {
   for (uint32_t i = 0, len = aKids->Length(); i < len; ++i) {
     nsIContent* kid = aKids->Item(i);
     uint16_t nodeType = kid->NodeType();
 
     NS_ASSERTION(nodeType && nodeType <= nsIDOMNode::NOTATION_NODE,
@@ -1241,25 +1237,20 @@ inDOMView::AppendKidsToArray(nsINodeList
           continue;
         }
       }
 
       nsCOMPtr<nsIDOMNode> node = do_QueryInterface(kid);
       aArray.AppendElement(node.forget());
     }
   }
-
-  return NS_OK;
 }
 
 nsresult
-inDOMView::AppendAttrsToArray(nsIDOMMozNamedAttrMap* aAttributes,
+inDOMView::AppendAttrsToArray(nsDOMAttributeMap* aAttributes,
                               nsCOMArray<nsIDOMNode>& aArray)
 {
-  uint32_t l = 0;
-  aAttributes->GetLength(&l);
-  nsCOMPtr<nsIDOMAttr> attribute;
+  uint32_t l = aAttributes->Length();
   for (uint32_t i = 0; i < l; ++i) {
-    aAttributes->Item(i, getter_AddRefs(attribute));
-    aArray.AppendElement(attribute.forget());
+    aArray.AppendElement(aAttributes->Item(i));
   }
   return NS_OK;
 }
--- a/layout/inspector/inDOMView.h
+++ b/layout/inspector/inDOMView.h
@@ -14,17 +14,17 @@
 #include "nsStubMutationObserver.h"
 #include "nsIDOMNode.h"
 #include "nsIDOMDocument.h"
 #include "nsTArray.h"
 #include "nsCOMArray.h"
 #include "nsCOMPtr.h"
 
 class inDOMViewNode;
-class nsIDOMMozNamedAttrMap;
+class nsDOMAttributeMap;
 
 class inDOMView : public inIDOMView,
                   public nsITreeView,
                   public nsStubMutationObserver
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_INIDOMVIEW
@@ -75,18 +75,18 @@ protected:
   nsresult NodeToRow(nsIDOMNode* aNode, int32_t* aRow);
 
   void InsertLinkAfter(inDOMViewNode* aNode, inDOMViewNode* aInsertAfter);
   void InsertLinkBefore(inDOMViewNode* aNode, inDOMViewNode* aInsertBefore);
   void RemoveLink(inDOMViewNode* aNode);
   void ReplaceLink(inDOMViewNode* aNewNode, inDOMViewNode* aOldNode);
 
   nsresult GetChildNodesFor(nsIDOMNode* aNode, nsCOMArray<nsIDOMNode>& aResult);
-  nsresult AppendKidsToArray(nsINodeList* aKids, nsCOMArray<nsIDOMNode>& aArray);
-  nsresult AppendAttrsToArray(nsIDOMMozNamedAttrMap* aKids, nsCOMArray<nsIDOMNode>& aArray);
+  void AppendKidsToArray(nsINodeList* aKids, nsCOMArray<nsIDOMNode>& aArray);
+  nsresult AppendAttrsToArray(nsDOMAttributeMap* aKids, nsCOMArray<nsIDOMNode>& aArray);
   nsresult GetFirstDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult);
   nsresult GetLastDescendantOf(inDOMViewNode* aNode, int32_t aRow, int32_t* aResult);
   nsresult GetRealPreviousSibling(nsIDOMNode* aNode, nsIDOMNode* aRealParent, nsIDOMNode** aSibling);
 };
 
 // {FB5C1775-1BBD-4b9c-ABB0-AE7ACD29E87E}
 #define IN_DOMVIEW_CID \
 { 0xfb5c1775, 0x1bbd, 0x4b9c, { 0xab, 0xb0, 0xae, 0x7a, 0xcd, 0x29, 0xe8, 0x7e } }
--- a/layout/xul/nsBox.cpp
+++ b/layout/xul/nsBox.cpp
@@ -2,29 +2,31 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsBoxLayoutState.h"
 #include "nsBox.h"
 #include "nsBoxFrame.h"
+#include "nsDOMAttributeMap.h"
 #include "nsPresContext.h"
 #include "nsCOMPtr.h"
 #include "nsIContent.h"
 #include "nsContainerFrame.h"
 #include "nsNameSpaceManager.h"
 #include "nsGkAtoms.h"
 #include "nsIDOMNode.h"
-#include "nsIDOMMozNamedAttrMap.h"
 #include "nsIDOMAttr.h"
 #include "nsITheme.h"
 #include "nsIServiceManager.h"
 #include "nsBoxLayout.h"
 #include "FrameLayerBuilder.h"
+#include "mozilla/dom/Attr.h"
+#include "mozilla/dom/Element.h"
 #include <algorithm>
 
 using namespace mozilla;
 
 #ifdef DEBUG_LAYOUT
 int32_t gIndent = 0;
 #endif
 
@@ -60,28 +62,25 @@ nsBox::ListBox(nsAutoString& aResult)
 
     aResult.AppendASCII(addr);
     aResult.Append(name);
     aResult.Append(' ');
 
     nsIContent* content = GetContent();
 
     // add on all the set attributes
-    if (content) {
-      nsCOMPtr<nsIDOMNode> node(do_QueryInterface(content));
-      nsCOMPtr<nsIDOMMozNamedAttrMap> namedMap;
+    if (content && content->IsElement()) {
+      RefPtr<nsDOMAttributeMap> namedMap = content->AsElement()->Attributes();
 
-      node->GetAttributes(getter_AddRefs(namedMap));
-      uint32_t length;
-      namedMap->GetLength(&length);
+      uint32_t length = namedMap->Length();
 
-      nsCOMPtr<nsIDOMAttr> attribute;
+      RefPtr<dom::Attr> attribute;
       for (uint32_t i = 0; i < length; ++i)
       {
-        namedMap->Item(i, getter_AddRefs(attribute));
+        attribute = namedMap->Item(i);
         attribute->GetName(name);
         nsAutoString value;
         attribute->GetValue(value);
         AppendAttribute(name, value, aResult);
       }
     }
 }