comctl32: Allow expanding/collapsing treeview nodes multiple times.
[wine] / dlls / mshtml / mshtml_private.h
1 /*
2  * Copyright 2005-2009 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 "docobjectservice.h"
22 #include "comcat.h"
23 #include "mshtml.h"
24 #include "mshtmhst.h"
25 #include "hlink.h"
26 #include "perhist.h"
27 #include "dispex.h"
28 #include "objsafe.h"
29 #include "htiframe.h"
30 #include "tlogstg.h"
31
32 #include "wine/list.h"
33 #include "wine/unicode.h"
34
35 #ifdef INIT_GUID
36 #include "initguid.h"
37 #endif
38
39 #include "nsiface.h"
40
41 #define NS_ERROR_GENERATE_FAILURE(module,code) \
42     ((nsresult) (((PRUint32)(1<<31)) | ((PRUint32)(module+0x45)<<16) | ((PRUint32)(code))))
43
44 #define NS_OK                     ((nsresult)0x00000000L)
45 #define NS_ERROR_FAILURE          ((nsresult)0x80004005L)
46 #define NS_ERROR_OUT_OF_MEMORY    ((nsresult)0x8007000EL)
47 #define NS_ERROR_NOT_IMPLEMENTED  ((nsresult)0x80004001L)
48 #define NS_NOINTERFACE            ((nsresult)0x80004002L)
49 #define NS_ERROR_INVALID_POINTER  ((nsresult)0x80004003L)
50 #define NS_ERROR_NULL_POINTER     NS_ERROR_INVALID_POINTER
51 #define NS_ERROR_NOT_AVAILABLE    ((nsresult)0x80040111L)
52 #define NS_ERROR_INVALID_ARG      ((nsresult)0x80070057L) 
53 #define NS_ERROR_UNEXPECTED       ((nsresult)0x8000ffffL)
54
55 #define NS_ERROR_MODULE_NETWORK    6
56
57 #define NS_BINDING_ABORTED         NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 2)
58 #define NS_ERROR_UNKNOWN_PROTOCOL  NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 18)
59
60 #define NS_FAILED(res) ((res) & 0x80000000)
61 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
62
63 #define NSAPI WINAPI
64
65 #define MSHTML_E_NODOC    0x800a025c
66
67 typedef struct HTMLDOMNode HTMLDOMNode;
68 typedef struct ConnectionPoint ConnectionPoint;
69 typedef struct BSCallback BSCallback;
70 typedef struct event_target_t event_target_t;
71
72 #define TID_LIST \
73     XIID(NULL) \
74     XDIID(DispCEventObj) \
75     XDIID(DispCPlugins) \
76     XDIID(DispDOMChildrenCollection) \
77     XDIID(DispHTMLAnchorElement) \
78     XDIID(DispHTMLAttributeCollection) \
79     XDIID(DispHTMLBody) \
80     XDIID(DispHTMLCommentElement) \
81     XDIID(DispHTMLCurrentStyle) \
82     XDIID(DispHTMLDocument) \
83     XDIID(DispHTMLDOMAttribute) \
84     XDIID(DispHTMLDOMTextNode) \
85     XDIID(DispHTMLElementCollection) \
86     XDIID(DispHTMLEmbed) \
87     XDIID(DispHTMLFormElement) \
88     XDIID(DispHTMLGenericElement) \
89     XDIID(DispHTMLFrameElement) \
90     XDIID(DispHTMLHeadElement) \
91     XDIID(DispHTMLHistory) \
92     XDIID(DispHTMLIFrame) \
93     XDIID(DispHTMLImg) \
94     XDIID(DispHTMLInputElement) \
95     XDIID(DispHTMLLinkElement) \
96     XDIID(DispHTMLLocation) \
97     XDIID(DispHTMLMetaElement) \
98     XDIID(DispHTMLNavigator) \
99     XDIID(DispHTMLObjectElement) \
100     XDIID(DispHTMLOptionElement) \
101     XDIID(DispHTMLScreen) \
102     XDIID(DispHTMLScriptElement) \
103     XDIID(DispHTMLSelectElement) \
104     XDIID(DispHTMLStyle) \
105     XDIID(DispHTMLStyleElement) \
106     XDIID(DispHTMLStyleSheetsCollection) \
107     XDIID(DispHTMLTable) \
108     XDIID(DispHTMLTableCell) \
109     XDIID(DispHTMLTableRow) \
110     XDIID(DispHTMLTextAreaElement) \
111     XDIID(DispHTMLTitleElement) \
112     XDIID(DispHTMLUnknownElement) \
113     XDIID(DispHTMLWindow2) \
114     XDIID(HTMLDocumentEvents) \
115     XIID(IHTMLAnchorElement) \
116     XIID(IHTMLAttributeCollection) \
117     XIID(IHTMLAttributeCollection2) \
118     XIID(IHTMLAttributeCollection3) \
119     XIID(IHTMLBodyElement) \
120     XIID(IHTMLBodyElement2) \
121     XIID(IHTMLCommentElement) \
122     XIID(IHTMLCurrentStyle) \
123     XIID(IHTMLCurrentStyle2) \
124     XIID(IHTMLCurrentStyle3) \
125     XIID(IHTMLCurrentStyle4) \
126     XIID(IHTMLDocument2) \
127     XIID(IHTMLDocument3) \
128     XIID(IHTMLDocument4) \
129     XIID(IHTMLDocument5) \
130     XIID(IHTMLDOMAttribute) \
131     XIID(IHTMLDOMChildrenCollection) \
132     XIID(IHTMLDOMNode) \
133     XIID(IHTMLDOMNode2) \
134     XIID(IHTMLDOMTextNode) \
135     XIID(IHTMLElement) \
136     XIID(IHTMLElement2) \
137     XIID(IHTMLElement3) \
138     XIID(IHTMLElement4) \
139     XIID(IHTMLElementCollection) \
140     XIID(IHTMLEmbedElement) \
141     XIID(IHTMLEventObj) \
142     XIID(IHTMLFiltersCollection) \
143     XIID(IHTMLFormElement) \
144     XIID(IHTMLFrameBase) \
145     XIID(IHTMLFrameBase2) \
146     XIID(IHTMLFrameElement3) \
147     XIID(IHTMLGenericElement) \
148     XIID(IHTMLHeadElement) \
149     XIID(IHTMLIFrameElement) \
150     XIID(IHTMLIFrameElement2) \
151     XIID(IHTMLIFrameElement3) \
152     XIID(IHTMLImageElementFactory) \
153     XIID(IHTMLImgElement) \
154     XIID(IHTMLInputElement) \
155     XIID(IHTMLLinkElement) \
156     XIID(IHTMLLocation) \
157     XIID(IHTMLMetaElement) \
158     XIID(IHTMLMimeTypesCollection) \
159     XIID(IHTMLObjectElement) \
160     XIID(IHTMLObjectElement2) \
161     XIID(IHTMLOptionElement) \
162     XIID(IHTMLPluginsCollection) \
163     XIID(IHTMLRect) \
164     XIID(IHTMLScreen) \
165     XIID(IHTMLScriptElement) \
166     XIID(IHTMLSelectElement) \
167     XIID(IHTMLStorage) \
168     XIID(IHTMLStyle) \
169     XIID(IHTMLStyle2) \
170     XIID(IHTMLStyle3) \
171     XIID(IHTMLStyle4) \
172     XIID(IHTMLStyle5) \
173     XIID(IHTMLStyle6) \
174     XIID(IHTMLStyleElement) \
175     XIID(IHTMLStyleSheetsCollection) \
176     XIID(IHTMLTable) \
177     XIID(IHTMLTable2) \
178     XIID(IHTMLTable3) \
179     XIID(IHTMLTableCell) \
180     XIID(IHTMLTableRow) \
181     XIID(IHTMLTextAreaElement) \
182     XIID(IHTMLTextContainer) \
183     XIID(IHTMLTitleElement) \
184     XIID(IHTMLUniqueName) \
185     XIID(IHTMLWindow2) \
186     XIID(IHTMLWindow3) \
187     XIID(IHTMLWindow4) \
188     XIID(IHTMLWindow5) \
189     XIID(IHTMLWindow6) \
190     XIID(IOmHistory) \
191     XIID(IOmNavigator)
192
193 typedef enum {
194 #define XIID(iface) iface ## _tid,
195 #define XDIID(iface) iface ## _tid,
196 TID_LIST
197 #undef XIID
198 #undef XDIID
199     LAST_tid
200 } tid_t;
201
202 typedef struct dispex_data_t dispex_data_t;
203 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
204
205 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
206 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
207 #define MSHTML_CUSTOM_DISPID_CNT (MSHTML_DISPID_CUSTOM_MAX-MSHTML_DISPID_CUSTOM_MIN)
208
209 typedef struct DispatchEx DispatchEx;
210
211 typedef struct {
212     HRESULT (*value)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
213     HRESULT (*get_dispid)(DispatchEx*,BSTR,DWORD,DISPID*);
214     HRESULT (*invoke)(DispatchEx*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
215     HRESULT (*populate_props)(DispatchEx*);
216 } dispex_static_data_vtbl_t;
217
218 typedef struct {
219     const dispex_static_data_vtbl_t *vtbl;
220     const tid_t disp_tid;
221     dispex_data_t *data;
222     const tid_t* const iface_tids;
223 } dispex_static_data_t;
224
225 struct DispatchEx {
226     IDispatchEx IDispatchEx_iface;
227
228     IUnknown *outer;
229
230     dispex_static_data_t *data;
231     dispex_dynamic_data_t *dynamic_data;
232 };
233
234 typedef struct {
235     void *x;
236 } nsCycleCollectingAutoRefCnt;
237
238 typedef struct {
239     void *x[9];
240 } nsXPCOMCycleCollectionParticipant;
241
242 typedef struct nsCycleCollectionTraversalCallback nsCycleCollectionTraversalCallback;
243
244 typedef struct {
245     void (NSAPI *unmark_if_purple)(void*);
246     nsresult (NSAPI *traverse)(void*,void*,nsCycleCollectionTraversalCallback*);
247     nsresult (NSAPI *unlink)(void*);
248 } CCObjCallback;
249
250 DEFINE_GUID(IID_nsXPCOMCycleCollectionParticipant, 0x9674489b,0x1f6f,0x4550,0xa7,0x30, 0xcc,0xae,0xdd,0x10,0x4c,0xf9);
251
252 nsrefcnt (__cdecl *ccref_incr)(nsCycleCollectingAutoRefCnt*,nsISupports*);
253 nsrefcnt (__cdecl *ccref_decr)(nsCycleCollectingAutoRefCnt*,nsISupports*);
254 void (__cdecl *ccref_init)(nsCycleCollectingAutoRefCnt*,nsrefcnt);
255 void (__cdecl *ccref_unmark_if_purple)(nsCycleCollectingAutoRefCnt*);
256 void (__cdecl *ccp_init)(nsXPCOMCycleCollectionParticipant*,const CCObjCallback*);
257 void (__cdecl *describe_cc_node)(nsCycleCollectingAutoRefCnt*,size_t,const char*,nsCycleCollectionTraversalCallback*);
258 void (__cdecl *note_cc_edge)(nsISupports*,const char*,nsCycleCollectionTraversalCallback*);
259
260 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*) DECLSPEC_HIDDEN;
261 void release_dispex(DispatchEx*) DECLSPEC_HIDDEN;
262 BOOL dispex_query_interface(DispatchEx*,REFIID,void**) DECLSPEC_HIDDEN;
263 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**) DECLSPEC_HIDDEN;
264 HRESULT get_dispids(tid_t,DWORD*,DISPID**) DECLSPEC_HIDDEN;
265 HRESULT remove_prop(DispatchEx*,BSTR,VARIANT_BOOL*) DECLSPEC_HIDDEN;
266 HRESULT dispex_get_dynid(DispatchEx*,const WCHAR*,DISPID*) DECLSPEC_HIDDEN;
267 void dispex_traverse(DispatchEx*,nsCycleCollectionTraversalCallback*) DECLSPEC_HIDDEN;
268 void dispex_unlink(DispatchEx*) DECLSPEC_HIDDEN;
269 void release_typelib(void) DECLSPEC_HIDDEN;
270 HRESULT get_htmldoc_classinfo(ITypeInfo **typeinfo) DECLSPEC_HIDDEN;
271
272 typedef enum {
273     DISPEXPROP_CUSTOM,
274     DISPEXPROP_DYNAMIC,
275     DISPEXPROP_BUILTIN
276 } dispex_prop_type_t;
277
278 dispex_prop_type_t get_dispid_type(DISPID) DECLSPEC_HIDDEN;
279
280 typedef struct HTMLWindow HTMLWindow;
281 typedef struct HTMLInnerWindow HTMLInnerWindow;
282 typedef struct HTMLOuterWindow HTMLOuterWindow;
283 typedef struct HTMLDocumentNode HTMLDocumentNode;
284 typedef struct HTMLDocumentObj HTMLDocumentObj;
285 typedef struct HTMLFrameBase HTMLFrameBase;
286 typedef struct NSContainer NSContainer;
287 typedef struct HTMLAttributeCollection HTMLAttributeCollection;
288
289 typedef enum {
290     SCRIPTMODE_GECKO,
291     SCRIPTMODE_ACTIVESCRIPT
292 } SCRIPTMODE;
293
294 typedef struct ScriptHost ScriptHost;
295
296 typedef enum {
297     GLOBAL_SCRIPTVAR,
298     GLOBAL_ELEMENTVAR,
299     GLOBAL_DISPEXVAR,
300     GLOBAL_FRAMEVAR
301 } global_prop_type_t;
302
303 typedef struct {
304     global_prop_type_t type;
305     WCHAR *name;
306     ScriptHost *script_host;
307     DISPID id;
308 } global_prop_t;
309
310 typedef struct {
311     IHTMLOptionElementFactory IHTMLOptionElementFactory_iface;
312
313     LONG ref;
314
315     HTMLInnerWindow *window;
316 } HTMLOptionElementFactory;
317
318 typedef struct {
319     DispatchEx dispex;
320     IHTMLImageElementFactory IHTMLImageElementFactory_iface;
321
322     LONG ref;
323
324     HTMLInnerWindow *window;
325 } HTMLImageElementFactory;
326
327 struct HTMLLocation {
328     DispatchEx dispex;
329     IHTMLLocation IHTMLLocation_iface;
330
331     LONG ref;
332
333     HTMLInnerWindow *window;
334 };
335
336 typedef struct {
337     HTMLOuterWindow *window;
338     LONG ref;
339 }  windowref_t;
340
341 typedef struct nsChannelBSC nsChannelBSC;
342
343 struct HTMLWindow {
344     IHTMLWindow2       IHTMLWindow2_iface;
345     IHTMLWindow3       IHTMLWindow3_iface;
346     IHTMLWindow4       IHTMLWindow4_iface;
347     IHTMLWindow5       IHTMLWindow5_iface;
348     IHTMLWindow6       IHTMLWindow6_iface;
349     IHTMLPrivateWindow IHTMLPrivateWindow_iface;
350     IDispatchEx        IDispatchEx_iface;
351     IServiceProvider   IServiceProvider_iface;
352     ITravelLogClient   ITravelLogClient_iface;
353
354     LONG ref;
355
356     HTMLInnerWindow *inner_window;
357     HTMLOuterWindow *outer_window;
358 };
359
360 struct HTMLOuterWindow {
361     HTMLWindow base;
362
363     windowref_t *window_ref;
364     LONG task_magic;
365
366     HTMLDocumentObj *doc_obj;
367     nsIDOMWindow *nswindow;
368     HTMLOuterWindow *parent;
369     HTMLFrameBase *frame_element;
370     READYSTATE readystate;
371
372     HTMLInnerWindow *pending_window;
373     IMoniker *mon;
374     IUri *uri;
375     BSTR url;
376
377     SCRIPTMODE scriptmode;
378
379     IInternetSecurityManager *secmgr;
380
381     struct list children;
382     struct list sibling_entry;
383     struct list entry;
384 };
385
386 struct HTMLInnerWindow {
387     HTMLWindow base;
388     DispatchEx dispex;
389
390     HTMLDocumentNode *doc;
391
392     struct list script_hosts;
393
394     IHTMLEventObj *event;
395
396     HTMLImageElementFactory *image_factory;
397     HTMLOptionElementFactory *option_factory;
398     IHTMLScreen *screen;
399     IOmHistory *history;
400     IHTMLStorage *session_storage;
401
402     global_prop_t *global_props;
403     DWORD global_prop_cnt;
404     DWORD global_prop_size;
405
406     LONG task_magic;
407
408     HTMLLocation *location;
409
410     IMoniker *mon;
411     nsChannelBSC *bscallback;
412     struct list bindings;
413 };
414
415 typedef enum {
416     UNKNOWN_USERMODE,
417     BROWSEMODE,
418     EDITMODE        
419 } USERMODE;
420
421 typedef struct _cp_static_data_t {
422     tid_t tid;
423     void (*on_advise)(IUnknown*,struct _cp_static_data_t*);
424     DWORD id_cnt;
425     DISPID *ids;
426 } cp_static_data_t;
427
428 typedef struct ConnectionPointContainer {
429     IConnectionPointContainer IConnectionPointContainer_iface;
430
431     ConnectionPoint *cp_list;
432     IUnknown *outer;
433     struct ConnectionPointContainer *forward_container;
434 } ConnectionPointContainer;
435
436 struct ConnectionPoint {
437     IConnectionPoint IConnectionPoint_iface;
438
439     ConnectionPointContainer *container;
440
441     union {
442         IUnknown *unk;
443         IDispatch *disp;
444         IPropertyNotifySink *propnotif;
445     } *sinks;
446     DWORD sinks_size;
447
448     const IID *iid;
449     cp_static_data_t *data;
450
451     ConnectionPoint *next;
452 };
453
454 struct HTMLDocument {
455     IHTMLDocument2              IHTMLDocument2_iface;
456     IHTMLDocument3              IHTMLDocument3_iface;
457     IHTMLDocument4              IHTMLDocument4_iface;
458     IHTMLDocument5              IHTMLDocument5_iface;
459     IHTMLDocument6              IHTMLDocument6_iface;
460     IPersistMoniker             IPersistMoniker_iface;
461     IPersistFile                IPersistFile_iface;
462     IPersistHistory             IPersistHistory_iface;
463     IMonikerProp                IMonikerProp_iface;
464     IOleObject                  IOleObject_iface;
465     IOleDocument                IOleDocument_iface;
466     IOleDocumentView            IOleDocumentView_iface;
467     IOleInPlaceActiveObject     IOleInPlaceActiveObject_iface;
468     IViewObjectEx               IViewObjectEx_iface;
469     IOleInPlaceObjectWindowless IOleInPlaceObjectWindowless_iface;
470     IServiceProvider            IServiceProvider_iface;
471     IOleCommandTarget           IOleCommandTarget_iface;
472     IOleControl                 IOleControl_iface;
473     IHlinkTarget                IHlinkTarget_iface;
474     IPersistStreamInit          IPersistStreamInit_iface;
475     IDispatchEx                 IDispatchEx_iface;
476     ISupportErrorInfo           ISupportErrorInfo_iface;
477     IObjectWithSite             IObjectWithSite_iface;
478     IOleContainer               IOleContainer_iface;
479     IObjectSafety               IObjectSafety_iface;
480     IProvideClassInfo           IProvideClassInfo_iface;
481
482     IUnknown *unk_impl;
483     IDispatchEx *dispex;
484
485     HTMLDocumentObj *doc_obj;
486     HTMLDocumentNode *doc_node;
487
488     HTMLOuterWindow *window;
489
490     LONG task_magic;
491
492     ConnectionPointContainer cp_container;
493     ConnectionPoint cp_htmldocevents;
494     ConnectionPoint cp_htmldocevents2;
495     ConnectionPoint cp_propnotif;
496     ConnectionPoint cp_dispatch;
497
498     IOleAdviseHolder *advise_holder;
499 };
500
501 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
502 {
503     return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
504 }
505
506 static inline ULONG htmldoc_addref(HTMLDocument *This)
507 {
508     return IUnknown_AddRef(This->unk_impl);
509 }
510
511 static inline ULONG htmldoc_release(HTMLDocument *This)
512 {
513     return IUnknown_Release(This->unk_impl);
514 }
515
516 struct HTMLDocumentObj {
517     HTMLDocument basedoc;
518     DispatchEx dispex;
519     ICustomDoc ICustomDoc_iface;
520     ITargetContainer ITargetContainer_iface;
521
522     IWindowForBindingUI IWindowForBindingUI_iface;
523
524     LONG ref;
525
526     NSContainer *nscontainer;
527
528     IOleClientSite *client;
529     IDocHostUIHandler *hostui;
530     BOOL custom_hostui;
531     IOleInPlaceSite *ipsite;
532     IOleInPlaceFrame *frame;
533     IOleInPlaceUIWindow *ip_window;
534     IAdviseSink *view_sink;
535     IDocObjectService *doc_object_service;
536
537     DOCHOSTUIINFO hostinfo;
538
539     IOleUndoManager *undomgr;
540
541     HWND hwnd;
542     HWND tooltips_hwnd;
543
544     BOOL request_uiactivate;
545     BOOL in_place_active;
546     BOOL ui_active;
547     BOOL window_active;
548     BOOL hostui_setup;
549     BOOL is_webbrowser;
550     BOOL container_locked;
551     BOOL focus;
552     BOOL has_popup;
553     INT download_state;
554
555     USERMODE usermode;
556     LPWSTR mime;
557
558     DWORD update;
559 };
560
561 typedef struct nsWeakReference nsWeakReference;
562
563 struct NSContainer {
564     nsIWebBrowserChrome      nsIWebBrowserChrome_iface;
565     nsIContextMenuListener   nsIContextMenuListener_iface;
566     nsIURIContentListener    nsIURIContentListener_iface;
567     nsIEmbeddingSiteWindow   nsIEmbeddingSiteWindow_iface;
568     nsITooltipListener       nsITooltipListener_iface;
569     nsIInterfaceRequestor    nsIInterfaceRequestor_iface;
570     nsISupportsWeakReference nsISupportsWeakReference_iface;
571
572     nsIWebBrowser *webbrowser;
573     nsIWebNavigation *navigation;
574     nsIBaseWindow *window;
575     nsIWebBrowserFocus *focus;
576
577     nsIEditor *editor;
578     nsIController *editor_controller;
579
580     LONG ref;
581
582     nsWeakReference *weak_reference;
583
584     NSContainer *parent;
585     HTMLDocumentObj *doc;
586
587     nsIURIContentListener *content_listener;
588
589     HWND hwnd;
590 };
591
592 typedef struct {
593     HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
594     void (*destructor)(HTMLDOMNode*);
595     HRESULT (*clone)(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
596     HRESULT (*handle_event)(HTMLDOMNode*,DWORD,nsIDOMEvent*,BOOL*);
597     HRESULT (*get_attr_col)(HTMLDOMNode*,HTMLAttributeCollection**);
598     event_target_t **(*get_event_target)(HTMLDOMNode*);
599     HRESULT (*fire_event)(HTMLDOMNode*,DWORD,BOOL*);
600     HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
601     HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
602     HRESULT (*get_document)(HTMLDOMNode*,IDispatch**);
603     HRESULT (*get_readystate)(HTMLDOMNode*,BSTR*);
604     HRESULT (*get_dispid)(HTMLDOMNode*,BSTR,DWORD,DISPID*);
605     HRESULT (*invoke)(HTMLDOMNode*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
606     HRESULT (*bind_to_tree)(HTMLDOMNode*);
607     void (*traverse)(HTMLDOMNode*,nsCycleCollectionTraversalCallback*);
608     void (*unlink)(HTMLDOMNode*);
609 } NodeImplVtbl;
610
611 struct HTMLDOMNode {
612     DispatchEx dispex;
613     IHTMLDOMNode  IHTMLDOMNode_iface;
614     IHTMLDOMNode2 IHTMLDOMNode2_iface;
615     const NodeImplVtbl *vtbl;
616
617     nsCycleCollectingAutoRefCnt ccref;
618
619     nsIDOMNode *nsnode;
620     HTMLDocumentNode *doc;
621     event_target_t *event_target;
622     ConnectionPointContainer *cp_container;
623 };
624
625 static inline void node_addref(HTMLDOMNode *node)
626 {
627     IHTMLDOMNode_AddRef(&node->IHTMLDOMNode_iface);
628 }
629
630 static inline void node_release(HTMLDOMNode *node)
631 {
632     IHTMLDOMNode_Release(&node->IHTMLDOMNode_iface);
633 }
634
635 typedef struct {
636     HTMLDOMNode node;
637     ConnectionPointContainer cp_container;
638
639     IHTMLElement  IHTMLElement_iface;
640     IHTMLElement2 IHTMLElement2_iface;
641     IHTMLElement3 IHTMLElement3_iface;
642     IHTMLElement4 IHTMLElement4_iface;
643
644     nsIDOMHTMLElement *nselem;
645     HTMLStyle *style;
646     HTMLStyle *runtime_style;
647     HTMLAttributeCollection *attrs;
648     WCHAR *filter;
649 } HTMLElement;
650
651 #define HTMLELEMENT_TIDS    \
652     IHTMLDOMNode_tid,       \
653     IHTMLDOMNode2_tid,      \
654     IHTMLElement_tid,       \
655     IHTMLElement2_tid,      \
656     IHTMLElement3_tid,      \
657     IHTMLElement4_tid
658
659 typedef struct {
660     HTMLElement element;
661
662     IHTMLTextContainer IHTMLTextContainer_iface;
663
664     ConnectionPoint cp;
665 } HTMLTextContainer;
666
667 struct HTMLFrameBase {
668     HTMLElement element;
669
670     IHTMLFrameBase  IHTMLFrameBase_iface;
671     IHTMLFrameBase2 IHTMLFrameBase2_iface;
672
673     HTMLOuterWindow *content_window;
674
675     nsIDOMHTMLFrameElement *nsframe;
676     nsIDOMHTMLIFrameElement *nsiframe;
677 };
678
679 typedef struct nsDocumentEventListener nsDocumentEventListener;
680
681 struct HTMLDocumentNode {
682     HTMLDOMNode node;
683     HTMLDocument basedoc;
684
685     IInternetHostSecurityManager IInternetHostSecurityManager_iface;
686
687     nsIDocumentObserver          nsIDocumentObserver_iface;
688
689     LONG ref;
690
691     HTMLInnerWindow *window;
692
693     nsIDOMHTMLDocument *nsdoc;
694     nsIDOMNodeSelector *nsnode_selector;
695     BOOL content_ready;
696     event_target_t *body_event_target;
697
698     ICatInformation *catmgr;
699     nsDocumentEventListener *nsevent_listener;
700     BOOL *event_vector;
701
702     WCHAR **elem_vars;
703     unsigned elem_vars_size;
704     unsigned elem_vars_cnt;
705
706     BOOL skip_mutation_notif;
707
708     struct list selection_list;
709     struct list range_list;
710     struct list plugin_hosts;
711 };
712
713 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
714 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
715 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLInnerWindow*,HTMLDocumentNode**) DECLSPEC_HIDDEN;
716 HRESULT create_document_fragment(nsIDOMNode*,HTMLDocumentNode*,HTMLDocumentNode**) DECLSPEC_HIDDEN;
717
718 HRESULT HTMLOuterWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLOuterWindow*,HTMLOuterWindow**) DECLSPEC_HIDDEN;
719 HRESULT update_window_doc(HTMLInnerWindow*) DECLSPEC_HIDDEN;
720 HTMLOuterWindow *nswindow_to_window(const nsIDOMWindow*) DECLSPEC_HIDDEN;
721 void get_top_window(HTMLOuterWindow*,HTMLOuterWindow**) DECLSPEC_HIDDEN;
722 HRESULT HTMLOptionElementFactory_Create(HTMLInnerWindow*,HTMLOptionElementFactory**) DECLSPEC_HIDDEN;
723 HRESULT HTMLImageElementFactory_Create(HTMLInnerWindow*,HTMLImageElementFactory**) DECLSPEC_HIDDEN;
724 HRESULT HTMLLocation_Create(HTMLInnerWindow*,HTMLLocation**) DECLSPEC_HIDDEN;
725 IOmNavigator *OmNavigator_Create(void) DECLSPEC_HIDDEN;
726 HRESULT HTMLScreen_Create(IHTMLScreen**) DECLSPEC_HIDDEN;
727 HRESULT create_history(IOmHistory**) DECLSPEC_HIDDEN;
728
729 HRESULT create_storage(IHTMLStorage**) DECLSPEC_HIDDEN;
730
731 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*) DECLSPEC_HIDDEN;
732 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*) DECLSPEC_HIDDEN;
733 void HTMLDocument_Persist_Init(HTMLDocument*) DECLSPEC_HIDDEN;
734 void HTMLDocument_OleCmd_Init(HTMLDocument*) DECLSPEC_HIDDEN;
735 void HTMLDocument_OleObj_Init(HTMLDocument*) DECLSPEC_HIDDEN;
736 void HTMLDocument_View_Init(HTMLDocument*) DECLSPEC_HIDDEN;
737 void HTMLDocument_Window_Init(HTMLDocument*) DECLSPEC_HIDDEN;
738 void HTMLDocument_Service_Init(HTMLDocument*) DECLSPEC_HIDDEN;
739 void HTMLDocument_Hlink_Init(HTMLDocument*) DECLSPEC_HIDDEN;
740
741 void TargetContainer_Init(HTMLDocumentObj*) DECLSPEC_HIDDEN;
742 void init_binding_ui(HTMLDocumentObj*) DECLSPEC_HIDDEN;
743
744 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*) DECLSPEC_HIDDEN;
745
746 typedef struct {
747     HTMLElement element;
748
749     IHTMLScriptElement IHTMLScriptElement_iface;
750
751     nsIDOMHTMLScriptElement *nsscript;
752     BOOL parsed;
753 } HTMLScriptElement;
754
755 HRESULT script_elem_from_nsscript(HTMLDocumentNode*,nsIDOMHTMLScriptElement*,HTMLScriptElement**) DECLSPEC_HIDDEN;
756 void bind_event_scripts(HTMLDocumentNode*) DECLSPEC_HIDDEN;
757
758 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**) DECLSPEC_HIDDEN;
759
760 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*) DECLSPEC_HIDDEN;
761 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*) DECLSPEC_HIDDEN;
762 void ConnectionPointContainer_Destroy(ConnectionPointContainer*) DECLSPEC_HIDDEN;
763
764 HRESULT create_nscontainer(HTMLDocumentObj*,NSContainer**) DECLSPEC_HIDDEN;
765 void NSContainer_Release(NSContainer*) DECLSPEC_HIDDEN;
766
767 void init_mutation(nsIComponentManager*) DECLSPEC_HIDDEN;
768 void init_document_mutation(HTMLDocumentNode*) DECLSPEC_HIDDEN;
769 void release_document_mutation(HTMLDocumentNode*) DECLSPEC_HIDDEN;
770
771 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL) DECLSPEC_HIDDEN;
772 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*) DECLSPEC_HIDDEN;
773 void notif_focus(HTMLDocumentObj*) DECLSPEC_HIDDEN;
774
775 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR) DECLSPEC_HIDDEN;
776 void hide_tooltip(HTMLDocumentObj*) DECLSPEC_HIDDEN;
777 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*) DECLSPEC_HIDDEN;
778
779 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**) DECLSPEC_HIDDEN;
780
781 BOOL load_gecko(void) DECLSPEC_HIDDEN;
782 void close_gecko(void) DECLSPEC_HIDDEN;
783 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*) DECLSPEC_HIDDEN;
784 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*) DECLSPEC_HIDDEN;
785 void release_nsio(void) DECLSPEC_HIDDEN;
786 BOOL is_gecko_path(const char*) DECLSPEC_HIDDEN;
787
788 void init_node_cc(void);
789
790 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*) DECLSPEC_HIDDEN;
791 BOOL compare_ignoring_frag(IUri*,IUri*) DECLSPEC_HIDDEN;
792
793 HRESULT navigate_url(HTMLOuterWindow*,const WCHAR*,IUri*) DECLSPEC_HIDDEN;
794 HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*) DECLSPEC_HIDDEN;
795
796 void call_property_onchanged(ConnectionPoint*,DISPID) DECLSPEC_HIDDEN;
797 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*) DECLSPEC_HIDDEN;
798
799 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1) DECLSPEC_HIDDEN;
800 void nsfree(void*) DECLSPEC_HIDDEN;
801
802 void nsACString_InitDepend(nsACString*,const char*) DECLSPEC_HIDDEN;
803 void nsACString_SetData(nsACString*,const char*) DECLSPEC_HIDDEN;
804 PRUint32 nsACString_GetData(const nsACString*,const char**) DECLSPEC_HIDDEN;
805 void nsACString_Finish(nsACString*) DECLSPEC_HIDDEN;
806
807 BOOL nsAString_Init(nsAString*,const PRUnichar*) DECLSPEC_HIDDEN;
808 void nsAString_InitDepend(nsAString*,const PRUnichar*) DECLSPEC_HIDDEN;
809 void nsAString_SetData(nsAString*,const PRUnichar*) DECLSPEC_HIDDEN;
810 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**) DECLSPEC_HIDDEN;
811 void nsAString_Finish(nsAString*) DECLSPEC_HIDDEN;
812 HRESULT return_nsstr(nsresult,nsAString*,BSTR*) DECLSPEC_HIDDEN;
813
814 nsICommandParams *create_nscommand_params(void) DECLSPEC_HIDDEN;
815 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*) DECLSPEC_HIDDEN;
816 void get_editor_controller(NSContainer*) DECLSPEC_HIDDEN;
817 nsresult get_nsinterface(nsISupports*,REFIID,void**) DECLSPEC_HIDDEN;
818 nsIWritableVariant *create_nsvariant(void) DECLSPEC_HIDDEN;
819 nsresult create_nsfile(const PRUnichar*,nsIFile**) DECLSPEC_HIDDEN;
820
821 HRESULT create_pending_window(HTMLOuterWindow*,nsChannelBSC*) DECLSPEC_HIDDEN;
822 void set_current_mon(HTMLOuterWindow*,IMoniker*) DECLSPEC_HIDDEN;
823 void set_current_uri(HTMLOuterWindow*,IUri*) DECLSPEC_HIDDEN;
824 HRESULT start_binding(HTMLInnerWindow*,BSCallback*,IBindCtx*) DECLSPEC_HIDDEN;
825 HRESULT async_start_doc_binding(HTMLOuterWindow*,HTMLInnerWindow*) DECLSPEC_HIDDEN;
826 void abort_window_bindings(HTMLInnerWindow*) DECLSPEC_HIDDEN;
827 void set_download_state(HTMLDocumentObj*,int) DECLSPEC_HIDDEN;
828 void call_docview_84(HTMLDocumentObj*) DECLSPEC_HIDDEN;
829
830 void set_ready_state(HTMLOuterWindow*,READYSTATE) DECLSPEC_HIDDEN;
831
832 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**) DECLSPEC_HIDDEN;
833 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**) DECLSPEC_HIDDEN;
834 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*) DECLSPEC_HIDDEN;
835 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*) DECLSPEC_HIDDEN;
836
837 void detach_selection(HTMLDocumentNode*) DECLSPEC_HIDDEN;
838 void detach_ranges(HTMLDocumentNode*) DECLSPEC_HIDDEN;
839 HRESULT get_node_text(HTMLDOMNode*,BSTR*) DECLSPEC_HIDDEN;
840 HRESULT replace_node_by_html(nsIDOMHTMLDocument*,nsIDOMNode*,const WCHAR*) DECLSPEC_HIDDEN;
841
842 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**) DECLSPEC_HIDDEN;
843 HRESULT create_element(HTMLDocumentNode*,const WCHAR*,HTMLElement**) DECLSPEC_HIDDEN;
844
845 HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**) DECLSPEC_HIDDEN;
846
847 struct HTMLAttributeCollection {
848     DispatchEx dispex;
849     IHTMLAttributeCollection IHTMLAttributeCollection_iface;
850     IHTMLAttributeCollection2 IHTMLAttributeCollection2_iface;
851     IHTMLAttributeCollection3 IHTMLAttributeCollection3_iface;
852
853     LONG ref;
854
855     HTMLElement *elem;
856     struct list attrs;
857 };
858
859 typedef struct {
860     DispatchEx dispex;
861     IHTMLDOMAttribute IHTMLDOMAttribute_iface;
862
863     LONG ref;
864
865     DISPID dispid;
866     HTMLElement *elem;
867     struct list entry;
868 } HTMLDOMAttribute;
869
870 HRESULT HTMLDOMAttribute_Create(HTMLElement*,DISPID,HTMLDOMAttribute**) DECLSPEC_HIDDEN;
871
872 HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**) DECLSPEC_HIDDEN;
873 HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**) DECLSPEC_HIDDEN;
874 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
875 HRESULT HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
876 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
877 HRESULT HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
878 HRESULT HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
879 HRESULT HTMLHeadElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
880 HRESULT HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
881 HRESULT HTMLStyleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
882 HRESULT HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
883 HRESULT HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
884 HRESULT HTMLLinkElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
885 HRESULT HTMLMetaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
886 HRESULT HTMLObjectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
887 HRESULT HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
888 HRESULT HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
889 HRESULT HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
890 HRESULT HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
891 HRESULT HTMLTableCell_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
892 HRESULT HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
893 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
894 HRESULT HTMLTitleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
895 HRESULT HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN;
896
897 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*) DECLSPEC_HIDDEN;
898 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*) DECLSPEC_HIDDEN;
899 void HTMLElement2_Init(HTMLElement*) DECLSPEC_HIDDEN;
900 void HTMLElement3_Init(HTMLElement*) DECLSPEC_HIDDEN;
901 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*) DECLSPEC_HIDDEN;
902 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*) DECLSPEC_HIDDEN;
903
904 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**) DECLSPEC_HIDDEN;
905 void HTMLDOMNode_destructor(HTMLDOMNode*) DECLSPEC_HIDDEN;
906
907 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**) DECLSPEC_HIDDEN;
908 void HTMLElement_destructor(HTMLDOMNode*) DECLSPEC_HIDDEN;
909 HRESULT HTMLElement_clone(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**) DECLSPEC_HIDDEN;
910 HRESULT HTMLElement_get_attr_col(HTMLDOMNode*,HTMLAttributeCollection**) DECLSPEC_HIDDEN;
911 HRESULT HTMLElement_handle_event(HTMLDOMNode*,DWORD,nsIDOMEvent*,BOOL*) DECLSPEC_HIDDEN;
912
913 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**) DECLSPEC_HIDDEN;
914 void HTMLFrameBase_destructor(HTMLFrameBase*) DECLSPEC_HIDDEN;
915
916 HRESULT get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLDOMNode**) DECLSPEC_HIDDEN;
917 HRESULT get_elem(HTMLDocumentNode*,nsIDOMElement*,HTMLElement**) DECLSPEC_HIDDEN;
918
919 HTMLElement *unsafe_impl_from_IHTMLElement(IHTMLElement*) DECLSPEC_HIDDEN;
920
921 void release_script_hosts(HTMLInnerWindow*) DECLSPEC_HIDDEN;
922 void connect_scripts(HTMLInnerWindow*) DECLSPEC_HIDDEN;
923 void doc_insert_script(HTMLInnerWindow*,HTMLScriptElement*) DECLSPEC_HIDDEN;
924 IDispatch *script_parse_event(HTMLInnerWindow*,LPCWSTR) DECLSPEC_HIDDEN;
925 HRESULT exec_script(HTMLInnerWindow*,const WCHAR*,const WCHAR*,VARIANT*) DECLSPEC_HIDDEN;
926 void set_script_mode(HTMLOuterWindow*,SCRIPTMODE) DECLSPEC_HIDDEN;
927 BOOL find_global_prop(HTMLInnerWindow*,BSTR,DWORD,ScriptHost**,DISPID*) DECLSPEC_HIDDEN;
928 IDispatch *get_script_disp(ScriptHost*) DECLSPEC_HIDDEN;
929 HRESULT search_window_props(HTMLInnerWindow*,BSTR,DWORD,DISPID*) DECLSPEC_HIDDEN;
930 HRESULT get_frame_by_name(HTMLOuterWindow*,const WCHAR*,BOOL,HTMLOuterWindow**) DECLSPEC_HIDDEN;
931 HRESULT get_doc_elem_by_id(HTMLDocumentNode*,const WCHAR*,HTMLElement**) DECLSPEC_HIDDEN;
932
933 HRESULT wrap_iface(IUnknown*,IUnknown*,IUnknown**) DECLSPEC_HIDDEN;
934
935 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL) DECLSPEC_HIDDEN;
936 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,nsIDOMNodeList*) DECLSPEC_HIDDEN;
937 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,nsIDOMHTMLCollection*) DECLSPEC_HIDDEN;
938
939 /* commands */
940 typedef struct {
941     DWORD id;
942     HRESULT (*query)(HTMLDocument*,OLECMD*);
943     HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
944 } cmdtable_t;
945
946 extern const cmdtable_t editmode_cmds[] DECLSPEC_HIDDEN;
947
948 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*) DECLSPEC_HIDDEN;
949
950 /* timer */
951 #define UPDATE_UI       0x0001
952 #define UPDATE_TITLE    0x0002
953
954 void update_doc(HTMLDocument*,DWORD) DECLSPEC_HIDDEN;
955 void update_title(HTMLDocumentObj*) DECLSPEC_HIDDEN;
956
957 HRESULT do_query_service(IUnknown*,REFGUID,REFIID,void**) DECLSPEC_HIDDEN;
958
959 /* editor */
960 void init_editor(HTMLDocument*) DECLSPEC_HIDDEN;
961 void handle_edit_event(HTMLDocument*,nsIDOMEvent*) DECLSPEC_HIDDEN;
962 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
963 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
964 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*) DECLSPEC_HIDDEN;
965 void handle_edit_load(HTMLDocument*) DECLSPEC_HIDDEN;
966 HRESULT editor_is_dirty(HTMLDocument*) DECLSPEC_HIDDEN;
967 void set_dirty(HTMLDocument*,VARIANT_BOOL) DECLSPEC_HIDDEN;
968
969 extern DWORD mshtml_tls DECLSPEC_HIDDEN;
970
971 typedef struct task_t task_t;
972 typedef void (*task_proc_t)(task_t*);
973
974 struct task_t {
975     LONG target_magic;
976     task_proc_t proc;
977     task_proc_t destr;
978     struct task_t *next;
979 };
980
981 typedef struct {
982     task_t header;
983     HTMLDocumentObj *doc;
984 } docobj_task_t;
985
986 typedef struct {
987     HWND thread_hwnd;
988     task_t *task_queue_head;
989     task_t *task_queue_tail;
990     struct list timer_list;
991 } thread_data_t;
992
993 thread_data_t *get_thread_data(BOOL) DECLSPEC_HIDDEN;
994 HWND get_thread_hwnd(void) DECLSPEC_HIDDEN;
995
996 LONG get_task_target_magic(void) DECLSPEC_HIDDEN;
997 void push_task(task_t*,task_proc_t,task_proc_t,LONG) DECLSPEC_HIDDEN;
998 void remove_target_tasks(LONG) DECLSPEC_HIDDEN;
999
1000 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*) DECLSPEC_HIDDEN;
1001 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD) DECLSPEC_HIDDEN;
1002
1003 const char *debugstr_variant(const VARIANT*) DECLSPEC_HIDDEN;
1004
1005 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
1006 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
1007 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
1008 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
1009 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
1010
1011 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
1012
1013 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
1014
1015 DEFINE_GUID(CLSID_JScript, 0xf414c260,0x6ac0,0x11cf, 0xb6,0xd1,0x00,0xaa,0x00,0xbb,0xbb,0x58);
1016 DEFINE_GUID(CLSID_VBScript, 0xb54f3741,0x5b07,0x11cf, 0xa4,0xb0,0x00,0xaa,0x00,0x4a,0x55,0xe8);
1017
1018 /* memory allocation functions */
1019
1020 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
1021 {
1022     return HeapAlloc(GetProcessHeap(), 0, len);
1023 }
1024
1025 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
1026 {
1027     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
1028 }
1029
1030 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
1031 {
1032     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
1033 }
1034
1035 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
1036 {
1037     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
1038 }
1039
1040 static inline BOOL heap_free(void *mem)
1041 {
1042     return HeapFree(GetProcessHeap(), 0, mem);
1043 }
1044
1045 static inline LPWSTR heap_strdupW(LPCWSTR str)
1046 {
1047     LPWSTR ret = NULL;
1048
1049     if(str) {
1050         DWORD size;
1051
1052         size = (strlenW(str)+1)*sizeof(WCHAR);
1053         ret = heap_alloc(size);
1054         memcpy(ret, str, size);
1055     }
1056
1057     return ret;
1058 }
1059
1060 static inline LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
1061 {
1062     LPWSTR ret = NULL;
1063
1064     if(str) {
1065         ret = heap_alloc((len+1)*sizeof(WCHAR));
1066         memcpy(ret, str, len*sizeof(WCHAR));
1067         ret[len] = 0;
1068     }
1069
1070     return ret;
1071 }
1072
1073 static inline char *heap_strdupA(const char *str)
1074 {
1075     char *ret = NULL;
1076
1077     if(str) {
1078         DWORD size;
1079
1080         size = strlen(str)+1;
1081         ret = heap_alloc(size);
1082         memcpy(ret, str, size);
1083     }
1084
1085     return ret;
1086 }
1087
1088 static inline WCHAR *heap_strdupAtoW(const char *str)
1089 {
1090     LPWSTR ret = NULL;
1091
1092     if(str) {
1093         DWORD len;
1094
1095         len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
1096         ret = heap_alloc(len*sizeof(WCHAR));
1097         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
1098     }
1099
1100     return ret;
1101 }
1102
1103 static inline char *heap_strdupWtoA(LPCWSTR str)
1104 {
1105     char *ret = NULL;
1106
1107     if(str) {
1108         DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
1109         ret = heap_alloc(size);
1110         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
1111     }
1112
1113     return ret;
1114 }
1115
1116 static inline void windowref_addref(windowref_t *ref)
1117 {
1118     InterlockedIncrement(&ref->ref);
1119 }
1120
1121 static inline void windowref_release(windowref_t *ref)
1122 {
1123     if(!InterlockedDecrement(&ref->ref))
1124         heap_free(ref);
1125 }
1126
1127 HDC get_display_dc(void) DECLSPEC_HIDDEN;
1128 HINSTANCE get_shdoclc(void) DECLSPEC_HIDDEN;
1129 void set_statustext(HTMLDocumentObj*,INT,LPCWSTR) DECLSPEC_HIDDEN;
1130
1131 extern HINSTANCE hInst DECLSPEC_HIDDEN;