Bug 815671 part 3. Make nsXULPopupManager::GetVisiblePopups use an array out param instead of returning array object copies. r=roc
authorBoris Zbarsky <bzbarsky@mit.edu>
Thu, 29 Nov 2012 11:14:13 -0500
changeset 124359 0bba55aab571ba62e91fa69f69d6ff89131806a3
parent 124358 6469b7a5ea10bac0a29e356947aed14083ac4f05
child 124360 453b63c3f22014ab9f8329158f1c805f86e494f4
push id297
push userlsblakk@mozilla.com
push dateTue, 26 Mar 2013 17:28:00 +0000
treeherdermozilla-release@64d7b45c34e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs815671
milestone20.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 815671 part 3. Make nsXULPopupManager::GetVisiblePopups use an array out param instead of returning array object copies. r=roc
dom/base/nsFocusManager.cpp
layout/base/nsCaret.cpp
layout/base/nsLayoutUtils.cpp
layout/xul/base/public/nsXULPopupManager.h
layout/xul/base/src/nsXULPopupManager.cpp
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -3106,17 +3106,18 @@ nsFocusManager::GetPreviousDocShell(nsID
 nsIContent*
 nsFocusManager::GetNextTabbablePanel(nsIDocument* aDocument, nsIFrame* aCurrentPopup, bool aForward)
 {
   nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
   if (!pm)
     return nullptr;
 
   // Iterate through the array backwards if aForward is false.
-  nsTArray<nsIFrame *> popups = pm->GetVisiblePopups();
+  nsTArray<nsIFrame *> popups;
+  pm->GetVisiblePopups(popups);
   int32_t i = aForward ? 0 : popups.Length() - 1;
   int32_t end = aForward ? popups.Length() : -1;
 
   for (; i != end; aForward ? i++ : i--) {
     nsIFrame* popupFrame = popups[i];
     if (aCurrentPopup) {
       // If the current popup is set, then we need to skip over this popup and
       // wait until the currently focused popup is found. Once found, the
--- a/layout/base/nsCaret.cpp
+++ b/layout/base/nsCaret.cpp
@@ -929,17 +929,18 @@ bool nsCaret::MustDrawCaret(bool aIgnore
   return isCollapsed;
 }
 
 bool nsCaret::IsMenuPopupHidingCaret()
 {
 #ifdef MOZ_XUL
   // Check if there are open popups.
   nsXULPopupManager *popMgr = nsXULPopupManager::GetInstance();
-  nsTArray<nsIFrame*> popups = popMgr->GetVisiblePopups();
+  nsTArray<nsIFrame*> popups;
+  popMgr->GetVisiblePopups(popups);
 
   if (popups.Length() == 0)
     return false; // No popups, so caret can't be hidden by them.
 
   // Get the selection focus content, that's where the caret would 
   // go if it was drawn.
   nsCOMPtr<nsIDOMNode> node;
   nsCOMPtr<nsISelection> domSelection = do_QueryReferent(mDomSelectionWeak);
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -1187,17 +1187,18 @@ nsIFrame*
 nsLayoutUtils::GetPopupFrameForEventCoordinates(nsPresContext* aPresContext,
                                                 const nsEvent* aEvent)
 {
 #ifdef MOZ_XUL
   nsXULPopupManager* pm = nsXULPopupManager::GetInstance();
   if (!pm) {
     return nullptr;
   }
-  nsTArray<nsIFrame*> popups = pm->GetVisiblePopups();
+  nsTArray<nsIFrame*> popups;
+  pm->GetVisiblePopups(popups);
   uint32_t i;
   // Search from top to bottom
   for (i = 0; i < popups.Length(); i++) {
     nsIFrame* popup = popups[i];
     if (popup->PresContext()->GetRootPresContext() == aPresContext &&
         popup->GetScrollableOverflowRect().Contains(
           GetEventCoordinatesRelativeTo(aEvent, popup))) {
       return popup;
--- a/layout/xul/base/public/nsXULPopupManager.h
+++ b/layout/xul/base/public/nsXULPopupManager.h
@@ -485,17 +485,17 @@ public:
    * type is returned, except for popups in the mNoHidePanels list.
    */
   nsIFrame* GetTopPopup(nsPopupType aType);
 
   /**
    * Return an array of all the open and visible popup frames for
    * menus, in order from top to bottom.
    */
-  nsTArray<nsIFrame *> GetVisiblePopups();
+  void GetVisiblePopups(nsTArray<nsIFrame *>& aPopups);
 
   /**
    * Get the node that last triggered a popup or tooltip in the document
    * aDocument. aDocument must be non-null and be a document contained within
    * the same window hierarchy as the popup to retrieve.
    */
   already_AddRefed<nsIDOMNode> GetLastTriggerPopupNode(nsIDocument* aDocument)
   {
--- a/layout/xul/base/src/nsXULPopupManager.cpp
+++ b/layout/xul/base/src/nsXULPopupManager.cpp
@@ -1320,39 +1320,37 @@ nsXULPopupManager::GetTopPopup(nsPopupTy
     if (item->PopupType() == aType || aType == ePopupTypeAny)
       return item->Frame();
     item = item->GetParent();
   }
 
   return nullptr;
 }
 
-nsTArray<nsIFrame *>
-nsXULPopupManager::GetVisiblePopups()
+void
+nsXULPopupManager::GetVisiblePopups(nsTArray<nsIFrame *>& aPopups)
 {
-  nsTArray<nsIFrame *> popups;
+  aPopups.Clear();
 
   nsMenuChainItem* item = mPopups;
   while (item) {
     if (item->Frame()->PopupState() == ePopupOpenAndVisible)
-      popups.AppendElement(static_cast<nsIFrame*>(item->Frame()));
+      aPopups.AppendElement(static_cast<nsIFrame*>(item->Frame()));
     item = item->GetParent();
   }
 
   item = mNoHidePanels;
   while (item) {
     // skip panels which are not open and visible as well as draggable popups,
     // as those don't respond to events.
     if (item->Frame()->PopupState() == ePopupOpenAndVisible && !item->Frame()->IsDragPopup()) {
-      popups.AppendElement(static_cast<nsIFrame*>(item->Frame()));
+      aPopups.AppendElement(static_cast<nsIFrame*>(item->Frame()));
     }
     item = item->GetParent();
   }
-
-  return popups;
 }
 
 already_AddRefed<nsIDOMNode>
 nsXULPopupManager::GetLastTriggerNode(nsIDocument* aDocument, bool aIsTooltip)
 {
   if (!aDocument)
     return nullptr;