d3d9: Hold the lock in stateblock methods.
[wine.git] / dlls / mshtml / mshtml_private.h
blobb20354c57c9143349065c67d58292485b77ca30e
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 struct HTMLDocument {
75 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
76 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
77 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
78 const IPersistFileVtbl *lpPersistFileVtbl;
79 const IMonikerPropVtbl *lpMonikerPropVtbl;
80 const IOleObjectVtbl *lpOleObjectVtbl;
81 const IOleDocumentVtbl *lpOleDocumentVtbl;
82 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
83 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
84 const IViewObject2Vtbl *lpViewObject2Vtbl;
85 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
86 const IServiceProviderVtbl *lpServiceProviderVtbl;
87 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
88 const IOleControlVtbl *lpOleControlVtbl;
89 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
90 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
91 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
93 LONG ref;
95 NSContainer *nscontainer;
96 HTMLWindow *window;
98 IOleClientSite *client;
99 IDocHostUIHandler *hostui;
100 IOleInPlaceSite *ipsite;
101 IOleInPlaceFrame *frame;
103 BSCallback *bscallback;
104 IMoniker *mon;
105 BSTR url;
107 HWND hwnd;
108 HWND tooltips_hwnd;
110 DOCHOSTUIINFO hostinfo;
112 USERMODE usermode;
113 READYSTATE readystate;
114 BOOL in_place_active;
115 BOOL ui_active;
116 BOOL window_active;
117 BOOL has_key_path;
118 BOOL container_locked;
120 DWORD update;
122 ConnectionPoint *cp_htmldocevents;
123 ConnectionPoint *cp_htmldocevents2;
124 ConnectionPoint *cp_propnotif;
126 HTMLDOMNode *nodes;
129 struct NSContainer {
130 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
131 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
132 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
133 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
134 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
135 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
136 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
137 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
138 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
140 nsIWebBrowser *webbrowser;
141 nsIWebNavigation *navigation;
142 nsIBaseWindow *window;
143 nsIWebBrowserFocus *focus;
145 nsIController *editor_controller;
147 LONG ref;
149 NSContainer *parent;
150 HTMLDocument *doc;
152 nsIURIContentListener *content_listener;
154 HWND hwnd;
156 BSCallback *bscallback; /* hack */
159 typedef struct {
160 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
161 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
163 LONG ref;
165 nsIChannel *channel;
166 nsIHttpChannel *http_channel;
167 nsIWineURI *uri;
168 nsIInputStream *post_data_stream;
169 nsILoadGroup *load_group;
170 nsIInterfaceRequestor *notif_callback;
171 nsLoadFlags load_flags;
172 nsIURI *original_uri;
173 char *content;
174 char *charset;
175 } nsChannel;
177 typedef struct {
178 const nsIInputStreamVtbl *lpInputStreamVtbl;
180 LONG ref;
182 char buf[1024];
183 DWORD buf_size;
184 } nsProtocolStream;
186 struct BSCallback {
187 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
188 const IServiceProviderVtbl *lpServiceProviderVtbl;
189 const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
190 const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
192 LONG ref;
194 LPWSTR headers;
195 HGLOBAL post_data;
196 ULONG post_data_len;
197 ULONG readed;
199 nsChannel *nschannel;
200 nsIStreamListener *nslistener;
201 nsISupports *nscontext;
203 IMoniker *mon;
204 IBinding *binding;
206 HTMLDocument *doc;
208 nsProtocolStream *nsstream;
211 struct HTMLDOMNode {
212 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
214 void (*destructor)(IUnknown*);
216 enum {
217 NT_UNKNOWN,
218 NT_HTMLELEM
219 } node_type;
221 union {
222 IUnknown *unk;
223 IHTMLElement *elem;
224 } impl;
226 nsIDOMNode *nsnode;
227 HTMLDocument *doc;
229 HTMLDOMNode *next;
232 typedef struct {
233 const IHTMLElementVtbl *lpHTMLElementVtbl;
234 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
236 void (*destructor)(IUnknown*);
238 nsIDOMHTMLElement *nselem;
239 HTMLDOMNode *node;
241 IUnknown *impl;
242 } HTMLElement;
244 typedef struct {
245 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
247 HTMLElement *element;
248 } HTMLTextContainer;
250 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
252 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
253 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
254 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
255 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
256 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
257 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
258 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
259 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
260 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
261 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
262 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
263 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
264 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
265 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
266 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
267 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
268 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
269 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
270 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
271 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
272 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
274 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
275 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
276 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
277 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
278 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
279 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
280 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
281 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
282 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
284 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
285 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
286 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
288 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
289 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
290 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
292 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
293 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
294 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
296 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
298 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
300 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
301 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
303 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
304 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
306 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
307 void HTMLDocument_Persist_Init(HTMLDocument*);
308 void HTMLDocument_OleCmd_Init(HTMLDocument*);
309 void HTMLDocument_OleObj_Init(HTMLDocument*);
310 void HTMLDocument_View_Init(HTMLDocument*);
311 void HTMLDocument_Window_Init(HTMLDocument*);
312 void HTMLDocument_Service_Init(HTMLDocument*);
313 void HTMLDocument_Hlink_Init(HTMLDocument*);
314 void HTMLDocument_ConnectionPoints_Init(HTMLDocument*);
316 void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument*);
318 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
319 void NSContainer_Release(NSContainer*);
321 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
322 void show_context_menu(HTMLDocument*,DWORD,POINT*);
324 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
325 void hide_tooltip(HTMLDocument*);
326 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
328 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
330 void close_gecko(void);
331 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
332 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
334 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
336 void call_property_onchanged(ConnectionPoint*,DISPID);
338 void *nsalloc(size_t);
339 void nsfree(void*);
341 void nsACString_Init(nsACString*,const char*);
342 void nsACString_SetData(nsACString*,const char*);
343 PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
344 void nsACString_Finish(nsACString*);
346 void nsAString_Init(nsAString*,const PRUnichar*);
347 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
348 void nsAString_Finish(nsAString*);
350 nsIInputStream *create_nsstream(const char*,PRInt32);
351 nsICommandParams *create_nscommand_params(void);
352 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
354 BSCallback *create_bscallback(IMoniker*);
355 HRESULT start_binding(BSCallback*);
356 HRESULT load_stream(BSCallback*,IStream*);
357 void set_document_bscallback(HTMLDocument*,BSCallback*);
358 void set_current_mon(HTMLDocument*,IMoniker*);
360 IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*);
361 IHTMLTxtRange *HTMLTxtRange_Create(nsIDOMRange*);
362 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
363 IHTMLStyleSheet *HTMLStyleSheet_Create(void);
365 void HTMLElement_Create(HTMLDOMNode*);
366 void HTMLBodyElement_Create(HTMLElement*);
367 void HTMLInputElement_Create(HTMLElement*);
368 void HTMLSelectElement_Create(HTMLElement*);
369 void HTMLTextAreaElement_Create(HTMLElement*);
371 void HTMLElement2_Init(HTMLElement*);
373 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLElement*);
375 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
376 HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
378 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
379 void release_nodes(HTMLDocument*);
381 BOOL install_wine_gecko(void);
383 /* commands */
384 typedef struct {
385 DWORD id;
386 HRESULT (*query)(HTMLDocument*,OLECMD*);
387 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
388 } cmdtable_t;
390 extern const cmdtable_t editmode_cmds[];
392 /* timer */
393 #define UPDATE_UI 0x0001
394 #define UPDATE_TITLE 0x0002
396 void update_doc(HTMLDocument *This, DWORD flags);
397 void update_title(HTMLDocument*);
399 /* editor */
400 void init_editor(HTMLDocument*);
401 void set_ns_editmode(NSContainer*);
402 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
403 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
404 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
405 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
407 extern DWORD mshtml_tls;
409 typedef struct task_t {
410 HTMLDocument *doc;
412 enum {
413 TASK_SETDOWNLOADSTATE,
414 TASK_PARSECOMPLETE,
415 TASK_SETPROGRESS,
416 TASK_START_BINDING
417 } task_id;
419 BSCallback *bscallback;
421 struct task_t *next;
422 } task_t;
424 typedef struct {
425 HWND thread_hwnd;
426 task_t *task_queue_head;
427 task_t *task_queue_tail;
428 } thread_data_t;
430 thread_data_t *get_thread_data(BOOL);
431 HWND get_thread_hwnd(void);
432 void push_task(task_t*);
433 void remove_doc_tasks(const HTMLDocument*);
435 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
436 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
437 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
438 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
439 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
441 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
443 extern LONG module_ref;
444 #define LOCK_MODULE() InterlockedIncrement(&module_ref)
445 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
447 /* memory allocation functions */
449 static inline void *mshtml_alloc(size_t len)
451 return HeapAlloc(GetProcessHeap(), 0, len);
454 static inline void *mshtml_alloc_zero(size_t len)
456 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
459 static inline void *mshtml_realloc(void *mem, size_t len)
461 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
464 static inline BOOL mshtml_free(void *mem)
466 return HeapFree(GetProcessHeap(), 0, mem);
469 HINSTANCE get_shdoclc(void);
471 extern HINSTANCE hInst;