Bug 1225923 - part 5 - fix AppendElement(nsDependentAtomString(...)) calls; r=bz
authorNathan Froyd <froydnj@mozilla.com>
Wed, 18 Nov 2015 12:38:34 -0500
changeset 274904 5e8e09fa2bbf5d0c8f22a3f8a79711ff17a67af5
parent 274903 3575f06c6dd18d7cd45826c5d91922aef1a367b4
child 274936 9c017873382788da0e303f4b37dee54373305bfb
push id68718
push usernfroyd@mozilla.com
push dateTue, 01 Dec 2015 14:08:13 +0000
treeherdermozilla-inbound@5e8e09fa2bbf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1225923
milestone45.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 1225923 - part 5 - fix AppendElement(nsDependentAtomString(...)) calls; r=bz The intent here is to copy the dependent string. We can make that behavior more explicit by using the ToString method of nsIAtom instead.
dom/base/nsContentList.cpp
dom/base/nsDOMMutationObserver.cpp
dom/html/HTMLAllCollection.cpp
dom/html/HTMLOptionsCollection.cpp
--- a/dom/base/nsContentList.cpp
+++ b/dom/base/nsContentList.cpp
@@ -573,19 +573,20 @@ nsContentList::GetSupportedNames(unsigne
                    "Empty names don't get atomized");
         if (!atoms.Contains(name)) {
           atoms.AppendElement(name);
         }
       }
     }
   }
 
-  aNames.SetCapacity(atoms.Length());
-  for (uint32_t i = 0; i < atoms.Length(); ++i) {
-    aNames.AppendElement(nsDependentAtomString(atoms[i]));
+  uint32_t atomsLen = atoms.Length();
+  nsString* names = aNames.AppendElements(atomsLen);
+  for (uint32_t i = 0; i < atomsLen; ++i) {
+    atoms[i]->ToString(names[i]);
   }
 }
 
 int32_t
 nsContentList::IndexOf(nsIContent *aContent, bool aDoFlush)
 {
   BringSelfUpToDate(aDoFlush);
     
--- a/dom/base/nsDOMMutationObserver.cpp
+++ b/dom/base/nsDOMMutationObserver.cpp
@@ -754,22 +754,24 @@ nsDOMMutationObserver::GetObservingInfo(
     info.mCharacterDataOldValue.Construct(mr->CharacterDataOldValue());
     info.mNativeAnonymousChildList = mr->NativeAnonymousChildList();
     info.mAnimations.Construct(mr->Animations());
     nsCOMArray<nsIAtom>& filters = mr->AttributeFilter();
     if (filters.Count()) {
       info.mAttributeFilter.Construct();
       mozilla::dom::Sequence<nsString>& filtersAsStrings =
         info.mAttributeFilter.Value();
+      nsString* strings = filtersAsStrings.AppendElements(filters.Count(),
+                                                          mozilla::fallible);
+      if (!strings) {
+        aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
+        return;
+      }
       for (int32_t j = 0; j < filters.Count(); ++j) {
-        if (!filtersAsStrings.AppendElement(nsDependentAtomString(filters[j]),
-                                            mozilla::fallible)) {
-          aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
-          return;
-        }
+        filters[j]->ToString(strings[j]);
       }
     }
     info.mObservedNode = mr->Target();
   }
 }
 
 // static
 already_AddRefed<nsDOMMutationObserver>
--- a/dom/html/HTMLAllCollection.cpp
+++ b/dom/html/HTMLAllCollection.cpp
@@ -197,19 +197,20 @@ HTMLAllCollection::GetSupportedNames(uns
                    "Empty names don't get atomized");
         if (!atoms.Contains(name)) {
           atoms.AppendElement(name);
         }
       }
     }
   }
 
-  aNames.SetCapacity(atoms.Length());
-  for (uint32_t i = 0; i < atoms.Length(); ++i) {
-    aNames.AppendElement(nsDependentAtomString(atoms[i]));
+  uint32_t atomsLen = atoms.Length();
+  nsString* names = aNames.AppendElements(atomsLen);
+  for (uint32_t i = 0; i < atomsLen; ++i) {
+    atoms[i]->ToString(names[i]);
   }
 }
 
 
 JSObject*
 HTMLAllCollection::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
 {
   return HTMLAllCollectionBinding::Wrap(aCx, this, aGivenProto);
--- a/dom/html/HTMLOptionsCollection.cpp
+++ b/dom/html/HTMLOptionsCollection.cpp
@@ -304,19 +304,20 @@ HTMLOptionsCollection::GetSupportedNames
         nsIAtom* id = content->GetID();
         if (!atoms.Contains(id)) {
           atoms.AppendElement(id);
         }
       }
     }
   }
 
-  aNames.SetCapacity(atoms.Length());
-  for (uint32_t i = 0; i < atoms.Length(); ++i) {
-    aNames.AppendElement(nsDependentAtomString(atoms[i]));
+  uint32_t atomsLen = atoms.Length();
+  nsString* names = aNames.AppendElements(atomsLen);
+  for (uint32_t i = 0; i < atomsLen; ++i) {
+    atoms[i]->ToString(names[i]);
   }
 }
 
 NS_IMETHODIMP
 HTMLOptionsCollection::GetSelect(nsIDOMHTMLSelectElement** aReturn)
 {
   NS_IF_ADDREF(*aReturn = mSelect);
   return NS_OK;