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