Bug 815671 part 3. Make nsXULPopupManager::GetVisiblePopups use an array out param instead of returning array object copies. r=roc

This commit is contained in:
Boris Zbarsky 2012-11-29 11:14:13 -05:00
parent 3695c38605
commit 542ae8e2de
5 changed files with 12 additions and 11 deletions

View File

@ -3111,7 +3111,8 @@ nsFocusManager::GetNextTabbablePanel(nsIDocument* aDocument, nsIFrame* aCurrentP
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;

View File

@ -934,7 +934,8 @@ 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.

View File

@ -1192,7 +1192,8 @@ nsLayoutUtils::GetPopupFrameForEventCoordinates(nsPresContext* aPresContext,
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++) {

View File

@ -490,7 +490,7 @@ public:
* 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

View File

@ -1325,15 +1325,15 @@ nsXULPopupManager::GetTopPopup(nsPopupType aType)
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();
}
@ -1342,12 +1342,10 @@ nsXULPopupManager::GetVisiblePopups()
// 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>