xref: /reactos/dll/win32/mshtml/htmllink.c (revision c2c66aff)
1*c2c66affSColin Finck  /*
2*c2c66affSColin Finck  * Copyright 2012 Jacek Caban for CodeWeavers
3*c2c66affSColin Finck  *
4*c2c66affSColin Finck  * This library is free software; you can redistribute it and/or
5*c2c66affSColin Finck  * modify it under the terms of the GNU Lesser General Public
6*c2c66affSColin Finck  * License as published by the Free Software Foundation; either
7*c2c66affSColin Finck  * version 2.1 of the License, or (at your option) any later version.
8*c2c66affSColin Finck  *
9*c2c66affSColin Finck  * This library is distributed in the hope that it will be useful,
10*c2c66affSColin Finck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11*c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12*c2c66affSColin Finck  * Lesser General Public License for more details.
13*c2c66affSColin Finck  *
14*c2c66affSColin Finck  * You should have received a copy of the GNU Lesser General Public
15*c2c66affSColin Finck  * License along with this library; if not, write to the Free Software
16*c2c66affSColin Finck  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17*c2c66affSColin Finck  */
18*c2c66affSColin Finck 
19*c2c66affSColin Finck #include "mshtml_private.h"
20*c2c66affSColin Finck 
21*c2c66affSColin Finck typedef struct {
22*c2c66affSColin Finck     HTMLElement element;
23*c2c66affSColin Finck     IHTMLLinkElement IHTMLLinkElement_iface;
24*c2c66affSColin Finck 
25*c2c66affSColin Finck     nsIDOMHTMLLinkElement *nslink;
26*c2c66affSColin Finck } HTMLLinkElement;
27*c2c66affSColin Finck 
impl_from_IHTMLLinkElement(IHTMLLinkElement * iface)28*c2c66affSColin Finck static inline HTMLLinkElement *impl_from_IHTMLLinkElement(IHTMLLinkElement *iface)
29*c2c66affSColin Finck {
30*c2c66affSColin Finck     return CONTAINING_RECORD(iface, HTMLLinkElement, IHTMLLinkElement_iface);
31*c2c66affSColin Finck }
32*c2c66affSColin Finck 
HTMLLinkElement_QueryInterface(IHTMLLinkElement * iface,REFIID riid,void ** ppv)33*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_QueryInterface(IHTMLLinkElement *iface,
34*c2c66affSColin Finck                                                          REFIID riid, void **ppv)
35*c2c66affSColin Finck {
36*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
37*c2c66affSColin Finck 
38*c2c66affSColin Finck     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
39*c2c66affSColin Finck }
40*c2c66affSColin Finck 
HTMLLinkElement_AddRef(IHTMLLinkElement * iface)41*c2c66affSColin Finck static ULONG WINAPI HTMLLinkElement_AddRef(IHTMLLinkElement *iface)
42*c2c66affSColin Finck {
43*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
44*c2c66affSColin Finck 
45*c2c66affSColin Finck     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
46*c2c66affSColin Finck }
47*c2c66affSColin Finck 
HTMLLinkElement_Release(IHTMLLinkElement * iface)48*c2c66affSColin Finck static ULONG WINAPI HTMLLinkElement_Release(IHTMLLinkElement *iface)
49*c2c66affSColin Finck {
50*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
51*c2c66affSColin Finck 
52*c2c66affSColin Finck     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
53*c2c66affSColin Finck }
54*c2c66affSColin Finck 
HTMLLinkElement_GetTypeInfoCount(IHTMLLinkElement * iface,UINT * pctinfo)55*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_GetTypeInfoCount(IHTMLLinkElement *iface, UINT *pctinfo)
56*c2c66affSColin Finck {
57*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
58*c2c66affSColin Finck 
59*c2c66affSColin Finck     return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
60*c2c66affSColin Finck }
61*c2c66affSColin Finck 
HTMLLinkElement_GetTypeInfo(IHTMLLinkElement * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)62*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_GetTypeInfo(IHTMLLinkElement *iface, UINT iTInfo,
63*c2c66affSColin Finck                                               LCID lcid, ITypeInfo **ppTInfo)
64*c2c66affSColin Finck {
65*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
66*c2c66affSColin Finck 
67*c2c66affSColin Finck     return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
68*c2c66affSColin Finck             ppTInfo);
69*c2c66affSColin Finck }
70*c2c66affSColin Finck 
HTMLLinkElement_GetIDsOfNames(IHTMLLinkElement * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)71*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_GetIDsOfNames(IHTMLLinkElement *iface, REFIID riid,
72*c2c66affSColin Finck                                                 LPOLESTR *rgszNames, UINT cNames,
73*c2c66affSColin Finck                                                 LCID lcid, DISPID *rgDispId)
74*c2c66affSColin Finck {
75*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
76*c2c66affSColin Finck 
77*c2c66affSColin Finck     return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
78*c2c66affSColin Finck             cNames, lcid, rgDispId);
79*c2c66affSColin Finck }
80*c2c66affSColin Finck 
HTMLLinkElement_Invoke(IHTMLLinkElement * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)81*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_Invoke(IHTMLLinkElement *iface, DISPID dispIdMember,
82*c2c66affSColin Finck                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
83*c2c66affSColin Finck                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
84*c2c66affSColin Finck {
85*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
86*c2c66affSColin Finck 
87*c2c66affSColin Finck     return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
88*c2c66affSColin Finck             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
89*c2c66affSColin Finck }
90*c2c66affSColin Finck 
HTMLLinkElement_put_href(IHTMLLinkElement * iface,BSTR v)91*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_put_href(IHTMLLinkElement *iface, BSTR v)
92*c2c66affSColin Finck {
93*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
94*c2c66affSColin Finck     nsAString href_str;
95*c2c66affSColin Finck     nsresult nsres;
96*c2c66affSColin Finck 
97*c2c66affSColin Finck     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
98*c2c66affSColin Finck 
99*c2c66affSColin Finck     nsAString_InitDepend(&href_str, v);
100*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_SetHref(This->nslink, &href_str);
101*c2c66affSColin Finck     nsAString_Finish(&href_str);
102*c2c66affSColin Finck 
103*c2c66affSColin Finck     return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
104*c2c66affSColin Finck }
105*c2c66affSColin Finck 
HTMLLinkElement_get_href(IHTMLLinkElement * iface,BSTR * p)106*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_href(IHTMLLinkElement *iface, BSTR *p)
107*c2c66affSColin Finck {
108*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
109*c2c66affSColin Finck     nsAString href_str;
110*c2c66affSColin Finck     nsresult nsres;
111*c2c66affSColin Finck 
112*c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, p);
113*c2c66affSColin Finck 
114*c2c66affSColin Finck     nsAString_Init(&href_str, NULL);
115*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_GetHref(This->nslink, &href_str);
116*c2c66affSColin Finck     return return_nsstr(nsres, &href_str, p);
117*c2c66affSColin Finck }
118*c2c66affSColin Finck 
HTMLLinkElement_put_rel(IHTMLLinkElement * iface,BSTR v)119*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_put_rel(IHTMLLinkElement *iface, BSTR v)
120*c2c66affSColin Finck {
121*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
122*c2c66affSColin Finck     nsAString rel_str;
123*c2c66affSColin Finck     nsresult nsres;
124*c2c66affSColin Finck 
125*c2c66affSColin Finck     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
126*c2c66affSColin Finck 
127*c2c66affSColin Finck     nsAString_InitDepend(&rel_str, v);
128*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_SetRel(This->nslink, &rel_str);
129*c2c66affSColin Finck     nsAString_Finish(&rel_str);
130*c2c66affSColin Finck 
131*c2c66affSColin Finck     return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
132*c2c66affSColin Finck }
133*c2c66affSColin Finck 
HTMLLinkElement_get_rel(IHTMLLinkElement * iface,BSTR * p)134*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_rel(IHTMLLinkElement *iface, BSTR *p)
135*c2c66affSColin Finck {
136*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
137*c2c66affSColin Finck     nsAString rel_str;
138*c2c66affSColin Finck     nsresult nsres;
139*c2c66affSColin Finck 
140*c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, p);
141*c2c66affSColin Finck 
142*c2c66affSColin Finck     nsAString_Init(&rel_str, NULL);
143*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_GetRel(This->nslink, &rel_str);
144*c2c66affSColin Finck     return return_nsstr(nsres, &rel_str, p);
145*c2c66affSColin Finck }
146*c2c66affSColin Finck 
HTMLLinkElement_put_rev(IHTMLLinkElement * iface,BSTR v)147*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_put_rev(IHTMLLinkElement *iface, BSTR v)
148*c2c66affSColin Finck {
149*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
150*c2c66affSColin Finck     nsAString nsstr;
151*c2c66affSColin Finck     nsresult nsres;
152*c2c66affSColin Finck 
153*c2c66affSColin Finck     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
154*c2c66affSColin Finck 
155*c2c66affSColin Finck     nsAString_InitDepend(&nsstr, v);
156*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_SetRev(This->nslink, &nsstr);
157*c2c66affSColin Finck     nsAString_Finish(&nsstr);
158*c2c66affSColin Finck     if(NS_FAILED(nsres)) {
159*c2c66affSColin Finck         ERR("SetRev failed: %08x\n", nsres);
160*c2c66affSColin Finck         return E_FAIL;
161*c2c66affSColin Finck     }
162*c2c66affSColin Finck 
163*c2c66affSColin Finck     return S_OK;
164*c2c66affSColin Finck }
165*c2c66affSColin Finck 
HTMLLinkElement_get_rev(IHTMLLinkElement * iface,BSTR * p)166*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_rev(IHTMLLinkElement *iface, BSTR *p)
167*c2c66affSColin Finck {
168*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
169*c2c66affSColin Finck     nsAString nsstr;
170*c2c66affSColin Finck     nsresult nsres;
171*c2c66affSColin Finck 
172*c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, p);
173*c2c66affSColin Finck 
174*c2c66affSColin Finck     nsAString_Init(&nsstr, NULL);
175*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_GetRev(This->nslink, &nsstr);
176*c2c66affSColin Finck     return return_nsstr(nsres, &nsstr, p);
177*c2c66affSColin Finck }
178*c2c66affSColin Finck 
HTMLLinkElement_put_type(IHTMLLinkElement * iface,BSTR v)179*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_put_type(IHTMLLinkElement *iface, BSTR v)
180*c2c66affSColin Finck {
181*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
182*c2c66affSColin Finck     nsAString type_str;
183*c2c66affSColin Finck     nsresult nsres;
184*c2c66affSColin Finck 
185*c2c66affSColin Finck     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
186*c2c66affSColin Finck 
187*c2c66affSColin Finck     nsAString_InitDepend(&type_str, v);
188*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_SetType(This->nslink, &type_str);
189*c2c66affSColin Finck     nsAString_Finish(&type_str);
190*c2c66affSColin Finck 
191*c2c66affSColin Finck     return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
192*c2c66affSColin Finck }
193*c2c66affSColin Finck 
HTMLLinkElement_get_type(IHTMLLinkElement * iface,BSTR * p)194*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_type(IHTMLLinkElement *iface, BSTR *p)
195*c2c66affSColin Finck {
196*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
197*c2c66affSColin Finck     nsAString type_str;
198*c2c66affSColin Finck     nsresult nsres;
199*c2c66affSColin Finck 
200*c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, p);
201*c2c66affSColin Finck 
202*c2c66affSColin Finck     nsAString_Init(&type_str, NULL);
203*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_GetType(This->nslink, &type_str);
204*c2c66affSColin Finck     return return_nsstr(nsres, &type_str, p);
205*c2c66affSColin Finck }
206*c2c66affSColin Finck 
HTMLLinkElement_get_readyState(IHTMLLinkElement * iface,BSTR * p)207*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_readyState(IHTMLLinkElement *iface, BSTR *p)
208*c2c66affSColin Finck {
209*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
210*c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, p);
211*c2c66affSColin Finck     return E_NOTIMPL;
212*c2c66affSColin Finck }
213*c2c66affSColin Finck 
HTMLLinkElement_put_onreadystatechange(IHTMLLinkElement * iface,VARIANT v)214*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_put_onreadystatechange(IHTMLLinkElement *iface, VARIANT v)
215*c2c66affSColin Finck {
216*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
217*c2c66affSColin Finck     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
218*c2c66affSColin Finck     return E_NOTIMPL;
219*c2c66affSColin Finck }
220*c2c66affSColin Finck 
HTMLLinkElement_get_onreadystatechange(IHTMLLinkElement * iface,VARIANT * p)221*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_onreadystatechange(IHTMLLinkElement *iface, VARIANT *p)
222*c2c66affSColin Finck {
223*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
224*c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, p);
225*c2c66affSColin Finck     return E_NOTIMPL;
226*c2c66affSColin Finck }
227*c2c66affSColin Finck 
HTMLLinkElement_put_onload(IHTMLLinkElement * iface,VARIANT v)228*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_put_onload(IHTMLLinkElement *iface, VARIANT v)
229*c2c66affSColin Finck {
230*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
231*c2c66affSColin Finck     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
232*c2c66affSColin Finck     return E_NOTIMPL;
233*c2c66affSColin Finck }
234*c2c66affSColin Finck 
HTMLLinkElement_get_onload(IHTMLLinkElement * iface,VARIANT * p)235*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_onload(IHTMLLinkElement *iface, VARIANT *p)
236*c2c66affSColin Finck {
237*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
238*c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, p);
239*c2c66affSColin Finck     return E_NOTIMPL;
240*c2c66affSColin Finck }
241*c2c66affSColin Finck 
HTMLLinkElement_put_onerror(IHTMLLinkElement * iface,VARIANT v)242*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_put_onerror(IHTMLLinkElement *iface, VARIANT v)
243*c2c66affSColin Finck {
244*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
245*c2c66affSColin Finck     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
246*c2c66affSColin Finck     return E_NOTIMPL;
247*c2c66affSColin Finck }
248*c2c66affSColin Finck 
HTMLLinkElement_get_onerror(IHTMLLinkElement * iface,VARIANT * p)249*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_onerror(IHTMLLinkElement *iface, VARIANT *p)
250*c2c66affSColin Finck {
251*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
252*c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, p);
253*c2c66affSColin Finck     return E_NOTIMPL;
254*c2c66affSColin Finck }
255*c2c66affSColin Finck 
HTMLLinkElement_get_styleSheet(IHTMLLinkElement * iface,IHTMLStyleSheet ** p)256*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_styleSheet(IHTMLLinkElement *iface, IHTMLStyleSheet **p)
257*c2c66affSColin Finck {
258*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
259*c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, p);
260*c2c66affSColin Finck     return E_NOTIMPL;
261*c2c66affSColin Finck }
262*c2c66affSColin Finck 
HTMLLinkElement_put_disabled(IHTMLLinkElement * iface,VARIANT_BOOL v)263*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_put_disabled(IHTMLLinkElement *iface, VARIANT_BOOL v)
264*c2c66affSColin Finck {
265*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
266*c2c66affSColin Finck     nsresult nsres;
267*c2c66affSColin Finck 
268*c2c66affSColin Finck     TRACE("(%p)->(%x)\n", This, v);
269*c2c66affSColin Finck 
270*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_SetDisabled(This->nslink, !!v);
271*c2c66affSColin Finck     return SUCCEEDED(nsres) ? S_OK : E_FAIL;
272*c2c66affSColin Finck }
273*c2c66affSColin Finck 
HTMLLinkElement_get_disabled(IHTMLLinkElement * iface,VARIANT_BOOL * p)274*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_disabled(IHTMLLinkElement *iface, VARIANT_BOOL *p)
275*c2c66affSColin Finck {
276*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
277*c2c66affSColin Finck     cpp_bool ret;
278*c2c66affSColin Finck     nsresult nsres;
279*c2c66affSColin Finck 
280*c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, p);
281*c2c66affSColin Finck 
282*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_GetDisabled(This->nslink, &ret);
283*c2c66affSColin Finck     if(NS_FAILED(nsres))
284*c2c66affSColin Finck         return E_FAIL;
285*c2c66affSColin Finck 
286*c2c66affSColin Finck     *p = ret ? VARIANT_TRUE : VARIANT_FALSE;
287*c2c66affSColin Finck     return S_OK;
288*c2c66affSColin Finck }
289*c2c66affSColin Finck 
HTMLLinkElement_put_media(IHTMLLinkElement * iface,BSTR v)290*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_put_media(IHTMLLinkElement *iface, BSTR v)
291*c2c66affSColin Finck {
292*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
293*c2c66affSColin Finck     nsresult nsres;
294*c2c66affSColin Finck     nsAString str;
295*c2c66affSColin Finck 
296*c2c66affSColin Finck     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
297*c2c66affSColin Finck 
298*c2c66affSColin Finck     nsAString_InitDepend(&str, v);
299*c2c66affSColin Finck 
300*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_SetMedia(This->nslink, &str);
301*c2c66affSColin Finck     nsAString_Finish(&str);
302*c2c66affSColin Finck 
303*c2c66affSColin Finck     if(NS_FAILED(nsres)) {
304*c2c66affSColin Finck         ERR("Set Media(%s) failed: %08x\n", debugstr_w(v), nsres);
305*c2c66affSColin Finck         return E_FAIL;
306*c2c66affSColin Finck     }
307*c2c66affSColin Finck     return S_OK;
308*c2c66affSColin Finck }
309*c2c66affSColin Finck 
HTMLLinkElement_get_media(IHTMLLinkElement * iface,BSTR * p)310*c2c66affSColin Finck static HRESULT WINAPI HTMLLinkElement_get_media(IHTMLLinkElement *iface, BSTR *p)
311*c2c66affSColin Finck {
312*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface);
313*c2c66affSColin Finck     nsresult nsres;
314*c2c66affSColin Finck     nsAString str;
315*c2c66affSColin Finck 
316*c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, p);
317*c2c66affSColin Finck 
318*c2c66affSColin Finck     nsAString_Init(&str, NULL);
319*c2c66affSColin Finck     nsres = nsIDOMHTMLLinkElement_GetMedia(This->nslink, &str);
320*c2c66affSColin Finck 
321*c2c66affSColin Finck     return return_nsstr(nsres, &str, p);
322*c2c66affSColin Finck }
323*c2c66affSColin Finck 
324*c2c66affSColin Finck static const IHTMLLinkElementVtbl HTMLLinkElementVtbl = {
325*c2c66affSColin Finck     HTMLLinkElement_QueryInterface,
326*c2c66affSColin Finck     HTMLLinkElement_AddRef,
327*c2c66affSColin Finck     HTMLLinkElement_Release,
328*c2c66affSColin Finck     HTMLLinkElement_GetTypeInfoCount,
329*c2c66affSColin Finck     HTMLLinkElement_GetTypeInfo,
330*c2c66affSColin Finck     HTMLLinkElement_GetIDsOfNames,
331*c2c66affSColin Finck     HTMLLinkElement_Invoke,
332*c2c66affSColin Finck     HTMLLinkElement_put_href,
333*c2c66affSColin Finck     HTMLLinkElement_get_href,
334*c2c66affSColin Finck     HTMLLinkElement_put_rel,
335*c2c66affSColin Finck     HTMLLinkElement_get_rel,
336*c2c66affSColin Finck     HTMLLinkElement_put_rev,
337*c2c66affSColin Finck     HTMLLinkElement_get_rev,
338*c2c66affSColin Finck     HTMLLinkElement_put_type,
339*c2c66affSColin Finck     HTMLLinkElement_get_type,
340*c2c66affSColin Finck     HTMLLinkElement_get_readyState,
341*c2c66affSColin Finck     HTMLLinkElement_put_onreadystatechange,
342*c2c66affSColin Finck     HTMLLinkElement_get_onreadystatechange,
343*c2c66affSColin Finck     HTMLLinkElement_put_onload,
344*c2c66affSColin Finck     HTMLLinkElement_get_onload,
345*c2c66affSColin Finck     HTMLLinkElement_put_onerror,
346*c2c66affSColin Finck     HTMLLinkElement_get_onerror,
347*c2c66affSColin Finck     HTMLLinkElement_get_styleSheet,
348*c2c66affSColin Finck     HTMLLinkElement_put_disabled,
349*c2c66affSColin Finck     HTMLLinkElement_get_disabled,
350*c2c66affSColin Finck     HTMLLinkElement_put_media,
351*c2c66affSColin Finck     HTMLLinkElement_get_media
352*c2c66affSColin Finck };
353*c2c66affSColin Finck 
impl_from_HTMLDOMNode(HTMLDOMNode * iface)354*c2c66affSColin Finck static inline HTMLLinkElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
355*c2c66affSColin Finck {
356*c2c66affSColin Finck     return CONTAINING_RECORD(iface, HTMLLinkElement, element.node);
357*c2c66affSColin Finck }
358*c2c66affSColin Finck 
HTMLLinkElement_QI(HTMLDOMNode * iface,REFIID riid,void ** ppv)359*c2c66affSColin Finck static HRESULT HTMLLinkElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
360*c2c66affSColin Finck {
361*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
362*c2c66affSColin Finck 
363*c2c66affSColin Finck     if(IsEqualGUID(&IID_IHTMLLinkElement, riid)) {
364*c2c66affSColin Finck         TRACE("(%p)->(IID_IHTMLLinkElement %p)\n", This, ppv);
365*c2c66affSColin Finck         *ppv = &This->IHTMLLinkElement_iface;
366*c2c66affSColin Finck     }else {
367*c2c66affSColin Finck         return HTMLElement_QI(&This->element.node, riid, ppv);
368*c2c66affSColin Finck     }
369*c2c66affSColin Finck 
370*c2c66affSColin Finck     IUnknown_AddRef((IUnknown*)*ppv);
371*c2c66affSColin Finck     return S_OK;
372*c2c66affSColin Finck }
373*c2c66affSColin Finck 
HTMLLinkElementImpl_put_disabled(HTMLDOMNode * iface,VARIANT_BOOL v)374*c2c66affSColin Finck static HRESULT HTMLLinkElementImpl_put_disabled(HTMLDOMNode *iface, VARIANT_BOOL v)
375*c2c66affSColin Finck {
376*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
377*c2c66affSColin Finck     return IHTMLLinkElement_put_disabled(&This->IHTMLLinkElement_iface, v);
378*c2c66affSColin Finck }
379*c2c66affSColin Finck 
HTMLLinkElementImpl_get_disabled(HTMLDOMNode * iface,VARIANT_BOOL * p)380*c2c66affSColin Finck static HRESULT HTMLLinkElementImpl_get_disabled(HTMLDOMNode *iface, VARIANT_BOOL *p)
381*c2c66affSColin Finck {
382*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
383*c2c66affSColin Finck     return IHTMLLinkElement_get_disabled(&This->IHTMLLinkElement_iface, p);
384*c2c66affSColin Finck }
385*c2c66affSColin Finck 
HTMLLinkElement_traverse(HTMLDOMNode * iface,nsCycleCollectionTraversalCallback * cb)386*c2c66affSColin Finck static void HTMLLinkElement_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
387*c2c66affSColin Finck {
388*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
389*c2c66affSColin Finck 
390*c2c66affSColin Finck     if(This->nslink)
391*c2c66affSColin Finck         note_cc_edge((nsISupports*)This->nslink, "This->nslink", cb);
392*c2c66affSColin Finck }
393*c2c66affSColin Finck 
HTMLLinkElement_unlink(HTMLDOMNode * iface)394*c2c66affSColin Finck static void HTMLLinkElement_unlink(HTMLDOMNode *iface)
395*c2c66affSColin Finck {
396*c2c66affSColin Finck     HTMLLinkElement *This = impl_from_HTMLDOMNode(iface);
397*c2c66affSColin Finck 
398*c2c66affSColin Finck     if(This->nslink) {
399*c2c66affSColin Finck         nsIDOMHTMLLinkElement *nslink = This->nslink;
400*c2c66affSColin Finck 
401*c2c66affSColin Finck         This->nslink = NULL;
402*c2c66affSColin Finck         nsIDOMHTMLLinkElement_Release(nslink);
403*c2c66affSColin Finck     }
404*c2c66affSColin Finck }
405*c2c66affSColin Finck static const NodeImplVtbl HTMLLinkElementImplVtbl = {
406*c2c66affSColin Finck     HTMLLinkElement_QI,
407*c2c66affSColin Finck     HTMLElement_destructor,
408*c2c66affSColin Finck     HTMLElement_cpc,
409*c2c66affSColin Finck     HTMLElement_clone,
410*c2c66affSColin Finck     HTMLElement_handle_event,
411*c2c66affSColin Finck     HTMLElement_get_attr_col,
412*c2c66affSColin Finck     NULL,
413*c2c66affSColin Finck     NULL,
414*c2c66affSColin Finck     HTMLLinkElementImpl_put_disabled,
415*c2c66affSColin Finck     HTMLLinkElementImpl_get_disabled,
416*c2c66affSColin Finck     NULL,
417*c2c66affSColin Finck     NULL,
418*c2c66affSColin Finck     NULL,
419*c2c66affSColin Finck     NULL,
420*c2c66affSColin Finck     NULL,
421*c2c66affSColin Finck     HTMLLinkElement_traverse,
422*c2c66affSColin Finck     HTMLLinkElement_unlink
423*c2c66affSColin Finck };
424*c2c66affSColin Finck 
425*c2c66affSColin Finck static const tid_t HTMLLinkElement_iface_tids[] = {
426*c2c66affSColin Finck     HTMLELEMENT_TIDS,
427*c2c66affSColin Finck     IHTMLLinkElement_tid,
428*c2c66affSColin Finck     0
429*c2c66affSColin Finck };
430*c2c66affSColin Finck static dispex_static_data_t HTMLLinkElement_dispex = {
431*c2c66affSColin Finck     NULL,
432*c2c66affSColin Finck     DispHTMLLinkElement_tid,
433*c2c66affSColin Finck     NULL,
434*c2c66affSColin Finck     HTMLLinkElement_iface_tids
435*c2c66affSColin Finck };
436*c2c66affSColin Finck 
HTMLLinkElement_Create(HTMLDocumentNode * doc,nsIDOMHTMLElement * nselem,HTMLElement ** elem)437*c2c66affSColin Finck HRESULT HTMLLinkElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
438*c2c66affSColin Finck {
439*c2c66affSColin Finck     HTMLLinkElement *ret;
440*c2c66affSColin Finck     nsresult nsres;
441*c2c66affSColin Finck 
442*c2c66affSColin Finck     ret = heap_alloc_zero(sizeof(*ret));
443*c2c66affSColin Finck     if(!ret)
444*c2c66affSColin Finck         return E_OUTOFMEMORY;
445*c2c66affSColin Finck 
446*c2c66affSColin Finck     ret->IHTMLLinkElement_iface.lpVtbl = &HTMLLinkElementVtbl;
447*c2c66affSColin Finck     ret->element.node.vtbl = &HTMLLinkElementImplVtbl;
448*c2c66affSColin Finck 
449*c2c66affSColin Finck     HTMLElement_Init(&ret->element, doc, nselem, &HTMLLinkElement_dispex);
450*c2c66affSColin Finck 
451*c2c66affSColin Finck     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLLinkElement, (void**)&ret->nslink);
452*c2c66affSColin Finck     assert(nsres == NS_OK);
453*c2c66affSColin Finck 
454*c2c66affSColin Finck     *elem = &ret->element;
455*c2c66affSColin Finck     return S_OK;
456*c2c66affSColin Finck }
457