mshtml: Allow post data and headers to be passed to create_channelbsc.
[wine/hacks.git] / dlls / mshtml / mshtml_private.h
blobbf6561c200d906d57dd49bc945fbe9796863911a
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
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.
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.
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
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"
28 #include "wine/list.h"
29 #include "wine/unicode.h"
31 #ifdef INIT_GUID
32 #include "initguid.h"
33 #endif
35 #include "nsiface.h"
37 #define NS_OK ((nsresult)0x00000000L)
38 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
39 #define NS_NOINTERFACE ((nsresult)0x80004002L)
40 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
41 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
42 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
43 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
45 #define NS_FAILED(res) ((res) & 0x80000000)
46 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
48 #define NSAPI WINAPI
50 #define MSHTML_E_NODOC 0x800a025c
52 typedef struct HTMLDOMNode HTMLDOMNode;
53 typedef struct ConnectionPoint ConnectionPoint;
54 typedef struct BSCallback BSCallback;
55 typedef struct event_target_t event_target_t;
57 /* NOTE: make sure to keep in sync with dispex.c */
58 typedef enum {
59 NULL_tid,
60 DispCEventObj_tid,
61 DispDOMChildrenCollection_tid,
62 DispHTMLAnchorElement_tid,
63 DispHTMLBody_tid,
64 DispHTMLCommentElement_tid,
65 DispHTMLCurrentStyle_tid,
66 DispHTMLDocument_tid,
67 DispHTMLDOMTextNode_tid,
68 DispHTMLElementCollection_tid,
69 DispHTMLFormElement_tid,
70 DispHTMLGenericElement_tid,
71 DispHTMLFrameElement_tid,
72 DispHTMLIFrame_tid,
73 DispHTMLImg_tid,
74 DispHTMLInputElement_tid,
75 DispHTMLLocation_tid,
76 DispHTMLNavigator_tid,
77 DispHTMLOptionElement_tid,
78 DispHTMLScreen_tid,
79 DispHTMLScriptElement_tid,
80 DispHTMLSelectElement_tid,
81 DispHTMLStyle_tid,
82 DispHTMLTable_tid,
83 DispHTMLTableRow_tid,
84 DispHTMLTextAreaElement_tid,
85 DispHTMLUnknownElement_tid,
86 DispHTMLWindow2_tid,
87 HTMLDocumentEvents_tid,
88 IHTMLAnchorElement_tid,
89 IHTMLBodyElement_tid,
90 IHTMLBodyElement2_tid,
91 IHTMLCommentElement_tid,
92 IHTMLCurrentStyle_tid,
93 IHTMLCurrentStyle2_tid,
94 IHTMLCurrentStyle3_tid,
95 IHTMLCurrentStyle4_tid,
96 IHTMLDocument2_tid,
97 IHTMLDocument3_tid,
98 IHTMLDocument4_tid,
99 IHTMLDocument5_tid,
100 IHTMLDOMChildrenCollection_tid,
101 IHTMLDOMNode_tid,
102 IHTMLDOMNode2_tid,
103 IHTMLDOMTextNode_tid,
104 IHTMLElement_tid,
105 IHTMLElement2_tid,
106 IHTMLElement3_tid,
107 IHTMLElement4_tid,
108 IHTMLElementCollection_tid,
109 IHTMLEventObj_tid,
110 IHTMLFiltersCollection_tid,
111 IHTMLFormElement_tid,
112 IHTMLFrameBase_tid,
113 IHTMLFrameBase2_tid,
114 IHTMLFrameElement3_tid,
115 IHTMLGenericElement_tid,
116 IHTMLIFrameElement_tid,
117 IHTMLImageElementFactory_tid,
118 IHTMLImgElement_tid,
119 IHTMLInputElement_tid,
120 IHTMLLocation_tid,
121 IHTMLOptionElement_tid,
122 IHTMLScreen_tid,
123 IHTMLScriptElement_tid,
124 IHTMLSelectElement_tid,
125 IHTMLStyle_tid,
126 IHTMLStyle2_tid,
127 IHTMLStyle3_tid,
128 IHTMLStyle4_tid,
129 IHTMLTable_tid,
130 IHTMLTableRow_tid,
131 IHTMLTextAreaElement_tid,
132 IHTMLTextContainer_tid,
133 IHTMLUniqueName_tid,
134 IHTMLWindow2_tid,
135 IHTMLWindow3_tid,
136 IHTMLWindow4_tid,
137 IOmNavigator_tid,
138 LAST_tid
139 } tid_t;
141 typedef struct dispex_data_t dispex_data_t;
142 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
144 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
145 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
147 typedef struct {
148 HRESULT (*value)(IUnknown*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
149 HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
150 HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
151 } dispex_static_data_vtbl_t;
153 typedef struct {
154 const dispex_static_data_vtbl_t *vtbl;
155 const tid_t disp_tid;
156 dispex_data_t *data;
157 const tid_t* const iface_tids;
158 } dispex_static_data_t;
160 typedef struct {
161 const IDispatchExVtbl *lpIDispatchExVtbl;
163 IUnknown *outer;
165 dispex_static_data_t *data;
166 dispex_dynamic_data_t *dynamic_data;
167 } DispatchEx;
169 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
170 void release_dispex(DispatchEx*);
171 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
172 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
173 HRESULT get_dispids(tid_t,DWORD*,DISPID**);
175 typedef struct HTMLWindow HTMLWindow;
176 typedef struct HTMLDocumentNode HTMLDocumentNode;
177 typedef struct HTMLDocumentObj HTMLDocumentObj;
178 typedef struct HTMLFrameBase HTMLFrameBase;
179 typedef struct NSContainer NSContainer;
181 typedef enum {
182 SCRIPTMODE_GECKO,
183 SCRIPTMODE_ACTIVESCRIPT
184 } SCRIPTMODE;
186 typedef struct ScriptHost ScriptHost;
188 typedef enum {
189 GLOBAL_SCRIPTVAR,
190 GLOBAL_ELEMENTVAR
191 } global_prop_type_t;
193 typedef struct {
194 global_prop_type_t type;
195 WCHAR *name;
196 ScriptHost *script_host;
197 DISPID id;
198 } global_prop_t;
200 typedef struct {
201 const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
203 LONG ref;
205 HTMLWindow *window;
206 } HTMLOptionElementFactory;
208 typedef struct {
209 DispatchEx dispex;
210 const IHTMLImageElementFactoryVtbl *lpHTMLImageElementFactoryVtbl;
212 LONG ref;
214 HTMLWindow *window;
215 } HTMLImageElementFactory;
217 struct HTMLLocation {
218 DispatchEx dispex;
219 const IHTMLLocationVtbl *lpHTMLLocationVtbl;
221 LONG ref;
223 HTMLWindow *window;
226 typedef struct {
227 HTMLWindow *window;
228 LONG ref;
229 } windowref_t;
231 typedef struct nsChannelBSC nsChannelBSC;
233 struct HTMLWindow {
234 DispatchEx dispex;
235 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
236 const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
237 const IHTMLWindow4Vtbl *lpHTMLWindow4Vtbl;
238 const IHTMLPrivateWindowVtbl *lpIHTMLPrivateWindowVtbl;
239 const IDispatchExVtbl *lpIDispatchExVtbl;
241 LONG ref;
243 windowref_t *window_ref;
244 LONG task_magic;
246 HTMLDocumentNode *doc;
247 HTMLDocumentObj *doc_obj;
248 nsIDOMWindow *nswindow;
249 HTMLWindow *parent;
250 HTMLFrameBase *frame_element;
251 READYSTATE readystate;
253 nsChannelBSC *bscallback;
254 IMoniker *mon;
255 LPOLESTR url;
257 IHTMLEventObj *event;
259 SCRIPTMODE scriptmode;
260 struct list script_hosts;
262 HTMLOptionElementFactory *option_factory;
263 HTMLImageElementFactory *image_factory;
264 HTMLLocation *location;
265 IHTMLScreen *screen;
267 global_prop_t *global_props;
268 DWORD global_prop_cnt;
269 DWORD global_prop_size;
271 struct list children;
272 struct list sibling_entry;
273 struct list entry;
276 typedef enum {
277 UNKNOWN_USERMODE,
278 BROWSEMODE,
279 EDITMODE
280 } USERMODE;
282 typedef struct _cp_static_data_t {
283 tid_t tid;
284 void (*on_advise)(IUnknown*,struct _cp_static_data_t*);
285 DWORD id_cnt;
286 DISPID *ids;
287 } cp_static_data_t;
289 typedef struct ConnectionPointContainer {
290 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
292 ConnectionPoint *cp_list;
293 IUnknown *outer;
294 struct ConnectionPointContainer *forward_container;
295 } ConnectionPointContainer;
297 struct ConnectionPoint {
298 const IConnectionPointVtbl *lpConnectionPointVtbl;
300 ConnectionPointContainer *container;
302 union {
303 IUnknown *unk;
304 IDispatch *disp;
305 IPropertyNotifySink *propnotif;
306 } *sinks;
307 DWORD sinks_size;
309 const IID *iid;
310 cp_static_data_t *data;
312 ConnectionPoint *next;
315 struct HTMLDocument {
316 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
317 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
318 const IHTMLDocument4Vtbl *lpHTMLDocument4Vtbl;
319 const IHTMLDocument5Vtbl *lpHTMLDocument5Vtbl;
320 const IHTMLDocument6Vtbl *lpHTMLDocument6Vtbl;
321 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
322 const IPersistFileVtbl *lpPersistFileVtbl;
323 const IPersistHistoryVtbl *lpPersistHistoryVtbl;
324 const IMonikerPropVtbl *lpMonikerPropVtbl;
325 const IOleObjectVtbl *lpOleObjectVtbl;
326 const IOleDocumentVtbl *lpOleDocumentVtbl;
327 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
328 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
329 const IViewObjectExVtbl *lpViewObjectExVtbl;
330 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
331 const IServiceProviderVtbl *lpServiceProviderVtbl;
332 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
333 const IOleControlVtbl *lpOleControlVtbl;
334 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
335 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
336 const IDispatchExVtbl *lpIDispatchExVtbl;
337 const ISupportErrorInfoVtbl *lpSupportErrorInfoVtbl;
338 const IObjectWithSiteVtbl *lpObjectWithSiteVtbl;
340 IUnknown *unk_impl;
341 IDispatchEx *dispex;
343 HTMLDocumentObj *doc_obj;
344 HTMLDocumentNode *doc_node;
346 HTMLWindow *window;
348 LONG task_magic;
350 ConnectionPointContainer cp_container;
351 ConnectionPoint cp_htmldocevents;
352 ConnectionPoint cp_htmldocevents2;
353 ConnectionPoint cp_propnotif;
354 ConnectionPoint cp_dispatch;
356 IOleAdviseHolder *advise_holder;
359 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
361 return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
364 static inline ULONG htmldoc_addref(HTMLDocument *This)
366 return IUnknown_AddRef(This->unk_impl);
369 static inline ULONG htmldoc_release(HTMLDocument *This)
371 return IUnknown_Release(This->unk_impl);
374 struct HTMLDocumentObj {
375 HTMLDocument basedoc;
376 DispatchEx dispex;
377 const ICustomDocVtbl *lpCustomDocVtbl;
379 LONG ref;
381 NSContainer *nscontainer;
383 IOleClientSite *client;
384 IDocHostUIHandler *hostui;
385 IOleInPlaceSite *ipsite;
386 IOleInPlaceFrame *frame;
387 IOleInPlaceUIWindow *ip_window;
388 IAdviseSink *view_sink;
390 DOCHOSTUIINFO hostinfo;
392 IOleUndoManager *undomgr;
394 HWND hwnd;
395 HWND tooltips_hwnd;
397 BOOL request_uiactivate;
398 BOOL in_place_active;
399 BOOL ui_active;
400 BOOL window_active;
401 BOOL has_key_path;
402 BOOL container_locked;
403 BOOL focus;
404 INT download_state;
406 USERMODE usermode;
407 LPWSTR mime;
409 DWORD update;
412 struct NSContainer {
413 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
414 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
415 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
416 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
417 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
418 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
419 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
420 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
422 nsIWebBrowser *webbrowser;
423 nsIWebNavigation *navigation;
424 nsIBaseWindow *window;
425 nsIWebBrowserFocus *focus;
427 nsIEditor *editor;
428 nsIController *editor_controller;
430 LONG ref;
432 NSContainer *parent;
433 HTMLDocumentObj *doc;
435 nsIURIContentListener *content_listener;
437 HWND hwnd;
439 HWND reset_focus; /* hack */
442 typedef struct nsWineURI nsWineURI;
444 HRESULT set_wine_url(nsWineURI*,LPCWSTR);
445 nsresult on_start_uri_open(NSContainer*,nsIURI*,PRBool*);
447 typedef struct {
448 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
449 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
450 const nsIHttpChannelInternalVtbl *lpIHttpChannelInternalVtbl;
452 LONG ref;
454 nsWineURI *uri;
455 nsIInputStream *post_data_stream;
456 nsILoadGroup *load_group;
457 nsIInterfaceRequestor *notif_callback;
458 nsISupports *owner;
459 nsLoadFlags load_flags;
460 nsIURI *original_uri;
461 char *content_type;
462 char *charset;
463 PRUint32 response_status;
464 UINT url_scheme;
465 } nsChannel;
467 typedef struct {
468 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
469 void (*destructor)(HTMLDOMNode*);
470 event_target_t **(*get_event_target)(HTMLDOMNode*);
471 HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
472 HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
473 HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
474 HRESULT (*get_document)(HTMLDOMNode*,IDispatch**);
475 HRESULT (*get_readystate)(HTMLDOMNode*,BSTR*);
476 HRESULT (*get_dispid)(HTMLDOMNode*,BSTR,DWORD,DISPID*);
477 HRESULT (*invoke)(HTMLDOMNode*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
478 HRESULT (*bind_to_tree)(HTMLDOMNode*);
479 } NodeImplVtbl;
481 struct HTMLDOMNode {
482 DispatchEx dispex;
483 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
484 const IHTMLDOMNode2Vtbl *lpHTMLDOMNode2Vtbl;
485 const NodeImplVtbl *vtbl;
487 LONG ref;
489 nsIDOMNode *nsnode;
490 HTMLDocumentNode *doc;
491 event_target_t *event_target;
492 ConnectionPointContainer *cp_container;
494 HTMLDOMNode *next;
497 typedef struct {
498 HTMLDOMNode node;
499 ConnectionPointContainer cp_container;
501 const IHTMLElementVtbl *lpHTMLElementVtbl;
502 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
503 const IHTMLElement3Vtbl *lpHTMLElement3Vtbl;
505 nsIDOMHTMLElement *nselem;
506 } HTMLElement;
508 #define HTMLELEMENT_TIDS \
509 IHTMLDOMNode_tid, \
510 IHTMLDOMNode2_tid, \
511 IHTMLElement_tid, \
512 IHTMLElement2_tid, \
513 IHTMLElement3_tid, \
514 IHTMLElement4_tid
516 typedef struct {
517 HTMLElement element;
519 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
521 ConnectionPoint cp;
522 } HTMLTextContainer;
524 struct HTMLFrameBase {
525 HTMLElement element;
527 const IHTMLFrameBaseVtbl *lpIHTMLFrameBaseVtbl;
528 const IHTMLFrameBase2Vtbl *lpIHTMLFrameBase2Vtbl;
530 HTMLWindow *content_window;
532 nsIDOMHTMLFrameElement *nsframe;
533 nsIDOMHTMLIFrameElement *nsiframe;
536 typedef struct _mutation_queue_t {
537 DWORD type;
538 nsISupports *nsiface;
540 struct _mutation_queue_t *next;
541 } mutation_queue_t;
543 typedef struct nsDocumentEventListener nsDocumentEventListener;
545 struct HTMLDocumentNode {
546 HTMLDOMNode node;
547 HTMLDocument basedoc;
549 const IInternetHostSecurityManagerVtbl *lpIInternetHostSecurityManagerVtbl;
551 const nsIDocumentObserverVtbl *lpIDocumentObserverVtbl;
552 const nsIRunnableVtbl *lpIRunnableVtbl;
554 LONG ref;
556 nsIDOMHTMLDocument *nsdoc;
557 HTMLDOMNode *nodes;
558 BOOL content_ready;
559 event_target_t *body_event_target;
561 IInternetSecurityManager *secmgr;
562 ICatInformation *catmgr;
563 nsDocumentEventListener *nsevent_listener;
564 BOOL *event_vector;
566 mutation_queue_t *mutation_queue;
567 mutation_queue_t *mutation_queue_tail;
569 struct list bindings;
570 struct list selection_list;
571 struct list range_list;
574 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
575 #define HTMLWINDOW3(x) ((IHTMLWindow3*) &(x)->lpHTMLWindow3Vtbl)
576 #define HTMLWINDOW4(x) ((IHTMLWindow4*) &(x)->lpHTMLWindow4Vtbl)
578 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
579 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
580 #define HTMLDOC4(x) ((IHTMLDocument4*) &(x)->lpHTMLDocument4Vtbl)
581 #define HTMLDOC5(x) ((IHTMLDocument5*) &(x)->lpHTMLDocument5Vtbl)
582 #define HTMLDOC6(x) ((IHTMLDocument6*) &(x)->lpHTMLDocument6Vtbl)
583 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
584 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
585 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
586 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
587 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
588 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
589 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
590 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
591 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
592 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObjectExVtbl)
593 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObjectExVtbl)
594 #define VIEWOBJEX(x) ((IViewObjectEx*) &(x)->lpViewObjectExVtbl)
595 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
596 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
597 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
598 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
599 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
600 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
601 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
602 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
603 #define PERSISTHIST(x) ((IPersistHistory*) &(x)->lpPersistHistoryVtbl)
604 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
605 #define OBJSITE(x) ((IObjectWithSite*) &(x)->lpObjectWithSiteVtbl)
607 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
608 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
609 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
610 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
611 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
612 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
613 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
614 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
615 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
617 #define NSDOCOBS(x) ((nsIDocumentObserver*) &(x)->lpIDocumentObserverVtbl)
619 #define NSRUNNABLE(x) ((nsIRunnable*) &(x)->lpIRunnableVtbl)
621 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
622 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
623 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
624 #define NSHTTPINTERNAL(x) ((nsIHttpChannelInternal*) &(x)->lpIHttpChannelInternalVtbl)
626 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
627 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
628 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
630 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
631 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
632 #define HTMLELEM3(x) ((IHTMLElement3*) &(x)->lpHTMLElement3Vtbl)
633 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
634 #define HTMLDOMNODE2(x) ((IHTMLDOMNode2*) &(x)->lpHTMLDOMNode2Vtbl)
636 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
637 #define HTMLFRAMEBASE(x) ((IHTMLFrameBase*) &(x)->lpIHTMLFrameBaseVtbl)
638 #define HTMLFRAMEBASE2(x) ((IHTMLFrameBase2*) &(x)->lpIHTMLFrameBase2Vtbl)
640 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
641 #define HTMLIMGFACTORY(x) ((IHTMLImageElementFactory*) &(x)->lpHTMLImageElementFactoryVtbl)
642 #define HTMLLOCATION(x) ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
644 #define DISPATCHEX(x) ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
646 #define SUPPERRINFO(x) ((ISupportErrorInfo*) &(x)->lpSupportErrorInfoVtbl)
648 #define HOSTSECMGR(x) ((IInternetHostSecurityManager*) &(x)->lpIInternetHostSecurityManagerVtbl)
650 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
651 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
653 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
654 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
655 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
657 HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**);
658 void update_window_doc(HTMLWindow*);
659 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
660 nsIDOMWindow *get_nsdoc_window(nsIDOMDocument*);
661 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
662 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
663 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
664 IOmNavigator *OmNavigator_Create(void);
665 HRESULT HTMLScreen_Create(IHTMLScreen**);
667 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
668 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
669 void HTMLDocument_Persist_Init(HTMLDocument*);
670 void HTMLDocument_OleCmd_Init(HTMLDocument*);
671 void HTMLDocument_OleObj_Init(HTMLDocument*);
672 void HTMLDocument_View_Init(HTMLDocument*);
673 void HTMLDocument_Window_Init(HTMLDocument*);
674 void HTMLDocument_Service_Init(HTMLDocument*);
675 void HTMLDocument_Hlink_Init(HTMLDocument*);
677 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
679 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
681 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*);
682 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
683 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
685 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
686 void NSContainer_Release(NSContainer*);
688 void init_mutation(HTMLDocumentNode*);
689 void release_mutation(HTMLDocumentNode*);
691 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
692 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
693 void notif_focus(HTMLDocumentObj*);
695 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
696 void hide_tooltip(HTMLDocumentObj*);
697 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
699 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
701 BOOL load_gecko(BOOL);
702 void close_gecko(void);
703 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
704 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
705 void release_nsio(void);
706 BOOL install_wine_gecko(BOOL);
708 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
709 HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**);
710 HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD);
712 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD);
713 HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
714 HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
716 void call_property_onchanged(ConnectionPoint*,DISPID);
717 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
719 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
720 void nsfree(void*);
722 void nsACString_SetData(nsACString*,const char*);
723 PRUint32 nsACString_GetData(const nsACString*,const char**);
725 BOOL nsAString_Init(nsAString*,const PRUnichar*);
726 void nsAString_InitDepend(nsAString*,const PRUnichar*);
727 void nsAString_SetData(nsAString*,const PRUnichar*);
728 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
729 void nsAString_Finish(nsAString*);
731 nsICommandParams *create_nscommand_params(void);
732 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
733 void get_editor_controller(NSContainer*);
734 nsresult get_nsinterface(nsISupports*,REFIID,void**);
736 void init_nsevents(HTMLDocumentNode*);
737 void release_nsevents(HTMLDocumentNode*);
738 void add_nsevent_listener(HTMLDocumentNode*,LPCWSTR);
740 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
741 void set_current_mon(HTMLWindow*,IMoniker*);
742 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
743 HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*);
744 void abort_document_bindings(HTMLDocumentNode*);
746 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
748 HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**);
749 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
750 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
751 IMoniker *get_channelbsc_mon(nsChannelBSC*);
753 void set_ready_state(HTMLWindow*,READYSTATE);
755 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
756 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
757 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
758 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
759 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
761 void detach_selection(HTMLDocumentNode*);
762 void detach_ranges(HTMLDocumentNode*);
763 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
765 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
767 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*);
769 HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL);
770 HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*);
771 HTMLElement *HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
772 HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
773 HTMLElement *HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
774 HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
775 HTMLElement *HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
776 HTMLElement *HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
777 HTMLElement *HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
778 HTMLElement *HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
779 HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
780 HTMLElement *HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
781 HTMLElement *HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
782 HTMLElement *HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
783 HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
784 HTMLElement *HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
786 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
787 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
788 void HTMLElement2_Init(HTMLElement*);
789 void HTMLElement3_Init(HTMLElement*);
790 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
791 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
793 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
794 void HTMLDOMNode_destructor(HTMLDOMNode*);
796 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
797 void HTMLElement_destructor(HTMLDOMNode*);
799 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
800 void HTMLFrameBase_destructor(HTMLFrameBase*);
802 HTMLDOMNode *get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL);
803 void release_nodes(HTMLDocumentNode*);
805 void release_script_hosts(HTMLWindow*);
806 void connect_scripts(HTMLWindow*);
807 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
808 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
809 void set_script_mode(HTMLWindow*,SCRIPTMODE);
810 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
811 IDispatch *get_script_disp(ScriptHost*);
812 HRESULT search_window_props(HTMLWindow*,BSTR,DWORD,DISPID*);
814 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
815 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
816 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
818 /* commands */
819 typedef struct {
820 DWORD id;
821 HRESULT (*query)(HTMLDocument*,OLECMD*);
822 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
823 } cmdtable_t;
825 extern const cmdtable_t editmode_cmds[];
827 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
829 /* timer */
830 #define UPDATE_UI 0x0001
831 #define UPDATE_TITLE 0x0002
833 void update_doc(HTMLDocument*,DWORD);
834 void update_title(HTMLDocumentObj*);
836 /* editor */
837 void init_editor(HTMLDocument*);
838 void set_ns_editmode(NSContainer*);
839 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
840 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
841 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
842 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
843 void handle_edit_load(HTMLDocument*);
844 HRESULT editor_is_dirty(HTMLDocument*);
845 void set_dirty(HTMLDocument*,VARIANT_BOOL);
847 extern DWORD mshtml_tls;
849 typedef struct task_t task_t;
850 typedef void (*task_proc_t)(task_t*);
852 struct task_t {
853 LONG target_magic;
854 task_proc_t proc;
855 struct task_t *next;
858 typedef struct {
859 task_t header;
860 HTMLDocumentObj *doc;
861 } docobj_task_t;
863 typedef struct {
864 HWND thread_hwnd;
865 task_t *task_queue_head;
866 task_t *task_queue_tail;
867 struct list timer_list;
868 } thread_data_t;
870 thread_data_t *get_thread_data(BOOL);
871 HWND get_thread_hwnd(void);
873 LONG get_task_target_magic(void);
874 void push_task(task_t*,task_proc_t,LONG);
875 void remove_target_tasks(LONG);
877 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
878 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
880 void release_typelib(void);
881 HRESULT call_disp_func(IDispatch*,DISPPARAMS*);
883 const char *debugstr_variant(const VARIANT*);
885 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
886 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
887 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
888 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
889 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
891 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
893 /* memory allocation functions */
895 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
897 return HeapAlloc(GetProcessHeap(), 0, len);
900 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
902 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
905 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
907 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
910 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
912 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
915 static inline BOOL heap_free(void *mem)
917 return HeapFree(GetProcessHeap(), 0, mem);
920 static inline LPWSTR heap_strdupW(LPCWSTR str)
922 LPWSTR ret = NULL;
924 if(str) {
925 DWORD size;
927 size = (strlenW(str)+1)*sizeof(WCHAR);
928 ret = heap_alloc(size);
929 memcpy(ret, str, size);
932 return ret;
935 static inline char *heap_strdupA(const char *str)
937 char *ret = NULL;
939 if(str) {
940 DWORD size;
942 size = strlen(str)+1;
943 ret = heap_alloc(size);
944 memcpy(ret, str, size);
947 return ret;
950 static inline WCHAR *heap_strdupAtoW(const char *str)
952 LPWSTR ret = NULL;
954 if(str) {
955 DWORD len;
957 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
958 ret = heap_alloc(len*sizeof(WCHAR));
959 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
962 return ret;
965 static inline char *heap_strdupWtoA(LPCWSTR str)
967 char *ret = NULL;
969 if(str) {
970 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
971 ret = heap_alloc(size);
972 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
975 return ret;
978 static inline void windowref_addref(windowref_t *ref)
980 InterlockedIncrement(&ref->ref);
983 static inline void windowref_release(windowref_t *ref)
985 if(!InterlockedDecrement(&ref->ref))
986 heap_free(ref);
989 HDC get_display_dc(void);
990 HINSTANCE get_shdoclc(void);
992 extern HINSTANCE hInst;