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
21 #include "docobjectservice.h"
30 #include "wine/list.h"
31 #include "wine/unicode.h"
39 #define NS_ERROR_GENERATE_FAILURE(module,code) \
40 ((nsresult) (((PRUint32)(1<<31)) | ((PRUint32)(module+0x45)<<16) | ((PRUint32)(code))))
42 #define NS_OK ((nsresult)0x00000000L)
43 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
44 #define NS_ERROR_OUT_OF_MEMORY ((nsresult)0x8007000EL)
45 #define NS_NOINTERFACE ((nsresult)0x80004002L)
46 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
47 #define NS_ERROR_NOT_AVAILABLE ((nsresult)0x80040111L)
48 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
49 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
51 #define NS_ERROR_MODULE_NETWORK 6
53 #define NS_BINDING_ABORTED NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 2)
54 #define NS_ERROR_UNKNOWN_PROTOCOL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_NETWORK, 18)
56 #define NS_FAILED(res) ((res) & 0x80000000)
57 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
61 #define MSHTML_E_NODOC 0x800a025c
63 typedef struct HTMLDOMNode HTMLDOMNode;
64 typedef struct ConnectionPoint ConnectionPoint;
65 typedef struct BSCallback BSCallback;
66 typedef struct event_target_t event_target_t;
70 XDIID(DispCEventObj) \
72 XDIID(DispDOMChildrenCollection) \
73 XDIID(DispHTMLAnchorElement) \
75 XDIID(DispHTMLCommentElement) \
76 XDIID(DispHTMLCurrentStyle) \
77 XDIID(DispHTMLDocument) \
78 XDIID(DispHTMLDOMAttribute) \
79 XDIID(DispHTMLDOMTextNode) \
80 XDIID(DispHTMLElementCollection) \
81 XDIID(DispHTMLEmbed) \
82 XDIID(DispHTMLFormElement) \
83 XDIID(DispHTMLGenericElement) \
84 XDIID(DispHTMLFrameElement) \
85 XDIID(DispHTMLIFrame) \
87 XDIID(DispHTMLInputElement) \
88 XDIID(DispHTMLLocation) \
89 XDIID(DispHTMLNavigator) \
90 XDIID(DispHTMLObjectElement) \
91 XDIID(DispHTMLOptionElement) \
92 XDIID(DispHTMLScreen) \
93 XDIID(DispHTMLScriptElement) \
94 XDIID(DispHTMLSelectElement) \
95 XDIID(DispHTMLStyle) \
96 XDIID(DispHTMLStyleElement) \
97 XDIID(DispHTMLStyleSheetsCollection) \
98 XDIID(DispHTMLTable) \
99 XDIID(DispHTMLTableRow) \
100 XDIID(DispHTMLTextAreaElement) \
101 XDIID(DispHTMLUnknownElement) \
102 XDIID(DispHTMLWindow2) \
103 XDIID(HTMLDocumentEvents) \
104 XIID(IHTMLAnchorElement) \
105 XIID(IHTMLBodyElement) \
106 XIID(IHTMLBodyElement2) \
107 XIID(IHTMLCommentElement) \
108 XIID(IHTMLCurrentStyle) \
109 XIID(IHTMLCurrentStyle2) \
110 XIID(IHTMLCurrentStyle3) \
111 XIID(IHTMLCurrentStyle4) \
112 XIID(IHTMLDocument2) \
113 XIID(IHTMLDocument3) \
114 XIID(IHTMLDocument4) \
115 XIID(IHTMLDocument5) \
116 XIID(IHTMLDOMAttribute) \
117 XIID(IHTMLDOMChildrenCollection) \
119 XIID(IHTMLDOMNode2) \
120 XIID(IHTMLDOMTextNode) \
122 XIID(IHTMLElement2) \
123 XIID(IHTMLElement3) \
124 XIID(IHTMLElement4) \
125 XIID(IHTMLElementCollection) \
126 XIID(IHTMLEmbedElement) \
127 XIID(IHTMLEventObj) \
128 XIID(IHTMLFiltersCollection) \
129 XIID(IHTMLFormElement) \
130 XIID(IHTMLFrameBase) \
131 XIID(IHTMLFrameBase2) \
132 XIID(IHTMLFrameElement3) \
133 XIID(IHTMLGenericElement) \
134 XIID(IHTMLIFrameElement) \
135 XIID(IHTMLImageElementFactory) \
136 XIID(IHTMLImgElement) \
137 XIID(IHTMLInputElement) \
138 XIID(IHTMLLocation) \
139 XIID(IHTMLObjectElement) \
140 XIID(IHTMLOptionElement) \
141 XIID(IHTMLPluginsCollection) \
144 XIID(IHTMLScriptElement) \
145 XIID(IHTMLSelectElement) \
150 XIID(IHTMLStyleElement) \
151 XIID(IHTMLStyleSheetsCollection) \
153 XIID(IHTMLTableRow) \
154 XIID(IHTMLTextAreaElement) \
155 XIID(IHTMLTextContainer) \
156 XIID(IHTMLUniqueName) \
163 #define XIID(iface) iface ## _tid,
164 #define XDIID(iface) iface ## _tid,
171 typedef struct dispex_data_t dispex_data_t;
172 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
174 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
175 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
176 #define MSHTML_CUSTOM_DISPID_CNT (MSHTML_DISPID_CUSTOM_MAX-MSHTML_DISPID_CUSTOM_MIN)
178 typedef struct DispatchEx DispatchEx;
181 HRESULT (*value)(DispatchEx*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
182 HRESULT (*get_dispid)(DispatchEx*,BSTR,DWORD,DISPID*);
183 HRESULT (*invoke)(DispatchEx*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
184 } dispex_static_data_vtbl_t;
187 const dispex_static_data_vtbl_t *vtbl;
188 const tid_t disp_tid;
190 const tid_t* const iface_tids;
191 } dispex_static_data_t;
194 IDispatchEx IDispatchEx_iface;
198 dispex_static_data_t *data;
199 dispex_dynamic_data_t *dynamic_data;
202 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
203 void release_dispex(DispatchEx*);
204 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
205 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
206 HRESULT get_dispids(tid_t,DWORD*,DISPID**);
207 HRESULT remove_prop(DispatchEx*,BSTR,VARIANT_BOOL*);
208 void release_typelib(void);
210 typedef struct HTMLWindow HTMLWindow;
211 typedef struct HTMLDocumentNode HTMLDocumentNode;
212 typedef struct HTMLDocumentObj HTMLDocumentObj;
213 typedef struct HTMLFrameBase HTMLFrameBase;
214 typedef struct NSContainer NSContainer;
218 SCRIPTMODE_ACTIVESCRIPT
221 typedef struct ScriptHost ScriptHost;
226 } global_prop_type_t;
229 global_prop_type_t type;
231 ScriptHost *script_host;
236 IHTMLOptionElementFactory IHTMLOptionElementFactory_iface;
241 } HTMLOptionElementFactory;
245 IHTMLImageElementFactory IHTMLImageElementFactory_iface;
250 } HTMLImageElementFactory;
252 struct HTMLLocation {
254 IHTMLLocation IHTMLLocation_iface;
266 typedef struct nsChannelBSC nsChannelBSC;
270 IHTMLWindow2 IHTMLWindow2_iface;
271 IHTMLWindow3 IHTMLWindow3_iface;
272 IHTMLWindow4 IHTMLWindow4_iface;
273 IHTMLPrivateWindow IHTMLPrivateWindow_iface;
274 IDispatchEx IDispatchEx_iface;
275 IServiceProvider IServiceProvider_iface;
279 windowref_t *window_ref;
282 HTMLDocumentNode *doc;
283 HTMLDocumentObj *doc_obj;
284 nsIDOMWindow *nswindow;
286 HTMLFrameBase *frame_element;
287 READYSTATE readystate;
289 nsChannelBSC *bscallback;
293 IHTMLEventObj *event;
295 SCRIPTMODE scriptmode;
296 struct list script_hosts;
298 HTMLOptionElementFactory *option_factory;
299 HTMLImageElementFactory *image_factory;
300 HTMLLocation *location;
303 global_prop_t *global_props;
304 DWORD global_prop_cnt;
305 DWORD global_prop_size;
307 struct list children;
308 struct list sibling_entry;
318 typedef struct _cp_static_data_t {
320 void (*on_advise)(IUnknown*,struct _cp_static_data_t*);
325 typedef struct ConnectionPointContainer {
326 IConnectionPointContainer IConnectionPointContainer_iface;
328 ConnectionPoint *cp_list;
330 struct ConnectionPointContainer *forward_container;
331 } ConnectionPointContainer;
333 struct ConnectionPoint {
334 IConnectionPoint IConnectionPoint_iface;
336 ConnectionPointContainer *container;
341 IPropertyNotifySink *propnotif;
346 cp_static_data_t *data;
348 ConnectionPoint *next;
351 struct HTMLDocument {
352 IHTMLDocument2 IHTMLDocument2_iface;
353 IHTMLDocument3 IHTMLDocument3_iface;
354 IHTMLDocument4 IHTMLDocument4_iface;
355 IHTMLDocument5 IHTMLDocument5_iface;
356 IHTMLDocument6 IHTMLDocument6_iface;
357 IPersistMoniker IPersistMoniker_iface;
358 IPersistFile IPersistFile_iface;
359 IPersistHistory IPersistHistory_iface;
360 IMonikerProp IMonikerProp_iface;
361 IOleObject IOleObject_iface;
362 IOleDocument IOleDocument_iface;
363 IOleDocumentView IOleDocumentView_iface;
364 IOleInPlaceActiveObject IOleInPlaceActiveObject_iface;
365 IViewObjectEx IViewObjectEx_iface;
366 IOleInPlaceObjectWindowless IOleInPlaceObjectWindowless_iface;
367 IServiceProvider IServiceProvider_iface;
368 IOleCommandTarget IOleCommandTarget_iface;
369 IOleControl IOleControl_iface;
370 IHlinkTarget IHlinkTarget_iface;
371 IPersistStreamInit IPersistStreamInit_iface;
372 IDispatchEx IDispatchEx_iface;
373 ISupportErrorInfo ISupportErrorInfo_iface;
374 IObjectWithSite IObjectWithSite_iface;
375 IOleContainer IOleContainer_iface;
376 IObjectSafety IObjectSafety_iface;
381 HTMLDocumentObj *doc_obj;
382 HTMLDocumentNode *doc_node;
388 ConnectionPointContainer cp_container;
389 ConnectionPoint cp_htmldocevents;
390 ConnectionPoint cp_htmldocevents2;
391 ConnectionPoint cp_propnotif;
392 ConnectionPoint cp_dispatch;
394 IOleAdviseHolder *advise_holder;
397 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
399 return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
402 static inline ULONG htmldoc_addref(HTMLDocument *This)
404 return IUnknown_AddRef(This->unk_impl);
407 static inline ULONG htmldoc_release(HTMLDocument *This)
409 return IUnknown_Release(This->unk_impl);
412 struct HTMLDocumentObj {
413 HTMLDocument basedoc;
415 ICustomDoc ICustomDoc_iface;
419 NSContainer *nscontainer;
421 IOleClientSite *client;
422 IDocHostUIHandler *hostui;
424 IOleInPlaceSite *ipsite;
425 IOleInPlaceFrame *frame;
426 IOleInPlaceUIWindow *ip_window;
427 IAdviseSink *view_sink;
428 IDocObjectService *doc_object_service;
430 DOCHOSTUIINFO hostinfo;
432 IOleUndoManager *undomgr;
437 BOOL request_uiactivate;
438 BOOL in_place_active;
442 BOOL container_locked;
453 nsIWebBrowserChrome nsIWebBrowserChrome_iface;
454 nsIContextMenuListener nsIContextMenuListener_iface;
455 nsIURIContentListener nsIURIContentListener_iface;
456 nsIEmbeddingSiteWindow nsIEmbeddingSiteWindow_iface;
457 nsITooltipListener nsITooltipListener_iface;
458 nsIInterfaceRequestor nsIInterfaceRequestor_iface;
459 nsIWeakReference nsIWeakReference_iface;
460 nsISupportsWeakReference nsISupportsWeakReference_iface;
462 nsIWebBrowser *webbrowser;
463 nsIWebNavigation *navigation;
464 nsIBaseWindow *window;
465 nsIWebBrowserFocus *focus;
468 nsIController *editor_controller;
473 HTMLDocumentObj *doc;
475 nsIURIContentListener *content_listener;
480 typedef struct nsWineURI nsWineURI;
482 HRESULT set_wine_url(nsWineURI*,LPCWSTR);
483 nsresult on_start_uri_open(NSContainer*,nsIURI*,PRBool*);
485 /* Keep sync with request_method_strings in nsio.c */
493 nsIHttpChannel nsIHttpChannel_iface;
494 nsIUploadChannel nsIUploadChannel_iface;
495 nsIHttpChannelInternal nsIHttpChannelInternal_iface;
500 nsIInputStream *post_data_stream;
501 nsILoadGroup *load_group;
502 nsIInterfaceRequestor *notif_callback;
504 nsLoadFlags load_flags;
505 nsIURI *original_uri;
509 PRUint32 response_status;
510 REQUEST_METHOD request_method;
511 struct list response_headers;
512 struct list request_headers;
522 HRESULT set_http_header(struct list*,const WCHAR*,int,const WCHAR*,int);
525 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
526 void (*destructor)(HTMLDOMNode*);
527 HRESULT (*clone)(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
528 event_target_t **(*get_event_target)(HTMLDOMNode*);
529 HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
530 HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
531 HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
532 HRESULT (*get_document)(HTMLDOMNode*,IDispatch**);
533 HRESULT (*get_readystate)(HTMLDOMNode*,BSTR*);
534 HRESULT (*get_dispid)(HTMLDOMNode*,BSTR,DWORD,DISPID*);
535 HRESULT (*invoke)(HTMLDOMNode*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
536 HRESULT (*bind_to_tree)(HTMLDOMNode*);
541 IHTMLDOMNode IHTMLDOMNode_iface;
542 IHTMLDOMNode2 IHTMLDOMNode2_iface;
543 const NodeImplVtbl *vtbl;
548 HTMLDocumentNode *doc;
549 event_target_t *event_target;
550 ConnectionPointContainer *cp_container;
557 ConnectionPointContainer cp_container;
559 IHTMLElement IHTMLElement_iface;
560 IHTMLElement2 IHTMLElement2_iface;
561 IHTMLElement3 IHTMLElement3_iface;
562 IHTMLElement4 IHTMLElement4_iface;
564 nsIDOMHTMLElement *nselem;
569 #define HTMLELEMENT_TIDS \
580 IHTMLTextContainer IHTMLTextContainer_iface;
585 struct HTMLFrameBase {
588 IHTMLFrameBase IHTMLFrameBase_iface;
589 IHTMLFrameBase2 IHTMLFrameBase2_iface;
591 HTMLWindow *content_window;
593 nsIDOMHTMLFrameElement *nsframe;
594 nsIDOMHTMLIFrameElement *nsiframe;
597 typedef struct nsDocumentEventListener nsDocumentEventListener;
599 struct HTMLDocumentNode {
601 HTMLDocument basedoc;
603 IInternetHostSecurityManager IInternetHostSecurityManager_iface;
605 nsIDocumentObserver nsIDocumentObserver_iface;
609 nsIDOMHTMLDocument *nsdoc;
612 event_target_t *body_event_target;
614 IInternetSecurityManager *secmgr;
615 ICatInformation *catmgr;
616 nsDocumentEventListener *nsevent_listener;
619 BOOL skip_mutation_notif;
621 struct list bindings;
622 struct list selection_list;
623 struct list range_list;
624 struct list plugin_hosts;
627 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
628 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
629 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
630 HRESULT create_document_fragment(nsIDOMNode*,HTMLDocumentNode*,HTMLDocumentNode**);
632 HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**);
633 void update_window_doc(HTMLWindow*);
634 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
635 nsIDOMWindow *get_nsdoc_window(nsIDOMDocument*);
636 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
637 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
638 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
639 IOmNavigator *OmNavigator_Create(void);
640 HRESULT HTMLScreen_Create(IHTMLScreen**);
642 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
643 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
644 void HTMLDocument_Persist_Init(HTMLDocument*);
645 void HTMLDocument_OleCmd_Init(HTMLDocument*);
646 void HTMLDocument_OleObj_Init(HTMLDocument*);
647 void HTMLDocument_View_Init(HTMLDocument*);
648 void HTMLDocument_Window_Init(HTMLDocument*);
649 void HTMLDocument_Service_Init(HTMLDocument*);
650 void HTMLDocument_Hlink_Init(HTMLDocument*);
652 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
654 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
656 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID,cp_static_data_t*);
657 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
658 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
660 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
661 void NSContainer_Release(NSContainer*);
662 nsresult create_chrome_window(nsIWebBrowserChrome*,nsIWebBrowserChrome**);
664 void init_mutation(nsIComponentManager*);
665 void init_document_mutation(HTMLDocumentNode*);
666 void release_document_mutation(HTMLDocumentNode*);
668 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
669 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
670 void notif_focus(HTMLDocumentObj*);
672 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
673 void hide_tooltip(HTMLDocumentObj*);
674 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
676 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
678 BOOL load_gecko(BOOL);
679 void close_gecko(void);
680 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
681 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
682 void release_nsio(void);
683 BOOL is_gecko_path(const char*);
685 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
686 HRESULT create_doc_uri(HTMLWindow*,WCHAR*,nsWineURI**);
687 HRESULT load_nsuri(HTMLWindow*,nsWineURI*,nsChannelBSC*,DWORD);
689 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD,BOOL*);
690 HRESULT navigate_url(HTMLWindow*,const WCHAR*,const WCHAR*);
691 HRESULT set_frame_doc(HTMLFrameBase*,nsIDOMDocument*);
692 HRESULT set_moniker(HTMLDocument*,IMoniker*,IBindCtx*,nsChannelBSC*,BOOL);
694 void call_property_onchanged(ConnectionPoint*,DISPID);
695 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
697 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
700 void nsACString_InitDepend(nsACString*,const char*);
701 void nsACString_SetData(nsACString*,const char*);
702 PRUint32 nsACString_GetData(const nsACString*,const char**);
703 void nsACString_Finish(nsACString*);
705 BOOL nsAString_Init(nsAString*,const PRUnichar*);
706 void nsAString_InitDepend(nsAString*,const PRUnichar*);
707 void nsAString_SetData(nsAString*,const PRUnichar*);
708 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
709 void nsAString_Finish(nsAString*);
710 HRESULT return_nsstr(nsresult,nsAString*,BSTR*);
712 nsICommandParams *create_nscommand_params(void);
713 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
714 void get_editor_controller(NSContainer*);
715 nsresult get_nsinterface(nsISupports*,REFIID,void**);
717 void init_nsevents(HTMLDocumentNode*);
718 void release_nsevents(HTMLDocumentNode*);
719 void add_nsevent_listener(HTMLDocumentNode*,nsIDOMNode*,LPCWSTR);
721 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
722 void set_current_mon(HTMLWindow*,IMoniker*);
723 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
724 HRESULT async_start_doc_binding(HTMLWindow*,nsChannelBSC*);
725 void abort_document_bindings(HTMLDocumentNode*);
727 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
729 HRESULT create_channelbsc(IMoniker*,WCHAR*,BYTE*,DWORD,nsChannelBSC**);
730 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
731 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
732 IMoniker *get_channelbsc_mon(nsChannelBSC*);
734 void set_ready_state(HTMLWindow*,READYSTATE);
736 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
737 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
738 HRESULT HTMLStyle_Create(nsIDOMCSSStyleDeclaration*,HTMLStyle**);
739 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
740 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
742 void detach_selection(HTMLDocumentNode*);
743 void detach_ranges(HTMLDocumentNode*);
744 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
746 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
748 HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**);
752 IHTMLDOMAttribute IHTMLDOMAttribute_iface;
761 HRESULT HTMLDOMAttribute_Create(HTMLElement*,DISPID,HTMLDOMAttribute**);
763 HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**);
764 HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**);
765 HRESULT HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
766 HRESULT HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
767 HRESULT HTMLEmbedElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
768 HRESULT HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
769 HRESULT HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
770 HRESULT HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
771 HRESULT HTMLStyleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
772 HRESULT HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
773 HRESULT HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
774 HRESULT HTMLObjectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
775 HRESULT HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
776 HRESULT HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
777 HRESULT HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
778 HRESULT HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
779 HRESULT HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
780 HRESULT HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
781 HRESULT HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**);
783 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
784 void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
785 void HTMLElement2_Init(HTMLElement*);
786 void HTMLElement3_Init(HTMLElement*);
787 void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
788 void HTMLFrameBase_Init(HTMLFrameBase*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
790 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
791 void HTMLDOMNode_destructor(HTMLDOMNode*);
793 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
794 void HTMLElement_destructor(HTMLDOMNode*);
795 HRESULT HTMLElement_clone(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
797 HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
798 void HTMLFrameBase_destructor(HTMLFrameBase*);
800 HRESULT get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLDOMNode**);
801 void release_nodes(HTMLDocumentNode*);
803 void release_script_hosts(HTMLWindow*);
804 void connect_scripts(HTMLWindow*);
805 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
806 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
807 HRESULT exec_script(HTMLWindow*,const WCHAR*,const WCHAR*,VARIANT*);
808 void set_script_mode(HTMLWindow*,SCRIPTMODE);
809 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
810 IDispatch *get_script_disp(ScriptHost*);
811 HRESULT search_window_props(HTMLWindow*,BSTR,DWORD,DISPID*);
813 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
814 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
815 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
820 HRESULT (*query)(HTMLDocument*,OLECMD*);
821 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
824 extern const cmdtable_t editmode_cmds[];
826 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
829 #define UPDATE_UI 0x0001
830 #define UPDATE_TITLE 0x0002
832 void update_doc(HTMLDocument*,DWORD);
833 void update_title(HTMLDocumentObj*);
836 void init_editor(HTMLDocument*);
837 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
838 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
839 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
840 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
841 void handle_edit_load(HTMLDocument*);
842 HRESULT editor_is_dirty(HTMLDocument*);
843 void set_dirty(HTMLDocument*,VARIANT_BOOL);
845 extern DWORD mshtml_tls;
847 typedef struct task_t task_t;
848 typedef void (*task_proc_t)(task_t*);
858 HTMLDocumentObj *doc;
863 task_t *task_queue_head;
864 task_t *task_queue_tail;
865 struct list timer_list;
868 thread_data_t *get_thread_data(BOOL);
869 HWND get_thread_hwnd(void);
871 LONG get_task_target_magic(void);
872 void push_task(task_t*,task_proc_t,LONG);
873 void remove_target_tasks(LONG);
875 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
876 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
878 const char *debugstr_variant(const VARIANT*);
880 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
881 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
882 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
883 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
884 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
886 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
888 DEFINE_OLEGUID(CGID_DocHostCmdPriv, 0x000214D4L, 0, 0);
890 /* memory allocation functions */
892 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
894 return HeapAlloc(GetProcessHeap(), 0, len);
897 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
899 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
902 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
904 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
907 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
909 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
912 static inline BOOL heap_free(void *mem)
914 return HeapFree(GetProcessHeap(), 0, mem);
917 static inline LPWSTR heap_strdupW(LPCWSTR str)
924 size = (strlenW(str)+1)*sizeof(WCHAR);
925 ret = heap_alloc(size);
926 memcpy(ret, str, size);
932 static inline LPWSTR heap_strndupW(LPCWSTR str, unsigned len)
937 ret = heap_alloc((len+1)*sizeof(WCHAR));
938 memcpy(ret, str, len*sizeof(WCHAR));
945 static inline char *heap_strdupA(const char *str)
952 size = strlen(str)+1;
953 ret = heap_alloc(size);
954 memcpy(ret, str, size);
960 static inline WCHAR *heap_strdupAtoW(const char *str)
967 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
968 ret = heap_alloc(len*sizeof(WCHAR));
969 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
975 static inline char *heap_strdupWtoA(LPCWSTR str)
980 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
981 ret = heap_alloc(size);
982 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
988 static inline void windowref_addref(windowref_t *ref)
990 InterlockedIncrement(&ref->ref);
993 static inline void windowref_release(windowref_t *ref)
995 if(!InterlockedDecrement(&ref->ref))
999 HDC get_display_dc(void);
1000 HINSTANCE get_shdoclc(void);
1001 void set_statustext(HTMLDocumentObj*,INT,LPCWSTR);
1003 extern HINSTANCE hInst;