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>
|
2012-07-19 11:29:34 +02:00
|
|
|
#include <assert.h>
|
2006-03-05 20:38:30 +01:00
|
|
|
|
|
|
|
#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);
|
|
|
|
|
2012-10-02 15:45:15 +02:00
|
|
|
static HTMLDOMNode *get_node_obj(IHTMLDOMNode*);
|
2010-12-01 22:42:03 +01:00
|
|
|
static HRESULT create_node(HTMLDocumentNode*,nsIDOMNode*,HTMLDOMNode**);
|
2008-06-23 16:49:26 +02:00
|
|
|
|
2014-11-03 12:39:59 +01:00
|
|
|
static ExternalCycleCollectionParticipant node_ccp;
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
nsIDOMNodeList *nslist;
|
|
|
|
} HTMLDOMChildrenCollection;
|
|
|
|
|
2014-04-22 16:23:22 +02:00
|
|
|
typedef struct {
|
|
|
|
IEnumVARIANT IEnumVARIANT_iface;
|
|
|
|
|
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
ULONG iter;
|
|
|
|
HTMLDOMChildrenCollection *col;
|
|
|
|
} HTMLDOMChildrenCollectionEnum;
|
|
|
|
|
|
|
|
static inline HTMLDOMChildrenCollectionEnum *impl_from_IEnumVARIANT(IEnumVARIANT *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLDOMChildrenCollectionEnum, IEnumVARIANT_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollectionEnum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
HTMLDOMChildrenCollectionEnum *This = impl_from_IEnumVARIANT(iface);
|
|
|
|
|
2014-05-08 11:48:32 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
|
|
|
|
2014-04-22 16:23:22 +02:00
|
|
|
if(IsEqualGUID(riid, &IID_IUnknown)) {
|
|
|
|
*ppv = &This->IEnumVARIANT_iface;
|
|
|
|
}else if(IsEqualGUID(riid, &IID_IEnumVARIANT)) {
|
|
|
|
*ppv = &This->IEnumVARIANT_iface;
|
|
|
|
}else {
|
2014-05-08 11:48:32 +02:00
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
2014-04-22 16:23:22 +02:00
|
|
|
*ppv = NULL;
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMChildrenCollectionEnum_AddRef(IEnumVARIANT *iface)
|
|
|
|
{
|
|
|
|
HTMLDOMChildrenCollectionEnum *This = impl_from_IEnumVARIANT(iface);
|
|
|
|
LONG ref = InterlockedIncrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMChildrenCollectionEnum_Release(IEnumVARIANT *iface)
|
|
|
|
{
|
|
|
|
HTMLDOMChildrenCollectionEnum *This = impl_from_IEnumVARIANT(iface);
|
|
|
|
LONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p) ref=%d\n", This, ref);
|
|
|
|
|
|
|
|
if(!ref) {
|
|
|
|
IHTMLDOMChildrenCollection_Release(&This->col->IHTMLDOMChildrenCollection_iface);
|
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG get_enum_len(HTMLDOMChildrenCollectionEnum *This)
|
|
|
|
{
|
|
|
|
ULONG len;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
nsres = nsIDOMNodeList_GetLength(This->col->nslist, &len);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollectionEnum_Next(IEnumVARIANT *iface, ULONG celt, VARIANT *rgVar, ULONG *pCeltFetched)
|
|
|
|
{
|
|
|
|
HTMLDOMChildrenCollectionEnum *This = impl_from_IEnumVARIANT(iface);
|
|
|
|
ULONG fetched = 0, len;
|
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
HTMLDOMNode *node;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d %p %p)\n", This, celt, rgVar, pCeltFetched);
|
|
|
|
|
|
|
|
len = get_enum_len(This);
|
|
|
|
|
|
|
|
while(This->iter+fetched < len && fetched < celt) {
|
|
|
|
nsres = nsIDOMNodeList_Item(This->col->nslist, This->iter+fetched, &nsnode);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nsnode, TRUE, &node);
|
2014-04-22 16:23:22 +02:00
|
|
|
nsIDOMNode_Release(nsnode);
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("get_node failed: %08x\n", hres);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
V_VT(rgVar+fetched) = VT_DISPATCH;
|
|
|
|
IHTMLDOMNode_AddRef(&node->IHTMLDOMNode_iface);
|
|
|
|
V_DISPATCH(rgVar+fetched) = (IDispatch*)&node->IHTMLDOMNode_iface;
|
|
|
|
fetched++;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->iter += fetched;
|
|
|
|
if(pCeltFetched)
|
|
|
|
*pCeltFetched = fetched;
|
|
|
|
return fetched == celt ? S_OK : S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollectionEnum_Skip(IEnumVARIANT *iface, ULONG celt)
|
|
|
|
{
|
|
|
|
HTMLDOMChildrenCollectionEnum *This = impl_from_IEnumVARIANT(iface);
|
|
|
|
ULONG len;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%d)\n", This, celt);
|
|
|
|
|
|
|
|
len = get_enum_len(This);
|
|
|
|
if(This->iter + celt > len) {
|
|
|
|
This->iter = len;
|
|
|
|
return S_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
This->iter += celt;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollectionEnum_Reset(IEnumVARIANT *iface)
|
|
|
|
{
|
|
|
|
HTMLDOMChildrenCollectionEnum *This = impl_from_IEnumVARIANT(iface);
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
|
|
|
This->iter = 0;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollectionEnum_Clone(IEnumVARIANT *iface, IEnumVARIANT **ppEnum)
|
|
|
|
{
|
|
|
|
HTMLDOMChildrenCollectionEnum *This = impl_from_IEnumVARIANT(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, ppEnum);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IEnumVARIANTVtbl HTMLDOMChildrenCollectionEnumVtbl = {
|
|
|
|
HTMLDOMChildrenCollectionEnum_QueryInterface,
|
|
|
|
HTMLDOMChildrenCollectionEnum_AddRef,
|
|
|
|
HTMLDOMChildrenCollectionEnum_Release,
|
|
|
|
HTMLDOMChildrenCollectionEnum_Next,
|
|
|
|
HTMLDOMChildrenCollectionEnum_Skip,
|
|
|
|
HTMLDOMChildrenCollectionEnum_Reset,
|
|
|
|
HTMLDOMChildrenCollectionEnum_Clone
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2014-05-08 11:48:32 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
2008-04-30 18:17:34 +02:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
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)) {
|
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;
|
2014-05-08 11:48:32 +02:00
|
|
|
}else {
|
|
|
|
*ppv = NULL;
|
|
|
|
WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
|
|
|
return E_NOINTERFACE;
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
2014-05-08 11:48:32 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 length=0;
|
2008-04-30 18:17:44 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsIDOMNodeList_GetLength(This->nslist, &length);
|
|
|
|
*p = length;
|
|
|
|
return S_OK;
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
2014-04-22 16:23:22 +02:00
|
|
|
static HRESULT WINAPI HTMLDOMChildrenCollection_get__newEnum(IHTMLDOMChildrenCollection *iface, IUnknown **p)
|
2008-04-30 18:17:34 +02:00
|
|
|
{
|
2010-12-30 01:41:56 +01:00
|
|
|
HTMLDOMChildrenCollection *This = impl_from_IHTMLDOMChildrenCollection(iface);
|
2014-04-22 16:23:22 +02:00
|
|
|
HTMLDOMChildrenCollectionEnum *ret;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
ret = heap_alloc(sizeof(*ret));
|
|
|
|
if(!ret)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
ret->IEnumVARIANT_iface.lpVtbl = &HTMLDOMChildrenCollectionEnumVtbl;
|
|
|
|
ret->ref = 1;
|
|
|
|
ret->iter = 0;
|
|
|
|
|
|
|
|
IHTMLDOMChildrenCollection_AddRef(&This->IHTMLDOMChildrenCollection_iface);
|
|
|
|
ret->col = This;
|
|
|
|
|
|
|
|
*p = (IUnknown*)&ret->IEnumVARIANT_iface;
|
|
|
|
return S_OK;
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
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;
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 length=0;
|
2008-04-30 18:17:56 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nsnode, TRUE, &node);
|
2010-12-01 12:52:08 +01:00
|
|
|
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
|
|
|
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,
|
2014-04-22 16:23:22 +02:00
|
|
|
HTMLDOMChildrenCollection_get__newEnum,
|
2010-12-27 18:34:39 +01:00
|
|
|
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;
|
2013-01-23 18:44:42 +01:00
|
|
|
UINT32 len = 0;
|
2008-06-24 03:02:42 +02:00
|
|
|
|
2019-11-12 20:49:03 +01:00
|
|
|
for(ptr = name; *ptr && is_digit(*ptr); ptr++)
|
2008-06-24 03:02:42 +02:00
|
|
|
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,
|
2017-07-19 20:32:55 +02:00
|
|
|
HTMLDOMChildrenCollection_iface_tids,
|
|
|
|
HTMLDOMNode_init_dispex_info
|
2008-04-30 18:18:09 +02:00
|
|
|
};
|
|
|
|
|
2021-03-16 19:57:08 +01:00
|
|
|
HRESULT create_child_collection(nsIDOMNodeList *nslist, compat_mode_t compat_mode, IHTMLDOMChildrenCollection **ret)
|
2008-04-30 18:17:34 +02:00
|
|
|
{
|
2021-03-16 19:57:08 +01:00
|
|
|
HTMLDOMChildrenCollection *collection;
|
2008-04-30 18:17:34 +02:00
|
|
|
|
2021-03-16 19:57:08 +01:00
|
|
|
if(!(collection = heap_alloc_zero(sizeof(*collection))))
|
|
|
|
return E_OUTOFMEMORY;
|
2012-10-19 11:58:34 +02:00
|
|
|
|
2021-03-16 19:57:08 +01:00
|
|
|
collection->IHTMLDOMChildrenCollection_iface.lpVtbl = &HTMLDOMChildrenCollectionVtbl;
|
|
|
|
collection->ref = 1;
|
2008-04-30 18:17:34 +02:00
|
|
|
|
|
|
|
nsIDOMNodeList_AddRef(nslist);
|
2021-03-16 19:57:08 +01:00
|
|
|
collection->nslist = nslist;
|
2012-06-28 11:20:50 +02:00
|
|
|
|
2021-03-16 19:57:45 +01:00
|
|
|
init_dispatch(&collection->dispex, (IUnknown*)&collection->IHTMLDOMChildrenCollection_iface,
|
|
|
|
&HTMLDOMChildrenCollection_dispex, compat_mode);
|
2008-04-30 18:18:09 +02:00
|
|
|
|
2021-03-16 19:57:08 +01:00
|
|
|
*ret = &collection->IHTMLDOMChildrenCollection_iface;
|
|
|
|
return S_OK;
|
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);
|
2014-11-03 12:39:59 +01:00
|
|
|
LONG ref;
|
|
|
|
|
|
|
|
ref = ccref_incr(&This->ccref, (nsISupports*)&This->IHTMLDOMNode_iface);
|
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);
|
2014-11-03 12:39:59 +01:00
|
|
|
LONG ref = ccref_decr(&This->ccref, (nsISupports*)&This->IHTMLDOMNode_iface, /*&node_ccp*/ NULL);
|
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 HRESULT WINAPI HTMLDOMNode_GetTypeInfoCount(IHTMLDOMNode *iface, UINT *pctinfo)
|
|
|
|
{
|
2010-12-30 01:39:16 +01:00
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(iface);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->event_target.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);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->event_target.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);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
|
2010-12-31 11:07:33 +01:00
|
|
|
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);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_Invoke(&This->event_target.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);
|
2013-01-23 18:43:55 +01:00
|
|
|
UINT16 type = -1;
|
2008-04-24 18:26:18 +02:00
|
|
|
|
|
|
|
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:
|
2013-01-17 15:24:38 +01:00
|
|
|
case DOCUMENT_TYPE_NODE:
|
2008-04-30 18:17:34 +02:00
|
|
|
*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;
|
|
|
|
}
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nsnode, TRUE, &node);
|
2010-12-01 12:52:08 +01:00
|
|
|
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
|
|
|
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);
|
|
|
|
|
2017-11-02 16:48:02 +01:00
|
|
|
*fChildren = variant_bool(has_child);
|
2008-06-24 03:03:25 +02:00
|
|
|
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;
|
2021-03-16 19:57:08 +01:00
|
|
|
HRESULT hres;
|
2008-04-30 18:17:34 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
2021-03-16 19:57:08 +01:00
|
|
|
hres = map_nsresult(nsIDOMNode_GetChildNodes(This->nsnode, &nslist));
|
|
|
|
if(FAILED(hres)) {
|
|
|
|
ERR("GetChildNodes failed: %08x\n", hres);
|
|
|
|
return hres;
|
2008-04-30 18:17:34 +02:00
|
|
|
}
|
|
|
|
|
2021-03-16 19:57:08 +01:00
|
|
|
hres = create_child_collection(nslist, dispex_compat_mode(&This->event_target.dispex),
|
|
|
|
(IHTMLDOMChildrenCollection**)p);
|
2008-04-30 18:17:34 +02:00
|
|
|
nsIDOMNodeList_Release(nslist);
|
2021-03-16 19:57:08 +01:00
|
|
|
return hres;
|
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);
|
2012-06-28 11:21:10 +02:00
|
|
|
HTMLDOMNode *new_child, *node_obj, *ref_node = NULL;
|
|
|
|
nsIDOMNode *nsnode;
|
2008-10-13 21:50:52 +02:00
|
|
|
nsresult nsres;
|
2012-06-28 11:21:10 +02:00
|
|
|
HRESULT hres = S_OK;
|
2008-10-13 21:50:52 +02:00
|
|
|
|
|
|
|
TRACE("(%p)->(%p %s %p)\n", This, newChild, debugstr_variant(&refChild), node);
|
|
|
|
|
2012-10-02 15:45:15 +02:00
|
|
|
new_child = get_node_obj(newChild);
|
2008-10-13 21:50:52 +02:00
|
|
|
if(!new_child) {
|
|
|
|
ERR("invalid newChild\n");
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(V_VT(&refChild)) {
|
|
|
|
case VT_NULL:
|
|
|
|
break;
|
|
|
|
case VT_DISPATCH: {
|
2012-10-02 15:45:15 +02:00
|
|
|
IHTMLDOMNode *ref_iface;
|
|
|
|
|
2012-07-26 17:52:42 +02:00
|
|
|
if(!V_DISPATCH(&refChild))
|
|
|
|
break;
|
2012-10-02 15:45:15 +02:00
|
|
|
|
|
|
|
hres = IDispatch_QueryInterface(V_DISPATCH(&refChild), &IID_IHTMLDOMNode, (void**)&ref_iface);
|
|
|
|
if(FAILED(hres))
|
|
|
|
break;
|
|
|
|
|
|
|
|
ref_node = get_node_obj(ref_iface);
|
|
|
|
IHTMLDOMNode_Release(ref_iface);
|
2008-10-13 21:50:52 +02:00
|
|
|
if(!ref_node) {
|
|
|
|
ERR("unvalid node\n");
|
2012-06-28 11:21:10 +02:00
|
|
|
hres = E_FAIL;
|
|
|
|
break;
|
2008-10-13 21:50:52 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2012-03-28 14:27:20 +02:00
|
|
|
FIXME("unimplemented refChild %s\n", debugstr_variant(&refChild));
|
2012-06-28 11:21:10 +02:00
|
|
|
hres = E_NOTIMPL;
|
2008-10-13 21:50:52 +02:00
|
|
|
}
|
|
|
|
|
2012-06-28 11:21:10 +02:00
|
|
|
if(SUCCEEDED(hres)) {
|
|
|
|
nsres = nsIDOMNode_InsertBefore(This->nsnode, new_child->nsnode, ref_node ? ref_node->nsnode : NULL, &nsnode);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("InsertBefore failed: %08x\n", nsres);
|
|
|
|
hres = E_FAIL;
|
|
|
|
}
|
2008-10-13 21:50:52 +02:00
|
|
|
}
|
2012-06-28 11:21:10 +02:00
|
|
|
node_release(new_child);
|
|
|
|
if(ref_node)
|
|
|
|
node_release(ref_node);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
2008-10-13 21:50:52 +02:00
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(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
|
|
|
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);
|
|
|
|
|
2012-10-02 15:45:15 +02:00
|
|
|
node_obj = get_node_obj(oldChild);
|
2008-06-24 03:03:43 +02:00
|
|
|
if(!node_obj)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_RemoveChild(This->nsnode, node_obj->nsnode, &nsnode);
|
2012-06-28 11:21:10 +02:00
|
|
|
node_release(node_obj);
|
2008-06-24 03:03:43 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("RemoveChild failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(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
|
|
|
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);
|
2012-06-28 11:21:10 +02:00
|
|
|
HTMLDOMNode *node_new, *node_old, *ret_node;
|
2011-02-19 05:58:30 +01:00
|
|
|
nsIDOMNode *nsnode;
|
|
|
|
nsresult nsres;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, newChild, oldChild, node);
|
|
|
|
|
2012-10-02 15:45:15 +02:00
|
|
|
node_new = get_node_obj(newChild);
|
2011-02-19 05:58:30 +01:00
|
|
|
if(!node_new)
|
|
|
|
return E_FAIL;
|
|
|
|
|
2012-10-02 15:45:15 +02:00
|
|
|
node_old = get_node_obj(oldChild);
|
2012-06-28 11:21:10 +02:00
|
|
|
if(!node_old) {
|
|
|
|
node_release(node_new);
|
2011-02-19 05:58:30 +01:00
|
|
|
return E_FAIL;
|
2012-06-28 11:21:10 +02:00
|
|
|
}
|
2011-02-19 05:58:30 +01:00
|
|
|
|
|
|
|
nsres = nsIDOMNode_ReplaceChild(This->nsnode, node_new->nsnode, node_old->nsnode, &nsnode);
|
2012-06-28 11:21:10 +02:00
|
|
|
node_release(node_new);
|
|
|
|
node_release(node_old);
|
|
|
|
if(NS_FAILED(nsres))
|
2011-02-19 05:58:30 +01:00
|
|
|
return E_FAIL;
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nsnode, TRUE, &ret_node);
|
2011-02-19 05:58:30 +01:00
|
|
|
nsIDOMNode_Release(nsnode);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2012-06-28 11:21:10 +02:00
|
|
|
*node = &ret_node->IHTMLDOMNode_iface;
|
2011-02-19 05:58:30 +01:00
|
|
|
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);
|
|
|
|
|
2012-06-11 15:32:18 +02:00
|
|
|
nsres = nsIDOMNode_CloneNode(This->nsnode, fDeep != VARIANT_FALSE, 1, &nsnode);
|
2009-10-02 13:54:22 +02:00
|
|
|
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);
|
|
|
|
|
2012-10-02 15:45:15 +02:00
|
|
|
node_obj = get_node_obj(newChild);
|
2008-06-23 16:49:26 +02:00
|
|
|
if(!node_obj)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_AppendChild(This->nsnode, node_obj->nsnode, &nsnode);
|
2012-06-28 11:21:10 +02:00
|
|
|
node_release(node_obj);
|
2008-06-23 16:49:26 +02:00
|
|
|
if(NS_FAILED(nsres)) {
|
2012-06-28 11:21:10 +02:00
|
|
|
ERR("AppendChild failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
2008-06-23 16:49:26 +02:00
|
|
|
}
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nsnode, TRUE, &node_obj);
|
2010-12-01 12:52:08 +01:00
|
|
|
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
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nschild, TRUE, &node);
|
2010-12-01 12:52:08 +01:00
|
|
|
nsIDOMNode_Release(nschild);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*p = &node->IHTMLDOMNode_iface;
|
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
|
|
|
}
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nschild, TRUE, &node);
|
2010-12-01 12:52:08 +01:00
|
|
|
nsIDOMNode_Release(nschild);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*p = &node->IHTMLDOMNode_iface;
|
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;
|
|
|
|
}
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nschild, TRUE, &node);
|
2011-03-08 10:39:08 +01:00
|
|
|
nsIDOMNode_Release(nschild);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
|
|
|
*p = &node->IHTMLDOMNode_iface;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
hres = get_node(nssibling, TRUE, &node);
|
2010-12-01 12:52:08 +01:00
|
|
|
nsIDOMNode_Release(nssibling);
|
|
|
|
if(FAILED(hres))
|
|
|
|
return hres;
|
|
|
|
|
2010-12-30 01:39:16 +01:00
|
|
|
*p = &node->IHTMLDOMNode_iface;
|
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
|
|
|
|
};
|
|
|
|
|
2012-10-02 15:45:15 +02:00
|
|
|
static HTMLDOMNode *get_node_obj(IHTMLDOMNode *iface)
|
2012-06-28 11:22:12 +02:00
|
|
|
{
|
2012-10-02 15:45:15 +02:00
|
|
|
HTMLDOMNode *ret;
|
|
|
|
|
|
|
|
if(iface->lpVtbl != &HTMLDOMNodeVtbl)
|
|
|
|
return NULL;
|
2012-06-28 11:22:12 +02:00
|
|
|
|
2012-10-02 15:45:15 +02:00
|
|
|
ret = impl_from_IHTMLDOMNode(iface);
|
|
|
|
node_addref(ret);
|
|
|
|
return ret;
|
2012-06-28 11:22:12 +02:00
|
|
|
}
|
|
|
|
|
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);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->event_target.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);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetTypeInfo(&This->event_target.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);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_GetIDsOfNames(&This->event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
|
2010-12-31 11:07:33 +01:00
|
|
|
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);
|
2015-05-14 13:24:19 +02:00
|
|
|
return IDispatchEx_Invoke(&This->event_target.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
|
|
|
|
};
|
|
|
|
|
2017-07-19 20:32:40 +02:00
|
|
|
static inline HTMLDOMNode *impl_from_IHTMLDOMNode3(IHTMLDOMNode3 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, HTMLDOMNode, IHTMLDOMNode3_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_QueryInterface(IHTMLDOMNode3 *iface, REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
return IHTMLDOMNode_QueryInterface(&This->IHTMLDOMNode_iface, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMNode3_AddRef(IHTMLDOMNode3 *iface)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
|
|
|
|
return IHTMLDOMNode_AddRef(&This->IHTMLDOMNode_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMNode3_Release(IHTMLDOMNode3 *iface)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
|
|
|
|
return IHTMLDOMNode_Release(&This->IHTMLDOMNode_iface);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_GetTypeInfoCount(IHTMLDOMNode3 *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
return IDispatchEx_GetTypeInfoCount(&This->event_target.dispex.IDispatchEx_iface, pctinfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_GetTypeInfo(IHTMLDOMNode3 *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
return IDispatchEx_GetTypeInfo(&This->event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_GetIDsOfNames(IHTMLDOMNode3 *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
return IDispatchEx_GetIDsOfNames(&This->event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
|
|
|
|
lcid, rgDispId);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_Invoke(IHTMLDOMNode3 *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
return IDispatchEx_Invoke(&This->event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
|
|
|
|
wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_put_prefix(IHTMLDOMNode3 *iface, VARIANT v)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_get_prefix(IHTMLDOMNode3 *iface, VARIANT *p)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_get_localName(IHTMLDOMNode3 *iface, VARIANT *p)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_get_namespaceURI(IHTMLDOMNode3 *iface, VARIANT *p)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
2019-03-28 15:55:56 +01:00
|
|
|
nsAString nsstr;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_InitDepend(&nsstr, NULL);
|
|
|
|
nsres = nsIDOMNode_GetNamespaceURI(This->nsnode, &nsstr);
|
2020-05-28 23:06:38 +02:00
|
|
|
return return_nsstr_variant(nsres, &nsstr, 0, p);
|
2017-07-19 20:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_put_textContent(IHTMLDOMNode3 *iface, VARIANT v)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
2017-07-21 15:11:10 +02:00
|
|
|
nsAString nsstr;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
|
|
|
|
|
2019-04-19 16:37:23 +02:00
|
|
|
variant_to_nsstr(&v, FALSE, &nsstr);
|
2017-07-21 15:11:10 +02:00
|
|
|
nsres = nsIDOMNode_SetTextContent(This->nsnode, &nsstr);
|
|
|
|
nsAString_Finish(&nsstr);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("SetTextContent failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
2017-07-19 20:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_get_textContent(IHTMLDOMNode3 *iface, VARIANT *p)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
2017-07-20 18:11:29 +02:00
|
|
|
nsAString nsstr;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsAString_Init(&nsstr, NULL);
|
|
|
|
nsres = nsIDOMNode_GetTextContent(This->nsnode, &nsstr);
|
2020-05-28 23:06:38 +02:00
|
|
|
return return_nsstr_variant(nsres, &nsstr, 0, p);
|
2017-07-19 20:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_isEqualNode(IHTMLDOMNode3 *iface, IHTMLDOMNode3 *otherNode, VARIANT_BOOL *isEqual)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_lookupNamespaceURI(IHTMLDOMNode3 *iface, VARIANT *prefix, VARIANT *namespaceURI)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_variant(prefix), namespaceURI);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_lookupPrefix(IHTMLDOMNode3 *iface, VARIANT *namespaceURI, VARIANT *prefix)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
FIXME("(%p)->(%s %p)\n", This, debugstr_variant(namespaceURI), prefix);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_isDefaultNamespace(IHTMLDOMNode3 *iface, VARIANT *namespace, VARIANT_BOOL *pfDefaultNamespace)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_appendChild(IHTMLDOMNode3 *iface, IHTMLDOMNode *newChild, IHTMLDOMNode **node)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
2017-07-19 20:32:49 +02:00
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
return IHTMLDOMNode_appendChild(&This->IHTMLDOMNode_iface, newChild, node);
|
2017-07-19 20:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_insertBefore(IHTMLDOMNode3 *iface, IHTMLDOMNode *newChild, VARIANT refChild, IHTMLDOMNode **node)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
2017-07-19 20:32:49 +02:00
|
|
|
TRACE("(%p)->(%p %s %p)\n", This, newChild, debugstr_variant(&refChild), node);
|
|
|
|
return IHTMLDOMNode_insertBefore(&This->IHTMLDOMNode_iface, newChild, refChild, node);
|
2017-07-19 20:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_removeChild(IHTMLDOMNode3 *iface, IHTMLDOMNode *oldChild, IHTMLDOMNode **node)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
2017-07-19 20:32:49 +02:00
|
|
|
TRACE("(%p)->(%p %p)\n", This, oldChild, node);
|
|
|
|
return IHTMLDOMNode_removeChild(&This->IHTMLDOMNode_iface, oldChild, node);
|
2017-07-19 20:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_replaceChild(IHTMLDOMNode3 *iface, IHTMLDOMNode *newChild, IHTMLDOMNode *oldChild, IHTMLDOMNode **node)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
2017-07-19 20:32:49 +02:00
|
|
|
TRACE("(%p)->(%p %p %p)\n", This, newChild, oldChild, node);
|
|
|
|
return IHTMLDOMNode_replaceChild(&This->IHTMLDOMNode_iface, newChild, oldChild, node);
|
2017-07-19 20:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_isSameNode(IHTMLDOMNode3 *iface, IHTMLDOMNode3 *otherNode, VARIANT_BOOL *isSame)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
FIXME("(%p)->()\n", This);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_compareDocumentPosition(IHTMLDOMNode3 *iface, IHTMLDOMNode *otherNode, USHORT *flags)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
2017-11-23 17:37:03 +01:00
|
|
|
HTMLDOMNode *other;
|
|
|
|
UINT16 position;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->()\n", This);
|
|
|
|
|
|
|
|
other = get_node_obj(otherNode);
|
|
|
|
if(!other)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
nsres = nsIDOMNode_CompareDocumentPosition(This->nsnode, other->nsnode, &position);
|
|
|
|
IHTMLDOMNode_Release(&other->IHTMLDOMNode_iface);
|
|
|
|
if(NS_FAILED(nsres)) {
|
|
|
|
ERR("failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
*flags = position;
|
|
|
|
return S_OK;
|
2017-07-19 20:32:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMNode3_isSupported(IHTMLDOMNode3 *iface, BSTR feature, VARIANT version, VARIANT_BOOL *pfisSupported)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode3(iface);
|
|
|
|
FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(feature), debugstr_variant(&version), pfisSupported);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IHTMLDOMNode3Vtbl HTMLDOMNode3Vtbl = {
|
|
|
|
HTMLDOMNode3_QueryInterface,
|
|
|
|
HTMLDOMNode3_AddRef,
|
|
|
|
HTMLDOMNode3_Release,
|
|
|
|
HTMLDOMNode3_GetTypeInfoCount,
|
|
|
|
HTMLDOMNode3_GetTypeInfo,
|
|
|
|
HTMLDOMNode3_GetIDsOfNames,
|
|
|
|
HTMLDOMNode3_Invoke,
|
|
|
|
HTMLDOMNode3_put_prefix,
|
|
|
|
HTMLDOMNode3_get_prefix,
|
|
|
|
HTMLDOMNode3_get_localName,
|
|
|
|
HTMLDOMNode3_get_namespaceURI,
|
|
|
|
HTMLDOMNode3_put_textContent,
|
|
|
|
HTMLDOMNode3_get_textContent,
|
|
|
|
HTMLDOMNode3_isEqualNode,
|
|
|
|
HTMLDOMNode3_lookupNamespaceURI,
|
|
|
|
HTMLDOMNode3_lookupPrefix,
|
|
|
|
HTMLDOMNode3_isDefaultNamespace,
|
|
|
|
HTMLDOMNode3_appendChild,
|
|
|
|
HTMLDOMNode3_insertBefore,
|
|
|
|
HTMLDOMNode3_removeChild,
|
|
|
|
HTMLDOMNode3_replaceChild,
|
|
|
|
HTMLDOMNode3_isSameNode,
|
|
|
|
HTMLDOMNode3_compareDocumentPosition,
|
|
|
|
HTMLDOMNode3_isSupported
|
|
|
|
};
|
|
|
|
|
2006-03-18 19:43:05 +01:00
|
|
|
HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv)
|
|
|
|
{
|
2014-05-08 11:48:32 +02:00
|
|
|
TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
|
2006-03-18 19:43:05 +01:00
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IUnknown, riid)) {
|
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)) {
|
2010-12-30 01:39:16 +01:00
|
|
|
*ppv = &This->IHTMLDOMNode_iface;
|
2006-03-18 19:43:05 +01:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
|
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)) {
|
2010-12-30 01:40:18 +01:00
|
|
|
*ppv = &This->IHTMLDOMNode2_iface;
|
2017-07-19 20:32:40 +02:00
|
|
|
}else if(IsEqualGUID(&IID_IHTMLDOMNode3, riid)) {
|
|
|
|
*ppv = &This->IHTMLDOMNode3_iface;
|
2012-07-19 11:28:35 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsXPCOMCycleCollectionParticipant, riid)) {
|
|
|
|
*ppv = &node_ccp;
|
2016-09-13 20:54:20 +02:00
|
|
|
return S_OK;
|
2012-07-19 11:28:35 +02:00
|
|
|
}else if(IsEqualGUID(&IID_nsCycleCollectionISupports, riid)) {
|
|
|
|
*ppv = &This->IHTMLDOMNode_iface;
|
2016-09-13 20:54:20 +02:00
|
|
|
return S_OK;
|
2014-05-08 11:48:32 +02:00
|
|
|
}else {
|
2017-09-21 23:25:36 +02:00
|
|
|
return EventTarget_QI(&This->event_target, riid, ppv);
|
2006-03-18 19:43:05 +01:00
|
|
|
}
|
|
|
|
|
2014-05-08 11:48:32 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
2006-03-18 19:43:05 +01:00
|
|
|
}
|
|
|
|
|
2007-10-04 02:09:48 +02:00
|
|
|
void HTMLDOMNode_destructor(HTMLDOMNode *This)
|
|
|
|
{
|
2017-02-13 21:11:50 +01:00
|
|
|
release_event_target(&This->event_target);
|
2007-10-04 02:09:48 +02:00
|
|
|
if(This->nsnode)
|
|
|
|
nsIDOMNode_Release(This->nsnode);
|
2012-07-19 11:29:34 +02:00
|
|
|
if(This->doc && &This->doc->node != This)
|
|
|
|
htmldoc_release(&This->doc->basedoc);
|
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)
|
|
|
|
{
|
2012-06-26 12:33:35 +02:00
|
|
|
return create_node(This->doc, nsnode, ret);
|
2010-11-14 14:41:39 +01:00
|
|
|
}
|
|
|
|
|
2017-07-19 20:32:55 +02:00
|
|
|
void HTMLDOMNode_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
|
|
|
|
{
|
|
|
|
if(mode >= COMPAT_MODE_IE9)
|
|
|
|
dispex_info_add_interface(info, IHTMLDOMNode3_tid, NULL);
|
2017-11-01 16:44:02 +01:00
|
|
|
|
|
|
|
EventTarget_init_dispex_info(info, mode);
|
2017-07-19 20:32:55 +02:00
|
|
|
}
|
|
|
|
|
2013-03-15 15:01:53 +01:00
|
|
|
static const cpc_entry_t HTMLDOMNode_cpc[] = {{NULL}};
|
|
|
|
|
2007-10-04 02:09:48 +02:00
|
|
|
static const NodeImplVtbl HTMLDOMNodeImplVtbl = {
|
2017-04-21 13:50:49 +02:00
|
|
|
NULL,
|
2007-10-04 02:10:36 +02:00
|
|
|
HTMLDOMNode_QI,
|
2010-11-14 14:41:39 +01:00
|
|
|
HTMLDOMNode_destructor,
|
2013-03-15 15:01:53 +01:00
|
|
|
HTMLDOMNode_cpc,
|
2010-11-14 14:41:39 +01:00
|
|
|
HTMLDOMNode_clone
|
2007-10-04 02:09:48 +02:00
|
|
|
};
|
|
|
|
|
2017-09-21 23:25:17 +02:00
|
|
|
void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsnode, dispex_static_data_t *dispex_data)
|
2008-06-19 23:13:16 +02:00
|
|
|
{
|
2012-07-19 11:29:34 +02:00
|
|
|
nsresult nsres;
|
|
|
|
|
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;
|
2017-07-19 20:32:40 +02:00
|
|
|
node->IHTMLDOMNode3_iface.lpVtbl = &HTMLDOMNode3Vtbl;
|
2012-07-19 11:29:34 +02:00
|
|
|
|
|
|
|
ccref_init(&node->ccref, 1);
|
2017-09-21 23:25:27 +02:00
|
|
|
EventTarget_Init(&node->event_target, (IUnknown*)&node->IHTMLDOMNode_iface, dispex_data, doc->document_mode);
|
2012-07-19 11:29:34 +02:00
|
|
|
|
|
|
|
if(&doc->node != node)
|
|
|
|
htmldoc_addref(&doc->basedoc);
|
2008-06-19 23:13:16 +02:00
|
|
|
node->doc = doc;
|
|
|
|
|
2012-10-19 11:58:34 +02:00
|
|
|
nsIDOMNode_AddRef(nsnode);
|
2008-06-19 23:13:16 +02:00
|
|
|
node->nsnode = nsnode;
|
|
|
|
|
2012-07-19 11:29:34 +02:00
|
|
|
nsres = nsIDOMNode_SetMshtmlNode(nsnode, (nsISupports*)&node->IHTMLDOMNode_iface);
|
|
|
|
assert(nsres == NS_OK);
|
2008-06-19 23:13:16 +02:00
|
|
|
}
|
|
|
|
|
2017-09-21 23:25:17 +02:00
|
|
|
static const tid_t HTMLDOMNode_iface_tids[] = {
|
|
|
|
IHTMLDOMNode_tid,
|
|
|
|
0
|
|
|
|
};
|
|
|
|
static dispex_static_data_t HTMLDOMNode_dispex = {
|
|
|
|
NULL,
|
|
|
|
IHTMLDOMNode_tid,
|
|
|
|
HTMLDOMNode_iface_tids,
|
|
|
|
HTMLDOMNode_init_dispex_info
|
|
|
|
};
|
|
|
|
|
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
|
|
|
{
|
2013-01-23 18:43:55 +01:00
|
|
|
UINT16 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;
|
2013-01-17 15:24:38 +01:00
|
|
|
/* doctype nodes are represented as comment nodes (at least in quirks mode) */
|
|
|
|
case DOCUMENT_TYPE_NODE:
|
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
|
|
|
|
2017-09-21 23:25:17 +02:00
|
|
|
FIXME("unimplemented node type %u\n", node_type);
|
|
|
|
|
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;
|
2017-09-21 23:25:17 +02:00
|
|
|
HTMLDOMNode_Init(doc, node, nsnode, &HTMLDOMNode_dispex);
|
2010-12-01 22:42:03 +01:00
|
|
|
*ret = node;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("type %d ret %p\n", node_type, *ret);
|
|
|
|
return S_OK;
|
2007-09-12 23:39:17 +02:00
|
|
|
}
|
|
|
|
|
2012-07-19 11:28:35 +02:00
|
|
|
static nsresult NSAPI HTMLDOMNode_traverse(void *ccp, void *p, nsCycleCollectionTraversalCallback *cb)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(p);
|
|
|
|
|
|
|
|
TRACE("%p\n", This);
|
|
|
|
|
2013-01-09 14:21:18 +01:00
|
|
|
describe_cc_node(&This->ccref, "HTMLDOMNode", cb);
|
2012-07-19 11:28:35 +02:00
|
|
|
|
|
|
|
if(This->nsnode)
|
|
|
|
note_cc_edge((nsISupports*)This->nsnode, "This->nsnode", cb);
|
2012-07-19 11:29:34 +02:00
|
|
|
if(This->doc && &This->doc->node != This)
|
|
|
|
note_cc_edge((nsISupports*)&This->doc->node.IHTMLDOMNode_iface, "This->doc", cb);
|
2015-05-14 13:24:19 +02:00
|
|
|
dispex_traverse(&This->event_target.dispex, cb);
|
2012-07-19 11:28:35 +02:00
|
|
|
|
2012-07-19 11:29:13 +02:00
|
|
|
if(This->vtbl->traverse)
|
|
|
|
This->vtbl->traverse(This, cb);
|
|
|
|
|
2012-07-19 11:28:35 +02:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult NSAPI HTMLDOMNode_unlink(void *p)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(p);
|
|
|
|
|
|
|
|
TRACE("%p\n", This);
|
|
|
|
|
2012-07-19 11:29:13 +02:00
|
|
|
if(This->vtbl->unlink)
|
|
|
|
This->vtbl->unlink(This);
|
|
|
|
|
2015-05-14 13:24:19 +02:00
|
|
|
dispex_unlink(&This->event_target.dispex);
|
2012-07-19 11:28:54 +02:00
|
|
|
|
2012-07-19 11:28:35 +02:00
|
|
|
if(This->nsnode) {
|
|
|
|
nsIDOMNode *nsnode = This->nsnode;
|
|
|
|
This->nsnode = NULL;
|
|
|
|
nsIDOMNode_Release(nsnode);
|
|
|
|
}
|
|
|
|
|
2012-07-19 11:29:34 +02:00
|
|
|
if(This->doc && &This->doc->node != This) {
|
2019-03-13 17:53:59 +01:00
|
|
|
HTMLDocumentNode *doc = This->doc;
|
2012-07-19 11:29:34 +02:00
|
|
|
This->doc = NULL;
|
2019-03-13 17:53:59 +01:00
|
|
|
htmldoc_release(&doc->basedoc);
|
2012-07-19 11:29:34 +02:00
|
|
|
}else {
|
|
|
|
This->doc = NULL;
|
|
|
|
}
|
|
|
|
|
2012-07-19 11:28:35 +02:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-11-03 12:39:59 +01:00
|
|
|
static void NSAPI HTMLDOMNode_delete_cycle_collectable(void *p)
|
|
|
|
{
|
|
|
|
HTMLDOMNode *This = impl_from_IHTMLDOMNode(p);
|
|
|
|
|
|
|
|
TRACE("(%p)\n", This);
|
|
|
|
|
|
|
|
if(This->vtbl->unlink)
|
|
|
|
This->vtbl->unlink(This);
|
|
|
|
This->vtbl->destructor(This);
|
2015-05-14 13:24:19 +02:00
|
|
|
release_dispex(&This->event_target.dispex);
|
2014-11-03 12:39:59 +01:00
|
|
|
heap_free(This);
|
|
|
|
}
|
|
|
|
|
2012-07-19 11:28:35 +02:00
|
|
|
void init_node_cc(void)
|
|
|
|
{
|
|
|
|
static const CCObjCallback node_ccp_callback = {
|
|
|
|
HTMLDOMNode_traverse,
|
2014-11-03 12:39:59 +01:00
|
|
|
HTMLDOMNode_unlink,
|
|
|
|
HTMLDOMNode_delete_cycle_collectable
|
2012-07-19 11:28:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
ccp_init(&node_ccp, &node_ccp_callback);
|
|
|
|
}
|
|
|
|
|
2018-02-19 14:49:07 +01:00
|
|
|
HRESULT get_node(nsIDOMNode *nsnode, BOOL create, HTMLDOMNode **ret)
|
2006-03-05 20:38:30 +01:00
|
|
|
{
|
2018-02-19 14:48:44 +01:00
|
|
|
nsIDOMDocument *dom_document;
|
|
|
|
HTMLDocumentNode *document;
|
2012-07-19 11:29:34 +02:00
|
|
|
nsISupports *unk = NULL;
|
|
|
|
nsresult nsres;
|
2018-02-19 14:48:44 +01:00
|
|
|
HRESULT hres;
|
2006-03-05 20:38:30 +01:00
|
|
|
|
2012-07-19 11:29:34 +02:00
|
|
|
nsres = nsIDOMNode_GetMshtmlNode(nsnode, &unk);
|
|
|
|
assert(nsres == NS_OK);
|
|
|
|
|
|
|
|
if(unk) {
|
2012-10-02 15:45:15 +02:00
|
|
|
*ret = get_node_obj((IHTMLDOMNode*)unk);
|
2013-04-29 11:52:18 +02:00
|
|
|
nsISupports_Release(unk);
|
2012-07-19 11:29:34 +02:00
|
|
|
return NS_OK;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|
|
|
|
|
2012-07-19 11:29:34 +02:00
|
|
|
if(!create) {
|
|
|
|
*ret = NULL;
|
2010-12-01 12:52:08 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2006-03-05 20:38:30 +01:00
|
|
|
|
2018-02-19 14:48:44 +01:00
|
|
|
nsres = nsIDOMNode_GetOwnerDocument(nsnode, &dom_document);
|
|
|
|
if(NS_FAILED(nsres) || !dom_document) {
|
|
|
|
ERR("GetOwnerDocument failed: %08x\n", nsres);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hres = get_document_node(dom_document, &document);
|
|
|
|
nsIDOMDocument_Release(dom_document);
|
|
|
|
if(!document)
|
|
|
|
return E_FAIL;
|
|
|
|
|
|
|
|
hres = create_node(document, nsnode, ret);
|
|
|
|
htmldoc_release(&document->basedoc);
|
|
|
|
return hres;
|
2006-03-05 20:38:30 +01:00
|
|
|
}
|