HTMLTableSectionElement.cpp [plain text]
#include "config.h"
#include "HTMLTableSectionElement.h"
#include "ExceptionCode.h"
#include "HTMLCollection.h"
#include "HTMLNames.h"
#include "HTMLTableRowElement.h"
#include "HTMLTableElement.h"
#include "NodeList.h"
#include "Text.h"
namespace WebCore {
using namespace HTMLNames;
inline HTMLTableSectionElement::HTMLTableSectionElement(const QualifiedName& tagName, Document* document)
: HTMLTablePartElement(tagName, document)
{
}
PassRefPtr<HTMLTableSectionElement> HTMLTableSectionElement::create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new HTMLTableSectionElement(tagName, document));
}
const StylePropertySet* HTMLTableSectionElement::additionalPresentationAttributeStyle()
{
if (HTMLTableElement* table = findParentTable())
return table->additionalGroupStyle(true);
return 0;
}
PassRefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionCode& ec)
{
RefPtr<HTMLTableRowElement> row;
RefPtr<HTMLCollection> children = rows();
int numRows = children ? (int)children->length() : 0;
if (index < -1 || index > numRows)
ec = INDEX_SIZE_ERR; else {
row = HTMLTableRowElement::create(trTag, document());
if (numRows == index || index == -1)
appendChild(row, ec);
else {
Node* n;
if (index < 1)
n = firstChild();
else
n = children->item(index);
insertBefore(row, n, ec);
}
}
return row.release();
}
void HTMLTableSectionElement::deleteRow(int index, ExceptionCode& ec)
{
RefPtr<HTMLCollection> children = rows();
int numRows = children ? (int)children->length() : 0;
if (index == -1)
index = numRows - 1;
if (index >= 0 && index < numRows) {
RefPtr<Node> row = children->item(index);
HTMLElement::removeChild(row.get(), ec);
} else
ec = INDEX_SIZE_ERR;
}
int HTMLTableSectionElement::numRows() const
{
int rows = 0;
const Node *n = firstChild();
while (n) {
if (n->hasTagName(trTag))
rows++;
n = n->nextSibling();
}
return rows;
}
String HTMLTableSectionElement::align() const
{
return getAttribute(alignAttr);
}
void HTMLTableSectionElement::setAlign(const String &value)
{
setAttribute(alignAttr, value);
}
String HTMLTableSectionElement::ch() const
{
return getAttribute(charAttr);
}
void HTMLTableSectionElement::setCh(const String &value)
{
setAttribute(charAttr, value);
}
String HTMLTableSectionElement::chOff() const
{
return getAttribute(charoffAttr);
}
void HTMLTableSectionElement::setChOff(const String &value)
{
setAttribute(charoffAttr, value);
}
String HTMLTableSectionElement::vAlign() const
{
return getAttribute(valignAttr);
}
void HTMLTableSectionElement::setVAlign(const String &value)
{
setAttribute(valignAttr, value);
}
PassRefPtr<HTMLCollection> HTMLTableSectionElement::rows()
{
return ensureCachedHTMLCollection(TSectionRows);
}
}