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