push e2dd5002080a3a5df525dea14b261213385de3ae
[wine/hacks.git] / dlls / mshtml / htmldoc.c
blobfcabaa16e6fc2ff04ae497c33fa7314d91cf8e7a
1 /*
2 * Copyright 2005 Jacek Caban
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
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
34 #include "htmlevent.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
40 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppvObject)
42 HTMLDocument *This = HTMLDOC_THIS(iface);
44 *ppvObject = NULL;
45 if(IsEqualGUID(&IID_IUnknown, riid)) {
46 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppvObject);
47 *ppvObject = HTMLDOC(This);
48 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
49 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppvObject);
50 *ppvObject = DISPATCHEX(This);
51 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
52 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppvObject);
53 *ppvObject = DISPATCHEX(This);
54 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
55 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppvObject);
56 *ppvObject = HTMLDOC(This);
57 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
58 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppvObject);
59 *ppvObject = HTMLDOC(This);
60 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
61 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppvObject);
62 *ppvObject = HTMLDOC3(This);
63 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
64 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppvObject);
65 *ppvObject = HTMLDOC4(This);
66 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
67 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppvObject);
68 *ppvObject = HTMLDOC5(This);
69 }else if(IsEqualGUID(&IID_IPersist, riid)) {
70 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppvObject);
71 *ppvObject = PERSIST(This);
72 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
73 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppvObject);
74 *ppvObject = PERSISTMON(This);
75 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
76 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppvObject);
77 *ppvObject = PERSISTFILE(This);
78 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
79 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppvObject);
80 *ppvObject = MONPROP(This);
81 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
82 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppvObject);
83 *ppvObject = OLEOBJ(This);
84 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
85 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppvObject);
86 *ppvObject = OLEDOC(This);
87 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
88 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppvObject);
89 *ppvObject = DOCVIEW(This);
90 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
91 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppvObject);
92 *ppvObject = ACTOBJ(This);
93 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
94 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppvObject);
95 *ppvObject = VIEWOBJ(This);
96 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
97 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppvObject);
98 *ppvObject = VIEWOBJ2(This);
99 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
100 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppvObject);
101 *ppvObject = OLEWIN(This);
102 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
103 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppvObject);
104 *ppvObject = INPLACEOBJ(This);
105 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
106 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppvObject);
107 *ppvObject = INPLACEWIN(This);
108 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
109 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppvObject);
110 *ppvObject = SERVPROV(This);
111 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
112 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppvObject);
113 *ppvObject = CMDTARGET(This);
114 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
115 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppvObject);
116 *ppvObject = CONTROL(This);
117 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
118 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppvObject);
119 *ppvObject = HLNKTARGET(This);
120 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
121 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppvObject);
122 *ppvObject = CONPTCONT(&This->cp_container);
123 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
124 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppvObject);
125 *ppvObject = PERSTRINIT(This);
126 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
127 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppvObject);
128 *ppvObject = CUSTOMDOC(This);
129 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
130 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppvObject);
131 *ppvObject = HTMLDOC(This);
132 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
133 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppvObject);
134 return E_NOINTERFACE;
135 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
136 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppvObject);
137 return E_NOINTERFACE;
138 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
139 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppvObject);
140 return E_NOINTERFACE;
141 }else if(dispex_query_interface(&This->dispex, riid, ppvObject)) {
142 return *ppvObject ? S_OK : E_NOINTERFACE;
145 if(*ppvObject) {
146 IHTMLDocument2_AddRef(iface);
147 return S_OK;
150 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppvObject);
151 return E_NOINTERFACE;
154 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
156 HTMLDocument *This = HTMLDOC_THIS(iface);
157 ULONG ref = InterlockedIncrement(&This->ref);
158 TRACE("(%p) ref = %u\n", This, ref);
159 return ref;
162 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
164 HTMLDocument *This = HTMLDOC_THIS(iface);
165 ULONG ref = InterlockedDecrement(&This->ref);
167 TRACE("(%p) ref = %u\n", This, ref);
169 if(!ref) {
170 remove_doc_tasks(This);
171 release_script_hosts(This);
173 if(This->client)
174 IOleObject_SetClientSite(OLEOBJ(This), NULL);
175 if(This->in_place_active)
176 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
177 if(This->ipsite)
178 IOleDocumentView_SetInPlaceSite(DOCVIEW(This), NULL);
179 if(This->undomgr)
180 IOleUndoManager_Release(This->undomgr);
182 set_document_bscallback(This, NULL);
183 set_current_mon(This, NULL);
185 if(This->tooltips_hwnd)
186 DestroyWindow(This->tooltips_hwnd);
187 if(This->hwnd)
188 DestroyWindow(This->hwnd);
190 if(This->option_factory) {
191 This->option_factory->doc = NULL;
192 IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
195 if(This->location)
196 This->location->doc = NULL;
198 if(This->window)
199 IHTMLWindow2_Release(HTMLWINDOW2(This->window));
201 if(This->event_target)
202 release_event_target(This->event_target);
204 heap_free(This->mime);
205 detach_selection(This);
206 detach_ranges(This);
207 release_nodes(This);
209 ConnectionPointContainer_Destroy(&This->cp_container);
211 if(This->nsdoc)
212 nsIDOMHTMLDocument_Release(This->nsdoc);
213 if(This->nscontainer)
214 NSContainer_Release(This->nscontainer);
216 heap_free(This);
218 UNLOCK_MODULE();
221 return ref;
224 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
226 HTMLDocument *This = HTMLDOC_THIS(iface);
228 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
231 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
232 LCID lcid, ITypeInfo **ppTInfo)
234 HTMLDocument *This = HTMLDOC_THIS(iface);
236 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
239 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
240 LPOLESTR *rgszNames, UINT cNames,
241 LCID lcid, DISPID *rgDispId)
243 HTMLDocument *This = HTMLDOC_THIS(iface);
245 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
248 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
249 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
250 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
252 HTMLDocument *This = HTMLDOC_THIS(iface);
254 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
255 pVarResult, pExcepInfo, puArgErr);
258 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
260 HTMLDocument *This = HTMLDOC_THIS(iface);
262 TRACE("(%p)->(%p)\n", This, p);
264 *p = (IDispatch*)HTMLWINDOW2(This->window);
265 IDispatch_AddRef(*p);
266 return S_OK;
269 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
271 HTMLDocument *This = HTMLDOC_THIS(iface);
272 nsIDOMElement *nselem = NULL;
273 nsresult nsres;
275 TRACE("(%p)->(%p)\n", This, p);
277 if(!This->nsdoc) {
278 WARN("NULL nsdoc\n");
279 return E_UNEXPECTED;
282 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->nsdoc, &nselem);
283 if(NS_FAILED(nsres)) {
284 ERR("GetDocumentElement failed: %08x\n", nsres);
285 return E_FAIL;
288 if(nselem) {
289 *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE), TRUE);
290 nsIDOMElement_Release(nselem);
291 }else {
292 *p = NULL;
295 return S_OK;
298 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
300 HTMLDocument *This = HTMLDOC_THIS(iface);
301 nsIDOMHTMLElement *nsbody = NULL;
302 HTMLDOMNode *node;
303 nsresult nsres;
305 TRACE("(%p)->(%p)\n", This, p);
307 if(!This->nsdoc) {
308 WARN("NULL nsdoc\n");
309 return E_UNEXPECTED;
312 nsres = nsIDOMHTMLDocument_GetBody(This->nsdoc, &nsbody);
313 if(NS_FAILED(nsres)) {
314 TRACE("Could not get body: %08x\n", nsres);
315 return E_UNEXPECTED;
318 if(nsbody) {
319 node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
320 nsIDOMHTMLElement_Release(nsbody);
322 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
323 }else {
324 *p = NULL;
327 TRACE("*p = %p\n", *p);
328 return S_OK;
331 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
333 HTMLDocument *This = HTMLDOC_THIS(iface);
334 FIXME("(%p)->(%p)\n", This, p);
335 return E_NOTIMPL;
338 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
340 HTMLDocument *This = HTMLDOC_THIS(iface);
341 FIXME("(%p)->(%p)\n", This, p);
342 return E_NOTIMPL;
345 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
347 HTMLDocument *This = HTMLDOC_THIS(iface);
348 FIXME("(%p)->(%p)\n", This, p);
349 return E_NOTIMPL;
352 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
354 HTMLDocument *This = HTMLDOC_THIS(iface);
355 FIXME("(%p)->(%p)\n", This, p);
356 return E_NOTIMPL;
359 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
361 HTMLDocument *This = HTMLDOC_THIS(iface);
362 FIXME("(%p)->(%p)\n", This, p);
363 return E_NOTIMPL;
366 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
368 HTMLDocument *This = HTMLDOC_THIS(iface);
369 FIXME("(%p)->(%p)\n", This, p);
370 return E_NOTIMPL;
373 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
375 HTMLDocument *This = HTMLDOC_THIS(iface);
376 nsAString nsstr;
377 nsresult nsres;
379 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
381 if(!This->nsdoc) {
382 WARN("NULL nsdoc\n");
383 return E_UNEXPECTED;
386 nsAString_Init(&nsstr, v);
387 nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr);
388 nsAString_Finish(&nsstr);
389 if(NS_FAILED(nsres))
390 ERR("SetTitle failed: %08x\n", nsres);
392 return S_OK;
395 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
397 HTMLDocument *This = HTMLDOC_THIS(iface);
398 const PRUnichar *ret;
399 nsAString nsstr;
400 nsresult nsres;
402 TRACE("(%p)->(%p)\n", This, p);
404 if(!This->nsdoc) {
405 WARN("NULL nsdoc\n");
406 return E_UNEXPECTED;
410 nsAString_Init(&nsstr, NULL);
411 nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
412 if (NS_SUCCEEDED(nsres)) {
413 nsAString_GetData(&nsstr, &ret);
414 *p = SysAllocString(ret);
416 nsAString_Finish(&nsstr);
418 if(NS_FAILED(nsres)) {
419 ERR("GetTitle failed: %08x\n", nsres);
420 return E_FAIL;
423 return S_OK;
426 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
428 HTMLDocument *This = HTMLDOC_THIS(iface);
429 FIXME("(%p)->(%p)\n", This, p);
430 return E_NOTIMPL;
433 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
435 HTMLDocument *This = HTMLDOC_THIS(iface);
436 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
437 return E_NOTIMPL;
440 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
442 HTMLDocument *This = HTMLDOC_THIS(iface);
443 FIXME("(%p)->(%p)\n", This, p);
444 return E_NOTIMPL;
447 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
449 HTMLDocument *This = HTMLDOC_THIS(iface);
450 nsISelection *nsselection = NULL;
452 TRACE("(%p)->(%p)\n", This, p);
454 if(This->nscontainer) {
455 nsIDOMWindow *dom_window = NULL;
457 nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
458 if(dom_window) {
459 nsIDOMWindow_GetSelection(dom_window, &nsselection);
460 nsIDOMWindow_Release(dom_window);
464 *p = HTMLSelectionObject_Create(This, nsselection);
465 return S_OK;
468 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
470 HTMLDocument *This = HTMLDOC_THIS(iface);
472 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
473 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
474 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
475 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
476 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
478 static const LPCWSTR readystate_str[] = {
479 wszUninitialized,
480 wszLoading,
481 wszLoaded,
482 wszInteractive,
483 wszComplete
486 TRACE("(%p)->(%p)\n", iface, p);
488 if(!p)
489 return E_POINTER;
491 *p = SysAllocString(readystate_str[This->readystate]);
492 return S_OK;
495 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
497 HTMLDocument *This = HTMLDOC_THIS(iface);
498 FIXME("(%p)->(%p)\n", This, p);
499 return E_NOTIMPL;
502 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
504 HTMLDocument *This = HTMLDOC_THIS(iface);
505 FIXME("(%p)->(%p)\n", This, p);
506 return E_NOTIMPL;
509 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
511 HTMLDocument *This = HTMLDOC_THIS(iface);
512 FIXME("(%p)->(%p)\n", This, p);
513 return E_NOTIMPL;
516 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
518 HTMLDocument *This = HTMLDOC_THIS(iface);
519 FIXME("(%p)\n", This);
520 return E_NOTIMPL;
523 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
525 HTMLDocument *This = HTMLDOC_THIS(iface);
526 FIXME("(%p)->(%p)\n", This, p);
527 return E_NOTIMPL;
530 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
532 HTMLDocument *This = HTMLDOC_THIS(iface);
533 FIXME("(%p)\n", This);
534 return E_NOTIMPL;
537 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
539 HTMLDocument *This = HTMLDOC_THIS(iface);
540 FIXME("(%p)->(%p)\n", This, p);
541 return E_NOTIMPL;
544 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
546 HTMLDocument *This = HTMLDOC_THIS(iface);
547 FIXME("(%p)\n", This);
548 return E_NOTIMPL;
551 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
553 HTMLDocument *This = HTMLDOC_THIS(iface);
554 FIXME("(%p)->(%p)\n", This, p);
555 return E_NOTIMPL;
558 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
560 HTMLDocument *This = HTMLDOC_THIS(iface);
561 FIXME("(%p)->()\n", This);
562 return E_NOTIMPL;
565 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
567 HTMLDocument *This = HTMLDOC_THIS(iface);
568 FIXME("(%p)->(%p)\n", This, p);
569 return E_NOTIMPL;
572 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
574 HTMLDocument *This = HTMLDOC_THIS(iface);
575 FIXME("(%p)\n", This);
576 return E_NOTIMPL;
579 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
581 HTMLDocument *This = HTMLDOC_THIS(iface);
582 FIXME("(%p)->(%p)\n", This, p);
583 return E_NOTIMPL;
586 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
588 HTMLDocument *This = HTMLDOC_THIS(iface);
589 FIXME("(%p)->(%p)\n", This, p);
590 return E_NOTIMPL;
593 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
595 HTMLDocument *This = HTMLDOC_THIS(iface);
597 TRACE("(%p)->(%p)\n", This, p);
599 if(This->location)
600 IHTMLLocation_AddRef(HTMLLOCATION(This->location));
601 else
602 This->location = HTMLLocation_Create(This);
604 *p = HTMLLOCATION(This->location);
605 return S_OK;
608 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
610 HTMLDocument *This = HTMLDOC_THIS(iface);
611 FIXME("(%p)->(%p)\n", This, p);
612 return E_NOTIMPL;
615 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
617 HTMLDocument *This = HTMLDOC_THIS(iface);
618 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
619 return E_NOTIMPL;
622 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
624 HTMLDocument *This = HTMLDOC_THIS(iface);
626 static const WCHAR about_blank_url[] =
627 {'a','b','o','u','t',':','b','l','a','n','k',0};
629 TRACE("(%p)->(%p)\n", iface, p);
631 *p = SysAllocString(This->url ? This->url : about_blank_url);
632 return S_OK;
635 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
637 HTMLDocument *This = HTMLDOC_THIS(iface);
638 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
639 return E_NOTIMPL;
642 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
644 HTMLDocument *This = HTMLDOC_THIS(iface);
645 FIXME("(%p)->(%p)\n", This, p);
646 return E_NOTIMPL;
649 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
651 HTMLDocument *This = HTMLDOC_THIS(iface);
652 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
653 return E_NOTIMPL;
656 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
658 HTMLDocument *This = HTMLDOC_THIS(iface);
659 FIXME("(%p)->(%p)\n", This, p);
660 return E_NOTIMPL;
663 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
665 HTMLDocument *This = HTMLDOC_THIS(iface);
666 FIXME("(%p)->(%x)\n", This, v);
667 return E_NOTIMPL;
670 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
672 HTMLDocument *This = HTMLDOC_THIS(iface);
673 FIXME("(%p)->(%p)\n", This, p);
674 return E_NOTIMPL;
677 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
679 HTMLDocument *This = HTMLDOC_THIS(iface);
680 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
681 return E_NOTIMPL;
684 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
686 HTMLDocument *This = HTMLDOC_THIS(iface);
687 FIXME("(%p)->(%p)\n", This, p);
688 return E_NOTIMPL;
691 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
693 HTMLDocument *This = HTMLDOC_THIS(iface);
694 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
695 return E_NOTIMPL;
698 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
700 HTMLDocument *This = HTMLDOC_THIS(iface);
701 FIXME("(%p)->(%p)\n", This, p);
702 return E_NOTIMPL;
705 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
707 HTMLDocument *This = HTMLDOC_THIS(iface);
708 FIXME("(%p)->(%p)\n", This, p);
709 return E_NOTIMPL;
712 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
714 HTMLDocument *This = HTMLDOC_THIS(iface);
715 FIXME("(%p)->(%p)\n", This, p);
716 return E_NOTIMPL;
719 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
721 HTMLDocument *This = HTMLDOC_THIS(iface);
722 FIXME("(%p)->(%p)\n", This, p);
723 return E_NOTIMPL;
726 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
728 HTMLDocument *This = HTMLDOC_THIS(iface);
729 FIXME("(%p)->(%p)\n", This, p);
730 return E_NOTIMPL;
733 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
735 HTMLDocument *This = HTMLDOC_THIS(iface);
736 FIXME("(%p)->(%p)\n", This, p);
737 return E_NOTIMPL;
740 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
742 HTMLDocument *This = HTMLDOC_THIS(iface);
743 FIXME("(%p)->(%p)\n", This, p);
744 return E_NOTIMPL;
747 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
749 HTMLDocument *This = HTMLDOC_THIS(iface);
750 FIXME("(%p)->(%p)\n", This, p);
751 return E_NOTIMPL;
754 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
756 HTMLDocument *This = HTMLDOC_THIS(iface);
757 FIXME("(%p)->(%p)\n", This, p);
758 return E_NOTIMPL;
761 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
763 HTMLDocument *This = HTMLDOC_THIS(iface);
764 nsAString nsstr;
765 VARIANT *var;
766 int i;
767 nsresult nsres;
768 HRESULT hres;
770 TRACE("(%p)->(%p)\n", iface, psarray);
772 if(!This->nsdoc) {
773 WARN("NULL nsdoc\n");
774 return E_UNEXPECTED;
777 if(psarray->cDims != 1) {
778 FIXME("cDims=%d\n", psarray->cDims);
779 return E_INVALIDARG;
782 hres = SafeArrayAccessData(psarray, (void**)&var);
783 if(FAILED(hres)) {
784 WARN("SafeArrayAccessData failed: %08x\n", hres);
785 return hres;
788 nsAString_Init(&nsstr, NULL);
790 for(i=0; i < psarray->rgsabound[0].cElements; i++) {
791 if(V_VT(var+i) == VT_BSTR) {
792 nsAString_SetData(&nsstr, V_BSTR(var+i));
793 nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
794 if(NS_FAILED(nsres))
795 ERR("Write failed: %08x\n", nsres);
796 }else {
797 FIXME("vt=%d\n", V_VT(var+i));
801 nsAString_Finish(&nsstr);
802 SafeArrayUnaccessData(psarray);
804 return S_OK;
807 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
809 HTMLDocument *This = HTMLDOC_THIS(iface);
810 FIXME("(%p)->(%p)\n", This, psarray);
811 return E_NOTIMPL;
814 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
815 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
817 HTMLDocument *This = HTMLDOC_THIS(iface);
818 nsresult nsres;
820 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
822 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
823 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
825 if(!This->nsdoc) {
826 ERR("!nsdoc\n");
827 return E_NOTIMPL;
830 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
831 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
832 FIXME("unsupported args\n");
834 nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
835 if(NS_FAILED(nsres)) {
836 ERR("Open failed: %08x\n", nsres);
837 return E_FAIL;
840 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
841 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
842 return S_OK;
845 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
847 HTMLDocument *This = HTMLDOC_THIS(iface);
848 nsresult nsres;
850 TRACE("(%p)\n", This);
852 if(!This->nsdoc) {
853 ERR("!nsdoc\n");
854 return E_NOTIMPL;
857 nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
858 if(NS_FAILED(nsres)) {
859 ERR("Close failed: %08x\n", nsres);
860 return E_FAIL;
863 return S_OK;
866 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
868 HTMLDocument *This = HTMLDOC_THIS(iface);
869 FIXME("(%p)\n", This);
870 return E_NOTIMPL;
873 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
874 VARIANT_BOOL *pfRet)
876 HTMLDocument *This = HTMLDOC_THIS(iface);
877 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
878 return E_NOTIMPL;
881 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
882 VARIANT_BOOL *pfRet)
884 HTMLDocument *This = HTMLDOC_THIS(iface);
885 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
886 return E_NOTIMPL;
889 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
890 VARIANT_BOOL *pfRet)
892 HTMLDocument *This = HTMLDOC_THIS(iface);
893 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
894 return E_NOTIMPL;
897 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
898 VARIANT_BOOL *pfRet)
900 HTMLDocument *This = HTMLDOC_THIS(iface);
901 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
902 return E_NOTIMPL;
905 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
906 BSTR *pfRet)
908 HTMLDocument *This = HTMLDOC_THIS(iface);
909 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
910 return E_NOTIMPL;
913 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
914 VARIANT *pfRet)
916 HTMLDocument *This = HTMLDOC_THIS(iface);
917 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
918 return E_NOTIMPL;
921 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
922 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
924 HTMLDocument *This = HTMLDOC_THIS(iface);
925 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
926 return E_NOTIMPL;
929 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
930 VARIANT_BOOL *pfRet)
932 HTMLDocument *This = HTMLDOC_THIS(iface);
933 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
934 return E_NOTIMPL;
937 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
938 IHTMLElement **newElem)
940 HTMLDocument *This = HTMLDOC_THIS(iface);
941 nsIDOMElement *nselem;
942 HTMLElement *elem;
943 nsAString tag_str;
944 nsresult nsres;
946 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
948 if(!This->nsdoc) {
949 WARN("NULL nsdoc\n");
950 return E_UNEXPECTED;
953 nsAString_Init(&tag_str, eTag);
954 nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
955 nsAString_Finish(&tag_str);
956 if(NS_FAILED(nsres)) {
957 ERR("CreateElement failed: %08x\n", nsres);
958 return E_FAIL;
961 elem = HTMLElement_Create(This, (nsIDOMNode*)nselem, TRUE);
962 nsIDOMElement_Release(nselem);
964 *newElem = HTMLELEM(elem);
965 IHTMLElement_AddRef(HTMLELEM(elem));
966 return S_OK;
969 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
971 HTMLDocument *This = HTMLDOC_THIS(iface);
972 FIXME("(%p)\n", This);
973 return E_NOTIMPL;
976 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
978 HTMLDocument *This = HTMLDOC_THIS(iface);
979 FIXME("(%p)->(%p)\n", This, p);
980 return E_NOTIMPL;
983 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
985 HTMLDocument *This = HTMLDOC_THIS(iface);
986 FIXME("(%p)\n", This);
987 return E_NOTIMPL;
990 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
992 HTMLDocument *This = HTMLDOC_THIS(iface);
993 FIXME("(%p)->(%p)\n", This, p);
994 return E_NOTIMPL;
997 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
999 HTMLDocument *This = HTMLDOC_THIS(iface);
1000 FIXME("(%p)\n", This);
1001 return E_NOTIMPL;
1004 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1006 HTMLDocument *This = HTMLDOC_THIS(iface);
1007 FIXME("(%p)->(%p)\n", This, p);
1008 return E_NOTIMPL;
1011 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1013 HTMLDocument *This = HTMLDOC_THIS(iface);
1015 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1017 return set_doc_event(This, EVENTID_KEYUP, &v);
1020 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1022 HTMLDocument *This = HTMLDOC_THIS(iface);
1024 TRACE("(%p)->(%p)\n", This, p);
1026 return get_doc_event(This, EVENTID_KEYUP, p);
1029 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1031 HTMLDocument *This = HTMLDOC_THIS(iface);
1033 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1035 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1038 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1040 HTMLDocument *This = HTMLDOC_THIS(iface);
1042 TRACE("(%p)->(%p)\n", This, p);
1044 return get_doc_event(This, EVENTID_KEYDOWN, p);
1047 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1049 HTMLDocument *This = HTMLDOC_THIS(iface);
1050 FIXME("(%p)\n", This);
1051 return E_NOTIMPL;
1054 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1056 HTMLDocument *This = HTMLDOC_THIS(iface);
1057 FIXME("(%p)->(%p)\n", This, p);
1058 return E_NOTIMPL;
1061 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1063 HTMLDocument *This = HTMLDOC_THIS(iface);
1064 FIXME("(%p)\n", This);
1065 return E_NOTIMPL;
1068 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1070 HTMLDocument *This = HTMLDOC_THIS(iface);
1071 FIXME("(%p)->(%p)\n", This, p);
1072 return E_NOTIMPL;
1075 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1077 HTMLDocument *This = HTMLDOC_THIS(iface);
1078 FIXME("(%p)\n", This);
1079 return E_NOTIMPL;
1082 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1084 HTMLDocument *This = HTMLDOC_THIS(iface);
1085 FIXME("(%p)->(%p)\n", This, p);
1086 return E_NOTIMPL;
1089 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1091 HTMLDocument *This = HTMLDOC_THIS(iface);
1092 FIXME("(%p)\n", This);
1093 return E_NOTIMPL;
1096 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1098 HTMLDocument *This = HTMLDOC_THIS(iface);
1099 FIXME("(%p)->(%p)\n", This, p);
1100 return E_NOTIMPL;
1103 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1105 HTMLDocument *This = HTMLDOC_THIS(iface);
1106 FIXME("(%p)\n", This);
1107 return E_NOTIMPL;
1110 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1112 HTMLDocument *This = HTMLDOC_THIS(iface);
1113 FIXME("(%p)->(%p)\n", This, p);
1114 return E_NOTIMPL;
1117 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1119 HTMLDocument *This = HTMLDOC_THIS(iface);
1121 TRACE("(%p)\n", This);
1123 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1126 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1128 HTMLDocument *This = HTMLDOC_THIS(iface);
1130 TRACE("(%p)->(%p)\n", This, p);
1132 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1135 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1137 HTMLDocument *This = HTMLDOC_THIS(iface);
1138 FIXME("(%p)\n", This);
1139 return E_NOTIMPL;
1142 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1144 HTMLDocument *This = HTMLDOC_THIS(iface);
1145 FIXME("(%p)->(%p)\n", This, p);
1146 return E_NOTIMPL;
1149 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1151 HTMLDocument *This = HTMLDOC_THIS(iface);
1152 FIXME("(%p)\n", This);
1153 return E_NOTIMPL;
1156 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1158 HTMLDocument *This = HTMLDOC_THIS(iface);
1159 FIXME("(%p)->(%p)\n", This, p);
1160 return E_NOTIMPL;
1163 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1165 HTMLDocument *This = HTMLDOC_THIS(iface);
1166 FIXME("(%p)\n", This);
1167 return E_NOTIMPL;
1170 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1172 HTMLDocument *This = HTMLDOC_THIS(iface);
1173 FIXME("(%p)->(%p)\n", This, p);
1174 return E_NOTIMPL;
1177 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1179 HTMLDocument *This = HTMLDOC_THIS(iface);
1180 FIXME("(%p)\n", This);
1181 return E_NOTIMPL;
1184 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1186 HTMLDocument *This = HTMLDOC_THIS(iface);
1187 FIXME("(%p)->(%p)\n", This, p);
1188 return E_NOTIMPL;
1191 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1193 HTMLDocument *This = HTMLDOC_THIS(iface);
1195 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1197 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1200 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1202 HTMLDocument *This = HTMLDOC_THIS(iface);
1204 TRACE("(%p)->(%p)\n", This, p);
1206 return get_doc_event(This, EVENTID_DRAGSTART, p);
1209 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1211 HTMLDocument *This = HTMLDOC_THIS(iface);
1213 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1215 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1218 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1220 HTMLDocument *This = HTMLDOC_THIS(iface);
1222 TRACE("(%p)->(%p)\n", This, p);
1224 return get_doc_event(This, EVENTID_SELECTSTART, p);
1227 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, long x, long y,
1228 IHTMLElement **elementHit)
1230 HTMLDocument *This = HTMLDOC_THIS(iface);
1231 FIXME("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1232 return E_NOTIMPL;
1235 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1237 HTMLDocument *This = HTMLDOC_THIS(iface);
1239 TRACE("(%p)->(%p)\n", This, p);
1241 *p = HTMLWINDOW2(This->window);
1242 IHTMLWindow2_AddRef(*p);
1243 return S_OK;
1246 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1247 IHTMLStyleSheetsCollection **p)
1249 HTMLDocument *This = HTMLDOC_THIS(iface);
1250 nsIDOMStyleSheetList *nsstylelist;
1251 nsIDOMDocumentStyle *nsdocstyle;
1252 nsresult nsres;
1254 TRACE("(%p)->(%p)\n", This, p);
1256 *p = NULL;
1258 if(!This->nsdoc) {
1259 WARN("NULL nsdoc\n");
1260 return E_UNEXPECTED;
1263 nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1264 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1265 nsIDOMDocumentStyle_Release(nsdocstyle);
1266 if(NS_FAILED(nsres)) {
1267 ERR("GetStyleSheets failed: %08x\n", nsres);
1268 return E_FAIL;
1271 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1272 nsIDOMDocumentStyle_Release(nsstylelist);
1274 return S_OK;
1277 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1279 HTMLDocument *This = HTMLDOC_THIS(iface);
1280 FIXME("(%p)\n", This);
1281 return E_NOTIMPL;
1284 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1286 HTMLDocument *This = HTMLDOC_THIS(iface);
1287 FIXME("(%p)->(%p)\n", This, p);
1288 return E_NOTIMPL;
1291 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1293 HTMLDocument *This = HTMLDOC_THIS(iface);
1294 FIXME("(%p)\n", This);
1295 return E_NOTIMPL;
1298 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1300 HTMLDocument *This = HTMLDOC_THIS(iface);
1301 FIXME("(%p)->(%p)\n", This, p);
1302 return E_NOTIMPL;
1305 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1307 HTMLDocument *This = HTMLDOC_THIS(iface);
1308 FIXME("(%p)->(%p)\n", This, String);
1309 return E_NOTIMPL;
1312 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1313 long lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1315 HTMLDocument *This = HTMLDOC_THIS(iface);
1317 FIXME("(%p)->(%s %ld %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1319 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1320 return S_OK;
1323 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1324 HTMLDocument_QueryInterface,
1325 HTMLDocument_AddRef,
1326 HTMLDocument_Release,
1327 HTMLDocument_GetTypeInfoCount,
1328 HTMLDocument_GetTypeInfo,
1329 HTMLDocument_GetIDsOfNames,
1330 HTMLDocument_Invoke,
1331 HTMLDocument_get_Script,
1332 HTMLDocument_get_all,
1333 HTMLDocument_get_body,
1334 HTMLDocument_get_activeElement,
1335 HTMLDocument_get_images,
1336 HTMLDocument_get_applets,
1337 HTMLDocument_get_links,
1338 HTMLDocument_get_forms,
1339 HTMLDocument_get_anchors,
1340 HTMLDocument_put_title,
1341 HTMLDocument_get_title,
1342 HTMLDocument_get_scripts,
1343 HTMLDocument_put_designMode,
1344 HTMLDocument_get_designMode,
1345 HTMLDocument_get_selection,
1346 HTMLDocument_get_readyState,
1347 HTMLDocument_get_frames,
1348 HTMLDocument_get_embeds,
1349 HTMLDocument_get_plugins,
1350 HTMLDocument_put_alinkColor,
1351 HTMLDocument_get_alinkColor,
1352 HTMLDocument_put_bgColor,
1353 HTMLDocument_get_bgColor,
1354 HTMLDocument_put_fgColor,
1355 HTMLDocument_get_fgColor,
1356 HTMLDocument_put_linkColor,
1357 HTMLDocument_get_linkColor,
1358 HTMLDocument_put_vlinkColor,
1359 HTMLDocument_get_vlinkColor,
1360 HTMLDocument_get_referrer,
1361 HTMLDocument_get_location,
1362 HTMLDocument_get_lastModified,
1363 HTMLDocument_put_URL,
1364 HTMLDocument_get_URL,
1365 HTMLDocument_put_domain,
1366 HTMLDocument_get_domain,
1367 HTMLDocument_put_cookie,
1368 HTMLDocument_get_cookie,
1369 HTMLDocument_put_expando,
1370 HTMLDocument_get_expando,
1371 HTMLDocument_put_charset,
1372 HTMLDocument_get_charset,
1373 HTMLDocument_put_defaultCharset,
1374 HTMLDocument_get_defaultCharset,
1375 HTMLDocument_get_mimeType,
1376 HTMLDocument_get_fileSize,
1377 HTMLDocument_get_fileCreatedDate,
1378 HTMLDocument_get_fileModifiedDate,
1379 HTMLDocument_get_fileUpdatedDate,
1380 HTMLDocument_get_security,
1381 HTMLDocument_get_protocol,
1382 HTMLDocument_get_nameProp,
1383 HTMLDocument_write,
1384 HTMLDocument_writeln,
1385 HTMLDocument_open,
1386 HTMLDocument_close,
1387 HTMLDocument_clear,
1388 HTMLDocument_queryCommandSupported,
1389 HTMLDocument_queryCommandEnabled,
1390 HTMLDocument_queryCommandState,
1391 HTMLDocument_queryCommandIndeterm,
1392 HTMLDocument_queryCommandText,
1393 HTMLDocument_queryCommandValue,
1394 HTMLDocument_execCommand,
1395 HTMLDocument_execCommandShowHelp,
1396 HTMLDocument_createElement,
1397 HTMLDocument_put_onhelp,
1398 HTMLDocument_get_onhelp,
1399 HTMLDocument_put_onclick,
1400 HTMLDocument_get_onclick,
1401 HTMLDocument_put_ondblclick,
1402 HTMLDocument_get_ondblclick,
1403 HTMLDocument_put_onkeyup,
1404 HTMLDocument_get_onkeyup,
1405 HTMLDocument_put_onkeydown,
1406 HTMLDocument_get_onkeydown,
1407 HTMLDocument_put_onkeypress,
1408 HTMLDocument_get_onkeypress,
1409 HTMLDocument_put_onmouseup,
1410 HTMLDocument_get_onmouseup,
1411 HTMLDocument_put_onmousedown,
1412 HTMLDocument_get_onmousedown,
1413 HTMLDocument_put_onmousemove,
1414 HTMLDocument_get_onmousemove,
1415 HTMLDocument_put_onmouseout,
1416 HTMLDocument_get_onmouseout,
1417 HTMLDocument_put_onmouseover,
1418 HTMLDocument_get_onmouseover,
1419 HTMLDocument_put_onreadystatechange,
1420 HTMLDocument_get_onreadystatechange,
1421 HTMLDocument_put_onafterupdate,
1422 HTMLDocument_get_onafterupdate,
1423 HTMLDocument_put_onrowexit,
1424 HTMLDocument_get_onrowexit,
1425 HTMLDocument_put_onrowenter,
1426 HTMLDocument_get_onrowenter,
1427 HTMLDocument_put_ondragstart,
1428 HTMLDocument_get_ondragstart,
1429 HTMLDocument_put_onselectstart,
1430 HTMLDocument_get_onselectstart,
1431 HTMLDocument_elementFromPoint,
1432 HTMLDocument_get_parentWindow,
1433 HTMLDocument_get_styleSheets,
1434 HTMLDocument_put_onbeforeupdate,
1435 HTMLDocument_get_onbeforeupdate,
1436 HTMLDocument_put_onerrorupdate,
1437 HTMLDocument_get_onerrorupdate,
1438 HTMLDocument_toString,
1439 HTMLDocument_createStyleSheet
1442 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1444 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1446 HTMLDocument *This = DISPEX_THIS(iface);
1448 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1451 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1453 HTMLDocument *This = DISPEX_THIS(iface);
1455 return IHTMLDocument2_AddRef(HTMLDOC(This));
1458 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1460 HTMLDocument *This = DISPEX_THIS(iface);
1462 return IHTMLDocument2_Release(HTMLDOC(This));
1465 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1467 HTMLDocument *This = DISPEX_THIS(iface);
1469 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1472 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1473 LCID lcid, ITypeInfo **ppTInfo)
1475 HTMLDocument *This = DISPEX_THIS(iface);
1477 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1480 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1481 LPOLESTR *rgszNames, UINT cNames,
1482 LCID lcid, DISPID *rgDispId)
1484 HTMLDocument *This = DISPEX_THIS(iface);
1486 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1489 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1490 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1491 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1493 HTMLDocument *This = DISPEX_THIS(iface);
1495 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1496 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1498 switch(dispIdMember) {
1499 case DISPID_READYSTATE:
1500 TRACE("DISPID_READYSTATE\n");
1502 if(!(wFlags & DISPATCH_PROPERTYGET))
1503 return E_INVALIDARG;
1505 V_VT(pVarResult) = VT_I4;
1506 V_I4(pVarResult) = This->readystate;
1507 return S_OK;
1510 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1511 pVarResult, pExcepInfo, puArgErr);
1514 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1516 HTMLDocument *This = DISPEX_THIS(iface);
1518 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1521 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1522 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1524 HTMLDocument *This = DISPEX_THIS(iface);
1526 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1529 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1531 HTMLDocument *This = DISPEX_THIS(iface);
1533 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1536 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1538 HTMLDocument *This = DISPEX_THIS(iface);
1540 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1543 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1545 HTMLDocument *This = DISPEX_THIS(iface);
1547 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1550 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1552 HTMLDocument *This = DISPEX_THIS(iface);
1554 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1557 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1559 HTMLDocument *This = DISPEX_THIS(iface);
1561 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1564 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1566 HTMLDocument *This = DISPEX_THIS(iface);
1568 return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1571 #undef DISPEX_THIS
1573 static const IDispatchExVtbl DocDispatchExVtbl = {
1574 DocDispatchEx_QueryInterface,
1575 DocDispatchEx_AddRef,
1576 DocDispatchEx_Release,
1577 DocDispatchEx_GetTypeInfoCount,
1578 DocDispatchEx_GetTypeInfo,
1579 DocDispatchEx_GetIDsOfNames,
1580 DocDispatchEx_Invoke,
1581 DocDispatchEx_GetDispID,
1582 DocDispatchEx_InvokeEx,
1583 DocDispatchEx_DeleteMemberByName,
1584 DocDispatchEx_DeleteMemberByDispID,
1585 DocDispatchEx_GetMemberProperties,
1586 DocDispatchEx_GetMemberName,
1587 DocDispatchEx_GetNextDispID,
1588 DocDispatchEx_GetNameSpaceParent
1591 static const tid_t HTMLDocument_iface_tids[] = {
1592 IHTMLDocument2_tid,
1593 IHTMLDocument3_tid,
1594 IHTMLDocument4_tid,
1595 IHTMLDocument5_tid,
1598 static dispex_static_data_t HTMLDocument_dispex = {
1599 NULL,
1600 DispHTMLDocument_tid,
1601 NULL,
1602 HTMLDocument_iface_tids
1605 static HRESULT alloc_doc(HTMLDocument **ret)
1607 HTMLDocument *doc;
1609 doc = heap_alloc_zero(sizeof(HTMLDocument));
1610 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1611 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1612 doc->ref = 1;
1613 doc->readystate = READYSTATE_UNINITIALIZED;
1614 doc->scriptmode = SCRIPTMODE_GECKO;
1616 list_init(&doc->bindings);
1617 list_init(&doc->script_hosts);
1618 list_init(&doc->selection_list);
1619 list_init(&doc->range_list);
1621 HTMLDocument_HTMLDocument3_Init(doc);
1622 HTMLDocument_HTMLDocument5_Init(doc);
1623 HTMLDocument_Persist_Init(doc);
1624 HTMLDocument_OleCmd_Init(doc);
1625 HTMLDocument_OleObj_Init(doc);
1626 HTMLDocument_View_Init(doc);
1627 HTMLDocument_Window_Init(doc);
1628 HTMLDocument_Service_Init(doc);
1629 HTMLDocument_Hlink_Init(doc);
1631 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1632 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
1633 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
1634 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
1636 init_dispex(&doc->dispex, (IUnknown*)HTMLDOC(doc), &HTMLDocument_dispex);
1638 *ret = doc;
1639 return S_OK;
1642 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocument **ret)
1644 HTMLDocument *doc;
1645 HRESULT hres;
1647 hres = alloc_doc(&doc);
1648 if(FAILED(hres))
1649 return hres;
1651 nsIDOMHTMLDocument_AddRef(nsdoc);
1652 doc->nsdoc = nsdoc;
1654 hres = HTMLWindow_Create(doc, NULL, &doc->window);
1655 if(FAILED(hres)) {
1656 IHTMLDocument_Release(HTMLDOC(doc));
1657 return hres;
1660 *ret = doc;
1661 return S_OK;
1664 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1666 HTMLDocument *doc;
1667 nsIDOMWindow *nswindow;
1668 HRESULT hres;
1670 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1672 hres = alloc_doc(&doc);
1673 if(FAILED(hres))
1674 return hres;
1676 hres = IHTMLDocument_QueryInterface(HTMLDOC(doc), riid, ppvObject);
1677 IHTMLDocument_Release(HTMLDOC(doc));
1678 if(FAILED(hres))
1679 return hres;
1681 LOCK_MODULE();
1683 doc->nscontainer = NSContainer_Create(doc, NULL);
1684 update_nsdocument(doc);
1686 if(doc->nscontainer) {
1687 nsresult nsres;
1689 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
1690 if(NS_FAILED(nsres))
1691 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1694 hres = HTMLWindow_Create(doc, nswindow, &doc->window);
1695 if(nswindow)
1696 nsIDOMWindow_Release(nswindow);
1697 if(FAILED(hres)) {
1698 IHTMLDocument_Release(HTMLDOC(doc));
1699 return hres;
1702 get_thread_hwnd();
1704 return S_OK;