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