2005-08-01 12:59:45 +02:00
|
|
|
/*
|
2007-06-10 11:52:53 +02:00
|
|
|
* Copyright 2005-2007 Jacek Caban for CodeWeavers
|
2005-08-01 12:59:45 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-08-01 12:59:45 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "ole2.h"
|
2010-08-23 15:07:30 +02:00
|
|
|
#include "shlobj.h"
|
2013-03-01 14:14:48 +01:00
|
|
|
#include "shlwapi.h"
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2019-05-14 12:30:46 +02:00
|
|
|
#include "wine/asm.h"
|
2005-08-01 12:59:45 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2010-05-07 15:20:33 +02:00
|
|
|
#include "htmlevent.h"
|
2011-07-23 12:50:11 +02:00
|
|
|
#include "binding.h"
|
2005-08-01 12:59:45 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
2008-12-30 21:21:33 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(gecko);
|
2005-08-01 12:59:45 +02:00
|
|
|
|
|
|
|
#define NS_APPSTARTUPNOTIFIER_CONTRACTID "@mozilla.org/embedcomp/appstartup-notifier;1"
|
|
|
|
#define NS_WEBBROWSER_CONTRACTID "@mozilla.org/embedding/browser/nsWebBrowser;1"
|
2006-08-27 16:01:06 +02:00
|
|
|
#define NS_COMMANDPARAMS_CONTRACTID "@mozilla.org/embedcomp/command-params;1"
|
2006-10-02 20:33:08 +02:00
|
|
|
#define NS_HTMLSERIALIZER_CONTRACTID "@mozilla.org/layout/contentserializer;1?mimetype=text/html"
|
2007-06-10 11:49:12 +02:00
|
|
|
#define NS_EDITORCONTROLLER_CONTRACTID "@mozilla.org/editor/editorcontroller;1"
|
2007-11-04 17:04:41 +01:00
|
|
|
#define NS_PREFERENCES_CONTRACTID "@mozilla.org/preferences;1"
|
2012-01-27 17:45:39 +01:00
|
|
|
#define NS_VARIANT_CONTRACTID "@mozilla.org/variant;1"
|
2013-09-19 16:12:51 +02:00
|
|
|
#define NS_CATEGORYMANAGER_CONTRACTID "@mozilla.org/categorymanager;1"
|
2015-06-30 15:50:30 +02:00
|
|
|
#define NS_XMLHTTPREQUEST_CONTRACTID "@mozilla.org/xmlextras/xmlhttprequest;1"
|
2005-08-01 12:59:45 +02:00
|
|
|
|
|
|
|
#define PR_UINT32_MAX 0xffffffff
|
|
|
|
|
2010-01-28 23:55:06 +01:00
|
|
|
#define NS_STRING_CONTAINER_INIT_DEPEND 0x0002
|
2010-04-22 17:48:12 +02:00
|
|
|
#define NS_CSTRING_CONTAINER_INIT_DEPEND 0x0002
|
2010-01-28 23:55:06 +01:00
|
|
|
|
2019-12-09 17:04:37 +01:00
|
|
|
#ifdef __i386__
|
|
|
|
#define GECKO_ARCH_STRING "x86"
|
|
|
|
#elif defined(__x86_64__)
|
|
|
|
#define GECKO_ARCH_STRING "x86_64"
|
|
|
|
#else
|
|
|
|
#define GECKO_ARCH_STRING ""
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define GECKO_DIR_NAME "wine-gecko-" GECKO_VERSION "-" GECKO_ARCH_STRING
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
typedef UINT32 PRUint32;
|
|
|
|
|
2010-08-19 14:49:23 +02:00
|
|
|
static nsresult (CDECL *NS_InitXPCOM2)(nsIServiceManager**,void*,void*);
|
|
|
|
static nsresult (CDECL *NS_ShutdownXPCOM)(nsIServiceManager*);
|
|
|
|
static nsresult (CDECL *NS_GetComponentRegistrar)(nsIComponentRegistrar**);
|
|
|
|
static nsresult (CDECL *NS_StringContainerInit2)(nsStringContainer*,const PRUnichar*,PRUint32,PRUint32);
|
|
|
|
static nsresult (CDECL *NS_CStringContainerInit2)(nsCStringContainer*,const char*,PRUint32,PRUint32);
|
|
|
|
static nsresult (CDECL *NS_StringContainerFinish)(nsStringContainer*);
|
|
|
|
static nsresult (CDECL *NS_CStringContainerFinish)(nsCStringContainer*);
|
|
|
|
static nsresult (CDECL *NS_StringSetData)(nsAString*,const PRUnichar*,PRUint32);
|
|
|
|
static nsresult (CDECL *NS_CStringSetData)(nsACString*,const char*,PRUint32);
|
2012-03-15 11:54:48 +01:00
|
|
|
static nsresult (CDECL *NS_NewLocalFile)(const nsAString*,cpp_bool,nsIFile**);
|
|
|
|
static PRUint32 (CDECL *NS_StringGetData)(const nsAString*,const PRUnichar **,cpp_bool*);
|
|
|
|
static PRUint32 (CDECL *NS_CStringGetData)(const nsACString*,const char**,cpp_bool*);
|
2017-07-20 18:11:22 +02:00
|
|
|
static cpp_bool (CDECL *NS_StringGetIsVoid)(const nsAString*);
|
2015-04-16 12:37:11 +02:00
|
|
|
static void* (CDECL *NS_Alloc)(SIZE_T);
|
|
|
|
static void (CDECL *NS_Free)(void*);
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2011-04-12 11:39:20 +02:00
|
|
|
static HINSTANCE xul_handle = NULL;
|
2005-08-01 12:59:45 +02:00
|
|
|
|
|
|
|
static nsIServiceManager *pServMgr = NULL;
|
|
|
|
static nsIComponentManager *pCompMgr = NULL;
|
2013-09-19 16:12:51 +02:00
|
|
|
static nsICategoryManager *cat_mgr;
|
2012-08-29 11:37:57 +02:00
|
|
|
static nsIFile *profile_directory, *plugin_directory;
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static ATOM browser_class;
|
2010-08-18 13:37:21 +02:00
|
|
|
static WCHAR gecko_path[MAX_PATH];
|
|
|
|
static unsigned gecko_path_len;
|
2005-08-10 11:54:02 +02:00
|
|
|
|
2012-07-20 12:36:50 +02:00
|
|
|
nsresult create_nsfile(const PRUnichar *path, nsIFile **ret)
|
2012-07-20 12:35:47 +02:00
|
|
|
{
|
|
|
|
nsAString str;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsAString_InitDepend(&str, path);
|
|
|
|
nsres = NS_NewLocalFile(&str, FALSE, ret);
|
|
|
|
nsAString_Finish(&str);
|
|
|
|
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
WARN("NS_NewLocalFile failed: %08lx\n", nsres);
|
2012-07-20 12:35:47 +02:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2012-08-29 11:37:57 +02:00
|
|
|
typedef struct {
|
|
|
|
nsISimpleEnumerator nsISimpleEnumerator_iface;
|
|
|
|
LONG ref;
|
|
|
|
nsISupports *value;
|
|
|
|
} nsSingletonEnumerator;
|
|
|
|
|
|
|
|
static inline nsSingletonEnumerator *impl_from_nsISimpleEnumerator(nsISimpleEnumerator *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsSingletonEnumerator, nsISimpleEnumerator_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsSingletonEnumerator_QueryInterface(nsISimpleEnumerator *iface, nsIIDRef riid, void **ppv)
|
|
|
|
{
|
|
|
|
nsSingletonEnumerator *This = impl_from_nsISimpleEnumerator(iface);
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, ppv);
|
|
|
|
*ppv = &This->nsISimpleEnumerator_iface;
|
|
|
|
}else if(IsEqualGUID(&IID_nsISimpleEnumerator, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISimpleEnumerator %p)\n", This, ppv);
|
|
|
|
*ppv = &This->nsISimpleEnumerator_iface;
|
|
|
|
}else {
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
*ppv = NULL;
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports_AddRef((nsISupports*)*ppv);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsSingletonEnumerator_AddRef(nsISimpleEnumerator *iface)
|
|
|
|
{
|
|
|
|
nsSingletonEnumerator *This = impl_from_nsISimpleEnumerator(iface);
|
|
|
|
nsrefcnt ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2012-08-29 11:37:57 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsSingletonEnumerator_Release(nsISimpleEnumerator *iface)
|
|
|
|
{
|
|
|
|
nsSingletonEnumerator *This = impl_from_nsISimpleEnumerator(iface);
|
|
|
|
nsrefcnt ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2012-08-29 11:37:57 +02:00
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
if(This->value)
|
|
|
|
nsISupports_Release(This->value);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsSingletonEnumerator_HasMoreElements(nsISimpleEnumerator *iface, cpp_bool *_retval)
|
|
|
|
{
|
|
|
|
nsSingletonEnumerator *This = impl_from_nsISimpleEnumerator(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
|
|
|
*_retval = This->value != NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsSingletonEnumerator_GetNext(nsISimpleEnumerator *iface, nsISupports **_retval)
|
|
|
|
{
|
|
|
|
nsSingletonEnumerator *This = impl_from_nsISimpleEnumerator(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
|
|
|
if(!This->value)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
|
|
|
*_retval = This->value;
|
|
|
|
This->value = NULL;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsISimpleEnumeratorVtbl nsSingletonEnumeratorVtbl = {
|
|
|
|
nsSingletonEnumerator_QueryInterface,
|
|
|
|
nsSingletonEnumerator_AddRef,
|
|
|
|
nsSingletonEnumerator_Release,
|
|
|
|
nsSingletonEnumerator_HasMoreElements,
|
|
|
|
nsSingletonEnumerator_GetNext
|
|
|
|
};
|
|
|
|
|
|
|
|
static nsISimpleEnumerator *create_singleton_enumerator(nsISupports *value)
|
|
|
|
{
|
|
|
|
nsSingletonEnumerator *ret;
|
|
|
|
|
|
|
|
ret = heap_alloc(sizeof(*ret));
|
|
|
|
if(!ret)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret->nsISimpleEnumerator_iface.lpVtbl = &nsSingletonEnumeratorVtbl;
|
|
|
|
ret->ref = 1;
|
|
|
|
|
|
|
|
if(value)
|
|
|
|
nsISupports_AddRef(value);
|
|
|
|
ret->value = value;
|
|
|
|
return &ret->nsISimpleEnumerator_iface;
|
|
|
|
}
|
|
|
|
|
2012-08-29 11:37:39 +02:00
|
|
|
static nsresult NSAPI nsDirectoryServiceProvider2_QueryInterface(nsIDirectoryServiceProvider2 *iface,
|
2010-08-23 15:07:30 +02:00
|
|
|
nsIIDRef riid, void **result)
|
|
|
|
{
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(IID_nsISupports %p)\n", result);
|
|
|
|
*result = iface;
|
|
|
|
}else if(IsEqualGUID(&IID_nsIDirectoryServiceProvider, riid)) {
|
|
|
|
TRACE("(IID_nsIDirectoryServiceProvider %p)\n", result);
|
|
|
|
*result = iface;
|
2012-08-29 11:37:39 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIDirectoryServiceProvider2, riid)) {
|
|
|
|
TRACE("(IID_nsIDirectoryServiceProvider2 %p)\n", result);
|
|
|
|
*result = iface;
|
2010-08-23 15:07:30 +02:00
|
|
|
}else {
|
|
|
|
WARN("(%s %p)\n", debugstr_guid(riid), result);
|
|
|
|
*result = NULL;
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports_AddRef((nsISupports*)*result);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-08-29 11:37:39 +02:00
|
|
|
static nsrefcnt NSAPI nsDirectoryServiceProvider2_AddRef(nsIDirectoryServiceProvider2 *iface)
|
2010-08-23 15:07:30 +02:00
|
|
|
{
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
2012-08-29 11:37:39 +02:00
|
|
|
static nsrefcnt NSAPI nsDirectoryServiceProvider2_Release(nsIDirectoryServiceProvider2 *iface)
|
2010-08-23 15:07:30 +02:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult create_profile_directory(void)
|
|
|
|
{
|
2020-11-24 23:29:19 +01:00
|
|
|
WCHAR path[MAX_PATH + ARRAY_SIZE(L"\\wine_gecko")];
|
2012-03-15 11:54:48 +01:00
|
|
|
cpp_bool exists;
|
2010-08-23 15:07:30 +02:00
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2012-02-07 00:39:57 +01:00
|
|
|
hres = SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, path);
|
2010-08-23 15:07:30 +02:00
|
|
|
if(FAILED(hres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("SHGetFolderPath failed: %08lx\n", hres);
|
2010-08-23 15:07:30 +02:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
lstrcatW(path, L"\\wine_gecko");
|
2012-07-20 12:35:47 +02:00
|
|
|
nsres = create_nsfile(path, &profile_directory);
|
|
|
|
if(NS_FAILED(nsres))
|
2010-08-23 15:07:30 +02:00
|
|
|
return nsres;
|
|
|
|
|
|
|
|
nsres = nsIFile_Exists(profile_directory, &exists);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Exists failed: %08lx\n", nsres);
|
2010-08-23 15:07:30 +02:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!exists) {
|
|
|
|
nsres = nsIFile_Create(profile_directory, 1, 0700);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Create failed: %08lx\n", nsres);
|
2010-08-23 15:07:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2012-08-29 11:37:39 +02:00
|
|
|
static nsresult NSAPI nsDirectoryServiceProvider2_GetFile(nsIDirectoryServiceProvider2 *iface,
|
2012-03-15 11:54:48 +01:00
|
|
|
const char *prop, cpp_bool *persistent, nsIFile **_retval)
|
2010-08-23 15:07:30 +02:00
|
|
|
{
|
|
|
|
TRACE("(%s %p %p)\n", debugstr_a(prop), persistent, _retval);
|
|
|
|
|
|
|
|
if(!strcmp(prop, "ProfD")) {
|
|
|
|
if(!profile_directory) {
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = create_profile_directory();
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2012-11-27 12:16:34 +01:00
|
|
|
assert(profile_directory != NULL);
|
2010-08-23 15:07:30 +02:00
|
|
|
return nsIFile_Clone(profile_directory, _retval);
|
|
|
|
}
|
|
|
|
|
2013-05-08 17:09:34 +02:00
|
|
|
*_retval = NULL;
|
2010-08-23 15:07:30 +02:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2012-08-29 11:37:39 +02:00
|
|
|
static nsresult NSAPI nsDirectoryServiceProvider2_GetFiles(nsIDirectoryServiceProvider2 *iface,
|
|
|
|
const char *prop, nsISimpleEnumerator **_retval)
|
|
|
|
{
|
|
|
|
TRACE("(%s %p)\n", debugstr_a(prop), _retval);
|
2012-08-29 11:37:57 +02:00
|
|
|
|
|
|
|
if(!strcmp(prop, "APluginsDL")) {
|
|
|
|
WCHAR plugin_path[MAX_PATH];
|
|
|
|
nsIFile *file;
|
|
|
|
int len;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
if(!plugin_directory) {
|
2020-11-24 23:29:19 +01:00
|
|
|
len = GetSystemDirectoryW(plugin_path, ARRAY_SIZE(plugin_path)-ARRAY_SIZE(L"\\gecko\\plugin")+1);
|
2012-08-29 11:37:57 +02:00
|
|
|
if(!len)
|
|
|
|
return NS_ERROR_UNEXPECTED;
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
lstrcpyW(plugin_path+len, L"\\gecko\\plugin");
|
2012-08-29 11:37:57 +02:00
|
|
|
nsres = create_nsfile(plugin_path, &plugin_directory);
|
2013-05-08 17:09:34 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
*_retval = NULL;
|
2012-08-29 11:37:57 +02:00
|
|
|
return nsres;
|
2013-05-08 17:09:34 +02:00
|
|
|
}
|
2012-08-29 11:37:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIFile_Clone(plugin_directory, &file);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
|
|
|
|
|
|
|
*_retval = create_singleton_enumerator((nsISupports*)file);
|
|
|
|
nsIFile_Release(file);
|
|
|
|
if(!*_retval)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-05-08 17:09:34 +02:00
|
|
|
*_retval = NULL;
|
2012-08-29 11:37:39 +02:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIDirectoryServiceProvider2Vtbl nsDirectoryServiceProvider2Vtbl = {
|
|
|
|
nsDirectoryServiceProvider2_QueryInterface,
|
|
|
|
nsDirectoryServiceProvider2_AddRef,
|
|
|
|
nsDirectoryServiceProvider2_Release,
|
|
|
|
nsDirectoryServiceProvider2_GetFile,
|
|
|
|
nsDirectoryServiceProvider2_GetFiles
|
2010-08-23 15:07:30 +02:00
|
|
|
};
|
|
|
|
|
2012-08-29 11:37:39 +02:00
|
|
|
static nsIDirectoryServiceProvider2 nsDirectoryServiceProvider2 =
|
|
|
|
{ &nsDirectoryServiceProvider2Vtbl };
|
2010-08-23 15:07:30 +02:00
|
|
|
|
2005-08-10 11:54:02 +02:00
|
|
|
static LRESULT WINAPI nsembed_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This;
|
2005-08-10 11:54:02 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
if(msg == WM_CREATE) {
|
2019-03-11 14:22:24 +01:00
|
|
|
This = *(GeckoBrowser**)lParam;
|
2020-11-24 23:29:19 +01:00
|
|
|
SetPropW(hwnd, L"THIS", This);
|
2005-08-10 11:54:02 +02:00
|
|
|
}else {
|
2020-11-24 23:29:19 +01:00
|
|
|
This = GetPropW(hwnd, L"THIS");
|
2005-08-10 11:54:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(msg) {
|
2007-11-12 01:23:47 +01:00
|
|
|
case WM_SIZE:
|
|
|
|
TRACE("(%p)->(WM_SIZE)\n", This);
|
|
|
|
|
|
|
|
nsres = nsIBaseWindow_SetSize(This->window,
|
|
|
|
LOWORD(lParam), HIWORD(lParam), TRUE);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
WARN("SetSize failed: %08lx\n", nsres);
|
2007-11-12 01:23:47 +01:00
|
|
|
break;
|
2005-08-10 11:54:02 +02:00
|
|
|
|
2010-04-13 20:01:21 +02:00
|
|
|
case WM_PARENTNOTIFY:
|
|
|
|
TRACE("WM_PARENTNOTIFY %x\n", (unsigned)wParam);
|
2008-01-10 22:13:35 +01:00
|
|
|
|
2010-04-13 20:01:21 +02:00
|
|
|
switch(wParam) {
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
nsIWebBrowserFocus_Activate(This->focus);
|
2007-11-12 01:23:47 +01:00
|
|
|
}
|
2005-08-10 11:54:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return DefWindowProcW(hwnd, msg, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2006-03-01 22:04:51 +01:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static void register_browser_class(void)
|
2005-08-10 11:54:02 +02:00
|
|
|
{
|
|
|
|
static WNDCLASSEXW wndclass = {
|
|
|
|
sizeof(WNDCLASSEXW),
|
|
|
|
CS_DBLCLKS,
|
|
|
|
nsembed_proc,
|
|
|
|
0, 0, NULL, NULL, NULL, NULL, NULL,
|
2020-11-24 23:29:19 +01:00
|
|
|
L"NsContainer",
|
2005-08-10 11:54:02 +02:00
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
wndclass.hInstance = hInst;
|
2019-03-11 14:22:24 +01:00
|
|
|
browser_class = RegisterClassExW(&wndclass);
|
2005-08-10 11:54:02 +02:00
|
|
|
}
|
|
|
|
|
2012-03-08 12:18:04 +01:00
|
|
|
static BOOL install_wine_gecko(void)
|
2010-12-06 19:26:10 +01:00
|
|
|
{
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
STARTUPINFOW si;
|
|
|
|
WCHAR app[MAX_PATH];
|
|
|
|
WCHAR *args;
|
|
|
|
LONG len;
|
|
|
|
BOOL ret;
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
static const WCHAR controlW[] = L"\\control.exe";
|
|
|
|
static const WCHAR argsW[] = L" appwiz.cpl install_gecko";
|
2010-12-06 19:26:10 +01:00
|
|
|
|
2018-08-23 23:31:15 +02:00
|
|
|
len = GetSystemDirectoryW(app, MAX_PATH-ARRAY_SIZE(controlW));
|
2010-12-06 19:26:10 +01:00
|
|
|
memcpy(app+len, controlW, sizeof(controlW));
|
|
|
|
|
|
|
|
args = heap_alloc(len*sizeof(WCHAR) + sizeof(controlW) + sizeof(argsW));
|
|
|
|
if(!args)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
memcpy(args, app, len*sizeof(WCHAR) + sizeof(controlW));
|
2018-08-23 23:31:15 +02:00
|
|
|
memcpy(args + len + ARRAY_SIZE(controlW)-1, argsW, sizeof(argsW));
|
2010-12-06 19:26:10 +01:00
|
|
|
|
|
|
|
TRACE("starting %s\n", debugstr_w(args));
|
|
|
|
|
|
|
|
memset(&si, 0, sizeof(si));
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
ret = CreateProcessW(app, args, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
|
|
|
|
heap_free(args);
|
|
|
|
if (ret) {
|
|
|
|
CloseHandle(pi.hThread);
|
|
|
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
|
|
CloseHandle(pi.hProcess);
|
2019-12-09 17:04:22 +01:00
|
|
|
}else {
|
|
|
|
WARN("installation failed\n");
|
2010-12-06 19:26:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-12-30 21:21:18 +01:00
|
|
|
static void set_environment(LPCWSTR gre_path)
|
2006-08-09 16:38:42 +02:00
|
|
|
{
|
2014-07-23 16:29:48 +02:00
|
|
|
size_t len, gre_path_len;
|
|
|
|
int debug_level = 0;
|
|
|
|
WCHAR *path, buf[20];
|
|
|
|
const WCHAR *ptr;
|
2006-08-09 16:38:42 +02:00
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
SetEnvironmentVariableW(L"XPCOM_DEBUG_BREAK", L"warn");
|
2008-12-30 21:21:33 +01:00
|
|
|
|
|
|
|
if(TRACE_ON(gecko))
|
|
|
|
debug_level = 5;
|
|
|
|
else if(WARN_ON(gecko))
|
|
|
|
debug_level = 2;
|
2016-01-30 16:50:52 +01:00
|
|
|
else if(ERR_ON(gecko))
|
|
|
|
debug_level = 1;
|
2008-12-30 21:21:33 +01:00
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
swprintf(buf, ARRAY_SIZE(buf), L"all:%d", debug_level);
|
|
|
|
SetEnvironmentVariableW(L"NSPR_LOG_MODULES", buf);
|
2014-07-23 16:29:48 +02:00
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
len = GetEnvironmentVariableW(L"PATH", NULL, 0);
|
2019-06-13 08:34:29 +02:00
|
|
|
gre_path_len = lstrlenW(gre_path);
|
2014-07-23 16:29:48 +02:00
|
|
|
path = heap_alloc((len+gre_path_len+1)*sizeof(WCHAR));
|
|
|
|
if(!path)
|
|
|
|
return;
|
2020-11-24 23:29:19 +01:00
|
|
|
GetEnvironmentVariableW(L"PATH", path, len);
|
2014-07-23 16:29:48 +02:00
|
|
|
|
|
|
|
/* We have to modify PATH as xul.dll loads other DLLs from this directory. */
|
2019-06-13 08:34:29 +02:00
|
|
|
if(!(ptr = wcsstr(path, gre_path))
|
2014-07-23 16:29:48 +02:00
|
|
|
|| (ptr > path && *(ptr-1) != ';')
|
|
|
|
|| (ptr[gre_path_len] && ptr[gre_path_len] != ';')) {
|
|
|
|
if(len)
|
|
|
|
path[len-1] = ';';
|
2019-06-13 08:34:29 +02:00
|
|
|
lstrcpyW(path+len, gre_path);
|
2020-11-24 23:29:19 +01:00
|
|
|
SetEnvironmentVariableW(L"PATH", path);
|
2014-07-23 16:29:48 +02:00
|
|
|
}
|
2015-11-10 21:30:59 +01:00
|
|
|
heap_free(path);
|
2008-12-30 21:21:18 +01:00
|
|
|
}
|
|
|
|
|
2009-08-21 13:27:20 +02:00
|
|
|
static void set_bool_pref(nsIPrefBranch *pref, const char *pref_name, BOOL val)
|
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIPrefBranch_SetBoolPref(pref, pref_name, val);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not set pref %s\n", debugstr_a(pref_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_int_pref(nsIPrefBranch *pref, const char *pref_name, int val)
|
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIPrefBranch_SetIntPref(pref, pref_name, val);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not set pref %s\n", debugstr_a(pref_name));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void set_string_pref(nsIPrefBranch *pref, const char *pref_name, const char *val)
|
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIPrefBranch_SetCharPref(pref, pref_name, val);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not set pref %s\n", debugstr_a(pref_name));
|
|
|
|
}
|
|
|
|
|
2007-11-04 17:04:41 +01:00
|
|
|
static void set_lang(nsIPrefBranch *pref)
|
|
|
|
{
|
|
|
|
char langs[100];
|
|
|
|
DWORD res, size, type;
|
|
|
|
HKEY hkey;
|
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Internet Explorer\\International", &hkey);
|
2007-11-04 17:04:41 +01:00
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
size = sizeof(langs);
|
|
|
|
res = RegQueryValueExA(hkey, "AcceptLanguage", 0, &type, (LPBYTE)langs, &size);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res != ERROR_SUCCESS || type != REG_SZ)
|
|
|
|
return;
|
|
|
|
|
|
|
|
TRACE("Setting lang %s\n", debugstr_a(langs));
|
|
|
|
|
2009-08-21 13:27:20 +02:00
|
|
|
set_string_pref(pref, "intl.accept_languages", langs);
|
2007-11-04 17:04:41 +01:00
|
|
|
}
|
|
|
|
|
2008-12-22 01:10:56 +01:00
|
|
|
static void set_preferences(void)
|
|
|
|
{
|
|
|
|
nsIPrefBranch *pref;
|
|
|
|
nsresult nsres;
|
2007-11-04 17:04:41 +01:00
|
|
|
|
|
|
|
nsres = nsIServiceManager_GetServiceByContractID(pServMgr, NS_PREFERENCES_CONTRACTID,
|
|
|
|
&IID_nsIPrefBranch, (void**)&pref);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get preference service: %08lx\n", nsres);
|
2007-11-04 17:04:41 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_lang(pref);
|
2008-01-11 12:06:35 +01:00
|
|
|
set_bool_pref(pref, "security.warn_entering_secure", FALSE);
|
|
|
|
set_bool_pref(pref, "security.warn_submit_insecure", FALSE);
|
2009-08-15 19:47:40 +02:00
|
|
|
set_int_pref(pref, "layout.spellcheckDefault", 0);
|
2007-11-04 17:04:41 +01:00
|
|
|
|
|
|
|
nsIPrefBranch_Release(pref);
|
2005-12-15 10:26:11 +01:00
|
|
|
}
|
|
|
|
|
2007-05-30 23:38:03 +02:00
|
|
|
static BOOL init_xpcom(const PRUnichar *gre_path)
|
2005-08-01 12:59:45 +02:00
|
|
|
{
|
2005-12-15 10:26:11 +01:00
|
|
|
nsIComponentRegistrar *registrar = NULL;
|
2005-08-01 12:59:45 +02:00
|
|
|
nsIFile *gre_dir;
|
2010-08-18 13:37:21 +02:00
|
|
|
WCHAR *ptr;
|
2011-04-04 19:32:35 +02:00
|
|
|
nsresult nsres;
|
2005-08-22 11:21:53 +02:00
|
|
|
|
2012-07-20 12:35:47 +02:00
|
|
|
nsres = create_nsfile(gre_path, &gre_dir);
|
2005-08-01 12:59:45 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2011-04-12 11:39:20 +02:00
|
|
|
FreeLibrary(xul_handle);
|
2005-08-01 12:59:45 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-08-29 11:37:39 +02:00
|
|
|
nsres = NS_InitXPCOM2(&pServMgr, gre_dir, (nsIDirectoryServiceProvider*)&nsDirectoryServiceProvider2);
|
2005-08-01 12:59:45 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("NS_InitXPCOM2 failed: %08lx\n", nsres);
|
2011-04-12 11:39:20 +02:00
|
|
|
FreeLibrary(xul_handle);
|
2005-08-01 12:59:45 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
lstrcpyW(gecko_path, gre_path);
|
2010-08-18 13:37:21 +02:00
|
|
|
for(ptr = gecko_path; *ptr; ptr++) {
|
|
|
|
if(*ptr == '\\')
|
|
|
|
*ptr = '/';
|
|
|
|
}
|
|
|
|
gecko_path_len = ptr-gecko_path;
|
|
|
|
|
2005-08-01 12:59:45 +02:00
|
|
|
nsres = nsIServiceManager_QueryInterface(pServMgr, &IID_nsIComponentManager, (void**)&pCompMgr);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsIComponentManager: %08lx\n", nsres);
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2016-01-30 16:50:52 +01:00
|
|
|
init_nsio(pCompMgr);
|
2011-03-15 13:45:29 +01:00
|
|
|
init_mutation(pCompMgr);
|
2008-12-22 01:10:56 +01:00
|
|
|
set_preferences();
|
2006-02-09 12:17:08 +01:00
|
|
|
|
2013-09-19 16:12:51 +02:00
|
|
|
nsres = nsIServiceManager_GetServiceByContractID(pServMgr, NS_CATEGORYMANAGER_CONTRACTID,
|
|
|
|
&IID_nsICategoryManager, (void**)&cat_mgr);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get category manager service: %08lx\n", nsres);
|
2013-09-19 16:12:51 +02:00
|
|
|
|
2016-01-30 16:50:52 +01:00
|
|
|
nsres = NS_GetComponentRegistrar(®istrar);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2006-03-01 22:04:51 +01:00
|
|
|
register_nsservice(registrar, pServMgr);
|
2005-12-09 11:51:02 +01:00
|
|
|
nsIComponentRegistrar_Release(registrar);
|
2016-01-30 16:50:52 +01:00
|
|
|
}else {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("NS_GetComponentRegistrar failed: %08lx\n", nsres);
|
2005-12-09 11:51:02 +01:00
|
|
|
}
|
|
|
|
|
2012-07-19 11:28:35 +02:00
|
|
|
init_node_cc();
|
|
|
|
|
2005-08-01 12:59:45 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2019-12-09 17:04:22 +01:00
|
|
|
static BOOL load_xul(WCHAR *gecko_path)
|
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
set_environment(gecko_path);
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_w(gecko_path));
|
|
|
|
|
|
|
|
len = wcslen(gecko_path);
|
|
|
|
wcscpy(gecko_path + len, L"\\xul.dll");
|
2021-03-29 16:00:07 +02:00
|
|
|
xul_handle = LoadLibraryExW(gecko_path, 0, LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
|
2019-12-09 17:04:22 +01:00
|
|
|
gecko_path[len] = 0;
|
|
|
|
if(!xul_handle) {
|
2022-02-15 07:29:41 +01:00
|
|
|
WARN("Could not load XUL: %ld\n", GetLastError());
|
2019-12-09 17:04:22 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_DLSYM(func) \
|
|
|
|
func = (void *)GetProcAddress(xul_handle, #func); \
|
|
|
|
if(!func) \
|
|
|
|
ERR("Could not GetProcAddress(" #func ") failed\n")
|
|
|
|
|
|
|
|
NS_DLSYM(NS_InitXPCOM2);
|
|
|
|
NS_DLSYM(NS_ShutdownXPCOM);
|
|
|
|
NS_DLSYM(NS_GetComponentRegistrar);
|
|
|
|
NS_DLSYM(NS_StringContainerInit2);
|
|
|
|
NS_DLSYM(NS_CStringContainerInit2);
|
|
|
|
NS_DLSYM(NS_StringContainerFinish);
|
|
|
|
NS_DLSYM(NS_CStringContainerFinish);
|
|
|
|
NS_DLSYM(NS_StringSetData);
|
|
|
|
NS_DLSYM(NS_CStringSetData);
|
|
|
|
NS_DLSYM(NS_NewLocalFile);
|
|
|
|
NS_DLSYM(NS_StringGetData);
|
|
|
|
NS_DLSYM(NS_CStringGetData);
|
|
|
|
NS_DLSYM(NS_StringGetIsVoid);
|
|
|
|
NS_DLSYM(NS_Alloc);
|
|
|
|
NS_DLSYM(NS_Free);
|
|
|
|
NS_DLSYM(ccref_incr);
|
|
|
|
NS_DLSYM(ccref_decr);
|
|
|
|
NS_DLSYM(ccref_init);
|
|
|
|
NS_DLSYM(ccp_init);
|
|
|
|
NS_DLSYM(describe_cc_node);
|
|
|
|
NS_DLSYM(note_cc_edge);
|
|
|
|
|
|
|
|
#undef NS_DLSYM
|
|
|
|
|
|
|
|
return init_xpcom(gecko_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *check_version(const WCHAR *path)
|
|
|
|
{
|
|
|
|
WCHAR *file_name;
|
|
|
|
char version[128];
|
|
|
|
DWORD read=0;
|
|
|
|
size_t len;
|
|
|
|
HANDLE hfile;
|
|
|
|
|
|
|
|
if(!wcsncmp(path, L"\\??\\", 4))
|
|
|
|
path += 4;
|
|
|
|
if(path[1] != ':') {
|
|
|
|
TRACE("Skipping %s\n", debugstr_w(path));
|
|
|
|
return FALSE; /* Gecko needs to be accessible via dos path */
|
|
|
|
}
|
|
|
|
|
|
|
|
len = wcslen(path);
|
|
|
|
file_name = heap_alloc((len + 12) * sizeof(WCHAR));
|
|
|
|
if(!file_name)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
PathCanonicalizeW(file_name, path);
|
|
|
|
len = lstrlenW(file_name);
|
|
|
|
wcscpy(file_name + len, L"\\VERSION");
|
|
|
|
|
|
|
|
hfile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
file_name[len] = 0;
|
|
|
|
if(hfile == INVALID_HANDLE_VALUE) {
|
|
|
|
TRACE("%s not found\n", debugstr_w(file_name));
|
|
|
|
heap_free(file_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReadFile(hfile, version, sizeof(version), &read, NULL);
|
|
|
|
version[read] = 0;
|
|
|
|
CloseHandle(hfile);
|
|
|
|
|
|
|
|
TRACE("%s: %s\n", debugstr_w(file_name), debugstr_a(version));
|
|
|
|
|
|
|
|
if(strcmp(version, GECKO_VERSION_STRING)) {
|
|
|
|
ERR("Unexpected version %s, expected \"%s\"\n", debugstr_a(version),
|
|
|
|
GECKO_VERSION_STRING);
|
|
|
|
heap_free(file_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return file_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *find_wine_gecko_reg(void)
|
|
|
|
{
|
|
|
|
WCHAR buffer[MAX_PATH];
|
|
|
|
DWORD res, type, size;
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKLM\Software\Wine\MSHTML\<version> */
|
|
|
|
res = RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\Wine\\MSHTML\\" GECKO_VERSION, &hkey);
|
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return NULL;
|
|
|
|
|
2021-10-19 10:30:58 +02:00
|
|
|
size = sizeof(buffer);
|
2019-12-09 17:04:22 +01:00
|
|
|
res = RegQueryValueExW(hkey, L"GeckoPath", NULL, &type, (LPBYTE)buffer, &size);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res != ERROR_SUCCESS || type != REG_SZ)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return check_version(buffer);
|
|
|
|
}
|
|
|
|
|
2019-12-09 17:04:37 +01:00
|
|
|
static WCHAR *heap_strcat(const WCHAR *str1, const WCHAR *str2)
|
|
|
|
{
|
|
|
|
size_t len1 = lstrlenW(str1);
|
|
|
|
size_t len2 = lstrlenW(str2);
|
|
|
|
WCHAR *ret = heap_alloc((len1 + len2 + 1) * sizeof(WCHAR));
|
|
|
|
if(!ret) return NULL;
|
|
|
|
memcpy(ret, str1, len1 * sizeof(WCHAR));
|
|
|
|
memcpy(ret + len1, str2, len2 * sizeof(WCHAR));
|
|
|
|
ret[len1 + len2] = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *find_wine_gecko_datadir(void)
|
|
|
|
{
|
|
|
|
const WCHAR *data_dir;
|
|
|
|
WCHAR *path = NULL, *ret;
|
|
|
|
|
|
|
|
if((data_dir = _wgetenv(L"WINEDATADIR")))
|
|
|
|
path = heap_strcat(data_dir, L"\\gecko\\" GECKO_DIR_NAME);
|
|
|
|
else if((data_dir = _wgetenv(L"WINEBUILDDIR")))
|
|
|
|
path = heap_strcat(data_dir, L"\\..\\gecko\\" GECKO_DIR_NAME);
|
|
|
|
if(!path)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
ret = check_version(path);
|
|
|
|
heap_free(path);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WCHAR *find_wine_gecko_unix(const char *unix_path)
|
|
|
|
{
|
|
|
|
static WCHAR * (CDECL *p_wine_get_dos_file_name)(const char*);
|
|
|
|
WCHAR *dos_dir, *ret;
|
|
|
|
|
|
|
|
if(!p_wine_get_dos_file_name) {
|
|
|
|
p_wine_get_dos_file_name = (void*)GetProcAddress(GetModuleHandleA("kernel32"), "wine_get_dos_file_name");
|
|
|
|
if(!p_wine_get_dos_file_name)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
dos_dir = p_wine_get_dos_file_name(unix_path);
|
|
|
|
if(!dos_dir)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
ret = check_version(dos_dir);
|
|
|
|
|
|
|
|
heap_free(dos_dir);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2007-02-13 18:06:25 +01:00
|
|
|
static CRITICAL_SECTION cs_load_gecko;
|
|
|
|
static CRITICAL_SECTION_DEBUG cs_load_gecko_dbg =
|
|
|
|
{
|
|
|
|
0, 0, &cs_load_gecko,
|
|
|
|
{ &cs_load_gecko_dbg.ProcessLocksList, &cs_load_gecko_dbg.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": load_gecko") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION cs_load_gecko = { &cs_load_gecko_dbg, -1, 0, 0, 0, 0 };
|
|
|
|
|
2012-03-08 12:18:04 +01:00
|
|
|
BOOL load_gecko(void)
|
2007-02-13 18:06:25 +01:00
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
2008-10-18 17:08:41 +02:00
|
|
|
static DWORD loading_thread;
|
2007-02-13 18:06:25 +01:00
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
2019-12-09 17:04:37 +01:00
|
|
|
if(!GECKO_ARCH_STRING[0]) {
|
|
|
|
FIXME("Wine Gecko is not supported on this architecture.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2007-02-13 18:06:25 +01:00
|
|
|
/* load_gecko may be called recursively */
|
|
|
|
if(loading_thread == GetCurrentThreadId())
|
|
|
|
return pCompMgr != NULL;
|
|
|
|
|
|
|
|
EnterCriticalSection(&cs_load_gecko);
|
|
|
|
|
|
|
|
if(!loading_thread) {
|
2019-12-09 17:04:22 +01:00
|
|
|
WCHAR *gecko_path;
|
|
|
|
|
2007-02-13 18:06:25 +01:00
|
|
|
loading_thread = GetCurrentThreadId();
|
|
|
|
|
2019-12-09 17:04:22 +01:00
|
|
|
if(!(gecko_path = find_wine_gecko_reg())
|
2019-12-09 17:04:37 +01:00
|
|
|
&& !(gecko_path = find_wine_gecko_datadir())
|
|
|
|
&& !(gecko_path = find_wine_gecko_unix(INSTALL_DATADIR "/wine/gecko/" GECKO_DIR_NAME))
|
|
|
|
&& (!strcmp(INSTALL_DATADIR, "/usr/share") ||
|
|
|
|
!(gecko_path = find_wine_gecko_unix("/usr/share/wine/gecko/" GECKO_DIR_NAME)))
|
|
|
|
&& !(gecko_path = find_wine_gecko_unix("/opt/wine/gecko/" GECKO_DIR_NAME))
|
2019-12-09 17:04:22 +01:00
|
|
|
&& install_wine_gecko())
|
|
|
|
gecko_path = find_wine_gecko_reg();
|
|
|
|
|
|
|
|
if(gecko_path) {
|
|
|
|
ret = load_xul(gecko_path);
|
|
|
|
heap_free(gecko_path);
|
|
|
|
}else {
|
|
|
|
MESSAGE("Could not find Wine Gecko. HTML rendering will be disabled.\n");
|
|
|
|
}
|
2007-02-13 18:06:25 +01:00
|
|
|
}else {
|
|
|
|
ret = pCompMgr != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&cs_load_gecko);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-03-27 21:02:28 +02:00
|
|
|
void *nsalloc(size_t size)
|
|
|
|
{
|
2015-04-16 12:37:11 +02:00
|
|
|
return NS_Alloc(size);
|
2006-03-27 21:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsfree(void *mem)
|
|
|
|
{
|
2015-04-16 12:37:11 +02:00
|
|
|
NS_Free(mem);
|
2006-03-27 21:02:28 +02:00
|
|
|
}
|
|
|
|
|
2015-06-30 15:51:21 +02:00
|
|
|
BOOL nsACString_Init(nsACString *str, const char *data)
|
2005-08-11 20:36:48 +02:00
|
|
|
{
|
2010-04-22 17:48:39 +02:00
|
|
|
return NS_SUCCEEDED(NS_CStringContainerInit2(str, data, PR_UINT32_MAX, 0));
|
2006-12-14 00:20:26 +01:00
|
|
|
}
|
|
|
|
|
2010-04-22 17:48:12 +02:00
|
|
|
/*
|
|
|
|
* Initializes nsACString with data owned by caller.
|
|
|
|
* Caller must ensure that data is valid during lifetime of string object.
|
|
|
|
*/
|
|
|
|
void nsACString_InitDepend(nsACString *str, const char *data)
|
|
|
|
{
|
|
|
|
NS_CStringContainerInit2(str, data, PR_UINT32_MAX, NS_CSTRING_CONTAINER_INIT_DEPEND);
|
|
|
|
}
|
|
|
|
|
2006-12-14 00:20:26 +01:00
|
|
|
void nsACString_SetData(nsACString *str, const char *data)
|
|
|
|
{
|
|
|
|
NS_CStringSetData(str, data, PR_UINT32_MAX);
|
2005-08-11 20:36:48 +02:00
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 nsACString_GetData(const nsACString *str, const char **data)
|
2005-09-02 14:19:42 +02:00
|
|
|
{
|
2007-12-17 01:38:15 +01:00
|
|
|
return NS_CStringGetData(str, data, NULL);
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
2010-04-22 17:48:12 +02:00
|
|
|
void nsACString_Finish(nsACString *str)
|
2005-08-11 20:36:48 +02:00
|
|
|
{
|
|
|
|
NS_CStringContainerFinish(str);
|
|
|
|
}
|
|
|
|
|
2010-01-28 23:54:38 +01:00
|
|
|
BOOL nsAString_Init(nsAString *str, const PRUnichar *data)
|
2006-03-06 22:34:49 +01:00
|
|
|
{
|
2010-01-28 23:54:38 +01:00
|
|
|
return NS_SUCCEEDED(NS_StringContainerInit2(str, data, PR_UINT32_MAX, 0));
|
2008-03-07 12:56:33 +01:00
|
|
|
}
|
|
|
|
|
2010-01-28 23:55:06 +01:00
|
|
|
/*
|
|
|
|
* Initializes nsAString with data owned by caller.
|
|
|
|
* Caller must ensure that data is valid during lifetime of string object.
|
|
|
|
*/
|
|
|
|
void nsAString_InitDepend(nsAString *str, const PRUnichar *data)
|
|
|
|
{
|
|
|
|
NS_StringContainerInit2(str, data, PR_UINT32_MAX, NS_STRING_CONTAINER_INIT_DEPEND);
|
|
|
|
}
|
|
|
|
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 nsAString_GetData(const nsAString *str, const PRUnichar **data)
|
2006-03-06 22:34:49 +01:00
|
|
|
{
|
2007-12-17 01:38:30 +01:00
|
|
|
return NS_StringGetData(str, data, NULL);
|
2019-04-19 16:36:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsAString_SetData(nsAString *str, const PRUnichar *data)
|
|
|
|
{
|
|
|
|
NS_StringSetData(str, data, PR_UINT32_MAX);
|
2006-03-06 22:34:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsAString_Finish(nsAString *str)
|
|
|
|
{
|
|
|
|
NS_StringContainerFinish(str);
|
|
|
|
}
|
|
|
|
|
2019-03-26 17:27:32 +01:00
|
|
|
HRESULT map_nsresult(nsresult nsres)
|
2019-03-26 17:27:22 +01:00
|
|
|
{
|
|
|
|
switch(nsres) {
|
|
|
|
case NS_OK:
|
|
|
|
return S_OK;
|
|
|
|
case NS_ERROR_OUT_OF_MEMORY:
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
case NS_ERROR_NOT_IMPLEMENTED:
|
|
|
|
return E_NOTIMPL;
|
|
|
|
case NS_NOINTERFACE:
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
case NS_ERROR_INVALID_POINTER:
|
|
|
|
return E_POINTER;
|
|
|
|
case NS_ERROR_INVALID_ARG:
|
|
|
|
return E_INVALIDARG;
|
|
|
|
case NS_ERROR_UNEXPECTED:
|
|
|
|
return E_UNEXPECTED;
|
2019-03-26 17:27:32 +01:00
|
|
|
case NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR:
|
|
|
|
return 0x80700007; /* according to tests */
|
2019-03-26 17:27:22 +01:00
|
|
|
}
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-12-17 03:39:11 +01:00
|
|
|
HRESULT return_nsstr(nsresult nsres, nsAString *nsstr, BSTR *p)
|
|
|
|
{
|
|
|
|
const PRUnichar *str;
|
2022-01-07 16:43:44 +01:00
|
|
|
HRESULT hres = S_OK;
|
2010-12-17 03:39:11 +01:00
|
|
|
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
WARN("failed: %08lx\n", nsres);
|
2010-12-17 03:39:11 +01:00
|
|
|
nsAString_Finish(nsstr);
|
2019-03-26 17:27:22 +01:00
|
|
|
return map_nsresult(nsres);
|
2010-12-17 03:39:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_GetData(nsstr, &str);
|
|
|
|
TRACE("ret %s\n", debugstr_w(str));
|
|
|
|
if(*str) {
|
|
|
|
*p = SysAllocString(str);
|
|
|
|
if(!*p)
|
2022-01-07 16:43:44 +01:00
|
|
|
hres = E_OUTOFMEMORY;
|
2010-12-17 03:39:11 +01:00
|
|
|
}else {
|
|
|
|
*p = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(nsstr);
|
2022-01-07 16:43:44 +01:00
|
|
|
return hres;
|
2010-12-17 03:39:11 +01:00
|
|
|
}
|
|
|
|
|
2020-05-28 23:06:38 +02:00
|
|
|
HRESULT return_nsstr_variant(nsresult nsres, nsAString *nsstr, unsigned flags, VARIANT *p)
|
2017-07-20 18:11:22 +02:00
|
|
|
{
|
2020-06-05 18:27:01 +02:00
|
|
|
HRESULT hres = S_OK;
|
|
|
|
|
2017-07-20 18:11:22 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("failed: %08lx\n", nsres);
|
2017-07-20 18:11:22 +02:00
|
|
|
nsAString_Finish(nsstr);
|
2020-06-05 18:27:01 +02:00
|
|
|
return map_nsresult(nsres);
|
2017-07-20 18:11:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(NS_StringGetIsVoid(nsstr)) {
|
|
|
|
V_VT(p) = VT_NULL;
|
|
|
|
}else {
|
2020-05-28 23:06:38 +02:00
|
|
|
const WCHAR *str;
|
|
|
|
size_t len;
|
2017-07-20 18:11:22 +02:00
|
|
|
nsAString_GetData(nsstr, &str);
|
2020-05-28 23:06:38 +02:00
|
|
|
len = wcslen(str);
|
|
|
|
if(flags & NSSTR_IMPLICIT_PX) {
|
|
|
|
const WCHAR *iter;
|
|
|
|
if(len > 2 && !wcscmp(str + len - 2, L"px"))
|
|
|
|
len -= 2;
|
|
|
|
for(iter = str; iter < str + len && is_digit(*iter); iter++);
|
|
|
|
if(*iter == '.') {
|
|
|
|
const WCHAR *dot = iter++;
|
|
|
|
while(iter < str + len && is_digit(*iter)) iter++;
|
|
|
|
if(iter == str + len && dot) len = dot - str;
|
|
|
|
}
|
|
|
|
}
|
2020-06-05 18:27:01 +02:00
|
|
|
if(flags & NSSTR_COLOR) {
|
|
|
|
hres = nscolor_to_str(str, &V_BSTR(p));
|
|
|
|
}else if(*str) {
|
2020-05-28 23:06:38 +02:00
|
|
|
V_BSTR(p) = SysAllocStringLen(str, len);
|
2020-06-05 18:27:01 +02:00
|
|
|
if(!V_BSTR(p))
|
|
|
|
hres = E_OUTOFMEMORY;
|
2017-07-20 18:11:22 +02:00
|
|
|
}else {
|
|
|
|
V_BSTR(p) = NULL;
|
|
|
|
}
|
2020-06-05 18:27:01 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
V_VT(p) = VT_BSTR;
|
2017-07-20 18:11:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(nsstr);
|
2020-06-05 18:27:01 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
TRACE("ret %s\n", debugstr_variant(p));
|
2017-07-20 18:11:22 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2019-04-19 16:37:16 +02:00
|
|
|
/*
|
|
|
|
* Converts VARIANT to string and stores the result in nsAString. To avoid useless
|
|
|
|
* allocations, the function uses an existing string if available, so caller must
|
|
|
|
* ensure that passed VARIANT is unchanged as long as its string representation is used
|
|
|
|
*/
|
|
|
|
HRESULT variant_to_nsstr(VARIANT *v, BOOL hex_int, nsAString *nsstr)
|
|
|
|
{
|
|
|
|
WCHAR buf[32];
|
|
|
|
|
|
|
|
switch(V_VT(v)) {
|
|
|
|
case VT_NULL:
|
|
|
|
nsAString_InitDepend(nsstr, NULL);
|
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
case VT_BSTR:
|
|
|
|
nsAString_InitDepend(nsstr, V_BSTR(v));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_BSTR|VT_BYREF:
|
|
|
|
nsAString_InitDepend(nsstr, *V_BSTRREF(v));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VT_I4:
|
2020-11-24 23:29:19 +01:00
|
|
|
wsprintfW(buf, hex_int ? L"#%06x" : L"%d", V_I4(v));
|
2019-04-19 16:37:16 +02:00
|
|
|
nsAString_Init(nsstr, buf);
|
|
|
|
break;
|
|
|
|
|
2021-11-25 21:01:48 +01:00
|
|
|
case VT_R8:
|
|
|
|
case VT_DISPATCH: {
|
2019-04-19 16:37:32 +02:00
|
|
|
VARIANT strv;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
V_VT(&strv) = VT_EMPTY;
|
|
|
|
hres = VariantChangeTypeEx(&strv, v, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT),
|
|
|
|
0, VT_BSTR);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
nsAString_Init(nsstr, V_BSTR(&strv));
|
|
|
|
SysFreeString(V_BSTR(&strv));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-04-19 16:37:16 +02:00
|
|
|
default:
|
|
|
|
FIXME("not implemented for %s\n", debugstr_variant(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2006-08-27 16:01:06 +02:00
|
|
|
nsICommandParams *create_nscommand_params(void)
|
|
|
|
{
|
|
|
|
nsICommandParams *ret = NULL;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
if(!pCompMgr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr,
|
|
|
|
NS_COMMANDPARAMS_CONTRACTID, NULL, &IID_nsICommandParams,
|
|
|
|
(void**)&ret);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not get nsICommandParams\n");
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-01-27 17:45:39 +01:00
|
|
|
nsIWritableVariant *create_nsvariant(void)
|
|
|
|
{
|
|
|
|
nsIWritableVariant *ret = NULL;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
if(!pCompMgr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr,
|
|
|
|
NS_VARIANT_CONTRACTID, NULL, &IID_nsIWritableVariant, (void**)&ret);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not get nsIVariant\n");
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-09-19 16:12:51 +02:00
|
|
|
char *get_nscategory_entry(const char *category, const char *entry)
|
|
|
|
{
|
|
|
|
char *ret = NULL;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsICategoryManager_GetCategoryEntry(cat_mgr, category, entry, &ret);
|
|
|
|
return NS_SUCCEEDED(nsres) ? ret : NULL;
|
|
|
|
}
|
|
|
|
|
2007-09-26 20:46:37 +02:00
|
|
|
nsresult get_nsinterface(nsISupports *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
nsIInterfaceRequestor *iface_req;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsISupports_QueryInterface(iface, &IID_nsIInterfaceRequestor, (void**)&iface_req);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
return nsres;
|
|
|
|
|
|
|
|
nsres = nsIInterfaceRequestor_GetInterface(iface_req, riid, ppv);
|
|
|
|
nsIInterfaceRequestor_Release(iface_req);
|
|
|
|
|
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
2009-08-11 19:17:19 +02:00
|
|
|
static HRESULT nsnode_to_nsstring_rec(nsIContentSerializer *serializer, nsIDOMNode *nsnode, nsAString *str)
|
2006-10-02 20:33:08 +02:00
|
|
|
{
|
|
|
|
nsIDOMNodeList *node_list = NULL;
|
2012-03-15 11:54:48 +01:00
|
|
|
cpp_bool has_children = FALSE;
|
2010-08-25 14:22:25 +02:00
|
|
|
nsIContent *nscontent;
|
2013-01-23 18:43:55 +01:00
|
|
|
UINT16 type;
|
2006-10-02 20:33:08 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsIDOMNode_HasChildNodes(nsnode, &has_children);
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_GetNodeType(nsnode, &type);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("GetType failed: %08lx\n", nsres);
|
2009-08-11 19:17:19 +02:00
|
|
|
return E_FAIL;
|
2006-10-02 20:33:08 +02:00
|
|
|
}
|
|
|
|
|
2011-08-04 14:05:23 +02:00
|
|
|
if(type != DOCUMENT_NODE) {
|
|
|
|
nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIContent, (void**)&nscontent);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsIContent interface: %08lx\n", nsres);
|
2011-08-04 14:05:23 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2010-08-25 14:22:25 +02:00
|
|
|
}
|
|
|
|
|
2006-10-02 20:33:08 +02:00
|
|
|
switch(type) {
|
2010-08-25 14:22:25 +02:00
|
|
|
case ELEMENT_NODE:
|
|
|
|
nsIContentSerializer_AppendElementStart(serializer, nscontent, nscontent, str);
|
2006-10-02 20:33:08 +02:00
|
|
|
break;
|
2010-08-25 14:22:25 +02:00
|
|
|
case TEXT_NODE:
|
|
|
|
nsIContentSerializer_AppendText(serializer, nscontent, 0, -1, str);
|
2006-10-02 20:33:08 +02:00
|
|
|
break;
|
2010-08-25 14:22:25 +02:00
|
|
|
case COMMENT_NODE:
|
2016-08-04 08:06:17 +02:00
|
|
|
nsIContentSerializer_AppendComment(serializer, nscontent, 0, -1, str);
|
2007-06-10 11:54:51 +02:00
|
|
|
break;
|
2006-10-02 20:33:08 +02:00
|
|
|
case DOCUMENT_NODE: {
|
2010-08-25 14:22:25 +02:00
|
|
|
nsIDocument *nsdoc;
|
|
|
|
nsIDOMNode_QueryInterface(nsnode, &IID_nsIDocument, (void**)&nsdoc);
|
2006-10-02 20:33:08 +02:00
|
|
|
nsIContentSerializer_AppendDocumentStart(serializer, nsdoc, str);
|
2010-08-25 14:22:25 +02:00
|
|
|
nsIDocument_Release(nsdoc);
|
2006-11-24 10:10:54 +01:00
|
|
|
break;
|
2006-10-02 20:33:08 +02:00
|
|
|
}
|
2009-08-11 19:16:54 +02:00
|
|
|
case DOCUMENT_TYPE_NODE:
|
2013-01-17 15:24:24 +01:00
|
|
|
nsIContentSerializer_AppendDoctype(serializer, nscontent, str);
|
2009-08-11 19:16:54 +02:00
|
|
|
break;
|
2007-06-10 11:54:11 +02:00
|
|
|
case DOCUMENT_FRAGMENT_NODE:
|
|
|
|
break;
|
2006-10-02 20:33:08 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unhandled type %u\n", type);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(has_children) {
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 child_cnt, i;
|
2006-10-02 20:33:08 +02:00
|
|
|
nsIDOMNode *child_node;
|
|
|
|
|
|
|
|
nsIDOMNode_GetChildNodes(nsnode, &node_list);
|
|
|
|
nsIDOMNodeList_GetLength(node_list, &child_cnt);
|
|
|
|
|
|
|
|
for(i=0; i<child_cnt; i++) {
|
|
|
|
nsres = nsIDOMNodeList_Item(node_list, i, &child_node);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsnode_to_nsstring_rec(serializer, child_node, str);
|
|
|
|
nsIDOMNode_Release(child_node);
|
|
|
|
}else {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Item failed: %08lx\n", nsres);
|
2006-10-02 20:33:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMNodeList_Release(node_list);
|
|
|
|
}
|
|
|
|
|
2010-08-25 14:22:25 +02:00
|
|
|
if(type == ELEMENT_NODE)
|
|
|
|
nsIContentSerializer_AppendElementEnd(serializer, nscontent, str);
|
2009-08-11 19:17:19 +02:00
|
|
|
|
2011-08-04 14:05:23 +02:00
|
|
|
if(type != DOCUMENT_NODE)
|
|
|
|
nsIContent_Release(nscontent);
|
2009-08-11 19:17:19 +02:00
|
|
|
return S_OK;
|
2006-10-02 20:33:08 +02:00
|
|
|
}
|
|
|
|
|
2009-08-11 19:17:19 +02:00
|
|
|
HRESULT nsnode_to_nsstring(nsIDOMNode *nsnode, nsAString *str)
|
2006-10-02 20:33:08 +02:00
|
|
|
{
|
|
|
|
nsIContentSerializer *serializer;
|
|
|
|
nsresult nsres;
|
2009-08-11 19:17:19 +02:00
|
|
|
HRESULT hres;
|
2006-10-02 20:33:08 +02:00
|
|
|
|
|
|
|
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr,
|
|
|
|
NS_HTMLSERIALIZER_CONTRACTID, NULL, &IID_nsIContentSerializer,
|
|
|
|
(void**)&serializer);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsIContentSerializer: %08lx\n", nsres);
|
2009-08-11 19:17:19 +02:00
|
|
|
return E_FAIL;
|
2006-10-02 20:33:08 +02:00
|
|
|
}
|
|
|
|
|
2008-12-30 06:48:59 +01:00
|
|
|
nsres = nsIContentSerializer_Init(serializer, 0, 100, NULL, FALSE, FALSE /* FIXME */);
|
2006-10-02 20:33:08 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Init failed: %08lx\n", nsres);
|
2006-10-02 20:33:08 +02:00
|
|
|
|
2009-08-11 19:17:19 +02:00
|
|
|
hres = nsnode_to_nsstring_rec(serializer, nsnode, str);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
nsres = nsIContentSerializer_Flush(serializer, str);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Flush failed: %08lx\n", nsres);
|
2009-08-11 19:17:19 +02:00
|
|
|
}
|
2006-10-02 20:33:08 +02:00
|
|
|
|
|
|
|
nsIContentSerializer_Release(serializer);
|
2009-08-11 19:17:19 +02:00
|
|
|
return hres;
|
2006-10-02 20:33:08 +02:00
|
|
|
}
|
|
|
|
|
2019-03-12 16:11:41 +01:00
|
|
|
void setup_editor_controller(GeckoBrowser *This)
|
2007-06-10 11:49:12 +02:00
|
|
|
{
|
|
|
|
nsIEditingSession *editing_session = NULL;
|
|
|
|
nsIControllerContext *ctrlctx;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2007-09-12 11:41:36 +02:00
|
|
|
if(This->editor) {
|
|
|
|
nsIEditor_Release(This->editor);
|
|
|
|
This->editor = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(This->editor_controller) {
|
|
|
|
nsIController_Release(This->editor_controller);
|
|
|
|
This->editor_controller = NULL;
|
|
|
|
}
|
|
|
|
|
2007-09-26 20:47:02 +02:00
|
|
|
nsres = get_nsinterface((nsISupports*)This->webbrowser, &IID_nsIEditingSession,
|
|
|
|
(void**)&editing_session);
|
2007-06-10 11:49:12 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsIEditingSession: %08lx\n", nsres);
|
2007-09-12 11:41:36 +02:00
|
|
|
return;
|
2007-06-10 11:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIEditingSession_GetEditorForWindow(editing_session,
|
2016-06-13 17:40:51 +02:00
|
|
|
This->doc->basedoc.window->window_proxy, &This->editor);
|
2007-06-10 11:49:12 +02:00
|
|
|
nsIEditingSession_Release(editing_session);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get editor: %08lx\n", nsres);
|
2007-09-12 11:41:36 +02:00
|
|
|
return;
|
2007-06-10 11:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr,
|
|
|
|
NS_EDITORCONTROLLER_CONTRACTID, NULL, &IID_nsIControllerContext, (void**)&ctrlctx);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2007-09-12 11:41:36 +02:00
|
|
|
nsres = nsIControllerContext_SetCommandContext(ctrlctx, (nsISupports *)This->editor);
|
2007-06-10 11:49:12 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("SetCommandContext failed: %08lx\n", nsres);
|
2007-06-10 11:49:12 +02:00
|
|
|
nsres = nsIControllerContext_QueryInterface(ctrlctx, &IID_nsIController,
|
2007-09-12 11:41:36 +02:00
|
|
|
(void**)&This->editor_controller);
|
2007-06-10 11:49:12 +02:00
|
|
|
nsIControllerContext_Release(ctrlctx);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsIController interface: %08lx\n", nsres);
|
2007-06-10 11:49:12 +02:00
|
|
|
}else {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not create edit controller: %08lx\n", nsres);
|
2007-06-10 11:49:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-10 22:00:47 +01:00
|
|
|
void close_gecko(void)
|
2005-08-01 12:59:45 +02:00
|
|
|
{
|
|
|
|
TRACE("()\n");
|
|
|
|
|
2008-12-18 14:08:13 +01:00
|
|
|
release_nsio();
|
2011-03-15 13:45:29 +01:00
|
|
|
init_mutation(NULL);
|
2008-12-18 14:08:13 +01:00
|
|
|
|
2010-08-23 15:07:30 +02:00
|
|
|
if(profile_directory) {
|
|
|
|
nsIFile_Release(profile_directory);
|
|
|
|
profile_directory = NULL;
|
|
|
|
}
|
|
|
|
|
2012-08-29 11:37:57 +02:00
|
|
|
if(plugin_directory) {
|
|
|
|
nsIFile_Release(plugin_directory);
|
|
|
|
plugin_directory = NULL;
|
|
|
|
}
|
|
|
|
|
2005-08-01 12:59:45 +02:00
|
|
|
if(pCompMgr)
|
|
|
|
nsIComponentManager_Release(pCompMgr);
|
|
|
|
|
|
|
|
if(pServMgr)
|
|
|
|
nsIServiceManager_Release(pServMgr);
|
|
|
|
|
2013-09-19 16:12:51 +02:00
|
|
|
if(cat_mgr)
|
|
|
|
nsICategoryManager_Release(cat_mgr);
|
|
|
|
|
2009-08-05 11:21:33 +02:00
|
|
|
/* Gecko doesn't really support being unloaded */
|
|
|
|
/* if (hXPCOM) FreeLibrary(hXPCOM); */
|
2011-11-17 09:52:21 +01:00
|
|
|
|
|
|
|
DeleteCriticalSection(&cs_load_gecko);
|
2005-08-01 12:59:45 +02:00
|
|
|
}
|
|
|
|
|
2010-08-18 13:37:21 +02:00
|
|
|
BOOL is_gecko_path(const char *path)
|
|
|
|
{
|
|
|
|
WCHAR *buf, *ptr;
|
|
|
|
BOOL ret;
|
|
|
|
|
2012-11-27 14:53:29 +01:00
|
|
|
buf = heap_strdupUtoW(path);
|
2019-06-13 08:34:29 +02:00
|
|
|
if(!buf || lstrlenW(buf) < gecko_path_len)
|
2010-08-18 13:37:21 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
for(ptr = buf; *ptr; ptr++) {
|
|
|
|
if(*ptr == '\\')
|
|
|
|
*ptr = '/';
|
|
|
|
}
|
|
|
|
|
2013-03-01 14:14:48 +01:00
|
|
|
UrlUnescapeW(buf, NULL, NULL, URL_UNESCAPE_INPLACE);
|
|
|
|
buf[gecko_path_len] = 0;
|
|
|
|
|
2019-06-13 08:34:29 +02:00
|
|
|
ret = !wcsicmp(buf, gecko_path);
|
2010-08-18 13:37:21 +02:00
|
|
|
heap_free(buf);
|
|
|
|
return ret;
|
|
|
|
}
|
2015-01-23 14:38:16 +01:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
void set_viewer_zoom(GeckoBrowser *browser, float factor)
|
2015-01-23 14:38:16 +01:00
|
|
|
{
|
|
|
|
nsIContentViewer *content_viewer;
|
|
|
|
nsIDocShell *doc_shell;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("Setting to %f\n", factor);
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = get_nsinterface((nsISupports*)browser->navigation, &IID_nsIDocShell, (void**)&doc_shell);
|
2015-01-23 14:38:16 +01:00
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
|
|
|
nsres = nsIDocShell_GetContentViewer(doc_shell, &content_viewer);
|
|
|
|
assert(nsres == NS_OK && content_viewer);
|
|
|
|
nsIDocShell_Release(doc_shell);
|
|
|
|
|
|
|
|
nsres = nsIContentViewer_SetFullZoom(content_viewer, factor);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("SetFullZoom failed: %08lx\n", nsres);
|
2015-01-23 14:38:16 +01:00
|
|
|
|
|
|
|
nsIContentViewer_Release(content_viewer);
|
|
|
|
}
|
2010-08-18 13:37:21 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
float get_viewer_zoom(GeckoBrowser *browser)
|
2018-10-03 21:43:44 +02:00
|
|
|
{
|
|
|
|
nsIContentViewer *content_viewer;
|
|
|
|
nsIDocShell *doc_shell;
|
|
|
|
nsresult nsres;
|
|
|
|
float factor;
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = get_nsinterface((nsISupports*)browser->navigation, &IID_nsIDocShell, (void**)&doc_shell);
|
2018-10-03 21:43:44 +02:00
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
|
|
|
nsres = nsIDocShell_GetContentViewer(doc_shell, &content_viewer);
|
|
|
|
assert(nsres == NS_OK && content_viewer);
|
|
|
|
nsIDocShell_Release(doc_shell);
|
|
|
|
|
|
|
|
nsres = nsIContentViewer_GetFullZoom(content_viewer, &factor);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("GetFullZoom failed: %08lx\n", nsres);
|
2018-10-03 21:43:44 +02:00
|
|
|
TRACE("Got %f\n", factor);
|
|
|
|
|
|
|
|
nsIContentViewer_Release(content_viewer);
|
|
|
|
return factor;
|
|
|
|
}
|
|
|
|
|
2011-04-22 14:07:18 +02:00
|
|
|
struct nsWeakReference {
|
|
|
|
nsIWeakReference nsIWeakReference_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *browser;
|
2011-04-22 14:07:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline nsWeakReference *impl_from_nsIWeakReference(nsIWeakReference *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, nsWeakReference, nsIWeakReference_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWeakReference_QueryInterface(nsIWeakReference *iface,
|
|
|
|
nsIIDRef riid, void **result)
|
|
|
|
{
|
|
|
|
nsWeakReference *This = impl_from_nsIWeakReference(iface);
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports %p)\n", This, result);
|
|
|
|
*result = &This->nsIWeakReference_iface;
|
|
|
|
}else if(IsEqualGUID(&IID_nsIWeakReference, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIWeakReference %p)\n", This, result);
|
|
|
|
*result = &This->nsIWeakReference_iface;
|
|
|
|
}else {
|
|
|
|
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
|
|
|
|
*result = NULL;
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsISupports_AddRef((nsISupports*)*result);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsWeakReference_AddRef(nsIWeakReference *iface)
|
|
|
|
{
|
|
|
|
nsWeakReference *This = impl_from_nsIWeakReference(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2011-04-22 14:07:18 +02:00
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsWeakReference_Release(nsIWeakReference *iface)
|
|
|
|
{
|
|
|
|
nsWeakReference *This = impl_from_nsIWeakReference(iface);
|
2017-03-21 06:56:50 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
2011-04-22 14:07:18 +02:00
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2011-04-22 14:07:18 +02:00
|
|
|
|
|
|
|
if(!ref) {
|
2019-03-11 14:22:24 +01:00
|
|
|
assert(!This->browser);
|
2011-04-22 14:07:18 +02:00
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWeakReference_QueryReferent(nsIWeakReference *iface,
|
|
|
|
const nsIID *riid, void **result)
|
|
|
|
{
|
|
|
|
nsWeakReference *This = impl_from_nsIWeakReference(iface);
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
if(!This->browser)
|
2011-04-22 14:07:18 +02:00
|
|
|
return NS_ERROR_NULL_POINTER;
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
return nsIWebBrowserChrome_QueryInterface(&This->browser->nsIWebBrowserChrome_iface, riid, result);
|
2011-04-22 14:07:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIWeakReferenceVtbl nsWeakReferenceVtbl = {
|
|
|
|
nsWeakReference_QueryInterface,
|
|
|
|
nsWeakReference_AddRef,
|
|
|
|
nsWeakReference_Release,
|
|
|
|
nsWeakReference_QueryReferent
|
|
|
|
};
|
|
|
|
|
2005-09-02 14:19:42 +02:00
|
|
|
/**********************************************************
|
|
|
|
* nsIWebBrowserChrome interface
|
|
|
|
*/
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static inline GeckoBrowser *impl_from_nsIWebBrowserChrome(nsIWebBrowserChrome *iface)
|
2010-12-27 23:27:55 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
return CONTAINING_RECORD(iface, GeckoBrowser, nsIWebBrowserChrome_iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
}
|
2005-08-25 21:24:58 +02:00
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_QueryInterface(nsIWebBrowserChrome *iface,
|
2010-08-02 11:08:26 +02:00
|
|
|
nsIIDRef riid, void **result)
|
2005-08-25 21:24:58 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports, %p)\n", This, result);
|
2010-12-27 23:27:55 +01:00
|
|
|
*result = &This->nsIWebBrowserChrome_iface;
|
2005-08-25 21:24:58 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIWebBrowserChrome, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIWebBrowserChrome, %p)\n", This, result);
|
2010-12-27 23:27:55 +01:00
|
|
|
*result = &This->nsIWebBrowserChrome_iface;
|
2005-08-25 21:24:58 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIContextMenuListener, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIContextMenuListener, %p)\n", This, result);
|
2010-12-27 23:30:53 +01:00
|
|
|
*result = &This->nsIContextMenuListener_iface;
|
2005-12-09 11:41:33 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIURIContentListener, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIURIContentListener %p)\n", This, result);
|
2010-12-27 23:30:53 +01:00
|
|
|
*result = &This->nsIURIContentListener_iface;
|
2005-12-09 11:23:58 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIEmbeddingSiteWindow, riid)) {
|
2006-02-15 11:51:44 +01:00
|
|
|
TRACE("(%p)->(IID_nsIEmbeddingSiteWindow %p)\n", This, result);
|
2010-12-27 23:30:53 +01:00
|
|
|
*result = &This->nsIEmbeddingSiteWindow_iface;
|
2006-03-27 21:02:28 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsITooltipListener, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsITooltipListener %p)\n", This, result);
|
2010-12-27 23:30:53 +01:00
|
|
|
*result = &This->nsITooltipListener_iface;
|
2006-02-27 19:08:23 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIInterfaceRequestor, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIInterfaceRequestor %p)\n", This, result);
|
2010-12-27 23:30:53 +01:00
|
|
|
*result = &This->nsIInterfaceRequestor_iface;
|
2006-03-27 21:02:28 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsISupportsWeakReference, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupportsWeakReference %p)\n", This, result);
|
2010-12-27 23:30:53 +01:00
|
|
|
*result = &This->nsISupportsWeakReference_iface;
|
2005-08-25 21:24:58 +02:00
|
|
|
}
|
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
if(*result) {
|
2010-12-27 23:27:55 +01:00
|
|
|
nsIWebBrowserChrome_AddRef(&This->nsIWebBrowserChrome_iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
return NS_OK;
|
2006-02-15 11:51:44 +01:00
|
|
|
}
|
2005-08-25 21:24:58 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
|
|
|
|
return NS_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsWebBrowserChrome_AddRef(nsIWebBrowserChrome *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2006-02-15 11:51:44 +01:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2006-02-15 11:51:44 +01:00
|
|
|
|
|
|
|
return ref;
|
2005-08-25 21:24:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsWebBrowserChrome_Release(nsIWebBrowserChrome *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2006-02-15 11:51:44 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2022-02-15 07:29:41 +01:00
|
|
|
TRACE("(%p) ref=%ld\n", This, ref);
|
2006-02-15 11:51:44 +01:00
|
|
|
|
2006-03-01 22:04:51 +01:00
|
|
|
if(!ref) {
|
2019-03-11 14:24:26 +01:00
|
|
|
if(This->doc)
|
|
|
|
detach_gecko_browser(This);
|
2011-04-22 14:07:18 +02:00
|
|
|
if(This->weak_reference) {
|
2019-03-11 14:22:24 +01:00
|
|
|
This->weak_reference->browser = NULL;
|
2011-04-22 14:07:18 +02:00
|
|
|
nsIWeakReference_Release(&This->weak_reference->nsIWeakReference_iface);
|
|
|
|
}
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2006-03-01 22:04:51 +01:00
|
|
|
}
|
2006-02-15 11:51:44 +01:00
|
|
|
|
|
|
|
return ref;
|
2005-08-25 21:24:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_SetStatus(nsIWebBrowserChrome *iface,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 statusType, const PRUnichar *status)
|
2005-08-25 21:24:58 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%d %s)\n", This, statusType, debugstr_w(status));
|
2008-10-08 20:27:25 +02:00
|
|
|
return NS_OK;
|
2005-08-25 21:24:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_GetWebBrowser(nsIWebBrowserChrome *iface,
|
|
|
|
nsIWebBrowser **aWebBrowser)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aWebBrowser);
|
|
|
|
|
|
|
|
if(!aWebBrowser)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
if(This->webbrowser)
|
|
|
|
nsIWebBrowser_AddRef(This->webbrowser);
|
2005-08-25 21:24:58 +02:00
|
|
|
*aWebBrowser = This->webbrowser;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_SetWebBrowser(nsIWebBrowserChrome *iface,
|
|
|
|
nsIWebBrowser *aWebBrowser)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aWebBrowser);
|
|
|
|
|
|
|
|
if(aWebBrowser != This->webbrowser)
|
|
|
|
ERR("Wrong nsWebBrowser!\n");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_GetChromeFlags(nsIWebBrowserChrome *iface,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 *aChromeFlags)
|
2005-08-25 21:24:58 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
WARN("(%p)->(%p)\n", This, aChromeFlags);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_SetChromeFlags(nsIWebBrowserChrome *iface,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 aChromeFlags)
|
2005-08-25 21:24:58 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("(%p)->(%08x)\n", This, aChromeFlags);
|
2005-08-25 21:24:58 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_DestroyBrowserWindow(nsIWebBrowserChrome *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_SizeBrowserTo(nsIWebBrowserChrome *iface,
|
2013-01-18 14:05:59 +01:00
|
|
|
LONG aCX, LONG aCY)
|
2005-08-25 21:24:58 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2022-02-15 07:29:41 +01:00
|
|
|
WARN("(%p)->(%ld %ld)\n", This, aCX, aCY);
|
2005-08-25 21:24:58 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_ShowAsModal(nsIWebBrowserChrome *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
WARN("(%p)\n", This);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2012-03-15 11:54:48 +01:00
|
|
|
static nsresult NSAPI nsWebBrowserChrome_IsWindowModal(nsIWebBrowserChrome *iface, cpp_bool *_retval)
|
2005-08-25 21:24:58 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
WARN("(%p)->(%p)\n", This, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_ExitModalEventLoop(nsIWebBrowserChrome *iface,
|
|
|
|
nsresult aStatus)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIWebBrowserChrome(iface);
|
2022-02-15 07:29:41 +01:00
|
|
|
WARN("(%p)->(%08lx)\n", This, aStatus);
|
2005-08-25 21:24:58 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIWebBrowserChromeVtbl nsWebBrowserChromeVtbl = {
|
|
|
|
nsWebBrowserChrome_QueryInterface,
|
|
|
|
nsWebBrowserChrome_AddRef,
|
|
|
|
nsWebBrowserChrome_Release,
|
|
|
|
nsWebBrowserChrome_SetStatus,
|
|
|
|
nsWebBrowserChrome_GetWebBrowser,
|
|
|
|
nsWebBrowserChrome_SetWebBrowser,
|
|
|
|
nsWebBrowserChrome_GetChromeFlags,
|
|
|
|
nsWebBrowserChrome_SetChromeFlags,
|
|
|
|
nsWebBrowserChrome_DestroyBrowserWindow,
|
|
|
|
nsWebBrowserChrome_SizeBrowserTo,
|
|
|
|
nsWebBrowserChrome_ShowAsModal,
|
|
|
|
nsWebBrowserChrome_IsWindowModal,
|
|
|
|
nsWebBrowserChrome_ExitModalEventLoop
|
|
|
|
};
|
|
|
|
|
2005-09-02 14:19:42 +02:00
|
|
|
/**********************************************************
|
|
|
|
* nsIContextMenuListener interface
|
|
|
|
*/
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static inline GeckoBrowser *impl_from_nsIContextMenuListener(nsIContextMenuListener *iface)
|
2010-12-27 23:30:53 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
return CONTAINING_RECORD(iface, GeckoBrowser, nsIContextMenuListener_iface);
|
2010-12-27 23:30:53 +01:00
|
|
|
}
|
2005-08-25 21:24:58 +02:00
|
|
|
|
|
|
|
static nsresult NSAPI nsContextMenuListener_QueryInterface(nsIContextMenuListener *iface,
|
2010-08-02 11:08:26 +02:00
|
|
|
nsIIDRef riid, void **result)
|
2005-08-25 21:24:58 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIContextMenuListener(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_QueryInterface(&This->nsIWebBrowserChrome_iface, riid, result);
|
2005-08-25 21:24:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsContextMenuListener_AddRef(nsIContextMenuListener *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIContextMenuListener(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_AddRef(&This->nsIWebBrowserChrome_iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsContextMenuListener_Release(nsIContextMenuListener *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIContextMenuListener(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface);
|
2005-08-25 21:24:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuListener *iface,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
|
2005-08-25 21:24:58 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIContextMenuListener(iface);
|
2017-10-20 15:09:29 +02:00
|
|
|
nsIDOMMouseEvent *mouse_event;
|
2010-12-01 12:52:08 +01:00
|
|
|
HTMLDOMNode *node;
|
2017-10-20 15:09:29 +02:00
|
|
|
DOMEvent *event;
|
2005-08-25 21:24:58 +02:00
|
|
|
POINT pt;
|
|
|
|
DWORD dwID = CONTEXT_MENU_DEFAULT;
|
|
|
|
nsresult nsres;
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT hres;
|
2005-08-25 21:24:58 +02:00
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p)->(%08x %p %p)\n", This, aContextFlags, aEvent, aNode);
|
2005-08-25 21:24:58 +02:00
|
|
|
|
2019-05-31 16:53:48 +02:00
|
|
|
if (!aNode)
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(aNode, TRUE, &node);
|
2016-04-04 13:21:58 +02:00
|
|
|
if(FAILED(hres))
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2021-03-11 20:40:19 +01:00
|
|
|
hres = create_event_from_nsevent(aEvent, dispex_compat_mode(&node->event_target.dispex), &event);
|
2017-10-20 15:09:29 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
2017-10-20 15:10:46 +02:00
|
|
|
dispatch_event(&node->event_target, event);
|
2017-10-20 15:09:29 +02:00
|
|
|
IDOMEvent_Release(&event->IDOMEvent_iface);
|
|
|
|
}
|
2010-05-07 15:20:33 +02:00
|
|
|
|
2017-10-20 15:09:29 +02:00
|
|
|
nsres = nsIDOMEvent_QueryInterface(aEvent, &IID_nsIDOMMouseEvent, (void**)&mouse_event);
|
2016-04-04 13:21:58 +02:00
|
|
|
assert(NS_SUCCEEDED(nsres));
|
2005-08-25 21:24:58 +02:00
|
|
|
|
2017-10-20 15:09:29 +02:00
|
|
|
nsIDOMMouseEvent_GetScreenX(mouse_event, &pt.x);
|
|
|
|
nsIDOMMouseEvent_GetScreenY(mouse_event, &pt.y);
|
|
|
|
nsIDOMMouseEvent_Release(mouse_event);
|
2005-08-25 21:24:58 +02:00
|
|
|
|
|
|
|
switch(aContextFlags) {
|
|
|
|
case CONTEXT_NONE:
|
|
|
|
case CONTEXT_DOCUMENT:
|
2015-02-23 14:08:12 +01:00
|
|
|
case CONTEXT_TEXT: {
|
|
|
|
nsISelection *selection;
|
|
|
|
|
|
|
|
nsres = nsIDOMHTMLDocument_GetSelection(This->doc->basedoc.doc_node->nsdoc, &selection);
|
|
|
|
if(NS_SUCCEEDED(nsres) && selection) {
|
|
|
|
cpp_bool is_collapsed;
|
|
|
|
|
|
|
|
/* FIXME: Check if the click was inside selection. */
|
|
|
|
nsres = nsISelection_GetIsCollapsed(selection, &is_collapsed);
|
|
|
|
nsISelection_Release(selection);
|
|
|
|
if(NS_SUCCEEDED(nsres) && !is_collapsed)
|
|
|
|
dwID = CONTEXT_MENU_TEXTSELECT;
|
|
|
|
}
|
2005-08-25 21:24:58 +02:00
|
|
|
break;
|
2015-02-23 14:08:12 +01:00
|
|
|
}
|
2005-08-25 21:24:58 +02:00
|
|
|
case CONTEXT_IMAGE:
|
|
|
|
case CONTEXT_IMAGE|CONTEXT_LINK:
|
|
|
|
dwID = CONTEXT_MENU_IMAGE;
|
|
|
|
break;
|
|
|
|
case CONTEXT_LINK:
|
|
|
|
dwID = CONTEXT_MENU_ANCHOR;
|
|
|
|
break;
|
|
|
|
case CONTEXT_INPUT:
|
|
|
|
dwID = CONTEXT_MENU_CONTROL;
|
|
|
|
break;
|
|
|
|
default:
|
2006-10-05 23:50:39 +02:00
|
|
|
FIXME("aContextFlags=%08x\n", aContextFlags);
|
2005-08-25 21:24:58 +02:00
|
|
|
};
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
show_context_menu(This->doc, dwID, &pt, (IDispatch*)&node->IHTMLDOMNode_iface);
|
2012-06-25 14:04:40 +02:00
|
|
|
node_release(node);
|
2005-08-25 21:24:58 +02:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIContextMenuListenerVtbl nsContextMenuListenerVtbl = {
|
|
|
|
nsContextMenuListener_QueryInterface,
|
|
|
|
nsContextMenuListener_AddRef,
|
|
|
|
nsContextMenuListener_Release,
|
|
|
|
nsContextMenuListener_OnShowContextMenu
|
|
|
|
};
|
|
|
|
|
2005-09-02 14:19:42 +02:00
|
|
|
/**********************************************************
|
|
|
|
* nsIURIContentListener interface
|
|
|
|
*/
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static inline GeckoBrowser *impl_from_nsIURIContentListener(nsIURIContentListener *iface)
|
2010-12-27 23:30:53 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
return CONTAINING_RECORD(iface, GeckoBrowser, nsIURIContentListener_iface);
|
2010-12-27 23:30:53 +01:00
|
|
|
}
|
2005-09-02 14:19:42 +02:00
|
|
|
|
|
|
|
static nsresult NSAPI nsURIContentListener_QueryInterface(nsIURIContentListener *iface,
|
2010-08-02 11:08:26 +02:00
|
|
|
nsIIDRef riid, void **result)
|
2005-09-02 14:19:42 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_QueryInterface(&This->nsIWebBrowserChrome_iface, riid, result);
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsURIContentListener_AddRef(nsIURIContentListener *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_AddRef(&This->nsIWebBrowserChrome_iface);
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsURIContentListener_Release(nsIURIContentListener *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface);
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
2006-02-09 12:19:33 +01:00
|
|
|
static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener *iface,
|
2012-03-15 11:54:48 +01:00
|
|
|
nsIURI *aURI, cpp_bool *_retval)
|
2005-09-02 14:19:42 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2006-03-18 22:00:34 +01:00
|
|
|
nsACString spec_str;
|
2006-02-09 12:19:33 +01:00
|
|
|
const char *spec;
|
2005-09-02 14:19:42 +02:00
|
|
|
|
2006-03-18 22:00:34 +01:00
|
|
|
nsACString_Init(&spec_str, NULL);
|
|
|
|
nsIURI_GetSpec(aURI, &spec_str);
|
2007-12-17 01:38:15 +01:00
|
|
|
nsACString_GetData(&spec_str, &spec);
|
2005-09-02 14:19:42 +02:00
|
|
|
|
2006-02-09 12:19:33 +01:00
|
|
|
TRACE("(%p)->(%p(%s) %p)\n", This, aURI, debugstr_a(spec), _retval);
|
2005-09-02 14:19:42 +02:00
|
|
|
|
2006-03-18 22:00:34 +01:00
|
|
|
nsACString_Finish(&spec_str);
|
2005-09-02 14:19:42 +02:00
|
|
|
|
2019-03-08 13:49:19 +01:00
|
|
|
return This->content_listener
|
2006-08-16 16:34:32 +02:00
|
|
|
? nsIURIContentListener_OnStartURIOpen(This->content_listener, aURI, _retval)
|
|
|
|
: NS_OK;
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURIContentListener_DoContent(nsIURIContentListener *iface,
|
2015-08-11 15:11:35 +02:00
|
|
|
const nsACString *aContentType, cpp_bool aIsContentPreferred, nsIRequest *aRequest,
|
2012-03-15 11:54:48 +01:00
|
|
|
nsIStreamListener **aContentHandler, cpp_bool *_retval)
|
2005-09-02 14:19:42 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
2015-08-11 15:11:35 +02:00
|
|
|
TRACE("(%p)->(%p %x %p %p %p)\n", This, aContentType, aIsContentPreferred,
|
2005-09-02 14:19:42 +02:00
|
|
|
aRequest, aContentHandler, _retval);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
|
|
|
return This->content_listener
|
|
|
|
? nsIURIContentListener_DoContent(This->content_listener, aContentType,
|
|
|
|
aIsContentPreferred, aRequest, aContentHandler, _retval)
|
|
|
|
: NS_ERROR_NOT_IMPLEMENTED;
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURIContentListener_IsPreferred(nsIURIContentListener *iface,
|
2012-03-15 11:54:48 +01:00
|
|
|
const char *aContentType, char **aDesiredContentType, cpp_bool *_retval)
|
2005-09-02 14:19:42 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2005-09-02 14:19:42 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%s %p %p)\n", This, debugstr_a(aContentType), aDesiredContentType, _retval);
|
|
|
|
|
|
|
|
/* FIXME: Should we do something here? */
|
|
|
|
*_retval = TRUE;
|
2006-08-16 16:34:32 +02:00
|
|
|
|
|
|
|
return This->content_listener
|
|
|
|
? nsIURIContentListener_IsPreferred(This->content_listener, aContentType,
|
|
|
|
aDesiredContentType, _retval)
|
|
|
|
: NS_OK;
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURIContentListener_CanHandleContent(nsIURIContentListener *iface,
|
2012-03-15 11:54:48 +01:00
|
|
|
const char *aContentType, cpp_bool aIsContentPreferred, char **aDesiredContentType,
|
|
|
|
cpp_bool *_retval)
|
2005-09-02 14:19:42 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
2005-09-02 14:19:42 +02:00
|
|
|
TRACE("(%p)->(%s %x %p %p)\n", This, debugstr_a(aContentType), aIsContentPreferred,
|
|
|
|
aDesiredContentType, _retval);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
|
|
|
return This->content_listener
|
|
|
|
? nsIURIContentListener_CanHandleContent(This->content_listener, aContentType,
|
|
|
|
aIsContentPreferred, aDesiredContentType, _retval)
|
|
|
|
: NS_ERROR_NOT_IMPLEMENTED;
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURIContentListener_GetLoadCookie(nsIURIContentListener *iface,
|
|
|
|
nsISupports **aLoadCookie)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
2005-09-02 14:19:42 +02:00
|
|
|
WARN("(%p)->(%p)\n", This, aLoadCookie);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
|
|
|
return This->content_listener
|
|
|
|
? nsIURIContentListener_GetLoadCookie(This->content_listener, aLoadCookie)
|
|
|
|
: NS_ERROR_NOT_IMPLEMENTED;
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURIContentListener_SetLoadCookie(nsIURIContentListener *iface,
|
|
|
|
nsISupports *aLoadCookie)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
2005-09-02 14:19:42 +02:00
|
|
|
WARN("(%p)->(%p)\n", This, aLoadCookie);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
|
|
|
return This->content_listener
|
|
|
|
? nsIURIContentListener_SetLoadCookie(This->content_listener, aLoadCookie)
|
|
|
|
: NS_ERROR_NOT_IMPLEMENTED;
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURIContentListener_GetParentContentListener(nsIURIContentListener *iface,
|
|
|
|
nsIURIContentListener **aParentContentListener)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aParentContentListener);
|
|
|
|
|
|
|
|
if(This->content_listener)
|
|
|
|
nsIURIContentListener_AddRef(This->content_listener);
|
|
|
|
|
|
|
|
*aParentContentListener = This->content_listener;
|
|
|
|
return NS_OK;
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURIContentListener_SetParentContentListener(nsIURIContentListener *iface,
|
|
|
|
nsIURIContentListener *aParentContentListener)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIURIContentListener(iface);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aParentContentListener);
|
|
|
|
|
2010-12-27 23:30:53 +01:00
|
|
|
if(aParentContentListener == &This->nsIURIContentListener_iface)
|
2006-08-16 16:34:32 +02:00
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
if(This->content_listener)
|
|
|
|
nsIURIContentListener_Release(This->content_listener);
|
|
|
|
|
|
|
|
This->content_listener = aParentContentListener;
|
|
|
|
if(This->content_listener)
|
|
|
|
nsIURIContentListener_AddRef(This->content_listener);
|
|
|
|
|
|
|
|
return NS_OK;
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIURIContentListenerVtbl nsURIContentListenerVtbl = {
|
|
|
|
nsURIContentListener_QueryInterface,
|
|
|
|
nsURIContentListener_AddRef,
|
|
|
|
nsURIContentListener_Release,
|
|
|
|
nsURIContentListener_OnStartURIOpen,
|
|
|
|
nsURIContentListener_DoContent,
|
|
|
|
nsURIContentListener_IsPreferred,
|
|
|
|
nsURIContentListener_CanHandleContent,
|
|
|
|
nsURIContentListener_GetLoadCookie,
|
|
|
|
nsURIContentListener_SetLoadCookie,
|
|
|
|
nsURIContentListener_GetParentContentListener,
|
|
|
|
nsURIContentListener_SetParentContentListener
|
|
|
|
};
|
|
|
|
|
2005-12-09 11:23:58 +01:00
|
|
|
/**********************************************************
|
|
|
|
* nsIEmbeddinSiteWindow interface
|
|
|
|
*/
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static inline GeckoBrowser *impl_from_nsIEmbeddingSiteWindow(nsIEmbeddingSiteWindow *iface)
|
2010-12-27 23:30:53 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
return CONTAINING_RECORD(iface, GeckoBrowser, nsIEmbeddingSiteWindow_iface);
|
2010-12-27 23:30:53 +01:00
|
|
|
}
|
2005-12-09 11:23:58 +01:00
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_QueryInterface(nsIEmbeddingSiteWindow *iface,
|
2010-08-02 11:08:26 +02:00
|
|
|
nsIIDRef riid, void **result)
|
2005-12-09 11:23:58 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_QueryInterface(&This->nsIWebBrowserChrome_iface, riid, result);
|
2005-12-09 11:23:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsEmbeddingSiteWindow_AddRef(nsIEmbeddingSiteWindow *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_AddRef(&This->nsIWebBrowserChrome_iface);
|
2005-12-09 11:23:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsEmbeddingSiteWindow_Release(nsIEmbeddingSiteWindow *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface);
|
2005-12-09 11:23:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_SetDimensions(nsIEmbeddingSiteWindow *iface,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 flags, LONG x, LONG y, LONG cx, LONG cy)
|
2005-12-09 11:23:58 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2022-02-15 07:29:41 +01:00
|
|
|
WARN("(%p)->(%08x %ld %ld %ld %ld)\n", This, flags, x, y, cx, cy);
|
2005-12-09 11:23:58 +01:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_GetDimensions(nsIEmbeddingSiteWindow *iface,
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 flags, LONG *x, LONG *y, LONG *cx, LONG *cy)
|
2005-12-09 11:23:58 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2014-12-23 21:12:36 +01:00
|
|
|
RECT r;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%x %p %p %p %p)\n", This, flags, x, y, cx, cy);
|
|
|
|
|
|
|
|
if(!GetWindowRect(This->hwnd, &r)) {
|
|
|
|
ERR("GetWindowRect failed\n");
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(x)
|
|
|
|
*x = r.left;
|
|
|
|
if(y)
|
|
|
|
*y = r.top;
|
|
|
|
if(cx)
|
|
|
|
*cx = r.right-r.left;
|
|
|
|
if(cy)
|
|
|
|
*cy = r.bottom-r.top;
|
|
|
|
return NS_OK;
|
2005-12-09 11:23:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_SetFocus(nsIEmbeddingSiteWindow *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2007-06-22 23:30:23 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
return nsIBaseWindow_SetFocus(This->window);
|
2005-12-09 11:23:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_GetVisibility(nsIEmbeddingSiteWindow *iface,
|
2012-03-15 11:54:48 +01:00
|
|
|
cpp_bool *aVisibility)
|
2005-12-09 11:23:58 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2007-06-22 23:31:43 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aVisibility);
|
|
|
|
|
2009-09-16 22:10:47 +02:00
|
|
|
*aVisibility = This->doc && This->doc->hwnd && IsWindowVisible(This->doc->hwnd);
|
2007-06-22 23:31:43 +02:00
|
|
|
return NS_OK;
|
2005-12-09 11:23:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_SetVisibility(nsIEmbeddingSiteWindow *iface,
|
2012-03-15 11:54:48 +01:00
|
|
|
cpp_bool aVisibility)
|
2005-12-09 11:23:58 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2007-06-22 23:31:43 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%x)\n", This, aVisibility);
|
|
|
|
|
|
|
|
return NS_OK;
|
2005-12-09 11:23:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_GetTitle(nsIEmbeddingSiteWindow *iface,
|
|
|
|
PRUnichar **aTitle)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2005-12-09 11:23:58 +01:00
|
|
|
WARN("(%p)->(%p)\n", This, aTitle);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_SetTitle(nsIEmbeddingSiteWindow *iface,
|
|
|
|
const PRUnichar *aTitle)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2005-12-09 11:23:58 +01:00
|
|
|
WARN("(%p)->(%s)\n", This, debugstr_w(aTitle));
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_GetSiteWindow(nsIEmbeddingSiteWindow *iface,
|
|
|
|
void **aSiteWindow)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIEmbeddingSiteWindow(iface);
|
2005-12-09 11:23:58 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aSiteWindow);
|
|
|
|
|
|
|
|
*aSiteWindow = This->hwnd;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIEmbeddingSiteWindowVtbl nsEmbeddingSiteWindowVtbl = {
|
|
|
|
nsEmbeddingSiteWindow_QueryInterface,
|
|
|
|
nsEmbeddingSiteWindow_AddRef,
|
|
|
|
nsEmbeddingSiteWindow_Release,
|
|
|
|
nsEmbeddingSiteWindow_SetDimensions,
|
|
|
|
nsEmbeddingSiteWindow_GetDimensions,
|
|
|
|
nsEmbeddingSiteWindow_SetFocus,
|
|
|
|
nsEmbeddingSiteWindow_GetVisibility,
|
|
|
|
nsEmbeddingSiteWindow_SetVisibility,
|
|
|
|
nsEmbeddingSiteWindow_GetTitle,
|
|
|
|
nsEmbeddingSiteWindow_SetTitle,
|
|
|
|
nsEmbeddingSiteWindow_GetSiteWindow
|
|
|
|
};
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static inline GeckoBrowser *impl_from_nsITooltipListener(nsITooltipListener *iface)
|
2010-12-27 23:30:53 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
return CONTAINING_RECORD(iface, GeckoBrowser, nsITooltipListener_iface);
|
2010-12-27 23:30:53 +01:00
|
|
|
}
|
2006-03-27 21:02:28 +02:00
|
|
|
|
|
|
|
static nsresult NSAPI nsTooltipListener_QueryInterface(nsITooltipListener *iface, nsIIDRef riid,
|
2010-08-02 11:08:26 +02:00
|
|
|
void **result)
|
2006-03-27 21:02:28 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsITooltipListener(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_QueryInterface(&This->nsIWebBrowserChrome_iface, riid, result);
|
2006-03-27 21:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsTooltipListener_AddRef(nsITooltipListener *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsITooltipListener(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_AddRef(&This->nsIWebBrowserChrome_iface);
|
2006-03-27 21:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsTooltipListener_Release(nsITooltipListener *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsITooltipListener(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface);
|
2006-03-27 21:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsTooltipListener_OnShowTooltip(nsITooltipListener *iface,
|
2013-01-18 14:05:59 +01:00
|
|
|
LONG aXCoord, LONG aYCoord, const PRUnichar *aTipText)
|
2006-03-27 21:02:28 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsITooltipListener(iface);
|
2006-03-27 21:02:28 +02:00
|
|
|
|
2008-12-27 18:28:42 +01:00
|
|
|
if (This->doc)
|
2009-09-16 22:10:47 +02:00
|
|
|
show_tooltip(This->doc, aXCoord, aYCoord, aTipText);
|
2006-03-27 21:02:28 +02:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsTooltipListener_OnHideTooltip(nsITooltipListener *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsITooltipListener(iface);
|
2006-03-27 21:02:28 +02:00
|
|
|
|
2008-12-27 18:28:42 +01:00
|
|
|
if (This->doc)
|
2009-09-16 22:10:47 +02:00
|
|
|
hide_tooltip(This->doc);
|
2006-03-27 21:02:28 +02:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const nsITooltipListenerVtbl nsTooltipListenerVtbl = {
|
|
|
|
nsTooltipListener_QueryInterface,
|
|
|
|
nsTooltipListener_AddRef,
|
|
|
|
nsTooltipListener_Release,
|
|
|
|
nsTooltipListener_OnShowTooltip,
|
|
|
|
nsTooltipListener_OnHideTooltip
|
|
|
|
};
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static inline GeckoBrowser *impl_from_nsIInterfaceRequestor(nsIInterfaceRequestor *iface)
|
2010-12-27 23:30:53 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
return CONTAINING_RECORD(iface, GeckoBrowser, nsIInterfaceRequestor_iface);
|
2010-12-27 23:30:53 +01:00
|
|
|
}
|
2006-02-27 19:08:23 +01:00
|
|
|
|
|
|
|
static nsresult NSAPI nsInterfaceRequestor_QueryInterface(nsIInterfaceRequestor *iface,
|
2010-08-02 11:08:26 +02:00
|
|
|
nsIIDRef riid, void **result)
|
2006-02-27 19:08:23 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIInterfaceRequestor(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_QueryInterface(&This->nsIWebBrowserChrome_iface, riid, result);
|
2006-02-27 19:08:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsInterfaceRequestor_AddRef(nsIInterfaceRequestor *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIInterfaceRequestor(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_AddRef(&This->nsIWebBrowserChrome_iface);
|
2006-02-27 19:08:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsInterfaceRequestor_Release(nsIInterfaceRequestor *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIInterfaceRequestor(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface);
|
2006-02-27 19:08:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInterfaceRequestor_GetInterface(nsIInterfaceRequestor *iface,
|
2010-08-02 11:08:26 +02:00
|
|
|
nsIIDRef riid, void **result)
|
2006-02-27 19:08:23 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsIInterfaceRequestor(iface);
|
2006-02-27 19:08:23 +01:00
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
if(IsEqualGUID(&IID_mozIDOMWindowProxy, riid)) {
|
2006-03-01 22:04:51 +01:00
|
|
|
TRACE("(%p)->(IID_nsIDOMWindow %p)\n", This, result);
|
2016-06-13 17:40:51 +02:00
|
|
|
return nsIWebBrowser_GetContentDOMWindow(This->webbrowser, (mozIDOMWindowProxy**)result);
|
2006-02-27 19:08:23 +01:00
|
|
|
}
|
|
|
|
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_QueryInterface(&This->nsIWebBrowserChrome_iface, riid, result);
|
2006-02-27 19:08:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const nsIInterfaceRequestorVtbl nsInterfaceRequestorVtbl = {
|
|
|
|
nsInterfaceRequestor_QueryInterface,
|
|
|
|
nsInterfaceRequestor_AddRef,
|
|
|
|
nsInterfaceRequestor_Release,
|
|
|
|
nsInterfaceRequestor_GetInterface
|
|
|
|
};
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static inline GeckoBrowser *impl_from_nsISupportsWeakReference(nsISupportsWeakReference *iface)
|
2010-12-27 23:30:53 +01:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
return CONTAINING_RECORD(iface, GeckoBrowser, nsISupportsWeakReference_iface);
|
2010-12-27 23:30:53 +01:00
|
|
|
}
|
2006-03-27 21:02:28 +02:00
|
|
|
|
|
|
|
static nsresult NSAPI nsSupportsWeakReference_QueryInterface(nsISupportsWeakReference *iface,
|
2010-08-02 11:08:26 +02:00
|
|
|
nsIIDRef riid, void **result)
|
2006-03-27 21:02:28 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsISupportsWeakReference(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_QueryInterface(&This->nsIWebBrowserChrome_iface, riid, result);
|
2006-03-27 21:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsSupportsWeakReference_AddRef(nsISupportsWeakReference *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsISupportsWeakReference(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_AddRef(&This->nsIWebBrowserChrome_iface);
|
2006-03-27 21:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsSupportsWeakReference_Release(nsISupportsWeakReference *iface)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsISupportsWeakReference(iface);
|
2010-12-27 23:27:55 +01:00
|
|
|
return nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface);
|
2006-03-27 21:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsSupportsWeakReference_GetWeakReference(nsISupportsWeakReference *iface,
|
|
|
|
nsIWeakReference **_retval)
|
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *This = impl_from_nsISupportsWeakReference(iface);
|
2006-03-27 21:02:28 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, _retval);
|
|
|
|
|
2011-04-22 14:07:18 +02:00
|
|
|
if(!This->weak_reference) {
|
|
|
|
This->weak_reference = heap_alloc(sizeof(nsWeakReference));
|
|
|
|
if(!This->weak_reference)
|
|
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
This->weak_reference->nsIWeakReference_iface.lpVtbl = &nsWeakReferenceVtbl;
|
|
|
|
This->weak_reference->ref = 1;
|
2019-03-11 14:22:24 +01:00
|
|
|
This->weak_reference->browser = This;
|
2011-04-22 14:07:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
*_retval = &This->weak_reference->nsIWeakReference_iface;
|
|
|
|
nsIWeakReference_AddRef(*_retval);
|
2006-03-27 21:02:28 +02:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-01-11 16:13:49 +01:00
|
|
|
static const nsISupportsWeakReferenceVtbl nsSupportsWeakReferenceVtbl = {
|
2006-03-27 21:02:28 +02:00
|
|
|
nsSupportsWeakReference_QueryInterface,
|
|
|
|
nsSupportsWeakReference_AddRef,
|
|
|
|
nsSupportsWeakReference_Release,
|
|
|
|
nsSupportsWeakReference_GetWeakReference
|
|
|
|
};
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
static HRESULT init_browser(GeckoBrowser *browser)
|
2005-08-01 12:59:45 +02:00
|
|
|
{
|
2019-03-11 14:26:39 +01:00
|
|
|
mozIDOMWindowProxy *mozwindow;
|
2005-08-01 12:59:45 +02:00
|
|
|
nsIWebBrowserSetup *wbsetup;
|
2007-06-10 11:52:53 +02:00
|
|
|
nsIScrollable *scrollable;
|
2005-08-01 12:59:45 +02:00
|
|
|
nsresult nsres;
|
2019-03-11 14:26:39 +01:00
|
|
|
HRESULT hres;
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2005-08-10 11:54:02 +02:00
|
|
|
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_WEBBROWSER_CONTRACTID,
|
2019-03-11 14:22:24 +01:00
|
|
|
NULL, &IID_nsIWebBrowser, (void**)&browser->webbrowser);
|
2008-04-07 13:05:56 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Creating WebBrowser failed: %08lx\n", nsres);
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
2008-04-07 13:05:56 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = nsIWebBrowser_SetContainerWindow(browser->webbrowser, &browser->nsIWebBrowserChrome_iface);
|
2011-10-18 12:27:37 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("SetContainerWindow failed: %08lx\n", nsres);
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-25 21:24:58 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = nsIWebBrowser_QueryInterface(browser->webbrowser, &IID_nsIBaseWindow,
|
|
|
|
(void**)&browser->window);
|
2011-10-18 12:27:37 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsIBaseWindow interface: %08lx\n", nsres);
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = nsIWebBrowser_QueryInterface(browser->webbrowser, &IID_nsIWebBrowserSetup,
|
2006-02-15 11:51:44 +01:00
|
|
|
(void**)&wbsetup);
|
2005-08-01 12:59:45 +02:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2007-10-10 13:15:21 +02:00
|
|
|
nsres = nsIWebBrowserSetup_SetProperty(wbsetup, SETUP_IS_CHROME_WRAPPER, FALSE);
|
2005-08-01 12:59:45 +02:00
|
|
|
nsIWebBrowserSetup_Release(wbsetup);
|
2011-10-18 12:27:37 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("SetProperty(SETUP_IS_CHROME_WRAPPER) failed: %08lx\n", nsres);
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-01 12:59:45 +02:00
|
|
|
}else {
|
|
|
|
ERR("Could not get nsIWebBrowserSetup interface\n");
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
2005-08-01 12:59:45 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = nsIWebBrowser_QueryInterface(browser->webbrowser, &IID_nsIWebNavigation,
|
|
|
|
(void**)&browser->navigation);
|
2011-10-18 12:27:37 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsIWebNavigation interface: %08lx\n", nsres);
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = nsIWebBrowser_QueryInterface(browser->webbrowser, &IID_nsIWebBrowserFocus,
|
|
|
|
(void**)&browser->focus);
|
2011-10-18 12:27:37 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsIWebBrowserFocus interface: %08lx\n", nsres);
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-26 12:05:52 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
if(!browser_class) {
|
|
|
|
register_browser_class();
|
|
|
|
if(!browser_class)
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-10 11:54:02 +02:00
|
|
|
|
2020-11-24 23:29:19 +01:00
|
|
|
browser->hwnd = CreateWindowExW(0, L"NsContainer", NULL,
|
2005-08-10 11:54:02 +02:00
|
|
|
WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 100, 100,
|
2019-03-11 14:22:24 +01:00
|
|
|
GetDesktopWindow(), NULL, hInst, browser);
|
|
|
|
if(!browser->hwnd) {
|
2011-10-18 12:27:37 +02:00
|
|
|
WARN("Could not create window\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-10 11:54:02 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = nsIBaseWindow_InitWindow(browser->window, browser->hwnd, NULL, 0, 0, 100, 100);
|
2005-08-10 11:54:02 +02:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = nsIBaseWindow_Create(browser->window);
|
2011-10-18 12:27:37 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
WARN("Creating window failed: %08lx\n", nsres);
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2005-08-10 11:54:02 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsIBaseWindow_SetVisibility(browser->window, FALSE);
|
|
|
|
nsIBaseWindow_SetEnabled(browser->window, FALSE);
|
2005-08-10 11:54:02 +02:00
|
|
|
}else {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("InitWindow failed: %08lx\n", nsres);
|
2011-10-18 12:27:37 +02:00
|
|
|
return E_FAIL;
|
2005-08-10 11:54:02 +02:00
|
|
|
}
|
2005-09-02 14:19:42 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = nsIWebBrowser_SetParentURIContentListener(browser->webbrowser,
|
|
|
|
&browser->nsIURIContentListener_iface);
|
2005-09-02 14:19:42 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("SetParentURIContentListener failed: %08lx\n", nsres);
|
2006-03-01 22:04:51 +01:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
nsres = nsIWebBrowser_QueryInterface(browser->webbrowser, &IID_nsIScrollable, (void**)&scrollable);
|
2007-06-10 11:52:53 +02:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable,
|
|
|
|
ScrollOrientation_Y, Scrollbar_Always);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not set default Y scrollbar prefs: %08lx\n", nsres);
|
2007-06-10 11:52:53 +02:00
|
|
|
|
|
|
|
nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable,
|
|
|
|
ScrollOrientation_X, Scrollbar_Auto);
|
|
|
|
if(NS_FAILED(nsres))
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not set default X scrollbar prefs: %08lx\n", nsres);
|
2007-06-10 11:52:53 +02:00
|
|
|
|
|
|
|
nsIScrollable_Release(scrollable);
|
|
|
|
}else {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get nsIScrollable: %08lx\n", nsres);
|
2007-06-10 11:52:53 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 14:26:39 +01:00
|
|
|
nsres = nsIWebBrowser_GetContentDOMWindow(browser->webbrowser, &mozwindow);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("GetContentDOMWindow failed: %08lx\n", nsres);
|
2019-03-11 14:26:39 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = create_outer_window(browser, mozwindow, NULL, &browser->content_window);
|
|
|
|
mozIDOMWindowProxy_Release(mozwindow);
|
|
|
|
return hres;
|
2011-10-18 12:27:37 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
HRESULT create_gecko_browser(HTMLDocumentObj *doc, GeckoBrowser **_ret)
|
2011-10-18 12:27:37 +02:00
|
|
|
{
|
2019-03-11 14:22:24 +01:00
|
|
|
GeckoBrowser *ret;
|
2011-10-18 12:27:37 +02:00
|
|
|
HRESULT hres;
|
|
|
|
|
2012-03-08 12:18:04 +01:00
|
|
|
if(!load_gecko())
|
2011-10-18 12:27:37 +02:00
|
|
|
return CLASS_E_CLASSNOTAVAILABLE;
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
ret = heap_alloc_zero(sizeof(GeckoBrowser));
|
2011-10-18 12:27:37 +02:00
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ret->nsIWebBrowserChrome_iface.lpVtbl = &nsWebBrowserChromeVtbl;
|
|
|
|
ret->nsIContextMenuListener_iface.lpVtbl = &nsContextMenuListenerVtbl;
|
|
|
|
ret->nsIURIContentListener_iface.lpVtbl = &nsURIContentListenerVtbl;
|
|
|
|
ret->nsIEmbeddingSiteWindow_iface.lpVtbl = &nsEmbeddingSiteWindowVtbl;
|
|
|
|
ret->nsITooltipListener_iface.lpVtbl = &nsTooltipListenerVtbl;
|
|
|
|
ret->nsIInterfaceRequestor_iface.lpVtbl = &nsInterfaceRequestorVtbl;
|
|
|
|
ret->nsISupportsWeakReference_iface.lpVtbl = &nsSupportsWeakReferenceVtbl;
|
|
|
|
|
|
|
|
ret->doc = doc;
|
|
|
|
ret->ref = 1;
|
2019-03-12 16:09:57 +01:00
|
|
|
ret->script_mode = SCRIPTMODE_ACTIVESCRIPT;
|
2019-03-12 16:10:24 +01:00
|
|
|
ret->usermode = UNKNOWN_USERMODE;
|
2019-03-11 14:24:26 +01:00
|
|
|
list_init(&ret->document_nodes);
|
2019-03-11 14:25:21 +01:00
|
|
|
list_init(&ret->outer_windows);
|
2011-10-18 12:27:37 +02:00
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
hres = init_browser(ret);
|
2011-10-18 12:27:37 +02:00
|
|
|
if(SUCCEEDED(hres))
|
|
|
|
*_ret = ret;
|
|
|
|
else
|
|
|
|
nsIWebBrowserChrome_Release(&ret->nsIWebBrowserChrome_iface);
|
|
|
|
return hres;
|
2005-08-01 12:59:45 +02:00
|
|
|
}
|
|
|
|
|
2019-03-11 14:22:24 +01:00
|
|
|
void detach_gecko_browser(GeckoBrowser *This)
|
2005-08-01 12:59:45 +02:00
|
|
|
{
|
2019-03-12 16:10:10 +01:00
|
|
|
nsIDOMWindowUtils *window_utils = NULL;
|
|
|
|
|
2005-08-01 12:59:45 +02:00
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
2008-07-02 18:43:22 +02:00
|
|
|
This->doc = NULL;
|
|
|
|
|
2019-03-11 14:26:39 +01:00
|
|
|
if(This->content_window) {
|
2019-03-12 16:10:10 +01:00
|
|
|
get_nsinterface((nsISupports*)This->content_window->nswindow, &IID_nsIDOMWindowUtils, (void**)&window_utils);
|
|
|
|
|
2019-03-11 14:26:39 +01:00
|
|
|
IHTMLWindow2_Release(&This->content_window->base.IHTMLWindow2_iface);
|
|
|
|
This->content_window = NULL;
|
|
|
|
}
|
|
|
|
|
2019-03-11 14:24:26 +01:00
|
|
|
while(!list_empty(&This->document_nodes)) {
|
|
|
|
HTMLDocumentNode *doc = LIST_ENTRY(list_head(&This->document_nodes), HTMLDocumentNode, browser_entry);
|
2019-03-13 17:54:04 +01:00
|
|
|
detach_document_node(doc);
|
2019-03-11 14:24:26 +01:00
|
|
|
}
|
|
|
|
|
2019-03-11 14:25:21 +01:00
|
|
|
while(!list_empty(&This->outer_windows)) {
|
|
|
|
HTMLOuterWindow *window = LIST_ENTRY(list_head(&This->outer_windows), HTMLOuterWindow, browser_entry);
|
|
|
|
list_remove(&window->browser_entry);
|
|
|
|
window->browser = NULL;
|
|
|
|
}
|
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
ShowWindow(This->hwnd, SW_HIDE);
|
|
|
|
SetParent(This->hwnd, NULL);
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2006-04-08 19:49:55 +02:00
|
|
|
nsIBaseWindow_SetVisibility(This->window, FALSE);
|
|
|
|
nsIBaseWindow_Destroy(This->window);
|
2006-02-15 11:51:44 +01:00
|
|
|
|
|
|
|
nsIWebBrowser_SetContainerWindow(This->webbrowser, NULL);
|
|
|
|
|
|
|
|
nsIWebBrowser_Release(This->webbrowser);
|
|
|
|
This->webbrowser = NULL;
|
|
|
|
|
|
|
|
nsIWebNavigation_Release(This->navigation);
|
|
|
|
This->navigation = NULL;
|
|
|
|
|
|
|
|
nsIBaseWindow_Release(This->window);
|
|
|
|
This->window = NULL;
|
|
|
|
|
2006-04-08 19:49:55 +02:00
|
|
|
nsIWebBrowserFocus_Release(This->focus);
|
|
|
|
This->focus = NULL;
|
|
|
|
|
2007-06-10 11:49:12 +02:00
|
|
|
if(This->editor_controller) {
|
|
|
|
nsIController_Release(This->editor_controller);
|
|
|
|
This->editor_controller = NULL;
|
|
|
|
}
|
|
|
|
|
2007-09-12 11:41:36 +02:00
|
|
|
if(This->editor) {
|
|
|
|
nsIEditor_Release(This->editor);
|
|
|
|
This->editor = NULL;
|
|
|
|
}
|
|
|
|
|
2006-08-16 16:34:32 +02:00
|
|
|
if(This->content_listener) {
|
|
|
|
nsIURIContentListener_Release(This->content_listener);
|
|
|
|
This->content_listener = NULL;
|
|
|
|
}
|
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
if(This->hwnd) {
|
|
|
|
DestroyWindow(This->hwnd);
|
|
|
|
This->hwnd = NULL;
|
|
|
|
}
|
2005-08-11 20:36:48 +02:00
|
|
|
|
2010-12-27 23:27:55 +01:00
|
|
|
nsIWebBrowserChrome_Release(&This->nsIWebBrowserChrome_iface);
|
2019-03-12 16:10:10 +01:00
|
|
|
|
|
|
|
/* Force cycle collection */
|
|
|
|
if(window_utils) {
|
|
|
|
nsIDOMWindowUtils_CycleCollect(window_utils, NULL, 0);
|
|
|
|
nsIDOMWindowUtils_Release(window_utils);
|
|
|
|
}
|
2005-08-01 12:59:45 +02:00
|
|
|
}
|
2015-06-30 15:50:30 +02:00
|
|
|
|
2016-08-03 15:53:28 +02:00
|
|
|
/*
|
|
|
|
* FIXME: nsIScriptObjectPrincipal uses thiscall calling convention, so we need this hack on i386.
|
|
|
|
* This will be removed after the next Gecko update, that will change calling convention on Gecko side.
|
|
|
|
*/
|
|
|
|
#ifdef __i386__
|
|
|
|
__ASM_GLOBAL_FUNC(call_thiscall_func,
|
|
|
|
"popl %eax\n\t"
|
|
|
|
"popl %edx\n\t"
|
|
|
|
"popl %ecx\n\t"
|
|
|
|
"pushl %eax\n\t"
|
|
|
|
"jmp *%edx\n\t")
|
|
|
|
#define nsIScriptObjectPrincipal_GetPrincipal(this) ((void* (WINAPI*)(void*,void*))&call_thiscall_func)((this)->lpVtbl->GetPrincipal,this)
|
|
|
|
#endif
|
|
|
|
|
2015-06-30 15:50:30 +02:00
|
|
|
nsIXMLHttpRequest *create_nsxhr(nsIDOMWindow *nswindow)
|
|
|
|
{
|
2016-08-03 15:53:28 +02:00
|
|
|
nsIScriptObjectPrincipal *sop;
|
2016-06-13 17:40:51 +02:00
|
|
|
mozIDOMWindow *inner_window;
|
2016-08-03 15:53:28 +02:00
|
|
|
nsIPrincipal *nspri;
|
|
|
|
nsIGlobalObject *nsglo;
|
|
|
|
nsIXMLHttpRequest *nsxhr;
|
|
|
|
nsresult nsres;
|
2015-06-30 15:50:30 +02:00
|
|
|
|
2016-06-13 17:40:51 +02:00
|
|
|
nsres = nsIDOMWindow_GetInnerWindow(nswindow, &inner_window);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("Could not get inner window: %08lx\n", nsres);
|
2016-06-13 17:40:51 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = mozIDOMWindow_QueryInterface(inner_window, &IID_nsIGlobalObject, (void **)&nsglo);
|
|
|
|
mozIDOMWindow_Release(inner_window);
|
2015-06-30 15:50:30 +02:00
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
2016-08-03 15:53:28 +02:00
|
|
|
nsres = nsIGlobalObject_QueryInterface(nsglo, &IID_nsIScriptObjectPrincipal, (void**)&sop);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
|
|
|
nspri = nsIScriptObjectPrincipal_GetPrincipal(sop);
|
|
|
|
nsIScriptObjectPrincipal_Release(sop);
|
|
|
|
|
2015-06-30 15:50:30 +02:00
|
|
|
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr,
|
|
|
|
NS_XMLHTTPREQUEST_CONTRACTID, NULL, &IID_nsIXMLHttpRequest,
|
|
|
|
(void**)&nsxhr);
|
2016-08-03 15:53:28 +02:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsres = nsIXMLHttpRequest_Init(nsxhr, nspri, NULL, nsglo, NULL, NULL);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
nsIXMLHttpRequest_Release(nsxhr);
|
2015-06-30 15:50:30 +02:00
|
|
|
}
|
|
|
|
nsISupports_Release(nspri);
|
|
|
|
nsIGlobalObject_Release(nsglo);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2022-02-15 07:29:41 +01:00
|
|
|
ERR("nsIXMLHttpRequest_Init failed: %08lx\n", nsres);
|
2015-06-30 15:50:30 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
2016-08-03 15:53:28 +02:00
|
|
|
|
2015-06-30 15:50:30 +02:00
|
|
|
return nsxhr;
|
|
|
|
}
|