2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/list.h"
28 #include "wine/unicode.h"
36 #define NS_OK ((nsresult)0x00000000L)
37 #define NS_ERROR_FAILURE ((nsresult)0x80004005L)
38 #define NS_NOINTERFACE ((nsresult)0x80004002L)
39 #define NS_ERROR_NOT_IMPLEMENTED ((nsresult)0x80004001L)
40 #define NS_ERROR_INVALID_ARG ((nsresult)0x80070057L)
41 #define NS_ERROR_UNEXPECTED ((nsresult)0x8000ffffL)
42 #define NS_ERROR_UNKNOWN_PROTOCOL ((nsresult)0x804b0012L)
44 #define NS_FAILED(res) ((res) & 0x80000000)
45 #define NS_SUCCEEDED(res) (!NS_FAILED(res))
49 #define MSHTML_E_NODOC 0x800a025c
51 typedef struct HTMLDOMNode HTMLDOMNode;
52 typedef struct ConnectionPoint ConnectionPoint;
53 typedef struct BSCallback BSCallback;
54 typedef struct nsChannelBSC nsChannelBSC;
55 typedef struct event_target_t event_target_t;
57 /* NOTE: make sure to keep in sync with dispex.c */
61 DispDOMChildrenCollection_tid,
62 DispHTMLAnchorElement_tid,
64 DispHTMLCommentElement_tid,
65 DispHTMLCurrentStyle_tid,
67 DispHTMLDOMTextNode_tid,
68 DispHTMLElementCollection_tid,
69 DispHTMLGenericElement_tid,
72 DispHTMLInputElement_tid,
74 DispHTMLNavigator_tid,
75 DispHTMLOptionElement_tid,
76 DispHTMLSelectElement_tid,
80 DispHTMLUnknownElement_tid,
82 IHTMLAnchorElement_tid,
84 IHTMLBodyElement2_tid,
85 IHTMLCommentElement_tid,
86 IHTMLCurrentStyle_tid,
87 IHTMLCurrentStyle2_tid,
88 IHTMLCurrentStyle3_tid,
89 IHTMLCurrentStyle4_tid,
94 IHTMLDOMChildrenCollection_tid,
102 IHTMLElementCollection_tid,
106 IHTMLGenericElement_tid,
107 IHTMLImageElementFactory_tid,
109 IHTMLInputElement_tid,
111 IHTMLOptionElement_tid,
112 IHTMLSelectElement_tid,
119 IHTMLTextContainer_tid,
127 typedef struct dispex_data_t dispex_data_t;
128 typedef struct dispex_dynamic_data_t dispex_dynamic_data_t;
130 #define MSHTML_DISPID_CUSTOM_MIN 0x60000000
131 #define MSHTML_DISPID_CUSTOM_MAX 0x6fffffff
134 HRESULT (*value)(IUnknown*,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
135 HRESULT (*get_dispid)(IUnknown*,BSTR,DWORD,DISPID*);
136 HRESULT (*invoke)(IUnknown*,DISPID,LCID,WORD,DISPPARAMS*,VARIANT*,EXCEPINFO*,IServiceProvider*);
137 } dispex_static_data_vtbl_t;
140 const dispex_static_data_vtbl_t *vtbl;
141 const tid_t disp_tid;
143 const tid_t* const iface_tids;
144 } dispex_static_data_t;
147 const IDispatchExVtbl *lpIDispatchExVtbl;
151 dispex_static_data_t *data;
152 dispex_dynamic_data_t *dynamic_data;
155 void init_dispex(DispatchEx*,IUnknown*,dispex_static_data_t*);
156 void release_dispex(DispatchEx*);
157 BOOL dispex_query_interface(DispatchEx*,REFIID,void**);
158 HRESULT dispex_get_dprop_ref(DispatchEx*,const WCHAR*,BOOL,VARIANT**);
160 typedef struct HTMLDocumentNode HTMLDocumentNode;
161 typedef struct HTMLDocumentObj HTMLDocumentObj;
165 SCRIPTMODE_ACTIVESCRIPT
168 typedef struct ScriptHost ScriptHost;
172 ScriptHost *script_host;
177 const IHTMLOptionElementFactoryVtbl *lpHTMLOptionElementFactoryVtbl;
182 } HTMLOptionElementFactory;
186 const IHTMLImageElementFactoryVtbl *lpHTMLImageElementFactoryVtbl;
191 } HTMLImageElementFactory;
193 struct HTMLLocation {
195 const IHTMLLocationVtbl *lpHTMLLocationVtbl;
209 const IHTMLWindow2Vtbl *lpHTMLWindow2Vtbl;
210 const IHTMLWindow3Vtbl *lpHTMLWindow3Vtbl;
211 const IDispatchExVtbl *lpIDispatchExVtbl;
215 windowref_t *window_ref;
218 HTMLDocumentNode *doc;
219 HTMLDocumentObj *doc_obj;
220 nsIDOMWindow *nswindow;
223 nsChannelBSC *bscallback;
227 event_target_t *event_target;
228 IHTMLEventObj *event;
231 SCRIPTMODE scriptmode;
232 struct list script_hosts;
234 HTMLOptionElementFactory *option_factory;
235 HTMLImageElementFactory *image_factory;
236 HTMLLocation *location;
238 global_prop_t *global_props;
239 DWORD global_prop_cnt;
240 DWORD global_prop_size;
242 struct list children;
243 struct list sibling_entry;
254 const IConnectionPointContainerVtbl *lpConnectionPointContainerVtbl;
256 ConnectionPoint *cp_list;
258 } ConnectionPointContainer;
260 struct ConnectionPoint {
261 const IConnectionPointVtbl *lpConnectionPointVtbl;
263 IConnectionPointContainer *container;
268 IPropertyNotifySink *propnotif;
274 ConnectionPoint *next;
277 struct HTMLDocument {
278 const IHTMLDocument2Vtbl *lpHTMLDocument2Vtbl;
279 const IHTMLDocument3Vtbl *lpHTMLDocument3Vtbl;
280 const IHTMLDocument4Vtbl *lpHTMLDocument4Vtbl;
281 const IHTMLDocument5Vtbl *lpHTMLDocument5Vtbl;
282 const IHTMLDocument6Vtbl *lpHTMLDocument6Vtbl;
283 const IPersistMonikerVtbl *lpPersistMonikerVtbl;
284 const IPersistFileVtbl *lpPersistFileVtbl;
285 const IPersistHistoryVtbl *lpPersistHistoryVtbl;
286 const IMonikerPropVtbl *lpMonikerPropVtbl;
287 const IOleObjectVtbl *lpOleObjectVtbl;
288 const IOleDocumentVtbl *lpOleDocumentVtbl;
289 const IOleDocumentViewVtbl *lpOleDocumentViewVtbl;
290 const IOleInPlaceActiveObjectVtbl *lpOleInPlaceActiveObjectVtbl;
291 const IViewObject2Vtbl *lpViewObject2Vtbl;
292 const IOleInPlaceObjectWindowlessVtbl *lpOleInPlaceObjectWindowlessVtbl;
293 const IServiceProviderVtbl *lpServiceProviderVtbl;
294 const IOleCommandTargetVtbl *lpOleCommandTargetVtbl;
295 const IOleControlVtbl *lpOleControlVtbl;
296 const IHlinkTargetVtbl *lpHlinkTargetVtbl;
297 const IPersistStreamInitVtbl *lpPersistStreamInitVtbl;
298 const IDispatchExVtbl *lpIDispatchExVtbl;
299 const ISupportErrorInfoVtbl *lpSupportErrorInfoVtbl;
304 HTMLDocumentObj *doc_obj;
305 HTMLDocumentNode *doc_node;
311 ConnectionPointContainer cp_container;
312 ConnectionPoint cp_htmldocevents;
313 ConnectionPoint cp_htmldocevents2;
314 ConnectionPoint cp_propnotif;
317 static inline HRESULT htmldoc_query_interface(HTMLDocument *This, REFIID riid, void **ppv)
319 return IUnknown_QueryInterface(This->unk_impl, riid, ppv);
322 static inline ULONG htmldoc_addref(HTMLDocument *This)
324 return IUnknown_AddRef(This->unk_impl);
327 static inline ULONG htmldoc_release(HTMLDocument *This)
329 return IUnknown_Release(This->unk_impl);
332 struct HTMLDocumentObj {
333 HTMLDocument basedoc;
335 const ICustomDocVtbl *lpCustomDocVtbl;
339 NSContainer *nscontainer;
341 IOleClientSite *client;
342 IDocHostUIHandler *hostui;
343 IOleInPlaceSite *ipsite;
344 IOleInPlaceFrame *frame;
345 IOleInPlaceUIWindow *ip_window;
347 DOCHOSTUIINFO hostinfo;
349 IOleUndoManager *undomgr;
354 BOOL in_place_active;
358 BOOL container_locked;
362 READYSTATE readystate;
369 const nsIDOMEventListenerVtbl *lpDOMEventListenerVtbl;
374 const nsIWebBrowserChromeVtbl *lpWebBrowserChromeVtbl;
375 const nsIContextMenuListenerVtbl *lpContextMenuListenerVtbl;
376 const nsIURIContentListenerVtbl *lpURIContentListenerVtbl;
377 const nsIEmbeddingSiteWindowVtbl *lpEmbeddingSiteWindowVtbl;
378 const nsITooltipListenerVtbl *lpTooltipListenerVtbl;
379 const nsIInterfaceRequestorVtbl *lpInterfaceRequestorVtbl;
380 const nsIWeakReferenceVtbl *lpWeakReferenceVtbl;
381 const nsISupportsWeakReferenceVtbl *lpSupportsWeakReferenceVtbl;
383 nsEventListener blur_listener;
384 nsEventListener focus_listener;
385 nsEventListener keypress_listener;
386 nsEventListener load_listener;
387 nsEventListener htmlevent_listener;
389 nsIWebBrowser *webbrowser;
390 nsIWebNavigation *navigation;
391 nsIBaseWindow *window;
392 nsIWebBrowserFocus *focus;
395 nsIController *editor_controller;
400 HTMLDocumentObj *doc;
402 nsIURIContentListener *content_listener;
406 nsChannelBSC *bscallback; /* hack */
407 HWND reset_focus; /* hack */
411 const nsIHttpChannelVtbl *lpHttpChannelVtbl;
412 const nsIUploadChannelVtbl *lpUploadChannelVtbl;
413 const nsIHttpChannelInternalVtbl *lpIHttpChannelInternalVtbl;
418 nsIHttpChannel *http_channel;
419 nsIHttpChannelInternal *http_channel_internal;
421 nsIInputStream *post_data_stream;
422 nsILoadGroup *load_group;
423 nsIInterfaceRequestor *notif_callback;
425 nsLoadFlags load_flags;
426 nsIURI *original_uri;
429 PRUint32 response_status;
433 HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
434 void (*destructor)(HTMLDOMNode*);
435 event_target_t **(*get_event_target)(HTMLDOMNode*);
436 HRESULT (*call_event)(HTMLDOMNode*,DWORD,BOOL*);
437 HRESULT (*put_disabled)(HTMLDOMNode*,VARIANT_BOOL);
438 HRESULT (*get_disabled)(HTMLDOMNode*,VARIANT_BOOL*);
443 const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
444 const IHTMLDOMNode2Vtbl *lpHTMLDOMNode2Vtbl;
445 const NodeImplVtbl *vtbl;
450 HTMLDocumentNode *doc;
451 event_target_t *event_target;
458 ConnectionPointContainer cp_container;
460 const IHTMLElementVtbl *lpHTMLElementVtbl;
461 const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
462 const IHTMLElement3Vtbl *lpHTMLElement3Vtbl;
464 nsIDOMHTMLElement *nselem;
470 const IHTMLTextContainerVtbl *lpHTMLTextContainerVtbl;
475 typedef struct _mutation_queue_t {
477 nsISupports *nsiface;
479 struct _mutation_queue_t *next;
482 struct HTMLDocumentNode {
484 HTMLDocument basedoc;
486 const IInternetHostSecurityManagerVtbl *lpIInternetHostSecurityManagerVtbl;
488 const nsIDocumentObserverVtbl *lpIDocumentObserverVtbl;
489 const nsIRunnableVtbl *lpIRunnableVtbl;
493 nsIDOMHTMLDocument *nsdoc;
497 IInternetSecurityManager *secmgr;
499 mutation_queue_t *mutation_queue;
500 mutation_queue_t *mutation_queue_tail;
502 struct list bindings;
503 struct list selection_list;
504 struct list range_list;
507 #define HTMLWINDOW2(x) ((IHTMLWindow2*) &(x)->lpHTMLWindow2Vtbl)
508 #define HTMLWINDOW3(x) ((IHTMLWindow3*) &(x)->lpHTMLWindow3Vtbl)
510 #define HTMLDOC(x) ((IHTMLDocument2*) &(x)->lpHTMLDocument2Vtbl)
511 #define HTMLDOC3(x) ((IHTMLDocument3*) &(x)->lpHTMLDocument3Vtbl)
512 #define HTMLDOC4(x) ((IHTMLDocument4*) &(x)->lpHTMLDocument4Vtbl)
513 #define HTMLDOC5(x) ((IHTMLDocument5*) &(x)->lpHTMLDocument5Vtbl)
514 #define HTMLDOC6(x) ((IHTMLDocument6*) &(x)->lpHTMLDocument6Vtbl)
515 #define PERSIST(x) ((IPersist*) &(x)->lpPersistFileVtbl)
516 #define PERSISTMON(x) ((IPersistMoniker*) &(x)->lpPersistMonikerVtbl)
517 #define PERSISTFILE(x) ((IPersistFile*) &(x)->lpPersistFileVtbl)
518 #define MONPROP(x) ((IMonikerProp*) &(x)->lpMonikerPropVtbl)
519 #define OLEOBJ(x) ((IOleObject*) &(x)->lpOleObjectVtbl)
520 #define OLEDOC(x) ((IOleDocument*) &(x)->lpOleDocumentVtbl)
521 #define DOCVIEW(x) ((IOleDocumentView*) &(x)->lpOleDocumentViewVtbl)
522 #define OLEWIN(x) ((IOleWindow*) &(x)->lpOleInPlaceActiveObjectVtbl)
523 #define ACTOBJ(x) ((IOleInPlaceActiveObject*) &(x)->lpOleInPlaceActiveObjectVtbl)
524 #define VIEWOBJ(x) ((IViewObject*) &(x)->lpViewObject2Vtbl)
525 #define VIEWOBJ2(x) ((IViewObject2*) &(x)->lpViewObject2Vtbl)
526 #define INPLACEOBJ(x) ((IOleInPlaceObject*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
527 #define INPLACEWIN(x) ((IOleInPlaceObjectWindowless*) &(x)->lpOleInPlaceObjectWindowlessVtbl)
528 #define SERVPROV(x) ((IServiceProvider*) &(x)->lpServiceProviderVtbl)
529 #define CMDTARGET(x) ((IOleCommandTarget*) &(x)->lpOleCommandTargetVtbl)
530 #define CONTROL(x) ((IOleControl*) &(x)->lpOleControlVtbl)
531 #define HLNKTARGET(x) ((IHlinkTarget*) &(x)->lpHlinkTargetVtbl)
532 #define CONPTCONT(x) ((IConnectionPointContainer*) &(x)->lpConnectionPointContainerVtbl)
533 #define PERSTRINIT(x) ((IPersistStreamInit*) &(x)->lpPersistStreamInitVtbl)
534 #define PERSISTHIST(x) ((IPersistHistory*) &(x)->lpPersistHistoryVtbl)
535 #define CUSTOMDOC(x) ((ICustomDoc*) &(x)->lpCustomDocVtbl)
537 #define NSWBCHROME(x) ((nsIWebBrowserChrome*) &(x)->lpWebBrowserChromeVtbl)
538 #define NSCML(x) ((nsIContextMenuListener*) &(x)->lpContextMenuListenerVtbl)
539 #define NSURICL(x) ((nsIURIContentListener*) &(x)->lpURIContentListenerVtbl)
540 #define NSEMBWNDS(x) ((nsIEmbeddingSiteWindow*) &(x)->lpEmbeddingSiteWindowVtbl)
541 #define NSIFACEREQ(x) ((nsIInterfaceRequestor*) &(x)->lpInterfaceRequestorVtbl)
542 #define NSTOOLTIP(x) ((nsITooltipListener*) &(x)->lpTooltipListenerVtbl)
543 #define NSEVENTLIST(x) ((nsIDOMEventListener*) &(x)->lpDOMEventListenerVtbl)
544 #define NSWEAKREF(x) ((nsIWeakReference*) &(x)->lpWeakReferenceVtbl)
545 #define NSSUPWEAKREF(x) ((nsISupportsWeakReference*) &(x)->lpSupportsWeakReferenceVtbl)
547 #define NSDOCOBS(x) ((nsIDocumentObserver*) &(x)->lpIDocumentObserverVtbl)
549 #define NSRUNNABLE(x) ((nsIRunnable*) &(x)->lpIRunnableVtbl)
551 #define NSCHANNEL(x) ((nsIChannel*) &(x)->lpHttpChannelVtbl)
552 #define NSHTTPCHANNEL(x) ((nsIHttpChannel*) &(x)->lpHttpChannelVtbl)
553 #define NSUPCHANNEL(x) ((nsIUploadChannel*) &(x)->lpUploadChannelVtbl)
554 #define NSHTTPINTERNAL(x) ((nsIHttpChannelInternal*) &(x)->lpIHttpChannelInternalVtbl)
556 #define HTTPNEG(x) ((IHttpNegotiate2*) &(x)->lpHttpNegotiate2Vtbl)
557 #define STATUSCLB(x) ((IBindStatusCallback*) &(x)->lpBindStatusCallbackVtbl)
558 #define BINDINFO(x) ((IInternetBindInfo*) &(x)->lpInternetBindInfoVtbl);
560 #define HTMLELEM(x) ((IHTMLElement*) &(x)->lpHTMLElementVtbl)
561 #define HTMLELEM2(x) ((IHTMLElement2*) &(x)->lpHTMLElement2Vtbl)
562 #define HTMLELEM3(x) ((IHTMLElement3*) &(x)->lpHTMLElement3Vtbl)
563 #define HTMLDOMNODE(x) ((IHTMLDOMNode*) &(x)->lpHTMLDOMNodeVtbl)
564 #define HTMLDOMNODE2(x) ((IHTMLDOMNode2*) &(x)->lpHTMLDOMNode2Vtbl)
566 #define HTMLTEXTCONT(x) ((IHTMLTextContainer*) &(x)->lpHTMLTextContainerVtbl)
568 #define HTMLOPTFACTORY(x) ((IHTMLOptionElementFactory*) &(x)->lpHTMLOptionElementFactoryVtbl)
569 #define HTMLIMGFACTORY(x) ((IHTMLImageElementFactory*) &(x)->lpHTMLImageElementFactoryVtbl)
570 #define HTMLLOCATION(x) ((IHTMLLocation*) &(x)->lpHTMLLocationVtbl)
572 #define DISPATCHEX(x) ((IDispatchEx*) &(x)->lpIDispatchExVtbl)
574 #define SUPPERRINFO(x) ((ISupportErrorInfo*) &(x)->lpSupportErrorInfoVtbl)
576 #define HOSTSECMGR(x) ((IInternetHostSecurityManager*) &(x)->lpIInternetHostSecurityManagerVtbl)
578 #define DEFINE_THIS2(cls,ifc,iface) ((cls*)((BYTE*)(iface)-offsetof(cls,ifc)))
579 #define DEFINE_THIS(cls,ifc,iface) DEFINE_THIS2(cls,lp ## ifc ## Vtbl,iface)
581 HRESULT HTMLDocument_Create(IUnknown*,REFIID,void**);
582 HRESULT HTMLLoadOptions_Create(IUnknown*,REFIID,void**);
583 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument*,HTMLDocumentObj*,HTMLWindow*,HTMLDocumentNode**);
585 HRESULT HTMLWindow_Create(HTMLDocumentObj*,nsIDOMWindow*,HTMLWindow*,HTMLWindow**);
586 void update_window_doc(HTMLWindow*);
587 HTMLWindow *nswindow_to_window(const nsIDOMWindow*);
588 nsIDOMWindow *get_nsdoc_window(nsIDOMDocument*);
589 HTMLOptionElementFactory *HTMLOptionElementFactory_Create(HTMLWindow*);
590 HTMLImageElementFactory *HTMLImageElementFactory_Create(HTMLWindow*);
591 HRESULT HTMLLocation_Create(HTMLWindow*,HTMLLocation**);
592 IOmNavigator *OmNavigator_Create(void);
594 void HTMLDocument_HTMLDocument3_Init(HTMLDocument*);
595 void HTMLDocument_HTMLDocument5_Init(HTMLDocument*);
596 void HTMLDocument_Persist_Init(HTMLDocument*);
597 void HTMLDocument_OleCmd_Init(HTMLDocument*);
598 void HTMLDocument_OleObj_Init(HTMLDocument*);
599 void HTMLDocument_View_Init(HTMLDocument*);
600 void HTMLDocument_Window_Init(HTMLDocument*);
601 void HTMLDocument_Service_Init(HTMLDocument*);
602 void HTMLDocument_Hlink_Init(HTMLDocument*);
604 void HTMLDocumentNode_SecMgr_Init(HTMLDocumentNode*);
606 HRESULT HTMLCurrentStyle_Create(HTMLElement*,IHTMLCurrentStyle**);
608 void ConnectionPoint_Init(ConnectionPoint*,ConnectionPointContainer*,REFIID);
609 void ConnectionPointContainer_Init(ConnectionPointContainer*,IUnknown*);
610 void ConnectionPointContainer_Destroy(ConnectionPointContainer*);
612 NSContainer *NSContainer_Create(HTMLDocumentObj*,NSContainer*);
613 void NSContainer_Release(NSContainer*);
615 void init_mutation(HTMLDocumentNode*);
616 void release_mutation(HTMLDocumentNode*);
618 void HTMLDocument_LockContainer(HTMLDocumentObj*,BOOL);
619 void show_context_menu(HTMLDocumentObj*,DWORD,POINT*,IDispatch*);
620 void notif_focus(HTMLDocumentObj*);
622 void show_tooltip(HTMLDocumentObj*,DWORD,DWORD,LPCWSTR);
623 void hide_tooltip(HTMLDocumentObj*);
624 HRESULT get_client_disp_property(IOleClientSite*,DISPID,VARIANT*);
626 HRESULT ProtocolFactory_Create(REFCLSID,REFIID,void**);
628 BOOL load_gecko(BOOL);
629 void close_gecko(void);
630 void register_nsservice(nsIComponentRegistrar*,nsIServiceManager*);
631 void init_nsio(nsIComponentManager*,nsIComponentRegistrar*);
632 void release_nsio(void);
633 BOOL install_wine_gecko(BOOL);
635 HRESULT nsuri_to_url(LPCWSTR,BOOL,BSTR*);
637 HRESULT hlink_frame_navigate(HTMLDocument*,LPCWSTR,nsIInputStream*,DWORD);
638 HRESULT navigate_url(HTMLDocumentNode*,OLECHAR*);
640 void call_property_onchanged(ConnectionPoint*,DISPID);
641 HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
643 void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
646 void nsACString_Init(nsACString*,const char*);
647 void nsACString_SetData(nsACString*,const char*);
648 PRUint32 nsACString_GetData(const nsACString*,const char**);
649 void nsACString_Finish(nsACString*);
651 void nsAString_Init(nsAString*,const PRUnichar*);
652 void nsAString_SetData(nsAString*,const PRUnichar*);
653 PRUint32 nsAString_GetData(const nsAString*,const PRUnichar**);
654 void nsAString_Finish(nsAString*);
656 nsICommandParams *create_nscommand_params(void);
657 HRESULT nsnode_to_nsstring(nsIDOMNode*,nsAString*);
658 void get_editor_controller(NSContainer*);
659 void init_nsevents(NSContainer*);
660 void add_nsevent_listener(HTMLWindow*,LPCWSTR);
661 nsresult get_nsinterface(nsISupports*,REFIID,void**);
663 void set_window_bscallback(HTMLWindow*,nsChannelBSC*);
664 void set_current_mon(HTMLWindow*,IMoniker*);
665 HRESULT start_binding(HTMLWindow*,HTMLDocumentNode*,BSCallback*,IBindCtx*);
666 void abort_document_bindings(HTMLDocumentNode*);
668 HRESULT bind_mon_to_buffer(HTMLDocumentNode*,IMoniker*,void**,DWORD*);
670 nsChannelBSC *create_channelbsc(IMoniker*);
671 HRESULT channelbsc_load_stream(nsChannelBSC*,IStream*);
672 void channelbsc_set_channel(nsChannelBSC*,nsChannel*,nsIStreamListener*,nsISupports*);
673 IMoniker *get_channelbsc_mon(nsChannelBSC*);
675 void parse_complete(HTMLDocumentObj*);
677 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**);
678 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**);
679 IHTMLStyle *HTMLStyle_Create(nsIDOMCSSStyleDeclaration*);
680 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*);
681 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*);
683 void detach_selection(HTMLDocumentNode*);
684 void detach_ranges(HTMLDocumentNode*);
685 HRESULT get_node_text(HTMLDOMNode*,BSTR*);
687 HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
689 HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*);
691 HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL);
692 HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*);
693 HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
694 HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
695 HTMLElement *HTMLIFrame_Create(nsIDOMHTMLElement*);
696 HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement*);
697 HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
698 HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
699 HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*);
700 HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
701 HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
702 HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement*);
703 HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
704 HTMLElement *HTMLGenericElement_Create(nsIDOMHTMLElement*);
706 void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
707 void HTMLElement_Init(HTMLElement*,dispex_static_data_t*);
708 void HTMLElement2_Init(HTMLElement*);
709 void HTMLElement3_Init(HTMLElement*);
710 void HTMLTextContainer_Init(HTMLTextContainer*,dispex_static_data_t*);
712 HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
713 void HTMLDOMNode_destructor(HTMLDOMNode*);
715 HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
716 void HTMLElement_destructor(HTMLDOMNode*);
718 HTMLDOMNode *get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL);
719 void release_nodes(HTMLDocumentNode*);
721 void release_script_hosts(HTMLWindow*);
722 void connect_scripts(HTMLWindow*);
723 void doc_insert_script(HTMLWindow*,nsIDOMHTMLScriptElement*);
724 IDispatch *script_parse_event(HTMLWindow*,LPCWSTR);
725 void set_script_mode(HTMLWindow*,SCRIPTMODE);
726 BOOL find_global_prop(HTMLWindow*,BSTR,DWORD,ScriptHost**,DISPID*);
727 IDispatch *get_script_disp(ScriptHost*);
729 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL);
730 IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*);
731 IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*);
736 HRESULT (*query)(HTMLDocument*,OLECMD*);
737 HRESULT (*exec)(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
740 extern const cmdtable_t editmode_cmds[];
742 void do_ns_command(HTMLDocument*,const char*,nsICommandParams*);
745 #define UPDATE_UI 0x0001
746 #define UPDATE_TITLE 0x0002
748 void update_doc(HTMLDocument*,DWORD);
749 void update_title(HTMLDocumentObj*);
752 void init_editor(HTMLDocument*);
753 void set_ns_editmode(NSContainer*);
754 void handle_edit_event(HTMLDocument*,nsIDOMEvent*);
755 HRESULT editor_exec_copy(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
756 HRESULT editor_exec_cut(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
757 HRESULT editor_exec_paste(HTMLDocument*,DWORD,VARIANT*,VARIANT*);
758 void handle_edit_load(HTMLDocument*);
759 HRESULT editor_is_dirty(HTMLDocument*);
760 void set_dirty(HTMLDocument*,VARIANT_BOOL);
762 extern DWORD mshtml_tls;
764 typedef struct task_t task_t;
765 typedef void (*task_proc_t)(task_t*);
775 HTMLDocumentObj *doc;
780 task_t *task_queue_head;
781 task_t *task_queue_tail;
782 struct list timer_list;
785 thread_data_t *get_thread_data(BOOL);
786 HWND get_thread_hwnd(void);
788 LONG get_task_target_magic(void);
789 void push_task(task_t*,task_proc_t,LONG);
790 void remove_target_tasks(LONG);
792 DWORD set_task_timer(HTMLDocument*,DWORD,BOOL,IDispatch*);
793 HRESULT clear_task_timer(HTMLDocument*,BOOL,DWORD);
795 void release_typelib(void);
796 HRESULT call_disp_func(IDispatch*,DISPPARAMS*);
798 const char *debugstr_variant(const VARIANT*);
800 DEFINE_GUID(CLSID_AboutProtocol, 0x3050F406, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
801 DEFINE_GUID(CLSID_JSProtocol, 0x3050F3B2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
802 DEFINE_GUID(CLSID_MailtoProtocol, 0x3050F3DA, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
803 DEFINE_GUID(CLSID_ResProtocol, 0x3050F3BC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
804 DEFINE_GUID(CLSID_SysimageProtocol, 0x76E67A63, 0x06E9, 0x11D2, 0xA8,0x40, 0x00,0x60,0x08,0x05,0x93,0x82);
806 DEFINE_GUID(CLSID_CMarkup,0x3050f4fb,0x98b5,0x11cf,0xbb,0x82,0x00,0xaa,0x00,0xbd,0xce,0x0b);
808 /* memory allocation functions */
810 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc(size_t len)
812 return HeapAlloc(GetProcessHeap(), 0, len);
815 static inline void * __WINE_ALLOC_SIZE(1) heap_alloc_zero(size_t len)
817 return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
820 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc(void *mem, size_t len)
822 return HeapReAlloc(GetProcessHeap(), 0, mem, len);
825 static inline void * __WINE_ALLOC_SIZE(2) heap_realloc_zero(void *mem, size_t len)
827 return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
830 static inline BOOL heap_free(void *mem)
832 return HeapFree(GetProcessHeap(), 0, mem);
835 static inline LPWSTR heap_strdupW(LPCWSTR str)
842 size = (strlenW(str)+1)*sizeof(WCHAR);
843 ret = heap_alloc(size);
844 memcpy(ret, str, size);
850 static inline char *heap_strdupA(const char *str)
857 size = strlen(str)+1;
858 ret = heap_alloc(size);
859 memcpy(ret, str, size);
865 static inline WCHAR *heap_strdupAtoW(const char *str)
872 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
873 ret = heap_alloc(len*sizeof(WCHAR));
874 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
880 static inline char *heap_strdupWtoA(LPCWSTR str)
885 DWORD size = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
886 ret = heap_alloc(size);
887 WideCharToMultiByte(CP_ACP, 0, str, -1, ret, size, NULL, NULL);
893 static inline void windowref_addref(windowref_t *ref)
895 InterlockedIncrement(&ref->ref);
898 static inline void windowref_release(windowref_t *ref)
900 if(!InterlockedDecrement(&ref->ref))
904 HINSTANCE get_shdoclc(void);
906 extern HINSTANCE hInst;