JSValue jsHTMLTableSectionElementRows(ExecState* exec, const Identifier&, const PropertySlot& slot) { JSHTMLTableSectionElement* castedThis = static_cast<JSHTMLTableSectionElement*>(asObject(slot.slotBase())); UNUSED_PARAM(exec); HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(castedThis->impl()); return toJS(exec, castedThis->globalObject(), WTF::getPtr(imp->rows())); }
JSValue* JSHTMLTableSectionElement::getValueProperty(ExecState* exec, int token) const { switch (token) { case AlignAttrNum: { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(impl()); return jsString(exec, imp->align()); } case ChAttrNum: { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(impl()); return jsString(exec, imp->ch()); } case ChOffAttrNum: { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(impl()); return jsString(exec, imp->chOff()); } case VAlignAttrNum: { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(impl()); return jsString(exec, imp->vAlign()); } case RowsAttrNum: { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(impl()); return toJS(exec, WTF::getPtr(imp->rows())); } case ConstructorAttrNum: return getConstructor(exec); } return 0; }
JSValue* jsHTMLTableSectionElementPrototypeFunctionDeleteRow(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSHTMLTableSectionElement::s_info)) return throwError(exec, TypeError); JSHTMLTableSectionElement* castedThisObj = static_cast<JSHTMLTableSectionElement*>(thisValue); HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(castedThisObj->impl()); ExceptionCode ec = 0; int index = args[0]->toInt32(exec); imp->deleteRow(index, ec); setDOMException(exec, ec); return jsUndefined(); }
HTMLTableRowElement* HTMLTableElement::insertRow( int index, ExceptionState& exceptionState) { if (index < -1) { exceptionState.throwDOMException( IndexSizeError, "The index provided (" + String::number(index) + ") is less than -1."); return nullptr; } HTMLTableRowElement* lastRow = nullptr; HTMLTableRowElement* row = nullptr; if (index == -1) { lastRow = HTMLTableRowsCollection::lastRow(*this); } else { for (int i = 0; i <= index; ++i) { row = HTMLTableRowsCollection::rowAfter(*this, lastRow); if (!row) { if (i != index) { exceptionState.throwDOMException( IndexSizeError, "The index provided (" + String::number(index) + ") is greater than the number of rows in the table (" + String::number(i) + ")."); return nullptr; } break; } lastRow = row; } } ContainerNode* parent; if (lastRow) { parent = row ? row->parentNode() : lastRow->parentNode(); } else { parent = lastBody(); if (!parent) { HTMLTableSectionElement* newBody = HTMLTableSectionElement::create(tbodyTag, document()); HTMLTableRowElement* newRow = HTMLTableRowElement::create(document()); newBody->appendChild(newRow, exceptionState); appendChild(newBody, exceptionState); return newRow; } } HTMLTableRowElement* newRow = HTMLTableRowElement::create(document()); parent->insertBefore(newRow, row, exceptionState); return newRow; }
JSValue* jsHTMLTableSectionElementPrototypeFunctionInsertRow(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSHTMLTableSectionElement::s_info)) return throwError(exec, TypeError); JSHTMLTableSectionElement* castedThisObj = static_cast<JSHTMLTableSectionElement*>(thisValue); HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(castedThisObj->impl()); ExceptionCode ec = 0; int index = args[0]->toInt32(exec); KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->insertRow(index, ec))); setDOMException(exec, ec); return result; }
void JSHTMLTableSectionElement::putValueProperty(ExecState* exec, int token, JSValue* value) { switch (token) { case AlignAttrNum: { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(impl()); imp->setAlign(valueToStringWithNullCheck(exec, value)); break; } case ChAttrNum: { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(impl()); imp->setCh(valueToStringWithNullCheck(exec, value)); break; } case ChOffAttrNum: { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(impl()); imp->setChOff(valueToStringWithNullCheck(exec, value)); break; } case VAlignAttrNum: { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(impl()); imp->setVAlign(valueToStringWithNullCheck(exec, value)); break; } } }
JSValue JSC_HOST_CALL jsHTMLTableSectionElementPrototypeFunctionDeleteRow(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSHTMLTableSectionElement::s_info)) return throwError(exec, TypeError); JSHTMLTableSectionElement* castedThisObj = static_cast<JSHTMLTableSectionElement*>(asObject(thisValue)); HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(castedThisObj->impl()); ExceptionCode ec = 0; int index = args.at(0).toInt32(exec); imp->deleteRow(index, ec); setDOMException(exec, ec); return jsUndefined(); }
int HTMLTableRowElement::rowIndex() const { ContainerNode* table = parentNode(); if (!table) return -1; table = table->parentNode(); if (!table || !table->hasTagName(tableTag)) 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 = static_cast<HTMLTableElement*>(table)->tHead()) { for (Node *row = head->firstChild(); row; row = row->nextSibling()) { if (row == this) return rIndex; if (row->hasTagName(trTag)) ++rIndex; } } for (Node *node = table->firstChild(); node; node = node->nextSibling()) { if (node->hasTagName(tbodyTag)) { HTMLTableSectionElement* section = static_cast<HTMLTableSectionElement*>(node); for (Node* row = section->firstChild(); row; row = row->nextSibling()) { if (row == this) return rIndex; if (row->hasTagName(trTag)) ++rIndex; } } } if (HTMLTableSectionElement* foot = static_cast<HTMLTableElement*>(table)->tFoot()) { for (Node *row = foot->firstChild(); row; row = row->nextSibling()) { if (row == this) return rIndex; if (row->hasTagName(trTag)) ++rIndex; } } // We get here for rows that are in <thead> or <tfoot> sections other than the main header and footer. return -1; }
JSValue JSC_HOST_CALL jsHTMLTableSectionElementPrototypeFunctionInsertRow(ExecState* exec, JSObject*, JSValue thisValue, const ArgList& args) { UNUSED_PARAM(args); if (!thisValue.inherits(&JSHTMLTableSectionElement::s_info)) return throwError(exec, TypeError); JSHTMLTableSectionElement* castedThisObj = static_cast<JSHTMLTableSectionElement*>(asObject(thisValue)); HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(castedThisObj->impl()); ExceptionCode ec = 0; int index = args.at(0).toInt32(exec); JSC::JSValue result = toJS(exec, castedThisObj->globalObject(), WTF::getPtr(imp->insertRow(index, ec))); setDOMException(exec, ec); return result; }
int32_t HTMLTableRowElement::SectionRowIndex() const { HTMLTableSectionElement* section = GetSection(); if (!section) { return -1; } nsCOMPtr<nsIHTMLCollection> coll = section->Rows(); uint32_t numRows = coll->Length(); for (uint32_t i = 0; i < numRows; i++) { if (coll->GetElementAt(i) == this) { return i; } } return -1; }
JSValue* JSHTMLTableSectionElementPrototypeFunction::callAsFunction(ExecState* exec, JSObject* thisObj, const List& args) { if (!thisObj->inherits(&JSHTMLTableSectionElement::info)) return throwError(exec, TypeError); JSHTMLTableSectionElement* castedThisObj = static_cast<JSHTMLTableSectionElement*>(thisObj); HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(castedThisObj->impl()); switch (id) { case JSHTMLTableSectionElement::InsertRowFuncNum: { ExceptionCode ec = 0; bool indexOk; int index = args[0]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } KJS::JSValue* result = toJS(exec, WTF::getPtr(imp->insertRow(index, ec))); setDOMException(exec, ec); return result; } case JSHTMLTableSectionElement::DeleteRowFuncNum: { ExceptionCode ec = 0; bool indexOk; int index = args[0]->toInt32(exec, indexOk); if (!indexOk) { setDOMException(exec, TYPE_MISMATCH_ERR); return jsUndefined(); } imp->deleteRow(index, ec); setDOMException(exec, ec); return jsUndefined(); } } return 0; }
void FTPDirectoryTokenizer::appendEntry(const String& filename, const String& size, const String& date, bool isDirectory) { ExceptionCode ec; RefPtr<Element> rowElement = m_doc->createElementNS(xhtmlNamespaceURI, "tr", ec); rowElement->setAttribute("class", "ftpDirectoryEntryRow", ec); RefPtr<Element> element = m_doc->createElementNS(xhtmlNamespaceURI, "td", ec); element->appendChild(new Text(m_doc, String(&noBreakSpace, 1)), ec); if (isDirectory) element->setAttribute("class", "ftpDirectoryIcon ftpDirectoryTypeDirectory", ec); else element->setAttribute("class", "ftpDirectoryIcon ftpDirectoryTypeFile", ec); rowElement->appendChild(element, ec); element = createTDForFilename(filename); element->setAttribute("class", "ftpDirectoryFileName", ec); rowElement->appendChild(element, ec); element = m_doc->createElementNS(xhtmlNamespaceURI, "td", ec); element->appendChild(new Text(m_doc, date), ec); element->setAttribute("class", "ftpDirectoryFileDate", ec); rowElement->appendChild(element, ec); element = m_doc->createElementNS(xhtmlNamespaceURI, "td", ec); element->appendChild(new Text(m_doc, size), ec); element->setAttribute("class", "ftpDirectoryFileSize", ec); rowElement->appendChild(element, ec); // Append the new row to the first tbody if it exists. // Many <TABLE> elements end up having an implicit <TBODY> created for them and in those // cases, it's more correct to append to the tbody instead of the table itself HTMLTableSectionElement* body = m_tableElement->firstTBody(); if (body) body->appendChild(rowElement, ec); else m_tableElement->appendChild(rowElement, ec); }
void setJSHTMLTableSectionElementVAlign(ExecState* exec, JSObject* thisObject, JSValue value) { HTMLTableSectionElement* imp = static_cast<HTMLTableSectionElement*>(static_cast<JSHTMLTableSectionElement*>(thisObject)->impl()); imp->setVAlign(valueToStringWithNullCheck(exec, value)); }