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