2008-04-24 18:25:34 +02:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Jacek Caban for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "ole2.h"
|
|
|
|
|
|
|
|
#include "mshtml_private.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
|
|
|
|
|
2009-01-28 06:59:34 +01:00
|
|
|
struct HTMLDOMTextNode {
|
2008-04-24 18:25:34 +02:00
|
|
|
HTMLDOMNode node;
|
|
|
|
const IHTMLDOMTextNodeVtbl *lpIHTMLDOMTextNodeVtbl;
|
2009-12-10 01:09:54 +01:00
|
|
|
|
|
|
|
nsIDOMText *nstext;
|
2009-01-28 06:59:34 +01:00
|
|
|
};
|
2008-04-24 18:25:34 +02:00
|
|
|
|
2009-02-16 09:53:46 +01:00
|
|
|
#define HTMLTEXT(x) (&(x)->lpIHTMLDOMTextNodeVtbl)
|
2008-04-24 18:25:34 +02:00
|
|
|
|
|
|
|
#define HTMLTEXT_THIS(iface) DEFINE_THIS(HTMLDOMTextNode, IHTMLDOMTextNode, iface)
|
|
|
|
|
|
|
|
#define HTMLTEXT_NODE_THIS(iface) DEFINE_THIS2(HTMLDOMTextNode, node, iface)
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_QueryInterface(IHTMLDOMTextNode *iface,
|
|
|
|
REFIID riid, void **ppv)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
|
|
|
|
|
|
|
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->node), riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMTextNode_AddRef(IHTMLDOMTextNode *iface)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
|
|
|
|
|
|
|
return IHTMLDOMNode_AddRef(HTMLDOMNODE(&This->node));
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI HTMLDOMTextNode_Release(IHTMLDOMTextNode *iface)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
|
|
|
|
|
|
|
return IHTMLDOMNode_Release(HTMLDOMNODE(&This->node));
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfoCount(IHTMLDOMTextNode *iface, UINT *pctinfo)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
2008-09-08 13:15:42 +02:00
|
|
|
return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->node.dispex), pctinfo);
|
2008-04-24 18:25:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfo(IHTMLDOMTextNode *iface, UINT iTInfo,
|
|
|
|
LCID lcid, ITypeInfo **ppTInfo)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
2008-09-08 13:15:42 +02:00
|
|
|
return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->node.dispex), iTInfo, lcid, ppTInfo);
|
2008-04-24 18:25:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_GetIDsOfNames(IHTMLDOMTextNode *iface, REFIID riid,
|
|
|
|
LPOLESTR *rgszNames, UINT cNames,
|
|
|
|
LCID lcid, DISPID *rgDispId)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
2008-09-08 13:15:42 +02:00
|
|
|
return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->node.dispex), riid, rgszNames, cNames, lcid, rgDispId);
|
2008-04-24 18:25:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_Invoke(IHTMLDOMTextNode *iface, DISPID dispIdMember,
|
|
|
|
REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
|
|
|
|
VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
2008-09-08 13:15:42 +02:00
|
|
|
return IDispatchEx_Invoke(DISPATCHEX(&This->node.dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
|
|
|
|
pVarResult, pExcepInfo, puArgErr);
|
2008-04-24 18:25:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_put_data(IHTMLDOMTextNode *iface, BSTR v)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
|
|
|
FIXME("(%p)->(%s)\n", This, debugstr_w(v));
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_get_data(IHTMLDOMTextNode *iface, BSTR *p)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, p);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_toString(IHTMLDOMTextNode *iface, BSTR *String)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
|
|
|
FIXME("(%p)->(%p)\n", This, String);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:31 +01:00
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *p)
|
2008-04-24 18:25:34 +02:00
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
2009-12-10 01:09:54 +01:00
|
|
|
PRUint32 length = 0;
|
|
|
|
nsresult nsres;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%p)\n", This, p);
|
|
|
|
|
|
|
|
nsres = nsIDOMText_GetLength(This->nstext, &length);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("GetLength failed: %08x\n", nsres);
|
|
|
|
|
|
|
|
*p = length;
|
|
|
|
return S_OK;
|
2008-04-24 18:25:34 +02:00
|
|
|
}
|
|
|
|
|
2009-03-12 01:43:31 +01:00
|
|
|
static HRESULT WINAPI HTMLDOMTextNode_splitText(IHTMLDOMTextNode *iface, LONG offset, IHTMLDOMNode **pRetNode)
|
2008-04-24 18:25:34 +02:00
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_THIS(iface);
|
2009-03-12 01:43:31 +01:00
|
|
|
FIXME("(%p)->(%d %p)\n", This, offset, pRetNode);
|
2008-04-24 18:25:34 +02:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef HTMLTEXT_THIS
|
|
|
|
|
|
|
|
static const IHTMLDOMTextNodeVtbl HTMLDOMTextNodeVtbl = {
|
|
|
|
HTMLDOMTextNode_QueryInterface,
|
|
|
|
HTMLDOMTextNode_AddRef,
|
|
|
|
HTMLDOMTextNode_Release,
|
|
|
|
HTMLDOMTextNode_GetTypeInfoCount,
|
|
|
|
HTMLDOMTextNode_GetTypeInfo,
|
|
|
|
HTMLDOMTextNode_GetIDsOfNames,
|
|
|
|
HTMLDOMTextNode_Invoke,
|
|
|
|
HTMLDOMTextNode_put_data,
|
|
|
|
HTMLDOMTextNode_get_data,
|
|
|
|
HTMLDOMTextNode_toString,
|
|
|
|
HTMLDOMTextNode_get_length,
|
|
|
|
HTMLDOMTextNode_splitText
|
|
|
|
};
|
|
|
|
|
|
|
|
#define HTMLTEXT_NODE_THIS(iface) DEFINE_THIS2(HTMLDOMTextNode, node, iface)
|
|
|
|
|
2008-12-02 15:28:04 +01:00
|
|
|
static HRESULT HTMLDOMTextNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
|
2008-04-24 18:25:34 +02:00
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_NODE_THIS(iface);
|
|
|
|
|
|
|
|
*ppv = NULL;
|
|
|
|
|
|
|
|
if(IsEqualGUID(&IID_IHTMLDOMTextNode, riid)) {
|
|
|
|
TRACE("(%p)->(IID_IHTMLDOMTextNode %p)\n", This, ppv);
|
|
|
|
*ppv = HTMLTEXT(This);
|
|
|
|
}else {
|
|
|
|
return HTMLDOMNode_QI(&This->node, riid, ppv);
|
|
|
|
}
|
|
|
|
|
|
|
|
IUnknown_AddRef((IUnknown*)*ppv);
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-12-02 15:28:04 +01:00
|
|
|
static void HTMLDOMTextNode_destructor(HTMLDOMNode *iface)
|
2008-04-24 18:25:34 +02:00
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_NODE_THIS(iface);
|
|
|
|
|
2009-12-10 01:09:54 +01:00
|
|
|
if(This->nstext)
|
|
|
|
IHTMLDOMTextNode_Release(This->nstext);
|
|
|
|
|
2008-04-24 18:25:34 +02:00
|
|
|
HTMLDOMNode_destructor(&This->node);
|
|
|
|
}
|
|
|
|
|
2010-11-14 14:41:39 +01:00
|
|
|
static HRESULT HTMLDOMTextNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
|
|
|
|
{
|
|
|
|
HTMLDOMTextNode *This = HTMLTEXT_NODE_THIS(iface);
|
|
|
|
|
|
|
|
*ret = HTMLDOMTextNode_Create(This->node.doc, nsnode);
|
|
|
|
IHTMLDOMNode_AddRef(HTMLDOMNODE(*ret));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-04-24 18:25:34 +02:00
|
|
|
#undef HTMLTEXT_NODE_THIS
|
|
|
|
|
|
|
|
static const NodeImplVtbl HTMLDOMTextNodeImplVtbl = {
|
|
|
|
HTMLDOMTextNode_QI,
|
2010-11-14 14:41:39 +01:00
|
|
|
HTMLDOMTextNode_destructor,
|
|
|
|
HTMLDOMTextNode_clone
|
2008-04-24 18:25:34 +02:00
|
|
|
};
|
|
|
|
|
2008-05-06 16:04:58 +02:00
|
|
|
static const tid_t HTMLDOMTextNode_iface_tids[] = {
|
|
|
|
IHTMLDOMNode_tid,
|
|
|
|
IHTMLDOMNode2_tid,
|
|
|
|
IHTMLDOMTextNode_tid,
|
|
|
|
0
|
|
|
|
};
|
2008-04-24 18:25:51 +02:00
|
|
|
static dispex_static_data_t HTMLDOMTextNode_dispex = {
|
2008-04-29 01:38:09 +02:00
|
|
|
NULL,
|
2008-04-24 18:25:51 +02:00
|
|
|
DispHTMLDOMTextNode_tid,
|
|
|
|
0,
|
2008-05-06 16:04:58 +02:00
|
|
|
HTMLDOMTextNode_iface_tids
|
2008-04-24 18:25:51 +02:00
|
|
|
};
|
|
|
|
|
2009-09-16 22:13:31 +02:00
|
|
|
HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode)
|
2008-04-24 18:25:34 +02:00
|
|
|
{
|
2009-12-10 01:09:54 +01:00
|
|
|
HTMLDOMTextNode *ret;
|
|
|
|
nsresult nsres;
|
2008-04-24 18:25:34 +02:00
|
|
|
|
|
|
|
ret = heap_alloc_zero(sizeof(*ret));
|
|
|
|
ret->node.vtbl = &HTMLDOMTextNodeImplVtbl;
|
|
|
|
ret->lpIHTMLDOMTextNodeVtbl = &HTMLDOMTextNodeVtbl;
|
|
|
|
|
2008-04-24 18:25:51 +02:00
|
|
|
init_dispex(&ret->node.dispex, (IUnknown*)HTMLTEXT(ret), &HTMLDOMTextNode_dispex);
|
2008-06-19 23:13:16 +02:00
|
|
|
HTMLDOMNode_Init(doc, &ret->node, nsnode);
|
2008-04-24 18:25:51 +02:00
|
|
|
|
2009-12-10 01:09:54 +01:00
|
|
|
nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMText, (void**)&ret->nstext);
|
|
|
|
if(NS_FAILED(nsres))
|
|
|
|
ERR("Could not get nsIDOMText iface: %08x\n", nsres);
|
|
|
|
|
2008-04-24 18:25:34 +02:00
|
|
|
return &ret->node;
|
|
|
|
}
|