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
28 #include "wine/list.h"
29 #include "wine/unicode.h"
37 #define NS_ERROR_GENERATE_FAILURE(module,code) \
38 ((nsresult) (((PRUint32)(1<<31)) | ((PRUint32)(module+0x45)<<16) | ((PRUint32)(code))))
40 #define NS_OK ((nsresult)0x00000000L)
41 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
42 #define NS_ERROR_OUT_OF_MEMORY ((nsresult)0x8007000EL)
43 #define NS_NOINTERFACE ((nsresult)0x80004002L)
44 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
45 #define NS_ERROR_NOT_AVAILABLE ((nsresult)0x80040111L)
46 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
47 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
49 #define NS_ERROR_MODULE_NETWORK 6
51 #define NS_BINDING_ABORTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 2)
52 #define NS_ERROR_UNKNOWN_PROTOCOL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 18)
54 #define NS_FAILED(res) ((res) & 0x80000000)
55 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
59 #define MSHTML_E_NODOC 0x800a025c
61 typedef struct HTMLDOMNode HTMLDOMNode;
62 typedef struct ConnectionPoint ConnectionPoint;
63 typedef struct BSCallback BSCallback;
64 typedef struct event_target_t event_target_t;
68 XDIID(DispCEventObj) \
70 XDIID(DispDOMChildrenCollection) \
71 XDIID(DispHTMLAnchorElement) \
73 XDIID(DispHTMLCommentElement) \
74 XDIID(DispHTMLCurrentStyle) \
75 XDIID(DispHTMLDocument) \
76 XDIID(DispHTMLDOMTextNode) \
77 XDIID(DispHTMLElementCollection) \
78 XDIID(DispHTMLEmbed) \
79 XDIID(DispHTMLFormElement) \
80 XDIID(DispHTMLGenericElement) \
81 XDIID(DispHTMLFrameElement) \
82 XDIID(DispHTMLIFrame) \
84 XDIID(DispHTMLInputElement) \
85 XDIID(DispHTMLLocation) \
86 XDIID(DispHTMLNavigator) \
87 XDIID(DispHTMLObjectElement) \
88 XDIID(DispHTMLOptionElement) \
89 XDIID(DispHTMLScreen) \
90 XDIID(DispHTMLScriptElement) \
91 XDIID(DispHTMLSelectElement) \
92 XDIID(DispHTMLStyle) \
93 XDIID(DispHTMLStyleElement) \
94 XDIID(DispHTMLStyleSheetsCollection) \
95 XDIID(DispHTMLTable) \
96 XDIID(DispHTMLTableRow) \
97 XDIID(DispHTMLTextAreaElement) \
98 XDIID(DispHTMLUnknownElement) \
99 XDIID(DispHTMLWindow2) \
100 XDIID(HTMLDocumentEvents) \
101 XIID(IHTMLAnchorElement) \
102 XIID(IHTMLBodyElement) \
103 XIID(IHTMLBodyElement2) \
104 XIID(IHTMLCommentElement) \
105 XIID(IHTMLCurrentStyle) \
106 XIID(IHTMLCurrentStyle2) \
107 XIID(IHTMLCurrentStyle3) \
108 XIID(IHTMLCurrentStyle4) \
109 XIID(IHTMLDocument2) \
110 XIID(IHTMLDocument3) \
111 XIID(IHTMLDocument4) \
112 XIID(IHTMLDocument5) \
113 XIID(IHTMLDOMChildrenCollection) \
115 XIID(IHTMLDOMNode2) \
116 XIID(IHTMLDOMTextNode) \
118 XIID(IHTMLElement2) \
119 XIID(IHTMLElement3) \
120 XIID(IHTMLElement4) \
121 XIID(IHTMLElementCollection) \
122 XIID(IHTMLEmbedElement) \
123 XIID(IHTMLEventObj) \
124 XIID(IHTMLFiltersCollection) \
125 XIID(IHTMLFormElement) \
126 XIID(IHTMLFrameBase) \
127 XIID(IHTMLFrameBase2) \
128 XIID(IHTMLFrameElement3) \
129 XIID(IHTMLGenericElement) \
130 XIID(IHTMLIFrameElement) \
131 XIID(IHTMLImageElementFactory) \
132 XIID(IHTMLImgElement) \
133 XIID(IHTMLInputElement) \
134 XIID(IHTMLLocation) \
135 XIID(IHTMLObjectElement) \
136 XIID(IHTMLOptionElement) \
137 XIID(IHTMLPluginsCollection) \
140 XIID(IHTMLScriptElement) \
141 XIID(IHTMLSelectElement) \
146 XIID(IHTMLStyleElement) \
147 XIID(IHTMLStyleSheetsCollection) \
149 XIID(IHTMLTableRow) \
150 XIID(IHTMLTextAreaElement) \
151 XIID(IHTMLTextContainer) \
152 XIID(IHTMLUniqueName) \
159 #define XIID(iface) iface ## _tid,
160 #define XDIID(iface) iface ## _tid,
167 typedef struct dispex_data_t dispex_data_t;
168 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
170 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
171 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
172 #define MSHTML_CUSTOM_DISPID_CNT (MSHTML_DISPID_CUSTOM_MAX-MSHTML_DISPID_CUSTOM_MIN)
174 typedef struct DispatchEx DispatchEx;
177 HRESULT (*value)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
178 HRESULT (*get_dispid)(DispatchEx*,BSTR,DWORD,DISPID*);
179 HRESULT (*invoke)(DispatchEx*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
180 } dispex_static_data_vtbl_t;
183 const dispex_static_data_vtbl_t *vtbl;
184 const tid_t disp_tid;
186 const tid_t* const iface_tids;
187 } dispex_static_data_t;
190 const IDispatchExVtbl *lpIDispatchExVtbl;
194 dispex_static_data_t *data;
195 dispex_dynamic_data_t *dynamic_data;
198 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
199 void release_dispex(DispatchEx*);
200 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
201 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
202 HRESULT get_dispids(tid_t,DWORD*,DISPID**);
203 HRESULT remove_prop(DispatchEx*,BSTR,VARIANT_BOOL*);
205 typedef struct HTMLWindow HTMLWindow;
206 typedef struct HTMLDocumentNode HTMLDocumentNode;
207 typedef struct HTMLDocumentObj HTMLDocumentObj;
208 typedef struct HTMLFrameBase HTMLFrameBase;
209 typedef struct NSContainer NSContainer;
213 SCRIPTMODE_ACTIVESCRIPT
216 typedef struct ScriptHost ScriptHost;
221 } global_prop_type_t;
224 global_prop_type_t type;
226 ScriptHost *script_host;
231 const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
236 } HTMLOptionElementFactory;
240 const IHTMLImageElementFactoryVtbl *lpHTMLImageElementFactoryVtbl;
245 } HTMLImageElementFactory;
247 struct HTMLLocation {
249 const IHTMLLocationVtbl *lpHTMLLocationVtbl;
261 typedef struct nsChannelBSC nsChannelBSC;
265 IHTMLWindow2 IHTMLWindow2_iface;
266 IHTMLWindow3 IHTMLWindow3_iface;
267 IHTMLWindow4 IHTMLWindow4_iface;
268 IHTMLPrivateWindow IHTMLPrivateWindow_iface;
269 const IDispatchExVtbl *lpIDispatchExVtbl;
270 IServiceProvider IServiceProvider_iface;
274 windowref_t *window_ref;
277 HTMLDocumentNode *doc;
278 HTMLDocumentObj *doc_obj;
279 nsIDOMWindow *nswindow;
281 HTMLFrameBase *frame_element;
282 READYSTATE readystate;
284 nsChannelBSC *bscallback;
288 IHTMLEventObj *event;
290 SCRIPTMODE scriptmode;
291 struct list script_hosts;
293 HTMLOptionElementFactory *option_factory;
294 HTMLImageElementFactory *image_factory;
295 HTMLLocation *location;
298 global_prop_t *global_props;
299 DWORD global_prop_cnt;
300 DWORD global_prop_size;
302 struct list children;
303 struct list sibling_entry;
313 typedef struct _cp_static_data_t {
315 void (*on_advise)(IUnknown*,struct _cp_static_data_t*);
320 typedef struct ConnectionPointContainer {
321 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
323 ConnectionPoint *cp_list;
325 struct ConnectionPointContainer *forward_container;
326 } ConnectionPointContainer;
328 struct ConnectionPoint {
329 const IConnectionPointVtbl *lpConnectionPointVtbl;
331 ConnectionPointContainer *container;
336 IPropertyNotifySink *propnotif;
341 cp_static_data_t *data;
343 ConnectionPoint *next;
346 struct HTMLDocument {
347 IHTMLDocument2 IHTMLDocument2_iface;
348 IHTMLDocument3 IHTMLDocument3_iface;
349 IHTMLDocument4 IHTMLDocument4_iface;
350 IHTMLDocument5 IHTMLDocument5_iface;
351 IHTMLDocument6 IHTMLDocument6_iface;
352 IPersistMoniker IPersistMoniker_iface;
353 IPersistFile IPersistFile_iface;
354 IPersistHistory IPersistHistory_iface;
355 IMonikerProp IMonikerProp_iface;
356 IOleObject IOleObject_iface;
357 IOleDocument IOleDocument_iface;
358 IOleDocumentView IOleDocumentView_iface;
359 IOleInPlaceActiveObject IOleInPlaceActiveObject_iface;
360 IViewObjectEx IViewObjectEx_iface;
361 IOleInPlaceObjectWindowless IOleInPlaceObjectWindowless_iface;
362 IServiceProvider IServiceProvider_iface;
363 IOleCommandTarget IOleCommandTarget_iface;
364 IOleControl IOleControl_iface;
365 IHlinkTarget IHlinkTarget_iface;
366 IPersistStreamInit IPersistStreamInit_iface;
367 const IDispatchExVtbl *lpIDispatchExVtbl;
368 ISupportErrorInfo ISupportErrorInfo_iface;
369 IObjectWithSite IObjectWithSite_iface;
370 IOleContainer IOleContainer_iface;
375 HTMLDocumentObj *doc_obj;
376 HTMLDocumentNode *doc_node;
382 ConnectionPointContainer cp_container;
383 ConnectionPoint cp_htmldocevents;
384 ConnectionPoint cp_htmldocevents2;
385 ConnectionPoint cp_propnotif;
386 ConnectionPoint cp_dispatch;
388 IOleAdviseHolder *advise_holder;
391 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
393 return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
396 static inline ULONG htmldoc_addref(HTMLDocument *This)
398 return IUnknown_AddRef(This->unk_impl);
401 static inline ULONG htmldoc_release(HTMLDocument *This)
403 return IUnknown_Release(This->unk_impl);
406 struct HTMLDocumentObj {
407 HTMLDocument basedoc;
409 const ICustomDocVtbl *lpCustomDocVtbl;
413 NSContainer *nscontainer;
415 IOleClientSite *client;
416 IDocHostUIHandler *hostui;
418 IOleInPlaceSite *ipsite;
419 IOleInPlaceFrame *frame;
420 IOleInPlaceUIWindow *ip_window;
421 IAdviseSink *view_sink;
423 DOCHOSTUIINFO hostinfo;
425 IOleUndoManager *undomgr;
430 BOOL request_uiactivate;
431 BOOL in_place_active;
435 BOOL container_locked;
446 nsIWebBrowserChrome nsIWebBrowserChrome_iface;
447 nsIContextMenuListener nsIContextMenuListener_iface;
448 nsIURIContentListener nsIURIContentListener_iface;
449 nsIEmbeddingSiteWindow nsIEmbeddingSiteWindow_iface;
450 nsITooltipListener nsITooltipListener_iface;
451 nsIInterfaceRequestor nsIInterfaceRequestor_iface;
452 nsIWeakReference nsIWeakReference_iface;
453 nsISupportsWeakReference nsISupportsWeakReference_iface;
455 nsIWebBrowser *webbrowser;
456 nsIWebNavigation *navigation;
457 nsIBaseWindow *window;
458 nsIWebBrowserFocus *focus;
461 nsIController *editor_controller;
466 HTMLDocumentObj *doc;
468 nsIURIContentListener *content_listener;
473 typedef struct nsWineURI nsWineURI;
475 HRESULT set_wine_url(nsWineURI*,LPCWSTR);
476 nsresult on_start_uri_open(NSContainer*,nsIURI*,PRBool*);
478 /* Keep sync with request_method_strings in nsio.c */
486 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
487 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
488 const nsIHttpChannelInternalVtbl *lpIHttpChannelInternalVtbl;
493 nsIInputStream *post_data_stream;
494 nsILoadGroup *load_group;
495 nsIInterfaceRequestor *notif_callback;
497 nsLoadFlags load_flags;
498 nsIURI *original_uri;
502 PRUint32 response_status;
503 REQUEST_METHOD request_method;
504 struct list response_headers;
505 struct list request_headers;
515 HRESULT set_http_header(struct list*,const WCHAR*,int,const WCHAR*,int);
518 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
519 void (*destructor)(HTMLDOMNode*);
520 HRESULT (*clone)(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
521 event_target_t **(*get_event_target)(HTMLDOMNode*);
522 HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
523 HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
524 HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
525 HRESULT (*get_document)(HTMLDOMNode*,IDispatch**);
526 HRESULT (*get_readystate)(HTMLDOMNode*,BSTR*);
527 HRESULT (*get_dispid)(HTMLDOMNode*,BSTR,DWORD,DISPID*);
528 HRESULT (*invoke)(HTMLDOMNode*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
529 HRESULT (*bind_to_tree)(HTMLDOMNode*);
534 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
535 const IHTMLDOMNode2Vtbl *lpHTMLDOMNode2Vtbl;
536 const NodeImplVtbl *vtbl;
541 HTMLDocumentNode *doc;
542 event_target_t *event_target;
543 ConnectionPointContainer *cp_container;
550 ConnectionPointContainer cp_container;
552 IHTMLElement IHTMLElement_iface;
553 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
554 const IHTMLElement3Vtbl *lpHTMLElement3Vtbl;
556 nsIDOMHTMLElement *nselem;
559 #define HTMLELEMENT_TIDS \
570 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
575 struct HTMLFrameBase {
578 const IHTMLFrameBaseVtbl *lpIHTMLFrameBaseVtbl;
579 const IHTMLFrameBase2Vtbl *lpIHTMLFrameBase2Vtbl;
581 HTMLWindow *content_window;
583 nsIDOMHTMLFrameElement *nsframe;
584 nsIDOMHTMLIFrameElement *nsiframe;
587 typedef struct _mutation_queue_t {
589 nsISupports *nsiface;
591 struct _mutation_queue_t *next;
594 typedef struct nsDocumentEventListener nsDocumentEventListener;
596 struct HTMLDocumentNode {
598 HTMLDocument basedoc;
600 const IInternetHostSecurityManagerVtbl *lpIInternetHostSecurityManagerVtbl;
602 const nsIDocumentObserverVtbl *lpIDocumentObserverVtbl;
603 const nsIRunnableVtbl *lpIRunnableVtbl;
607 nsIDOMHTMLDocument *nsdoc;
610 event_target_t *body_event_target;
612 IInternetSecurityManager *secmgr;
613 ICatInformation *catmgr;
614 nsDocumentEventListener *nsevent_listener;
617 BOOL skip_mutation_notif;
618 mutation_queue_t *mutation_queue;
619 mutation_queue_t *mutation_queue_tail;
621 struct list bindings;
622 struct list selection_list;
623 struct list range_list;
624 struct list plugin_hosts;
627 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
628 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
630 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
632 #define NSDOCOBS(x) ((nsIDocumentObserver*) &(x)->lpIDocumentObserverVtbl)
634 #define NSRUNNABLE(x) ((nsIRunnable*) &(x)->lpIRunnableVtbl)
636 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
637 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
638 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
639 #define NSHTTPINTERNAL(x) ((nsIHttpChannelInternal*) &(x)->lpIHttpChannelInternalVtbl)
641 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
642 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
643 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
645 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
646 #define HTMLELEM3(x) ((IHTMLElement3*) &(x)->lpHTMLElement3Vtbl)
647 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
648 #define HTMLDOMNODE2(x) ((IHTMLDOMNode2*) &(x)->lpHTMLDOMNode2Vtbl)
650 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
651 #define HTMLFRAMEBASE(x) ((IHTMLFrameBase*) &(x)->lpIHTMLFrameBaseVtbl)
652 #define HTMLFRAMEBASE2(x) ((IHTMLFrameBase2*) &(x)->lpIHTMLFrameBase2Vtbl)
654 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
655 #define HTMLIMGFACTORY(x) ((IHTMLImageElementFactory*) &(x)->lpHTMLImageElementFactoryVtbl)
656 #define HTMLLOCATION(x) ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
658 #define DISPATCHEX(x) ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
660 #define HOSTSECMGR(x) ((IInternetHostSecurityManager*) &(x)->lpIInternetHostSecurityManagerVtbl)
662 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
664 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
665 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
666 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
667 HRESULT create_document_fragment(nsIDOMNode*,HTMLDocumentNode*,HTMLDocumentNode**);
669 HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**);
670 void update_window_doc(HTMLWindow*);
671 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
672 nsIDOMWindow *get_nsdoc_window(nsIDOMDocument*);
673 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
674 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
675 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
676 IOmNavigator *OmNavigator_Create(void);
677 HRESULT HTMLScreen_Create(IHTMLScreen**);
679 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
680 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
681 void HTMLDocument_Persist_Init(HTMLDocument*);
682 void HTMLDocument_OleCmd_Init(HTMLDocument*);
683 void HTMLDocument_OleObj_Init(HTMLDocument*);
684 void HTMLDocument_View_Init(HTMLDocument*);
685 void HTMLDocument_Window_Init(HTMLDocument*);
686 void HTMLDocument_Service_Init(HTMLDocument*);
687 void HTMLDocument_Hlink_Init(HTMLDocument*);
689 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
691 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
693 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*);
694 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
695 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
697 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
698 void NSContainer_Release(NSContainer*);
699 nsresult create_chrome_window(nsIWebBrowserChrome*,nsIWebBrowserChrome**);
701 void init_mutation(HTMLDocumentNode*);
702 void release_mutation(HTMLDocumentNode*);
704 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
705 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
706 void notif_focus(HTMLDocumentObj*);
708 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
709 void hide_tooltip(HTMLDocumentObj*);
710 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
712 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
714 BOOL load_gecko(BOOL);
715 void close_gecko(void);
716 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
717 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
718 void release_nsio(void);
719 BOOL is_gecko_path(const char*);
721 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
722 HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**);
723 HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD);
725 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD,BOOL*);
726 HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
727 HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
728 HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL);
730 void call_property_onchanged(ConnectionPoint*,DISPID);
731 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
733 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
736 void nsACString_InitDepend(nsACString*,const char*);
737 void nsACString_SetData(nsACString*,const char*);
738 PRUint32 nsACString_GetData(const nsACString*,const char**);
739 void nsACString_Finish(nsACString*);
741 BOOL nsAString_Init(nsAString*,const PRUnichar*);
742 void nsAString_InitDepend(nsAString*,const PRUnichar*);
743 void nsAString_SetData(nsAString*,const PRUnichar*);
744 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
745 void nsAString_Finish(nsAString*);
746 HRESULT return_nsstr(nsresult,nsAString*,BSTR*);
748 nsICommandParams *create_nscommand_params(void);
749 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
750 void get_editor_controller(NSContainer*);
751 nsresult get_nsinterface(nsISupports*,REFIID,void**);
753 void init_nsevents(HTMLDocumentNode*);
754 void release_nsevents(HTMLDocumentNode*);
755 void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR);
757 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
758 void set_current_mon(HTMLWindow*,IMoniker*);
759 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
760 HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*);
761 void abort_document_bindings(HTMLDocumentNode*);
763 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
765 HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**);
766 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
767 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
768 IMoniker *get_channelbsc_mon(nsChannelBSC*);
770 void set_ready_state(HTMLWindow*,READYSTATE);
772 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
773 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
774 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
775 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
776 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
778 void detach_selection(HTMLDocumentNode*);
779 void detach_ranges(HTMLDocumentNode*);
780 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
782 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
784 HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**);
786 HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**);
787 HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**);
788 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
789 HRESULT HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
790 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
791 HRESULT HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
792 HRESULT HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
793 HRESULT HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
794 HRESULT HTMLStyleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
795 HRESULT HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
796 HRESULT HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
797 HRESULT HTMLObjectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
798 HRESULT HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
799 HRESULT HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
800 HRESULT HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
801 HRESULT HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
802 HRESULT HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
803 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
804 HRESULT HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
806 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
807 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
808 void HTMLElement2_Init(HTMLElement*);
809 void HTMLElement3_Init(HTMLElement*);
810 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
811 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
813 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
814 void HTMLDOMNode_destructor(HTMLDOMNode*);
816 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
817 void HTMLElement_destructor(HTMLDOMNode*);
818 HRESULT HTMLElement_clone(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
820 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
821 void HTMLFrameBase_destructor(HTMLFrameBase*);
823 HRESULT get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLDOMNode**);
824 void release_nodes(HTMLDocumentNode*);
826 void release_script_hosts(HTMLWindow*);
827 void connect_scripts(HTMLWindow*);
828 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
829 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
830 HRESULT exec_script(HTMLWindow*,const WCHAR*,const WCHAR*,VARIANT*);
831 void set_script_mode(HTMLWindow*,SCRIPTMODE);
832 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
833 IDispatch *get_script_disp(ScriptHost*);
834 HRESULT search_window_props(HTMLWindow*,BSTR,DWORD,DISPID*);
836 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
837 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
838 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
843 HRESULT (*query)(HTMLDocument*,OLECMD*);
844 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
847 extern const cmdtable_t editmode_cmds[];
849 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
852 #define UPDATE_UI 0x0001
853 #define UPDATE_TITLE 0x0002
855 void update_doc(HTMLDocument*,DWORD);
856 void update_title(HTMLDocumentObj*);
859 void init_editor(HTMLDocument*);
860 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
861 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
862 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
863 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
864 void handle_edit_load(HTMLDocument*);
865 HRESULT editor_is_dirty(HTMLDocument*);
866 void set_dirty(HTMLDocument*,VARIANT_BOOL);
868 extern DWORD mshtml_tls;
870 typedef struct task_t task_t;
871 typedef void (*task_proc_t)(task_t*);
881 HTMLDocumentObj *doc;
886 task_t *task_queue_head;
887 task_t *task_queue_tail;
888 struct list timer_list;
891 thread_data_t *get_thread_data(BOOL);
892 HWND get_thread_hwnd(void);
894 LONG get_task_target_magic(void);
895 void push_task(task_t*,task_proc_t,LONG);
896 void remove_target_tasks(LONG);
898 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
899 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
901 void release_typelib(void);
902 HRESULT call_disp_func(IDispatch*,DISPPARAMS*);
904 const char *debugstr_variant(const VARIANT*);
906 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
907 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
908 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
909 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
910 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
912 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
914 /* memory allocation functions */
916 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
918 return HeapAlloc(GetProcessHeap(), 0, len);
921 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
923 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
926 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
928 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
931 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
933 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
936 static inline BOOL heap_free(void *mem)
938 return HeapFree(GetProcessHeap(), 0, mem);
941 static inline LPWSTR heap_strdupW(LPCWSTR str)
948 size = (strlenW(str)+1)*sizeof(WCHAR);
949 ret = heap_alloc(size);
950 memcpy(ret, str, size);
956 static inline LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
961 ret = heap_alloc((len+1)*sizeof(WCHAR));
962 memcpy(ret, str, len*sizeof(WCHAR));
969 static inline char *heap_strdupA(const char *str)
976 size = strlen(str)+1;
977 ret = heap_alloc(size);
978 memcpy(ret, str, size);
984 static inline WCHAR *heap_strdupAtoW(const char *str)
991 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
992 ret = heap_alloc(len*sizeof(WCHAR));
993 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
999 static inline char *heap_strdupWtoA(LPCWSTR str)
1004 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
1005 ret = heap_alloc(size);
1006 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
1012 static inline void windowref_addref(windowref_t *ref)
1014 InterlockedIncrement(&ref->ref);
1017 static inline void windowref_release(windowref_t *ref)
1019 if(!InterlockedDecrement(&ref->ref))
1023 HDC get_display_dc(void);
1024 HINSTANCE get_shdoclc(void);
1025 void set_statustext(HTMLDocumentObj*,INT,LPCWSTR);
1027 extern HINSTANCE hInst;