Bug 803106 part 1. Convert DOMStringList to WebIDL bindings - move files and rename class. r=bzbarsky
authorPeter Van der Beken <peterv@propagandism.org>
Tue, 09 Jul 2013 13:51:03 -0400
changeset 171288 d4040ae9a5ed02aec1d652f4be6add66b508d2af
parent 171287 9bd0b172034c1e763afa36765272fb187f8a9055
child 171289 95fd860273067e84e81e4f88eb4b12e69e8e638b
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersbzbarsky
bugs803106
milestone30.0a1
Bug 803106 part 1. Convert DOMStringList to WebIDL bindings - move files and rename class. r=bzbarsky
content/base/src/DOMStringList.cpp
content/base/src/DOMStringList.h
content/base/src/WebSocket.cpp
content/base/src/moz.build
content/base/src/nsDOMLists.cpp
content/base/src/nsDOMLists.h
content/base/src/nsDocument.cpp
content/base/src/nsFrameMessageManager.cpp
content/html/content/src/HTMLPropertiesCollection.cpp
content/html/content/src/HTMLPropertiesCollection.h
dom/events/DataTransfer.cpp
dom/indexedDB/IDBDatabase.cpp
dom/indexedDB/IDBObjectStore.cpp
dom/indexedDB/IDBTransaction.cpp
dom/src/offline/nsDOMOfflineResourceList.cpp
rename from content/base/src/nsDOMLists.cpp
rename to content/base/src/DOMStringList.cpp
--- a/content/base/src/nsDOMLists.cpp
+++ b/content/base/src/DOMStringList.cpp
@@ -1,59 +1,61 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-/*
- * Implementation of nsIDOMDOMStringList, used by various DOM stuff.
- */
-
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsError.h"
 #include "nsDOMClassInfoID.h"
 #include "nsINode.h"
 
-nsDOMStringList::nsDOMStringList()
+DOMCI_DATA(DOMStringList, mozilla::dom::DOMStringList)
+
+namespace mozilla {
+namespace dom {
+
+DOMStringList::DOMStringList()
 {
 }
 
-nsDOMStringList::~nsDOMStringList()
+DOMStringList::~DOMStringList()
 {
 }
 
-DOMCI_DATA(DOMStringList, nsDOMStringList)
-
-NS_IMPL_ADDREF(nsDOMStringList)
-NS_IMPL_RELEASE(nsDOMStringList)
-NS_INTERFACE_TABLE_HEAD(nsDOMStringList)
-  NS_INTERFACE_TABLE1(nsDOMStringList, nsIDOMDOMStringList)
+NS_IMPL_ADDREF(DOMStringList)
+NS_IMPL_RELEASE(DOMStringList)
+NS_INTERFACE_TABLE_HEAD(DOMStringList)
+  NS_INTERFACE_TABLE1(DOMStringList, nsIDOMDOMStringList)
   NS_INTERFACE_TABLE_TO_MAP_SEGUE
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMStringList)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
-nsDOMStringList::Item(uint32_t aIndex, nsAString& aResult)
+DOMStringList::Item(uint32_t aIndex, nsAString& aResult)
 {
   if (aIndex >= mNames.Length()) {
     SetDOMStringToNull(aResult);
   } else {
     aResult = mNames[aIndex];
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMStringList::GetLength(uint32_t *aLength)
+DOMStringList::GetLength(uint32_t *aLength)
 {
   *aLength = mNames.Length();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMStringList::Contains(const nsAString& aString, bool *aResult)
+DOMStringList::Contains(const nsAString& aString, bool *aResult)
 {
   *aResult = mNames.Contains(aString);
 
   return NS_OK;
 }
+
+} // namespace dom
+} // namespace mozilla
rename from content/base/src/nsDOMLists.h
rename to content/base/src/DOMStringList.h
--- a/content/base/src/nsDOMLists.h
+++ b/content/base/src/DOMStringList.h
@@ -2,28 +2,31 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /*
  * Implementation of nsIDOMDOMStringList, used by various DOM stuff.
  */
 
-#ifndef nsDOMLists_h___
-#define nsDOMLists_h___
+#ifndef mozilla_dom_DOMStringList_h
+#define mozilla_dom_DOMStringList_h
 
 #include "nsIDOMDOMStringList.h"
 #include "nsTArray.h"
 #include "nsString.h"
 
-class nsDOMStringList : public nsIDOMDOMStringList
+namespace mozilla {
+namespace dom {
+
+class DOMStringList : public nsIDOMDOMStringList
 {
 public:
-  nsDOMStringList();
-  virtual ~nsDOMStringList();
+  DOMStringList();
+  virtual ~DOMStringList();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMDOMSTRINGLIST
 
   bool Add(const nsAString& aName)
   {
     return mNames.AppendElement(aName) != nullptr;
   }
@@ -37,9 +40,12 @@ public:
   {
     aNames = mNames;
   }
 
 private:
   nsTArray<nsString> mNames;
 };
 
-#endif /* nsDOMLists_h___ */
+} // namespace dom
+} // namespace mozilla
+
+#endif /* mozilla_dom_DOMStringList_h */
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -31,17 +31,17 @@
 #include "nsIConsoleService.h"
 #include "nsIDOMCloseEvent.h"
 #include "nsICryptoHash.h"
 #include "nsJSUtils.h"
 #include "nsIScriptError.h"
 #include "nsNetUtil.h"
 #include "nsILoadGroup.h"
 #include "mozilla/Preferences.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "xpcpublic.h"
 #include "nsContentPolicyUtils.h"
 #include "nsDOMFile.h"
 #include "nsWrapperCacheInlines.h"
 #include "nsDOMEventTargetHelper.h"
 #include "nsIObserverService.h"
 #include "nsIWebSocketChannel.h"
 #include "GeneratedEvents.h"
--- a/content/base/src/moz.build
+++ b/content/base/src/moz.build
@@ -57,16 +57,17 @@ if CONFIG['INTEL_ARCHITECTURE']:
 EXPORTS.mozilla.dom += [
     'Attr.h',
     'Comment.h',
     'DocumentFragment.h',
     'DocumentType.h',
     'DOMImplementation.h',
     'DOMParser.h',
     'DOMRect.h',
+    'DOMStringList.h',
     'EventSource.h',
     'Link.h',
     'NodeIterator.h',
     'ShadowRoot.h',
     'Text.h',
     'TreeWalker.h',
 ]
 
@@ -75,16 +76,17 @@ UNIFIED_SOURCES += [
     'ChildIterator.cpp',
     'Comment.cpp',
     'DirectionalityUtils.cpp',
     'DocumentFragment.cpp',
     'DocumentType.cpp',
     'DOMImplementation.cpp',
     'DOMParser.cpp',
     'DOMRect.cpp',
+    'DOMStringList.cpp',
     'Element.cpp',
     'EventSource.cpp',
     'FileIOObject.cpp',
     'FragmentOrElement.cpp',
     'Link.cpp',
     'NodeIterator.cpp',
     'nsAtomListUtils.cpp',
     'nsAttrAndChildArray.cpp',
@@ -102,17 +104,16 @@ UNIFIED_SOURCES += [
     'nsCSPService.cpp',
     'nsDataDocumentContentPolicy.cpp',
     'nsDocumentEncoder.cpp',
     'nsDOMAttributeMap.cpp',
     'nsDOMBlobBuilder.cpp',
     'nsDOMCaretPosition.cpp',
     'nsDOMFile.cpp',
     'nsDOMFileReader.cpp',
-    'nsDOMLists.cpp',
     'nsDOMMutationObserver.cpp',
     'nsDOMSerializer.cpp',
     'nsDOMSettableTokenList.cpp',
     'nsDOMTokenList.cpp',
     'nsFormData.cpp',
     'nsFrameLoader.cpp',
     'nsFrameMessageManager.cpp',
     'nsGenConImageContent.cpp',
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -1302,17 +1302,17 @@ nsExternalResourceMap::ExternalResource:
   }
 }
 
 // ==================================================================
 // =
 // ==================================================================
 
 // If we ever have an nsIDocumentObserver notification for stylesheet title
-// changes, we could make this inherit from nsDOMStringList instead of
+// changes, we could make this inherit from DOMStringList instead of
 // reimplementing nsIDOMDOMStringList.
 class nsDOMStyleSheetSetList MOZ_FINAL : public nsIDOMDOMStringList
 {
 public:
   NS_DECL_ISUPPORTS
 
   NS_DECL_NSIDOMDOMSTRINGLIST
 
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -28,17 +28,17 @@
 #include "nsIJSRuntimeService.h"
 #include "nsIDOMClassInfo.h"
 #include "nsIDOMFile.h"
 #include "xpcpublic.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/StructuredCloneUtils.h"
 #include "JavaScriptChild.h"
 #include "JavaScriptParent.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsPrintfCString.h"
 #include <algorithm>
 
 #ifdef ANDROID
 #include <android/log.h>
 #endif
 #ifdef XP_WIN
 #include <windows.h>
--- a/content/html/content/src/HTMLPropertiesCollection.cpp
+++ b/content/html/content/src/HTMLPropertiesCollection.cpp
@@ -487,17 +487,17 @@ PropertyNodeList::EnsureFresh()
     const nsAttrValue* attr = element->GetParsedAttr(nsGkAtoms::itemprop);
     if (attr->Contains(mName)) {
       AppendElement(element);
     }
   }
 }
 
 PropertyStringList::PropertyStringList(HTMLPropertiesCollection* aCollection)
-  : nsDOMStringList()
+  : DOMStringList()
   , mCollection(aCollection)
 { }
 
 NS_IMPL_CYCLE_COLLECTION_1(PropertyStringList, mCollection)
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(PropertyStringList)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(PropertyStringList)
 
@@ -506,36 +506,36 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(
   NS_INTERFACE_MAP_ENTRY(nsISupports)
   NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMStringList)
 NS_INTERFACE_MAP_END
 
 NS_IMETHODIMP
 PropertyStringList::Item(uint32_t aIndex, nsAString& aResult)
 {
   mCollection->EnsureFresh();
-  return nsDOMStringList::Item(aIndex, aResult);
+  return DOMStringList::Item(aIndex, aResult);
 }
 
 NS_IMETHODIMP
 PropertyStringList::GetLength(uint32_t* aLength)
 {
   mCollection->EnsureFresh();
-  return nsDOMStringList::GetLength(aLength);
+  return DOMStringList::GetLength(aLength);
 }
 
 NS_IMETHODIMP
 PropertyStringList::Contains(const nsAString& aString, bool* aResult)
 {
   mCollection->EnsureFresh();
-  return nsDOMStringList::Contains(aString, aResult);
+  return DOMStringList::Contains(aString, aResult);
 }
 
 bool
 PropertyStringList::ContainsInternal(const nsAString& aString)
 {
   // This method should not call EnsureFresh, otherwise we may become stuck in an infinite loop.
   bool result;
-  nsDOMStringList::Contains(aString, &result);
+  DOMStringList::Contains(aString, &result);
   return result;
 }
 
 } // namespace dom
 } // namespace mozilla
--- a/content/html/content/src/HTMLPropertiesCollection.h
+++ b/content/html/content/src/HTMLPropertiesCollection.h
@@ -3,17 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef HTMLPropertiesCollection_h_
 #define HTMLPropertiesCollection_h_
 
 #include "mozilla/Attributes.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsAutoPtr.h"
 #include "nsCOMArray.h"
 #include "nsIMutationObserver.h"
 #include "nsStubMutationObserver.h"
 #include "nsBaseHashtable.h"
 #include "nsINodeList.h"
 #include "nsIHTMLCollection.h"
@@ -26,17 +26,17 @@ class nsINode;
 
 namespace mozilla {
 namespace dom {
 
 class HTMLPropertiesCollection;
 class PropertyNodeList;
 class Element;
 
-class PropertyStringList : public nsDOMStringList
+class PropertyStringList : public DOMStringList
 {
 public:
   PropertyStringList(HTMLPropertiesCollection* aCollection);
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(PropertyStringList)
   NS_DECL_NSIDOMDOMSTRINGLIST
 
   bool ContainsInternal(const nsAString& aString);
@@ -81,17 +81,17 @@ public:
     return nullptr;
   }
   PropertyNodeList* NamedItem(const nsAString& aName);
   PropertyNodeList* NamedGetter(const nsAString& aName, bool& aFound)
   {
     aFound = IsSupportedNamedProperty(aName);
     return aFound ? NamedItem(aName) : nullptr;
   }
-  nsDOMStringList* Names()
+  DOMStringList* Names()
   {
     EnsureFresh();
     return mNames;
   }
   virtual void GetSupportedNames(nsTArray<nsString>& aNames) MOZ_OVERRIDE;
 
   NS_DECL_NSIDOMHTMLCOLLECTION
 
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -8,17 +8,17 @@
 #include "mozilla/BasicEvents.h"
 
 #include "DataTransfer.h"
 
 #include "nsIDOMDocument.h"
 #include "nsIVariant.h"
 #include "nsISupportsPrimitives.h"
 #include "nsIScriptSecurityManager.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsError.h"
 #include "nsIDragService.h"
 #include "nsIClipboard.h"
 #include "nsContentUtils.h"
 #include "nsIContent.h"
 #include "nsCRT.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptContext.h"
@@ -322,17 +322,17 @@ DataTransfer::GetFiles(nsIDOMFileList** 
   ErrorResult rv;
   *aFileList = GetFiles(rv);
   return rv.ErrorCode();
 }
 
 already_AddRefed<nsIDOMDOMStringList>
 DataTransfer::Types()
 {
-  nsRefPtr<nsDOMStringList> types = new nsDOMStringList();
+  nsRefPtr<DOMStringList> types = new DOMStringList();
   if (mItems.Length()) {
     const nsTArray<TransferItem>& item = mItems[0];
     for (uint32_t i = 0; i < item.Length(); i++)
       types->Add(item[i].mFormat);
 
     bool filePresent, filePromisePresent;
     types->Contains(NS_LITERAL_STRING(kFileMime), &filePresent);
     types->Contains(NS_LITERAL_STRING("application/x-moz-file-promise"), &filePromisePresent);
@@ -526,17 +526,17 @@ DataTransfer::MozTypesAt(uint32_t aIndex
 {
   // Only the first item is valid for clipboard events
   if (aIndex > 0 &&
       (mEventType == NS_CUT || mEventType == NS_COPY || mEventType == NS_PASTE)) {
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return nullptr;
   }
 
-  nsRefPtr<nsDOMStringList> types = new nsDOMStringList();
+  nsRefPtr<DOMStringList> types = new DOMStringList();
   if (aIndex < mItems.Length()) {
     // note that you can retrieve the types regardless of their principal
     nsTArray<TransferItem>& item = mItems[aIndex];
     for (uint32_t i = 0; i < item.Length(); i++)
       types->Add(item[i].mFormat);
   }
 
   return types.forget();
--- a/dom/indexedDB/IDBDatabase.cpp
+++ b/dom/indexedDB/IDBDatabase.cpp
@@ -7,19 +7,19 @@
 #include "base/basictypes.h"
 
 #include "IDBDatabase.h"
 
 #include "DictionaryHelpers.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/storage.h"
 #include "mozilla/dom/ContentParent.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "mozilla/dom/quota/Client.h"
 #include "mozilla/dom/quota/QuotaManager.h"
-#include "nsDOMLists.h"
 #include "nsJSUtils.h"
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 
 #include "AsyncConnectionHelper.h"
 #include "DatabaseInfo.h"
 #include "IDBEvents.h"
 #include "IDBFactory.h"
@@ -503,17 +503,17 @@ IDBDatabase::GetObjectStoreNames(ErrorRe
 
   nsAutoTArray<nsString, 10> objectStoreNames;
   if (!info->GetObjectStoreNames(objectStoreNames)) {
     IDB_WARNING("Couldn't get names!");
     aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
     return nullptr;
   }
 
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
+  nsRefPtr<DOMStringList> list(new DOMStringList());
   uint32_t count = objectStoreNames.Length();
   for (uint32_t index = 0; index < count; index++) {
     if (!list->Add(objectStoreNames[index])) {
       IDB_WARNING("Failed to add element");
       aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
       return nullptr;
     }
   }
--- a/dom/indexedDB/IDBObjectStore.cpp
+++ b/dom/indexedDB/IDBObjectStore.cpp
@@ -19,17 +19,17 @@
 #include "mozilla/dom/StructuredCloneTags.h"
 #include "mozilla/dom/ipc/Blob.h"
 #include "mozilla/dom/quota/FileStreams.h"
 #include "mozilla/Endian.h"
 #include "mozilla/storage.h"
 #include "nsContentUtils.h"
 #include "nsDOMClassInfo.h"
 #include "nsDOMFile.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsEventDispatcher.h"
 #include "nsJSUtils.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "snappy/snappy.h"
 
 #include "AsyncConnectionHelper.h"
 #include "IDBCursor.h"
@@ -2637,17 +2637,17 @@ IDBObjectStore::GetKeyPath(JSContext* aC
   return mCachedKeyPath;
 }
 
 already_AddRefed<nsIDOMDOMStringList>
 IDBObjectStore::GetIndexNames(ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
+  nsRefPtr<DOMStringList> list(new DOMStringList());
 
   nsAutoTArray<nsString, 10> names;
   uint32_t count = mInfo->indexes.Length();
   names.SetCapacity(count);
 
   for (uint32_t index = 0; index < count; index++) {
     names.InsertElementSorted(mInfo->indexes[index].name);
   }
--- a/dom/indexedDB/IDBTransaction.cpp
+++ b/dom/indexedDB/IDBTransaction.cpp
@@ -9,17 +9,17 @@
 #include "IDBTransaction.h"
 
 #include "nsIAppShell.h"
 #include "nsIScriptContext.h"
 
 #include "mozilla/dom/quota/QuotaManager.h"
 #include "mozilla/storage.h"
 #include "nsDOMClassInfoID.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsEventDispatcher.h"
 #include "nsPIDOMWindow.h"
 #include "nsProxyRelease.h"
 #include "nsThreadUtils.h"
 #include "nsWidgetsCID.h"
 
 #include "AsyncConnectionHelper.h"
 #include "DatabaseInfo.h"
@@ -671,17 +671,17 @@ IDBTransaction::GetError(ErrorResult& aR
   return mError;
 }
 
 already_AddRefed<nsIDOMDOMStringList>
 IDBTransaction::GetObjectStoreNames(ErrorResult& aRv)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
+  nsRefPtr<DOMStringList> list(new DOMStringList());
 
   nsAutoTArray<nsString, 10> stackArray;
   nsTArray<nsString>* arrayOfNames;
 
   if (mMode == IDBTransaction::VERSION_CHANGE) {
     mDatabaseInfo->GetObjectStoreNames(stackArray);
 
     arrayOfNames = &stackArray;
--- a/dom/src/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/src/offline/nsDOMOfflineResourceList.cpp
@@ -1,17 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsDOMOfflineResourceList.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsError.h"
-#include "nsDOMLists.h"
+#include "mozilla/dom/DOMStringList.h"
 #include "nsIPrefetchService.h"
 #include "nsCPrefetchService.h"
 #include "nsNetUtil.h"
 #include "nsNetCID.h"
 #include "nsICacheSession.h"
 #include "nsICacheService.h"
 #include "nsIOfflineCacheUpdate.h"
 #include "nsAutoPtr.h"
@@ -184,17 +184,17 @@ nsDOMOfflineResourceList::Disconnect()
 NS_IMETHODIMP
 nsDOMOfflineResourceList::GetMozItems(nsIDOMDOMStringList **aItems)
 {
   if (IS_CHILD_PROCESS()) 
     return NS_ERROR_NOT_IMPLEMENTED;
 
   *aItems = nullptr;
 
-  nsRefPtr<nsDOMStringList> items = new nsDOMStringList();
+  nsRefPtr<DOMStringList> items = new DOMStringList();
 
   // If we are not associated with an application cache, return an
   // empty list.
   nsCOMPtr<nsIApplicationCache> appCache = GetDocumentAppCache();
   if (!appCache) {
     NS_ADDREF(*aItems = items);
     return NS_OK;
   }