Module: wine Branch: master Commit: 0e3bf9b2285a1f5e3e98b82dc6a76782c1f79cf1 URL: http://source.winehq.org/git/wine.git/?a=commit;h=0e3bf9b2285a1f5e3e98b82dc6...
Author: Jacek Caban jacek@codeweavers.com Date: Thu Feb 24 13:04:08 2011 +0100
mshtml: Added IHTMLElement4::getAttributeNode implementation.
---
dlls/mshtml/Makefile.in | 1 + dlls/mshtml/htmlattr.c | 177 ++++++++++++++++++++++++++++++++++++++++++ dlls/mshtml/htmlelem3.c | 29 +++++++- dlls/mshtml/mshtml_private.h | 9 ++ dlls/mshtml/nsiface.idl | 16 ++++- 5 files changed, 229 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index 2093eb6..ea716fb 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -10,6 +10,7 @@ C_SRCS = \ editor.c \ hlink.c \ htmlanchor.c \ + htmlattr.c \ htmlbody.c \ htmlcomment.c \ htmlcurstyle.c \ diff --git a/dlls/mshtml/htmlattr.c b/dlls/mshtml/htmlattr.c new file mode 100644 index 0000000..05b13fc --- /dev/null +++ b/dlls/mshtml/htmlattr.c @@ -0,0 +1,177 @@ +/* + * Copyright 2011 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + + +#include <stdarg.h> + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" + +#include "mshtml_private.h" + +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +static inline HTMLDOMAttribute *impl_from_IHTMLDOMAttribute(IHTMLDOMAttribute *iface) +{ + return CONTAINING_RECORD(iface, HTMLDOMAttribute, IHTMLDOMAttribute_iface); +} + +static HRESULT WINAPI HTMLDOMAttribute_QueryInterface(IHTMLDOMAttribute *iface, + REFIID riid, void **ppv) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + + if(IsEqualGUID(&IID_IUnknown, riid)) { + TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); + *ppv = &This->IHTMLDOMAttribute_iface; + }else if(IsEqualGUID(&IID_IHTMLDOMAttribute, riid)) { + TRACE("(%p)->(IID_IHTMLDOMAttribute %p)\n", This, ppv); + *ppv = &This->IHTMLDOMAttribute_iface; + }else { + WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); + *ppv = NULL; + return E_NOINTERFACE; + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static ULONG WINAPI HTMLDOMAttribute_AddRef(IHTMLDOMAttribute *iface) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + LONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; +} + +static ULONG WINAPI HTMLDOMAttribute_Release(IHTMLDOMAttribute *iface) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + LONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if(!ref) { + nsIDOMAttr_Release(This->nsattr); + heap_free(This); + } + + return ref; +} + +static HRESULT WINAPI HTMLDOMAttribute_GetTypeInfoCount(IHTMLDOMAttribute *iface, UINT *pctinfo) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + FIXME("%p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLDOMAttribute_GetTypeInfo(IHTMLDOMAttribute *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + FIXME("%p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLDOMAttribute_GetIDsOfNames(IHTMLDOMAttribute *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + FIXME("%p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLDOMAttribute_Invoke(IHTMLDOMAttribute *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + FIXME("%p\n", This); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLDOMAttribute_get_nodeName(IHTMLDOMAttribute *iface, BSTR *p) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLDOMAttribute_put_nodeName(IHTMLDOMAttribute *iface, VARIANT v) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLDOMAttribute_get_nodeValue(IHTMLDOMAttribute *iface, VARIANT *p) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLDOMAttribute_get_specified(IHTMLDOMAttribute *iface, VARIANT_BOOL *p) +{ + HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static const IHTMLDOMAttributeVtbl HTMLDOMAttributeVtbl = { + HTMLDOMAttribute_QueryInterface, + HTMLDOMAttribute_AddRef, + HTMLDOMAttribute_Release, + HTMLDOMAttribute_GetTypeInfoCount, + HTMLDOMAttribute_GetTypeInfo, + HTMLDOMAttribute_GetIDsOfNames, + HTMLDOMAttribute_Invoke, + HTMLDOMAttribute_get_nodeName, + HTMLDOMAttribute_put_nodeName, + HTMLDOMAttribute_get_nodeValue, + HTMLDOMAttribute_get_specified +}; + +HRESULT HTMLDOMAttribute_Create(HTMLDocumentNode *doc, nsIDOMAttr *nsattr, HTMLDOMAttribute **attr) +{ + HTMLDOMAttribute *ret; + + ret = heap_alloc_zero(sizeof(*ret)); + if(!ret) + return E_OUTOFMEMORY; + + ret->IHTMLDOMAttribute_iface.lpVtbl = &HTMLDOMAttributeVtbl; + ret->ref = 1; + + nsIDOMAttr_AddRef(nsattr); + ret->nsattr = nsattr; + + *attr = ret; + return S_OK; +} diff --git a/dlls/mshtml/htmlelem3.c b/dlls/mshtml/htmlelem3.c index 9fc0d39..7841346 100644 --- a/dlls/mshtml/htmlelem3.c +++ b/dlls/mshtml/htmlelem3.c @@ -560,8 +560,33 @@ static HRESULT WINAPI HTMLElement4_normalize(IHTMLElement4 *iface) static HRESULT WINAPI HTMLElement4_getAttributeNode(IHTMLElement4 *iface, BSTR bstrname, IHTMLDOMAttribute **ppAttribute) { HTMLElement *This = impl_from_IHTMLElement4(iface); - FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute); - return E_NOTIMPL; + HTMLDOMAttribute *attr; + nsAString name_str; + nsIDOMAttr *nsattr; + nsresult nsres; + HRESULT hres; + + TRACE("(%p)->(%s %p)\n", This, debugstr_w(bstrname), ppAttribute); + + nsAString_InitDepend(&name_str, bstrname); + nsres = nsIDOMHTMLElement_GetAttributeNode(This->nselem, &name_str, &nsattr); + nsAString_Finish(&name_str); + if(NS_FAILED(nsres)) { + ERR("GetAttributeNode failed: %08x\n", nsres); + return E_FAIL; + } + + if(nsattr) { + hres = HTMLDOMAttribute_Create(This->node.doc, nsattr, &attr); + nsIDOMAttr_Release(nsattr); + if(FAILED(hres)) + return hres; + + *ppAttribute = &attr->IHTMLDOMAttribute_iface; + }else { + *ppAttribute = NULL; + } + return S_OK; }
static HRESULT WINAPI HTMLElement4_setAttributeNode(IHTMLElement4 *iface, IHTMLDOMAttribute *pattr, diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index c6d56ee..dc99fbf 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -739,6 +739,15 @@ HRESULT create_nselem(HTMLDocumentNode*,const WCHAR*,nsIDOMHTMLElement**);
HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**);
+typedef struct { + IHTMLDOMAttribute IHTMLDOMAttribute_iface; + + LONG ref; + nsIDOMAttr *nsattr; +} HTMLDOMAttribute; + +HRESULT HTMLDOMAttribute_Create(HTMLDocumentNode*,nsIDOMAttr*,HTMLDOMAttribute**); + HRESULT HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLElement**); HRESULT HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*,HTMLElement**); HRESULT HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**); diff --git a/dlls/mshtml/nsiface.idl b/dlls/mshtml/nsiface.idl index 4248768..7d8b5ce 100644 --- a/dlls/mshtml/nsiface.idl +++ b/dlls/mshtml/nsiface.idl @@ -89,6 +89,7 @@ interface nsIDOMCSSStyleSheet; interface nsIDOMDocumentView; interface nsIDocumentObserver; interface nsIDOMWindow; +interface nsIDOMElement;
interface IMoniker;
@@ -111,7 +112,6 @@ typedef nsISupports nsIDOMBarProp; typedef nsISupports nsIPrompt; typedef nsISupports nsIAuthPrompt; typedef nsISupports nsIDOMNamedNodeMap; -typedef nsISupports nsIDOMAttr; typedef nsISupports nsIDOMDocumentType; typedef nsISupports nsIDOMDOMImplementation; typedef nsISupports nsIDOMCDATASection; @@ -675,6 +675,20 @@ interface nsIDOMNode : nsISupports
[ object, + uuid(a6cf9070-15b3-11d2-932e-00805f8add32), + local +] +interface nsIDOMAttr : nsIDOMNode +{ + nsresult GetName(nsAString *aName); + nsresult GetSpecified(PRBool *aSpecified); + nsresult GetValue(nsAString *aValue); + nsresult SetValue(const nsAString *aValue); + nsresult GetOwnerElement(nsIDOMElement **aOwnerElement); +} + +[ + object, uuid(a6cf9078-15b3-11d2-932e-00805f8add32), local ]