int HTMLTableRowElement::rowIndex() const { ContainerNode* table = parentNode(); if (!table) return -1; table = table->parentNode(); if (!isHTMLTableElement(table)) return -1; // To match Firefox, the row indices work like this: // Rows from the first <thead> are numbered before all <tbody> rows. // Rows from the first <tfoot> are numbered after all <tbody> rows. // Rows from other <thead> and <tfoot> elements don't get row indices at all. int rIndex = 0; if (HTMLTableSectionElement* head = toHTMLTableElement(table)->tHead()) { for (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::firstChild(*head); row; row = Traversal<HTMLTableRowElement>::nextSibling(*row)) { if (row == this) return rIndex; ++rIndex; } } for (Element* child = ElementTraversal::firstWithin(*table); child; child = ElementTraversal::nextSibling(*child)) { if (child->hasTagName(tbodyTag)) { HTMLTableSectionElement* section = toHTMLTableSectionElement(child); for (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::firstChild(*section); row; row = Traversal<HTMLTableRowElement>::nextSibling(*row)) { if (row == this) return rIndex; ++rIndex; } } } if (HTMLTableSectionElement* foot = toHTMLTableElement(table)->tFoot()) { for (HTMLTableRowElement* row = Traversal<HTMLTableRowElement>::firstChild(*foot); row; row = Traversal<HTMLTableRowElement>::nextSibling(*row)) { if (row == this) return rIndex; ++rIndex; } } // We get here for rows that are in <thead> or <tfoot> sections other than the main header and footer. return -1; }
void JSHTMLTableElement::putValueProperty(ExecState* exec, int token, JSValue* value) { switch (token) { case CaptionAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); ExceptionCode ec = 0; imp->setCaption(toHTMLTableCaptionElement(value), ec); setDOMException(exec, ec); break; } case THeadAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); ExceptionCode ec = 0; imp->setTHead(toHTMLTableSectionElement(value), ec); setDOMException(exec, ec); break; } case TFootAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); ExceptionCode ec = 0; imp->setTFoot(toHTMLTableSectionElement(value), ec); setDOMException(exec, ec); break; } case AlignAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); imp->setAlign(valueToStringWithNullCheck(exec, value)); break; } case BgColorAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); imp->setBgColor(valueToStringWithNullCheck(exec, value)); break; } case BorderAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); imp->setBorder(valueToStringWithNullCheck(exec, value)); break; } case CellPaddingAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); imp->setCellPadding(valueToStringWithNullCheck(exec, value)); break; } case CellSpacingAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); imp->setCellSpacing(valueToStringWithNullCheck(exec, value)); break; } case FrameAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); imp->setFrame(valueToStringWithNullCheck(exec, value)); break; } case RulesAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); imp->setRules(valueToStringWithNullCheck(exec, value)); break; } case SummaryAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); imp->setSummary(valueToStringWithNullCheck(exec, value)); break; } case WidthAttrNum: { HTMLTableElement* imp = static_cast<HTMLTableElement*>(impl()); imp->setWidth(valueToStringWithNullCheck(exec, value)); break; } } }
HTMLTableSectionElement* HTMLTableElement::tFoot() const { return toHTMLTableSectionElement(Traversal<HTMLElement>::firstChild(*this, HasHTMLTagName(tfootTag))); }
HTMLTableSectionElement* HTMLTableElement::lastBody() const { return toHTMLTableSectionElement(Traversal<HTMLElement>::lastChild(*this, HasHTMLTagName(tbodyTag))); }