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 MSHTML_E_NODOC 0x800a025c
52 typedef struct HTMLDOMNode HTMLDOMNode
;
53 typedef struct ConnectionPoint ConnectionPoint
;
54 typedef struct BSCallback BSCallback
;
57 const IHTMLWindow2Vtbl
*lpHTMLWindow2Vtbl
;
62 nsIDOMWindow
*nswindow
;
74 const IConnectionPointContainerVtbl
*lpConnectionPointContainerVtbl
;
76 ConnectionPoint
*cp_list
;
78 } ConnectionPointContainer
;
80 struct ConnectionPoint
{
81 const IConnectionPointVtbl
*lpConnectionPointVtbl
;
83 IConnectionPointContainer
*container
;
88 IPropertyNotifySink
*propnotif
;
94 ConnectionPoint
*next
;
98 const IHTMLDocument2Vtbl
*lpHTMLDocument2Vtbl
;
99 const IHTMLDocument3Vtbl
*lpHTMLDocument3Vtbl
;
100 const IPersistMonikerVtbl
*lpPersistMonikerVtbl
;
101 const IPersistFileVtbl
*lpPersistFileVtbl
;
102 const IMonikerPropVtbl
*lpMonikerPropVtbl
;
103 const IOleObjectVtbl
*lpOleObjectVtbl
;
104 const IOleDocumentVtbl
*lpOleDocumentVtbl
;
105 const IOleDocumentViewVtbl
*lpOleDocumentViewVtbl
;
106 const IOleInPlaceActiveObjectVtbl
*lpOleInPlaceActiveObjectVtbl
;
107 const IViewObject2Vtbl
*lpViewObject2Vtbl
;
108 const IOleInPlaceObjectWindowlessVtbl
*lpOleInPlaceObjectWindowlessVtbl
;
109 const IServiceProviderVtbl
*lpServiceProviderVtbl
;
110 const IOleCommandTargetVtbl
*lpOleCommandTargetVtbl
;
111 const IOleControlVtbl
*lpOleControlVtbl
;
112 const IHlinkTargetVtbl
*lpHlinkTargetVtbl
;
113 const IPersistStreamInitVtbl
*lpPersistStreamInitVtbl
;
114 const ICustomDocVtbl
*lpCustomDocVtbl
;
118 NSContainer
*nscontainer
;
121 IOleClientSite
*client
;
122 IDocHostUIHandler
*hostui
;
123 IOleInPlaceSite
*ipsite
;
124 IOleInPlaceFrame
*frame
;
125 IOleInPlaceUIWindow
*ip_window
;
127 IOleUndoManager
*undomgr
;
129 BSCallback
*bscallback
;
136 DOCHOSTUIINFO hostinfo
;
139 READYSTATE readystate
;
140 BOOL in_place_active
;
144 BOOL container_locked
;
149 ConnectionPointContainer cp_container
;
150 ConnectionPoint cp_htmldocevents
;
151 ConnectionPoint cp_htmldocevents2
;
152 ConnectionPoint cp_propnotif
;
154 struct list selection_list
;
155 struct list range_list
;
161 const nsIDOMEventListenerVtbl
*lpDOMEventListenerVtbl
;
166 const nsIWebBrowserChromeVtbl
*lpWebBrowserChromeVtbl
;
167 const nsIContextMenuListenerVtbl
*lpContextMenuListenerVtbl
;
168 const nsIURIContentListenerVtbl
*lpURIContentListenerVtbl
;
169 const nsIEmbeddingSiteWindowVtbl
*lpEmbeddingSiteWindowVtbl
;
170 const nsITooltipListenerVtbl
*lpTooltipListenerVtbl
;
171 const nsIInterfaceRequestorVtbl
*lpInterfaceRequestorVtbl
;
172 const nsIWeakReferenceVtbl
*lpWeakReferenceVtbl
;
173 const nsISupportsWeakReferenceVtbl
*lpSupportsWeakReferenceVtbl
;
175 nsEventListener blur_listener
;
176 nsEventListener focus_listener
;
177 nsEventListener keypress_listener
;
178 nsEventListener load_listener
;
180 nsIWebBrowser
*webbrowser
;
181 nsIWebNavigation
*navigation
;
182 nsIBaseWindow
*window
;
183 nsIWebBrowserFocus
*focus
;
186 nsIController
*editor_controller
;
193 nsIURIContentListener
*content_listener
;
197 BSCallback
*bscallback
; /* hack */
201 const nsIHttpChannelVtbl
*lpHttpChannelVtbl
;
202 const nsIUploadChannelVtbl
*lpUploadChannelVtbl
;
207 nsIHttpChannel
*http_channel
;
209 nsIInputStream
*post_data_stream
;
210 nsILoadGroup
*load_group
;
211 nsIInterfaceRequestor
*notif_callback
;
212 nsLoadFlags load_flags
;
213 nsIURI
*original_uri
;
219 const nsIInputStreamVtbl
*lpInputStreamVtbl
;
228 const IBindStatusCallbackVtbl
*lpBindStatusCallbackVtbl
;
229 const IServiceProviderVtbl
*lpServiceProviderVtbl
;
230 const IHttpNegotiate2Vtbl
*lpHttpNegotiate2Vtbl
;
231 const IInternetBindInfoVtbl
*lpInternetBindInfoVtbl
;
240 nsChannel
*nschannel
;
241 nsIStreamListener
*nslistener
;
242 nsISupports
*nscontext
;
249 nsProtocolStream
*nsstream
;
253 const IHTMLDOMNodeVtbl
*lpHTMLDOMNodeVtbl
;
255 void (*destructor
)(IUnknown
*);
276 const IHTMLElementVtbl
*lpHTMLElementVtbl
;
277 const IHTMLElement2Vtbl
*lpHTMLElement2Vtbl
;
279 void (*destructor
)(IUnknown
*);
281 nsIDOMHTMLElement
*nselem
;
287 const IHTMLTextContainerVtbl
*lpHTMLTextContainerVtbl
;
289 HTMLElement
*element
;
292 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
294 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
295 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
296 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
297 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
298 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
299 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
300 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
301 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
302 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
303 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
304 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
305 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
306 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
307 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
308 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
309 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
310 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
311 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
312 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
313 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
314 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
315 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
317 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
318 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
319 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
320 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
321 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
322 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
323 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
324 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
325 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
327 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
328 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
329 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
331 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
332 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
333 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
335 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
336 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
337 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
339 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
341 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
343 HRESULT
HTMLDocument_Create(IUnknown
*,REFIID
,void**);
344 HRESULT
HTMLLoadOptions_Create(IUnknown
*,REFIID
,void**);
346 HTMLWindow
*HTMLWindow_Create(HTMLDocument
*);
347 HTMLWindow
*nswindow_to_window(const nsIDOMWindow
*);
348 void setup_nswindow(HTMLWindow
*);
350 void HTMLDocument_HTMLDocument3_Init(HTMLDocument
*);
351 void HTMLDocument_Persist_Init(HTMLDocument
*);
352 void HTMLDocument_OleCmd_Init(HTMLDocument
*);
353 void HTMLDocument_OleObj_Init(HTMLDocument
*);
354 void HTMLDocument_View_Init(HTMLDocument
*);
355 void HTMLDocument_Window_Init(HTMLDocument
*);
356 void HTMLDocument_Service_Init(HTMLDocument
*);
357 void HTMLDocument_Hlink_Init(HTMLDocument
*);
359 void ConnectionPoint_Init(ConnectionPoint
*,IConnectionPointContainer
*,REFIID
,ConnectionPoint
*);
360 void ConnectionPointContainer_Init(ConnectionPointContainer
*,ConnectionPoint
*,IUnknown
*);
361 void ConnectionPointContainer_Destroy(ConnectionPointContainer
*);
363 NSContainer
*NSContainer_Create(HTMLDocument
*,NSContainer
*);
364 void NSContainer_Release(NSContainer
*);
366 void HTMLDocument_LockContainer(HTMLDocument
*,BOOL
);
367 void show_context_menu(HTMLDocument
*,DWORD
,POINT
*);
368 void notif_focus(HTMLDocument
*);
370 void show_tooltip(HTMLDocument
*,DWORD
,DWORD
,LPCWSTR
);
371 void hide_tooltip(HTMLDocument
*);
372 HRESULT
get_client_disp_property(IOleClientSite
*,DISPID
,VARIANT
*);
374 HRESULT
ProtocolFactory_Create(REFCLSID
,REFIID
,void**);
376 void close_gecko(void);
377 void register_nsservice(nsIComponentRegistrar
*,nsIServiceManager
*);
378 void init_nsio(nsIComponentManager
*,nsIComponentRegistrar
*);
380 void hlink_frame_navigate(HTMLDocument
*,IHlinkFrame
*,LPCWSTR
,nsIInputStream
*,DWORD
);
382 void call_property_onchanged(ConnectionPoint
*,DISPID
);
384 void *nsalloc(size_t);
387 void nsACString_Init(nsACString
*,const char*);
388 void nsACString_SetData(nsACString
*,const char*);
389 PRUint32
nsACString_GetData(const nsACString
*,const char**,PRBool
*);
390 void nsACString_Finish(nsACString
*);
392 void nsAString_Init(nsAString
*,const PRUnichar
*);
393 PRUint32
nsAString_GetData(const nsAString
*,const PRUnichar
**,PRBool
*);
394 void nsAString_Finish(nsAString
*);
396 nsIInputStream
*create_nsstream(const char*,PRInt32
);
397 nsICommandParams
*create_nscommand_params(void);
398 nsIMutableArray
*create_nsarray(void);
399 nsIWritableVariant
*create_nsvariant(void);
400 void nsnode_to_nsstring(nsIDOMNode
*,nsAString
*);
401 void get_editor_controller(NSContainer
*);
402 void init_nsevents(NSContainer
*);
404 BSCallback
*create_bscallback(IMoniker
*);
405 HRESULT
start_binding(BSCallback
*);
406 HRESULT
load_stream(BSCallback
*,IStream
*);
407 void set_document_bscallback(HTMLDocument
*,BSCallback
*);
408 void set_current_mon(HTMLDocument
*,IMoniker
*);
410 IHTMLSelectionObject
*HTMLSelectionObject_Create(HTMLDocument
*,nsISelection
*);
411 IHTMLTxtRange
*HTMLTxtRange_Create(HTMLDocument
*,nsIDOMRange
*);
412 IHTMLStyle
*HTMLStyle_Create(nsIDOMCSSStyleDeclaration
*);
413 IHTMLStyleSheet
*HTMLStyleSheet_Create(void);
415 void detach_selection(HTMLDocument
*);
416 void detach_ranges(HTMLDocument
*);
418 HTMLElement
*HTMLElement_Create(nsIDOMNode
*);
419 void HTMLAnchorElement_Create(HTMLElement
*);
420 void HTMLBodyElement_Create(HTMLElement
*);
421 void HTMLInputElement_Create(HTMLElement
*);
422 void HTMLSelectElement_Create(HTMLElement
*);
423 void HTMLTextAreaElement_Create(HTMLElement
*);
425 void HTMLElement2_Init(HTMLElement
*);
427 void HTMLTextContainer_Init(HTMLTextContainer
*,HTMLElement
*);
429 HRESULT
HTMLDOMNode_QI(HTMLDOMNode
*,REFIID
,void**);
430 HRESULT
HTMLElement_QI(HTMLElement
*,REFIID
,void**);
432 HTMLDOMNode
*get_node(HTMLDocument
*,nsIDOMNode
*);
433 void release_nodes(HTMLDocument
*);
435 BOOL
install_wine_gecko(void);
440 HRESULT (*query
)(HTMLDocument
*,OLECMD
*);
441 HRESULT (*exec
)(HTMLDocument
*,DWORD
,VARIANT
*,VARIANT
*);
444 extern const cmdtable_t editmode_cmds
[];
447 #define UPDATE_UI 0x0001
448 #define UPDATE_TITLE 0x0002
450 void update_doc(HTMLDocument
*This
, DWORD flags
);
451 void update_title(HTMLDocument
*);
454 void init_editor(HTMLDocument
*);
455 void set_ns_editmode(NSContainer
*);
456 void handle_edit_event(HTMLDocument
*,nsIDOMEvent
*);
457 HRESULT
editor_exec_copy(HTMLDocument
*,DWORD
,VARIANT
*,VARIANT
*);
458 HRESULT
editor_exec_cut(HTMLDocument
*,DWORD
,VARIANT
*,VARIANT
*);
459 HRESULT
editor_exec_paste(HTMLDocument
*,DWORD
,VARIANT
*,VARIANT
*);
460 void handle_edit_load(HTMLDocument
*This
);
461 HRESULT
editor_is_dirty(HTMLDocument
*);
463 extern DWORD mshtml_tls
;
465 typedef struct task_t
{
469 TASK_SETDOWNLOADSTATE
,
475 BSCallback
*bscallback
;
482 task_t
*task_queue_head
;
483 task_t
*task_queue_tail
;
486 thread_data_t
*get_thread_data(BOOL
);
487 HWND
get_thread_hwnd(void);
488 void push_task(task_t
*);
489 void remove_doc_tasks(const HTMLDocument
*);
497 HRESULT
get_typeinfo(enum tid_t
, ITypeInfo
**);
499 DEFINE_GUID(CLSID_AboutProtocol
, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
500 DEFINE_GUID(CLSID_JSProtocol
, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
501 DEFINE_GUID(CLSID_MailtoProtocol
, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
502 DEFINE_GUID(CLSID_ResProtocol
, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
503 DEFINE_GUID(CLSID_SysimageProtocol
, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
505 DEFINE_GUID(CLSID_CMarkup
,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
507 extern LONG module_ref
;
508 #define LOCK_MODULE() InterlockedIncrement(&module_ref)
509 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
511 /* memory allocation functions */
513 static inline void *mshtml_alloc(size_t len
)
515 return HeapAlloc(GetProcessHeap(), 0, len
);
518 static inline void *mshtml_alloc_zero(size_t len
)
520 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, len
);
523 static inline void *mshtml_realloc(void *mem
, size_t len
)
525 return HeapReAlloc(GetProcessHeap(), 0, mem
, len
);
528 static inline BOOL
mshtml_free(void *mem
)
530 return HeapFree(GetProcessHeap(), 0, mem
);
533 HINSTANCE
get_shdoclc(void);
535 extern HINSTANCE hInst
;