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
24 #include "wine/list.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))
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;
58 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
63 nsIDOMWindow *nswindow;
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;
95 NSContainer *nscontainer;
98 IOleClientSite *client;
99 IDocHostUIHandler *hostui;
100 IOleInPlaceSite *ipsite;
101 IOleInPlaceFrame *frame;
103 BSCallback *bscallback;
108 DOCHOSTUIINFO hostinfo;
111 READYSTATE readystate;
112 BOOL in_place_active;
116 BOOL container_locked;
120 ConnectionPoint *cp_htmldocevents;
121 ConnectionPoint *cp_htmldocevents2;
122 ConnectionPoint *cp_propnotif;
128 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
129 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
130 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
131 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
132 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
133 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
134 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
135 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
136 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
138 nsIWebBrowser *webbrowser;
139 nsIWebNavigation *navigation;
140 nsIBaseWindow *window;
141 nsIWebBrowserFocus *focus;
143 nsIController *editor_controller;
150 nsIURIContentListener *content_listener;
154 BSCallback *bscallback; /* hack */
158 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
159 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
164 nsIHttpChannel *http_channel;
166 nsIInputStream *post_data_stream;
167 nsILoadGroup *load_group;
168 nsIInterfaceRequestor *notif_callback;
169 nsLoadFlags load_flags;
170 nsIURI *original_uri;
176 const nsIInputStreamVtbl *lpInputStreamVtbl;
185 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
186 const IServiceProviderVtbl *lpServiceProviderVtbl;
187 const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
188 const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
197 nsChannel *nschannel;
198 nsIStreamListener *nslistener;
199 nsISupports *nscontext;
206 nsProtocolStream *nsstream;
210 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
212 void (*destructor)(IUnknown*);
231 const IHTMLElementVtbl *lpHTMLElementVtbl;
232 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
234 void (*destructor)(IUnknown*);
236 nsIDOMHTMLElement *nselem;
243 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
245 HTMLElement *element;
248 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
250 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
251 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
252 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
253 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
254 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
255 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
256 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
257 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
258 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
259 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
260 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
261 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
262 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
263 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
264 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
265 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
266 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
267 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
268 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
269 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
270 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
272 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
273 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
274 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
275 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
276 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
277 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
278 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
279 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
280 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
282 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
283 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
284 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
286 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
287 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
288 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
290 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
291 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
292 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
294 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
296 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
298 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
299 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
301 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
302 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
304 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
305 void HTMLDocument_Persist_Init(HTMLDocument*);
306 void HTMLDocument_OleCmd_Init(HTMLDocument*);
307 void HTMLDocument_OleObj_Init(HTMLDocument*);
308 void HTMLDocument_View_Init(HTMLDocument*);
309 void HTMLDocument_Window_Init(HTMLDocument*);
310 void HTMLDocument_Service_Init(HTMLDocument*);
311 void HTMLDocument_Hlink_Init(HTMLDocument*);
312 void HTMLDocument_ConnectionPoints_Init(HTMLDocument*);
314 void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument*);
316 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
317 void NSContainer_Release(NSContainer*);
319 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
320 void show_context_menu(HTMLDocument*,DWORD,POINT*);
322 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
323 void hide_tooltip(HTMLDocument*);
324 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
326 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
328 void close_gecko(void);
329 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
330 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
332 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
334 void call_property_onchanged(ConnectionPoint*,DISPID);
336 void *nsalloc(size_t);
339 void nsACString_Init(nsACString*,const char*);
340 void nsACString_SetData(nsACString*,const char*);
341 PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
342 void nsACString_Finish(nsACString*);
344 void nsAString_Init(nsAString*,const PRUnichar*);
345 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
346 void nsAString_Finish(nsAString*);
348 nsIInputStream *create_nsstream(const char*,PRInt32);
349 nsICommandParams *create_nscommand_params(void);
350 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
352 BSCallback *create_bscallback(IMoniker*);
353 HRESULT start_binding(BSCallback*);
354 HRESULT load_stream(BSCallback*,IStream*);
355 void set_document_bscallback(HTMLDocument*,BSCallback*);
357 IHlink *Hlink_Create(void);
358 IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*);
359 IHTMLTxtRange *HTMLTxtRange_Create(nsIDOMRange*);
360 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
361 IHTMLStyleSheet *HTMLStyleSheet_Create(void);
363 void HTMLElement_Create(HTMLDOMNode*);
364 void HTMLBodyElement_Create(HTMLElement*);
365 void HTMLInputElement_Create(HTMLElement*);
366 void HTMLSelectElement_Create(HTMLElement*);
367 void HTMLTextAreaElement_Create(HTMLElement*);
369 void HTMLElement2_Init(HTMLElement*);
371 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLElement*);
373 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
374 HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
376 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
377 void release_nodes(HTMLDocument*);
379 BOOL install_wine_gecko(void);
384 HRESULT (*query)(HTMLDocument*,OLECMD*);
385 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
388 extern const cmdtable_t editmode_cmds[];
391 #define UPDATE_UI 0x0001
392 #define UPDATE_TITLE 0x0002
394 void update_doc(HTMLDocument *This, DWORD flags);
395 void update_title(HTMLDocument*);
398 void init_editor(HTMLDocument*);
399 void set_ns_editmode(NSContainer*);
400 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
402 extern DWORD mshtml_tls;
404 typedef struct task_t {
408 TASK_SETDOWNLOADSTATE,
414 BSCallback *bscallback;
421 task_t *task_queue_head;
422 task_t *task_queue_tail;
425 thread_data_t *get_thread_data(BOOL);
426 HWND get_thread_hwnd(void);
427 void push_task(task_t*);
428 void remove_doc_tasks(const HTMLDocument*);
430 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
431 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
432 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
433 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
434 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
436 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
438 extern LONG module_ref;
439 #define LOCK_MODULE() InterlockedIncrement(&module_ref)
440 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
442 /* memory allocation functions */
444 static inline void *mshtml_alloc(size_t len)
446 return HeapAlloc(GetProcessHeap(), 0, len);
449 static inline void *mshtml_alloc_zero(size_t len)
451 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
454 static inline void *mshtml_realloc(void *mem, size_t len)
456 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
459 static inline BOOL mshtml_free(void *mem)
461 return HeapFree(GetProcessHeap(), 0, mem);
464 HINSTANCE get_shdoclc(void);
466 extern HINSTANCE hInst;