2 * Copyright 2005-2007 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
33 #include "wine/debug.h"
34 #include "wine/unicode.h"
36 #include "mshtml_private.h"
37 #include "htmlevent.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
41 WINE_DECLARE_DEBUG_CHANNEL(gecko
);
43 #define NS_APPSTARTUPNOTIFIER_CONTRACTID "@mozilla.org/embedcomp/appstartup-notifier;1"
44 #define NS_WEBBROWSER_CONTRACTID "@mozilla.org/embedding/browser/nsWebBrowser;1"
45 #define NS_MEMORY_CONTRACTID "@mozilla.org/xpcom/memory-service;1"
46 #define NS_COMMANDPARAMS_CONTRACTID "@mozilla.org/embedcomp/command-params;1"
47 #define NS_HTMLSERIALIZER_CONTRACTID "@mozilla.org/layout/contentserializer;1?mimetype=text/html"
48 #define NS_EDITORCONTROLLER_CONTRACTID "@mozilla.org/editor/editorcontroller;1"
49 #define NS_PREFERENCES_CONTRACTID "@mozilla.org/preferences;1"
51 #define PR_UINT32_MAX 0xffffffff
53 #define NS_STRING_CONTAINER_INIT_DEPEND 0x0002
54 #define NS_CSTRING_CONTAINER_INIT_DEPEND 0x0002
56 static nsresult (CDECL
*NS_InitXPCOM2
)(nsIServiceManager
**,void*,void*);
57 static nsresult (CDECL
*NS_ShutdownXPCOM
)(nsIServiceManager
*);
58 static nsresult (CDECL
*NS_GetComponentRegistrar
)(nsIComponentRegistrar
**);
59 static nsresult (CDECL
*NS_StringContainerInit2
)(nsStringContainer
*,const PRUnichar
*,PRUint32
,PRUint32
);
60 static nsresult (CDECL
*NS_CStringContainerInit2
)(nsCStringContainer
*,const char*,PRUint32
,PRUint32
);
61 static nsresult (CDECL
*NS_StringContainerFinish
)(nsStringContainer
*);
62 static nsresult (CDECL
*NS_CStringContainerFinish
)(nsCStringContainer
*);
63 static nsresult (CDECL
*NS_StringSetData
)(nsAString
*,const PRUnichar
*,PRUint32
);
64 static nsresult (CDECL
*NS_CStringSetData
)(nsACString
*,const char*,PRUint32
);
65 static nsresult (CDECL
*NS_NewLocalFile
)(const nsAString
*,PRBool
,nsIFile
**);
66 static PRUint32 (CDECL
*NS_StringGetData
)(const nsAString
*,const PRUnichar
**,PRBool
*);
67 static PRUint32 (CDECL
*NS_CStringGetData
)(const nsACString
*,const char**,PRBool
*);
69 static HINSTANCE xul_handle
= NULL
;
71 static nsIServiceManager
*pServMgr
= NULL
;
72 static nsIComponentManager
*pCompMgr
= NULL
;
73 static nsIMemory
*nsmem
= NULL
;
74 static nsIFile
*profile_directory
;
76 static const WCHAR wszNsContainer
[] = {'N','s','C','o','n','t','a','i','n','e','r',0};
78 static ATOM nscontainer_class
;
79 static WCHAR gecko_path
[MAX_PATH
];
80 static unsigned gecko_path_len
;
82 static nsresult NSAPI
nsDirectoryServiceProvider_QueryInterface(nsIDirectoryServiceProvider
*iface
,
83 nsIIDRef riid
, void **result
)
85 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
86 TRACE("(IID_nsISupports %p)\n", result
);
88 }else if(IsEqualGUID(&IID_nsIDirectoryServiceProvider
, riid
)) {
89 TRACE("(IID_nsIDirectoryServiceProvider %p)\n", result
);
92 WARN("(%s %p)\n", debugstr_guid(riid
), result
);
94 return NS_NOINTERFACE
;
97 nsISupports_AddRef((nsISupports
*)*result
);
101 static nsrefcnt NSAPI
nsDirectoryServiceProvider_AddRef(nsIDirectoryServiceProvider
*iface
)
106 static nsrefcnt NSAPI
nsDirectoryServiceProvider_Release(nsIDirectoryServiceProvider
*iface
)
111 static nsresult
create_profile_directory(void)
113 static const WCHAR wine_geckoW
[] = {'\\','w','i','n','e','_','g','e','c','k','o',0};
115 WCHAR path
[MAX_PATH
+ sizeof(wine_geckoW
)/sizeof(WCHAR
)];
121 hres
= SHGetFolderPathW(NULL
, CSIDL_APPDATA
, NULL
, SHGFP_TYPE_DEFAULT
, path
);
123 ERR("SHGetFolderPath failed: %08x\n", hres
);
124 return NS_ERROR_FAILURE
;
127 strcatW(path
, wine_geckoW
);
128 nsAString_InitDepend(&str
, path
);
129 nsres
= NS_NewLocalFile(&str
, FALSE
, &profile_directory
);
130 nsAString_Finish(&str
);
131 if(NS_FAILED(nsres
)) {
132 ERR("NS_NewLocalFile failed: %08x\n", nsres
);
136 nsres
= nsIFile_Exists(profile_directory
, &exists
);
137 if(NS_FAILED(nsres
)) {
138 ERR("Exists failed: %08x\n", nsres
);
143 nsres
= nsIFile_Create(profile_directory
, 1, 0700);
145 ERR("Create failed: %08x\n", nsres
);
151 static nsresult NSAPI
nsDirectoryServiceProvider_GetFile(nsIDirectoryServiceProvider
*iface
,
152 const char *prop
, PRBool
*persistent
, nsIFile
**_retval
)
154 TRACE("(%s %p %p)\n", debugstr_a(prop
), persistent
, _retval
);
156 if(!strcmp(prop
, "ProfD")) {
157 if(!profile_directory
) {
160 nsres
= create_profile_directory();
165 return nsIFile_Clone(profile_directory
, _retval
);
168 return NS_ERROR_FAILURE
;
171 static const nsIDirectoryServiceProviderVtbl nsDirectoryServiceProviderVtbl
= {
172 nsDirectoryServiceProvider_QueryInterface
,
173 nsDirectoryServiceProvider_AddRef
,
174 nsDirectoryServiceProvider_Release
,
175 nsDirectoryServiceProvider_GetFile
178 static nsIDirectoryServiceProvider nsDirectoryServiceProvider
=
179 { &nsDirectoryServiceProviderVtbl
};
181 static LRESULT WINAPI
nsembed_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
186 static const WCHAR wszTHIS
[] = {'T','H','I','S',0};
188 if(msg
== WM_CREATE
) {
189 This
= *(NSContainer
**)lParam
;
190 SetPropW(hwnd
, wszTHIS
, This
);
192 This
= GetPropW(hwnd
, wszTHIS
);
197 TRACE("(%p)->(WM_SIZE)\n", This
);
199 nsres
= nsIBaseWindow_SetSize(This
->window
,
200 LOWORD(lParam
), HIWORD(lParam
), TRUE
);
202 WARN("SetSize failed: %08x\n", nsres
);
205 case WM_PARENTNOTIFY
:
206 TRACE("WM_PARENTNOTIFY %x\n", (unsigned)wParam
);
211 nsIWebBrowserFocus_Activate(This
->focus
);
215 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
219 static void register_nscontainer_class(void)
221 static WNDCLASSEXW wndclass
= {
225 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
229 wndclass
.hInstance
= hInst
;
230 nscontainer_class
= RegisterClassExW(&wndclass
);
233 static BOOL
install_wine_gecko(BOOL silent
)
235 PROCESS_INFORMATION pi
;
242 static const WCHAR controlW
[] = {'\\','c','o','n','t','r','o','l','.','e','x','e',0};
243 static const WCHAR argsW
[] =
244 {' ','a','p','p','w','i','z','.','c','p','l',' ','i','n','s','t','a','l','l','_','g','e','c','k','o',0};
246 len
= GetSystemDirectoryW(app
, MAX_PATH
-sizeof(controlW
)/sizeof(WCHAR
));
247 memcpy(app
+len
, controlW
, sizeof(controlW
));
249 args
= heap_alloc(len
*sizeof(WCHAR
) + sizeof(controlW
) + sizeof(argsW
));
253 memcpy(args
, app
, len
*sizeof(WCHAR
) + sizeof(controlW
));
254 memcpy(args
+ len
+ sizeof(controlW
)/sizeof(WCHAR
)-1, argsW
, sizeof(argsW
));
256 TRACE("starting %s\n", debugstr_w(args
));
258 memset(&si
, 0, sizeof(si
));
260 ret
= CreateProcessW(app
, args
, NULL
, NULL
, FALSE
, 0, NULL
, NULL
, &si
, &pi
);
263 CloseHandle(pi
.hThread
);
264 WaitForSingleObject(pi
.hProcess
, INFINITE
);
265 CloseHandle(pi
.hProcess
);
271 static void set_environment(LPCWSTR gre_path
)
273 WCHAR path_env
[MAX_PATH
], buf
[20];
274 int len
, debug_level
= 0;
276 static const WCHAR pathW
[] = {'P','A','T','H',0};
277 static const WCHAR warnW
[] = {'w','a','r','n',0};
278 static const WCHAR xpcom_debug_breakW
[] =
279 {'X','P','C','O','M','_','D','E','B','U','G','_','B','R','E','A','K',0};
280 static const WCHAR nspr_log_modulesW
[] =
281 {'N','S','P','R','_','L','O','G','_','M','O','D','U','L','E','S',0};
282 static const WCHAR debug_formatW
[] = {'a','l','l',':','%','d',0};
283 static const WCHAR moz_plugin_pathW
[] = {'M','O','Z','_','P','L','U','G','I','N','_','P','A','T','H',0};
284 static const WCHAR gecko_pluginW
[] = {'\\','g','e','c','k','o','\\','p','l','u','g','i','n',0};
286 /* We have to modify PATH as XPCOM loads other DLLs from this directory. */
287 GetEnvironmentVariableW(pathW
, path_env
, sizeof(path_env
)/sizeof(WCHAR
));
288 len
= strlenW(path_env
);
289 path_env
[len
++] = ';';
290 strcpyW(path_env
+len
, gre_path
);
291 SetEnvironmentVariableW(pathW
, path_env
);
293 SetEnvironmentVariableW(xpcom_debug_breakW
, warnW
);
297 else if(WARN_ON(gecko
))
299 else if(ERR_ON(gecko
))
302 sprintfW(buf
, debug_formatW
, debug_level
);
303 SetEnvironmentVariableW(nspr_log_modulesW
, buf
);
305 len
= GetSystemDirectoryW(path_env
, (sizeof(path_env
)-sizeof(gecko_pluginW
))/sizeof(WCHAR
)+1);
307 strcpyW(path_env
+len
, gecko_pluginW
);
308 SetEnvironmentVariableW(moz_plugin_pathW
, path_env
);
312 static BOOL
load_xul(const PRUnichar
*gre_path
)
314 static const WCHAR xul_dllW
[] = {'\\','x','u','l','.','d','l','l',0};
315 WCHAR file_name
[MAX_PATH
];
317 strcpyW(file_name
, gre_path
);
318 strcatW(file_name
, xul_dllW
);
320 TRACE("(%s)\n", debugstr_w(file_name
));
322 set_environment(gre_path
);
324 xul_handle
= LoadLibraryExW(file_name
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
);
326 WARN("Could not load XUL: %d\n", GetLastError());
330 #define NS_DLSYM(func) \
331 func = (void *)GetProcAddress(xul_handle, #func "_P"); \
333 ERR("Could not GetProcAddress(" #func ") failed\n")
335 NS_DLSYM(NS_InitXPCOM2
);
336 NS_DLSYM(NS_ShutdownXPCOM
);
337 NS_DLSYM(NS_GetComponentRegistrar
);
338 NS_DLSYM(NS_StringContainerInit2
);
339 NS_DLSYM(NS_CStringContainerInit2
);
340 NS_DLSYM(NS_StringContainerFinish
);
341 NS_DLSYM(NS_CStringContainerFinish
);
342 NS_DLSYM(NS_StringSetData
);
343 NS_DLSYM(NS_CStringSetData
);
344 NS_DLSYM(NS_NewLocalFile
);
345 NS_DLSYM(NS_StringGetData
);
346 NS_DLSYM(NS_CStringGetData
);
353 static BOOL
check_version(LPCWSTR gre_path
, const char *version_string
)
355 WCHAR file_name
[MAX_PATH
];
360 static const WCHAR wszVersion
[] = {'\\','V','E','R','S','I','O','N',0};
362 strcpyW(file_name
, gre_path
);
363 strcatW(file_name
, wszVersion
);
365 hfile
= CreateFileW(file_name
, GENERIC_READ
, FILE_SHARE_READ
, NULL
,
366 OPEN_EXISTING
, FILE_ATTRIBUTE_NORMAL
, NULL
);
367 if(hfile
== INVALID_HANDLE_VALUE
) {
368 ERR("Could not open VERSION file\n");
372 ReadFile(hfile
, version
, sizeof(version
), &read
, NULL
);
376 TRACE("%s\n", debugstr_a(version
));
378 if(strcmp(version
, version_string
)) {
379 ERR("Unexpected version %s, expected %s\n", debugstr_a(version
),
380 debugstr_a(version_string
));
387 static BOOL
load_wine_gecko_v(PRUnichar
*gre_path
, HKEY mshtml_key
,
388 const char *version
, const char *version_string
)
390 DWORD res
, type
, size
= MAX_PATH
;
391 HKEY hkey
= mshtml_key
;
393 static const WCHAR wszGeckoPath
[] =
394 {'G','e','c','k','o','P','a','t','h',0};
397 /* @@ Wine registry key: HKLM\Software\Wine\MSHTML\<version> */
398 res
= RegOpenKeyA(mshtml_key
, version
, &hkey
);
399 if(res
!= ERROR_SUCCESS
)
403 res
= RegQueryValueExW(hkey
, wszGeckoPath
, NULL
, &type
, (LPBYTE
)gre_path
, &size
);
404 if(hkey
!= mshtml_key
)
406 if(res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
409 if(!check_version(gre_path
, version_string
))
412 return load_xul(gre_path
);
415 static BOOL
load_wine_gecko(PRUnichar
*gre_path
)
421 static const WCHAR wszMshtmlKey
[] = {
422 'S','o','f','t','w','a','r','e','\\','W','i','n','e',
423 '\\','M','S','H','T','M','L',0};
425 /* @@ Wine registry key: HKLM\Software\Wine\MSHTML */
426 res
= RegOpenKeyW(HKEY_LOCAL_MACHINE
, wszMshtmlKey
, &hkey
);
427 if(res
!= ERROR_SUCCESS
)
430 ret
= load_wine_gecko_v(gre_path
, hkey
, GECKO_VERSION
, GECKO_VERSION_STRING
);
436 static void set_bool_pref(nsIPrefBranch
*pref
, const char *pref_name
, BOOL val
)
440 nsres
= nsIPrefBranch_SetBoolPref(pref
, pref_name
, val
);
442 ERR("Could not set pref %s\n", debugstr_a(pref_name
));
445 static void set_int_pref(nsIPrefBranch
*pref
, const char *pref_name
, int val
)
449 nsres
= nsIPrefBranch_SetIntPref(pref
, pref_name
, val
);
451 ERR("Could not set pref %s\n", debugstr_a(pref_name
));
454 static void set_string_pref(nsIPrefBranch
*pref
, const char *pref_name
, const char *val
)
458 nsres
= nsIPrefBranch_SetCharPref(pref
, pref_name
, val
);
460 ERR("Could not set pref %s\n", debugstr_a(pref_name
));
463 static void set_lang(nsIPrefBranch
*pref
)
466 DWORD res
, size
, type
;
469 static const WCHAR international_keyW
[] =
470 {'S','o','f','t','w','a','r','e',
471 '\\','M','i','c','r','o','s','o','f','t',
472 '\\','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r',
473 '\\','I','n','t','e','r','n','a','t','i','o','n','a','l',0};
475 res
= RegOpenKeyW(HKEY_CURRENT_USER
, international_keyW
, &hkey
);
476 if(res
!= ERROR_SUCCESS
)
479 size
= sizeof(langs
);
480 res
= RegQueryValueExA(hkey
, "AcceptLanguage", 0, &type
, (LPBYTE
)langs
, &size
);
482 if(res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
485 TRACE("Setting lang %s\n", debugstr_a(langs
));
487 set_string_pref(pref
, "intl.accept_languages", langs
);
490 static void set_proxy(nsIPrefBranch
*pref
)
495 DWORD enabled
= 0, res
, size
, type
;
498 static const WCHAR proxy_keyW
[] =
499 {'S','o','f','t','w','a','r','e',
500 '\\','M','i','c','r','o','s','o','f','t',
501 '\\','W','i','n','d','o','w','s',
502 '\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',
503 '\\','I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0};
505 res
= RegOpenKeyW(HKEY_CURRENT_USER
, proxy_keyW
, &hkey
);
506 if(res
!= ERROR_SUCCESS
)
509 size
= sizeof(enabled
);
510 res
= RegQueryValueExA(hkey
, "ProxyEnable", 0, &type
, (LPBYTE
)&enabled
, &size
);
511 if(res
!= ERROR_SUCCESS
|| type
!= REG_DWORD
|| enabled
== 0)
517 size
= sizeof(proxy
);
518 res
= RegQueryValueExA(hkey
, "ProxyServer", 0, &type
, (LPBYTE
)proxy
, &size
);
520 if(res
!= ERROR_SUCCESS
|| type
!= REG_SZ
)
523 proxy_port
= strchr(proxy
, ':');
528 proxy_port_num
= atoi(proxy_port
+ 1);
529 TRACE("Setting proxy to %s, port %d\n", debugstr_a(proxy
), proxy_port_num
);
531 set_string_pref(pref
, "network.proxy.http", proxy
);
532 set_string_pref(pref
, "network.proxy.ssl", proxy
);
534 set_int_pref(pref
, "network.proxy.type", 1);
535 set_int_pref(pref
, "network.proxy.http_port", proxy_port_num
);
536 set_int_pref(pref
, "network.proxy.ssl_port", proxy_port_num
);
539 static void set_preferences(void)
544 nsres
= nsIServiceManager_GetServiceByContractID(pServMgr
, NS_PREFERENCES_CONTRACTID
,
545 &IID_nsIPrefBranch
, (void**)&pref
);
546 if(NS_FAILED(nsres
)) {
547 ERR("Could not get preference service: %08x\n", nsres
);
553 set_bool_pref(pref
, "security.warn_entering_secure", FALSE
);
554 set_bool_pref(pref
, "security.warn_submit_insecure", FALSE
);
555 set_int_pref(pref
, "layout.spellcheckDefault", 0);
557 nsIPrefBranch_Release(pref
);
560 static BOOL
init_xpcom(const PRUnichar
*gre_path
)
562 nsIComponentRegistrar
*registrar
= NULL
;
568 nsAString_InitDepend(&path
, gre_path
);
569 nsres
= NS_NewLocalFile(&path
, FALSE
, &gre_dir
);
570 nsAString_Finish(&path
);
571 if(NS_FAILED(nsres
)) {
572 ERR("NS_NewLocalFile failed: %08x\n", nsres
);
573 FreeLibrary(xul_handle
);
577 nsres
= NS_InitXPCOM2(&pServMgr
, gre_dir
, &nsDirectoryServiceProvider
);
578 if(NS_FAILED(nsres
)) {
579 ERR("NS_InitXPCOM2 failed: %08x\n", nsres
);
580 FreeLibrary(xul_handle
);
584 strcpyW(gecko_path
, gre_path
);
585 for(ptr
= gecko_path
; *ptr
; ptr
++) {
589 gecko_path_len
= ptr
-gecko_path
;
591 nsres
= nsIServiceManager_QueryInterface(pServMgr
, &IID_nsIComponentManager
, (void**)&pCompMgr
);
593 ERR("Could not get nsIComponentManager: %08x\n", nsres
);
595 nsres
= NS_GetComponentRegistrar(®istrar
);
596 if(NS_SUCCEEDED(nsres
))
597 init_nsio(pCompMgr
, registrar
);
599 ERR("NS_GetComponentRegistrar failed: %08x\n", nsres
);
601 init_mutation(pCompMgr
);
604 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
, NS_MEMORY_CONTRACTID
,
605 NULL
, &IID_nsIMemory
, (void**)&nsmem
);
607 ERR("Could not get nsIMemory: %08x\n", nsres
);
610 register_nsservice(registrar
, pServMgr
);
611 nsIComponentRegistrar_Release(registrar
);
617 static CRITICAL_SECTION cs_load_gecko
;
618 static CRITICAL_SECTION_DEBUG cs_load_gecko_dbg
=
620 0, 0, &cs_load_gecko
,
621 { &cs_load_gecko_dbg
.ProcessLocksList
, &cs_load_gecko_dbg
.ProcessLocksList
},
622 0, 0, { (DWORD_PTR
)(__FILE__
": load_gecko") }
624 static CRITICAL_SECTION cs_load_gecko
= { &cs_load_gecko_dbg
, -1, 0, 0, 0, 0 };
626 BOOL
load_gecko(BOOL silent
)
628 PRUnichar gre_path
[MAX_PATH
];
631 static DWORD loading_thread
;
635 /* load_gecko may be called recursively */
636 if(loading_thread
== GetCurrentThreadId())
637 return pCompMgr
!= NULL
;
639 EnterCriticalSection(&cs_load_gecko
);
641 if(!loading_thread
) {
642 loading_thread
= GetCurrentThreadId();
644 if(load_wine_gecko(gre_path
)
645 || (install_wine_gecko(silent
) && load_wine_gecko(gre_path
)))
646 ret
= init_xpcom(gre_path
);
648 MESSAGE("Could not load wine-gecko. HTML rendering will be disabled.\n");
650 ret
= pCompMgr
!= NULL
;
653 LeaveCriticalSection(&cs_load_gecko
);
658 void *nsalloc(size_t size
)
660 return nsIMemory_Alloc(nsmem
, size
);
663 void nsfree(void *mem
)
665 nsIMemory_Free(nsmem
, mem
);
668 static BOOL
nsACString_Init(nsACString
*str
, const char *data
)
670 return NS_SUCCEEDED(NS_CStringContainerInit2(str
, data
, PR_UINT32_MAX
, 0));
674 * Initializes nsACString with data owned by caller.
675 * Caller must ensure that data is valid during lifetime of string object.
677 void nsACString_InitDepend(nsACString
*str
, const char *data
)
679 NS_CStringContainerInit2(str
, data
, PR_UINT32_MAX
, NS_CSTRING_CONTAINER_INIT_DEPEND
);
682 void nsACString_SetData(nsACString
*str
, const char *data
)
684 NS_CStringSetData(str
, data
, PR_UINT32_MAX
);
687 PRUint32
nsACString_GetData(const nsACString
*str
, const char **data
)
689 return NS_CStringGetData(str
, data
, NULL
);
692 void nsACString_Finish(nsACString
*str
)
694 NS_CStringContainerFinish(str
);
697 BOOL
nsAString_Init(nsAString
*str
, const PRUnichar
*data
)
699 return NS_SUCCEEDED(NS_StringContainerInit2(str
, data
, PR_UINT32_MAX
, 0));
703 * Initializes nsAString with data owned by caller.
704 * Caller must ensure that data is valid during lifetime of string object.
706 void nsAString_InitDepend(nsAString
*str
, const PRUnichar
*data
)
708 NS_StringContainerInit2(str
, data
, PR_UINT32_MAX
, NS_STRING_CONTAINER_INIT_DEPEND
);
711 void nsAString_SetData(nsAString
*str
, const PRUnichar
*data
)
713 NS_StringSetData(str
, data
, PR_UINT32_MAX
);
716 PRUint32
nsAString_GetData(const nsAString
*str
, const PRUnichar
**data
)
718 return NS_StringGetData(str
, data
, NULL
);
721 void nsAString_Finish(nsAString
*str
)
723 NS_StringContainerFinish(str
);
726 HRESULT
return_nsstr(nsresult nsres
, nsAString
*nsstr
, BSTR
*p
)
728 const PRUnichar
*str
;
730 if(NS_FAILED(nsres
)) {
731 ERR("failed: %08x\n", nsres
);
732 nsAString_Finish(nsstr
);
736 nsAString_GetData(nsstr
, &str
);
737 TRACE("ret %s\n", debugstr_w(str
));
739 *p
= SysAllocString(str
);
741 return E_OUTOFMEMORY
;
746 nsAString_Finish(nsstr
);
750 nsICommandParams
*create_nscommand_params(void)
752 nsICommandParams
*ret
= NULL
;
758 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
,
759 NS_COMMANDPARAMS_CONTRACTID
, NULL
, &IID_nsICommandParams
,
762 ERR("Could not get nsICommandParams\n");
767 nsresult
get_nsinterface(nsISupports
*iface
, REFIID riid
, void **ppv
)
769 nsIInterfaceRequestor
*iface_req
;
772 nsres
= nsISupports_QueryInterface(iface
, &IID_nsIInterfaceRequestor
, (void**)&iface_req
);
776 nsres
= nsIInterfaceRequestor_GetInterface(iface_req
, riid
, ppv
);
777 nsIInterfaceRequestor_Release(iface_req
);
782 static HRESULT
nsnode_to_nsstring_rec(nsIContentSerializer
*serializer
, nsIDOMNode
*nsnode
, nsAString
*str
)
784 nsIDOMNodeList
*node_list
= NULL
;
785 PRBool has_children
= FALSE
;
786 nsIContent
*nscontent
;
790 nsIDOMNode_HasChildNodes(nsnode
, &has_children
);
792 nsres
= nsIDOMNode_GetNodeType(nsnode
, &type
);
793 if(NS_FAILED(nsres
)) {
794 ERR("GetType failed: %08x\n", nsres
);
798 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIContent
, (void**)&nscontent
);
799 if(NS_FAILED(nsres
)) {
800 ERR("Could not get nsIDontent interface: %08x\n", nsres
);
806 nsIContentSerializer_AppendElementStart(serializer
, nscontent
, nscontent
, str
);
809 nsIContentSerializer_AppendText(serializer
, nscontent
, 0, -1, str
);
812 nsres
= nsIContentSerializer_AppendComment(serializer
, nscontent
, 0, -1, str
);
814 case DOCUMENT_NODE
: {
816 nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDocument
, (void**)&nsdoc
);
817 nsIContentSerializer_AppendDocumentStart(serializer
, nsdoc
, str
);
818 nsIDocument_Release(nsdoc
);
821 case DOCUMENT_TYPE_NODE
:
822 WARN("Ignoring DOCUMENT_TYPE_NODE\n");
824 case DOCUMENT_FRAGMENT_NODE
:
827 FIXME("Unhandled type %u\n", type
);
831 PRUint32 child_cnt
, i
;
832 nsIDOMNode
*child_node
;
834 nsIDOMNode_GetChildNodes(nsnode
, &node_list
);
835 nsIDOMNodeList_GetLength(node_list
, &child_cnt
);
837 for(i
=0; i
<child_cnt
; i
++) {
838 nsres
= nsIDOMNodeList_Item(node_list
, i
, &child_node
);
839 if(NS_SUCCEEDED(nsres
)) {
840 nsnode_to_nsstring_rec(serializer
, child_node
, str
);
841 nsIDOMNode_Release(child_node
);
843 ERR("Item failed: %08x\n", nsres
);
847 nsIDOMNodeList_Release(node_list
);
850 if(type
== ELEMENT_NODE
)
851 nsIContentSerializer_AppendElementEnd(serializer
, nscontent
, str
);
853 nsIContent_Release(nscontent
);
857 HRESULT
nsnode_to_nsstring(nsIDOMNode
*nsnode
, nsAString
*str
)
859 nsIContentSerializer
*serializer
;
863 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
,
864 NS_HTMLSERIALIZER_CONTRACTID
, NULL
, &IID_nsIContentSerializer
,
865 (void**)&serializer
);
866 if(NS_FAILED(nsres
)) {
867 ERR("Could not get nsIContentSerializer: %08x\n", nsres
);
871 nsres
= nsIContentSerializer_Init(serializer
, 0, 100, NULL
, FALSE
, FALSE
/* FIXME */);
873 ERR("Init failed: %08x\n", nsres
);
875 hres
= nsnode_to_nsstring_rec(serializer
, nsnode
, str
);
876 if(SUCCEEDED(hres
)) {
877 nsres
= nsIContentSerializer_Flush(serializer
, str
);
879 ERR("Flush failed: %08x\n", nsres
);
882 nsIContentSerializer_Release(serializer
);
886 void get_editor_controller(NSContainer
*This
)
888 nsIEditingSession
*editing_session
= NULL
;
889 nsIControllerContext
*ctrlctx
;
893 nsIEditor_Release(This
->editor
);
897 if(This
->editor_controller
) {
898 nsIController_Release(This
->editor_controller
);
899 This
->editor_controller
= NULL
;
902 nsres
= get_nsinterface((nsISupports
*)This
->webbrowser
, &IID_nsIEditingSession
,
903 (void**)&editing_session
);
904 if(NS_FAILED(nsres
)) {
905 ERR("Could not get nsIEditingSession: %08x\n", nsres
);
909 nsres
= nsIEditingSession_GetEditorForWindow(editing_session
,
910 This
->doc
->basedoc
.window
->nswindow
, &This
->editor
);
911 nsIEditingSession_Release(editing_session
);
912 if(NS_FAILED(nsres
)) {
913 ERR("Could not get editor: %08x\n", nsres
);
917 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
,
918 NS_EDITORCONTROLLER_CONTRACTID
, NULL
, &IID_nsIControllerContext
, (void**)&ctrlctx
);
919 if(NS_SUCCEEDED(nsres
)) {
920 nsres
= nsIControllerContext_SetCommandContext(ctrlctx
, (nsISupports
*)This
->editor
);
922 ERR("SetCommandContext failed: %08x\n", nsres
);
923 nsres
= nsIControllerContext_QueryInterface(ctrlctx
, &IID_nsIController
,
924 (void**)&This
->editor_controller
);
925 nsIControllerContext_Release(ctrlctx
);
927 ERR("Could not get nsIController interface: %08x\n", nsres
);
929 ERR("Could not create edit controller: %08x\n", nsres
);
933 void close_gecko(void)
940 if(profile_directory
) {
941 nsIFile_Release(profile_directory
);
942 profile_directory
= NULL
;
946 nsIComponentManager_Release(pCompMgr
);
949 nsIServiceManager_Release(pServMgr
);
952 nsIMemory_Release(nsmem
);
954 /* Gecko doesn't really support being unloaded */
955 /* if (hXPCOM) FreeLibrary(hXPCOM); */
958 BOOL
is_gecko_path(const char *path
)
963 buf
= heap_strdupAtoW(path
);
964 if(strlenW(buf
) < gecko_path_len
)
967 buf
[gecko_path_len
] = 0;
968 for(ptr
= buf
; *ptr
; ptr
++) {
973 ret
= !strcmpiW(buf
, gecko_path
);
978 struct nsWeakReference
{
979 nsIWeakReference nsIWeakReference_iface
;
983 NSContainer
*nscontainer
;
986 static inline nsWeakReference
*impl_from_nsIWeakReference(nsIWeakReference
*iface
)
988 return CONTAINING_RECORD(iface
, nsWeakReference
, nsIWeakReference_iface
);
991 static nsresult NSAPI
nsWeakReference_QueryInterface(nsIWeakReference
*iface
,
992 nsIIDRef riid
, void **result
)
994 nsWeakReference
*This
= impl_from_nsIWeakReference(iface
);
996 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
997 TRACE("(%p)->(IID_nsISupports %p)\n", This
, result
);
998 *result
= &This
->nsIWeakReference_iface
;
999 }else if(IsEqualGUID(&IID_nsIWeakReference
, riid
)) {
1000 TRACE("(%p)->(IID_nsIWeakReference %p)\n", This
, result
);
1001 *result
= &This
->nsIWeakReference_iface
;
1003 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1005 return NS_NOINTERFACE
;
1008 nsISupports_AddRef((nsISupports
*)*result
);
1012 static nsrefcnt NSAPI
nsWeakReference_AddRef(nsIWeakReference
*iface
)
1014 nsWeakReference
*This
= impl_from_nsIWeakReference(iface
);
1015 LONG ref
= InterlockedIncrement(&This
->ref
);
1017 TRACE("(%p) ref=%d\n", This
, ref
);
1022 static nsrefcnt NSAPI
nsWeakReference_Release(nsIWeakReference
*iface
)
1024 nsWeakReference
*This
= impl_from_nsIWeakReference(iface
);
1025 LONG ref
= InterlockedIncrement(&This
->ref
);
1027 TRACE("(%p) ref=%d\n", This
, ref
);
1030 assert(!This
->nscontainer
);
1037 static nsresult NSAPI
nsWeakReference_QueryReferent(nsIWeakReference
*iface
,
1038 const nsIID
*riid
, void **result
)
1040 nsWeakReference
*This
= impl_from_nsIWeakReference(iface
);
1042 if(!This
->nscontainer
)
1043 return NS_ERROR_NULL_POINTER
;
1045 return nsIWebBrowserChrome_QueryInterface(&This
->nscontainer
->nsIWebBrowserChrome_iface
, riid
, result
);
1048 static const nsIWeakReferenceVtbl nsWeakReferenceVtbl
= {
1049 nsWeakReference_QueryInterface
,
1050 nsWeakReference_AddRef
,
1051 nsWeakReference_Release
,
1052 nsWeakReference_QueryReferent
1055 /**********************************************************
1056 * nsIWebBrowserChrome interface
1059 static inline NSContainer
*impl_from_nsIWebBrowserChrome(nsIWebBrowserChrome
*iface
)
1061 return CONTAINING_RECORD(iface
, NSContainer
, nsIWebBrowserChrome_iface
);
1064 static nsresult NSAPI
nsWebBrowserChrome_QueryInterface(nsIWebBrowserChrome
*iface
,
1065 nsIIDRef riid
, void **result
)
1067 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1070 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1071 TRACE("(%p)->(IID_nsISupports, %p)\n", This
, result
);
1072 *result
= &This
->nsIWebBrowserChrome_iface
;
1073 }else if(IsEqualGUID(&IID_nsIWebBrowserChrome
, riid
)) {
1074 TRACE("(%p)->(IID_nsIWebBrowserChrome, %p)\n", This
, result
);
1075 *result
= &This
->nsIWebBrowserChrome_iface
;
1076 }else if(IsEqualGUID(&IID_nsIContextMenuListener
, riid
)) {
1077 TRACE("(%p)->(IID_nsIContextMenuListener, %p)\n", This
, result
);
1078 *result
= &This
->nsIContextMenuListener_iface
;
1079 }else if(IsEqualGUID(&IID_nsIURIContentListener
, riid
)) {
1080 TRACE("(%p)->(IID_nsIURIContentListener %p)\n", This
, result
);
1081 *result
= &This
->nsIURIContentListener_iface
;
1082 }else if(IsEqualGUID(&IID_nsIEmbeddingSiteWindow
, riid
)) {
1083 TRACE("(%p)->(IID_nsIEmbeddingSiteWindow %p)\n", This
, result
);
1084 *result
= &This
->nsIEmbeddingSiteWindow_iface
;
1085 }else if(IsEqualGUID(&IID_nsITooltipListener
, riid
)) {
1086 TRACE("(%p)->(IID_nsITooltipListener %p)\n", This
, result
);
1087 *result
= &This
->nsITooltipListener_iface
;
1088 }else if(IsEqualGUID(&IID_nsIInterfaceRequestor
, riid
)) {
1089 TRACE("(%p)->(IID_nsIInterfaceRequestor %p)\n", This
, result
);
1090 *result
= &This
->nsIInterfaceRequestor_iface
;
1091 }else if(IsEqualGUID(&IID_nsISupportsWeakReference
, riid
)) {
1092 TRACE("(%p)->(IID_nsISupportsWeakReference %p)\n", This
, result
);
1093 *result
= &This
->nsISupportsWeakReference_iface
;
1097 nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1101 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1102 return NS_NOINTERFACE
;
1105 static nsrefcnt NSAPI
nsWebBrowserChrome_AddRef(nsIWebBrowserChrome
*iface
)
1107 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1108 LONG ref
= InterlockedIncrement(&This
->ref
);
1110 TRACE("(%p) ref=%d\n", This
, ref
);
1115 static nsrefcnt NSAPI
nsWebBrowserChrome_Release(nsIWebBrowserChrome
*iface
)
1117 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1118 LONG ref
= InterlockedDecrement(&This
->ref
);
1120 TRACE("(%p) ref=%d\n", This
, ref
);
1124 nsIWebBrowserChrome_Release(&This
->parent
->nsIWebBrowserChrome_iface
);
1125 if(This
->weak_reference
) {
1126 This
->weak_reference
->nscontainer
= NULL
;
1127 nsIWeakReference_Release(&This
->weak_reference
->nsIWeakReference_iface
);
1135 static nsresult NSAPI
nsWebBrowserChrome_SetStatus(nsIWebBrowserChrome
*iface
,
1136 PRUint32 statusType
, const PRUnichar
*status
)
1138 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1139 TRACE("(%p)->(%d %s)\n", This
, statusType
, debugstr_w(status
));
1143 static nsresult NSAPI
nsWebBrowserChrome_GetWebBrowser(nsIWebBrowserChrome
*iface
,
1144 nsIWebBrowser
**aWebBrowser
)
1146 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1148 TRACE("(%p)->(%p)\n", This
, aWebBrowser
);
1151 return NS_ERROR_INVALID_ARG
;
1153 if(This
->webbrowser
)
1154 nsIWebBrowser_AddRef(This
->webbrowser
);
1155 *aWebBrowser
= This
->webbrowser
;
1159 static nsresult NSAPI
nsWebBrowserChrome_SetWebBrowser(nsIWebBrowserChrome
*iface
,
1160 nsIWebBrowser
*aWebBrowser
)
1162 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1164 TRACE("(%p)->(%p)\n", This
, aWebBrowser
);
1166 if(aWebBrowser
!= This
->webbrowser
)
1167 ERR("Wrong nsWebBrowser!\n");
1172 static nsresult NSAPI
nsWebBrowserChrome_GetChromeFlags(nsIWebBrowserChrome
*iface
,
1173 PRUint32
*aChromeFlags
)
1175 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1176 WARN("(%p)->(%p)\n", This
, aChromeFlags
);
1177 return NS_ERROR_NOT_IMPLEMENTED
;
1180 static nsresult NSAPI
nsWebBrowserChrome_SetChromeFlags(nsIWebBrowserChrome
*iface
,
1181 PRUint32 aChromeFlags
)
1183 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1184 WARN("(%p)->(%08x)\n", This
, aChromeFlags
);
1185 return NS_ERROR_NOT_IMPLEMENTED
;
1188 static nsresult NSAPI
nsWebBrowserChrome_DestroyBrowserWindow(nsIWebBrowserChrome
*iface
)
1190 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1191 TRACE("(%p)\n", This
);
1192 return NS_ERROR_NOT_IMPLEMENTED
;
1195 static nsresult NSAPI
nsWebBrowserChrome_SizeBrowserTo(nsIWebBrowserChrome
*iface
,
1196 PRInt32 aCX
, PRInt32 aCY
)
1198 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1199 WARN("(%p)->(%d %d)\n", This
, aCX
, aCY
);
1200 return NS_ERROR_NOT_IMPLEMENTED
;
1203 static nsresult NSAPI
nsWebBrowserChrome_ShowAsModal(nsIWebBrowserChrome
*iface
)
1205 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1206 WARN("(%p)\n", This
);
1207 return NS_ERROR_NOT_IMPLEMENTED
;
1210 static nsresult NSAPI
nsWebBrowserChrome_IsWindowModal(nsIWebBrowserChrome
*iface
, PRBool
*_retval
)
1212 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1213 WARN("(%p)->(%p)\n", This
, _retval
);
1214 return NS_ERROR_NOT_IMPLEMENTED
;
1217 static nsresult NSAPI
nsWebBrowserChrome_ExitModalEventLoop(nsIWebBrowserChrome
*iface
,
1220 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1221 WARN("(%p)->(%08x)\n", This
, aStatus
);
1222 return NS_ERROR_NOT_IMPLEMENTED
;
1225 static const nsIWebBrowserChromeVtbl nsWebBrowserChromeVtbl
= {
1226 nsWebBrowserChrome_QueryInterface
,
1227 nsWebBrowserChrome_AddRef
,
1228 nsWebBrowserChrome_Release
,
1229 nsWebBrowserChrome_SetStatus
,
1230 nsWebBrowserChrome_GetWebBrowser
,
1231 nsWebBrowserChrome_SetWebBrowser
,
1232 nsWebBrowserChrome_GetChromeFlags
,
1233 nsWebBrowserChrome_SetChromeFlags
,
1234 nsWebBrowserChrome_DestroyBrowserWindow
,
1235 nsWebBrowserChrome_SizeBrowserTo
,
1236 nsWebBrowserChrome_ShowAsModal
,
1237 nsWebBrowserChrome_IsWindowModal
,
1238 nsWebBrowserChrome_ExitModalEventLoop
1241 /**********************************************************
1242 * nsIContextMenuListener interface
1245 static inline NSContainer
*impl_from_nsIContextMenuListener(nsIContextMenuListener
*iface
)
1247 return CONTAINING_RECORD(iface
, NSContainer
, nsIContextMenuListener_iface
);
1250 static nsresult NSAPI
nsContextMenuListener_QueryInterface(nsIContextMenuListener
*iface
,
1251 nsIIDRef riid
, void **result
)
1253 NSContainer
*This
= impl_from_nsIContextMenuListener(iface
);
1254 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1257 static nsrefcnt NSAPI
nsContextMenuListener_AddRef(nsIContextMenuListener
*iface
)
1259 NSContainer
*This
= impl_from_nsIContextMenuListener(iface
);
1260 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1263 static nsrefcnt NSAPI
nsContextMenuListener_Release(nsIContextMenuListener
*iface
)
1265 NSContainer
*This
= impl_from_nsIContextMenuListener(iface
);
1266 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1269 static nsresult NSAPI
nsContextMenuListener_OnShowContextMenu(nsIContextMenuListener
*iface
,
1270 PRUint32 aContextFlags
, nsIDOMEvent
*aEvent
, nsIDOMNode
*aNode
)
1272 NSContainer
*This
= impl_from_nsIContextMenuListener(iface
);
1273 nsIDOMMouseEvent
*event
;
1276 DWORD dwID
= CONTEXT_MENU_DEFAULT
;
1280 TRACE("(%p)->(%08x %p %p)\n", This
, aContextFlags
, aEvent
, aNode
);
1282 fire_event(This
->doc
->basedoc
.doc_node
/* FIXME */, EVENTID_CONTEXTMENU
, TRUE
, aNode
, aEvent
);
1284 nsres
= nsIDOMEvent_QueryInterface(aEvent
, &IID_nsIDOMMouseEvent
, (void**)&event
);
1285 if(NS_FAILED(nsres
)) {
1286 ERR("Could not get nsIDOMMouseEvent interface: %08x\n", nsres
);
1290 nsIDOMMouseEvent_GetScreenX(event
, &pt
.x
);
1291 nsIDOMMouseEvent_GetScreenY(event
, &pt
.y
);
1292 nsIDOMMouseEvent_Release(event
);
1294 switch(aContextFlags
) {
1296 case CONTEXT_DOCUMENT
:
1298 dwID
= CONTEXT_MENU_DEFAULT
;
1301 case CONTEXT_IMAGE
|CONTEXT_LINK
:
1302 dwID
= CONTEXT_MENU_IMAGE
;
1305 dwID
= CONTEXT_MENU_ANCHOR
;
1308 dwID
= CONTEXT_MENU_CONTROL
;
1311 FIXME("aContextFlags=%08x\n", aContextFlags
);
1314 hres
= get_node(This
->doc
->basedoc
.doc_node
, aNode
, TRUE
, &node
);
1316 return NS_ERROR_FAILURE
;
1318 show_context_menu(This
->doc
, dwID
, &pt
, (IDispatch
*)&node
->IHTMLDOMNode_iface
);
1322 static const nsIContextMenuListenerVtbl nsContextMenuListenerVtbl
= {
1323 nsContextMenuListener_QueryInterface
,
1324 nsContextMenuListener_AddRef
,
1325 nsContextMenuListener_Release
,
1326 nsContextMenuListener_OnShowContextMenu
1329 /**********************************************************
1330 * nsIURIContentListener interface
1333 static inline NSContainer
*impl_from_nsIURIContentListener(nsIURIContentListener
*iface
)
1335 return CONTAINING_RECORD(iface
, NSContainer
, nsIURIContentListener_iface
);
1338 static nsresult NSAPI
nsURIContentListener_QueryInterface(nsIURIContentListener
*iface
,
1339 nsIIDRef riid
, void **result
)
1341 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1342 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1345 static nsrefcnt NSAPI
nsURIContentListener_AddRef(nsIURIContentListener
*iface
)
1347 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1348 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1351 static nsrefcnt NSAPI
nsURIContentListener_Release(nsIURIContentListener
*iface
)
1353 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1354 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1357 static nsresult NSAPI
nsURIContentListener_OnStartURIOpen(nsIURIContentListener
*iface
,
1358 nsIURI
*aURI
, PRBool
*_retval
)
1360 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1361 nsACString spec_str
;
1365 nsACString_Init(&spec_str
, NULL
);
1366 nsIURI_GetSpec(aURI
, &spec_str
);
1367 nsACString_GetData(&spec_str
, &spec
);
1369 TRACE("(%p)->(%p(%s) %p)\n", This
, aURI
, debugstr_a(spec
), _retval
);
1371 nsACString_Finish(&spec_str
);
1373 nsres
= on_start_uri_open(This
, aURI
, _retval
);
1374 if(NS_FAILED(nsres
))
1377 return !*_retval
&& This
->content_listener
1378 ? nsIURIContentListener_OnStartURIOpen(This
->content_listener
, aURI
, _retval
)
1382 static nsresult NSAPI
nsURIContentListener_DoContent(nsIURIContentListener
*iface
,
1383 const char *aContentType
, PRBool aIsContentPreferred
, nsIRequest
*aRequest
,
1384 nsIStreamListener
**aContentHandler
, PRBool
*_retval
)
1386 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1388 TRACE("(%p)->(%s %x %p %p %p)\n", This
, debugstr_a(aContentType
), aIsContentPreferred
,
1389 aRequest
, aContentHandler
, _retval
);
1391 return This
->content_listener
1392 ? nsIURIContentListener_DoContent(This
->content_listener
, aContentType
,
1393 aIsContentPreferred
, aRequest
, aContentHandler
, _retval
)
1394 : NS_ERROR_NOT_IMPLEMENTED
;
1397 static nsresult NSAPI
nsURIContentListener_IsPreferred(nsIURIContentListener
*iface
,
1398 const char *aContentType
, char **aDesiredContentType
, PRBool
*_retval
)
1400 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1402 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_a(aContentType
), aDesiredContentType
, _retval
);
1404 /* FIXME: Should we do something here? */
1407 return This
->content_listener
1408 ? nsIURIContentListener_IsPreferred(This
->content_listener
, aContentType
,
1409 aDesiredContentType
, _retval
)
1413 static nsresult NSAPI
nsURIContentListener_CanHandleContent(nsIURIContentListener
*iface
,
1414 const char *aContentType
, PRBool aIsContentPreferred
, char **aDesiredContentType
,
1417 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1419 TRACE("(%p)->(%s %x %p %p)\n", This
, debugstr_a(aContentType
), aIsContentPreferred
,
1420 aDesiredContentType
, _retval
);
1422 return This
->content_listener
1423 ? nsIURIContentListener_CanHandleContent(This
->content_listener
, aContentType
,
1424 aIsContentPreferred
, aDesiredContentType
, _retval
)
1425 : NS_ERROR_NOT_IMPLEMENTED
;
1428 static nsresult NSAPI
nsURIContentListener_GetLoadCookie(nsIURIContentListener
*iface
,
1429 nsISupports
**aLoadCookie
)
1431 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1433 WARN("(%p)->(%p)\n", This
, aLoadCookie
);
1435 return This
->content_listener
1436 ? nsIURIContentListener_GetLoadCookie(This
->content_listener
, aLoadCookie
)
1437 : NS_ERROR_NOT_IMPLEMENTED
;
1440 static nsresult NSAPI
nsURIContentListener_SetLoadCookie(nsIURIContentListener
*iface
,
1441 nsISupports
*aLoadCookie
)
1443 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1445 WARN("(%p)->(%p)\n", This
, aLoadCookie
);
1447 return This
->content_listener
1448 ? nsIURIContentListener_SetLoadCookie(This
->content_listener
, aLoadCookie
)
1449 : NS_ERROR_NOT_IMPLEMENTED
;
1452 static nsresult NSAPI
nsURIContentListener_GetParentContentListener(nsIURIContentListener
*iface
,
1453 nsIURIContentListener
**aParentContentListener
)
1455 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1457 TRACE("(%p)->(%p)\n", This
, aParentContentListener
);
1459 if(This
->content_listener
)
1460 nsIURIContentListener_AddRef(This
->content_listener
);
1462 *aParentContentListener
= This
->content_listener
;
1466 static nsresult NSAPI
nsURIContentListener_SetParentContentListener(nsIURIContentListener
*iface
,
1467 nsIURIContentListener
*aParentContentListener
)
1469 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1471 TRACE("(%p)->(%p)\n", This
, aParentContentListener
);
1473 if(aParentContentListener
== &This
->nsIURIContentListener_iface
)
1476 if(This
->content_listener
)
1477 nsIURIContentListener_Release(This
->content_listener
);
1479 This
->content_listener
= aParentContentListener
;
1480 if(This
->content_listener
)
1481 nsIURIContentListener_AddRef(This
->content_listener
);
1486 static const nsIURIContentListenerVtbl nsURIContentListenerVtbl
= {
1487 nsURIContentListener_QueryInterface
,
1488 nsURIContentListener_AddRef
,
1489 nsURIContentListener_Release
,
1490 nsURIContentListener_OnStartURIOpen
,
1491 nsURIContentListener_DoContent
,
1492 nsURIContentListener_IsPreferred
,
1493 nsURIContentListener_CanHandleContent
,
1494 nsURIContentListener_GetLoadCookie
,
1495 nsURIContentListener_SetLoadCookie
,
1496 nsURIContentListener_GetParentContentListener
,
1497 nsURIContentListener_SetParentContentListener
1500 /**********************************************************
1501 * nsIEmbeddinSiteWindow interface
1504 static inline NSContainer
*impl_from_nsIEmbeddingSiteWindow(nsIEmbeddingSiteWindow
*iface
)
1506 return CONTAINING_RECORD(iface
, NSContainer
, nsIEmbeddingSiteWindow_iface
);
1509 static nsresult NSAPI
nsEmbeddingSiteWindow_QueryInterface(nsIEmbeddingSiteWindow
*iface
,
1510 nsIIDRef riid
, void **result
)
1512 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1513 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1516 static nsrefcnt NSAPI
nsEmbeddingSiteWindow_AddRef(nsIEmbeddingSiteWindow
*iface
)
1518 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1519 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1522 static nsrefcnt NSAPI
nsEmbeddingSiteWindow_Release(nsIEmbeddingSiteWindow
*iface
)
1524 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1525 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1528 static nsresult NSAPI
nsEmbeddingSiteWindow_SetDimensions(nsIEmbeddingSiteWindow
*iface
,
1529 PRUint32 flags
, PRInt32 x
, PRInt32 y
, PRInt32 cx
, PRInt32 cy
)
1531 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1532 WARN("(%p)->(%08x %d %d %d %d)\n", This
, flags
, x
, y
, cx
, cy
);
1533 return NS_ERROR_NOT_IMPLEMENTED
;
1536 static nsresult NSAPI
nsEmbeddingSiteWindow_GetDimensions(nsIEmbeddingSiteWindow
*iface
,
1537 PRUint32 flags
, PRInt32
*x
, PRInt32
*y
, PRInt32
*cx
, PRInt32
*cy
)
1539 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1540 WARN("(%p)->(%08x %p %p %p %p)\n", This
, flags
, x
, y
, cx
, cy
);
1541 return NS_ERROR_NOT_IMPLEMENTED
;
1544 static nsresult NSAPI
nsEmbeddingSiteWindow_SetFocus(nsIEmbeddingSiteWindow
*iface
)
1546 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1548 TRACE("(%p)\n", This
);
1550 return nsIBaseWindow_SetFocus(This
->window
);
1553 static nsresult NSAPI
nsEmbeddingSiteWindow_GetVisibility(nsIEmbeddingSiteWindow
*iface
,
1554 PRBool
*aVisibility
)
1556 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1558 TRACE("(%p)->(%p)\n", This
, aVisibility
);
1560 *aVisibility
= This
->doc
&& This
->doc
->hwnd
&& IsWindowVisible(This
->doc
->hwnd
);
1564 static nsresult NSAPI
nsEmbeddingSiteWindow_SetVisibility(nsIEmbeddingSiteWindow
*iface
,
1567 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1569 TRACE("(%p)->(%x)\n", This
, aVisibility
);
1574 static nsresult NSAPI
nsEmbeddingSiteWindow_GetTitle(nsIEmbeddingSiteWindow
*iface
,
1577 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1578 WARN("(%p)->(%p)\n", This
, aTitle
);
1579 return NS_ERROR_NOT_IMPLEMENTED
;
1582 static nsresult NSAPI
nsEmbeddingSiteWindow_SetTitle(nsIEmbeddingSiteWindow
*iface
,
1583 const PRUnichar
*aTitle
)
1585 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1586 WARN("(%p)->(%s)\n", This
, debugstr_w(aTitle
));
1587 return NS_ERROR_NOT_IMPLEMENTED
;
1590 static nsresult NSAPI
nsEmbeddingSiteWindow_GetSiteWindow(nsIEmbeddingSiteWindow
*iface
,
1593 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1595 TRACE("(%p)->(%p)\n", This
, aSiteWindow
);
1597 *aSiteWindow
= This
->hwnd
;
1601 static const nsIEmbeddingSiteWindowVtbl nsEmbeddingSiteWindowVtbl
= {
1602 nsEmbeddingSiteWindow_QueryInterface
,
1603 nsEmbeddingSiteWindow_AddRef
,
1604 nsEmbeddingSiteWindow_Release
,
1605 nsEmbeddingSiteWindow_SetDimensions
,
1606 nsEmbeddingSiteWindow_GetDimensions
,
1607 nsEmbeddingSiteWindow_SetFocus
,
1608 nsEmbeddingSiteWindow_GetVisibility
,
1609 nsEmbeddingSiteWindow_SetVisibility
,
1610 nsEmbeddingSiteWindow_GetTitle
,
1611 nsEmbeddingSiteWindow_SetTitle
,
1612 nsEmbeddingSiteWindow_GetSiteWindow
1615 static inline NSContainer
*impl_from_nsITooltipListener(nsITooltipListener
*iface
)
1617 return CONTAINING_RECORD(iface
, NSContainer
, nsITooltipListener_iface
);
1620 static nsresult NSAPI
nsTooltipListener_QueryInterface(nsITooltipListener
*iface
, nsIIDRef riid
,
1623 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1624 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1627 static nsrefcnt NSAPI
nsTooltipListener_AddRef(nsITooltipListener
*iface
)
1629 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1630 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1633 static nsrefcnt NSAPI
nsTooltipListener_Release(nsITooltipListener
*iface
)
1635 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1636 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1639 static nsresult NSAPI
nsTooltipListener_OnShowTooltip(nsITooltipListener
*iface
,
1640 PRInt32 aXCoord
, PRInt32 aYCoord
, const PRUnichar
*aTipText
)
1642 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1645 show_tooltip(This
->doc
, aXCoord
, aYCoord
, aTipText
);
1650 static nsresult NSAPI
nsTooltipListener_OnHideTooltip(nsITooltipListener
*iface
)
1652 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1655 hide_tooltip(This
->doc
);
1660 static const nsITooltipListenerVtbl nsTooltipListenerVtbl
= {
1661 nsTooltipListener_QueryInterface
,
1662 nsTooltipListener_AddRef
,
1663 nsTooltipListener_Release
,
1664 nsTooltipListener_OnShowTooltip
,
1665 nsTooltipListener_OnHideTooltip
1668 static inline NSContainer
*impl_from_nsIInterfaceRequestor(nsIInterfaceRequestor
*iface
)
1670 return CONTAINING_RECORD(iface
, NSContainer
, nsIInterfaceRequestor_iface
);
1673 static nsresult NSAPI
nsInterfaceRequestor_QueryInterface(nsIInterfaceRequestor
*iface
,
1674 nsIIDRef riid
, void **result
)
1676 NSContainer
*This
= impl_from_nsIInterfaceRequestor(iface
);
1677 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1680 static nsrefcnt NSAPI
nsInterfaceRequestor_AddRef(nsIInterfaceRequestor
*iface
)
1682 NSContainer
*This
= impl_from_nsIInterfaceRequestor(iface
);
1683 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1686 static nsrefcnt NSAPI
nsInterfaceRequestor_Release(nsIInterfaceRequestor
*iface
)
1688 NSContainer
*This
= impl_from_nsIInterfaceRequestor(iface
);
1689 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1692 static nsresult NSAPI
nsInterfaceRequestor_GetInterface(nsIInterfaceRequestor
*iface
,
1693 nsIIDRef riid
, void **result
)
1695 NSContainer
*This
= impl_from_nsIInterfaceRequestor(iface
);
1697 if(IsEqualGUID(&IID_nsIDOMWindow
, riid
)) {
1698 TRACE("(%p)->(IID_nsIDOMWindow %p)\n", This
, result
);
1699 return nsIWebBrowser_GetContentDOMWindow(This
->webbrowser
, (nsIDOMWindow
**)result
);
1702 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1705 static const nsIInterfaceRequestorVtbl nsInterfaceRequestorVtbl
= {
1706 nsInterfaceRequestor_QueryInterface
,
1707 nsInterfaceRequestor_AddRef
,
1708 nsInterfaceRequestor_Release
,
1709 nsInterfaceRequestor_GetInterface
1712 static inline NSContainer
*impl_from_nsISupportsWeakReference(nsISupportsWeakReference
*iface
)
1714 return CONTAINING_RECORD(iface
, NSContainer
, nsISupportsWeakReference_iface
);
1717 static nsresult NSAPI
nsSupportsWeakReference_QueryInterface(nsISupportsWeakReference
*iface
,
1718 nsIIDRef riid
, void **result
)
1720 NSContainer
*This
= impl_from_nsISupportsWeakReference(iface
);
1721 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1724 static nsrefcnt NSAPI
nsSupportsWeakReference_AddRef(nsISupportsWeakReference
*iface
)
1726 NSContainer
*This
= impl_from_nsISupportsWeakReference(iface
);
1727 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1730 static nsrefcnt NSAPI
nsSupportsWeakReference_Release(nsISupportsWeakReference
*iface
)
1732 NSContainer
*This
= impl_from_nsISupportsWeakReference(iface
);
1733 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1736 static nsresult NSAPI
nsSupportsWeakReference_GetWeakReference(nsISupportsWeakReference
*iface
,
1737 nsIWeakReference
**_retval
)
1739 NSContainer
*This
= impl_from_nsISupportsWeakReference(iface
);
1741 TRACE("(%p)->(%p)\n", This
, _retval
);
1743 if(!This
->weak_reference
) {
1744 This
->weak_reference
= heap_alloc(sizeof(nsWeakReference
));
1745 if(!This
->weak_reference
)
1746 return NS_ERROR_OUT_OF_MEMORY
;
1748 This
->weak_reference
->nsIWeakReference_iface
.lpVtbl
= &nsWeakReferenceVtbl
;
1749 This
->weak_reference
->ref
= 1;
1750 This
->weak_reference
->nscontainer
= This
;
1753 *_retval
= &This
->weak_reference
->nsIWeakReference_iface
;
1754 nsIWeakReference_AddRef(*_retval
);
1758 static const nsISupportsWeakReferenceVtbl nsSupportsWeakReferenceVtbl
= {
1759 nsSupportsWeakReference_QueryInterface
,
1760 nsSupportsWeakReference_AddRef
,
1761 nsSupportsWeakReference_Release
,
1762 nsSupportsWeakReference_GetWeakReference
1765 nsresult
create_chrome_window(nsIWebBrowserChrome
*parent
, nsIWebBrowserChrome
**ret
)
1767 NSContainer
*new_container
;
1769 if(parent
->lpVtbl
!= &nsWebBrowserChromeVtbl
)
1770 return NS_ERROR_UNEXPECTED
;
1772 new_container
= NSContainer_Create(NULL
, impl_from_nsIWebBrowserChrome(parent
));
1773 *ret
= &new_container
->nsIWebBrowserChrome_iface
;
1777 NSContainer
*NSContainer_Create(HTMLDocumentObj
*doc
, NSContainer
*parent
)
1779 nsIWebBrowserSetup
*wbsetup
;
1780 nsIScrollable
*scrollable
;
1784 if(!load_gecko(TRUE
))
1787 ret
= heap_alloc_zero(sizeof(NSContainer
));
1789 ret
->nsIWebBrowserChrome_iface
.lpVtbl
= &nsWebBrowserChromeVtbl
;
1790 ret
->nsIContextMenuListener_iface
.lpVtbl
= &nsContextMenuListenerVtbl
;
1791 ret
->nsIURIContentListener_iface
.lpVtbl
= &nsURIContentListenerVtbl
;
1792 ret
->nsIEmbeddingSiteWindow_iface
.lpVtbl
= &nsEmbeddingSiteWindowVtbl
;
1793 ret
->nsITooltipListener_iface
.lpVtbl
= &nsTooltipListenerVtbl
;
1794 ret
->nsIInterfaceRequestor_iface
.lpVtbl
= &nsInterfaceRequestorVtbl
;
1795 ret
->nsISupportsWeakReference_iface
.lpVtbl
= &nsSupportsWeakReferenceVtbl
;
1800 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
, NS_WEBBROWSER_CONTRACTID
,
1801 NULL
, &IID_nsIWebBrowser
, (void**)&ret
->webbrowser
);
1802 if(NS_FAILED(nsres
)) {
1803 ERR("Creating WebBrowser failed: %08x\n", nsres
);
1809 nsIWebBrowserChrome_AddRef(&parent
->nsIWebBrowserChrome_iface
);
1810 ret
->parent
= parent
;
1812 nsres
= nsIWebBrowser_SetContainerWindow(ret
->webbrowser
, &ret
->nsIWebBrowserChrome_iface
);
1813 if(NS_FAILED(nsres
))
1814 ERR("SetContainerWindow failed: %08x\n", nsres
);
1816 nsres
= nsIWebBrowser_QueryInterface(ret
->webbrowser
, &IID_nsIBaseWindow
,
1817 (void**)&ret
->window
);
1818 if(NS_FAILED(nsres
))
1819 ERR("Could not get nsIBaseWindow interface: %08x\n", nsres
);
1821 nsres
= nsIWebBrowser_QueryInterface(ret
->webbrowser
, &IID_nsIWebBrowserSetup
,
1823 if(NS_SUCCEEDED(nsres
)) {
1824 nsres
= nsIWebBrowserSetup_SetProperty(wbsetup
, SETUP_IS_CHROME_WRAPPER
, FALSE
);
1825 nsIWebBrowserSetup_Release(wbsetup
);
1826 if(NS_FAILED(nsres
))
1827 ERR("SetProperty(SETUP_IS_CHROME_WRAPPER) failed: %08x\n", nsres
);
1829 ERR("Could not get nsIWebBrowserSetup interface\n");
1832 nsres
= nsIWebBrowser_QueryInterface(ret
->webbrowser
, &IID_nsIWebNavigation
,
1833 (void**)&ret
->navigation
);
1834 if(NS_FAILED(nsres
))
1835 ERR("Could not get nsIWebNavigation interface: %08x\n", nsres
);
1837 nsres
= nsIWebBrowserFocus_QueryInterface(ret
->webbrowser
, &IID_nsIWebBrowserFocus
,
1838 (void**)&ret
->focus
);
1839 if(NS_FAILED(nsres
))
1840 ERR("Could not get nsIWebBrowserFocus interface: %08x\n", nsres
);
1842 if(!nscontainer_class
)
1843 register_nscontainer_class();
1845 ret
->hwnd
= CreateWindowExW(0, wszNsContainer
, NULL
,
1846 WS_CHILD
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
, 0, 0, 100, 100,
1847 GetDesktopWindow(), NULL
, hInst
, ret
);
1849 nsres
= nsIBaseWindow_InitWindow(ret
->window
, ret
->hwnd
, NULL
, 0, 0, 100, 100);
1850 if(NS_SUCCEEDED(nsres
)) {
1851 nsres
= nsIBaseWindow_Create(ret
->window
);
1852 if(NS_FAILED(nsres
))
1853 WARN("Creating window failed: %08x\n", nsres
);
1855 nsIBaseWindow_SetVisibility(ret
->window
, FALSE
);
1856 nsIBaseWindow_SetEnabled(ret
->window
, FALSE
);
1858 ERR("InitWindow failed: %08x\n", nsres
);
1861 nsres
= nsIWebBrowser_SetParentURIContentListener(ret
->webbrowser
,
1862 &ret
->nsIURIContentListener_iface
);
1863 if(NS_FAILED(nsres
))
1864 ERR("SetParentURIContentListener failed: %08x\n", nsres
);
1866 nsres
= nsIWebBrowser_QueryInterface(ret
->webbrowser
, &IID_nsIScrollable
, (void**)&scrollable
);
1867 if(NS_SUCCEEDED(nsres
)) {
1868 nsres
= nsIScrollable_SetDefaultScrollbarPreferences(scrollable
,
1869 ScrollOrientation_Y
, Scrollbar_Always
);
1870 if(NS_FAILED(nsres
))
1871 ERR("Could not set default Y scrollbar prefs: %08x\n", nsres
);
1873 nsres
= nsIScrollable_SetDefaultScrollbarPreferences(scrollable
,
1874 ScrollOrientation_X
, Scrollbar_Auto
);
1875 if(NS_FAILED(nsres
))
1876 ERR("Could not set default X scrollbar prefs: %08x\n", nsres
);
1878 nsIScrollable_Release(scrollable
);
1880 ERR("Could not get nsIScrollable: %08x\n", nsres
);
1886 void NSContainer_Release(NSContainer
*This
)
1888 TRACE("(%p)\n", This
);
1892 ShowWindow(This
->hwnd
, SW_HIDE
);
1893 SetParent(This
->hwnd
, NULL
);
1895 nsIBaseWindow_SetVisibility(This
->window
, FALSE
);
1896 nsIBaseWindow_Destroy(This
->window
);
1898 nsIWebBrowser_SetContainerWindow(This
->webbrowser
, NULL
);
1900 nsIWebBrowser_Release(This
->webbrowser
);
1901 This
->webbrowser
= NULL
;
1903 nsIWebNavigation_Release(This
->navigation
);
1904 This
->navigation
= NULL
;
1906 nsIBaseWindow_Release(This
->window
);
1907 This
->window
= NULL
;
1909 nsIWebBrowserFocus_Release(This
->focus
);
1912 if(This
->editor_controller
) {
1913 nsIController_Release(This
->editor_controller
);
1914 This
->editor_controller
= NULL
;
1918 nsIEditor_Release(This
->editor
);
1919 This
->editor
= NULL
;
1922 if(This
->content_listener
) {
1923 nsIURIContentListener_Release(This
->content_listener
);
1924 This
->content_listener
= NULL
;
1928 DestroyWindow(This
->hwnd
);
1932 nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);