ReactOS 0.4.15-dev-7712-gbbbcd8e
htmllink.c
Go to the documentation of this file.
1 /*
2 * Copyright 2012 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
21typedef struct {
23 IHTMLLinkElement IHTMLLinkElement_iface;
24
27
28static inline HTMLLinkElement *impl_from_IHTMLLinkElement(IHTMLLinkElement *iface)
29{
30 return CONTAINING_RECORD(iface, HTMLLinkElement, IHTMLLinkElement_iface);
31}
32
33static HRESULT WINAPI HTMLLinkElement_QueryInterface(IHTMLLinkElement *iface,
34 REFIID riid, void **ppv)
35{
37
38 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
39}
40
41static ULONG WINAPI HTMLLinkElement_AddRef(IHTMLLinkElement *iface)
42{
44
45 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
46}
47
48static ULONG WINAPI HTMLLinkElement_Release(IHTMLLinkElement *iface)
49{
51
52 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
53}
54
55static HRESULT WINAPI HTMLLinkElement_GetTypeInfoCount(IHTMLLinkElement *iface, UINT *pctinfo)
56{
58
59 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
60}
61
62static HRESULT WINAPI HTMLLinkElement_GetTypeInfo(IHTMLLinkElement *iface, UINT iTInfo,
63 LCID lcid, ITypeInfo **ppTInfo)
64{
66
67 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
68 ppTInfo);
69}
70
71static HRESULT WINAPI HTMLLinkElement_GetIDsOfNames(IHTMLLinkElement *iface, REFIID riid,
72 LPOLESTR *rgszNames, UINT cNames,
73 LCID lcid, DISPID *rgDispId)
74{
76
77 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
78 cNames, lcid, rgDispId);
79}
80
81static HRESULT WINAPI HTMLLinkElement_Invoke(IHTMLLinkElement *iface, DISPID dispIdMember,
82 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
83 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
84{
86
87 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
88 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
89}
90
91static HRESULT WINAPI HTMLLinkElement_put_href(IHTMLLinkElement *iface, BSTR v)
92{
94 nsAString href_str;
95 nsresult nsres;
96
97 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
98
99 nsAString_InitDepend(&href_str, v);
100 nsres = nsIDOMHTMLLinkElement_SetHref(This->nslink, &href_str);
101 nsAString_Finish(&href_str);
102
103 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
104}
105
106static HRESULT WINAPI HTMLLinkElement_get_href(IHTMLLinkElement *iface, BSTR *p)
107{
109 nsAString href_str;
110 nsresult nsres;
111
112 TRACE("(%p)->(%p)\n", This, p);
113
114 nsAString_Init(&href_str, NULL);
115 nsres = nsIDOMHTMLLinkElement_GetHref(This->nslink, &href_str);
116 return return_nsstr(nsres, &href_str, p);
117}
118
119static HRESULT WINAPI HTMLLinkElement_put_rel(IHTMLLinkElement *iface, BSTR v)
120{
122 nsAString rel_str;
123 nsresult nsres;
124
125 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
126
127 nsAString_InitDepend(&rel_str, v);
128 nsres = nsIDOMHTMLLinkElement_SetRel(This->nslink, &rel_str);
129 nsAString_Finish(&rel_str);
130
131 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
132}
133
134static HRESULT WINAPI HTMLLinkElement_get_rel(IHTMLLinkElement *iface, BSTR *p)
135{
137 nsAString rel_str;
138 nsresult nsres;
139
140 TRACE("(%p)->(%p)\n", This, p);
141
142 nsAString_Init(&rel_str, NULL);
143 nsres = nsIDOMHTMLLinkElement_GetRel(This->nslink, &rel_str);
144 return return_nsstr(nsres, &rel_str, p);
145}
146
147static HRESULT WINAPI HTMLLinkElement_put_rev(IHTMLLinkElement *iface, BSTR v)
148{
150 nsAString nsstr;
151 nsresult nsres;
152
153 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
154
155 nsAString_InitDepend(&nsstr, v);
156 nsres = nsIDOMHTMLLinkElement_SetRev(This->nslink, &nsstr);
157 nsAString_Finish(&nsstr);
158 if(NS_FAILED(nsres)) {
159 ERR("SetRev failed: %08x\n", nsres);
160 return E_FAIL;
161 }
162
163 return S_OK;
164}
165
166static HRESULT WINAPI HTMLLinkElement_get_rev(IHTMLLinkElement *iface, BSTR *p)
167{
169 nsAString nsstr;
170 nsresult nsres;
171
172 TRACE("(%p)->(%p)\n", This, p);
173
174 nsAString_Init(&nsstr, NULL);
175 nsres = nsIDOMHTMLLinkElement_GetRev(This->nslink, &nsstr);
176 return return_nsstr(nsres, &nsstr, p);
177}
178
179static HRESULT WINAPI HTMLLinkElement_put_type(IHTMLLinkElement *iface, BSTR v)
180{
182 nsAString type_str;
183 nsresult nsres;
184
185 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
186
187 nsAString_InitDepend(&type_str, v);
188 nsres = nsIDOMHTMLLinkElement_SetType(This->nslink, &type_str);
189 nsAString_Finish(&type_str);
190
191 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
192}
193
194static HRESULT WINAPI HTMLLinkElement_get_type(IHTMLLinkElement *iface, BSTR *p)
195{
197 nsAString type_str;
198 nsresult nsres;
199
200 TRACE("(%p)->(%p)\n", This, p);
201
202 nsAString_Init(&type_str, NULL);
203 nsres = nsIDOMHTMLLinkElement_GetType(This->nslink, &type_str);
204 return return_nsstr(nsres, &type_str, p);
205}
206
207static HRESULT WINAPI HTMLLinkElement_get_readyState(IHTMLLinkElement *iface, BSTR *p)
208{
210 FIXME("(%p)->(%p)\n", This, p);
211 return E_NOTIMPL;
212}
213
215{
217 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
218 return E_NOTIMPL;
219}
220
222{
224 FIXME("(%p)->(%p)\n", This, p);
225 return E_NOTIMPL;
226}
227
228static HRESULT WINAPI HTMLLinkElement_put_onload(IHTMLLinkElement *iface, VARIANT v)
229{
231 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
232 return E_NOTIMPL;
233}
234
235static HRESULT WINAPI HTMLLinkElement_get_onload(IHTMLLinkElement *iface, VARIANT *p)
236{
238 FIXME("(%p)->(%p)\n", This, p);
239 return E_NOTIMPL;
240}
241
242static HRESULT WINAPI HTMLLinkElement_put_onerror(IHTMLLinkElement *iface, VARIANT v)
243{
245 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
246 return E_NOTIMPL;
247}
248
249static HRESULT WINAPI HTMLLinkElement_get_onerror(IHTMLLinkElement *iface, VARIANT *p)
250{
252 FIXME("(%p)->(%p)\n", This, p);
253 return E_NOTIMPL;
254}
255
256static HRESULT WINAPI HTMLLinkElement_get_styleSheet(IHTMLLinkElement *iface, IHTMLStyleSheet **p)
257{
259 FIXME("(%p)->(%p)\n", This, p);
260 return E_NOTIMPL;
261}
262
264{
266 nsresult nsres;
267
268 TRACE("(%p)->(%x)\n", This, v);
269
270 nsres = nsIDOMHTMLLinkElement_SetDisabled(This->nslink, !!v);
271 return SUCCEEDED(nsres) ? S_OK : E_FAIL;
272}
273
275{
278 nsresult nsres;
279
280 TRACE("(%p)->(%p)\n", This, p);
281
282 nsres = nsIDOMHTMLLinkElement_GetDisabled(This->nslink, &ret);
283 if(NS_FAILED(nsres))
284 return E_FAIL;
285
286 *p = ret ? VARIANT_TRUE : VARIANT_FALSE;
287 return S_OK;
288}
289
290static HRESULT WINAPI HTMLLinkElement_put_media(IHTMLLinkElement *iface, BSTR v)
291{
293 nsresult nsres;
295
296 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
297
299
300 nsres = nsIDOMHTMLLinkElement_SetMedia(This->nslink, &str);
302
303 if(NS_FAILED(nsres)) {
304 ERR("Set Media(%s) failed: %08x\n", debugstr_w(v), nsres);
305 return E_FAIL;
306 }
307 return S_OK;
308}
309
310static HRESULT WINAPI HTMLLinkElement_get_media(IHTMLLinkElement *iface, BSTR *p)
311{
313 nsresult nsres;
315
316 TRACE("(%p)->(%p)\n", This, p);
317
319 nsres = nsIDOMHTMLLinkElement_GetMedia(This->nslink, &str);
320
321 return return_nsstr(nsres, &str, p);
322}
323
324static const IHTMLLinkElementVtbl HTMLLinkElementVtbl = {
352};
353
355{
356 return CONTAINING_RECORD(iface, HTMLLinkElement, element.node);
357}
358
360{
362
363 if(IsEqualGUID(&IID_IHTMLLinkElement, riid)) {
364 TRACE("(%p)->(IID_IHTMLLinkElement %p)\n", This, ppv);
365 *ppv = &This->IHTMLLinkElement_iface;
366 }else {
367 return HTMLElement_QI(&This->element.node, riid, ppv);
368 }
369
370 IUnknown_AddRef((IUnknown*)*ppv);
371 return S_OK;
372}
373
375{
377 return IHTMLLinkElement_put_disabled(&This->IHTMLLinkElement_iface, v);
378}
379
381{
383 return IHTMLLinkElement_get_disabled(&This->IHTMLLinkElement_iface, p);
384}
385
387{
389
390 if(This->nslink)
391 note_cc_edge((nsISupports*)This->nslink, "This->nslink", cb);
392}
393
395{
397
398 if(This->nslink) {
399 nsIDOMHTMLLinkElement *nslink = This->nslink;
400
401 This->nslink = NULL;
402 nsIDOMHTMLLinkElement_Release(nslink);
403 }
404}
412 NULL,
413 NULL,
416 NULL,
417 NULL,
418 NULL,
419 NULL,
420 NULL,
423};
424
427 IHTMLLinkElement_tid,
428 0
429};
431 NULL,
432 DispHTMLLinkElement_tid,
433 NULL,
435};
436
438{
440 nsresult nsres;
441
442 ret = heap_alloc_zero(sizeof(*ret));
443 if(!ret)
444 return E_OUTOFMEMORY;
445
446 ret->IHTMLLinkElement_iface.lpVtbl = &HTMLLinkElementVtbl;
447 ret->element.node.vtbl = &HTMLLinkElementImplVtbl;
448
449 HTMLElement_Init(&ret->element, doc, nselem, &HTMLLinkElement_dispex);
450
451 nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLLinkElement, (void**)&ret->nslink);
452 assert(nsres == NS_OK);
453
454 *elem = &ret->element;
455 return S_OK;
456}
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERR(fmt,...)
Definition: debug.h:110
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
unsigned char cpp_bool
Definition: atl.c:38
OLECHAR * BSTR
Definition: compat.h:2293
short VARIANT_BOOL
Definition: compat.h:2290
#define assert(x)
Definition: debug.h:53
unsigned short WORD
Definition: ntddk_ex.h:93
const GLdouble * v
Definition: gl.h:2040
GLfloat GLfloat p
Definition: glext.h:8902
HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
Definition: htmlelem.c:3793
void HTMLElement_destructor(HTMLDOMNode *iface)
Definition: htmlelem.c:3764
HRESULT HTMLElement_handle_event(HTMLDOMNode *iface, DWORD eid, nsIDOMEvent *event, BOOL *prevent_default)
Definition: htmlelem.c:3815
const cpc_entry_t HTMLElement_cpc[]
Definition: htmlelem.c:3847
void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
Definition: htmlelem.c:4008
HRESULT HTMLElement_get_attr_col(HTMLDOMNode *iface, HTMLAttributeCollection **ac)
Definition: htmlelem.c:4827
HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
Definition: htmlelem.c:3738
tid_t
Definition: ieframe.h:311
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define debugstr_w
Definition: kernel32.h:32
static const char * debugstr_variant(const VARIANT *var)
Definition: container.c:46
static HMODULE MODULEINFO DWORD cb
Definition: module.c:33
static size_t elem
Definition: string.c:68
static LPOLESTR
Definition: stg_prop.c:27
static VARIANTARG static DISPID
Definition: ordinal.c:52
#define NS_OK
void nsAString_Finish(nsAString *) DECLSPEC_HIDDEN
Definition: nsembed.c:836
#define HTMLELEMENT_TIDS
void nsAString_InitDepend(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:826
BOOL nsAString_Init(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:817
struct nsCycleCollectionTraversalCallback nsCycleCollectionTraversalCallback
#define NS_SUCCEEDED(res)
#define NS_FAILED(res)
HRESULT return_nsstr(nsresult, nsAString *, BSTR *) DECLSPEC_HIDDEN
Definition: nsembed.c:841
unsigned int UINT
Definition: ndis.h:50
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
const WCHAR * str
DWORD LCID
Definition: nls.h:13
#define TRACE(s)
Definition: solgame.cpp:4
HTMLElement element
Definition: htmllink.c:22
IHTMLLinkElement IHTMLLinkElement_iface
Definition: htmllink.c:23
nsIDOMHTMLLinkElement * nslink
Definition: htmllink.c:25
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
int ret
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
#define WINAPI
Definition: msvc.h:6