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