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 IDispatchEx IDispatchEx_iface;
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 IDispatchEx IDispatchEx_iface;
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 IDispatchEx IDispatchEx_iface;
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 nsIHttpChannel nsIHttpChannel_iface;
487 nsIUploadChannel nsIUploadChannel_iface;
488 nsIHttpChannelInternal nsIHttpChannelInternal_iface;
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 IHTMLDOMNode IHTMLDOMNode_iface;
535 IHTMLDOMNode2 IHTMLDOMNode2_iface;
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 IHTMLElement2 IHTMLElement2_iface;
554 IHTMLElement3 IHTMLElement3_iface;
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 HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
637 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
638 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
640 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
641 #define HTMLFRAMEBASE(x) ((IHTMLFrameBase*) &(x)->lpIHTMLFrameBaseVtbl)
642 #define HTMLFRAMEBASE2(x) ((IHTMLFrameBase2*) &(x)->lpIHTMLFrameBase2Vtbl)
644 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
645 #define HTMLIMGFACTORY(x) ((IHTMLImageElementFactory*) &(x)->lpHTMLImageElementFactoryVtbl)
646 #define HTMLLOCATION(x) ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
648 #define HOSTSECMGR(x) ((IInternetHostSecurityManager*) &(x)->lpIInternetHostSecurityManagerVtbl)
650 #define DEFINE_THIS(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,lp ## ifc ## Vtbl)))
652 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
653 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
654 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
655 HRESULT create_document_fragment(nsIDOMNode*,HTMLDocumentNode*,HTMLDocumentNode**);
657 HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**);
658 void update_window_doc(HTMLWindow*);
659 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
660 nsIDOMWindow *get_nsdoc_window(nsIDOMDocument*);
661 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
662 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
663 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
664 IOmNavigator *OmNavigator_Create(void);
665 HRESULT HTMLScreen_Create(IHTMLScreen**);
667 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
668 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
669 void HTMLDocument_Persist_Init(HTMLDocument*);
670 void HTMLDocument_OleCmd_Init(HTMLDocument*);
671 void HTMLDocument_OleObj_Init(HTMLDocument*);
672 void HTMLDocument_View_Init(HTMLDocument*);
673 void HTMLDocument_Window_Init(HTMLDocument*);
674 void HTMLDocument_Service_Init(HTMLDocument*);
675 void HTMLDocument_Hlink_Init(HTMLDocument*);
677 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
679 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
681 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*);
682 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
683 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
685 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
686 void NSContainer_Release(NSContainer*);
687 nsresult create_chrome_window(nsIWebBrowserChrome*,nsIWebBrowserChrome**);
689 void init_mutation(HTMLDocumentNode*);
690 void release_mutation(HTMLDocumentNode*);
692 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
693 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
694 void notif_focus(HTMLDocumentObj*);
696 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
697 void hide_tooltip(HTMLDocumentObj*);
698 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
700 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
702 BOOL load_gecko(BOOL);
703 void close_gecko(void);
704 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
705 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
706 void release_nsio(void);
707 BOOL is_gecko_path(const char*);
709 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
710 HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**);
711 HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD);
713 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD,BOOL*);
714 HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
715 HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
716 HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL);
718 void call_property_onchanged(ConnectionPoint*,DISPID);
719 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
721 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
724 void nsACString_InitDepend(nsACString*,const char*);
725 void nsACString_SetData(nsACString*,const char*);
726 PRUint32 nsACString_GetData(const nsACString*,const char**);
727 void nsACString_Finish(nsACString*);
729 BOOL nsAString_Init(nsAString*,const PRUnichar*);
730 void nsAString_InitDepend(nsAString*,const PRUnichar*);
731 void nsAString_SetData(nsAString*,const PRUnichar*);
732 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
733 void nsAString_Finish(nsAString*);
734 HRESULT return_nsstr(nsresult,nsAString*,BSTR*);
736 nsICommandParams *create_nscommand_params(void);
737 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
738 void get_editor_controller(NSContainer*);
739 nsresult get_nsinterface(nsISupports*,REFIID,void**);
741 void init_nsevents(HTMLDocumentNode*);
742 void release_nsevents(HTMLDocumentNode*);
743 void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR);
745 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
746 void set_current_mon(HTMLWindow*,IMoniker*);
747 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
748 HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*);
749 void abort_document_bindings(HTMLDocumentNode*);
751 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
753 HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**);
754 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
755 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
756 IMoniker *get_channelbsc_mon(nsChannelBSC*);
758 void set_ready_state(HTMLWindow*,READYSTATE);
760 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
761 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
762 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
763 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
764 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
766 void detach_selection(HTMLDocumentNode*);
767 void detach_ranges(HTMLDocumentNode*);
768 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
770 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
772 HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**);
774 HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**);
775 HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**);
776 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
777 HRESULT HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
778 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
779 HRESULT HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
780 HRESULT HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
781 HRESULT HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
782 HRESULT HTMLStyleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
783 HRESULT HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
784 HRESULT HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
785 HRESULT HTMLObjectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
786 HRESULT HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
787 HRESULT HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
788 HRESULT HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
789 HRESULT HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
790 HRESULT HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
791 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
792 HRESULT HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
794 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
795 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
796 void HTMLElement2_Init(HTMLElement*);
797 void HTMLElement3_Init(HTMLElement*);
798 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
799 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
801 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
802 void HTMLDOMNode_destructor(HTMLDOMNode*);
804 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
805 void HTMLElement_destructor(HTMLDOMNode*);
806 HRESULT HTMLElement_clone(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
808 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
809 void HTMLFrameBase_destructor(HTMLFrameBase*);
811 HRESULT get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLDOMNode**);
812 void release_nodes(HTMLDocumentNode*);
814 void release_script_hosts(HTMLWindow*);
815 void connect_scripts(HTMLWindow*);
816 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
817 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
818 HRESULT exec_script(HTMLWindow*,const WCHAR*,const WCHAR*,VARIANT*);
819 void set_script_mode(HTMLWindow*,SCRIPTMODE);
820 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
821 IDispatch *get_script_disp(ScriptHost*);
822 HRESULT search_window_props(HTMLWindow*,BSTR,DWORD,DISPID*);
824 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
825 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
826 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
831 HRESULT (*query)(HTMLDocument*,OLECMD*);
832 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
835 extern const cmdtable_t editmode_cmds[];
837 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
840 #define UPDATE_UI 0x0001
841 #define UPDATE_TITLE 0x0002
843 void update_doc(HTMLDocument*,DWORD);
844 void update_title(HTMLDocumentObj*);
847 void init_editor(HTMLDocument*);
848 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
849 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
850 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
851 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
852 void handle_edit_load(HTMLDocument*);
853 HRESULT editor_is_dirty(HTMLDocument*);
854 void set_dirty(HTMLDocument*,VARIANT_BOOL);
856 extern DWORD mshtml_tls;
858 typedef struct task_t task_t;
859 typedef void (*task_proc_t)(task_t*);
869 HTMLDocumentObj *doc;
874 task_t *task_queue_head;
875 task_t *task_queue_tail;
876 struct list timer_list;
879 thread_data_t *get_thread_data(BOOL);
880 HWND get_thread_hwnd(void);
882 LONG get_task_target_magic(void);
883 void push_task(task_t*,task_proc_t,LONG);
884 void remove_target_tasks(LONG);
886 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
887 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
889 void release_typelib(void);
890 HRESULT call_disp_func(IDispatch*,DISPPARAMS*);
892 const char *debugstr_variant(const VARIANT*);
894 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
895 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
896 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
897 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
898 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
900 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
902 /* memory allocation functions */
904 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
906 return HeapAlloc(GetProcessHeap(), 0, len);
909 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
911 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
914 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
916 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
919 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
921 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
924 static inline BOOL heap_free(void *mem)
926 return HeapFree(GetProcessHeap(), 0, mem);
929 static inline LPWSTR heap_strdupW(LPCWSTR str)
936 size = (strlenW(str)+1)*sizeof(WCHAR);
937 ret = heap_alloc(size);
938 memcpy(ret, str, size);
944 static inline LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
949 ret = heap_alloc((len+1)*sizeof(WCHAR));
950 memcpy(ret, str, len*sizeof(WCHAR));
957 static inline char *heap_strdupA(const char *str)
964 size = strlen(str)+1;
965 ret = heap_alloc(size);
966 memcpy(ret, str, size);
972 static inline WCHAR *heap_strdupAtoW(const char *str)
979 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
980 ret = heap_alloc(len*sizeof(WCHAR));
981 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
987 static inline char *heap_strdupWtoA(LPCWSTR str)
992 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
993 ret = heap_alloc(size);
994 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
1000 static inline void windowref_addref(windowref_t *ref)
1002 InterlockedIncrement(&ref->ref);
1005 static inline void windowref_release(windowref_t *ref)
1007 if(!InterlockedDecrement(&ref->ref))
1011 HDC get_display_dc(void);
1012 HINSTANCE get_shdoclc(void);
1013 void set_statustext(HTMLDocumentObj*,INT,LPCWSTR);
1015 extern HINSTANCE hInst;