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