push 0661da64275a0e67e1a41492b8d7716e364e773c
[wine/hacks.git] / dlls / mshtml / htmldoc.c
blob0d9a0a859435ef2b942ab69fe6649fe55d80c8d5
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 nsIDOMHTMLCollection *nscoll = NULL;
342 nsresult nsres;
344 TRACE("(%p)->(%p)\n", This, p);
346 if(!p)
347 return E_INVALIDARG;
349 *p = NULL;
351 if(!This->nsdoc) {
352 WARN("NULL nsdoc\n");
353 return E_UNEXPECTED;
356 nsres = nsIDOMHTMLDocument_GetImages(This->nsdoc, &nscoll);
357 if(NS_FAILED(nsres)) {
358 ERR("GetImages failed: %08x\n", nsres);
359 return E_FAIL;
362 if(nscoll) {
363 *p = create_collection_from_htmlcol(This, (IUnknown*)HTMLDOC(This), nscoll);
364 nsIDOMElement_Release(nscoll);
367 return S_OK;
370 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
372 HTMLDocument *This = HTMLDOC_THIS(iface);
373 FIXME("(%p)->(%p)\n", This, p);
374 return E_NOTIMPL;
377 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
379 HTMLDocument *This = HTMLDOC_THIS(iface);
380 FIXME("(%p)->(%p)\n", This, p);
381 return E_NOTIMPL;
384 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
386 HTMLDocument *This = HTMLDOC_THIS(iface);
387 FIXME("(%p)->(%p)\n", This, p);
388 return E_NOTIMPL;
391 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
393 HTMLDocument *This = HTMLDOC_THIS(iface);
394 FIXME("(%p)->(%p)\n", This, p);
395 return E_NOTIMPL;
398 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
400 HTMLDocument *This = HTMLDOC_THIS(iface);
401 nsAString nsstr;
402 nsresult nsres;
404 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
406 if(!This->nsdoc) {
407 WARN("NULL nsdoc\n");
408 return E_UNEXPECTED;
411 nsAString_Init(&nsstr, v);
412 nsres = nsIDOMHTMLDocument_SetTitle(This->nsdoc, &nsstr);
413 nsAString_Finish(&nsstr);
414 if(NS_FAILED(nsres))
415 ERR("SetTitle failed: %08x\n", nsres);
417 return S_OK;
420 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
422 HTMLDocument *This = HTMLDOC_THIS(iface);
423 const PRUnichar *ret;
424 nsAString nsstr;
425 nsresult nsres;
427 TRACE("(%p)->(%p)\n", This, p);
429 if(!This->nsdoc) {
430 WARN("NULL nsdoc\n");
431 return E_UNEXPECTED;
435 nsAString_Init(&nsstr, NULL);
436 nsres = nsIDOMHTMLDocument_GetTitle(This->nsdoc, &nsstr);
437 if (NS_SUCCEEDED(nsres)) {
438 nsAString_GetData(&nsstr, &ret);
439 *p = SysAllocString(ret);
441 nsAString_Finish(&nsstr);
443 if(NS_FAILED(nsres)) {
444 ERR("GetTitle failed: %08x\n", nsres);
445 return E_FAIL;
448 return S_OK;
451 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
453 HTMLDocument *This = HTMLDOC_THIS(iface);
454 FIXME("(%p)->(%p)\n", This, p);
455 return E_NOTIMPL;
458 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
460 HTMLDocument *This = HTMLDOC_THIS(iface);
461 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
462 return E_NOTIMPL;
465 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
467 HTMLDocument *This = HTMLDOC_THIS(iface);
468 static WCHAR szOff[] = {'O','f','f',0};
469 FIXME("(%p)->(%p) always returning Off\n", This, p);
471 if(!p)
472 return E_INVALIDARG;
474 *p = SysAllocString(szOff);
476 return S_OK;
479 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
481 HTMLDocument *This = HTMLDOC_THIS(iface);
482 nsISelection *nsselection = NULL;
484 TRACE("(%p)->(%p)\n", This, p);
486 if(This->nscontainer) {
487 nsIDOMWindow *dom_window = NULL;
489 nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
490 if(dom_window) {
491 nsIDOMWindow_GetSelection(dom_window, &nsselection);
492 nsIDOMWindow_Release(dom_window);
496 *p = HTMLSelectionObject_Create(This, nsselection);
497 return S_OK;
500 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
502 HTMLDocument *This = HTMLDOC_THIS(iface);
504 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
505 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
506 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
507 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
508 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
510 static const LPCWSTR readystate_str[] = {
511 wszUninitialized,
512 wszLoading,
513 wszLoaded,
514 wszInteractive,
515 wszComplete
518 TRACE("(%p)->(%p)\n", iface, p);
520 if(!p)
521 return E_POINTER;
523 *p = SysAllocString(readystate_str[This->readystate]);
524 return S_OK;
527 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
529 HTMLDocument *This = HTMLDOC_THIS(iface);
530 FIXME("(%p)->(%p)\n", This, p);
531 return E_NOTIMPL;
534 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
536 HTMLDocument *This = HTMLDOC_THIS(iface);
537 FIXME("(%p)->(%p)\n", This, p);
538 return E_NOTIMPL;
541 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
543 HTMLDocument *This = HTMLDOC_THIS(iface);
544 FIXME("(%p)->(%p)\n", This, p);
545 return E_NOTIMPL;
548 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
550 HTMLDocument *This = HTMLDOC_THIS(iface);
551 FIXME("(%p)\n", This);
552 return E_NOTIMPL;
555 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
557 HTMLDocument *This = HTMLDOC_THIS(iface);
558 FIXME("(%p)->(%p)\n", This, p);
559 return E_NOTIMPL;
562 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
564 HTMLDocument *This = HTMLDOC_THIS(iface);
565 FIXME("(%p)\n", This);
566 return E_NOTIMPL;
569 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
571 HTMLDocument *This = HTMLDOC_THIS(iface);
572 FIXME("(%p)->(%p)\n", This, p);
573 return E_NOTIMPL;
576 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
578 HTMLDocument *This = HTMLDOC_THIS(iface);
579 FIXME("(%p)\n", This);
580 return E_NOTIMPL;
583 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
585 HTMLDocument *This = HTMLDOC_THIS(iface);
586 FIXME("(%p)->(%p)\n", This, p);
587 return E_NOTIMPL;
590 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
592 HTMLDocument *This = HTMLDOC_THIS(iface);
593 FIXME("(%p)->()\n", This);
594 return E_NOTIMPL;
597 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
599 HTMLDocument *This = HTMLDOC_THIS(iface);
600 FIXME("(%p)->(%p)\n", This, p);
601 return E_NOTIMPL;
604 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
606 HTMLDocument *This = HTMLDOC_THIS(iface);
607 FIXME("(%p)\n", This);
608 return E_NOTIMPL;
611 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
613 HTMLDocument *This = HTMLDOC_THIS(iface);
614 FIXME("(%p)->(%p)\n", This, p);
615 return E_NOTIMPL;
618 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
620 HTMLDocument *This = HTMLDOC_THIS(iface);
621 FIXME("(%p)->(%p)\n", This, p);
622 return E_NOTIMPL;
625 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
627 HTMLDocument *This = HTMLDOC_THIS(iface);
629 TRACE("(%p)->(%p)\n", This, p);
631 if(This->location)
632 IHTMLLocation_AddRef(HTMLLOCATION(This->location));
633 else
634 This->location = HTMLLocation_Create(This);
636 *p = HTMLLOCATION(This->location);
637 return S_OK;
640 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
642 HTMLDocument *This = HTMLDOC_THIS(iface);
643 FIXME("(%p)->(%p)\n", This, p);
644 return E_NOTIMPL;
647 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
649 HTMLDocument *This = HTMLDOC_THIS(iface);
650 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
651 return E_NOTIMPL;
654 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
656 HTMLDocument *This = HTMLDOC_THIS(iface);
658 static const WCHAR about_blank_url[] =
659 {'a','b','o','u','t',':','b','l','a','n','k',0};
661 TRACE("(%p)->(%p)\n", iface, p);
663 *p = SysAllocString(This->url ? This->url : about_blank_url);
664 return S_OK;
667 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
669 HTMLDocument *This = HTMLDOC_THIS(iface);
670 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
671 return E_NOTIMPL;
674 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
676 HTMLDocument *This = HTMLDOC_THIS(iface);
677 FIXME("(%p)->(%p)\n", This, p);
678 return E_NOTIMPL;
681 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
683 HTMLDocument *This = HTMLDOC_THIS(iface);
684 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
685 return E_NOTIMPL;
688 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
690 HTMLDocument *This = HTMLDOC_THIS(iface);
691 FIXME("(%p)->(%p)\n", This, p);
692 return E_NOTIMPL;
695 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
697 HTMLDocument *This = HTMLDOC_THIS(iface);
698 FIXME("(%p)->(%x)\n", This, v);
699 return E_NOTIMPL;
702 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
704 HTMLDocument *This = HTMLDOC_THIS(iface);
705 FIXME("(%p)->(%p)\n", This, p);
706 return E_NOTIMPL;
709 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
711 HTMLDocument *This = HTMLDOC_THIS(iface);
712 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
713 return E_NOTIMPL;
716 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
718 HTMLDocument *This = HTMLDOC_THIS(iface);
719 FIXME("(%p)->(%p)\n", This, p);
720 return E_NOTIMPL;
723 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
725 HTMLDocument *This = HTMLDOC_THIS(iface);
726 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
727 return E_NOTIMPL;
730 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
732 HTMLDocument *This = HTMLDOC_THIS(iface);
733 FIXME("(%p)->(%p)\n", This, p);
734 return E_NOTIMPL;
737 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
739 HTMLDocument *This = HTMLDOC_THIS(iface);
740 FIXME("(%p)->(%p)\n", This, p);
741 return E_NOTIMPL;
744 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
746 HTMLDocument *This = HTMLDOC_THIS(iface);
747 FIXME("(%p)->(%p)\n", This, p);
748 return E_NOTIMPL;
751 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
753 HTMLDocument *This = HTMLDOC_THIS(iface);
754 FIXME("(%p)->(%p)\n", This, p);
755 return E_NOTIMPL;
758 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
760 HTMLDocument *This = HTMLDOC_THIS(iface);
761 FIXME("(%p)->(%p)\n", This, p);
762 return E_NOTIMPL;
765 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
767 HTMLDocument *This = HTMLDOC_THIS(iface);
768 FIXME("(%p)->(%p)\n", This, p);
769 return E_NOTIMPL;
772 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
774 HTMLDocument *This = HTMLDOC_THIS(iface);
775 FIXME("(%p)->(%p)\n", This, p);
776 return E_NOTIMPL;
779 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
781 HTMLDocument *This = HTMLDOC_THIS(iface);
782 FIXME("(%p)->(%p)\n", This, p);
783 return E_NOTIMPL;
786 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
788 HTMLDocument *This = HTMLDOC_THIS(iface);
789 FIXME("(%p)->(%p)\n", This, p);
790 return E_NOTIMPL;
793 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
795 HTMLDocument *This = HTMLDOC_THIS(iface);
796 nsAString nsstr;
797 VARIANT *var;
798 ULONG i;
799 nsresult nsres;
800 HRESULT hres;
802 TRACE("(%p)->(%p)\n", iface, psarray);
804 if(!This->nsdoc) {
805 WARN("NULL nsdoc\n");
806 return E_UNEXPECTED;
809 if(psarray->cDims != 1) {
810 FIXME("cDims=%d\n", psarray->cDims);
811 return E_INVALIDARG;
814 hres = SafeArrayAccessData(psarray, (void**)&var);
815 if(FAILED(hres)) {
816 WARN("SafeArrayAccessData failed: %08x\n", hres);
817 return hres;
820 nsAString_Init(&nsstr, NULL);
822 for(i=0; i < psarray->rgsabound[0].cElements; i++) {
823 if(V_VT(var+i) == VT_BSTR) {
824 nsAString_SetData(&nsstr, V_BSTR(var+i));
825 nsres = nsIDOMHTMLDocument_Write(This->nsdoc, &nsstr);
826 if(NS_FAILED(nsres))
827 ERR("Write failed: %08x\n", nsres);
828 }else {
829 FIXME("vt=%d\n", V_VT(var+i));
833 nsAString_Finish(&nsstr);
834 SafeArrayUnaccessData(psarray);
836 return S_OK;
839 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
841 HTMLDocument *This = HTMLDOC_THIS(iface);
842 FIXME("(%p)->(%p)\n", This, psarray);
843 return E_NOTIMPL;
846 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
847 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
849 HTMLDocument *This = HTMLDOC_THIS(iface);
850 nsresult nsres;
852 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
854 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
855 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
857 if(!This->nsdoc) {
858 ERR("!nsdoc\n");
859 return E_NOTIMPL;
862 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
863 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
864 FIXME("unsupported args\n");
866 nsres = nsIDOMHTMLDocument_Open(This->nsdoc);
867 if(NS_FAILED(nsres)) {
868 ERR("Open failed: %08x\n", nsres);
869 return E_FAIL;
872 *pomWindowResult = (IDispatch*)HTMLWINDOW2(This->window);
873 IHTMLWindow2_AddRef(HTMLWINDOW2(This->window));
874 return S_OK;
877 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
879 HTMLDocument *This = HTMLDOC_THIS(iface);
880 nsresult nsres;
882 TRACE("(%p)\n", This);
884 if(!This->nsdoc) {
885 ERR("!nsdoc\n");
886 return E_NOTIMPL;
889 nsres = nsIDOMHTMLDocument_Close(This->nsdoc);
890 if(NS_FAILED(nsres)) {
891 ERR("Close failed: %08x\n", nsres);
892 return E_FAIL;
895 return S_OK;
898 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
900 HTMLDocument *This = HTMLDOC_THIS(iface);
901 FIXME("(%p)\n", This);
902 return E_NOTIMPL;
905 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
906 VARIANT_BOOL *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_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
914 VARIANT_BOOL *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_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
922 VARIANT_BOOL *pfRet)
924 HTMLDocument *This = HTMLDOC_THIS(iface);
925 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
926 return E_NOTIMPL;
929 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(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_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
938 BSTR *pfRet)
940 HTMLDocument *This = HTMLDOC_THIS(iface);
941 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
942 return E_NOTIMPL;
945 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
946 VARIANT *pfRet)
948 HTMLDocument *This = HTMLDOC_THIS(iface);
949 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
950 return E_NOTIMPL;
953 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
954 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
956 HTMLDocument *This = HTMLDOC_THIS(iface);
957 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
958 return E_NOTIMPL;
961 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
962 VARIANT_BOOL *pfRet)
964 HTMLDocument *This = HTMLDOC_THIS(iface);
965 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
966 return E_NOTIMPL;
969 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
970 IHTMLElement **newElem)
972 HTMLDocument *This = HTMLDOC_THIS(iface);
973 nsIDOMElement *nselem;
974 HTMLElement *elem;
975 nsAString tag_str;
976 nsresult nsres;
978 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
980 if(!This->nsdoc) {
981 WARN("NULL nsdoc\n");
982 return E_UNEXPECTED;
985 nsAString_Init(&tag_str, eTag);
986 nsres = nsIDOMDocument_CreateElement(This->nsdoc, &tag_str, &nselem);
987 nsAString_Finish(&tag_str);
988 if(NS_FAILED(nsres)) {
989 ERR("CreateElement failed: %08x\n", nsres);
990 return E_FAIL;
993 elem = HTMLElement_Create(This, (nsIDOMNode*)nselem, TRUE);
994 nsIDOMElement_Release(nselem);
996 *newElem = HTMLELEM(elem);
997 IHTMLElement_AddRef(HTMLELEM(elem));
998 return S_OK;
1001 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1003 HTMLDocument *This = HTMLDOC_THIS(iface);
1004 FIXME("(%p)\n", This);
1005 return E_NOTIMPL;
1008 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1010 HTMLDocument *This = HTMLDOC_THIS(iface);
1011 FIXME("(%p)->(%p)\n", This, p);
1012 return E_NOTIMPL;
1015 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1017 HTMLDocument *This = HTMLDOC_THIS(iface);
1018 FIXME("(%p)\n", This);
1019 return E_NOTIMPL;
1022 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1024 HTMLDocument *This = HTMLDOC_THIS(iface);
1025 FIXME("(%p)->(%p)\n", This, p);
1026 return E_NOTIMPL;
1029 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1031 HTMLDocument *This = HTMLDOC_THIS(iface);
1032 FIXME("(%p)\n", This);
1033 return E_NOTIMPL;
1036 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1038 HTMLDocument *This = HTMLDOC_THIS(iface);
1039 FIXME("(%p)->(%p)\n", This, p);
1040 return E_NOTIMPL;
1043 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1045 HTMLDocument *This = HTMLDOC_THIS(iface);
1047 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1049 return set_doc_event(This, EVENTID_KEYUP, &v);
1052 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1054 HTMLDocument *This = HTMLDOC_THIS(iface);
1056 TRACE("(%p)->(%p)\n", This, p);
1058 return get_doc_event(This, EVENTID_KEYUP, p);
1061 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1063 HTMLDocument *This = HTMLDOC_THIS(iface);
1065 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1067 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1070 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1072 HTMLDocument *This = HTMLDOC_THIS(iface);
1074 TRACE("(%p)->(%p)\n", This, p);
1076 return get_doc_event(This, EVENTID_KEYDOWN, p);
1079 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1081 HTMLDocument *This = HTMLDOC_THIS(iface);
1082 FIXME("(%p)\n", This);
1083 return E_NOTIMPL;
1086 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1088 HTMLDocument *This = HTMLDOC_THIS(iface);
1089 FIXME("(%p)->(%p)\n", This, p);
1090 return E_NOTIMPL;
1093 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1095 HTMLDocument *This = HTMLDOC_THIS(iface);
1096 FIXME("(%p)\n", This);
1097 return E_NOTIMPL;
1100 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1102 HTMLDocument *This = HTMLDOC_THIS(iface);
1103 FIXME("(%p)->(%p)\n", This, p);
1104 return E_NOTIMPL;
1107 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1109 HTMLDocument *This = HTMLDOC_THIS(iface);
1110 FIXME("(%p)\n", This);
1111 return E_NOTIMPL;
1114 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1116 HTMLDocument *This = HTMLDOC_THIS(iface);
1117 FIXME("(%p)->(%p)\n", This, p);
1118 return E_NOTIMPL;
1121 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1123 HTMLDocument *This = HTMLDOC_THIS(iface);
1124 FIXME("(%p)\n", This);
1125 return E_NOTIMPL;
1128 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1130 HTMLDocument *This = HTMLDOC_THIS(iface);
1131 FIXME("(%p)->(%p)\n", This, p);
1132 return E_NOTIMPL;
1135 static HRESULT WINAPI HTMLDocument_put_onmouseout(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_onmouseout(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_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1151 HTMLDocument *This = HTMLDOC_THIS(iface);
1153 TRACE("(%p)\n", This);
1155 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1158 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1160 HTMLDocument *This = HTMLDOC_THIS(iface);
1162 TRACE("(%p)->(%p)\n", This, p);
1164 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1167 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1169 HTMLDocument *This = HTMLDOC_THIS(iface);
1170 FIXME("(%p)\n", This);
1171 return E_NOTIMPL;
1174 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1176 HTMLDocument *This = HTMLDOC_THIS(iface);
1177 FIXME("(%p)->(%p)\n", This, p);
1178 return E_NOTIMPL;
1181 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1183 HTMLDocument *This = HTMLDOC_THIS(iface);
1184 FIXME("(%p)\n", This);
1185 return E_NOTIMPL;
1188 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1190 HTMLDocument *This = HTMLDOC_THIS(iface);
1191 FIXME("(%p)->(%p)\n", This, p);
1192 return E_NOTIMPL;
1195 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1197 HTMLDocument *This = HTMLDOC_THIS(iface);
1198 FIXME("(%p)\n", This);
1199 return E_NOTIMPL;
1202 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1204 HTMLDocument *This = HTMLDOC_THIS(iface);
1205 FIXME("(%p)->(%p)\n", This, p);
1206 return E_NOTIMPL;
1209 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1211 HTMLDocument *This = HTMLDOC_THIS(iface);
1212 FIXME("(%p)\n", This);
1213 return E_NOTIMPL;
1216 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1218 HTMLDocument *This = HTMLDOC_THIS(iface);
1219 FIXME("(%p)->(%p)\n", This, p);
1220 return E_NOTIMPL;
1223 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1225 HTMLDocument *This = HTMLDOC_THIS(iface);
1227 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1229 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1232 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1234 HTMLDocument *This = HTMLDOC_THIS(iface);
1236 TRACE("(%p)->(%p)\n", This, p);
1238 return get_doc_event(This, EVENTID_DRAGSTART, p);
1241 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1243 HTMLDocument *This = HTMLDOC_THIS(iface);
1245 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1247 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1250 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1252 HTMLDocument *This = HTMLDOC_THIS(iface);
1254 TRACE("(%p)->(%p)\n", This, p);
1256 return get_doc_event(This, EVENTID_SELECTSTART, p);
1259 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, long x, long y,
1260 IHTMLElement **elementHit)
1262 HTMLDocument *This = HTMLDOC_THIS(iface);
1263 FIXME("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1264 return E_NOTIMPL;
1267 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1269 HTMLDocument *This = HTMLDOC_THIS(iface);
1271 TRACE("(%p)->(%p)\n", This, p);
1273 *p = HTMLWINDOW2(This->window);
1274 IHTMLWindow2_AddRef(*p);
1275 return S_OK;
1278 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1279 IHTMLStyleSheetsCollection **p)
1281 HTMLDocument *This = HTMLDOC_THIS(iface);
1282 nsIDOMStyleSheetList *nsstylelist;
1283 nsIDOMDocumentStyle *nsdocstyle;
1284 nsresult nsres;
1286 TRACE("(%p)->(%p)\n", This, p);
1288 *p = NULL;
1290 if(!This->nsdoc) {
1291 WARN("NULL nsdoc\n");
1292 return E_UNEXPECTED;
1295 nsIDOMHTMLDocument_QueryInterface(This->nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1296 nsres = nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1297 nsIDOMDocumentStyle_Release(nsdocstyle);
1298 if(NS_FAILED(nsres)) {
1299 ERR("GetStyleSheets failed: %08x\n", nsres);
1300 return E_FAIL;
1303 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1304 nsIDOMDocumentStyle_Release(nsstylelist);
1306 return S_OK;
1309 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1311 HTMLDocument *This = HTMLDOC_THIS(iface);
1312 FIXME("(%p)\n", This);
1313 return E_NOTIMPL;
1316 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1318 HTMLDocument *This = HTMLDOC_THIS(iface);
1319 FIXME("(%p)->(%p)\n", This, p);
1320 return E_NOTIMPL;
1323 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1325 HTMLDocument *This = HTMLDOC_THIS(iface);
1326 FIXME("(%p)\n", This);
1327 return E_NOTIMPL;
1330 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1332 HTMLDocument *This = HTMLDOC_THIS(iface);
1333 FIXME("(%p)->(%p)\n", This, p);
1334 return E_NOTIMPL;
1337 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1339 HTMLDocument *This = HTMLDOC_THIS(iface);
1340 FIXME("(%p)->(%p)\n", This, String);
1341 return E_NOTIMPL;
1344 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1345 long lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1347 HTMLDocument *This = HTMLDOC_THIS(iface);
1349 FIXME("(%p)->(%s %ld %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1351 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1352 return S_OK;
1355 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1356 HTMLDocument_QueryInterface,
1357 HTMLDocument_AddRef,
1358 HTMLDocument_Release,
1359 HTMLDocument_GetTypeInfoCount,
1360 HTMLDocument_GetTypeInfo,
1361 HTMLDocument_GetIDsOfNames,
1362 HTMLDocument_Invoke,
1363 HTMLDocument_get_Script,
1364 HTMLDocument_get_all,
1365 HTMLDocument_get_body,
1366 HTMLDocument_get_activeElement,
1367 HTMLDocument_get_images,
1368 HTMLDocument_get_applets,
1369 HTMLDocument_get_links,
1370 HTMLDocument_get_forms,
1371 HTMLDocument_get_anchors,
1372 HTMLDocument_put_title,
1373 HTMLDocument_get_title,
1374 HTMLDocument_get_scripts,
1375 HTMLDocument_put_designMode,
1376 HTMLDocument_get_designMode,
1377 HTMLDocument_get_selection,
1378 HTMLDocument_get_readyState,
1379 HTMLDocument_get_frames,
1380 HTMLDocument_get_embeds,
1381 HTMLDocument_get_plugins,
1382 HTMLDocument_put_alinkColor,
1383 HTMLDocument_get_alinkColor,
1384 HTMLDocument_put_bgColor,
1385 HTMLDocument_get_bgColor,
1386 HTMLDocument_put_fgColor,
1387 HTMLDocument_get_fgColor,
1388 HTMLDocument_put_linkColor,
1389 HTMLDocument_get_linkColor,
1390 HTMLDocument_put_vlinkColor,
1391 HTMLDocument_get_vlinkColor,
1392 HTMLDocument_get_referrer,
1393 HTMLDocument_get_location,
1394 HTMLDocument_get_lastModified,
1395 HTMLDocument_put_URL,
1396 HTMLDocument_get_URL,
1397 HTMLDocument_put_domain,
1398 HTMLDocument_get_domain,
1399 HTMLDocument_put_cookie,
1400 HTMLDocument_get_cookie,
1401 HTMLDocument_put_expando,
1402 HTMLDocument_get_expando,
1403 HTMLDocument_put_charset,
1404 HTMLDocument_get_charset,
1405 HTMLDocument_put_defaultCharset,
1406 HTMLDocument_get_defaultCharset,
1407 HTMLDocument_get_mimeType,
1408 HTMLDocument_get_fileSize,
1409 HTMLDocument_get_fileCreatedDate,
1410 HTMLDocument_get_fileModifiedDate,
1411 HTMLDocument_get_fileUpdatedDate,
1412 HTMLDocument_get_security,
1413 HTMLDocument_get_protocol,
1414 HTMLDocument_get_nameProp,
1415 HTMLDocument_write,
1416 HTMLDocument_writeln,
1417 HTMLDocument_open,
1418 HTMLDocument_close,
1419 HTMLDocument_clear,
1420 HTMLDocument_queryCommandSupported,
1421 HTMLDocument_queryCommandEnabled,
1422 HTMLDocument_queryCommandState,
1423 HTMLDocument_queryCommandIndeterm,
1424 HTMLDocument_queryCommandText,
1425 HTMLDocument_queryCommandValue,
1426 HTMLDocument_execCommand,
1427 HTMLDocument_execCommandShowHelp,
1428 HTMLDocument_createElement,
1429 HTMLDocument_put_onhelp,
1430 HTMLDocument_get_onhelp,
1431 HTMLDocument_put_onclick,
1432 HTMLDocument_get_onclick,
1433 HTMLDocument_put_ondblclick,
1434 HTMLDocument_get_ondblclick,
1435 HTMLDocument_put_onkeyup,
1436 HTMLDocument_get_onkeyup,
1437 HTMLDocument_put_onkeydown,
1438 HTMLDocument_get_onkeydown,
1439 HTMLDocument_put_onkeypress,
1440 HTMLDocument_get_onkeypress,
1441 HTMLDocument_put_onmouseup,
1442 HTMLDocument_get_onmouseup,
1443 HTMLDocument_put_onmousedown,
1444 HTMLDocument_get_onmousedown,
1445 HTMLDocument_put_onmousemove,
1446 HTMLDocument_get_onmousemove,
1447 HTMLDocument_put_onmouseout,
1448 HTMLDocument_get_onmouseout,
1449 HTMLDocument_put_onmouseover,
1450 HTMLDocument_get_onmouseover,
1451 HTMLDocument_put_onreadystatechange,
1452 HTMLDocument_get_onreadystatechange,
1453 HTMLDocument_put_onafterupdate,
1454 HTMLDocument_get_onafterupdate,
1455 HTMLDocument_put_onrowexit,
1456 HTMLDocument_get_onrowexit,
1457 HTMLDocument_put_onrowenter,
1458 HTMLDocument_get_onrowenter,
1459 HTMLDocument_put_ondragstart,
1460 HTMLDocument_get_ondragstart,
1461 HTMLDocument_put_onselectstart,
1462 HTMLDocument_get_onselectstart,
1463 HTMLDocument_elementFromPoint,
1464 HTMLDocument_get_parentWindow,
1465 HTMLDocument_get_styleSheets,
1466 HTMLDocument_put_onbeforeupdate,
1467 HTMLDocument_get_onbeforeupdate,
1468 HTMLDocument_put_onerrorupdate,
1469 HTMLDocument_get_onerrorupdate,
1470 HTMLDocument_toString,
1471 HTMLDocument_createStyleSheet
1474 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1476 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1478 HTMLDocument *This = DISPEX_THIS(iface);
1480 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1483 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1485 HTMLDocument *This = DISPEX_THIS(iface);
1487 return IHTMLDocument2_AddRef(HTMLDOC(This));
1490 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1492 HTMLDocument *This = DISPEX_THIS(iface);
1494 return IHTMLDocument2_Release(HTMLDOC(This));
1497 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1499 HTMLDocument *This = DISPEX_THIS(iface);
1501 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1504 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1505 LCID lcid, ITypeInfo **ppTInfo)
1507 HTMLDocument *This = DISPEX_THIS(iface);
1509 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1512 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1513 LPOLESTR *rgszNames, UINT cNames,
1514 LCID lcid, DISPID *rgDispId)
1516 HTMLDocument *This = DISPEX_THIS(iface);
1518 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1521 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1522 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1523 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1525 HTMLDocument *This = DISPEX_THIS(iface);
1527 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1528 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1530 switch(dispIdMember) {
1531 case DISPID_READYSTATE:
1532 TRACE("DISPID_READYSTATE\n");
1534 if(!(wFlags & DISPATCH_PROPERTYGET))
1535 return E_INVALIDARG;
1537 V_VT(pVarResult) = VT_I4;
1538 V_I4(pVarResult) = This->readystate;
1539 return S_OK;
1542 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1543 pVarResult, pExcepInfo, puArgErr);
1546 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1548 HTMLDocument *This = DISPEX_THIS(iface);
1550 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1553 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1554 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1556 HTMLDocument *This = DISPEX_THIS(iface);
1558 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1561 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1563 HTMLDocument *This = DISPEX_THIS(iface);
1565 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1568 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1570 HTMLDocument *This = DISPEX_THIS(iface);
1572 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1575 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1577 HTMLDocument *This = DISPEX_THIS(iface);
1579 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1582 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1584 HTMLDocument *This = DISPEX_THIS(iface);
1586 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1589 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1591 HTMLDocument *This = DISPEX_THIS(iface);
1593 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1596 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1598 HTMLDocument *This = DISPEX_THIS(iface);
1600 return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1603 #undef DISPEX_THIS
1605 static const IDispatchExVtbl DocDispatchExVtbl = {
1606 DocDispatchEx_QueryInterface,
1607 DocDispatchEx_AddRef,
1608 DocDispatchEx_Release,
1609 DocDispatchEx_GetTypeInfoCount,
1610 DocDispatchEx_GetTypeInfo,
1611 DocDispatchEx_GetIDsOfNames,
1612 DocDispatchEx_Invoke,
1613 DocDispatchEx_GetDispID,
1614 DocDispatchEx_InvokeEx,
1615 DocDispatchEx_DeleteMemberByName,
1616 DocDispatchEx_DeleteMemberByDispID,
1617 DocDispatchEx_GetMemberProperties,
1618 DocDispatchEx_GetMemberName,
1619 DocDispatchEx_GetNextDispID,
1620 DocDispatchEx_GetNameSpaceParent
1623 static const tid_t HTMLDocument_iface_tids[] = {
1624 IHTMLDocument2_tid,
1625 IHTMLDocument3_tid,
1626 IHTMLDocument4_tid,
1627 IHTMLDocument5_tid,
1630 static dispex_static_data_t HTMLDocument_dispex = {
1631 NULL,
1632 DispHTMLDocument_tid,
1633 NULL,
1634 HTMLDocument_iface_tids
1637 static HRESULT alloc_doc(HTMLDocument **ret)
1639 HTMLDocument *doc;
1641 doc = heap_alloc_zero(sizeof(HTMLDocument));
1642 doc->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1643 doc->lpIDispatchExVtbl = &DocDispatchExVtbl;
1644 doc->ref = 1;
1645 doc->readystate = READYSTATE_UNINITIALIZED;
1646 doc->scriptmode = SCRIPTMODE_GECKO;
1648 list_init(&doc->bindings);
1649 list_init(&doc->script_hosts);
1650 list_init(&doc->selection_list);
1651 list_init(&doc->range_list);
1653 HTMLDocument_HTMLDocument3_Init(doc);
1654 HTMLDocument_HTMLDocument5_Init(doc);
1655 HTMLDocument_Persist_Init(doc);
1656 HTMLDocument_OleCmd_Init(doc);
1657 HTMLDocument_OleObj_Init(doc);
1658 HTMLDocument_View_Init(doc);
1659 HTMLDocument_Window_Init(doc);
1660 HTMLDocument_Service_Init(doc);
1661 HTMLDocument_Hlink_Init(doc);
1663 ConnectionPointContainer_Init(&doc->cp_container, (IUnknown*)HTMLDOC(doc));
1664 ConnectionPoint_Init(&doc->cp_propnotif, &doc->cp_container, &IID_IPropertyNotifySink);
1665 ConnectionPoint_Init(&doc->cp_htmldocevents, &doc->cp_container, &DIID_HTMLDocumentEvents);
1666 ConnectionPoint_Init(&doc->cp_htmldocevents2, &doc->cp_container, &DIID_HTMLDocumentEvents2);
1668 init_dispex(&doc->dispex, (IUnknown*)HTMLDOC(doc), &HTMLDocument_dispex);
1670 *ret = doc;
1671 return S_OK;
1674 HRESULT create_doc_from_nsdoc(nsIDOMHTMLDocument *nsdoc, HTMLDocument **ret)
1676 HTMLDocument *doc;
1677 HRESULT hres;
1679 hres = alloc_doc(&doc);
1680 if(FAILED(hres))
1681 return hres;
1683 nsIDOMHTMLDocument_AddRef(nsdoc);
1684 doc->nsdoc = nsdoc;
1686 hres = HTMLWindow_Create(doc, NULL, &doc->window);
1687 if(FAILED(hres)) {
1688 IHTMLDocument_Release(HTMLDOC(doc));
1689 return hres;
1692 *ret = doc;
1693 return S_OK;
1696 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1698 HTMLDocument *doc;
1699 nsIDOMWindow *nswindow = NULL;
1700 HRESULT hres;
1702 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1704 hres = alloc_doc(&doc);
1705 if(FAILED(hres))
1706 return hres;
1708 hres = IHTMLDocument_QueryInterface(HTMLDOC(doc), riid, ppvObject);
1709 IHTMLDocument_Release(HTMLDOC(doc));
1710 if(FAILED(hres))
1711 return hres;
1713 LOCK_MODULE();
1715 doc->nscontainer = NSContainer_Create(doc, NULL);
1716 update_nsdocument(doc);
1718 if(doc->nscontainer) {
1719 nsresult nsres;
1721 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &nswindow);
1722 if(NS_FAILED(nsres))
1723 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1726 hres = HTMLWindow_Create(doc, nswindow, &doc->window);
1727 if(nswindow)
1728 nsIDOMWindow_Release(nswindow);
1729 if(FAILED(hres)) {
1730 IHTMLDocument_Release(HTMLDOC(doc));
1731 return hres;
1734 get_thread_hwnd();
1736 return S_OK;