ReactOS 0.4.16-dev-297-gc569aee
htmltextnode.c
Go to the documentation of this file.
1/*
2 * Copyright 2008 Jacek Caban for CodeWeavers
3 *
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.
8 *
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.
13 *
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
17 */
18
19#include "mshtml_private.h"
20
23 IHTMLDOMTextNode IHTMLDOMTextNode_iface;
24 IHTMLDOMTextNode2 IHTMLDOMTextNode2_iface;
25
27};
28
29static inline HTMLDOMTextNode *impl_from_IHTMLDOMTextNode(IHTMLDOMTextNode *iface)
30{
31 return CONTAINING_RECORD(iface, HTMLDOMTextNode, IHTMLDOMTextNode_iface);
32}
33
34static HRESULT WINAPI HTMLDOMTextNode_QueryInterface(IHTMLDOMTextNode *iface,
35 REFIID riid, void **ppv)
36{
38
39 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
40}
41
42static ULONG WINAPI HTMLDOMTextNode_AddRef(IHTMLDOMTextNode *iface)
43{
45
46 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
47}
48
49static ULONG WINAPI HTMLDOMTextNode_Release(IHTMLDOMTextNode *iface)
50{
52
53 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
54}
55
56static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfoCount(IHTMLDOMTextNode *iface, UINT *pctinfo)
57{
59 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
60}
61
62static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfo(IHTMLDOMTextNode *iface, UINT iTInfo,
63 LCID lcid, ITypeInfo **ppTInfo)
64{
66 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
67}
68
69static HRESULT WINAPI HTMLDOMTextNode_GetIDsOfNames(IHTMLDOMTextNode *iface, REFIID riid,
70 LPOLESTR *rgszNames, UINT cNames,
71 LCID lcid, DISPID *rgDispId)
72{
74 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
75 lcid, rgDispId);
76}
77
78static HRESULT WINAPI HTMLDOMTextNode_Invoke(IHTMLDOMTextNode *iface, DISPID dispIdMember,
79 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
80 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
81{
83 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
84 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
85}
86
87static HRESULT WINAPI HTMLDOMTextNode_put_data(IHTMLDOMTextNode *iface, BSTR v)
88{
90 nsAString nsstr;
91 nsresult nsres;
92
93 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
94
95 nsAString_InitDepend(&nsstr, v);
96 nsres = nsIDOMText_SetData(This->nstext, &nsstr);
97 nsAString_Finish(&nsstr);
98 return NS_SUCCEEDED(nsres) ? S_OK : E_FAIL;
99}
100
101static HRESULT WINAPI HTMLDOMTextNode_get_data(IHTMLDOMTextNode *iface, BSTR *p)
102{
104 nsAString nsstr;
105 nsresult nsres;
106
107 TRACE("(%p)->(%p)\n", This, p);
108
109 nsAString_Init(&nsstr, NULL);
110 nsres = nsIDOMText_GetData(This->nstext, &nsstr);
111 return return_nsstr(nsres, &nsstr, p);
112}
113
114static HRESULT WINAPI HTMLDOMTextNode_toString(IHTMLDOMTextNode *iface, BSTR *String)
115{
117 FIXME("(%p)->(%p)\n", This, String);
118 return E_NOTIMPL;
119}
120
121static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *p)
122{
124 UINT32 length = 0;
125 nsresult nsres;
126
127 TRACE("(%p)->(%p)\n", This, p);
128
129 nsres = nsIDOMText_GetLength(This->nstext, &length);
130 if(NS_FAILED(nsres))
131 ERR("GetLength failed: %08x\n", nsres);
132
133 *p = length;
134 return S_OK;
135}
136
137static HRESULT WINAPI HTMLDOMTextNode_splitText(IHTMLDOMTextNode *iface, LONG offset, IHTMLDOMNode **pRetNode)
138{
142 nsresult nsres;
144
145 TRACE("(%p)->(%d %p)\n", This, offset, pRetNode);
146
147 nsres = nsIDOMText_SplitText(This->nstext, offset, &text);
148 if(NS_FAILED(nsres)) {
149 ERR("SplitText failed: %x08x\n", nsres);
150 return E_FAIL;
151 }
152
153 if(!text) {
154 *pRetNode = NULL;
155 return S_OK;
156 }
157
158 hres = get_node(This->node.doc, (nsIDOMNode*)text, TRUE, &node);
159 nsIDOMText_Release(text);
160 if(FAILED(hres))
161 return hres;
162
163 *pRetNode = &node->IHTMLDOMNode_iface;
164 return S_OK;
165}
166
167static const IHTMLDOMTextNodeVtbl HTMLDOMTextNodeVtbl = {
180};
181
182static inline HTMLDOMTextNode *impl_from_IHTMLDOMTextNode2(IHTMLDOMTextNode2 *iface)
183{
184 return CONTAINING_RECORD(iface, HTMLDOMTextNode, IHTMLDOMTextNode2_iface);
185}
186
187static HRESULT WINAPI HTMLDOMTextNode2_QueryInterface(IHTMLDOMTextNode2 *iface, REFIID riid, void **ppv)
188{
190
191 return IHTMLDOMNode_QueryInterface(&This->node.IHTMLDOMNode_iface, riid, ppv);
192}
193
194static ULONG WINAPI HTMLDOMTextNode2_AddRef(IHTMLDOMTextNode2 *iface)
195{
197
198 return IHTMLDOMNode_AddRef(&This->node.IHTMLDOMNode_iface);
199}
200
201static ULONG WINAPI HTMLDOMTextNode2_Release(IHTMLDOMTextNode2 *iface)
202{
204
205 return IHTMLDOMNode_Release(&This->node.IHTMLDOMNode_iface);
206}
207
208static HRESULT WINAPI HTMLDOMTextNode2_GetTypeInfoCount(IHTMLDOMTextNode2 *iface, UINT *pctinfo)
209{
211 return IDispatchEx_GetTypeInfoCount(&This->node.event_target.dispex.IDispatchEx_iface, pctinfo);
212}
213
214static HRESULT WINAPI HTMLDOMTextNode2_GetTypeInfo(IHTMLDOMTextNode2 *iface, UINT iTInfo,
215 LCID lcid, ITypeInfo **ppTInfo)
216{
218 return IDispatchEx_GetTypeInfo(&This->node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
219}
220
221static HRESULT WINAPI HTMLDOMTextNode2_GetIDsOfNames(IHTMLDOMTextNode2 *iface, REFIID riid,
222 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
223{
225 return IDispatchEx_GetIDsOfNames(&This->node.event_target.dispex.IDispatchEx_iface, riid, rgszNames, cNames,
226 lcid, rgDispId);
227}
228
229static HRESULT WINAPI HTMLDOMTextNode2_Invoke(IHTMLDOMTextNode2 *iface, DISPID dispIdMember,
230 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
231 EXCEPINFO *pExcepInfo, UINT *puArgErr)
232{
234 return IDispatchEx_Invoke(&This->node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
235 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
236}
237
238static HRESULT WINAPI HTMLDOMTextNode2_substringData(IHTMLDOMTextNode2 *iface, LONG offset, LONG count, BSTR *string)
239{
241 FIXME("(%p)->(%d %d %p)\n", This, offset, count, string);
242 return E_NOTIMPL;
243}
244
245static HRESULT WINAPI HTMLDOMTextNode2_appendData(IHTMLDOMTextNode2 *iface, BSTR string)
246{
248 nsAString nsstr;
249 nsresult nsres;
250
251 TRACE("(%p)->(%s)\n", This, debugstr_w(string));
252
253 nsAString_InitDepend(&nsstr, string);
254 nsres = nsIDOMText_AppendData(This->nstext, &nsstr);
255 nsAString_Finish(&nsstr);
256 if(NS_FAILED(nsres)) {
257 ERR("AppendData failed: %08x\n", nsres);
258 return E_FAIL;
259 }
260
261 return S_OK;
262}
263
264static HRESULT WINAPI HTMLDOMTextNode2_insertData(IHTMLDOMTextNode2 *iface, LONG offset, BSTR string)
265{
267 FIXME("(%p)->(%d %s)\n", This, offset, debugstr_w(string));
268 return E_NOTIMPL;
269}
270
272{
274 FIXME("(%p)->(%d %d)\n", This, offset, count);
275 return E_NOTIMPL;
276}
277
278static HRESULT WINAPI HTMLDOMTextNode2_replaceData(IHTMLDOMTextNode2 *iface, LONG offset, LONG count, BSTR string)
279{
281 FIXME("(%p)->(%d %d %s)\n", This, offset, count, debugstr_w(string));
282 return E_NOTIMPL;
283}
284
285static const IHTMLDOMTextNode2Vtbl HTMLDOMTextNode2Vtbl = {
298};
299
301{
302 return CONTAINING_RECORD(iface, HTMLDOMTextNode, node);
303}
304
306{
308
309 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
310
311 if(IsEqualGUID(&IID_IHTMLDOMTextNode, riid))
312 *ppv = &This->IHTMLDOMTextNode_iface;
313 else if(IsEqualGUID(&IID_IHTMLDOMTextNode2, riid))
314 *ppv = &This->IHTMLDOMTextNode2_iface;
315 else
316 return HTMLDOMNode_QI(&This->node, riid, ppv);
317
318 IUnknown_AddRef((IUnknown*)*ppv);
319 return S_OK;
320}
321
323{
325
326 return HTMLDOMTextNode_Create(This->node.doc, nsnode, ret);
327}
328
330
336};
337
339 IHTMLDOMNode_tid,
340 IHTMLDOMNode2_tid,
341 IHTMLDOMTextNode_tid,
342 IHTMLDOMTextNode2_tid,
343 0
344};
346 NULL,
347 DispHTMLDOMTextNode_tid,
348 0,
350};
351
353{
355 nsresult nsres;
356
357 ret = heap_alloc_zero(sizeof(*ret));
358 if(!ret)
359 return E_OUTOFMEMORY;
360
361 ret->node.vtbl = &HTMLDOMTextNodeImplVtbl;
362 ret->IHTMLDOMTextNode_iface.lpVtbl = &HTMLDOMTextNodeVtbl;
363 ret->IHTMLDOMTextNode2_iface.lpVtbl = &HTMLDOMTextNode2Vtbl;
364
365 init_dispex(&ret->node.event_target.dispex, (IUnknown*)&ret->IHTMLDOMTextNode_iface,
367
368 HTMLDOMNode_Init(doc, &ret->node, nsnode);
369
370 nsres = nsIDOMNode_QueryInterface(nsnode, &IID_nsIDOMText, (void**)&ret->nstext);
371 assert(nsres == NS_OK && (nsIDOMNode*)ret->nstext == ret->node.nsnode);
372
373 /* Share reference with nsnode */
374 nsIDOMNode_Release(ret->node.nsnode);
375
376 *node = &ret->node;
377 return S_OK;
378}
unsigned int UINT32
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERR(fmt,...)
Definition: precomp.h:57
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
OLECHAR * BSTR
Definition: compat.h:2293
const char * debugstr_mshtml_guid(const GUID *iid)
Definition: main.c:542
const WCHAR * text
Definition: package.c:1794
#define assert(x)
Definition: debug.h:53
unsigned short WORD
Definition: ntddk_ex.h:93
const GLdouble * v
Definition: gl.h:2040
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLfloat GLfloat p
Definition: glext.h:8902
GLintptr offset
Definition: glext.h:5920
HRESULT get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create, HTMLDOMNode **ret)
Definition: htmlnode.c:1339
HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv)
Definition: htmlnode.c:1142
void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsnode)
Definition: htmlnode.c:1196
void HTMLDOMNode_destructor(HTMLDOMNode *This)
Definition: htmlnode.c:1172
static HRESULT HTMLDOMTextNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
Definition: htmltextnode.c:322
static ULONG WINAPI HTMLDOMTextNode2_Release(IHTMLDOMTextNode2 *iface)
Definition: htmltextnode.c:201
static HRESULT WINAPI HTMLDOMTextNode2_insertData(IHTMLDOMTextNode2 *iface, LONG offset, BSTR string)
Definition: htmltextnode.c:264
static HRESULT WINAPI HTMLDOMTextNode2_GetIDsOfNames(IHTMLDOMTextNode2 *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: htmltextnode.c:221
static const IHTMLDOMTextNode2Vtbl HTMLDOMTextNode2Vtbl
Definition: htmltextnode.c:285
static HRESULT WINAPI HTMLDOMTextNode_QueryInterface(IHTMLDOMTextNode *iface, REFIID riid, void **ppv)
Definition: htmltextnode.c:34
static HRESULT WINAPI HTMLDOMTextNode2_Invoke(IHTMLDOMTextNode2 *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: htmltextnode.c:229
static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfo(IHTMLDOMTextNode *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: htmltextnode.c:62
static dispex_static_data_t HTMLDOMTextNode_dispex
Definition: htmltextnode.c:345
static HRESULT WINAPI HTMLDOMTextNode_toString(IHTMLDOMTextNode *iface, BSTR *String)
Definition: htmltextnode.c:114
static HRESULT WINAPI HTMLDOMTextNode2_QueryInterface(IHTMLDOMTextNode2 *iface, REFIID riid, void **ppv)
Definition: htmltextnode.c:187
static HRESULT WINAPI HTMLDOMTextNode_Invoke(IHTMLDOMTextNode *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: htmltextnode.c:78
static HTMLDOMTextNode * impl_from_HTMLDOMNode(HTMLDOMNode *iface)
Definition: htmltextnode.c:300
static HTMLDOMTextNode * impl_from_IHTMLDOMTextNode2(IHTMLDOMTextNode2 *iface)
Definition: htmltextnode.c:182
static HRESULT WINAPI HTMLDOMTextNode_splitText(IHTMLDOMTextNode *iface, LONG offset, IHTMLDOMNode **pRetNode)
Definition: htmltextnode.c:137
static ULONG WINAPI HTMLDOMTextNode_Release(IHTMLDOMTextNode *iface)
Definition: htmltextnode.c:49
static HRESULT WINAPI HTMLDOMTextNode_put_data(IHTMLDOMTextNode *iface, BSTR v)
Definition: htmltextnode.c:87
static const IHTMLDOMTextNodeVtbl HTMLDOMTextNodeVtbl
Definition: htmltextnode.c:167
static const cpc_entry_t HTMLDOMTextNode_cpc[]
Definition: htmltextnode.c:329
static HRESULT WINAPI HTMLDOMTextNode_get_data(IHTMLDOMTextNode *iface, BSTR *p)
Definition: htmltextnode.c:101
HRESULT HTMLDOMTextNode_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNode **node)
Definition: htmltextnode.c:352
static HRESULT WINAPI HTMLDOMTextNode2_deleteData(IHTMLDOMTextNode2 *iface, LONG offset, LONG count)
Definition: htmltextnode.c:271
static HRESULT WINAPI HTMLDOMTextNode2_substringData(IHTMLDOMTextNode2 *iface, LONG offset, LONG count, BSTR *string)
Definition: htmltextnode.c:238
static HRESULT WINAPI HTMLDOMTextNode2_replaceData(IHTMLDOMTextNode2 *iface, LONG offset, LONG count, BSTR string)
Definition: htmltextnode.c:278
static const NodeImplVtbl HTMLDOMTextNodeImplVtbl
Definition: htmltextnode.c:331
static const tid_t HTMLDOMTextNode_iface_tids[]
Definition: htmltextnode.c:338
static HRESULT WINAPI HTMLDOMTextNode2_GetTypeInfo(IHTMLDOMTextNode2 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: htmltextnode.c:214
static ULONG WINAPI HTMLDOMTextNode_AddRef(IHTMLDOMTextNode *iface)
Definition: htmltextnode.c:42
static HRESULT WINAPI HTMLDOMTextNode_get_length(IHTMLDOMTextNode *iface, LONG *p)
Definition: htmltextnode.c:121
static HRESULT WINAPI HTMLDOMTextNode_GetTypeInfoCount(IHTMLDOMTextNode *iface, UINT *pctinfo)
Definition: htmltextnode.c:56
static HRESULT WINAPI HTMLDOMTextNode_GetIDsOfNames(IHTMLDOMTextNode *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: htmltextnode.c:69
static HRESULT WINAPI HTMLDOMTextNode2_GetTypeInfoCount(IHTMLDOMTextNode2 *iface, UINT *pctinfo)
Definition: htmltextnode.c:208
static HRESULT HTMLDOMTextNode_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
Definition: htmltextnode.c:305
static ULONG WINAPI HTMLDOMTextNode2_AddRef(IHTMLDOMTextNode2 *iface)
Definition: htmltextnode.c:194
static HRESULT WINAPI HTMLDOMTextNode2_appendData(IHTMLDOMTextNode2 *iface, BSTR string)
Definition: htmltextnode.c:245
static HTMLDOMTextNode * impl_from_IHTMLDOMTextNode(IHTMLDOMTextNode *iface)
Definition: htmltextnode.c:29
tid_t
Definition: ieframe.h:311
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:919
#define debugstr_w
Definition: kernel32.h:32
HRESULT hres
Definition: protocol.c:465
static LPOLESTR
Definition: stg_prop.c:27
static VARIANTARG static DISPID
Definition: ordinal.c:52
#define NS_OK
void nsAString_Finish(nsAString *) DECLSPEC_HIDDEN
Definition: nsembed.c:836
void nsAString_InitDepend(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:826
BOOL nsAString_Init(nsAString *, const PRUnichar *) DECLSPEC_HIDDEN
Definition: nsembed.c:817
#define NS_SUCCEEDED(res)
#define NS_FAILED(res)
HRESULT return_nsstr(nsresult, nsAString *, BSTR *) DECLSPEC_HIDDEN
Definition: nsembed.c:841
unsigned int UINT
Definition: ndis.h:50
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
DWORD LCID
Definition: nls.h:13
#define TRACE(s)
Definition: solgame.cpp:4
IHTMLDOMTextNode2 IHTMLDOMTextNode2_iface
Definition: htmltextnode.c:24
nsIDOMText * nstext
Definition: htmltextnode.c:26
IHTMLDOMTextNode IHTMLDOMTextNode_iface
Definition: htmltextnode.c:23
HTMLDOMNode node
Definition: htmltextnode.c:22
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
Definition: dlist.c:348
int ret
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2433
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
#define WINAPI
Definition: msvc.h:6