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