windowscodecs: Add support for converting to 32bppPBGRA.
[wine.git] / dlls / mshtml / mshtml_private.h
blob44b6b1d750519537a60465ddccd6fb9d53d0dad5
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "wingdi.h"
20 #include "docobj.h"
21 #include "docobjectservice.h"
22 #include "comcat.h"
23 #include "mshtml.h"
24 #include "mshtmhst.h"
25 #include "hlink.h"
26 #include "perhist.h"
27 #include "dispex.h"
28 #include "objsafe.h"
30 #include "wine/list.h"
31 #include "wine/unicode.h"
33 #ifdef INIT_GUID
34 #include "initguid.h"
35 #endif
37 #include "nsiface.h"
39 #define NS_ERROR_GENERATE_FAILURE(module,code) \
40 ((nsresult) (((PRUint32)(1<<31)) | ((PRUint32)(module+0x45)<<16) | ((PRUint32)(code))))
42 #define NS_OK ((nsresult)0x00000000L)
43 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
44 #define NS_ERROR_OUT_OF_MEMORY ((nsresult)0x8007000EL)
45 #define NS_NOINTERFACE ((nsresult)0x80004002L)
46 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
47 #define NS_ERROR_NOT_AVAILABLE ((nsresult)0x80040111L)
48 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
49 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
51 #define NS_ERROR_MODULE_NETWORK 6
53 #define NS_BINDING_ABORTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 2)
54 #define NS_ERROR_UNKNOWN_PROTOCOL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 18)
56 #define NS_FAILED(res) ((res) & 0x80000000)
57 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
59 #define NSAPI WINAPI
61 #define MSHTML_E_NODOC 0x800a025c
63 typedef struct HTMLDOMNode HTMLDOMNode;
64 typedef struct ConnectionPoint ConnectionPoint;
65 typedef struct BSCallback BSCallback;
66 typedef struct event_target_t event_target_t;
68 #define TID_LIST \
69 XIID(NULL) \
70 XDIID(DispCEventObj) \
71 XDIID(DispCPlugins) \
72 XDIID(DispDOMChildrenCollection) \
73 XDIID(DispHTMLAnchorElement) \
74 XDIID(DispHTMLBody) \
75 XDIID(DispHTMLCommentElement) \
76 XDIID(DispHTMLCurrentStyle) \
77 XDIID(DispHTMLDocument) \
78 XDIID(DispHTMLDOMAttribute) \
79 XDIID(DispHTMLDOMTextNode) \
80 XDIID(DispHTMLElementCollection) \
81 XDIID(DispHTMLEmbed) \
82 XDIID(DispHTMLFormElement) \
83 XDIID(DispHTMLGenericElement) \
84 XDIID(DispHTMLFrameElement) \
85 XDIID(DispHTMLIFrame) \
86 XDIID(DispHTMLImg) \
87 XDIID(DispHTMLInputElement) \
88 XDIID(DispHTMLLocation) \
89 XDIID(DispHTMLNavigator) \
90 XDIID(DispHTMLObjectElement) \
91 XDIID(DispHTMLOptionElement) \
92 XDIID(DispHTMLScreen) \
93 XDIID(DispHTMLScriptElement) \
94 XDIID(DispHTMLSelectElement) \
95 XDIID(DispHTMLStyle) \
96 XDIID(DispHTMLStyleElement) \
97 XDIID(DispHTMLStyleSheetsCollection) \
98 XDIID(DispHTMLTable) \
99 XDIID(DispHTMLTableRow) \
100 XDIID(DispHTMLTextAreaElement) \
101 XDIID(DispHTMLUnknownElement) \
102 XDIID(DispHTMLWindow2) \
103 XDIID(HTMLDocumentEvents) \
104 XIID(IHTMLAnchorElement) \
105 XIID(IHTMLBodyElement) \
106 XIID(IHTMLBodyElement2) \
107 XIID(IHTMLCommentElement) \
108 XIID(IHTMLCurrentStyle) \
109 XIID(IHTMLCurrentStyle2) \
110 XIID(IHTMLCurrentStyle3) \
111 XIID(IHTMLCurrentStyle4) \
112 XIID(IHTMLDocument2) \
113 XIID(IHTMLDocument3) \
114 XIID(IHTMLDocument4) \
115 XIID(IHTMLDocument5) \
116 XIID(IHTMLDOMAttribute) \
117 XIID(IHTMLDOMChildrenCollection) \
118 XIID(IHTMLDOMNode) \
119 XIID(IHTMLDOMNode2) \
120 XIID(IHTMLDOMTextNode) \
121 XIID(IHTMLElement) \
122 XIID(IHTMLElement2) \
123 XIID(IHTMLElement3) \
124 XIID(IHTMLElement4) \
125 XIID(IHTMLElementCollection) \
126 XIID(IHTMLEmbedElement) \
127 XIID(IHTMLEventObj) \
128 XIID(IHTMLFiltersCollection) \
129 XIID(IHTMLFormElement) \
130 XIID(IHTMLFrameBase) \
131 XIID(IHTMLFrameBase2) \
132 XIID(IHTMLFrameElement3) \
133 XIID(IHTMLGenericElement) \
134 XIID(IHTMLIFrameElement) \
135 XIID(IHTMLImageElementFactory) \
136 XIID(IHTMLImgElement) \
137 XIID(IHTMLInputElement) \
138 XIID(IHTMLLocation) \
139 XIID(IHTMLObjectElement) \
140 XIID(IHTMLOptionElement) \
141 XIID(IHTMLPluginsCollection) \
142 XIID(IHTMLRect) \
143 XIID(IHTMLScreen) \
144 XIID(IHTMLScriptElement) \
145 XIID(IHTMLSelectElement) \
146 XIID(IHTMLStyle) \
147 XIID(IHTMLStyle2) \
148 XIID(IHTMLStyle3) \
149 XIID(IHTMLStyle4) \
150 XIID(IHTMLStyleElement) \
151 XIID(IHTMLStyleSheetsCollection) \
152 XIID(IHTMLTable) \
153 XIID(IHTMLTableRow) \
154 XIID(IHTMLTextAreaElement) \
155 XIID(IHTMLTextContainer) \
156 XIID(IHTMLUniqueName) \
157 XIID(IHTMLWindow2) \
158 XIID(IHTMLWindow3) \
159 XIID(IHTMLWindow4) \
160 XIID(IOmNavigator)
162 typedef enum {
163 #define XIID(iface) iface ## _tid,
164 #define XDIID(iface) iface ## _tid,
165 TID_LIST
166 #undef XIID
167 #undef XDIID
168 LAST_tid
169 } tid_t;
171 typedef struct dispex_data_t dispex_data_t;
172 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
174 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
175 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
176 #define MSHTML_CUSTOM_DISPID_CNT (MSHTML_DISPID_CUSTOM_MAX-MSHTML_DISPID_CUSTOM_MIN)
178 typedef struct DispatchEx DispatchEx;
180 typedef struct {
181 HRESULT (*value)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
182 HRESULT (*get_dispid)(DispatchEx*,BSTR,DWORD,DISPID*);
183 HRESULT (*invoke)(DispatchEx*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
184 } dispex_static_data_vtbl_t;
186 typedef struct {
187 const dispex_static_data_vtbl_t *vtbl;
188 const tid_t disp_tid;
189 dispex_data_t *data;
190 const tid_t* const iface_tids;
191 } dispex_static_data_t;
193 struct DispatchEx {
194 IDispatchEx IDispatchEx_iface;
196 IUnknown *outer;
198 dispex_static_data_t *data;
199 dispex_dynamic_data_t *dynamic_data;
202 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
203 void release_dispex(DispatchEx*);
204 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
205 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
206 HRESULT get_dispids(tid_t,DWORD*,DISPID**);
207 HRESULT remove_prop(DispatchEx*,BSTR,VARIANT_BOOL*);
208 void release_typelib(void);
210 typedef struct HTMLWindow HTMLWindow;
211 typedef struct HTMLDocumentNode HTMLDocumentNode;
212 typedef struct HTMLDocumentObj HTMLDocumentObj;
213 typedef struct HTMLFrameBase HTMLFrameBase;
214 typedef struct NSContainer NSContainer;
216 typedef enum {
217 SCRIPTMODE_GECKO,
218 SCRIPTMODE_ACTIVESCRIPT
219 } SCRIPTMODE;
221 typedef struct ScriptHost ScriptHost;
223 typedef enum {
224 GLOBAL_SCRIPTVAR,
225 GLOBAL_ELEMENTVAR
226 } global_prop_type_t;
228 typedef struct {
229 global_prop_type_t type;
230 WCHAR *name;
231 ScriptHost *script_host;
232 DISPID id;
233 } global_prop_t;
235 typedef struct {
236 IHTMLOptionElementFactory IHTMLOptionElementFactory_iface;
238 LONG ref;
240 HTMLWindow *window;
241 } HTMLOptionElementFactory;
243 typedef struct {
244 DispatchEx dispex;
245 IHTMLImageElementFactory IHTMLImageElementFactory_iface;
247 LONG ref;
249 HTMLWindow *window;
250 } HTMLImageElementFactory;
252 struct HTMLLocation {
253 DispatchEx dispex;
254 IHTMLLocation IHTMLLocation_iface;
256 LONG ref;
258 HTMLWindow *window;
261 typedef struct {
262 HTMLWindow *window;
263 LONG ref;
264 } windowref_t;
266 typedef struct nsChannelBSC nsChannelBSC;
268 struct HTMLWindow {
269 DispatchEx dispex;
270 IHTMLWindow2 IHTMLWindow2_iface;
271 IHTMLWindow3 IHTMLWindow3_iface;
272 IHTMLWindow4 IHTMLWindow4_iface;
273 IHTMLPrivateWindow IHTMLPrivateWindow_iface;
274 IDispatchEx IDispatchEx_iface;
275 IServiceProvider IServiceProvider_iface;
277 LONG ref;
279 windowref_t *window_ref;
280 LONG task_magic;
282 HTMLDocumentNode *doc;
283 HTMLDocumentObj *doc_obj;
284 nsIDOMWindow *nswindow;
285 HTMLWindow *parent;
286 HTMLFrameBase *frame_element;
287 READYSTATE readystate;
289 nsChannelBSC *bscallback;
290 IMoniker *mon;
291 LPOLESTR url;
293 IHTMLEventObj *event;
295 SCRIPTMODE scriptmode;
296 struct list script_hosts;
298 IInternetSecurityManager *secmgr;
300 HTMLOptionElementFactory *option_factory;
301 HTMLImageElementFactory *image_factory;
302 HTMLLocation *location;
303 IHTMLScreen *screen;
305 global_prop_t *global_props;
306 DWORD global_prop_cnt;
307 DWORD global_prop_size;
309 struct list children;
310 struct list sibling_entry;
311 struct list entry;
314 typedef enum {
315 UNKNOWN_USERMODE,
316 BROWSEMODE,
317 EDITMODE
318 } USERMODE;
320 typedef struct _cp_static_data_t {
321 tid_t tid;
322 void (*on_advise)(IUnknown*,struct _cp_static_data_t*);
323 DWORD id_cnt;
324 DISPID *ids;
325 } cp_static_data_t;
327 typedef struct ConnectionPointContainer {
328 IConnectionPointContainer IConnectionPointContainer_iface;
330 ConnectionPoint *cp_list;
331 IUnknown *outer;
332 struct ConnectionPointContainer *forward_container;
333 } ConnectionPointContainer;
335 struct ConnectionPoint {
336 IConnectionPoint IConnectionPoint_iface;
338 ConnectionPointContainer *container;
340 union {
341 IUnknown *unk;
342 IDispatch *disp;
343 IPropertyNotifySink *propnotif;
344 } *sinks;
345 DWORD sinks_size;
347 const IID *iid;
348 cp_static_data_t *data;
350 ConnectionPoint *next;
353 struct HTMLDocument {
354 IHTMLDocument2 IHTMLDocument2_iface;
355 IHTMLDocument3 IHTMLDocument3_iface;
356 IHTMLDocument4 IHTMLDocument4_iface;
357 IHTMLDocument5 IHTMLDocument5_iface;
358 IHTMLDocument6 IHTMLDocument6_iface;
359 IPersistMoniker IPersistMoniker_iface;
360 IPersistFile IPersistFile_iface;
361 IPersistHistory IPersistHistory_iface;
362 IMonikerProp IMonikerProp_iface;
363 IOleObject IOleObject_iface;
364 IOleDocument IOleDocument_iface;
365 IOleDocumentView IOleDocumentView_iface;
366 IOleInPlaceActiveObject IOleInPlaceActiveObject_iface;
367 IViewObjectEx IViewObjectEx_iface;
368 IOleInPlaceObjectWindowless IOleInPlaceObjectWindowless_iface;
369 IServiceProvider IServiceProvider_iface;
370 IOleCommandTarget IOleCommandTarget_iface;
371 IOleControl IOleControl_iface;
372 IHlinkTarget IHlinkTarget_iface;
373 IPersistStreamInit IPersistStreamInit_iface;
374 IDispatchEx IDispatchEx_iface;
375 ISupportErrorInfo ISupportErrorInfo_iface;
376 IObjectWithSite IObjectWithSite_iface;
377 IOleContainer IOleContainer_iface;
378 IObjectSafety IObjectSafety_iface;
380 IUnknown *unk_impl;
381 IDispatchEx *dispex;
383 HTMLDocumentObj *doc_obj;
384 HTMLDocumentNode *doc_node;
386 HTMLWindow *window;
388 LONG task_magic;
390 ConnectionPointContainer cp_container;
391 ConnectionPoint cp_htmldocevents;
392 ConnectionPoint cp_htmldocevents2;
393 ConnectionPoint cp_propnotif;
394 ConnectionPoint cp_dispatch;
396 IOleAdviseHolder *advise_holder;
399 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
401 return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
404 static inline ULONG htmldoc_addref(HTMLDocument *This)
406 return IUnknown_AddRef(This->unk_impl);
409 static inline ULONG htmldoc_release(HTMLDocument *This)
411 return IUnknown_Release(This->unk_impl);
414 struct HTMLDocumentObj {
415 HTMLDocument basedoc;
416 DispatchEx dispex;
417 ICustomDoc ICustomDoc_iface;
419 LONG ref;
421 NSContainer *nscontainer;
423 IOleClientSite *client;
424 IDocHostUIHandler *hostui;
425 BOOL custom_hostui;
426 IOleInPlaceSite *ipsite;
427 IOleInPlaceFrame *frame;
428 IOleInPlaceUIWindow *ip_window;
429 IAdviseSink *view_sink;
430 IDocObjectService *doc_object_service;
432 DOCHOSTUIINFO hostinfo;
434 IOleUndoManager *undomgr;
436 HWND hwnd;
437 HWND tooltips_hwnd;
439 BOOL request_uiactivate;
440 BOOL in_place_active;
441 BOOL ui_active;
442 BOOL window_active;
443 BOOL hostui_setup;
444 BOOL container_locked;
445 BOOL focus;
446 INT download_state;
448 USERMODE usermode;
449 LPWSTR mime;
451 DWORD update;
454 struct NSContainer {
455 nsIWebBrowserChrome nsIWebBrowserChrome_iface;
456 nsIContextMenuListener nsIContextMenuListener_iface;
457 nsIURIContentListener nsIURIContentListener_iface;
458 nsIEmbeddingSiteWindow nsIEmbeddingSiteWindow_iface;
459 nsITooltipListener nsITooltipListener_iface;
460 nsIInterfaceRequestor nsIInterfaceRequestor_iface;
461 nsIWeakReference nsIWeakReference_iface;
462 nsISupportsWeakReference nsISupportsWeakReference_iface;
464 nsIWebBrowser *webbrowser;
465 nsIWebNavigation *navigation;
466 nsIBaseWindow *window;
467 nsIWebBrowserFocus *focus;
469 nsIEditor *editor;
470 nsIController *editor_controller;
472 LONG ref;
474 NSContainer *parent;
475 HTMLDocumentObj *doc;
477 nsIURIContentListener *content_listener;
479 HWND hwnd;
482 typedef struct nsWineURI nsWineURI;
484 HRESULT set_wine_url(nsWineURI*,LPCWSTR);
485 nsresult on_start_uri_open(NSContainer*,nsIURI*,PRBool*);
487 /* Keep sync with request_method_strings in nsio.c */
488 typedef enum {
489 METHOD_GET,
490 METHOD_PUT,
491 METHOD_POST
492 } REQUEST_METHOD;
494 typedef struct {
495 nsIHttpChannel nsIHttpChannel_iface;
496 nsIUploadChannel nsIUploadChannel_iface;
497 nsIHttpChannelInternal nsIHttpChannelInternal_iface;
499 LONG ref;
501 nsWineURI *uri;
502 nsIInputStream *post_data_stream;
503 BOOL post_data_contains_headers;
504 nsILoadGroup *load_group;
505 nsIInterfaceRequestor *notif_callback;
506 nsISupports *owner;
507 nsLoadFlags load_flags;
508 nsIURI *original_uri;
509 nsIURI *referrer;
510 char *content_type;
511 char *charset;
512 PRUint32 response_status;
513 REQUEST_METHOD request_method;
514 struct list response_headers;
515 struct list request_headers;
516 UINT url_scheme;
517 } nsChannel;
519 typedef struct {
520 struct list entry;
521 WCHAR *header;
522 WCHAR *data;
523 } http_header_t;
525 HRESULT set_http_header(struct list*,const WCHAR*,int,const WCHAR*,int);
527 typedef struct {
528 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
529 void (*destructor)(HTMLDOMNode*);
530 HRESULT (*clone)(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
531 event_target_t **(*get_event_target)(HTMLDOMNode*);
532 HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
533 HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
534 HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
535 HRESULT (*get_document)(HTMLDOMNode*,IDispatch**);
536 HRESULT (*get_readystate)(HTMLDOMNode*,BSTR*);
537 HRESULT (*get_dispid)(HTMLDOMNode*,BSTR,DWORD,DISPID*);
538 HRESULT (*invoke)(HTMLDOMNode*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
539 HRESULT (*bind_to_tree)(HTMLDOMNode*);
540 } NodeImplVtbl;
542 struct HTMLDOMNode {
543 DispatchEx dispex;
544 IHTMLDOMNode IHTMLDOMNode_iface;
545 IHTMLDOMNode2 IHTMLDOMNode2_iface;
546 const NodeImplVtbl *vtbl;
548 LONG ref;
550 nsIDOMNode *nsnode;
551 HTMLDocumentNode *doc;
552 event_target_t *event_target;
553 ConnectionPointContainer *cp_container;
555 HTMLDOMNode *next;
558 typedef struct {
559 HTMLDOMNode node;
560 ConnectionPointContainer cp_container;
562 IHTMLElement IHTMLElement_iface;
563 IHTMLElement2 IHTMLElement2_iface;
564 IHTMLElement3 IHTMLElement3_iface;
565 IHTMLElement4 IHTMLElement4_iface;
567 nsIDOMHTMLElement *nselem;
568 HTMLStyle *style;
569 struct list attrs;
570 } HTMLElement;
572 #define HTMLELEMENT_TIDS \
573 IHTMLDOMNode_tid, \
574 IHTMLDOMNode2_tid, \
575 IHTMLElement_tid, \
576 IHTMLElement2_tid, \
577 IHTMLElement3_tid, \
578 IHTMLElement4_tid
580 typedef struct {
581 HTMLElement element;
583 IHTMLTextContainer IHTMLTextContainer_iface;
585 ConnectionPoint cp;
586 } HTMLTextContainer;
588 struct HTMLFrameBase {
589 HTMLElement element;
591 IHTMLFrameBase IHTMLFrameBase_iface;
592 IHTMLFrameBase2 IHTMLFrameBase2_iface;
594 HTMLWindow *content_window;
596 nsIDOMHTMLFrameElement *nsframe;
597 nsIDOMHTMLIFrameElement *nsiframe;
600 typedef struct nsDocumentEventListener nsDocumentEventListener;
602 struct HTMLDocumentNode {
603 HTMLDOMNode node;
604 HTMLDocument basedoc;
606 IInternetHostSecurityManager IInternetHostSecurityManager_iface;
608 nsIDocumentObserver nsIDocumentObserver_iface;
610 LONG ref;
612 nsIDOMHTMLDocument *nsdoc;
613 HTMLDOMNode *nodes;
614 BOOL content_ready;
615 event_target_t *body_event_target;
617 ICatInformation *catmgr;
618 nsDocumentEventListener *nsevent_listener;
619 BOOL *event_vector;
621 BOOL skip_mutation_notif;
623 struct list bindings;
624 struct list selection_list;
625 struct list range_list;
626 struct list plugin_hosts;
629 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
630 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
631 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
632 HRESULT create_document_fragment(nsIDOMNode*,HTMLDocumentNode*,HTMLDocumentNode**);
634 HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**);
635 void update_window_doc(HTMLWindow*);
636 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
637 nsIDOMWindow *get_nsdoc_window(nsIDOMDocument*);
638 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
639 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
640 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
641 IOmNavigator *OmNavigator_Create(void);
642 HRESULT HTMLScreen_Create(IHTMLScreen**);
644 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
645 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
646 void HTMLDocument_Persist_Init(HTMLDocument*);
647 void HTMLDocument_OleCmd_Init(HTMLDocument*);
648 void HTMLDocument_OleObj_Init(HTMLDocument*);
649 void HTMLDocument_View_Init(HTMLDocument*);
650 void HTMLDocument_Window_Init(HTMLDocument*);
651 void HTMLDocument_Service_Init(HTMLDocument*);
652 void HTMLDocument_Hlink_Init(HTMLDocument*);
654 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
656 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
658 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*);
659 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
660 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
662 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
663 void NSContainer_Release(NSContainer*);
664 nsresult create_chrome_window(nsIWebBrowserChrome*,nsIWebBrowserChrome**);
666 void init_mutation(nsIComponentManager*);
667 void init_document_mutation(HTMLDocumentNode*);
668 void release_document_mutation(HTMLDocumentNode*);
670 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
671 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
672 void notif_focus(HTMLDocumentObj*);
674 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
675 void hide_tooltip(HTMLDocumentObj*);
676 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
678 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
680 BOOL load_gecko(BOOL);
681 void close_gecko(void);
682 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
683 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
684 void release_nsio(void);
685 BOOL is_gecko_path(const char*);
687 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
688 HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**);
689 HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD);
691 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsChannel*,DWORD,BOOL*);
692 HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
693 HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
694 HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL);
696 void call_property_onchanged(ConnectionPoint*,DISPID);
697 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
699 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
700 void nsfree(void*);
702 void nsACString_InitDepend(nsACString*,const char*);
703 void nsACString_SetData(nsACString*,const char*);
704 PRUint32 nsACString_GetData(const nsACString*,const char**);
705 void nsACString_Finish(nsACString*);
707 BOOL nsAString_Init(nsAString*,const PRUnichar*);
708 void nsAString_InitDepend(nsAString*,const PRUnichar*);
709 void nsAString_SetData(nsAString*,const PRUnichar*);
710 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
711 void nsAString_Finish(nsAString*);
712 HRESULT return_nsstr(nsresult,nsAString*,BSTR*);
714 nsICommandParams *create_nscommand_params(void);
715 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
716 void get_editor_controller(NSContainer*);
717 nsresult get_nsinterface(nsISupports*,REFIID,void**);
719 void init_nsevents(HTMLDocumentNode*);
720 void release_nsevents(HTMLDocumentNode*);
721 void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR);
723 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
724 void set_current_mon(HTMLWindow*,IMoniker*);
725 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
726 HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*);
727 void abort_document_bindings(HTMLDocumentNode*);
729 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
731 HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**);
732 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
733 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
734 IMoniker *get_channelbsc_mon(nsChannelBSC*);
736 void set_ready_state(HTMLWindow*,READYSTATE);
738 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
739 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
740 HRESULT HTMLStyle_Create(nsIDOMCSSStyleDeclaration*,HTMLStyle**);
741 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
742 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
744 void detach_selection(HTMLDocumentNode*);
745 void detach_ranges(HTMLDocumentNode*);
746 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
748 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
750 HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**);
752 typedef struct {
753 DispatchEx dispex;
754 IHTMLDOMAttribute IHTMLDOMAttribute_iface;
756 LONG ref;
758 DISPID dispid;
759 HTMLElement *elem;
760 struct list entry;
761 } HTMLDOMAttribute;
763 HRESULT HTMLDOMAttribute_Create(HTMLElement*,DISPID,HTMLDOMAttribute**);
765 HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**);
766 HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**);
767 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
768 HRESULT HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
769 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
770 HRESULT HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
771 HRESULT HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
772 HRESULT HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
773 HRESULT HTMLStyleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
774 HRESULT HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
775 HRESULT HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
776 HRESULT HTMLObjectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
777 HRESULT HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
778 HRESULT HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
779 HRESULT HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
780 HRESULT HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
781 HRESULT HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
782 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
783 HRESULT HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
785 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
786 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
787 void HTMLElement2_Init(HTMLElement*);
788 void HTMLElement3_Init(HTMLElement*);
789 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
790 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
792 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
793 void HTMLDOMNode_destructor(HTMLDOMNode*);
795 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
796 void HTMLElement_destructor(HTMLDOMNode*);
797 HRESULT HTMLElement_clone(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
799 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
800 void HTMLFrameBase_destructor(HTMLFrameBase*);
802 HRESULT get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLDOMNode**);
803 void release_nodes(HTMLDocumentNode*);
805 void release_script_hosts(HTMLWindow*);
806 void connect_scripts(HTMLWindow*);
807 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
808 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
809 HRESULT exec_script(HTMLWindow*,const WCHAR*,const WCHAR*,VARIANT*);
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*);
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*);
819 /* commands */
820 typedef struct {
821 DWORD id;
822 HRESULT (*query)(HTMLDocument*,OLECMD*);
823 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
824 } cmdtable_t;
826 extern const cmdtable_t editmode_cmds[];
828 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
830 /* timer */
831 #define UPDATE_UI 0x0001
832 #define UPDATE_TITLE 0x0002
834 void update_doc(HTMLDocument*,DWORD);
835 void update_title(HTMLDocumentObj*);
837 /* editor */
838 void init_editor(HTMLDocument*);
839 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
840 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
841 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
842 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
843 void handle_edit_load(HTMLDocument*);
844 HRESULT editor_is_dirty(HTMLDocument*);
845 void set_dirty(HTMLDocument*,VARIANT_BOOL);
847 extern DWORD mshtml_tls;
849 typedef struct task_t task_t;
850 typedef void (*task_proc_t)(task_t*);
852 struct task_t {
853 LONG target_magic;
854 task_proc_t proc;
855 struct task_t *next;
858 typedef struct {
859 task_t header;
860 HTMLDocumentObj *doc;
861 } docobj_task_t;
863 typedef struct {
864 HWND thread_hwnd;
865 task_t *task_queue_head;
866 task_t *task_queue_tail;
867 struct list timer_list;
868 } thread_data_t;
870 thread_data_t *get_thread_data(BOOL);
871 HWND get_thread_hwnd(void);
873 LONG get_task_target_magic(void);
874 void push_task(task_t*,task_proc_t,LONG);
875 void remove_target_tasks(LONG);
877 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
878 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
880 const char *debugstr_variant(const VARIANT*);
882 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
883 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
884 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
885 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
886 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
888 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
890 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
892 /* memory allocation functions */
894 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
896 return HeapAlloc(GetProcessHeap(), 0, len);
899 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
901 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
904 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
906 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
909 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
911 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
914 static inline BOOL heap_free(void *mem)
916 return HeapFree(GetProcessHeap(), 0, mem);
919 static inline LPWSTR heap_strdupW(LPCWSTR str)
921 LPWSTR ret = NULL;
923 if(str) {
924 DWORD size;
926 size = (strlenW(str)+1)*sizeof(WCHAR);
927 ret = heap_alloc(size);
928 memcpy(ret, str, size);
931 return ret;
934 static inline LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
936 LPWSTR ret = NULL;
938 if(str) {
939 ret = heap_alloc((len+1)*sizeof(WCHAR));
940 memcpy(ret, str, len*sizeof(WCHAR));
941 ret[len] = 0;
944 return ret;
947 static inline char *heap_strdupA(const char *str)
949 char *ret = NULL;
951 if(str) {
952 DWORD size;
954 size = strlen(str)+1;
955 ret = heap_alloc(size);
956 memcpy(ret, str, size);
959 return ret;
962 static inline WCHAR *heap_strdupAtoW(const char *str)
964 LPWSTR ret = NULL;
966 if(str) {
967 DWORD len;
969 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
970 ret = heap_alloc(len*sizeof(WCHAR));
971 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
974 return ret;
977 static inline char *heap_strdupWtoA(LPCWSTR str)
979 char *ret = NULL;
981 if(str) {
982 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
983 ret = heap_alloc(size);
984 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
987 return ret;
990 static inline void windowref_addref(windowref_t *ref)
992 InterlockedIncrement(&ref->ref);
995 static inline void windowref_release(windowref_t *ref)
997 if(!InterlockedDecrement(&ref->ref))
998 heap_free(ref);
1001 HDC get_display_dc(void);
1002 HINSTANCE get_shdoclc(void);
1003 void set_statustext(HTMLDocumentObj*,INT,LPCWSTR);
1005 extern HINSTANCE hInst;