From 13f77846345569bb68059e7b9b48f6838f74b6eb Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Fri, 8 Dec 2006 12:38:19 +0100 Subject: [PATCH] mshtml: Use HTMLWindow::alert in nsPromptService::Alert. --- dlls/mshtml/htmlwindow.c | 15 ++++++++++++++- dlls/mshtml/mshtml_private.h | 4 ++++ dlls/mshtml/nsservice.c | 18 ++++++++++++++++-- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/htmlwindow.c b/dlls/mshtml/htmlwindow.c index 8f0fc2b0559..6cd106ff62b 100644 --- a/dlls/mshtml/htmlwindow.c +++ b/dlls/mshtml/htmlwindow.c @@ -39,6 +39,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml); #define HTMLWINDOW2_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow2, iface) +static struct list window_list = LIST_INIT(window_list); + static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv) { HTMLWindow *This = HTMLWINDOW2_THIS(iface); @@ -85,8 +87,10 @@ static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface) TRACE("(%p) ref=%d\n", This, ref); - if(!ref) + if(!ref) { + list_remove(&This->entry); mshtml_free(This); + } return ref; } @@ -734,10 +738,19 @@ HTMLWindow *HTMLWindow_Create(HTMLDocument *doc) ERR("GetContentDOMWindow failed: %08x\n", nsres); } + list_add_head(&window_list, &ret->entry); + return ret; } HTMLWindow *nswindow_to_window(nsIDOMWindow *nswindow) { + HTMLWindow *iter; + + LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) { + if(iter->nswindow == nswindow) + return iter; + } + return NULL; } diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index a4631293b28..b7bfb36d888 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -21,6 +21,8 @@ #include "mshtmhst.h" #include "hlink.h" +#include "wine/list.h" + #ifdef INIT_GUID #include "initguid.h" #endif @@ -59,6 +61,8 @@ typedef struct { HTMLDocument *doc; nsIDOMWindow *nswindow; + + struct list entry; } HTMLWindow; typedef enum { diff --git a/dlls/mshtml/nsservice.c b/dlls/mshtml/nsservice.c index 76887b2c238..d4c9d6b8683 100644 --- a/dlls/mshtml/nsservice.c +++ b/dlls/mshtml/nsservice.c @@ -146,8 +146,22 @@ static nsrefcnt NSAPI nsPromptService_Release(nsIPromptService *iface) static nsresult NSAPI nsPromptService_Alert(nsIPromptService *iface, nsIDOMWindow *aParent, const PRUnichar *aDialogTitle, const PRUnichar *aText) { - FIXME("(%p %s %s)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText)); - return NS_ERROR_NOT_IMPLEMENTED; + HTMLWindow *window; + BSTR text; + + TRACE("(%p %s %s)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText)); + + window = nswindow_to_window(aParent); + if(!window) { + WARN("Could not find HTMLWindow for nsIDOMWindow %p\n", aParent); + return NS_ERROR_UNEXPECTED; + } + + text = SysAllocString(aText); + IHTMLWindow2_alert(HTMLWINDOW2(window), text); + SysFreeString(text); + + return NS_OK; } static nsresult NSAPI nsPromptService_AlertCheck(nsIPromptService *iface,