Jacek Caban : mshtml: Create one "Internet Explorer_Hidden"
window per thread.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Sep 25 14:45:40 CDT 2006
Module: wine
Branch: master
Commit: a14e2aaf97e638a46c56d618b08c7d9bf7b6885e
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=a14e2aaf97e638a46c56d618b08c7d9bf7b6885e
Author: Jacek Caban <jacek at codeweavers.com>
Date: Sun Sep 24 23:10:38 2006 +0200
mshtml: Create one "Internet Explorer_Hidden" window per thread.
---
dlls/mshtml/Makefile.in | 1
dlls/mshtml/htmldoc.c | 3 +
dlls/mshtml/main.c | 31 +++++++++++--
dlls/mshtml/mshtml_private.h | 16 ++++++-
dlls/mshtml/task.c | 98 ++++++++++++++++++++++++++++++++++++++++++
dlls/mshtml/view.c | 32 --------------
6 files changed, 140 insertions(+), 41 deletions(-)
diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in
index a6942ff..b3009b1 100644
--- a/dlls/mshtml/Makefile.in
+++ b/dlls/mshtml/Makefile.in
@@ -35,6 +35,7 @@ C_SRCS = \
protocol.c \
selection.c \
service.c \
+ task.c \
txtrange.c \
view.c
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index c991e28..066e87d 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -154,7 +154,6 @@ static ULONG WINAPI HTMLDocument_Release
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 *pU
ret->nscontainer = NSContainer_Create(ret, NULL);
+ get_thread_hwnd();
+
return hres;
}
diff --git a/dlls/mshtml/main.c b/dlls/mshtml/main.c
index f713e27..d49a8d2 100644
--- a/dlls/mshtml/main.c
+++ b/dlls/mshtml/main.c
@@ -47,16 +47,35 @@ 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)
{
switch(fdwReason) {
- case DLL_PROCESS_ATTACH:
- hInst = hInstDLL;
- break;
- case DLL_PROCESS_DETACH:
- close_gecko();
- break;
+ case DLL_PROCESS_ATTACH:
+ hInst = hInstDLL;
+ break;
+ case DLL_PROCESS_DETACH:
+ close_gecko();
+ if(mshtml_tls)
+ TlsFree(mshtml_tls);
+ break;
+ case DLL_THREAD_DETACH:
+ thread_detach();
+ break;
}
return TRUE;
}
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index b9eb7d3..75d132c 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -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_param
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
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);
diff --git a/dlls/mshtml/task.c b/dlls/mshtml/task.c
new file mode 100644
index 0000000..0619cd1
--- /dev/null
+++ b/dlls/mshtml/task.c
@@ -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;
+}
diff --git a/dlls/mshtml/view.c b/dlls/mshtml/view.c
index dc7a74f..e233d7a 100644
--- a/dlls/mshtml/view.c
+++ b/dlls/mshtml/view.c
@@ -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->in_place_active = FALSE;
This->ui_active = FALSE;
This->window_active = FALSE;
-
- create_hidden_window(This);
}
More information about the wine-cvs
mailing list