mshtml: Wrap nsIHttpChannelInternal interface.
[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     const nsIHttpChannelInternalVtbl *lpIHttpChannelInternalVtbl;
367
368     LONG ref;
369
370     nsIChannel *channel;
371     nsIHttpChannel *http_channel;
372     nsIHttpChannelInternal *http_channel_internal;
373     nsIWineURI *uri;
374     nsIInputStream *post_data_stream;
375     nsILoadGroup *load_group;
376     nsIInterfaceRequestor *notif_callback;
377     nsISupports *owner;
378     nsLoadFlags load_flags;
379     nsIURI *original_uri;
380     char *content_type;
381     char *charset;
382     PRUint32 response_status;
383 } nsChannel;
384
385 typedef struct {
386     HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
387     void (*destructor)(HTMLDOMNode*);
388     HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
389     HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
390 } NodeImplVtbl;
391
392 struct HTMLDOMNode {
393     DispatchEx dispex;
394     const IHTMLDOMNodeVtbl   *lpHTMLDOMNodeVtbl;
395     const IHTMLDOMNode2Vtbl  *lpHTMLDOMNode2Vtbl;
396     const NodeImplVtbl *vtbl;
397
398     LONG ref;
399
400     nsIDOMNode *nsnode;
401     HTMLDocument *doc;
402     event_target_t *event_target;
403
404     HTMLDOMNode *next;
405 };
406
407 typedef struct {
408     HTMLDOMNode node;
409     ConnectionPointContainer cp_container;
410
411     const IHTMLElementVtbl   *lpHTMLElementVtbl;
412     const IHTMLElement2Vtbl  *lpHTMLElement2Vtbl;
413     const IHTMLElement3Vtbl  *lpHTMLElement3Vtbl;
414
415     nsIDOMHTMLElement *nselem;
416 } HTMLElement;
417
418 typedef struct {
419     HTMLElement element;
420
421     const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
422
423     ConnectionPoint cp;
424 } HTMLTextContainer;
425
426 #define HTMLWINDOW2(x)   ((IHTMLWindow2*)                 &(x)->lpHTMLWindow2Vtbl)
427 #define HTMLWINDOW3(x)   ((IHTMLWindow3*)                 &(x)->lpHTMLWindow3Vtbl)
428
429 #define HTMLDOC(x)       ((IHTMLDocument2*)               &(x)->lpHTMLDocument2Vtbl)
430 #define HTMLDOC3(x)      ((IHTMLDocument3*)               &(x)->lpHTMLDocument3Vtbl)
431 #define HTMLDOC4(x)      ((IHTMLDocument4*)               &(x)->lpHTMLDocument4Vtbl)
432 #define HTMLDOC5(x)      ((IHTMLDocument5*)               &(x)->lpHTMLDocument5Vtbl)
433 #define PERSIST(x)       ((IPersist*)                     &(x)->lpPersistFileVtbl)
434 #define PERSISTMON(x)    ((IPersistMoniker*)              &(x)->lpPersistMonikerVtbl)
435 #define PERSISTFILE(x)   ((IPersistFile*)                 &(x)->lpPersistFileVtbl)
436 #define MONPROP(x)       ((IMonikerProp*)                 &(x)->lpMonikerPropVtbl)
437 #define OLEOBJ(x)        ((IOleObject*)                   &(x)->lpOleObjectVtbl)
438 #define OLEDOC(x)        ((IOleDocument*)                 &(x)->lpOleDocumentVtbl)
439 #define DOCVIEW(x)       ((IOleDocumentView*)             &(x)->lpOleDocumentViewVtbl)
440 #define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
441 #define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
442 #define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObject2Vtbl)
443 #define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObject2Vtbl)
444 #define INPLACEOBJ(x)    ((IOleInPlaceObject*)            &(x)->lpOleInPlaceObjectWindowlessVtbl)
445 #define INPLACEWIN(x)    ((IOleInPlaceObjectWindowless*)  &(x)->lpOleInPlaceObjectWindowlessVtbl)
446 #define SERVPROV(x)      ((IServiceProvider*)             &(x)->lpServiceProviderVtbl)
447 #define CMDTARGET(x)     ((IOleCommandTarget*)            &(x)->lpOleCommandTargetVtbl)
448 #define CONTROL(x)       ((IOleControl*)                  &(x)->lpOleControlVtbl)
449 #define HLNKTARGET(x)    ((IHlinkTarget*)                 &(x)->lpHlinkTargetVtbl)
450 #define CONPTCONT(x)     ((IConnectionPointContainer*)    &(x)->lpConnectionPointContainerVtbl)
451 #define PERSTRINIT(x)    ((IPersistStreamInit*)           &(x)->lpPersistStreamInitVtbl)
452 #define PERSISTHIST(x)   ((IPersistHistory*)              &(x)->lpPersistHistoryVtbl)
453 #define CUSTOMDOC(x)     ((ICustomDoc*)                   &(x)->lpCustomDocVtbl)
454
455 #define NSWBCHROME(x)    ((nsIWebBrowserChrome*)          &(x)->lpWebBrowserChromeVtbl)
456 #define NSCML(x)         ((nsIContextMenuListener*)       &(x)->lpContextMenuListenerVtbl)
457 #define NSURICL(x)       ((nsIURIContentListener*)        &(x)->lpURIContentListenerVtbl)
458 #define NSEMBWNDS(x)     ((nsIEmbeddingSiteWindow*)       &(x)->lpEmbeddingSiteWindowVtbl)
459 #define NSIFACEREQ(x)    ((nsIInterfaceRequestor*)        &(x)->lpInterfaceRequestorVtbl)
460 #define NSTOOLTIP(x)     ((nsITooltipListener*)           &(x)->lpTooltipListenerVtbl)
461 #define NSEVENTLIST(x)   ((nsIDOMEventListener*)          &(x)->lpDOMEventListenerVtbl)
462 #define NSWEAKREF(x)     ((nsIWeakReference*)             &(x)->lpWeakReferenceVtbl)
463 #define NSSUPWEAKREF(x)  ((nsISupportsWeakReference*)     &(x)->lpSupportsWeakReferenceVtbl)
464
465 #define NSDOCOBS(x)      ((nsIDocumentObserver*)          &(x)->lpDocumentObserverVtbl)
466
467 #define NSRUNNABLE(x)    ((nsIRunnable*)  &(x)->lpRunnableVtbl)
468
469 #define NSCHANNEL(x)     ((nsIChannel*)        &(x)->lpHttpChannelVtbl)
470 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*)    &(x)->lpHttpChannelVtbl)
471 #define NSUPCHANNEL(x)   ((nsIUploadChannel*)  &(x)->lpUploadChannelVtbl)
472 #define NSHTTPINTERNAL(x) ((nsIHttpChannelInternal*)  &(x)->lpIHttpChannelInternalVtbl)
473
474 #define HTTPNEG(x)       ((IHttpNegotiate2*)              &(x)->lpHttpNegotiate2Vtbl)
475 #define STATUSCLB(x)     ((IBindStatusCallback*)          &(x)->lpBindStatusCallbackVtbl)
476 #define BINDINFO(x)      ((IInternetBindInfo*)            &(x)->lpInternetBindInfoVtbl);
477
478 #define HTMLELEM(x)      ((IHTMLElement*)                 &(x)->lpHTMLElementVtbl)
479 #define HTMLELEM2(x)     ((IHTMLElement2*)                &(x)->lpHTMLElement2Vtbl)
480 #define HTMLELEM3(x)     ((IHTMLElement3*)                &(x)->lpHTMLElement3Vtbl)
481 #define HTMLDOMNODE(x)   ((IHTMLDOMNode*)                 &(x)->lpHTMLDOMNodeVtbl)
482 #define HTMLDOMNODE2(x)  ((IHTMLDOMNode2*)                &(x)->lpHTMLDOMNode2Vtbl)
483
484 #define HTMLTEXTCONT(x)  ((IHTMLTextContainer*)           &(x)->lpHTMLTextContainerVtbl)
485
486 #define HTMLOPTFACTORY(x)  ((IHTMLOptionElementFactory*)  &(x)->lpHTMLOptionElementFactoryVtbl)
487 #define HTMLLOCATION(x)  ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
488
489 #define DISPATCHEX(x)    ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
490
491 #define SUPPERRINFO(x)   ((ISupportErrorInfo*) &(x)->lpSupportErrorInfoVtbl)
492
493 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
494 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
495
496 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
497 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
498 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocument**);
499
500 HRESULT HTMLWindow_Create(HTMLDocument*,nsIDOMWindow*,HTMLWindow**);
501 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
502 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
503 HTMLLocation *HTMLLocation_Create(HTMLDocument*);
504 IOmNavigator *OmNavigator_Create(void);
505
506 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
507 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
508 void HTMLDocument_Persist_Init(HTMLDocument*);
509 void HTMLDocument_OleCmd_Init(HTMLDocument*);
510 void HTMLDocument_OleObj_Init(HTMLDocument*);
511 void HTMLDocument_View_Init(HTMLDocument*);
512 void HTMLDocument_Window_Init(HTMLDocument*);
513 void HTMLDocument_Service_Init(HTMLDocument*);
514 void HTMLDocument_Hlink_Init(HTMLDocument*);
515
516 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
517
518 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
519 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
520 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
521
522 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
523 void NSContainer_Release(NSContainer*);
524
525 void init_mutation(NSContainer*);
526 void set_mutation_observer(NSContainer*,nsIDOMHTMLDocument*);
527 void remove_mutation_observer(NSContainer*,nsIDOMHTMLDocument*);
528
529 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
530 void show_context_menu(HTMLDocument*,DWORD,POINT*,IDispatch*);
531 void notif_focus(HTMLDocument*);
532
533 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
534 void hide_tooltip(HTMLDocument*);
535 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
536
537 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
538
539 BOOL load_gecko(BOOL);
540 void close_gecko(void);
541 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
542 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
543 void release_nsio(void);
544 BOOL install_wine_gecko(BOOL);
545
546 HRESULT nsuri_to_url(LPCWSTR,BSTR*);
547
548 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
549
550 void call_property_onchanged(ConnectionPoint*,DISPID);
551 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
552
553 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
554 void nsfree(void*);
555
556 void nsACString_Init(nsACString*,const char*);
557 void nsACString_SetData(nsACString*,const char*);
558 PRUint32 nsACString_GetData(const nsACString*,const char**);
559 void nsACString_Finish(nsACString*);
560
561 void nsAString_Init(nsAString*,const PRUnichar*);
562 void nsAString_SetData(nsAString*,const PRUnichar*);
563 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
564 void nsAString_Finish(nsAString*);
565
566 nsIInputStream *create_nsstream(const char*,PRInt32);
567 nsICommandParams *create_nscommand_params(void);
568 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
569 void get_editor_controller(NSContainer*);
570 void init_nsevents(NSContainer*);
571 void add_nsevent_listener(NSContainer*,LPCWSTR);
572 nsresult get_nsinterface(nsISupports*,REFIID,void**);
573 void update_nsdocument(HTMLDocument*);
574
575 void set_document_bscallback(HTMLDocument*,nsChannelBSC*);
576 void set_current_mon(HTMLDocument*,IMoniker*);
577 HRESULT start_binding(HTMLDocument*,BSCallback*,IBindCtx*);
578
579 HRESULT bind_mon_to_buffer(HTMLDocument*,IMoniker*,void**,DWORD*);
580
581 nsChannelBSC *create_channelbsc(IMoniker*);
582 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
583 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
584 IMoniker *get_channelbsc_mon(nsChannelBSC*);
585
586 IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*);
587 IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*);
588 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
589 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
590 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
591
592 void detach_selection(HTMLDocument*);
593 void detach_ranges(HTMLDocument*);
594 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
595
596 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocument*,nsIDOMNode*);
597
598 HTMLElement *HTMLElement_Create(HTMLDocument*,nsIDOMNode*,BOOL);
599 HTMLElement *HTMLCommentElement_Create(HTMLDocument*,nsIDOMNode*);
600 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
601 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
602 HTMLElement *HTMLIFrame_Create(nsIDOMHTMLElement*);
603 HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement*);
604 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
605 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
606 HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*);
607 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
608 HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
609 HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement*);
610 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
611 HTMLElement *HTMLGenericElement_Create(nsIDOMHTMLElement*);
612
613 void HTMLDOMNode_Init(HTMLDocument*,HTMLDOMNode*,nsIDOMNode*);
614 void HTMLElement_Init(HTMLElement*);
615 void HTMLElement2_Init(HTMLElement*);
616 void HTMLElement3_Init(HTMLElement*);
617 void HTMLTextContainer_Init(HTMLTextContainer*);
618
619 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
620 void HTMLDOMNode_destructor(HTMLDOMNode*);
621
622 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
623 void HTMLElement_destructor(HTMLDOMNode*);
624
625 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*,BOOL);
626 void release_nodes(HTMLDocument*);
627
628 void release_script_hosts(HTMLDocument*);
629 void connect_scripts(HTMLDocument*);
630 void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*);
631 IDispatch *script_parse_event(HTMLDocument*,LPCWSTR);
632 void set_script_mode(HTMLDocument*,SCRIPTMODE);
633
634 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
635 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument*,IUnknown*,nsIDOMNodeList*);
636 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocument*,IUnknown*,nsIDOMHTMLCollection*);
637
638 /* commands */
639 typedef struct {
640     DWORD id;
641     HRESULT (*query)(HTMLDocument*,OLECMD*);
642     HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
643 } cmdtable_t;
644
645 extern const cmdtable_t editmode_cmds[];
646
647 void do_ns_command(NSContainer*,const char*,nsICommandParams*);
648
649 /* timer */
650 #define UPDATE_UI       0x0001
651 #define UPDATE_TITLE    0x0002
652
653 void update_doc(HTMLDocument *This, DWORD flags);
654 void update_title(HTMLDocument*);
655
656 /* editor */
657 void init_editor(HTMLDocument*);
658 void set_ns_editmode(NSContainer*);
659 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
660 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
661 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
662 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
663 void handle_edit_load(HTMLDocument*);
664 HRESULT editor_is_dirty(HTMLDocument*);
665 void set_dirty(HTMLDocument*,VARIANT_BOOL);
666
667 extern DWORD mshtml_tls;
668
669 typedef struct task_t {
670     HTMLDocument *doc;
671
672     enum {
673         TASK_SETDOWNLOADSTATE,
674         TASK_PARSECOMPLETE,
675         TASK_SETPROGRESS,
676         TASK_START_BINDING
677     } task_id;
678
679     nsChannelBSC *bscallback;
680
681     struct task_t *next;
682 } task_t;
683
684 typedef struct {
685     HWND thread_hwnd;
686     task_t *task_queue_head;
687     task_t *task_queue_tail;
688     struct list timer_list;
689 } thread_data_t;
690
691 thread_data_t *get_thread_data(BOOL);
692 HWND get_thread_hwnd(void);
693 void push_task(task_t*);
694 void remove_doc_tasks(const HTMLDocument*);
695 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
696 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
697
698 void release_typelib(void);
699 void call_disp_func(HTMLDocument*,IDispatch*,IDispatch*);
700
701 const char *debugstr_variant(const VARIANT*);
702
703 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
704 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
705 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
706 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
707 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
708
709 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
710
711 /* memory allocation functions */
712
713 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
714 {
715     return HeapAlloc(GetProcessHeap(), 0, len);
716 }
717
718 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
719 {
720     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
721 }
722
723 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
724 {
725     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
726 }
727
728 static inline BOOL heap_free(void *mem)
729 {
730     return HeapFree(GetProcessHeap(), 0, mem);
731 }
732
733 static inline LPWSTR heap_strdupW(LPCWSTR str)
734 {
735     LPWSTR ret = NULL;
736
737     if(str) {
738         DWORD size;
739
740         size = (strlenW(str)+1)*sizeof(WCHAR);
741         ret = heap_alloc(size);
742         memcpy(ret, str, size);
743     }
744
745     return ret;
746 }
747
748 static inline char *heap_strdupA(const char *str)
749 {
750     char *ret = NULL;
751
752     if(str) {
753         DWORD size;
754
755         size = strlen(str)+1;
756         ret = heap_alloc(size);
757         memcpy(ret, str, size);
758     }
759
760     return ret;
761 }
762
763 static inline WCHAR *heap_strdupAtoW(const char *str)
764 {
765     LPWSTR ret = NULL;
766
767     if(str) {
768         DWORD len;
769
770         len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
771         ret = heap_alloc(len*sizeof(WCHAR));
772         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
773     }
774
775     return ret;
776 }
777
778 static inline char *heap_strdupWtoA(LPCWSTR str)
779 {
780     char *ret = NULL;
781
782     if(str) {
783         DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
784         ret = heap_alloc(size);
785         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
786     }
787
788     return ret;
789 }
790
791 HINSTANCE get_shdoclc(void);
792
793 extern HINSTANCE hInst;