[MSHTML] Fake Success in HTMLDocument_put_bgColor()
[reactos.git] / dll / win32 / mshtml / htmldoc.c
1 /*
2 * Copyright 2005-2009 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19 #include "mshtml_private.h"
20
21 static HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node, HTMLDocumentNode **ret);
22
23 HRESULT get_doc_elem_by_id(HTMLDocumentNode *doc, const WCHAR *id, HTMLElement **ret)
24 {
25 nsIDOMNodeList *nsnode_list;
26 nsIDOMElement *nselem;
27 nsIDOMNode *nsnode;
28 nsAString id_str;
29 nsresult nsres;
30 HRESULT hres;
31
32 if(!doc->nsdoc) {
33 WARN("NULL nsdoc\n");
34 return E_UNEXPECTED;
35 }
36
37 nsAString_InitDepend(&id_str, id);
38 /* get element by id attribute */
39 nsres = nsIDOMHTMLDocument_GetElementById(doc->nsdoc, &id_str, &nselem);
40 if(FAILED(nsres)) {
41 ERR("GetElementById failed: %08x\n", nsres);
42 nsAString_Finish(&id_str);
43 return E_FAIL;
44 }
45
46 /* get first element by name attribute */
47 nsres = nsIDOMHTMLDocument_GetElementsByName(doc->nsdoc, &id_str, &nsnode_list);
48 nsAString_Finish(&id_str);
49 if(FAILED(nsres)) {
50 ERR("getElementsByName failed: %08x\n", nsres);
51 if(nselem)
52 nsIDOMElement_Release(nselem);
53 return E_FAIL;
54 }
55
56 nsres = nsIDOMNodeList_Item(nsnode_list, 0, &nsnode);
57 nsIDOMNodeList_Release(nsnode_list);
58 assert(nsres == NS_OK);
59
60 if(nsnode && nselem) {
61 UINT16 pos;
62
63 nsres = nsIDOMNode_CompareDocumentPosition(nsnode, (nsIDOMNode*)nselem, &pos);
64 if(NS_FAILED(nsres)) {
65 FIXME("CompareDocumentPosition failed: 0x%08x\n", nsres);
66 nsIDOMNode_Release(nsnode);
67 nsIDOMElement_Release(nselem);
68 return E_FAIL;
69 }
70
71 TRACE("CompareDocumentPosition gave: 0x%x\n", pos);
72 if(!(pos & (DOCUMENT_POSITION_PRECEDING | DOCUMENT_POSITION_CONTAINS))) {
73 nsIDOMElement_Release(nselem);
74 nselem = NULL;
75 }
76 }
77
78 if(nsnode) {
79 if(!nselem) {
80 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMElement, (void**)&nselem);
81 assert(nsres == NS_OK);
82 }
83 nsIDOMNode_Release(nsnode);
84 }
85
86 if(!nselem) {
87 *ret = NULL;
88 return S_OK;
89 }
90
91 hres = get_elem(doc, nselem, ret);
92 nsIDOMElement_Release(nselem);
93 return hres;
94 }
95
96 UINT get_document_charset(HTMLDocumentNode *doc)
97 {
98 nsAString charset_str;
99 UINT ret = 0;
100 nsresult nsres;
101
102 if(doc->charset)
103 return doc->charset;
104
105 nsAString_Init(&charset_str, NULL);
106 nsres = nsIDOMHTMLDocument_GetCharacterSet(doc->nsdoc, &charset_str);
107 if(NS_SUCCEEDED(nsres)) {
108 const PRUnichar *charset;
109
110 nsAString_GetData(&charset_str, &charset);
111
112 if(*charset) {
113 BSTR str = SysAllocString(charset);
114 ret = cp_from_charset_string(str);
115 SysFreeString(str);
116 }
117 }else {
118 ERR("GetCharset failed: %08x\n", nsres);
119 }
120 nsAString_Finish(&charset_str);
121
122 if(!ret)
123 return CP_UTF8;
124
125 return doc->charset = ret;
126 }
127
128 static inline HTMLDocument *impl_from_IHTMLDocument2(IHTMLDocument2 *iface)
129 {
130 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument2_iface);
131 }
132
133 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppv)
134 {
135 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
136
137 return htmldoc_query_interface(This, riid, ppv);
138 }
139
140 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
141 {
142 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
143
144 return htmldoc_addref(This);
145 }
146
147 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
148 {
149 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
150
151 return htmldoc_release(This);
152 }
153
154 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
155 {
156 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
157
158 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
159 }
160
161 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
162 LCID lcid, ITypeInfo **ppTInfo)
163 {
164 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
165
166 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
167 }
168
169 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
170 LPOLESTR *rgszNames, UINT cNames,
171 LCID lcid, DISPID *rgDispId)
172 {
173 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
174
175 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
176 rgDispId);
177 }
178
179 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
180 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
181 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
182 {
183 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
184
185 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
186 pDispParams, pVarResult, pExcepInfo, puArgErr);
187 }
188
189 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
190 {
191 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
192
193 TRACE("(%p)->(%p)\n", This, p);
194
195 *p = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
196 IDispatch_AddRef(*p);
197 return S_OK;
198 }
199
200 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
201 {
202 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
203 nsIDOMElement *nselem = NULL;
204 HTMLDOMNode *node;
205 nsresult nsres;
206 HRESULT hres;
207
208 TRACE("(%p)->(%p)\n", This, p);
209
210 if(!This->doc_node->nsdoc) {
211 WARN("NULL nsdoc\n");
212 return E_UNEXPECTED;
213 }
214
215 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
216 if(NS_FAILED(nsres)) {
217 ERR("GetDocumentElement failed: %08x\n", nsres);
218 return E_FAIL;
219 }
220
221 if(!nselem) {
222 *p = NULL;
223 return S_OK;
224 }
225
226 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
227 nsIDOMElement_Release(nselem);
228 if(FAILED(hres))
229 return hres;
230
231 *p = create_all_collection(node, TRUE);
232 node_release(node);
233 return hres;
234 }
235
236 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
237 {
238 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
239 nsIDOMHTMLElement *nsbody = NULL;
240 HTMLDOMNode *node;
241 HRESULT hres;
242
243 TRACE("(%p)->(%p)\n", This, p);
244
245 if(This->doc_node->nsdoc) {
246 nsresult nsres;
247
248 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
249 if(NS_FAILED(nsres)) {
250 TRACE("Could not get body: %08x\n", nsres);
251 return E_UNEXPECTED;
252 }
253 }
254
255 if(!nsbody) {
256 *p = NULL;
257 return S_OK;
258 }
259
260 hres = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE, &node);
261 nsIDOMHTMLElement_Release(nsbody);
262 if(FAILED(hres))
263 return hres;
264
265 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
266 node_release(node);
267 return hres;
268 }
269
270 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
271 {
272 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
273 nsIDOMElement *nselem;
274 HTMLElement *elem;
275 nsresult nsres;
276 HRESULT hres;
277
278 TRACE("(%p)->(%p)\n", This, p);
279
280 if(!This->doc_node->nsdoc) {
281 *p = NULL;
282 return S_OK;
283 }
284
285 /*
286 * NOTE: Gecko may return an active element even if the document is not visible.
287 * IE returns NULL in this case.
288 */
289 nsres = nsIDOMHTMLDocument_GetActiveElement(This->doc_node->nsdoc, &nselem);
290 if(NS_FAILED(nsres)) {
291 ERR("GetActiveElement failed: %08x\n", nsres);
292 return E_FAIL;
293 }
294
295 if(!nselem) {
296 *p = NULL;
297 return S_OK;
298 }
299
300 hres = get_elem(This->doc_node, nselem, &elem);
301 nsIDOMElement_Release(nselem);
302 if(FAILED(hres))
303 return hres;
304
305 *p = &elem->IHTMLElement_iface;
306 return S_OK;
307 }
308
309 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
310 {
311 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
312 nsIDOMHTMLCollection *nscoll = NULL;
313 nsresult nsres;
314
315 TRACE("(%p)->(%p)\n", This, p);
316
317 if(!p)
318 return E_INVALIDARG;
319
320 *p = NULL;
321
322 if(!This->doc_node->nsdoc) {
323 WARN("NULL nsdoc\n");
324 return E_UNEXPECTED;
325 }
326
327 nsres = nsIDOMHTMLDocument_GetImages(This->doc_node->nsdoc, &nscoll);
328 if(NS_FAILED(nsres)) {
329 ERR("GetImages failed: %08x\n", nsres);
330 return E_FAIL;
331 }
332
333 if(nscoll) {
334 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
335 nsIDOMHTMLCollection_Release(nscoll);
336 }
337
338 return S_OK;
339 }
340
341 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
342 {
343 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
344 nsIDOMHTMLCollection *nscoll = NULL;
345 nsresult nsres;
346
347 TRACE("(%p)->(%p)\n", This, p);
348
349 if(!p)
350 return E_INVALIDARG;
351
352 *p = NULL;
353
354 if(!This->doc_node->nsdoc) {
355 WARN("NULL nsdoc\n");
356 return E_UNEXPECTED;
357 }
358
359 nsres = nsIDOMHTMLDocument_GetApplets(This->doc_node->nsdoc, &nscoll);
360 if(NS_FAILED(nsres)) {
361 ERR("GetApplets failed: %08x\n", nsres);
362 return E_FAIL;
363 }
364
365 if(nscoll) {
366 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
367 nsIDOMHTMLCollection_Release(nscoll);
368 }
369
370 return S_OK;
371 }
372
373 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
374 {
375 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
376 nsIDOMHTMLCollection *nscoll = NULL;
377 nsresult nsres;
378
379 TRACE("(%p)->(%p)\n", This, p);
380
381 if(!p)
382 return E_INVALIDARG;
383
384 *p = NULL;
385
386 if(!This->doc_node->nsdoc) {
387 WARN("NULL nsdoc\n");
388 return E_UNEXPECTED;
389 }
390
391 nsres = nsIDOMHTMLDocument_GetLinks(This->doc_node->nsdoc, &nscoll);
392 if(NS_FAILED(nsres)) {
393 ERR("GetLinks failed: %08x\n", nsres);
394 return E_FAIL;
395 }
396
397 if(nscoll) {
398 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
399 nsIDOMHTMLCollection_Release(nscoll);
400 }
401
402 return S_OK;
403 }
404
405 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
406 {
407 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
408 nsIDOMHTMLCollection *nscoll = NULL;
409 nsresult nsres;
410
411 TRACE("(%p)->(%p)\n", This, p);
412
413 if(!p)
414 return E_INVALIDARG;
415
416 *p = NULL;
417
418 if(!This->doc_node->nsdoc) {
419 WARN("NULL nsdoc\n");
420 return E_UNEXPECTED;
421 }
422
423 nsres = nsIDOMHTMLDocument_GetForms(This->doc_node->nsdoc, &nscoll);
424 if(NS_FAILED(nsres)) {
425 ERR("GetForms failed: %08x\n", nsres);
426 return E_FAIL;
427 }
428
429 if(nscoll) {
430 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
431 nsIDOMHTMLCollection_Release(nscoll);
432 }
433
434 return S_OK;
435 }
436
437 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
438 {
439 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
440 nsIDOMHTMLCollection *nscoll = NULL;
441 nsresult nsres;
442
443 TRACE("(%p)->(%p)\n", This, p);
444
445 if(!p)
446 return E_INVALIDARG;
447
448 *p = NULL;
449
450 if(!This->doc_node->nsdoc) {
451 WARN("NULL nsdoc\n");
452 return E_UNEXPECTED;
453 }
454
455 nsres = nsIDOMHTMLDocument_GetAnchors(This->doc_node->nsdoc, &nscoll);
456 if(NS_FAILED(nsres)) {
457 ERR("GetAnchors failed: %08x\n", nsres);
458 return E_FAIL;
459 }
460
461 if(nscoll) {
462 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
463 nsIDOMHTMLCollection_Release(nscoll);
464 }
465
466 return S_OK;
467 }
468
469 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
470 {
471 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
472 nsAString nsstr;
473 nsresult nsres;
474
475 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
476
477 if(!This->doc_node->nsdoc) {
478 WARN("NULL nsdoc\n");
479 return E_UNEXPECTED;
480 }
481
482 nsAString_InitDepend(&nsstr, v);
483 nsres = nsIDOMHTMLDocument_SetTitle(This->doc_node->nsdoc, &nsstr);
484 nsAString_Finish(&nsstr);
485 if(NS_FAILED(nsres))
486 ERR("SetTitle failed: %08x\n", nsres);
487
488 return S_OK;
489 }
490
491 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
492 {
493 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
494 const PRUnichar *ret;
495 nsAString nsstr;
496 nsresult nsres;
497
498 TRACE("(%p)->(%p)\n", This, p);
499
500 if(!This->doc_node->nsdoc) {
501 WARN("NULL nsdoc\n");
502 return E_UNEXPECTED;
503 }
504
505
506 nsAString_Init(&nsstr, NULL);
507 nsres = nsIDOMHTMLDocument_GetTitle(This->doc_node->nsdoc, &nsstr);
508 if (NS_SUCCEEDED(nsres)) {
509 nsAString_GetData(&nsstr, &ret);
510 *p = SysAllocString(ret);
511 }
512 nsAString_Finish(&nsstr);
513
514 if(NS_FAILED(nsres)) {
515 ERR("GetTitle failed: %08x\n", nsres);
516 return E_FAIL;
517 }
518
519 return S_OK;
520 }
521
522 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
523 {
524 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
525 nsIDOMHTMLCollection *nscoll = NULL;
526 nsresult nsres;
527
528 TRACE("(%p)->(%p)\n", This, p);
529
530 if(!p)
531 return E_INVALIDARG;
532
533 *p = NULL;
534
535 if(!This->doc_node->nsdoc) {
536 WARN("NULL nsdoc\n");
537 return E_UNEXPECTED;
538 }
539
540 nsres = nsIDOMHTMLDocument_GetScripts(This->doc_node->nsdoc, &nscoll);
541 if(NS_FAILED(nsres)) {
542 ERR("GetImages failed: %08x\n", nsres);
543 return E_FAIL;
544 }
545
546 if(nscoll) {
547 *p = create_collection_from_htmlcol(This->doc_node, nscoll);
548 nsIDOMHTMLCollection_Release(nscoll);
549 }
550
551 return S_OK;
552 }
553
554 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
555 {
556 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
557 HRESULT hres;
558
559 static const WCHAR onW[] = {'o','n',0};
560
561 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
562
563 if(strcmpiW(v, onW)) {
564 FIXME("Unsupported arg %s\n", debugstr_w(v));
565 return E_NOTIMPL;
566 }
567
568 hres = setup_edit_mode(This->doc_obj);
569 if(FAILED(hres))
570 return hres;
571
572 call_property_onchanged(&This->cp_container, DISPID_IHTMLDOCUMENT2_DESIGNMODE);
573 return S_OK;
574 }
575
576 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
577 {
578 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
579 static const WCHAR szOff[] = {'O','f','f',0};
580 FIXME("(%p)->(%p) always returning Off\n", This, p);
581
582 if(!p)
583 return E_INVALIDARG;
584
585 *p = SysAllocString(szOff);
586
587 return S_OK;
588 }
589
590 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
591 {
592 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
593 nsISelection *nsselection;
594 nsresult nsres;
595
596 TRACE("(%p)->(%p)\n", This, p);
597
598 nsres = nsIDOMWindow_GetSelection(This->window->nswindow, &nsselection);
599 if(NS_FAILED(nsres)) {
600 ERR("GetSelection failed: %08x\n", nsres);
601 return E_FAIL;
602 }
603
604 return HTMLSelectionObject_Create(This->doc_node, nsselection, p);
605 }
606
607 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
608 {
609 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
610
611
612 TRACE("(%p)->(%p)\n", iface, p);
613
614 if(!p)
615 return E_POINTER;
616
617 return get_readystate_string(This->window->readystate, p);
618 }
619
620 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
621 {
622 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
623
624 TRACE("(%p)->(%p)\n", This, p);
625
626 return IHTMLWindow2_get_frames(&This->window->base.IHTMLWindow2_iface, p);
627 }
628
629 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
630 {
631 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
632 FIXME("(%p)->(%p)\n", This, p);
633 return E_NOTIMPL;
634 }
635
636 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
637 {
638 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
639 FIXME("(%p)->(%p)\n", This, p);
640 return E_NOTIMPL;
641 }
642
643 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
644 {
645 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
646 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
647 return E_NOTIMPL;
648 }
649
650 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
651 {
652 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
653 FIXME("(%p)->(%p)\n", This, p);
654 return E_NOTIMPL;
655 }
656
657 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
658 {
659 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
660 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
661 #ifdef __REACTOS__
662 return S_OK;
663 #else
664 return E_NOTIMPL;
665 #endif
666 }
667
668 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
669 {
670 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
671 FIXME("(%p)->(%p)\n", This, p);
672 return E_NOTIMPL;
673 }
674
675 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
676 {
677 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
678 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
679 return E_NOTIMPL;
680 }
681
682 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
683 {
684 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
685 FIXME("(%p)->(%p)\n", This, p);
686 return E_NOTIMPL;
687 }
688
689 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
690 {
691 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
692 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
693 return E_NOTIMPL;
694 }
695
696 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
697 {
698 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
699 FIXME("(%p)->(%p)\n", This, p);
700 return E_NOTIMPL;
701 }
702
703 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
704 {
705 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
706 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
707 return E_NOTIMPL;
708 }
709
710 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
711 {
712 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
713 FIXME("(%p)->(%p)\n", This, p);
714 return E_NOTIMPL;
715 }
716
717 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
718 {
719 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
720
721 FIXME("(%p)->(%p)\n", This, p);
722
723 *p = NULL;
724 return S_OK;
725 }
726
727 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
728 {
729 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
730
731 TRACE("(%p)->(%p)\n", This, p);
732
733 if(!This->doc_node->nsdoc) {
734 WARN("NULL nsdoc\n");
735 return E_UNEXPECTED;
736 }
737
738 return IHTMLWindow2_get_location(&This->window->base.IHTMLWindow2_iface, p);
739 }
740
741 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
742 {
743 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
744 FIXME("(%p)->(%p)\n", This, p);
745 return E_NOTIMPL;
746 }
747
748 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
749 {
750 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
751
752 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
753
754 if(!This->window) {
755 FIXME("No window available\n");
756 return E_FAIL;
757 }
758
759 return navigate_url(This->window, v, This->window->uri, BINDING_NAVIGATED);
760 }
761
762 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
763 {
764 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
765
766 static const WCHAR about_blank_url[] =
767 {'a','b','o','u','t',':','b','l','a','n','k',0};
768
769 TRACE("(%p)->(%p)\n", iface, p);
770
771 *p = SysAllocString(This->window->url ? This->window->url : about_blank_url);
772 return *p ? S_OK : E_OUTOFMEMORY;
773 }
774
775 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
776 {
777 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
778 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
779 return E_NOTIMPL;
780 }
781
782 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
783 {
784 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
785 HRESULT hres;
786
787 TRACE("(%p)->(%p)\n", This, p);
788
789 if(!This->window || !This->window->uri) {
790 FIXME("No current URI\n");
791 return E_FAIL;
792 }
793
794 hres = IUri_GetHost(This->window->uri, p);
795 return FAILED(hres) ? hres : S_OK;
796 }
797
798 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
799 {
800 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
801 BOOL bret;
802
803 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
804
805 bret = InternetSetCookieExW(This->window->url, NULL, v, 0, 0);
806 if(!bret) {
807 FIXME("InternetSetCookieExW failed: %u\n", GetLastError());
808 return HRESULT_FROM_WIN32(GetLastError());
809 }
810
811 return S_OK;
812 }
813
814 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
815 {
816 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
817 DWORD size;
818 BOOL bret;
819
820 TRACE("(%p)->(%p)\n", This, p);
821
822 size = 0;
823 bret = InternetGetCookieExW(This->window->url, NULL, NULL, &size, 0, NULL);
824 if(!bret) {
825 switch(GetLastError()) {
826 case ERROR_INSUFFICIENT_BUFFER:
827 break;
828 case ERROR_NO_MORE_ITEMS:
829 *p = NULL;
830 return S_OK;
831 default:
832 FIXME("InternetGetCookieExW failed: %u\n", GetLastError());
833 return HRESULT_FROM_WIN32(GetLastError());
834 }
835 }
836
837 if(!size) {
838 *p = NULL;
839 return S_OK;
840 }
841
842 *p = SysAllocStringLen(NULL, size/sizeof(WCHAR)-1);
843 if(!*p)
844 return E_OUTOFMEMORY;
845
846 bret = InternetGetCookieExW(This->window->url, NULL, *p, &size, 0, NULL);
847 if(!bret) {
848 ERR("InternetGetCookieExW failed: %u\n", GetLastError());
849 return E_FAIL;
850 }
851
852 return S_OK;
853 }
854
855 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
856 {
857 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
858 FIXME("(%p)->(%x)\n", This, v);
859 return E_NOTIMPL;
860 }
861
862 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
863 {
864 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
865 FIXME("(%p)->(%p)\n", This, p);
866 return E_NOTIMPL;
867 }
868
869 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
870 {
871 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
872 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
873 return E_NOTIMPL;
874 }
875
876 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
877 {
878 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
879 nsAString charset_str;
880 nsresult nsres;
881
882 TRACE("(%p)->(%p)\n", This, p);
883
884 if(!This->doc_node->nsdoc) {
885 FIXME("NULL nsdoc\n");
886 return E_FAIL;
887 }
888
889 nsAString_Init(&charset_str, NULL);
890 nsres = nsIDOMHTMLDocument_GetCharacterSet(This->doc_node->nsdoc, &charset_str);
891 return return_nsstr(nsres, &charset_str, p);
892 }
893
894 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
895 {
896 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
897 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
898 return E_NOTIMPL;
899 }
900
901 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
902 {
903 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
904 FIXME("(%p)->(%p)\n", This, p);
905 return E_NOTIMPL;
906 }
907
908 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
909 {
910 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
911 FIXME("(%p)->(%p)\n", This, p);
912 return E_NOTIMPL;
913 }
914
915 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
916 {
917 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
918 FIXME("(%p)->(%p)\n", This, p);
919 return E_NOTIMPL;
920 }
921
922 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
923 {
924 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
925 FIXME("(%p)->(%p)\n", This, p);
926 return E_NOTIMPL;
927 }
928
929 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
930 {
931 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
932 FIXME("(%p)->(%p)\n", This, p);
933 return E_NOTIMPL;
934 }
935
936 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
937 {
938 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
939 FIXME("(%p)->(%p)\n", This, p);
940 return E_NOTIMPL;
941 }
942
943 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
944 {
945 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
946 FIXME("(%p)->(%p)\n", This, p);
947 return E_NOTIMPL;
948 }
949
950 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
951 {
952 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
953 FIXME("(%p)->(%p)\n", This, p);
954 return E_NOTIMPL;
955 }
956
957 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
958 {
959 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
960 FIXME("(%p)->(%p)\n", This, p);
961 return E_NOTIMPL;
962 }
963
964 static HRESULT document_write(HTMLDocument *This, SAFEARRAY *psarray, BOOL ln)
965 {
966 VARIANT *var, tmp;
967 JSContext *jsctx;
968 nsAString nsstr;
969 ULONG i, argc;
970 nsresult nsres;
971 HRESULT hres;
972
973 if(!This->doc_node->nsdoc) {
974 WARN("NULL nsdoc\n");
975 return E_UNEXPECTED;
976 }
977
978 if (!psarray)
979 return S_OK;
980
981 if(psarray->cDims != 1) {
982 FIXME("cDims=%d\n", psarray->cDims);
983 return E_INVALIDARG;
984 }
985
986 hres = SafeArrayAccessData(psarray, (void**)&var);
987 if(FAILED(hres)) {
988 WARN("SafeArrayAccessData failed: %08x\n", hres);
989 return hres;
990 }
991
992 V_VT(&tmp) = VT_EMPTY;
993
994 jsctx = get_context_from_document(This->doc_node->nsdoc);
995 argc = psarray->rgsabound[0].cElements;
996 for(i=0; i < argc; i++) {
997 if(V_VT(var+i) == VT_BSTR) {
998 nsAString_InitDepend(&nsstr, V_BSTR(var+i));
999 }else {
1000 hres = VariantChangeTypeEx(&tmp, var+i, MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, VT_BSTR);
1001 if(FAILED(hres)) {
1002 WARN("Could not convert %s to string\n", debugstr_variant(var+i));
1003 break;
1004 }
1005 nsAString_InitDepend(&nsstr, V_BSTR(&tmp));
1006 }
1007
1008 if(!ln || i != argc-1)
1009 nsres = nsIDOMHTMLDocument_Write(This->doc_node->nsdoc, &nsstr, jsctx);
1010 else
1011 nsres = nsIDOMHTMLDocument_Writeln(This->doc_node->nsdoc, &nsstr, jsctx);
1012 nsAString_Finish(&nsstr);
1013 if(V_VT(var+i) != VT_BSTR)
1014 VariantClear(&tmp);
1015 if(NS_FAILED(nsres)) {
1016 ERR("Write failed: %08x\n", nsres);
1017 hres = E_FAIL;
1018 break;
1019 }
1020 }
1021
1022 SafeArrayUnaccessData(psarray);
1023
1024 return hres;
1025 }
1026
1027 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1028 {
1029 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1030
1031 TRACE("(%p)->(%p)\n", iface, psarray);
1032
1033 return document_write(This, psarray, FALSE);
1034 }
1035
1036 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
1037 {
1038 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1039
1040 TRACE("(%p)->(%p)\n", This, psarray);
1041
1042 return document_write(This, psarray, TRUE);
1043 }
1044
1045 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
1046 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
1047 {
1048 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1049 nsISupports *tmp;
1050 nsresult nsres;
1051
1052 static const WCHAR text_htmlW[] = {'t','e','x','t','/','h','t','m','l',0};
1053
1054 TRACE("(%p)->(%s %s %s %s %p)\n", This, debugstr_w(url), debugstr_variant(&name),
1055 debugstr_variant(&features), debugstr_variant(&replace), pomWindowResult);
1056
1057 if(!This->doc_node->nsdoc) {
1058 ERR("!nsdoc\n");
1059 return E_NOTIMPL;
1060 }
1061
1062 if(!url || strcmpW(url, text_htmlW) || V_VT(&name) != VT_ERROR
1063 || V_VT(&features) != VT_ERROR || V_VT(&replace) != VT_ERROR)
1064 FIXME("unsupported args\n");
1065
1066 nsres = nsIDOMHTMLDocument_Open(This->doc_node->nsdoc, NULL, NULL, NULL,
1067 get_context_from_document(This->doc_node->nsdoc), 0, &tmp);
1068 if(NS_FAILED(nsres)) {
1069 ERR("Open failed: %08x\n", nsres);
1070 return E_FAIL;
1071 }
1072
1073 if(tmp)
1074 nsISupports_Release(tmp);
1075
1076 *pomWindowResult = (IDispatch*)&This->window->base.IHTMLWindow2_iface;
1077 IHTMLWindow2_AddRef(&This->window->base.IHTMLWindow2_iface);
1078 return S_OK;
1079 }
1080
1081 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
1082 {
1083 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1084 nsresult nsres;
1085
1086 TRACE("(%p)\n", This);
1087
1088 if(!This->doc_node->nsdoc) {
1089 ERR("!nsdoc\n");
1090 return E_NOTIMPL;
1091 }
1092
1093 nsres = nsIDOMHTMLDocument_Close(This->doc_node->nsdoc);
1094 if(NS_FAILED(nsres)) {
1095 ERR("Close failed: %08x\n", nsres);
1096 return E_FAIL;
1097 }
1098
1099 return S_OK;
1100 }
1101
1102 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
1103 {
1104 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1105 nsresult nsres;
1106
1107 TRACE("(%p)\n", This);
1108
1109 nsres = nsIDOMHTMLDocument_Clear(This->doc_node->nsdoc);
1110 if(NS_FAILED(nsres)) {
1111 ERR("Clear failed: %08x\n", nsres);
1112 return E_FAIL;
1113 }
1114
1115 return S_OK;
1116 }
1117
1118 static const WCHAR copyW[] =
1119 {'c','o','p','y',0};
1120 static const WCHAR cutW[] =
1121 {'c','u','t',0};
1122 static const WCHAR fontnameW[] =
1123 {'f','o','n','t','n','a','m','e',0};
1124 static const WCHAR fontsizeW[] =
1125 {'f','o','n','t','s','i','z','e',0};
1126 static const WCHAR indentW[] =
1127 {'i','n','d','e','n','t',0};
1128 static const WCHAR insertorderedlistW[] =
1129 {'i','n','s','e','r','t','o','r','d','e','r','e','d','l','i','s','t',0};
1130 static const WCHAR insertunorderedlistW[] =
1131 {'i','n','s','e','r','t','u','n','o','r','d','e','r','e','d','l','i','s','t',0};
1132 static const WCHAR outdentW[] =
1133 {'o','u','t','d','e','n','t',0};
1134 static const WCHAR pasteW[] =
1135 {'p','a','s','t','e',0};
1136 static const WCHAR respectvisibilityindesignW[] =
1137 {'r','e','s','p','e','c','t','v','i','s','i','b','i','l','i','t','y','i','n','d','e','s','i','g','n',0};
1138
1139 static const struct {
1140 const WCHAR *name;
1141 OLECMDID id;
1142 }command_names[] = {
1143 {copyW, IDM_COPY},
1144 {cutW, IDM_CUT},
1145 {fontnameW, IDM_FONTNAME},
1146 {fontsizeW, IDM_FONTSIZE},
1147 {indentW, IDM_INDENT},
1148 {insertorderedlistW, IDM_ORDERLIST},
1149 {insertunorderedlistW, IDM_UNORDERLIST},
1150 {outdentW, IDM_OUTDENT},
1151 {pasteW, IDM_PASTE},
1152 {respectvisibilityindesignW, IDM_RESPECTVISIBILITY_INDESIGN}
1153 };
1154
1155 static BOOL cmdid_from_string(const WCHAR *str, OLECMDID *cmdid)
1156 {
1157 int i;
1158
1159 for(i = 0; i < sizeof(command_names)/sizeof(*command_names); i++) {
1160 if(!strcmpiW(command_names[i].name, str)) {
1161 *cmdid = command_names[i].id;
1162 return TRUE;
1163 }
1164 }
1165
1166 FIXME("Unknown command %s\n", debugstr_w(str));
1167 return FALSE;
1168 }
1169
1170 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
1171 VARIANT_BOOL *pfRet)
1172 {
1173 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1174 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1175 return E_NOTIMPL;
1176 }
1177
1178 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
1179 VARIANT_BOOL *pfRet)
1180 {
1181 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1182 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1183 return E_NOTIMPL;
1184 }
1185
1186 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
1187 VARIANT_BOOL *pfRet)
1188 {
1189 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1190 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1191 return E_NOTIMPL;
1192 }
1193
1194 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
1195 VARIANT_BOOL *pfRet)
1196 {
1197 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1198 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1199 return E_NOTIMPL;
1200 }
1201
1202 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
1203 BSTR *pfRet)
1204 {
1205 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1206 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1207 return E_NOTIMPL;
1208 }
1209
1210 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
1211 VARIANT *pfRet)
1212 {
1213 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1214 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1215 return E_NOTIMPL;
1216 }
1217
1218 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
1219 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
1220 {
1221 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1222 OLECMDID cmdid;
1223 VARIANT ret;
1224 HRESULT hres;
1225
1226 TRACE("(%p)->(%s %x %s %p)\n", This, debugstr_w(cmdID), showUI, debugstr_variant(&value), pfRet);
1227
1228 if(!cmdid_from_string(cmdID, &cmdid))
1229 return OLECMDERR_E_NOTSUPPORTED;
1230
1231 V_VT(&ret) = VT_EMPTY;
1232 hres = IOleCommandTarget_Exec(&This->IOleCommandTarget_iface, &CGID_MSHTML, cmdid,
1233 showUI ? 0 : OLECMDEXECOPT_DONTPROMPTUSER, &value, &ret);
1234 if(FAILED(hres))
1235 return hres;
1236
1237 if(V_VT(&ret) != VT_EMPTY) {
1238 FIXME("Handle ret %s\n", debugstr_variant(&ret));
1239 VariantClear(&ret);
1240 }
1241
1242 *pfRet = VARIANT_TRUE;
1243 return S_OK;
1244 }
1245
1246 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
1247 VARIANT_BOOL *pfRet)
1248 {
1249 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1250 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
1251 return E_NOTIMPL;
1252 }
1253
1254 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
1255 IHTMLElement **newElem)
1256 {
1257 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1258 HTMLElement *elem;
1259 HRESULT hres;
1260
1261 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
1262
1263 hres = create_element(This->doc_node, eTag, &elem);
1264 if(FAILED(hres))
1265 return hres;
1266
1267 *newElem = &elem->IHTMLElement_iface;
1268 return S_OK;
1269 }
1270
1271 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
1272 {
1273 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1274 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1275 return E_NOTIMPL;
1276 }
1277
1278 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
1279 {
1280 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1281 FIXME("(%p)->(%p)\n", This, p);
1282 return E_NOTIMPL;
1283 }
1284
1285 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
1286 {
1287 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1288
1289 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1290
1291 return set_doc_event(This, EVENTID_CLICK, &v);
1292 }
1293
1294 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
1295 {
1296 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1297
1298 TRACE("(%p)->(%p)\n", This, p);
1299
1300 return get_doc_event(This, EVENTID_CLICK, p);
1301 }
1302
1303 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
1304 {
1305 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1306
1307 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1308
1309 return set_doc_event(This, EVENTID_DBLCLICK, &v);
1310 }
1311
1312 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
1313 {
1314 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1315
1316 TRACE("(%p)->(%p)\n", This, p);
1317
1318 return get_doc_event(This, EVENTID_DBLCLICK, p);
1319 }
1320
1321 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
1322 {
1323 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1324
1325 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1326
1327 return set_doc_event(This, EVENTID_KEYUP, &v);
1328 }
1329
1330 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
1331 {
1332 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1333
1334 TRACE("(%p)->(%p)\n", This, p);
1335
1336 return get_doc_event(This, EVENTID_KEYUP, p);
1337 }
1338
1339 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
1340 {
1341 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1342
1343 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1344
1345 return set_doc_event(This, EVENTID_KEYDOWN, &v);
1346 }
1347
1348 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
1349 {
1350 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1351
1352 TRACE("(%p)->(%p)\n", This, p);
1353
1354 return get_doc_event(This, EVENTID_KEYDOWN, p);
1355 }
1356
1357 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
1358 {
1359 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1360
1361 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1362
1363 return set_doc_event(This, EVENTID_KEYPRESS, &v);
1364 }
1365
1366 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
1367 {
1368 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1369
1370 TRACE("(%p)->(%p)\n", This, p);
1371
1372 return get_doc_event(This, EVENTID_KEYPRESS, p);
1373 }
1374
1375 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
1376 {
1377 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1378
1379 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1380
1381 return set_doc_event(This, EVENTID_MOUSEUP, &v);
1382 }
1383
1384 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1385 {
1386 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1387
1388 TRACE("(%p)->(%p)\n", This, p);
1389
1390 return get_doc_event(This, EVENTID_MOUSEUP, p);
1391 }
1392
1393 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1394 {
1395 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1396
1397 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1398
1399 return set_doc_event(This, EVENTID_MOUSEDOWN, &v);
1400 }
1401
1402 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1403 {
1404 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1405
1406 TRACE("(%p)->(%p)\n", This, p);
1407
1408 return get_doc_event(This, EVENTID_MOUSEDOWN, p);
1409 }
1410
1411 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1412 {
1413 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1414
1415 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1416
1417 return set_doc_event(This, EVENTID_MOUSEMOVE, &v);
1418 }
1419
1420 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1421 {
1422 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1423
1424 TRACE("(%p)->(%p)\n", This, p);
1425
1426 return get_doc_event(This, EVENTID_MOUSEMOVE, p);
1427 }
1428
1429 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1430 {
1431 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1432
1433 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1434
1435 return set_doc_event(This, EVENTID_MOUSEOUT, &v);
1436 }
1437
1438 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1439 {
1440 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1441
1442 TRACE("(%p)->(%p)\n", This, p);
1443
1444 return get_doc_event(This, EVENTID_MOUSEOUT, p);
1445 }
1446
1447 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1448 {
1449 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1450
1451 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1452
1453 return set_doc_event(This, EVENTID_MOUSEOVER, &v);
1454 }
1455
1456 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1457 {
1458 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1459
1460 TRACE("(%p)->(%p)\n", This, p);
1461
1462 return get_doc_event(This, EVENTID_MOUSEOVER, p);
1463 }
1464
1465 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1466 {
1467 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1468
1469 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1470
1471 return set_doc_event(This, EVENTID_READYSTATECHANGE, &v);
1472 }
1473
1474 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1475 {
1476 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1477
1478 TRACE("(%p)->(%p)\n", This, p);
1479
1480 return get_doc_event(This, EVENTID_READYSTATECHANGE, p);
1481 }
1482
1483 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1484 {
1485 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1486 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1487 return E_NOTIMPL;
1488 }
1489
1490 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1491 {
1492 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1493 FIXME("(%p)->(%p)\n", This, p);
1494 return E_NOTIMPL;
1495 }
1496
1497 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1498 {
1499 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1500 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1501 return E_NOTIMPL;
1502 }
1503
1504 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1505 {
1506 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1507 FIXME("(%p)->(%p)\n", This, p);
1508 return E_NOTIMPL;
1509 }
1510
1511 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1512 {
1513 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1514 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1515 return E_NOTIMPL;
1516 }
1517
1518 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1519 {
1520 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1521 FIXME("(%p)->(%p)\n", This, p);
1522 return E_NOTIMPL;
1523 }
1524
1525 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1526 {
1527 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1528
1529 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1530
1531 return set_doc_event(This, EVENTID_DRAGSTART, &v);
1532 }
1533
1534 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1535 {
1536 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1537
1538 TRACE("(%p)->(%p)\n", This, p);
1539
1540 return get_doc_event(This, EVENTID_DRAGSTART, p);
1541 }
1542
1543 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1544 {
1545 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1546
1547 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1548
1549 return set_doc_event(This, EVENTID_SELECTSTART, &v);
1550 }
1551
1552 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1553 {
1554 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1555
1556 TRACE("(%p)->(%p)\n", This, p);
1557
1558 return get_doc_event(This, EVENTID_SELECTSTART, p);
1559 }
1560
1561 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, LONG x, LONG y,
1562 IHTMLElement **elementHit)
1563 {
1564 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1565 nsIDOMElement *nselem;
1566 HTMLDOMNode *node;
1567 nsresult nsres;
1568 HRESULT hres;
1569
1570 TRACE("(%p)->(%d %d %p)\n", This, x, y, elementHit);
1571
1572 nsres = nsIDOMHTMLDocument_ElementFromPoint(This->doc_node->nsdoc, x, y, &nselem);
1573 if(NS_FAILED(nsres)) {
1574 ERR("ElementFromPoint failed: %08x\n", nsres);
1575 return E_FAIL;
1576 }
1577
1578 if(!nselem) {
1579 *elementHit = NULL;
1580 return S_OK;
1581 }
1582
1583 hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
1584 nsIDOMElement_Release(nselem);
1585 if(FAILED(hres))
1586 return hres;
1587
1588 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)elementHit);
1589 node_release(node);
1590 return hres;
1591 }
1592
1593 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1594 {
1595 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1596
1597 TRACE("(%p)->(%p)\n", This, p);
1598
1599 *p = &This->window->base.IHTMLWindow2_iface;
1600 IHTMLWindow2_AddRef(*p);
1601 return S_OK;
1602 }
1603
1604 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1605 IHTMLStyleSheetsCollection **p)
1606 {
1607 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1608 nsIDOMStyleSheetList *nsstylelist;
1609 nsresult nsres;
1610
1611 TRACE("(%p)->(%p)\n", This, p);
1612
1613 *p = NULL;
1614
1615 if(!This->doc_node->nsdoc) {
1616 WARN("NULL nsdoc\n");
1617 return E_UNEXPECTED;
1618 }
1619
1620 nsres = nsIDOMHTMLDocument_GetStyleSheets(This->doc_node->nsdoc, &nsstylelist);
1621 if(NS_FAILED(nsres)) {
1622 ERR("GetStyleSheets failed: %08x\n", nsres);
1623 return E_FAIL;
1624 }
1625
1626 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1627 nsIDOMStyleSheetList_Release(nsstylelist);
1628
1629 return S_OK;
1630 }
1631
1632 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1633 {
1634 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1635 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1636 return E_NOTIMPL;
1637 }
1638
1639 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1640 {
1641 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1642 FIXME("(%p)->(%p)\n", This, p);
1643 return E_NOTIMPL;
1644 }
1645
1646 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1647 {
1648 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1649 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1650 return E_NOTIMPL;
1651 }
1652
1653 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1654 {
1655 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1656 FIXME("(%p)->(%p)\n", This, p);
1657 return E_NOTIMPL;
1658 }
1659
1660 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1661 {
1662 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1663
1664 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1665
1666 TRACE("(%p)->(%p)\n", This, String);
1667
1668 if(!String)
1669 return E_INVALIDARG;
1670
1671 *String = SysAllocString(objectW);
1672 return *String ? S_OK : E_OUTOFMEMORY;
1673
1674 }
1675
1676 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1677 LONG lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1678 {
1679 HTMLDocument *This = impl_from_IHTMLDocument2(iface);
1680 nsIDOMHTMLHeadElement *head_elem;
1681 IHTMLStyleElement *style_elem;
1682 HTMLElement *elem;
1683 nsresult nsres;
1684 HRESULT hres;
1685
1686 static const WCHAR styleW[] = {'s','t','y','l','e',0};
1687
1688 TRACE("(%p)->(%s %d %p)\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1689
1690 if(!This->doc_node->nsdoc) {
1691 FIXME("not a real doc object\n");
1692 return E_NOTIMPL;
1693 }
1694
1695 if(lIndex != -1)
1696 FIXME("Unsupported lIndex %d\n", lIndex);
1697
1698 if(bstrHref && *bstrHref) {
1699 FIXME("semi-stub for href %s\n", debugstr_w(bstrHref));
1700 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1701 return S_OK;
1702 }
1703
1704 hres = create_element(This->doc_node, styleW, &elem);
1705 if(FAILED(hres))
1706 return hres;
1707
1708 nsres = nsIDOMHTMLDocument_GetHead(This->doc_node->nsdoc, &head_elem);
1709 if(NS_SUCCEEDED(nsres)) {
1710 nsIDOMNode *head_node, *tmp_node;
1711
1712 nsres = nsIDOMHTMLHeadElement_QueryInterface(head_elem, &IID_nsIDOMNode, (void**)&head_node);
1713 nsIDOMHTMLHeadElement_Release(head_elem);
1714 assert(nsres == NS_OK);
1715
1716 nsres = nsIDOMNode_AppendChild(head_node, elem->node.nsnode, &tmp_node);
1717 nsIDOMNode_Release(head_node);
1718 if(NS_SUCCEEDED(nsres) && tmp_node)
1719 nsIDOMNode_Release(tmp_node);
1720 }
1721 if(NS_FAILED(nsres)) {
1722 IHTMLElement_Release(&elem->IHTMLElement_iface);
1723 return E_FAIL;
1724 }
1725
1726 hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLStyleElement, (void**)&style_elem);
1727 assert(hres == S_OK);
1728 IHTMLElement_Release(&elem->IHTMLElement_iface);
1729
1730 hres = IHTMLStyleElement_get_styleSheet(style_elem, ppnewStyleSheet);
1731 IHTMLStyleElement_Release(style_elem);
1732 return hres;
1733 }
1734
1735 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1736 HTMLDocument_QueryInterface,
1737 HTMLDocument_AddRef,
1738 HTMLDocument_Release,
1739 HTMLDocument_GetTypeInfoCount,
1740 HTMLDocument_GetTypeInfo,
1741 HTMLDocument_GetIDsOfNames,
1742 HTMLDocument_Invoke,
1743 HTMLDocument_get_Script,
1744 HTMLDocument_get_all,
1745 HTMLDocument_get_body,
1746 HTMLDocument_get_activeElement,
1747 HTMLDocument_get_images,
1748 HTMLDocument_get_applets,
1749 HTMLDocument_get_links,
1750 HTMLDocument_get_forms,
1751 HTMLDocument_get_anchors,
1752 HTMLDocument_put_title,
1753 HTMLDocument_get_title,
1754 HTMLDocument_get_scripts,
1755 HTMLDocument_put_designMode,
1756 HTMLDocument_get_designMode,
1757 HTMLDocument_get_selection,
1758 HTMLDocument_get_readyState,
1759 HTMLDocument_get_frames,
1760 HTMLDocument_get_embeds,
1761 HTMLDocument_get_plugins,
1762 HTMLDocument_put_alinkColor,
1763 HTMLDocument_get_alinkColor,
1764 HTMLDocument_put_bgColor,
1765 HTMLDocument_get_bgColor,
1766 HTMLDocument_put_fgColor,
1767 HTMLDocument_get_fgColor,
1768 HTMLDocument_put_linkColor,
1769 HTMLDocument_get_linkColor,
1770 HTMLDocument_put_vlinkColor,
1771 HTMLDocument_get_vlinkColor,
1772 HTMLDocument_get_referrer,
1773 HTMLDocument_get_location,
1774 HTMLDocument_get_lastModified,
1775 HTMLDocument_put_URL,
1776 HTMLDocument_get_URL,
1777 HTMLDocument_put_domain,
1778 HTMLDocument_get_domain,
1779 HTMLDocument_put_cookie,
1780 HTMLDocument_get_cookie,
1781 HTMLDocument_put_expando,
1782 HTMLDocument_get_expando,
1783 HTMLDocument_put_charset,
1784 HTMLDocument_get_charset,
1785 HTMLDocument_put_defaultCharset,
1786 HTMLDocument_get_defaultCharset,
1787 HTMLDocument_get_mimeType,
1788 HTMLDocument_get_fileSize,
1789 HTMLDocument_get_fileCreatedDate,
1790 HTMLDocument_get_fileModifiedDate,
1791 HTMLDocument_get_fileUpdatedDate,
1792 HTMLDocument_get_security,
1793 HTMLDocument_get_protocol,
1794 HTMLDocument_get_nameProp,
1795 HTMLDocument_write,
1796 HTMLDocument_writeln,
1797 HTMLDocument_open,
1798 HTMLDocument_close,
1799 HTMLDocument_clear,
1800 HTMLDocument_queryCommandSupported,
1801 HTMLDocument_queryCommandEnabled,
1802 HTMLDocument_queryCommandState,
1803 HTMLDocument_queryCommandIndeterm,
1804 HTMLDocument_queryCommandText,
1805 HTMLDocument_queryCommandValue,
1806 HTMLDocument_execCommand,
1807 HTMLDocument_execCommandShowHelp,
1808 HTMLDocument_createElement,
1809 HTMLDocument_put_onhelp,
1810 HTMLDocument_get_onhelp,
1811 HTMLDocument_put_onclick,
1812 HTMLDocument_get_onclick,
1813 HTMLDocument_put_ondblclick,
1814 HTMLDocument_get_ondblclick,
1815 HTMLDocument_put_onkeyup,
1816 HTMLDocument_get_onkeyup,
1817 HTMLDocument_put_onkeydown,
1818 HTMLDocument_get_onkeydown,
1819 HTMLDocument_put_onkeypress,
1820 HTMLDocument_get_onkeypress,
1821 HTMLDocument_put_onmouseup,
1822 HTMLDocument_get_onmouseup,
1823 HTMLDocument_put_onmousedown,
1824 HTMLDocument_get_onmousedown,
1825 HTMLDocument_put_onmousemove,
1826 HTMLDocument_get_onmousemove,
1827 HTMLDocument_put_onmouseout,
1828 HTMLDocument_get_onmouseout,
1829 HTMLDocument_put_onmouseover,
1830 HTMLDocument_get_onmouseover,
1831 HTMLDocument_put_onreadystatechange,
1832 HTMLDocument_get_onreadystatechange,
1833 HTMLDocument_put_onafterupdate,
1834 HTMLDocument_get_onafterupdate,
1835 HTMLDocument_put_onrowexit,
1836 HTMLDocument_get_onrowexit,
1837 HTMLDocument_put_onrowenter,
1838 HTMLDocument_get_onrowenter,
1839 HTMLDocument_put_ondragstart,
1840 HTMLDocument_get_ondragstart,
1841 HTMLDocument_put_onselectstart,
1842 HTMLDocument_get_onselectstart,
1843 HTMLDocument_elementFromPoint,
1844 HTMLDocument_get_parentWindow,
1845 HTMLDocument_get_styleSheets,
1846 HTMLDocument_put_onbeforeupdate,
1847 HTMLDocument_get_onbeforeupdate,
1848 HTMLDocument_put_onerrorupdate,
1849 HTMLDocument_get_onerrorupdate,
1850 HTMLDocument_toString,
1851 HTMLDocument_createStyleSheet
1852 };
1853
1854 static inline HTMLDocument *impl_from_IHTMLDocument3(IHTMLDocument3 *iface)
1855 {
1856 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument3_iface);
1857 }
1858
1859 static HRESULT WINAPI HTMLDocument3_QueryInterface(IHTMLDocument3 *iface,
1860 REFIID riid, void **ppv)
1861 {
1862 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1863 return htmldoc_query_interface(This, riid, ppv);
1864 }
1865
1866 static ULONG WINAPI HTMLDocument3_AddRef(IHTMLDocument3 *iface)
1867 {
1868 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1869 return htmldoc_addref(This);
1870 }
1871
1872 static ULONG WINAPI HTMLDocument3_Release(IHTMLDocument3 *iface)
1873 {
1874 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1875 return htmldoc_release(This);
1876 }
1877
1878 static HRESULT WINAPI HTMLDocument3_GetTypeInfoCount(IHTMLDocument3 *iface, UINT *pctinfo)
1879 {
1880 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1881 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1882 }
1883
1884 static HRESULT WINAPI HTMLDocument3_GetTypeInfo(IHTMLDocument3 *iface, UINT iTInfo,
1885 LCID lcid, ITypeInfo **ppTInfo)
1886 {
1887 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1888 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1889 }
1890
1891 static HRESULT WINAPI HTMLDocument3_GetIDsOfNames(IHTMLDocument3 *iface, REFIID riid,
1892 LPOLESTR *rgszNames, UINT cNames,
1893 LCID lcid, DISPID *rgDispId)
1894 {
1895 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1896 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1897 rgDispId);
1898 }
1899
1900 static HRESULT WINAPI HTMLDocument3_Invoke(IHTMLDocument3 *iface, DISPID dispIdMember,
1901 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1902 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1903 {
1904 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1905 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1906 pDispParams, pVarResult, pExcepInfo, puArgErr);
1907 }
1908
1909 static HRESULT WINAPI HTMLDocument3_releaseCapture(IHTMLDocument3 *iface)
1910 {
1911 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1912 FIXME("(%p)\n", This);
1913 return E_NOTIMPL;
1914 }
1915
1916 static HRESULT WINAPI HTMLDocument3_recalc(IHTMLDocument3 *iface, VARIANT_BOOL fForce)
1917 {
1918 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1919
1920 WARN("(%p)->(%x)\n", This, fForce);
1921
1922 /* Doing nothing here should be fine for us. */
1923 return S_OK;
1924 }
1925
1926 static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR text,
1927 IHTMLDOMNode **newTextNode)
1928 {
1929 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1930 nsIDOMText *nstext;
1931 HTMLDOMNode *node;
1932 nsAString text_str;
1933 nsresult nsres;
1934 HRESULT hres;
1935
1936 TRACE("(%p)->(%s %p)\n", This, debugstr_w(text), newTextNode);
1937
1938 if(!This->doc_node->nsdoc) {
1939 WARN("NULL nsdoc\n");
1940 return E_UNEXPECTED;
1941 }
1942
1943 nsAString_InitDepend(&text_str, text);
1944 nsres = nsIDOMHTMLDocument_CreateTextNode(This->doc_node->nsdoc, &text_str, &nstext);
1945 nsAString_Finish(&text_str);
1946 if(NS_FAILED(nsres)) {
1947 ERR("CreateTextNode failed: %08x\n", nsres);
1948 return E_FAIL;
1949 }
1950
1951 hres = HTMLDOMTextNode_Create(This->doc_node, (nsIDOMNode*)nstext, &node);
1952 nsIDOMText_Release(nstext);
1953 if(FAILED(hres))
1954 return hres;
1955
1956 *newTextNode = &node->IHTMLDOMNode_iface;
1957 return S_OK;
1958 }
1959
1960 static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, IHTMLElement **p)
1961 {
1962 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
1963 nsIDOMElement *nselem = NULL;
1964 HTMLDOMNode *node;
1965 nsresult nsres;
1966 HRESULT hres;
1967
1968 TRACE("(%p)->(%p)\n", This, p);
1969
1970 if(This->window->readystate == READYSTATE_UNINITIALIZED) {
1971 *p = NULL;
1972 return S_OK;
1973 }
1974
1975 if(!This->doc_node->nsdoc) {
1976 WARN("NULL nsdoc\n");
1977 return E_UNEXPECTED;
1978 }
1979
1980 nsres = nsIDOMHTMLDocument_GetDocumentElement(This->doc_node->nsdoc, &nselem);
1981 if(NS_FAILED(nsres)) {
1982 ERR("GetDocumentElement failed: %08x\n", nsres);
1983 return E_FAIL;
1984 }
1985
1986 if(!nselem) {
1987 *p = NULL;
1988 return S_OK;
1989 }
1990
1991 hres = get_node(This->doc_node, (nsIDOMNode *)nselem, TRUE, &node);
1992 nsIDOMElement_Release(nselem);
1993 if(FAILED(hres))
1994 return hres;
1995
1996 hres = IHTMLDOMNode_QueryInterface(&node->IHTMLDOMNode_iface, &IID_IHTMLElement, (void**)p);
1997 node_release(node);
1998 return hres;
1999 }
2000
2001 static HRESULT WINAPI HTMLDocument3_uniqueID(IHTMLDocument3 *iface, BSTR *p)
2002 {
2003 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2004 FIXME("(%p)->(%p)\n", This, p);
2005 return E_NOTIMPL;
2006 }
2007
2008 static HRESULT WINAPI HTMLDocument3_attachEvent(IHTMLDocument3 *iface, BSTR event,
2009 IDispatch* pDisp, VARIANT_BOOL *pfResult)
2010 {
2011 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2012
2013 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
2014
2015 return attach_event(&This->doc_node->node.event_target, event, pDisp, pfResult);
2016 }
2017
2018 static HRESULT WINAPI HTMLDocument3_detachEvent(IHTMLDocument3 *iface, BSTR event,
2019 IDispatch *pDisp)
2020 {
2021 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2022
2023 TRACE("(%p)->(%s %p)\n", This, debugstr_w(event), pDisp);
2024
2025 return detach_event(&This->doc_node->node.event_target, event, pDisp);
2026 }
2027
2028 static HRESULT WINAPI HTMLDocument3_put_onrowsdelete(IHTMLDocument3 *iface, VARIANT v)
2029 {
2030 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2031 FIXME("(%p)->()\n", This);
2032 return E_NOTIMPL;
2033 }
2034
2035 static HRESULT WINAPI HTMLDocument3_get_onrowsdelete(IHTMLDocument3 *iface, VARIANT *p)
2036 {
2037 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2038 FIXME("(%p)->(%p)\n", This, p);
2039 return E_NOTIMPL;
2040 }
2041
2042 static HRESULT WINAPI HTMLDocument3_put_onrowsinserted(IHTMLDocument3 *iface, VARIANT v)
2043 {
2044 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2045 FIXME("(%p)->()\n", This);
2046 return E_NOTIMPL;
2047 }
2048
2049 static HRESULT WINAPI HTMLDocument3_get_onrowsinserted(IHTMLDocument3 *iface, VARIANT *p)
2050 {
2051 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2052 FIXME("(%p)->(%p)\n", This, p);
2053 return E_NOTIMPL;
2054 }
2055
2056 static HRESULT WINAPI HTMLDocument3_put_oncellchange(IHTMLDocument3 *iface, VARIANT v)
2057 {
2058 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2059 FIXME("(%p)->()\n", This);
2060 return E_NOTIMPL;
2061 }
2062
2063 static HRESULT WINAPI HTMLDocument3_get_oncellchange(IHTMLDocument3 *iface, VARIANT *p)
2064 {
2065 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2066 FIXME("(%p)->(%p)\n", This, p);
2067 return E_NOTIMPL;
2068 }
2069
2070 static HRESULT WINAPI HTMLDocument3_put_ondatasetchanged(IHTMLDocument3 *iface, VARIANT v)
2071 {
2072 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2073 FIXME("(%p)->()\n", This);
2074 return E_NOTIMPL;
2075 }
2076
2077 static HRESULT WINAPI HTMLDocument3_get_ondatasetchanged(IHTMLDocument3 *iface, VARIANT *p)
2078 {
2079 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2080 FIXME("(%p)->(%p)\n", This, p);
2081 return E_NOTIMPL;
2082 }
2083
2084 static HRESULT WINAPI HTMLDocument3_put_ondataavailable(IHTMLDocument3 *iface, VARIANT v)
2085 {
2086 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2087 FIXME("(%p)->()\n", This);
2088 return E_NOTIMPL;
2089 }
2090
2091 static HRESULT WINAPI HTMLDocument3_get_ondataavailable(IHTMLDocument3 *iface, VARIANT *p)
2092 {
2093 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2094 FIXME("(%p)->(%p)\n", This, p);
2095 return E_NOTIMPL;
2096 }
2097
2098 static HRESULT WINAPI HTMLDocument3_put_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT v)
2099 {
2100 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2101 FIXME("(%p)->()\n", This);
2102 return E_NOTIMPL;
2103 }
2104
2105 static HRESULT WINAPI HTMLDocument3_get_ondatasetcomplete(IHTMLDocument3 *iface, VARIANT *p)
2106 {
2107 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2108 FIXME("(%p)->(%p)\n", This, p);
2109 return E_NOTIMPL;
2110 }
2111
2112 static HRESULT WINAPI HTMLDocument3_put_onpropertychange(IHTMLDocument3 *iface, VARIANT v)
2113 {
2114 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2115 FIXME("(%p)->()\n", This);
2116 return E_NOTIMPL;
2117 }
2118
2119 static HRESULT WINAPI HTMLDocument3_get_onpropertychange(IHTMLDocument3 *iface, VARIANT *p)
2120 {
2121 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2122 FIXME("(%p)->(%p)\n", This, p);
2123 return E_NOTIMPL;
2124 }
2125
2126 static HRESULT WINAPI HTMLDocument3_put_dir(IHTMLDocument3 *iface, BSTR v)
2127 {
2128 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2129 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2130 return E_NOTIMPL;
2131 }
2132
2133 static HRESULT WINAPI HTMLDocument3_get_dir(IHTMLDocument3 *iface, BSTR *p)
2134 {
2135 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2136 FIXME("(%p)->(%p)\n", This, p);
2137 return E_NOTIMPL;
2138 }
2139
2140 static HRESULT WINAPI HTMLDocument3_put_oncontextmenu(IHTMLDocument3 *iface, VARIANT v)
2141 {
2142 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2143
2144 TRACE("(%p)->()\n", This);
2145
2146 return set_doc_event(This, EVENTID_CONTEXTMENU, &v);
2147 }
2148
2149 static HRESULT WINAPI HTMLDocument3_get_oncontextmenu(IHTMLDocument3 *iface, VARIANT *p)
2150 {
2151 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2152
2153 TRACE("(%p)->(%p)\n", This, p);
2154
2155 return get_doc_event(This, EVENTID_CONTEXTMENU, p);
2156 }
2157
2158 static HRESULT WINAPI HTMLDocument3_put_onstop(IHTMLDocument3 *iface, VARIANT v)
2159 {
2160 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2161 FIXME("(%p)->()\n", This);
2162 return E_NOTIMPL;
2163 }
2164
2165 static HRESULT WINAPI HTMLDocument3_get_onstop(IHTMLDocument3 *iface, VARIANT *p)
2166 {
2167 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2168 FIXME("(%p)->(%p)\n", This, p);
2169 return E_NOTIMPL;
2170 }
2171
2172 static HRESULT WINAPI HTMLDocument3_createDocumentFragment(IHTMLDocument3 *iface,
2173 IHTMLDocument2 **ppNewDoc)
2174 {
2175 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2176 nsIDOMDocumentFragment *doc_frag;
2177 HTMLDocumentNode *docnode;
2178 nsresult nsres;
2179 HRESULT hres;
2180
2181 TRACE("(%p)->(%p)\n", This, ppNewDoc);
2182
2183 if(!This->doc_node->nsdoc) {
2184 FIXME("NULL nsdoc\n");
2185 return E_NOTIMPL;
2186 }
2187
2188 nsres = nsIDOMHTMLDocument_CreateDocumentFragment(This->doc_node->nsdoc, &doc_frag);
2189 if(NS_FAILED(nsres)) {
2190 ERR("CreateDocumentFragment failed: %08x\n", nsres);
2191 return E_FAIL;
2192 }
2193
2194 hres = create_document_fragment((nsIDOMNode*)doc_frag, This->doc_node, &docnode);
2195 nsIDOMDocumentFragment_Release(doc_frag);
2196 if(FAILED(hres))
2197 return hres;
2198
2199 *ppNewDoc = &docnode->basedoc.IHTMLDocument2_iface;
2200 return S_OK;
2201 }
2202
2203 static HRESULT WINAPI HTMLDocument3_get_parentDocument(IHTMLDocument3 *iface,
2204 IHTMLDocument2 **p)
2205 {
2206 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2207 FIXME("(%p)->(%p)\n", This, p);
2208 return E_NOTIMPL;
2209 }
2210
2211 static HRESULT WINAPI HTMLDocument3_put_enableDownload(IHTMLDocument3 *iface,
2212 VARIANT_BOOL v)
2213 {
2214 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2215 FIXME("(%p)->(%x)\n", This, v);
2216 return E_NOTIMPL;
2217 }
2218
2219 static HRESULT WINAPI HTMLDocument3_get_enableDownload(IHTMLDocument3 *iface,
2220 VARIANT_BOOL *p)
2221 {
2222 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2223 FIXME("(%p)->(%p)\n", This, p);
2224 return E_NOTIMPL;
2225 }
2226
2227 static HRESULT WINAPI HTMLDocument3_put_baseUrl(IHTMLDocument3 *iface, BSTR v)
2228 {
2229 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2230 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2231 return E_NOTIMPL;
2232 }
2233
2234 static HRESULT WINAPI HTMLDocument3_get_baseUrl(IHTMLDocument3 *iface, BSTR *p)
2235 {
2236 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2237 FIXME("(%p)->(%p)\n", This, p);
2238 return E_NOTIMPL;
2239 }
2240
2241 static HRESULT WINAPI HTMLDocument3_get_childNodes(IHTMLDocument3 *iface, IDispatch **p)
2242 {
2243 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2244
2245 TRACE("(%p)->(%p)\n", This, p);
2246
2247 return IHTMLDOMNode_get_childNodes(&This->doc_node->node.IHTMLDOMNode_iface, p);
2248 }
2249
2250 static HRESULT WINAPI HTMLDocument3_put_inheritStyleSheets(IHTMLDocument3 *iface,
2251 VARIANT_BOOL v)
2252 {
2253 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2254 FIXME("(%p)->()\n", This);
2255 return E_NOTIMPL;
2256 }
2257
2258 static HRESULT WINAPI HTMLDocument3_get_inheritStyleSheets(IHTMLDocument3 *iface,
2259 VARIANT_BOOL *p)
2260 {
2261 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2262 FIXME("(%p)->(%p)\n", This, p);
2263 return E_NOTIMPL;
2264 }
2265
2266 static HRESULT WINAPI HTMLDocument3_put_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT v)
2267 {
2268 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2269 FIXME("(%p)->()\n", This);
2270 return E_NOTIMPL;
2271 }
2272
2273 static HRESULT WINAPI HTMLDocument3_get_onbeforeeditfocus(IHTMLDocument3 *iface, VARIANT *p)
2274 {
2275 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2276 FIXME("(%p)->(%p)\n", This, p);
2277 return E_NOTIMPL;
2278 }
2279
2280 static HRESULT WINAPI HTMLDocument3_getElementsByName(IHTMLDocument3 *iface, BSTR v,
2281 IHTMLElementCollection **ppelColl)
2282 {
2283 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2284 nsIDOMNodeList *node_list;
2285 nsAString selector_str;
2286 WCHAR *selector;
2287 nsresult nsres;
2288
2289 static const WCHAR formatW[] = {'*','[','i','d','=','%','s',']',',','*','[','n','a','m','e','=','%','s',']',0};
2290
2291 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), ppelColl);
2292
2293 if(!This->doc_node || !This->doc_node->nsdoc) {
2294 /* We should probably return an empty collection. */
2295 FIXME("No nsdoc\n");
2296 return E_NOTIMPL;
2297 }
2298
2299 selector = heap_alloc(2*SysStringLen(v)*sizeof(WCHAR) + sizeof(formatW));
2300 if(!selector)
2301 return E_OUTOFMEMORY;
2302 sprintfW(selector, formatW, v, v);
2303
2304 /*
2305 * NOTE: IE getElementsByName implementation differs from Gecko. It searches both name and id attributes.
2306 * That's why we use CSS selector instead. We should also use name only when it applies to given element
2307 * types and search should be case insensitive. Those are currently not supported properly.
2308 */
2309 nsAString_InitDepend(&selector_str, selector);
2310 nsres = nsIDOMHTMLDocument_QuerySelectorAll(This->doc_node->nsdoc, &selector_str, &node_list);
2311 nsAString_Finish(&selector_str);
2312 heap_free(selector);
2313 if(NS_FAILED(nsres)) {
2314 ERR("QuerySelectorAll failed: %08x\n", nsres);
2315 return E_FAIL;
2316 }
2317
2318 *ppelColl = create_collection_from_nodelist(This->doc_node, node_list);
2319 nsIDOMNodeList_Release(node_list);
2320 return S_OK;
2321 }
2322
2323
2324 static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v,
2325 IHTMLElement **pel)
2326 {
2327 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2328 HTMLElement *elem;
2329 HRESULT hres;
2330
2331 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
2332
2333 hres = get_doc_elem_by_id(This->doc_node, v, &elem);
2334 if(FAILED(hres) || !elem) {
2335 *pel = NULL;
2336 return hres;
2337 }
2338
2339 *pel = &elem->IHTMLElement_iface;
2340 return S_OK;
2341 }
2342
2343
2344 static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface, BSTR v,
2345 IHTMLElementCollection **pelColl)
2346 {
2347 HTMLDocument *This = impl_from_IHTMLDocument3(iface);
2348 nsIDOMNodeList *nslist;
2349 nsAString id_str;
2350 nsresult nsres;
2351
2352 TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pelColl);
2353
2354 if(!This->doc_node->nsdoc) {
2355 WARN("NULL nsdoc\n");
2356 return E_UNEXPECTED;
2357 }
2358
2359 nsAString_InitDepend(&id_str, v);
2360 nsres = nsIDOMHTMLDocument_GetElementsByTagName(This->doc_node->nsdoc, &id_str, &nslist);
2361 nsAString_Finish(&id_str);
2362 if(FAILED(nsres)) {
2363 ERR("GetElementByName failed: %08x\n", nsres);
2364 return E_FAIL;
2365 }
2366
2367 *pelColl = create_collection_from_nodelist(This->doc_node, nslist);
2368 nsIDOMNodeList_Release(nslist);
2369
2370 return S_OK;
2371 }
2372
2373 static const IHTMLDocument3Vtbl HTMLDocument3Vtbl = {
2374 HTMLDocument3_QueryInterface,
2375 HTMLDocument3_AddRef,
2376 HTMLDocument3_Release,
2377 HTMLDocument3_GetTypeInfoCount,
2378 HTMLDocument3_GetTypeInfo,
2379 HTMLDocument3_GetIDsOfNames,
2380 HTMLDocument3_Invoke,
2381 HTMLDocument3_releaseCapture,
2382 HTMLDocument3_recalc,
2383 HTMLDocument3_createTextNode,
2384 HTMLDocument3_get_documentElement,
2385 HTMLDocument3_uniqueID,
2386 HTMLDocument3_attachEvent,
2387 HTMLDocument3_detachEvent,
2388 HTMLDocument3_put_onrowsdelete,
2389 HTMLDocument3_get_onrowsdelete,
2390 HTMLDocument3_put_onrowsinserted,
2391 HTMLDocument3_get_onrowsinserted,
2392 HTMLDocument3_put_oncellchange,
2393 HTMLDocument3_get_oncellchange,
2394 HTMLDocument3_put_ondatasetchanged,
2395 HTMLDocument3_get_ondatasetchanged,
2396 HTMLDocument3_put_ondataavailable,
2397 HTMLDocument3_get_ondataavailable,
2398 HTMLDocument3_put_ondatasetcomplete,
2399 HTMLDocument3_get_ondatasetcomplete,
2400 HTMLDocument3_put_onpropertychange,
2401 HTMLDocument3_get_onpropertychange,
2402 HTMLDocument3_put_dir,
2403 HTMLDocument3_get_dir,
2404 HTMLDocument3_put_oncontextmenu,
2405 HTMLDocument3_get_oncontextmenu,
2406 HTMLDocument3_put_onstop,
2407 HTMLDocument3_get_onstop,
2408 HTMLDocument3_createDocumentFragment,
2409 HTMLDocument3_get_parentDocument,
2410 HTMLDocument3_put_enableDownload,
2411 HTMLDocument3_get_enableDownload,
2412 HTMLDocument3_put_baseUrl,
2413 HTMLDocument3_get_baseUrl,
2414 HTMLDocument3_get_childNodes,
2415 HTMLDocument3_put_inheritStyleSheets,
2416 HTMLDocument3_get_inheritStyleSheets,
2417 HTMLDocument3_put_onbeforeeditfocus,
2418 HTMLDocument3_get_onbeforeeditfocus,
2419 HTMLDocument3_getElementsByName,
2420 HTMLDocument3_getElementById,
2421 HTMLDocument3_getElementsByTagName
2422 };
2423
2424 static inline HTMLDocument *impl_from_IHTMLDocument4(IHTMLDocument4 *iface)
2425 {
2426 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument4_iface);
2427 }
2428
2429 static HRESULT WINAPI HTMLDocument4_QueryInterface(IHTMLDocument4 *iface,
2430 REFIID riid, void **ppv)
2431 {
2432 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2433 return htmldoc_query_interface(This, riid, ppv);
2434 }
2435
2436 static ULONG WINAPI HTMLDocument4_AddRef(IHTMLDocument4 *iface)
2437 {
2438 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2439 return htmldoc_addref(This);
2440 }
2441
2442 static ULONG WINAPI HTMLDocument4_Release(IHTMLDocument4 *iface)
2443 {
2444 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2445 return htmldoc_release(This);
2446 }
2447
2448 static HRESULT WINAPI HTMLDocument4_GetTypeInfoCount(IHTMLDocument4 *iface, UINT *pctinfo)
2449 {
2450 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2451 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2452 }
2453
2454 static HRESULT WINAPI HTMLDocument4_GetTypeInfo(IHTMLDocument4 *iface, UINT iTInfo,
2455 LCID lcid, ITypeInfo **ppTInfo)
2456 {
2457 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2458 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2459 }
2460
2461 static HRESULT WINAPI HTMLDocument4_GetIDsOfNames(IHTMLDocument4 *iface, REFIID riid,
2462 LPOLESTR *rgszNames, UINT cNames,
2463 LCID lcid, DISPID *rgDispId)
2464 {
2465 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2466 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2467 rgDispId);
2468 }
2469
2470 static HRESULT WINAPI HTMLDocument4_Invoke(IHTMLDocument4 *iface, DISPID dispIdMember,
2471 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2472 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2473 {
2474 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2475 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2476 pDispParams, pVarResult, pExcepInfo, puArgErr);
2477 }
2478
2479 static HRESULT WINAPI HTMLDocument4_focus(IHTMLDocument4 *iface)
2480 {
2481 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2482 nsIDOMHTMLElement *nsbody;
2483 nsresult nsres;
2484
2485 TRACE("(%p)->()\n", This);
2486
2487 nsres = nsIDOMHTMLDocument_GetBody(This->doc_node->nsdoc, &nsbody);
2488 if(NS_FAILED(nsres) || !nsbody) {
2489 ERR("GetBody failed: %08x\n", nsres);
2490 return E_FAIL;
2491 }
2492
2493 nsres = nsIDOMHTMLElement_Focus(nsbody);
2494 nsIDOMHTMLElement_Release(nsbody);
2495 if(NS_FAILED(nsres)) {
2496 ERR("Focus failed: %08x\n", nsres);
2497 return E_FAIL;
2498 }
2499
2500 return S_OK;
2501 }
2502
2503 static HRESULT WINAPI HTMLDocument4_hasFocus(IHTMLDocument4 *iface, VARIANT_BOOL *pfFocus)
2504 {
2505 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2506 FIXME("(%p)->(%p)\n", This, pfFocus);
2507 return E_NOTIMPL;
2508 }
2509
2510 static HRESULT WINAPI HTMLDocument4_put_onselectionchange(IHTMLDocument4 *iface, VARIANT v)
2511 {
2512 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2513 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2514 return E_NOTIMPL;
2515 }
2516
2517 static HRESULT WINAPI HTMLDocument4_get_onselectionchange(IHTMLDocument4 *iface, VARIANT *p)
2518 {
2519 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2520 FIXME("(%p)->(%p)\n", This, p);
2521 return E_NOTIMPL;
2522 }
2523
2524 static HRESULT WINAPI HTMLDocument4_get_namespace(IHTMLDocument4 *iface, IDispatch **p)
2525 {
2526 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2527 FIXME("(%p)->(%p)\n", This, p);
2528 return E_NOTIMPL;
2529 }
2530
2531 static HRESULT WINAPI HTMLDocument4_createDocumentFromUrl(IHTMLDocument4 *iface, BSTR bstrUrl,
2532 BSTR bstrOptions, IHTMLDocument2 **newDoc)
2533 {
2534 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2535 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(bstrUrl), debugstr_w(bstrOptions), newDoc);
2536 return E_NOTIMPL;
2537 }
2538
2539 static HRESULT WINAPI HTMLDocument4_put_media(IHTMLDocument4 *iface, BSTR v)
2540 {
2541 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2542 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
2543 return E_NOTIMPL;
2544 }
2545
2546 static HRESULT WINAPI HTMLDocument4_get_media(IHTMLDocument4 *iface, BSTR *p)
2547 {
2548 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2549 FIXME("(%p)->(%p)\n", This, p);
2550 return E_NOTIMPL;
2551 }
2552
2553 static HRESULT WINAPI HTMLDocument4_createEventObject(IHTMLDocument4 *iface,
2554 VARIANT *pvarEventObject, IHTMLEventObj **ppEventObj)
2555 {
2556 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2557
2558 TRACE("(%p)->(%s %p)\n", This, debugstr_variant(pvarEventObject), ppEventObj);
2559
2560 if(pvarEventObject && V_VT(pvarEventObject) != VT_ERROR && V_VT(pvarEventObject) != VT_EMPTY) {
2561 FIXME("unsupported pvarEventObject %s\n", debugstr_variant(pvarEventObject));
2562 return E_NOTIMPL;
2563 }
2564
2565 return create_event_obj(ppEventObj);
2566 }
2567
2568 static HRESULT WINAPI HTMLDocument4_fireEvent(IHTMLDocument4 *iface, BSTR bstrEventName,
2569 VARIANT *pvarEventObject, VARIANT_BOOL *pfCanceled)
2570 {
2571 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2572
2573 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(bstrEventName), pvarEventObject, pfCanceled);
2574
2575 return dispatch_event(&This->doc_node->node, bstrEventName, pvarEventObject, pfCanceled);
2576 }
2577
2578 static HRESULT WINAPI HTMLDocument4_createRenderStyle(IHTMLDocument4 *iface, BSTR v,
2579 IHTMLRenderStyle **ppIHTMLRenderStyle)
2580 {
2581 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2582 FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), ppIHTMLRenderStyle);
2583 return E_NOTIMPL;
2584 }
2585
2586 static HRESULT WINAPI HTMLDocument4_put_oncontrolselect(IHTMLDocument4 *iface, VARIANT v)
2587 {
2588 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2589 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2590 return E_NOTIMPL;
2591 }
2592
2593 static HRESULT WINAPI HTMLDocument4_get_oncontrolselect(IHTMLDocument4 *iface, VARIANT *p)
2594 {
2595 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2596 FIXME("(%p)->(%p)\n", This, p);
2597 return E_NOTIMPL;
2598 }
2599
2600 static HRESULT WINAPI HTMLDocument4_get_URLEncoded(IHTMLDocument4 *iface, BSTR *p)
2601 {
2602 HTMLDocument *This = impl_from_IHTMLDocument4(iface);
2603 FIXME("(%p)->(%p)\n", This, p);
2604 return E_NOTIMPL;
2605 }
2606
2607 static const IHTMLDocument4Vtbl HTMLDocument4Vtbl = {
2608 HTMLDocument4_QueryInterface,
2609 HTMLDocument4_AddRef,
2610 HTMLDocument4_Release,
2611 HTMLDocument4_GetTypeInfoCount,
2612 HTMLDocument4_GetTypeInfo,
2613 HTMLDocument4_GetIDsOfNames,
2614 HTMLDocument4_Invoke,
2615 HTMLDocument4_focus,
2616 HTMLDocument4_hasFocus,
2617 HTMLDocument4_put_onselectionchange,
2618 HTMLDocument4_get_onselectionchange,
2619 HTMLDocument4_get_namespace,
2620 HTMLDocument4_createDocumentFromUrl,
2621 HTMLDocument4_put_media,
2622 HTMLDocument4_get_media,
2623 HTMLDocument4_createEventObject,
2624 HTMLDocument4_fireEvent,
2625 HTMLDocument4_createRenderStyle,
2626 HTMLDocument4_put_oncontrolselect,
2627 HTMLDocument4_get_oncontrolselect,
2628 HTMLDocument4_get_URLEncoded
2629 };
2630
2631 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
2632 {
2633 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
2634 }
2635
2636 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
2637 REFIID riid, void **ppv)
2638 {
2639 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2640 return htmldoc_query_interface(This, riid, ppv);
2641 }
2642
2643 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
2644 {
2645 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2646 return htmldoc_addref(This);
2647 }
2648
2649 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
2650 {
2651 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2652 return htmldoc_release(This);
2653 }
2654
2655 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
2656 {
2657 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2658 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2659 }
2660
2661 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
2662 LCID lcid, ITypeInfo **ppTInfo)
2663 {
2664 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2665 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2666 }
2667
2668 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
2669 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2670 {
2671 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2672 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2673 rgDispId);
2674 }
2675
2676 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
2677 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2678 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2679 {
2680 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2681 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2682 pDispParams, pVarResult, pExcepInfo, puArgErr);
2683 }
2684
2685 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
2686 {
2687 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2688 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2689 return E_NOTIMPL;
2690 }
2691
2692 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
2693 {
2694 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2695 FIXME("(%p)->(%p)\n", This, p);
2696 return E_NOTIMPL;
2697 }
2698
2699 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
2700 {
2701 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2702 FIXME("(%p)->(%p)\n", This, p);
2703 return E_NOTIMPL;
2704 }
2705
2706 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
2707 {
2708 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2709 HTMLDocumentNode *doc_node = This->doc_node;
2710
2711 TRACE("(%p)->(%p)\n", This, p);
2712
2713 if(!doc_node->dom_implementation) {
2714 HRESULT hres;
2715
2716 hres = create_dom_implementation(&doc_node->dom_implementation);
2717 if(FAILED(hres))
2718 return hres;
2719 }
2720
2721 IHTMLDOMImplementation_AddRef(doc_node->dom_implementation);
2722 *p = doc_node->dom_implementation;
2723 return S_OK;
2724 }
2725
2726 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
2727 IHTMLDOMAttribute **ppattribute)
2728 {
2729 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2730 HTMLDOMAttribute *attr;
2731 HRESULT hres;
2732
2733 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
2734
2735 hres = HTMLDOMAttribute_Create(bstrattrName, NULL, 0, &attr);
2736 if(FAILED(hres))
2737 return hres;
2738
2739 *ppattribute = &attr->IHTMLDOMAttribute_iface;
2740 return S_OK;
2741 }
2742
2743 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
2744 IHTMLDOMNode **ppRetNode)
2745 {
2746 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2747 nsIDOMComment *nscomment;
2748 HTMLElement *elem;
2749 nsAString str;
2750 nsresult nsres;
2751 HRESULT hres;
2752
2753 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
2754
2755 if(!This->doc_node->nsdoc) {
2756 WARN("NULL nsdoc\n");
2757 return E_UNEXPECTED;
2758 }
2759
2760 nsAString_InitDepend(&str, bstrdata);
2761 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
2762 nsAString_Finish(&str);
2763 if(NS_FAILED(nsres)) {
2764 ERR("CreateTextNode failed: %08x\n", nsres);
2765 return E_FAIL;
2766 }
2767
2768 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
2769 nsIDOMComment_Release(nscomment);
2770 if(FAILED(hres))
2771 return hres;
2772
2773 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
2774 return S_OK;
2775 }
2776
2777 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
2778 {
2779 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2780 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2781 return E_NOTIMPL;
2782 }
2783
2784 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
2785 {
2786 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2787 FIXME("(%p)->(%p)\n", This, p);
2788 return E_NOTIMPL;
2789 }
2790
2791 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
2792 {
2793 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2794 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2795 return E_NOTIMPL;
2796 }
2797
2798 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
2799 {
2800 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2801 FIXME("(%p)->(%p)\n", This, p);
2802 return E_NOTIMPL;
2803 }
2804
2805 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
2806 {
2807 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2808 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2809 return E_NOTIMPL;
2810 }
2811
2812 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
2813 {
2814 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2815 FIXME("(%p)->(%p)\n", This, p);
2816 return E_NOTIMPL;
2817 }
2818
2819 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
2820 {
2821 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2822 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2823 return E_NOTIMPL;
2824 }
2825
2826 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
2827 {
2828 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2829 FIXME("(%p)->(%p)\n", This, p);
2830 return E_NOTIMPL;
2831 }
2832
2833 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
2834 {
2835 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2836 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2837 return E_NOTIMPL;
2838 }
2839
2840 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
2841 {
2842 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2843 FIXME("(%p)->(%p)\n", This, p);
2844 return E_NOTIMPL;
2845 }
2846
2847 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
2848 {
2849 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2850 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2851 return E_NOTIMPL;
2852 }
2853
2854 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
2855 {
2856 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2857 FIXME("(%p)->(%p)\n", This, p);
2858 return E_NOTIMPL;
2859 }
2860
2861 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
2862 {
2863 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
2864 nsAString mode_str;
2865 nsresult nsres;
2866
2867 TRACE("(%p)->(%p)\n", This, p);
2868
2869 if(!This->doc_node->nsdoc) {
2870 WARN("NULL nsdoc\n");
2871 return E_UNEXPECTED;
2872 }
2873
2874 nsAString_Init(&mode_str, NULL);
2875 nsres = nsIDOMHTMLDocument_GetCompatMode(This->doc_node->nsdoc, &mode_str);
2876 return return_nsstr(nsres, &mode_str, p);
2877 }
2878
2879 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
2880 HTMLDocument5_QueryInterface,
2881 HTMLDocument5_AddRef,
2882 HTMLDocument5_Release,
2883 HTMLDocument5_GetTypeInfoCount,
2884 HTMLDocument5_GetTypeInfo,
2885 HTMLDocument5_GetIDsOfNames,
2886 HTMLDocument5_Invoke,
2887 HTMLDocument5_put_onmousewheel,
2888 HTMLDocument5_get_onmousewheel,
2889 HTMLDocument5_get_doctype,
2890 HTMLDocument5_get_implementation,
2891 HTMLDocument5_createAttribute,
2892 HTMLDocument5_createComment,
2893 HTMLDocument5_put_onfocusin,
2894 HTMLDocument5_get_onfocusin,
2895 HTMLDocument5_put_onfocusout,
2896 HTMLDocument5_get_onfocusout,
2897 HTMLDocument5_put_onactivate,
2898 HTMLDocument5_get_onactivate,
2899 HTMLDocument5_put_ondeactivate,
2900 HTMLDocument5_get_ondeactivate,
2901 HTMLDocument5_put_onbeforeactivate,
2902 HTMLDocument5_get_onbeforeactivate,
2903 HTMLDocument5_put_onbeforedeactivate,
2904 HTMLDocument5_get_onbeforedeactivate,
2905 HTMLDocument5_get_compatMode
2906 };
2907
2908 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
2909 {
2910 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
2911 }
2912
2913 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
2914 REFIID riid, void **ppv)
2915 {
2916 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2917 return htmldoc_query_interface(This, riid, ppv);
2918 }
2919
2920 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
2921 {
2922 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2923 return htmldoc_addref(This);
2924 }
2925
2926 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
2927 {
2928 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2929 return htmldoc_release(This);
2930 }
2931
2932 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
2933 {
2934 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2935 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
2936 }
2937
2938 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
2939 LCID lcid, ITypeInfo **ppTInfo)
2940 {
2941 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2942 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2943 }
2944
2945 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
2946 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2947 {
2948 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2949 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
2950 rgDispId);
2951 }
2952
2953 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
2954 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2955 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2956 {
2957 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2958 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2959 pDispParams, pVarResult, pExcepInfo, puArgErr);
2960 }
2961
2962 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
2963 IHTMLDocumentCompatibleInfoCollection **p)
2964 {
2965 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2966 FIXME("(%p)->(%p)\n", This, p);
2967 return E_NOTIMPL;
2968 }
2969
2970 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface,
2971 VARIANT *p)
2972 {
2973 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2974 FIXME("(%p)->(%p)\n", This, p);
2975 return E_NOTIMPL;
2976 }
2977
2978 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
2979 VARIANT *p)
2980 {
2981 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2982 FIXME("(%p)->(%p)\n", This, p);
2983 return E_NOTIMPL;
2984 }
2985
2986 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
2987 {
2988 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2989 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
2990 return E_NOTIMPL;
2991 }
2992
2993 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
2994 VARIANT *p)
2995 {
2996 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
2997 FIXME("(%p)->(%p)\n", This, p);
2998 return E_NOTIMPL;
2999 }
3000
3001 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
3002 {
3003 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3004 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3005 return E_NOTIMPL;
3006 }
3007
3008 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
3009 BSTR bstrId, IHTMLElement2 **p)
3010 {
3011 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3012 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
3013 return E_NOTIMPL;
3014 }
3015
3016 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
3017 {
3018 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
3019 FIXME("(%p)->()\n", This);
3020 return E_NOTIMPL;
3021 }
3022
3023 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
3024 HTMLDocument6_QueryInterface,
3025 HTMLDocument6_AddRef,
3026 HTMLDocument6_Release,
3027 HTMLDocument6_GetTypeInfoCount,
3028 HTMLDocument6_GetTypeInfo,
3029 HTMLDocument6_GetIDsOfNames,
3030 HTMLDocument6_Invoke,
3031 HTMLDocument6_get_compatible,
3032 HTMLDocument6_get_documentMode,
3033 HTMLDocument6_put_onstorage,
3034 HTMLDocument6_get_onstorage,
3035 HTMLDocument6_put_onstoragecommit,
3036 HTMLDocument6_get_onstoragecommit,
3037 HTMLDocument6_getElementById,
3038 HTMLDocument6_updateSettings
3039 };
3040
3041 static inline HTMLDocument *impl_from_IHTMLDocument7(IHTMLDocument7 *iface)
3042 {
3043 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument7_iface);
3044 }
3045
3046 static HRESULT WINAPI HTMLDocument7_QueryInterface(IHTMLDocument7 *iface, REFIID riid, void **ppv)
3047 {
3048 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3049 return htmldoc_query_interface(This, riid, ppv);
3050 }
3051
3052 static ULONG WINAPI HTMLDocument7_AddRef(IHTMLDocument7 *iface)
3053 {
3054 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3055 return htmldoc_addref(This);
3056 }
3057
3058 static ULONG WINAPI HTMLDocument7_Release(IHTMLDocument7 *iface)
3059 {
3060 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3061 return htmldoc_release(This);
3062 }
3063
3064 static HRESULT WINAPI HTMLDocument7_GetTypeInfoCount(IHTMLDocument7 *iface, UINT *pctinfo)
3065 {
3066 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3067 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
3068 }
3069
3070 static HRESULT WINAPI HTMLDocument7_GetTypeInfo(IHTMLDocument7 *iface, UINT iTInfo,
3071 LCID lcid, ITypeInfo **ppTInfo)
3072 {
3073 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3074 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
3075 }
3076
3077 static HRESULT WINAPI HTMLDocument7_GetIDsOfNames(IHTMLDocument7 *iface, REFIID riid,
3078 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
3079 {
3080 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3081 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
3082 rgDispId);
3083 }
3084
3085 static HRESULT WINAPI HTMLDocument7_Invoke(IHTMLDocument7 *iface, DISPID dispIdMember,
3086 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
3087 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
3088 {
3089 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3090 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
3091 pDispParams, pVarResult, pExcepInfo, puArgErr);
3092 }
3093
3094 static HRESULT WINAPI HTMLDocument7_get_defaultView(IHTMLDocument7 *iface, IHTMLWindow2 **p)
3095 {
3096 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3097 FIXME("(%p)->(%p)\n", This, p);
3098 return E_NOTIMPL;
3099 }
3100
3101 static HRESULT WINAPI HTMLDocument7_createCDATASection(IHTMLDocument7 *iface, BSTR text, IHTMLDOMNode **newCDATASectionNode)
3102 {
3103 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3104 FIXME("(%p)->(%p)\n", This, newCDATASectionNode);
3105 return E_NOTIMPL;
3106 }
3107
3108 static HRESULT WINAPI HTMLDocument7_getSelection(IHTMLDocument7 *iface, IHTMLSelection **ppIHTMLSelection)
3109 {
3110 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3111 FIXME("(%p)->(%p)\n", This, ppIHTMLSelection);
3112 return E_NOTIMPL;
3113 }
3114
3115 static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3116 BSTR bstrLocalName, IHTMLElementCollection **pelColl)
3117 {
3118 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3119 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrLocalName), pelColl);
3120 return E_NOTIMPL;
3121 }
3122
3123 static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
3124 {
3125 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3126 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
3127 return E_NOTIMPL;
3128 }
3129
3130 static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,
3131 BSTR bstrAttrName, IHTMLDOMAttribute **ppAttribute)
3132 {
3133 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3134 FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrAttrName), ppAttribute);
3135 return E_NOTIMPL;
3136 }
3137
3138 static HRESULT WINAPI HTMLDocument7_put_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT v)
3139 {
3140 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3141 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
3142 return E_NOTIMPL;
3143 }
3144
3145 static HRESULT WINAPI HTMLDocument7_get_onmsthumbnailclick(IHTMLDocument7 *iface, VARIANT *p)
3146 {
3147 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3148 FIXME("(%p)->(%p)\n", This, p);
3149 return E_NOTIMPL;
3150 }
3151
3152 static HRESULT WINAPI HTMLDocument7_get_characterSet(IHTMLDocument7 *iface, BSTR *p)
3153 {
3154 HTMLDocument *This = impl_from_IHTMLDocument7(iface);
3155 FIXME("(%p)->(%p)\n", This, p);
3156 return E_NOTIMPL;
3157 }
3158
3159 static HRESULT WINAPI HTMLDocument7_createElement(IHTMLDocument7 *iface, BSTR bstrTag, IHTMLElement **newElem)
3160 {
3161 HTMLDocument *This =