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_OK ((nsresult)0x00000000L)
38 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
39 #define NS_NOINTERFACE ((nsresult)0x80004002L)
40 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
41 #define NS_ERROR_NOT_AVAILABLE ((nsresult)0x80040111L)
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 NS_FAILED(res) ((res) & 0x80000000)
47 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
51 #define MSHTML_E_NODOC 0x800a025c
53 typedef struct HTMLDOMNode HTMLDOMNode;
54 typedef struct ConnectionPoint ConnectionPoint;
55 typedef struct BSCallback BSCallback;
56 typedef struct event_target_t event_target_t;
58 /* NOTE: make sure to keep in sync with dispex.c */
62 DispDOMChildrenCollection_tid,
63 DispHTMLAnchorElement_tid,
65 DispHTMLCommentElement_tid,
66 DispHTMLCurrentStyle_tid,
68 DispHTMLDOMTextNode_tid,
69 DispHTMLElementCollection_tid,
70 DispHTMLFormElement_tid,
71 DispHTMLGenericElement_tid,
72 DispHTMLFrameElement_tid,
75 DispHTMLInputElement_tid,
77 DispHTMLNavigator_tid,
78 DispHTMLOptionElement_tid,
80 DispHTMLScriptElement_tid,
81 DispHTMLSelectElement_tid,
85 DispHTMLTextAreaElement_tid,
86 DispHTMLUnknownElement_tid,
88 HTMLDocumentEvents_tid,
89 IHTMLAnchorElement_tid,
91 IHTMLBodyElement2_tid,
92 IHTMLCommentElement_tid,
93 IHTMLCurrentStyle_tid,
94 IHTMLCurrentStyle2_tid,
95 IHTMLCurrentStyle3_tid,
96 IHTMLCurrentStyle4_tid,
101 IHTMLDOMChildrenCollection_tid,
104 IHTMLDOMTextNode_tid,
109 IHTMLElementCollection_tid,
111 IHTMLFiltersCollection_tid,
112 IHTMLFormElement_tid,
115 IHTMLFrameElement3_tid,
116 IHTMLGenericElement_tid,
117 IHTMLIFrameElement_tid,
118 IHTMLImageElementFactory_tid,
120 IHTMLInputElement_tid,
122 IHTMLOptionElement_tid,
125 IHTMLScriptElement_tid,
126 IHTMLSelectElement_tid,
133 IHTMLTextAreaElement_tid,
134 IHTMLTextContainer_tid,
143 typedef struct dispex_data_t dispex_data_t;
144 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
146 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
147 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
148 #define MSHTML_CUSTOM_DISPID_CNT (MSHTML_DISPID_CUSTOM_MAX-MSHTML_DISPID_CUSTOM_MIN)
151 HRESULT (*value)(IUnknown*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
152 HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
153 HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
154 } dispex_static_data_vtbl_t;
157 const dispex_static_data_vtbl_t *vtbl;
158 const tid_t disp_tid;
160 const tid_t* const iface_tids;
161 } dispex_static_data_t;
164 const IDispatchExVtbl *lpIDispatchExVtbl;
168 dispex_static_data_t *data;
169 dispex_dynamic_data_t *dynamic_data;
172 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
173 void release_dispex(DispatchEx*);
174 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
175 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
176 HRESULT get_dispids(tid_t,DWORD*,DISPID**);
177 HRESULT remove_prop(DispatchEx*,BSTR,VARIANT_BOOL*);
179 typedef struct HTMLWindow HTMLWindow;
180 typedef struct HTMLDocumentNode HTMLDocumentNode;
181 typedef struct HTMLDocumentObj HTMLDocumentObj;
182 typedef struct HTMLFrameBase HTMLFrameBase;
183 typedef struct NSContainer NSContainer;
187 SCRIPTMODE_ACTIVESCRIPT
190 typedef struct ScriptHost ScriptHost;
195 } global_prop_type_t;
198 global_prop_type_t type;
200 ScriptHost *script_host;
205 const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
210 } HTMLOptionElementFactory;
214 const IHTMLImageElementFactoryVtbl *lpHTMLImageElementFactoryVtbl;
219 } HTMLImageElementFactory;
221 struct HTMLLocation {
223 const IHTMLLocationVtbl *lpHTMLLocationVtbl;
235 typedef struct nsChannelBSC nsChannelBSC;
239 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
240 const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
241 const IHTMLWindow4Vtbl *lpHTMLWindow4Vtbl;
242 const IHTMLPrivateWindowVtbl *lpIHTMLPrivateWindowVtbl;
243 const IDispatchExVtbl *lpIDispatchExVtbl;
247 windowref_t *window_ref;
250 HTMLDocumentNode *doc;
251 HTMLDocumentObj *doc_obj;
252 nsIDOMWindow *nswindow;
254 HTMLFrameBase *frame_element;
255 READYSTATE readystate;
257 nsChannelBSC *bscallback;
261 IHTMLEventObj *event;
263 SCRIPTMODE scriptmode;
264 struct list script_hosts;
266 HTMLOptionElementFactory *option_factory;
267 HTMLImageElementFactory *image_factory;
268 HTMLLocation *location;
271 global_prop_t *global_props;
272 DWORD global_prop_cnt;
273 DWORD global_prop_size;
275 struct list children;
276 struct list sibling_entry;
286 typedef struct _cp_static_data_t {
288 void (*on_advise)(IUnknown*,struct _cp_static_data_t*);
293 typedef struct ConnectionPointContainer {
294 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
296 ConnectionPoint *cp_list;
298 struct ConnectionPointContainer *forward_container;
299 } ConnectionPointContainer;
301 struct ConnectionPoint {
302 const IConnectionPointVtbl *lpConnectionPointVtbl;
304 ConnectionPointContainer *container;
309 IPropertyNotifySink *propnotif;
314 cp_static_data_t *data;
316 ConnectionPoint *next;
319 struct HTMLDocument {
320 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
321 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
322 const IHTMLDocument4Vtbl *lpHTMLDocument4Vtbl;
323 const IHTMLDocument5Vtbl *lpHTMLDocument5Vtbl;
324 const IHTMLDocument6Vtbl *lpHTMLDocument6Vtbl;
325 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
326 const IPersistFileVtbl *lpPersistFileVtbl;
327 const IPersistHistoryVtbl *lpPersistHistoryVtbl;
328 const IMonikerPropVtbl *lpMonikerPropVtbl;
329 const IOleObjectVtbl *lpOleObjectVtbl;
330 const IOleDocumentVtbl *lpOleDocumentVtbl;
331 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
332 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
333 const IViewObjectExVtbl *lpViewObjectExVtbl;
334 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
335 const IServiceProviderVtbl *lpServiceProviderVtbl;
336 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
337 const IOleControlVtbl *lpOleControlVtbl;
338 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
339 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
340 const IDispatchExVtbl *lpIDispatchExVtbl;
341 const ISupportErrorInfoVtbl *lpSupportErrorInfoVtbl;
342 const IObjectWithSiteVtbl *lpObjectWithSiteVtbl;
347 HTMLDocumentObj *doc_obj;
348 HTMLDocumentNode *doc_node;
354 ConnectionPointContainer cp_container;
355 ConnectionPoint cp_htmldocevents;
356 ConnectionPoint cp_htmldocevents2;
357 ConnectionPoint cp_propnotif;
358 ConnectionPoint cp_dispatch;
360 IOleAdviseHolder *advise_holder;
363 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
365 return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
368 static inline ULONG htmldoc_addref(HTMLDocument *This)
370 return IUnknown_AddRef(This->unk_impl);
373 static inline ULONG htmldoc_release(HTMLDocument *This)
375 return IUnknown_Release(This->unk_impl);
378 struct HTMLDocumentObj {
379 HTMLDocument basedoc;
381 const ICustomDocVtbl *lpCustomDocVtbl;
385 NSContainer *nscontainer;
387 IOleClientSite *client;
388 IDocHostUIHandler *hostui;
389 IOleInPlaceSite *ipsite;
390 IOleInPlaceFrame *frame;
391 IOleInPlaceUIWindow *ip_window;
392 IAdviseSink *view_sink;
394 DOCHOSTUIINFO hostinfo;
396 IOleUndoManager *undomgr;
401 BOOL request_uiactivate;
402 BOOL in_place_active;
406 BOOL container_locked;
417 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
418 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
419 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
420 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
421 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
422 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
423 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
424 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
426 nsIWebBrowser *webbrowser;
427 nsIWebNavigation *navigation;
428 nsIBaseWindow *window;
429 nsIWebBrowserFocus *focus;
432 nsIController *editor_controller;
437 HTMLDocumentObj *doc;
439 nsIURIContentListener *content_listener;
444 typedef struct nsWineURI nsWineURI;
446 HRESULT set_wine_url(nsWineURI*,LPCWSTR);
447 nsresult on_start_uri_open(NSContainer*,nsIURI*,PRBool*);
450 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
451 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
452 const nsIHttpChannelInternalVtbl *lpIHttpChannelInternalVtbl;
457 nsIInputStream *post_data_stream;
458 nsILoadGroup *load_group;
459 nsIInterfaceRequestor *notif_callback;
461 nsLoadFlags load_flags;
462 nsIURI *original_uri;
465 PRUint32 response_status;
466 struct list response_headers;
467 struct list request_headers;
477 HRESULT set_http_header(struct list*,const WCHAR*,int,const WCHAR*,int);
480 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
481 void (*destructor)(HTMLDOMNode*);
482 event_target_t **(*get_event_target)(HTMLDOMNode*);
483 HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
484 HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
485 HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
486 HRESULT (*get_document)(HTMLDOMNode*,IDispatch**);
487 HRESULT (*get_readystate)(HTMLDOMNode*,BSTR*);
488 HRESULT (*get_dispid)(HTMLDOMNode*,BSTR,DWORD,DISPID*);
489 HRESULT (*invoke)(HTMLDOMNode*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
490 HRESULT (*bind_to_tree)(HTMLDOMNode*);
495 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
496 const IHTMLDOMNode2Vtbl *lpHTMLDOMNode2Vtbl;
497 const NodeImplVtbl *vtbl;
502 HTMLDocumentNode *doc;
503 event_target_t *event_target;
504 ConnectionPointContainer *cp_container;
511 ConnectionPointContainer cp_container;
513 const IHTMLElementVtbl *lpHTMLElementVtbl;
514 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
515 const IHTMLElement3Vtbl *lpHTMLElement3Vtbl;
517 nsIDOMHTMLElement *nselem;
520 #define HTMLELEMENT_TIDS \
531 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
536 struct HTMLFrameBase {
539 const IHTMLFrameBaseVtbl *lpIHTMLFrameBaseVtbl;
540 const IHTMLFrameBase2Vtbl *lpIHTMLFrameBase2Vtbl;
542 HTMLWindow *content_window;
544 nsIDOMHTMLFrameElement *nsframe;
545 nsIDOMHTMLIFrameElement *nsiframe;
548 typedef struct _mutation_queue_t {
550 nsISupports *nsiface;
552 struct _mutation_queue_t *next;
555 typedef struct nsDocumentEventListener nsDocumentEventListener;
557 struct HTMLDocumentNode {
559 HTMLDocument basedoc;
561 const IInternetHostSecurityManagerVtbl *lpIInternetHostSecurityManagerVtbl;
563 const nsIDocumentObserverVtbl *lpIDocumentObserverVtbl;
564 const nsIRunnableVtbl *lpIRunnableVtbl;
568 nsIDOMHTMLDocument *nsdoc;
571 event_target_t *body_event_target;
573 IInternetSecurityManager *secmgr;
574 ICatInformation *catmgr;
575 nsDocumentEventListener *nsevent_listener;
578 mutation_queue_t *mutation_queue;
579 mutation_queue_t *mutation_queue_tail;
581 struct list bindings;
582 struct list selection_list;
583 struct list range_list;
586 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
587 #define HTMLWINDOW3(x) ((IHTMLWindow3*) &(x)->lpHTMLWindow3Vtbl)
588 #define HTMLWINDOW4(x) ((IHTMLWindow4*) &(x)->lpHTMLWindow4Vtbl)
590 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
591 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
592 #define HTMLDOC4(x) ((IHTMLDocument4*) &(x)->lpHTMLDocument4Vtbl)
593 #define HTMLDOC5(x) ((IHTMLDocument5*) &(x)->lpHTMLDocument5Vtbl)
594 #define HTMLDOC6(x) ((IHTMLDocument6*) &(x)->lpHTMLDocument6Vtbl)
595 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
596 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
597 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
598 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
599 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
600 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
601 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
602 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
603 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
604 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObjectExVtbl)
605 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObjectExVtbl)
606 #define VIEWOBJEX(x) ((IViewObjectEx*) &(x)->lpViewObjectExVtbl)
607 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
608 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
609 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
610 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
611 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
612 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
613 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
614 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
615 #define PERSISTHIST(x) ((IPersistHistory*) &(x)->lpPersistHistoryVtbl)
616 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
617 #define OBJSITE(x) ((IObjectWithSite*) &(x)->lpObjectWithSiteVtbl)
619 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
620 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
621 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
622 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
623 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
624 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
625 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
626 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
627 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
629 #define NSDOCOBS(x) ((nsIDocumentObserver*) &(x)->lpIDocumentObserverVtbl)
631 #define NSRUNNABLE(x) ((nsIRunnable*) &(x)->lpIRunnableVtbl)
633 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
634 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
635 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
636 #define NSHTTPINTERNAL(x) ((nsIHttpChannelInternal*) &(x)->lpIHttpChannelInternalVtbl)
638 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
639 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
640 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
642 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
643 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
644 #define HTMLELEM3(x) ((IHTMLElement3*) &(x)->lpHTMLElement3Vtbl)
645 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
646 #define HTMLDOMNODE2(x) ((IHTMLDOMNode2*) &(x)->lpHTMLDOMNode2Vtbl)
648 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
649 #define HTMLFRAMEBASE(x) ((IHTMLFrameBase*) &(x)->lpIHTMLFrameBaseVtbl)
650 #define HTMLFRAMEBASE2(x) ((IHTMLFrameBase2*) &(x)->lpIHTMLFrameBase2Vtbl)
652 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
653 #define HTMLIMGFACTORY(x) ((IHTMLImageElementFactory*) &(x)->lpHTMLImageElementFactoryVtbl)
654 #define HTMLLOCATION(x) ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
656 #define DISPATCHEX(x) ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
658 #define SUPPERRINFO(x) ((ISupportErrorInfo*) &(x)->lpSupportErrorInfoVtbl)
660 #define HOSTSECMGR(x) ((IInternetHostSecurityManager*) &(x)->lpIInternetHostSecurityManagerVtbl)
662 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
663 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
665 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
666 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
667 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,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*);
700 void init_mutation(HTMLDocumentNode*);
701 void release_mutation(HTMLDocumentNode*);
703 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
704 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
705 void notif_focus(HTMLDocumentObj*);
707 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
708 void hide_tooltip(HTMLDocumentObj*);
709 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
711 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
713 BOOL load_gecko(BOOL);
714 void close_gecko(void);
715 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
716 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
717 void release_nsio(void);
718 BOOL install_wine_gecko(BOOL);
720 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
721 HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**);
722 HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD);
724 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD,BOOL*);
725 HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
726 HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
727 HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL);
729 void call_property_onchanged(ConnectionPoint*,DISPID);
730 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
732 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
735 void nsACString_InitDepend(nsACString*,const char*);
736 void nsACString_SetData(nsACString*,const char*);
737 PRUint32 nsACString_GetData(const nsACString*,const char**);
738 void nsACString_Finish(nsACString*);
740 BOOL nsAString_Init(nsAString*,const PRUnichar*);
741 void nsAString_InitDepend(nsAString*,const PRUnichar*);
742 void nsAString_SetData(nsAString*,const PRUnichar*);
743 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
744 void nsAString_Finish(nsAString*);
746 nsICommandParams *create_nscommand_params(void);
747 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
748 void get_editor_controller(NSContainer*);
749 nsresult get_nsinterface(nsISupports*,REFIID,void**);
751 void init_nsevents(HTMLDocumentNode*);
752 void release_nsevents(HTMLDocumentNode*);
753 void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR);
755 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
756 void set_current_mon(HTMLWindow*,IMoniker*);
757 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
758 HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*);
759 void abort_document_bindings(HTMLDocumentNode*);
761 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
763 HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**);
764 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
765 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
766 IMoniker *get_channelbsc_mon(nsChannelBSC*);
768 void set_ready_state(HTMLWindow*,READYSTATE);
770 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
771 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
772 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
773 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
774 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
776 void detach_selection(HTMLDocumentNode*);
777 void detach_ranges(HTMLDocumentNode*);
778 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
780 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
782 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*);
784 HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL);
785 HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*);
786 HTMLElement *HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
787 HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
788 HTMLElement *HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
789 HTMLElement *HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
790 HTMLElement *HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
791 HTMLElement *HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
792 HTMLElement *HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
793 HTMLElement *HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
794 HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
795 HTMLElement *HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
796 HTMLElement *HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
797 HTMLElement *HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
798 HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
799 HTMLElement *HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
801 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
802 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
803 void HTMLElement2_Init(HTMLElement*);
804 void HTMLElement3_Init(HTMLElement*);
805 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
806 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
808 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
809 void HTMLDOMNode_destructor(HTMLDOMNode*);
811 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
812 void HTMLElement_destructor(HTMLDOMNode*);
814 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
815 void HTMLFrameBase_destructor(HTMLFrameBase*);
817 HTMLDOMNode *get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL);
818 void release_nodes(HTMLDocumentNode*);
820 void release_script_hosts(HTMLWindow*);
821 void connect_scripts(HTMLWindow*);
822 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
823 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
824 void set_script_mode(HTMLWindow*,SCRIPTMODE);
825 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
826 IDispatch *get_script_disp(ScriptHost*);
827 HRESULT search_window_props(HTMLWindow*,BSTR,DWORD,DISPID*);
829 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
830 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
831 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
836 HRESULT (*query)(HTMLDocument*,OLECMD*);
837 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
840 extern const cmdtable_t editmode_cmds[];
842 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
845 #define UPDATE_UI 0x0001
846 #define UPDATE_TITLE 0x0002
848 void update_doc(HTMLDocument*,DWORD);
849 void update_title(HTMLDocumentObj*);
852 void init_editor(HTMLDocument*);
853 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
854 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
855 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
856 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
857 void handle_edit_load(HTMLDocument*);
858 HRESULT editor_is_dirty(HTMLDocument*);
859 void set_dirty(HTMLDocument*,VARIANT_BOOL);
861 extern DWORD mshtml_tls;
863 typedef struct task_t task_t;
864 typedef void (*task_proc_t)(task_t*);
874 HTMLDocumentObj *doc;
879 task_t *task_queue_head;
880 task_t *task_queue_tail;
881 struct list timer_list;
884 thread_data_t *get_thread_data(BOOL);
885 HWND get_thread_hwnd(void);
887 LONG get_task_target_magic(void);
888 void push_task(task_t*,task_proc_t,LONG);
889 void remove_target_tasks(LONG);
891 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
892 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
894 void release_typelib(void);
895 HRESULT call_disp_func(IDispatch*,DISPPARAMS*);
897 const char *debugstr_variant(const VARIANT*);
899 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
900 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
901 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
902 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
903 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
905 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
907 /* memory allocation functions */
909 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
911 return HeapAlloc(GetProcessHeap(), 0, len);
914 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
916 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
919 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
921 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
924 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
926 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
929 static inline BOOL heap_free(void *mem)
931 return HeapFree(GetProcessHeap(), 0, mem);
934 static inline LPWSTR heap_strdupW(LPCWSTR str)
941 size = (strlenW(str)+1)*sizeof(WCHAR);
942 ret = heap_alloc(size);
943 memcpy(ret, str, size);
949 static inline LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
954 ret = heap_alloc((len+1)*sizeof(WCHAR));
955 memcpy(ret, str, len*sizeof(WCHAR));
962 static inline char *heap_strdupA(const char *str)
969 size = strlen(str)+1;
970 ret = heap_alloc(size);
971 memcpy(ret, str, size);
977 static inline WCHAR *heap_strdupAtoW(const char *str)
984 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
985 ret = heap_alloc(len*sizeof(WCHAR));
986 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
992 static inline char *heap_strdupWtoA(LPCWSTR str)
997 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
998 ret = heap_alloc(size);
999 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
1005 static inline void windowref_addref(windowref_t *ref)
1007 InterlockedIncrement(&ref->ref);
1010 static inline void windowref_release(windowref_t *ref)
1012 if(!InterlockedDecrement(&ref->ref))
1016 HDC get_display_dc(void);
1017 HINSTANCE get_shdoclc(void);
1019 extern HINSTANCE hInst;