2 * Copyright 2005-2009 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
27 #include "wine/list.h"
28 #include "wine/unicode.h"
36 #define NS_OK ((nsresult)0x00000000L)
37 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
38 #define NS_NOINTERFACE ((nsresult)0x80004002L)
39 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
40 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
41 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
42 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
44 #define NS_FAILED(res) ((res) & 0x80000000)
45 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
49 #define MSHTML_E_NODOC 0x800a025c
51 typedef struct HTMLDOMNode HTMLDOMNode;
52 typedef struct ConnectionPoint ConnectionPoint;
53 typedef struct BSCallback BSCallback;
54 typedef struct nsChannelBSC nsChannelBSC;
55 typedef struct event_target_t event_target_t;
57 /* NOTE: make sure to keep in sync with dispex.c */
61 DispDOMChildrenCollection_tid,
62 DispHTMLAnchorElement_tid,
64 DispHTMLCommentElement_tid,
65 DispHTMLCurrentStyle_tid,
67 DispHTMLDOMTextNode_tid,
68 DispHTMLElementCollection_tid,
69 DispHTMLGenericElement_tid,
72 DispHTMLInputElement_tid,
74 DispHTMLNavigator_tid,
75 DispHTMLOptionElement_tid,
76 DispHTMLSelectElement_tid,
80 DispHTMLUnknownElement_tid,
82 IHTMLAnchorElement_tid,
84 IHTMLBodyElement2_tid,
85 IHTMLCommentElement_tid,
86 IHTMLCurrentStyle_tid,
87 IHTMLCurrentStyle2_tid,
88 IHTMLCurrentStyle3_tid,
89 IHTMLCurrentStyle4_tid,
94 IHTMLDOMChildrenCollection_tid,
102 IHTMLElementCollection_tid,
106 IHTMLGenericElement_tid,
107 IHTMLImageElementFactory_tid,
109 IHTMLInputElement_tid,
111 IHTMLOptionElement_tid,
112 IHTMLSelectElement_tid,
119 IHTMLTextContainer_tid,
127 typedef struct dispex_data_t dispex_data_t;
128 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
130 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
131 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
134 HRESULT (*value)(IUnknown*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
135 HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
136 HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
137 } dispex_static_data_vtbl_t;
140 const dispex_static_data_vtbl_t *vtbl;
141 const tid_t disp_tid;
143 const tid_t* const iface_tids;
144 } dispex_static_data_t;
147 const IDispatchExVtbl *lpIDispatchExVtbl;
151 dispex_static_data_t *data;
152 dispex_dynamic_data_t *dynamic_data;
155 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
156 void release_dispex(DispatchEx*);
157 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
158 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
160 typedef struct HTMLDocumentNode HTMLDocumentNode;
161 typedef struct HTMLDocumentObj HTMLDocumentObj;
165 SCRIPTMODE_ACTIVESCRIPT
168 typedef struct ScriptHost ScriptHost;
172 ScriptHost *script_host;
177 const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
182 } HTMLOptionElementFactory;
186 const IHTMLImageElementFactoryVtbl *lpHTMLImageElementFactoryVtbl;
191 } HTMLImageElementFactory;
193 struct HTMLLocation {
195 const IHTMLLocationVtbl *lpHTMLLocationVtbl;
209 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
210 const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
211 const IDispatchExVtbl *lpIDispatchExVtbl;
215 windowref_t *window_ref;
217 HTMLDocumentNode *doc;
218 HTMLDocumentObj *doc_obj;
219 nsIDOMWindow *nswindow;
222 nsChannelBSC *bscallback;
226 event_target_t *event_target;
227 IHTMLEventObj *event;
230 SCRIPTMODE scriptmode;
231 struct list script_hosts;
233 HTMLOptionElementFactory *option_factory;
234 HTMLImageElementFactory *image_factory;
235 HTMLLocation *location;
237 global_prop_t *global_props;
238 DWORD global_prop_cnt;
239 DWORD global_prop_size;
241 struct list children;
242 struct list sibling_entry;
253 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
255 ConnectionPoint *cp_list;
257 } ConnectionPointContainer;
259 struct ConnectionPoint {
260 const IConnectionPointVtbl *lpConnectionPointVtbl;
262 IConnectionPointContainer *container;
267 IPropertyNotifySink *propnotif;
273 ConnectionPoint *next;
276 struct HTMLDocument {
277 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
278 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
279 const IHTMLDocument4Vtbl *lpHTMLDocument4Vtbl;
280 const IHTMLDocument5Vtbl *lpHTMLDocument5Vtbl;
281 const IHTMLDocument6Vtbl *lpHTMLDocument6Vtbl;
282 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
283 const IPersistFileVtbl *lpPersistFileVtbl;
284 const IPersistHistoryVtbl *lpPersistHistoryVtbl;
285 const IMonikerPropVtbl *lpMonikerPropVtbl;
286 const IOleObjectVtbl *lpOleObjectVtbl;
287 const IOleDocumentVtbl *lpOleDocumentVtbl;
288 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
289 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
290 const IViewObject2Vtbl *lpViewObject2Vtbl;
291 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
292 const IServiceProviderVtbl *lpServiceProviderVtbl;
293 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
294 const IOleControlVtbl *lpOleControlVtbl;
295 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
296 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
297 const IDispatchExVtbl *lpIDispatchExVtbl;
298 const ISupportErrorInfoVtbl *lpSupportErrorInfoVtbl;
303 HTMLDocumentObj *doc_obj;
304 HTMLDocumentNode *doc_node;
310 ConnectionPointContainer cp_container;
311 ConnectionPoint cp_htmldocevents;
312 ConnectionPoint cp_htmldocevents2;
313 ConnectionPoint cp_propnotif;
316 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
318 return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
321 static inline ULONG htmldoc_addref(HTMLDocument *This)
323 return IUnknown_AddRef(This->unk_impl);
326 static inline ULONG htmldoc_release(HTMLDocument *This)
328 return IUnknown_Release(This->unk_impl);
331 struct HTMLDocumentObj {
332 HTMLDocument basedoc;
334 const ICustomDocVtbl *lpCustomDocVtbl;
338 NSContainer *nscontainer;
340 IOleClientSite *client;
341 IDocHostUIHandler *hostui;
342 IOleInPlaceSite *ipsite;
343 IOleInPlaceFrame *frame;
344 IOleInPlaceUIWindow *ip_window;
346 DOCHOSTUIINFO hostinfo;
348 IOleUndoManager *undomgr;
353 BOOL in_place_active;
357 BOOL container_locked;
361 READYSTATE readystate;
366 /* FIXME: probably should be in document node object */
367 struct list bindings;
371 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
376 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
377 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
378 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
379 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
380 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
381 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
382 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
383 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
385 nsEventListener blur_listener;
386 nsEventListener focus_listener;
387 nsEventListener keypress_listener;
388 nsEventListener load_listener;
389 nsEventListener htmlevent_listener;
391 nsIWebBrowser *webbrowser;
392 nsIWebNavigation *navigation;
393 nsIBaseWindow *window;
394 nsIWebBrowserFocus *focus;
397 nsIController *editor_controller;
402 HTMLDocumentObj *doc;
404 nsIURIContentListener *content_listener;
408 nsChannelBSC *bscallback; /* hack */
409 HWND reset_focus; /* hack */
413 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
414 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
415 const nsIHttpChannelInternalVtbl *lpIHttpChannelInternalVtbl;
420 nsIHttpChannel *http_channel;
421 nsIHttpChannelInternal *http_channel_internal;
423 nsIInputStream *post_data_stream;
424 nsILoadGroup *load_group;
425 nsIInterfaceRequestor *notif_callback;
427 nsLoadFlags load_flags;
428 nsIURI *original_uri;
431 PRUint32 response_status;
435 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
436 void (*destructor)(HTMLDOMNode*);
437 event_target_t **(*get_event_target)(HTMLDOMNode*);
438 HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
439 HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
440 HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
445 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
446 const IHTMLDOMNode2Vtbl *lpHTMLDOMNode2Vtbl;
447 const NodeImplVtbl *vtbl;
452 HTMLDocumentNode *doc;
453 event_target_t *event_target;
460 ConnectionPointContainer cp_container;
462 const IHTMLElementVtbl *lpHTMLElementVtbl;
463 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
464 const IHTMLElement3Vtbl *lpHTMLElement3Vtbl;
466 nsIDOMHTMLElement *nselem;
472 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
477 typedef struct _mutation_queue_t {
479 nsISupports *nsiface;
481 struct _mutation_queue_t *next;
484 struct HTMLDocumentNode {
486 HTMLDocument basedoc;
488 const IInternetHostSecurityManagerVtbl *lpIInternetHostSecurityManagerVtbl;
490 const nsIDocumentObserverVtbl *lpIDocumentObserverVtbl;
491 const nsIRunnableVtbl *lpIRunnableVtbl;
495 nsIDOMHTMLDocument *nsdoc;
499 IInternetSecurityManager *secmgr;
501 mutation_queue_t *mutation_queue;
502 mutation_queue_t *mutation_queue_tail;
504 struct list selection_list;
505 struct list range_list;
508 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
509 #define HTMLWINDOW3(x) ((IHTMLWindow3*) &(x)->lpHTMLWindow3Vtbl)
511 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
512 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
513 #define HTMLDOC4(x) ((IHTMLDocument4*) &(x)->lpHTMLDocument4Vtbl)
514 #define HTMLDOC5(x) ((IHTMLDocument5*) &(x)->lpHTMLDocument5Vtbl)
515 #define HTMLDOC6(x) ((IHTMLDocument6*) &(x)->lpHTMLDocument6Vtbl)
516 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
517 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
518 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
519 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
520 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
521 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
522 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
523 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
524 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
525 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
526 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
527 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
528 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
529 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
530 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
531 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
532 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
533 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
534 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
535 #define PERSISTHIST(x) ((IPersistHistory*) &(x)->lpPersistHistoryVtbl)
536 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
538 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
539 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
540 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
541 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
542 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
543 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
544 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
545 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
546 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
548 #define NSDOCOBS(x) ((nsIDocumentObserver*) &(x)->lpIDocumentObserverVtbl)
550 #define NSRUNNABLE(x) ((nsIRunnable*) &(x)->lpIRunnableVtbl)
552 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
553 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
554 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
555 #define NSHTTPINTERNAL(x) ((nsIHttpChannelInternal*) &(x)->lpIHttpChannelInternalVtbl)
557 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
558 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
559 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
561 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
562 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
563 #define HTMLELEM3(x) ((IHTMLElement3*) &(x)->lpHTMLElement3Vtbl)
564 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
565 #define HTMLDOMNODE2(x) ((IHTMLDOMNode2*) &(x)->lpHTMLDOMNode2Vtbl)
567 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
569 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
570 #define HTMLIMGFACTORY(x) ((IHTMLImageElementFactory*) &(x)->lpHTMLImageElementFactoryVtbl)
571 #define HTMLLOCATION(x) ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
573 #define DISPATCHEX(x) ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
575 #define SUPPERRINFO(x) ((ISupportErrorInfo*) &(x)->lpSupportErrorInfoVtbl)
577 #define HOSTSECMGR(x) ((IInternetHostSecurityManager*) &(x)->lpIInternetHostSecurityManagerVtbl)
579 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
580 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
582 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
583 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
584 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
586 HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**);
587 void update_window_doc(HTMLWindow*);
588 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
589 nsIDOMWindow *get_nsdoc_window(nsIDOMDocument*);
590 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
591 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
592 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
593 IOmNavigator *OmNavigator_Create(void);
595 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
596 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
597 void HTMLDocument_Persist_Init(HTMLDocument*);
598 void HTMLDocument_OleCmd_Init(HTMLDocument*);
599 void HTMLDocument_OleObj_Init(HTMLDocument*);
600 void HTMLDocument_View_Init(HTMLDocument*);
601 void HTMLDocument_Window_Init(HTMLDocument*);
602 void HTMLDocument_Service_Init(HTMLDocument*);
603 void HTMLDocument_Hlink_Init(HTMLDocument*);
605 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
607 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
609 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
610 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
611 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
613 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
614 void NSContainer_Release(NSContainer*);
616 void init_mutation(HTMLDocumentNode*);
617 void release_mutation(HTMLDocumentNode*);
619 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
620 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
621 void notif_focus(HTMLDocumentObj*);
623 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
624 void hide_tooltip(HTMLDocumentObj*);
625 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
627 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
629 BOOL load_gecko(BOOL);
630 void close_gecko(void);
631 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
632 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
633 void release_nsio(void);
634 BOOL install_wine_gecko(BOOL);
636 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
638 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD);
639 HRESULT navigate_url(HTMLDocumentNode*,OLECHAR*);
641 void call_property_onchanged(ConnectionPoint*,DISPID);
642 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
644 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
647 void nsACString_Init(nsACString*,const char*);
648 void nsACString_SetData(nsACString*,const char*);
649 PRUint32 nsACString_GetData(const nsACString*,const char**);
650 void nsACString_Finish(nsACString*);
652 void nsAString_Init(nsAString*,const PRUnichar*);
653 void nsAString_SetData(nsAString*,const PRUnichar*);
654 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
655 void nsAString_Finish(nsAString*);
657 nsICommandParams *create_nscommand_params(void);
658 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
659 void get_editor_controller(NSContainer*);
660 void init_nsevents(NSContainer*);
661 void add_nsevent_listener(HTMLWindow*,LPCWSTR);
662 nsresult get_nsinterface(nsISupports*,REFIID,void**);
664 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
665 void set_current_mon(HTMLWindow*,IMoniker*);
666 HRESULT start_binding(HTMLDocument*,BSCallback*,IBindCtx*);
667 void detach_document_bindings(HTMLDocumentObj*);
669 HRESULT bind_mon_to_buffer(HTMLDocument*,IMoniker*,void**,DWORD*);
671 nsChannelBSC *create_channelbsc(IMoniker*);
672 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
673 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
674 IMoniker *get_channelbsc_mon(nsChannelBSC*);
676 void parse_complete(HTMLDocumentObj*);
678 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
679 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
680 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
681 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
682 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
684 void detach_selection(HTMLDocumentNode*);
685 void detach_ranges(HTMLDocumentNode*);
686 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
688 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
690 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*);
692 HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL);
693 HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*);
694 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
695 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
696 HTMLElement *HTMLIFrame_Create(nsIDOMHTMLElement*);
697 HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement*);
698 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
699 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
700 HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*);
701 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
702 HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
703 HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement*);
704 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
705 HTMLElement *HTMLGenericElement_Create(nsIDOMHTMLElement*);
707 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
708 void HTMLElement_Init(HTMLElement*,dispex_static_data_t*);
709 void HTMLElement2_Init(HTMLElement*);
710 void HTMLElement3_Init(HTMLElement*);
711 void HTMLTextContainer_Init(HTMLTextContainer*,dispex_static_data_t*);
713 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
714 void HTMLDOMNode_destructor(HTMLDOMNode*);
716 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
717 void HTMLElement_destructor(HTMLDOMNode*);
719 HTMLDOMNode *get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL);
720 void release_nodes(HTMLDocumentNode*);
722 void release_script_hosts(HTMLWindow*);
723 void connect_scripts(HTMLWindow*);
724 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
725 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
726 void set_script_mode(HTMLWindow*,SCRIPTMODE);
727 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
728 IDispatch *get_script_disp(ScriptHost*);
730 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
731 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
732 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
737 HRESULT (*query)(HTMLDocument*,OLECMD*);
738 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
741 extern const cmdtable_t editmode_cmds[];
743 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
746 #define UPDATE_UI 0x0001
747 #define UPDATE_TITLE 0x0002
749 void update_doc(HTMLDocument*,DWORD);
750 void update_title(HTMLDocumentObj*);
753 void init_editor(HTMLDocument*);
754 void set_ns_editmode(NSContainer*);
755 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
756 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
757 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
758 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
759 void handle_edit_load(HTMLDocument*);
760 HRESULT editor_is_dirty(HTMLDocument*);
761 void set_dirty(HTMLDocument*,VARIANT_BOOL);
763 extern DWORD mshtml_tls;
765 typedef struct task_t task_t;
766 typedef void (*task_proc_t)(task_t*);
776 HTMLDocumentObj *doc;
781 task_t *task_queue_head;
782 task_t *task_queue_tail;
783 struct list timer_list;
786 thread_data_t *get_thread_data(BOOL);
787 HWND get_thread_hwnd(void);
789 LONG get_task_target_magic(void);
790 void push_task(task_t*,task_proc_t,LONG);
791 void remove_target_tasks(LONG);
793 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
794 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
796 void release_typelib(void);
797 HRESULT call_disp_func(IDispatch*,DISPPARAMS*);
799 const char *debugstr_variant(const VARIANT*);
801 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
802 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
803 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
804 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
805 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
807 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
809 /* memory allocation functions */
811 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
813 return HeapAlloc(GetProcessHeap(), 0, len);
816 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
818 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
821 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
823 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
826 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
828 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
831 static inline BOOL heap_free(void *mem)
833 return HeapFree(GetProcessHeap(), 0, mem);
836 static inline LPWSTR heap_strdupW(LPCWSTR str)
843 size = (strlenW(str)+1)*sizeof(WCHAR);
844 ret = heap_alloc(size);
845 memcpy(ret, str, size);
851 static inline char *heap_strdupA(const char *str)
858 size = strlen(str)+1;
859 ret = heap_alloc(size);
860 memcpy(ret, str, size);
866 static inline WCHAR *heap_strdupAtoW(const char *str)
873 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
874 ret = heap_alloc(len*sizeof(WCHAR));
875 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
881 static inline char *heap_strdupWtoA(LPCWSTR str)
886 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
887 ret = heap_alloc(size);
888 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
894 static inline void windowref_addref(windowref_t *ref)
896 InterlockedIncrement(&ref->ref);
899 static inline void windowref_release(windowref_t *ref)
901 if(!InterlockedDecrement(&ref->ref))
905 HINSTANCE get_shdoclc(void);
907 extern HINSTANCE hInst;