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
30 #include "mshtml_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
36 static inline HTMLDOMAttribute
*impl_from_IHTMLDOMAttribute(IHTMLDOMAttribute
*iface
)
38 return CONTAINING_RECORD(iface
, HTMLDOMAttribute
, IHTMLDOMAttribute_iface
);
41 static HRESULT WINAPI
HTMLDOMAttribute_QueryInterface(IHTMLDOMAttribute
*iface
,
42 REFIID riid
, void **ppv
)
44 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
46 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
47 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
48 *ppv
= &This
->IHTMLDOMAttribute_iface
;
49 }else if(IsEqualGUID(&IID_IHTMLDOMAttribute
, riid
)) {
50 TRACE("(%p)->(IID_IHTMLDOMAttribute %p)\n", This
, ppv
);
51 *ppv
= &This
->IHTMLDOMAttribute_iface
;
52 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
53 return *ppv
? S_OK
: E_NOINTERFACE
;
55 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
60 IUnknown_AddRef((IUnknown
*)*ppv
);
64 static ULONG WINAPI
HTMLDOMAttribute_AddRef(IHTMLDOMAttribute
*iface
)
66 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
67 LONG ref
= InterlockedIncrement(&This
->ref
);
69 TRACE("(%p) ref=%d\n", This
, ref
);
74 static ULONG WINAPI
HTMLDOMAttribute_Release(IHTMLDOMAttribute
*iface
)
76 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
77 LONG ref
= InterlockedDecrement(&This
->ref
);
79 TRACE("(%p) ref=%d\n", This
, ref
);
83 release_dispex(&This
->dispex
);
90 static HRESULT WINAPI
HTMLDOMAttribute_GetTypeInfoCount(IHTMLDOMAttribute
*iface
, UINT
*pctinfo
)
92 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
93 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
96 static HRESULT WINAPI
HTMLDOMAttribute_GetTypeInfo(IHTMLDOMAttribute
*iface
, UINT iTInfo
,
97 LCID lcid
, ITypeInfo
**ppTInfo
)
99 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
100 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
103 static HRESULT WINAPI
HTMLDOMAttribute_GetIDsOfNames(IHTMLDOMAttribute
*iface
, REFIID riid
,
104 LPOLESTR
*rgszNames
, UINT cNames
,
105 LCID lcid
, DISPID
*rgDispId
)
107 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
108 return IDispatchEx_GetIDsOfNames(&This
->dispex
.IDispatchEx_iface
, riid
, rgszNames
, cNames
,
112 static HRESULT WINAPI
HTMLDOMAttribute_Invoke(IHTMLDOMAttribute
*iface
, DISPID dispIdMember
,
113 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
114 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
116 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
117 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
,
118 wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
121 static HRESULT WINAPI
HTMLDOMAttribute_get_nodeName(IHTMLDOMAttribute
*iface
, BSTR
*p
)
123 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
125 TRACE("(%p)->(%p)\n", This
, p
);
127 return IDispatchEx_GetMemberName(&This
->elem
->node
.dispex
.IDispatchEx_iface
, This
->dispid
, p
);
130 static HRESULT WINAPI
HTMLDOMAttribute_put_nodeName(IHTMLDOMAttribute
*iface
, VARIANT v
)
132 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
133 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
137 static HRESULT WINAPI
HTMLDOMAttribute_get_nodeValue(IHTMLDOMAttribute
*iface
, VARIANT
*p
)
139 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
140 DISPPARAMS dp
= {NULL
, NULL
, 0, 0};
143 TRACE("(%p)->(%p)\n", This
, p
);
146 FIXME("NULL This->elem\n");
150 memset(&ei
, 0, sizeof(ei
));
151 return IDispatchEx_InvokeEx(&This
->elem
->node
.dispex
.IDispatchEx_iface
, This
->dispid
, LOCALE_SYSTEM_DEFAULT
,
152 DISPATCH_PROPERTYGET
, &dp
, p
, &ei
, NULL
);
155 static HRESULT WINAPI
HTMLDOMAttribute_get_specified(IHTMLDOMAttribute
*iface
, VARIANT_BOOL
*p
)
157 HTMLDOMAttribute
*This
= impl_from_IHTMLDOMAttribute(iface
);
164 TRACE("(%p)->(%p)\n", This
, p
);
166 if(get_dispid_type(This
->dispid
) != DISPEXPROP_BUILTIN
) {
171 if(!This
->elem
|| !This
->elem
->nselem
) {
172 FIXME("NULL This->elem\n");
176 hres
= IDispatchEx_GetMemberName(&This
->elem
->node
.dispex
.IDispatchEx_iface
, This
->dispid
, &name
);
180 /* FIXME: This is not exactly right, we have some attributes that don't map directly to Gecko attributes. */
181 nsAString_InitDepend(&nsname
, name
);
182 nsres
= nsIDOMHTMLElement_GetAttributeNode(This
->elem
->nselem
, &nsname
, &nsattr
);
183 nsAString_Finish(&nsname
);
188 /* If the Gecko attribute node can be found, we know that the attribute is specified.
189 There is no point in calling GetSpecified */
191 nsIDOMAttr_Release(nsattr
);
199 static const IHTMLDOMAttributeVtbl HTMLDOMAttributeVtbl
= {
200 HTMLDOMAttribute_QueryInterface
,
201 HTMLDOMAttribute_AddRef
,
202 HTMLDOMAttribute_Release
,
203 HTMLDOMAttribute_GetTypeInfoCount
,
204 HTMLDOMAttribute_GetTypeInfo
,
205 HTMLDOMAttribute_GetIDsOfNames
,
206 HTMLDOMAttribute_Invoke
,
207 HTMLDOMAttribute_get_nodeName
,
208 HTMLDOMAttribute_put_nodeName
,
209 HTMLDOMAttribute_get_nodeValue
,
210 HTMLDOMAttribute_get_specified
213 static const tid_t HTMLDOMAttribute_iface_tids
[] = {
214 IHTMLDOMAttribute_tid
,
217 static dispex_static_data_t HTMLDOMAttribute_dispex
= {
219 DispHTMLDOMAttribute_tid
,
221 HTMLDOMAttribute_iface_tids
224 HRESULT
HTMLDOMAttribute_Create(HTMLElement
*elem
, DISPID dispid
, HTMLDOMAttribute
**attr
)
226 HTMLAttributeCollection
*col
;
227 HTMLDOMAttribute
*ret
;
230 ret
= heap_alloc_zero(sizeof(*ret
));
232 return E_OUTOFMEMORY
;
234 hres
= HTMLElement_get_attr_col(&elem
->node
, &col
);
239 IHTMLAttributeCollection_Release(&col
->IHTMLAttributeCollection_iface
);
241 ret
->IHTMLDOMAttribute_iface
.lpVtbl
= &HTMLDOMAttributeVtbl
;
244 ret
->dispid
= dispid
;
246 list_add_tail(&elem
->attrs
->attrs
, &ret
->entry
);
248 init_dispex(&ret
->dispex
, (IUnknown
*)&ret
->IHTMLDOMAttribute_iface
,
249 &HTMLDOMAttribute_dispex
);