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
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 #include "mshtml_private.h"
36 #include "htmlevent.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
39 WINE_DECLARE_DEBUG_CHANNEL(gecko
);
41 #define NS_APPSTARTUPNOTIFIER_CONTRACTID "@mozilla.org/embedcomp/appstartup-notifier;1"
42 #define NS_WEBBROWSER_CONTRACTID "@mozilla.org/embedding/browser/nsWebBrowser;1"
43 #define NS_MEMORY_CONTRACTID "@mozilla.org/xpcom/memory-service;1"
44 #define NS_COMMANDPARAMS_CONTRACTID "@mozilla.org/embedcomp/command-params;1"
45 #define NS_HTMLSERIALIZER_CONTRACTID "@mozilla.org/layout/contentserializer;1?mimetype=text/html"
46 #define NS_EDITORCONTROLLER_CONTRACTID "@mozilla.org/editor/editorcontroller;1"
47 #define NS_PREFERENCES_CONTRACTID "@mozilla.org/preferences;1"
49 #define APPSTARTUP_TOPIC "app-startup"
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 hXPCOM
= 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_xpcom(const PRUnichar
*gre_path
)
314 static const WCHAR strXPCOM
[] = {'\\','x','p','c','o','m','.','d','l','l',0};
315 WCHAR file_name
[MAX_PATH
];
317 strcpyW(file_name
, gre_path
);
318 strcatW(file_name
, strXPCOM
);
320 TRACE("(%s)\n", debugstr_w(file_name
));
322 set_environment(gre_path
);
324 hXPCOM
= LoadLibraryExW(file_name
, 0, LOAD_WITH_ALTERED_SEARCH_PATH
);
326 WARN("Could not load XPCOM: %d\n", GetLastError());
330 #define NS_DLSYM(func) \
331 func = (void *)GetProcAddress(hXPCOM, #func); \
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_xpcom(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
)
563 nsIObserver
*pStartNotif
;
564 nsIComponentRegistrar
*registrar
= NULL
;
569 nsAString_InitDepend(&path
, gre_path
);
570 nsres
= NS_NewLocalFile(&path
, FALSE
, &gre_dir
);
571 nsAString_Finish(&path
);
572 if(NS_FAILED(nsres
)) {
573 ERR("NS_NewLocalFile failed: %08x\n", nsres
);
578 nsres
= NS_InitXPCOM2(&pServMgr
, gre_dir
, &nsDirectoryServiceProvider
);
579 if(NS_FAILED(nsres
)) {
580 ERR("NS_InitXPCOM2 failed: %08x\n", nsres
);
585 strcpyW(gecko_path
, gre_path
);
586 for(ptr
= gecko_path
; *ptr
; ptr
++) {
590 gecko_path_len
= ptr
-gecko_path
;
592 nsres
= nsIServiceManager_QueryInterface(pServMgr
, &IID_nsIComponentManager
, (void**)&pCompMgr
);
594 ERR("Could not get nsIComponentManager: %08x\n", nsres
);
596 nsres
= NS_GetComponentRegistrar(®istrar
);
597 if(NS_SUCCEEDED(nsres
))
598 init_nsio(pCompMgr
, registrar
);
600 ERR("NS_GetComponentRegistrar failed: %08x\n", nsres
);
602 init_mutation(pCompMgr
);
604 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
, NS_APPSTARTUPNOTIFIER_CONTRACTID
,
605 NULL
, &IID_nsIObserver
, (void**)&pStartNotif
);
606 if(NS_SUCCEEDED(nsres
)) {
607 nsres
= nsIObserver_Observe(pStartNotif
, NULL
, APPSTARTUP_TOPIC
, NULL
);
609 ERR("Observe failed: %08x\n", nsres
);
611 nsIObserver_Release(pStartNotif
);
613 ERR("could not get appstartup-notifier: %08x\n", nsres
);
618 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
, NS_MEMORY_CONTRACTID
,
619 NULL
, &IID_nsIMemory
, (void**)&nsmem
);
621 ERR("Could not get nsIMemory: %08x\n", nsres
);
624 register_nsservice(registrar
, pServMgr
);
625 nsIComponentRegistrar_Release(registrar
);
631 static CRITICAL_SECTION cs_load_gecko
;
632 static CRITICAL_SECTION_DEBUG cs_load_gecko_dbg
=
634 0, 0, &cs_load_gecko
,
635 { &cs_load_gecko_dbg
.ProcessLocksList
, &cs_load_gecko_dbg
.ProcessLocksList
},
636 0, 0, { (DWORD_PTR
)(__FILE__
": load_gecko") }
638 static CRITICAL_SECTION cs_load_gecko
= { &cs_load_gecko_dbg
, -1, 0, 0, 0, 0 };
640 BOOL
load_gecko(BOOL silent
)
642 PRUnichar gre_path
[MAX_PATH
];
645 static DWORD loading_thread
;
649 /* load_gecko may be called recursively */
650 if(loading_thread
== GetCurrentThreadId())
651 return pCompMgr
!= NULL
;
653 EnterCriticalSection(&cs_load_gecko
);
655 if(!loading_thread
) {
656 loading_thread
= GetCurrentThreadId();
658 if(load_wine_gecko(gre_path
)
659 || (install_wine_gecko(silent
) && load_wine_gecko(gre_path
)))
660 ret
= init_xpcom(gre_path
);
662 MESSAGE("Could not load wine-gecko. HTML rendering will be disabled.\n");
664 ret
= pCompMgr
!= NULL
;
667 LeaveCriticalSection(&cs_load_gecko
);
672 void *nsalloc(size_t size
)
674 return nsIMemory_Alloc(nsmem
, size
);
677 void nsfree(void *mem
)
679 nsIMemory_Free(nsmem
, mem
);
682 static BOOL
nsACString_Init(nsACString
*str
, const char *data
)
684 return NS_SUCCEEDED(NS_CStringContainerInit2(str
, data
, PR_UINT32_MAX
, 0));
688 * Initializes nsACString with data owned by caller.
689 * Caller must ensure that data is valid during lifetime of string object.
691 void nsACString_InitDepend(nsACString
*str
, const char *data
)
693 NS_CStringContainerInit2(str
, data
, PR_UINT32_MAX
, NS_CSTRING_CONTAINER_INIT_DEPEND
);
696 void nsACString_SetData(nsACString
*str
, const char *data
)
698 NS_CStringSetData(str
, data
, PR_UINT32_MAX
);
701 PRUint32
nsACString_GetData(const nsACString
*str
, const char **data
)
703 return NS_CStringGetData(str
, data
, NULL
);
706 void nsACString_Finish(nsACString
*str
)
708 NS_CStringContainerFinish(str
);
711 BOOL
nsAString_Init(nsAString
*str
, const PRUnichar
*data
)
713 return NS_SUCCEEDED(NS_StringContainerInit2(str
, data
, PR_UINT32_MAX
, 0));
717 * Initializes nsAString with data owned by caller.
718 * Caller must ensure that data is valid during lifetime of string object.
720 void nsAString_InitDepend(nsAString
*str
, const PRUnichar
*data
)
722 NS_StringContainerInit2(str
, data
, PR_UINT32_MAX
, NS_STRING_CONTAINER_INIT_DEPEND
);
725 void nsAString_SetData(nsAString
*str
, const PRUnichar
*data
)
727 NS_StringSetData(str
, data
, PR_UINT32_MAX
);
730 PRUint32
nsAString_GetData(const nsAString
*str
, const PRUnichar
**data
)
732 return NS_StringGetData(str
, data
, NULL
);
735 void nsAString_Finish(nsAString
*str
)
737 NS_StringContainerFinish(str
);
740 HRESULT
return_nsstr(nsresult nsres
, nsAString
*nsstr
, BSTR
*p
)
742 const PRUnichar
*str
;
744 if(NS_FAILED(nsres
)) {
745 ERR("failed: %08x\n", nsres
);
746 nsAString_Finish(nsstr
);
750 nsAString_GetData(nsstr
, &str
);
751 TRACE("ret %s\n", debugstr_w(str
));
753 *p
= SysAllocString(str
);
755 return E_OUTOFMEMORY
;
760 nsAString_Finish(nsstr
);
764 nsICommandParams
*create_nscommand_params(void)
766 nsICommandParams
*ret
= NULL
;
772 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
,
773 NS_COMMANDPARAMS_CONTRACTID
, NULL
, &IID_nsICommandParams
,
776 ERR("Could not get nsICommandParams\n");
781 nsresult
get_nsinterface(nsISupports
*iface
, REFIID riid
, void **ppv
)
783 nsIInterfaceRequestor
*iface_req
;
786 nsres
= nsISupports_QueryInterface(iface
, &IID_nsIInterfaceRequestor
, (void**)&iface_req
);
790 nsres
= nsIInterfaceRequestor_GetInterface(iface_req
, riid
, ppv
);
791 nsIInterfaceRequestor_Release(iface_req
);
796 static HRESULT
nsnode_to_nsstring_rec(nsIContentSerializer
*serializer
, nsIDOMNode
*nsnode
, nsAString
*str
)
798 nsIDOMNodeList
*node_list
= NULL
;
799 PRBool has_children
= FALSE
;
800 nsIContent
*nscontent
;
804 nsIDOMNode_HasChildNodes(nsnode
, &has_children
);
806 nsres
= nsIDOMNode_GetNodeType(nsnode
, &type
);
807 if(NS_FAILED(nsres
)) {
808 ERR("GetType failed: %08x\n", nsres
);
812 nsres
= nsIDOMNode_QueryInterface(nsnode
, &IID_nsIContent
, (void**)&nscontent
);
813 if(NS_FAILED(nsres
)) {
814 ERR("Could not get nsIDontent interface: %08x\n", nsres
);
820 nsIContentSerializer_AppendElementStart(serializer
, nscontent
, nscontent
, str
);
823 nsIContentSerializer_AppendText(serializer
, nscontent
, 0, -1, str
);
826 nsres
= nsIContentSerializer_AppendComment(serializer
, nscontent
, 0, -1, str
);
828 case DOCUMENT_NODE
: {
830 nsIDOMNode_QueryInterface(nsnode
, &IID_nsIDocument
, (void**)&nsdoc
);
831 nsIContentSerializer_AppendDocumentStart(serializer
, nsdoc
, str
);
832 nsIDocument_Release(nsdoc
);
835 case DOCUMENT_TYPE_NODE
:
836 WARN("Ignoring DOCUMENT_TYPE_NODE\n");
838 case DOCUMENT_FRAGMENT_NODE
:
841 FIXME("Unhandled type %u\n", type
);
845 PRUint32 child_cnt
, i
;
846 nsIDOMNode
*child_node
;
848 nsIDOMNode_GetChildNodes(nsnode
, &node_list
);
849 nsIDOMNodeList_GetLength(node_list
, &child_cnt
);
851 for(i
=0; i
<child_cnt
; i
++) {
852 nsres
= nsIDOMNodeList_Item(node_list
, i
, &child_node
);
853 if(NS_SUCCEEDED(nsres
)) {
854 nsnode_to_nsstring_rec(serializer
, child_node
, str
);
855 nsIDOMNode_Release(child_node
);
857 ERR("Item failed: %08x\n", nsres
);
861 nsIDOMNodeList_Release(node_list
);
864 if(type
== ELEMENT_NODE
)
865 nsIContentSerializer_AppendElementEnd(serializer
, nscontent
, str
);
867 nsIContent_Release(nscontent
);
871 HRESULT
nsnode_to_nsstring(nsIDOMNode
*nsnode
, nsAString
*str
)
873 nsIContentSerializer
*serializer
;
877 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
,
878 NS_HTMLSERIALIZER_CONTRACTID
, NULL
, &IID_nsIContentSerializer
,
879 (void**)&serializer
);
880 if(NS_FAILED(nsres
)) {
881 ERR("Could not get nsIContentSerializer: %08x\n", nsres
);
885 nsres
= nsIContentSerializer_Init(serializer
, 0, 100, NULL
, FALSE
, FALSE
/* FIXME */);
887 ERR("Init failed: %08x\n", nsres
);
889 hres
= nsnode_to_nsstring_rec(serializer
, nsnode
, str
);
890 if(SUCCEEDED(hres
)) {
891 nsres
= nsIContentSerializer_Flush(serializer
, str
);
893 ERR("Flush failed: %08x\n", nsres
);
896 nsIContentSerializer_Release(serializer
);
900 void get_editor_controller(NSContainer
*This
)
902 nsIEditingSession
*editing_session
= NULL
;
903 nsIControllerContext
*ctrlctx
;
907 nsIEditor_Release(This
->editor
);
911 if(This
->editor_controller
) {
912 nsIController_Release(This
->editor_controller
);
913 This
->editor_controller
= NULL
;
916 nsres
= get_nsinterface((nsISupports
*)This
->webbrowser
, &IID_nsIEditingSession
,
917 (void**)&editing_session
);
918 if(NS_FAILED(nsres
)) {
919 ERR("Could not get nsIEditingSession: %08x\n", nsres
);
923 nsres
= nsIEditingSession_GetEditorForWindow(editing_session
,
924 This
->doc
->basedoc
.window
->nswindow
, &This
->editor
);
925 nsIEditingSession_Release(editing_session
);
926 if(NS_FAILED(nsres
)) {
927 ERR("Could not get editor: %08x\n", nsres
);
931 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
,
932 NS_EDITORCONTROLLER_CONTRACTID
, NULL
, &IID_nsIControllerContext
, (void**)&ctrlctx
);
933 if(NS_SUCCEEDED(nsres
)) {
934 nsres
= nsIControllerContext_SetCommandContext(ctrlctx
, (nsISupports
*)This
->editor
);
936 ERR("SetCommandContext failed: %08x\n", nsres
);
937 nsres
= nsIControllerContext_QueryInterface(ctrlctx
, &IID_nsIController
,
938 (void**)&This
->editor_controller
);
939 nsIControllerContext_Release(ctrlctx
);
941 ERR("Could not get nsIController interface: %08x\n", nsres
);
943 ERR("Could not create edit controller: %08x\n", nsres
);
947 void close_gecko(void)
954 if(profile_directory
) {
955 nsIFile_Release(profile_directory
);
956 profile_directory
= NULL
;
960 nsIComponentManager_Release(pCompMgr
);
963 nsIServiceManager_Release(pServMgr
);
966 nsIMemory_Release(nsmem
);
968 /* Gecko doesn't really support being unloaded */
969 /* if (hXPCOM) FreeLibrary(hXPCOM); */
972 BOOL
is_gecko_path(const char *path
)
977 buf
= heap_strdupAtoW(path
);
978 if(strlenW(buf
) < gecko_path_len
)
981 buf
[gecko_path_len
] = 0;
982 for(ptr
= buf
; *ptr
; ptr
++) {
987 ret
= !strcmpiW(buf
, gecko_path
);
992 /**********************************************************
993 * nsIWebBrowserChrome interface
996 static inline NSContainer
*impl_from_nsIWebBrowserChrome(nsIWebBrowserChrome
*iface
)
998 return CONTAINING_RECORD(iface
, NSContainer
, nsIWebBrowserChrome_iface
);
1001 static nsresult NSAPI
nsWebBrowserChrome_QueryInterface(nsIWebBrowserChrome
*iface
,
1002 nsIIDRef riid
, void **result
)
1004 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1007 if(IsEqualGUID(&IID_nsISupports
, riid
)) {
1008 TRACE("(%p)->(IID_nsISupports, %p)\n", This
, result
);
1009 *result
= &This
->nsIWebBrowserChrome_iface
;
1010 }else if(IsEqualGUID(&IID_nsIWebBrowserChrome
, riid
)) {
1011 TRACE("(%p)->(IID_nsIWebBrowserChrome, %p)\n", This
, result
);
1012 *result
= &This
->nsIWebBrowserChrome_iface
;
1013 }else if(IsEqualGUID(&IID_nsIContextMenuListener
, riid
)) {
1014 TRACE("(%p)->(IID_nsIContextMenuListener, %p)\n", This
, result
);
1015 *result
= &This
->nsIContextMenuListener_iface
;
1016 }else if(IsEqualGUID(&IID_nsIURIContentListener
, riid
)) {
1017 TRACE("(%p)->(IID_nsIURIContentListener %p)\n", This
, result
);
1018 *result
= &This
->nsIURIContentListener_iface
;
1019 }else if(IsEqualGUID(&IID_nsIEmbeddingSiteWindow
, riid
)) {
1020 TRACE("(%p)->(IID_nsIEmbeddingSiteWindow %p)\n", This
, result
);
1021 *result
= &This
->nsIEmbeddingSiteWindow_iface
;
1022 }else if(IsEqualGUID(&IID_nsITooltipListener
, riid
)) {
1023 TRACE("(%p)->(IID_nsITooltipListener %p)\n", This
, result
);
1024 *result
= &This
->nsITooltipListener_iface
;
1025 }else if(IsEqualGUID(&IID_nsIInterfaceRequestor
, riid
)) {
1026 TRACE("(%p)->(IID_nsIInterfaceRequestor %p)\n", This
, result
);
1027 *result
= &This
->nsIInterfaceRequestor_iface
;
1028 }else if(IsEqualGUID(&IID_nsIWeakReference
, riid
)) {
1029 TRACE("(%p)->(IID_nsIWeakReference %p)\n", This
, result
);
1030 *result
= &This
->nsIWeakReference_iface
;
1031 }else if(IsEqualGUID(&IID_nsISupportsWeakReference
, riid
)) {
1032 TRACE("(%p)->(IID_nsISupportsWeakReference %p)\n", This
, result
);
1033 *result
= &This
->nsISupportsWeakReference_iface
;
1037 nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1041 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), result
);
1042 return NS_NOINTERFACE
;
1045 static nsrefcnt NSAPI
nsWebBrowserChrome_AddRef(nsIWebBrowserChrome
*iface
)
1047 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1048 LONG ref
= InterlockedIncrement(&This
->ref
);
1050 TRACE("(%p) ref=%d\n", This
, ref
);
1055 static nsrefcnt NSAPI
nsWebBrowserChrome_Release(nsIWebBrowserChrome
*iface
)
1057 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1058 LONG ref
= InterlockedDecrement(&This
->ref
);
1060 TRACE("(%p) ref=%d\n", This
, ref
);
1064 nsIWebBrowserChrome_Release(&This
->parent
->nsIWebBrowserChrome_iface
);
1071 static nsresult NSAPI
nsWebBrowserChrome_SetStatus(nsIWebBrowserChrome
*iface
,
1072 PRUint32 statusType
, const PRUnichar
*status
)
1074 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1075 TRACE("(%p)->(%d %s)\n", This
, statusType
, debugstr_w(status
));
1079 static nsresult NSAPI
nsWebBrowserChrome_GetWebBrowser(nsIWebBrowserChrome
*iface
,
1080 nsIWebBrowser
**aWebBrowser
)
1082 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1084 TRACE("(%p)->(%p)\n", This
, aWebBrowser
);
1087 return NS_ERROR_INVALID_ARG
;
1089 if(This
->webbrowser
)
1090 nsIWebBrowser_AddRef(This
->webbrowser
);
1091 *aWebBrowser
= This
->webbrowser
;
1095 static nsresult NSAPI
nsWebBrowserChrome_SetWebBrowser(nsIWebBrowserChrome
*iface
,
1096 nsIWebBrowser
*aWebBrowser
)
1098 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1100 TRACE("(%p)->(%p)\n", This
, aWebBrowser
);
1102 if(aWebBrowser
!= This
->webbrowser
)
1103 ERR("Wrong nsWebBrowser!\n");
1108 static nsresult NSAPI
nsWebBrowserChrome_GetChromeFlags(nsIWebBrowserChrome
*iface
,
1109 PRUint32
*aChromeFlags
)
1111 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1112 WARN("(%p)->(%p)\n", This
, aChromeFlags
);
1113 return NS_ERROR_NOT_IMPLEMENTED
;
1116 static nsresult NSAPI
nsWebBrowserChrome_SetChromeFlags(nsIWebBrowserChrome
*iface
,
1117 PRUint32 aChromeFlags
)
1119 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1120 WARN("(%p)->(%08x)\n", This
, aChromeFlags
);
1121 return NS_ERROR_NOT_IMPLEMENTED
;
1124 static nsresult NSAPI
nsWebBrowserChrome_DestroyBrowserWindow(nsIWebBrowserChrome
*iface
)
1126 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1127 TRACE("(%p)\n", This
);
1128 return NS_ERROR_NOT_IMPLEMENTED
;
1131 static nsresult NSAPI
nsWebBrowserChrome_SizeBrowserTo(nsIWebBrowserChrome
*iface
,
1132 PRInt32 aCX
, PRInt32 aCY
)
1134 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1135 WARN("(%p)->(%d %d)\n", This
, aCX
, aCY
);
1136 return NS_ERROR_NOT_IMPLEMENTED
;
1139 static nsresult NSAPI
nsWebBrowserChrome_ShowAsModal(nsIWebBrowserChrome
*iface
)
1141 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1142 WARN("(%p)\n", This
);
1143 return NS_ERROR_NOT_IMPLEMENTED
;
1146 static nsresult NSAPI
nsWebBrowserChrome_IsWindowModal(nsIWebBrowserChrome
*iface
, PRBool
*_retval
)
1148 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1149 WARN("(%p)->(%p)\n", This
, _retval
);
1150 return NS_ERROR_NOT_IMPLEMENTED
;
1153 static nsresult NSAPI
nsWebBrowserChrome_ExitModalEventLoop(nsIWebBrowserChrome
*iface
,
1156 NSContainer
*This
= impl_from_nsIWebBrowserChrome(iface
);
1157 WARN("(%p)->(%08x)\n", This
, aStatus
);
1158 return NS_ERROR_NOT_IMPLEMENTED
;
1161 static const nsIWebBrowserChromeVtbl nsWebBrowserChromeVtbl
= {
1162 nsWebBrowserChrome_QueryInterface
,
1163 nsWebBrowserChrome_AddRef
,
1164 nsWebBrowserChrome_Release
,
1165 nsWebBrowserChrome_SetStatus
,
1166 nsWebBrowserChrome_GetWebBrowser
,
1167 nsWebBrowserChrome_SetWebBrowser
,
1168 nsWebBrowserChrome_GetChromeFlags
,
1169 nsWebBrowserChrome_SetChromeFlags
,
1170 nsWebBrowserChrome_DestroyBrowserWindow
,
1171 nsWebBrowserChrome_SizeBrowserTo
,
1172 nsWebBrowserChrome_ShowAsModal
,
1173 nsWebBrowserChrome_IsWindowModal
,
1174 nsWebBrowserChrome_ExitModalEventLoop
1177 /**********************************************************
1178 * nsIContextMenuListener interface
1181 static inline NSContainer
*impl_from_nsIContextMenuListener(nsIContextMenuListener
*iface
)
1183 return CONTAINING_RECORD(iface
, NSContainer
, nsIContextMenuListener_iface
);
1186 static nsresult NSAPI
nsContextMenuListener_QueryInterface(nsIContextMenuListener
*iface
,
1187 nsIIDRef riid
, void **result
)
1189 NSContainer
*This
= impl_from_nsIContextMenuListener(iface
);
1190 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1193 static nsrefcnt NSAPI
nsContextMenuListener_AddRef(nsIContextMenuListener
*iface
)
1195 NSContainer
*This
= impl_from_nsIContextMenuListener(iface
);
1196 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1199 static nsrefcnt NSAPI
nsContextMenuListener_Release(nsIContextMenuListener
*iface
)
1201 NSContainer
*This
= impl_from_nsIContextMenuListener(iface
);
1202 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1205 static nsresult NSAPI
nsContextMenuListener_OnShowContextMenu(nsIContextMenuListener
*iface
,
1206 PRUint32 aContextFlags
, nsIDOMEvent
*aEvent
, nsIDOMNode
*aNode
)
1208 NSContainer
*This
= impl_from_nsIContextMenuListener(iface
);
1209 nsIDOMMouseEvent
*event
;
1212 DWORD dwID
= CONTEXT_MENU_DEFAULT
;
1216 TRACE("(%p)->(%08x %p %p)\n", This
, aContextFlags
, aEvent
, aNode
);
1218 fire_event(This
->doc
->basedoc
.doc_node
/* FIXME */, EVENTID_CONTEXTMENU
, TRUE
, aNode
, aEvent
);
1220 nsres
= nsIDOMEvent_QueryInterface(aEvent
, &IID_nsIDOMMouseEvent
, (void**)&event
);
1221 if(NS_FAILED(nsres
)) {
1222 ERR("Could not get nsIDOMMouseEvent interface: %08x\n", nsres
);
1226 nsIDOMMouseEvent_GetScreenX(event
, &pt
.x
);
1227 nsIDOMMouseEvent_GetScreenY(event
, &pt
.y
);
1228 nsIDOMMouseEvent_Release(event
);
1230 switch(aContextFlags
) {
1232 case CONTEXT_DOCUMENT
:
1234 dwID
= CONTEXT_MENU_DEFAULT
;
1237 case CONTEXT_IMAGE
|CONTEXT_LINK
:
1238 dwID
= CONTEXT_MENU_IMAGE
;
1241 dwID
= CONTEXT_MENU_ANCHOR
;
1244 dwID
= CONTEXT_MENU_CONTROL
;
1247 FIXME("aContextFlags=%08x\n", aContextFlags
);
1250 hres
= get_node(This
->doc
->basedoc
.doc_node
, aNode
, TRUE
, &node
);
1252 return NS_ERROR_FAILURE
;
1254 show_context_menu(This
->doc
, dwID
, &pt
, (IDispatch
*)&node
->IHTMLDOMNode_iface
);
1258 static const nsIContextMenuListenerVtbl nsContextMenuListenerVtbl
= {
1259 nsContextMenuListener_QueryInterface
,
1260 nsContextMenuListener_AddRef
,
1261 nsContextMenuListener_Release
,
1262 nsContextMenuListener_OnShowContextMenu
1265 /**********************************************************
1266 * nsIURIContentListener interface
1269 static inline NSContainer
*impl_from_nsIURIContentListener(nsIURIContentListener
*iface
)
1271 return CONTAINING_RECORD(iface
, NSContainer
, nsIURIContentListener_iface
);
1274 static nsresult NSAPI
nsURIContentListener_QueryInterface(nsIURIContentListener
*iface
,
1275 nsIIDRef riid
, void **result
)
1277 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1278 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1281 static nsrefcnt NSAPI
nsURIContentListener_AddRef(nsIURIContentListener
*iface
)
1283 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1284 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1287 static nsrefcnt NSAPI
nsURIContentListener_Release(nsIURIContentListener
*iface
)
1289 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1290 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1293 static nsresult NSAPI
nsURIContentListener_OnStartURIOpen(nsIURIContentListener
*iface
,
1294 nsIURI
*aURI
, PRBool
*_retval
)
1296 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1297 nsACString spec_str
;
1301 nsACString_Init(&spec_str
, NULL
);
1302 nsIURI_GetSpec(aURI
, &spec_str
);
1303 nsACString_GetData(&spec_str
, &spec
);
1305 TRACE("(%p)->(%p(%s) %p)\n", This
, aURI
, debugstr_a(spec
), _retval
);
1307 nsACString_Finish(&spec_str
);
1309 nsres
= on_start_uri_open(This
, aURI
, _retval
);
1310 if(NS_FAILED(nsres
))
1313 return !*_retval
&& This
->content_listener
1314 ? nsIURIContentListener_OnStartURIOpen(This
->content_listener
, aURI
, _retval
)
1318 static nsresult NSAPI
nsURIContentListener_DoContent(nsIURIContentListener
*iface
,
1319 const char *aContentType
, PRBool aIsContentPreferred
, nsIRequest
*aRequest
,
1320 nsIStreamListener
**aContentHandler
, PRBool
*_retval
)
1322 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1324 TRACE("(%p)->(%s %x %p %p %p)\n", This
, debugstr_a(aContentType
), aIsContentPreferred
,
1325 aRequest
, aContentHandler
, _retval
);
1327 return This
->content_listener
1328 ? nsIURIContentListener_DoContent(This
->content_listener
, aContentType
,
1329 aIsContentPreferred
, aRequest
, aContentHandler
, _retval
)
1330 : NS_ERROR_NOT_IMPLEMENTED
;
1333 static nsresult NSAPI
nsURIContentListener_IsPreferred(nsIURIContentListener
*iface
,
1334 const char *aContentType
, char **aDesiredContentType
, PRBool
*_retval
)
1336 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1338 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_a(aContentType
), aDesiredContentType
, _retval
);
1340 /* FIXME: Should we do something here? */
1343 return This
->content_listener
1344 ? nsIURIContentListener_IsPreferred(This
->content_listener
, aContentType
,
1345 aDesiredContentType
, _retval
)
1349 static nsresult NSAPI
nsURIContentListener_CanHandleContent(nsIURIContentListener
*iface
,
1350 const char *aContentType
, PRBool aIsContentPreferred
, char **aDesiredContentType
,
1353 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1355 TRACE("(%p)->(%s %x %p %p)\n", This
, debugstr_a(aContentType
), aIsContentPreferred
,
1356 aDesiredContentType
, _retval
);
1358 return This
->content_listener
1359 ? nsIURIContentListener_CanHandleContent(This
->content_listener
, aContentType
,
1360 aIsContentPreferred
, aDesiredContentType
, _retval
)
1361 : NS_ERROR_NOT_IMPLEMENTED
;
1364 static nsresult NSAPI
nsURIContentListener_GetLoadCookie(nsIURIContentListener
*iface
,
1365 nsISupports
**aLoadCookie
)
1367 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1369 WARN("(%p)->(%p)\n", This
, aLoadCookie
);
1371 return This
->content_listener
1372 ? nsIURIContentListener_GetLoadCookie(This
->content_listener
, aLoadCookie
)
1373 : NS_ERROR_NOT_IMPLEMENTED
;
1376 static nsresult NSAPI
nsURIContentListener_SetLoadCookie(nsIURIContentListener
*iface
,
1377 nsISupports
*aLoadCookie
)
1379 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1381 WARN("(%p)->(%p)\n", This
, aLoadCookie
);
1383 return This
->content_listener
1384 ? nsIURIContentListener_SetLoadCookie(This
->content_listener
, aLoadCookie
)
1385 : NS_ERROR_NOT_IMPLEMENTED
;
1388 static nsresult NSAPI
nsURIContentListener_GetParentContentListener(nsIURIContentListener
*iface
,
1389 nsIURIContentListener
**aParentContentListener
)
1391 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1393 TRACE("(%p)->(%p)\n", This
, aParentContentListener
);
1395 if(This
->content_listener
)
1396 nsIURIContentListener_AddRef(This
->content_listener
);
1398 *aParentContentListener
= This
->content_listener
;
1402 static nsresult NSAPI
nsURIContentListener_SetParentContentListener(nsIURIContentListener
*iface
,
1403 nsIURIContentListener
*aParentContentListener
)
1405 NSContainer
*This
= impl_from_nsIURIContentListener(iface
);
1407 TRACE("(%p)->(%p)\n", This
, aParentContentListener
);
1409 if(aParentContentListener
== &This
->nsIURIContentListener_iface
)
1412 if(This
->content_listener
)
1413 nsIURIContentListener_Release(This
->content_listener
);
1415 This
->content_listener
= aParentContentListener
;
1416 if(This
->content_listener
)
1417 nsIURIContentListener_AddRef(This
->content_listener
);
1422 static const nsIURIContentListenerVtbl nsURIContentListenerVtbl
= {
1423 nsURIContentListener_QueryInterface
,
1424 nsURIContentListener_AddRef
,
1425 nsURIContentListener_Release
,
1426 nsURIContentListener_OnStartURIOpen
,
1427 nsURIContentListener_DoContent
,
1428 nsURIContentListener_IsPreferred
,
1429 nsURIContentListener_CanHandleContent
,
1430 nsURIContentListener_GetLoadCookie
,
1431 nsURIContentListener_SetLoadCookie
,
1432 nsURIContentListener_GetParentContentListener
,
1433 nsURIContentListener_SetParentContentListener
1436 /**********************************************************
1437 * nsIEmbeddinSiteWindow interface
1440 static inline NSContainer
*impl_from_nsIEmbeddingSiteWindow(nsIEmbeddingSiteWindow
*iface
)
1442 return CONTAINING_RECORD(iface
, NSContainer
, nsIEmbeddingSiteWindow_iface
);
1445 static nsresult NSAPI
nsEmbeddingSiteWindow_QueryInterface(nsIEmbeddingSiteWindow
*iface
,
1446 nsIIDRef riid
, void **result
)
1448 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1449 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1452 static nsrefcnt NSAPI
nsEmbeddingSiteWindow_AddRef(nsIEmbeddingSiteWindow
*iface
)
1454 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1455 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1458 static nsrefcnt NSAPI
nsEmbeddingSiteWindow_Release(nsIEmbeddingSiteWindow
*iface
)
1460 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1461 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1464 static nsresult NSAPI
nsEmbeddingSiteWindow_SetDimensions(nsIEmbeddingSiteWindow
*iface
,
1465 PRUint32 flags
, PRInt32 x
, PRInt32 y
, PRInt32 cx
, PRInt32 cy
)
1467 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1468 WARN("(%p)->(%08x %d %d %d %d)\n", This
, flags
, x
, y
, cx
, cy
);
1469 return NS_ERROR_NOT_IMPLEMENTED
;
1472 static nsresult NSAPI
nsEmbeddingSiteWindow_GetDimensions(nsIEmbeddingSiteWindow
*iface
,
1473 PRUint32 flags
, PRInt32
*x
, PRInt32
*y
, PRInt32
*cx
, PRInt32
*cy
)
1475 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1476 WARN("(%p)->(%08x %p %p %p %p)\n", This
, flags
, x
, y
, cx
, cy
);
1477 return NS_ERROR_NOT_IMPLEMENTED
;
1480 static nsresult NSAPI
nsEmbeddingSiteWindow_SetFocus(nsIEmbeddingSiteWindow
*iface
)
1482 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1484 TRACE("(%p)\n", This
);
1486 return nsIBaseWindow_SetFocus(This
->window
);
1489 static nsresult NSAPI
nsEmbeddingSiteWindow_GetVisibility(nsIEmbeddingSiteWindow
*iface
,
1490 PRBool
*aVisibility
)
1492 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1494 TRACE("(%p)->(%p)\n", This
, aVisibility
);
1496 *aVisibility
= This
->doc
&& This
->doc
->hwnd
&& IsWindowVisible(This
->doc
->hwnd
);
1500 static nsresult NSAPI
nsEmbeddingSiteWindow_SetVisibility(nsIEmbeddingSiteWindow
*iface
,
1503 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1505 TRACE("(%p)->(%x)\n", This
, aVisibility
);
1510 static nsresult NSAPI
nsEmbeddingSiteWindow_GetTitle(nsIEmbeddingSiteWindow
*iface
,
1513 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1514 WARN("(%p)->(%p)\n", This
, aTitle
);
1515 return NS_ERROR_NOT_IMPLEMENTED
;
1518 static nsresult NSAPI
nsEmbeddingSiteWindow_SetTitle(nsIEmbeddingSiteWindow
*iface
,
1519 const PRUnichar
*aTitle
)
1521 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1522 WARN("(%p)->(%s)\n", This
, debugstr_w(aTitle
));
1523 return NS_ERROR_NOT_IMPLEMENTED
;
1526 static nsresult NSAPI
nsEmbeddingSiteWindow_GetSiteWindow(nsIEmbeddingSiteWindow
*iface
,
1529 NSContainer
*This
= impl_from_nsIEmbeddingSiteWindow(iface
);
1531 TRACE("(%p)->(%p)\n", This
, aSiteWindow
);
1533 *aSiteWindow
= This
->hwnd
;
1537 static const nsIEmbeddingSiteWindowVtbl nsEmbeddingSiteWindowVtbl
= {
1538 nsEmbeddingSiteWindow_QueryInterface
,
1539 nsEmbeddingSiteWindow_AddRef
,
1540 nsEmbeddingSiteWindow_Release
,
1541 nsEmbeddingSiteWindow_SetDimensions
,
1542 nsEmbeddingSiteWindow_GetDimensions
,
1543 nsEmbeddingSiteWindow_SetFocus
,
1544 nsEmbeddingSiteWindow_GetVisibility
,
1545 nsEmbeddingSiteWindow_SetVisibility
,
1546 nsEmbeddingSiteWindow_GetTitle
,
1547 nsEmbeddingSiteWindow_SetTitle
,
1548 nsEmbeddingSiteWindow_GetSiteWindow
1551 static inline NSContainer
*impl_from_nsITooltipListener(nsITooltipListener
*iface
)
1553 return CONTAINING_RECORD(iface
, NSContainer
, nsITooltipListener_iface
);
1556 static nsresult NSAPI
nsTooltipListener_QueryInterface(nsITooltipListener
*iface
, nsIIDRef riid
,
1559 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1560 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1563 static nsrefcnt NSAPI
nsTooltipListener_AddRef(nsITooltipListener
*iface
)
1565 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1566 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1569 static nsrefcnt NSAPI
nsTooltipListener_Release(nsITooltipListener
*iface
)
1571 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1572 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1575 static nsresult NSAPI
nsTooltipListener_OnShowTooltip(nsITooltipListener
*iface
,
1576 PRInt32 aXCoord
, PRInt32 aYCoord
, const PRUnichar
*aTipText
)
1578 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1581 show_tooltip(This
->doc
, aXCoord
, aYCoord
, aTipText
);
1586 static nsresult NSAPI
nsTooltipListener_OnHideTooltip(nsITooltipListener
*iface
)
1588 NSContainer
*This
= impl_from_nsITooltipListener(iface
);
1591 hide_tooltip(This
->doc
);
1596 static const nsITooltipListenerVtbl nsTooltipListenerVtbl
= {
1597 nsTooltipListener_QueryInterface
,
1598 nsTooltipListener_AddRef
,
1599 nsTooltipListener_Release
,
1600 nsTooltipListener_OnShowTooltip
,
1601 nsTooltipListener_OnHideTooltip
1604 static inline NSContainer
*impl_from_nsIInterfaceRequestor(nsIInterfaceRequestor
*iface
)
1606 return CONTAINING_RECORD(iface
, NSContainer
, nsIInterfaceRequestor_iface
);
1609 static nsresult NSAPI
nsInterfaceRequestor_QueryInterface(nsIInterfaceRequestor
*iface
,
1610 nsIIDRef riid
, void **result
)
1612 NSContainer
*This
= impl_from_nsIInterfaceRequestor(iface
);
1613 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1616 static nsrefcnt NSAPI
nsInterfaceRequestor_AddRef(nsIInterfaceRequestor
*iface
)
1618 NSContainer
*This
= impl_from_nsIInterfaceRequestor(iface
);
1619 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1622 static nsrefcnt NSAPI
nsInterfaceRequestor_Release(nsIInterfaceRequestor
*iface
)
1624 NSContainer
*This
= impl_from_nsIInterfaceRequestor(iface
);
1625 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1628 static nsresult NSAPI
nsInterfaceRequestor_GetInterface(nsIInterfaceRequestor
*iface
,
1629 nsIIDRef riid
, void **result
)
1631 NSContainer
*This
= impl_from_nsIInterfaceRequestor(iface
);
1633 if(IsEqualGUID(&IID_nsIDOMWindow
, riid
)) {
1634 TRACE("(%p)->(IID_nsIDOMWindow %p)\n", This
, result
);
1635 return nsIWebBrowser_GetContentDOMWindow(This
->webbrowser
, (nsIDOMWindow
**)result
);
1638 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1641 static const nsIInterfaceRequestorVtbl nsInterfaceRequestorVtbl
= {
1642 nsInterfaceRequestor_QueryInterface
,
1643 nsInterfaceRequestor_AddRef
,
1644 nsInterfaceRequestor_Release
,
1645 nsInterfaceRequestor_GetInterface
1648 static inline NSContainer
*impl_from_nsIWeakReference(nsIWeakReference
*iface
)
1650 return CONTAINING_RECORD(iface
, NSContainer
, nsIWeakReference_iface
);
1653 static nsresult NSAPI
nsWeakReference_QueryInterface(nsIWeakReference
*iface
,
1654 nsIIDRef riid
, void **result
)
1656 NSContainer
*This
= impl_from_nsIWeakReference(iface
);
1657 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1660 static nsrefcnt NSAPI
nsWeakReference_AddRef(nsIWeakReference
*iface
)
1662 NSContainer
*This
= impl_from_nsIWeakReference(iface
);
1663 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1666 static nsrefcnt NSAPI
nsWeakReference_Release(nsIWeakReference
*iface
)
1668 NSContainer
*This
= impl_from_nsIWeakReference(iface
);
1669 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1672 static nsresult NSAPI
nsWeakReference_QueryReferent(nsIWeakReference
*iface
,
1673 const nsIID
*riid
, void **result
)
1675 NSContainer
*This
= impl_from_nsIWeakReference(iface
);
1676 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1679 static const nsIWeakReferenceVtbl nsWeakReferenceVtbl
= {
1680 nsWeakReference_QueryInterface
,
1681 nsWeakReference_AddRef
,
1682 nsWeakReference_Release
,
1683 nsWeakReference_QueryReferent
1686 static inline NSContainer
*impl_from_nsISupportsWeakReference(nsISupportsWeakReference
*iface
)
1688 return CONTAINING_RECORD(iface
, NSContainer
, nsISupportsWeakReference_iface
);
1691 static nsresult NSAPI
nsSupportsWeakReference_QueryInterface(nsISupportsWeakReference
*iface
,
1692 nsIIDRef riid
, void **result
)
1694 NSContainer
*This
= impl_from_nsISupportsWeakReference(iface
);
1695 return nsIWebBrowserChrome_QueryInterface(&This
->nsIWebBrowserChrome_iface
, riid
, result
);
1698 static nsrefcnt NSAPI
nsSupportsWeakReference_AddRef(nsISupportsWeakReference
*iface
)
1700 NSContainer
*This
= impl_from_nsISupportsWeakReference(iface
);
1701 return nsIWebBrowserChrome_AddRef(&This
->nsIWebBrowserChrome_iface
);
1704 static nsrefcnt NSAPI
nsSupportsWeakReference_Release(nsISupportsWeakReference
*iface
)
1706 NSContainer
*This
= impl_from_nsISupportsWeakReference(iface
);
1707 return nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);
1710 static nsresult NSAPI
nsSupportsWeakReference_GetWeakReference(nsISupportsWeakReference
*iface
,
1711 nsIWeakReference
**_retval
)
1713 NSContainer
*This
= impl_from_nsISupportsWeakReference(iface
);
1715 TRACE("(%p)->(%p)\n", This
, _retval
);
1717 nsIWeakReference_AddRef(&This
->nsIWeakReference_iface
);
1718 *_retval
= &This
->nsIWeakReference_iface
;
1722 static const nsISupportsWeakReferenceVtbl nsSupportsWeakReferenceVtbl
= {
1723 nsSupportsWeakReference_QueryInterface
,
1724 nsSupportsWeakReference_AddRef
,
1725 nsSupportsWeakReference_Release
,
1726 nsSupportsWeakReference_GetWeakReference
1729 nsresult
create_chrome_window(nsIWebBrowserChrome
*parent
, nsIWebBrowserChrome
**ret
)
1731 NSContainer
*new_container
;
1733 if(parent
->lpVtbl
!= &nsWebBrowserChromeVtbl
)
1734 return NS_ERROR_UNEXPECTED
;
1736 new_container
= NSContainer_Create(NULL
, impl_from_nsIWebBrowserChrome(parent
));
1737 *ret
= &new_container
->nsIWebBrowserChrome_iface
;
1741 NSContainer
*NSContainer_Create(HTMLDocumentObj
*doc
, NSContainer
*parent
)
1743 nsIWebBrowserSetup
*wbsetup
;
1744 nsIScrollable
*scrollable
;
1748 if(!load_gecko(TRUE
))
1751 ret
= heap_alloc_zero(sizeof(NSContainer
));
1753 ret
->nsIWebBrowserChrome_iface
.lpVtbl
= &nsWebBrowserChromeVtbl
;
1754 ret
->nsIContextMenuListener_iface
.lpVtbl
= &nsContextMenuListenerVtbl
;
1755 ret
->nsIURIContentListener_iface
.lpVtbl
= &nsURIContentListenerVtbl
;
1756 ret
->nsIEmbeddingSiteWindow_iface
.lpVtbl
= &nsEmbeddingSiteWindowVtbl
;
1757 ret
->nsITooltipListener_iface
.lpVtbl
= &nsTooltipListenerVtbl
;
1758 ret
->nsIInterfaceRequestor_iface
.lpVtbl
= &nsInterfaceRequestorVtbl
;
1759 ret
->nsIWeakReference_iface
.lpVtbl
= &nsWeakReferenceVtbl
;
1760 ret
->nsISupportsWeakReference_iface
.lpVtbl
= &nsSupportsWeakReferenceVtbl
;
1765 nsres
= nsIComponentManager_CreateInstanceByContractID(pCompMgr
, NS_WEBBROWSER_CONTRACTID
,
1766 NULL
, &IID_nsIWebBrowser
, (void**)&ret
->webbrowser
);
1767 if(NS_FAILED(nsres
)) {
1768 ERR("Creating WebBrowser failed: %08x\n", nsres
);
1774 nsIWebBrowserChrome_AddRef(&parent
->nsIWebBrowserChrome_iface
);
1775 ret
->parent
= parent
;
1777 nsres
= nsIWebBrowser_SetContainerWindow(ret
->webbrowser
, &ret
->nsIWebBrowserChrome_iface
);
1778 if(NS_FAILED(nsres
))
1779 ERR("SetContainerWindow failed: %08x\n", nsres
);
1781 nsres
= nsIWebBrowser_QueryInterface(ret
->webbrowser
, &IID_nsIBaseWindow
,
1782 (void**)&ret
->window
);
1783 if(NS_FAILED(nsres
))
1784 ERR("Could not get nsIBaseWindow interface: %08x\n", nsres
);
1786 nsres
= nsIWebBrowser_QueryInterface(ret
->webbrowser
, &IID_nsIWebBrowserSetup
,
1788 if(NS_SUCCEEDED(nsres
)) {
1789 nsres
= nsIWebBrowserSetup_SetProperty(wbsetup
, SETUP_IS_CHROME_WRAPPER
, FALSE
);
1790 nsIWebBrowserSetup_Release(wbsetup
);
1791 if(NS_FAILED(nsres
))
1792 ERR("SetProperty(SETUP_IS_CHROME_WRAPPER) failed: %08x\n", nsres
);
1794 ERR("Could not get nsIWebBrowserSetup interface\n");
1797 nsres
= nsIWebBrowser_QueryInterface(ret
->webbrowser
, &IID_nsIWebNavigation
,
1798 (void**)&ret
->navigation
);
1799 if(NS_FAILED(nsres
))
1800 ERR("Could not get nsIWebNavigation interface: %08x\n", nsres
);
1802 nsres
= nsIWebBrowserFocus_QueryInterface(ret
->webbrowser
, &IID_nsIWebBrowserFocus
,
1803 (void**)&ret
->focus
);
1804 if(NS_FAILED(nsres
))
1805 ERR("Could not get nsIWebBrowserFocus interface: %08x\n", nsres
);
1807 if(!nscontainer_class
)
1808 register_nscontainer_class();
1810 ret
->hwnd
= CreateWindowExW(0, wszNsContainer
, NULL
,
1811 WS_CHILD
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
, 0, 0, 100, 100,
1812 GetDesktopWindow(), NULL
, hInst
, ret
);
1814 nsres
= nsIBaseWindow_InitWindow(ret
->window
, ret
->hwnd
, NULL
, 0, 0, 100, 100);
1815 if(NS_SUCCEEDED(nsres
)) {
1816 nsres
= nsIBaseWindow_Create(ret
->window
);
1817 if(NS_FAILED(nsres
))
1818 WARN("Creating window failed: %08x\n", nsres
);
1820 nsIBaseWindow_SetVisibility(ret
->window
, FALSE
);
1821 nsIBaseWindow_SetEnabled(ret
->window
, FALSE
);
1823 ERR("InitWindow failed: %08x\n", nsres
);
1826 nsres
= nsIWebBrowser_SetParentURIContentListener(ret
->webbrowser
,
1827 &ret
->nsIURIContentListener_iface
);
1828 if(NS_FAILED(nsres
))
1829 ERR("SetParentURIContentListener failed: %08x\n", nsres
);
1831 nsres
= nsIWebBrowser_QueryInterface(ret
->webbrowser
, &IID_nsIScrollable
, (void**)&scrollable
);
1832 if(NS_SUCCEEDED(nsres
)) {
1833 nsres
= nsIScrollable_SetDefaultScrollbarPreferences(scrollable
,
1834 ScrollOrientation_Y
, Scrollbar_Always
);
1835 if(NS_FAILED(nsres
))
1836 ERR("Could not set default Y scrollbar prefs: %08x\n", nsres
);
1838 nsres
= nsIScrollable_SetDefaultScrollbarPreferences(scrollable
,
1839 ScrollOrientation_X
, Scrollbar_Auto
);
1840 if(NS_FAILED(nsres
))
1841 ERR("Could not set default X scrollbar prefs: %08x\n", nsres
);
1843 nsIScrollable_Release(scrollable
);
1845 ERR("Could not get nsIScrollable: %08x\n", nsres
);
1851 void NSContainer_Release(NSContainer
*This
)
1853 TRACE("(%p)\n", This
);
1857 ShowWindow(This
->hwnd
, SW_HIDE
);
1858 SetParent(This
->hwnd
, NULL
);
1860 nsIBaseWindow_SetVisibility(This
->window
, FALSE
);
1861 nsIBaseWindow_Destroy(This
->window
);
1863 nsIWebBrowser_SetContainerWindow(This
->webbrowser
, NULL
);
1865 nsIWebBrowser_Release(This
->webbrowser
);
1866 This
->webbrowser
= NULL
;
1868 nsIWebNavigation_Release(This
->navigation
);
1869 This
->navigation
= NULL
;
1871 nsIBaseWindow_Release(This
->window
);
1872 This
->window
= NULL
;
1874 nsIWebBrowserFocus_Release(This
->focus
);
1877 if(This
->editor_controller
) {
1878 nsIController_Release(This
->editor_controller
);
1879 This
->editor_controller
= NULL
;
1883 nsIEditor_Release(This
->editor
);
1884 This
->editor
= NULL
;
1887 if(This
->content_listener
) {
1888 nsIURIContentListener_Release(This
->content_listener
);
1889 This
->content_listener
= NULL
;
1893 DestroyWindow(This
->hwnd
);
1897 nsIWebBrowserChrome_Release(&This
->nsIWebBrowserChrome_iface
);