diff --git a/mozilla/widget/src/xpwidgets/nsBaseFilePicker.cpp b/mozilla/widget/src/xpwidgets/nsBaseFilePicker.cpp index fa8a6000176..a91054294e1 100644 --- a/mozilla/widget/src/xpwidgets/nsBaseFilePicker.cpp +++ b/mozilla/widget/src/xpwidgets/nsBaseFilePicker.cpp @@ -42,6 +42,8 @@ #include "nsIDOMWindow.h" #include "nsIScriptGlobalObject.h" #include "nsIDocShell.h" +#include "nsIDocShellTreeItem.h" +#include "nsIInterfaceRequestorUtils.h" #include "nsIBaseWindow.h" #include "nsIContentViewer.h" #include "nsIDocumentViewer.h" @@ -81,8 +83,24 @@ nsIWidget *nsBaseFilePicker::DOMWindowToWidget(nsIDOMWindow *dw) if (sgo) { nsCOMPtr baseWin(do_QueryInterface(sgo->GetDocShell())); - if (baseWin) { + while (!widget && baseWin) { baseWin->GetParentWidget(getter_AddRefs(widget)); + if (!widget) { + nsCOMPtr docShellAsItem(do_QueryInterface(baseWin)); + if (!docShellAsItem) + return nsnull; + + nsCOMPtr parent; + docShellAsItem->GetSameTypeParent(getter_AddRefs(parent)); + if (!parent) + return nsnull; + + sgo = do_GetInterface(parent); + if (!sgo) + return nsnull; + + baseWin = do_QueryInterface(sgo->GetDocShell()); + } } }