2 * Copyright 2008 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "mshtml_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 struct HTMLDOMTextNode {
38 IHTMLDOMTextNode IHTMLDOMTextNode_iface;
43 static inline HTMLDOMTextNode *impl_from_IHTMLDOMTextNode(IHTMLDOMTextNode *iface)
45 return CONTAINING_RECORD(iface, HTMLDOMTextNode, IHTMLDOMTextNode_iface);
48 static HRESULT WINAPI HTMLDOMTextNode_QueryInterface(IHTMLDOMTextNode *iface,
49 REFIID riid, void **ppv)
51 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
53 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
56 static ULONG WINAPI HTMLDOMTextNode_AddRef(IHTMLDOMTextNode *iface)
58 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
60 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
63 static ULONG WINAPI HTMLDOMTextNode_Release(IHTMLDOMTextNode *iface)
65 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
67 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
70 static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfoCount(IHTMLDOMTextNode *iface, UINT *pctinfo)
72 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
73 return IDispatchEx_GetTypeInfoCount(&This->node.dispex.IDispatchEx_iface, pctinfo);
76 static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfo(IHTMLDOMTextNode *iface, UINT iTInfo,
77 LCID lcid, ITypeInfo **ppTInfo)
79 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
80 return IDispatchEx_GetTypeInfo(&This->node.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
83 static HRESULT WINAPI HTMLDOMTextNode_GetIDsOfNames(IHTMLDOMTextNode *iface, REFIID riid,
84 LPOLESTR *rgszNames, UINT cNames,
85 LCID lcid, DISPID *rgDispId)
87 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
88 return IDispatchEx_GetIDsOfNames(&This->node.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
92 static HRESULT WINAPI HTMLDOMTextNode_Invoke(IHTMLDOMTextNode *iface, DISPID dispIdMember,
93 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
94 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
96 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
97 return IDispatchEx_Invoke(&This->node.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
98 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
101 static HRESULT WINAPI HTMLDOMTextNode_put_data(IHTMLDOMTextNode *iface, BSTR v)
103 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
104 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
108 static HRESULT WINAPI HTMLDOMTextNode_get_data(IHTMLDOMTextNode *iface, BSTR *p)
110 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
111 FIXME("(%p)->(%p)\n", This, p);
115 static HRESULT WINAPI HTMLDOMTextNode_toString(IHTMLDOMTextNode *iface, BSTR *String)
117 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
118 FIXME("(%p)->(%p)\n", This, String);
122 static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *p)
124 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
128 TRACE("(%p)->(%p)\n", This, p);
130 nsres = nsIDOMText_GetLength(This->nstext, &length);
132 ERR("GetLength failed: %08x\n", nsres);
138 static HRESULT WINAPI HTMLDOMTextNode_splitText(IHTMLDOMTextNode *iface, LONG offset, IHTMLDOMNode **pRetNode)
140 HTMLDOMTextNode *This = impl_from_IHTMLDOMTextNode(iface);
141 FIXME("(%p)->(%d %p)\n", This, offset, pRetNode);
145 static const IHTMLDOMTextNodeVtbl HTMLDOMTextNodeVtbl = {
146 HTMLDOMTextNode_QueryInterface,
147 HTMLDOMTextNode_AddRef,
148 HTMLDOMTextNode_Release,
149 HTMLDOMTextNode_GetTypeInfoCount,
150 HTMLDOMTextNode_GetTypeInfo,
151 HTMLDOMTextNode_GetIDsOfNames,
152 HTMLDOMTextNode_Invoke,
153 HTMLDOMTextNode_put_data,
154 HTMLDOMTextNode_get_data,
155 HTMLDOMTextNode_toString,
156 HTMLDOMTextNode_get_length,
157 HTMLDOMTextNode_splitText
160 static inline HTMLDOMTextNode *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
162 return CONTAINING_RECORD(iface, HTMLDOMTextNode, node);
165 static HRESULT HTMLDOMTextNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
167 HTMLDOMTextNode *This = impl_from_HTMLDOMNode(iface);
171 if(IsEqualGUID(&IID_IHTMLDOMTextNode, riid)) {
172 TRACE("(%p)->(IID_IHTMLDOMTextNode %p)\n", This, ppv);
173 *ppv = &This->IHTMLDOMTextNode_iface;
175 return HTMLDOMNode_QI(&This->node, riid, ppv);
178 IUnknown_AddRef((IUnknown*)*ppv);
182 static HRESULT HTMLDOMTextNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
184 HTMLDOMTextNode *This = impl_from_HTMLDOMNode(iface);
186 return HTMLDOMTextNode_Create(This->node.doc, nsnode, ret);
189 static const NodeImplVtbl HTMLDOMTextNodeImplVtbl = {
191 HTMLDOMNode_destructor,
192 HTMLDOMTextNode_clone
195 static const tid_t HTMLDOMTextNode_iface_tids[] = {
198 IHTMLDOMTextNode_tid,
201 static dispex_static_data_t HTMLDOMTextNode_dispex = {
203 DispHTMLDOMTextNode_tid,
205 HTMLDOMTextNode_iface_tids
208 HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **node)
210 HTMLDOMTextNode *ret;
213 ret = heap_alloc_zero(sizeof(*ret));
215 return E_OUTOFMEMORY;
217 ret->node.vtbl = &HTMLDOMTextNodeImplVtbl;
218 ret->IHTMLDOMTextNode_iface.lpVtbl = &HTMLDOMTextNodeVtbl;
220 init_dispex(&ret->node.dispex, (IUnknown*)&ret->IHTMLDOMTextNode_iface,
221 &HTMLDOMTextNode_dispex);
223 HTMLDOMNode_Init(doc, &ret->node, nsnode);
225 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMText, (void**)&ret->nstext);
226 assert(nsres == NS_OK && (nsIDOMNode*)ret->nstext == ret->node.nsnode);
228 /* Share reference with nsnode */
229 nsIDOMNode_Release(ret->node.nsnode);