2006-03-05 20:38:30 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2006 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-03-05 20:38:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
2008-10-09 22:36:01 +02:00
|
|
|
#include "htmlevent.h"
|
2006-03-05 20:38:30 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2009-09-16 22:13:31 +02:00
|
|
|
static HTMLDOMNode *get_node_obj(HTMLDocumentNode*,IUnknown*);
|
2010-12-01 22:42:03 +01:00
|
|
|
static HRESULT create_node(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**);
|
2008-06-23 16:49:26 +02:00
|
|
|
|
2008-04-30 18:17:34 +02:00
|
|
|
typedef struct {
|
2008-04-30 18:18:09 +02:00
|
|
|
DispatchEx dispex;
|
2010-12-30 01:41:56 +01:00
|
|
|
IHTMLDOMChildrenCollection IHTMLDOMChildrenCollection_iface;
|
2008-04-30 18:17:34 +02:00
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
/* FIXME: implement weak reference */
|
2009-09-16 22:13:31 +02:00
|
|
|
HTMLDocumentNode *doc;
|
2008-04-30 18:17:34 +02:00
|
|
|
|
|
|
|
nsIDOMNodeList *nslist;
|
|
|
|
} HTMLDOMChildrenCollection;
|
|
|
|
|
2010-12-30 01:41:56 +01:00
|
|
|
static inline HTMLDOMChildrenCollection *impl_from_IHTMLDOMChildrenCollection(IHTMLDOMChildrenCollection *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLDOMChildrenCollection, IHTMLDOMChildrenCollection_iface);
|
|
|
|
}
|
2008-04-30 18:17:34 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollection_QueryInterface(IHTMLDOMChildrenCollection *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2008-04-30 18:17:34 +02:00
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2010-12-30 01:41:56 +01:00
|
|
|
*ppv = &This->IHTMLDOMChildrenCollection_iface;
|
2008-04-30 18:17:34 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLDOMChildrenCollection, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHTMLDOMChildrenCollection %p)\n", This, ppv);
|
2010-12-30 01:41:56 +01:00
|
|
|
*ppv = &This->IHTMLDOMChildrenCollection_iface;
|
2008-06-30 21:38:23 +02:00
|
|
|
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
|
|
|
|
return *ppv ? S_OK : E_NOINTERFACE;
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMChildrenCollection_AddRef(IHTMLDOMChildrenCollection *iface)
|
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2008-04-30 18:17:34 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMChildrenCollection_Release(IHTMLDOMChildrenCollection *iface)
|
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2008-04-30 18:17:34 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
nsIDOMNodeList_Release(This->nslist);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfoCount(IHTMLDOMChildrenCollection *iface, UINT *pctinfo)
|
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollection_GetTypeInfo(IHTMLDOMChildrenCollection *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollection_GetIDsOfNames(IHTMLDOMChildrenCollection *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollection_Invoke(IHTMLDOMChildrenCollection *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
|
2008-09-20 12:03:28 +02:00
|
|
|
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:31 +01:00
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollection_get_length(IHTMLDOMChildrenCollection *iface, LONG *p)
|
2008-04-30 18:17:34 +02:00
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2008-04-30 18:17:44 +02:00
|
|
|
PRUint32 length=0;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsIDOMNodeList_GetLength(This->nslist, &length);
|
|
|
|
*p = length;
|
|
|
|
return S_OK;
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollection__newEnum(IHTMLDOMChildrenCollection *iface, IUnknown **p)
|
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2008-04-30 18:17:34 +02:00
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:31 +01:00
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection *iface, LONG index, IDispatch **ppItem)
|
2008-04-30 18:17:34 +02:00
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2008-04-30 18:17:56 +02:00
|
|
|
nsIDOMNode *nsnode = NULL;
|
2010-12-01 12:52:08 +01:00
|
|
|
HTMLDOMNode *node;
|
2008-04-30 18:17:56 +02:00
|
|
|
PRUint32 length=0;
|
|
|
|
nsresult nsres;
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT hres;
|
2008-04-30 18:17:56 +02:00
|
|
|
|
2009-03-12 01:43:31 +01:00
|
|
|
TRACE("(%p)->(%d %p)\n", This, index, ppItem);
|
2008-04-30 18:17:56 +02:00
|
|
|
|
2009-05-27 13:21:25 +02:00
|
|
|
if (ppItem)
|
|
|
|
*ppItem = NULL;
|
|
|
|
else
|
|
|
|
return E_POINTER;
|
|
|
|
|
2008-04-30 18:17:56 +02:00
|
|
|
nsIDOMNodeList_GetLength(This->nslist, &length);
|
2008-06-24 03:03:06 +02:00
|
|
|
if(index < 0 || index >= length)
|
2008-04-30 18:17:56 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
nsres = nsIDOMNodeList_Item(This->nslist, index, &nsnode);
|
|
|
|
if(NS_FAILED(nsres) || !nsnode) {
|
|
|
|
ERR("Item failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(This->doc, nsnode, TRUE, &node);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*ppItem = (IDispatch*)&node->IHTMLDOMNode_iface;
|
2008-04-30 18:17:56 +02:00
|
|
|
IDispatch_AddRef(*ppItem);
|
|
|
|
return S_OK;
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
2010-12-27 18:34:39 +01:00
|
|
|
static const IHTMLDOMChildrenCollectionVtbl HTMLDOMChildrenCollectionVtbl = {
|
|
|
|
HTMLDOMChildrenCollection_QueryInterface,
|
|
|
|
HTMLDOMChildrenCollection_AddRef,
|
|
|
|
HTMLDOMChildrenCollection_Release,
|
|
|
|
HTMLDOMChildrenCollection_GetTypeInfoCount,
|
|
|
|
HTMLDOMChildrenCollection_GetTypeInfo,
|
|
|
|
HTMLDOMChildrenCollection_GetIDsOfNames,
|
|
|
|
HTMLDOMChildrenCollection_Invoke,
|
|
|
|
HTMLDOMChildrenCollection_get_length,
|
|
|
|
HTMLDOMChildrenCollection__newEnum,
|
|
|
|
HTMLDOMChildrenCollection_item
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline HTMLDOMChildrenCollection *impl_from_DispatchEx(DispatchEx *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLDOMChildrenCollection, dispex);
|
|
|
|
}
|
|
|
|
|
2008-06-24 03:02:42 +02:00
|
|
|
#define DISPID_CHILDCOL_0 MSHTML_DISPID_CUSTOM_MIN
|
|
|
|
|
2010-12-27 18:34:39 +01:00
|
|
|
static HRESULT HTMLDOMChildrenCollection_get_dispid(DispatchEx *dispex, BSTR name, DWORD flags, DISPID *dispid)
|
2008-06-24 03:02:42 +02:00
|
|
|
{
|
2010-12-27 18:34:39 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_DispatchEx(dispex);
|
2008-06-24 03:02:42 +02:00
|
|
|
WCHAR *ptr;
|
|
|
|
DWORD idx=0;
|
|
|
|
PRUint32 len = 0;
|
|
|
|
|
|
|
|
for(ptr = name; *ptr && isdigitW(*ptr); ptr++)
|
|
|
|
idx = idx*10 + (*ptr-'0');
|
|
|
|
if(*ptr)
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
|
|
|
|
nsIDOMNodeList_GetLength(This->nslist, &len);
|
|
|
|
if(idx >= len)
|
|
|
|
return DISP_E_UNKNOWNNAME;
|
|
|
|
|
|
|
|
*dispid = DISPID_CHILDCOL_0 + idx;
|
|
|
|
TRACE("ret %x\n", *dispid);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-27 18:34:39 +01:00
|
|
|
static HRESULT HTMLDOMChildrenCollection_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
|
2008-06-24 03:02:42 +02:00
|
|
|
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
|
|
|
|
{
|
2010-12-27 18:34:39 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_DispatchEx(dispex);
|
2008-06-24 03:02:42 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, flags, params, res, ei, caller);
|
|
|
|
|
|
|
|
switch(flags) {
|
2009-10-13 20:50:02 +02:00
|
|
|
case DISPATCH_PROPERTYGET: {
|
2008-06-24 03:02:42 +02:00
|
|
|
IDispatch *disp = NULL;
|
|
|
|
HRESULT hres;
|
|
|
|
|
2010-12-30 01:41:56 +01:00
|
|
|
hres = IHTMLDOMChildrenCollection_item(&This->IHTMLDOMChildrenCollection_iface,
|
|
|
|
id - DISPID_CHILDCOL_0, &disp);
|
2011-09-02 14:18:08 +02:00
|
|
|
if(FAILED(hres))
|
2008-06-24 03:02:42 +02:00
|
|
|
return hres;
|
|
|
|
|
|
|
|
V_VT(res) = VT_DISPATCH;
|
|
|
|
V_DISPATCH(res) = disp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("unimplemented flags %x\n", flags);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-27 18:34:39 +01:00
|
|
|
static const dispex_static_data_vtbl_t HTMLDOMChildrenCollection_dispex_vtbl = {
|
|
|
|
NULL,
|
|
|
|
HTMLDOMChildrenCollection_get_dispid,
|
2011-08-23 11:33:18 +02:00
|
|
|
HTMLDOMChildrenCollection_invoke,
|
|
|
|
NULL
|
2008-04-30 18:17:34 +02:00
|
|
|
};
|
|
|
|
|
2008-05-06 16:04:58 +02:00
|
|
|
static const tid_t HTMLDOMChildrenCollection_iface_tids[] = {
|
|
|
|
IHTMLDOMChildrenCollection_tid,
|
|
|
|
0
|
|
|
|
};
|
2008-06-24 03:02:42 +02:00
|
|
|
|
2008-04-30 18:18:09 +02:00
|
|
|
static dispex_static_data_t HTMLDOMChildrenCollection_dispex = {
|
2008-06-24 03:02:42 +02:00
|
|
|
&HTMLDOMChildrenCollection_dispex_vtbl,
|
2008-04-30 18:18:09 +02:00
|
|
|
DispDOMChildrenCollection_tid,
|
|
|
|
NULL,
|
2008-05-06 16:04:58 +02:00
|
|
|
HTMLDOMChildrenCollection_iface_tids
|
2008-04-30 18:18:09 +02:00
|
|
|
};
|
|
|
|
|
2009-09-16 22:13:31 +02:00
|
|
|
static IHTMLDOMChildrenCollection *create_child_collection(HTMLDocumentNode *doc, nsIDOMNodeList *nslist)
|
2008-04-30 18:17:34 +02:00
|
|
|
{
|
|
|
|
HTMLDOMChildrenCollection *ret;
|
|
|
|
|
|
|
|
ret = heap_alloc_zero(sizeof(*ret));
|
2010-12-30 01:41:56 +01:00
|
|
|
ret->IHTMLDOMChildrenCollection_iface.lpVtbl = &HTMLDOMChildrenCollectionVtbl;
|
2008-04-30 18:17:34 +02:00
|
|
|
ret->ref = 1;
|
|
|
|
|
|
|
|
nsIDOMNodeList_AddRef(nslist);
|
|
|
|
ret->nslist = nslist;
|
|
|
|
ret->doc = doc;
|
|
|
|
|
2010-12-30 01:41:56 +01:00
|
|
|
init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLDOMChildrenCollection_iface,
|
|
|
|
&HTMLDOMChildrenCollection_dispex);
|
2008-04-30 18:18:09 +02:00
|
|
|
|
2010-12-30 01:41:56 +01:00
|
|
|
return &ret->IHTMLDOMChildrenCollection_iface;
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
static inline HTMLDOMNode *impl_from_IHTMLDOMNode(IHTMLDOMNode *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLDOMNode, IHTMLDOMNode_iface);
|
|
|
|
}
|
2006-03-05 20:38:30 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_QueryInterface(IHTMLDOMNode *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2006-03-05 20:38:30 +01:00
|
|
|
|
2007-10-04 02:10:36 +02:00
|
|
|
return This->vtbl->qi(This, riid, ppv);
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMNode_AddRef(IHTMLDOMNode *iface)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2007-10-14 12:07:27 +02:00
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
2006-03-05 20:38:30 +01:00
|
|
|
|
2007-10-14 12:07:27 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2007-09-19 12:40:41 +02:00
|
|
|
|
2007-10-14 12:07:27 +02:00
|
|
|
return ref;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMNode_Release(IHTMLDOMNode *iface)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2007-10-14 12:07:27 +02:00
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
2006-03-05 20:38:30 +01:00
|
|
|
|
2007-10-14 12:07:27 +02:00
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
2007-09-19 12:40:41 +02:00
|
|
|
|
2007-10-14 12:07:27 +02:00
|
|
|
if(!ref) {
|
|
|
|
This->vtbl->destructor(This);
|
2009-08-31 20:47:55 +02:00
|
|
|
release_dispex(&This->dispex);
|
2007-12-05 21:52:31 +01:00
|
|
|
heap_free(This);
|
2007-10-14 12:07:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode *iface, UINT *pctinfo)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_GetTypeInfo(IHTMLDOMNode *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_GetIDsOfNames(IHTMLDOMNode *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_Invoke(IHTMLDOMNode *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
|
2008-09-20 12:06:14 +02:00
|
|
|
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:31 +01:00
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_nodeType(IHTMLDOMNode *iface, LONG *p)
|
2006-03-05 20:38:30 +01:00
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-04-24 18:26:18 +02:00
|
|
|
PRUint16 type = -1;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsIDOMNode_GetNodeType(This->nsnode, &type);
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case ELEMENT_NODE:
|
|
|
|
*p = 1;
|
|
|
|
break;
|
|
|
|
case TEXT_NODE:
|
|
|
|
*p = 3;
|
|
|
|
break;
|
2008-04-30 18:17:34 +02:00
|
|
|
case COMMENT_NODE:
|
|
|
|
*p = 8;
|
|
|
|
break;
|
2008-06-26 02:28:53 +02:00
|
|
|
case DOCUMENT_NODE:
|
|
|
|
*p = 9;
|
|
|
|
break;
|
2010-11-14 14:42:43 +01:00
|
|
|
case DOCUMENT_FRAGMENT_NODE:
|
|
|
|
*p = 11;
|
|
|
|
break;
|
2008-04-24 18:26:18 +02:00
|
|
|
default:
|
|
|
|
/*
|
|
|
|
* FIXME:
|
|
|
|
* According to MSDN only ELEMENT_NODE and TEXT_NODE are supported.
|
|
|
|
* It needs more tests.
|
|
|
|
*/
|
|
|
|
FIXME("type %u\n", type);
|
|
|
|
*p = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_parentNode(IHTMLDOMNode *iface, IHTMLDOMNode **p)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-06-26 02:28:37 +02:00
|
|
|
HTMLDOMNode *node;
|
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
nsresult nsres;
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT hres;
|
2008-06-26 02:28:37 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_GetParentNode(This->nsnode, &nsnode);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetParentNode failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!nsnode) {
|
|
|
|
*p = NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(This->doc, nsnode, TRUE, &node);
|
|
|
|
nsIDOMNode_Release(nsnode);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*p = &node->IHTMLDOMNode_iface;
|
2008-06-26 02:28:37 +02:00
|
|
|
IHTMLDOMNode_AddRef(*p);
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_hasChildNodes(IHTMLDOMNode *iface, VARIANT_BOOL *fChildren)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2012-03-15 11:55:01 +01:00
|
|
|
cpp_bool has_child = FALSE;
|
2008-06-24 03:03:25 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, fChildren);
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_HasChildNodes(This->nsnode, &has_child);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("HasChildNodes failed: %08x\n", nsres);
|
|
|
|
|
|
|
|
*fChildren = has_child ? VARIANT_TRUE : VARIANT_FALSE;
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_childNodes(IHTMLDOMNode *iface, IDispatch **p)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-04-30 18:17:34 +02:00
|
|
|
nsIDOMNodeList *nslist;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_GetChildNodes(This->nsnode, &nslist);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("GetChildNodes failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = (IDispatch*)create_child_collection(This->doc, nslist);
|
|
|
|
nsIDOMNodeList_Release(nslist);
|
|
|
|
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_attributes(IHTMLDOMNode *iface, IDispatch **p)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2011-08-25 15:23:35 +02:00
|
|
|
HTMLAttributeCollection *col;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
if(This->vtbl->get_attr_col) {
|
|
|
|
hres = This->vtbl->get_attr_col(This, &col);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
*p = (IDispatch*)&col->IHTMLAttributeCollection_iface;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*p = NULL;
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_insertBefore(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
|
|
|
|
VARIANT refChild, IHTMLDOMNode **node)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-10-13 21:50:52 +02:00
|
|
|
nsIDOMNode *nsnode, *nsref = NULL;
|
|
|
|
HTMLDOMNode *new_child;
|
2010-12-01 12:52:08 +01:00
|
|
|
HTMLDOMNode *node_obj;
|
2008-10-13 21:50:52 +02:00
|
|
|
nsresult nsres;
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT hres;
|
2008-10-13 21:50:52 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %s %p)\n", This, newChild, debugstr_variant(&refChild), node);
|
|
|
|
|
|
|
|
new_child = get_node_obj(This->doc, (IUnknown*)newChild);
|
|
|
|
if(!new_child) {
|
|
|
|
ERR("invalid newChild\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(V_VT(&refChild)) {
|
|
|
|
case VT_NULL:
|
|
|
|
break;
|
|
|
|
case VT_DISPATCH: {
|
|
|
|
HTMLDOMNode *ref_node;
|
|
|
|
|
|
|
|
ref_node = get_node_obj(This->doc, (IUnknown*)V_DISPATCH(&refChild));
|
|
|
|
if(!ref_node) {
|
|
|
|
ERR("unvalid node\n");
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsref = ref_node->nsnode;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-03-28 14:27:20 +02:00
|
|
|
FIXME("unimplemented refChild %s\n", debugstr_variant(&refChild));
|
2008-10-13 21:50:52 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_InsertBefore(This->nsnode, new_child->nsnode, nsref, &nsnode);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("InsertBefore failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(This->doc, nsnode, TRUE, &node_obj);
|
2008-10-13 21:50:52 +02:00
|
|
|
nsIDOMNode_Release(nsnode);
|
2010-12-01 12:52:08 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*node = &node_obj->IHTMLDOMNode_iface;
|
2008-10-13 21:50:52 +02:00
|
|
|
IHTMLDOMNode_AddRef(*node);
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
2008-06-24 03:02:42 +02:00
|
|
|
static HRESULT WINAPI HTMLDOMNode_removeChild(IHTMLDOMNode *iface, IHTMLDOMNode *oldChild,
|
2006-03-05 20:38:30 +01:00
|
|
|
IHTMLDOMNode **node)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-06-24 03:03:43 +02:00
|
|
|
HTMLDOMNode *node_obj;
|
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
nsresult nsres;
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT hres;
|
2008-06-24 03:03:43 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, oldChild, node);
|
|
|
|
|
|
|
|
node_obj = get_node_obj(This->doc, (IUnknown*)oldChild);
|
|
|
|
if(!node_obj)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_RemoveChild(This->nsnode, node_obj->nsnode, &nsnode);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("RemoveChild failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(This->doc, nsnode, TRUE, &node_obj);
|
2008-10-13 21:51:04 +02:00
|
|
|
nsIDOMNode_Release(nsnode);
|
2010-12-01 12:52:08 +01:00
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
/* FIXME: Make sure that node != newChild */
|
2010-12-30 01:39:16 +01:00
|
|
|
*node = &node_obj->IHTMLDOMNode_iface;
|
2008-06-24 03:03:43 +02:00
|
|
|
IHTMLDOMNode_AddRef(*node);
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_replaceChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
|
|
|
|
IHTMLDOMNode *oldChild, IHTMLDOMNode **node)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2011-02-19 05:58:30 +01:00
|
|
|
HTMLDOMNode *node_new;
|
|
|
|
HTMLDOMNode *node_old;
|
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, newChild, oldChild, node);
|
|
|
|
|
|
|
|
node_new = get_node_obj(This->doc, (IUnknown*)newChild);
|
|
|
|
if(!node_new)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
node_old = get_node_obj(This->doc, (IUnknown*)oldChild);
|
|
|
|
if(!node_old)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_ReplaceChild(This->nsnode, node_new->nsnode, node_old->nsnode, &nsnode);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsnode = node_new->nsnode;
|
|
|
|
|
|
|
|
hres = get_node(This->doc, nsnode, TRUE, &node_new);
|
|
|
|
nsIDOMNode_Release(nsnode);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
*node = &node_new->IHTMLDOMNode_iface;
|
|
|
|
IHTMLDOMNode_AddRef(*node);
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_cloneNode(IHTMLDOMNode *iface, VARIANT_BOOL fDeep,
|
|
|
|
IHTMLDOMNode **clonedNode)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2010-11-14 14:41:39 +01:00
|
|
|
HTMLDOMNode *new_node;
|
2009-10-02 13:54:22 +02:00
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
nsresult nsres;
|
2010-11-14 14:41:39 +01:00
|
|
|
HRESULT hres;
|
2009-10-02 13:54:22 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%x %p)\n", This, fDeep, clonedNode);
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_CloneNode(This->nsnode, fDeep != VARIANT_FALSE, &nsnode);
|
|
|
|
if(NS_FAILED(nsres) || !nsnode) {
|
|
|
|
ERR("CloneNode failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2010-11-14 14:41:39 +01:00
|
|
|
hres = This->vtbl->clone(This, nsnode, &new_node);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*clonedNode = &new_node->IHTMLDOMNode_iface;
|
2009-10-02 13:54:22 +02:00
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_removeNode(IHTMLDOMNode *iface, VARIANT_BOOL fDeep,
|
|
|
|
IHTMLDOMNode **removed)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2006-03-05 20:38:30 +01:00
|
|
|
FIXME("(%p)->(%x %p)\n", This, fDeep, removed);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_swapNode(IHTMLDOMNode *iface, IHTMLDOMNode *otherNode,
|
|
|
|
IHTMLDOMNode **swappedNode)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2006-03-05 20:38:30 +01:00
|
|
|
FIXME("(%p)->(%p %p)\n", This, otherNode, swappedNode);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_replaceNode(IHTMLDOMNode *iface, IHTMLDOMNode *replacement,
|
|
|
|
IHTMLDOMNode **replaced)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2006-03-05 20:38:30 +01:00
|
|
|
FIXME("(%p)->(%p %p)\n", This, replacement, replaced);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_appendChild(IHTMLDOMNode *iface, IHTMLDOMNode *newChild,
|
|
|
|
IHTMLDOMNode **node)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-06-23 16:49:26 +02:00
|
|
|
HTMLDOMNode *node_obj;
|
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
nsresult nsres;
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT hres;
|
2008-06-23 16:49:26 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p)\n", This, newChild, node);
|
|
|
|
|
|
|
|
node_obj = get_node_obj(This->doc, (IUnknown*)newChild);
|
|
|
|
if(!node_obj)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_AppendChild(This->nsnode, node_obj->nsnode, &nsnode);
|
|
|
|
if(NS_FAILED(nsres)) {
|
2008-10-13 21:51:04 +02:00
|
|
|
WARN("AppendChild failed: %08x\n", nsres);
|
|
|
|
nsnode = node_obj->nsnode;
|
2008-06-23 16:49:26 +02:00
|
|
|
}
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(This->doc, nsnode, TRUE, &node_obj);
|
|
|
|
nsIDOMNode_Release(nsnode);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2008-06-23 16:49:26 +02:00
|
|
|
/* FIXME: Make sure that node != newChild */
|
2010-12-30 01:39:16 +01:00
|
|
|
*node = &node_obj->IHTMLDOMNode_iface;
|
2008-06-23 16:49:26 +02:00
|
|
|
IHTMLDOMNode_AddRef(*node);
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_nodeName(IHTMLDOMNode *iface, BSTR *p)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2012-04-13 12:20:25 +02:00
|
|
|
nsAString name;
|
|
|
|
nsresult nsres;
|
2007-06-24 21:07:23 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
2012-04-13 12:20:25 +02:00
|
|
|
nsAString_Init(&name, NULL);
|
|
|
|
nsres = nsIDOMNode_GetNodeName(This->nsnode, &name);
|
|
|
|
return return_nsstr(nsres, &name, p);
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_put_nodeValue(IHTMLDOMNode *iface, VARIANT v)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-06-19 00:06:34 +02:00
|
|
|
|
2012-03-28 14:27:20 +02:00
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
|
2008-06-19 00:06:34 +02:00
|
|
|
|
|
|
|
switch(V_VT(&v)) {
|
|
|
|
case VT_BSTR: {
|
|
|
|
nsAString val_str;
|
|
|
|
|
2010-01-28 23:56:31 +01:00
|
|
|
nsAString_InitDepend(&val_str, V_BSTR(&v));
|
2008-06-19 00:06:34 +02:00
|
|
|
nsIDOMNode_SetNodeValue(This->nsnode, &val_str);
|
|
|
|
nsAString_Finish(&val_str);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2012-03-28 14:27:20 +02:00
|
|
|
FIXME("unsupported value %s\n", debugstr_variant(&v));
|
2008-06-19 00:06:34 +02:00
|
|
|
}
|
|
|
|
|
2006-03-05 20:38:30 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_nodeValue(IHTMLDOMNode *iface, VARIANT *p)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-06-19 00:06:00 +02:00
|
|
|
const PRUnichar *val;
|
|
|
|
nsAString val_str;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&val_str, NULL);
|
|
|
|
nsIDOMNode_GetNodeValue(This->nsnode, &val_str);
|
|
|
|
nsAString_GetData(&val_str, &val);
|
|
|
|
|
|
|
|
if(*val) {
|
|
|
|
V_VT(p) = VT_BSTR;
|
|
|
|
V_BSTR(p) = SysAllocString(val);
|
|
|
|
}else {
|
|
|
|
V_VT(p) = VT_NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAString_Finish(&val_str);
|
|
|
|
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_firstChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-04-24 18:24:59 +02:00
|
|
|
nsIDOMNode *nschild = NULL;
|
2010-12-01 12:52:08 +01:00
|
|
|
HTMLDOMNode *node;
|
|
|
|
HRESULT hres;
|
2008-04-24 18:24:59 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsIDOMNode_GetFirstChild(This->nsnode, &nschild);
|
2010-12-01 12:52:08 +01:00
|
|
|
if(!nschild) {
|
2008-04-24 18:24:59 +02:00
|
|
|
*p = NULL;
|
2010-12-01 12:52:08 +01:00
|
|
|
return S_OK;
|
2008-04-24 18:24:59 +02:00
|
|
|
}
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(This->doc, nschild, TRUE, &node);
|
|
|
|
nsIDOMNode_Release(nschild);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*p = &node->IHTMLDOMNode_iface;
|
2010-12-01 12:52:08 +01:00
|
|
|
IHTMLDOMNode_AddRef(*p);
|
2008-04-24 18:24:59 +02:00
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_lastChild(IHTMLDOMNode *iface, IHTMLDOMNode **p)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2008-06-24 03:02:42 +02:00
|
|
|
nsIDOMNode *nschild = NULL;
|
2010-12-01 12:52:08 +01:00
|
|
|
HTMLDOMNode *node;
|
|
|
|
HRESULT hres;
|
2008-06-24 03:02:42 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsIDOMNode_GetLastChild(This->nsnode, &nschild);
|
2010-12-01 12:52:08 +01:00
|
|
|
if(!nschild) {
|
2008-06-24 03:02:42 +02:00
|
|
|
*p = NULL;
|
2010-12-01 12:52:08 +01:00
|
|
|
return S_OK;
|
2008-06-24 03:02:42 +02:00
|
|
|
}
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(This->doc, nschild, TRUE, &node);
|
|
|
|
nsIDOMNode_Release(nschild);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*p = &node->IHTMLDOMNode_iface;
|
2010-12-01 12:52:08 +01:00
|
|
|
IHTMLDOMNode_AddRef(*p);
|
2008-06-24 03:02:42 +02:00
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_previousSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2011-03-08 10:39:08 +01:00
|
|
|
nsIDOMNode *nschild = NULL;
|
|
|
|
HTMLDOMNode *node;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsIDOMNode_GetPreviousSibling(This->nsnode, &nschild);
|
|
|
|
if(!nschild) {
|
|
|
|
*p = NULL;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = get_node(This->doc, nschild, TRUE, &node);
|
|
|
|
nsIDOMNode_Release(nschild);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
*p = &node->IHTMLDOMNode_iface;
|
|
|
|
IHTMLDOMNode_AddRef(*p);
|
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode_get_nextSibling(IHTMLDOMNode *iface, IHTMLDOMNode **p)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2009-10-29 02:37:44 +01:00
|
|
|
nsIDOMNode *nssibling = NULL;
|
2010-12-01 12:52:08 +01:00
|
|
|
HTMLDOMNode *node;
|
|
|
|
HRESULT hres;
|
2009-10-29 02:37:44 +01:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsIDOMNode_GetNextSibling(This->nsnode, &nssibling);
|
2010-12-01 12:52:08 +01:00
|
|
|
if(!nssibling) {
|
2009-10-29 02:37:44 +01:00
|
|
|
*p = NULL;
|
2010-12-01 12:52:08 +01:00
|
|
|
return S_OK;
|
2009-10-29 02:37:44 +01:00
|
|
|
}
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
hres = get_node(This->doc, nssibling, TRUE, &node);
|
|
|
|
nsIDOMNode_Release(nssibling);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*p = &node->IHTMLDOMNode_iface;
|
2010-12-01 12:52:08 +01:00
|
|
|
IHTMLDOMNode_AddRef(*p);
|
2009-10-29 02:37:44 +01:00
|
|
|
return S_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl = {
|
|
|
|
HTMLDOMNode_QueryInterface,
|
|
|
|
HTMLDOMNode_AddRef,
|
|
|
|
HTMLDOMNode_Release,
|
|
|
|
HTMLDOMNode_GetTypeInfoCount,
|
|
|
|
HTMLDOMNode_GetTypeInfo,
|
|
|
|
HTMLDOMNode_GetIDsOfNames,
|
|
|
|
HTMLDOMNode_Invoke,
|
|
|
|
HTMLDOMNode_get_nodeType,
|
|
|
|
HTMLDOMNode_get_parentNode,
|
|
|
|
HTMLDOMNode_hasChildNodes,
|
|
|
|
HTMLDOMNode_get_childNodes,
|
|
|
|
HTMLDOMNode_get_attributes,
|
|
|
|
HTMLDOMNode_insertBefore,
|
|
|
|
HTMLDOMNode_removeChild,
|
|
|
|
HTMLDOMNode_replaceChild,
|
|
|
|
HTMLDOMNode_cloneNode,
|
|
|
|
HTMLDOMNode_removeNode,
|
|
|
|
HTMLDOMNode_swapNode,
|
|
|
|
HTMLDOMNode_replaceNode,
|
|
|
|
HTMLDOMNode_appendChild,
|
|
|
|
HTMLDOMNode_get_nodeName,
|
|
|
|
HTMLDOMNode_put_nodeValue,
|
|
|
|
HTMLDOMNode_get_nodeValue,
|
|
|
|
HTMLDOMNode_get_firstChild,
|
|
|
|
HTMLDOMNode_get_lastChild,
|
|
|
|
HTMLDOMNode_get_previousSibling,
|
|
|
|
HTMLDOMNode_get_nextSibling
|
|
|
|
};
|
|
|
|
|
2010-12-30 01:40:18 +01:00
|
|
|
static inline HTMLDOMNode *impl_from_IHTMLDOMNode2(IHTMLDOMNode2 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLDOMNode, IHTMLDOMNode2_iface);
|
|
|
|
}
|
2008-04-24 18:22:51 +02:00
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode2_QueryInterface(IHTMLDOMNode2 *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
2010-12-30 01:40:18 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode2(iface);
|
2008-04-24 18:22:51 +02:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_QueryInterface(&This->IHTMLDOMNode_iface, riid, ppv);
|
2008-04-24 18:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMNode2_AddRef(IHTMLDOMNode2 *iface)
|
|
|
|
{
|
2010-12-30 01:40:18 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode2(iface);
|
2008-04-24 18:22:51 +02:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_AddRef(&This->IHTMLDOMNode_iface);
|
2008-04-24 18:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMNode2_Release(IHTMLDOMNode2 *iface)
|
|
|
|
{
|
2010-12-30 01:40:18 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode2(iface);
|
2008-04-24 18:22:51 +02:00
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
return IHTMLDOMNode_Release(&This->IHTMLDOMNode_iface);
|
2008-04-24 18:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode2_GetTypeInfoCount(IHTMLDOMNode2 *iface, UINT *pctinfo)
|
|
|
|
{
|
2010-12-30 01:40:18 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode2(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
|
2008-04-24 18:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode2_GetTypeInfo(IHTMLDOMNode2 *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
2010-12-30 01:40:18 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode2(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
2008-04-24 18:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode2_GetIDsOfNames(IHTMLDOMNode2 *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
2010-12-30 01:40:18 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode2(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
2008-04-24 18:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode2_Invoke(IHTMLDOMNode2 *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
2010-12-30 01:40:18 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode2(iface);
|
2010-12-31 11:07:33 +01:00
|
|
|
return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
|
2008-09-20 12:07:32 +02:00
|
|
|
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
2008-04-24 18:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode2_get_ownerDocument(IHTMLDOMNode2 *iface, IDispatch **p)
|
|
|
|
{
|
2010-12-30 01:40:18 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode2(iface);
|
2009-09-20 18:59:57 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
2009-11-01 19:24:03 +01:00
|
|
|
/* FIXME: Better check for document node */
|
|
|
|
if(This == &This->doc->node) {
|
|
|
|
*p = NULL;
|
|
|
|
}else {
|
2010-12-16 14:59:51 +01:00
|
|
|
*p = (IDispatch*)&This->doc->basedoc.IHTMLDocument2_iface;
|
2009-11-01 19:24:03 +01:00
|
|
|
IDispatch_AddRef(*p);
|
|
|
|
}
|
2009-09-20 18:59:57 +02:00
|
|
|
return S_OK;
|
2008-04-24 18:22:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLDOMNode2Vtbl HTMLDOMNode2Vtbl = {
|
|
|
|
HTMLDOMNode2_QueryInterface,
|
|
|
|
HTMLDOMNode2_AddRef,
|
|
|
|
HTMLDOMNode2_Release,
|
|
|
|
HTMLDOMNode2_GetTypeInfoCount,
|
|
|
|
HTMLDOMNode2_GetTypeInfo,
|
|
|
|
HTMLDOMNode2_GetIDsOfNames,
|
|
|
|
HTMLDOMNode2_Invoke,
|
|
|
|
HTMLDOMNode2_get_ownerDocument
|
|
|
|
};
|
|
|
|
|
2006-03-18 19:43:05 +01:00
|
|
|
HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
|
2010-12-30 01:39:16 +01:00
|
|
|
*ppv = &This->IHTMLDOMNode_iface;
|
2006-03-18 19:43:05 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
|
2010-12-30 01:39:16 +01:00
|
|
|
*ppv = &This->IHTMLDOMNode_iface;
|
2008-04-23 16:45:52 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
|
|
|
|
if(This->dispex.data) {
|
|
|
|
TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
|
2010-12-31 11:07:33 +01:00
|
|
|
*ppv = &This->dispex.IDispatchEx_iface;
|
2008-04-23 16:45:52 +02:00
|
|
|
}else {
|
|
|
|
FIXME("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2006-03-18 19:43:05 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
|
2010-12-30 01:39:16 +01:00
|
|
|
*ppv = &This->IHTMLDOMNode_iface;
|
2008-04-24 18:22:51 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLDOMNode2, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHTMLDOMNode2 %p)\n", This, ppv);
|
2010-12-30 01:40:18 +01:00
|
|
|
*ppv = &This->IHTMLDOMNode2_iface;
|
2008-06-30 21:38:23 +02:00
|
|
|
}else if(dispex_query_interface(&This->dispex, riid, ppv)) {
|
|
|
|
return *ppv ? S_OK : E_NOINTERFACE;
|
2006-03-18 19:43:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppv) {
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-10-04 02:10:36 +02:00
|
|
|
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
|
2006-03-18 19:43:05 +01:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2007-10-04 02:09:48 +02:00
|
|
|
void HTMLDOMNode_destructor(HTMLDOMNode *This)
|
|
|
|
{
|
|
|
|
if(This->nsnode)
|
|
|
|
nsIDOMNode_Release(This->nsnode);
|
2008-04-18 20:16:35 +02:00
|
|
|
if(This->event_target)
|
|
|
|
release_event_target(This->event_target);
|
2007-10-04 02:09:48 +02:00
|
|
|
}
|
|
|
|
|
2010-11-14 14:41:39 +01:00
|
|
|
static HRESULT HTMLDOMNode_clone(HTMLDOMNode *This, nsIDOMNode *nsnode, HTMLDOMNode **ret)
|
|
|
|
{
|
2010-12-01 22:42:03 +01:00
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
hres = create_node(This->doc, nsnode, ret);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
IHTMLDOMNode_AddRef(&(*ret)->IHTMLDOMNode_iface);
|
2010-11-14 14:41:39 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-10-04 02:09:48 +02:00
|
|
|
static const NodeImplVtbl HTMLDOMNodeImplVtbl = {
|
2007-10-04 02:10:36 +02:00
|
|
|
HTMLDOMNode_QI,
|
2010-11-14 14:41:39 +01:00
|
|
|
HTMLDOMNode_destructor,
|
|
|
|
HTMLDOMNode_clone
|
2007-10-04 02:09:48 +02:00
|
|
|
};
|
|
|
|
|
2009-09-16 22:13:31 +02:00
|
|
|
void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsnode)
|
2008-06-19 23:13:16 +02:00
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
node->IHTMLDOMNode_iface.lpVtbl = &HTMLDOMNodeVtbl;
|
2010-12-30 01:40:18 +01:00
|
|
|
node->IHTMLDOMNode2_iface.lpVtbl = &HTMLDOMNode2Vtbl;
|
2008-06-19 23:13:16 +02:00
|
|
|
node->ref = 1;
|
|
|
|
node->doc = doc;
|
|
|
|
|
2009-11-01 19:16:48 +01:00
|
|
|
if(nsnode)
|
|
|
|
nsIDOMNode_AddRef(nsnode);
|
2008-06-19 23:13:16 +02:00
|
|
|
node->nsnode = nsnode;
|
|
|
|
|
|
|
|
node->next = doc->nodes;
|
|
|
|
doc->nodes = node;
|
|
|
|
}
|
|
|
|
|
2010-12-01 22:42:03 +01:00
|
|
|
static HRESULT create_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **ret)
|
2007-09-12 23:39:17 +02:00
|
|
|
{
|
|
|
|
PRUint16 node_type;
|
2010-12-01 22:42:03 +01:00
|
|
|
HRESULT hres;
|
2007-09-12 23:39:17 +02:00
|
|
|
|
|
|
|
nsIDOMNode_GetNodeType(nsnode, &node_type);
|
|
|
|
|
|
|
|
switch(node_type) {
|
2010-12-01 22:42:51 +01:00
|
|
|
case ELEMENT_NODE: {
|
|
|
|
HTMLElement *elem;
|
|
|
|
hres = HTMLElement_Create(doc, nsnode, FALSE, &elem);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
*ret = &elem->node;
|
2007-09-12 23:39:17 +02:00
|
|
|
break;
|
2010-12-01 22:42:51 +01:00
|
|
|
}
|
2008-04-24 18:25:34 +02:00
|
|
|
case TEXT_NODE:
|
2010-12-01 22:42:03 +01:00
|
|
|
hres = HTMLDOMTextNode_Create(doc, nsnode, ret);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2008-04-24 18:25:34 +02:00
|
|
|
break;
|
2010-12-01 22:42:03 +01:00
|
|
|
case COMMENT_NODE: {
|
|
|
|
HTMLElement *comment;
|
|
|
|
hres = HTMLCommentElement_Create(doc, nsnode, &comment);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
*ret = &comment->node;
|
2008-04-30 18:19:49 +02:00
|
|
|
break;
|
2007-09-12 23:39:17 +02:00
|
|
|
}
|
2011-02-24 13:04:39 +01:00
|
|
|
case ATTRIBUTE_NODE:
|
|
|
|
ERR("Called on attribute node\n");
|
|
|
|
return E_UNEXPECTED;
|
2010-12-01 22:42:03 +01:00
|
|
|
default: {
|
|
|
|
HTMLDOMNode *node;
|
2007-09-12 23:39:17 +02:00
|
|
|
|
2010-12-01 22:42:03 +01:00
|
|
|
node = heap_alloc_zero(sizeof(HTMLDOMNode));
|
|
|
|
if(!node)
|
|
|
|
return E_OUTOFMEMORY;
|
2008-04-24 18:22:51 +02:00
|
|
|
|
2010-12-01 22:42:03 +01:00
|
|
|
node->vtbl = &HTMLDOMNodeImplVtbl;
|
|
|
|
HTMLDOMNode_Init(doc, node, nsnode);
|
|
|
|
*ret = node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("type %d ret %p\n", node_type, *ret);
|
|
|
|
return S_OK;
|
2007-09-12 23:39:17 +02:00
|
|
|
}
|
|
|
|
|
2006-03-05 20:38:30 +01:00
|
|
|
/*
|
|
|
|
* FIXME
|
|
|
|
* List looks really ugly here. We should use a better data structure or
|
2008-04-04 21:23:01 +02:00
|
|
|
* (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
|
2006-03-05 20:38:30 +01:00
|
|
|
*/
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
HRESULT get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create, HTMLDOMNode **ret)
|
2006-03-05 20:38:30 +01:00
|
|
|
{
|
2008-06-19 23:13:16 +02:00
|
|
|
HTMLDOMNode *iter = This->nodes;
|
2006-03-05 20:38:30 +01:00
|
|
|
|
|
|
|
while(iter) {
|
|
|
|
if(iter->nsnode == nsnode)
|
|
|
|
break;
|
|
|
|
iter = iter->next;
|
|
|
|
}
|
|
|
|
|
2010-12-01 12:52:08 +01:00
|
|
|
if(iter || !create) {
|
|
|
|
*ret = iter;
|
|
|
|
return S_OK;
|
|
|
|
}
|
2006-03-05 20:38:30 +01:00
|
|
|
|
2010-12-01 22:42:03 +01:00
|
|
|
return create_node(This, nsnode, ret);
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
2008-06-23 16:49:26 +02:00
|
|
|
/*
|
|
|
|
* FIXME
|
|
|
|
* We should use better way for getting node object (like private interface)
|
|
|
|
* or avoid it at all.
|
|
|
|
*/
|
2009-09-16 22:13:31 +02:00
|
|
|
static HTMLDOMNode *get_node_obj(HTMLDocumentNode *This, IUnknown *iface)
|
2008-06-23 16:49:26 +02:00
|
|
|
{
|
|
|
|
HTMLDOMNode *iter = This->nodes;
|
|
|
|
IHTMLDOMNode *node;
|
|
|
|
|
|
|
|
IUnknown_QueryInterface(iface, &IID_IHTMLDOMNode, (void**)&node);
|
|
|
|
IHTMLDOMNode_Release(node);
|
|
|
|
|
|
|
|
while(iter) {
|
2010-12-30 01:39:16 +01:00
|
|
|
if(&iter->IHTMLDOMNode_iface == node)
|
2008-06-23 16:49:26 +02:00
|
|
|
return iter;
|
|
|
|
iter = iter->next;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Not found %p\n", iface);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-09-16 22:13:31 +02:00
|
|
|
void release_nodes(HTMLDocumentNode *This)
|
2006-03-05 20:38:30 +01:00
|
|
|
{
|
|
|
|
HTMLDOMNode *iter, *next;
|
|
|
|
|
|
|
|
if(!This->nodes)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for(iter = This->nodes; iter; iter = next) {
|
|
|
|
next = iter->next;
|
2007-10-14 12:07:27 +02:00
|
|
|
iter->doc = NULL;
|
2009-09-16 22:13:49 +02:00
|
|
|
if(&This->node != iter)
|
2010-12-30 01:39:16 +01:00
|
|
|
IHTMLDOMNode_Release(&iter->IHTMLDOMNode_iface);
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
}
|