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