mshtml: Added IHTMLDocument2::write implementation.
[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     nsEventListener node_insert_listener;
196
197     nsIWebBrowser *webbrowser;
198     nsIWebNavigation *navigation;
199     nsIBaseWindow *window;
200     nsIWebBrowserFocus *focus;
201
202     nsIEditor *editor;
203     nsIController *editor_controller;
204
205     LONG ref;
206
207     NSContainer *parent;
208     HTMLDocument *doc;
209
210     nsIURIContentListener *content_listener;
211
212     HWND hwnd;
213
214     BSCallback *bscallback; /* hack */
215     HWND reset_focus; /* hack */
216 };
217
218 typedef struct {
219     const nsIHttpChannelVtbl *lpHttpChannelVtbl;
220     const nsIUploadChannelVtbl *lpUploadChannelVtbl;
221
222     LONG ref;
223
224     nsIChannel *channel;
225     nsIHttpChannel *http_channel;
226     nsIWineURI *uri;
227     nsIInputStream *post_data_stream;
228     nsILoadGroup *load_group;
229     nsIInterfaceRequestor *notif_callback;
230     nsLoadFlags load_flags;
231     nsIURI *original_uri;
232     char *content;
233     char *charset;
234 } nsChannel;
235
236 typedef struct {
237     const nsIInputStreamVtbl *lpInputStreamVtbl;
238
239     LONG ref;
240
241     char buf[1024];
242     DWORD buf_size;
243 } nsProtocolStream;
244
245 struct BSCallback {
246     const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
247     const IServiceProviderVtbl    *lpServiceProviderVtbl;
248     const IHttpNegotiate2Vtbl     *lpHttpNegotiate2Vtbl;
249     const IInternetBindInfoVtbl   *lpInternetBindInfoVtbl;
250
251     LONG ref;
252
253     LPWSTR headers;
254     HGLOBAL post_data;
255     ULONG post_data_len;
256     ULONG readed;
257
258     nsChannel *nschannel;
259     nsIStreamListener *nslistener;
260     nsISupports *nscontext;
261
262     IMoniker *mon;
263     IBinding *binding;
264
265     HTMLDocument *doc;
266
267     nsProtocolStream *nsstream;
268
269     struct list entry;
270 };
271
272 typedef struct {
273     HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
274     void (*destructor)(HTMLDOMNode*);
275 } NodeImplVtbl;
276
277 struct HTMLDOMNode {
278     const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
279     const NodeImplVtbl *vtbl;
280
281     LONG ref;
282
283     nsIDOMNode *nsnode;
284     HTMLDocument *doc;
285
286     HTMLDOMNode *next;
287 };
288
289 typedef struct {
290     HTMLDOMNode node;
291     ConnectionPointContainer cp_container;
292
293     const IHTMLElementVtbl   *lpHTMLElementVtbl;
294     const IHTMLElement2Vtbl  *lpHTMLElement2Vtbl;
295
296     nsIDOMHTMLElement *nselem;
297 } HTMLElement;
298
299 typedef struct {
300     HTMLElement element;
301
302     const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
303
304     ConnectionPoint cp;
305 } HTMLTextContainer;
306
307 #define HTMLWINDOW2(x)   ((IHTMLWindow2*)                 &(x)->lpHTMLWindow2Vtbl)
308
309 #define HTMLDOC(x)       ((IHTMLDocument2*)               &(x)->lpHTMLDocument2Vtbl)
310 #define HTMLDOC3(x)      ((IHTMLDocument3*)               &(x)->lpHTMLDocument3Vtbl)
311 #define HTMLDOC4(x)      ((IHTMLDocument4*)               &(x)->lpHTMLDocument4Vtbl)
312 #define HTMLDOC5(x)      ((IHTMLDocument5*)               &(x)->lpHTMLDocument5Vtbl)
313 #define PERSIST(x)       ((IPersist*)                     &(x)->lpPersistFileVtbl)
314 #define PERSISTMON(x)    ((IPersistMoniker*)              &(x)->lpPersistMonikerVtbl)
315 #define PERSISTFILE(x)   ((IPersistFile*)                 &(x)->lpPersistFileVtbl)
316 #define MONPROP(x)       ((IMonikerProp*)                 &(x)->lpMonikerPropVtbl)
317 #define OLEOBJ(x)        ((IOleObject*)                   &(x)->lpOleObjectVtbl)
318 #define OLEDOC(x)        ((IOleDocument*)                 &(x)->lpOleDocumentVtbl)
319 #define DOCVIEW(x)       ((IOleDocumentView*)             &(x)->lpOleDocumentViewVtbl)
320 #define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
321 #define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
322 #define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObject2Vtbl)
323 #define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObject2Vtbl)
324 #define INPLACEOBJ(x)    ((IOleInPlaceObject*)            &(x)->lpOleInPlaceObjectWindowlessVtbl)
325 #define INPLACEWIN(x)    ((IOleInPlaceObjectWindowless*)  &(x)->lpOleInPlaceObjectWindowlessVtbl)
326 #define SERVPROV(x)      ((IServiceProvider*)             &(x)->lpServiceProviderVtbl)
327 #define CMDTARGET(x)     ((IOleCommandTarget*)            &(x)->lpOleCommandTargetVtbl)
328 #define CONTROL(x)       ((IOleControl*)                  &(x)->lpOleControlVtbl)
329 #define HLNKTARGET(x)    ((IHlinkTarget*)                 &(x)->lpHlinkTargetVtbl)
330 #define CONPTCONT(x)     ((IConnectionPointContainer*)    &(x)->lpConnectionPointContainerVtbl)
331 #define PERSTRINIT(x)    ((IPersistStreamInit*)           &(x)->lpPersistStreamInitVtbl)
332 #define CUSTOMDOC(x)     ((ICustomDoc*)                   &(x)->lpCustomDocVtbl)
333
334 #define NSWBCHROME(x)    ((nsIWebBrowserChrome*)          &(x)->lpWebBrowserChromeVtbl)
335 #define NSCML(x)         ((nsIContextMenuListener*)       &(x)->lpContextMenuListenerVtbl)
336 #define NSURICL(x)       ((nsIURIContentListener*)        &(x)->lpURIContentListenerVtbl)
337 #define NSEMBWNDS(x)     ((nsIEmbeddingSiteWindow*)       &(x)->lpEmbeddingSiteWindowVtbl)
338 #define NSIFACEREQ(x)    ((nsIInterfaceRequestor*)        &(x)->lpInterfaceRequestorVtbl)
339 #define NSTOOLTIP(x)     ((nsITooltipListener*)           &(x)->lpTooltipListenerVtbl)
340 #define NSEVENTLIST(x)   ((nsIDOMEventListener*)          &(x)->lpDOMEventListenerVtbl)
341 #define NSWEAKREF(x)     ((nsIWeakReference*)             &(x)->lpWeakReferenceVtbl)
342 #define NSSUPWEAKREF(x)  ((nsISupportsWeakReference*)     &(x)->lpSupportsWeakReferenceVtbl)
343
344 #define NSCHANNEL(x)     ((nsIChannel*)        &(x)->lpHttpChannelVtbl)
345 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*)    &(x)->lpHttpChannelVtbl)
346 #define NSUPCHANNEL(x)   ((nsIUploadChannel*)  &(x)->lpUploadChannelVtbl)
347
348 #define HTTPNEG(x)       ((IHttpNegotiate2*)              &(x)->lpHttpNegotiate2Vtbl)
349 #define STATUSCLB(x)     ((IBindStatusCallback*)          &(x)->lpBindStatusCallbackVtbl)
350 #define BINDINFO(x)      ((IInternetBindInfo*)            &(x)->lpInternetBindInfoVtbl);
351
352 #define HTMLELEM(x)      ((IHTMLElement*)                 &(x)->lpHTMLElementVtbl)
353 #define HTMLELEM2(x)     ((IHTMLElement2*)                &(x)->lpHTMLElement2Vtbl)
354 #define HTMLDOMNODE(x)   ((IHTMLDOMNode*)                 &(x)->lpHTMLDOMNodeVtbl)
355
356 #define HTMLTEXTCONT(x)  ((IHTMLTextContainer*)           &(x)->lpHTMLTextContainerVtbl)
357
358 #define HTMLOPTFACTORY(x)  ((IHTMLOptionElementFactory*)  &(x)->lpHTMLOptionElementFactoryVtbl)
359
360 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
361 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
362
363 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
364 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
365
366 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
367 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
368 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
369 void setup_nswindow(HTMLWindow*);
370
371 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
372 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
373 void HTMLDocument_Persist_Init(HTMLDocument*);
374 void HTMLDocument_OleCmd_Init(HTMLDocument*);
375 void HTMLDocument_OleObj_Init(HTMLDocument*);
376 void HTMLDocument_View_Init(HTMLDocument*);
377 void HTMLDocument_Window_Init(HTMLDocument*);
378 void HTMLDocument_Service_Init(HTMLDocument*);
379 void HTMLDocument_Hlink_Init(HTMLDocument*);
380
381 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
382 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
383 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
384
385 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
386 void NSContainer_Release(NSContainer*);
387
388 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
389 void show_context_menu(HTMLDocument*,DWORD,POINT*,IDispatch*);
390 void notif_focus(HTMLDocument*);
391
392 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
393 void hide_tooltip(HTMLDocument*);
394 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
395
396 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
397
398 BOOL load_gecko(BOOL);
399 void close_gecko(void);
400 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
401 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
402 BOOL install_wine_gecko(BOOL);
403
404 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
405
406 void call_property_onchanged(ConnectionPoint*,DISPID);
407 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
408
409 void *nsalloc(size_t);
410 void nsfree(void*);
411
412 void nsACString_Init(nsACString*,const char*);
413 void nsACString_SetData(nsACString*,const char*);
414 PRUint32 nsACString_GetData(const nsACString*,const char**);
415 void nsACString_Finish(nsACString*);
416
417 void nsAString_Init(nsAString*,const PRUnichar*);
418 void nsAString_SetData(nsAString*,const PRUnichar*);
419 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
420 void nsAString_Finish(nsAString*);
421
422 nsIInputStream *create_nsstream(const char*,PRInt32);
423 nsICommandParams *create_nscommand_params(void);
424 nsIMutableArray *create_nsarray(void);
425 nsIWritableVariant *create_nsvariant(void);
426 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
427 void get_editor_controller(NSContainer*);
428 void init_nsevents(NSContainer*);
429 nsresult get_nsinterface(nsISupports*,REFIID,void**);
430
431 BSCallback *create_bscallback(IMoniker*);
432 HRESULT start_binding(HTMLDocument*,BSCallback*,IBindCtx*);
433 HRESULT load_stream(BSCallback*,IStream*);
434 void set_document_bscallback(HTMLDocument*,BSCallback*);
435 void set_current_mon(HTMLDocument*,IMoniker*);
436
437 IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*);
438 IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*);
439 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
440 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
441 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
442
443 void detach_selection(HTMLDocument*);
444 void detach_ranges(HTMLDocument*);
445
446 HTMLElement *HTMLElement_Create(nsIDOMNode*);
447 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
448 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
449 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
450 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
451 HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*);
452 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
453 HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
454 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
455
456 void HTMLElement_Init(HTMLElement*);
457 void HTMLElement2_Init(HTMLElement*);
458 void HTMLTextContainer_Init(HTMLTextContainer*);
459
460 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
461 void HTMLDOMNode_destructor(HTMLDOMNode*);
462
463 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
464 void HTMLElement_destructor(HTMLDOMNode*);
465
466 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
467 void release_nodes(HTMLDocument*);
468
469 IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
470
471 /* commands */
472 typedef struct {
473     DWORD id;
474     HRESULT (*query)(HTMLDocument*,OLECMD*);
475     HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
476 } cmdtable_t;
477
478 extern const cmdtable_t editmode_cmds[];
479
480 void do_ns_command(NSContainer*,const char*,nsICommandParams*);
481
482 /* timer */
483 #define UPDATE_UI       0x0001
484 #define UPDATE_TITLE    0x0002
485
486 void update_doc(HTMLDocument *This, DWORD flags);
487 void update_title(HTMLDocument*);
488
489 /* editor */
490 void init_editor(HTMLDocument*);
491 void set_ns_editmode(NSContainer*);
492 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
493 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
494 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
495 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
496 void handle_edit_load(HTMLDocument*);
497 HRESULT editor_is_dirty(HTMLDocument*);
498 void set_dirty(HTMLDocument*,VARIANT_BOOL);
499
500 extern DWORD mshtml_tls;
501
502 typedef struct task_t {
503     HTMLDocument *doc;
504
505     enum {
506         TASK_SETDOWNLOADSTATE,
507         TASK_PARSECOMPLETE,
508         TASK_SETPROGRESS,
509         TASK_START_BINDING
510     } task_id;
511
512     BSCallback *bscallback;
513
514     struct task_t *next;
515 } task_t;
516
517 typedef struct {
518     HWND thread_hwnd;
519     task_t *task_queue_head;
520     task_t *task_queue_tail;
521 } thread_data_t;
522
523 thread_data_t *get_thread_data(BOOL);
524 HWND get_thread_hwnd(void);
525 void push_task(task_t*);
526 void remove_doc_tasks(const HTMLDocument*);
527
528 /* typelibs */
529 enum tid_t {
530     IHTMLWindow2_tid,
531     LAST_tid
532 };
533
534 HRESULT get_typeinfo(enum tid_t, ITypeInfo**);
535
536 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
537 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
538 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
539 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
540 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
541
542 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
543
544 extern LONG module_ref;
545 #define LOCK_MODULE()   InterlockedIncrement(&module_ref)
546 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
547
548 /* memory allocation functions */
549
550 static inline void *heap_alloc(size_t len)
551 {
552     return HeapAlloc(GetProcessHeap(), 0, len);
553 }
554
555 static inline void *heap_alloc_zero(size_t len)
556 {
557     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
558 }
559
560 static inline void *heap_realloc(void *mem, size_t len)
561 {
562     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
563 }
564
565 static inline BOOL heap_free(void *mem)
566 {
567     return HeapFree(GetProcessHeap(), 0, mem);
568 }
569
570 static inline LPWSTR heap_strdupW(LPCWSTR str)
571 {
572     LPWSTR ret = NULL;
573
574     if(str) {
575         DWORD size;
576
577         size = (strlenW(str)+1)*sizeof(WCHAR);
578         ret = heap_alloc(size);
579         memcpy(ret, str, size);
580     }
581
582     return ret;
583 }
584
585 static inline WCHAR *heap_strdupAtoW(const char *str)
586 {
587     LPWSTR ret = NULL;
588
589     if(str) {
590         DWORD len;
591
592         len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
593         ret = heap_alloc(len*sizeof(WCHAR));
594         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, -1);
595     }
596
597     return ret;
598 }
599
600 HINSTANCE get_shdoclc(void);
601
602 extern HINSTANCE hInst;