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 IHTMLDocument5Vtbl *lpHTMLDocument5Vtbl;
101 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
102 const IPersistFileVtbl *lpPersistFileVtbl;
103 const IMonikerPropVtbl *lpMonikerPropVtbl;
104 const IOleObjectVtbl *lpOleObjectVtbl;
105 const IOleDocumentVtbl *lpOleDocumentVtbl;
106 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
107 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
108 const IViewObject2Vtbl *lpViewObject2Vtbl;
109 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
110 const IServiceProviderVtbl *lpServiceProviderVtbl;
111 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
112 const IOleControlVtbl *lpOleControlVtbl;
113 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
114 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
115 const ICustomDocVtbl *lpCustomDocVtbl;
119 NSContainer *nscontainer;
122 IOleClientSite *client;
123 IDocHostUIHandler *hostui;
124 IOleInPlaceSite *ipsite;
125 IOleInPlaceFrame *frame;
126 IOleInPlaceUIWindow *ip_window;
128 IOleUndoManager *undomgr;
130 BSCallback *bscallback;
137 DOCHOSTUIINFO hostinfo;
140 READYSTATE readystate;
141 BOOL in_place_active;
145 BOOL container_locked;
150 ConnectionPointContainer cp_container;
151 ConnectionPoint cp_htmldocevents;
152 ConnectionPoint cp_htmldocevents2;
153 ConnectionPoint cp_propnotif;
155 struct list selection_list;
156 struct list range_list;
162 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
167 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
168 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
169 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
170 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
171 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
172 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
173 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
174 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
176 nsEventListener blur_listener;
177 nsEventListener focus_listener;
178 nsEventListener keypress_listener;
179 nsEventListener load_listener;
181 nsIWebBrowser *webbrowser;
182 nsIWebNavigation *navigation;
183 nsIBaseWindow *window;
184 nsIWebBrowserFocus *focus;
187 nsIController *editor_controller;
194 nsIURIContentListener *content_listener;
198 BSCallback *bscallback; /* hack */
202 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
203 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
208 nsIHttpChannel *http_channel;
210 nsIInputStream *post_data_stream;
211 nsILoadGroup *load_group;
212 nsIInterfaceRequestor *notif_callback;
213 nsLoadFlags load_flags;
214 nsIURI *original_uri;
220 const nsIInputStreamVtbl *lpInputStreamVtbl;
229 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
230 const IServiceProviderVtbl *lpServiceProviderVtbl;
231 const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
232 const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
241 nsChannel *nschannel;
242 nsIStreamListener *nslistener;
243 nsISupports *nscontext;
250 nsProtocolStream *nsstream;
254 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
255 void (*destructor)(HTMLDOMNode*);
259 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
260 const NodeImplVtbl *vtbl;
271 const IHTMLElementVtbl *lpHTMLElementVtbl;
272 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
274 nsIDOMHTMLElement *nselem;
280 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
283 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
285 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
286 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
287 #define HTMLDOC5(x) ((IHTMLDocument5*) &(x)->lpHTMLDocument5Vtbl)
288 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
289 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
290 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
291 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
292 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
293 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
294 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
295 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
296 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
297 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
298 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
299 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
300 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
301 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
302 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
303 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
304 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
305 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
306 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
307 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
309 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
310 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
311 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
312 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
313 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
314 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
315 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
316 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
317 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
319 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
320 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
321 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
323 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
324 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
325 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
327 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
328 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
329 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
331 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
333 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
334 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
336 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
337 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
339 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
340 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
341 void setup_nswindow(HTMLWindow*);
343 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
344 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
345 void HTMLDocument_Persist_Init(HTMLDocument*);
346 void HTMLDocument_OleCmd_Init(HTMLDocument*);
347 void HTMLDocument_OleObj_Init(HTMLDocument*);
348 void HTMLDocument_View_Init(HTMLDocument*);
349 void HTMLDocument_Window_Init(HTMLDocument*);
350 void HTMLDocument_Service_Init(HTMLDocument*);
351 void HTMLDocument_Hlink_Init(HTMLDocument*);
353 void ConnectionPoint_Init(ConnectionPoint*,IConnectionPointContainer*,REFIID,ConnectionPoint*);
354 void ConnectionPointContainer_Init(ConnectionPointContainer*,ConnectionPoint*,IUnknown*);
355 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
357 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
358 void NSContainer_Release(NSContainer*);
360 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
361 void show_context_menu(HTMLDocument*,DWORD,POINT*,IDispatch*);
362 void notif_focus(HTMLDocument*);
364 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
365 void hide_tooltip(HTMLDocument*);
366 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
368 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
370 void close_gecko(void);
371 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
372 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
374 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
376 void call_property_onchanged(ConnectionPoint*,DISPID);
378 void *nsalloc(size_t);
381 void nsACString_Init(nsACString*,const char*);
382 void nsACString_SetData(nsACString*,const char*);
383 PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
384 void nsACString_Finish(nsACString*);
386 void nsAString_Init(nsAString*,const PRUnichar*);
387 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
388 void nsAString_Finish(nsAString*);
390 nsIInputStream *create_nsstream(const char*,PRInt32);
391 nsICommandParams *create_nscommand_params(void);
392 nsIMutableArray *create_nsarray(void);
393 nsIWritableVariant *create_nsvariant(void);
394 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
395 void get_editor_controller(NSContainer*);
396 void init_nsevents(NSContainer*);
397 nsresult get_nsinterface(nsISupports*,REFIID,void**);
399 BSCallback *create_bscallback(IMoniker*);
400 HRESULT start_binding(BSCallback*);
401 HRESULT load_stream(BSCallback*,IStream*);
402 void set_document_bscallback(HTMLDocument*,BSCallback*);
403 void set_current_mon(HTMLDocument*,IMoniker*);
405 IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*);
406 IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*);
407 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
408 IHTMLStyleSheet *HTMLStyleSheet_Create(void);
409 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
411 void detach_selection(HTMLDocument*);
412 void detach_ranges(HTMLDocument*);
414 HTMLElement *HTMLElement_Create(nsIDOMNode*);
415 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
416 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
417 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
418 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
419 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
420 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
422 void HTMLElement2_Init(HTMLElement*);
423 void HTMLTextContainer_Init(HTMLTextContainer*);
425 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
426 void HTMLDOMNode_destructor(HTMLDOMNode*);
428 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
429 void HTMLElement_destructor(HTMLDOMNode*);
431 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
432 void release_nodes(HTMLDocument*);
434 IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
436 BOOL install_wine_gecko(void);
441 HRESULT (*query)(HTMLDocument*,OLECMD*);
442 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
445 extern const cmdtable_t editmode_cmds[];
447 void do_ns_command(NSContainer*,const char*,nsICommandParams*);
450 #define UPDATE_UI 0x0001
451 #define UPDATE_TITLE 0x0002
453 void update_doc(HTMLDocument *This, DWORD flags);
454 void update_title(HTMLDocument*);
457 void init_editor(HTMLDocument*);
458 void set_ns_editmode(NSContainer*);
459 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
460 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
461 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
462 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
463 void handle_edit_load(HTMLDocument *This);
464 HRESULT editor_is_dirty(HTMLDocument*);
466 extern DWORD mshtml_tls;
468 typedef struct task_t {
472 TASK_SETDOWNLOADSTATE,
478 BSCallback *bscallback;
485 task_t *task_queue_head;
486 task_t *task_queue_tail;
489 thread_data_t *get_thread_data(BOOL);
490 HWND get_thread_hwnd(void);
491 void push_task(task_t*);
492 void remove_doc_tasks(const HTMLDocument*);
500 HRESULT get_typeinfo(enum tid_t, ITypeInfo**);
502 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
503 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
504 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
505 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
506 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
508 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
510 extern LONG module_ref;
511 #define LOCK_MODULE() InterlockedIncrement(&module_ref)
512 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
514 /* memory allocation functions */
516 static inline void *mshtml_alloc(size_t len)
518 return HeapAlloc(GetProcessHeap(), 0, len);
521 static inline void *mshtml_alloc_zero(size_t len)
523 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
526 static inline void *mshtml_realloc(void *mem, size_t len)
528 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
531 static inline BOOL mshtml_free(void *mem)
533 return HeapFree(GetProcessHeap(), 0, mem);
536 HINSTANCE get_shdoclc(void);
538 extern HINSTANCE hInst;