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