Bug 552982, Part 1: change nsXULPopupManager::AdjustPopupsOnWindowChange so that it only adjusts popups associated with the same window, r=mats

This commit is contained in:
Neil Deakin 2010-07-27 09:38:02 -04:00
Родитель 51d0705279
Коммит 8f313e5f72
4 изменённых файлов: 33 добавлений и 12 удалений

Просмотреть файл

@ -321,7 +321,7 @@ public:
NS_IMETHOD ShouldRollupOnMouseActivate(PRBool *aShould);
virtual PRUint32 GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain);
virtual void AdjustPopupsOnWindowChange(void);
virtual void AdjustPopupsOnWindowChange(nsPIDOMWindow* aWindow);
static nsXULPopupManager* sInstance;

Просмотреть файл

@ -260,16 +260,32 @@ nsXULPopupManager::GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain)
}
void
nsXULPopupManager::AdjustPopupsOnWindowChange()
nsXULPopupManager::AdjustPopupsOnWindowChange(nsPIDOMWindow* aWindow)
{
// Panels with noautohide="true" are moved and kept aligned with the anchor
// when the parent window moves. Dismissable menus and panels are expected
// to roll up when a window is moved, so there is no need to check these.
nsMenuChainItem* item = mNoHidePanels;
while (item) {
// if the auto positioning has been disabled, don't move the popup
if (item->Frame()->GetAutoPosition())
item->Frame()->SetPopupPosition(nsnull, PR_TRUE);
// only move popups that are within the same window and where auto
// positioning has not been disabled
nsMenuPopupFrame* frame= item->Frame();
if (frame->GetAutoPosition()) {
nsIContent* popup = frame->GetContent();
if (popup) {
nsIDocument* document = popup->GetCurrentDoc();
if (document) {
nsPIDOMWindow* window = document->GetWindow();
if (window) {
window = window->GetPrivateRoot();
if (window == aWindow) {
frame->SetPopupPosition(nsnull, PR_TRUE);
}
}
}
}
}
item = item->GetParent();
}
}

Просмотреть файл

@ -44,10 +44,11 @@
class nsIWidget;
class nsIContent;
class nsPIDOMWindow;
#define NS_IMENUROLLUP_IID \
{0x61c9d01f, 0x8a4c, 0x4bb0, \
{ 0xa9, 0x90, 0xeb, 0xf6, 0x65, 0x4c, 0xda, 0x61 }}
{0xa707b588, 0xa564, 0x488d, \
{ 0x87, 0xb6, 0xdb, 0x71, 0x2d, 0x78, 0x9d, 0x4c }}
class nsIMenuRollup : public nsISupports {
public:
@ -66,7 +67,7 @@ class nsIMenuRollup : public nsISupports {
/**
* Adjust the position of open panels when a window is moved or resized.
*/
virtual void AdjustPopupsOnWindowChange(void) = 0;
virtual void AdjustPopupsOnWindowChange(nsPIDOMWindow* aWindow) = 0;
};

Просмотреть файл

@ -326,8 +326,10 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
// which does this for us.
nsCOMPtr<nsIMenuRollup> pm =
do_GetService("@mozilla.org/xul/xul-popup-manager;1");
if (pm)
pm->AdjustPopupsOnWindowChange();
if (pm) {
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(docShell);
pm->AdjustPopupsOnWindowChange(window);
}
#endif
// persist position, but not immediately, in case this OS is firing
@ -339,8 +341,10 @@ nsWebShellWindow::HandleEvent(nsGUIEvent *aEvent)
#ifndef XP_MACOSX
nsCOMPtr<nsIMenuRollup> pm =
do_GetService("@mozilla.org/xul/xul-popup-manager;1");
if (pm)
pm->AdjustPopupsOnWindowChange();
if (pm) {
nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(docShell);
pm->AdjustPopupsOnWindowChange(window);
}
#endif
nsSizeEvent* sizeEvent = (nsSizeEvent*)aEvent;