quartz: Fix discontinuities in wave parser.
[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 typedef struct nsChannelBSC nsChannelBSC;
58
59 typedef struct {
60     const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
61
62     LONG ref;
63
64     HTMLDocument *doc;
65     nsIDOMWindow *nswindow;
66
67     struct list entry;
68 } HTMLWindow;
69
70 typedef enum {
71     UNKNOWN_USERMODE,
72     BROWSEMODE,
73     EDITMODE        
74 } USERMODE;
75
76 typedef struct {
77     const IConnectionPointContainerVtbl  *lpConnectionPointContainerVtbl;
78
79     ConnectionPoint *cp_list;
80     IUnknown *outer;
81 } ConnectionPointContainer;
82
83 struct ConnectionPoint {
84     const IConnectionPointVtbl *lpConnectionPointVtbl;
85
86     IConnectionPointContainer *container;
87
88     union {
89         IUnknown *unk;
90         IDispatch *disp;
91         IPropertyNotifySink *propnotif;
92     } *sinks;
93     DWORD sinks_size;
94
95     const IID *iid;
96
97     ConnectionPoint *next;
98 };
99
100 typedef struct {
101     const IHTMLLocationVtbl *lpHTMLLocationVtbl;
102
103     LONG ref;
104
105     HTMLDocument *doc;
106 } HTMLLocation;
107
108 typedef struct {
109     const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
110
111     LONG ref;
112
113     HTMLDocument *doc;
114 } HTMLOptionElementFactory;
115
116 struct HTMLDocument {
117     const IHTMLDocument2Vtbl              *lpHTMLDocument2Vtbl;
118     const IHTMLDocument3Vtbl              *lpHTMLDocument3Vtbl;
119     const IHTMLDocument4Vtbl              *lpHTMLDocument4Vtbl;
120     const IHTMLDocument5Vtbl              *lpHTMLDocument5Vtbl;
121     const IPersistMonikerVtbl             *lpPersistMonikerVtbl;
122     const IPersistFileVtbl                *lpPersistFileVtbl;
123     const IMonikerPropVtbl                *lpMonikerPropVtbl;
124     const IOleObjectVtbl                  *lpOleObjectVtbl;
125     const IOleDocumentVtbl                *lpOleDocumentVtbl;
126     const IOleDocumentViewVtbl            *lpOleDocumentViewVtbl;
127     const IOleInPlaceActiveObjectVtbl     *lpOleInPlaceActiveObjectVtbl;
128     const IViewObject2Vtbl                *lpViewObject2Vtbl;
129     const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
130     const IServiceProviderVtbl            *lpServiceProviderVtbl;
131     const IOleCommandTargetVtbl           *lpOleCommandTargetVtbl;
132     const IOleControlVtbl                 *lpOleControlVtbl;
133     const IHlinkTargetVtbl                *lpHlinkTargetVtbl;
134     const IPersistStreamInitVtbl          *lpPersistStreamInitVtbl;
135     const ICustomDocVtbl                  *lpCustomDocVtbl;
136
137     LONG ref;
138
139     NSContainer *nscontainer;
140     HTMLWindow *window;
141
142     IOleClientSite *client;
143     IDocHostUIHandler *hostui;
144     IOleInPlaceSite *ipsite;
145     IOleInPlaceFrame *frame;
146     IOleInPlaceUIWindow *ip_window;
147
148     IOleUndoManager *undomgr;
149
150     nsChannelBSC *bscallback;
151     IMoniker *mon;
152     LPOLESTR url;
153     struct list bindings;
154
155     struct list script_hosts;
156
157     HWND hwnd;
158     HWND tooltips_hwnd;
159
160     DOCHOSTUIINFO hostinfo;
161
162     USERMODE usermode;
163     READYSTATE readystate;
164     BOOL in_place_active;
165     BOOL ui_active;
166     BOOL window_active;
167     BOOL has_key_path;
168     BOOL container_locked;
169     BOOL focus;
170     LPWSTR mime;
171
172     DWORD update;
173
174     ConnectionPointContainer cp_container;
175     ConnectionPoint cp_htmldocevents;
176     ConnectionPoint cp_htmldocevents2;
177     ConnectionPoint cp_propnotif;
178
179     HTMLOptionElementFactory *option_factory;
180     HTMLLocation *location;
181
182     struct list selection_list;
183     struct list range_list;
184
185     HTMLDOMNode *nodes;
186 };
187
188 typedef struct {
189     const nsIDOMEventListenerVtbl      *lpDOMEventListenerVtbl;
190     NSContainer *This;
191 } nsEventListener;
192
193 struct NSContainer {
194     const nsIWebBrowserChromeVtbl       *lpWebBrowserChromeVtbl;
195     const nsIContextMenuListenerVtbl    *lpContextMenuListenerVtbl;
196     const nsIURIContentListenerVtbl     *lpURIContentListenerVtbl;
197     const nsIEmbeddingSiteWindowVtbl    *lpEmbeddingSiteWindowVtbl;
198     const nsITooltipListenerVtbl        *lpTooltipListenerVtbl;
199     const nsIInterfaceRequestorVtbl     *lpInterfaceRequestorVtbl;
200     const nsIWeakReferenceVtbl          *lpWeakReferenceVtbl;
201     const nsISupportsWeakReferenceVtbl  *lpSupportsWeakReferenceVtbl;
202
203     nsEventListener blur_listener;
204     nsEventListener focus_listener;
205     nsEventListener keypress_listener;
206     nsEventListener load_listener;
207     nsEventListener node_insert_listener;
208
209     nsIWebBrowser *webbrowser;
210     nsIWebNavigation *navigation;
211     nsIBaseWindow *window;
212     nsIWebBrowserFocus *focus;
213
214     nsIEditor *editor;
215     nsIController *editor_controller;
216
217     LONG ref;
218
219     NSContainer *parent;
220     HTMLDocument *doc;
221
222     nsIURIContentListener *content_listener;
223
224     HWND hwnd;
225
226     nsChannelBSC *bscallback; /* hack */
227     HWND reset_focus; /* hack */
228 };
229
230 typedef struct {
231     const nsIHttpChannelVtbl *lpHttpChannelVtbl;
232     const nsIUploadChannelVtbl *lpUploadChannelVtbl;
233
234     LONG ref;
235
236     nsIChannel *channel;
237     nsIHttpChannel *http_channel;
238     nsIWineURI *uri;
239     nsIInputStream *post_data_stream;
240     nsILoadGroup *load_group;
241     nsIInterfaceRequestor *notif_callback;
242     nsLoadFlags load_flags;
243     nsIURI *original_uri;
244     char *content_type;
245     char *charset;
246 } nsChannel;
247
248 typedef struct {
249     HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
250     void (*destructor)(HTMLDOMNode*);
251 } NodeImplVtbl;
252
253 struct HTMLDOMNode {
254     const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
255     const NodeImplVtbl *vtbl;
256
257     LONG ref;
258
259     nsIDOMNode *nsnode;
260     HTMLDocument *doc;
261
262     HTMLDOMNode *next;
263 };
264
265 typedef struct {
266     HTMLDOMNode node;
267     ConnectionPointContainer cp_container;
268
269     const IHTMLElementVtbl   *lpHTMLElementVtbl;
270     const IHTMLElement2Vtbl  *lpHTMLElement2Vtbl;
271
272     nsIDOMHTMLElement *nselem;
273 } HTMLElement;
274
275 typedef struct {
276     HTMLElement element;
277
278     const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
279
280     ConnectionPoint cp;
281 } HTMLTextContainer;
282
283 #define HTMLWINDOW2(x)   ((IHTMLWindow2*)                 &(x)->lpHTMLWindow2Vtbl)
284
285 #define HTMLDOC(x)       ((IHTMLDocument2*)               &(x)->lpHTMLDocument2Vtbl)
286 #define HTMLDOC3(x)      ((IHTMLDocument3*)               &(x)->lpHTMLDocument3Vtbl)
287 #define HTMLDOC4(x)      ((IHTMLDocument4*)               &(x)->lpHTMLDocument4Vtbl)
288 #define HTMLDOC5(x)      ((IHTMLDocument5*)               &(x)->lpHTMLDocument5Vtbl)
289 #define PERSIST(x)       ((IPersist*)                     &(x)->lpPersistFileVtbl)
290 #define PERSISTMON(x)    ((IPersistMoniker*)              &(x)->lpPersistMonikerVtbl)
291 #define PERSISTFILE(x)   ((IPersistFile*)                 &(x)->lpPersistFileVtbl)
292 #define MONPROP(x)       ((IMonikerProp*)                 &(x)->lpMonikerPropVtbl)
293 #define OLEOBJ(x)        ((IOleObject*)                   &(x)->lpOleObjectVtbl)
294 #define OLEDOC(x)        ((IOleDocument*)                 &(x)->lpOleDocumentVtbl)
295 #define DOCVIEW(x)       ((IOleDocumentView*)             &(x)->lpOleDocumentViewVtbl)
296 #define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
297 #define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
298 #define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObject2Vtbl)
299 #define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObject2Vtbl)
300 #define INPLACEOBJ(x)    ((IOleInPlaceObject*)            &(x)->lpOleInPlaceObjectWindowlessVtbl)
301 #define INPLACEWIN(x)    ((IOleInPlaceObjectWindowless*)  &(x)->lpOleInPlaceObjectWindowlessVtbl)
302 #define SERVPROV(x)      ((IServiceProvider*)             &(x)->lpServiceProviderVtbl)
303 #define CMDTARGET(x)     ((IOleCommandTarget*)            &(x)->lpOleCommandTargetVtbl)
304 #define CONTROL(x)       ((IOleControl*)                  &(x)->lpOleControlVtbl)
305 #define HLNKTARGET(x)    ((IHlinkTarget*)                 &(x)->lpHlinkTargetVtbl)
306 #define CONPTCONT(x)     ((IConnectionPointContainer*)    &(x)->lpConnectionPointContainerVtbl)
307 #define PERSTRINIT(x)    ((IPersistStreamInit*)           &(x)->lpPersistStreamInitVtbl)
308 #define CUSTOMDOC(x)     ((ICustomDoc*)                   &(x)->lpCustomDocVtbl)
309
310 #define NSWBCHROME(x)    ((nsIWebBrowserChrome*)          &(x)->lpWebBrowserChromeVtbl)
311 #define NSCML(x)         ((nsIContextMenuListener*)       &(x)->lpContextMenuListenerVtbl)
312 #define NSURICL(x)       ((nsIURIContentListener*)        &(x)->lpURIContentListenerVtbl)
313 #define NSEMBWNDS(x)     ((nsIEmbeddingSiteWindow*)       &(x)->lpEmbeddingSiteWindowVtbl)
314 #define NSIFACEREQ(x)    ((nsIInterfaceRequestor*)        &(x)->lpInterfaceRequestorVtbl)
315 #define NSTOOLTIP(x)     ((nsITooltipListener*)           &(x)->lpTooltipListenerVtbl)
316 #define NSEVENTLIST(x)   ((nsIDOMEventListener*)          &(x)->lpDOMEventListenerVtbl)
317 #define NSWEAKREF(x)     ((nsIWeakReference*)             &(x)->lpWeakReferenceVtbl)
318 #define NSSUPWEAKREF(x)  ((nsISupportsWeakReference*)     &(x)->lpSupportsWeakReferenceVtbl)
319
320 #define NSCHANNEL(x)     ((nsIChannel*)        &(x)->lpHttpChannelVtbl)
321 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*)    &(x)->lpHttpChannelVtbl)
322 #define NSUPCHANNEL(x)   ((nsIUploadChannel*)  &(x)->lpUploadChannelVtbl)
323
324 #define HTTPNEG(x)       ((IHttpNegotiate2*)              &(x)->lpHttpNegotiate2Vtbl)
325 #define STATUSCLB(x)     ((IBindStatusCallback*)          &(x)->lpBindStatusCallbackVtbl)
326 #define BINDINFO(x)      ((IInternetBindInfo*)            &(x)->lpInternetBindInfoVtbl);
327
328 #define HTMLELEM(x)      ((IHTMLElement*)                 &(x)->lpHTMLElementVtbl)
329 #define HTMLELEM2(x)     ((IHTMLElement2*)                &(x)->lpHTMLElement2Vtbl)
330 #define HTMLDOMNODE(x)   ((IHTMLDOMNode*)                 &(x)->lpHTMLDOMNodeVtbl)
331
332 #define HTMLTEXTCONT(x)  ((IHTMLTextContainer*)           &(x)->lpHTMLTextContainerVtbl)
333
334 #define HTMLOPTFACTORY(x)  ((IHTMLOptionElementFactory*)  &(x)->lpHTMLOptionElementFactoryVtbl)
335 #define HTMLLOCATION(x)  ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
336
337 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
338 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
339
340 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
341 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
342
343 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
344 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
345 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
346 HTMLLocation *HTMLLocation_Create(HTMLDocument*);
347 IOmNavigator *OmNavigator_Create(void);
348 void setup_nswindow(HTMLWindow*);
349
350 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
351 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
352 void HTMLDocument_Persist_Init(HTMLDocument*);
353 void HTMLDocument_OleCmd_Init(HTMLDocument*);
354 void HTMLDocument_OleObj_Init(HTMLDocument*);
355 void HTMLDocument_View_Init(HTMLDocument*);
356 void HTMLDocument_Window_Init(HTMLDocument*);
357 void HTMLDocument_Service_Init(HTMLDocument*);
358 void HTMLDocument_Hlink_Init(HTMLDocument*);
359
360 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
361 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
362 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
363
364 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
365 void NSContainer_Release(NSContainer*);
366
367 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
368 void show_context_menu(HTMLDocument*,DWORD,POINT*,IDispatch*);
369 void notif_focus(HTMLDocument*);
370
371 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
372 void hide_tooltip(HTMLDocument*);
373 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
374
375 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
376
377 BOOL load_gecko(BOOL);
378 void close_gecko(void);
379 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
380 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
381 BOOL install_wine_gecko(BOOL);
382
383 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
384
385 void call_property_onchanged(ConnectionPoint*,DISPID);
386 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
387
388 void *nsalloc(size_t);
389 void nsfree(void*);
390
391 void nsACString_Init(nsACString*,const char*);
392 void nsACString_SetData(nsACString*,const char*);
393 PRUint32 nsACString_GetData(const nsACString*,const char**);
394 void nsACString_Finish(nsACString*);
395
396 void nsAString_Init(nsAString*,const PRUnichar*);
397 void nsAString_SetData(nsAString*,const PRUnichar*);
398 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
399 void nsAString_Finish(nsAString*);
400
401 nsIInputStream *create_nsstream(const char*,PRInt32);
402 nsICommandParams *create_nscommand_params(void);
403 nsIMutableArray *create_nsarray(void);
404 nsIWritableVariant *create_nsvariant(void);
405 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
406 void get_editor_controller(NSContainer*);
407 void init_nsevents(NSContainer*);
408 nsresult get_nsinterface(nsISupports*,REFIID,void**);
409
410 void set_document_bscallback(HTMLDocument*,nsChannelBSC*);
411 void set_current_mon(HTMLDocument*,IMoniker*);
412 HRESULT start_binding(HTMLDocument*,BSCallback*,IBindCtx*);
413
414 HRESULT bind_mon_to_buffer(HTMLDocument*,IMoniker*,void**);
415
416 nsChannelBSC *create_channelbsc(IMoniker*);
417 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
418 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
419 IMoniker *get_channelbsc_mon(nsChannelBSC*);
420
421 IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*);
422 IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*);
423 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
424 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
425 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
426
427 void detach_selection(HTMLDocument*);
428 void detach_ranges(HTMLDocument*);
429
430 HTMLElement *HTMLElement_Create(nsIDOMNode*);
431 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
432 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
433 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
434 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
435 HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*);
436 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
437 HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
438 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
439
440 void HTMLElement_Init(HTMLElement*);
441 void HTMLElement2_Init(HTMLElement*);
442 void HTMLTextContainer_Init(HTMLTextContainer*);
443
444 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
445 void HTMLDOMNode_destructor(HTMLDOMNode*);
446
447 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
448 void HTMLElement_destructor(HTMLDOMNode*);
449
450 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
451 void release_nodes(HTMLDocument*);
452
453 void release_script_hosts(HTMLDocument*);
454 void connect_scripts(HTMLDocument*);
455 void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*);
456
457 IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
458
459 /* commands */
460 typedef struct {
461     DWORD id;
462     HRESULT (*query)(HTMLDocument*,OLECMD*);
463     HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
464 } cmdtable_t;
465
466 extern const cmdtable_t editmode_cmds[];
467
468 void do_ns_command(NSContainer*,const char*,nsICommandParams*);
469
470 /* timer */
471 #define UPDATE_UI       0x0001
472 #define UPDATE_TITLE    0x0002
473
474 void update_doc(HTMLDocument *This, DWORD flags);
475 void update_title(HTMLDocument*);
476
477 /* editor */
478 void init_editor(HTMLDocument*);
479 void set_ns_editmode(NSContainer*);
480 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
481 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
482 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
483 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
484 void handle_edit_load(HTMLDocument*);
485 HRESULT editor_is_dirty(HTMLDocument*);
486 void set_dirty(HTMLDocument*,VARIANT_BOOL);
487
488 extern DWORD mshtml_tls;
489
490 typedef struct task_t {
491     HTMLDocument *doc;
492
493     enum {
494         TASK_SETDOWNLOADSTATE,
495         TASK_PARSECOMPLETE,
496         TASK_SETPROGRESS,
497         TASK_START_BINDING
498     } task_id;
499
500     nsChannelBSC *bscallback;
501
502     struct task_t *next;
503 } task_t;
504
505 typedef struct {
506     HWND thread_hwnd;
507     task_t *task_queue_head;
508     task_t *task_queue_tail;
509 } thread_data_t;
510
511 thread_data_t *get_thread_data(BOOL);
512 HWND get_thread_hwnd(void);
513 void push_task(task_t*);
514 void remove_doc_tasks(const HTMLDocument*);
515
516 /* typelibs */
517 enum tid_t {
518     IHTMLWindow2_tid,
519     LAST_tid
520 };
521
522 HRESULT get_typeinfo(enum tid_t, ITypeInfo**);
523
524 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
525 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
526 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
527 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
528 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
529
530 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
531
532 extern LONG module_ref;
533 #define LOCK_MODULE()   InterlockedIncrement(&module_ref)
534 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
535
536 /* memory allocation functions */
537
538 static inline void *heap_alloc(size_t len)
539 {
540     return HeapAlloc(GetProcessHeap(), 0, len);
541 }
542
543 static inline void *heap_alloc_zero(size_t len)
544 {
545     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
546 }
547
548 static inline void *heap_realloc(void *mem, size_t len)
549 {
550     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
551 }
552
553 static inline BOOL heap_free(void *mem)
554 {
555     return HeapFree(GetProcessHeap(), 0, mem);
556 }
557
558 static inline LPWSTR heap_strdupW(LPCWSTR str)
559 {
560     LPWSTR ret = NULL;
561
562     if(str) {
563         DWORD size;
564
565         size = (strlenW(str)+1)*sizeof(WCHAR);
566         ret = heap_alloc(size);
567         memcpy(ret, str, size);
568     }
569
570     return ret;
571 }
572
573 static inline char *heap_strdupA(const char *str)
574 {
575     char *ret = NULL;
576
577     if(str) {
578         DWORD size;
579
580         size = strlen(str)+1;
581         ret = heap_alloc(size);
582         memcpy(ret, str, size);
583     }
584
585     return ret;
586 }
587
588 static inline WCHAR *heap_strdupAtoW(const char *str)
589 {
590     LPWSTR ret = NULL;
591
592     if(str) {
593         DWORD len;
594
595         len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
596         ret = heap_alloc(len*sizeof(WCHAR));
597         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
598     }
599
600     return ret;
601 }
602
603 static inline char *heap_strdupWtoA(LPCWSTR str)
604 {
605     char *ret = NULL;
606
607     if(str) {
608         DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
609         ret = heap_alloc(size);
610         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
611     }
612
613     return ret;
614 }
615
616 HINSTANCE get_shdoclc(void);
617
618 extern HINSTANCE hInst;