diff options
Diffstat (limited to 'embed/mozilla/MozillaPrivate.cpp')
-rw-r--r-- | embed/mozilla/MozillaPrivate.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/embed/mozilla/MozillaPrivate.cpp b/embed/mozilla/MozillaPrivate.cpp index 1950f0e6c..f793f5e5e 100644 --- a/embed/mozilla/MozillaPrivate.cpp +++ b/embed/mozilla/MozillaPrivate.cpp @@ -15,28 +15,37 @@ GtkWidget *MozillaFindEmbed (nsIDOMWindow *aDOMWindow) nsCOMPtr<nsIWindowWatcher> wwatch (do_GetService("@mozilla.org/embedcomp/window-watcher;1")); - if (!wwatch) return nsnull; + NS_ENSURE_TRUE (wwatch, nsnull); - nsCOMPtr<nsIDOMWindow> domWindow(aDOMWindow); - if (!domWindow) + nsCOMPtr<nsIDOMWindow> domWindow; + if (aDOMWindow) { - result = wwatch->GetActiveWindow(getter_AddRefs(domWindow)); - if (NS_FAILED(result) || !domWindow) return nsnull; + /* this DOM window may belong to some inner frame, we need + * to get the topmost DOM window to get the embed + */ + aDOMWindow->GetTop (getter_AddRefs (domWindow)); } + else + { + /* get the active window */ + wwatch->GetActiveWindow (getter_AddRefs(domWindow)); + } + NS_ENSURE_TRUE (domWindow, nsnull); nsCOMPtr<nsIWebBrowserChrome> windowChrome; result = wwatch->GetChromeForWindow (domWindow, getter_AddRefs(windowChrome)); - if (NS_FAILED(result)) return nsnull; + NS_ENSURE_TRUE (windowChrome, nsnull); nsCOMPtr<nsIEmbeddingSiteWindow> window (do_QueryInterface(windowChrome, &result)); - if (NS_FAILED(result)) return nsnull; + NS_ENSURE_TRUE (window, nsnull); GtkWidget *mozembed; result = window->GetSiteWindow ((void **)&mozembed); - if (NS_FAILED(result)) return nsnull; + NS_ENSURE_SUCCESS (result, nsnull); + g_print ("returning %p\n", mozembed); return mozembed; } |