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