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