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