directmanipulation: Return S_OK form viewport_SetViewportOptions stub.
[wine/zf.git] / dlls / mshtml / htmllink.c
blob22342027cbc30793b1eec5c27dd438c5d23f7bef
1 /*
2 * Copyright 2012 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 <stdarg.h>
20 #include <assert.h>
22 #define COBJMACROS
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winuser.h"
27 #include "ole2.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 struct HTMLLinkElement {
37 HTMLElement element;
38 IHTMLLinkElement IHTMLLinkElement_iface;
40 nsIDOMHTMLLinkElement *nslink;
43 static inline HTMLLinkElement *impl_from_IHTMLLinkElement(IHTMLLinkElement *iface)
45 return CONTAINING_RECORD(iface, HTMLLinkElement, IHTMLLinkElement_iface);
48 static HRESULT WINAPI HTMLLinkElement_QueryInterface(IHTMLLinkElement *iface,
49 REFIID riid, void **ppv)
51 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
53 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
56 static ULONG WINAPI HTMLLinkElement_AddRef(IHTMLLinkElement *iface)
58 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
60 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
63 static ULONG WINAPI HTMLLinkElement_Release(IHTMLLinkElement *iface)
65 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
67 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
70 static HRESULT WINAPI HTMLLinkElement_GetTypeInfoCount(IHTMLLinkElement *iface, UINT *pctinfo)
72 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
74 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
77 static HRESULT WINAPI HTMLLinkElement_GetTypeInfo(IHTMLLinkElement *iface, UINT iTInfo,
78 LCID lcid, ITypeInfo **ppTInfo)
80 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
82 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
83 ppTInfo);
86 static HRESULT WINAPI HTMLLinkElement_GetIDsOfNames(IHTMLLinkElement *iface, REFIID riid,
87 LPOLESTR *rgszNames, UINT cNames,
88 LCID lcid, DISPID *rgDispId)
90 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
92 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
93 cNames, lcid, rgDispId);
96 static HRESULT WINAPI HTMLLinkElement_Invoke(IHTMLLinkElement *iface, DISPID dispIdMember,
97 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
98 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
100 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
102 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
103 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
106 static HRESULT WINAPI HTMLLinkElement_put_href(IHTMLLinkElement *iface, BSTR v)
108 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
109 nsAString href_str;
110 nsresult nsres;
112 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
114 nsAString_InitDepend(&href_str, v);
115 nsres = nsIDOMHTMLLinkElement_SetHref(This->nslink, &href_str);
116 nsAString_Finish(&href_str);
118 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
121 static HRESULT WINAPI HTMLLinkElement_get_href(IHTMLLinkElement *iface, BSTR *p)
123 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
124 nsAString href_str;
125 nsresult nsres;
127 TRACE("(%p)->(%p)\n", This, p);
129 nsAString_Init(&href_str, NULL);
130 nsres = nsIDOMHTMLLinkElement_GetHref(This->nslink, &href_str);
131 return return_nsstr(nsres, &href_str, p);
134 static HRESULT WINAPI HTMLLinkElement_put_rel(IHTMLLinkElement *iface, BSTR v)
136 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
137 nsAString rel_str;
138 nsresult nsres;
140 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
142 nsAString_InitDepend(&rel_str, v);
143 nsres = nsIDOMHTMLLinkElement_SetRel(This->nslink, &rel_str);
144 nsAString_Finish(&rel_str);
146 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
149 static HRESULT WINAPI HTMLLinkElement_get_rel(IHTMLLinkElement *iface, BSTR *p)
151 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
152 nsAString rel_str;
153 nsresult nsres;
155 TRACE("(%p)->(%p)\n", This, p);
157 nsAString_Init(&rel_str, NULL);
158 nsres = nsIDOMHTMLLinkElement_GetRel(This->nslink, &rel_str);
159 return return_nsstr(nsres, &rel_str, p);
162 static HRESULT WINAPI HTMLLinkElement_put_rev(IHTMLLinkElement *iface, BSTR v)
164 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
165 nsAString nsstr;
166 nsresult nsres;
168 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
170 nsAString_InitDepend(&nsstr, v);
171 nsres = nsIDOMHTMLLinkElement_SetRev(This->nslink, &nsstr);
172 nsAString_Finish(&nsstr);
173 if(NS_FAILED(nsres)) {
174 ERR("SetRev failed: %08x\n", nsres);
175 return E_FAIL;
178 return S_OK;
181 static HRESULT WINAPI HTMLLinkElement_get_rev(IHTMLLinkElement *iface, BSTR *p)
183 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
184 nsAString nsstr;
185 nsresult nsres;
187 TRACE("(%p)->(%p)\n", This, p);
189 nsAString_Init(&nsstr, NULL);
190 nsres = nsIDOMHTMLLinkElement_GetRev(This->nslink, &nsstr);
191 return return_nsstr(nsres, &nsstr, p);
194 static HRESULT WINAPI HTMLLinkElement_put_type(IHTMLLinkElement *iface, BSTR v)
196 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
197 nsAString type_str;
198 nsresult nsres;
200 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
202 nsAString_InitDepend(&type_str, v);
203 nsres = nsIDOMHTMLLinkElement_SetType(This->nslink, &type_str);
204 nsAString_Finish(&type_str);
206 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
209 static HRESULT WINAPI HTMLLinkElement_get_type(IHTMLLinkElement *iface, BSTR *p)
211 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
212 nsAString type_str;
213 nsresult nsres;
215 TRACE("(%p)->(%p)\n", This, p);
217 nsAString_Init(&type_str, NULL);
218 nsres = nsIDOMHTMLLinkElement_GetType(This->nslink, &type_str);
219 return return_nsstr(nsres, &type_str, p);
222 static HRESULT WINAPI HTMLLinkElement_get_readyState(IHTMLLinkElement *iface, BSTR *p)
224 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
225 FIXME("(%p)->(%p)\n", This, p);
226 return E_NOTIMPL;
229 static HRESULT WINAPI HTMLLinkElement_put_onreadystatechange(IHTMLLinkElement *iface, VARIANT v)
231 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
232 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
233 return E_NOTIMPL;
236 static HRESULT WINAPI HTMLLinkElement_get_onreadystatechange(IHTMLLinkElement *iface, VARIANT *p)
238 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
239 FIXME("(%p)->(%p)\n", This, p);
240 return E_NOTIMPL;
243 static HRESULT WINAPI HTMLLinkElement_put_onload(IHTMLLinkElement *iface, VARIANT v)
245 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
247 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
249 return set_node_event(&This->element.node, EVENTID_LOAD, &v);
252 static HRESULT WINAPI HTMLLinkElement_get_onload(IHTMLLinkElement *iface, VARIANT *p)
254 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
256 TRACE("(%p)->(%p)\n", This, p);
258 return get_node_event(&This->element.node, EVENTID_LOAD, p);
261 static HRESULT WINAPI HTMLLinkElement_put_onerror(IHTMLLinkElement *iface, VARIANT v)
263 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
264 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
265 return E_NOTIMPL;
268 static HRESULT WINAPI HTMLLinkElement_get_onerror(IHTMLLinkElement *iface, VARIANT *p)
270 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
271 FIXME("(%p)->(%p)\n", This, p);
272 return E_NOTIMPL;
275 static HRESULT WINAPI HTMLLinkElement_get_styleSheet(IHTMLLinkElement *iface, IHTMLStyleSheet **p)
277 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
278 FIXME("(%p)->(%p)\n", This, p);
279 return E_NOTIMPL;
282 static HRESULT WINAPI HTMLLinkElement_put_disabled(IHTMLLinkElement *iface, VARIANT_BOOL v)
284 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
285 nsresult nsres;
287 TRACE("(%p)->(%x)\n", This, v);
289 nsres = nsIDOMHTMLLinkElement_SetDisabled(This->nslink, !!v);
290 return SUCCEEDED(nsres) ? S_OK : E_FAIL;
293 static HRESULT WINAPI HTMLLinkElement_get_disabled(IHTMLLinkElement *iface, VARIANT_BOOL *p)
295 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
296 cpp_bool ret;
297 nsresult nsres;
299 TRACE("(%p)->(%p)\n", This, p);
301 nsres = nsIDOMHTMLLinkElement_GetDisabled(This->nslink, &ret);
302 if(NS_FAILED(nsres))
303 return E_FAIL;
305 *p = variant_bool(ret);
306 return S_OK;
309 static HRESULT WINAPI HTMLLinkElement_put_media(IHTMLLinkElement *iface, BSTR v)
311 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
312 nsresult nsres;
313 nsAString str;
315 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
317 nsAString_InitDepend(&str, v);
319 nsres = nsIDOMHTMLLinkElement_SetMedia(This->nslink, &str);
320 nsAString_Finish(&str);
322 if(NS_FAILED(nsres)) {
323 ERR("Set Media(%s) failed: %08x\n", debugstr_w(v), nsres);
324 return E_FAIL;
326 return S_OK;
329 static HRESULT WINAPI HTMLLinkElement_get_media(IHTMLLinkElement *iface, BSTR *p)
331 HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
332 nsresult nsres;
333 nsAString str;
335 TRACE("(%p)->(%p)\n", This, p);
337 nsAString_Init(&str, NULL);
338 nsres = nsIDOMHTMLLinkElement_GetMedia(This->nslink, &str);
340 return return_nsstr(nsres, &str, p);
343 static const IHTMLLinkElementVtbl HTMLLinkElementVtbl = {
344 HTMLLinkElement_QueryInterface,
345 HTMLLinkElement_AddRef,
346 HTMLLinkElement_Release,
347 HTMLLinkElement_GetTypeInfoCount,
348 HTMLLinkElement_GetTypeInfo,
349 HTMLLinkElement_GetIDsOfNames,
350 HTMLLinkElement_Invoke,
351 HTMLLinkElement_put_href,
352 HTMLLinkElement_get_href,
353 HTMLLinkElement_put_rel,
354 HTMLLinkElement_get_rel,
355 HTMLLinkElement_put_rev,
356 HTMLLinkElement_get_rev,
357 HTMLLinkElement_put_type,
358 HTMLLinkElement_get_type,
359 HTMLLinkElement_get_readyState,
360 HTMLLinkElement_put_onreadystatechange,
361 HTMLLinkElement_get_onreadystatechange,
362 HTMLLinkElement_put_onload,
363 HTMLLinkElement_get_onload,
364 HTMLLinkElement_put_onerror,
365 HTMLLinkElement_get_onerror,
366 HTMLLinkElement_get_styleSheet,
367 HTMLLinkElement_put_disabled,
368 HTMLLinkElement_get_disabled,
369 HTMLLinkElement_put_media,
370 HTMLLinkElement_get_media
373 static inline HTMLLinkElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
375 return CONTAINING_RECORD(iface, HTMLLinkElement, element.node);
378 static HRESULT HTMLLinkElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
380 HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
382 if(IsEqualGUID(&IID_IHTMLLinkElement, riid)) {
383 TRACE("(%p)->(IID_IHTMLLinkElement %p)\n", This, ppv);
384 *ppv = &This->IHTMLLinkElement_iface;
385 }else {
386 return HTMLElement_QI(&This->element.node, riid, ppv);
389 IUnknown_AddRef((IUnknown*)*ppv);
390 return S_OK;
393 static HRESULT HTMLLinkElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
395 HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
396 return IHTMLLinkElement_put_disabled(&This->IHTMLLinkElement_iface, v);
399 static HRESULT HTMLLinkElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
401 HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
402 return IHTMLLinkElement_get_disabled(&This->IHTMLLinkElement_iface, p);
405 static void HTMLLinkElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
407 HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
409 if(This->nslink)
410 note_cc_edge((nsISupports*)This->nslink, "This->nslink", cb);
413 static void HTMLLinkElement_unlink(HTMLDOMNode *iface)
415 HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
417 if(This->nslink) {
418 nsIDOMHTMLLinkElement *nslink = This->nslink;
420 This->nslink = NULL;
421 nsIDOMHTMLLinkElement_Release(nslink);
424 static const NodeImplVtbl HTMLLinkElementImplVtbl = {
425 &CLSID_HTMLLinkElement,
426 HTMLLinkElement_QI,
427 HTMLElement_destructor,
428 HTMLElement_cpc,
429 HTMLElement_clone,
430 HTMLElement_handle_event,
431 HTMLElement_get_attr_col,
432 NULL,
433 HTMLLinkElementImpl_put_disabled,
434 HTMLLinkElementImpl_get_disabled,
435 NULL,
436 NULL,
437 NULL,
438 NULL,
439 NULL,
440 HTMLLinkElement_traverse,
441 HTMLLinkElement_unlink
444 static const tid_t HTMLLinkElement_iface_tids[] = {
445 HTMLELEMENT_TIDS,
446 IHTMLLinkElement_tid,
449 static dispex_static_data_t HTMLLinkElement_dispex = {
450 NULL,
451 DispHTMLLinkElement_tid,
452 HTMLLinkElement_iface_tids,
453 HTMLElement_init_dispex_info
456 HRESULT HTMLLinkElement_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
458 HTMLLinkElement *ret;
459 nsresult nsres;
461 ret = heap_alloc_zero(sizeof(*ret));
462 if(!ret)
463 return E_OUTOFMEMORY;
465 ret->IHTMLLinkElement_iface.lpVtbl = &HTMLLinkElementVtbl;
466 ret->element.node.vtbl = &HTMLLinkElementImplVtbl;
468 HTMLElement_Init(&ret->element, doc, nselem, &HTMLLinkElement_dispex);
470 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLLinkElement, (void**)&ret->nslink);
471 assert(nsres == NS_OK);
473 *elem = &ret->element;
474 return S_OK;