dbghelp: Sparse array speed up.
[wine/wine-kai.git] / dlls / mshtml / mshtml_private.h
bloba4631293b28dc05bd4481470c7ec28897f2bb921
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 #ifdef INIT_GUID
25 #include "initguid.h"
26 #endif
28 #include "nsiface.h"
30 #define GENERATE_MSHTML_NS_FAILURE(code) \
31 ((nsresult) ((PRUint32)(1<<31) | ((PRUint32)(0x45+6)<<16) | (PRUint32)(code)))
33 #define NS_OK ((nsresult)0x00000000L)
34 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
35 #define NS_NOINTERFACE ((nsresult)0x80004002L)
36 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
37 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
38 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
39 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
41 #define WINE_NS_LOAD_FROM_MONIKER GENERATE_MSHTML_NS_FAILURE(0)
43 #define NS_FAILED(res) ((res) & 0x80000000)
44 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
46 #define NSAPI WINAPI
48 #define NS_ELEMENT_NODE 1
49 #define NS_DOCUMENT_NODE 9
51 typedef struct HTMLDOMNode HTMLDOMNode;
52 typedef struct ConnectionPoint ConnectionPoint;
53 typedef struct BSCallback BSCallback;
55 typedef struct {
56 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
58 LONG ref;
60 HTMLDocument *doc;
61 nsIDOMWindow *nswindow;
62 } HTMLWindow;
64 typedef enum {
65 UNKNOWN_USERMODE,
66 BROWSEMODE,
67 EDITMODE
68 } USERMODE;
70 struct HTMLDocument {
71 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
72 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
73 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
74 const IPersistFileVtbl *lpPersistFileVtbl;
75 const IMonikerPropVtbl *lpMonikerPropVtbl;
76 const IOleObjectVtbl *lpOleObjectVtbl;
77 const IOleDocumentVtbl *lpOleDocumentVtbl;
78 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
79 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
80 const IViewObject2Vtbl *lpViewObject2Vtbl;
81 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
82 const IServiceProviderVtbl *lpServiceProviderVtbl;
83 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
84 const IOleControlVtbl *lpOleControlVtbl;
85 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
86 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
87 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
89 LONG ref;
91 NSContainer *nscontainer;
92 HTMLWindow *window;
94 IOleClientSite *client;
95 IDocHostUIHandler *hostui;
96 IOleInPlaceSite *ipsite;
97 IOleInPlaceFrame *frame;
99 BSCallback *bscallback;
101 HWND hwnd;
102 HWND tooltips_hwnd;
104 DOCHOSTUIINFO hostinfo;
106 USERMODE usermode;
107 READYSTATE readystate;
108 BOOL in_place_active;
109 BOOL ui_active;
110 BOOL window_active;
111 BOOL has_key_path;
112 BOOL container_locked;
114 ConnectionPoint *cp_htmldocevents;
115 ConnectionPoint *cp_htmldocevents2;
116 ConnectionPoint *cp_propnotif;
118 HTMLDOMNode *nodes;
121 struct NSContainer {
122 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
123 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
124 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
125 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
126 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
127 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
128 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
129 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
130 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
132 nsIWebBrowser *webbrowser;
133 nsIWebNavigation *navigation;
134 nsIBaseWindow *window;
135 nsIWebBrowserFocus *focus;
137 LONG ref;
139 NSContainer *parent;
140 HTMLDocument *doc;
142 nsIURIContentListener *content_listener;
144 HWND hwnd;
146 BSCallback *bscallback; /* hack */
149 typedef struct {
150 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
151 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
153 LONG ref;
155 nsIChannel *channel;
156 nsIHttpChannel *http_channel;
157 nsIWineURI *uri;
158 nsIInputStream *post_data_stream;
159 nsILoadGroup *load_group;
160 nsIInterfaceRequestor *notif_callback;
161 nsLoadFlags load_flags;
162 nsIURI *original_uri;
163 char *content;
164 } nsChannel;
166 typedef struct {
167 const nsIInputStreamVtbl *lpInputStreamVtbl;
169 LONG ref;
171 char buf[1024];
172 DWORD buf_size;
173 } nsProtocolStream;
175 struct BSCallback {
176 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
177 const IServiceProviderVtbl *lpServiceProviderVtbl;
178 const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
179 const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
181 LONG ref;
183 LPWSTR headers;
184 HGLOBAL post_data;
185 ULONG post_data_len;
186 ULONG readed;
188 nsChannel *nschannel;
189 nsIStreamListener *nslistener;
190 nsISupports *nscontext;
192 IMoniker *mon;
193 IBinding *binding;
195 HTMLDocument *doc;
197 nsProtocolStream *nsstream;
200 struct HTMLDOMNode {
201 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
203 void (*destructor)(IUnknown*);
205 enum {
206 NT_UNKNOWN,
207 NT_HTMLELEM
208 } node_type;
210 union {
211 IUnknown *unk;
212 IHTMLElement *elem;
213 } impl;
215 nsIDOMNode *nsnode;
216 HTMLDocument *doc;
218 HTMLDOMNode *next;
221 typedef struct {
222 const IHTMLElementVtbl *lpHTMLElementVtbl;
223 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
225 void (*destructor)(IUnknown*);
227 nsIDOMHTMLElement *nselem;
228 HTMLDOMNode *node;
230 IUnknown *impl;
231 } HTMLElement;
233 typedef struct {
234 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
236 HTMLElement *element;
237 } HTMLTextContainer;
239 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
241 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
242 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
243 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
244 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
245 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
246 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
247 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
248 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
249 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
250 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
251 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
252 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
253 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
254 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
255 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
256 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
257 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
258 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
259 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
260 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
261 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
263 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
264 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
265 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
266 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
267 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
268 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
269 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
270 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
271 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
273 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
274 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
275 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
277 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
278 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
279 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
281 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
282 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
283 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
285 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
287 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
289 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
290 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
292 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
293 HTMLWindow *nswindow_to_window(nsIDOMWindow*);
295 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
296 void HTMLDocument_Persist_Init(HTMLDocument*);
297 void HTMLDocument_OleCmd_Init(HTMLDocument*);
298 void HTMLDocument_OleObj_Init(HTMLDocument*);
299 void HTMLDocument_View_Init(HTMLDocument*);
300 void HTMLDocument_Window_Init(HTMLDocument*);
301 void HTMLDocument_Service_Init(HTMLDocument*);
302 void HTMLDocument_Hlink_Init(HTMLDocument*);
303 void HTMLDocument_ConnectionPoints_Init(HTMLDocument*);
305 void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument*);
307 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
308 void NSContainer_Release(NSContainer*);
310 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
311 void HTMLDocument_ShowContextMenu(HTMLDocument*,DWORD,POINT*);
313 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
314 void hide_tooltip(HTMLDocument*);
315 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
317 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
319 void close_gecko(void);
320 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
321 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
323 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
325 void call_property_onchanged(ConnectionPoint*,DISPID);
327 void *nsalloc(size_t);
328 void nsfree(void*);
330 void nsACString_Init(nsACString*,const char*);
331 PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
332 void nsACString_Finish(nsACString*);
334 void nsAString_Init(nsAString*,const PRUnichar*);
335 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
336 void nsAString_Finish(nsAString*);
338 nsIInputStream *create_nsstream(const char*,PRInt32);
339 nsICommandParams *create_nscommand_params(void);
340 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
342 BSCallback *create_bscallback(IMoniker*);
343 HRESULT start_binding(BSCallback*);
344 void set_document_bscallback(HTMLDocument*,BSCallback*);
346 IHlink *Hlink_Create(void);
347 IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*);
348 IHTMLTxtRange *HTMLTxtRange_Create(nsISelection*);
349 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
350 IHTMLStyleSheet *HTMLStyleSheet_Create(void);
352 void HTMLElement_Create(HTMLDOMNode*);
353 void HTMLBodyElement_Create(HTMLElement*);
354 void HTMLInputElement_Create(HTMLElement*);
355 void HTMLSelectElement_Create(HTMLElement*);
356 void HTMLTextAreaElement_Create(HTMLElement*);
358 void HTMLElement2_Init(HTMLElement*);
360 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLElement*);
362 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
363 HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
365 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
366 void release_nodes(HTMLDocument*);
368 void install_wine_gecko(void);
370 /* editor */
371 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
373 void get_font_size(HTMLDocument*,WCHAR*);
374 void set_font_size(HTMLDocument*,LPCWSTR);
376 extern DWORD mshtml_tls;
378 typedef struct task_t {
379 HTMLDocument *doc;
381 enum {
382 TASK_SETDOWNLOADSTATE,
383 TASK_PARSECOMPLETE,
384 TASK_SETPROGRESS
385 } task_id;
387 struct task_t *next;
388 } task_t;
390 typedef struct {
391 HWND thread_hwnd;
392 task_t *task_queue_head;
393 task_t *task_queue_tail;
394 } thread_data_t;
396 thread_data_t *get_thread_data(BOOL);
397 HWND get_thread_hwnd(void);
398 void push_task(task_t*);
399 void remove_doc_tasks(HTMLDocument*);
401 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
402 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
403 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
404 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
405 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
407 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
409 extern LONG module_ref;
410 #define LOCK_MODULE() InterlockedIncrement(&module_ref)
411 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
413 /* memory allocation functions */
415 static inline void *mshtml_alloc(size_t len)
417 return HeapAlloc(GetProcessHeap(), 0, len);
420 static inline void *mshtml_alloc_zero(size_t len)
422 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
425 static inline void *mshtml_realloc(void *mem, size_t len)
427 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
430 static inline BOOL mshtml_free(void *mem)
432 return HeapFree(GetProcessHeap(), 0, mem);
435 HINSTANCE get_shdoclc(void);
437 extern HINSTANCE hInst;