Bug 685404. Make callers of nsDisplayList::HitTest use nsAutoTArrays to reduce allocations. r=tnikkel
authorRobert O'Callahan <robert@ocallahan.org>
Thu, 08 Sep 2011 17:29:54 -0400
changeset 76784 aea08d37a22b31c294f6be561d2c8599b57b334b
parent 76783 a38ad346d7cba3d4c13eab623dfcf62b2459cf58
child 76785 077597e9accd846d364cb60881bef60e05f7b80d
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewerstnikkel
bugs685404
milestone9.0a1
Bug 685404. Make callers of nsDisplayList::HitTest use nsAutoTArrays to reduce allocations. r=tnikkel
content/base/src/nsDocument.cpp
layout/base/nsLayoutUtils.cpp
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -2873,17 +2873,17 @@ nsDocument::NodesFromRectHelper(float aX
   nsIPresShell *ps = GetShell();
   NS_ENSURE_STATE(ps);
   nsIFrame *rootFrame = ps->GetRootFrame();
 
   // XUL docs, unlike HTML, have no frame tree until everything's done loading
   if (!rootFrame)
     return NS_OK; // return nothing to premature XUL callers as a reminder to wait
 
-  nsTArray<nsIFrame*> outFrames;
+  nsAutoTArray<nsIFrame*,8> outFrames;
   nsLayoutUtils::GetFramesForArea(rootFrame, rect, outFrames,
                                   PR_TRUE, aIgnoreRootScrollFrame);
 
   PRInt32 length = outFrames.Length();
   if (!length)
     return NS_OK;
 
   // Used to filter out repeated elements in sequence.
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1292,31 +1292,31 @@ nsLayoutUtils::GetRemoteContentIds(nsIFr
   builder.EnterPresShell(aFrame, aTarget);
 
   nsresult rv =
     aFrame->BuildDisplayListForStackingContext(&builder, aTarget, &list);
 
   builder.LeavePresShell(aFrame, aTarget);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsTArray<nsIFrame*> outFrames;
+  nsAutoTArray<nsIFrame*,8> outFrames;
   nsDisplayItem::HitTestState hitTestState(&aOutIDs);
   list.HitTest(&builder, aTarget, &hitTestState, &outFrames);
   list.DeleteAll();
 
   return NS_OK;
 }
 
 nsIFrame*
 nsLayoutUtils::GetFrameForPoint(nsIFrame* aFrame, nsPoint aPt,
                                 PRBool aShouldIgnoreSuppression,
                                 PRBool aIgnoreRootScrollFrame)
 {
   nsresult rv;
-  nsTArray<nsIFrame*> outFrames;
+  nsAutoTArray<nsIFrame*,8> outFrames;
   rv = GetFramesForArea(aFrame, nsRect(aPt, nsSize(1, 1)), outFrames,
                         aShouldIgnoreSuppression, aIgnoreRootScrollFrame);
   NS_ENSURE_SUCCESS(rv, nsnull);
   return outFrames.Length() ? outFrames.ElementAt(0) : nsnull;
 }
 
 nsresult
 nsLayoutUtils::GetFramesForArea(nsIFrame* aFrame, const nsRect& aRect,