2 * Copyright 2005-2006 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 #define NS_APPSTARTUPNOTIFIER_CONTRACTID "@mozilla.org/embedcomp/appstartup-notifier;1"
39 #define NS_WEBBROWSER_CONTRACTID "@mozilla.org/embedding/browser/nsWebBrowser;1"
40 #define NS_PROFILE_CONTRACTID "@mozilla.org/profile/manager;1"
41 #define NS_MEMORY_CONTRACTID "@mozilla.org/xpcom/memory-service;1"
42 #define NS_STRINGSTREAM_CONTRACTID "@mozilla.org/io/string-input-stream;1"
44 #define APPSTARTUP_TOPIC "app-startup"
46 #define PR_UINT32_MAX 0xffffffff
48 struct nsCStringContainer {
55 static nsresult (*NS_InitXPCOM2)(nsIServiceManager**,void*,void*);
56 static nsresult (*NS_ShutdownXPCOM)(nsIServiceManager*);
57 static nsresult (*NS_GetComponentRegistrar)(nsIComponentRegistrar**);
58 static nsresult (*NS_StringContainerInit)(nsStringContainer*);
59 static nsresult (*NS_CStringContainerInit)(nsCStringContainer*);
60 static nsresult (*NS_StringContainerFinish)(nsStringContainer*);
61 static nsresult (*NS_CStringContainerFinish)(nsCStringContainer*);
62 static nsresult (*NS_StringSetData)(nsAString*,const PRUnichar*,PRUint32);
63 static nsresult (*NS_CStringSetData)(nsACString*,const char*,PRUint32);
64 static nsresult (*NS_NewLocalFile)(const nsAString*,PRBool,nsIFile**);
65 static PRUint32 (*NS_StringGetData)(const nsAString*,const PRUnichar **,PRBool*);
66 static PRUint32 (*NS_CStringGetData)(const nsACString*,const char**,PRBool*);
68 static HINSTANCE hXPCOM = NULL;
70 static nsIServiceManager *pServMgr = NULL;
71 static nsIComponentManager *pCompMgr = NULL;
72 static nsIMemory *nsmem = NULL;
74 static const WCHAR wszNsContainer[] = {'N','s','C','o','n','t','a','i','n','e','r',0};
76 static ATOM nscontainer_class;
78 static LRESULT WINAPI nsembed_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
83 static const WCHAR wszTHIS[] = {'T','H','I','S',0};
85 if(msg == WM_CREATE) {
86 This = *(NSContainer**)lParam;
87 SetPropW(hwnd, wszTHIS, This);
89 This = (NSContainer*)GetPropW(hwnd, wszTHIS);
94 TRACE("(%p)->(WM_SIZE)\n", This);
96 nsres = nsIBaseWindow_SetSize(This->window,
97 LOWORD(lParam), HIWORD(lParam), TRUE);
99 WARN("SetSize failed: %08lx\n", nsres);
102 return DefWindowProcW(hwnd, msg, wParam, lParam);
106 static void register_nscontainer_class(void)
108 static WNDCLASSEXW wndclass = {
112 0, 0, NULL, NULL, NULL, NULL, NULL,
116 wndclass.hInstance = hInst;
117 nscontainer_class = RegisterClassExW(&wndclass);
120 static BOOL load_xpcom(PRUnichar *gre_path)
122 WCHAR path_env[MAX_PATH];
125 static const WCHAR wszPATH[] = {'P','A','T','H',0};
126 static const WCHAR strXPCOM[] = {'x','p','c','o','m','.','d','l','l',0};
128 TRACE("(%s)\n", debugstr_w(gre_path));
130 /* We have to modify PATH as XPCOM loads other DLLs from this directory. */
131 GetEnvironmentVariableW(wszPATH, path_env, sizeof(path_env)/sizeof(WCHAR));
132 len = strlenW(path_env);
133 path_env[len++] = ';';
134 strcpyW(path_env+len, gre_path);
135 SetEnvironmentVariableW(wszPATH, path_env);
137 hXPCOM = LoadLibraryW(strXPCOM);
139 WARN("Could not load XPCOM: %ld\n", GetLastError());
143 #define NS_DLSYM(func) \
144 func = (typeof(func))GetProcAddress(hXPCOM, #func); \
146 ERR("Could not GetProcAddress(" #func ") failed\n")
148 NS_DLSYM(NS_InitXPCOM2);
149 NS_DLSYM(NS_ShutdownXPCOM);
150 NS_DLSYM(NS_GetComponentRegistrar);
151 NS_DLSYM(NS_StringContainerInit);
152 NS_DLSYM(NS_CStringContainerInit);
153 NS_DLSYM(NS_StringContainerFinish);
154 NS_DLSYM(NS_CStringContainerFinish);
155 NS_DLSYM(NS_StringSetData);
156 NS_DLSYM(NS_CStringSetData);
157 NS_DLSYM(NS_NewLocalFile);
158 NS_DLSYM(NS_StringGetData);
159 NS_DLSYM(NS_CStringGetData);
166 static BOOL load_mozilla(PRUnichar *gre_path)
168 DWORD res, type, i, size = MAX_PATH;
169 HKEY mozilla_key, hkey;
173 static const WCHAR wszGreKey[] =
174 {'S','o','f','t','w','a','r','e','\\',
175 'm','o','z','i','l','l','a','.','o','r','g','\\',
178 static const WCHAR wszGreHome[] = {'G','r','e','H','o','m','e',0};
180 res = RegOpenKeyW(HKEY_LOCAL_MACHINE, wszGreKey, &mozilla_key);
181 if(res != ERROR_SUCCESS) {
182 TRACE("Could not open key %s\n", debugstr_w(wszGreKey));
186 for(i=0; !ret && RegEnumKeyW(mozilla_key, i, key_name, sizeof(key_name)/sizeof(WCHAR)) == ERROR_SUCCESS; i++) {
187 RegOpenKeyW(mozilla_key, key_name, &hkey);
188 res = RegQueryValueExW(hkey, wszGreHome, NULL, &type, (LPBYTE)gre_path, &size);
189 if(res == ERROR_SUCCESS)
194 RegCloseKey(mozilla_key);
195 return ret ? load_xpcom(gre_path) : FALSE;
198 static BOOL load_mozctl(PRUnichar *gre_path)
201 DWORD res, type, size = MAX_PATH;
203 static const WCHAR wszMozCtlKey[] =
204 {'S','o','f','t','w','a','r','e','\\','M','o','z','i','l','l','a',0};
205 static const WCHAR wszBinDirectoryPath[] =
206 {'B','i','n','D','i','r','e','c','t','o','r','y','P','a','t','h',0};
207 static const WCHAR wszMozCtlClsidKey[] =
208 {'C','L','S','I','D','\\',
209 '{','1','3','3','9','B','5','4','C','-','3','4','5','3','-','1','1','D','2',
210 '-','9','3','B','9','-','0','0','0','0','0','0','0','0','0','0','0','0','}','\\',
211 'I','n','p','r','o','c','S','e','r','v','e','r','3','2',0};
213 res = RegOpenKeyW(HKEY_LOCAL_MACHINE, wszMozCtlKey, &hkey);
214 if(res == ERROR_SUCCESS) {
215 res = RegQueryValueExW(hkey, wszBinDirectoryPath, NULL, &type, (LPBYTE)gre_path, &size);
216 if(res == ERROR_SUCCESS)
217 return load_xpcom(gre_path);
219 ERR("Could not get value %s\n", debugstr_w(wszBinDirectoryPath));
222 res = RegOpenKeyW(HKEY_CLASSES_ROOT, wszMozCtlClsidKey, &hkey);
223 if(res == ERROR_SUCCESS) {
224 res = RegQueryValueExW(hkey, NULL, NULL, &type, (LPBYTE)gre_path, &size);
225 if(res == ERROR_SUCCESS) {
227 if((ptr = strrchrW(gre_path, '\\')))
229 load_xpcom(gre_path);
231 ERR("Could not get value of %s\n", debugstr_w(wszMozCtlClsidKey));
235 TRACE("Could not find Mozilla ActiveX Control\n");
240 static BOOL load_wine_gecko(PRUnichar *gre_path)
243 DWORD res, type, size = MAX_PATH;
245 static const WCHAR wszMshtmlKey[] = {
246 'S','o','f','t','w','a','r','e','\\','W','i','n','e',
247 '\\','M','S','H','T','M','L',0};
248 static const WCHAR wszGeckoPath[] =
249 {'G','e','c','k','o','P','a','t','h',0};
251 /* @@ Wine registry key: HKCU\Software\Wine\MSHTML */
252 res = RegOpenKeyW(HKEY_CURRENT_USER, wszMshtmlKey, &hkey);
253 if(res != ERROR_SUCCESS)
256 res = RegQueryValueExW(hkey, wszGeckoPath, NULL, &type, (LPBYTE)gre_path, &size);
257 if(res != ERROR_SUCCESS || type != REG_SZ)
260 return load_xpcom(gre_path);
263 static void set_profile(void)
266 PRBool exists = FALSE;
269 static const WCHAR wszMSHTML[] = {'M','S','H','T','M','L',0};
271 nsres = nsIServiceManager_GetServiceByContactID(pServMgr, NS_PROFILE_CONTRACTID,
272 &IID_nsIProfile, (void**)&profile);
273 if(NS_FAILED(nsres)) {
274 ERR("Could not get profile service: %08lx\n", nsres);
278 nsres = nsIProfile_ProfileExists(profile, wszMSHTML, &exists);
280 nsres = nsIProfile_CreateNewProfile(profile, wszMSHTML, NULL, NULL, FALSE);
282 ERR("CreateNewProfile failed: %08lx\n", nsres);
285 nsres = nsIProfile_SetCurrentProfile(profile, wszMSHTML);
287 ERR("SetCurrentProfile failed: %08lx\n", nsres);
289 nsIProfile_Release(profile);
292 static BOOL load_gecko(void)
295 nsIObserver *pStartNotif;
296 nsIComponentRegistrar *registrar = NULL;
299 PRUnichar gre_path[MAX_PATH];
301 static BOOL tried_load = FALSE;
306 return pCompMgr != NULL;
309 if(!load_wine_gecko(gre_path) && !load_mozctl(gre_path) && !load_mozilla(gre_path)) {
310 install_wine_gecko();
311 if(!load_wine_gecko(gre_path)) {
312 MESSAGE("Could not load Mozilla. HTML rendering will be disabled.\n");
317 NS_StringContainerInit(&path);
318 NS_StringSetData(&path, gre_path, PR_UINT32_MAX);
319 nsres = NS_NewLocalFile(&path, FALSE, &gre_dir);
320 NS_StringContainerFinish(&path);
321 if(NS_FAILED(nsres)) {
322 ERR("NS_NewLocalFile failed: %08lx\n", nsres);
327 nsres = NS_InitXPCOM2(&pServMgr, gre_dir, NULL);
328 if(NS_FAILED(nsres)) {
329 ERR("NS_InitXPCOM2 failed: %08lx\n", nsres);
334 nsres = nsIServiceManager_QueryInterface(pServMgr, &IID_nsIComponentManager, (void**)&pCompMgr);
336 ERR("Could not get nsIComponentManager: %08lx\n", nsres);
338 nsres = NS_GetComponentRegistrar(®istrar);
339 if(NS_SUCCEEDED(nsres)) {
340 nsres = nsIComponentRegistrar_AutoRegister(registrar, NULL);
342 ERR("AutoRegister(NULL) failed: %08lx\n", nsres);
344 nsres = nsIComponentRegistrar_AutoRegister(registrar, gre_dir);
346 ERR("AutoRegister(gre_dir) failed: %08lx\n", nsres);
348 init_nsio(pCompMgr, registrar);
350 ERR("NS_GetComponentRegistrar failed: %08lx\n", nsres);
353 nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_APPSTARTUPNOTIFIER_CONTRACTID,
354 NULL, &IID_nsIObserver, (void**)&pStartNotif);
355 if(NS_SUCCEEDED(nsres)) {
356 nsres = nsIObserver_Observe(pStartNotif, NULL, APPSTARTUP_TOPIC, NULL);
358 ERR("Observe failed: %08lx\n", nsres);
360 nsIObserver_Release(pStartNotif);
362 ERR("could not get appstartup-notifier: %08lx\n", nsres);
367 nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_MEMORY_CONTRACTID,
368 NULL, &IID_nsIMemory, (void**)&nsmem);
370 ERR("Could not get nsIMemory: %08lx\n", nsres);
373 register_nsservice(registrar, pServMgr);
374 nsIComponentRegistrar_Release(registrar);
380 void *nsalloc(size_t size)
382 return nsIMemory_Alloc(nsmem, size);
385 void nsfree(void *mem)
387 nsIMemory_Free(nsmem, mem);
390 void nsACString_Init(nsACString *str, const char *data)
392 NS_CStringContainerInit(str);
394 NS_CStringSetData(str, data, PR_UINT32_MAX);
397 PRUint32 nsACString_GetData(const nsACString *str, const char **data, PRBool *termited)
399 return NS_CStringGetData(str, data, termited);
402 void nsACString_Finish(nsACString *str)
404 NS_CStringContainerFinish(str);
407 void nsAString_Init(nsAString *str, const PRUnichar *data)
409 NS_StringContainerInit(str);
411 NS_StringSetData(str, data, PR_UINT32_MAX);
414 PRUint32 nsAString_GetData(const nsAString *str, const PRUnichar **data, PRBool *termited)
416 return NS_StringGetData(str, data, termited);
419 void nsAString_Finish(nsAString *str)
421 NS_StringContainerFinish(str);
424 nsIInputStream *create_nsstream(const char *data, PRInt32 data_len)
426 nsIStringInputStream *ret;
432 nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr,
433 NS_STRINGSTREAM_CONTRACTID, NULL, &IID_nsIStringInputStream,
435 if(NS_FAILED(nsres)) {
436 ERR("Could not get nsIStringInputStream\n");
440 nsres = nsIStringInputStream_SetData(ret, data, data_len);
441 if(NS_FAILED(nsres)) {
442 ERR("AdoptData failed: %08lx\n", nsres);
443 nsIStringInputStream_Release(ret);
447 return (nsIInputStream*)ret;
455 nsIComponentManager_Release(pCompMgr);
458 nsIServiceManager_Release(pServMgr);
461 nsIMemory_Release(nsmem);
467 /**********************************************************
468 * nsIWebBrowserChrome interface
471 #define NSWBCHROME_THIS(iface) DEFINE_THIS(NSContainer, WebBrowserChrome, iface)
473 static nsresult NSAPI nsWebBrowserChrome_QueryInterface(nsIWebBrowserChrome *iface,
474 nsIIDRef riid, nsQIResult result)
476 NSContainer *This = NSWBCHROME_THIS(iface);
479 if(IsEqualGUID(&IID_nsISupports, riid)) {
480 TRACE("(%p)->(IID_nsISupports, %p)\n", This, result);
481 *result = NSWBCHROME(This);
482 }else if(IsEqualGUID(&IID_nsIWebBrowserChrome, riid)) {
483 TRACE("(%p)->(IID_nsIWebBrowserChrome, %p)\n", This, result);
484 *result = NSWBCHROME(This);
485 }else if(IsEqualGUID(&IID_nsIContextMenuListener, riid)) {
486 TRACE("(%p)->(IID_nsIContextMenuListener, %p)\n", This, result);
487 *result = NSCML(This);
488 }else if(IsEqualGUID(&IID_nsIURIContentListener, riid)) {
489 TRACE("(%p)->(IID_nsIURIContentListener %p)\n", This, result);
490 *result = NSURICL(This);
491 }else if(IsEqualGUID(&IID_nsIEmbeddingSiteWindow, riid)) {
492 TRACE("(%p)->(IID_nsIEmbeddingSiteWindow %p)\n", This, result);
493 *result = NSEMBWNDS(This);
494 }else if(IsEqualGUID(&IID_nsITooltipListener, riid)) {
495 TRACE("(%p)->(IID_nsITooltipListener %p)\n", This, result);
496 *result = NSTOOLTIP(This);
497 }else if(IsEqualGUID(&IID_nsIInterfaceRequestor, riid)) {
498 TRACE("(%p)->(IID_nsIInterfaceRequestor %p)\n", This, result);
499 *result = NSIFACEREQ(This);
500 }else if(IsEqualGUID(&IID_nsIWeakReference, riid)) {
501 TRACE("(%p)->(IID_nsIWeakReference %p)\n", This, result);
502 *result = NSWEAKREF(This);
503 }else if(IsEqualGUID(&IID_nsISupportsWeakReference, riid)) {
504 TRACE("(%p)->(IID_nsISupportsWeakReference %p)\n", This, result);
505 *result = NSSUPWEAKREF(This);
509 nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
513 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
514 return NS_NOINTERFACE;
517 static nsrefcnt NSAPI nsWebBrowserChrome_AddRef(nsIWebBrowserChrome *iface)
519 NSContainer *This = NSWBCHROME_THIS(iface);
520 LONG ref = InterlockedIncrement(&This->ref);
522 TRACE("(%p) ref=%ld\n", This, ref);
527 static nsrefcnt NSAPI nsWebBrowserChrome_Release(nsIWebBrowserChrome *iface)
529 NSContainer *This = NSWBCHROME_THIS(iface);
530 LONG ref = InterlockedDecrement(&This->ref);
532 TRACE("(%p) ref=%ld\n", This, ref);
536 nsIWebBrowserChrome_Release(NSWBCHROME(This->parent));
543 static nsresult NSAPI nsWebBrowserChrome_SetStatus(nsIWebBrowserChrome *iface,
544 PRUint32 statusType, const PRUnichar *status)
546 NSContainer *This = NSWBCHROME_THIS(iface);
547 TRACE("(%p)->(%ld %s)\n", This, statusType, debugstr_w(status));
548 return NS_ERROR_NOT_IMPLEMENTED;
551 static nsresult NSAPI nsWebBrowserChrome_GetWebBrowser(nsIWebBrowserChrome *iface,
552 nsIWebBrowser **aWebBrowser)
554 NSContainer *This = NSWBCHROME_THIS(iface);
556 TRACE("(%p)->(%p)\n", This, aWebBrowser);
559 return NS_ERROR_INVALID_ARG;
562 nsIWebBrowser_AddRef(This->webbrowser);
563 *aWebBrowser = This->webbrowser;
567 static nsresult NSAPI nsWebBrowserChrome_SetWebBrowser(nsIWebBrowserChrome *iface,
568 nsIWebBrowser *aWebBrowser)
570 NSContainer *This = NSWBCHROME_THIS(iface);
572 TRACE("(%p)->(%p)\n", This, aWebBrowser);
574 if(aWebBrowser != This->webbrowser)
575 ERR("Wrong nsWebBrowser!\n");
580 static nsresult NSAPI nsWebBrowserChrome_GetChromeFlags(nsIWebBrowserChrome *iface,
581 PRUint32 *aChromeFlags)
583 NSContainer *This = NSWBCHROME_THIS(iface);
584 WARN("(%p)->(%p)\n", This, aChromeFlags);
585 return NS_ERROR_NOT_IMPLEMENTED;
588 static nsresult NSAPI nsWebBrowserChrome_SetChromeFlags(nsIWebBrowserChrome *iface,
589 PRUint32 aChromeFlags)
591 NSContainer *This = NSWBCHROME_THIS(iface);
592 WARN("(%p)->(%08lx)\n", This, aChromeFlags);
593 return NS_ERROR_NOT_IMPLEMENTED;
596 static nsresult NSAPI nsWebBrowserChrome_DestroyBrowserWindow(nsIWebBrowserChrome *iface)
598 NSContainer *This = NSWBCHROME_THIS(iface);
599 TRACE("(%p)\n", This);
600 return NS_ERROR_NOT_IMPLEMENTED;
603 static nsresult NSAPI nsWebBrowserChrome_SizeBrowserTo(nsIWebBrowserChrome *iface,
604 PRInt32 aCX, PRInt32 aCY)
606 NSContainer *This = NSWBCHROME_THIS(iface);
607 WARN("(%p)->(%ld %ld)\n", This, aCX, aCY);
608 return NS_ERROR_NOT_IMPLEMENTED;
611 static nsresult NSAPI nsWebBrowserChrome_ShowAsModal(nsIWebBrowserChrome *iface)
613 NSContainer *This = NSWBCHROME_THIS(iface);
614 WARN("(%p)\n", This);
615 return NS_ERROR_NOT_IMPLEMENTED;
618 static nsresult NSAPI nsWebBrowserChrome_IsWindowModal(nsIWebBrowserChrome *iface, PRBool *_retval)
620 NSContainer *This = NSWBCHROME_THIS(iface);
621 WARN("(%p)->(%p)\n", This, _retval);
622 return NS_ERROR_NOT_IMPLEMENTED;
625 static nsresult NSAPI nsWebBrowserChrome_ExitModalEventLoop(nsIWebBrowserChrome *iface,
628 NSContainer *This = NSWBCHROME_THIS(iface);
629 WARN("(%p)->(%08lx)\n", This, aStatus);
630 return NS_ERROR_NOT_IMPLEMENTED;
633 #undef NSWBCHROME_THIS
635 static const nsIWebBrowserChromeVtbl nsWebBrowserChromeVtbl = {
636 nsWebBrowserChrome_QueryInterface,
637 nsWebBrowserChrome_AddRef,
638 nsWebBrowserChrome_Release,
639 nsWebBrowserChrome_SetStatus,
640 nsWebBrowserChrome_GetWebBrowser,
641 nsWebBrowserChrome_SetWebBrowser,
642 nsWebBrowserChrome_GetChromeFlags,
643 nsWebBrowserChrome_SetChromeFlags,
644 nsWebBrowserChrome_DestroyBrowserWindow,
645 nsWebBrowserChrome_SizeBrowserTo,
646 nsWebBrowserChrome_ShowAsModal,
647 nsWebBrowserChrome_IsWindowModal,
648 nsWebBrowserChrome_ExitModalEventLoop
651 /**********************************************************
652 * nsIContextMenuListener interface
655 #define NSCML_THIS(iface) DEFINE_THIS(NSContainer, ContextMenuListener, iface)
657 static nsresult NSAPI nsContextMenuListener_QueryInterface(nsIContextMenuListener *iface,
658 nsIIDRef riid, nsQIResult result)
660 NSContainer *This = NSCML_THIS(iface);
661 return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
664 static nsrefcnt NSAPI nsContextMenuListener_AddRef(nsIContextMenuListener *iface)
666 NSContainer *This = NSCML_THIS(iface);
667 return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
670 static nsrefcnt NSAPI nsContextMenuListener_Release(nsIContextMenuListener *iface)
672 NSContainer *This = NSCML_THIS(iface);
673 return nsIWebBrowserChrome_Release(NSWBCHROME(This));
676 static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuListener *iface,
677 PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
679 NSContainer *This = NSCML_THIS(iface);
680 nsIDOMMouseEvent *event;
682 DWORD dwID = CONTEXT_MENU_DEFAULT;
685 TRACE("(%p)->(%08lx %p %p)\n", This, aContextFlags, aEvent, aNode);
687 nsres = nsIDOMEvent_QueryInterface(aEvent, &IID_nsIDOMMouseEvent, (void**)&event);
688 if(NS_FAILED(nsres)) {
689 ERR("Could not get nsIDOMMouseEvent interface: %08lx\n", nsres);
693 nsIDOMMouseEvent_GetScreenX(event, &pt.x);
694 nsIDOMMouseEvent_GetScreenY(event, &pt.y);
695 nsIDOMMouseEvent_Release(event);
697 switch(aContextFlags) {
699 case CONTEXT_DOCUMENT:
701 dwID = CONTEXT_MENU_DEFAULT;
704 case CONTEXT_IMAGE|CONTEXT_LINK:
705 dwID = CONTEXT_MENU_IMAGE;
708 dwID = CONTEXT_MENU_ANCHOR;
711 dwID = CONTEXT_MENU_CONTROL;
714 FIXME("aContextFlags=%08lx\n", aContextFlags);
717 HTMLDocument_ShowContextMenu(This->doc, dwID, &pt);
724 static const nsIContextMenuListenerVtbl nsContextMenuListenerVtbl = {
725 nsContextMenuListener_QueryInterface,
726 nsContextMenuListener_AddRef,
727 nsContextMenuListener_Release,
728 nsContextMenuListener_OnShowContextMenu
731 /**********************************************************
732 * nsIURIContentListener interface
735 #define NSURICL_THIS(iface) DEFINE_THIS(NSContainer, URIContentListener, iface)
737 static nsresult NSAPI nsURIContentListener_QueryInterface(nsIURIContentListener *iface,
738 nsIIDRef riid, nsQIResult result)
740 NSContainer *This = NSURICL_THIS(iface);
741 return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
744 static nsrefcnt NSAPI nsURIContentListener_AddRef(nsIURIContentListener *iface)
746 NSContainer *This = NSURICL_THIS(iface);
747 return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
750 static nsrefcnt NSAPI nsURIContentListener_Release(nsIURIContentListener *iface)
752 NSContainer *This = NSURICL_THIS(iface);
753 return nsIWebBrowserChrome_Release(NSWBCHROME(This));
756 static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener *iface,
757 nsIURI *aURI, PRBool *_retval)
759 NSContainer *This = NSURICL_THIS(iface);
760 nsIWineURI *wine_uri;
765 nsACString_Init(&spec_str, NULL);
766 nsIURI_GetSpec(aURI, &spec_str);
767 nsACString_GetData(&spec_str, &spec, NULL);
769 TRACE("(%p)->(%p(%s) %p)\n", This, aURI, debugstr_a(spec), _retval);
771 nsACString_Finish(&spec_str);
773 nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri);
774 if(NS_FAILED(nsres)) {
775 WARN("Could not get nsIWineURI interface: %08lx\n", nsres);
776 return NS_ERROR_NOT_IMPLEMENTED;
779 nsIWineURI_SetNSContainer(wine_uri, This);
781 if(This->bscallback && This->bscallback->mon) {
785 hres = IMoniker_GetDisplayName(This->bscallback->mon, NULL, 0, &url);
786 if(SUCCEEDED(hres)) {
787 IMoniker *mon = NULL;
789 hres = CreateURLMoniker(NULL, url, &mon);
790 if(SUCCEEDED(hres)) {
791 nsIWineURI_SetMoniker(wine_uri, mon);
792 IMoniker_Release(mon);
794 WARN("CreateURLMoniker failed: %08lx\n", hres);
797 WARN("GetDisplayName failed: %08lx\n", hres);
801 nsIWineURI_Release(wine_uri);
804 return This->content_listener
805 ? nsIURIContentListener_OnStartURIOpen(This->content_listener, aURI, _retval)
809 static nsresult NSAPI nsURIContentListener_DoContent(nsIURIContentListener *iface,
810 const char *aContentType, PRBool aIsContentPreferred, nsIRequest *aRequest,
811 nsIStreamListener **aContentHandler, PRBool *_retval)
813 NSContainer *This = NSURICL_THIS(iface);
815 TRACE("(%p)->(%s %x %p %p %p)\n", This, debugstr_a(aContentType), aIsContentPreferred,
816 aRequest, aContentHandler, _retval);
818 return This->content_listener
819 ? nsIURIContentListener_DoContent(This->content_listener, aContentType,
820 aIsContentPreferred, aRequest, aContentHandler, _retval)
821 : NS_ERROR_NOT_IMPLEMENTED;
824 static nsresult NSAPI nsURIContentListener_IsPreferred(nsIURIContentListener *iface,
825 const char *aContentType, char **aDesiredContentType, PRBool *_retval)
827 NSContainer *This = NSURICL_THIS(iface);
829 TRACE("(%p)->(%s %p %p)\n", This, debugstr_a(aContentType), aDesiredContentType, _retval);
831 /* FIXME: Should we do something here? */
834 return This->content_listener
835 ? nsIURIContentListener_IsPreferred(This->content_listener, aContentType,
836 aDesiredContentType, _retval)
840 static nsresult NSAPI nsURIContentListener_CanHandleContent(nsIURIContentListener *iface,
841 const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType,
844 NSContainer *This = NSURICL_THIS(iface);
846 TRACE("(%p)->(%s %x %p %p)\n", This, debugstr_a(aContentType), aIsContentPreferred,
847 aDesiredContentType, _retval);
849 return This->content_listener
850 ? nsIURIContentListener_CanHandleContent(This->content_listener, aContentType,
851 aIsContentPreferred, aDesiredContentType, _retval)
852 : NS_ERROR_NOT_IMPLEMENTED;
855 static nsresult NSAPI nsURIContentListener_GetLoadCookie(nsIURIContentListener *iface,
856 nsISupports **aLoadCookie)
858 NSContainer *This = NSURICL_THIS(iface);
860 WARN("(%p)->(%p)\n", This, aLoadCookie);
862 return This->content_listener
863 ? nsIURIContentListener_GetLoadCookie(This->content_listener, aLoadCookie)
864 : NS_ERROR_NOT_IMPLEMENTED;
867 static nsresult NSAPI nsURIContentListener_SetLoadCookie(nsIURIContentListener *iface,
868 nsISupports *aLoadCookie)
870 NSContainer *This = NSURICL_THIS(iface);
872 WARN("(%p)->(%p)\n", This, aLoadCookie);
874 return This->content_listener
875 ? nsIURIContentListener_SetLoadCookie(This->content_listener, aLoadCookie)
876 : NS_ERROR_NOT_IMPLEMENTED;
879 static nsresult NSAPI nsURIContentListener_GetParentContentListener(nsIURIContentListener *iface,
880 nsIURIContentListener **aParentContentListener)
882 NSContainer *This = NSURICL_THIS(iface);
884 TRACE("(%p)->(%p)\n", This, aParentContentListener);
886 if(This->content_listener)
887 nsIURIContentListener_AddRef(This->content_listener);
889 *aParentContentListener = This->content_listener;
893 static nsresult NSAPI nsURIContentListener_SetParentContentListener(nsIURIContentListener *iface,
894 nsIURIContentListener *aParentContentListener)
896 NSContainer *This = NSURICL_THIS(iface);
898 TRACE("(%p)->(%p)\n", This, aParentContentListener);
900 if(aParentContentListener == NSURICL(This))
903 if(This->content_listener)
904 nsIURIContentListener_Release(This->content_listener);
906 This->content_listener = aParentContentListener;
907 if(This->content_listener)
908 nsIURIContentListener_AddRef(This->content_listener);
915 static const nsIURIContentListenerVtbl nsURIContentListenerVtbl = {
916 nsURIContentListener_QueryInterface,
917 nsURIContentListener_AddRef,
918 nsURIContentListener_Release,
919 nsURIContentListener_OnStartURIOpen,
920 nsURIContentListener_DoContent,
921 nsURIContentListener_IsPreferred,
922 nsURIContentListener_CanHandleContent,
923 nsURIContentListener_GetLoadCookie,
924 nsURIContentListener_SetLoadCookie,
925 nsURIContentListener_GetParentContentListener,
926 nsURIContentListener_SetParentContentListener
929 /**********************************************************
930 * nsIEmbeddinSiteWindow interface
933 #define NSEMBWNDS_THIS(iface) DEFINE_THIS(NSContainer, EmbeddingSiteWindow, iface)
935 static nsresult NSAPI nsEmbeddingSiteWindow_QueryInterface(nsIEmbeddingSiteWindow *iface,
936 nsIIDRef riid, nsQIResult result)
938 NSContainer *This = NSEMBWNDS_THIS(iface);
939 return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
942 static nsrefcnt NSAPI nsEmbeddingSiteWindow_AddRef(nsIEmbeddingSiteWindow *iface)
944 NSContainer *This = NSEMBWNDS_THIS(iface);
945 return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
948 static nsrefcnt NSAPI nsEmbeddingSiteWindow_Release(nsIEmbeddingSiteWindow *iface)
950 NSContainer *This = NSEMBWNDS_THIS(iface);
951 return nsIWebBrowserChrome_Release(NSWBCHROME(This));
954 static nsresult NSAPI nsEmbeddingSiteWindow_SetDimensions(nsIEmbeddingSiteWindow *iface,
955 PRUint32 flags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
957 NSContainer *This = NSEMBWNDS_THIS(iface);
958 WARN("(%p)->(%08lx %ld %ld %ld %ld)\n", This, flags, x, y, cx, cy);
959 return NS_ERROR_NOT_IMPLEMENTED;
962 static nsresult NSAPI nsEmbeddingSiteWindow_GetDimensions(nsIEmbeddingSiteWindow *iface,
963 PRUint32 flags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
965 NSContainer *This = NSEMBWNDS_THIS(iface);
966 WARN("(%p)->(%08lx %p %p %p %p)\n", This, flags, x, y, cx, cy);
967 return NS_ERROR_NOT_IMPLEMENTED;
970 static nsresult NSAPI nsEmbeddingSiteWindow_SetFocus(nsIEmbeddingSiteWindow *iface)
972 NSContainer *This = NSEMBWNDS_THIS(iface);
973 WARN("(%p)\n", This);
974 return NS_ERROR_NOT_IMPLEMENTED;
977 static nsresult NSAPI nsEmbeddingSiteWindow_GetVisibility(nsIEmbeddingSiteWindow *iface,
980 NSContainer *This = NSEMBWNDS_THIS(iface);
981 WARN("(%p)->(%p)\n", This, aVisibility);
982 return NS_ERROR_NOT_IMPLEMENTED;
985 static nsresult NSAPI nsEmbeddingSiteWindow_SetVisibility(nsIEmbeddingSiteWindow *iface,
988 NSContainer *This = NSEMBWNDS_THIS(iface);
989 WARN("(%p)->(%x)\n", This, aVisibility);
990 return NS_ERROR_NOT_IMPLEMENTED;
993 static nsresult NSAPI nsEmbeddingSiteWindow_GetTitle(nsIEmbeddingSiteWindow *iface,
996 NSContainer *This = NSEMBWNDS_THIS(iface);
997 WARN("(%p)->(%p)\n", This, aTitle);
998 return NS_ERROR_NOT_IMPLEMENTED;
1001 static nsresult NSAPI nsEmbeddingSiteWindow_SetTitle(nsIEmbeddingSiteWindow *iface,
1002 const PRUnichar *aTitle)
1004 NSContainer *This = NSEMBWNDS_THIS(iface);
1005 WARN("(%p)->(%s)\n", This, debugstr_w(aTitle));
1006 return NS_ERROR_NOT_IMPLEMENTED;
1009 static nsresult NSAPI nsEmbeddingSiteWindow_GetSiteWindow(nsIEmbeddingSiteWindow *iface,
1012 NSContainer *This = NSEMBWNDS_THIS(iface);
1014 TRACE("(%p)->(%p)\n", This, aSiteWindow);
1016 *aSiteWindow = This->hwnd;
1020 static const nsIEmbeddingSiteWindowVtbl nsEmbeddingSiteWindowVtbl = {
1021 nsEmbeddingSiteWindow_QueryInterface,
1022 nsEmbeddingSiteWindow_AddRef,
1023 nsEmbeddingSiteWindow_Release,
1024 nsEmbeddingSiteWindow_SetDimensions,
1025 nsEmbeddingSiteWindow_GetDimensions,
1026 nsEmbeddingSiteWindow_SetFocus,
1027 nsEmbeddingSiteWindow_GetVisibility,
1028 nsEmbeddingSiteWindow_SetVisibility,
1029 nsEmbeddingSiteWindow_GetTitle,
1030 nsEmbeddingSiteWindow_SetTitle,
1031 nsEmbeddingSiteWindow_GetSiteWindow
1034 #define NSTOOLTIP_THIS(iface) DEFINE_THIS(NSContainer, TooltipListener, iface)
1036 static nsresult NSAPI nsTooltipListener_QueryInterface(nsITooltipListener *iface, nsIIDRef riid,
1039 NSContainer *This = NSTOOLTIP_THIS(iface);
1040 return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
1043 static nsrefcnt NSAPI nsTooltipListener_AddRef(nsITooltipListener *iface)
1045 NSContainer *This = NSTOOLTIP_THIS(iface);
1046 return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
1049 static nsrefcnt NSAPI nsTooltipListener_Release(nsITooltipListener *iface)
1051 NSContainer *This = NSTOOLTIP_THIS(iface);
1052 return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
1055 static nsresult NSAPI nsTooltipListener_OnShowTooltip(nsITooltipListener *iface,
1056 PRInt32 aXCoord, PRInt32 aYCoord, const PRUnichar *aTipText)
1058 NSContainer *This = NSTOOLTIP_THIS(iface);
1060 show_tooltip(This->doc, aXCoord, aYCoord, aTipText);
1065 static nsresult NSAPI nsTooltipListener_OnHideTooltip(nsITooltipListener *iface)
1067 NSContainer *This = NSTOOLTIP_THIS(iface);
1069 hide_tooltip(This->doc);
1074 #undef NSTOOLTIM_THIS
1076 static const nsITooltipListenerVtbl nsTooltipListenerVtbl = {
1077 nsTooltipListener_QueryInterface,
1078 nsTooltipListener_AddRef,
1079 nsTooltipListener_Release,
1080 nsTooltipListener_OnShowTooltip,
1081 nsTooltipListener_OnHideTooltip
1084 #define NSIFACEREQ_THIS(iface) DEFINE_THIS(NSContainer, InterfaceRequestor, iface)
1086 static nsresult NSAPI nsInterfaceRequestor_QueryInterface(nsIInterfaceRequestor *iface,
1087 nsIIDRef riid, nsQIResult result)
1089 NSContainer *This = NSIFACEREQ_THIS(iface);
1090 return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
1093 static nsrefcnt NSAPI nsInterfaceRequestor_AddRef(nsIInterfaceRequestor *iface)
1095 NSContainer *This = NSIFACEREQ_THIS(iface);
1096 return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
1099 static nsrefcnt NSAPI nsInterfaceRequestor_Release(nsIInterfaceRequestor *iface)
1101 NSContainer *This = NSIFACEREQ_THIS(iface);
1102 return nsIWebBrowserChrome_Release(NSWBCHROME(This));
1105 static nsresult NSAPI nsInterfaceRequestor_GetInterface(nsIInterfaceRequestor *iface,
1106 nsIIDRef riid, nsQIResult result)
1108 NSContainer *This = NSIFACEREQ_THIS(iface);
1110 if(IsEqualGUID(&IID_nsIDOMWindow, riid)) {
1111 TRACE("(%p)->(IID_nsIDOMWindow %p)\n", This, result);
1112 return nsIWebBrowser_GetContentDOMWindow(This->webbrowser, (nsIDOMWindow**)result);
1115 return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
1118 #undef NSIFACEREQ_THIS
1120 static const nsIInterfaceRequestorVtbl nsInterfaceRequestorVtbl = {
1121 nsInterfaceRequestor_QueryInterface,
1122 nsInterfaceRequestor_AddRef,
1123 nsInterfaceRequestor_Release,
1124 nsInterfaceRequestor_GetInterface
1127 #define NSWEAKREF_THIS(iface) DEFINE_THIS(NSContainer, WeakReference, iface)
1129 static nsresult NSAPI nsWeakReference_QueryInterface(nsIWeakReference *iface,
1130 nsIIDRef riid, nsQIResult result)
1132 NSContainer *This = NSWEAKREF_THIS(iface);
1133 return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
1136 static nsrefcnt NSAPI nsWeakReference_AddRef(nsIWeakReference *iface)
1138 NSContainer *This = NSWEAKREF_THIS(iface);
1139 return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
1142 static nsrefcnt NSAPI nsWeakReference_Release(nsIWeakReference *iface)
1144 NSContainer *This = NSWEAKREF_THIS(iface);
1145 return nsIWebBrowserChrome_Release(NSWBCHROME(This));
1148 static nsresult NSAPI nsWeakReference_QueryReferent(nsIWeakReference *iface,
1149 const nsIID *riid, void **result)
1151 NSContainer *This = NSWEAKREF_THIS(iface);
1152 return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
1155 #undef NSWEAKREF_THIS
1157 static const nsIWeakReferenceVtbl nsWeakReferenceVtbl = {
1158 nsWeakReference_QueryInterface,
1159 nsWeakReference_AddRef,
1160 nsWeakReference_Release,
1161 nsWeakReference_QueryReferent
1164 #define NSSUPWEAKREF_THIS(iface) DEFINE_THIS(NSContainer, SupportsWeakReference, iface)
1166 static nsresult NSAPI nsSupportsWeakReference_QueryInterface(nsISupportsWeakReference *iface,
1167 nsIIDRef riid, nsQIResult result)
1169 NSContainer *This = NSSUPWEAKREF_THIS(iface);
1170 return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
1173 static nsrefcnt NSAPI nsSupportsWeakReference_AddRef(nsISupportsWeakReference *iface)
1175 NSContainer *This = NSSUPWEAKREF_THIS(iface);
1176 return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
1179 static nsrefcnt NSAPI nsSupportsWeakReference_Release(nsISupportsWeakReference *iface)
1181 NSContainer *This = NSSUPWEAKREF_THIS(iface);
1182 return nsIWebBrowserChrome_Release(NSWBCHROME(This));
1185 static nsresult NSAPI nsSupportsWeakReference_GetWeakReference(nsISupportsWeakReference *iface,
1186 nsIWeakReference **_retval)
1188 NSContainer *This = NSSUPWEAKREF_THIS(iface);
1190 TRACE("(%p)->(%p)\n", This, _retval);
1192 nsIWeakReference_AddRef(NSWEAKREF(This));
1193 *_retval = NSWEAKREF(This);
1197 #undef NSWEAKREF_THIS
1199 const nsISupportsWeakReferenceVtbl nsSupportsWeakReferenceVtbl = {
1200 nsSupportsWeakReference_QueryInterface,
1201 nsSupportsWeakReference_AddRef,
1202 nsSupportsWeakReference_Release,
1203 nsSupportsWeakReference_GetWeakReference
1207 NSContainer *NSContainer_Create(HTMLDocument *doc, NSContainer *parent)
1209 nsIWebBrowserSetup *wbsetup;
1216 ret = mshtml_alloc(sizeof(NSContainer));
1218 ret->lpWebBrowserChromeVtbl = &nsWebBrowserChromeVtbl;
1219 ret->lpContextMenuListenerVtbl = &nsContextMenuListenerVtbl;
1220 ret->lpURIContentListenerVtbl = &nsURIContentListenerVtbl;
1221 ret->lpEmbeddingSiteWindowVtbl = &nsEmbeddingSiteWindowVtbl;
1222 ret->lpTooltipListenerVtbl = &nsTooltipListenerVtbl;
1223 ret->lpInterfaceRequestorVtbl = &nsInterfaceRequestorVtbl;
1224 ret->lpWeakReferenceVtbl = &nsWeakReferenceVtbl;
1225 ret->lpSupportsWeakReferenceVtbl = &nsSupportsWeakReferenceVtbl;
1230 ret->bscallback = NULL;
1231 ret->content_listener = NULL;
1234 nsIWebBrowserChrome_AddRef(NSWBCHROME(parent));
1235 ret->parent = parent;
1237 nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_WEBBROWSER_CONTRACTID,
1238 NULL, &IID_nsIWebBrowser, (void**)&ret->webbrowser);
1239 if(NS_FAILED(nsres))
1240 ERR("Creating WebBrowser failed: %08lx\n", nsres);
1242 nsres = nsIWebBrowser_SetContainerWindow(ret->webbrowser, NSWBCHROME(ret));
1243 if(NS_FAILED(nsres))
1244 ERR("SetContainerWindow failed: %08lx\n", nsres);
1246 nsres = nsIWebBrowser_QueryInterface(ret->webbrowser, &IID_nsIBaseWindow,
1247 (void**)&ret->window);
1248 if(NS_FAILED(nsres))
1249 ERR("Could not get nsIBaseWindow interface: %08lx\n", nsres);
1251 nsres = nsIWebBrowser_QueryInterface(ret->webbrowser, &IID_nsIWebBrowserSetup,
1253 if(NS_SUCCEEDED(nsres)) {
1254 nsres = nsIWebBrowserSetup_SetProperty(wbsetup, SETUP_IS_CHROME_WRAPPER, TRUE);
1255 nsIWebBrowserSetup_Release(wbsetup);
1256 if(NS_FAILED(nsres))
1257 ERR("SetProperty(SETUP_IS_CHROME_WRAPPER) failed: %08lx\n", nsres);
1259 ERR("Could not get nsIWebBrowserSetup interface\n");
1262 nsres = nsIWebBrowser_QueryInterface(ret->webbrowser, &IID_nsIWebNavigation,
1263 (void**)&ret->navigation);
1264 if(NS_FAILED(nsres))
1265 ERR("Could not get nsIWebNavigation interface: %08lx\n", nsres);
1267 nsres = nsIWebBrowserFocus_QueryInterface(ret->webbrowser, &IID_nsIWebBrowserFocus,
1268 (void**)&ret->focus);
1269 if(NS_FAILED(nsres))
1270 ERR("Could not get nsIWebBrowserFocus interface: %08lx\n", nsres);
1272 if(!nscontainer_class)
1273 register_nscontainer_class();
1275 ret->hwnd = CreateWindowExW(0, wszNsContainer, NULL,
1276 WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 100, 100,
1277 GetDesktopWindow(), NULL, hInst, ret);
1279 nsres = nsIBaseWindow_InitWindow(ret->window, ret->hwnd, NULL, 0, 0, 100, 100);
1280 if(NS_SUCCEEDED(nsres)) {
1281 nsres = nsIBaseWindow_Create(ret->window);
1282 if(NS_FAILED(nsres))
1283 WARN("Creating window failed: %08lx\n", nsres);
1285 nsIBaseWindow_SetVisibility(ret->window, FALSE);
1286 nsIBaseWindow_SetEnabled(ret->window, FALSE);
1288 ERR("InitWindow failed: %08lx\n", nsres);
1291 nsres = nsIWebBrowser_SetParentURIContentListener(ret->webbrowser, NSURICL(ret));
1292 if(NS_FAILED(nsres))
1293 ERR("SetParentURIContentListener failed: %08lx\n", nsres);
1298 void NSContainer_Release(NSContainer *This)
1300 TRACE("(%p)\n", This);
1302 ShowWindow(This->hwnd, SW_HIDE);
1303 SetParent(This->hwnd, NULL);
1305 nsIBaseWindow_SetVisibility(This->window, FALSE);
1306 nsIBaseWindow_Destroy(This->window);
1308 nsIWebBrowser_SetContainerWindow(This->webbrowser, NULL);
1310 nsIWebBrowser_Release(This->webbrowser);
1311 This->webbrowser = NULL;
1313 nsIWebNavigation_Release(This->navigation);
1314 This->navigation = NULL;
1316 nsIBaseWindow_Release(This->window);
1317 This->window = NULL;
1319 nsIWebBrowserFocus_Release(This->focus);
1322 if(This->content_listener) {
1323 nsIURIContentListener_Release(This->content_listener);
1324 This->content_listener = NULL;
1328 DestroyWindow(This->hwnd);
1332 nsIWebBrowserChrome_Release(NSWBCHROME(This));