dnsapi: Cast-qual warnings fix.
[wine] / dlls / mshtml / mshtml_private.h
1 /*
2  * Copyright 2005-2006 Jacek Caban for CodeWeavers
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include "docobj.h"
20 #include "mshtml.h"
21 #include "mshtmhst.h"
22 #include "hlink.h"
23
24 #ifdef INIT_GUID
25 #include "initguid.h"
26 #endif
27
28 #include "nsiface.h"
29
30 #define GENERATE_MSHTML_NS_FAILURE(code) \
31     ((nsresult) ((PRUint32)(1<<31) | ((PRUint32)(0x45+6)<<16) | (PRUint32)(code)))
32
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)
40
41 #define WINE_NS_LOAD_FROM_MONIKER GENERATE_MSHTML_NS_FAILURE(0)
42
43 #define NS_FAILED(res) ((res) & 0x80000000)
44 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
45
46 #define NSAPI WINAPI
47
48 #define NS_ELEMENT_NODE   1
49 #define NS_DOCUMENT_NODE  9
50
51 typedef struct HTMLDOMNode HTMLDOMNode;
52 typedef struct ConnectionPoint ConnectionPoint;
53 typedef struct BSCallback BSCallback;
54
55 typedef enum {
56     UNKNOWN_USERMODE,
57     BROWSEMODE,
58     EDITMODE        
59 } USERMODE;
60
61 struct HTMLDocument {
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;
79
80     LONG ref;
81
82     NSContainer *nscontainer;
83
84     IOleClientSite *client;
85     IDocHostUIHandler *hostui;
86     IOleInPlaceSite *ipsite;
87     IOleInPlaceFrame *frame;
88
89     HWND hwnd;
90     HWND hidden_hwnd;
91     HWND tooltips_hwnd;
92
93     USERMODE usermode;
94     BOOL in_place_active;
95     BOOL ui_active;
96     BOOL window_active;
97     BOOL has_key_path;
98     BOOL container_locked;
99
100     ConnectionPoint *cp_htmldocevents;
101     ConnectionPoint *cp_htmldocevents2;
102     ConnectionPoint *cp_propnotif;
103
104     HTMLDOMNode *nodes;
105 };
106
107 struct NSContainer {
108     const nsIWebBrowserChromeVtbl       *lpWebBrowserChromeVtbl;
109     const nsIContextMenuListenerVtbl    *lpContextMenuListenerVtbl;
110     const nsIURIContentListenerVtbl     *lpURIContentListenerVtbl;
111     const nsIEmbeddingSiteWindowVtbl    *lpEmbeddingSiteWindowVtbl;
112     const nsITooltipListenerVtbl        *lpTooltipListenerVtbl;
113     const nsIInterfaceRequestorVtbl     *lpInterfaceRequestorVtbl;
114     const nsIWeakReferenceVtbl          *lpWeakReferenceVtbl;
115     const nsISupportsWeakReferenceVtbl  *lpSupportsWeakReferenceVtbl;
116
117     nsIWebBrowser *webbrowser;
118     nsIWebNavigation *navigation;
119     nsIBaseWindow *window;
120     nsIWebBrowserFocus *focus;
121
122     LONG ref;
123
124     NSContainer *parent;
125     HTMLDocument *doc;
126
127     nsIURIContentListener *content_listener;
128
129     HWND hwnd;
130
131     BSCallback *bscallback; /* hack */
132 };
133
134 typedef struct {
135     const nsIHttpChannelVtbl *lpHttpChannelVtbl;
136     const nsIUploadChannelVtbl *lpUploadChannelVtbl;
137
138     LONG ref;
139
140     nsIChannel *channel;
141     nsIHttpChannel *http_channel;
142     nsIWineURI *uri;
143     nsIInputStream *post_data_stream;
144     nsILoadGroup *load_group;
145     nsIInterfaceRequestor *notif_callback;
146     nsLoadFlags load_flags;
147     nsIURI *original_uri;
148     char *content;
149 } nsChannel;
150
151 typedef struct {
152     const nsIInputStreamVtbl *lpInputStreamVtbl;
153
154     LONG ref;
155
156     char buf[1024];
157     DWORD buf_size;
158 } nsProtocolStream;
159
160 struct BSCallback {
161     const IBindStatusCallbackVtbl *lpBindStatusCallbackVtbl;
162     const IServiceProviderVtbl    *lpServiceProviderVtbl;
163     const IHttpNegotiate2Vtbl     *lpHttpNegotiate2Vtbl;
164     const IInternetBindInfoVtbl   *lpInternetBindInfoVtbl;
165
166     LONG ref;
167
168     LPWSTR headers;
169     HGLOBAL post_data;
170     ULONG post_data_len;
171     ULONG readed;
172
173     nsChannel *nschannel;
174     nsIStreamListener *nslistener;
175     nsISupports *nscontext;
176
177     IMoniker *mon;
178
179     nsProtocolStream *nsstream;
180 };
181
182 struct HTMLDOMNode {
183     const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
184
185     void (*destructor)(IUnknown*);
186
187     enum {
188         NT_UNKNOWN,
189         NT_HTMLELEM
190     } node_type;
191
192     union {
193         IUnknown *unk;
194         IHTMLElement *elem;
195     } impl;
196
197     nsIDOMNode *nsnode;
198     HTMLDocument *doc;
199
200     HTMLDOMNode *next;
201 };
202
203 typedef struct {
204     const IHTMLElementVtbl *lpHTMLElementVtbl;
205     const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
206
207     void (*destructor)(IUnknown*);
208
209     nsIDOMHTMLElement *nselem;
210     HTMLDOMNode *node;
211
212     IUnknown *impl;
213 } HTMLElement;
214
215 typedef struct {
216     const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
217
218     HTMLElement *element;
219 } HTMLTextContainer;
220
221 #define HTMLDOC(x)       ((IHTMLDocument2*)               &(x)->lpHTMLDocument2Vtbl)
222 #define HTMLDOC3(x)      ((IHTMLDocument3*)               &(x)->lpHTMLDocument3Vtbl)
223 #define PERSIST(x)       ((IPersist*)                     &(x)->lpPersistFileVtbl)
224 #define PERSISTMON(x)    ((IPersistMoniker*)              &(x)->lpPersistMonikerVtbl)
225 #define PERSISTFILE(x)   ((IPersistFile*)                 &(x)->lpPersistFileVtbl)
226 #define MONPROP(x)       ((IMonikerProp*)                 &(x)->lpMonikerPropVtbl)
227 #define OLEOBJ(x)        ((IOleObject*)                   &(x)->lpOleObjectVtbl)
228 #define OLEDOC(x)        ((IOleDocument*)                 &(x)->lpOleDocumentVtbl)
229 #define DOCVIEW(x)       ((IOleDocumentView*)             &(x)->lpOleDocumentViewVtbl)
230 #define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
231 #define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
232 #define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObject2Vtbl)
233 #define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObject2Vtbl)
234 #define INPLACEOBJ(x)    ((IOleInPlaceObject*)            &(x)->lpOleInPlaceObjectWindowlessVtbl)
235 #define INPLACEWIN(x)    ((IOleInPlaceObjectWindowless*)  &(x)->lpOleInPlaceObjectWindowlessVtbl)
236 #define SERVPROV(x)      ((IServiceProvider*)             &(x)->lpServiceProviderVtbl)
237 #define CMDTARGET(x)     ((IOleCommandTarget*)            &(x)->lpOleCommandTargetVtbl)
238 #define CONTROL(x)       ((IOleControl*)                  &(x)->lpOleControlVtbl)
239 #define HLNKTARGET(x)    ((IHlinkTarget*)                 &(x)->lpHlinkTargetVtbl)
240 #define CONPTCONT(x)     ((IConnectionPointContainer*)    &(x)->lpConnectionPointContainerVtbl)
241 #define PERSTRINIT(x)    ((IPersistStreamInit*)           &(x)->lpPersistStreamInitVtbl)
242
243 #define NSWBCHROME(x)    ((nsIWebBrowserChrome*)          &(x)->lpWebBrowserChromeVtbl)
244 #define NSCML(x)         ((nsIContextMenuListener*)       &(x)->lpContextMenuListenerVtbl)
245 #define NSURICL(x)       ((nsIURIContentListener*)        &(x)->lpURIContentListenerVtbl)
246 #define NSEMBWNDS(x)     ((nsIEmbeddingSiteWindow*)       &(x)->lpEmbeddingSiteWindowVtbl)
247 #define NSIFACEREQ(x)    ((nsIInterfaceRequestor*)        &(x)->lpInterfaceRequestorVtbl)
248 #define NSTOOLTIP(x)     ((nsITooltipListener*)           &(x)->lpTooltipListenerVtbl)
249 #define NSWEAKREF(x)     ((nsIWeakReference*)             &(x)->lpWeakReferenceVtbl)
250 #define NSSUPWEAKREF(x)  ((nsISupportsWeakReference*)     &(x)->lpSupportsWeakReferenceVtbl)
251
252 #define NSCHANNEL(x)     ((nsIChannel*)        &(x)->lpHttpChannelVtbl)
253 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*)    &(x)->lpHttpChannelVtbl)
254 #define NSUPCHANNEL(x)   ((nsIUploadChannel*)  &(x)->lpUploadChannelVtbl)
255
256 #define HTTPNEG(x)       ((IHttpNegotiate2*)              &(x)->lpHttpNegotiate2Vtbl)
257 #define STATUSCLB(x)     ((IBindStatusCallback*)          &(x)->lpBindStatusCallbackVtbl)
258 #define BINDINFO(x)      ((IInternetBindInfo*)            &(x)->lpInternetBindInfoVtbl);
259
260 #define HTMLELEM(x)      ((IHTMLElement*)                 &(x)->lpHTMLElementVtbl)
261 #define HTMLELEM2(x)     ((IHTMLElement2*)                &(x)->lpHTMLElement2Vtbl)
262 #define HTMLDOMNODE(x)   ((IHTMLDOMNode*)                 &(x)->lpHTMLDOMNodeVtbl)
263
264 #define HTMLTEXTCONT(x)  ((IHTMLTextContainer*)           &(x)->lpHTMLTextContainerVtbl)
265
266 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
267
268 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
269 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
270
271 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
272 void HTMLDocument_Persist_Init(HTMLDocument*);
273 void HTMLDocument_OleCmd_Init(HTMLDocument*);
274 void HTMLDocument_OleObj_Init(HTMLDocument*);
275 void HTMLDocument_View_Init(HTMLDocument*);
276 void HTMLDocument_Window_Init(HTMLDocument*);
277 void HTMLDocument_Service_Init(HTMLDocument*);
278 void HTMLDocument_Hlink_Init(HTMLDocument*);
279 void HTMLDocument_ConnectionPoints_Init(HTMLDocument*);
280
281 void HTMLDocument_ConnectionPoints_Destroy(HTMLDocument*);
282
283 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
284 void NSContainer_Release(NSContainer*);
285
286 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
287 void HTMLDocument_ShowContextMenu(HTMLDocument*,DWORD,POINT*);
288
289 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
290 void hide_tooltip(HTMLDocument*);
291 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
292
293 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
294
295 void close_gecko(void);
296 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
297 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
298
299 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
300
301 void call_property_onchanged(ConnectionPoint*,DISPID);
302
303 void *nsalloc(size_t);
304 void nsfree(void*);
305
306 void nsACString_Init(nsACString*,const char*);
307 PRUint32 nsACString_GetData(const nsACString*,const char**,PRBool*);
308 void nsACString_Finish(nsACString*);
309
310 void nsAString_Init(nsAString*,const PRUnichar*);
311 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**,PRBool*);
312 void nsAString_Finish(nsAString*);
313
314 nsIInputStream *create_nsstream(const char*,PRInt32);
315 nsICommandParams *create_nscommand_params(void);
316
317 BSCallback *create_bscallback(HTMLDocument*,IMoniker*);
318 HRESULT start_binding(BSCallback*);
319 void create_hidden_hwnd(HTMLDocument*);
320
321 IHlink *Hlink_Create(void);
322 IHTMLSelectionObject *HTMLSelectionObject_Create(nsISelection*);
323 IHTMLTxtRange *HTMLTxtRange_Create(nsISelection*);
324
325 void HTMLElement_Create(HTMLDOMNode*);
326 void HTMLBodyElement_Create(HTMLElement*);
327 void HTMLInputElement_Create(HTMLElement*);
328 void HTMLSelectElement_Create(HTMLElement*);
329 void HTMLTextAreaElement_Create(HTMLElement*);
330
331 void HTMLElement2_Init(HTMLElement*);
332
333 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLElement*);
334
335 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
336 HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
337
338 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
339 void release_nodes(HTMLDocument*);
340
341 void install_wine_gecko(void);
342
343 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
344 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
345 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
346 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
347 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
348
349 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
350
351 extern LONG module_ref;
352 #define LOCK_MODULE()   InterlockedIncrement(&module_ref)
353 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
354
355 /* memory allocation functions */
356
357 static inline void *mshtml_alloc(size_t len)
358 {
359     return HeapAlloc(GetProcessHeap(), 0, len);
360 }
361
362 static inline void *mshtml_realloc(void *mem, size_t len)
363 {
364     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
365 }
366
367 static inline BOOL mshtml_free(void *mem)
368 {
369     return HeapFree(GetProcessHeap(), 0, mem);
370 }
371
372 extern HINSTANCE hInst;