urlmon: Don't create stgmed_obj for binding to object.
[wine] / dlls / mshtml / mshtml_private.h
1 /*
2  * Copyright 2005-2006 Jacek Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "wingdi.h"
20 #include "docobj.h"
21 #include "mshtml.h"
22 #include "mshtmhst.h"
23 #include "hlink.h"
24
25 #include "wine/list.h"
26 #include "wine/unicode.h"
27
28 #ifdef INIT_GUID
29 #include "initguid.h"
30 #endif
31
32 #include "nsiface.h"
33
34 #define GENERATE_MSHTML_NS_FAILURE(code) \
35     ((nsresult) ((PRUint32)(1<<31) | ((PRUint32)(0x45+6)<<16) | (PRUint32)(code)))
36
37 #define NS_OK                     ((nsresult)0x00000000L)
38 #define NS_ERROR_FAILURE          ((nsresult)0x80004005L)
39 #define NS_NOINTERFACE            ((nsresult)0x80004002L)
40 #define NS_ERROR_NOT_IMPLEMENTED  ((nsresult)0x80004001L)
41 #define NS_ERROR_INVALID_ARG      ((nsresult)0x80070057L) 
42 #define NS_ERROR_UNEXPECTED       ((nsresult)0x8000ffffL)
43 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
44
45 #define WINE_NS_LOAD_FROM_MONIKER GENERATE_MSHTML_NS_FAILURE(0)
46
47 #define NS_FAILED(res) ((res) & 0x80000000)
48 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
49
50 #define NSAPI WINAPI
51
52 #define MSHTML_E_NODOC    0x800a025c
53
54 typedef struct HTMLDOMNode HTMLDOMNode;
55 typedef struct ConnectionPoint ConnectionPoint;
56 typedef struct BSCallback BSCallback;
57
58 typedef struct {
59     const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
60
61     LONG ref;
62
63     HTMLDocument *doc;
64     nsIDOMWindow *nswindow;
65
66     struct list entry;
67 } HTMLWindow;
68
69 typedef enum {
70     UNKNOWN_USERMODE,
71     BROWSEMODE,
72     EDITMODE        
73 } USERMODE;
74
75 typedef struct {
76     const IConnectionPointContainerVtbl  *lpConnectionPointContainerVtbl;
77
78     ConnectionPoint *cp_list;
79     IUnknown *outer;
80 } ConnectionPointContainer;
81
82 struct ConnectionPoint {
83     const IConnectionPointVtbl *lpConnectionPointVtbl;
84
85     IConnectionPointContainer *container;
86
87     union {
88         IUnknown *unk;
89         IDispatch *disp;
90         IPropertyNotifySink *propnotif;
91     } *sinks;
92     DWORD sinks_size;
93
94     const IID *iid;
95
96     ConnectionPoint *next;
97 };
98
99 typedef struct {
100     const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
101
102     LONG ref;
103
104     HTMLDocument *doc;
105 } HTMLOptionElementFactory;
106
107 struct HTMLDocument {
108     const IHTMLDocument2Vtbl              *lpHTMLDocument2Vtbl;
109     const IHTMLDocument3Vtbl              *lpHTMLDocument3Vtbl;
110     const IHTMLDocument4Vtbl              *lpHTMLDocument4Vtbl;
111     const IHTMLDocument5Vtbl              *lpHTMLDocument5Vtbl;
112     const IPersistMonikerVtbl             *lpPersistMonikerVtbl;
113     const IPersistFileVtbl                *lpPersistFileVtbl;
114     const IMonikerPropVtbl                *lpMonikerPropVtbl;
115     const IOleObjectVtbl                  *lpOleObjectVtbl;
116     const IOleDocumentVtbl                *lpOleDocumentVtbl;
117     const IOleDocumentViewVtbl            *lpOleDocumentViewVtbl;
118     const IOleInPlaceActiveObjectVtbl     *lpOleInPlaceActiveObjectVtbl;
119     const IViewObject2Vtbl                *lpViewObject2Vtbl;
120     const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
121     const IServiceProviderVtbl            *lpServiceProviderVtbl;
122     const IOleCommandTargetVtbl           *lpOleCommandTargetVtbl;
123     const IOleControlVtbl                 *lpOleControlVtbl;
124     const IHlinkTargetVtbl                *lpHlinkTargetVtbl;
125     const IPersistStreamInitVtbl          *lpPersistStreamInitVtbl;
126     const ICustomDocVtbl                  *lpCustomDocVtbl;
127
128     LONG ref;
129
130     NSContainer *nscontainer;
131     HTMLWindow *window;
132
133     IOleClientSite *client;
134     IDocHostUIHandler *hostui;
135     IOleInPlaceSite *ipsite;
136     IOleInPlaceFrame *frame;
137     IOleInPlaceUIWindow *ip_window;
138
139     IOleUndoManager *undomgr;
140
141     BSCallback *bscallback;
142     IMoniker *mon;
143     LPOLESTR url;
144     struct list bindings;
145
146     HWND hwnd;
147     HWND tooltips_hwnd;
148
149     DOCHOSTUIINFO hostinfo;
150
151     USERMODE usermode;
152     READYSTATE readystate;
153     BOOL in_place_active;
154     BOOL ui_active;
155     BOOL window_active;
156     BOOL has_key_path;
157     BOOL container_locked;
158     BOOL focus;
159     LPWSTR mime;
160
161     DWORD update;
162
163     ConnectionPointContainer cp_container;
164     ConnectionPoint cp_htmldocevents;
165     ConnectionPoint cp_htmldocevents2;
166     ConnectionPoint cp_propnotif;
167
168     HTMLOptionElementFactory *option_factory;
169
170     struct list selection_list;
171     struct list range_list;
172
173     HTMLDOMNode *nodes;
174 };
175
176 typedef struct {
177     const nsIDOMEventListenerVtbl      *lpDOMEventListenerVtbl;
178     NSContainer *This;
179 } nsEventListener;
180
181 struct NSContainer {
182     const nsIWebBrowserChromeVtbl       *lpWebBrowserChromeVtbl;
183     const nsIContextMenuListenerVtbl    *lpContextMenuListenerVtbl;
184     const nsIURIContentListenerVtbl     *lpURIContentListenerVtbl;
185     const nsIEmbeddingSiteWindowVtbl    *lpEmbeddingSiteWindowVtbl;
186     const nsITooltipListenerVtbl        *lpTooltipListenerVtbl;
187     const nsIInterfaceRequestorVtbl     *lpInterfaceRequestorVtbl;
188     const nsIWeakReferenceVtbl          *lpWeakReferenceVtbl;
189     const nsISupportsWeakReferenceVtbl  *lpSupportsWeakReferenceVtbl;
190
191     nsEventListener blur_listener;
192     nsEventListener focus_listener;
193     nsEventListener keypress_listener;
194     nsEventListener load_listener;
195
196     nsIWebBrowser *webbrowser;
197     nsIWebNavigation *navigation;
198     nsIBaseWindow *window;
199     nsIWebBrowserFocus *focus;
200
201     nsIEditor *editor;
202     nsIController *editor_controller;
203
204     LONG ref;
205
206     NSContainer *parent;
207     HTMLDocument *doc;
208
209     nsIURIContentListener *content_listener;
210
211     HWND hwnd;
212
213     BSCallback *bscallback; /* hack */
214     HWND reset_focus; /* hack */
215 };
216
217 typedef struct {
218     const nsIHttpChannelVtbl *lpHttpChannelVtbl;
219     const nsIUploadChannelVtbl *lpUploadChannelVtbl;
220
221     LONG ref;
222
223     nsIChannel *channel;
224     nsIHttpChannel *http_channel;
225     nsIWineURI *uri;
226     nsIInputStream *post_data_stream;
227     nsILoadGroup *load_group;
228     nsIInterfaceRequestor *notif_callback;
229     nsLoadFlags load_flags;
230     nsIURI *original_uri;
231     char *content;
232     char *charset;
233 } nsChannel;
234
235 typedef struct {
236     const nsIInputStreamVtbl *lpInputStreamVtbl;
237
238     LONG ref;
239
240     char buf[1024];
241     DWORD buf_size;
242 } nsProtocolStream;
243
244 struct BSCallback {
245     const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
246     const IServiceProviderVtbl    *lpServiceProviderVtbl;
247     const IHttpNegotiate2Vtbl     *lpHttpNegotiate2Vtbl;
248     const IInternetBindInfoVtbl   *lpInternetBindInfoVtbl;
249
250     LONG ref;
251
252     LPWSTR headers;
253     HGLOBAL post_data;
254     ULONG post_data_len;
255     ULONG readed;
256
257     nsChannel *nschannel;
258     nsIStreamListener *nslistener;
259     nsISupports *nscontext;
260
261     IMoniker *mon;
262     IBinding *binding;
263
264     HTMLDocument *doc;
265
266     nsProtocolStream *nsstream;
267
268     struct list entry;
269 };
270
271 typedef struct {
272     HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
273     void (*destructor)(HTMLDOMNode*);
274 } NodeImplVtbl;
275
276 struct HTMLDOMNode {
277     const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
278     const NodeImplVtbl *vtbl;
279
280     LONG ref;
281
282     nsIDOMNode *nsnode;
283     HTMLDocument *doc;
284
285     HTMLDOMNode *next;
286 };
287
288 typedef struct {
289     HTMLDOMNode node;
290     ConnectionPointContainer cp_container;
291
292     const IHTMLElementVtbl   *lpHTMLElementVtbl;
293     const IHTMLElement2Vtbl  *lpHTMLElement2Vtbl;
294
295     nsIDOMHTMLElement *nselem;
296 } HTMLElement;
297
298 typedef struct {
299     HTMLElement element;
300
301     const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
302
303     ConnectionPoint cp;
304 } HTMLTextContainer;
305
306 #define HTMLWINDOW2(x)   ((IHTMLWindow2*)                 &(x)->lpHTMLWindow2Vtbl)
307
308 #define HTMLDOC(x)       ((IHTMLDocument2*)               &(x)->lpHTMLDocument2Vtbl)
309 #define HTMLDOC3(x)      ((IHTMLDocument3*)               &(x)->lpHTMLDocument3Vtbl)
310 #define HTMLDOC4(x)      ((IHTMLDocument4*)               &(x)->lpHTMLDocument4Vtbl)
311 #define HTMLDOC5(x)      ((IHTMLDocument5*)               &(x)->lpHTMLDocument5Vtbl)
312 #define PERSIST(x)       ((IPersist*)                     &(x)->lpPersistFileVtbl)
313 #define PERSISTMON(x)    ((IPersistMoniker*)              &(x)->lpPersistMonikerVtbl)
314 #define PERSISTFILE(x)   ((IPersistFile*)                 &(x)->lpPersistFileVtbl)
315 #define MONPROP(x)       ((IMonikerProp*)                 &(x)->lpMonikerPropVtbl)
316 #define OLEOBJ(x)        ((IOleObject*)                   &(x)->lpOleObjectVtbl)
317 #define OLEDOC(x)        ((IOleDocument*)                 &(x)->lpOleDocumentVtbl)
318 #define DOCVIEW(x)       ((IOleDocumentView*)             &(x)->lpOleDocumentViewVtbl)
319 #define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
320 #define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
321 #define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObject2Vtbl)
322 #define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObject2Vtbl)
323 #define INPLACEOBJ(x)    ((IOleInPlaceObject*)            &(x)->lpOleInPlaceObjectWindowlessVtbl)
324 #define INPLACEWIN(x)    ((IOleInPlaceObjectWindowless*)  &(x)->lpOleInPlaceObjectWindowlessVtbl)
325 #define SERVPROV(x)      ((IServiceProvider*)             &(x)->lpServiceProviderVtbl)
326 #define CMDTARGET(x)     ((IOleCommandTarget*)            &(x)->lpOleCommandTargetVtbl)
327 #define CONTROL(x)       ((IOleControl*)                  &(x)->lpOleControlVtbl)
328 #define HLNKTARGET(x)    ((IHlinkTarget*)                 &(x)->lpHlinkTargetVtbl)
329 #define CONPTCONT(x)     ((IConnectionPointContainer*)    &(x)->lpConnectionPointContainerVtbl)
330 #define PERSTRINIT(x)    ((IPersistStreamInit*)           &(x)->lpPersistStreamInitVtbl)
331 #define CUSTOMDOC(x)     ((ICustomDoc*)                   &(x)->lpCustomDocVtbl)
332
333 #define NSWBCHROME(x)    ((nsIWebBrowserChrome*)          &(x)->lpWebBrowserChromeVtbl)
334 #define NSCML(x)         ((nsIContextMenuListener*)       &(x)->lpContextMenuListenerVtbl)
335 #define NSURICL(x)       ((nsIURIContentListener*)        &(x)->lpURIContentListenerVtbl)
336 #define NSEMBWNDS(x)     ((nsIEmbeddingSiteWindow*)       &(x)->lpEmbeddingSiteWindowVtbl)
337 #define NSIFACEREQ(x)    ((nsIInterfaceRequestor*)        &(x)->lpInterfaceRequestorVtbl)
338 #define NSTOOLTIP(x)     ((nsITooltipListener*)           &(x)->lpTooltipListenerVtbl)
339 #define NSEVENTLIST(x)   ((nsIDOMEventListener*)          &(x)->lpDOMEventListenerVtbl)
340 #define NSWEAKREF(x)     ((nsIWeakReference*)             &(x)->lpWeakReferenceVtbl)
341 #define NSSUPWEAKREF(x)  ((nsISupportsWeakReference*)     &(x)->lpSupportsWeakReferenceVtbl)
342
343 #define NSCHANNEL(x)     ((nsIChannel*)        &(x)->lpHttpChannelVtbl)
344 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*)    &(x)->lpHttpChannelVtbl)
345 #define NSUPCHANNEL(x)   ((nsIUploadChannel*)  &(x)->lpUploadChannelVtbl)
346
347 #define HTTPNEG(x)       ((IHttpNegotiate2*)              &(x)->lpHttpNegotiate2Vtbl)
348 #define STATUSCLB(x)     ((IBindStatusCallback*)          &(x)->lpBindStatusCallbackVtbl)
349 #define BINDINFO(x)      ((IInternetBindInfo*)            &(x)->lpInternetBindInfoVtbl);
350
351 #define HTMLELEM(x)      ((IHTMLElement*)                 &(x)->lpHTMLElementVtbl)
352 #define HTMLELEM2(x)     ((IHTMLElement2*)                &(x)->lpHTMLElement2Vtbl)
353 #define HTMLDOMNODE(x)   ((IHTMLDOMNode*)                 &(x)->lpHTMLDOMNodeVtbl)
354
355 #define HTMLTEXTCONT(x)  ((IHTMLTextContainer*)           &(x)->lpHTMLTextContainerVtbl)
356
357 #define HTMLOPTFACTORY(x)  ((IHTMLOptionElementFactory*)  &(x)->lpHTMLOptionElementFactoryVtbl)
358
359 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
360 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
361
362 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
363 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
364
365 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
366 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
367 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
368 void setup_nswindow(HTMLWindow*);
369
370 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
371 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
372 void HTMLDocument_Persist_Init(HTMLDocument*);
373 void HTMLDocument_OleCmd_Init(HTMLDocument*);
374 void HTMLDocument_OleObj_Init(HTMLDocument*);
375 void HTMLDocument_View_Init(HTMLDocument*);
376 void HTMLDocument_Window_Init(HTMLDocument*);
377 void HTMLDocument_Service_Init(HTMLDocument*);
378 void HTMLDocument_Hlink_Init(HTMLDocument*);
379
380 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
381 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
382 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
383
384 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
385 void NSContainer_Release(NSContainer*);
386
387 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
388 void show_context_menu(HTMLDocument*,DWORD,POINT*,IDispatch*);
389 void notif_focus(HTMLDocument*);
390
391 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
392 void hide_tooltip(HTMLDocument*);
393 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
394
395 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
396
397 BOOL load_gecko(BOOL);
398 void close_gecko(void);
399 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
400 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
401 BOOL install_wine_gecko(BOOL);
402
403 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
404
405 void call_property_onchanged(ConnectionPoint*,DISPID);
406 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
407
408 void *nsalloc(size_t);
409 void nsfree(void*);
410
411 void nsACString_Init(nsACString*,const char*);
412 void nsACString_SetData(nsACString*,const char*);
413 PRUint32 nsACString_GetData(const nsACString*,const char**);
414 void nsACString_Finish(nsACString*);
415
416 void nsAString_Init(nsAString*,const PRUnichar*);
417 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
418 void nsAString_Finish(nsAString*);
419
420 nsIInputStream *create_nsstream(const char*,PRInt32);
421 nsICommandParams *create_nscommand_params(void);
422 nsIMutableArray *create_nsarray(void);
423 nsIWritableVariant *create_nsvariant(void);
424 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
425 void get_editor_controller(NSContainer*);
426 void init_nsevents(NSContainer*);
427 nsresult get_nsinterface(nsISupports*,REFIID,void**);
428
429 BSCallback *create_bscallback(IMoniker*);
430 HRESULT start_binding(HTMLDocument*,BSCallback*,IBindCtx*);
431 HRESULT load_stream(BSCallback*,IStream*);
432 void set_document_bscallback(HTMLDocument*,BSCallback*);
433 void set_current_mon(HTMLDocument*,IMoniker*);
434
435 IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*);
436 IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*);
437 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
438 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
439 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
440
441 void detach_selection(HTMLDocument*);
442 void detach_ranges(HTMLDocument*);
443
444 HTMLElement *HTMLElement_Create(nsIDOMNode*);
445 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
446 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
447 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
448 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
449 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
450 HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
451 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
452
453 void HTMLElement_Init(HTMLElement*);
454 void HTMLElement2_Init(HTMLElement*);
455 void HTMLTextContainer_Init(HTMLTextContainer*);
456
457 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
458 void HTMLDOMNode_destructor(HTMLDOMNode*);
459
460 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
461 void HTMLElement_destructor(HTMLDOMNode*);
462
463 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
464 void release_nodes(HTMLDocument*);
465
466 IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
467
468 /* commands */
469 typedef struct {
470     DWORD id;
471     HRESULT (*query)(HTMLDocument*,OLECMD*);
472     HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
473 } cmdtable_t;
474
475 extern const cmdtable_t editmode_cmds[];
476
477 void do_ns_command(NSContainer*,const char*,nsICommandParams*);
478
479 /* timer */
480 #define UPDATE_UI       0x0001
481 #define UPDATE_TITLE    0x0002
482
483 void update_doc(HTMLDocument *This, DWORD flags);
484 void update_title(HTMLDocument*);
485
486 /* editor */
487 void init_editor(HTMLDocument*);
488 void set_ns_editmode(NSContainer*);
489 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
490 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
491 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
492 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
493 void handle_edit_load(HTMLDocument*);
494 HRESULT editor_is_dirty(HTMLDocument*);
495 void set_dirty(HTMLDocument*,VARIANT_BOOL);
496
497 extern DWORD mshtml_tls;
498
499 typedef struct task_t {
500     HTMLDocument *doc;
501
502     enum {
503         TASK_SETDOWNLOADSTATE,
504         TASK_PARSECOMPLETE,
505         TASK_SETPROGRESS,
506         TASK_START_BINDING
507     } task_id;
508
509     BSCallback *bscallback;
510
511     struct task_t *next;
512 } task_t;
513
514 typedef struct {
515     HWND thread_hwnd;
516     task_t *task_queue_head;
517     task_t *task_queue_tail;
518 } thread_data_t;
519
520 thread_data_t *get_thread_data(BOOL);
521 HWND get_thread_hwnd(void);
522 void push_task(task_t*);
523 void remove_doc_tasks(const HTMLDocument*);
524
525 /* typelibs */
526 enum tid_t {
527     IHTMLWindow2_tid,
528     LAST_tid
529 };
530
531 HRESULT get_typeinfo(enum tid_t, ITypeInfo**);
532
533 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
534 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
535 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
536 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
537 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
538
539 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
540
541 extern LONG module_ref;
542 #define LOCK_MODULE()   InterlockedIncrement(&module_ref)
543 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
544
545 /* memory allocation functions */
546
547 static inline void *heap_alloc(size_t len)
548 {
549     return HeapAlloc(GetProcessHeap(), 0, len);
550 }
551
552 static inline void *heap_alloc_zero(size_t len)
553 {
554     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
555 }
556
557 static inline void *heap_realloc(void *mem, size_t len)
558 {
559     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
560 }
561
562 static inline BOOL heap_free(void *mem)
563 {
564     return HeapFree(GetProcessHeap(), 0, mem);
565 }
566
567 static inline LPWSTR heap_strdupW(LPCWSTR str)
568 {
569     LPWSTR ret = NULL;
570
571     if(str) {
572         DWORD size;
573
574         size = (strlenW(str)+1)*sizeof(WCHAR);
575         ret = heap_alloc(size);
576         memcpy(ret, str, size);
577     }
578
579     return ret;
580 }
581
582
583 HINSTANCE get_shdoclc(void);
584
585 extern HINSTANCE hInst;