sync with trunk r46493
[reactos.git] / dll / win32 / 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_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)
44
45 #define NS_FAILED(res) ((res) & 0x80000000)
46 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
47
48 #define NSAPI WINAPI
49
50 #define MSHTML_E_NODOC 0x800a025c
51
52 typedef struct HTMLDOMNode HTMLDOMNode;
53 typedef struct ConnectionPoint ConnectionPoint;
54 typedef struct BSCallback BSCallback;
55 typedef struct event_target_t event_target_t;
56
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;
140
141 typedef struct dispex_data_t dispex_data_t;
142 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
143
144 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
145 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
146
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;
152
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;
159
160 typedef struct {
161 const IDispatchExVtbl *lpIDispatchExVtbl;
162
163 IUnknown *outer;
164
165 dispex_static_data_t *data;
166 dispex_dynamic_data_t *dynamic_data;
167 } DispatchEx;
168
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**);
174
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;
180
181 typedef enum {
182 SCRIPTMODE_GECKO,
183 SCRIPTMODE_ACTIVESCRIPT
184 } SCRIPTMODE;
185
186 typedef struct ScriptHost ScriptHost;
187
188 typedef enum {
189 GLOBAL_SCRIPTVAR,
190 GLOBAL_ELEMENTVAR
191 } global_prop_type_t;
192
193 typedef struct {
194 global_prop_type_t type;
195 WCHAR *name;
196 ScriptHost *script_host;
197 DISPID id;
198 } global_prop_t;
199
200 typedef struct {
201 const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
202
203 LONG ref;
204
205 HTMLWindow *window;
206 } HTMLOptionElementFactory;
207
208 typedef struct {
209 DispatchEx dispex;
210 const IHTMLImageElementFactoryVtbl *lpHTMLImageElementFactoryVtbl;
211
212 LONG ref;
213
214 HTMLWindow *window;
215 } HTMLImageElementFactory;
216
217 struct HTMLLocation {
218 DispatchEx dispex;
219 const IHTMLLocationVtbl *lpHTMLLocationVtbl;
220
221 LONG ref;
222
223 HTMLWindow *window;
224 };
225
226 typedef struct {
227 HTMLWindow *window;
228 LONG ref;
229 } windowref_t;
230
231 typedef struct nsChannelBSC nsChannelBSC;
232
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;
240
241 LONG ref;
242
243 windowref_t *window_ref;
244 LONG task_magic;
245
246 HTMLDocumentNode *doc;
247 HTMLDocumentObj *doc_obj;
248 nsIDOMWindow *nswindow;
249 HTMLWindow *parent;
250 HTMLFrameBase *frame_element;
251 READYSTATE readystate;
252
253 nsChannelBSC *bscallback;
254 IMoniker *mon;
255 LPOLESTR url;
256
257 IHTMLEventObj *event;
258
259 SCRIPTMODE scriptmode;
260 struct list script_hosts;
261
262 HTMLOptionElementFactory *option_factory;
263 HTMLImageElementFactory *image_factory;
264 HTMLLocation *location;
265 IHTMLScreen *screen;
266
267 global_prop_t *global_props;
268 DWORD global_prop_cnt;
269 DWORD global_prop_size;
270
271 struct list children;
272 struct list sibling_entry;
273 struct list entry;
274 };
275
276 typedef enum {
277 UNKNOWN_USERMODE,
278 BROWSEMODE,
279 EDITMODE
280 } USERMODE;
281
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;
288
289 typedef struct ConnectionPointContainer {
290 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
291
292 ConnectionPoint *cp_list;
293 IUnknown *outer;
294 struct ConnectionPointContainer *forward_container;
295 } ConnectionPointContainer;
296
297 struct ConnectionPoint {
298 const IConnectionPointVtbl *lpConnectionPointVtbl;
299
300 ConnectionPointContainer *container;
301
302 union {
303 IUnknown *unk;
304 IDispatch *disp;
305 IPropertyNotifySink *propnotif;
306 } *sinks;
307 DWORD sinks_size;
308
309 const IID *iid;
310 cp_static_data_t *data;
311
312 ConnectionPoint *next;
313 };
314
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;
339
340 IUnknown *unk_impl;
341 IDispatchEx *dispex;
342
343 HTMLDocumentObj *doc_obj;
344 HTMLDocumentNode *doc_node;
345
346 HTMLWindow *window;
347
348 LONG task_magic;
349
350 ConnectionPointContainer cp_container;
351 ConnectionPoint cp_htmldocevents;
352 ConnectionPoint cp_htmldocevents2;
353 ConnectionPoint cp_propnotif;
354 ConnectionPoint cp_dispatch;
355
356 IOleAdviseHolder *advise_holder;
357 };
358
359 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
360 {
361 return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
362 }
363
364 static inline ULONG htmldoc_addref(HTMLDocument *This)
365 {
366 return IUnknown_AddRef(This->unk_impl);
367 }
368
369 static inline ULONG htmldoc_release(HTMLDocument *This)
370 {
371 return IUnknown_Release(This->unk_impl);
372 }
373
374 struct HTMLDocumentObj {
375 HTMLDocument basedoc;
376 DispatchEx dispex;
377 const ICustomDocVtbl *lpCustomDocVtbl;
378
379 LONG ref;
380
381 NSContainer *nscontainer;
382
383 IOleClientSite *client;
384 IDocHostUIHandler *hostui;
385 IOleInPlaceSite *ipsite;
386 IOleInPlaceFrame *frame;
387 IOleInPlaceUIWindow *ip_window;
388 IAdviseSink *view_sink;
389
390 DOCHOSTUIINFO hostinfo;
391
392 IOleUndoManager *undomgr;
393
394 HWND hwnd;
395 HWND tooltips_hwnd;
396
397 BOOL request_uiactivate;
398 BOOL in_place_active;
399 BOOL ui_active;
400 BOOL window_active;
401 BOOL hostui_setup;
402 BOOL container_locked;
403 BOOL focus;
404 INT download_state;
405
406 USERMODE usermode;
407 LPWSTR mime;
408
409 DWORD update;
410 };
411
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;
421
422 nsIWebBrowser *webbrowser;
423 nsIWebNavigation *navigation;
424 nsIBaseWindow *window;
425 nsIWebBrowserFocus *focus;
426
427 nsIEditor *editor;
428 nsIController *editor_controller;
429
430 LONG ref;
431
432 NSContainer *parent;
433 HTMLDocumentObj *doc;
434
435 nsIURIContentListener *content_listener;
436
437 HWND hwnd;
438
439 HWND reset_focus; /* hack */
440 };
441
442 typedef struct nsWineURI nsWineURI;
443
444 HRESULT set_wine_url(nsWineURI*,LPCWSTR);
445 nsresult on_start_uri_open(NSContainer*,nsIURI*,PRBool*);
446
447 typedef struct {
448 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
449 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
450 const nsIHttpChannelInternalVtbl *lpIHttpChannelInternalVtbl;
451
452 LONG ref;
453
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;
466
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;
480
481 struct HTMLDOMNode {
482 DispatchEx dispex;
483 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
484 const IHTMLDOMNode2Vtbl *lpHTMLDOMNode2Vtbl;
485 const NodeImplVtbl *vtbl;
486
487 LONG ref;
488
489 nsIDOMNode *nsnode;
490 HTMLDocumentNode *doc;
491 event_target_t *event_target;
492 ConnectionPointContainer *cp_container;
493
494 HTMLDOMNode *next;
495 };
496
497 typedef struct {
498 HTMLDOMNode node;
499 ConnectionPointContainer cp_container;
500
501 const IHTMLElementVtbl *lpHTMLElementVtbl;
502 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
503 const IHTMLElement3Vtbl *lpHTMLElement3Vtbl;
504
505 nsIDOMHTMLElement *nselem;
506 } HTMLElement;
507
508 #define HTMLELEMENT_TIDS \
509 IHTMLDOMNode_tid, \
510 IHTMLDOMNode2_tid, \
511 IHTMLElement_tid, \
512 IHTMLElement2_tid, \
513 IHTMLElement3_tid, \
514 IHTMLElement4_tid
515
516 typedef struct {
517 HTMLElement element;
518
519 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
520
521 ConnectionPoint cp;
522 } HTMLTextContainer;
523
524 struct HTMLFrameBase {
525 HTMLElement element;
526
527 const IHTMLFrameBaseVtbl *lpIHTMLFrameBaseVtbl;
528 const IHTMLFrameBase2Vtbl *lpIHTMLFrameBase2Vtbl;
529
530 HTMLWindow *content_window;
531
532 nsIDOMHTMLFrameElement *nsframe;
533 nsIDOMHTMLIFrameElement *nsiframe;
534 };
535
536 typedef struct _mutation_queue_t {
537 DWORD type;
538 nsISupports *nsiface;
539
540 struct _mutation_queue_t *next;
541 } mutation_queue_t;
542
543 typedef struct nsDocumentEventListener nsDocumentEventListener;
544
545 struct HTMLDocumentNode {
546 HTMLDOMNode node;
547 HTMLDocument basedoc;
548
549 const IInternetHostSecurityManagerVtbl *lpIInternetHostSecurityManagerVtbl;
550
551 const nsIDocumentObserverVtbl *lpIDocumentObserverVtbl;
552 const nsIRunnableVtbl *lpIRunnableVtbl;
553
554 LONG ref;
555
556 nsIDOMHTMLDocument *nsdoc;
557 HTMLDOMNode *nodes;
558 BOOL content_ready;
559 event_target_t *body_event_target;
560
561 IInternetSecurityManager *secmgr;
562 ICatInformation *catmgr;
563 nsDocumentEventListener *nsevent_listener;
564 BOOL *event_vector;
565
566 mutation_queue_t *mutation_queue;
567 mutation_queue_t *mutation_queue_tail;
568
569 struct list bindings;
570 struct list selection_list;
571 struct list range_list;
572 };
573
574 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
575 #define HTMLWINDOW3(x) ((IHTMLWindow3*) &(x)->lpHTMLWindow3Vtbl)
576 #define HTMLWINDOW4(x) ((IHTMLWindow4*) &(x)->lpHTMLWindow4Vtbl)
577
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)
606
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)
616
617 #define NSDOCOBS(x) ((nsIDocumentObserver*) &(x)->lpIDocumentObserverVtbl)
618
619 #define NSRUNNABLE(x) ((nsIRunnable*) &(x)->lpIRunnableVtbl)
620
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)
625
626 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
627 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
628 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
629
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)
635
636 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
637 #define HTMLFRAMEBASE(x) ((IHTMLFrameBase*) &(x)->lpIHTMLFrameBaseVtbl)
638 #define HTMLFRAMEBASE2(x) ((IHTMLFrameBase2*) &(x)->lpIHTMLFrameBase2Vtbl)
639
640 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
641 #define HTMLIMGFACTORY(x) ((IHTMLImageElementFactory*) &(x)->lpHTMLImageElementFactoryVtbl)
642 #define HTMLLOCATION(x) ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
643
644 #define DISPATCHEX(x) ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
645
646 #define SUPPERRINFO(x) ((ISupportErrorInfo*) &(x)->lpSupportErrorInfoVtbl)
647
648 #define HOSTSECMGR(x) ((IInternetHostSecurityManager*) &(x)->lpIInternetHostSecurityManagerVtbl)
649
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)
652
653 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
654 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
655 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
656
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**);
666
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*);
676
677 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
678
679 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
680
681 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*);
682 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
683 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
684
685 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
686 void NSContainer_Release(NSContainer*);
687
688 void init_mutation(HTMLDocumentNode*);
689 void release_mutation(HTMLDocumentNode*);
690
691 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
692 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
693 void notif_focus(HTMLDocumentObj*);
694
695 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
696 void hide_tooltip(HTMLDocumentObj*);
697 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
698
699 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
700
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);
707
708 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
709 HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**);
710 HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD);
711
712 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD,BOOL*);
713 HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
714 HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
715 HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL);
716
717 void call_property_onchanged(ConnectionPoint*,DISPID);
718 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
719
720 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
721 void nsfree(void*);
722
723 void nsACString_SetData(nsACString*,const char*);
724 PRUint32 nsACString_GetData(const nsACString*,const char**);
725
726 BOOL nsAString_Init(nsAString*,const PRUnichar*);
727 void nsAString_InitDepend(nsAString*,const PRUnichar*);
728 void nsAString_SetData(nsAString*,const PRUnichar*);
729 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
730 void nsAString_Finish(nsAString*);
731
732 nsICommandParams *create_nscommand_params(void);
733 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
734 void get_editor_controller(NSContainer*);
735 nsresult get_nsinterface(nsISupports*,REFIID,void**);
736
737 void init_nsevents(HTMLDocumentNode*);
738 void release_nsevents(HTMLDocumentNode*);
739 void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR);
740
741 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
742 void set_current_mon(HTMLWindow*,IMoniker*);
743 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
744 HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*);
745 void abort_document_bindings(HTMLDocumentNode*);
746
747 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
748
749 HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**);
750 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
751 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
752 IMoniker *get_channelbsc_mon(nsChannelBSC*);
753
754 void set_ready_state(HTMLWindow*,READYSTATE);
755
756 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
757 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
758 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
759 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
760 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
761
762 void detach_selection(HTMLDocumentNode*);
763 void detach_ranges(HTMLDocumentNode*);
764 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
765
766 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
767
768 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*);
769
770 HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL);
771 HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*);
772 HTMLElement *HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
773 HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
774 HTMLElement *HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
775 HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
776 HTMLElement *HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
777 HTMLElement *HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
778 HTMLElement *HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
779 HTMLElement *HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
780 HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
781 HTMLElement *HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
782 HTMLElement *HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
783 HTMLElement *HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
784 HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
785 HTMLElement *HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
786
787 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
788 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
789 void HTMLElement2_Init(HTMLElement*);
790 void HTMLElement3_Init(HTMLElement*);
791 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
792 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
793
794 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
795 void HTMLDOMNode_destructor(HTMLDOMNode*);
796
797 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
798 void HTMLElement_destructor(HTMLDOMNode*);
799
800 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
801 void HTMLFrameBase_destructor(HTMLFrameBase*);
802
803 HTMLDOMNode *get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL);
804 void release_nodes(HTMLDocumentNode*);
805
806 void release_script_hosts(HTMLWindow*);
807 void connect_scripts(HTMLWindow*);
808 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
809 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
810 void set_script_mode(HTMLWindow*,SCRIPTMODE);
811 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
812 IDispatch *get_script_disp(ScriptHost*);
813 HRESULT search_window_props(HTMLWindow*,BSTR,DWORD,DISPID*);
814
815 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
816 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
817 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
818
819 /* commands */
820 typedef struct {
821 DWORD id;
822 HRESULT (*query)(HTMLDocument*,OLECMD*);
823 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
824 } cmdtable_t;
825
826 extern const cmdtable_t editmode_cmds[];
827
828 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
829
830 /* timer */
831 #define UPDATE_UI 0x0001
832 #define UPDATE_TITLE 0x0002
833
834 void update_doc(HTMLDocument*,DWORD);
835 void update_title(HTMLDocumentObj*);
836
837 /* editor */
838 void init_editor(HTMLDocument*);
839 void set_ns_editmode(NSContainer*);
840 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
841 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
842 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
843 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
844 void handle_edit_load(HTMLDocument*);
845 HRESULT editor_is_dirty(HTMLDocument*);
846 void set_dirty(HTMLDocument*,VARIANT_BOOL);
847
848 extern DWORD mshtml_tls;
849
850 typedef struct task_t task_t;
851 typedef void (*task_proc_t)(task_t*);
852
853 struct task_t {
854 LONG target_magic;
855 task_proc_t proc;
856 struct task_t *next;
857 };
858
859 typedef struct {
860 task_t header;
861 HTMLDocumentObj *doc;
862 } docobj_task_t;
863
864 typedef struct {
865 HWND thread_hwnd;
866 task_t *task_queue_head;
867 task_t *task_queue_tail;
868 struct list timer_list;
869 } thread_data_t;
870
871 thread_data_t *get_thread_data(BOOL);
872 HWND get_thread_hwnd(void);
873
874 LONG get_task_target_magic(void);
875 void push_task(task_t*,task_proc_t,LONG);
876 void remove_target_tasks(LONG);
877
878 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
879 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
880
881 void release_typelib(void);
882 HRESULT call_disp_func(IDispatch*,DISPPARAMS*);
883
884 const char *debugstr_variant(const VARIANT*);
885
886 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
887 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
888 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
889 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
890 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
891
892 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
893
894 /* memory allocation functions */
895
896 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
897 {
898 return HeapAlloc(GetProcessHeap(), 0, len);
899 }
900
901 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
902 {
903 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
904 }
905
906 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
907 {
908 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
909 }
910
911 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
912 {
913 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
914 }
915
916 static inline BOOL heap_free(void *mem)
917 {
918 return HeapFree(GetProcessHeap(), 0, mem);
919 }
920
921 static inline LPWSTR heap_strdupW(LPCWSTR str)
922 {
923 LPWSTR ret = NULL;
924
925 if(str) {
926 DWORD size;
927
928 size = (strlenW(str)+1)*sizeof(WCHAR);
929 ret = heap_alloc(size);
930 memcpy(ret, str, size);
931 }
932
933 return ret;
934 }
935
936 static inline char *heap_strdupA(const char *str)
937 {
938 char *ret = NULL;
939
940 if(str) {
941 DWORD size;
942
943 size = strlen(str)+1;
944 ret = heap_alloc(size);
945 memcpy(ret, str, size);
946 }
947
948 return ret;
949 }
950
951 static inline WCHAR *heap_strdupAtoW(const char *str)
952 {
953 LPWSTR ret = NULL;
954
955 if(str) {
956 DWORD len;
957
958 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
959 ret = heap_alloc(len*sizeof(WCHAR));
960 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
961 }
962
963 return ret;
964 }
965
966 static inline char *heap_strdupWtoA(LPCWSTR str)
967 {
968 char *ret = NULL;
969
970 if(str) {
971 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
972 ret = heap_alloc(size);
973 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
974 }
975
976 return ret;
977 }
978
979 static inline void windowref_addref(windowref_t *ref)
980 {
981 InterlockedIncrement(&ref->ref);
982 }
983
984 static inline void windowref_release(windowref_t *ref)
985 {
986 if(!InterlockedDecrement(&ref->ref))
987 heap_free(ref);
988 }
989
990 HDC get_display_dc(void);
991 HINSTANCE get_shdoclc(void);
992
993 extern HINSTANCE hInst;