mshtml: Create one "Internet Explorer_Hidden" window per thread.

This commit is contained in:
Jacek Caban 2006-09-24 23:10:38 +02:00 committed by Alexandre Julliard
parent 8fc83b1f46
commit a14e2aaf97
6 changed files with 140 additions and 41 deletions

View File

@ -35,6 +35,7 @@ C_SRCS = \
protocol.c \
selection.c \
service.c \
task.c \
txtrange.c \
view.c

View File

@ -154,7 +154,6 @@ static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
DestroyWindow(This->tooltips_hwnd);
if(This->hwnd)
DestroyWindow(This->hwnd);
DestroyWindow(This->hidden_hwnd);
release_nodes(This);
@ -1093,5 +1092,7 @@ HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
ret->nscontainer = NSContainer_Create(ret, NULL);
get_thread_hwnd();
return hres;
}

View File

@ -47,6 +47,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
HINSTANCE hInst;
LONG module_ref = 0;
DWORD mshtml_tls = 0;
static void thread_detach(void)
{
thread_data_t *thread_data = get_thread_data(FALSE);
if(!thread_data)
return;
if(thread_data->thread_hwnd)
DestroyWindow(thread_data->thread_hwnd);
mshtml_free(thread_data);
}
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
{
@ -56,6 +70,11 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
break;
case DLL_PROCESS_DETACH:
close_gecko();
if(mshtml_tls)
TlsFree(mshtml_tls);
break;
case DLL_THREAD_DETACH:
thread_detach();
break;
}
return TRUE;

View File

@ -87,7 +87,6 @@ struct HTMLDocument {
IOleInPlaceFrame *frame;
HWND hwnd;
HWND hidden_hwnd;
HWND tooltips_hwnd;
USERMODE usermode;
@ -316,7 +315,6 @@ nsICommandParams *create_nscommand_params(void);
BSCallback *create_bscallback(HTMLDocument*,IMoniker*);
HRESULT start_binding(BSCallback*);
void create_hidden_hwnd(HTMLDocument*);
IHlink *Hlink_Create(void);
IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*);
@ -340,6 +338,15 @@ void release_nodes(HTMLDocument*);
void install_wine_gecko(void);
extern DWORD mshtml_tls;
typedef struct {
HWND thread_hwnd;
} thread_data_t;
thread_data_t *get_thread_data(BOOL);
HWND get_thread_hwnd(void);
DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
@ -359,6 +366,11 @@ static inline void *mshtml_alloc(size_t len)
return HeapAlloc(GetProcessHeap(), 0, len);
}
static inline void *mshtml_alloc_zero(size_t len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
static inline void *mshtml_realloc(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), 0, mem, len);

98
dlls/mshtml/task.c Normal file
View File

@ -0,0 +1,98 @@
/*
* Copyright 2006 Jacek Caban for CodeWeavers
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#include <stdio.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "mshtmcid.h"
#include "wine/debug.h"
#include "mshtml_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
#define WM_PROCESSTASK 0x8008
static LRESULT WINAPI hidden_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if(msg > WM_USER)
FIXME("(%p %d %x %lx)\n", hwnd, msg, wParam, lParam);
return DefWindowProcW(hwnd, msg, wParam, lParam);
}
static HWND create_thread_hwnd(void)
{
static ATOM hidden_wnd_class = 0;
static const WCHAR wszInternetExplorer_Hidden[] = {'I','n','t','e','r','n','e','t',
' ','E','x','p','l','o','r','e','r','_','H','i','d','d','e','n',0};
if(!hidden_wnd_class) {
WNDCLASSEXW wndclass = {
sizeof(WNDCLASSEXW), 0,
hidden_proc,
0, 0, hInst, NULL, NULL, NULL, NULL,
wszInternetExplorer_Hidden,
NULL
};
hidden_wnd_class = RegisterClassExW(&wndclass);
}
return CreateWindowExW(0, wszInternetExplorer_Hidden, NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL, hInst, NULL);
}
HWND get_thread_hwnd(void)
{
thread_data_t *thread_data = get_thread_data(TRUE);
if(!thread_data->thread_hwnd)
thread_data->thread_hwnd = create_thread_hwnd();
return thread_data->thread_hwnd;
}
thread_data_t *get_thread_data(BOOL create)
{
thread_data_t *thread_data;
if(!mshtml_tls) {
if(create)
mshtml_tls = TlsAlloc();
else
return NULL;
}
thread_data = TlsGetValue(mshtml_tls);
if(!thread_data && create) {
thread_data = mshtml_alloc_zero(sizeof(thread_data_t));
TlsSetValue(mshtml_tls, thread_data);
}
return thread_data;
}

View File

@ -49,36 +49,6 @@ typedef struct {
WNDPROC proc;
} tooltip_data;
static LRESULT WINAPI hidden_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if(msg > WM_USER)
FIXME("(%p %d %x %lx)\n", hwnd, msg, wParam, lParam);
return DefWindowProcW(hwnd, msg, wParam, lParam);
}
static void create_hidden_window(HTMLDocument *This)
{
static ATOM hidden_wnd_class = 0;
static const WCHAR wszInternetExplorer_Hidden[] = {'I','n','t','e','r','n','e','t',
' ','E','x','p','l','o','r','e','r','_','H','i','d','d','e','n',0};
if(!hidden_wnd_class) {
WNDCLASSEXW wndclass = {
sizeof(WNDCLASSEXW), 0,
hidden_proc,
0, 0, hInst, NULL, NULL, NULL, NULL,
wszInternetExplorer_Hidden,
NULL
};
hidden_wnd_class = RegisterClassExW(&wndclass);
}
This->hidden_hwnd = CreateWindowExW(0, wszInternetExplorer_Hidden, NULL, WS_POPUP,
0, 0, 0, 0, NULL, NULL, hInst, This);
}
static void paint_disabled(HWND hwnd) {
HDC hdc;
PAINTSTRUCT ps;
@ -696,6 +666,4 @@ void HTMLDocument_View_Init(HTMLDocument *This)
This->in_place_active = FALSE;
This->ui_active = FALSE;
This->window_active = FALSE;
create_hidden_window(This);
}