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