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