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