Bug 1298243 part 4. Drop the pointless ErrorResult from the DataTransferItemList indexed getter. r=mystor
authorBoris Zbarsky <bzbarsky@mit.edu>
Mon, 10 Oct 2016 21:07:47 -0400
changeset 317388 5725d27a0bf144266dcc7a98062c935fe8e536bf
parent 317387 1873ffaafd2598b605658031b389baca35df2aa5
child 317389 d15ec8c5a75f89e80f90491526303255d6d4723c
push id30804
push usercbook@mozilla.com
push dateTue, 11 Oct 2016 10:01:46 +0000
treeherdermozilla-central@7ae377917236 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmystor
bugs1298243
milestone52.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 1298243 part 4. Drop the pointless ErrorResult from the DataTransferItemList indexed getter. r=mystor
dom/events/DataTransfer.cpp
dom/events/DataTransferItemList.cpp
dom/events/DataTransferItemList.h
dom/webidl/DataTransferItemList.webidl
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -335,21 +335,20 @@ DataTransfer::GetTypes(ErrorResult& aRv)
       if (NS_WARN_IF(!types->Add(type))) {
         aRv.Throw(NS_ERROR_FAILURE);
         return nullptr;
       }
     }
   }
 
   for (uint32_t i = 0; i < mItems->Length(); ++i) {
-    ErrorResult rv;
     bool found = false;
-    DataTransferItem* item = mItems->IndexedGetter(i, found, rv);
-    if (!found || rv.Failed() || item->Kind() != DataTransferItem::KIND_FILE) {
-      rv.SuppressException();
+    DataTransferItem* item = mItems->IndexedGetter(i, found);
+    MOZ_ASSERT(found);
+    if (item->Kind() != DataTransferItem::KIND_FILE) {
       continue;
     }
     if (NS_WARN_IF(!types->Add(NS_LITERAL_STRING("Files")))) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
     break;
   }
--- a/dom/events/DataTransferItemList.cpp
+++ b/dom/events/DataTransferItemList.cpp
@@ -96,17 +96,17 @@ DataTransferItemList::Remove(uint32_t aI
     aRv.Throw(NS_ERROR_DOM_INDEX_SIZE_ERR);
     return;
   }
 
   ClearDataHelper(mItems[aIndex], aIndex, -1, aSubjectPrincipal, aRv);
 }
 
 DataTransferItem*
-DataTransferItemList::IndexedGetter(uint32_t aIndex, bool& aFound, ErrorResult& aRv) const
+DataTransferItemList::IndexedGetter(uint32_t aIndex, bool& aFound) const
 {
   if (aIndex >= mItems.Length()) {
     aFound = false;
     return nullptr;
   }
 
   MOZ_ASSERT(mItems[aIndex]);
   aFound = true;
@@ -495,24 +495,22 @@ DataTransferItemList::ClearDataHelper(Da
   if (aItem->Principal() && aSubjectPrincipal.isSome() &&
       !aSubjectPrincipal.value()->Subsumes(aItem->Principal())) {
     aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
     return;
   }
 
   // Check if the aIndexHint is actually the index, and then remove the item
   // from aItems
-  ErrorResult rv;
   bool found;
-  if (IndexedGetter(aIndexHint, found, rv) == aItem) {
+  if (IndexedGetter(aIndexHint, found) == aItem) {
     mItems.RemoveElementAt(aIndexHint);
   } else {
     mItems.RemoveElement(aItem);
   }
-  rv.SuppressException();
 
   // Check if the aMozIndexHint and aMozOffsetHint are actually the index and
   // offset, and then remove them from mIndexedItems
   MOZ_ASSERT(aItem->Index() < mIndexedItems.Length());
   nsTArray<RefPtr<DataTransferItem>>& items = mIndexedItems[aItem->Index()];
   if (aMozOffsetHint < items.Length() && aItem == items[aMozOffsetHint]) {
     items.RemoveElementAt(aMozOffsetHint);
   } else {
@@ -559,24 +557,22 @@ DataTransferItemList::RegenerateFiles()
 void
 DataTransferItemList::GenerateFiles(FileList* aFiles,
                                     nsIPrincipal* aFilesPrincipal)
 {
   MOZ_ASSERT(aFiles);
   MOZ_ASSERT(aFilesPrincipal);
   uint32_t count = Length();
   for (uint32_t i = 0; i < count; i++) {
-    ErrorResult rv;
     bool found;
-    RefPtr<DataTransferItem> item = IndexedGetter(i, found, rv);
-    if (NS_WARN_IF(!found || rv.Failed())) {
-      continue;
-    }
+    RefPtr<DataTransferItem> item = IndexedGetter(i, found);
+    MOZ_ASSERT(found);
 
     if (item->Kind() == DataTransferItem::KIND_FILE) {
+      IgnoredErrorResult rv;
       RefPtr<File> file = item->GetAsFile(Some(aFilesPrincipal), rv);
       if (NS_WARN_IF(rv.Failed() || !file)) {
         continue;
       }
       aFiles->Append(file);
     }
   }
 }
--- a/dom/events/DataTransferItemList.h
+++ b/dom/events/DataTransferItemList.h
@@ -56,18 +56,17 @@ public:
   DataTransferItem* Add(File& aData,
                         const Maybe<nsIPrincipal*>& aSubjectPrincipal,
                         ErrorResult& aRv);
 
   void Remove(uint32_t aIndex,
               const Maybe<nsIPrincipal*>& aSubjectPrincipal,
               ErrorResult& aRv);
 
-  DataTransferItem* IndexedGetter(uint32_t aIndex, bool& aFound,
-                                  ErrorResult& aRv) const;
+  DataTransferItem* IndexedGetter(uint32_t aIndex, bool& aFound) const;
 
   DataTransfer* GetParentObject() const
   {
     return mDataTransfer;
   }
 
   void Clear(const Maybe<nsIPrincipal*>& aSubjectPrincipal, ErrorResult& aRv);
 
--- a/dom/webidl/DataTransferItemList.webidl
+++ b/dom/webidl/DataTransferItemList.webidl
@@ -4,17 +4,16 @@
  * You can obtain one at http://mozilla.org/MPL/2.0/.
  *
  * The origin of this IDL file is:
  * https://html.spec.whatwg.org/multipage/interaction.html#the-datatransferitemlist-interface
  */
 
 interface DataTransferItemList {
   readonly attribute unsigned long length;
-  [Throws]
   getter DataTransferItem (unsigned long index);
   [Throws, NeedsSubjectPrincipal]
   DataTransferItem? add(DOMString data, DOMString type);
   [Throws, NeedsSubjectPrincipal]
   DataTransferItem? add(File data);
   [Throws, NeedsSubjectPrincipal]
   void remove(unsigned long index);
   [Throws, NeedsSubjectPrincipal]