mshtml: Added IHTMLWindow2::get_history implementation.
[wine/multimedia.git] / dlls / mshtml / htmldoc5.c
blob587d75b7cabf74a3c0c41feeb62a5214b5b3689e
1 /*
2 * Copyright 2007 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "config.h"
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define COBJMACROS
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winuser.h"
29 #include "ole2.h"
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
37 static inline HTMLDocument *impl_from_IHTMLDocument5(IHTMLDocument5 *iface)
39 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument5_iface);
42 static HRESULT WINAPI HTMLDocument5_QueryInterface(IHTMLDocument5 *iface,
43 REFIID riid, void **ppv)
45 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
46 return htmldoc_query_interface(This, riid, ppv);
49 static ULONG WINAPI HTMLDocument5_AddRef(IHTMLDocument5 *iface)
51 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
52 return htmldoc_addref(This);
55 static ULONG WINAPI HTMLDocument5_Release(IHTMLDocument5 *iface)
57 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
58 return htmldoc_release(This);
61 static HRESULT WINAPI HTMLDocument5_GetTypeInfoCount(IHTMLDocument5 *iface, UINT *pctinfo)
63 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
64 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
67 static HRESULT WINAPI HTMLDocument5_GetTypeInfo(IHTMLDocument5 *iface, UINT iTInfo,
68 LCID lcid, ITypeInfo **ppTInfo)
70 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
71 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
74 static HRESULT WINAPI HTMLDocument5_GetIDsOfNames(IHTMLDocument5 *iface, REFIID riid,
75 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
77 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
78 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
79 rgDispId);
82 static HRESULT WINAPI HTMLDocument5_Invoke(IHTMLDocument5 *iface, DISPID dispIdMember,
83 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
84 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
86 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
87 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
88 pDispParams, pVarResult, pExcepInfo, puArgErr);
91 static HRESULT WINAPI HTMLDocument5_put_onmousewheel(IHTMLDocument5 *iface, VARIANT v)
93 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
94 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
95 return E_NOTIMPL;
98 static HRESULT WINAPI HTMLDocument5_get_onmousewheel(IHTMLDocument5 *iface, VARIANT *p)
100 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
101 FIXME("(%p)->(%p)\n", This, p);
102 return E_NOTIMPL;
105 static HRESULT WINAPI HTMLDocument5_get_doctype(IHTMLDocument5 *iface, IHTMLDOMNode **p)
107 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
108 FIXME("(%p)->(%p)\n", This, p);
109 return E_NOTIMPL;
112 static HRESULT WINAPI HTMLDocument5_get_implementation(IHTMLDocument5 *iface, IHTMLDOMImplementation **p)
114 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
115 FIXME("(%p)->(%p)\n", This, p);
116 return E_NOTIMPL;
119 static HRESULT WINAPI HTMLDocument5_createAttribute(IHTMLDocument5 *iface, BSTR bstrattrName,
120 IHTMLDOMAttribute **ppattribute)
122 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
123 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrattrName), ppattribute);
124 return E_NOTIMPL;
127 static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bstrdata,
128 IHTMLDOMNode **ppRetNode)
130 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
131 nsIDOMComment *nscomment;
132 HTMLElement *elem;
133 nsAString str;
134 nsresult nsres;
135 HRESULT hres;
137 TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrdata), ppRetNode);
139 if(!This->doc_node->nsdoc) {
140 WARN("NULL nsdoc\n");
141 return E_UNEXPECTED;
144 nsAString_InitDepend(&str, bstrdata);
145 nsres = nsIDOMHTMLDocument_CreateComment(This->doc_node->nsdoc, &str, &nscomment);
146 nsAString_Finish(&str);
147 if(NS_FAILED(nsres)) {
148 ERR("CreateTextNode failed: %08x\n", nsres);
149 return E_FAIL;
152 hres = HTMLCommentElement_Create(This->doc_node, (nsIDOMNode*)nscomment, &elem);
153 nsIDOMElement_Release(nscomment);
154 if(FAILED(hres))
155 return hres;
157 *ppRetNode = &elem->node.IHTMLDOMNode_iface;
158 IHTMLDOMNode_AddRef(&elem->node.IHTMLDOMNode_iface);
159 return S_OK;
162 static HRESULT WINAPI HTMLDocument5_put_onfocusin(IHTMLDocument5 *iface, VARIANT v)
164 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
165 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
166 return E_NOTIMPL;
169 static HRESULT WINAPI HTMLDocument5_get_onfocusin(IHTMLDocument5 *iface, VARIANT *p)
171 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
172 FIXME("(%p)->(%p)\n", This, p);
173 return E_NOTIMPL;
176 static HRESULT WINAPI HTMLDocument5_put_onfocusout(IHTMLDocument5 *iface, VARIANT v)
178 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
179 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
180 return E_NOTIMPL;
183 static HRESULT WINAPI HTMLDocument5_get_onfocusout(IHTMLDocument5 *iface, VARIANT *p)
185 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
186 FIXME("(%p)->(%p)\n", This, p);
187 return E_NOTIMPL;
190 static HRESULT WINAPI HTMLDocument5_put_onactivate(IHTMLDocument5 *iface, VARIANT v)
192 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
193 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
194 return E_NOTIMPL;
197 static HRESULT WINAPI HTMLDocument5_get_onactivate(IHTMLDocument5 *iface, VARIANT *p)
199 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
200 FIXME("(%p)->(%p)\n", This, p);
201 return E_NOTIMPL;
204 static HRESULT WINAPI HTMLDocument5_put_ondeactivate(IHTMLDocument5 *iface, VARIANT v)
206 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
207 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
208 return E_NOTIMPL;
211 static HRESULT WINAPI HTMLDocument5_get_ondeactivate(IHTMLDocument5 *iface, VARIANT *p)
213 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
214 FIXME("(%p)->(%p)\n", This, p);
215 return E_NOTIMPL;
218 static HRESULT WINAPI HTMLDocument5_put_onbeforeactivate(IHTMLDocument5 *iface, VARIANT v)
220 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
221 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
222 return E_NOTIMPL;
225 static HRESULT WINAPI HTMLDocument5_get_onbeforeactivate(IHTMLDocument5 *iface, VARIANT *p)
227 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
228 FIXME("(%p)->(%p)\n", This, p);
229 return E_NOTIMPL;
232 static HRESULT WINAPI HTMLDocument5_put_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT v)
234 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
235 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
236 return E_NOTIMPL;
239 static HRESULT WINAPI HTMLDocument5_get_onbeforedeactivate(IHTMLDocument5 *iface, VARIANT *p)
241 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
242 FIXME("(%p)->(%p)\n", This, p);
243 return E_NOTIMPL;
246 static HRESULT WINAPI HTMLDocument5_get_compatMode(IHTMLDocument5 *iface, BSTR *p)
248 HTMLDocument *This = impl_from_IHTMLDocument5(iface);
249 nsAString mode_str;
250 const PRUnichar *mode;
252 TRACE("(%p)->(%p)\n", This, p);
254 if(!This->doc_node->nsdoc) {
255 WARN("NULL nsdoc\n");
256 return E_UNEXPECTED;
259 nsAString_Init(&mode_str, NULL);
260 nsIDOMHTMLDocument_GetCompatMode(This->doc_node->nsdoc, &mode_str);
262 nsAString_GetData(&mode_str, &mode);
263 *p = SysAllocString(mode);
264 nsAString_Finish(&mode_str);
266 return S_OK;
269 static const IHTMLDocument5Vtbl HTMLDocument5Vtbl = {
270 HTMLDocument5_QueryInterface,
271 HTMLDocument5_AddRef,
272 HTMLDocument5_Release,
273 HTMLDocument5_GetTypeInfoCount,
274 HTMLDocument5_GetTypeInfo,
275 HTMLDocument5_GetIDsOfNames,
276 HTMLDocument5_Invoke,
277 HTMLDocument5_put_onmousewheel,
278 HTMLDocument5_get_onmousewheel,
279 HTMLDocument5_get_doctype,
280 HTMLDocument5_get_implementation,
281 HTMLDocument5_createAttribute,
282 HTMLDocument5_createComment,
283 HTMLDocument5_put_onfocusin,
284 HTMLDocument5_get_onfocusin,
285 HTMLDocument5_put_onfocusout,
286 HTMLDocument5_get_onfocusout,
287 HTMLDocument5_put_onactivate,
288 HTMLDocument5_get_onactivate,
289 HTMLDocument5_put_ondeactivate,
290 HTMLDocument5_get_ondeactivate,
291 HTMLDocument5_put_onbeforeactivate,
292 HTMLDocument5_get_onbeforeactivate,
293 HTMLDocument5_put_onbeforedeactivate,
294 HTMLDocument5_get_onbeforedeactivate,
295 HTMLDocument5_get_compatMode
298 static inline HTMLDocument *impl_from_IHTMLDocument6(IHTMLDocument6 *iface)
300 return CONTAINING_RECORD(iface, HTMLDocument, IHTMLDocument6_iface);
303 static HRESULT WINAPI HTMLDocument6_QueryInterface(IHTMLDocument6 *iface,
304 REFIID riid, void **ppv)
306 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
307 return htmldoc_query_interface(This, riid, ppv);
310 static ULONG WINAPI HTMLDocument6_AddRef(IHTMLDocument6 *iface)
312 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
313 return htmldoc_addref(This);
316 static ULONG WINAPI HTMLDocument6_Release(IHTMLDocument6 *iface)
318 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
319 return htmldoc_release(This);
322 static HRESULT WINAPI HTMLDocument6_GetTypeInfoCount(IHTMLDocument6 *iface, UINT *pctinfo)
324 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
325 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
328 static HRESULT WINAPI HTMLDocument6_GetTypeInfo(IHTMLDocument6 *iface, UINT iTInfo,
329 LCID lcid, ITypeInfo **ppTInfo)
331 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
332 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
335 static HRESULT WINAPI HTMLDocument6_GetIDsOfNames(IHTMLDocument6 *iface, REFIID riid,
336 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
338 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
339 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
340 rgDispId);
343 static HRESULT WINAPI HTMLDocument6_Invoke(IHTMLDocument6 *iface, DISPID dispIdMember,
344 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
345 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
347 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
348 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
349 pDispParams, pVarResult, pExcepInfo, puArgErr);
352 static HRESULT WINAPI HTMLDocument6_get_compatible(IHTMLDocument6 *iface,
353 IHTMLDocumentCompatibleInfoCollection **p)
355 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
356 FIXME("(%p)->(%p)\n", This, p);
357 return E_NOTIMPL;
360 static HRESULT WINAPI HTMLDocument6_get_documentMode(IHTMLDocument6 *iface,
361 VARIANT *p)
363 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
364 FIXME("(%p)->(%p)\n", This, p);
365 return E_NOTIMPL;
368 static HRESULT WINAPI HTMLDocument6_get_onstorage(IHTMLDocument6 *iface,
369 VARIANT *p)
371 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
372 FIXME("(%p)->(%p)\n", This, p);
373 return E_NOTIMPL;
376 static HRESULT WINAPI HTMLDocument6_put_onstorage(IHTMLDocument6 *iface, VARIANT v)
378 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
379 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
380 return E_NOTIMPL;
383 static HRESULT WINAPI HTMLDocument6_get_onstoragecommit(IHTMLDocument6 *iface,
384 VARIANT *p)
386 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
387 FIXME("(%p)->(%p)\n", This, p);
388 return E_NOTIMPL;
391 static HRESULT WINAPI HTMLDocument6_put_onstoragecommit(IHTMLDocument6 *iface, VARIANT v)
393 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
394 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
395 return E_NOTIMPL;
398 static HRESULT WINAPI HTMLDocument6_getElementById(IHTMLDocument6 *iface,
399 BSTR bstrId, IHTMLElement2 **p)
401 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
402 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrId), p);
403 return E_NOTIMPL;
406 static HRESULT WINAPI HTMLDocument6_updateSettings(IHTMLDocument6 *iface)
408 HTMLDocument *This = impl_from_IHTMLDocument6(iface);
409 FIXME("(%p)->()\n", This);
410 return E_NOTIMPL;
413 static const IHTMLDocument6Vtbl HTMLDocument6Vtbl = {
414 HTMLDocument6_QueryInterface,
415 HTMLDocument6_AddRef,
416 HTMLDocument6_Release,
417 HTMLDocument6_GetTypeInfoCount,
418 HTMLDocument6_GetTypeInfo,
419 HTMLDocument6_GetIDsOfNames,
420 HTMLDocument6_Invoke,
421 HTMLDocument6_get_compatible,
422 HTMLDocument6_get_documentMode,
423 HTMLDocument6_put_onstorage,
424 HTMLDocument6_get_onstorage,
425 HTMLDocument6_put_onstoragecommit,
426 HTMLDocument6_get_onstoragecommit,
427 HTMLDocument6_getElementById,
428 HTMLDocument6_updateSettings
431 void HTMLDocument_HTMLDocument5_Init(HTMLDocument *This)
433 This->IHTMLDocument5_iface.lpVtbl = &HTMLDocument5Vtbl;
434 This->IHTMLDocument6_iface.lpVtbl = &HTMLDocument6Vtbl;