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