Bug 1478879 - Remove Range/Enum use in dom/. r=mccr8 draft
authorNicholas Nethercote <nnethercote@mozilla.com>
Tue, 31 Jul 2018 10:31:00 +1000
changeset 825238 ea13b88f0403184b6308d95c47e4dee40095f06f
parent 825237 d8603c4c578f1074ca8fc5fde1d629a499ebf97f
child 825239 8e4de81ff4b2f8ba38c80be362440b02fbec0c5a
push id118039
push usernnethercote@mozilla.com
push dateWed, 01 Aug 2018 03:07:33 +0000
reviewersmccr8
bugs1478879
milestone63.0a1
Bug 1478879 - Remove Range/Enum use in dom/. r=mccr8 MozReview-Commit-ID: I2GOEHHtWPa
dom/base/CustomElementRegistry.cpp
dom/plugins/base/nsJSNPRuntime.cpp
--- a/dom/base/CustomElementRegistry.cpp
+++ b/dom/base/CustomElementRegistry.cpp
@@ -259,18 +259,18 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CustomElementRegistry)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCustomDefinitions)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWhenDefinedPromiseMap)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mElementCreationCallbacks)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(CustomElementRegistry)
-  for (ConstructorMap::Enum iter(tmp->mConstructors); !iter.empty(); iter.popFront()) {
-    aCallbacks.Trace(&iter.front().mutableKey(),
+  for (auto iter = tmp->mConstructors.iter(); !iter.done(); iter.next()) {
+    aCallbacks.Trace(&iter.get().mutableKey(),
                      "mConstructors key",
                      aClosure);
   }
   NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(CustomElementRegistry)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(CustomElementRegistry)
--- a/dom/plugins/base/nsJSNPRuntime.cpp
+++ b/dom/plugins/base/nsJSNPRuntime.cpp
@@ -2016,27 +2016,27 @@ nsNPObjWrapper::GetNewOrUsed(NPP npp, JS
 void
 nsJSNPRuntime::OnPluginDestroy(NPP npp)
 {
   if (sJSObjWrappersAccessible) {
 
     // Prevent modification of sJSObjWrappers table if we go reentrant.
     sJSObjWrappersAccessible = false;
 
-    for (JSObjWrapperTable::Enum e(sJSObjWrappers); !e.empty(); e.popFront()) {
-      nsJSObjWrapper *npobj = e.front().value();
+    for (auto iter = sJSObjWrappers.modIter(); !iter.done(); iter.next()) {
+      nsJSObjWrapper* npobj = iter.get().value();
       MOZ_ASSERT(npobj->_class == &nsJSObjWrapper::sJSObjWrapperNPClass);
       if (npobj->mNpp == npp) {
         if (npobj->_class && npobj->_class->invalidate) {
           npobj->_class->invalidate(npobj);
         }
 
         _releaseobject(npobj);
 
-        e.removeFront();
+        iter.remove();
       }
     }
 
     sJSObjWrappersAccessible = true;
   }
 
   if (sNPObjWrappers) {
     for (auto i = sNPObjWrappers->Iter(); !i.Done(); i.Next()) {
@@ -2089,18 +2089,18 @@ nsJSNPRuntime::OnPluginDestroy(NPP npp)
 
 // static
 void
 nsJSNPRuntime::OnPluginDestroyPending(NPP npp)
 {
   if (sJSObjWrappersAccessible) {
     // Prevent modification of sJSObjWrappers table if we go reentrant.
     sJSObjWrappersAccessible = false;
-    for (JSObjWrapperTable::Enum e(sJSObjWrappers); !e.empty(); e.popFront()) {
-      nsJSObjWrapper *npobj = e.front().value();
+    for (auto iter = sJSObjWrappers.iter(); !iter.done(); iter.next()) {
+      nsJSObjWrapper* npobj = iter.get().value();
       MOZ_ASSERT(npobj->_class == &nsJSObjWrapper::sJSObjWrapperNPClass);
       if (npobj->mNpp == npp) {
         npobj->mDestroyPending = true;
       }
     }
     sJSObjWrappersAccessible = true;
   }
 }