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 "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
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-03-27 21:02:28 +02:00
|
|
|
#define NS_MEMORY_CONTRACTID "@mozilla.org/xpcom/memory-service;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"
|
2005-08-01 12:59:45 +02:00
|
|
|
|
|
|
|
#define APPSTARTUP_TOPIC "app-startup"
|
|
|
|
|
|
|
|
#define PR_UINT32_MAX 0xffffffff
|
|
|
|
|
2006-02-09 12:17:38 +01:00
|
|
|
struct nsCStringContainer {
|
|
|
|
void *v;
|
|
|
|
void *d1;
|
|
|
|
PRUint32 d2;
|
|
|
|
void *d3;
|
|
|
|
};
|
|
|
|
|
2005-08-01 12:59:45 +02:00
|
|
|
static nsresult (*NS_InitXPCOM2)(nsIServiceManager**,void*,void*);
|
|
|
|
static nsresult (*NS_ShutdownXPCOM)(nsIServiceManager*);
|
2005-12-09 11:51:02 +01:00
|
|
|
static nsresult (*NS_GetComponentRegistrar)(nsIComponentRegistrar**);
|
2005-12-15 10:41:56 +01:00
|
|
|
static nsresult (*NS_StringContainerInit)(nsStringContainer*);
|
|
|
|
static nsresult (*NS_CStringContainerInit)(nsCStringContainer*);
|
|
|
|
static nsresult (*NS_StringContainerFinish)(nsStringContainer*);
|
|
|
|
static nsresult (*NS_CStringContainerFinish)(nsCStringContainer*);
|
|
|
|
static nsresult (*NS_StringSetData)(nsAString*,const PRUnichar*,PRUint32);
|
2005-09-02 14:19:42 +02:00
|
|
|
static nsresult (*NS_CStringSetData)(nsACString*,const char*,PRUint32);
|
2005-12-15 10:41:56 +01:00
|
|
|
static nsresult (*NS_NewLocalFile)(const nsAString*,PRBool,nsIFile**);
|
2006-03-06 22:34:49 +01:00
|
|
|
static PRUint32 (*NS_StringGetData)(const nsAString*,const PRUnichar **,PRBool*);
|
2006-02-09 12:17:38 +01:00
|
|
|
static PRUint32 (*NS_CStringGetData)(const nsACString*,const char**,PRBool*);
|
2005-08-01 12:59:45 +02:00
|
|
|
|
|
|
|
static HINSTANCE hXPCOM = NULL;
|
|
|
|
|
|
|
|
static nsIServiceManager *pServMgr = NULL;
|
|
|
|
static nsIComponentManager *pCompMgr = NULL;
|
2006-03-27 21:02:28 +02:00
|
|
|
static nsIMemory *nsmem = NULL;
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2005-08-10 11:54:02 +02:00
|
|
|
static const WCHAR wszNsContainer[] = {'N','s','C','o','n','t','a','i','n','e','r',0};
|
|
|
|
|
|
|
|
static ATOM nscontainer_class;
|
|
|
|
|
2007-11-12 01:23:47 +01:00
|
|
|
#define WM_RESETFOCUS_HACK WM_USER+600
|
|
|
|
|
2005-08-10 11:54:02 +02:00
|
|
|
static LRESULT WINAPI nsembed_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
2006-03-01 22:03:00 +01:00
|
|
|
NSContainer *This;
|
2005-08-10 11:54:02 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
static const WCHAR wszTHIS[] = {'T','H','I','S',0};
|
|
|
|
|
|
|
|
if(msg == WM_CREATE) {
|
2006-03-01 22:03:00 +01:00
|
|
|
This = *(NSContainer**)lParam;
|
2005-08-10 11:54:02 +02:00
|
|
|
SetPropW(hwnd, wszTHIS, This);
|
|
|
|
}else {
|
2008-12-05 07:46:08 +01:00
|
|
|
This = GetPropW(hwnd, wszTHIS);
|
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))
|
|
|
|
WARN("SetSize failed: %08x\n", nsres);
|
|
|
|
break;
|
2005-08-10 11:54:02 +02:00
|
|
|
|
2007-11-12 01:23:47 +01:00
|
|
|
case WM_RESETFOCUS_HACK:
|
|
|
|
/*
|
|
|
|
* FIXME
|
|
|
|
* Gecko grabs focus in edit mode and some apps don't like it.
|
|
|
|
* We should somehow prevent grabbing focus.
|
|
|
|
*/
|
2008-01-10 22:13:35 +01:00
|
|
|
|
|
|
|
TRACE("WM_RESETFOCUS_HACK\n");
|
|
|
|
|
2007-11-12 01:23:47 +01:00
|
|
|
if(This->reset_focus) {
|
|
|
|
SetFocus(This->reset_focus);
|
|
|
|
This->reset_focus = NULL;
|
2008-01-10 22:13:35 +01:00
|
|
|
if(This->doc)
|
2009-09-16 22:11:26 +02:00
|
|
|
This->doc->focus = FALSE;
|
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
|
|
|
|
2005-08-10 11:54:02 +02:00
|
|
|
static void register_nscontainer_class(void)
|
|
|
|
{
|
|
|
|
static WNDCLASSEXW wndclass = {
|
|
|
|
sizeof(WNDCLASSEXW),
|
|
|
|
CS_DBLCLKS,
|
|
|
|
nsembed_proc,
|
|
|
|
0, 0, NULL, NULL, NULL, NULL, NULL,
|
|
|
|
wszNsContainer,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
wndclass.hInstance = hInst;
|
|
|
|
nscontainer_class = RegisterClassExW(&wndclass);
|
|
|
|
}
|
|
|
|
|
2008-12-30 21:21:18 +01:00
|
|
|
static void set_environment(LPCWSTR gre_path)
|
2006-08-09 16:38:42 +02:00
|
|
|
{
|
2008-12-30 21:21:33 +01:00
|
|
|
WCHAR path_env[MAX_PATH], buf[20];
|
|
|
|
int len, debug_level = 0;
|
2006-08-09 16:38:42 +02:00
|
|
|
|
2008-12-30 21:21:18 +01:00
|
|
|
static const WCHAR pathW[] = {'P','A','T','H',0};
|
|
|
|
static const WCHAR warnW[] = {'w','a','r','n',0};
|
|
|
|
static const WCHAR xpcom_debug_breakW[] =
|
|
|
|
{'X','P','C','O','M','_','D','E','B','U','G','_','B','R','E','A','K',0};
|
2008-12-30 21:21:33 +01:00
|
|
|
static const WCHAR nspr_log_modulesW[] =
|
|
|
|
{'N','S','P','R','_','L','O','G','_','M','O','D','U','L','E','S',0};
|
|
|
|
static const WCHAR debug_formatW[] = {'a','l','l',':','%','d',0};
|
2006-08-09 16:38:42 +02:00
|
|
|
|
|
|
|
/* We have to modify PATH as XPCOM loads other DLLs from this directory. */
|
2008-12-30 21:21:18 +01:00
|
|
|
GetEnvironmentVariableW(pathW, path_env, sizeof(path_env)/sizeof(WCHAR));
|
2006-08-09 16:38:42 +02:00
|
|
|
len = strlenW(path_env);
|
|
|
|
path_env[len++] = ';';
|
|
|
|
strcpyW(path_env+len, gre_path);
|
2008-12-30 21:21:18 +01:00
|
|
|
SetEnvironmentVariableW(pathW, path_env);
|
|
|
|
|
|
|
|
SetEnvironmentVariableW(xpcom_debug_breakW, warnW);
|
2008-12-30 21:21:33 +01:00
|
|
|
|
|
|
|
if(TRACE_ON(gecko))
|
|
|
|
debug_level = 5;
|
|
|
|
else if(WARN_ON(gecko))
|
|
|
|
debug_level = 3;
|
|
|
|
else if(ERR_ON(gecko))
|
|
|
|
debug_level = 2;
|
|
|
|
|
|
|
|
sprintfW(buf, debug_formatW, debug_level);
|
|
|
|
SetEnvironmentVariableW(nspr_log_modulesW, buf);
|
2008-12-30 21:21:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL load_xpcom(const PRUnichar *gre_path)
|
|
|
|
{
|
|
|
|
static const WCHAR strXPCOM[] = {'x','p','c','o','m','.','d','l','l',0};
|
|
|
|
|
|
|
|
TRACE("(%s)\n", debugstr_w(gre_path));
|
|
|
|
|
|
|
|
set_environment(gre_path);
|
2006-08-09 16:38:42 +02:00
|
|
|
|
|
|
|
hXPCOM = LoadLibraryW(strXPCOM);
|
|
|
|
if(!hXPCOM) {
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("Could not load XPCOM: %d\n", GetLastError());
|
2006-08-09 16:38:42 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define NS_DLSYM(func) \
|
2008-02-26 12:13:07 +01:00
|
|
|
func = (void *)GetProcAddress(hXPCOM, #func); \
|
2006-08-09 16:38:42 +02:00
|
|
|
if(!func) \
|
|
|
|
ERR("Could not GetProcAddress(" #func ") failed\n")
|
|
|
|
|
|
|
|
NS_DLSYM(NS_InitXPCOM2);
|
|
|
|
NS_DLSYM(NS_ShutdownXPCOM);
|
|
|
|
NS_DLSYM(NS_GetComponentRegistrar);
|
|
|
|
NS_DLSYM(NS_StringContainerInit);
|
|
|
|
NS_DLSYM(NS_CStringContainerInit);
|
|
|
|
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);
|
|
|
|
|
|
|
|
#undef NS_DLSYM
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-06-06 19:44:20 +02:00
|
|
|
static BOOL check_version(LPCWSTR gre_path, const char *version_string)
|
2006-10-28 14:16:05 +02:00
|
|
|
{
|
|
|
|
WCHAR file_name[MAX_PATH];
|
|
|
|
char version[128];
|
|
|
|
DWORD read=0;
|
|
|
|
HANDLE hfile;
|
|
|
|
|
|
|
|
static const WCHAR wszVersion[] = {'\\','V','E','R','S','I','O','N',0};
|
|
|
|
|
|
|
|
strcpyW(file_name, gre_path);
|
|
|
|
strcatW(file_name, wszVersion);
|
|
|
|
|
|
|
|
hfile = CreateFileW(file_name, GENERIC_READ, FILE_SHARE_READ, NULL,
|
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if(hfile == INVALID_HANDLE_VALUE) {
|
2007-06-06 19:44:20 +02:00
|
|
|
ERR("Could not open VERSION file\n");
|
|
|
|
return FALSE;
|
2006-10-28 14:16:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ReadFile(hfile, version, sizeof(version), &read, NULL);
|
|
|
|
version[read] = 0;
|
2007-06-06 19:44:20 +02:00
|
|
|
CloseHandle(hfile);
|
2006-10-28 14:16:05 +02:00
|
|
|
|
|
|
|
TRACE("%s\n", debugstr_a(version));
|
|
|
|
|
2007-06-06 19:44:20 +02:00
|
|
|
if(strcmp(version, version_string)) {
|
|
|
|
ERR("Unexpected version %s, expected %s\n", debugstr_a(version),
|
|
|
|
debugstr_a(version_string));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL load_wine_gecko_v(PRUnichar *gre_path, HKEY mshtml_key,
|
|
|
|
const char *version, const char *version_string)
|
|
|
|
{
|
|
|
|
DWORD res, type, size = MAX_PATH;
|
|
|
|
HKEY hkey = mshtml_key;
|
|
|
|
|
|
|
|
static const WCHAR wszGeckoPath[] =
|
|
|
|
{'G','e','c','k','o','P','a','t','h',0};
|
|
|
|
|
|
|
|
if(version) {
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\MSHTML\<version> */
|
|
|
|
res = RegOpenKeyA(mshtml_key, version, &hkey);
|
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = RegQueryValueExW(hkey, wszGeckoPath, NULL, &type, (LPBYTE)gre_path, &size);
|
|
|
|
if(hkey != mshtml_key)
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res != ERROR_SUCCESS || type != REG_SZ)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if(!check_version(gre_path, version_string))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return load_xpcom(gre_path);
|
2006-10-28 14:16:05 +02:00
|
|
|
}
|
|
|
|
|
2006-08-09 16:38:42 +02:00
|
|
|
static BOOL load_wine_gecko(PRUnichar *gre_path)
|
2005-12-07 13:07:42 +01:00
|
|
|
{
|
|
|
|
HKEY hkey;
|
2007-06-06 19:44:20 +02:00
|
|
|
DWORD res;
|
|
|
|
BOOL ret;
|
2005-12-07 13:07:42 +01:00
|
|
|
|
|
|
|
static const WCHAR wszMshtmlKey[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\','W','i','n','e',
|
|
|
|
'\\','M','S','H','T','M','L',0};
|
|
|
|
|
|
|
|
/* @@ Wine registry key: HKCU\Software\Wine\MSHTML */
|
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, wszMshtmlKey, &hkey);
|
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return FALSE;
|
|
|
|
|
2008-03-16 23:41:55 +01:00
|
|
|
ret = load_wine_gecko_v(gre_path, hkey, GECKO_VERSION, GECKO_VERSION_STRING);
|
2006-10-28 14:16:05 +02:00
|
|
|
|
2007-06-06 19:44:20 +02:00
|
|
|
RegCloseKey(hkey);
|
|
|
|
return ret;
|
2005-12-07 13:07:42 +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;
|
|
|
|
|
|
|
|
static const WCHAR international_keyW[] =
|
|
|
|
{'S','o','f','t','w','a','r','e',
|
|
|
|
'\\','M','i','c','r','o','s','o','f','t',
|
|
|
|
'\\','I','n','t','e','r','n','e','t',' ','E','x','p','l','o','r','e','r',
|
|
|
|
'\\','I','n','t','e','r','n','a','t','i','o','n','a','l',0};
|
|
|
|
|
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, international_keyW, &hkey);
|
|
|
|
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-05-22 02:43:29 +02:00
|
|
|
static void set_proxy(nsIPrefBranch *pref)
|
|
|
|
{
|
|
|
|
char proxy[512];
|
|
|
|
char * proxy_port;
|
|
|
|
int proxy_port_num;
|
|
|
|
DWORD enabled = 0, res, size, type;
|
|
|
|
HKEY hkey;
|
|
|
|
|
|
|
|
static const WCHAR proxy_keyW[] =
|
|
|
|
{'S','o','f','t','w','a','r','e',
|
|
|
|
'\\','M','i','c','r','o','s','o','f','t',
|
|
|
|
'\\','W','i','n','d','o','w','s',
|
|
|
|
'\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n',
|
|
|
|
'\\','I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0};
|
|
|
|
|
|
|
|
res = RegOpenKeyW(HKEY_CURRENT_USER, proxy_keyW, &hkey);
|
|
|
|
if(res != ERROR_SUCCESS)
|
|
|
|
return;
|
|
|
|
|
|
|
|
size = sizeof(enabled);
|
|
|
|
res = RegQueryValueExA(hkey, "ProxyEnable", 0, &type, (LPBYTE)&enabled, &size);
|
|
|
|
if(res != ERROR_SUCCESS || type != REG_DWORD || enabled == 0)
|
|
|
|
{
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = sizeof(proxy);
|
|
|
|
res = RegQueryValueExA(hkey, "ProxyServer", 0, &type, (LPBYTE)proxy, &size);
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
if(res != ERROR_SUCCESS || type != REG_SZ)
|
|
|
|
return;
|
|
|
|
|
|
|
|
proxy_port = strchr(proxy, ':');
|
|
|
|
if (!proxy_port)
|
|
|
|
return;
|
|
|
|
|
|
|
|
*proxy_port = 0;
|
|
|
|
proxy_port_num = atoi(proxy_port + 1);
|
|
|
|
TRACE("Setting proxy to %s, port %d\n", debugstr_a(proxy), proxy_port_num);
|
|
|
|
|
2009-08-21 13:27:20 +02:00
|
|
|
set_string_pref(pref, "network.proxy.http", proxy);
|
|
|
|
set_string_pref(pref, "network.proxy.ssl", proxy);
|
2008-01-11 12:06:35 +01:00
|
|
|
|
2009-08-21 13:27:20 +02:00
|
|
|
set_int_pref(pref, "network.proxy.type", 1);
|
|
|
|
set_int_pref(pref, "network.proxy.http_port", proxy_port_num);
|
|
|
|
set_int_pref(pref, "network.proxy.ssl_port", proxy_port_num);
|
2009-08-15 19:47:40 +02: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)) {
|
|
|
|
ERR("Could not get preference service: %08x\n", nsres);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_lang(pref);
|
2008-05-22 02:43:29 +02:00
|
|
|
set_proxy(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
|
|
|
{
|
|
|
|
nsresult nsres;
|
|
|
|
nsIObserver *pStartNotif;
|
2005-12-15 10:26:11 +01:00
|
|
|
nsIComponentRegistrar *registrar = NULL;
|
2005-12-15 10:41:56 +01:00
|
|
|
nsAString path;
|
2005-08-01 12:59:45 +02:00
|
|
|
nsIFile *gre_dir;
|
2005-08-22 11:21:53 +02:00
|
|
|
|
2006-10-02 20:07:13 +02:00
|
|
|
nsAString_Init(&path, gre_path);
|
2005-08-01 12:59:45 +02:00
|
|
|
nsres = NS_NewLocalFile(&path, FALSE, &gre_dir);
|
2006-10-02 20:07:13 +02:00
|
|
|
nsAString_Finish(&path);
|
2005-08-01 12:59:45 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("NS_NewLocalFile failed: %08x\n", nsres);
|
2005-08-01 12:59:45 +02:00
|
|
|
FreeLibrary(hXPCOM);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = NS_InitXPCOM2(&pServMgr, gre_dir, NULL);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("NS_InitXPCOM2 failed: %08x\n", nsres);
|
2005-08-01 12:59:45 +02:00
|
|
|
FreeLibrary(hXPCOM);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIServiceManager_QueryInterface(pServMgr, &IID_nsIComponentManager, (void**)&pCompMgr);
|
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Could not get nsIComponentManager: %08x\n", nsres);
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2005-12-15 10:26:11 +01:00
|
|
|
nsres = NS_GetComponentRegistrar(®istrar);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsres = nsIComponentRegistrar_AutoRegister(registrar, NULL);
|
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("AutoRegister(NULL) failed: %08x\n", nsres);
|
2005-12-15 10:26:11 +01:00
|
|
|
|
2006-02-24 20:27:38 +01:00
|
|
|
init_nsio(pCompMgr, registrar);
|
2005-12-15 10:26:11 +01:00
|
|
|
}else {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("NS_GetComponentRegistrar failed: %08x\n", nsres);
|
2005-12-15 10:26:11 +01:00
|
|
|
}
|
|
|
|
|
2005-08-01 12:59:45 +02:00
|
|
|
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_APPSTARTUPNOTIFIER_CONTRACTID,
|
|
|
|
NULL, &IID_nsIObserver, (void**)&pStartNotif);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsres = nsIObserver_Observe(pStartNotif, NULL, APPSTARTUP_TOPIC, NULL);
|
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Observe failed: %08x\n", nsres);
|
2005-08-01 12:59:45 +02:00
|
|
|
|
|
|
|
nsIObserver_Release(pStartNotif);
|
|
|
|
}else {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("could not get appstartup-notifier: %08x\n", nsres);
|
2005-08-01 12:59:45 +02:00
|
|
|
}
|
|
|
|
|
2008-12-22 01:10:56 +01:00
|
|
|
set_preferences();
|
2006-02-09 12:17:08 +01:00
|
|
|
|
2006-03-27 21:02:28 +02:00
|
|
|
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_MEMORY_CONTRACTID,
|
|
|
|
NULL, &IID_nsIMemory, (void**)&nsmem);
|
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Could not get nsIMemory: %08x\n", nsres);
|
2006-03-27 21:02:28 +02:00
|
|
|
|
2005-12-15 10:26:11 +01:00
|
|
|
if(registrar) {
|
2006-03-01 22:04:51 +01:00
|
|
|
register_nsservice(registrar, pServMgr);
|
2005-12-09 11:51:02 +01:00
|
|
|
nsIComponentRegistrar_Release(registrar);
|
|
|
|
}
|
|
|
|
|
2005-08-01 12:59:45 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
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 };
|
|
|
|
|
2007-10-14 01:49:19 +02:00
|
|
|
BOOL load_gecko(BOOL silent)
|
2007-02-13 18:06:25 +01:00
|
|
|
{
|
|
|
|
PRUnichar gre_path[MAX_PATH];
|
|
|
|
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");
|
|
|
|
|
|
|
|
/* load_gecko may be called recursively */
|
|
|
|
if(loading_thread == GetCurrentThreadId())
|
|
|
|
return pCompMgr != NULL;
|
|
|
|
|
|
|
|
EnterCriticalSection(&cs_load_gecko);
|
|
|
|
|
|
|
|
if(!loading_thread) {
|
|
|
|
loading_thread = GetCurrentThreadId();
|
|
|
|
|
|
|
|
if(load_wine_gecko(gre_path)
|
2007-10-14 01:49:19 +02:00
|
|
|
|| (install_wine_gecko(silent) && load_wine_gecko(gre_path)))
|
2007-02-13 18:06:25 +01:00
|
|
|
ret = init_xpcom(gre_path);
|
|
|
|
else
|
2009-06-07 20:36:03 +02:00
|
|
|
MESSAGE("Could not load 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)
|
|
|
|
{
|
|
|
|
return nsIMemory_Alloc(nsmem, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsfree(void *mem)
|
|
|
|
{
|
|
|
|
nsIMemory_Free(nsmem, mem);
|
|
|
|
}
|
|
|
|
|
2006-03-18 22:00:34 +01:00
|
|
|
void nsACString_Init(nsACString *str, const char *data)
|
2005-08-11 20:36:48 +02:00
|
|
|
{
|
2006-03-18 22:00:34 +01:00
|
|
|
NS_CStringContainerInit(str);
|
|
|
|
if(data)
|
2006-12-14 00:20:26 +01:00
|
|
|
nsACString_SetData(str, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsACString_SetData(nsACString *str, const char *data)
|
|
|
|
{
|
|
|
|
NS_CStringSetData(str, data, PR_UINT32_MAX);
|
2005-08-11 20:36:48 +02:00
|
|
|
}
|
|
|
|
|
2007-12-17 01:38:15 +01:00
|
|
|
PRUint32 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
|
|
|
}
|
|
|
|
|
2006-03-18 22:00:34 +01:00
|
|
|
void nsACString_Finish(nsACString *str)
|
2005-08-11 20:36:48 +02:00
|
|
|
{
|
|
|
|
NS_CStringContainerFinish(str);
|
|
|
|
}
|
|
|
|
|
2006-03-06 22:34:49 +01:00
|
|
|
void nsAString_Init(nsAString *str, const PRUnichar *data)
|
|
|
|
{
|
|
|
|
NS_StringContainerInit(str);
|
|
|
|
if(data)
|
2008-03-07 12:56:33 +01:00
|
|
|
nsAString_SetData(str, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsAString_SetData(nsAString *str, const PRUnichar *data)
|
|
|
|
{
|
|
|
|
NS_StringSetData(str, data, PR_UINT32_MAX);
|
2006-03-06 22:34:49 +01:00
|
|
|
}
|
|
|
|
|
2007-12-17 01:38:30 +01:00
|
|
|
PRUint32 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);
|
2006-03-06 22:34:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsAString_Finish(nsAString *str)
|
|
|
|
{
|
|
|
|
NS_StringContainerFinish(str);
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
PRBool has_children = FALSE;
|
|
|
|
PRUint16 type;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsIDOMNode_HasChildNodes(nsnode, &has_children);
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_GetNodeType(nsnode, &type);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("GetType failed: %08x\n", nsres);
|
2009-08-11 19:17:19 +02:00
|
|
|
return E_FAIL;
|
2006-10-02 20:33:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case ELEMENT_NODE: {
|
|
|
|
nsIDOMElement *nselem;
|
|
|
|
nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
|
2008-12-30 06:48:59 +01:00
|
|
|
nsIContentSerializer_AppendElementStart(serializer, nselem, nselem, str);
|
2006-10-02 20:33:08 +02:00
|
|
|
nsIDOMElement_Release(nselem);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case TEXT_NODE: {
|
|
|
|
nsIDOMText *nstext;
|
|
|
|
nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMText, (void**)&nstext);
|
|
|
|
nsIContentSerializer_AppendText(serializer, nstext, 0, -1, str);
|
|
|
|
nsIDOMText_Release(nstext);
|
|
|
|
break;
|
|
|
|
}
|
2007-06-10 11:54:51 +02:00
|
|
|
case COMMENT_NODE: {
|
|
|
|
nsIDOMComment *nscomment;
|
|
|
|
nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMComment, (void**)&nscomment);
|
|
|
|
nsres = nsIContentSerializer_AppendComment(serializer, nscomment, 0, -1, str);
|
|
|
|
break;
|
|
|
|
}
|
2006-10-02 20:33:08 +02:00
|
|
|
case DOCUMENT_NODE: {
|
|
|
|
nsIDOMDocument *nsdoc;
|
|
|
|
nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMDocument, (void**)&nsdoc);
|
|
|
|
nsIContentSerializer_AppendDocumentStart(serializer, nsdoc, str);
|
|
|
|
nsIDOMDocument_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:
|
|
|
|
WARN("Ignoring DOCUMENT_TYPE_NODE\n");
|
|
|
|
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) {
|
|
|
|
PRUint32 child_cnt, i;
|
|
|
|
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 {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Item failed: %08x\n", nsres);
|
2006-10-02 20:33:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMNodeList_Release(node_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(type == ELEMENT_NODE) {
|
|
|
|
nsIDOMElement *nselem;
|
|
|
|
nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
|
|
|
|
nsIContentSerializer_AppendElementEnd(serializer, nselem, str);
|
|
|
|
nsIDOMElement_Release(nselem);
|
|
|
|
}
|
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)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Could not get nsIContentSerializer: %08x\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))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Init failed: %08x\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))
|
|
|
|
ERR("Flush failed: %08x\n", nsres);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2007-09-12 11:41:36 +02:00
|
|
|
void get_editor_controller(NSContainer *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)) {
|
|
|
|
ERR("Could not get nsIEditingSession: %08x\n", nsres);
|
2007-09-12 11:41:36 +02:00
|
|
|
return;
|
2007-06-10 11:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIEditingSession_GetEditorForWindow(editing_session,
|
2009-09-16 22:09:17 +02:00
|
|
|
This->doc->basedoc.window->nswindow, &This->editor);
|
2007-06-10 11:49:12 +02:00
|
|
|
nsIEditingSession_Release(editing_session);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get editor: %08x\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))
|
|
|
|
ERR("SetCommandContext failed: %08x\n", nsres);
|
|
|
|
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))
|
|
|
|
ERR("Could not get nsIController interface: %08x\n", nsres);
|
|
|
|
}else {
|
|
|
|
ERR("Could not create edit controller: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-06-10 11:35:11 +02:00
|
|
|
void set_ns_editmode(NSContainer *This)
|
|
|
|
{
|
|
|
|
nsIEditingSession *editing_session = NULL;
|
|
|
|
nsIURIContentListener *listener = NULL;
|
|
|
|
nsIDOMWindow *dom_window = NULL;
|
|
|
|
nsresult nsres;
|
|
|
|
|
2007-09-26 20:47:02 +02:00
|
|
|
nsres = get_nsinterface((nsISupports*)This->webbrowser, &IID_nsIEditingSession,
|
|
|
|
(void**)&editing_session);
|
2007-06-10 11:35:11 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get nsIEditingSession: %08x\n", nsres);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIWebBrowser_GetContentDOMWindow(This->webbrowser, &dom_window);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get content DOM window: %08x\n", nsres);
|
|
|
|
nsIEditingSession_Release(editing_session);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-12-30 06:48:59 +01:00
|
|
|
nsres = nsIEditingSession_MakeWindowEditable(editing_session, dom_window,
|
|
|
|
NULL, FALSE, TRUE, TRUE);
|
2007-06-10 11:35:11 +02:00
|
|
|
nsIEditingSession_Release(editing_session);
|
|
|
|
nsIDOMWindow_Release(dom_window);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("MakeWindowEditable failed: %08x\n", nsres);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* MakeWindowEditable changes WebBrowser's parent URI content listener.
|
|
|
|
* It seams to be a bug in Gecko. To workaround it we set our content
|
|
|
|
* listener again and Gecko's one as its parent.
|
|
|
|
*/
|
|
|
|
nsIWebBrowser_GetParentURIContentListener(This->webbrowser, &listener);
|
|
|
|
nsIURIContentListener_SetParentContentListener(NSURICL(This), listener);
|
|
|
|
nsIURIContentListener_Release(listener);
|
|
|
|
nsIWebBrowser_SetParentURIContentListener(This->webbrowser, NSURICL(This));
|
|
|
|
}
|
|
|
|
|
2009-09-16 22:07:58 +02:00
|
|
|
void update_nsdocument(HTMLDocumentObj *doc)
|
2008-10-08 20:27:25 +02:00
|
|
|
{
|
2009-09-16 22:07:58 +02:00
|
|
|
HTMLDocumentNode *doc_node;
|
2008-10-08 20:27:25 +02:00
|
|
|
nsIDOMHTMLDocument *nsdoc;
|
|
|
|
nsIDOMDocument *nsdomdoc;
|
|
|
|
nsresult nsres;
|
2009-09-16 22:07:58 +02:00
|
|
|
HRESULT hres;
|
2008-10-08 20:27:25 +02:00
|
|
|
|
2009-09-16 22:09:17 +02:00
|
|
|
if(!doc->nscontainer || !doc->nscontainer->navigation)
|
2008-10-08 20:27:25 +02:00
|
|
|
return;
|
|
|
|
|
2009-09-16 22:09:17 +02:00
|
|
|
nsres = nsIWebNavigation_GetDocument(doc->nscontainer->navigation, &nsdomdoc);
|
2008-10-08 20:27:25 +02:00
|
|
|
if(NS_FAILED(nsres) || !nsdomdoc) {
|
|
|
|
ERR("GetDocument failed: %08x\n", nsres);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDOMDocument_QueryInterface(nsdomdoc, &IID_nsIDOMHTMLDocument, (void**)&nsdoc);
|
|
|
|
nsIDOMDocument_Release(nsdomdoc);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-16 22:07:58 +02:00
|
|
|
if(nsdoc == doc->basedoc.nsdoc) {
|
2008-10-08 20:27:25 +02:00
|
|
|
nsIDOMHTMLDocument_Release(nsdoc);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-09-16 22:07:58 +02:00
|
|
|
if(doc->basedoc.nsdoc) {
|
2009-09-16 22:09:17 +02:00
|
|
|
remove_mutation_observer(doc->nscontainer, doc->basedoc.nsdoc);
|
2009-09-16 22:07:58 +02:00
|
|
|
nsIDOMHTMLDocument_Release(doc->basedoc.nsdoc);
|
|
|
|
|
|
|
|
doc_node = doc->basedoc.doc_node;
|
|
|
|
doc_node->basedoc.doc_obj = NULL;
|
|
|
|
IHTMLDocument2_Release(HTMLDOC(&doc_node->basedoc));
|
|
|
|
doc->basedoc.doc_node = NULL;
|
2009-02-05 21:18:16 +01:00
|
|
|
}
|
2008-10-08 20:27:25 +02:00
|
|
|
|
2009-09-16 22:07:58 +02:00
|
|
|
doc->basedoc.nsdoc = nsdoc;
|
2009-09-16 22:08:41 +02:00
|
|
|
if(!nsdoc) {
|
|
|
|
window_set_docnode(doc->basedoc.window, NULL);
|
2009-09-16 22:07:58 +02:00
|
|
|
return;
|
2009-09-16 22:08:41 +02:00
|
|
|
}
|
2009-09-16 22:07:58 +02:00
|
|
|
|
2009-09-16 22:09:17 +02:00
|
|
|
set_mutation_observer(doc->nscontainer, nsdoc);
|
2009-09-16 22:07:58 +02:00
|
|
|
|
|
|
|
hres = create_doc_from_nsdoc(nsdoc, doc, doc->basedoc.window, &doc_node);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("Could not create document: %08x\n", hres);
|
|
|
|
return;
|
|
|
|
}
|
2008-12-30 06:48:59 +01:00
|
|
|
|
2009-09-16 22:07:58 +02:00
|
|
|
doc->basedoc.doc_node = doc_node;
|
2009-09-16 22:08:41 +02:00
|
|
|
window_set_docnode(doc->basedoc.window, doc_node);
|
2008-10-08 20:27:25 +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();
|
|
|
|
|
2005-08-01 12:59:45 +02:00
|
|
|
if(pCompMgr)
|
|
|
|
nsIComponentManager_Release(pCompMgr);
|
|
|
|
|
|
|
|
if(pServMgr)
|
|
|
|
nsIServiceManager_Release(pServMgr);
|
|
|
|
|
2006-03-27 21:02:28 +02:00
|
|
|
if(nsmem)
|
|
|
|
nsIMemory_Release(nsmem);
|
|
|
|
|
2009-08-05 11:21:33 +02:00
|
|
|
/* Gecko doesn't really support being unloaded */
|
|
|
|
/* if (hXPCOM) FreeLibrary(hXPCOM); */
|
2005-08-01 12:59:45 +02:00
|
|
|
}
|
|
|
|
|
2005-09-02 14:19:42 +02:00
|
|
|
/**********************************************************
|
|
|
|
* nsIWebBrowserChrome interface
|
|
|
|
*/
|
|
|
|
|
2005-08-25 21:24:58 +02:00
|
|
|
#define NSWBCHROME_THIS(iface) DEFINE_THIS(NSContainer, WebBrowserChrome, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_QueryInterface(nsIWebBrowserChrome *iface,
|
|
|
|
nsIIDRef riid, nsQIResult result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
|
|
|
|
|
|
|
*result = NULL;
|
|
|
|
if(IsEqualGUID(&IID_nsISupports, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupports, %p)\n", This, result);
|
|
|
|
*result = NSWBCHROME(This);
|
|
|
|
}else if(IsEqualGUID(&IID_nsIWebBrowserChrome, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIWebBrowserChrome, %p)\n", This, result);
|
|
|
|
*result = NSWBCHROME(This);
|
|
|
|
}else if(IsEqualGUID(&IID_nsIContextMenuListener, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIContextMenuListener, %p)\n", This, result);
|
|
|
|
*result = NSCML(This);
|
2005-12-09 11:41:33 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIURIContentListener, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIURIContentListener %p)\n", This, result);
|
|
|
|
*result = NSURICL(This);
|
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);
|
2005-12-09 11:23:58 +01:00
|
|
|
*result = NSEMBWNDS(This);
|
2006-03-27 21:02:28 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsITooltipListener, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsITooltipListener %p)\n", This, result);
|
|
|
|
*result = NSTOOLTIP(This);
|
2006-02-27 19:08:23 +01:00
|
|
|
}else if(IsEqualGUID(&IID_nsIInterfaceRequestor, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIInterfaceRequestor %p)\n", This, result);
|
|
|
|
*result = NSIFACEREQ(This);
|
2006-03-27 21:02:28 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsIWeakReference, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsIWeakReference %p)\n", This, result);
|
|
|
|
*result = NSWEAKREF(This);
|
|
|
|
}else if(IsEqualGUID(&IID_nsISupportsWeakReference, riid)) {
|
|
|
|
TRACE("(%p)->(IID_nsISupportsWeakReference %p)\n", This, result);
|
|
|
|
*result = NSSUPWEAKREF(This);
|
2005-08-25 21:24:58 +02:00
|
|
|
}
|
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
if(*result) {
|
|
|
|
nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
2006-02-15 11:51:44 +01:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
2006-02-15 11:51:44 +01:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
2006-10-05 23:50:39 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2006-02-15 11:51:44 +01:00
|
|
|
|
2006-03-01 22:04:51 +01:00
|
|
|
if(!ref) {
|
|
|
|
if(This->parent)
|
|
|
|
nsIWebBrowserChrome_Release(NSWBCHROME(This->parent));
|
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,
|
|
|
|
PRUint32 statusType, const PRUnichar *status)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
2008-10-08 20:27:25 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
/* FIXME: This hack should be removed when we'll load all pages by URLMoniker */
|
|
|
|
if(This->doc)
|
2009-09-16 22:09:17 +02:00
|
|
|
update_nsdocument(This->doc);
|
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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aWebBrowser);
|
|
|
|
|
|
|
|
if(aWebBrowser != This->webbrowser)
|
|
|
|
ERR("Wrong nsWebBrowser!\n");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_GetChromeFlags(nsIWebBrowserChrome *iface,
|
|
|
|
PRUint32 *aChromeFlags)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
|
|
|
WARN("(%p)->(%p)\n", This, aChromeFlags);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_SetChromeFlags(nsIWebBrowserChrome *iface,
|
|
|
|
PRUint32 aChromeFlags)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_SizeBrowserTo(nsIWebBrowserChrome *iface,
|
|
|
|
PRInt32 aCX, PRInt32 aCY)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("(%p)->(%d %d)\n", This, aCX, aCY);
|
2005-08-25 21:24:58 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_ShowAsModal(nsIWebBrowserChrome *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
|
|
|
WARN("(%p)\n", This);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_IsWindowModal(nsIWebBrowserChrome *iface, PRBool *_retval)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
|
|
|
WARN("(%p)->(%p)\n", This, _retval);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWebBrowserChrome_ExitModalEventLoop(nsIWebBrowserChrome *iface,
|
|
|
|
nsresult aStatus)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWBCHROME_THIS(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("(%p)->(%08x)\n", This, aStatus);
|
2005-08-25 21:24:58 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSWBCHROME_THIS
|
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
2005-08-25 21:24:58 +02:00
|
|
|
#define NSCML_THIS(iface) DEFINE_THIS(NSContainer, ContextMenuListener, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsContextMenuListener_QueryInterface(nsIContextMenuListener *iface,
|
|
|
|
nsIIDRef riid, nsQIResult result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSCML_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsContextMenuListener_AddRef(nsIContextMenuListener *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSCML_THIS(iface);
|
2005-09-02 14:19:42 +02:00
|
|
|
return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
2005-08-25 21:24:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsContextMenuListener_Release(nsIContextMenuListener *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSCML_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_Release(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuListener *iface,
|
|
|
|
PRUint32 aContextFlags, nsIDOMEvent *aEvent, nsIDOMNode *aNode)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSCML_THIS(iface);
|
|
|
|
nsIDOMMouseEvent *event;
|
|
|
|
POINT pt;
|
|
|
|
DWORD dwID = CONTEXT_MENU_DEFAULT;
|
|
|
|
nsresult nsres;
|
|
|
|
|
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
|
|
|
|
|
|
|
nsres = nsIDOMEvent_QueryInterface(aEvent, &IID_nsIDOMMouseEvent, (void**)&event);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Could not get nsIDOMMouseEvent interface: %08x\n", nsres);
|
2005-08-25 21:24:58 +02:00
|
|
|
return nsres;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMMouseEvent_GetScreenX(event, &pt.x);
|
|
|
|
nsIDOMMouseEvent_GetScreenY(event, &pt.y);
|
|
|
|
nsIDOMMouseEvent_Release(event);
|
|
|
|
|
|
|
|
switch(aContextFlags) {
|
|
|
|
case CONTEXT_NONE:
|
|
|
|
case CONTEXT_DOCUMENT:
|
|
|
|
case CONTEXT_TEXT:
|
|
|
|
dwID = CONTEXT_MENU_DEFAULT;
|
|
|
|
break;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2009-09-16 22:10:03 +02:00
|
|
|
show_context_menu(This->doc, dwID, &pt, (IDispatch*)HTMLDOMNODE(get_node(&This->doc->basedoc, aNode, TRUE)));
|
2005-08-25 21:24:58 +02:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSCML_THIS
|
|
|
|
|
|
|
|
static const nsIContextMenuListenerVtbl nsContextMenuListenerVtbl = {
|
|
|
|
nsContextMenuListener_QueryInterface,
|
|
|
|
nsContextMenuListener_AddRef,
|
|
|
|
nsContextMenuListener_Release,
|
|
|
|
nsContextMenuListener_OnShowContextMenu
|
|
|
|
};
|
|
|
|
|
2005-09-02 14:19:42 +02:00
|
|
|
/**********************************************************
|
|
|
|
* nsIURIContentListener interface
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NSURICL_THIS(iface) DEFINE_THIS(NSContainer, URIContentListener, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsURIContentListener_QueryInterface(nsIURIContentListener *iface,
|
|
|
|
nsIIDRef riid, nsQIResult result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsURIContentListener_AddRef(nsIURIContentListener *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsURIContentListener_Release(nsIURIContentListener *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_Release(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
2009-09-16 22:10:03 +02:00
|
|
|
static BOOL translate_url(HTMLDocumentObj *doc, nsIWineURI *nsuri)
|
2009-08-11 19:16:31 +02:00
|
|
|
{
|
|
|
|
OLECHAR *new_url = NULL, *url;
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
LPCWSTR wine_url;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if(!doc->hostui)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
nsIWineURI_GetWineURL(nsuri, &wine_url);
|
|
|
|
|
|
|
|
url = heap_strdupW(wine_url);
|
|
|
|
hres = IDocHostUIHandler_TranslateUrl(doc->hostui, 0, url, &new_url);
|
|
|
|
heap_free(url);
|
|
|
|
if(hres != S_OK || !new_url)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if(strcmpW(url, new_url)) {
|
|
|
|
FIXME("TranslateUrl returned new URL %s -> %s\n", debugstr_w(url), debugstr_w(new_url));
|
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoTaskMemFree(new_url);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2006-02-09 12:19:33 +01:00
|
|
|
static nsresult NSAPI nsURIContentListener_OnStartURIOpen(nsIURIContentListener *iface,
|
|
|
|
nsIURI *aURI, PRBool *_retval)
|
2005-09-02 14:19:42 +02:00
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(iface);
|
2006-02-09 12:19:33 +01:00
|
|
|
nsIWineURI *wine_uri;
|
2006-03-18 22:00:34 +01:00
|
|
|
nsACString spec_str;
|
2006-02-09 12:19:33 +01:00
|
|
|
const char *spec;
|
|
|
|
nsresult nsres;
|
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
|
|
|
|
2006-02-09 12:19:33 +01:00
|
|
|
nsres = nsIURI_QueryInterface(aURI, &IID_nsIWineURI, (void**)&wine_uri);
|
2006-08-09 16:42:24 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("Could not get nsIWineURI interface: %08x\n", nsres);
|
2006-08-09 16:42:24 +02:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
2005-09-02 14:19:42 +02:00
|
|
|
}
|
|
|
|
|
2006-08-09 16:42:24 +02:00
|
|
|
nsIWineURI_SetNSContainer(wine_uri, This);
|
2006-12-21 23:32:25 +01:00
|
|
|
nsIWineURI_SetIsDocumentURI(wine_uri, TRUE);
|
2006-08-09 16:42:24 +02:00
|
|
|
|
2008-03-23 02:15:39 +01:00
|
|
|
if(This->bscallback) {
|
|
|
|
IMoniker *mon = get_channelbsc_mon(This->bscallback);
|
|
|
|
|
|
|
|
if(mon) {
|
|
|
|
LPWSTR wine_url;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = IMoniker_GetDisplayName(mon, NULL, 0, &wine_url);
|
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
nsIWineURI_SetWineURL(wine_uri, wine_url);
|
|
|
|
CoTaskMemFree(wine_url);
|
|
|
|
}else {
|
|
|
|
WARN("GetDisplayName failed: %08x\n", hres);
|
|
|
|
}
|
|
|
|
|
|
|
|
IMoniker_Release(mon);
|
2006-08-09 16:42:24 +02:00
|
|
|
}
|
2009-08-11 19:16:31 +02:00
|
|
|
|
|
|
|
*_retval = FALSE;
|
|
|
|
}else if(This->doc) {
|
2009-09-16 22:10:03 +02:00
|
|
|
*_retval = translate_url(This->doc->basedoc.doc_obj, wine_uri);
|
2006-08-09 16:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
nsIWineURI_Release(wine_uri);
|
|
|
|
|
2009-08-11 19:16:31 +02:00
|
|
|
return !*_retval && 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,
|
|
|
|
const char *aContentType, PRBool aIsContentPreferred, nsIRequest *aRequest,
|
|
|
|
nsIStreamListener **aContentHandler, PRBool *_retval)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(iface);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
2005-09-02 14:19:42 +02:00
|
|
|
TRACE("(%p)->(%s %x %p %p %p)\n", This, debugstr_a(aContentType), aIsContentPreferred,
|
|
|
|
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,
|
|
|
|
const char *aContentType, char **aDesiredContentType, PRBool *_retval)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(iface);
|
|
|
|
|
|
|
|
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,
|
|
|
|
const char *aContentType, PRBool aIsContentPreferred, char **aDesiredContentType,
|
|
|
|
PRBool *_retval)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSURICL_THIS(iface);
|
2006-08-16 16:34:32 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, aParentContentListener);
|
|
|
|
|
|
|
|
if(aParentContentListener == NSURICL(This))
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSURICL_THIS
|
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define NSEMBWNDS_THIS(iface) DEFINE_THIS(NSContainer, EmbeddingSiteWindow, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_QueryInterface(nsIEmbeddingSiteWindow *iface,
|
|
|
|
nsIIDRef riid, nsQIResult result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsEmbeddingSiteWindow_AddRef(nsIEmbeddingSiteWindow *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsEmbeddingSiteWindow_Release(nsIEmbeddingSiteWindow *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_Release(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_SetDimensions(nsIEmbeddingSiteWindow *iface,
|
|
|
|
PRUint32 flags, PRInt32 x, PRInt32 y, PRInt32 cx, PRInt32 cy)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("(%p)->(%08x %d %d %d %d)\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,
|
|
|
|
PRUint32 flags, PRInt32 *x, PRInt32 *y, PRInt32 *cx, PRInt32 *cy)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(iface);
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("(%p)->(%08x %p %p %p %p)\n", This, flags, x, y, cx, cy);
|
2005-12-09 11:23:58 +01:00
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_SetFocus(nsIEmbeddingSiteWindow *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(iface);
|
2007-06-22 23:30:23 +02:00
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
2007-11-12 01:23:47 +01:00
|
|
|
if(This->reset_focus)
|
|
|
|
PostMessageW(This->hwnd, WM_RESETFOCUS_HACK, 0, 0);
|
|
|
|
|
2007-06-22 23:30:23 +02:00
|
|
|
return nsIBaseWindow_SetFocus(This->window);
|
2005-12-09 11:23:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_GetVisibility(nsIEmbeddingSiteWindow *iface,
|
|
|
|
PRBool *aVisibility)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(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,
|
|
|
|
PRBool aVisibility)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(iface);
|
|
|
|
WARN("(%p)->(%p)\n", This, aTitle);
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_SetTitle(nsIEmbeddingSiteWindow *iface,
|
|
|
|
const PRUnichar *aTitle)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(iface);
|
|
|
|
WARN("(%p)->(%s)\n", This, debugstr_w(aTitle));
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsEmbeddingSiteWindow_GetSiteWindow(nsIEmbeddingSiteWindow *iface,
|
|
|
|
void **aSiteWindow)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSEMBWNDS_THIS(iface);
|
|
|
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2006-03-27 21:02:28 +02:00
|
|
|
#define NSTOOLTIP_THIS(iface) DEFINE_THIS(NSContainer, TooltipListener, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsTooltipListener_QueryInterface(nsITooltipListener *iface, nsIIDRef riid,
|
|
|
|
nsQIResult result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSTOOLTIP_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsTooltipListener_AddRef(nsITooltipListener *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSTOOLTIP_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsTooltipListener_Release(nsITooltipListener *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSTOOLTIP_THIS(iface);
|
2008-06-02 17:49:50 +02:00
|
|
|
return nsIWebBrowserChrome_Release(NSWBCHROME(This));
|
2006-03-27 21:02:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsTooltipListener_OnShowTooltip(nsITooltipListener *iface,
|
|
|
|
PRInt32 aXCoord, PRInt32 aYCoord, const PRUnichar *aTipText)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSTOOLTIP_THIS(iface);
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSTOOLTIP_THIS(iface);
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSTOOLTIM_THIS
|
|
|
|
|
|
|
|
static const nsITooltipListenerVtbl nsTooltipListenerVtbl = {
|
|
|
|
nsTooltipListener_QueryInterface,
|
|
|
|
nsTooltipListener_AddRef,
|
|
|
|
nsTooltipListener_Release,
|
|
|
|
nsTooltipListener_OnShowTooltip,
|
|
|
|
nsTooltipListener_OnHideTooltip
|
|
|
|
};
|
|
|
|
|
2006-02-27 19:08:23 +01:00
|
|
|
#define NSIFACEREQ_THIS(iface) DEFINE_THIS(NSContainer, InterfaceRequestor, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInterfaceRequestor_QueryInterface(nsIInterfaceRequestor *iface,
|
|
|
|
nsIIDRef riid, nsQIResult result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSIFACEREQ_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsInterfaceRequestor_AddRef(nsIInterfaceRequestor *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSIFACEREQ_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsInterfaceRequestor_Release(nsIInterfaceRequestor *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSIFACEREQ_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_Release(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsInterfaceRequestor_GetInterface(nsIInterfaceRequestor *iface,
|
|
|
|
nsIIDRef riid, nsQIResult result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSIFACEREQ_THIS(iface);
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_nsIDOMWindow, riid)) {
|
2006-03-01 22:04:51 +01:00
|
|
|
TRACE("(%p)->(IID_nsIDOMWindow %p)\n", This, result);
|
|
|
|
return nsIWebBrowser_GetContentDOMWindow(This->webbrowser, (nsIDOMWindow**)result);
|
2006-02-27 19:08:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSIFACEREQ_THIS
|
|
|
|
|
|
|
|
static const nsIInterfaceRequestorVtbl nsInterfaceRequestorVtbl = {
|
|
|
|
nsInterfaceRequestor_QueryInterface,
|
|
|
|
nsInterfaceRequestor_AddRef,
|
|
|
|
nsInterfaceRequestor_Release,
|
|
|
|
nsInterfaceRequestor_GetInterface
|
|
|
|
};
|
|
|
|
|
2006-03-27 21:02:28 +02:00
|
|
|
#define NSWEAKREF_THIS(iface) DEFINE_THIS(NSContainer, WeakReference, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWeakReference_QueryInterface(nsIWeakReference *iface,
|
|
|
|
nsIIDRef riid, nsQIResult result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWEAKREF_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsWeakReference_AddRef(nsIWeakReference *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWEAKREF_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsWeakReference_Release(nsIWeakReference *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWEAKREF_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_Release(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsWeakReference_QueryReferent(nsIWeakReference *iface,
|
|
|
|
const nsIID *riid, void **result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSWEAKREF_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSWEAKREF_THIS
|
|
|
|
|
|
|
|
static const nsIWeakReferenceVtbl nsWeakReferenceVtbl = {
|
|
|
|
nsWeakReference_QueryInterface,
|
|
|
|
nsWeakReference_AddRef,
|
|
|
|
nsWeakReference_Release,
|
|
|
|
nsWeakReference_QueryReferent
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NSSUPWEAKREF_THIS(iface) DEFINE_THIS(NSContainer, SupportsWeakReference, iface)
|
|
|
|
|
|
|
|
static nsresult NSAPI nsSupportsWeakReference_QueryInterface(nsISupportsWeakReference *iface,
|
|
|
|
nsIIDRef riid, nsQIResult result)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSSUPWEAKREF_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_QueryInterface(NSWBCHROME(This), riid, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsSupportsWeakReference_AddRef(nsISupportsWeakReference *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSSUPWEAKREF_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_AddRef(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsrefcnt NSAPI nsSupportsWeakReference_Release(nsISupportsWeakReference *iface)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSSUPWEAKREF_THIS(iface);
|
|
|
|
return nsIWebBrowserChrome_Release(NSWBCHROME(This));
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI nsSupportsWeakReference_GetWeakReference(nsISupportsWeakReference *iface,
|
|
|
|
nsIWeakReference **_retval)
|
|
|
|
{
|
|
|
|
NSContainer *This = NSSUPWEAKREF_THIS(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, _retval);
|
|
|
|
|
2006-04-08 19:49:55 +02:00
|
|
|
nsIWeakReference_AddRef(NSWEAKREF(This));
|
2006-03-27 21:02:28 +02:00
|
|
|
*_retval = NSWEAKREF(This);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef NSWEAKREF_THIS
|
|
|
|
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-09-16 22:09:17 +02:00
|
|
|
NSContainer *NSContainer_Create(HTMLDocumentObj *doc, NSContainer *parent)
|
2005-08-01 12:59:45 +02:00
|
|
|
{
|
|
|
|
nsIWebBrowserSetup *wbsetup;
|
2007-06-10 11:52:53 +02:00
|
|
|
nsIScrollable *scrollable;
|
2006-02-15 11:51:44 +01:00
|
|
|
NSContainer *ret;
|
2005-08-01 12:59:45 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
2007-10-14 01:49:19 +02:00
|
|
|
if(!load_gecko(FALSE))
|
2006-03-01 22:04:51 +01:00
|
|
|
return NULL;
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2008-06-23 16:54:16 +02:00
|
|
|
ret = heap_alloc_zero(sizeof(NSContainer));
|
2006-02-15 11:51:44 +01:00
|
|
|
|
2006-03-27 21:02:28 +02:00
|
|
|
ret->lpWebBrowserChromeVtbl = &nsWebBrowserChromeVtbl;
|
|
|
|
ret->lpContextMenuListenerVtbl = &nsContextMenuListenerVtbl;
|
|
|
|
ret->lpURIContentListenerVtbl = &nsURIContentListenerVtbl;
|
|
|
|
ret->lpEmbeddingSiteWindowVtbl = &nsEmbeddingSiteWindowVtbl;
|
|
|
|
ret->lpTooltipListenerVtbl = &nsTooltipListenerVtbl;
|
|
|
|
ret->lpInterfaceRequestorVtbl = &nsInterfaceRequestorVtbl;
|
|
|
|
ret->lpWeakReferenceVtbl = &nsWeakReferenceVtbl;
|
|
|
|
ret->lpSupportsWeakReferenceVtbl = &nsSupportsWeakReferenceVtbl;
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
ret->doc = doc;
|
|
|
|
ret->ref = 1;
|
2008-12-30 06:48:59 +01:00
|
|
|
init_mutation(ret);
|
2005-08-25 21:24:58 +02:00
|
|
|
|
2005-08-10 11:54:02 +02:00
|
|
|
nsres = nsIComponentManager_CreateInstanceByContractID(pCompMgr, NS_WEBBROWSER_CONTRACTID,
|
2006-02-15 11:51:44 +01:00
|
|
|
NULL, &IID_nsIWebBrowser, (void**)&ret->webbrowser);
|
2008-04-07 13:05:56 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Creating WebBrowser failed: %08x\n", nsres);
|
2008-04-07 13:05:56 +02:00
|
|
|
heap_free(ret);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(parent)
|
|
|
|
nsIWebBrowserChrome_AddRef(NSWBCHROME(parent));
|
|
|
|
ret->parent = parent;
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
nsres = nsIWebBrowser_SetContainerWindow(ret->webbrowser, NSWBCHROME(ret));
|
2005-08-25 21:24:58 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("SetContainerWindow failed: %08x\n", nsres);
|
2005-08-25 21:24:58 +02:00
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
nsres = nsIWebBrowser_QueryInterface(ret->webbrowser, &IID_nsIBaseWindow,
|
|
|
|
(void**)&ret->window);
|
2005-08-01 12:59:45 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Could not get nsIBaseWindow interface: %08x\n", nsres);
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
nsres = nsIWebBrowser_QueryInterface(ret->webbrowser, &IID_nsIWebBrowserSetup,
|
|
|
|
(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);
|
2005-12-09 11:41:33 +01:00
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("SetProperty(SETUP_IS_CHROME_WRAPPER) failed: %08x\n", nsres);
|
2005-08-01 12:59:45 +02:00
|
|
|
}else {
|
|
|
|
ERR("Could not get nsIWebBrowserSetup interface\n");
|
|
|
|
}
|
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
nsres = nsIWebBrowser_QueryInterface(ret->webbrowser, &IID_nsIWebNavigation,
|
|
|
|
(void**)&ret->navigation);
|
2005-08-01 12:59:45 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Could not get nsIWebNavigation interface: %08x\n", nsres);
|
2005-08-01 12:59:45 +02:00
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
nsres = nsIWebBrowserFocus_QueryInterface(ret->webbrowser, &IID_nsIWebBrowserFocus,
|
|
|
|
(void**)&ret->focus);
|
2005-08-26 12:05:52 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("Could not get nsIWebBrowserFocus interface: %08x\n", nsres);
|
2005-08-26 12:05:52 +02:00
|
|
|
|
2005-08-10 11:54:02 +02:00
|
|
|
if(!nscontainer_class)
|
|
|
|
register_nscontainer_class();
|
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
ret->hwnd = CreateWindowExW(0, wszNsContainer, NULL,
|
2005-08-10 11:54:02 +02:00
|
|
|
WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 100, 100,
|
2006-03-01 22:03:00 +01:00
|
|
|
GetDesktopWindow(), NULL, hInst, ret);
|
2005-08-10 11:54:02 +02:00
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
nsres = nsIBaseWindow_InitWindow(ret->window, ret->hwnd, NULL, 0, 0, 100, 100);
|
2005-08-10 11:54:02 +02:00
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
2006-02-15 11:51:44 +01:00
|
|
|
nsres = nsIBaseWindow_Create(ret->window);
|
2005-08-10 11:54:02 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
WARN("Creating window failed: %08x\n", nsres);
|
2005-08-10 11:54:02 +02:00
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
nsIBaseWindow_SetVisibility(ret->window, FALSE);
|
|
|
|
nsIBaseWindow_SetEnabled(ret->window, FALSE);
|
2005-08-10 11:54:02 +02:00
|
|
|
}else {
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("InitWindow failed: %08x\n", nsres);
|
2005-08-10 11:54:02 +02:00
|
|
|
}
|
2005-09-02 14:19:42 +02:00
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
nsres = nsIWebBrowser_SetParentURIContentListener(ret->webbrowser, NSURICL(ret));
|
2005-09-02 14:19:42 +02:00
|
|
|
if(NS_FAILED(nsres))
|
2006-10-05 23:50:39 +02:00
|
|
|
ERR("SetParentURIContentListener failed: %08x\n", nsres);
|
2006-03-01 22:04:51 +01:00
|
|
|
|
2007-06-22 23:28:09 +02:00
|
|
|
init_nsevents(ret);
|
|
|
|
|
2007-06-10 11:52:53 +02:00
|
|
|
nsres = nsIWebBrowser_QueryInterface(ret->webbrowser, &IID_nsIScrollable, (void**)&scrollable);
|
|
|
|
if(NS_SUCCEEDED(nsres)) {
|
|
|
|
nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable,
|
|
|
|
ScrollOrientation_Y, Scrollbar_Always);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not set default Y scrollbar prefs: %08x\n", nsres);
|
|
|
|
|
|
|
|
nsres = nsIScrollable_SetDefaultScrollbarPreferences(scrollable,
|
|
|
|
ScrollOrientation_X, Scrollbar_Auto);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not set default X scrollbar prefs: %08x\n", nsres);
|
|
|
|
|
|
|
|
nsIScrollable_Release(scrollable);
|
|
|
|
}else {
|
|
|
|
ERR("Could not get nsIScrollable: %08x\n", nsres);
|
|
|
|
}
|
|
|
|
|
2006-03-01 22:04:51 +01:00
|
|
|
return ret;
|
2005-08-01 12:59:45 +02:00
|
|
|
}
|
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
void NSContainer_Release(NSContainer *This)
|
2005-08-01 12:59:45 +02:00
|
|
|
{
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
2008-07-02 18:43:22 +02:00
|
|
|
This->doc = 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
|
|
|
|
2006-02-15 11:51:44 +01:00
|
|
|
nsIWebBrowserChrome_Release(NSWBCHROME(This));
|
2005-08-01 12:59:45 +02:00
|
|
|
}
|