43601ae9ddf81ccda515bf27678059a25f2e1c84
[reactos.git] / reactos / 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 "mshtml.h"
22 #include "mshtmhst.h"
23 #include "hlink.h"
24 #include "perhist.h"
25 #include "dispex.h"
26
27 #include "wine/list.h"
28 #include "wine/unicode.h"
29
30 #ifdef INIT_GUID
31 #include "initguid.h"
32 #endif
33
34 #include "nsiface.h"
35
36 #define NS_OK ((nsresult)0x00000000L)
37 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
38 #define NS_NOINTERFACE ((nsresult)0x80004002L)
39 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
40 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
41 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
42 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
43
44 #define NS_FAILED(res) ((res) & 0x80000000)
45 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
46
47 #define NSAPI WINAPI
48
49 #define MSHTML_E_NODOC 0x800a025c
50
51 typedef struct HTMLDOMNode HTMLDOMNode;
52 typedef struct ConnectionPoint ConnectionPoint;
53 typedef struct BSCallback BSCallback;
54 typedef struct nsChannelBSC nsChannelBSC;
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 DispHTMLGenericElement_tid,
70 DispHTMLIFrame_tid,
71 DispHTMLImg_tid,
72 DispHTMLInputElement_tid,
73 DispHTMLLocation_tid,
74 DispHTMLNavigator_tid,
75 DispHTMLOptionElement_tid,
76 DispHTMLSelectElement_tid,
77 DispHTMLStyle_tid,
78 DispHTMLTable_tid,
79 DispHTMLTableRow_tid,
80 DispHTMLUnknownElement_tid,
81 DispHTMLWindow2_tid,
82 IHTMLAnchorElement_tid,
83 IHTMLBodyElement_tid,
84 IHTMLBodyElement2_tid,
85 IHTMLCommentElement_tid,
86 IHTMLCurrentStyle_tid,
87 IHTMLCurrentStyle2_tid,
88 IHTMLCurrentStyle3_tid,
89 IHTMLCurrentStyle4_tid,
90 IHTMLDocument2_tid,
91 IHTMLDocument3_tid,
92 IHTMLDocument4_tid,
93 IHTMLDocument5_tid,
94 IHTMLDOMChildrenCollection_tid,
95 IHTMLDOMNode_tid,
96 IHTMLDOMNode2_tid,
97 IHTMLDOMTextNode_tid,
98 IHTMLElement_tid,
99 IHTMLElement2_tid,
100 IHTMLElement3_tid,
101 IHTMLElement4_tid,
102 IHTMLElementCollection_tid,
103 IHTMLEventObj_tid,
104 IHTMLFrameBase_tid,
105 IHTMLFrameBase2_tid,
106 IHTMLGenericElement_tid,
107 IHTMLImageElementFactory_tid,
108 IHTMLImgElement_tid,
109 IHTMLInputElement_tid,
110 IHTMLLocation_tid,
111 IHTMLOptionElement_tid,
112 IHTMLSelectElement_tid,
113 IHTMLStyle_tid,
114 IHTMLStyle2_tid,
115 IHTMLStyle3_tid,
116 IHTMLStyle4_tid,
117 IHTMLTable_tid,
118 IHTMLTableRow_tid,
119 IHTMLTextContainer_tid,
120 IHTMLUniqueName_tid,
121 IHTMLWindow2_tid,
122 IHTMLWindow3_tid,
123 IOmNavigator_tid,
124 LAST_tid
125 } tid_t;
126
127 typedef struct dispex_data_t dispex_data_t;
128 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
129
130 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
131 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
132
133 typedef struct {
134 HRESULT (*value)(IUnknown*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
135 HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
136 HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
137 } dispex_static_data_vtbl_t;
138
139 typedef struct {
140 const dispex_static_data_vtbl_t *vtbl;
141 const tid_t disp_tid;
142 dispex_data_t *data;
143 const tid_t* const iface_tids;
144 } dispex_static_data_t;
145
146 typedef struct {
147 const IDispatchExVtbl *lpIDispatchExVtbl;
148
149 IUnknown *outer;
150
151 dispex_static_data_t *data;
152 dispex_dynamic_data_t *dynamic_data;
153 } DispatchEx;
154
155 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
156 void release_dispex(DispatchEx*);
157 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
158 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
159
160 typedef struct HTMLDocumentNode HTMLDocumentNode;
161 typedef struct HTMLDocumentObj HTMLDocumentObj;
162 typedef struct HTMLFrameBase HTMLFrameBase;
163
164 typedef enum {
165 SCRIPTMODE_GECKO,
166 SCRIPTMODE_ACTIVESCRIPT
167 } SCRIPTMODE;
168
169 typedef struct ScriptHost ScriptHost;
170
171 typedef enum {
172 GLOBAL_SCRIPTVAR,
173 GLOBAL_ELEMENTVAR
174 } global_prop_type_t;
175
176 typedef struct {
177 global_prop_type_t type;
178 WCHAR *name;
179 ScriptHost *script_host;
180 DISPID id;
181 } global_prop_t;
182
183 typedef struct {
184 const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
185
186 LONG ref;
187
188 HTMLWindow *window;
189 } HTMLOptionElementFactory;
190
191 typedef struct {
192 DispatchEx dispex;
193 const IHTMLImageElementFactoryVtbl *lpHTMLImageElementFactoryVtbl;
194
195 LONG ref;
196
197 HTMLWindow *window;
198 } HTMLImageElementFactory;
199
200 struct HTMLLocation {
201 DispatchEx dispex;
202 const IHTMLLocationVtbl *lpHTMLLocationVtbl;
203
204 LONG ref;
205
206 HTMLWindow *window;
207 };
208
209 typedef struct {
210 HTMLWindow *window;
211 LONG ref;
212 } windowref_t;
213
214 struct HTMLWindow {
215 DispatchEx dispex;
216 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
217 const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
218 const IDispatchExVtbl *lpIDispatchExVtbl;
219
220 LONG ref;
221
222 windowref_t *window_ref;
223 LONG task_magic;
224
225 HTMLDocumentNode *doc;
226 HTMLDocumentObj *doc_obj;
227 nsIDOMWindow *nswindow;
228 HTMLWindow *parent;
229 HTMLFrameBase *frame_element;
230 READYSTATE readystate;
231
232 nsChannelBSC *bscallback;
233 IMoniker *mon;
234 LPOLESTR url;
235
236 event_target_t *event_target;
237 IHTMLEventObj *event;
238
239 SCRIPTMODE scriptmode;
240 struct list script_hosts;
241
242 HTMLOptionElementFactory *option_factory;
243 HTMLImageElementFactory *image_factory;
244 HTMLLocation *location;
245
246 global_prop_t *global_props;
247 DWORD global_prop_cnt;
248 DWORD global_prop_size;
249
250 struct list children;
251 struct list sibling_entry;
252 struct list entry;
253 };
254
255 typedef enum {
256 UNKNOWN_USERMODE,
257 BROWSEMODE,
258 EDITMODE
259 } USERMODE;
260
261 typedef struct {
262 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
263
264 ConnectionPoint *cp_list;
265 IUnknown *outer;
266 } ConnectionPointContainer;
267
268 struct ConnectionPoint {
269 const IConnectionPointVtbl *lpConnectionPointVtbl;
270
271 IConnectionPointContainer *container;
272
273 union {
274 IUnknown *unk;
275 IDispatch *disp;
276 IPropertyNotifySink *propnotif;
277 } *sinks;
278 DWORD sinks_size;
279
280 const IID *iid;
281
282 ConnectionPoint *next;
283 };
284
285 struct HTMLDocument {
286 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
287 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
288 const IHTMLDocument4Vtbl *lpHTMLDocument4Vtbl;
289 const IHTMLDocument5Vtbl *lpHTMLDocument5Vtbl;
290 const IHTMLDocument6Vtbl *lpHTMLDocument6Vtbl;
291 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
292 const IPersistFileVtbl *lpPersistFileVtbl;
293 const IPersistHistoryVtbl *lpPersistHistoryVtbl;
294 const IMonikerPropVtbl *lpMonikerPropVtbl;
295 const IOleObjectVtbl *lpOleObjectVtbl;
296 const IOleDocumentVtbl *lpOleDocumentVtbl;
297 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
298 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
299 const IViewObject2Vtbl *lpViewObject2Vtbl;
300 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
301 const IServiceProviderVtbl *lpServiceProviderVtbl;
302 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
303 const IOleControlVtbl *lpOleControlVtbl;
304 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
305 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
306 const IDispatchExVtbl *lpIDispatchExVtbl;
307 const ISupportErrorInfoVtbl *lpSupportErrorInfoVtbl;
308
309 IUnknown *unk_impl;
310 IDispatchEx *dispex;
311
312 HTMLDocumentObj *doc_obj;
313 HTMLDocumentNode *doc_node;
314
315 HTMLWindow *window;
316
317 LONG task_magic;
318
319 ConnectionPointContainer cp_container;
320 ConnectionPoint cp_htmldocevents;
321 ConnectionPoint cp_htmldocevents2;
322 ConnectionPoint cp_propnotif;
323 };
324
325 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
326 {
327 return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
328 }
329
330 static inline ULONG htmldoc_addref(HTMLDocument *This)
331 {
332 return IUnknown_AddRef(This->unk_impl);
333 }
334
335 static inline ULONG htmldoc_release(HTMLDocument *This)
336 {
337 return IUnknown_Release(This->unk_impl);
338 }
339
340 struct HTMLDocumentObj {
341 HTMLDocument basedoc;
342 DispatchEx dispex;
343 const ICustomDocVtbl *lpCustomDocVtbl;
344
345 LONG ref;
346
347 NSContainer *nscontainer;
348
349 IOleClientSite *client;
350 IDocHostUIHandler *hostui;
351 IOleInPlaceSite *ipsite;
352 IOleInPlaceFrame *frame;
353 IOleInPlaceUIWindow *ip_window;
354
355 DOCHOSTUIINFO hostinfo;
356
357 IOleUndoManager *undomgr;
358
359 HWND hwnd;
360 HWND tooltips_hwnd;
361
362 BOOL in_place_active;
363 BOOL ui_active;
364 BOOL window_active;
365 BOOL has_key_path;
366 BOOL container_locked;
367 BOOL focus;
368
369 USERMODE usermode;
370 LPWSTR mime;
371
372 DWORD update;
373 };
374
375 struct NSContainer {
376 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
377 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
378 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
379 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
380 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
381 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
382 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
383 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
384
385 nsIWebBrowser *webbrowser;
386 nsIWebNavigation *navigation;
387 nsIBaseWindow *window;
388 nsIWebBrowserFocus *focus;
389
390 nsIEditor *editor;
391 nsIController *editor_controller;
392
393 LONG ref;
394
395 NSContainer *parent;
396 HTMLDocumentObj *doc;
397
398 nsIURIContentListener *content_listener;
399
400 HWND hwnd;
401
402 nsChannelBSC *bscallback; /* hack */
403 HWND reset_focus; /* hack */
404 };
405
406 typedef struct {
407 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
408 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
409 const nsIHttpChannelInternalVtbl *lpIHttpChannelInternalVtbl;
410
411 LONG ref;
412
413 nsIChannel *channel;
414 nsIHttpChannel *http_channel;
415 nsIHttpChannelInternal *http_channel_internal;
416 nsIWineURI *uri;
417 nsIInputStream *post_data_stream;
418 nsILoadGroup *load_group;
419 nsIInterfaceRequestor *notif_callback;
420 nsISupports *owner;
421 nsLoadFlags load_flags;
422 nsIURI *original_uri;
423 char *content_type;
424 char *charset;
425 PRUint32 response_status;
426 } nsChannel;
427
428 typedef struct {
429 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
430 void (*destructor)(HTMLDOMNode*);
431 event_target_t **(*get_event_target)(HTMLDOMNode*);
432 HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
433 HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
434 HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
435 } NodeImplVtbl;
436
437 struct HTMLDOMNode {
438 DispatchEx dispex;
439 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
440 const IHTMLDOMNode2Vtbl *lpHTMLDOMNode2Vtbl;
441 const NodeImplVtbl *vtbl;
442
443 LONG ref;
444
445 nsIDOMNode *nsnode;
446 HTMLDocumentNode *doc;
447 event_target_t *event_target;
448
449 HTMLDOMNode *next;
450 };
451
452 typedef struct {
453 HTMLDOMNode node;
454 ConnectionPointContainer cp_container;
455
456 const IHTMLElementVtbl *lpHTMLElementVtbl;
457 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
458 const IHTMLElement3Vtbl *lpHTMLElement3Vtbl;
459
460 nsIDOMHTMLElement *nselem;
461 } HTMLElement;
462
463 typedef struct {
464 HTMLElement element;
465
466 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
467
468 ConnectionPoint cp;
469 } HTMLTextContainer;
470
471 struct HTMLFrameBase {
472 HTMLElement element;
473
474 const IHTMLFrameBaseVtbl *lpIHTMLFrameBaseVtbl;
475
476 HTMLWindow *content_window;
477 };
478
479 typedef struct _mutation_queue_t {
480 DWORD type;
481 nsISupports *nsiface;
482
483 struct _mutation_queue_t *next;
484 } mutation_queue_t;
485
486 typedef struct nsDocumentEventListener nsDocumentEventListener;
487
488 struct HTMLDocumentNode {
489 HTMLDOMNode node;
490 HTMLDocument basedoc;
491
492 const IInternetHostSecurityManagerVtbl *lpIInternetHostSecurityManagerVtbl;
493
494 const nsIDocumentObserverVtbl *lpIDocumentObserverVtbl;
495 const nsIRunnableVtbl *lpIRunnableVtbl;
496
497 LONG ref;
498
499 nsIDOMHTMLDocument *nsdoc;
500 HTMLDOMNode *nodes;
501 BOOL content_ready;
502
503 IInternetSecurityManager *secmgr;
504 nsDocumentEventListener *nsevent_listener;
505 BOOL *event_vector;
506
507 mutation_queue_t *mutation_queue;
508 mutation_queue_t *mutation_queue_tail;
509
510 struct list bindings;
511 struct list selection_list;
512 struct list range_list;
513 };
514
515 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
516 #define HTMLWINDOW3(x) ((IHTMLWindow3*) &(x)->lpHTMLWindow3Vtbl)
517
518 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
519 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
520 #define HTMLDOC4(x) ((IHTMLDocument4*) &(x)->lpHTMLDocument4Vtbl)
521 #define HTMLDOC5(x) ((IHTMLDocument5*) &(x)->lpHTMLDocument5Vtbl)
522 #define HTMLDOC6(x) ((IHTMLDocument6*) &(x)->lpHTMLDocument6Vtbl)
523 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
524 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
525 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
526 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
527 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
528 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
529 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
530 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
531 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
532 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
533 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
534 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
535 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
536 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
537 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
538 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
539 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
540 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
541 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
542 #define PERSISTHIST(x) ((IPersistHistory*) &(x)->lpPersistHistoryVtbl)
543 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
544
545 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
546 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
547 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
548 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
549 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
550 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
551 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
552 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
553 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
554
555 #define NSDOCOBS(x) ((nsIDocumentObserver*) &(x)->lpIDocumentObserverVtbl)
556
557 #define NSRUNNABLE(x) ((nsIRunnable*) &(x)->lpIRunnableVtbl)
558
559 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
560 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
561 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
562 #define NSHTTPINTERNAL(x) ((nsIHttpChannelInternal*) &(x)->lpIHttpChannelInternalVtbl)
563
564 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
565 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
566 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
567
568 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
569 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
570 #define HTMLELEM3(x) ((IHTMLElement3*) &(x)->lpHTMLElement3Vtbl)
571 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
572 #define HTMLDOMNODE2(x) ((IHTMLDOMNode2*) &(x)->lpHTMLDOMNode2Vtbl)
573
574 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
575 #define HTMLFRAMEBASE(x) ((IHTMLFrameBase*) &(x)->lpIHTMLFrameBaseVtbl)
576
577 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
578 #define HTMLIMGFACTORY(x) ((IHTMLImageElementFactory*) &(x)->lpHTMLImageElementFactoryVtbl)
579 #define HTMLLOCATION(x) ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
580
581 #define DISPATCHEX(x) ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
582
583 #define SUPPERRINFO(x) ((ISupportErrorInfo*) &(x)->lpSupportErrorInfoVtbl)
584
585 #define HOSTSECMGR(x) ((IInternetHostSecurityManager*) &(x)->lpIInternetHostSecurityManagerVtbl)
586
587 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
588 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
589
590 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
591 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
592 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
593
594 HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**);
595 void update_window_doc(HTMLWindow*);
596 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
597 nsIDOMWindow *get_nsdoc_window(nsIDOMDocument*);
598 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
599 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
600 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
601 IOmNavigator *OmNavigator_Create(void);
602
603 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
604 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
605 void HTMLDocument_Persist_Init(HTMLDocument*);
606 void HTMLDocument_OleCmd_Init(HTMLDocument*);
607 void HTMLDocument_OleObj_Init(HTMLDocument*);
608 void HTMLDocument_View_Init(HTMLDocument*);
609 void HTMLDocument_Window_Init(HTMLDocument*);
610 void HTMLDocument_Service_Init(HTMLDocument*);
611 void HTMLDocument_Hlink_Init(HTMLDocument*);
612
613 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
614
615 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
616
617 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
618 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
619 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
620
621 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
622 void NSContainer_Release(NSContainer*);
623
624 void init_mutation(HTMLDocumentNode*);
625 void release_mutation(HTMLDocumentNode*);
626
627 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
628 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
629 void notif_focus(HTMLDocumentObj*);
630
631 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
632 void hide_tooltip(HTMLDocumentObj*);
633 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
634
635 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
636
637 BOOL load_gecko(BOOL);
638 void close_gecko(void);
639 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
640 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
641 void release_nsio(void);
642 BOOL install_wine_gecko(BOOL);
643
644 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
645
646 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD);
647 HRESULT navigate_url(HTMLDocumentNode*,OLECHAR*);
648
649 void call_property_onchanged(ConnectionPoint*,DISPID);
650 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
651
652 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
653 void nsfree(void*);
654
655 void nsACString_Init(nsACString*,const char*);
656 void nsACString_SetData(nsACString*,const char*);
657 PRUint32 nsACString_GetData(const nsACString*,const char**);
658 void nsACString_Finish(nsACString*);
659
660 void nsAString_Init(nsAString*,const PRUnichar*);
661 void nsAString_SetData(nsAString*,const PRUnichar*);
662 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
663 void nsAString_Finish(nsAString*);
664
665 nsICommandParams *create_nscommand_params(void);
666 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
667 void get_editor_controller(NSContainer*);
668 nsresult get_nsinterface(nsISupports*,REFIID,void**);
669
670 void init_nsevents(HTMLDocumentNode*);
671 void release_nsevents(HTMLDocumentNode*);
672 void add_nsevent_listener(HTMLDocumentNode*,LPCWSTR);
673
674 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
675 void set_current_mon(HTMLWindow*,IMoniker*);
676 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
677 void abort_document_bindings(HTMLDocumentNode*);
678
679 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
680
681 nsChannelBSC *create_channelbsc(IMoniker*);
682 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
683 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
684 IMoniker *get_channelbsc_mon(nsChannelBSC*);
685
686 void set_ready_state(HTMLWindow*,READYSTATE);
687
688 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
689 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
690 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
691 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
692 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
693
694 void detach_selection(HTMLDocumentNode*);
695 void detach_ranges(HTMLDocumentNode*);
696 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
697
698 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
699
700 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*);
701
702 HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL);
703 HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*);
704 HTMLElement *HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
705 HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
706 HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*);
707 HTMLElement *HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*);
708 HTMLElement *HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
709 HTMLElement *HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
710 HTMLElement *HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
711 HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
712 HTMLElement *HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
713 HTMLElement *HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
714 HTMLElement *HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
715 HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
716 HTMLElement *HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
717
718 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
719 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
720 void HTMLElement2_Init(HTMLElement*);
721 void HTMLElement3_Init(HTMLElement*);
722 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
723 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLWindow*,dispex_static_data_t*);
724
725 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
726 void HTMLDOMNode_destructor(HTMLDOMNode*);
727
728 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
729 void HTMLElement_destructor(HTMLDOMNode*);
730
731 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
732 void HTMLFrameBase_destructor(HTMLFrameBase*);
733
734 HTMLDOMNode *get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL);
735 void release_nodes(HTMLDocumentNode*);
736
737 void release_script_hosts(HTMLWindow*);
738 void connect_scripts(HTMLWindow*);
739 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
740 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
741 void set_script_mode(HTMLWindow*,SCRIPTMODE);
742 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
743 IDispatch *get_script_disp(ScriptHost*);
744
745 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
746 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
747 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
748
749 /* commands */
750 typedef struct {
751 DWORD id;
752 HRESULT (*query)(HTMLDocument*,OLECMD*);
753 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
754 } cmdtable_t;
755
756 extern const cmdtable_t editmode_cmds[];
757
758 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
759
760 /* timer */
761 #define UPDATE_UI 0x0001
762 #define UPDATE_TITLE 0x0002
763
764 void update_doc(HTMLDocument*,DWORD);
765 void update_title(HTMLDocumentObj*);
766
767 /* editor */
768 void init_editor(HTMLDocument*);
769 void set_ns_editmode(NSContainer*);
770 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
771 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
772 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
773 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
774 void handle_edit_load(HTMLDocument*);
775 HRESULT editor_is_dirty(HTMLDocument*);
776 void set_dirty(HTMLDocument*,VARIANT_BOOL);
777
778 extern DWORD mshtml_tls;
779
780 typedef struct task_t task_t;
781 typedef void (*task_proc_t)(task_t*);
782
783 struct task_t {
784 LONG target_magic;
785 task_proc_t proc;
786 struct task_t *next;
787 };
788
789 typedef struct {
790 task_t header;
791 HTMLDocumentObj *doc;
792 } docobj_task_t;
793
794 typedef struct {
795 HWND thread_hwnd;
796 task_t *task_queue_head;
797 task_t *task_queue_tail;
798 struct list timer_list;
799 } thread_data_t;
800
801 thread_data_t *get_thread_data(BOOL);
802 HWND get_thread_hwnd(void);
803
804 LONG get_task_target_magic(void);
805 void push_task(task_t*,task_proc_t,LONG);
806 void remove_target_tasks(LONG);
807
808 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
809 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
810
811 void release_typelib(void);
812 HRESULT call_disp_func(IDispatch*,DISPPARAMS*);
813
814 const char *debugstr_variant(const VARIANT*);
815
816 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
817 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
818 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
819 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
820 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
821
822 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
823
824 /* memory allocation functions */
825
826 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
827 {
828 return HeapAlloc(GetProcessHeap(), 0, len);
829 }
830
831 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
832 {
833 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
834 }
835
836 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
837 {
838 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
839 }
840
841 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
842 {
843 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
844 }
845
846 static inline BOOL heap_free(void *mem)
847 {
848 return HeapFree(GetProcessHeap(), 0, mem);
849 }
850
851 static inline LPWSTR heap_strdupW(LPCWSTR str)
852 {
853 LPWSTR ret = NULL;
854
855 if(str) {
856 DWORD size;
857
858 size = (strlenW(str)+1)*sizeof(WCHAR);
859 ret = heap_alloc(size);
860 memcpy(ret, str, size);
861 }
862
863 return ret;
864 }
865
866 static inline char *heap_strdupA(const char *str)
867 {
868 char *ret = NULL;
869
870 if(str) {
871 DWORD size;
872
873 size = strlen(str)+1;
874 ret = heap_alloc(size);
875 memcpy(ret, str, size);
876 }
877
878 return ret;
879 }
880
881 static inline WCHAR *heap_strdupAtoW(const char *str)
882 {
883 LPWSTR ret = NULL;
884
885 if(str) {
886 DWORD len;
887
888 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
889 ret = heap_alloc(len*sizeof(WCHAR));
890 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
891 }
892
893 return ret;
894 }
895
896 static inline char *heap_strdupWtoA(LPCWSTR str)
897 {
898 char *ret = NULL;
899
900 if(str) {
901 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
902 ret = heap_alloc(size);
903 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
904 }
905
906 return ret;
907 }
908
909 static inline void windowref_addref(windowref_t *ref)
910 {
911 InterlockedIncrement(&ref->ref);
912 }
913
914 static inline void windowref_release(windowref_t *ref)
915 {
916 if(!InterlockedDecrement(&ref->ref))
917 heap_free(ref);
918 }
919
920 HINSTANCE get_shdoclc(void);
921
922 extern HINSTANCE hInst;