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
25 #include "wine/list.h"
33 #define GENERATE_MSHTML_NS_FAILURE(code) \
34 ((nsresult) ((PRUint32)(1<<31) | ((PRUint32)(0x45+6)<<16) | (PRUint32)(code)))
36 #define NS_OK ((nsresult)0x00000000L)
37 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
38 #define NS_NOINTERFACE ((nsresult)0x80004002L)
39 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
40 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
41 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
42 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
44 #define WINE_NS_LOAD_FROM_MONIKER GENERATE_MSHTML_NS_FAILURE(0)
46 #define NS_FAILED(res) ((res) & 0x80000000)
47 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
51 #define MSHTML_E_NODOC 0x800a025c
53 typedef struct HTMLDOMNode HTMLDOMNode;
54 typedef struct ConnectionPoint ConnectionPoint;
55 typedef struct BSCallback BSCallback;
58 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
63 nsIDOMWindow *nswindow;
75 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
77 ConnectionPoint *cp_list;
79 } ConnectionPointContainer;
81 struct ConnectionPoint {
82 const IConnectionPointVtbl *lpConnectionPointVtbl;
84 IConnectionPointContainer *container;
89 IPropertyNotifySink *propnotif;
95 ConnectionPoint *next;
99 const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
104 } HTMLOptionElementFactory;
106 struct HTMLDocument {
107 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
108 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
109 const IHTMLDocument4Vtbl *lpHTMLDocument4Vtbl;
110 const IHTMLDocument5Vtbl *lpHTMLDocument5Vtbl;
111 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
112 const IPersistFileVtbl *lpPersistFileVtbl;
113 const IMonikerPropVtbl *lpMonikerPropVtbl;
114 const IOleObjectVtbl *lpOleObjectVtbl;
115 const IOleDocumentVtbl *lpOleDocumentVtbl;
116 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
117 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
118 const IViewObject2Vtbl *lpViewObject2Vtbl;
119 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
120 const IServiceProviderVtbl *lpServiceProviderVtbl;
121 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
122 const IOleControlVtbl *lpOleControlVtbl;
123 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
124 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
125 const ICustomDocVtbl *lpCustomDocVtbl;
129 NSContainer *nscontainer;
132 IOleClientSite *client;
133 IDocHostUIHandler *hostui;
134 IOleInPlaceSite *ipsite;
135 IOleInPlaceFrame *frame;
136 IOleInPlaceUIWindow *ip_window;
138 IOleUndoManager *undomgr;
140 BSCallback *bscallback;
143 struct list bindings;
148 DOCHOSTUIINFO hostinfo;
151 READYSTATE readystate;
152 BOOL in_place_active;
156 BOOL container_locked;
161 ConnectionPointContainer cp_container;
162 ConnectionPoint cp_htmldocevents;
163 ConnectionPoint cp_htmldocevents2;
164 ConnectionPoint cp_propnotif;
166 HTMLOptionElementFactory *option_factory;
168 struct list selection_list;
169 struct list range_list;
175 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
180 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
181 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
182 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
183 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
184 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
185 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
186 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
187 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
189 nsEventListener blur_listener;
190 nsEventListener focus_listener;
191 nsEventListener keypress_listener;
192 nsEventListener load_listener;
194 nsIWebBrowser *webbrowser;
195 nsIWebNavigation *navigation;
196 nsIBaseWindow *window;
197 nsIWebBrowserFocus *focus;
200 nsIController *editor_controller;
207 nsIURIContentListener *content_listener;
211 BSCallback *bscallback; /* hack */
215 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
216 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
221 nsIHttpChannel *http_channel;
223 nsIInputStream *post_data_stream;
224 nsILoadGroup *load_group;
225 nsIInterfaceRequestor *notif_callback;
226 nsLoadFlags load_flags;
227 nsIURI *original_uri;
233 const nsIInputStreamVtbl *lpInputStreamVtbl;
242 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
243 const IServiceProviderVtbl *lpServiceProviderVtbl;
244 const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
245 const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
254 nsChannel *nschannel;
255 nsIStreamListener *nslistener;
256 nsISupports *nscontext;
263 nsProtocolStream *nsstream;
269 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
270 void (*destructor)(HTMLDOMNode*);
274 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
275 const NodeImplVtbl *vtbl;
288 const IHTMLElementVtbl *lpHTMLElementVtbl;
289 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
291 nsIDOMHTMLElement *nselem;
297 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
300 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
302 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
303 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
304 #define HTMLDOC4(x) ((IHTMLDocument4*) &(x)->lpHTMLDocument4Vtbl)
305 #define HTMLDOC5(x) ((IHTMLDocument5*) &(x)->lpHTMLDocument5Vtbl)
306 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
307 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
308 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
309 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
310 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
311 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
312 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
313 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
314 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
315 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
316 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
317 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
318 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
319 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
320 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
321 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
322 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
323 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
324 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
325 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
327 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
328 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
329 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
330 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
331 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
332 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
333 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
334 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
335 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
337 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
338 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
339 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
341 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
342 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
343 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
345 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
346 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
347 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
349 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
351 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
353 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
354 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
356 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
357 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
359 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
360 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
361 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
362 void setup_nswindow(HTMLWindow*);
364 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
365 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
366 void HTMLDocument_Persist_Init(HTMLDocument*);
367 void HTMLDocument_OleCmd_Init(HTMLDocument*);
368 void HTMLDocument_OleObj_Init(HTMLDocument*);
369 void HTMLDocument_View_Init(HTMLDocument*);
370 void HTMLDocument_Window_Init(HTMLDocument*);
371 void HTMLDocument_Service_Init(HTMLDocument*);
372 void HTMLDocument_Hlink_Init(HTMLDocument*);
374 void ConnectionPoint_Init(ConnectionPoint*,IConnectionPointContainer*,REFIID,ConnectionPoint*);
375 void ConnectionPointContainer_Init(ConnectionPointContainer*,ConnectionPoint*,IUnknown*);
376 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
378 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
379 void NSContainer_Release(NSContainer*);
381 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
382 void show_context_menu(HTMLDocument*,DWORD,POINT*,IDispatch*);
383 void notif_focus(HTMLDocument*);
385 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
386 void hide_tooltip(HTMLDocument*);
387 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
389 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
391 BOOL load_gecko(BOOL);
392 void close_gecko(void);
393 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
394 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
395 BOOL install_wine_gecko(BOOL);
397 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
399 void call_property_onchanged(ConnectionPoint*,DISPID);
401 void *nsalloc(size_t);
404 void nsACString_Init(nsACString*,const char*);
405 void nsACString_SetData(nsACString*,const char*);
406 PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
407 void nsACString_Finish(nsACString*);
409 void nsAString_Init(nsAString*,const PRUnichar*);
410 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
411 void nsAString_Finish(nsAString*);
413 nsIInputStream *create_nsstream(const char*,PRInt32);
414 nsICommandParams *create_nscommand_params(void);
415 nsIMutableArray *create_nsarray(void);
416 nsIWritableVariant *create_nsvariant(void);
417 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
418 void get_editor_controller(NSContainer*);
419 void init_nsevents(NSContainer*);
420 nsresult get_nsinterface(nsISupports*,REFIID,void**);
422 BSCallback *create_bscallback(IMoniker*);
423 HRESULT start_binding(HTMLDocument*,BSCallback*);
424 HRESULT load_stream(BSCallback*,IStream*);
425 void set_document_bscallback(HTMLDocument*,BSCallback*);
426 void set_current_mon(HTMLDocument*,IMoniker*);
428 IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*);
429 IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*);
430 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
431 IHTMLStyleSheet *HTMLStyleSheet_Create(void);
432 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
434 void detach_selection(HTMLDocument*);
435 void detach_ranges(HTMLDocument*);
437 HTMLElement *HTMLElement_Create(nsIDOMNode*);
438 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
439 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
440 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
441 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
442 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
443 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
445 void HTMLElement2_Init(HTMLElement*);
446 void HTMLTextContainer_Init(HTMLTextContainer*);
448 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
449 void HTMLDOMNode_destructor(HTMLDOMNode*);
451 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
452 void HTMLElement_destructor(HTMLDOMNode*);
454 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
455 void release_nodes(HTMLDocument*);
457 IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
462 HRESULT (*query)(HTMLDocument*,OLECMD*);
463 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
466 extern const cmdtable_t editmode_cmds[];
468 void do_ns_command(NSContainer*,const char*,nsICommandParams*);
471 #define UPDATE_UI 0x0001
472 #define UPDATE_TITLE 0x0002
474 void update_doc(HTMLDocument *This, DWORD flags);
475 void update_title(HTMLDocument*);
478 void init_editor(HTMLDocument*);
479 void set_ns_editmode(NSContainer*);
480 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
481 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
482 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
483 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
484 void handle_edit_load(HTMLDocument *This);
485 HRESULT editor_is_dirty(HTMLDocument*);
487 extern DWORD mshtml_tls;
489 typedef struct task_t {
493 TASK_SETDOWNLOADSTATE,
499 BSCallback *bscallback;
506 task_t *task_queue_head;
507 task_t *task_queue_tail;
510 thread_data_t *get_thread_data(BOOL);
511 HWND get_thread_hwnd(void);
512 void push_task(task_t*);
513 void remove_doc_tasks(const HTMLDocument*);
521 HRESULT get_typeinfo(enum tid_t, ITypeInfo**);
523 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
524 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
525 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
526 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
527 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
529 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
531 extern LONG module_ref;
532 #define LOCK_MODULE() InterlockedIncrement(&module_ref)
533 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
535 /* memory allocation functions */
537 static inline void *mshtml_alloc(size_t len)
539 return HeapAlloc(GetProcessHeap(), 0, len);
542 static inline void *mshtml_alloc_zero(size_t len)
544 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
547 static inline void *mshtml_realloc(void *mem, size_t len)
549 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
552 static inline BOOL mshtml_free(void *mem)
554 return HeapFree(GetProcessHeap(), 0, mem);
557 HINSTANCE get_shdoclc(void);
559 extern HINSTANCE hInst;