- Implement ProtocolResetComplete
[reactos.git] / dll / win32 / mshtml / htmldoc.c
1 /*
2 * Copyright 2005 Jacek Caban
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 "config.h"
20
21 #include <stdarg.h>
22 #include <stdio.h>
23
24 #define COBJMACROS
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
30
31 #include "wine/debug.h"
32
33 #include "mshtml_private.h"
34
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36
37 #define HTMLDOC_THIS(iface) DEFINE_THIS(HTMLDocument, HTMLDocument2, iface)
38
39 static HRESULT WINAPI HTMLDocument_QueryInterface(IHTMLDocument2 *iface, REFIID riid, void **ppvObject)
40 {
41 HTMLDocument *This = HTMLDOC_THIS(iface);
42
43 *ppvObject = NULL;
44 if(IsEqualGUID(&IID_IUnknown, riid)) {
45 TRACE("(%p)->(IID_IUnknown, %p)\n", This, ppvObject);
46 *ppvObject = HTMLDOC(This);
47 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
48 TRACE("(%p)->(IID_IDispatch, %p)\n", This, ppvObject);
49 *ppvObject = DISPATCHEX(This);
50 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
51 TRACE("(%p)->(IID_IDispatchEx, %p)\n", This, ppvObject);
52 *ppvObject = DISPATCHEX(This);
53 }else if(IsEqualGUID(&IID_IHTMLDocument, riid)) {
54 TRACE("(%p)->(IID_IHTMLDocument, %p)\n", This, ppvObject);
55 *ppvObject = HTMLDOC(This);
56 }else if(IsEqualGUID(&IID_IHTMLDocument2, riid)) {
57 TRACE("(%p)->(IID_IHTMLDocument2, %p)\n", This, ppvObject);
58 *ppvObject = HTMLDOC(This);
59 }else if(IsEqualGUID(&IID_IHTMLDocument3, riid)) {
60 TRACE("(%p)->(IID_IHTMLDocument3, %p)\n", This, ppvObject);
61 *ppvObject = HTMLDOC3(This);
62 }else if(IsEqualGUID(&IID_IHTMLDocument4, riid)) {
63 TRACE("(%p)->(IID_IHTMLDocument4, %p)\n", This, ppvObject);
64 *ppvObject = HTMLDOC4(This);
65 }else if(IsEqualGUID(&IID_IHTMLDocument5, riid)) {
66 TRACE("(%p)->(IID_IHTMLDocument5, %p)\n", This, ppvObject);
67 *ppvObject = HTMLDOC5(This);
68 }else if(IsEqualGUID(&IID_IPersist, riid)) {
69 TRACE("(%p)->(IID_IPersist, %p)\n", This, ppvObject);
70 *ppvObject = PERSIST(This);
71 }else if(IsEqualGUID(&IID_IPersistMoniker, riid)) {
72 TRACE("(%p)->(IID_IPersistMoniker, %p)\n", This, ppvObject);
73 *ppvObject = PERSISTMON(This);
74 }else if(IsEqualGUID(&IID_IPersistFile, riid)) {
75 TRACE("(%p)->(IID_IPersistFile, %p)\n", This, ppvObject);
76 *ppvObject = PERSISTFILE(This);
77 }else if(IsEqualGUID(&IID_IMonikerProp, riid)) {
78 TRACE("(%p)->(IID_IMonikerProp, %p)\n", This, ppvObject);
79 *ppvObject = MONPROP(This);
80 }else if(IsEqualGUID(&IID_IOleObject, riid)) {
81 TRACE("(%p)->(IID_IOleObject, %p)\n", This, ppvObject);
82 *ppvObject = OLEOBJ(This);
83 }else if(IsEqualGUID(&IID_IOleDocument, riid)) {
84 TRACE("(%p)->(IID_IOleDocument, %p)\n", This, ppvObject);
85 *ppvObject = OLEDOC(This);
86 }else if(IsEqualGUID(&IID_IOleDocumentView, riid)) {
87 TRACE("(%p)->(IID_IOleDocumentView, %p)\n", This, ppvObject);
88 *ppvObject = DOCVIEW(This);
89 }else if(IsEqualGUID(&IID_IOleInPlaceActiveObject, riid)) {
90 TRACE("(%p)->(IID_IOleInPlaceActiveObject, %p)\n", This, ppvObject);
91 *ppvObject = ACTOBJ(This);
92 }else if(IsEqualGUID(&IID_IViewObject, riid)) {
93 TRACE("(%p)->(IID_IViewObject, %p)\n", This, ppvObject);
94 *ppvObject = VIEWOBJ(This);
95 }else if(IsEqualGUID(&IID_IViewObject2, riid)) {
96 TRACE("(%p)->(IID_IViewObject2, %p)\n", This, ppvObject);
97 *ppvObject = VIEWOBJ2(This);
98 }else if(IsEqualGUID(&IID_IOleWindow, riid)) {
99 TRACE("(%p)->(IID_IOleWindow, %p)\n", This, ppvObject);
100 *ppvObject = OLEWIN(This);
101 }else if(IsEqualGUID(&IID_IOleInPlaceObject, riid)) {
102 TRACE("(%p)->(IID_IOleInPlaceObject, %p)\n", This, ppvObject);
103 *ppvObject = INPLACEOBJ(This);
104 }else if(IsEqualGUID(&IID_IOleInPlaceObjectWindowless, riid)) {
105 TRACE("(%p)->(IID_IOleInPlaceObjectWindowless, %p)\n", This, ppvObject);
106 *ppvObject = INPLACEWIN(This);
107 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
108 TRACE("(%p)->(IID_IServiceProvider, %p)\n", This, ppvObject);
109 *ppvObject = SERVPROV(This);
110 }else if(IsEqualGUID(&IID_IOleCommandTarget, riid)) {
111 TRACE("(%p)->(IID_IOleCommandTarget, %p)\n", This, ppvObject);
112 *ppvObject = CMDTARGET(This);
113 }else if(IsEqualGUID(&IID_IOleControl, riid)) {
114 TRACE("(%p)->(IID_IOleControl, %p)\n", This, ppvObject);
115 *ppvObject = CONTROL(This);
116 }else if(IsEqualGUID(&IID_IHlinkTarget, riid)) {
117 TRACE("(%p)->(IID_IHlinkTarget, %p)\n", This, ppvObject);
118 *ppvObject = HLNKTARGET(This);
119 }else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
120 TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppvObject);
121 *ppvObject = CONPTCONT(&This->cp_container);
122 }else if(IsEqualGUID(&IID_IPersistStreamInit, riid)) {
123 TRACE("(%p)->(IID_IPersistStreamInit %p)\n", This, ppvObject);
124 *ppvObject = PERSTRINIT(This);
125 }else if(IsEqualGUID(&IID_ICustomDoc, riid)) {
126 TRACE("(%p)->(IID_ICustomDoc %p)\n", This, ppvObject);
127 *ppvObject = CUSTOMDOC(This);
128 }else if(IsEqualGUID(&DIID_DispHTMLDocument, riid)) {
129 TRACE("(%p)->(DIID_DispHTMLDocument %p)\n", This, ppvObject);
130 *ppvObject = HTMLDOC(This);
131 }else if(IsEqualGUID(&CLSID_CMarkup, riid)) {
132 FIXME("(%p)->(CLSID_CMarkup %p)\n", This, ppvObject);
133 return E_NOINTERFACE;
134 }else if(IsEqualGUID(&IID_IRunnableObject, riid)) {
135 TRACE("(%p)->(IID_IRunnableObject %p) returning NULL\n", This, ppvObject);
136 return E_NOINTERFACE;
137 }else if(IsEqualGUID(&IID_IPersistPropertyBag, riid)) {
138 TRACE("(%p)->(IID_IPersistPropertyBag %p) returning NULL\n", This, ppvObject);
139 return E_NOINTERFACE;
140 }else if(dispex_query_interface(&This->dispex, riid, ppvObject)) {
141 return *ppvObject ? S_OK : E_NOINTERFACE;
142 }
143
144 if(*ppvObject) {
145 IHTMLDocument2_AddRef(iface);
146 return S_OK;
147 }
148
149 FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppvObject);
150 return E_NOINTERFACE;
151 }
152
153 static ULONG WINAPI HTMLDocument_AddRef(IHTMLDocument2 *iface)
154 {
155 HTMLDocument *This = HTMLDOC_THIS(iface);
156 ULONG ref = InterlockedIncrement(&This->ref);
157 TRACE("(%p) ref = %u\n", This, ref);
158 return ref;
159 }
160
161 static ULONG WINAPI HTMLDocument_Release(IHTMLDocument2 *iface)
162 {
163 HTMLDocument *This = HTMLDOC_THIS(iface);
164 ULONG ref = InterlockedDecrement(&This->ref);
165
166 TRACE("(%p) ref = %u\n", This, ref);
167
168 if(!ref) {
169 remove_doc_tasks(This);
170 release_script_hosts(This);
171
172 if(This->client)
173 IOleObject_SetClientSite(OLEOBJ(This), NULL);
174 if(This->in_place_active)
175 IOleInPlaceObjectWindowless_InPlaceDeactivate(INPLACEWIN(This));
176 if(This->ipsite)
177 IOleDocumentView_SetInPlaceSite(DOCVIEW(This), NULL);
178 if(This->undomgr)
179 IOleUndoManager_Release(This->undomgr);
180
181 set_document_bscallback(This, NULL);
182 set_current_mon(This, NULL);
183
184 if(This->tooltips_hwnd)
185 DestroyWindow(This->tooltips_hwnd);
186 if(This->hwnd)
187 DestroyWindow(This->hwnd);
188
189 if(This->option_factory) {
190 This->option_factory->doc = NULL;
191 IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This->option_factory));
192 }
193
194 if(This->location)
195 This->location->doc = NULL;
196
197 if(This->window)
198 IHTMLWindow2_Release(HTMLWINDOW2(This->window));
199
200 heap_free(This->mime);
201 detach_selection(This);
202 detach_ranges(This);
203 release_nodes(This);
204
205 ConnectionPointContainer_Destroy(&This->cp_container);
206
207 if(This->nscontainer)
208 NSContainer_Release(This->nscontainer);
209
210 heap_free(This);
211
212 UNLOCK_MODULE();
213 }
214
215 return ref;
216 }
217
218 static HRESULT WINAPI HTMLDocument_GetTypeInfoCount(IHTMLDocument2 *iface, UINT *pctinfo)
219 {
220 HTMLDocument *This = HTMLDOC_THIS(iface);
221
222 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
223 }
224
225 static HRESULT WINAPI HTMLDocument_GetTypeInfo(IHTMLDocument2 *iface, UINT iTInfo,
226 LCID lcid, ITypeInfo **ppTInfo)
227 {
228 HTMLDocument *This = HTMLDOC_THIS(iface);
229
230 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
231 }
232
233 static HRESULT WINAPI HTMLDocument_GetIDsOfNames(IHTMLDocument2 *iface, REFIID riid,
234 LPOLESTR *rgszNames, UINT cNames,
235 LCID lcid, DISPID *rgDispId)
236 {
237 HTMLDocument *This = HTMLDOC_THIS(iface);
238
239 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
240 }
241
242 static HRESULT WINAPI HTMLDocument_Invoke(IHTMLDocument2 *iface, DISPID dispIdMember,
243 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
244 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
245 {
246 HTMLDocument *This = HTMLDOC_THIS(iface);
247
248 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
249 pVarResult, pExcepInfo, puArgErr);
250 }
251
252 static HRESULT WINAPI HTMLDocument_get_Script(IHTMLDocument2 *iface, IDispatch **p)
253 {
254 HTMLDocument *This = HTMLDOC_THIS(iface);
255 FIXME("(%p)->(%p)\n", This, p);
256 return E_NOTIMPL;
257 }
258
259 static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCollection **p)
260 {
261 HTMLDocument *This = HTMLDOC_THIS(iface);
262 nsIDOMDocument *nsdoc = NULL;
263 nsIDOMElement *nselem = NULL;
264 nsresult nsres;
265
266 TRACE("(%p)->(%p)\n", This, p);
267
268 if(!This->nscontainer) {
269 *p = NULL;
270 return S_OK;
271 }
272
273 nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
274 if(NS_FAILED(nsres))
275 ERR("GetDocument failed: %08x\n", nsres);
276
277 if(nsdoc) {
278 nsres = nsIDOMHTMLDocument_GetDocumentElement(nsdoc, &nselem);
279 if(NS_FAILED(nsres))
280 ERR("GetDocumentElement failed: %08x\n", nsres);
281 }
282
283 if(!nselem) {
284 *p = NULL;
285 return S_OK;
286 }
287
288 *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE));
289
290 nsIDOMElement_Release(nselem);
291 return S_OK;
292 }
293
294 static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
295 {
296 HTMLDocument *This = HTMLDOC_THIS(iface);
297 nsIDOMDocument *nsdoc;
298 nsIDOMHTMLDocument *nshtmldoc;
299 nsIDOMHTMLElement *nsbody = NULL;
300 HTMLDOMNode *node;
301 nsresult nsres;
302
303 TRACE("(%p)->(%p)\n", This, p);
304
305 *p = NULL;
306
307 if(!This->nscontainer)
308 return S_OK;
309
310 nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
311 if(NS_FAILED(nsres)) {
312 ERR("GetDocument failed: %08x\n", nsres);
313 return S_OK;
314 }
315
316 if(NS_FAILED(nsres) || !nsdoc)
317 return S_OK;
318
319 nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
320 nsIDOMDocument_Release(nsdoc);
321
322 nsres = nsIDOMHTMLDocument_GetBody(nshtmldoc, &nsbody);
323 nsIDOMHTMLDocument_Release(nshtmldoc);
324
325 if(NS_FAILED(nsres) || !nsbody) {
326 TRACE("Could not get body: %08x\n", nsres);
327 return S_OK;
328 }
329
330 node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
331 nsIDOMHTMLElement_Release(nsbody);
332
333 IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
334
335 TRACE("*p = %p\n", *p);
336 return S_OK;
337 }
338
339 static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
340 {
341 HTMLDocument *This = HTMLDOC_THIS(iface);
342 FIXME("(%p)->(%p)\n", This, p);
343 return E_NOTIMPL;
344 }
345
346 static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElementCollection **p)
347 {
348 HTMLDocument *This = HTMLDOC_THIS(iface);
349 FIXME("(%p)->(%p)\n", This, p);
350 return E_NOTIMPL;
351 }
352
353 static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLElementCollection **p)
354 {
355 HTMLDocument *This = HTMLDOC_THIS(iface);
356 FIXME("(%p)->(%p)\n", This, p);
357 return E_NOTIMPL;
358 }
359
360 static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElementCollection **p)
361 {
362 HTMLDocument *This = HTMLDOC_THIS(iface);
363 FIXME("(%p)->(%p)\n", This, p);
364 return E_NOTIMPL;
365 }
366
367 static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElementCollection **p)
368 {
369 HTMLDocument *This = HTMLDOC_THIS(iface);
370 FIXME("(%p)->(%p)\n", This, p);
371 return E_NOTIMPL;
372 }
373
374 static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLElementCollection **p)
375 {
376 HTMLDocument *This = HTMLDOC_THIS(iface);
377 FIXME("(%p)->(%p)\n", This, p);
378 return E_NOTIMPL;
379 }
380
381 static HRESULT WINAPI HTMLDocument_put_title(IHTMLDocument2 *iface, BSTR v)
382 {
383 HTMLDocument *This = HTMLDOC_THIS(iface);
384 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
385 return E_NOTIMPL;
386 }
387
388 static HRESULT WINAPI HTMLDocument_get_title(IHTMLDocument2 *iface, BSTR *p)
389 {
390 HTMLDocument *This = HTMLDOC_THIS(iface);
391 FIXME("(%p)->(%p)\n", This, p);
392 return E_NOTIMPL;
393 }
394
395 static HRESULT WINAPI HTMLDocument_get_scripts(IHTMLDocument2 *iface, IHTMLElementCollection **p)
396 {
397 HTMLDocument *This = HTMLDOC_THIS(iface);
398 FIXME("(%p)->(%p)\n", This, p);
399 return E_NOTIMPL;
400 }
401
402 static HRESULT WINAPI HTMLDocument_put_designMode(IHTMLDocument2 *iface, BSTR v)
403 {
404 HTMLDocument *This = HTMLDOC_THIS(iface);
405 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
406 return E_NOTIMPL;
407 }
408
409 static HRESULT WINAPI HTMLDocument_get_designMode(IHTMLDocument2 *iface, BSTR *p)
410 {
411 HTMLDocument *This = HTMLDOC_THIS(iface);
412 FIXME("(%p)->(%p)\n", This, p);
413 return E_NOTIMPL;
414 }
415
416 static HRESULT WINAPI HTMLDocument_get_selection(IHTMLDocument2 *iface, IHTMLSelectionObject **p)
417 {
418 HTMLDocument *This = HTMLDOC_THIS(iface);
419 nsISelection *nsselection = NULL;
420
421 TRACE("(%p)->(%p)\n", This, p);
422
423 if(This->nscontainer) {
424 nsIDOMWindow *dom_window = NULL;
425
426 nsIWebBrowser_GetContentDOMWindow(This->nscontainer->webbrowser, &dom_window);
427 if(dom_window) {
428 nsIDOMWindow_GetSelection(dom_window, &nsselection);
429 nsIDOMWindow_Release(dom_window);
430 }
431 }
432
433 *p = HTMLSelectionObject_Create(This, nsselection);
434 return S_OK;
435 }
436
437 static HRESULT WINAPI HTMLDocument_get_readyState(IHTMLDocument2 *iface, BSTR *p)
438 {
439 HTMLDocument *This = HTMLDOC_THIS(iface);
440
441 static const WCHAR wszUninitialized[] = {'u','n','i','n','i','t','i','a','l','i','z','e','d',0};
442 static const WCHAR wszLoading[] = {'l','o','a','d','i','n','g',0};
443 static const WCHAR wszLoaded[] = {'l','o','a','d','e','d',0};
444 static const WCHAR wszInteractive[] = {'i','n','t','e','r','a','c','t','i','v','e',0};
445 static const WCHAR wszComplete[] = {'c','o','m','p','l','e','t','e',0};
446
447 static const LPCWSTR readystate_str[] = {
448 wszUninitialized,
449 wszLoading,
450 wszLoaded,
451 wszInteractive,
452 wszComplete
453 };
454
455 TRACE("(%p)->(%p)\n", iface, p);
456
457 if(!p)
458 return E_POINTER;
459
460 *p = SysAllocString(readystate_str[This->readystate]);
461 return S_OK;
462 }
463
464 static HRESULT WINAPI HTMLDocument_get_frames(IHTMLDocument2 *iface, IHTMLFramesCollection2 **p)
465 {
466 HTMLDocument *This = HTMLDOC_THIS(iface);
467 FIXME("(%p)->(%p)\n", This, p);
468 return E_NOTIMPL;
469 }
470
471 static HRESULT WINAPI HTMLDocument_get_embeds(IHTMLDocument2 *iface, IHTMLElementCollection **p)
472 {
473 HTMLDocument *This = HTMLDOC_THIS(iface);
474 FIXME("(%p)->(%p)\n", This, p);
475 return E_NOTIMPL;
476 }
477
478 static HRESULT WINAPI HTMLDocument_get_plugins(IHTMLDocument2 *iface, IHTMLElementCollection **p)
479 {
480 HTMLDocument *This = HTMLDOC_THIS(iface);
481 FIXME("(%p)->(%p)\n", This, p);
482 return E_NOTIMPL;
483 }
484
485 static HRESULT WINAPI HTMLDocument_put_alinkColor(IHTMLDocument2 *iface, VARIANT v)
486 {
487 HTMLDocument *This = HTMLDOC_THIS(iface);
488 FIXME("(%p)\n", This);
489 return E_NOTIMPL;
490 }
491
492 static HRESULT WINAPI HTMLDocument_get_alinkColor(IHTMLDocument2 *iface, VARIANT *p)
493 {
494 HTMLDocument *This = HTMLDOC_THIS(iface);
495 FIXME("(%p)->(%p)\n", This, p);
496 return E_NOTIMPL;
497 }
498
499 static HRESULT WINAPI HTMLDocument_put_bgColor(IHTMLDocument2 *iface, VARIANT v)
500 {
501 HTMLDocument *This = HTMLDOC_THIS(iface);
502 FIXME("(%p)\n", This);
503 return E_NOTIMPL;
504 }
505
506 static HRESULT WINAPI HTMLDocument_get_bgColor(IHTMLDocument2 *iface, VARIANT *p)
507 {
508 HTMLDocument *This = HTMLDOC_THIS(iface);
509 FIXME("(%p)->(%p)\n", This, p);
510 return E_NOTIMPL;
511 }
512
513 static HRESULT WINAPI HTMLDocument_put_fgColor(IHTMLDocument2 *iface, VARIANT v)
514 {
515 HTMLDocument *This = HTMLDOC_THIS(iface);
516 FIXME("(%p)\n", This);
517 return E_NOTIMPL;
518 }
519
520 static HRESULT WINAPI HTMLDocument_get_fgColor(IHTMLDocument2 *iface, VARIANT *p)
521 {
522 HTMLDocument *This = HTMLDOC_THIS(iface);
523 FIXME("(%p)->(%p)\n", This, p);
524 return E_NOTIMPL;
525 }
526
527 static HRESULT WINAPI HTMLDocument_put_linkColor(IHTMLDocument2 *iface, VARIANT v)
528 {
529 HTMLDocument *This = HTMLDOC_THIS(iface);
530 FIXME("(%p)->()\n", This);
531 return E_NOTIMPL;
532 }
533
534 static HRESULT WINAPI HTMLDocument_get_linkColor(IHTMLDocument2 *iface, VARIANT *p)
535 {
536 HTMLDocument *This = HTMLDOC_THIS(iface);
537 FIXME("(%p)->(%p)\n", This, p);
538 return E_NOTIMPL;
539 }
540
541 static HRESULT WINAPI HTMLDocument_put_vlinkColor(IHTMLDocument2 *iface, VARIANT v)
542 {
543 HTMLDocument *This = HTMLDOC_THIS(iface);
544 FIXME("(%p)\n", This);
545 return E_NOTIMPL;
546 }
547
548 static HRESULT WINAPI HTMLDocument_get_vlinkColor(IHTMLDocument2 *iface, VARIANT *p)
549 {
550 HTMLDocument *This = HTMLDOC_THIS(iface);
551 FIXME("(%p)->(%p)\n", This, p);
552 return E_NOTIMPL;
553 }
554
555 static HRESULT WINAPI HTMLDocument_get_referrer(IHTMLDocument2 *iface, BSTR *p)
556 {
557 HTMLDocument *This = HTMLDOC_THIS(iface);
558 FIXME("(%p)->(%p)\n", This, p);
559 return E_NOTIMPL;
560 }
561
562 static HRESULT WINAPI HTMLDocument_get_location(IHTMLDocument2 *iface, IHTMLLocation **p)
563 {
564 HTMLDocument *This = HTMLDOC_THIS(iface);
565
566 TRACE("(%p)->(%p)\n", This, p);
567
568 if(This->location)
569 IHTMLLocation_AddRef(HTMLLOCATION(This->location));
570 else
571 This->location = HTMLLocation_Create(This);
572
573 *p = HTMLLOCATION(This->location);
574 return S_OK;
575 }
576
577 static HRESULT WINAPI HTMLDocument_get_lastModified(IHTMLDocument2 *iface, BSTR *p)
578 {
579 HTMLDocument *This = HTMLDOC_THIS(iface);
580 FIXME("(%p)->(%p)\n", This, p);
581 return E_NOTIMPL;
582 }
583
584 static HRESULT WINAPI HTMLDocument_put_URL(IHTMLDocument2 *iface, BSTR v)
585 {
586 HTMLDocument *This = HTMLDOC_THIS(iface);
587 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
588 return E_NOTIMPL;
589 }
590
591 static HRESULT WINAPI HTMLDocument_get_URL(IHTMLDocument2 *iface, BSTR *p)
592 {
593 HTMLDocument *This = HTMLDOC_THIS(iface);
594
595 static const WCHAR about_blank_url[] =
596 {'a','b','o','u','t',':','b','l','a','n','k',0};
597
598 TRACE("(%p)->(%p)\n", iface, p);
599
600 *p = SysAllocString(This->url ? This->url : about_blank_url);
601 return S_OK;
602 }
603
604 static HRESULT WINAPI HTMLDocument_put_domain(IHTMLDocument2 *iface, BSTR v)
605 {
606 HTMLDocument *This = HTMLDOC_THIS(iface);
607 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
608 return E_NOTIMPL;
609 }
610
611 static HRESULT WINAPI HTMLDocument_get_domain(IHTMLDocument2 *iface, BSTR *p)
612 {
613 HTMLDocument *This = HTMLDOC_THIS(iface);
614 FIXME("(%p)->(%p)\n", This, p);
615 return E_NOTIMPL;
616 }
617
618 static HRESULT WINAPI HTMLDocument_put_cookie(IHTMLDocument2 *iface, BSTR v)
619 {
620 HTMLDocument *This = HTMLDOC_THIS(iface);
621 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
622 return E_NOTIMPL;
623 }
624
625 static HRESULT WINAPI HTMLDocument_get_cookie(IHTMLDocument2 *iface, BSTR *p)
626 {
627 HTMLDocument *This = HTMLDOC_THIS(iface);
628 FIXME("(%p)->(%p)\n", This, p);
629 return E_NOTIMPL;
630 }
631
632 static HRESULT WINAPI HTMLDocument_put_expando(IHTMLDocument2 *iface, VARIANT_BOOL v)
633 {
634 HTMLDocument *This = HTMLDOC_THIS(iface);
635 FIXME("(%p)->(%x)\n", This, v);
636 return E_NOTIMPL;
637 }
638
639 static HRESULT WINAPI HTMLDocument_get_expando(IHTMLDocument2 *iface, VARIANT_BOOL *p)
640 {
641 HTMLDocument *This = HTMLDOC_THIS(iface);
642 FIXME("(%p)->(%p)\n", This, p);
643 return E_NOTIMPL;
644 }
645
646 static HRESULT WINAPI HTMLDocument_put_charset(IHTMLDocument2 *iface, BSTR v)
647 {
648 HTMLDocument *This = HTMLDOC_THIS(iface);
649 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
650 return E_NOTIMPL;
651 }
652
653 static HRESULT WINAPI HTMLDocument_get_charset(IHTMLDocument2 *iface, BSTR *p)
654 {
655 HTMLDocument *This = HTMLDOC_THIS(iface);
656 FIXME("(%p)->(%p)\n", This, p);
657 return E_NOTIMPL;
658 }
659
660 static HRESULT WINAPI HTMLDocument_put_defaultCharset(IHTMLDocument2 *iface, BSTR v)
661 {
662 HTMLDocument *This = HTMLDOC_THIS(iface);
663 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
664 return E_NOTIMPL;
665 }
666
667 static HRESULT WINAPI HTMLDocument_get_defaultCharset(IHTMLDocument2 *iface, BSTR *p)
668 {
669 HTMLDocument *This = HTMLDOC_THIS(iface);
670 FIXME("(%p)->(%p)\n", This, p);
671 return E_NOTIMPL;
672 }
673
674 static HRESULT WINAPI HTMLDocument_get_mimeType(IHTMLDocument2 *iface, BSTR *p)
675 {
676 HTMLDocument *This = HTMLDOC_THIS(iface);
677 FIXME("(%p)->(%p)\n", This, p);
678 return E_NOTIMPL;
679 }
680
681 static HRESULT WINAPI HTMLDocument_get_fileSize(IHTMLDocument2 *iface, BSTR *p)
682 {
683 HTMLDocument *This = HTMLDOC_THIS(iface);
684 FIXME("(%p)->(%p)\n", This, p);
685 return E_NOTIMPL;
686 }
687
688 static HRESULT WINAPI HTMLDocument_get_fileCreatedDate(IHTMLDocument2 *iface, BSTR *p)
689 {
690 HTMLDocument *This = HTMLDOC_THIS(iface);
691 FIXME("(%p)->(%p)\n", This, p);
692 return E_NOTIMPL;
693 }
694
695 static HRESULT WINAPI HTMLDocument_get_fileModifiedDate(IHTMLDocument2 *iface, BSTR *p)
696 {
697 HTMLDocument *This = HTMLDOC_THIS(iface);
698 FIXME("(%p)->(%p)\n", This, p);
699 return E_NOTIMPL;
700 }
701
702 static HRESULT WINAPI HTMLDocument_get_fileUpdatedDate(IHTMLDocument2 *iface, BSTR *p)
703 {
704 HTMLDocument *This = HTMLDOC_THIS(iface);
705 FIXME("(%p)->(%p)\n", This, p);
706 return E_NOTIMPL;
707 }
708
709 static HRESULT WINAPI HTMLDocument_get_security(IHTMLDocument2 *iface, BSTR *p)
710 {
711 HTMLDocument *This = HTMLDOC_THIS(iface);
712 FIXME("(%p)->(%p)\n", This, p);
713 return E_NOTIMPL;
714 }
715
716 static HRESULT WINAPI HTMLDocument_get_protocol(IHTMLDocument2 *iface, BSTR *p)
717 {
718 HTMLDocument *This = HTMLDOC_THIS(iface);
719 FIXME("(%p)->(%p)\n", This, p);
720 return E_NOTIMPL;
721 }
722
723 static HRESULT WINAPI HTMLDocument_get_nameProp(IHTMLDocument2 *iface, BSTR *p)
724 {
725 HTMLDocument *This = HTMLDOC_THIS(iface);
726 FIXME("(%p)->(%p)\n", This, p);
727 return E_NOTIMPL;
728 }
729
730 static HRESULT WINAPI HTMLDocument_write(IHTMLDocument2 *iface, SAFEARRAY *psarray)
731 {
732 HTMLDocument *This = HTMLDOC_THIS(iface);
733 nsIDOMDocument *domdoc;
734 nsIDOMHTMLDocument *nsdoc;
735 nsAString nsstr;
736 VARIANT *var;
737 int i;
738 nsresult nsres;
739 HRESULT hres;
740
741 TRACE("(%p)->(%p)\n", iface, psarray);
742
743 if(psarray->cDims != 1) {
744 FIXME("cDims=%d\n", psarray->cDims);
745 return E_INVALIDARG;
746 }
747
748 if(!This->nscontainer)
749 return S_OK;
750
751 nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &domdoc);
752 if(NS_FAILED(nsres)) {
753 ERR("GetDocument failed: %08x\n", nsres);
754 return S_OK;
755 }
756
757 nsres = nsIDOMDocument_QueryInterface(domdoc, &IID_nsIDOMHTMLDocument, (void**)&nsdoc);
758 nsIDOMDocument_Release(domdoc);
759 if(NS_FAILED(nsres))
760 return S_OK;
761
762 hres = SafeArrayAccessData(psarray, (void**)&var);
763 if(FAILED(hres)) {
764 WARN("SafeArrayAccessData failed: %08x\n", hres);
765 nsIDOMHTMLDocument_Release(nsdoc);
766 return hres;
767 }
768
769 nsAString_Init(&nsstr, NULL);
770
771 for(i=0; i < psarray->rgsabound[0].cElements; i++) {
772 if(V_VT(var+i) == VT_BSTR) {
773 nsAString_SetData(&nsstr, V_BSTR(var+i));
774 nsres = nsIDOMHTMLDocument_Write(nsdoc, &nsstr);
775 if(NS_FAILED(nsres))
776 ERR("Write failed: %08x\n", nsres);
777 }else {
778 FIXME("vt=%d\n", V_VT(var+i));
779 }
780 }
781
782 nsAString_Finish(&nsstr);
783 SafeArrayUnaccessData(psarray);
784 nsIDOMHTMLDocument_Release(nsdoc);
785
786 return S_OK;
787 }
788
789 static HRESULT WINAPI HTMLDocument_writeln(IHTMLDocument2 *iface, SAFEARRAY *psarray)
790 {
791 HTMLDocument *This = HTMLDOC_THIS(iface);
792 FIXME("(%p)->(%p)\n", This, psarray);
793 return E_NOTIMPL;
794 }
795
796 static HRESULT WINAPI HTMLDocument_open(IHTMLDocument2 *iface, BSTR url, VARIANT name,
797 VARIANT features, VARIANT replace, IDispatch **pomWindowResult)
798 {
799 HTMLDocument *This = HTMLDOC_THIS(iface);
800 FIXME("(%p)->(%s %p)\n", This, debugstr_w(url), pomWindowResult);
801 return E_NOTIMPL;
802 }
803
804 static HRESULT WINAPI HTMLDocument_close(IHTMLDocument2 *iface)
805 {
806 HTMLDocument *This = HTMLDOC_THIS(iface);
807 FIXME("(%p)\n", This);
808 return E_NOTIMPL;
809 }
810
811 static HRESULT WINAPI HTMLDocument_clear(IHTMLDocument2 *iface)
812 {
813 HTMLDocument *This = HTMLDOC_THIS(iface);
814 FIXME("(%p)\n", This);
815 return E_NOTIMPL;
816 }
817
818 static HRESULT WINAPI HTMLDocument_queryCommandSupported(IHTMLDocument2 *iface, BSTR cmdID,
819 VARIANT_BOOL *pfRet)
820 {
821 HTMLDocument *This = HTMLDOC_THIS(iface);
822 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
823 return E_NOTIMPL;
824 }
825
826 static HRESULT WINAPI HTMLDocument_queryCommandEnabled(IHTMLDocument2 *iface, BSTR cmdID,
827 VARIANT_BOOL *pfRet)
828 {
829 HTMLDocument *This = HTMLDOC_THIS(iface);
830 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
831 return E_NOTIMPL;
832 }
833
834 static HRESULT WINAPI HTMLDocument_queryCommandState(IHTMLDocument2 *iface, BSTR cmdID,
835 VARIANT_BOOL *pfRet)
836 {
837 HTMLDocument *This = HTMLDOC_THIS(iface);
838 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
839 return E_NOTIMPL;
840 }
841
842 static HRESULT WINAPI HTMLDocument_queryCommandIndeterm(IHTMLDocument2 *iface, BSTR cmdID,
843 VARIANT_BOOL *pfRet)
844 {
845 HTMLDocument *This = HTMLDOC_THIS(iface);
846 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
847 return E_NOTIMPL;
848 }
849
850 static HRESULT WINAPI HTMLDocument_queryCommandText(IHTMLDocument2 *iface, BSTR cmdID,
851 BSTR *pfRet)
852 {
853 HTMLDocument *This = HTMLDOC_THIS(iface);
854 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
855 return E_NOTIMPL;
856 }
857
858 static HRESULT WINAPI HTMLDocument_queryCommandValue(IHTMLDocument2 *iface, BSTR cmdID,
859 VARIANT *pfRet)
860 {
861 HTMLDocument *This = HTMLDOC_THIS(iface);
862 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
863 return E_NOTIMPL;
864 }
865
866 static HRESULT WINAPI HTMLDocument_execCommand(IHTMLDocument2 *iface, BSTR cmdID,
867 VARIANT_BOOL showUI, VARIANT value, VARIANT_BOOL *pfRet)
868 {
869 HTMLDocument *This = HTMLDOC_THIS(iface);
870 FIXME("(%p)->(%s %x %p)\n", This, debugstr_w(cmdID), showUI, pfRet);
871 return E_NOTIMPL;
872 }
873
874 static HRESULT WINAPI HTMLDocument_execCommandShowHelp(IHTMLDocument2 *iface, BSTR cmdID,
875 VARIANT_BOOL *pfRet)
876 {
877 HTMLDocument *This = HTMLDOC_THIS(iface);
878 FIXME("(%p)->(%s %p)\n", This, debugstr_w(cmdID), pfRet);
879 return E_NOTIMPL;
880 }
881
882 static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTag,
883 IHTMLElement **newElem)
884 {
885 HTMLDocument *This = HTMLDOC_THIS(iface);
886 nsIDOMDocument *nsdoc;
887 nsIDOMElement *nselem;
888 HTMLElement *elem;
889 nsAString tag_str;
890 nsresult nsres;
891
892 TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
893
894 nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
895
896 nsAString_Init(&tag_str, eTag);
897 nsres = nsIDOMDocument_CreateElement(nsdoc, &tag_str, &nselem);
898 nsAString_Finish(&tag_str);
899 nsIDOMDocument_Release(nsdoc);
900 if(NS_FAILED(nsres)) {
901 ERR("CreateElement failed: %08x\n", nsres);
902 return E_FAIL;
903 }
904
905 elem = HTMLElement_Create(This, (nsIDOMNode*)nselem, TRUE);
906 nsIDOMElement_Release(nselem);
907
908 *newElem = HTMLELEM(elem);
909 IHTMLElement_AddRef(HTMLELEM(elem));
910 return S_OK;
911 }
912
913 static HRESULT WINAPI HTMLDocument_put_onhelp(IHTMLDocument2 *iface, VARIANT v)
914 {
915 HTMLDocument *This = HTMLDOC_THIS(iface);
916 FIXME("(%p)\n", This);
917 return E_NOTIMPL;
918 }
919
920 static HRESULT WINAPI HTMLDocument_get_onhelp(IHTMLDocument2 *iface, VARIANT *p)
921 {
922 HTMLDocument *This = HTMLDOC_THIS(iface);
923 FIXME("(%p)->(%p)\n", This, p);
924 return E_NOTIMPL;
925 }
926
927 static HRESULT WINAPI HTMLDocument_put_onclick(IHTMLDocument2 *iface, VARIANT v)
928 {
929 HTMLDocument *This = HTMLDOC_THIS(iface);
930 FIXME("(%p)\n", This);
931 return E_NOTIMPL;
932 }
933
934 static HRESULT WINAPI HTMLDocument_get_onclick(IHTMLDocument2 *iface, VARIANT *p)
935 {
936 HTMLDocument *This = HTMLDOC_THIS(iface);
937 FIXME("(%p)->(%p)\n", This, p);
938 return E_NOTIMPL;
939 }
940
941 static HRESULT WINAPI HTMLDocument_put_ondblclick(IHTMLDocument2 *iface, VARIANT v)
942 {
943 HTMLDocument *This = HTMLDOC_THIS(iface);
944 FIXME("(%p)\n", This);
945 return E_NOTIMPL;
946 }
947
948 static HRESULT WINAPI HTMLDocument_get_ondblclick(IHTMLDocument2 *iface, VARIANT *p)
949 {
950 HTMLDocument *This = HTMLDOC_THIS(iface);
951 FIXME("(%p)->(%p)\n", This, p);
952 return E_NOTIMPL;
953 }
954
955 static HRESULT WINAPI HTMLDocument_put_onkeyup(IHTMLDocument2 *iface, VARIANT v)
956 {
957 HTMLDocument *This = HTMLDOC_THIS(iface);
958 FIXME("(%p)\n", This);
959 return E_NOTIMPL;
960 }
961
962 static HRESULT WINAPI HTMLDocument_get_onkeyup(IHTMLDocument2 *iface, VARIANT *p)
963 {
964 HTMLDocument *This = HTMLDOC_THIS(iface);
965 FIXME("(%p)->(%p)\n", This, p);
966 return E_NOTIMPL;
967 }
968
969 static HRESULT WINAPI HTMLDocument_put_onkeydown(IHTMLDocument2 *iface, VARIANT v)
970 {
971 HTMLDocument *This = HTMLDOC_THIS(iface);
972 FIXME("(%p)\n", This);
973 return E_NOTIMPL;
974 }
975
976 static HRESULT WINAPI HTMLDocument_get_onkeydown(IHTMLDocument2 *iface, VARIANT *p)
977 {
978 HTMLDocument *This = HTMLDOC_THIS(iface);
979 FIXME("(%p)->(%p)\n", This, p);
980 return E_NOTIMPL;
981 }
982
983 static HRESULT WINAPI HTMLDocument_put_onkeypress(IHTMLDocument2 *iface, VARIANT v)
984 {
985 HTMLDocument *This = HTMLDOC_THIS(iface);
986 FIXME("(%p)\n", This);
987 return E_NOTIMPL;
988 }
989
990 static HRESULT WINAPI HTMLDocument_get_onkeypress(IHTMLDocument2 *iface, VARIANT *p)
991 {
992 HTMLDocument *This = HTMLDOC_THIS(iface);
993 FIXME("(%p)->(%p)\n", This, p);
994 return E_NOTIMPL;
995 }
996
997 static HRESULT WINAPI HTMLDocument_put_onmouseup(IHTMLDocument2 *iface, VARIANT v)
998 {
999 HTMLDocument *This = HTMLDOC_THIS(iface);
1000 FIXME("(%p)\n", This);
1001 return E_NOTIMPL;
1002 }
1003
1004 static HRESULT WINAPI HTMLDocument_get_onmouseup(IHTMLDocument2 *iface, VARIANT *p)
1005 {
1006 HTMLDocument *This = HTMLDOC_THIS(iface);
1007 FIXME("(%p)->(%p)\n", This, p);
1008 return E_NOTIMPL;
1009 }
1010
1011 static HRESULT WINAPI HTMLDocument_put_onmousedown(IHTMLDocument2 *iface, VARIANT v)
1012 {
1013 HTMLDocument *This = HTMLDOC_THIS(iface);
1014 FIXME("(%p)\n", This);
1015 return E_NOTIMPL;
1016 }
1017
1018 static HRESULT WINAPI HTMLDocument_get_onmousedown(IHTMLDocument2 *iface, VARIANT *p)
1019 {
1020 HTMLDocument *This = HTMLDOC_THIS(iface);
1021 FIXME("(%p)->(%p)\n", This, p);
1022 return E_NOTIMPL;
1023 }
1024
1025 static HRESULT WINAPI HTMLDocument_put_onmousemove(IHTMLDocument2 *iface, VARIANT v)
1026 {
1027 HTMLDocument *This = HTMLDOC_THIS(iface);
1028 FIXME("(%p)\n", This);
1029 return E_NOTIMPL;
1030 }
1031
1032 static HRESULT WINAPI HTMLDocument_get_onmousemove(IHTMLDocument2 *iface, VARIANT *p)
1033 {
1034 HTMLDocument *This = HTMLDOC_THIS(iface);
1035 FIXME("(%p)->(%p)\n", This, p);
1036 return E_NOTIMPL;
1037 }
1038
1039 static HRESULT WINAPI HTMLDocument_put_onmouseout(IHTMLDocument2 *iface, VARIANT v)
1040 {
1041 HTMLDocument *This = HTMLDOC_THIS(iface);
1042 FIXME("(%p)\n", This);
1043 return E_NOTIMPL;
1044 }
1045
1046 static HRESULT WINAPI HTMLDocument_get_onmouseout(IHTMLDocument2 *iface, VARIANT *p)
1047 {
1048 HTMLDocument *This = HTMLDOC_THIS(iface);
1049 FIXME("(%p)->(%p)\n", This, p);
1050 return E_NOTIMPL;
1051 }
1052
1053 static HRESULT WINAPI HTMLDocument_put_onmouseover(IHTMLDocument2 *iface, VARIANT v)
1054 {
1055 HTMLDocument *This = HTMLDOC_THIS(iface);
1056 FIXME("(%p)\n", This);
1057 return E_NOTIMPL;
1058 }
1059
1060 static HRESULT WINAPI HTMLDocument_get_onmouseover(IHTMLDocument2 *iface, VARIANT *p)
1061 {
1062 HTMLDocument *This = HTMLDOC_THIS(iface);
1063 FIXME("(%p)->(%p)\n", This, p);
1064 return E_NOTIMPL;
1065 }
1066
1067 static HRESULT WINAPI HTMLDocument_put_onreadystatechange(IHTMLDocument2 *iface, VARIANT v)
1068 {
1069 HTMLDocument *This = HTMLDOC_THIS(iface);
1070 FIXME("(%p)\n", This);
1071 return E_NOTIMPL;
1072 }
1073
1074 static HRESULT WINAPI HTMLDocument_get_onreadystatechange(IHTMLDocument2 *iface, VARIANT *p)
1075 {
1076 HTMLDocument *This = HTMLDOC_THIS(iface);
1077 FIXME("(%p)->(%p)\n", This, p);
1078 return E_NOTIMPL;
1079 }
1080
1081 static HRESULT WINAPI HTMLDocument_put_onafterupdate(IHTMLDocument2 *iface, VARIANT v)
1082 {
1083 HTMLDocument *This = HTMLDOC_THIS(iface);
1084 FIXME("(%p)\n", This);
1085 return E_NOTIMPL;
1086 }
1087
1088 static HRESULT WINAPI HTMLDocument_get_onafterupdate(IHTMLDocument2 *iface, VARIANT *p)
1089 {
1090 HTMLDocument *This = HTMLDOC_THIS(iface);
1091 FIXME("(%p)->(%p)\n", This, p);
1092 return E_NOTIMPL;
1093 }
1094
1095 static HRESULT WINAPI HTMLDocument_put_onrowexit(IHTMLDocument2 *iface, VARIANT v)
1096 {
1097 HTMLDocument *This = HTMLDOC_THIS(iface);
1098 FIXME("(%p)\n", This);
1099 return E_NOTIMPL;
1100 }
1101
1102 static HRESULT WINAPI HTMLDocument_get_onrowexit(IHTMLDocument2 *iface, VARIANT *p)
1103 {
1104 HTMLDocument *This = HTMLDOC_THIS(iface);
1105 FIXME("(%p)->(%p)\n", This, p);
1106 return E_NOTIMPL;
1107 }
1108
1109 static HRESULT WINAPI HTMLDocument_put_onrowenter(IHTMLDocument2 *iface, VARIANT v)
1110 {
1111 HTMLDocument *This = HTMLDOC_THIS(iface);
1112 FIXME("(%p)\n", This);
1113 return E_NOTIMPL;
1114 }
1115
1116 static HRESULT WINAPI HTMLDocument_get_onrowenter(IHTMLDocument2 *iface, VARIANT *p)
1117 {
1118 HTMLDocument *This = HTMLDOC_THIS(iface);
1119 FIXME("(%p)->(%p)\n", This, p);
1120 return E_NOTIMPL;
1121 }
1122
1123 static HRESULT WINAPI HTMLDocument_put_ondragstart(IHTMLDocument2 *iface, VARIANT v)
1124 {
1125 HTMLDocument *This = HTMLDOC_THIS(iface);
1126 FIXME("(%p)\n", This);
1127 return E_NOTIMPL;
1128 }
1129
1130 static HRESULT WINAPI HTMLDocument_get_ondragstart(IHTMLDocument2 *iface, VARIANT *p)
1131 {
1132 HTMLDocument *This = HTMLDOC_THIS(iface);
1133 FIXME("(%p)->(%p)\n", This, p);
1134 return E_NOTIMPL;
1135 }
1136
1137 static HRESULT WINAPI HTMLDocument_put_onselectstart(IHTMLDocument2 *iface, VARIANT v)
1138 {
1139 HTMLDocument *This = HTMLDOC_THIS(iface);
1140 FIXME("(%p)\n", This);
1141 return E_NOTIMPL;
1142 }
1143
1144 static HRESULT WINAPI HTMLDocument_get_onselectstart(IHTMLDocument2 *iface, VARIANT *p)
1145 {
1146 HTMLDocument *This = HTMLDOC_THIS(iface);
1147 FIXME("(%p)->(%p)\n", This, p);
1148 return E_NOTIMPL;
1149 }
1150
1151 static HRESULT WINAPI HTMLDocument_elementFromPoint(IHTMLDocument2 *iface, long x, long y,
1152 IHTMLElement **elementHit)
1153 {
1154 HTMLDocument *This = HTMLDOC_THIS(iface);
1155 FIXME("(%p)->(%ld %ld %p)\n", This, x, y, elementHit);
1156 return E_NOTIMPL;
1157 }
1158
1159 static HRESULT WINAPI HTMLDocument_get_parentWindow(IHTMLDocument2 *iface, IHTMLWindow2 **p)
1160 {
1161 HTMLDocument *This = HTMLDOC_THIS(iface);
1162
1163 TRACE("(%p)->(%p)\n", This, p);
1164
1165 *p = HTMLWINDOW2(This->window);
1166 IHTMLWindow2_AddRef(*p);
1167 return S_OK;
1168 }
1169
1170 static HRESULT WINAPI HTMLDocument_get_styleSheets(IHTMLDocument2 *iface,
1171 IHTMLStyleSheetsCollection **p)
1172 {
1173 HTMLDocument *This = HTMLDOC_THIS(iface);
1174 nsIDOMStyleSheetList *nsstylelist;
1175 nsIDOMDocumentStyle *nsdocstyle;
1176 nsIDOMDocument *nsdoc;
1177 nsresult nsres;
1178
1179 TRACE("(%p)->(%p)\n", This, p);
1180
1181 *p = NULL;
1182
1183 if(!This->nscontainer)
1184 return S_OK;
1185
1186 nsres = nsIWebNavigation_GetDocument(This->nscontainer->navigation, &nsdoc);
1187 if(NS_FAILED(nsres)) {
1188 ERR("GetDocument failed: %08x\n", nsres);
1189 return S_OK;
1190 }
1191
1192 if(NS_FAILED(nsres) || !nsdoc)
1193 return S_OK;
1194
1195 nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentStyle, (void**)&nsdocstyle);
1196 nsIDOMDocument_Release(nsdoc);
1197
1198 nsIDOMDocumentStyle_GetStyleSheets(nsdocstyle, &nsstylelist);
1199 nsIDOMDocumentStyle_Release(nsdocstyle);
1200
1201 *p = HTMLStyleSheetsCollection_Create(nsstylelist);
1202 nsIDOMDocumentStyle_Release(nsstylelist);
1203
1204 return S_OK;
1205 }
1206
1207 static HRESULT WINAPI HTMLDocument_put_onbeforeupdate(IHTMLDocument2 *iface, VARIANT v)
1208 {
1209 HTMLDocument *This = HTMLDOC_THIS(iface);
1210 FIXME("(%p)\n", This);
1211 return E_NOTIMPL;
1212 }
1213
1214 static HRESULT WINAPI HTMLDocument_get_onbeforeupdate(IHTMLDocument2 *iface, VARIANT *p)
1215 {
1216 HTMLDocument *This = HTMLDOC_THIS(iface);
1217 FIXME("(%p)->(%p)\n", This, p);
1218 return E_NOTIMPL;
1219 }
1220
1221 static HRESULT WINAPI HTMLDocument_put_onerrorupdate(IHTMLDocument2 *iface, VARIANT v)
1222 {
1223 HTMLDocument *This = HTMLDOC_THIS(iface);
1224 FIXME("(%p)\n", This);
1225 return E_NOTIMPL;
1226 }
1227
1228 static HRESULT WINAPI HTMLDocument_get_onerrorupdate(IHTMLDocument2 *iface, VARIANT *p)
1229 {
1230 HTMLDocument *This = HTMLDOC_THIS(iface);
1231 FIXME("(%p)->(%p)\n", This, p);
1232 return E_NOTIMPL;
1233 }
1234
1235 static HRESULT WINAPI HTMLDocument_toString(IHTMLDocument2 *iface, BSTR *String)
1236 {
1237 HTMLDocument *This = HTMLDOC_THIS(iface);
1238 FIXME("(%p)->(%p)\n", This, String);
1239 return E_NOTIMPL;
1240 }
1241
1242 static HRESULT WINAPI HTMLDocument_createStyleSheet(IHTMLDocument2 *iface, BSTR bstrHref,
1243 long lIndex, IHTMLStyleSheet **ppnewStyleSheet)
1244 {
1245 HTMLDocument *This = HTMLDOC_THIS(iface);
1246
1247 FIXME("(%p)->(%s %ld %p) semi-stub\n", This, debugstr_w(bstrHref), lIndex, ppnewStyleSheet);
1248
1249 *ppnewStyleSheet = HTMLStyleSheet_Create(NULL);
1250 return S_OK;
1251 }
1252
1253 static const IHTMLDocument2Vtbl HTMLDocumentVtbl = {
1254 HTMLDocument_QueryInterface,
1255 HTMLDocument_AddRef,
1256 HTMLDocument_Release,
1257 HTMLDocument_GetTypeInfoCount,
1258 HTMLDocument_GetTypeInfo,
1259 HTMLDocument_GetIDsOfNames,
1260 HTMLDocument_Invoke,
1261 HTMLDocument_get_Script,
1262 HTMLDocument_get_all,
1263 HTMLDocument_get_body,
1264 HTMLDocument_get_activeElement,
1265 HTMLDocument_get_images,
1266 HTMLDocument_get_applets,
1267 HTMLDocument_get_links,
1268 HTMLDocument_get_forms,
1269 HTMLDocument_get_anchors,
1270 HTMLDocument_put_title,
1271 HTMLDocument_get_title,
1272 HTMLDocument_get_scripts,
1273 HTMLDocument_put_designMode,
1274 HTMLDocument_get_designMode,
1275 HTMLDocument_get_selection,
1276 HTMLDocument_get_readyState,
1277 HTMLDocument_get_frames,
1278 HTMLDocument_get_embeds,
1279 HTMLDocument_get_plugins,
1280 HTMLDocument_put_alinkColor,
1281 HTMLDocument_get_alinkColor,
1282 HTMLDocument_put_bgColor,
1283 HTMLDocument_get_bgColor,
1284 HTMLDocument_put_fgColor,
1285 HTMLDocument_get_fgColor,
1286 HTMLDocument_put_linkColor,
1287 HTMLDocument_get_linkColor,
1288 HTMLDocument_put_vlinkColor,
1289 HTMLDocument_get_vlinkColor,
1290 HTMLDocument_get_referrer,
1291 HTMLDocument_get_location,
1292 HTMLDocument_get_lastModified,
1293 HTMLDocument_put_URL,
1294 HTMLDocument_get_URL,
1295 HTMLDocument_put_domain,
1296 HTMLDocument_get_domain,
1297 HTMLDocument_put_cookie,
1298 HTMLDocument_get_cookie,
1299 HTMLDocument_put_expando,
1300 HTMLDocument_get_expando,
1301 HTMLDocument_put_charset,
1302 HTMLDocument_get_charset,
1303 HTMLDocument_put_defaultCharset,
1304 HTMLDocument_get_defaultCharset,
1305 HTMLDocument_get_mimeType,
1306 HTMLDocument_get_fileSize,
1307 HTMLDocument_get_fileCreatedDate,
1308 HTMLDocument_get_fileModifiedDate,
1309 HTMLDocument_get_fileUpdatedDate,
1310 HTMLDocument_get_security,
1311 HTMLDocument_get_protocol,
1312 HTMLDocument_get_nameProp,
1313 HTMLDocument_write,
1314 HTMLDocument_writeln,
1315 HTMLDocument_open,
1316 HTMLDocument_close,
1317 HTMLDocument_clear,
1318 HTMLDocument_queryCommandSupported,
1319 HTMLDocument_queryCommandEnabled,
1320 HTMLDocument_queryCommandState,
1321 HTMLDocument_queryCommandIndeterm,
1322 HTMLDocument_queryCommandText,
1323 HTMLDocument_queryCommandValue,
1324 HTMLDocument_execCommand,
1325 HTMLDocument_execCommandShowHelp,
1326 HTMLDocument_createElement,
1327 HTMLDocument_put_onhelp,
1328 HTMLDocument_get_onhelp,
1329 HTMLDocument_put_onclick,
1330 HTMLDocument_get_onclick,
1331 HTMLDocument_put_ondblclick,
1332 HTMLDocument_get_ondblclick,
1333 HTMLDocument_put_onkeyup,
1334 HTMLDocument_get_onkeyup,
1335 HTMLDocument_put_onkeydown,
1336 HTMLDocument_get_onkeydown,
1337 HTMLDocument_put_onkeypress,
1338 HTMLDocument_get_onkeypress,
1339 HTMLDocument_put_onmouseup,
1340 HTMLDocument_get_onmouseup,
1341 HTMLDocument_put_onmousedown,
1342 HTMLDocument_get_onmousedown,
1343 HTMLDocument_put_onmousemove,
1344 HTMLDocument_get_onmousemove,
1345 HTMLDocument_put_onmouseout,
1346 HTMLDocument_get_onmouseout,
1347 HTMLDocument_put_onmouseover,
1348 HTMLDocument_get_onmouseover,
1349 HTMLDocument_put_onreadystatechange,
1350 HTMLDocument_get_onreadystatechange,
1351 HTMLDocument_put_onafterupdate,
1352 HTMLDocument_get_onafterupdate,
1353 HTMLDocument_put_onrowexit,
1354 HTMLDocument_get_onrowexit,
1355 HTMLDocument_put_onrowenter,
1356 HTMLDocument_get_onrowenter,
1357 HTMLDocument_put_ondragstart,
1358 HTMLDocument_get_ondragstart,
1359 HTMLDocument_put_onselectstart,
1360 HTMLDocument_get_onselectstart,
1361 HTMLDocument_elementFromPoint,
1362 HTMLDocument_get_parentWindow,
1363 HTMLDocument_get_styleSheets,
1364 HTMLDocument_put_onbeforeupdate,
1365 HTMLDocument_get_onbeforeupdate,
1366 HTMLDocument_put_onerrorupdate,
1367 HTMLDocument_get_onerrorupdate,
1368 HTMLDocument_toString,
1369 HTMLDocument_createStyleSheet
1370 };
1371
1372 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLDocument, IDispatchEx, iface)
1373
1374 static HRESULT WINAPI DocDispatchEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1375 {
1376 HTMLDocument *This = DISPEX_THIS(iface);
1377
1378 return IHTMLDocument2_QueryInterface(HTMLDOC(This), riid, ppv);
1379 }
1380
1381 static ULONG WINAPI DocDispatchEx_AddRef(IDispatchEx *iface)
1382 {
1383 HTMLDocument *This = DISPEX_THIS(iface);
1384
1385 return IHTMLDocument2_AddRef(HTMLDOC(This));
1386 }
1387
1388 static ULONG WINAPI DocDispatchEx_Release(IDispatchEx *iface)
1389 {
1390 HTMLDocument *This = DISPEX_THIS(iface);
1391
1392 return IHTMLDocument2_Release(HTMLDOC(This));
1393 }
1394
1395 static HRESULT WINAPI DocDispatchEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1396 {
1397 HTMLDocument *This = DISPEX_THIS(iface);
1398
1399 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1400 }
1401
1402 static HRESULT WINAPI DocDispatchEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1403 LCID lcid, ITypeInfo **ppTInfo)
1404 {
1405 HTMLDocument *This = DISPEX_THIS(iface);
1406
1407 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1408 }
1409
1410 static HRESULT WINAPI DocDispatchEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1411 LPOLESTR *rgszNames, UINT cNames,
1412 LCID lcid, DISPID *rgDispId)
1413 {
1414 HTMLDocument *This = DISPEX_THIS(iface);
1415
1416 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1417 }
1418
1419 static HRESULT WINAPI DocDispatchEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1420 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1421 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1422 {
1423 HTMLDocument *This = DISPEX_THIS(iface);
1424
1425 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1426 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1427
1428 switch(dispIdMember) {
1429 case DISPID_READYSTATE:
1430 TRACE("DISPID_READYSTATE\n");
1431
1432 if(!(wFlags & DISPATCH_PROPERTYGET))
1433 return E_INVALIDARG;
1434
1435 V_VT(pVarResult) = VT_I4;
1436 V_I4(pVarResult) = This->readystate;
1437 return S_OK;
1438 }
1439
1440 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1441 pVarResult, pExcepInfo, puArgErr);
1442 }
1443
1444 static HRESULT WINAPI DocDispatchEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1445 {
1446 HTMLDocument *This = DISPEX_THIS(iface);
1447
1448 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1449 }
1450
1451 static HRESULT WINAPI DocDispatchEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1452 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1453 {
1454 HTMLDocument *This = DISPEX_THIS(iface);
1455
1456 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1457 }
1458
1459 static HRESULT WINAPI DocDispatchEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1460 {
1461 HTMLDocument *This = DISPEX_THIS(iface);
1462
1463 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1464 }
1465
1466 static HRESULT WINAPI DocDispatchEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1467 {
1468 HTMLDocument *This = DISPEX_THIS(iface);
1469
1470 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1471 }
1472
1473 static HRESULT WINAPI DocDispatchEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1474 {
1475 HTMLDocument *This = DISPEX_THIS(iface);
1476
1477 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1478 }
1479
1480 static HRESULT WINAPI DocDispatchEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1481 {
1482 HTMLDocument *This = DISPEX_THIS(iface);
1483
1484 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1485 }
1486
1487 static HRESULT WINAPI DocDispatchEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1488 {
1489 HTMLDocument *This = DISPEX_THIS(iface);
1490
1491 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1492 }
1493
1494 static HRESULT WINAPI DocDispatchEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1495 {
1496 HTMLDocument *This = DISPEX_THIS(iface);
1497
1498 return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1499 }
1500
1501 #undef DISPEX_THIS
1502
1503 static const IDispatchExVtbl DocDispatchExVtbl = {
1504 DocDispatchEx_QueryInterface,
1505 DocDispatchEx_AddRef,
1506 DocDispatchEx_Release,
1507 DocDispatchEx_GetTypeInfoCount,
1508 DocDispatchEx_GetTypeInfo,
1509 DocDispatchEx_GetIDsOfNames,
1510 DocDispatchEx_Invoke,
1511 DocDispatchEx_GetDispID,
1512 DocDispatchEx_InvokeEx,
1513 DocDispatchEx_DeleteMemberByName,
1514 DocDispatchEx_DeleteMemberByDispID,
1515 DocDispatchEx_GetMemberProperties,
1516 DocDispatchEx_GetMemberName,
1517 DocDispatchEx_GetNextDispID,
1518 DocDispatchEx_GetNameSpaceParent
1519 };
1520
1521 static const tid_t HTMLDocument_iface_tids[] = {
1522 IHTMLDocument2_tid,
1523 IHTMLDocument3_tid,
1524 IHTMLDocument4_tid,
1525 IHTMLDocument5_tid,
1526 0
1527 };
1528 static dispex_static_data_t HTMLDocument_dispex = {
1529 NULL,
1530 DispHTMLDocument_tid,
1531 NULL,
1532 HTMLDocument_iface_tids
1533 };
1534
1535 HRESULT HTMLDocument_Create(IUnknown *pUnkOuter, REFIID riid, void** ppvObject)
1536 {
1537 HTMLDocument *ret;
1538 HRESULT hres;
1539
1540 TRACE("(%p %s %p)\n", pUnkOuter, debugstr_guid(riid), ppvObject);
1541
1542 ret = heap_alloc_zero(sizeof(HTMLDocument));
1543 ret->lpHTMLDocument2Vtbl = &HTMLDocumentVtbl;
1544 ret->lpIDispatchExVtbl = &DocDispatchExVtbl;
1545 ret->ref = 0;
1546 ret->readystate = READYSTATE_UNINITIALIZED;
1547
1548 list_init(&ret->bindings);
1549 list_init(&ret->script_hosts);
1550 list_init(&ret->selection_list);
1551 list_init(&ret->range_list);
1552
1553 hres = IHTMLDocument_QueryInterface(HTMLDOC(ret), riid, ppvObject);
1554 if(FAILED(hres)) {
1555 heap_free(ret);
1556 return hres;
1557 }
1558
1559 LOCK_MODULE();
1560
1561 HTMLDocument_HTMLDocument3_Init(ret);
1562 HTMLDocument_HTMLDocument5_Init(ret);
1563 HTMLDocument_Persist_Init(ret);
1564 HTMLDocument_OleCmd_Init(ret);
1565 HTMLDocument_OleObj_Init(ret);
1566 HTMLDocument_View_Init(ret);
1567 HTMLDocument_Window_Init(ret);
1568 HTMLDocument_Service_Init(ret);
1569 HTMLDocument_Hlink_Init(ret);
1570
1571 ConnectionPointContainer_Init(&ret->cp_container, (IUnknown*)HTMLDOC(ret));
1572 ConnectionPoint_Init(&ret->cp_propnotif, &ret->cp_container, &IID_IPropertyNotifySink);
1573 ConnectionPoint_Init(&ret->cp_htmldocevents, &ret->cp_container, &DIID_HTMLDocumentEvents);
1574 ConnectionPoint_Init(&ret->cp_htmldocevents2, &ret->cp_container, &DIID_HTMLDocumentEvents2);
1575
1576 init_dispex(&ret->dispex, (IUnknown*)HTMLDOC(ret), &HTMLDocument_dispex);
1577
1578 ret->nscontainer = NSContainer_Create(ret, NULL);
1579 ret->window = HTMLWindow_Create(ret);
1580
1581 get_thread_hwnd();
1582
1583 return hres;
1584 }