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
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))
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;
62 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
63 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
64 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
65 const IPersistFileVtbl *lpPersistFileVtbl;
66 const IMonikerPropVtbl *lpMonikerPropVtbl;
67 const IOleObjectVtbl *lpOleObjectVtbl;
68 const IOleDocumentVtbl *lpOleDocumentVtbl;
69 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
70 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
71 const IViewObject2Vtbl *lpViewObject2Vtbl;
72 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
73 const IServiceProviderVtbl *lpServiceProviderVtbl;
74 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
75 const IOleControlVtbl *lpOleControlVtbl;
76 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
77 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
78 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
82 NSContainer *nscontainer;
84 IOleClientSite *client;
85 IDocHostUIHandler *hostui;
86 IOleInPlaceSite *ipsite;
87 IOleInPlaceFrame *frame;
89 BSCallback *bscallback;
94 DOCHOSTUIINFO hostinfo;
97 READYSTATE readystate;
102 BOOL container_locked;
104 ConnectionPoint *cp_htmldocevents;
105 ConnectionPoint *cp_htmldocevents2;
106 ConnectionPoint *cp_propnotif;
112 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
113 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
114 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
115 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
116 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
117 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
118 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
119 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
120 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
122 nsIWebBrowser *webbrowser;
123 nsIWebNavigation *navigation;
124 nsIBaseWindow *window;
125 nsIWebBrowserFocus *focus;
132 nsIURIContentListener *content_listener;
136 BSCallback *bscallback; /* hack */
140 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
141 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
146 nsIHttpChannel *http_channel;
148 nsIInputStream *post_data_stream;
149 nsILoadGroup *load_group;
150 nsIInterfaceRequestor *notif_callback;
151 nsLoadFlags load_flags;
152 nsIURI *original_uri;
157 const nsIInputStreamVtbl *lpInputStreamVtbl;
166 const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
167 const IServiceProviderVtbl *lpServiceProviderVtbl;
168 const IHttpNegotiate2Vtbl *lpHttpNegotiate2Vtbl;
169 const IInternetBindInfoVtbl *lpInternetBindInfoVtbl;
178 nsChannel *nschannel;
179 nsIStreamListener *nslistener;
180 nsISupports *nscontext;
187 nsProtocolStream *nsstream;
191 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
193 void (*destructor)(IUnknown*);
212 const IHTMLElementVtbl *lpHTMLElementVtbl;
213 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
215 void (*destructor)(IUnknown*);
217 nsIDOMHTMLElement *nselem;
224 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
226 HTMLElement *element;
229 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
230 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
231 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
232 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
233 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
234 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
235 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
236 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
237 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
238 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
239 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
240 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
241 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
242 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
243 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
244 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
245 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
246 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
247 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
248 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
249 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
251 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
252 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
253 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
254 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
255 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
256 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
257 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
258 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
259 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
261 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
262 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
263 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
265 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
266 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
267 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
269 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
270 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
271 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
273 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
275 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
277 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
278 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
280 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
281 void HTMLDocument_Persist_Init(HTMLDocument*);
282 void HTMLDocument_OleCmd_Init(HTMLDocument*);
283 void HTMLDocument_OleObj_Init(HTMLDocument*);
284 void HTMLDocument_View_Init(HTMLDocument*);
285 void HTMLDocument_Window_Init(HTMLDocument*);
286 void HTMLDocument_Service_Init(HTMLDocument*);
287 void HTMLDocument_Hlink_Init(HTMLDocument*);
288 void HTMLDocument_ConnectionPoints_Init(HTMLDocument*);
290 void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument*);
292 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
293 void NSContainer_Release(NSContainer*);
295 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
296 void HTMLDocument_ShowContextMenu(HTMLDocument*,DWORD,POINT*);
298 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
299 void hide_tooltip(HTMLDocument*);
300 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
302 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
304 void close_gecko(void);
305 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
306 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
308 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
310 void call_property_onchanged(ConnectionPoint*,DISPID);
312 void *nsalloc(size_t);
315 void nsACString_Init(nsACString*,const char*);
316 PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
317 void nsACString_Finish(nsACString*);
319 void nsAString_Init(nsAString*,const PRUnichar*);
320 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
321 void nsAString_Finish(nsAString*);
323 nsIInputStream *create_nsstream(const char*,PRInt32);
324 nsICommandParams *create_nscommand_params(void);
325 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
327 BSCallback *create_bscallback(IMoniker*);
328 HRESULT start_binding(BSCallback*);
329 void set_document_bscallback(HTMLDocument*,BSCallback*);
331 IHlink *Hlink_Create(void);
332 IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*);
333 IHTMLTxtRange *HTMLTxtRange_Create(nsISelection*);
334 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
335 IHTMLStyleSheet *HTMLStyleSheet_Create(void);
337 void HTMLElement_Create(HTMLDOMNode*);
338 void HTMLBodyElement_Create(HTMLElement*);
339 void HTMLInputElement_Create(HTMLElement*);
340 void HTMLSelectElement_Create(HTMLElement*);
341 void HTMLTextAreaElement_Create(HTMLElement*);
343 void HTMLElement2_Init(HTMLElement*);
345 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLElement*);
347 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
348 HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
350 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
351 void release_nodes(HTMLDocument*);
353 void install_wine_gecko(void);
356 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
358 void get_font_size(HTMLDocument*,WCHAR*);
359 void set_font_size(HTMLDocument*,LPCWSTR);
361 extern DWORD mshtml_tls;
363 typedef struct task_t {
367 TASK_SETDOWNLOADSTATE,
377 task_t *task_queue_head;
378 task_t *task_queue_tail;
381 thread_data_t *get_thread_data(BOOL);
382 HWND get_thread_hwnd(void);
383 void push_task(task_t*);
384 void remove_doc_tasks(HTMLDocument*);
386 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
387 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
388 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
389 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
390 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
392 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
394 extern LONG module_ref;
395 #define LOCK_MODULE() InterlockedIncrement(&module_ref)
396 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
398 /* memory allocation functions */
400 static inline void *mshtml_alloc(size_t len)
402 return HeapAlloc(GetProcessHeap(), 0, len);
405 static inline void *mshtml_alloc_zero(size_t len)
407 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
410 static inline void *mshtml_realloc(void *mem, size_t len)
412 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
415 static inline BOOL mshtml_free(void *mem)
417 return HeapFree(GetProcessHeap(), 0, mem);
420 HINSTANCE get_shdoclc(void);
422 extern HINSTANCE hInst;