include: Define more wuapi interfaces to avoid undefined forward declarations.
[wine] / dlls / mshtml / mshtml_private.h
1 /*
2  * Copyright 2005-2009 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 "comcat.h"
22 #include "mshtml.h"
23 #include "mshtmhst.h"
24 #include "hlink.h"
25 #include "perhist.h"
26 #include "dispex.h"
27
28 #include "wine/list.h"
29 #include "wine/unicode.h"
30
31 #ifdef INIT_GUID
32 #include "initguid.h"
33 #endif
34
35 #include "nsiface.h"
36
37 #define NS_ERROR_GENERATE_FAILURE(module,code) \
38     ((nsresult) (((PRUint32)(1<<31)) | ((PRUint32)(module+0x45)<<16) | ((PRUint32)(code))))
39
40 #define NS_OK                     ((nsresult)0x00000000L)
41 #define NS_ERROR_FAILURE          ((nsresult)0x80004005L)
42 #define NS_ERROR_OUT_OF_MEMORY    ((nsresult)0x8007000EL)
43 #define NS_NOINTERFACE            ((nsresult)0x80004002L)
44 #define NS_ERROR_NOT_IMPLEMENTED  ((nsresult)0x80004001L)
45 #define NS_ERROR_NOT_AVAILABLE    ((nsresult)0x80040111L)
46 #define NS_ERROR_INVALID_ARG      ((nsresult)0x80070057L) 
47 #define NS_ERROR_UNEXPECTED       ((nsresult)0x8000ffffL)
48
49 #define NS_ERROR_MODULE_NETWORK    6
50
51 #define NS_BINDING_ABORTED         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 2)
52 #define NS_ERROR_UNKNOWN_PROTOCOL  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 18)
53
54 #define NS_FAILED(res) ((res) & 0x80000000)
55 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
56
57 #define NSAPI WINAPI
58
59 #define MSHTML_E_NODOC    0x800a025c
60
61 typedef struct HTMLDOMNode HTMLDOMNode;
62 typedef struct ConnectionPoint ConnectionPoint;
63 typedef struct BSCallback BSCallback;
64 typedef struct event_target_t event_target_t;
65
66 #define TID_LIST \
67     XIID(NULL) \
68     XDIID(DispCEventObj) \
69     XDIID(DispCPlugins) \
70     XDIID(DispDOMChildrenCollection) \
71     XDIID(DispHTMLAnchorElement) \
72     XDIID(DispHTMLBody) \
73     XDIID(DispHTMLCommentElement) \
74     XDIID(DispHTMLCurrentStyle) \
75     XDIID(DispHTMLDocument) \
76     XDIID(DispHTMLDOMTextNode) \
77     XDIID(DispHTMLElementCollection) \
78     XDIID(DispHTMLEmbed) \
79     XDIID(DispHTMLFormElement) \
80     XDIID(DispHTMLGenericElement) \
81     XDIID(DispHTMLFrameElement) \
82     XDIID(DispHTMLIFrame) \
83     XDIID(DispHTMLImg) \
84     XDIID(DispHTMLInputElement) \
85     XDIID(DispHTMLLocation) \
86     XDIID(DispHTMLNavigator) \
87     XDIID(DispHTMLObjectElement) \
88     XDIID(DispHTMLOptionElement) \
89     XDIID(DispHTMLScreen) \
90     XDIID(DispHTMLScriptElement) \
91     XDIID(DispHTMLSelectElement) \
92     XDIID(DispHTMLStyle) \
93     XDIID(DispHTMLStyleElement) \
94     XDIID(DispHTMLStyleSheetsCollection) \
95     XDIID(DispHTMLTable) \
96     XDIID(DispHTMLTableRow) \
97     XDIID(DispHTMLTextAreaElement) \
98     XDIID(DispHTMLUnknownElement) \
99     XDIID(DispHTMLWindow2) \
100     XDIID(HTMLDocumentEvents) \
101     XIID(IHTMLAnchorElement) \
102     XIID(IHTMLBodyElement) \
103     XIID(IHTMLBodyElement2) \
104     XIID(IHTMLCommentElement) \
105     XIID(IHTMLCurrentStyle) \
106     XIID(IHTMLCurrentStyle2) \
107     XIID(IHTMLCurrentStyle3) \
108     XIID(IHTMLCurrentStyle4) \
109     XIID(IHTMLDocument2) \
110     XIID(IHTMLDocument3) \
111     XIID(IHTMLDocument4) \
112     XIID(IHTMLDocument5) \
113     XIID(IHTMLDOMChildrenCollection) \
114     XIID(IHTMLDOMNode) \
115     XIID(IHTMLDOMNode2) \
116     XIID(IHTMLDOMTextNode) \
117     XIID(IHTMLElement) \
118     XIID(IHTMLElement2) \
119     XIID(IHTMLElement3) \
120     XIID(IHTMLElement4) \
121     XIID(IHTMLElementCollection) \
122     XIID(IHTMLEmbedElement) \
123     XIID(IHTMLEventObj) \
124     XIID(IHTMLFiltersCollection) \
125     XIID(IHTMLFormElement) \
126     XIID(IHTMLFrameBase) \
127     XIID(IHTMLFrameBase2) \
128     XIID(IHTMLFrameElement3) \
129     XIID(IHTMLGenericElement) \
130     XIID(IHTMLIFrameElement) \
131     XIID(IHTMLImageElementFactory) \
132     XIID(IHTMLImgElement) \
133     XIID(IHTMLInputElement) \
134     XIID(IHTMLLocation) \
135     XIID(IHTMLObjectElement) \
136     XIID(IHTMLOptionElement) \
137     XIID(IHTMLPluginsCollection) \
138     XIID(IHTMLRect) \
139     XIID(IHTMLScreen) \
140     XIID(IHTMLScriptElement) \
141     XIID(IHTMLSelectElement) \
142     XIID(IHTMLStyle) \
143     XIID(IHTMLStyle2) \
144     XIID(IHTMLStyle3) \
145     XIID(IHTMLStyle4) \
146     XIID(IHTMLStyleElement) \
147     XIID(IHTMLStyleSheetsCollection) \
148     XIID(IHTMLTable) \
149     XIID(IHTMLTableRow) \
150     XIID(IHTMLTextAreaElement) \
151     XIID(IHTMLTextContainer) \
152     XIID(IHTMLUniqueName) \
153     XIID(IHTMLWindow2) \
154     XIID(IHTMLWindow3) \
155     XIID(IHTMLWindow4) \
156     XIID(IOmNavigator)
157
158 typedef enum {
159 #define XIID(iface) iface ## _tid,
160 #define XDIID(iface) iface ## _tid,
161 TID_LIST
162 #undef XIID
163 #undef XDIID
164     LAST_tid
165 } tid_t;
166
167 typedef struct dispex_data_t dispex_data_t;
168 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
169
170 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
171 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
172 #define MSHTML_CUSTOM_DISPID_CNT (MSHTML_DISPID_CUSTOM_MAX-MSHTML_DISPID_CUSTOM_MIN)
173
174 typedef struct {
175     HRESULT (*value)(IUnknown*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
176     HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
177     HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
178 } dispex_static_data_vtbl_t;
179
180 typedef struct {
181     const dispex_static_data_vtbl_t *vtbl;
182     const tid_t disp_tid;
183     dispex_data_t *data;
184     const tid_t* const iface_tids;
185 } dispex_static_data_t;
186
187 typedef struct {
188     const IDispatchExVtbl  *lpIDispatchExVtbl;
189
190     IUnknown *outer;
191
192     dispex_static_data_t *data;
193     dispex_dynamic_data_t *dynamic_data;
194 } DispatchEx;
195
196 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
197 void release_dispex(DispatchEx*);
198 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
199 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
200 HRESULT get_dispids(tid_t,DWORD*,DISPID**);
201 HRESULT remove_prop(DispatchEx*,BSTR,VARIANT_BOOL*);
202
203 typedef struct HTMLWindow HTMLWindow;
204 typedef struct HTMLDocumentNode HTMLDocumentNode;
205 typedef struct HTMLDocumentObj HTMLDocumentObj;
206 typedef struct HTMLFrameBase HTMLFrameBase;
207 typedef struct NSContainer NSContainer;
208
209 typedef enum {
210     SCRIPTMODE_GECKO,
211     SCRIPTMODE_ACTIVESCRIPT
212 } SCRIPTMODE;
213
214 typedef struct ScriptHost ScriptHost;
215
216 typedef enum {
217     GLOBAL_SCRIPTVAR,
218     GLOBAL_ELEMENTVAR
219 } global_prop_type_t;
220
221 typedef struct {
222     global_prop_type_t type;
223     WCHAR *name;
224     ScriptHost *script_host;
225     DISPID id;
226 } global_prop_t;
227
228 typedef struct {
229     const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
230
231     LONG ref;
232
233     HTMLWindow *window;
234 } HTMLOptionElementFactory;
235
236 typedef struct {
237     DispatchEx dispex;
238     const IHTMLImageElementFactoryVtbl *lpHTMLImageElementFactoryVtbl;
239
240     LONG ref;
241
242     HTMLWindow *window;
243 } HTMLImageElementFactory;
244
245 struct HTMLLocation {
246     DispatchEx dispex;
247     const IHTMLLocationVtbl *lpHTMLLocationVtbl;
248
249     LONG ref;
250
251     HTMLWindow *window;
252 };
253
254 typedef struct {
255     HTMLWindow *window;
256     LONG ref;
257 }  windowref_t;
258
259 typedef struct nsChannelBSC nsChannelBSC;
260
261 struct HTMLWindow {
262     DispatchEx dispex;
263     const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
264     const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
265     const IHTMLWindow4Vtbl *lpHTMLWindow4Vtbl;
266     const IHTMLPrivateWindowVtbl *lpIHTMLPrivateWindowVtbl;
267     const IDispatchExVtbl         *lpIDispatchExVtbl;
268     const IServiceProviderVtbl    *lpServiceProviderVtbl;
269
270     LONG ref;
271
272     windowref_t *window_ref;
273     LONG task_magic;
274
275     HTMLDocumentNode *doc;
276     HTMLDocumentObj *doc_obj;
277     nsIDOMWindow *nswindow;
278     HTMLWindow *parent;
279     HTMLFrameBase *frame_element;
280     READYSTATE readystate;
281
282     nsChannelBSC *bscallback;
283     IMoniker *mon;
284     LPOLESTR url;
285
286     IHTMLEventObj *event;
287
288     SCRIPTMODE scriptmode;
289     struct list script_hosts;
290
291     HTMLOptionElementFactory *option_factory;
292     HTMLImageElementFactory *image_factory;
293     HTMLLocation *location;
294     IHTMLScreen *screen;
295
296     global_prop_t *global_props;
297     DWORD global_prop_cnt;
298     DWORD global_prop_size;
299
300     struct list children;
301     struct list sibling_entry;
302     struct list entry;
303 };
304
305 typedef enum {
306     UNKNOWN_USERMODE,
307     BROWSEMODE,
308     EDITMODE        
309 } USERMODE;
310
311 typedef struct _cp_static_data_t {
312     tid_t tid;
313     void (*on_advise)(IUnknown*,struct _cp_static_data_t*);
314     DWORD id_cnt;
315     DISPID *ids;
316 } cp_static_data_t;
317
318 typedef struct ConnectionPointContainer {
319     const IConnectionPointContainerVtbl  *lpConnectionPointContainerVtbl;
320
321     ConnectionPoint *cp_list;
322     IUnknown *outer;
323     struct ConnectionPointContainer *forward_container;
324 } ConnectionPointContainer;
325
326 struct ConnectionPoint {
327     const IConnectionPointVtbl *lpConnectionPointVtbl;
328
329     ConnectionPointContainer *container;
330
331     union {
332         IUnknown *unk;
333         IDispatch *disp;
334         IPropertyNotifySink *propnotif;
335     } *sinks;
336     DWORD sinks_size;
337
338     const IID *iid;
339     cp_static_data_t *data;
340
341     ConnectionPoint *next;
342 };
343
344 struct HTMLDocument {
345     const IHTMLDocument2Vtbl              *lpHTMLDocument2Vtbl;
346     const IHTMLDocument3Vtbl              *lpHTMLDocument3Vtbl;
347     const IHTMLDocument4Vtbl              *lpHTMLDocument4Vtbl;
348     const IHTMLDocument5Vtbl              *lpHTMLDocument5Vtbl;
349     const IHTMLDocument6Vtbl              *lpHTMLDocument6Vtbl;
350     const IPersistMonikerVtbl             *lpPersistMonikerVtbl;
351     const IPersistFileVtbl                *lpPersistFileVtbl;
352     const IPersistHistoryVtbl             *lpPersistHistoryVtbl;
353     const IMonikerPropVtbl                *lpMonikerPropVtbl;
354     const IOleObjectVtbl                  *lpOleObjectVtbl;
355     const IOleDocumentVtbl                *lpOleDocumentVtbl;
356     const IOleDocumentViewVtbl            *lpOleDocumentViewVtbl;
357     const IOleInPlaceActiveObjectVtbl     *lpOleInPlaceActiveObjectVtbl;
358     const IViewObjectExVtbl               *lpViewObjectExVtbl;
359     const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
360     const IServiceProviderVtbl            *lpServiceProviderVtbl;
361     const IOleCommandTargetVtbl           *lpOleCommandTargetVtbl;
362     const IOleControlVtbl                 *lpOleControlVtbl;
363     const IHlinkTargetVtbl                *lpHlinkTargetVtbl;
364     const IPersistStreamInitVtbl          *lpPersistStreamInitVtbl;
365     const IDispatchExVtbl                 *lpIDispatchExVtbl;
366     const ISupportErrorInfoVtbl           *lpSupportErrorInfoVtbl;
367     const IObjectWithSiteVtbl             *lpObjectWithSiteVtbl;
368
369     IUnknown *unk_impl;
370     IDispatchEx *dispex;
371
372     HTMLDocumentObj *doc_obj;
373     HTMLDocumentNode *doc_node;
374
375     HTMLWindow *window;
376
377     LONG task_magic;
378
379     ConnectionPointContainer cp_container;
380     ConnectionPoint cp_htmldocevents;
381     ConnectionPoint cp_htmldocevents2;
382     ConnectionPoint cp_propnotif;
383     ConnectionPoint cp_dispatch;
384
385     IOleAdviseHolder *advise_holder;
386 };
387
388 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
389 {
390     return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
391 }
392
393 static inline ULONG htmldoc_addref(HTMLDocument *This)
394 {
395     return IUnknown_AddRef(This->unk_impl);
396 }
397
398 static inline ULONG htmldoc_release(HTMLDocument *This)
399 {
400     return IUnknown_Release(This->unk_impl);
401 }
402
403 struct HTMLDocumentObj {
404     HTMLDocument basedoc;
405     DispatchEx dispex;
406     const ICustomDocVtbl  *lpCustomDocVtbl;
407
408     LONG ref;
409
410     NSContainer *nscontainer;
411
412     IOleClientSite *client;
413     IDocHostUIHandler *hostui;
414     BOOL custom_hostui;
415     IOleInPlaceSite *ipsite;
416     IOleInPlaceFrame *frame;
417     IOleInPlaceUIWindow *ip_window;
418     IAdviseSink *view_sink;
419
420     DOCHOSTUIINFO hostinfo;
421
422     IOleUndoManager *undomgr;
423
424     HWND hwnd;
425     HWND tooltips_hwnd;
426
427     BOOL request_uiactivate;
428     BOOL in_place_active;
429     BOOL ui_active;
430     BOOL window_active;
431     BOOL hostui_setup;
432     BOOL container_locked;
433     BOOL focus;
434     INT download_state;
435
436     USERMODE usermode;
437     LPWSTR mime;
438
439     DWORD update;
440 };
441
442 struct NSContainer {
443     const nsIWebBrowserChromeVtbl       *lpWebBrowserChromeVtbl;
444     const nsIContextMenuListenerVtbl    *lpContextMenuListenerVtbl;
445     const nsIURIContentListenerVtbl     *lpURIContentListenerVtbl;
446     const nsIEmbeddingSiteWindowVtbl    *lpEmbeddingSiteWindowVtbl;
447     const nsITooltipListenerVtbl        *lpTooltipListenerVtbl;
448     const nsIInterfaceRequestorVtbl     *lpInterfaceRequestorVtbl;
449     const nsIWeakReferenceVtbl          *lpWeakReferenceVtbl;
450     const nsISupportsWeakReferenceVtbl  *lpSupportsWeakReferenceVtbl;
451
452     nsIWebBrowser *webbrowser;
453     nsIWebNavigation *navigation;
454     nsIBaseWindow *window;
455     nsIWebBrowserFocus *focus;
456
457     nsIEditor *editor;
458     nsIController *editor_controller;
459
460     LONG ref;
461
462     NSContainer *parent;
463     HTMLDocumentObj *doc;
464
465     nsIURIContentListener *content_listener;
466
467     HWND hwnd;
468 };
469
470 typedef struct nsWineURI nsWineURI;
471
472 HRESULT set_wine_url(nsWineURI*,LPCWSTR);
473 nsresult on_start_uri_open(NSContainer*,nsIURI*,PRBool*);
474
475 /* Keep sync with request_method_strings in nsio.c */
476 typedef enum {
477     METHOD_GET,
478     METHOD_PUT,
479     METHOD_POST
480 } REQUEST_METHOD;
481
482 typedef struct {
483     const nsIHttpChannelVtbl *lpHttpChannelVtbl;
484     const nsIUploadChannelVtbl *lpUploadChannelVtbl;
485     const nsIHttpChannelInternalVtbl *lpIHttpChannelInternalVtbl;
486
487     LONG ref;
488
489     nsWineURI *uri;
490     nsIInputStream *post_data_stream;
491     nsILoadGroup *load_group;
492     nsIInterfaceRequestor *notif_callback;
493     nsISupports *owner;
494     nsLoadFlags load_flags;
495     nsIURI *original_uri;
496     nsIURI *referrer;
497     char *content_type;
498     char *charset;
499     PRUint32 response_status;
500     REQUEST_METHOD request_method;
501     struct list response_headers;
502     struct list request_headers;
503     UINT url_scheme;
504 } nsChannel;
505
506 typedef struct {
507     struct list entry;
508     WCHAR *header;
509     WCHAR *data;
510 } http_header_t;
511
512 HRESULT set_http_header(struct list*,const WCHAR*,int,const WCHAR*,int);
513
514 typedef struct {
515     HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
516     void (*destructor)(HTMLDOMNode*);
517     HRESULT (*clone)(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
518     event_target_t **(*get_event_target)(HTMLDOMNode*);
519     HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
520     HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
521     HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
522     HRESULT (*get_document)(HTMLDOMNode*,IDispatch**);
523     HRESULT (*get_readystate)(HTMLDOMNode*,BSTR*);
524     HRESULT (*get_dispid)(HTMLDOMNode*,BSTR,DWORD,DISPID*);
525     HRESULT (*invoke)(HTMLDOMNode*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
526     HRESULT (*bind_to_tree)(HTMLDOMNode*);
527 } NodeImplVtbl;
528
529 struct HTMLDOMNode {
530     DispatchEx dispex;
531     const IHTMLDOMNodeVtbl   *lpHTMLDOMNodeVtbl;
532     const IHTMLDOMNode2Vtbl  *lpHTMLDOMNode2Vtbl;
533     const NodeImplVtbl *vtbl;
534
535     LONG ref;
536
537     nsIDOMNode *nsnode;
538     HTMLDocumentNode *doc;
539     event_target_t *event_target;
540     ConnectionPointContainer *cp_container;
541
542     HTMLDOMNode *next;
543 };
544
545 typedef struct {
546     HTMLDOMNode node;
547     ConnectionPointContainer cp_container;
548
549     const IHTMLElementVtbl   *lpHTMLElementVtbl;
550     const IHTMLElement2Vtbl  *lpHTMLElement2Vtbl;
551     const IHTMLElement3Vtbl  *lpHTMLElement3Vtbl;
552
553     nsIDOMHTMLElement *nselem;
554 } HTMLElement;
555
556 #define HTMLELEMENT_TIDS    \
557     IHTMLDOMNode_tid,       \
558     IHTMLDOMNode2_tid,      \
559     IHTMLElement_tid,       \
560     IHTMLElement2_tid,      \
561     IHTMLElement3_tid,      \
562     IHTMLElement4_tid
563
564 typedef struct {
565     HTMLElement element;
566
567     const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
568
569     ConnectionPoint cp;
570 } HTMLTextContainer;
571
572 struct HTMLFrameBase {
573     HTMLElement element;
574
575     const IHTMLFrameBaseVtbl   *lpIHTMLFrameBaseVtbl;
576     const IHTMLFrameBase2Vtbl  *lpIHTMLFrameBase2Vtbl;
577
578     HTMLWindow *content_window;
579
580     nsIDOMHTMLFrameElement *nsframe;
581     nsIDOMHTMLIFrameElement *nsiframe;
582 };
583
584 typedef struct _mutation_queue_t {
585     DWORD type;
586     nsISupports *nsiface;
587
588     struct _mutation_queue_t *next;
589 } mutation_queue_t;
590
591 typedef struct nsDocumentEventListener nsDocumentEventListener;
592
593 struct HTMLDocumentNode {
594     HTMLDOMNode node;
595     HTMLDocument basedoc;
596
597     const IInternetHostSecurityManagerVtbl *lpIInternetHostSecurityManagerVtbl;
598
599     const nsIDocumentObserverVtbl  *lpIDocumentObserverVtbl;
600     const nsIRunnableVtbl  *lpIRunnableVtbl;
601
602     LONG ref;
603
604     nsIDOMHTMLDocument *nsdoc;
605     HTMLDOMNode *nodes;
606     BOOL content_ready;
607     event_target_t *body_event_target;
608
609     IInternetSecurityManager *secmgr;
610     ICatInformation *catmgr;
611     nsDocumentEventListener *nsevent_listener;
612     BOOL *event_vector;
613
614     BOOL skip_mutation_notif;
615     mutation_queue_t *mutation_queue;
616     mutation_queue_t *mutation_queue_tail;
617
618     struct list bindings;
619     struct list selection_list;
620     struct list range_list;
621 };
622
623 #define HTMLWINDOW2(x)   ((IHTMLWindow2*)                 &(x)->lpHTMLWindow2Vtbl)
624 #define HTMLWINDOW3(x)   ((IHTMLWindow3*)                 &(x)->lpHTMLWindow3Vtbl)
625 #define HTMLWINDOW4(x)   ((IHTMLWindow4*)                 &(x)->lpHTMLWindow4Vtbl)
626
627 #define HTMLDOC(x)       ((IHTMLDocument2*)               &(x)->lpHTMLDocument2Vtbl)
628 #define HTMLDOC3(x)      ((IHTMLDocument3*)               &(x)->lpHTMLDocument3Vtbl)
629 #define HTMLDOC4(x)      ((IHTMLDocument4*)               &(x)->lpHTMLDocument4Vtbl)
630 #define HTMLDOC5(x)      ((IHTMLDocument5*)               &(x)->lpHTMLDocument5Vtbl)
631 #define HTMLDOC6(x)      ((IHTMLDocument6*)               &(x)->lpHTMLDocument6Vtbl)
632 #define PERSIST(x)       ((IPersist*)                     &(x)->lpPersistFileVtbl)
633 #define PERSISTMON(x)    ((IPersistMoniker*)              &(x)->lpPersistMonikerVtbl)
634 #define PERSISTFILE(x)   ((IPersistFile*)                 &(x)->lpPersistFileVtbl)
635 #define MONPROP(x)       ((IMonikerProp*)                 &(x)->lpMonikerPropVtbl)
636 #define OLEOBJ(x)        ((IOleObject*)                   &(x)->lpOleObjectVtbl)
637 #define OLEDOC(x)        ((IOleDocument*)                 &(x)->lpOleDocumentVtbl)
638 #define DOCVIEW(x)       ((IOleDocumentView*)             &(x)->lpOleDocumentViewVtbl)
639 #define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
640 #define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
641 #define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObjectExVtbl)
642 #define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObjectExVtbl)
643 #define VIEWOBJEX(x)      ((IViewObjectEx*)               &(x)->lpViewObjectExVtbl)
644 #define INPLACEOBJ(x)    ((IOleInPlaceObject*)            &(x)->lpOleInPlaceObjectWindowlessVtbl)
645 #define INPLACEWIN(x)    ((IOleInPlaceObjectWindowless*)  &(x)->lpOleInPlaceObjectWindowlessVtbl)
646 #define SERVPROV(x)      ((IServiceProvider*)             &(x)->lpServiceProviderVtbl)
647 #define CMDTARGET(x)     ((IOleCommandTarget*)            &(x)->lpOleCommandTargetVtbl)
648 #define CONTROL(x)       ((IOleControl*)                  &(x)->lpOleControlVtbl)
649 #define HLNKTARGET(x)    ((IHlinkTarget*)                 &(x)->lpHlinkTargetVtbl)
650 #define CONPTCONT(x)     ((IConnectionPointContainer*)    &(x)->lpConnectionPointContainerVtbl)
651 #define PERSTRINIT(x)    ((IPersistStreamInit*)           &(x)->lpPersistStreamInitVtbl)
652 #define PERSISTHIST(x)   ((IPersistHistory*)              &(x)->lpPersistHistoryVtbl)
653 #define CUSTOMDOC(x)     ((ICustomDoc*)                   &(x)->lpCustomDocVtbl)
654 #define OBJSITE(x)       ((IObjectWithSite*)              &(x)->lpObjectWithSiteVtbl)
655
656 #define NSWBCHROME(x)    ((nsIWebBrowserChrome*)          &(x)->lpWebBrowserChromeVtbl)
657 #define NSCML(x)         ((nsIContextMenuListener*)       &(x)->lpContextMenuListenerVtbl)
658 #define NSURICL(x)       ((nsIURIContentListener*)        &(x)->lpURIContentListenerVtbl)
659 #define NSEMBWNDS(x)     ((nsIEmbeddingSiteWindow*)       &(x)->lpEmbeddingSiteWindowVtbl)
660 #define NSIFACEREQ(x)    ((nsIInterfaceRequestor*)        &(x)->lpInterfaceRequestorVtbl)
661 #define NSTOOLTIP(x)     ((nsITooltipListener*)           &(x)->lpTooltipListenerVtbl)
662 #define NSEVENTLIST(x)   ((nsIDOMEventListener*)          &(x)->lpDOMEventListenerVtbl)
663 #define NSWEAKREF(x)     ((nsIWeakReference*)             &(x)->lpWeakReferenceVtbl)
664 #define NSSUPWEAKREF(x)  ((nsISupportsWeakReference*)     &(x)->lpSupportsWeakReferenceVtbl)
665
666 #define NSDOCOBS(x)      ((nsIDocumentObserver*)          &(x)->lpIDocumentObserverVtbl)
667
668 #define NSRUNNABLE(x)    ((nsIRunnable*)  &(x)->lpIRunnableVtbl)
669
670 #define NSCHANNEL(x)     ((nsIChannel*)        &(x)->lpHttpChannelVtbl)
671 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*)    &(x)->lpHttpChannelVtbl)
672 #define NSUPCHANNEL(x)   ((nsIUploadChannel*)  &(x)->lpUploadChannelVtbl)
673 #define NSHTTPINTERNAL(x) ((nsIHttpChannelInternal*)  &(x)->lpIHttpChannelInternalVtbl)
674
675 #define HTTPNEG(x)       ((IHttpNegotiate2*)              &(x)->lpHttpNegotiate2Vtbl)
676 #define STATUSCLB(x)     ((IBindStatusCallback*)          &(x)->lpBindStatusCallbackVtbl)
677 #define BINDINFO(x)      ((IInternetBindInfo*)            &(x)->lpInternetBindInfoVtbl);
678
679 #define HTMLELEM(x)      ((IHTMLElement*)                 &(x)->lpHTMLElementVtbl)
680 #define HTMLELEM2(x)     ((IHTMLElement2*)                &(x)->lpHTMLElement2Vtbl)
681 #define HTMLELEM3(x)     ((IHTMLElement3*)                &(x)->lpHTMLElement3Vtbl)
682 #define HTMLDOMNODE(x)   ((IHTMLDOMNode*)                 &(x)->lpHTMLDOMNodeVtbl)
683 #define HTMLDOMNODE2(x)  ((IHTMLDOMNode2*)                &(x)->lpHTMLDOMNode2Vtbl)
684
685 #define HTMLTEXTCONT(x)  ((IHTMLTextContainer*)           &(x)->lpHTMLTextContainerVtbl)
686 #define HTMLFRAMEBASE(x) ((IHTMLFrameBase*)               &(x)->lpIHTMLFrameBaseVtbl)
687 #define HTMLFRAMEBASE2(x) ((IHTMLFrameBase2*)             &(x)->lpIHTMLFrameBase2Vtbl)
688
689 #define HTMLOPTFACTORY(x)  ((IHTMLOptionElementFactory*)  &(x)->lpHTMLOptionElementFactoryVtbl)
690 #define HTMLIMGFACTORY(x)  ((IHTMLImageElementFactory*)   &(x)->lpHTMLImageElementFactoryVtbl)
691 #define HTMLLOCATION(x)    ((IHTMLLocation*)              &(x)->lpHTMLLocationVtbl)
692
693 #define DISPATCHEX(x)    ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
694
695 #define SUPPERRINFO(x)   ((ISupportErrorInfo*) &(x)->lpSupportErrorInfoVtbl)
696
697 #define HOSTSECMGR(x)    ((IInternetHostSecurityManager*)  &(x)->lpIInternetHostSecurityManagerVtbl)
698
699 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
700 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
701
702 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
703 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
704 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
705 HRESULT create_document_fragment(nsIDOMNode*,HTMLDocumentNode*,HTMLDocumentNode**);
706
707 HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**);
708 void update_window_doc(HTMLWindow*);
709 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
710 nsIDOMWindow *get_nsdoc_window(nsIDOMDocument*);
711 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
712 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
713 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
714 IOmNavigator *OmNavigator_Create(void);
715 HRESULT HTMLScreen_Create(IHTMLScreen**);
716
717 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
718 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
719 void HTMLDocument_Persist_Init(HTMLDocument*);
720 void HTMLDocument_OleCmd_Init(HTMLDocument*);
721 void HTMLDocument_OleObj_Init(HTMLDocument*);
722 void HTMLDocument_View_Init(HTMLDocument*);
723 void HTMLDocument_Window_Init(HTMLDocument*);
724 void HTMLDocument_Service_Init(HTMLDocument*);
725 void HTMLDocument_Hlink_Init(HTMLDocument*);
726
727 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
728
729 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
730
731 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*);
732 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
733 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
734
735 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
736 void NSContainer_Release(NSContainer*);
737
738 void init_mutation(HTMLDocumentNode*);
739 void release_mutation(HTMLDocumentNode*);
740
741 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
742 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
743 void notif_focus(HTMLDocumentObj*);
744
745 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
746 void hide_tooltip(HTMLDocumentObj*);
747 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
748
749 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
750
751 BOOL load_gecko(BOOL);
752 void close_gecko(void);
753 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
754 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
755 void release_nsio(void);
756 BOOL is_gecko_path(const char*);
757
758 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
759 HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**);
760 HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD);
761
762 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD,BOOL*);
763 HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
764 HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
765 HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL);
766
767 void call_property_onchanged(ConnectionPoint*,DISPID);
768 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
769
770 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
771 void nsfree(void*);
772
773 void nsACString_InitDepend(nsACString*,const char*);
774 void nsACString_SetData(nsACString*,const char*);
775 PRUint32 nsACString_GetData(const nsACString*,const char**);
776 void nsACString_Finish(nsACString*);
777
778 BOOL nsAString_Init(nsAString*,const PRUnichar*);
779 void nsAString_InitDepend(nsAString*,const PRUnichar*);
780 void nsAString_SetData(nsAString*,const PRUnichar*);
781 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
782 void nsAString_Finish(nsAString*);
783
784 nsICommandParams *create_nscommand_params(void);
785 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
786 void get_editor_controller(NSContainer*);
787 nsresult get_nsinterface(nsISupports*,REFIID,void**);
788
789 void init_nsevents(HTMLDocumentNode*);
790 void release_nsevents(HTMLDocumentNode*);
791 void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR);
792
793 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
794 void set_current_mon(HTMLWindow*,IMoniker*);
795 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
796 HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*);
797 void abort_document_bindings(HTMLDocumentNode*);
798
799 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
800
801 HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**);
802 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
803 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
804 IMoniker *get_channelbsc_mon(nsChannelBSC*);
805
806 void set_ready_state(HTMLWindow*,READYSTATE);
807
808 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
809 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
810 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
811 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
812 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
813
814 void detach_selection(HTMLDocumentNode*);
815 void detach_ranges(HTMLDocumentNode*);
816 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
817
818 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
819
820 HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**);
821
822 HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**);
823 HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**);
824 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
825 HRESULT HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
826 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
827 HRESULT HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
828 HRESULT HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
829 HRESULT HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
830 HRESULT HTMLStyleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
831 HRESULT HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
832 HRESULT HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
833 HRESULT HTMLObjectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
834 HRESULT HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
835 HRESULT HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
836 HRESULT HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
837 HRESULT HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
838 HRESULT HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
839 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
840 HRESULT HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
841
842 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
843 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
844 void HTMLElement2_Init(HTMLElement*);
845 void HTMLElement3_Init(HTMLElement*);
846 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
847 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
848
849 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
850 void HTMLDOMNode_destructor(HTMLDOMNode*);
851
852 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
853 void HTMLElement_destructor(HTMLDOMNode*);
854 HRESULT HTMLElement_clone(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
855
856 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
857 void HTMLFrameBase_destructor(HTMLFrameBase*);
858
859 HRESULT get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLDOMNode**);
860 void release_nodes(HTMLDocumentNode*);
861
862 void release_script_hosts(HTMLWindow*);
863 void connect_scripts(HTMLWindow*);
864 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
865 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
866 HRESULT exec_script(HTMLWindow*,const WCHAR*,const WCHAR*,VARIANT*);
867 void set_script_mode(HTMLWindow*,SCRIPTMODE);
868 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
869 IDispatch *get_script_disp(ScriptHost*);
870 HRESULT search_window_props(HTMLWindow*,BSTR,DWORD,DISPID*);
871
872 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
873 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
874 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
875
876 /* commands */
877 typedef struct {
878     DWORD id;
879     HRESULT (*query)(HTMLDocument*,OLECMD*);
880     HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
881 } cmdtable_t;
882
883 extern const cmdtable_t editmode_cmds[];
884
885 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
886
887 /* timer */
888 #define UPDATE_UI       0x0001
889 #define UPDATE_TITLE    0x0002
890
891 void update_doc(HTMLDocument*,DWORD);
892 void update_title(HTMLDocumentObj*);
893
894 /* editor */
895 void init_editor(HTMLDocument*);
896 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
897 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
898 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
899 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
900 void handle_edit_load(HTMLDocument*);
901 HRESULT editor_is_dirty(HTMLDocument*);
902 void set_dirty(HTMLDocument*,VARIANT_BOOL);
903
904 extern DWORD mshtml_tls;
905
906 typedef struct task_t task_t;
907 typedef void (*task_proc_t)(task_t*);
908
909 struct task_t {
910     LONG target_magic;
911     task_proc_t proc;
912     struct task_t *next;
913 };
914
915 typedef struct {
916     task_t header;
917     HTMLDocumentObj *doc;
918 } docobj_task_t;
919
920 typedef struct {
921     HWND thread_hwnd;
922     task_t *task_queue_head;
923     task_t *task_queue_tail;
924     struct list timer_list;
925 } thread_data_t;
926
927 thread_data_t *get_thread_data(BOOL);
928 HWND get_thread_hwnd(void);
929
930 LONG get_task_target_magic(void);
931 void push_task(task_t*,task_proc_t,LONG);
932 void remove_target_tasks(LONG);
933
934 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
935 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
936
937 void release_typelib(void);
938 HRESULT call_disp_func(IDispatch*,DISPPARAMS*);
939
940 const char *debugstr_variant(const VARIANT*);
941
942 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
943 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
944 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
945 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
946 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
947
948 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
949
950 /* memory allocation functions */
951
952 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
953 {
954     return HeapAlloc(GetProcessHeap(), 0, len);
955 }
956
957 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
958 {
959     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
960 }
961
962 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
963 {
964     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
965 }
966
967 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
968 {
969     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
970 }
971
972 static inline BOOL heap_free(void *mem)
973 {
974     return HeapFree(GetProcessHeap(), 0, mem);
975 }
976
977 static inline LPWSTR heap_strdupW(LPCWSTR str)
978 {
979     LPWSTR ret = NULL;
980
981     if(str) {
982         DWORD size;
983
984         size = (strlenW(str)+1)*sizeof(WCHAR);
985         ret = heap_alloc(size);
986         memcpy(ret, str, size);
987     }
988
989     return ret;
990 }
991
992 static inline LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
993 {
994     LPWSTR ret = NULL;
995
996     if(str) {
997         ret = heap_alloc((len+1)*sizeof(WCHAR));
998         memcpy(ret, str, len*sizeof(WCHAR));
999         ret[len] = 0;
1000     }
1001
1002     return ret;
1003 }
1004
1005 static inline char *heap_strdupA(const char *str)
1006 {
1007     char *ret = NULL;
1008
1009     if(str) {
1010         DWORD size;
1011
1012         size = strlen(str)+1;
1013         ret = heap_alloc(size);
1014         memcpy(ret, str, size);
1015     }
1016
1017     return ret;
1018 }
1019
1020 static inline WCHAR *heap_strdupAtoW(const char *str)
1021 {
1022     LPWSTR ret = NULL;
1023
1024     if(str) {
1025         DWORD len;
1026
1027         len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
1028         ret = heap_alloc(len*sizeof(WCHAR));
1029         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
1030     }
1031
1032     return ret;
1033 }
1034
1035 static inline char *heap_strdupWtoA(LPCWSTR str)
1036 {
1037     char *ret = NULL;
1038
1039     if(str) {
1040         DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
1041         ret = heap_alloc(size);
1042         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
1043     }
1044
1045     return ret;
1046 }
1047
1048 static inline void windowref_addref(windowref_t *ref)
1049 {
1050     InterlockedIncrement(&ref->ref);
1051 }
1052
1053 static inline void windowref_release(windowref_t *ref)
1054 {
1055     if(!InterlockedDecrement(&ref->ref))
1056         heap_free(ref);
1057 }
1058
1059 HDC get_display_dc(void);
1060 HINSTANCE get_shdoclc(void);
1061 void set_statustext(HTMLDocumentObj*,INT,LPCWSTR);
1062
1063 extern HINSTANCE hInst;