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