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