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