mshtml: Added IHTMLStyle::[get|put]_verticalAlign implementation.
[wine] / dlls / mshtml / mshtml_private.h
1 /*
2  * Copyright 2005-2008 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 "wingdi.h"
20 #include "docobj.h"
21 #include "mshtml.h"
22 #include "mshtmhst.h"
23 #include "hlink.h"
24 #include "dispex.h"
25
26 #include "wine/list.h"
27 #include "wine/unicode.h"
28
29 #ifdef INIT_GUID
30 #include "initguid.h"
31 #endif
32
33 #include "nsiface.h"
34
35 #define GENERATE_MSHTML_NS_FAILURE(code) \
36     ((nsresult) ((PRUint32)(1<<31) | ((PRUint32)(0x45+6)<<16) | (PRUint32)(code)))
37
38 #define NS_OK                     ((nsresult)0x00000000L)
39 #define NS_ERROR_FAILURE          ((nsresult)0x80004005L)
40 #define NS_NOINTERFACE            ((nsresult)0x80004002L)
41 #define NS_ERROR_NOT_IMPLEMENTED  ((nsresult)0x80004001L)
42 #define NS_ERROR_INVALID_ARG      ((nsresult)0x80070057L) 
43 #define NS_ERROR_UNEXPECTED       ((nsresult)0x8000ffffL)
44 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
45
46 #define WINE_NS_LOAD_FROM_MONIKER GENERATE_MSHTML_NS_FAILURE(0)
47
48 #define NS_FAILED(res) ((res) & 0x80000000)
49 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
50
51 #define NSAPI WINAPI
52
53 #define MSHTML_E_NODOC    0x800a025c
54
55 typedef struct HTMLDOMNode HTMLDOMNode;
56 typedef struct ConnectionPoint ConnectionPoint;
57 typedef struct BSCallback BSCallback;
58 typedef struct nsChannelBSC nsChannelBSC;
59 typedef struct event_target_t event_target_t;
60
61 /* NOTE: make sure to keep in sync with dispex.c */
62 typedef enum {
63     NULL_tid,
64     DispDOMChildrenCollection_tid,
65     DispHTMLBody_tid,
66     DispHTMLCommentElement_tid,
67     DispHTMLCurrentStyle_tid,
68     DispHTMLDocument_tid,
69     DispHTMLDOMTextNode_tid,
70     DispHTMLElementCollection_tid,
71     DispHTMLGenericElement_tid,
72     DispHTMLImg_tid,
73     DispHTMLInputElement_tid,
74     DispHTMLOptionElement_tid,
75     DispHTMLSelectElement_tid,
76     DispHTMLStyle_tid,
77     DispHTMLTable_tid,
78     DispHTMLTableRow_tid,
79     DispHTMLUnknownElement_tid,
80     DispHTMLWindow2_tid,
81     IHTMLBodyElement_tid,
82     IHTMLBodyElement2_tid,
83     IHTMLCommentElement_tid,
84     IHTMLCurrentStyle_tid,
85     IHTMLDocument2_tid,
86     IHTMLDocument3_tid,
87     IHTMLDocument4_tid,
88     IHTMLDocument5_tid,
89     IHTMLDOMChildrenCollection_tid,
90     IHTMLDOMNode_tid,
91     IHTMLDOMNode2_tid,
92     IHTMLDOMTextNode_tid,
93     IHTMLElement_tid,
94     IHTMLElement2_tid,
95     IHTMLElement3_tid,
96     IHTMLElement4_tid,
97     IHTMLElementCollection_tid,
98     IHTMLGenericElement_tid,
99     IHTMLImgElement_tid,
100     IHTMLInputElement_tid,
101     IHTMLOptionElement_tid,
102     IHTMLSelectElement_tid,
103     IHTMLStyle_tid,
104     IHTMLStyle2_tid,
105     IHTMLTable_tid,
106     IHTMLTableRow_tid,
107     IHTMLTextContainer_tid,
108     IHTMLUniqueName_tid,
109     IHTMLWindow2_tid,
110     IHTMLWindow3_tid,
111     IOmNavigator_tid,
112     LAST_tid
113 } tid_t;
114
115 typedef enum {
116     EVENTID_CHANGE,
117     EVENTID_CLICK,
118     EVENTID_KEYUP,
119     EVENTID_LOAD,
120     EVENTID_LAST
121 } eventid_t;
122
123 typedef struct dispex_data_t dispex_data_t;
124 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
125
126 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
127 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
128
129 typedef struct {
130     HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
131     HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
132 } dispex_static_data_vtbl_t;
133
134 typedef struct {
135     const dispex_static_data_vtbl_t *vtbl;
136     const tid_t disp_tid;
137     dispex_data_t *data;
138     const tid_t* const iface_tids;
139 } dispex_static_data_t;
140
141 typedef struct {
142     const IDispatchExVtbl  *lpIDispatchExVtbl;
143
144     IUnknown *outer;
145
146     dispex_static_data_t *data;
147     dispex_dynamic_data_t *dynamic_data;
148 } DispatchEx;
149
150 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
151 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
152
153 typedef struct {
154     DispatchEx dispex;
155     const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
156     const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
157     const IDispatchExVtbl  *lpIDispatchExVtbl;
158
159     LONG ref;
160
161     HTMLDocument *doc;
162     nsIDOMWindow *nswindow;
163
164     IHTMLEventObj *event;
165
166     struct list entry;
167 } HTMLWindow;
168
169 typedef enum {
170     UNKNOWN_USERMODE,
171     BROWSEMODE,
172     EDITMODE        
173 } USERMODE;
174
175 typedef enum {
176     SCRIPTMODE_GECKO,
177     SCRIPTMODE_ACTIVESCRIPT
178 } SCRIPTMODE;
179
180 typedef struct {
181     const IConnectionPointContainerVtbl  *lpConnectionPointContainerVtbl;
182
183     ConnectionPoint *cp_list;
184     IUnknown *outer;
185 } ConnectionPointContainer;
186
187 struct ConnectionPoint {
188     const IConnectionPointVtbl *lpConnectionPointVtbl;
189
190     IConnectionPointContainer *container;
191
192     union {
193         IUnknown *unk;
194         IDispatch *disp;
195         IPropertyNotifySink *propnotif;
196     } *sinks;
197     DWORD sinks_size;
198
199     const IID *iid;
200
201     ConnectionPoint *next;
202 };
203
204 typedef struct {
205     const IHTMLLocationVtbl *lpHTMLLocationVtbl;
206
207     LONG ref;
208
209     HTMLDocument *doc;
210 } HTMLLocation;
211
212 typedef struct {
213     const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
214
215     LONG ref;
216
217     HTMLDocument *doc;
218 } HTMLOptionElementFactory;
219
220 struct HTMLDocument {
221     DispatchEx dispex;
222     const IHTMLDocument2Vtbl              *lpHTMLDocument2Vtbl;
223     const IHTMLDocument3Vtbl              *lpHTMLDocument3Vtbl;
224     const IHTMLDocument4Vtbl              *lpHTMLDocument4Vtbl;
225     const IHTMLDocument5Vtbl              *lpHTMLDocument5Vtbl;
226     const IPersistMonikerVtbl             *lpPersistMonikerVtbl;
227     const IPersistFileVtbl                *lpPersistFileVtbl;
228     const IMonikerPropVtbl                *lpMonikerPropVtbl;
229     const IOleObjectVtbl                  *lpOleObjectVtbl;
230     const IOleDocumentVtbl                *lpOleDocumentVtbl;
231     const IOleDocumentViewVtbl            *lpOleDocumentViewVtbl;
232     const IOleInPlaceActiveObjectVtbl     *lpOleInPlaceActiveObjectVtbl;
233     const IViewObject2Vtbl                *lpViewObject2Vtbl;
234     const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
235     const IServiceProviderVtbl            *lpServiceProviderVtbl;
236     const IOleCommandTargetVtbl           *lpOleCommandTargetVtbl;
237     const IOleControlVtbl                 *lpOleControlVtbl;
238     const IHlinkTargetVtbl                *lpHlinkTargetVtbl;
239     const IPersistStreamInitVtbl          *lpPersistStreamInitVtbl;
240     const ICustomDocVtbl                  *lpCustomDocVtbl;
241     const IDispatchExVtbl                 *lpIDispatchExVtbl;
242
243     LONG ref;
244
245     NSContainer *nscontainer;
246     HTMLWindow *window;
247
248     IOleClientSite *client;
249     IDocHostUIHandler *hostui;
250     IOleInPlaceSite *ipsite;
251     IOleInPlaceFrame *frame;
252     IOleInPlaceUIWindow *ip_window;
253
254     IOleUndoManager *undomgr;
255
256     nsChannelBSC *bscallback;
257     IMoniker *mon;
258     LPOLESTR url;
259     struct list bindings;
260
261     struct list script_hosts;
262
263     HWND hwnd;
264     HWND tooltips_hwnd;
265
266     DOCHOSTUIINFO hostinfo;
267
268     USERMODE usermode;
269     SCRIPTMODE scriptmode;
270     READYSTATE readystate;
271     BOOL in_place_active;
272     BOOL ui_active;
273     BOOL window_active;
274     BOOL has_key_path;
275     BOOL container_locked;
276     BOOL focus;
277     LPWSTR mime;
278
279     DWORD update;
280
281     ConnectionPointContainer cp_container;
282     ConnectionPoint cp_htmldocevents;
283     ConnectionPoint cp_htmldocevents2;
284     ConnectionPoint cp_propnotif;
285
286     HTMLOptionElementFactory *option_factory;
287     HTMLLocation *location;
288
289     struct list selection_list;
290     struct list range_list;
291
292     HTMLDOMNode *nodes;
293 };
294
295 typedef struct {
296     const nsIDOMEventListenerVtbl      *lpDOMEventListenerVtbl;
297     NSContainer *This;
298 } nsEventListener;
299
300 struct NSContainer {
301     const nsIWebBrowserChromeVtbl       *lpWebBrowserChromeVtbl;
302     const nsIContextMenuListenerVtbl    *lpContextMenuListenerVtbl;
303     const nsIURIContentListenerVtbl     *lpURIContentListenerVtbl;
304     const nsIEmbeddingSiteWindowVtbl    *lpEmbeddingSiteWindowVtbl;
305     const nsITooltipListenerVtbl        *lpTooltipListenerVtbl;
306     const nsIInterfaceRequestorVtbl     *lpInterfaceRequestorVtbl;
307     const nsIWeakReferenceVtbl          *lpWeakReferenceVtbl;
308     const nsISupportsWeakReferenceVtbl  *lpSupportsWeakReferenceVtbl;
309
310     nsEventListener blur_listener;
311     nsEventListener focus_listener;
312     nsEventListener keypress_listener;
313     nsEventListener load_listener;
314     nsEventListener node_insert_listener;
315     nsEventListener htmlevent_listener;
316
317     nsIWebBrowser *webbrowser;
318     nsIWebNavigation *navigation;
319     nsIBaseWindow *window;
320     nsIWebBrowserFocus *focus;
321
322     nsIEditor *editor;
323     nsIController *editor_controller;
324
325     LONG ref;
326
327     NSContainer *parent;
328     HTMLDocument *doc;
329
330     nsIURIContentListener *content_listener;
331
332     HWND hwnd;
333
334     nsChannelBSC *bscallback; /* hack */
335     HWND reset_focus; /* hack */
336
337     BOOL event_vector[EVENTID_LAST];
338 };
339
340 typedef struct {
341     const nsIHttpChannelVtbl *lpHttpChannelVtbl;
342     const nsIUploadChannelVtbl *lpUploadChannelVtbl;
343
344     LONG ref;
345
346     nsIChannel *channel;
347     nsIHttpChannel *http_channel;
348     nsIWineURI *uri;
349     nsIInputStream *post_data_stream;
350     nsILoadGroup *load_group;
351     nsIInterfaceRequestor *notif_callback;
352     nsLoadFlags load_flags;
353     nsIURI *original_uri;
354     char *content_type;
355     char *charset;
356 } nsChannel;
357
358 typedef struct {
359     HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
360     void (*destructor)(HTMLDOMNode*);
361 } NodeImplVtbl;
362
363 struct HTMLDOMNode {
364     DispatchEx dispex;
365     const IHTMLDOMNodeVtbl   *lpHTMLDOMNodeVtbl;
366     const IHTMLDOMNode2Vtbl  *lpHTMLDOMNode2Vtbl;
367     const NodeImplVtbl *vtbl;
368
369     LONG ref;
370
371     nsIDOMNode *nsnode;
372     HTMLDocument *doc;
373     event_target_t *event_target;
374
375     HTMLDOMNode *next;
376 };
377
378 typedef struct {
379     HTMLDOMNode node;
380     ConnectionPointContainer cp_container;
381
382     const IHTMLElementVtbl   *lpHTMLElementVtbl;
383     const IHTMLElement2Vtbl  *lpHTMLElement2Vtbl;
384
385     nsIDOMHTMLElement *nselem;
386 } HTMLElement;
387
388 typedef struct {
389     HTMLElement element;
390
391     const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
392
393     ConnectionPoint cp;
394 } HTMLTextContainer;
395
396 #define HTMLWINDOW2(x)   ((IHTMLWindow2*)                 &(x)->lpHTMLWindow2Vtbl)
397 #define HTMLWINDOW3(x)   ((IHTMLWindow3*)                 &(x)->lpHTMLWindow3Vtbl)
398
399 #define HTMLDOC(x)       ((IHTMLDocument2*)               &(x)->lpHTMLDocument2Vtbl)
400 #define HTMLDOC3(x)      ((IHTMLDocument3*)               &(x)->lpHTMLDocument3Vtbl)
401 #define HTMLDOC4(x)      ((IHTMLDocument4*)               &(x)->lpHTMLDocument4Vtbl)
402 #define HTMLDOC5(x)      ((IHTMLDocument5*)               &(x)->lpHTMLDocument5Vtbl)
403 #define PERSIST(x)       ((IPersist*)                     &(x)->lpPersistFileVtbl)
404 #define PERSISTMON(x)    ((IPersistMoniker*)              &(x)->lpPersistMonikerVtbl)
405 #define PERSISTFILE(x)   ((IPersistFile*)                 &(x)->lpPersistFileVtbl)
406 #define MONPROP(x)       ((IMonikerProp*)                 &(x)->lpMonikerPropVtbl)
407 #define OLEOBJ(x)        ((IOleObject*)                   &(x)->lpOleObjectVtbl)
408 #define OLEDOC(x)        ((IOleDocument*)                 &(x)->lpOleDocumentVtbl)
409 #define DOCVIEW(x)       ((IOleDocumentView*)             &(x)->lpOleDocumentViewVtbl)
410 #define OLEWIN(x)        ((IOleWindow*)                   &(x)->lpOleInPlaceActiveObjectVtbl)
411 #define ACTOBJ(x)        ((IOleInPlaceActiveObject*)      &(x)->lpOleInPlaceActiveObjectVtbl)
412 #define VIEWOBJ(x)       ((IViewObject*)                  &(x)->lpViewObject2Vtbl)
413 #define VIEWOBJ2(x)      ((IViewObject2*)                 &(x)->lpViewObject2Vtbl)
414 #define INPLACEOBJ(x)    ((IOleInPlaceObject*)            &(x)->lpOleInPlaceObjectWindowlessVtbl)
415 #define INPLACEWIN(x)    ((IOleInPlaceObjectWindowless*)  &(x)->lpOleInPlaceObjectWindowlessVtbl)
416 #define SERVPROV(x)      ((IServiceProvider*)             &(x)->lpServiceProviderVtbl)
417 #define CMDTARGET(x)     ((IOleCommandTarget*)            &(x)->lpOleCommandTargetVtbl)
418 #define CONTROL(x)       ((IOleControl*)                  &(x)->lpOleControlVtbl)
419 #define HLNKTARGET(x)    ((IHlinkTarget*)                 &(x)->lpHlinkTargetVtbl)
420 #define CONPTCONT(x)     ((IConnectionPointContainer*)    &(x)->lpConnectionPointContainerVtbl)
421 #define PERSTRINIT(x)    ((IPersistStreamInit*)           &(x)->lpPersistStreamInitVtbl)
422 #define CUSTOMDOC(x)     ((ICustomDoc*)                   &(x)->lpCustomDocVtbl)
423
424 #define NSWBCHROME(x)    ((nsIWebBrowserChrome*)          &(x)->lpWebBrowserChromeVtbl)
425 #define NSCML(x)         ((nsIContextMenuListener*)       &(x)->lpContextMenuListenerVtbl)
426 #define NSURICL(x)       ((nsIURIContentListener*)        &(x)->lpURIContentListenerVtbl)
427 #define NSEMBWNDS(x)     ((nsIEmbeddingSiteWindow*)       &(x)->lpEmbeddingSiteWindowVtbl)
428 #define NSIFACEREQ(x)    ((nsIInterfaceRequestor*)        &(x)->lpInterfaceRequestorVtbl)
429 #define NSTOOLTIP(x)     ((nsITooltipListener*)           &(x)->lpTooltipListenerVtbl)
430 #define NSEVENTLIST(x)   ((nsIDOMEventListener*)          &(x)->lpDOMEventListenerVtbl)
431 #define NSWEAKREF(x)     ((nsIWeakReference*)             &(x)->lpWeakReferenceVtbl)
432 #define NSSUPWEAKREF(x)  ((nsISupportsWeakReference*)     &(x)->lpSupportsWeakReferenceVtbl)
433
434 #define NSCHANNEL(x)     ((nsIChannel*)        &(x)->lpHttpChannelVtbl)
435 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*)    &(x)->lpHttpChannelVtbl)
436 #define NSUPCHANNEL(x)   ((nsIUploadChannel*)  &(x)->lpUploadChannelVtbl)
437
438 #define HTTPNEG(x)       ((IHttpNegotiate2*)              &(x)->lpHttpNegotiate2Vtbl)
439 #define STATUSCLB(x)     ((IBindStatusCallback*)          &(x)->lpBindStatusCallbackVtbl)
440 #define BINDINFO(x)      ((IInternetBindInfo*)            &(x)->lpInternetBindInfoVtbl);
441
442 #define HTMLELEM(x)      ((IHTMLElement*)                 &(x)->lpHTMLElementVtbl)
443 #define HTMLELEM2(x)     ((IHTMLElement2*)                &(x)->lpHTMLElement2Vtbl)
444 #define HTMLDOMNODE(x)   ((IHTMLDOMNode*)                 &(x)->lpHTMLDOMNodeVtbl)
445 #define HTMLDOMNODE2(x)  ((IHTMLDOMNode2*)                &(x)->lpHTMLDOMNode2Vtbl)
446
447 #define HTMLTEXTCONT(x)  ((IHTMLTextContainer*)           &(x)->lpHTMLTextContainerVtbl)
448
449 #define HTMLOPTFACTORY(x)  ((IHTMLOptionElementFactory*)  &(x)->lpHTMLOptionElementFactoryVtbl)
450 #define HTMLLOCATION(x)  ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
451
452 #define DISPATCHEX(x)    ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
453
454 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
455 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
456
457 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
458 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
459
460 HTMLWindow *HTMLWindow_Create(HTMLDocument*);
461 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
462 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLDocument*);
463 HTMLLocation *HTMLLocation_Create(HTMLDocument*);
464 IOmNavigator *OmNavigator_Create(void);
465 void setup_nswindow(HTMLWindow*);
466
467 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
468 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
469 void HTMLDocument_Persist_Init(HTMLDocument*);
470 void HTMLDocument_OleCmd_Init(HTMLDocument*);
471 void HTMLDocument_OleObj_Init(HTMLDocument*);
472 void HTMLDocument_View_Init(HTMLDocument*);
473 void HTMLDocument_Window_Init(HTMLDocument*);
474 void HTMLDocument_Service_Init(HTMLDocument*);
475 void HTMLDocument_Hlink_Init(HTMLDocument*);
476
477 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
478
479 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
480 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
481 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
482
483 NSContainer *NSContainer_Create(HTMLDocument*,NSContainer*);
484 void NSContainer_Release(NSContainer*);
485
486 void HTMLDocument_LockContainer(HTMLDocument*,BOOL);
487 void show_context_menu(HTMLDocument*,DWORD,POINT*,IDispatch*);
488 void notif_focus(HTMLDocument*);
489
490 void show_tooltip(HTMLDocument*,DWORD,DWORD,LPCWSTR);
491 void hide_tooltip(HTMLDocument*);
492 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
493
494 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
495
496 BOOL load_gecko(BOOL);
497 void close_gecko(void);
498 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
499 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
500 BOOL install_wine_gecko(BOOL);
501
502 void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWORD);
503
504 void call_property_onchanged(ConnectionPoint*,DISPID);
505 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
506
507 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
508 void nsfree(void*);
509
510 void nsACString_Init(nsACString*,const char*);
511 void nsACString_SetData(nsACString*,const char*);
512 PRUint32 nsACString_GetData(const nsACString*,const char**);
513 void nsACString_Finish(nsACString*);
514
515 void nsAString_Init(nsAString*,const PRUnichar*);
516 void nsAString_SetData(nsAString*,const PRUnichar*);
517 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
518 void nsAString_Finish(nsAString*);
519
520 nsIInputStream *create_nsstream(const char*,PRInt32);
521 nsICommandParams *create_nscommand_params(void);
522 nsIMutableArray *create_nsarray(void);
523 nsIWritableVariant *create_nsvariant(void);
524 void nsnode_to_nsstring(nsIDOMNode*,nsAString*);
525 void get_editor_controller(NSContainer*);
526 void init_nsevents(NSContainer*);
527 void add_nsevent_listener(NSContainer*,LPCWSTR);
528 nsresult get_nsinterface(nsISupports*,REFIID,void**);
529
530 void check_event_attr(HTMLDocument*,nsIDOMElement*);
531 void release_event_target(event_target_t*);
532 void fire_event(HTMLDocument*,eventid_t,nsIDOMNode*);
533 HRESULT set_node_event(HTMLDOMNode*,eventid_t,VARIANT*);
534 eventid_t str_to_eid(LPCWSTR);
535
536 void set_document_bscallback(HTMLDocument*,nsChannelBSC*);
537 void set_current_mon(HTMLDocument*,IMoniker*);
538 HRESULT start_binding(HTMLDocument*,BSCallback*,IBindCtx*);
539
540 HRESULT bind_mon_to_buffer(HTMLDocument*,IMoniker*,void**,DWORD*);
541
542 nsChannelBSC *create_channelbsc(IMoniker*);
543 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
544 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
545 IMoniker *get_channelbsc_mon(nsChannelBSC*);
546
547 IHTMLSelectionObject *HTMLSelectionObject_Create(HTMLDocument*,nsISelection*);
548 IHTMLTxtRange *HTMLTxtRange_Create(HTMLDocument*,nsIDOMRange*);
549 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
550 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
551 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
552
553 void detach_selection(HTMLDocument*);
554 void detach_ranges(HTMLDocument*);
555
556 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocument*,nsIDOMNode*);
557
558 HTMLElement *HTMLElement_Create(HTMLDocument*,nsIDOMNode*,BOOL);
559 HTMLElement *HTMLCommentElement_Create(HTMLDocument*,nsIDOMNode*);
560 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
561 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
562 HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement*);
563 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
564 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
565 HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*);
566 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
567 HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
568 HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement*);
569 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
570 HTMLElement *HTMLGenericElement_Create(nsIDOMHTMLElement*);
571
572 void HTMLDOMNode_Init(HTMLDocument*,HTMLDOMNode*,nsIDOMNode*);
573 void HTMLElement_Init(HTMLElement*);
574 void HTMLElement2_Init(HTMLElement*);
575 void HTMLTextContainer_Init(HTMLTextContainer*);
576
577 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
578 void HTMLDOMNode_destructor(HTMLDOMNode*);
579
580 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
581 void HTMLElement_destructor(HTMLDOMNode*);
582
583 HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*,BOOL);
584 void release_nodes(HTMLDocument*);
585
586 void release_script_hosts(HTMLDocument*);
587 void connect_scripts(HTMLDocument*);
588 void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*);
589 IDispatch *script_parse_event(HTMLDocument*,LPCWSTR);
590 void set_script_mode(HTMLDocument*,SCRIPTMODE);
591
592 IHTMLElementCollection *HTMLElementCollection_Create(IUnknown*,HTMLElement**,DWORD);
593 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
594 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocument*,IUnknown*,nsIDOMNodeList*);
595 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocument*,IUnknown*,nsIDOMHTMLCollection*);
596
597 /* commands */
598 typedef struct {
599     DWORD id;
600     HRESULT (*query)(HTMLDocument*,OLECMD*);
601     HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
602 } cmdtable_t;
603
604 extern const cmdtable_t editmode_cmds[];
605
606 void do_ns_command(NSContainer*,const char*,nsICommandParams*);
607
608 /* timer */
609 #define UPDATE_UI       0x0001
610 #define UPDATE_TITLE    0x0002
611
612 void update_doc(HTMLDocument *This, DWORD flags);
613 void update_title(HTMLDocument*);
614
615 /* editor */
616 void init_editor(HTMLDocument*);
617 void set_ns_editmode(NSContainer*);
618 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
619 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
620 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
621 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
622 void handle_edit_load(HTMLDocument*);
623 HRESULT editor_is_dirty(HTMLDocument*);
624 void set_dirty(HTMLDocument*,VARIANT_BOOL);
625
626 extern DWORD mshtml_tls;
627
628 typedef struct task_t {
629     HTMLDocument *doc;
630
631     enum {
632         TASK_SETDOWNLOADSTATE,
633         TASK_PARSECOMPLETE,
634         TASK_SETPROGRESS,
635         TASK_START_BINDING
636     } task_id;
637
638     nsChannelBSC *bscallback;
639
640     struct task_t *next;
641 } task_t;
642
643 typedef struct {
644     HWND thread_hwnd;
645     task_t *task_queue_head;
646     task_t *task_queue_tail;
647     struct list timer_list;
648 } thread_data_t;
649
650 thread_data_t *get_thread_data(BOOL);
651 HWND get_thread_hwnd(void);
652 void push_task(task_t*);
653 void remove_doc_tasks(const HTMLDocument*);
654 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
655 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
656
657 HRESULT get_typeinfo(tid_t,ITypeInfo**);
658 void release_typelib(void);
659 void call_disp_func(HTMLDocument*,IDispatch*);
660
661 const char *debugstr_variant(const VARIANT*);
662
663 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
664 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
665 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
666 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
667 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
668
669 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
670
671 extern LONG module_ref;
672 #define LOCK_MODULE()   InterlockedIncrement(&module_ref)
673 #define UNLOCK_MODULE() InterlockedDecrement(&module_ref)
674
675 /* memory allocation functions */
676
677 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
678 {
679     return HeapAlloc(GetProcessHeap(), 0, len);
680 }
681
682 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
683 {
684     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
685 }
686
687 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
688 {
689     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
690 }
691
692 static inline BOOL heap_free(void *mem)
693 {
694     return HeapFree(GetProcessHeap(), 0, mem);
695 }
696
697 static inline LPWSTR heap_strdupW(LPCWSTR str)
698 {
699     LPWSTR ret = NULL;
700
701     if(str) {
702         DWORD size;
703
704         size = (strlenW(str)+1)*sizeof(WCHAR);
705         ret = heap_alloc(size);
706         memcpy(ret, str, size);
707     }
708
709     return ret;
710 }
711
712 static inline char *heap_strdupA(const char *str)
713 {
714     char *ret = NULL;
715
716     if(str) {
717         DWORD size;
718
719         size = strlen(str)+1;
720         ret = heap_alloc(size);
721         memcpy(ret, str, size);
722     }
723
724     return ret;
725 }
726
727 static inline WCHAR *heap_strdupAtoW(const char *str)
728 {
729     LPWSTR ret = NULL;
730
731     if(str) {
732         DWORD len;
733
734         len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
735         ret = heap_alloc(len*sizeof(WCHAR));
736         MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
737     }
738
739     return ret;
740 }
741
742 static inline char *heap_strdupWtoA(LPCWSTR str)
743 {
744     char *ret = NULL;
745
746     if(str) {
747         DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
748         ret = heap_alloc(size);
749         WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
750     }
751
752     return ret;
753 }
754
755 HINSTANCE get_shdoclc(void);
756
757 extern HINSTANCE hInst;