xref: /reactos/dll/win32/mshtml/htmltable.c (revision c2c66aff)
1 /*
2  * Copyright 2007 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 
21 struct HTMLTable {
22     HTMLElement element;
23 
24     IHTMLTable  IHTMLTable_iface;
25     IHTMLTable2 IHTMLTable2_iface;
26     IHTMLTable3 IHTMLTable3_iface;
27 
28     nsIDOMHTMLTableElement *nstable;
29 };
30 
impl_from_IHTMLTable(IHTMLTable * iface)31 static inline HTMLTable *impl_from_IHTMLTable(IHTMLTable *iface)
32 {
33     return CONTAINING_RECORD(iface, HTMLTable, IHTMLTable_iface);
34 }
35 
impl_from_IHTMLTable2(IHTMLTable2 * iface)36 static inline HTMLTable *impl_from_IHTMLTable2(IHTMLTable2 *iface)
37 {
38     return CONTAINING_RECORD(iface, HTMLTable, IHTMLTable2_iface);
39 }
40 
impl_from_IHTMLTable3(IHTMLTable3 * iface)41 static inline HTMLTable *impl_from_IHTMLTable3(IHTMLTable3 *iface)
42 {
43     return CONTAINING_RECORD(iface, HTMLTable, IHTMLTable3_iface);
44 }
45 
var2str(const VARIANT * p,nsAString * nsstr)46 static HRESULT var2str(const VARIANT *p, nsAString *nsstr)
47 {
48     BSTR str;
49     BOOL ret;
50     HRESULT hres;
51 
52     switch(V_VT(p)) {
53     case VT_BSTR:
54         return nsAString_Init(nsstr, V_BSTR(p))?
55             S_OK : E_OUTOFMEMORY;
56     case VT_R8:
57         hres = VarBstrFromR8(V_R8(p), 0, 0, &str);
58         break;
59     case VT_R4:
60         hres = VarBstrFromR4(V_R4(p), 0, 0, &str);
61         break;
62     case VT_I4:
63         hres = VarBstrFromI4(V_I4(p), 0, 0, &str);
64         break;
65     default:
66         FIXME("unsupported arg %s\n", debugstr_variant(p));
67         return E_NOTIMPL;
68     }
69     if (FAILED(hres))
70         return hres;
71 
72     ret = nsAString_Init(nsstr, str);
73     SysFreeString(str);
74     return ret ? S_OK : E_OUTOFMEMORY;
75 }
76 
nsstr_to_truncated_bstr(const nsAString * nsstr,BSTR * ret_ptr)77 static HRESULT nsstr_to_truncated_bstr(const nsAString *nsstr, BSTR *ret_ptr)
78 {
79     const PRUnichar *str, *ptr, *end = NULL;
80     BSTR ret;
81 
82     nsAString_GetData(nsstr, &str);
83 
84     for(ptr = str; isdigitW(*ptr); ptr++);
85     if(*ptr == '.') {
86         for(end = ptr++; isdigitW(*ptr); ptr++);
87         if(*ptr)
88             end = NULL;
89     }
90 
91     ret = end ? SysAllocStringLen(str, end-str) : SysAllocString(str);
92 
93     *ret_ptr = ret;
94     return ret ? S_OK : E_OUTOFMEMORY;
95 }
96 
HTMLTable_QueryInterface(IHTMLTable * iface,REFIID riid,void ** ppv)97 static HRESULT WINAPI HTMLTable_QueryInterface(IHTMLTable *iface,
98                                                          REFIID riid, void **ppv)
99 {
100     HTMLTable *This = impl_from_IHTMLTable(iface);
101 
102     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
103 }
104 
HTMLTable_AddRef(IHTMLTable * iface)105 static ULONG WINAPI HTMLTable_AddRef(IHTMLTable *iface)
106 {
107     HTMLTable *This = impl_from_IHTMLTable(iface);
108 
109     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
110 }
111 
HTMLTable_Release(IHTMLTable * iface)112 static ULONG WINAPI HTMLTable_Release(IHTMLTable *iface)
113 {
114     HTMLTable *This = impl_from_IHTMLTable(iface);
115 
116     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
117 }
118 
HTMLTable_GetTypeInfoCount(IHTMLTable * iface,UINT * pctinfo)119 static HRESULT WINAPI HTMLTable_GetTypeInfoCount(IHTMLTable *iface, UINT *pctinfo)
120 {
121     HTMLTable *This = impl_from_IHTMLTable(iface);
122     return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
123 }
124 
HTMLTable_GetTypeInfo(IHTMLTable * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)125 static HRESULT WINAPI HTMLTable_GetTypeInfo(IHTMLTable *iface, UINT iTInfo,
126                                               LCID lcid, ITypeInfo **ppTInfo)
127 {
128     HTMLTable *This = impl_from_IHTMLTable(iface);
129     return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
130             ppTInfo);
131 }
132 
HTMLTable_GetIDsOfNames(IHTMLTable * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)133 static HRESULT WINAPI HTMLTable_GetIDsOfNames(IHTMLTable *iface, REFIID riid,
134                                                 LPOLESTR *rgszNames, UINT cNames,
135                                                 LCID lcid, DISPID *rgDispId)
136 {
137     HTMLTable *This = impl_from_IHTMLTable(iface);
138     return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
139             cNames, lcid, rgDispId);
140 }
141 
HTMLTable_Invoke(IHTMLTable * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)142 static HRESULT WINAPI HTMLTable_Invoke(IHTMLTable *iface, DISPID dispIdMember,
143                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
144                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
145 {
146     HTMLTable *This = impl_from_IHTMLTable(iface);
147     return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
148             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
149 }
150 
HTMLTable_put_cols(IHTMLTable * iface,LONG v)151 static HRESULT WINAPI HTMLTable_put_cols(IHTMLTable *iface, LONG v)
152 {
153     HTMLTable *This = impl_from_IHTMLTable(iface);
154     FIXME("(%p)->(%d)\n", This, v);
155     return E_NOTIMPL;
156 }
157 
HTMLTable_get_cols(IHTMLTable * iface,LONG * p)158 static HRESULT WINAPI HTMLTable_get_cols(IHTMLTable *iface, LONG *p)
159 {
160     HTMLTable *This = impl_from_IHTMLTable(iface);
161     FIXME("(%p)->(%p)\n", This, p);
162     return E_NOTIMPL;
163 }
164 
HTMLTable_put_border(IHTMLTable * iface,VARIANT v)165 static HRESULT WINAPI HTMLTable_put_border(IHTMLTable *iface, VARIANT v)
166 {
167     HTMLTable *This = impl_from_IHTMLTable(iface);
168     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
169     return E_NOTIMPL;
170 }
171 
HTMLTable_get_border(IHTMLTable * iface,VARIANT * p)172 static HRESULT WINAPI HTMLTable_get_border(IHTMLTable *iface, VARIANT *p)
173 {
174     HTMLTable *This = impl_from_IHTMLTable(iface);
175     FIXME("(%p)->(%p)\n", This, p);
176     return E_NOTIMPL;
177 }
178 
HTMLTable_put_frame(IHTMLTable * iface,BSTR v)179 static HRESULT WINAPI HTMLTable_put_frame(IHTMLTable *iface, BSTR v)
180 {
181     HTMLTable *This = impl_from_IHTMLTable(iface);
182     nsAString str;
183     nsresult nsres;
184 
185     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
186 
187     nsAString_InitDepend(&str, v);
188     nsres = nsIDOMHTMLTableElement_SetFrame(This->nstable, &str);
189     nsAString_Finish(&str);
190 
191     if (NS_FAILED(nsres)) {
192         ERR("SetFrame(%s) failed: %08x\n", debugstr_w(v), nsres);
193         return E_FAIL;
194     }
195     return S_OK;
196 }
197 
HTMLTable_get_frame(IHTMLTable * iface,BSTR * p)198 static HRESULT WINAPI HTMLTable_get_frame(IHTMLTable *iface, BSTR *p)
199 {
200     HTMLTable *This = impl_from_IHTMLTable(iface);
201     nsAString str;
202     nsresult nsres;
203 
204     TRACE("(%p)->(%p)\n", This, p);
205 
206     nsAString_Init(&str, NULL);
207     nsres = nsIDOMHTMLTableElement_GetFrame(This->nstable, &str);
208 
209     return return_nsstr(nsres, &str, p);
210 }
211 
HTMLTable_put_rules(IHTMLTable * iface,BSTR v)212 static HRESULT WINAPI HTMLTable_put_rules(IHTMLTable *iface, BSTR v)
213 {
214     HTMLTable *This = impl_from_IHTMLTable(iface);
215     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
216     return E_NOTIMPL;
217 }
218 
HTMLTable_get_rules(IHTMLTable * iface,BSTR * p)219 static HRESULT WINAPI HTMLTable_get_rules(IHTMLTable *iface, BSTR *p)
220 {
221     HTMLTable *This = impl_from_IHTMLTable(iface);
222     FIXME("(%p)->(%p)\n", This, p);
223     return E_NOTIMPL;
224 }
225 
HTMLTable_put_cellSpacing(IHTMLTable * iface,VARIANT v)226 static HRESULT WINAPI HTMLTable_put_cellSpacing(IHTMLTable *iface, VARIANT v)
227 {
228     HTMLTable *This = impl_from_IHTMLTable(iface);
229     nsAString nsstr;
230     WCHAR buf[64];
231     nsresult nsres;
232 
233     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
234 
235     switch(V_VT(&v)) {
236     case VT_BSTR:
237         nsAString_InitDepend(&nsstr, V_BSTR(&v));
238         break;
239     case VT_I4: {
240         static const WCHAR formatW[] = {'%','d',0};
241         sprintfW(buf, formatW, V_I4(&v));
242         nsAString_InitDepend(&nsstr, buf);
243         break;
244     }
245     default:
246         FIXME("unsupported arg %s\n", debugstr_variant(&v));
247         return E_NOTIMPL;
248     }
249 
250     nsres = nsIDOMHTMLTableElement_SetCellSpacing(This->nstable, &nsstr);
251     nsAString_Finish(&nsstr);
252     if(NS_FAILED(nsres)) {
253         ERR("SetCellSpacing failed: %08x\n", nsres);
254         return E_FAIL;
255     }
256 
257     return S_OK;
258 }
259 
HTMLTable_get_cellSpacing(IHTMLTable * iface,VARIANT * p)260 static HRESULT WINAPI HTMLTable_get_cellSpacing(IHTMLTable *iface, VARIANT *p)
261 {
262     HTMLTable *This = impl_from_IHTMLTable(iface);
263     nsAString nsstr;
264     nsresult nsres;
265 
266     TRACE("(%p)->(%p)\n", This, p);
267 
268     nsAString_Init(&nsstr, NULL);
269     nsres = nsIDOMHTMLTableElement_GetCellSpacing(This->nstable, &nsstr);
270     V_VT(p) = VT_BSTR;
271     return return_nsstr(nsres, &nsstr, &V_BSTR(p));
272 }
273 
HTMLTable_put_cellPadding(IHTMLTable * iface,VARIANT v)274 static HRESULT WINAPI HTMLTable_put_cellPadding(IHTMLTable *iface, VARIANT v)
275 {
276     HTMLTable *This = impl_from_IHTMLTable(iface);
277     nsAString val;
278     HRESULT hres;
279     nsresult nsres;
280 
281     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
282 
283     hres = var2str(&v, &val);
284     if(FAILED(hres))
285         return hres;
286 
287     nsres = nsIDOMHTMLTableElement_SetCellPadding(This->nstable, &val);
288     nsAString_Finish(&val);
289     if(NS_FAILED(nsres)) {
290         ERR("Set Width(%s) failed, err = %08x\n", debugstr_variant(&v), nsres);
291         return E_FAIL;
292     }
293 
294     return S_OK;
295 }
296 
HTMLTable_get_cellPadding(IHTMLTable * iface,VARIANT * p)297 static HRESULT WINAPI HTMLTable_get_cellPadding(IHTMLTable *iface, VARIANT *p)
298 {
299     HTMLTable *This = impl_from_IHTMLTable(iface);
300     nsAString val;
301     nsresult nsres;
302 
303     TRACE("(%p)->(%p)\n", This, p);
304 
305     nsAString_Init(&val, NULL);
306     nsres = nsIDOMHTMLTableElement_GetCellPadding(This->nstable, &val);
307     return return_nsstr_variant(nsres, &val, p);
308 }
309 
HTMLTable_put_background(IHTMLTable * iface,BSTR v)310 static HRESULT WINAPI HTMLTable_put_background(IHTMLTable *iface, BSTR v)
311 {
312     HTMLTable *This = impl_from_IHTMLTable(iface);
313     FIXME("(%p)->(%s)\n", This, debugstr_w(v));
314     return E_NOTIMPL;
315 }
316 
HTMLTable_get_background(IHTMLTable * iface,BSTR * p)317 static HRESULT WINAPI HTMLTable_get_background(IHTMLTable *iface, BSTR *p)
318 {
319     HTMLTable *This = impl_from_IHTMLTable(iface);
320     FIXME("(%p)->(%p)\n", This, p);
321     return E_NOTIMPL;
322 }
323 
HTMLTable_put_bgColor(IHTMLTable * iface,VARIANT v)324 static HRESULT WINAPI HTMLTable_put_bgColor(IHTMLTable *iface, VARIANT v)
325 {
326     HTMLTable *This = impl_from_IHTMLTable(iface);
327     nsAString val;
328     nsresult nsres;
329 
330     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
331 
332     if(!variant_to_nscolor(&v, &val))
333         return S_OK;
334 
335     nsres = nsIDOMHTMLTableElement_SetBgColor(This->nstable, &val);
336     nsAString_Finish(&val);
337     if (NS_FAILED(nsres)){
338         ERR("Set BgColor(%s) failed!\n", debugstr_variant(&v));
339         return E_FAIL;
340     }
341 
342     return S_OK;
343 }
344 
HTMLTable_get_bgColor(IHTMLTable * iface,VARIANT * p)345 static HRESULT WINAPI HTMLTable_get_bgColor(IHTMLTable *iface, VARIANT *p)
346 {
347     HTMLTable *This = impl_from_IHTMLTable(iface);
348     nsAString strColor;
349     nsresult nsres;
350     HRESULT hres;
351     const PRUnichar *color;
352 
353     TRACE("(%p)->(%p)\n", This, p);
354 
355     nsAString_Init(&strColor, NULL);
356     nsres = nsIDOMHTMLTableElement_GetBgColor(This->nstable, &strColor);
357 
358     if(NS_SUCCEEDED(nsres)) {
359        nsAString_GetData(&strColor, &color);
360        V_VT(p) = VT_BSTR;
361        hres = nscolor_to_str(color, &V_BSTR(p));
362     }else {
363        ERR("SetBgColor failed: %08x\n", nsres);
364        hres = E_FAIL;
365     }
366 
367     nsAString_Finish(&strColor);
368     return hres;
369 }
370 
HTMLTable_put_borderColor(IHTMLTable * iface,VARIANT v)371 static HRESULT WINAPI HTMLTable_put_borderColor(IHTMLTable *iface, VARIANT v)
372 {
373     HTMLTable *This = impl_from_IHTMLTable(iface);
374     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
375     return E_NOTIMPL;
376 }
377 
HTMLTable_get_borderColor(IHTMLTable * iface,VARIANT * p)378 static HRESULT WINAPI HTMLTable_get_borderColor(IHTMLTable *iface, VARIANT *p)
379 {
380     HTMLTable *This = impl_from_IHTMLTable(iface);
381     FIXME("(%p)->(%p)\n", This, p);
382     return E_NOTIMPL;
383 }
384 
HTMLTable_put_borderColorLight(IHTMLTable * iface,VARIANT v)385 static HRESULT WINAPI HTMLTable_put_borderColorLight(IHTMLTable *iface, VARIANT v)
386 {
387     HTMLTable *This = impl_from_IHTMLTable(iface);
388     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
389     return E_NOTIMPL;
390 }
391 
HTMLTable_get_borderColorLight(IHTMLTable * iface,VARIANT * p)392 static HRESULT WINAPI HTMLTable_get_borderColorLight(IHTMLTable *iface, VARIANT *p)
393 {
394     HTMLTable *This = impl_from_IHTMLTable(iface);
395     FIXME("(%p)->(%p)\n", This, p);
396     return E_NOTIMPL;
397 }
398 
HTMLTable_put_borderColorDark(IHTMLTable * iface,VARIANT v)399 static HRESULT WINAPI HTMLTable_put_borderColorDark(IHTMLTable *iface, VARIANT v)
400 {
401     HTMLTable *This = impl_from_IHTMLTable(iface);
402     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
403     return E_NOTIMPL;
404 }
405 
HTMLTable_get_borderColorDark(IHTMLTable * iface,VARIANT * p)406 static HRESULT WINAPI HTMLTable_get_borderColorDark(IHTMLTable *iface, VARIANT *p)
407 {
408     HTMLTable *This = impl_from_IHTMLTable(iface);
409     FIXME("(%p)->(%p)\n", This, p);
410     return E_NOTIMPL;
411 }
412 
HTMLTable_put_align(IHTMLTable * iface,BSTR v)413 static HRESULT WINAPI HTMLTable_put_align(IHTMLTable *iface, BSTR v)
414 {
415     HTMLTable *This = impl_from_IHTMLTable(iface);
416     nsAString val;
417     nsresult nsres;
418 
419     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
420 
421     nsAString_InitDepend(&val, v);
422 
423     nsres = nsIDOMHTMLTableElement_SetAlign(This->nstable, &val);
424     nsAString_Finish(&val);
425     if (NS_FAILED(nsres)){
426         ERR("Set Align(%s) failed!\n", debugstr_w(v));
427         return E_FAIL;
428     }
429     return S_OK;
430 }
431 
HTMLTable_get_align(IHTMLTable * iface,BSTR * p)432 static HRESULT WINAPI HTMLTable_get_align(IHTMLTable *iface, BSTR *p)
433 {
434     HTMLTable *This = impl_from_IHTMLTable(iface);
435     nsAString val;
436     nsresult nsres;
437 
438     TRACE("(%p)->(%p)\n", This, p);
439 
440     nsAString_Init(&val, NULL);
441     nsres = nsIDOMHTMLTableElement_GetAlign(This->nstable, &val);
442 
443     return return_nsstr(nsres, &val, p);
444 }
445 
HTMLTable_refresh(IHTMLTable * iface)446 static HRESULT WINAPI HTMLTable_refresh(IHTMLTable *iface)
447 {
448     HTMLTable *This = impl_from_IHTMLTable(iface);
449     FIXME("(%p)\n", This);
450     return E_NOTIMPL;
451 }
452 
HTMLTable_get_rows(IHTMLTable * iface,IHTMLElementCollection ** p)453 static HRESULT WINAPI HTMLTable_get_rows(IHTMLTable *iface, IHTMLElementCollection **p)
454 {
455     HTMLTable *This = impl_from_IHTMLTable(iface);
456     nsIDOMHTMLCollection *nscol;
457     nsresult nsres;
458 
459     TRACE("(%p)->(%p)\n", This, p);
460 
461     nsres = nsIDOMHTMLTableElement_GetRows(This->nstable, &nscol);
462     if(NS_FAILED(nsres)) {
463         ERR("GetRows failed: %08x\n", nsres);
464         return E_FAIL;
465     }
466 
467     *p = create_collection_from_htmlcol(This->element.node.doc, nscol);
468 
469     nsIDOMHTMLCollection_Release(nscol);
470     return S_OK;
471 }
472 
HTMLTable_put_width(IHTMLTable * iface,VARIANT v)473 static HRESULT WINAPI HTMLTable_put_width(IHTMLTable *iface, VARIANT v)
474 {
475     HTMLTable *This = impl_from_IHTMLTable(iface);
476     nsAString val;
477     HRESULT hres;
478     nsresult nsres;
479 
480     TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
481     hres = var2str(&v, &val);
482 
483     if (FAILED(hres)){
484         ERR("Set Width(%s) failed when initializing a nsAString, err = %08x\n",
485             debugstr_variant(&v), hres);
486         return hres;
487     }
488 
489     nsres = nsIDOMHTMLTableElement_SetWidth(This->nstable, &val);
490     nsAString_Finish(&val);
491 
492     if (NS_FAILED(nsres)){
493         ERR("Set Width(%s) failed, err = %08x\n", debugstr_variant(&v), nsres);
494         return E_FAIL;
495     }
496     return S_OK;
497 }
498 
HTMLTable_get_width(IHTMLTable * iface,VARIANT * p)499 static HRESULT WINAPI HTMLTable_get_width(IHTMLTable *iface, VARIANT *p)
500 {
501     HTMLTable *This = impl_from_IHTMLTable(iface);
502     nsAString val;
503     BSTR bstr;
504     nsresult nsres;
505     HRESULT hres;
506 
507     TRACE("(%p)->(%p)\n", This, p);
508     nsAString_Init(&val, NULL);
509     nsres = nsIDOMHTMLTableElement_GetWidth(This->nstable, &val);
510     if (NS_FAILED(nsres)){
511         ERR("Get Width failed!\n");
512         nsAString_Finish(&val);
513         return E_FAIL;
514     }
515 
516     hres = nsstr_to_truncated_bstr(&val, &bstr);
517     nsAString_Finish(&val);
518 
519     V_VT(p) = VT_BSTR;
520     V_BSTR(p) = bstr;
521     return hres;
522 }
523 
HTMLTable_put_height(IHTMLTable * iface,VARIANT v)524 static HRESULT WINAPI HTMLTable_put_height(IHTMLTable *iface, VARIANT v)
525 {
526     HTMLTable *This = impl_from_IHTMLTable(iface);
527     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
528     return E_NOTIMPL;
529 }
530 
HTMLTable_get_height(IHTMLTable * iface,VARIANT * p)531 static HRESULT WINAPI HTMLTable_get_height(IHTMLTable *iface, VARIANT *p)
532 {
533     HTMLTable *This = impl_from_IHTMLTable(iface);
534     FIXME("(%p)->(%p)\n", This, p);
535     return E_NOTIMPL;
536 }
537 
HTMLTable_put_dataPageSize(IHTMLTable * iface,LONG v)538 static HRESULT WINAPI HTMLTable_put_dataPageSize(IHTMLTable *iface, LONG v)
539 {
540     HTMLTable *This = impl_from_IHTMLTable(iface);
541     FIXME("(%p)->(%d)\n", This, v);
542     return E_NOTIMPL;
543 }
544 
HTMLTable_get_dataPageSize(IHTMLTable * iface,LONG * p)545 static HRESULT WINAPI HTMLTable_get_dataPageSize(IHTMLTable *iface, LONG *p)
546 {
547     HTMLTable *This = impl_from_IHTMLTable(iface);
548     FIXME("(%p)->(%p)\n", This, p);
549     return E_NOTIMPL;
550 }
551 
HTMLTable_nextPage(IHTMLTable * iface)552 static HRESULT WINAPI HTMLTable_nextPage(IHTMLTable *iface)
553 {
554     HTMLTable *This = impl_from_IHTMLTable(iface);
555     FIXME("(%p)\n", This);
556     return E_NOTIMPL;
557 }
558 
HTMLTable_previousPage(IHTMLTable * iface)559 static HRESULT WINAPI HTMLTable_previousPage(IHTMLTable *iface)
560 {
561     HTMLTable *This = impl_from_IHTMLTable(iface);
562     FIXME("(%p)\n", This);
563     return E_NOTIMPL;
564 }
565 
HTMLTable_get_tHead(IHTMLTable * iface,IHTMLTableSection ** p)566 static HRESULT WINAPI HTMLTable_get_tHead(IHTMLTable *iface, IHTMLTableSection **p)
567 {
568     HTMLTable *This = impl_from_IHTMLTable(iface);
569     FIXME("(%p)->(%p)\n", This, p);
570     return E_NOTIMPL;
571 }
572 
HTMLTable_get_tFoot(IHTMLTable * iface,IHTMLTableSection ** p)573 static HRESULT WINAPI HTMLTable_get_tFoot(IHTMLTable *iface, IHTMLTableSection **p)
574 {
575     HTMLTable *This = impl_from_IHTMLTable(iface);
576     FIXME("(%p)->(%p)\n", This, p);
577     return E_NOTIMPL;
578 }
579 
HTMLTable_get_tBodies(IHTMLTable * iface,IHTMLElementCollection ** p)580 static HRESULT WINAPI HTMLTable_get_tBodies(IHTMLTable *iface, IHTMLElementCollection **p)
581 {
582     HTMLTable *This = impl_from_IHTMLTable(iface);
583     nsIDOMHTMLCollection *nscol = NULL;
584     nsresult nsres;
585 
586     TRACE("(%p)->(%p)\n", This, p);
587 
588     nsres = nsIDOMHTMLTableElement_GetTBodies(This->nstable, &nscol);
589     if(NS_FAILED(nsres)) {
590         ERR("GetTBodies failed: %08x\n", nsres);
591         return E_FAIL;
592     }
593 
594     *p = create_collection_from_htmlcol(This->element.node.doc, nscol);
595 
596     nsIDOMHTMLCollection_Release(nscol);
597     return S_OK;
598 }
599 
HTMLTable_get_caption(IHTMLTable * iface,IHTMLTableCaption ** p)600 static HRESULT WINAPI HTMLTable_get_caption(IHTMLTable *iface, IHTMLTableCaption **p)
601 {
602     HTMLTable *This = impl_from_IHTMLTable(iface);
603     FIXME("(%p)->(%p)\n", This, p);
604     return E_NOTIMPL;
605 }
606 
HTMLTable_createTHead(IHTMLTable * iface,IDispatch ** head)607 static HRESULT WINAPI HTMLTable_createTHead(IHTMLTable *iface, IDispatch **head)
608 {
609     HTMLTable *This = impl_from_IHTMLTable(iface);
610     FIXME("(%p)->(%p)\n", This, head);
611     return E_NOTIMPL;
612 }
613 
HTMLTable_deleteTHead(IHTMLTable * iface)614 static HRESULT WINAPI HTMLTable_deleteTHead(IHTMLTable *iface)
615 {
616     HTMLTable *This = impl_from_IHTMLTable(iface);
617     FIXME("(%p)\n", This);
618     return E_NOTIMPL;
619 }
620 
HTMLTable_createTFoot(IHTMLTable * iface,IDispatch ** foot)621 static HRESULT WINAPI HTMLTable_createTFoot(IHTMLTable *iface, IDispatch **foot)
622 {
623     HTMLTable *This = impl_from_IHTMLTable(iface);
624     FIXME("(%p)->(%p)\n", This, foot);
625     return E_NOTIMPL;
626 }
627 
HTMLTable_deleteTFoot(IHTMLTable * iface)628 static HRESULT WINAPI HTMLTable_deleteTFoot(IHTMLTable *iface)
629 {
630     HTMLTable *This = impl_from_IHTMLTable(iface);
631     FIXME("(%p)\n", This);
632     return E_NOTIMPL;
633 }
634 
HTMLTable_createCaption(IHTMLTable * iface,IHTMLTableCaption ** caption)635 static HRESULT WINAPI HTMLTable_createCaption(IHTMLTable *iface, IHTMLTableCaption **caption)
636 {
637     HTMLTable *This = impl_from_IHTMLTable(iface);
638     FIXME("(%p)->(%p)\n", This, caption);
639     return E_NOTIMPL;
640 }
641 
HTMLTable_deleteCaption(IHTMLTable * iface)642 static HRESULT WINAPI HTMLTable_deleteCaption(IHTMLTable *iface)
643 {
644     HTMLTable *This = impl_from_IHTMLTable(iface);
645     FIXME("(%p)\n", This);
646     return E_NOTIMPL;
647 }
648 
HTMLTable_insertRow(IHTMLTable * iface,LONG index,IDispatch ** row)649 static HRESULT WINAPI HTMLTable_insertRow(IHTMLTable *iface, LONG index, IDispatch **row)
650 {
651     HTMLTable *This = impl_from_IHTMLTable(iface);
652     nsIDOMHTMLElement *nselem;
653     HTMLElement *elem;
654     nsresult nsres;
655     HRESULT hres;
656 
657     TRACE("(%p)->(%d %p)\n", This, index, row);
658     nsres = nsIDOMHTMLTableElement_InsertRow(This->nstable, index, &nselem);
659     if(NS_FAILED(nsres)) {
660         ERR("Insert Row at %d failed: %08x\n", index, nsres);
661         return E_FAIL;
662     }
663 
664     hres = HTMLTableRow_Create(This->element.node.doc, nselem, &elem);
665     nsIDOMHTMLElement_Release(nselem);
666     if (FAILED(hres)) {
667         ERR("Create TableRow failed: %08x\n", hres);
668         return hres;
669     }
670 
671     *row = (IDispatch *)&elem->IHTMLElement_iface;
672     return S_OK;
673 }
674 
HTMLTable_deleteRow(IHTMLTable * iface,LONG index)675 static HRESULT WINAPI HTMLTable_deleteRow(IHTMLTable *iface, LONG index)
676 {
677     HTMLTable *This = impl_from_IHTMLTable(iface);
678     nsresult nsres;
679 
680     TRACE("(%p)->(%d)\n", This, index);
681     nsres = nsIDOMHTMLTableElement_DeleteRow(This->nstable, index);
682     if(NS_FAILED(nsres)) {
683         ERR("Delete Row failed: %08x\n", nsres);
684         return E_FAIL;
685     }
686     return S_OK;
687 }
688 
HTMLTable_get_readyState(IHTMLTable * iface,BSTR * p)689 static HRESULT WINAPI HTMLTable_get_readyState(IHTMLTable *iface, BSTR *p)
690 {
691     HTMLTable *This = impl_from_IHTMLTable(iface);
692     FIXME("(%p)->(%p)\n", This, p);
693     return E_NOTIMPL;
694 }
695 
HTMLTable_put_onreadystatechange(IHTMLTable * iface,VARIANT v)696 static HRESULT WINAPI HTMLTable_put_onreadystatechange(IHTMLTable *iface, VARIANT v)
697 {
698     HTMLTable *This = impl_from_IHTMLTable(iface);
699     FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
700     return E_NOTIMPL;
701 }
702 
HTMLTable_get_onreadystatechange(IHTMLTable * iface,VARIANT * p)703 static HRESULT WINAPI HTMLTable_get_onreadystatechange(IHTMLTable *iface, VARIANT *p)
704 {
705     HTMLTable *This = impl_from_IHTMLTable(iface);
706     FIXME("(%p)->(%p)\n", This, p);
707     return E_NOTIMPL;
708 }
709 
710 static const IHTMLTableVtbl HTMLTableVtbl = {
711     HTMLTable_QueryInterface,
712     HTMLTable_AddRef,
713     HTMLTable_Release,
714     HTMLTable_GetTypeInfoCount,
715     HTMLTable_GetTypeInfo,
716     HTMLTable_GetIDsOfNames,
717     HTMLTable_Invoke,
718     HTMLTable_put_cols,
719     HTMLTable_get_cols,
720     HTMLTable_put_border,
721     HTMLTable_get_border,
722     HTMLTable_put_frame,
723     HTMLTable_get_frame,
724     HTMLTable_put_rules,
725     HTMLTable_get_rules,
726     HTMLTable_put_cellSpacing,
727     HTMLTable_get_cellSpacing,
728     HTMLTable_put_cellPadding,
729     HTMLTable_get_cellPadding,
730     HTMLTable_put_background,
731     HTMLTable_get_background,
732     HTMLTable_put_bgColor,
733     HTMLTable_get_bgColor,
734     HTMLTable_put_borderColor,
735     HTMLTable_get_borderColor,
736     HTMLTable_put_borderColorLight,
737     HTMLTable_get_borderColorLight,
738     HTMLTable_put_borderColorDark,
739     HTMLTable_get_borderColorDark,
740     HTMLTable_put_align,
741     HTMLTable_get_align,
742     HTMLTable_refresh,
743     HTMLTable_get_rows,
744     HTMLTable_put_width,
745     HTMLTable_get_width,
746     HTMLTable_put_height,
747     HTMLTable_get_height,
748     HTMLTable_put_dataPageSize,
749     HTMLTable_get_dataPageSize,
750     HTMLTable_nextPage,
751     HTMLTable_previousPage,
752     HTMLTable_get_tHead,
753     HTMLTable_get_tFoot,
754     HTMLTable_get_tBodies,
755     HTMLTable_get_caption,
756     HTMLTable_createTHead,
757     HTMLTable_deleteTHead,
758     HTMLTable_createTFoot,
759     HTMLTable_deleteTFoot,
760     HTMLTable_createCaption,
761     HTMLTable_deleteCaption,
762     HTMLTable_insertRow,
763     HTMLTable_deleteRow,
764     HTMLTable_get_readyState,
765     HTMLTable_put_onreadystatechange,
766     HTMLTable_get_onreadystatechange
767 };
768 
769 /* IHTMLTable2 */
HTMLTable2_QueryInterface(IHTMLTable2 * iface,REFIID riid,void ** ppv)770 static HRESULT WINAPI HTMLTable2_QueryInterface(IHTMLTable2 *iface,
771                                                          REFIID riid, void **ppv)
772 {
773     HTMLTable *This = impl_from_IHTMLTable2(iface);
774 
775     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
776 }
777 
HTMLTable2_AddRef(IHTMLTable2 * iface)778 static ULONG WINAPI HTMLTable2_AddRef(IHTMLTable2 *iface)
779 {
780     HTMLTable *This = impl_from_IHTMLTable2(iface);
781 
782     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
783 }
784 
HTMLTable2_Release(IHTMLTable2 * iface)785 static ULONG WINAPI HTMLTable2_Release(IHTMLTable2 *iface)
786 {
787     HTMLTable *This = impl_from_IHTMLTable2(iface);
788 
789     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
790 }
791 
HTMLTable2_GetTypeInfoCount(IHTMLTable2 * iface,UINT * pctinfo)792 static HRESULT WINAPI HTMLTable2_GetTypeInfoCount(IHTMLTable2 *iface, UINT *pctinfo)
793 {
794     HTMLTable *This = impl_from_IHTMLTable2(iface);
795     return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
796 }
797 
HTMLTable2_GetTypeInfo(IHTMLTable2 * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)798 static HRESULT WINAPI HTMLTable2_GetTypeInfo(IHTMLTable2 *iface, UINT iTInfo,
799                                               LCID lcid, ITypeInfo **ppTInfo)
800 {
801     HTMLTable *This = impl_from_IHTMLTable2(iface);
802     return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
803             ppTInfo);
804 }
805 
HTMLTable2_GetIDsOfNames(IHTMLTable2 * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)806 static HRESULT WINAPI HTMLTable2_GetIDsOfNames(IHTMLTable2 *iface, REFIID riid,
807                                                 LPOLESTR *rgszNames, UINT cNames,
808                                                 LCID lcid, DISPID *rgDispId)
809 {
810     HTMLTable *This = impl_from_IHTMLTable2(iface);
811     return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
812             cNames, lcid, rgDispId);
813 }
814 
HTMLTable2_Invoke(IHTMLTable2 * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)815 static HRESULT WINAPI HTMLTable2_Invoke(IHTMLTable2 *iface, DISPID dispIdMember,
816                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
817                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
818 {
819     HTMLTable *This = impl_from_IHTMLTable2(iface);
820     return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
821             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
822 }
823 
HTMLTable2_firstPage(IHTMLTable2 * iface)824 static HRESULT WINAPI HTMLTable2_firstPage(IHTMLTable2 *iface)
825 {
826     HTMLTable *This = impl_from_IHTMLTable2(iface);
827     FIXME("(%p)->()\n", This);
828     return E_NOTIMPL;
829 }
830 
HTMLTable2_lastPage(IHTMLTable2 * iface)831 static HRESULT WINAPI HTMLTable2_lastPage(IHTMLTable2 *iface)
832 {
833     HTMLTable *This = impl_from_IHTMLTable2(iface);
834     FIXME("(%p)->()\n", This);
835     return E_NOTIMPL;
836 }
837 
HTMLTable2_cells(IHTMLTable2 * iface,IHTMLElementCollection ** p)838 static HRESULT WINAPI HTMLTable2_cells(IHTMLTable2 *iface, IHTMLElementCollection **p)
839 {
840     HTMLTable *This = impl_from_IHTMLTable2(iface);
841     FIXME("(%p)->(%p)\n", This, p);
842     return E_NOTIMPL;
843 }
844 
HTMLTable2_moveRow(IHTMLTable2 * iface,LONG indexFrom,LONG indexTo,IDispatch ** row)845 static HRESULT WINAPI HTMLTable2_moveRow(IHTMLTable2 *iface, LONG indexFrom, LONG indexTo, IDispatch **row)
846 {
847     HTMLTable *This = impl_from_IHTMLTable2(iface);
848     FIXME("(%p)->(%d %d %p)\n", This, indexFrom, indexTo, row);
849     return E_NOTIMPL;
850 }
851 
852 
853 static const IHTMLTable2Vtbl HTMLTable2Vtbl = {
854     HTMLTable2_QueryInterface,
855     HTMLTable2_AddRef,
856     HTMLTable2_Release,
857     HTMLTable2_GetTypeInfoCount,
858     HTMLTable2_GetTypeInfo,
859     HTMLTable2_GetIDsOfNames,
860     HTMLTable2_Invoke,
861     HTMLTable2_firstPage,
862     HTMLTable2_lastPage,
863     HTMLTable2_cells,
864     HTMLTable2_moveRow
865 };
866 
867 /* IHTMLTable3 */
HTMLTable3_QueryInterface(IHTMLTable3 * iface,REFIID riid,void ** ppv)868 static HRESULT WINAPI HTMLTable3_QueryInterface(IHTMLTable3 *iface,
869                                                          REFIID riid, void **ppv)
870 {
871     HTMLTable *This = impl_from_IHTMLTable3(iface);
872 
873     return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
874 }
875 
HTMLTable3_AddRef(IHTMLTable3 * iface)876 static ULONG WINAPI HTMLTable3_AddRef(IHTMLTable3 *iface)
877 {
878     HTMLTable *This = impl_from_IHTMLTable3(iface);
879 
880     return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
881 }
882 
HTMLTable3_Release(IHTMLTable3 * iface)883 static ULONG WINAPI HTMLTable3_Release(IHTMLTable3 *iface)
884 {
885     HTMLTable *This = impl_from_IHTMLTable3(iface);
886 
887     return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
888 }
889 
HTMLTable3_GetTypeInfoCount(IHTMLTable3 * iface,UINT * pctinfo)890 static HRESULT WINAPI HTMLTable3_GetTypeInfoCount(IHTMLTable3 *iface, UINT *pctinfo)
891 {
892     HTMLTable *This = impl_from_IHTMLTable3(iface);
893     return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
894 }
895 
HTMLTable3_GetTypeInfo(IHTMLTable3 * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)896 static HRESULT WINAPI HTMLTable3_GetTypeInfo(IHTMLTable3 *iface, UINT iTInfo,
897                                               LCID lcid, ITypeInfo **ppTInfo)
898 {
899     HTMLTable *This = impl_from_IHTMLTable3(iface);
900     return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
901             ppTInfo);
902 }
903 
HTMLTable3_GetIDsOfNames(IHTMLTable3 * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)904 static HRESULT WINAPI HTMLTable3_GetIDsOfNames(IHTMLTable3 *iface, REFIID riid,
905                                                 LPOLESTR *rgszNames, UINT cNames,
906                                                 LCID lcid, DISPID *rgDispId)
907 {
908     HTMLTable *This = impl_from_IHTMLTable3(iface);
909     return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
910             cNames, lcid, rgDispId);
911 }
912 
HTMLTable3_Invoke(IHTMLTable3 * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)913 static HRESULT WINAPI HTMLTable3_Invoke(IHTMLTable3 *iface, DISPID dispIdMember,
914                             REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
915                             VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
916 {
917     HTMLTable *This = impl_from_IHTMLTable3(iface);
918     return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
919             lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
920 }
921 
HTMLTable3_put_summary(IHTMLTable3 * iface,BSTR v)922 static HRESULT WINAPI HTMLTable3_put_summary(IHTMLTable3 *iface, BSTR v)
923 {
924     HTMLTable *This = impl_from_IHTMLTable3(iface);
925     nsAString str;
926     nsresult nsres;
927 
928     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
929 
930     nsAString_InitDepend(&str, v);
931 
932     nsres = nsIDOMHTMLTableElement_SetSummary(This->nstable, &str);
933 
934     nsAString_Finish(&str);
935     if (NS_FAILED(nsres)) {
936         ERR("Set summary(%s) failed: %08x\n", debugstr_w(v), nsres);
937         return E_FAIL;
938     }
939     return S_OK;
940 }
941 
HTMLTable3_get_summary(IHTMLTable3 * iface,BSTR * p)942 static HRESULT WINAPI HTMLTable3_get_summary(IHTMLTable3 *iface, BSTR * p)
943 {
944     HTMLTable *This = impl_from_IHTMLTable3(iface);
945     nsAString str;
946     nsresult nsres;
947 
948     TRACE("(%p)->(%p)\n", This, p);
949 
950     nsAString_Init(&str, NULL);
951     nsres = nsIDOMHTMLTableElement_GetSummary(This->nstable, &str);
952 
953     return return_nsstr(nsres, &str, p);
954 }
955 
956 static const IHTMLTable3Vtbl HTMLTable3Vtbl = {
957     HTMLTable3_QueryInterface,
958     HTMLTable3_AddRef,
959     HTMLTable3_Release,
960     HTMLTable3_GetTypeInfoCount,
961     HTMLTable3_GetTypeInfo,
962     HTMLTable3_GetIDsOfNames,
963     HTMLTable3_Invoke,
964     HTMLTable3_put_summary,
965     HTMLTable3_get_summary
966 };
967 
impl_from_HTMLDOMNode(HTMLDOMNode * iface)968 static inline HTMLTable *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
969 {
970     return CONTAINING_RECORD(iface, HTMLTable, element.node);
971 }
972 
HTMLTable_QI(HTMLDOMNode * iface,REFIID riid,void ** ppv)973 static HRESULT HTMLTable_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
974 {
975     HTMLTable *This = impl_from_HTMLDOMNode(iface);
976 
977     *ppv = NULL;
978 
979     if(IsEqualGUID(&IID_IUnknown, riid)) {
980         TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
981         *ppv = &This->IHTMLTable_iface;
982     }else if(IsEqualGUID(&IID_IDispatch, riid)) {
983         TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
984         *ppv = &This->IHTMLTable_iface;
985     }else if(IsEqualGUID(&IID_IHTMLTable, riid)) {
986         TRACE("(%p)->(IID_IHTMLTable %p)\n", This, ppv);
987         *ppv = &This->IHTMLTable_iface;
988     }else if(IsEqualGUID(&IID_IHTMLTable2, riid)) {
989         TRACE("(%p)->(IID_IHTMLTable2 %p)\n", This, ppv);
990         *ppv = &This->IHTMLTable2_iface;
991     }else if(IsEqualGUID(&IID_IHTMLTable3, riid)) {
992         TRACE("(%p)->(IID_IHTMLTable3 %p)\n", This, ppv);
993         *ppv = &This->IHTMLTable3_iface;
994     }
995 
996     if(*ppv) {
997         IUnknown_AddRef((IUnknown*)*ppv);
998         return S_OK;
999     }
1000 
1001     return HTMLElement_QI(&This->element.node, riid, ppv);
1002 }
1003 
HTMLTable_traverse(HTMLDOMNode * iface,nsCycleCollectionTraversalCallback * cb)1004 static void HTMLTable_traverse(HTMLDOMNode *iface, nsCycleCollectionTraversalCallback *cb)
1005 {
1006     HTMLTable *This = impl_from_HTMLDOMNode(iface);
1007 
1008     if(This->nstable)
1009         note_cc_edge((nsISupports*)This->nstable, "This->nstable", cb);
1010 }
1011 
HTMLTable_unlink(HTMLDOMNode * iface)1012 static void HTMLTable_unlink(HTMLDOMNode *iface)
1013 {
1014     HTMLTable *This = impl_from_HTMLDOMNode(iface);
1015 
1016     if(This->nstable) {
1017         nsIDOMHTMLTableElement *nstable = This->nstable;
1018 
1019         This->nstable = NULL;
1020         nsIDOMHTMLTableElement_Release(nstable);
1021     }
1022 }
1023 
1024 static const cpc_entry_t HTMLTable_cpc[] = {
1025     {&DIID_HTMLTableEvents},
1026     HTMLELEMENT_CPC,
1027     {NULL}
1028 };
1029 
1030 static const NodeImplVtbl HTMLTableImplVtbl = {
1031     HTMLTable_QI,
1032     HTMLElement_destructor,
1033     HTMLTable_cpc,
1034     HTMLElement_clone,
1035     HTMLElement_handle_event,
1036     HTMLElement_get_attr_col,
1037     NULL,
1038     NULL,
1039     NULL,
1040     NULL,
1041     NULL,
1042     NULL,
1043     NULL,
1044     NULL,
1045     NULL,
1046     HTMLTable_traverse,
1047     HTMLTable_unlink
1048 };
1049 
1050 static const tid_t HTMLTable_iface_tids[] = {
1051     HTMLELEMENT_TIDS,
1052     IHTMLTable_tid,
1053     IHTMLTable2_tid,
1054     IHTMLTable3_tid,
1055     0
1056 };
1057 
1058 static dispex_static_data_t HTMLTable_dispex = {
1059     NULL,
1060     DispHTMLTable_tid,
1061     NULL,
1062     HTMLTable_iface_tids
1063 };
1064 
HTMLTable_Create(HTMLDocumentNode * doc,nsIDOMHTMLElement * nselem,HTMLElement ** elem)1065 HRESULT HTMLTable_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
1066 {
1067     HTMLTable *ret;
1068     nsresult nsres;
1069 
1070     ret = heap_alloc_zero(sizeof(HTMLTable));
1071     if(!ret)
1072         return E_OUTOFMEMORY;
1073 
1074     ret->element.node.vtbl = &HTMLTableImplVtbl;
1075     ret->IHTMLTable_iface.lpVtbl = &HTMLTableVtbl;
1076     ret->IHTMLTable2_iface.lpVtbl = &HTMLTable2Vtbl;
1077     ret->IHTMLTable3_iface.lpVtbl = &HTMLTable3Vtbl;
1078 
1079     HTMLElement_Init(&ret->element, doc, nselem, &HTMLTable_dispex);
1080 
1081     nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTableElement, (void**)&ret->nstable);
1082     assert(nsres == NS_OK);
1083 
1084     *elem = &ret->element;
1085     return S_OK;
1086 }
1087