Bug 1302556 - Start AnonymousContent::GetElementById iteration at mContentNode. r=smaug
authorMarkus Stange <mstange@themasta.com>
Tue, 13 Sep 2016 18:19:07 -0400
changeset 314252 59935b389c879fb62c572f5283ec43b203a4edfb
parent 314251 0abb41799b5b9a232485fd240b270d879504e775
child 314253 7fb647a90a467cf90057d9153bf508d22719acb0
push id81842
push userkgupta@mozilla.com
push dateFri, 16 Sep 2016 21:27:29 +0000
treeherdermozilla-inbound@eb2ab5bb6930 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1302556
milestone51.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 1302556 - Start AnonymousContent::GetElementById iteration at mContentNode. r=smaug This renames kid to node and starts the iteration at mContentNode instead of at mContentNode->GetFirstChild(). MozReview-Commit-ID: HFiHXZg0gLS
dom/base/AnonymousContent.cpp
--- a/dom/base/AnonymousContent.cpp
+++ b/dom/base/AnonymousContent.cpp
@@ -154,24 +154,24 @@ AnonymousContent::SetAnimationForElement
   return element->Animate(aContext, aKeyframes, aOptions, aRv);
 }
 
 Element*
 AnonymousContent::GetElementById(const nsAString& aElementId)
 {
   // This can be made faster in the future if needed.
   nsCOMPtr<nsIAtom> elementId = NS_Atomize(aElementId);
-  for (nsIContent* kid = mContentNode->GetFirstChild(); kid;
-       kid = kid->GetNextNode(mContentNode)) {
-    if (!kid->IsElement()) {
+  for (nsIContent* node = mContentNode; node;
+       node = node->GetNextNode(mContentNode)) {
+    if (!node->IsElement()) {
       continue;
     }
-    nsIAtom* id = kid->AsElement()->GetID();
+    nsIAtom* id = node->AsElement()->GetID();
     if (id && id == elementId) {
-      return kid->AsElement();
+      return node->AsElement();
     }
   }
   return nullptr;
 }
 
 bool
 AnonymousContent::WrapObject(JSContext* aCx,
                              JS::Handle<JSObject*> aGivenProto,