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