push aea352fc3df615e3f4b48daf6f897ea93ad1fffd
[wine/hacks.git] / dlls / mshtml / mshtml_private.h
blob244a0e468d1eda8878c765551096c59e0805b556
1 /*
2 * Copyright 2005-2006 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 "docobj.h"
20 #include "mshtml.h"
21 #include "mshtmhst.h"
22 #include "hlink.h"
24 #include "wine/list.h"
26 #ifdef INIT_GUID
27 #include "initguid.h"
28 #endif
30 #include "nsiface.h"
32 #define GENERATE_MSHTML_NS_FAILURE(code) \
33 ((nsresult) ((PRUint32)(1<<31) | ((PRUint32)(0x45+6)<<16) | (PRUint32)(code)))
35 #define NS_OK ((nsresult)0x00000000L)
36 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
37 #define NS_NOINTERFACE ((nsresult)0x80004002L)
38 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
39 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
40 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
41 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
43 #define WINE_NS_LOAD_FROM_MONIKER GENERATE_MSHTML_NS_FAILURE(0)
45 #define NS_FAILED(res) ((res) & 0x80000000)
46 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
48 #define NSAPI WINAPI
50 #define NS_ELEMENT_NODE 1
51 #define NS_DOCUMENT_NODE 9
53 typedef struct HTMLDOMNode HTMLDOMNode;
54 typedef struct ConnectionPoint ConnectionPoint;
55 typedef struct BSCallback BSCallback;
57 typedef struct {
58 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
60 LONG ref;
62 HTMLDocument *doc;
63 nsIDOMWindow *nswindow;
65 struct list entry;
66 } HTMLWindow;
68 typedef enum {
69 UNKNOWN_USERMODE,
70 BROWSEMODE,
71 EDITMODE
72 } USERMODE;
74 typedef struct {
75 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
77 ConnectionPoint *cp_list;
78 IUnknown *outer;
79 } ConnectionPointContainer;
81 struct ConnectionPoint {
82 const IConnectionPointVtbl *lpConnectionPointVtbl;
84 IConnectionPointContainer *container;
86 union {
87 IUnknown *unk;
88 IDispatch *disp;
89 IPropertyNotifySink *propnotif;
90 } *sinks;
91 DWORD sinks_size;
93 IID iid;
95 ConnectionPoint *next;
98 struct HTMLDocument {
99 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
100 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
101 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
102 const IPersistFileVtbl *lpPersistFileVtbl;
103 const IMonikerPropVtbl *lpMonikerPropVtbl;
104 const IOleObjectVtbl *lpOleObjectVtbl;
105 const IOleDocumentVtbl *lpOleDocumentVtbl;
106 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
107 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
108 const IViewObject2Vtbl *lpViewObject2Vtbl;
109 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
110 const IServiceProviderVtbl *lpServiceProviderVtbl;
111 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
112 const IOleControlVtbl *lpOleControlVtbl;
113 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
114 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
116 LONG ref;
118 NSContainer *nscontainer;
119 HTMLWindow *window;
121 IOleClientSite *client;
122 IDocHostUIHandler *hostui;
123 IOleInPlaceSite *ipsite;
124 IOleInPlaceFrame *frame;
126 BSCallback *bscallback;
127 IMoniker *mon;
128 BSTR url;
130 HWND hwnd;
131 HWND tooltips_hwnd;
133 DOCHOSTUIINFO hostinfo;
135 USERMODE usermode;
136 READYSTATE readystate;
137 BOOL in_place_active;
138 BOOL ui_active;
139 BOOL window_active;
140 BOOL has_key_path;
141 BOOL container_locked;
142 BOOL focus;
144 DWORD update;
146 ConnectionPointContainer cp_container;
147 ConnectionPoint cp_htmldocevents;
148 ConnectionPoint cp_htmldocevents2;
149 ConnectionPoint cp_propnotif;
151 HTMLDOMNode *nodes;
154 typedef struct {
155 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
156 NSContainer *This;
157 } nsEventListener;
159 struct NSContainer {
160 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
161 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
162 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
163 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
164 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
165 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
166 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
167 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
169 nsEventListener blur_listener;
170 nsEventListener focus_listener;
171 nsEventListener keypress_listener;
172 nsEventListener load_listener;
174 nsIWebBrowser *webbrowser;
175 nsIWebNavigation *navigation;
176 nsIBaseWindow *window;
177 nsIWebBrowserFocus *focus;
179 nsIController *editor_controller;
181 LONG ref;
183 NSContainer *parent;
184 HTMLDocument *doc;
186 nsIURIContentListener *content_listener;
188 HWND hwnd;
190 BSCallback *bscallback; /* hack */
193 typedef struct {
194 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
195 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
197 LONG ref;
199 nsIChannel *channel;
200 nsIHttpChannel *http_channel;
201 nsIWineURI *uri;
202 nsIInputStream *post_data_stream;
203 nsILoadGroup *load_group;
204 nsIInterfaceRequestor *notif_callback;
205 nsLoadFlags load_flags;
206 nsIURI *original_uri;
207 char *content;
208 char *charset;
209 } nsChannel;
211 typedef struct {
212 const nsIInputStreamVtbl *lpInputStreamVtbl;
214 LONG ref;
216 char buf[1024];
217 DWORD buf_size;
218 } nsProtocolStream;
220 struct BSCallback {
221 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
222 const IServiceProviderVtbl *lpServiceProviderVtbl;
223 const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
224 const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
226 LONG ref;
228 LPWSTR headers;
229 HGLOBAL post_data;
230 ULONG post_data_len;
231 ULONG readed;
233 nsChannel *nschannel;
234 nsIStreamListener *nslistener;
235 nsISupports *nscontext;
237 IMoniker *mon;
238 IBinding *binding;
240 HTMLDocument *doc;
242 nsProtocolStream *nsstream;
245 struct HTMLDOMNode {
246 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
248 void (*destructor)(IUnknown*);
250 enum {
251 NT_UNKNOWN,
252 NT_HTMLELEM
253 } node_type;
255 union {
256 IUnknown *unk;
257 IHTMLElement *elem;
258 } impl;
260 nsIDOMNode *nsnode;
261 HTMLDocument *doc;
263 HTMLDOMNode *next;
266 typedef struct {
267 const IHTMLElementVtbl *lpHTMLElementVtbl;
268 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
270 void (*destructor)(IUnknown*);
272 nsIDOMHTMLElement *nselem;
273 HTMLDOMNode *node;
275 IUnknown *impl;
276 } HTMLElement;
278 typedef struct {
279 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
281 HTMLElement *element;
282 } HTMLTextContainer;
284 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
286 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
287 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
288 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
289 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
290 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
291 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
292 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
293 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
294 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
295 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
296 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
297 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
298 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
299 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
300 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
301 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
302 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
303 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
304 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
305 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
306 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
308 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
309 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
310 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
311 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
312 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
313 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
314 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
315 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
316 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
318 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
319 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
320 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
322 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
323 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
324 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
326 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
327 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
328 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
330 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
332 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
334 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
335 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
337 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
338 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
340 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
341 void HTMLDocument_Persist_Init(HTMLDocument*);
342 void HTMLDocument_OleCmd_Init(HTMLDocument*);
343 void HTMLDocument_OleObj_Init(HTMLDocument*);
344 void HTMLDocument_View_Init(HTMLDocument*);
345 void HTMLDocument_Window_Init(HTMLDocument*);
346 void HTMLDocument_Service_Init(HTMLDocument*);
347 void HTMLDocument_Hlink_Init(HTMLDocument*);
349 void ConnectionPoint_Init(ConnectionPoint*,IConnectionPointContainer*,REFIID,ConnectionPoint*);
350 void ConnectionPointContainer_Init(ConnectionPointContainer*,ConnectionPoint*,IUnknown*);
351 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
353 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
354 void NSContainer_Release(NSContainer*);
356 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
357 void show_context_menu(HTMLDocument*,DWORD,POINT*);
358 void notif_focus(HTMLDocument*);
360 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
361 void hide_tooltip(HTMLDocument*);
362 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
364 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
366 void close_gecko(void);
367 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
368 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
370 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
372 void call_property_onchanged(ConnectionPoint*,DISPID);
374 void *nsalloc(size_t);
375 void nsfree(void*);
377 void nsACString_Init(nsACString*,const char*);
378 void nsACString_SetData(nsACString*,const char*);
379 PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
380 void nsACString_Finish(nsACString*);
382 void nsAString_Init(nsAString*,const PRUnichar*);
383 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
384 void nsAString_Finish(nsAString*);
386 nsIInputStream *create_nsstream(const char*,PRInt32);
387 nsICommandParams *create_nscommand_params(void);
388 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
389 nsIController *get_editor_controller(NSContainer*);
390 void init_nsevents(NSContainer*);
392 BSCallback *create_bscallback(IMoniker*);
393 HRESULT start_binding(BSCallback*);
394 HRESULT load_stream(BSCallback*,IStream*);
395 void set_document_bscallback(HTMLDocument*,BSCallback*);
396 void set_current_mon(HTMLDocument*,IMoniker*);
398 IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*);
399 IHTMLTxtRange *HTMLTxtRange_Create(nsIDOMRange*);
400 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
401 IHTMLStyleSheet *HTMLStyleSheet_Create(void);
403 void HTMLElement_Create(HTMLDOMNode*);
404 void HTMLBodyElement_Create(HTMLElement*);
405 void HTMLInputElement_Create(HTMLElement*);
406 void HTMLSelectElement_Create(HTMLElement*);
407 void HTMLTextAreaElement_Create(HTMLElement*);
409 void HTMLElement2_Init(HTMLElement*);
411 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLElement*);
413 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
414 HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
416 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
417 void release_nodes(HTMLDocument*);
419 BOOL install_wine_gecko(void);
421 /* commands */
422 typedef struct {
423 DWORD id;
424 HRESULT (*query)(HTMLDocument*,OLECMD*);
425 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
426 } cmdtable_t;
428 extern const cmdtable_t editmode_cmds[];
430 /* timer */
431 #define UPDATE_UI 0x0001
432 #define UPDATE_TITLE 0x0002
434 void update_doc(HTMLDocument *This, DWORD flags);
435 void update_title(HTMLDocument*);
437 /* editor */
438 void init_editor(HTMLDocument*);
439 void set_ns_editmode(NSContainer*);
440 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
441 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
442 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
443 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
445 extern DWORD mshtml_tls;
447 typedef struct task_t {
448 HTMLDocument *doc;
450 enum {
451 TASK_SETDOWNLOADSTATE,
452 TASK_PARSECOMPLETE,
453 TASK_SETPROGRESS,
454 TASK_START_BINDING
455 } task_id;
457 BSCallback *bscallback;
459 struct task_t *next;
460 } task_t;
462 typedef struct {
463 HWND thread_hwnd;
464 task_t *task_queue_head;
465 task_t *task_queue_tail;
466 } thread_data_t;
468 thread_data_t *get_thread_data(BOOL);
469 HWND get_thread_hwnd(void);
470 void push_task(task_t*);
471 void remove_doc_tasks(const HTMLDocument*);
473 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
474 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
475 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
476 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
477 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
479 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
481 extern LONG module_ref;
482 #define LOCK_MODULE() InterlockedIncrement(&module_ref)
483 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
485 /* memory allocation functions */
487 static inline void *mshtml_alloc(size_t len)
489 return HeapAlloc(GetProcessHeap(), 0, len);
492 static inline void *mshtml_alloc_zero(size_t len)
494 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
497 static inline void *mshtml_realloc(void *mem, size_t len)
499 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
502 static inline BOOL mshtml_free(void *mem)
504 return HeapFree(GetProcessHeap(), 0, mem);
507 HINSTANCE get_shdoclc(void);
509 extern HINSTANCE hInst;