2 * Copyright 2011 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
29 #include "mshtml_private.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 static inline HTMLDOMAttribute *impl_from_IHTMLDOMAttribute(IHTMLDOMAttribute *iface)
37 return CONTAINING_RECORD(iface, HTMLDOMAttribute, IHTMLDOMAttribute_iface);
40 static HRESULT WINAPI HTMLDOMAttribute_QueryInterface(IHTMLDOMAttribute *iface,
41 REFIID riid, void **ppv)
43 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
45 if(IsEqualGUID(&IID_IUnknown, riid)) {
46 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
47 *ppv = &This->IHTMLDOMAttribute_iface;
48 }else if(IsEqualGUID(&IID_IHTMLDOMAttribute, riid)) {
49 TRACE("(%p)->(IID_IHTMLDOMAttribute %p)\n", This, ppv);
50 *ppv = &This->IHTMLDOMAttribute_iface;
51 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
52 return *ppv ? S_OK : E_NOINTERFACE;
54 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
59 IUnknown_AddRef((IUnknown*)*ppv);
63 static ULONG WINAPI HTMLDOMAttribute_AddRef(IHTMLDOMAttribute *iface)
65 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
66 LONG ref = InterlockedIncrement(&This->ref);
68 TRACE("(%p) ref=%d\n", This, ref);
73 static ULONG WINAPI HTMLDOMAttribute_Release(IHTMLDOMAttribute *iface)
75 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
76 LONG ref = InterlockedDecrement(&This->ref);
78 TRACE("(%p) ref=%d\n", This, ref);
81 nsIDOMAttr_Release(This->nsattr);
82 release_dispex(&This->dispex);
89 static HRESULT WINAPI HTMLDOMAttribute_GetTypeInfoCount(IHTMLDOMAttribute *iface, UINT *pctinfo)
91 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
92 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
95 static HRESULT WINAPI HTMLDOMAttribute_GetTypeInfo(IHTMLDOMAttribute *iface, UINT iTInfo,
96 LCID lcid, ITypeInfo **ppTInfo)
98 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
99 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
102 static HRESULT WINAPI HTMLDOMAttribute_GetIDsOfNames(IHTMLDOMAttribute *iface, REFIID riid,
103 LPOLESTR *rgszNames, UINT cNames,
104 LCID lcid, DISPID *rgDispId)
106 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
107 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
111 static HRESULT WINAPI HTMLDOMAttribute_Invoke(IHTMLDOMAttribute *iface, DISPID dispIdMember,
112 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
113 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
115 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
116 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
117 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
120 static HRESULT WINAPI HTMLDOMAttribute_get_nodeName(IHTMLDOMAttribute *iface, BSTR *p)
122 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
123 FIXME("(%p)->(%p)\n", This, p);
127 static HRESULT WINAPI HTMLDOMAttribute_put_nodeName(IHTMLDOMAttribute *iface, VARIANT v)
129 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
130 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
134 static HRESULT WINAPI HTMLDOMAttribute_get_nodeValue(IHTMLDOMAttribute *iface, VARIANT *p)
136 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
137 const PRUnichar *val;
141 TRACE("(%p)->(%p)\n", This, p);
143 nsAString_Init(&val_str, NULL);
144 nsIDOMAttr_GetNodeValue(This->nsattr, &val_str);
145 nsAString_GetData(&val_str, &val);
149 V_BSTR(p) = SysAllocString(val);
151 hres = E_OUTOFMEMORY;
156 nsAString_Finish(&val_str);
160 static HRESULT WINAPI HTMLDOMAttribute_get_specified(IHTMLDOMAttribute *iface, VARIANT_BOOL *p)
162 HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
163 FIXME("(%p)->(%p)\n", This, p);
167 static const IHTMLDOMAttributeVtbl HTMLDOMAttributeVtbl = {
168 HTMLDOMAttribute_QueryInterface,
169 HTMLDOMAttribute_AddRef,
170 HTMLDOMAttribute_Release,
171 HTMLDOMAttribute_GetTypeInfoCount,
172 HTMLDOMAttribute_GetTypeInfo,
173 HTMLDOMAttribute_GetIDsOfNames,
174 HTMLDOMAttribute_Invoke,
175 HTMLDOMAttribute_get_nodeName,
176 HTMLDOMAttribute_put_nodeName,
177 HTMLDOMAttribute_get_nodeValue,
178 HTMLDOMAttribute_get_specified
181 static const tid_t HTMLDOMAttribute_iface_tids[] = {
182 IHTMLDOMAttribute_tid,
185 static dispex_static_data_t HTMLDOMAttribute_dispex = {
187 DispHTMLDOMAttribute_tid,
189 HTMLDOMAttribute_iface_tids
192 HRESULT HTMLDOMAttribute_Create(HTMLDocumentNode *doc, nsIDOMAttr *nsattr, HTMLDOMAttribute **attr)
194 HTMLDOMAttribute *ret;
196 ret = heap_alloc_zero(sizeof(*ret));
198 return E_OUTOFMEMORY;
200 ret->IHTMLDOMAttribute_iface.lpVtbl = &HTMLDOMAttributeVtbl;
203 nsIDOMAttr_AddRef(nsattr);
204 ret->nsattr = nsattr;
206 init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLDOMAttribute_iface,
207 &HTMLDOMAttribute_dispex);