ddraw: Set dwMaxVertexCount to 2048.
[wine.git] / dlls / mshtml / htmltable.c
blob6c2d72cdcea5aa97f54b77e5ad48c35d03b42b64
1 /*
2 * Copyright 2007,2008,2012 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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
31 #include "htmlevent.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 struct HTMLTableCell {
36 HTMLElement element;
38 IHTMLTableCell IHTMLTableCell_iface;
40 nsIDOMHTMLTableCellElement *nscell;
43 static inline HTMLTableCell *impl_from_IHTMLTableCell(IHTMLTableCell *iface)
45 return CONTAINING_RECORD(iface, HTMLTableCell, IHTMLTableCell_iface);
48 DISPEX_IDISPATCH_IMPL(HTMLTableCell, IHTMLTableCell,
49 impl_from_IHTMLTableCell(iface)->element.node.event_target.dispex)
51 static HRESULT WINAPI HTMLTableCell_put_rowSpan(IHTMLTableCell *iface, LONG v)
53 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
54 nsresult nsres;
56 TRACE("(%p)->(%ld)\n", This, v);
58 if(v <= 0)
59 return E_INVALIDARG;
61 nsres = nsIDOMHTMLTableCellElement_SetRowSpan(This->nscell, v);
62 if(NS_FAILED(nsres)) {
63 ERR("SetRowSpan failed: %08lx\n", nsres);
64 return E_FAIL;
67 return S_OK;
70 static HRESULT WINAPI HTMLTableCell_get_rowSpan(IHTMLTableCell *iface, LONG *p)
72 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
73 nsresult nsres;
75 TRACE("(%p)->(%p)\n", This, p);
77 nsres = nsIDOMHTMLTableCellElement_GetRowSpan(This->nscell, p);
78 if(NS_FAILED(nsres)) {
79 ERR("GetRowSpan failed: %08lx\n", nsres);
80 return E_FAIL;
83 return S_OK;
86 static HRESULT WINAPI HTMLTableCell_put_colSpan(IHTMLTableCell *iface, LONG v)
88 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
89 nsresult nsres;
91 TRACE("(%p)->(%ld)\n", This, v);
93 if(v <= 0)
94 return E_INVALIDARG;
96 nsres = nsIDOMHTMLTableCellElement_SetColSpan(This->nscell, v);
97 if(NS_FAILED(nsres)) {
98 ERR("SetColSpan failed: %08lx\n", nsres);
99 return E_FAIL;
102 return S_OK;
105 static HRESULT WINAPI HTMLTableCell_get_colSpan(IHTMLTableCell *iface, LONG *p)
107 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
108 nsresult nsres;
110 TRACE("(%p)->(%p)\n", This, p);
112 nsres = nsIDOMHTMLTableCellElement_GetColSpan(This->nscell, p);
113 if(NS_FAILED(nsres)) {
114 ERR("GetColSpan failed: %08lx\n", nsres);
115 return E_FAIL;
118 return S_OK;
121 static HRESULT WINAPI HTMLTableCell_put_align(IHTMLTableCell *iface, BSTR v)
123 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
124 nsAString str;
125 nsresult nsres;
127 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
129 nsAString_InitDepend(&str, v);
130 nsres = nsIDOMHTMLTableCellElement_SetAlign(This->nscell, &str);
131 nsAString_Finish(&str);
132 if (NS_FAILED(nsres)) {
133 ERR("Set Align failed: %08lx\n", nsres);
134 return E_FAIL;
136 return S_OK;
139 static HRESULT WINAPI HTMLTableCell_get_align(IHTMLTableCell *iface, BSTR *p)
141 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
142 nsAString str;
143 nsresult nsres;
145 TRACE("(%p)->(%p)\n", This, p);
147 nsAString_Init(&str, NULL);
148 nsres = nsIDOMHTMLTableCellElement_GetAlign(This->nscell, &str);
150 return return_nsstr(nsres, &str, p);
153 static HRESULT WINAPI HTMLTableCell_put_vAlign(IHTMLTableCell *iface, BSTR v)
155 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
156 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
157 return E_NOTIMPL;
160 static HRESULT WINAPI HTMLTableCell_get_vAlign(IHTMLTableCell *iface, BSTR *p)
162 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
163 FIXME("(%p)->(%p)\n", This, p);
164 return E_NOTIMPL;
167 static HRESULT WINAPI HTMLTableCell_put_bgColor(IHTMLTableCell *iface, VARIANT v)
169 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
170 nsAString strColor;
171 nsresult nsres;
173 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
175 if(!variant_to_nscolor(&v, &strColor))
176 return S_OK;
178 nsres = nsIDOMHTMLTableCellElement_SetBgColor(This->nscell, &strColor);
179 nsAString_Finish(&strColor);
180 if(NS_FAILED(nsres)) {
181 ERR("SetBgColor(%s) failed: %08lx\n", debugstr_variant(&v), nsres);
182 return E_FAIL;
185 return S_OK;
188 static HRESULT WINAPI HTMLTableCell_get_bgColor(IHTMLTableCell *iface, VARIANT *p)
190 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
191 nsAString strColor;
192 nsresult nsres;
193 HRESULT hres;
195 TRACE("(%p)->(%p)\n", This, p);
197 nsAString_Init(&strColor, NULL);
198 nsres = nsIDOMHTMLTableCellElement_GetBgColor(This->nscell, &strColor);
200 if(NS_SUCCEEDED(nsres)) {
201 const PRUnichar *color;
202 nsAString_GetData(&strColor, &color);
203 V_VT(p) = VT_BSTR;
204 hres = nscolor_to_str(color, &V_BSTR(p));
205 }else {
206 ERR("GetBgColor failed: %08lx\n", nsres);
207 hres = E_FAIL;
209 nsAString_Finish(&strColor);
210 return hres;
213 static HRESULT WINAPI HTMLTableCell_put_noWrap(IHTMLTableCell *iface, VARIANT_BOOL v)
215 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
216 FIXME("(%p)->(%x)\n", This, v);
217 return E_NOTIMPL;
220 static HRESULT WINAPI HTMLTableCell_get_noWrap(IHTMLTableCell *iface, VARIANT_BOOL *p)
222 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
223 FIXME("(%p)->(%p)\n", This, p);
224 return E_NOTIMPL;
227 static HRESULT WINAPI HTMLTableCell_put_background(IHTMLTableCell *iface, BSTR v)
229 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
230 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
231 return E_NOTIMPL;
234 static HRESULT WINAPI HTMLTableCell_get_background(IHTMLTableCell *iface, BSTR *p)
236 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
237 FIXME("(%p)->(%p)\n", This, p);
238 return E_NOTIMPL;
241 static HRESULT WINAPI HTMLTableCell_put_borderColor(IHTMLTableCell *iface, VARIANT v)
243 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
244 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
245 return E_NOTIMPL;
248 static HRESULT WINAPI HTMLTableCell_get_borderColor(IHTMLTableCell *iface, VARIANT *p)
250 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
251 FIXME("(%p)->(%p)\n", This, p);
252 return E_NOTIMPL;
255 static HRESULT WINAPI HTMLTableCell_put_borderColorLight(IHTMLTableCell *iface, VARIANT v)
257 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
258 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
259 return E_NOTIMPL;
262 static HRESULT WINAPI HTMLTableCell_get_borderColorLight(IHTMLTableCell *iface, VARIANT *p)
264 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
265 FIXME("(%p)->(%p)\n", This, p);
266 return E_NOTIMPL;
269 static HRESULT WINAPI HTMLTableCell_put_borderColorDark(IHTMLTableCell *iface, VARIANT v)
271 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
272 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
273 return E_NOTIMPL;
276 static HRESULT WINAPI HTMLTableCell_get_borderColorDark(IHTMLTableCell *iface, VARIANT *p)
278 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
279 FIXME("(%p)->(%p)\n", This, p);
280 return E_NOTIMPL;
283 static HRESULT WINAPI HTMLTableCell_put_width(IHTMLTableCell *iface, VARIANT v)
285 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
286 nsAString nsstr;
287 nsresult nsres;
288 HRESULT hres;
290 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
292 hres = variant_to_nsstr(&v, FALSE, &nsstr);
293 if(FAILED(hres))
294 return hres;
296 nsres = nsIDOMHTMLTableCellElement_SetWidth(This->nscell, &nsstr);
297 nsAString_Finish(&nsstr);
298 return map_nsresult(nsres);
301 static HRESULT WINAPI HTMLTableCell_get_width(IHTMLTableCell *iface, VARIANT *p)
303 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
304 nsAString nsstr;
305 nsresult nsres;
307 TRACE("(%p)->(%p)\n", This, p);
309 nsAString_Init(&nsstr, NULL);
310 nsres = nsIDOMHTMLTableCellElement_GetWidth(This->nscell, &nsstr);
311 return return_nsstr_variant(nsres, &nsstr, NSSTR_IMPLICIT_PX, p);
314 static HRESULT WINAPI HTMLTableCell_put_height(IHTMLTableCell *iface, VARIANT v)
316 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
317 nsAString nsstr;
318 nsresult nsres;
319 HRESULT hres;
321 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
323 hres = variant_to_nsstr(&v, FALSE, &nsstr);
324 if(FAILED(hres))
325 return hres;
327 nsres = nsIDOMHTMLTableCellElement_SetHeight(This->nscell, &nsstr);
328 nsAString_Finish(&nsstr);
329 return map_nsresult(nsres);
332 static HRESULT WINAPI HTMLTableCell_get_height(IHTMLTableCell *iface, VARIANT *p)
334 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
335 nsAString nsstr;
336 nsresult nsres;
338 TRACE("(%p)->(%p)\n", This, p);
340 nsAString_Init(&nsstr, NULL);
341 nsres = nsIDOMHTMLTableCellElement_GetHeight(This->nscell, &nsstr);
342 return return_nsstr_variant(nsres, &nsstr, NSSTR_IMPLICIT_PX, p);
345 static HRESULT WINAPI HTMLTableCell_get_cellIndex(IHTMLTableCell *iface, LONG *p)
347 HTMLTableCell *This = impl_from_IHTMLTableCell(iface);
348 nsresult nsres;
350 TRACE("(%p)->(%p)\n", This, p);
351 nsres = nsIDOMHTMLTableCellElement_GetCellIndex(This->nscell, p);
352 if (NS_FAILED(nsres)) {
353 ERR("Get CellIndex failed: %08lx\n", nsres);
354 return E_FAIL;
357 return S_OK;
360 static const IHTMLTableCellVtbl HTMLTableCellVtbl = {
361 HTMLTableCell_QueryInterface,
362 HTMLTableCell_AddRef,
363 HTMLTableCell_Release,
364 HTMLTableCell_GetTypeInfoCount,
365 HTMLTableCell_GetTypeInfo,
366 HTMLTableCell_GetIDsOfNames,
367 HTMLTableCell_Invoke,
368 HTMLTableCell_put_rowSpan,
369 HTMLTableCell_get_rowSpan,
370 HTMLTableCell_put_colSpan,
371 HTMLTableCell_get_colSpan,
372 HTMLTableCell_put_align,
373 HTMLTableCell_get_align,
374 HTMLTableCell_put_vAlign,
375 HTMLTableCell_get_vAlign,
376 HTMLTableCell_put_bgColor,
377 HTMLTableCell_get_bgColor,
378 HTMLTableCell_put_noWrap,
379 HTMLTableCell_get_noWrap,
380 HTMLTableCell_put_background,
381 HTMLTableCell_get_background,
382 HTMLTableCell_put_borderColor,
383 HTMLTableCell_get_borderColor,
384 HTMLTableCell_put_borderColorLight,
385 HTMLTableCell_get_borderColorLight,
386 HTMLTableCell_put_borderColorDark,
387 HTMLTableCell_get_borderColorDark,
388 HTMLTableCell_put_width,
389 HTMLTableCell_get_width,
390 HTMLTableCell_put_height,
391 HTMLTableCell_get_height,
392 HTMLTableCell_get_cellIndex
395 static inline HTMLTableCell *HTMLTableCell_from_DispatchEx(DispatchEx *iface)
397 return CONTAINING_RECORD(iface, HTMLTableCell, element.node.event_target.dispex);
400 static void *HTMLTableCell_query_interface(DispatchEx *dispex, REFIID riid)
402 HTMLTableCell *This = HTMLTableCell_from_DispatchEx(dispex);
404 if(IsEqualGUID(&IID_IHTMLTableCell, riid))
405 return &This->IHTMLTableCell_iface;
407 return HTMLElement_query_interface(&This->element.node.event_target.dispex, riid);
410 static void HTMLTableCell_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
412 HTMLTableCell *This = HTMLTableCell_from_DispatchEx(dispex);
413 HTMLElement_traverse(dispex, cb);
415 if(This->nscell)
416 note_cc_edge((nsISupports*)This->nscell, "nstablecell", cb);
419 static void HTMLTableCell_unlink(DispatchEx *dispex)
421 HTMLTableCell *This = HTMLTableCell_from_DispatchEx(dispex);
422 HTMLElement_unlink(dispex);
423 unlink_ref(&This->nscell);
426 static const NodeImplVtbl HTMLTableCellImplVtbl = {
427 .clsid = &CLSID_HTMLTableCell,
428 .cpc_entries = HTMLElement_cpc,
429 .clone = HTMLElement_clone,
430 .get_attr_col = HTMLElement_get_attr_col,
433 static const event_target_vtbl_t HTMLTableCell_event_target_vtbl = {
435 HTMLELEMENT_DISPEX_VTBL_ENTRIES,
436 .query_interface= HTMLTableCell_query_interface,
437 .destructor = HTMLElement_destructor,
438 .traverse = HTMLTableCell_traverse,
439 .unlink = HTMLTableCell_unlink
441 HTMLELEMENT_EVENT_TARGET_VTBL_ENTRIES,
442 .handle_event = HTMLElement_handle_event
445 static const tid_t HTMLTableCell_iface_tids[] = {
446 HTMLELEMENT_TIDS,
447 IHTMLTableCell_tid,
451 static dispex_static_data_t HTMLTableCell_dispex = {
452 "HTMLTableDataCellElement",
453 &HTMLTableCell_event_target_vtbl.dispex_vtbl,
454 DispHTMLTableCell_tid,
455 HTMLTableCell_iface_tids,
456 HTMLElement_init_dispex_info
459 HRESULT HTMLTableCell_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
461 HTMLTableCell *ret;
462 nsresult nsres;
464 ret = calloc(1, sizeof(*ret));
465 if(!ret)
466 return E_OUTOFMEMORY;
468 ret->IHTMLTableCell_iface.lpVtbl = &HTMLTableCellVtbl;
469 ret->element.node.vtbl = &HTMLTableCellImplVtbl;
471 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTableCell_dispex);
473 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLTableCellElement, (void**)&ret->nscell);
474 assert(nsres == NS_OK);
476 *elem = &ret->element;
477 return S_OK;
480 struct HTMLTableRow {
481 HTMLElement element;
483 IHTMLTableRow IHTMLTableRow_iface;
485 nsIDOMHTMLTableRowElement *nsrow;
488 static inline HTMLTableRow *impl_from_IHTMLTableRow(IHTMLTableRow *iface)
490 return CONTAINING_RECORD(iface, HTMLTableRow, IHTMLTableRow_iface);
493 DISPEX_IDISPATCH_IMPL(HTMLTableRow, IHTMLTableRow,
494 impl_from_IHTMLTableRow(iface)->element.node.event_target.dispex)
496 static HRESULT WINAPI HTMLTableRow_put_align(IHTMLTableRow *iface, BSTR v)
498 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
499 nsAString val;
500 nsresult nsres;
502 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
504 nsAString_InitDepend(&val, v);
506 nsres = nsIDOMHTMLTableRowElement_SetAlign(This->nsrow, &val);
507 nsAString_Finish(&val);
508 if (NS_FAILED(nsres)){
509 ERR("Set Align(%s) failed!\n", debugstr_w(v));
510 return E_FAIL;
512 return S_OK;
515 static HRESULT WINAPI HTMLTableRow_get_align(IHTMLTableRow *iface, BSTR *p)
517 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
518 nsAString val;
519 nsresult nsres;
521 TRACE("(%p)->(%p)\n", This, p);
523 nsAString_Init(&val, NULL);
524 nsres = nsIDOMHTMLTableRowElement_GetAlign(This->nsrow, &val);
526 return return_nsstr(nsres, &val, p);
529 static HRESULT WINAPI HTMLTableRow_put_vAlign(IHTMLTableRow *iface, BSTR v)
531 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
532 nsAString val;
533 nsresult nsres;
535 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
537 nsAString_InitDepend(&val, v);
539 nsres = nsIDOMHTMLTableRowElement_SetVAlign(This->nsrow, &val);
540 nsAString_Finish(&val);
542 if (NS_FAILED(nsres)){
543 ERR("Set VAlign(%s) failed!\n", debugstr_w(v));
544 return E_FAIL;
547 return S_OK;
550 static HRESULT WINAPI HTMLTableRow_get_vAlign(IHTMLTableRow *iface, BSTR *p)
552 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
553 nsAString val;
554 nsresult nsres;
556 TRACE("(%p)->(%p)\n", This, p);
558 nsAString_Init(&val, NULL);
559 nsres = nsIDOMHTMLTableRowElement_GetVAlign(This->nsrow, &val);
561 return return_nsstr(nsres, &val, p);
564 static HRESULT WINAPI HTMLTableRow_put_bgColor(IHTMLTableRow *iface, VARIANT v)
566 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
567 nsAString val;
568 nsresult nsres;
570 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
572 if (!variant_to_nscolor(&v, &val))
573 return S_OK;
575 nsres = nsIDOMHTMLTableRowElement_SetBgColor(This->nsrow, &val);
576 nsAString_Finish(&val);
578 if (NS_FAILED(nsres)){
579 ERR("Set BgColor(%s) failed!\n", debugstr_variant(&v));
580 return E_FAIL;
583 return S_OK;
586 static HRESULT WINAPI HTMLTableRow_get_bgColor(IHTMLTableRow *iface, VARIANT *p)
588 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
589 nsAString strColor;
590 nsresult nsres;
591 HRESULT hres;
592 const PRUnichar *color;
594 TRACE("(%p)->(%p)\n", This, p);
596 nsAString_Init(&strColor, NULL);
597 nsres = nsIDOMHTMLTableRowElement_GetBgColor(This->nsrow, &strColor);
599 if(NS_SUCCEEDED(nsres)) {
600 nsAString_GetData(&strColor, &color);
601 V_VT(p) = VT_BSTR;
602 hres = nscolor_to_str(color, &V_BSTR(p));
603 }else {
604 ERR("SetBgColor failed: %08lx\n", nsres);
605 hres = E_FAIL;
608 nsAString_Finish(&strColor);
609 return hres;
612 static HRESULT WINAPI HTMLTableRow_put_borderColor(IHTMLTableRow *iface, VARIANT v)
614 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
615 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
616 return E_NOTIMPL;
619 static HRESULT WINAPI HTMLTableRow_get_borderColor(IHTMLTableRow *iface, VARIANT *p)
621 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
622 FIXME("(%p)->(%p)\n", This, p);
623 return E_NOTIMPL;
626 static HRESULT WINAPI HTMLTableRow_put_borderColorLight(IHTMLTableRow *iface, VARIANT v)
628 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
629 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
630 return E_NOTIMPL;
633 static HRESULT WINAPI HTMLTableRow_get_borderColorLight(IHTMLTableRow *iface, VARIANT *p)
635 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
636 FIXME("(%p)->(%p)\n", This, p);
637 return E_NOTIMPL;
640 static HRESULT WINAPI HTMLTableRow_put_borderColorDark(IHTMLTableRow *iface, VARIANT v)
642 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
643 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
644 return E_NOTIMPL;
647 static HRESULT WINAPI HTMLTableRow_get_borderColorDark(IHTMLTableRow *iface, VARIANT *p)
649 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
650 FIXME("(%p)->(%p)\n", This, p);
651 return E_NOTIMPL;
654 static HRESULT WINAPI HTMLTableRow_get_rowIndex(IHTMLTableRow *iface, LONG *p)
656 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
657 nsresult nsres;
659 TRACE("(%p)->(%p)\n", This, p);
660 nsres = nsIDOMHTMLTableRowElement_GetRowIndex(This->nsrow, p);
661 if(NS_FAILED(nsres)) {
662 ERR("Get rowIndex failed: %08lx\n", nsres);
663 return E_FAIL;
665 return S_OK;
668 static HRESULT WINAPI HTMLTableRow_get_sectionRowIndex(IHTMLTableRow *iface, LONG *p)
670 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
671 nsresult nsres;
673 TRACE("(%p)->(%p)\n", This, p);
674 nsres = nsIDOMHTMLTableRowElement_GetSectionRowIndex(This->nsrow, p);
675 if(NS_FAILED(nsres)) {
676 ERR("Get selectionRowIndex failed: %08lx\n", nsres);
677 return E_FAIL;
679 return S_OK;
682 static HRESULT WINAPI HTMLTableRow_get_cells(IHTMLTableRow *iface, IHTMLElementCollection **p)
684 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
685 nsIDOMHTMLCollection *nscol;
686 nsresult nsres;
688 TRACE("(%p)->(%p)\n", This, p);
690 nsres = nsIDOMHTMLTableRowElement_GetCells(This->nsrow, &nscol);
691 if(NS_FAILED(nsres)) {
692 ERR("GetCells failed: %08lx\n", nsres);
693 return E_FAIL;
696 *p = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->element.node.event_target.dispex));
698 nsIDOMHTMLCollection_Release(nscol);
699 return S_OK;
702 static HRESULT WINAPI HTMLTableRow_insertCell(IHTMLTableRow *iface, LONG index, IDispatch **row)
704 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
705 nsIDOMHTMLElement *nselem;
706 HTMLElement *elem;
707 nsresult nsres;
708 HRESULT hres;
710 TRACE("(%p)->(%ld %p)\n", This, index, row);
711 nsres = nsIDOMHTMLTableRowElement_InsertCell(This->nsrow, index, &nselem);
712 if(NS_FAILED(nsres)) {
713 ERR("Insert Cell at %ld failed: %08lx\n", index, nsres);
714 return E_FAIL;
717 hres = HTMLTableCell_Create(This->element.node.doc, (nsIDOMElement*)nselem, &elem);
718 nsIDOMHTMLElement_Release(nselem);
719 if (FAILED(hres)) {
720 ERR("Create TableCell failed: %08lx\n", hres);
721 return hres;
724 *row = (IDispatch *)&elem->IHTMLElement_iface;
725 return S_OK;
728 static HRESULT WINAPI HTMLTableRow_deleteCell(IHTMLTableRow *iface, LONG index)
730 HTMLTableRow *This = impl_from_IHTMLTableRow(iface);
731 nsresult nsres;
733 TRACE("(%p)->(%ld)\n", This, index);
734 nsres = nsIDOMHTMLTableRowElement_DeleteCell(This->nsrow, index);
735 if(NS_FAILED(nsres)) {
736 ERR("Delete Cell failed: %08lx\n", nsres);
737 return E_FAIL;
739 return S_OK;
742 static const IHTMLTableRowVtbl HTMLTableRowVtbl = {
743 HTMLTableRow_QueryInterface,
744 HTMLTableRow_AddRef,
745 HTMLTableRow_Release,
746 HTMLTableRow_GetTypeInfoCount,
747 HTMLTableRow_GetTypeInfo,
748 HTMLTableRow_GetIDsOfNames,
749 HTMLTableRow_Invoke,
750 HTMLTableRow_put_align,
751 HTMLTableRow_get_align,
752 HTMLTableRow_put_vAlign,
753 HTMLTableRow_get_vAlign,
754 HTMLTableRow_put_bgColor,
755 HTMLTableRow_get_bgColor,
756 HTMLTableRow_put_borderColor,
757 HTMLTableRow_get_borderColor,
758 HTMLTableRow_put_borderColorLight,
759 HTMLTableRow_get_borderColorLight,
760 HTMLTableRow_put_borderColorDark,
761 HTMLTableRow_get_borderColorDark,
762 HTMLTableRow_get_rowIndex,
763 HTMLTableRow_get_sectionRowIndex,
764 HTMLTableRow_get_cells,
765 HTMLTableRow_insertCell,
766 HTMLTableRow_deleteCell
769 static inline HTMLTableRow *HTMLTableRow_from_DispatchEx(DispatchEx *iface)
771 return CONTAINING_RECORD(iface, HTMLTableRow, element.node.event_target.dispex);
774 static void *HTMLTableRow_query_interface(DispatchEx *dispex, REFIID riid)
776 HTMLTableRow *This = HTMLTableRow_from_DispatchEx(dispex);
778 if(IsEqualGUID(&IID_IHTMLTableRow, riid))
779 return &This->IHTMLTableRow_iface;
781 return HTMLElement_query_interface(&This->element.node.event_target.dispex, riid);
784 static void HTMLTableRow_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
786 HTMLTableRow *This = HTMLTableRow_from_DispatchEx(dispex);
787 HTMLElement_traverse(dispex, cb);
789 if(This->nsrow)
790 note_cc_edge((nsISupports*)This->nsrow, "nstablerow", cb);
793 static void HTMLTableRow_unlink(DispatchEx *dispex)
795 HTMLTableRow *This = HTMLTableRow_from_DispatchEx(dispex);
796 HTMLElement_unlink(dispex);
797 unlink_ref(&This->nsrow);
800 static const NodeImplVtbl HTMLTableRowImplVtbl = {
801 .clsid = &CLSID_HTMLTableRow,
802 .cpc_entries = HTMLElement_cpc,
803 .clone = HTMLElement_clone,
804 .get_attr_col = HTMLElement_get_attr_col,
807 static const event_target_vtbl_t HTMLTableRow_event_target_vtbl = {
809 HTMLELEMENT_DISPEX_VTBL_ENTRIES,
810 .query_interface= HTMLTableRow_query_interface,
811 .destructor = HTMLElement_destructor,
812 .traverse = HTMLTableRow_traverse,
813 .unlink = HTMLTableRow_unlink
815 HTMLELEMENT_EVENT_TARGET_VTBL_ENTRIES,
816 .handle_event = HTMLElement_handle_event
819 static const tid_t HTMLTableRow_iface_tids[] = {
820 HTMLELEMENT_TIDS,
821 IHTMLTableRow_tid,
825 static dispex_static_data_t HTMLTableRow_dispex = {
826 "HTMLTableRowElement",
827 &HTMLTableRow_event_target_vtbl.dispex_vtbl,
828 DispHTMLTableRow_tid,
829 HTMLTableRow_iface_tids,
830 HTMLElement_init_dispex_info
833 HRESULT HTMLTableRow_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
835 HTMLTableRow *ret;
836 nsresult nsres;
838 ret = calloc(1, sizeof(HTMLTableRow));
839 if(!ret)
840 return E_OUTOFMEMORY;
842 ret->IHTMLTableRow_iface.lpVtbl = &HTMLTableRowVtbl;
843 ret->element.node.vtbl = &HTMLTableRowImplVtbl;
845 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTableRow_dispex);
847 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLTableRowElement, (void**)&ret->nsrow);
848 assert(nsres == NS_OK);
850 *elem = &ret->element;
851 return S_OK;
854 struct HTMLTable {
855 HTMLElement element;
857 IHTMLTable IHTMLTable_iface;
858 IHTMLTable2 IHTMLTable2_iface;
859 IHTMLTable3 IHTMLTable3_iface;
861 nsIDOMHTMLTableElement *nstable;
864 static inline HTMLTable *impl_from_IHTMLTable(IHTMLTable *iface)
866 return CONTAINING_RECORD(iface, HTMLTable, IHTMLTable_iface);
869 static inline HTMLTable *impl_from_IHTMLTable2(IHTMLTable2 *iface)
871 return CONTAINING_RECORD(iface, HTMLTable, IHTMLTable2_iface);
874 static inline HTMLTable *impl_from_IHTMLTable3(IHTMLTable3 *iface)
876 return CONTAINING_RECORD(iface, HTMLTable, IHTMLTable3_iface);
879 static HRESULT var2str(const VARIANT *p, nsAString *nsstr)
881 BSTR str;
882 BOOL ret;
883 HRESULT hres;
885 switch(V_VT(p)) {
886 case VT_BSTR:
887 return nsAString_Init(nsstr, V_BSTR(p))?
888 S_OK : E_OUTOFMEMORY;
889 case VT_R8:
890 hres = VarBstrFromR8(V_R8(p), MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, &str);
891 break;
892 case VT_R4:
893 hres = VarBstrFromR4(V_R4(p), MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, &str);
894 break;
895 case VT_I4:
896 hres = VarBstrFromI4(V_I4(p), MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT), 0, &str);
897 break;
898 default:
899 FIXME("unsupported arg %s\n", debugstr_variant(p));
900 return E_NOTIMPL;
902 if (FAILED(hres))
903 return hres;
905 ret = nsAString_Init(nsstr, str);
906 SysFreeString(str);
907 return ret ? S_OK : E_OUTOFMEMORY;
910 DISPEX_IDISPATCH_IMPL(HTMLTable, IHTMLTable, impl_from_IHTMLTable(iface)->element.node.event_target.dispex)
912 static HRESULT WINAPI HTMLTable_put_cols(IHTMLTable *iface, LONG v)
914 HTMLTable *This = impl_from_IHTMLTable(iface);
915 FIXME("(%p)->(%ld)\n", This, v);
916 return E_NOTIMPL;
919 static HRESULT WINAPI HTMLTable_get_cols(IHTMLTable *iface, LONG *p)
921 HTMLTable *This = impl_from_IHTMLTable(iface);
922 FIXME("(%p)->(%p)\n", This, p);
923 return E_NOTIMPL;
926 static HRESULT WINAPI HTMLTable_put_border(IHTMLTable *iface, VARIANT v)
928 HTMLTable *This = impl_from_IHTMLTable(iface);
929 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
930 return E_NOTIMPL;
933 static HRESULT WINAPI HTMLTable_get_border(IHTMLTable *iface, VARIANT *p)
935 HTMLTable *This = impl_from_IHTMLTable(iface);
936 FIXME("(%p)->(%p)\n", This, p);
937 return E_NOTIMPL;
940 static HRESULT WINAPI HTMLTable_put_frame(IHTMLTable *iface, BSTR v)
942 HTMLTable *This = impl_from_IHTMLTable(iface);
943 nsAString str;
944 nsresult nsres;
946 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
948 nsAString_InitDepend(&str, v);
949 nsres = nsIDOMHTMLTableElement_SetFrame(This->nstable, &str);
950 nsAString_Finish(&str);
952 if (NS_FAILED(nsres)) {
953 ERR("SetFrame(%s) failed: %08lx\n", debugstr_w(v), nsres);
954 return E_FAIL;
956 return S_OK;
959 static HRESULT WINAPI HTMLTable_get_frame(IHTMLTable *iface, BSTR *p)
961 HTMLTable *This = impl_from_IHTMLTable(iface);
962 nsAString str;
963 nsresult nsres;
965 TRACE("(%p)->(%p)\n", This, p);
967 nsAString_Init(&str, NULL);
968 nsres = nsIDOMHTMLTableElement_GetFrame(This->nstable, &str);
970 return return_nsstr(nsres, &str, p);
973 static HRESULT WINAPI HTMLTable_put_rules(IHTMLTable *iface, BSTR v)
975 HTMLTable *This = impl_from_IHTMLTable(iface);
976 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
977 return E_NOTIMPL;
980 static HRESULT WINAPI HTMLTable_get_rules(IHTMLTable *iface, BSTR *p)
982 HTMLTable *This = impl_from_IHTMLTable(iface);
983 FIXME("(%p)->(%p)\n", This, p);
984 return E_NOTIMPL;
987 static HRESULT WINAPI HTMLTable_put_cellSpacing(IHTMLTable *iface, VARIANT v)
989 HTMLTable *This = impl_from_IHTMLTable(iface);
990 nsAString nsstr;
991 WCHAR buf[64];
992 nsresult nsres;
994 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
996 switch(V_VT(&v)) {
997 case VT_BSTR:
998 nsAString_InitDepend(&nsstr, V_BSTR(&v));
999 break;
1000 case VT_I4: {
1001 swprintf(buf, ARRAY_SIZE(buf), L"%d", V_I4(&v));
1002 nsAString_InitDepend(&nsstr, buf);
1003 break;
1005 default:
1006 FIXME("unsupported arg %s\n", debugstr_variant(&v));
1007 return E_NOTIMPL;
1010 nsres = nsIDOMHTMLTableElement_SetCellSpacing(This->nstable, &nsstr);
1011 nsAString_Finish(&nsstr);
1012 if(NS_FAILED(nsres)) {
1013 ERR("SetCellSpacing failed: %08lx\n", nsres);
1014 return E_FAIL;
1017 return S_OK;
1020 static HRESULT WINAPI HTMLTable_get_cellSpacing(IHTMLTable *iface, VARIANT *p)
1022 HTMLTable *This = impl_from_IHTMLTable(iface);
1023 nsAString nsstr;
1024 nsresult nsres;
1026 TRACE("(%p)->(%p)\n", This, p);
1028 nsAString_Init(&nsstr, NULL);
1029 nsres = nsIDOMHTMLTableElement_GetCellSpacing(This->nstable, &nsstr);
1030 V_VT(p) = VT_BSTR;
1031 return return_nsstr(nsres, &nsstr, &V_BSTR(p));
1034 static HRESULT WINAPI HTMLTable_put_cellPadding(IHTMLTable *iface, VARIANT v)
1036 HTMLTable *This = impl_from_IHTMLTable(iface);
1037 nsAString val;
1038 HRESULT hres;
1039 nsresult nsres;
1041 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1043 hres = var2str(&v, &val);
1044 if(FAILED(hres))
1045 return hres;
1047 nsres = nsIDOMHTMLTableElement_SetCellPadding(This->nstable, &val);
1048 nsAString_Finish(&val);
1049 if(NS_FAILED(nsres)) {
1050 ERR("Set Width(%s) failed, err = %08lx\n", debugstr_variant(&v), nsres);
1051 return E_FAIL;
1054 return S_OK;
1057 static HRESULT WINAPI HTMLTable_get_cellPadding(IHTMLTable *iface, VARIANT *p)
1059 HTMLTable *This = impl_from_IHTMLTable(iface);
1060 nsAString val;
1061 nsresult nsres;
1063 TRACE("(%p)->(%p)\n", This, p);
1065 nsAString_Init(&val, NULL);
1066 nsres = nsIDOMHTMLTableElement_GetCellPadding(This->nstable, &val);
1067 return return_nsstr_variant(nsres, &val, 0, p);
1070 static HRESULT WINAPI HTMLTable_put_background(IHTMLTable *iface, BSTR v)
1072 HTMLTable *This = impl_from_IHTMLTable(iface);
1073 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
1074 return E_NOTIMPL;
1077 static HRESULT WINAPI HTMLTable_get_background(IHTMLTable *iface, BSTR *p)
1079 HTMLTable *This = impl_from_IHTMLTable(iface);
1080 FIXME("(%p)->(%p)\n", This, p);
1081 return E_NOTIMPL;
1084 static HRESULT WINAPI HTMLTable_put_bgColor(IHTMLTable *iface, VARIANT v)
1086 HTMLTable *This = impl_from_IHTMLTable(iface);
1087 nsAString val;
1088 nsresult nsres;
1090 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1092 if(!variant_to_nscolor(&v, &val))
1093 return S_OK;
1095 nsres = nsIDOMHTMLTableElement_SetBgColor(This->nstable, &val);
1096 nsAString_Finish(&val);
1097 if (NS_FAILED(nsres)){
1098 ERR("Set BgColor(%s) failed!\n", debugstr_variant(&v));
1099 return E_FAIL;
1102 return S_OK;
1105 static HRESULT WINAPI HTMLTable_get_bgColor(IHTMLTable *iface, VARIANT *p)
1107 HTMLTable *This = impl_from_IHTMLTable(iface);
1108 nsAString strColor;
1109 nsresult nsres;
1110 HRESULT hres;
1111 const PRUnichar *color;
1113 TRACE("(%p)->(%p)\n", This, p);
1115 nsAString_Init(&strColor, NULL);
1116 nsres = nsIDOMHTMLTableElement_GetBgColor(This->nstable, &strColor);
1118 if(NS_SUCCEEDED(nsres)) {
1119 nsAString_GetData(&strColor, &color);
1120 V_VT(p) = VT_BSTR;
1121 hres = nscolor_to_str(color, &V_BSTR(p));
1122 }else {
1123 ERR("SetBgColor failed: %08lx\n", nsres);
1124 hres = E_FAIL;
1127 nsAString_Finish(&strColor);
1128 return hres;
1131 static HRESULT WINAPI HTMLTable_put_borderColor(IHTMLTable *iface, VARIANT v)
1133 HTMLTable *This = impl_from_IHTMLTable(iface);
1134 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1135 return E_NOTIMPL;
1138 static HRESULT WINAPI HTMLTable_get_borderColor(IHTMLTable *iface, VARIANT *p)
1140 HTMLTable *This = impl_from_IHTMLTable(iface);
1141 FIXME("(%p)->(%p)\n", This, p);
1142 return E_NOTIMPL;
1145 static HRESULT WINAPI HTMLTable_put_borderColorLight(IHTMLTable *iface, VARIANT v)
1147 HTMLTable *This = impl_from_IHTMLTable(iface);
1148 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1149 return E_NOTIMPL;
1152 static HRESULT WINAPI HTMLTable_get_borderColorLight(IHTMLTable *iface, VARIANT *p)
1154 HTMLTable *This = impl_from_IHTMLTable(iface);
1155 FIXME("(%p)->(%p)\n", This, p);
1156 return E_NOTIMPL;
1159 static HRESULT WINAPI HTMLTable_put_borderColorDark(IHTMLTable *iface, VARIANT v)
1161 HTMLTable *This = impl_from_IHTMLTable(iface);
1162 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1163 return E_NOTIMPL;
1166 static HRESULT WINAPI HTMLTable_get_borderColorDark(IHTMLTable *iface, VARIANT *p)
1168 HTMLTable *This = impl_from_IHTMLTable(iface);
1169 FIXME("(%p)->(%p)\n", This, p);
1170 return E_NOTIMPL;
1173 static HRESULT WINAPI HTMLTable_put_align(IHTMLTable *iface, BSTR v)
1175 HTMLTable *This = impl_from_IHTMLTable(iface);
1176 nsAString val;
1177 nsresult nsres;
1179 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1181 nsAString_InitDepend(&val, v);
1183 nsres = nsIDOMHTMLTableElement_SetAlign(This->nstable, &val);
1184 nsAString_Finish(&val);
1185 if (NS_FAILED(nsres)){
1186 ERR("Set Align(%s) failed!\n", debugstr_w(v));
1187 return E_FAIL;
1189 return S_OK;
1192 static HRESULT WINAPI HTMLTable_get_align(IHTMLTable *iface, BSTR *p)
1194 HTMLTable *This = impl_from_IHTMLTable(iface);
1195 nsAString val;
1196 nsresult nsres;
1198 TRACE("(%p)->(%p)\n", This, p);
1200 nsAString_Init(&val, NULL);
1201 nsres = nsIDOMHTMLTableElement_GetAlign(This->nstable, &val);
1203 return return_nsstr(nsres, &val, p);
1206 static HRESULT WINAPI HTMLTable_refresh(IHTMLTable *iface)
1208 HTMLTable *This = impl_from_IHTMLTable(iface);
1209 FIXME("(%p)\n", This);
1210 return E_NOTIMPL;
1213 static HRESULT WINAPI HTMLTable_get_rows(IHTMLTable *iface, IHTMLElementCollection **p)
1215 HTMLTable *This = impl_from_IHTMLTable(iface);
1216 nsIDOMHTMLCollection *nscol;
1217 nsresult nsres;
1219 TRACE("(%p)->(%p)\n", This, p);
1221 nsres = nsIDOMHTMLTableElement_GetRows(This->nstable, &nscol);
1222 if(NS_FAILED(nsres)) {
1223 ERR("GetRows failed: %08lx\n", nsres);
1224 return E_FAIL;
1227 *p = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->element.node.event_target.dispex));
1229 nsIDOMHTMLCollection_Release(nscol);
1230 return S_OK;
1233 static HRESULT WINAPI HTMLTable_put_width(IHTMLTable *iface, VARIANT v)
1235 HTMLTable *This = impl_from_IHTMLTable(iface);
1236 nsAString val;
1237 HRESULT hres;
1238 nsresult nsres;
1240 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1241 hres = var2str(&v, &val);
1243 if (FAILED(hres)){
1244 ERR("Set Width(%s) failed when initializing a nsAString, err = %08lx\n",
1245 debugstr_variant(&v), hres);
1246 return hres;
1249 nsres = nsIDOMHTMLTableElement_SetWidth(This->nstable, &val);
1250 nsAString_Finish(&val);
1252 if (NS_FAILED(nsres)){
1253 ERR("Set Width(%s) failed, err = %08lx\n", debugstr_variant(&v), nsres);
1254 return E_FAIL;
1256 return S_OK;
1259 static HRESULT WINAPI HTMLTable_get_width(IHTMLTable *iface, VARIANT *p)
1261 HTMLTable *This = impl_from_IHTMLTable(iface);
1262 nsAString val;
1263 nsresult nsres;
1265 TRACE("(%p)->(%p)\n", This, p);
1267 nsAString_Init(&val, NULL);
1268 nsres = nsIDOMHTMLTableElement_GetWidth(This->nstable, &val);
1269 return return_nsstr_variant(nsres, &val, NSSTR_IMPLICIT_PX, p);
1272 static HRESULT WINAPI HTMLTable_put_height(IHTMLTable *iface, VARIANT v)
1274 HTMLTable *This = impl_from_IHTMLTable(iface);
1275 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1276 return E_NOTIMPL;
1279 static HRESULT WINAPI HTMLTable_get_height(IHTMLTable *iface, VARIANT *p)
1281 HTMLTable *This = impl_from_IHTMLTable(iface);
1282 FIXME("(%p)->(%p)\n", This, p);
1283 return E_NOTIMPL;
1286 static HRESULT WINAPI HTMLTable_put_dataPageSize(IHTMLTable *iface, LONG v)
1288 HTMLTable *This = impl_from_IHTMLTable(iface);
1289 FIXME("(%p)->(%ld)\n", This, v);
1290 return E_NOTIMPL;
1293 static HRESULT WINAPI HTMLTable_get_dataPageSize(IHTMLTable *iface, LONG *p)
1295 HTMLTable *This = impl_from_IHTMLTable(iface);
1296 FIXME("(%p)->(%p)\n", This, p);
1297 return E_NOTIMPL;
1300 static HRESULT WINAPI HTMLTable_nextPage(IHTMLTable *iface)
1302 HTMLTable *This = impl_from_IHTMLTable(iface);
1303 FIXME("(%p)\n", This);
1304 return E_NOTIMPL;
1307 static HRESULT WINAPI HTMLTable_previousPage(IHTMLTable *iface)
1309 HTMLTable *This = impl_from_IHTMLTable(iface);
1310 FIXME("(%p)\n", This);
1311 return E_NOTIMPL;
1314 static HRESULT WINAPI HTMLTable_get_tHead(IHTMLTable *iface, IHTMLTableSection **p)
1316 HTMLTable *This = impl_from_IHTMLTable(iface);
1317 FIXME("(%p)->(%p)\n", This, p);
1318 return E_NOTIMPL;
1321 static HRESULT WINAPI HTMLTable_get_tFoot(IHTMLTable *iface, IHTMLTableSection **p)
1323 HTMLTable *This = impl_from_IHTMLTable(iface);
1324 FIXME("(%p)->(%p)\n", This, p);
1325 return E_NOTIMPL;
1328 static HRESULT WINAPI HTMLTable_get_tBodies(IHTMLTable *iface, IHTMLElementCollection **p)
1330 HTMLTable *This = impl_from_IHTMLTable(iface);
1331 nsIDOMHTMLCollection *nscol = NULL;
1332 nsresult nsres;
1334 TRACE("(%p)->(%p)\n", This, p);
1336 nsres = nsIDOMHTMLTableElement_GetTBodies(This->nstable, &nscol);
1337 if(NS_FAILED(nsres)) {
1338 ERR("GetTBodies failed: %08lx\n", nsres);
1339 return E_FAIL;
1342 *p = create_collection_from_htmlcol(nscol, dispex_compat_mode(&This->element.node.event_target.dispex));
1344 nsIDOMHTMLCollection_Release(nscol);
1345 return S_OK;
1348 static HRESULT WINAPI HTMLTable_get_caption(IHTMLTable *iface, IHTMLTableCaption **p)
1350 HTMLTable *This = impl_from_IHTMLTable(iface);
1351 FIXME("(%p)->(%p)\n", This, p);
1352 return E_NOTIMPL;
1355 static HRESULT WINAPI HTMLTable_createTHead(IHTMLTable *iface, IDispatch **head)
1357 HTMLTable *This = impl_from_IHTMLTable(iface);
1358 FIXME("(%p)->(%p)\n", This, head);
1359 return E_NOTIMPL;
1362 static HRESULT WINAPI HTMLTable_deleteTHead(IHTMLTable *iface)
1364 HTMLTable *This = impl_from_IHTMLTable(iface);
1365 FIXME("(%p)\n", This);
1366 return E_NOTIMPL;
1369 static HRESULT WINAPI HTMLTable_createTFoot(IHTMLTable *iface, IDispatch **foot)
1371 HTMLTable *This = impl_from_IHTMLTable(iface);
1372 FIXME("(%p)->(%p)\n", This, foot);
1373 return E_NOTIMPL;
1376 static HRESULT WINAPI HTMLTable_deleteTFoot(IHTMLTable *iface)
1378 HTMLTable *This = impl_from_IHTMLTable(iface);
1379 FIXME("(%p)\n", This);
1380 return E_NOTIMPL;
1383 static HRESULT WINAPI HTMLTable_createCaption(IHTMLTable *iface, IHTMLTableCaption **caption)
1385 HTMLTable *This = impl_from_IHTMLTable(iface);
1386 FIXME("(%p)->(%p)\n", This, caption);
1387 return E_NOTIMPL;
1390 static HRESULT WINAPI HTMLTable_deleteCaption(IHTMLTable *iface)
1392 HTMLTable *This = impl_from_IHTMLTable(iface);
1393 FIXME("(%p)\n", This);
1394 return E_NOTIMPL;
1397 static HRESULT WINAPI HTMLTable_insertRow(IHTMLTable *iface, LONG index, IDispatch **row)
1399 HTMLTable *This = impl_from_IHTMLTable(iface);
1400 nsIDOMHTMLElement *nselem;
1401 HTMLElement *elem;
1402 nsresult nsres;
1403 HRESULT hres;
1405 TRACE("(%p)->(%ld %p)\n", This, index, row);
1406 nsres = nsIDOMHTMLTableElement_InsertRow(This->nstable, index, &nselem);
1407 if(NS_FAILED(nsres)) {
1408 ERR("Insert Row at %ld failed: %08lx\n", index, nsres);
1409 return E_FAIL;
1412 hres = HTMLTableRow_Create(This->element.node.doc, (nsIDOMElement*)nselem, &elem);
1413 nsIDOMHTMLElement_Release(nselem);
1414 if (FAILED(hres)) {
1415 ERR("Create TableRow failed: %08lx\n", hres);
1416 return hres;
1419 *row = (IDispatch *)&elem->IHTMLElement_iface;
1420 return S_OK;
1423 static HRESULT WINAPI HTMLTable_deleteRow(IHTMLTable *iface, LONG index)
1425 HTMLTable *This = impl_from_IHTMLTable(iface);
1426 nsresult nsres;
1428 TRACE("(%p)->(%ld)\n", This, index);
1429 nsres = nsIDOMHTMLTableElement_DeleteRow(This->nstable, index);
1430 if(NS_FAILED(nsres)) {
1431 ERR("Delete Row failed: %08lx\n", nsres);
1432 return E_FAIL;
1434 return S_OK;
1437 static HRESULT WINAPI HTMLTable_get_readyState(IHTMLTable *iface, BSTR *p)
1439 HTMLTable *This = impl_from_IHTMLTable(iface);
1440 FIXME("(%p)->(%p)\n", This, p);
1441 return E_NOTIMPL;
1444 static HRESULT WINAPI HTMLTable_put_onreadystatechange(IHTMLTable *iface, VARIANT v)
1446 HTMLTable *This = impl_from_IHTMLTable(iface);
1447 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1448 return E_NOTIMPL;
1451 static HRESULT WINAPI HTMLTable_get_onreadystatechange(IHTMLTable *iface, VARIANT *p)
1453 HTMLTable *This = impl_from_IHTMLTable(iface);
1454 FIXME("(%p)->(%p)\n", This, p);
1455 return E_NOTIMPL;
1458 static const IHTMLTableVtbl HTMLTableVtbl = {
1459 HTMLTable_QueryInterface,
1460 HTMLTable_AddRef,
1461 HTMLTable_Release,
1462 HTMLTable_GetTypeInfoCount,
1463 HTMLTable_GetTypeInfo,
1464 HTMLTable_GetIDsOfNames,
1465 HTMLTable_Invoke,
1466 HTMLTable_put_cols,
1467 HTMLTable_get_cols,
1468 HTMLTable_put_border,
1469 HTMLTable_get_border,
1470 HTMLTable_put_frame,
1471 HTMLTable_get_frame,
1472 HTMLTable_put_rules,
1473 HTMLTable_get_rules,
1474 HTMLTable_put_cellSpacing,
1475 HTMLTable_get_cellSpacing,
1476 HTMLTable_put_cellPadding,
1477 HTMLTable_get_cellPadding,
1478 HTMLTable_put_background,
1479 HTMLTable_get_background,
1480 HTMLTable_put_bgColor,
1481 HTMLTable_get_bgColor,
1482 HTMLTable_put_borderColor,
1483 HTMLTable_get_borderColor,
1484 HTMLTable_put_borderColorLight,
1485 HTMLTable_get_borderColorLight,
1486 HTMLTable_put_borderColorDark,
1487 HTMLTable_get_borderColorDark,
1488 HTMLTable_put_align,
1489 HTMLTable_get_align,
1490 HTMLTable_refresh,
1491 HTMLTable_get_rows,
1492 HTMLTable_put_width,
1493 HTMLTable_get_width,
1494 HTMLTable_put_height,
1495 HTMLTable_get_height,
1496 HTMLTable_put_dataPageSize,
1497 HTMLTable_get_dataPageSize,
1498 HTMLTable_nextPage,
1499 HTMLTable_previousPage,
1500 HTMLTable_get_tHead,
1501 HTMLTable_get_tFoot,
1502 HTMLTable_get_tBodies,
1503 HTMLTable_get_caption,
1504 HTMLTable_createTHead,
1505 HTMLTable_deleteTHead,
1506 HTMLTable_createTFoot,
1507 HTMLTable_deleteTFoot,
1508 HTMLTable_createCaption,
1509 HTMLTable_deleteCaption,
1510 HTMLTable_insertRow,
1511 HTMLTable_deleteRow,
1512 HTMLTable_get_readyState,
1513 HTMLTable_put_onreadystatechange,
1514 HTMLTable_get_onreadystatechange
1517 DISPEX_IDISPATCH_IMPL(HTMLTable2, IHTMLTable2, impl_from_IHTMLTable2(iface)->element.node.event_target.dispex)
1519 static HRESULT WINAPI HTMLTable2_firstPage(IHTMLTable2 *iface)
1521 HTMLTable *This = impl_from_IHTMLTable2(iface);
1522 FIXME("(%p)->()\n", This);
1523 return E_NOTIMPL;
1526 static HRESULT WINAPI HTMLTable2_lastPage(IHTMLTable2 *iface)
1528 HTMLTable *This = impl_from_IHTMLTable2(iface);
1529 FIXME("(%p)->()\n", This);
1530 return E_NOTIMPL;
1533 static HRESULT WINAPI HTMLTable2_cells(IHTMLTable2 *iface, IHTMLElementCollection **p)
1535 HTMLTable *This = impl_from_IHTMLTable2(iface);
1536 FIXME("(%p)->(%p)\n", This, p);
1537 return E_NOTIMPL;
1540 static HRESULT WINAPI HTMLTable2_moveRow(IHTMLTable2 *iface, LONG indexFrom, LONG indexTo, IDispatch **row)
1542 HTMLTable *This = impl_from_IHTMLTable2(iface);
1543 FIXME("(%p)->(%ld %ld %p)\n", This, indexFrom, indexTo, row);
1544 return E_NOTIMPL;
1548 static const IHTMLTable2Vtbl HTMLTable2Vtbl = {
1549 HTMLTable2_QueryInterface,
1550 HTMLTable2_AddRef,
1551 HTMLTable2_Release,
1552 HTMLTable2_GetTypeInfoCount,
1553 HTMLTable2_GetTypeInfo,
1554 HTMLTable2_GetIDsOfNames,
1555 HTMLTable2_Invoke,
1556 HTMLTable2_firstPage,
1557 HTMLTable2_lastPage,
1558 HTMLTable2_cells,
1559 HTMLTable2_moveRow
1562 DISPEX_IDISPATCH_IMPL(HTMLTable3, IHTMLTable3, impl_from_IHTMLTable3(iface)->element.node.event_target.dispex)
1564 static HRESULT WINAPI HTMLTable3_put_summary(IHTMLTable3 *iface, BSTR v)
1566 HTMLTable *This = impl_from_IHTMLTable3(iface);
1567 nsAString str;
1568 nsresult nsres;
1570 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
1572 nsAString_InitDepend(&str, v);
1574 nsres = nsIDOMHTMLTableElement_SetSummary(This->nstable, &str);
1576 nsAString_Finish(&str);
1577 if (NS_FAILED(nsres)) {
1578 ERR("Set summary(%s) failed: %08lx\n", debugstr_w(v), nsres);
1579 return E_FAIL;
1581 return S_OK;
1584 static HRESULT WINAPI HTMLTable3_get_summary(IHTMLTable3 *iface, BSTR * p)
1586 HTMLTable *This = impl_from_IHTMLTable3(iface);
1587 nsAString str;
1588 nsresult nsres;
1590 TRACE("(%p)->(%p)\n", This, p);
1592 nsAString_Init(&str, NULL);
1593 nsres = nsIDOMHTMLTableElement_GetSummary(This->nstable, &str);
1595 return return_nsstr(nsres, &str, p);
1598 static const IHTMLTable3Vtbl HTMLTable3Vtbl = {
1599 HTMLTable3_QueryInterface,
1600 HTMLTable3_AddRef,
1601 HTMLTable3_Release,
1602 HTMLTable3_GetTypeInfoCount,
1603 HTMLTable3_GetTypeInfo,
1604 HTMLTable3_GetIDsOfNames,
1605 HTMLTable3_Invoke,
1606 HTMLTable3_put_summary,
1607 HTMLTable3_get_summary
1610 static inline HTMLTable *impl_from_DispatchEx(DispatchEx *iface)
1612 return CONTAINING_RECORD(iface, HTMLTable, element.node.event_target.dispex);
1615 static void *HTMLTable_query_interface(DispatchEx *dispex, REFIID riid)
1617 HTMLTable *This = impl_from_DispatchEx(dispex);
1619 if(IsEqualGUID(&IID_IHTMLTable, riid))
1620 return &This->IHTMLTable_iface;
1621 if(IsEqualGUID(&IID_IHTMLTable2, riid))
1622 return &This->IHTMLTable2_iface;
1623 if(IsEqualGUID(&IID_IHTMLTable3, riid))
1624 return &This->IHTMLTable3_iface;
1626 return HTMLElement_query_interface(&This->element.node.event_target.dispex, riid);
1629 static void HTMLTable_traverse(DispatchEx *dispex, nsCycleCollectionTraversalCallback *cb)
1631 HTMLTable *This = impl_from_DispatchEx(dispex);
1632 HTMLElement_traverse(dispex, cb);
1634 if(This->nstable)
1635 note_cc_edge((nsISupports*)This->nstable, "nstable", cb);
1638 static void HTMLTable_unlink(DispatchEx *dispex)
1640 HTMLTable *This = impl_from_DispatchEx(dispex);
1641 HTMLElement_unlink(dispex);
1642 unlink_ref(&This->nstable);
1645 static const cpc_entry_t HTMLTable_cpc[] = {
1646 {&DIID_HTMLTableEvents},
1647 HTMLELEMENT_CPC,
1648 {NULL}
1651 static const NodeImplVtbl HTMLTableImplVtbl = {
1652 .clsid = &CLSID_HTMLTable,
1653 .cpc_entries = HTMLTable_cpc,
1654 .clone = HTMLElement_clone,
1655 .get_attr_col = HTMLElement_get_attr_col,
1658 static const event_target_vtbl_t HTMLTable_event_target_vtbl = {
1660 HTMLELEMENT_DISPEX_VTBL_ENTRIES,
1661 .query_interface= HTMLTable_query_interface,
1662 .destructor = HTMLElement_destructor,
1663 .traverse = HTMLTable_traverse,
1664 .unlink = HTMLTable_unlink
1666 HTMLELEMENT_EVENT_TARGET_VTBL_ENTRIES,
1667 .handle_event = HTMLElement_handle_event
1670 static const tid_t HTMLTable_iface_tids[] = {
1671 HTMLELEMENT_TIDS,
1672 IHTMLTable_tid,
1673 IHTMLTable2_tid,
1674 IHTMLTable3_tid,
1678 static dispex_static_data_t HTMLTable_dispex = {
1679 "HTMLTableElement",
1680 &HTMLTable_event_target_vtbl.dispex_vtbl,
1681 DispHTMLTable_tid,
1682 HTMLTable_iface_tids,
1683 HTMLElement_init_dispex_info
1686 HRESULT HTMLTable_Create(HTMLDocumentNode *doc, nsIDOMElement *nselem, HTMLElement **elem)
1688 HTMLTable *ret;
1689 nsresult nsres;
1691 ret = calloc(1, sizeof(HTMLTable));
1692 if(!ret)
1693 return E_OUTOFMEMORY;
1695 ret->element.node.vtbl = &HTMLTableImplVtbl;
1696 ret->IHTMLTable_iface.lpVtbl = &HTMLTableVtbl;
1697 ret->IHTMLTable2_iface.lpVtbl = &HTMLTable2Vtbl;
1698 ret->IHTMLTable3_iface.lpVtbl = &HTMLTable3Vtbl;
1700 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTable_dispex);
1702 nsres = nsIDOMElement_QueryInterface(nselem, &IID_nsIDOMHTMLTableElement, (void**)&ret->nstable);
1703 assert(nsres == NS_OK);
1705 *elem = &ret->element;
1706 return S_OK;