HTMLTableSectionElement.cpp [plain text]
#include "config.h"
#include "HTMLTableSectionElement.h"
#include "ExceptionCode.h"
#include "GenericCachedHTMLCollection.h"
#include "HTMLCollection.h"
#include "HTMLNames.h"
#include "HTMLTableRowElement.h"
#include "HTMLTableElement.h"
#include "NodeList.h"
#include "NodeRareData.h"
#include "Text.h"
namespace WebCore {
using namespace HTMLNames;
inline HTMLTableSectionElement::HTMLTableSectionElement(const QualifiedName& tagName, Document& document)
: HTMLTablePartElement(tagName, document)
{
}
Ref<HTMLTableSectionElement> HTMLTableSectionElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new HTMLTableSectionElement(tagName, document));
}
const StyleProperties* HTMLTableSectionElement::additionalPresentationAttributeStyle() const
{
if (HTMLTableElement* table = findParentTable())
return table->additionalGroupStyle(true);
return 0;
}
RefPtr<HTMLElement> HTMLTableSectionElement::insertRow(int index, ExceptionCode& ec)
{
RefPtr<HTMLTableRowElement> row;
Ref<HTMLCollection> children = rows();
int numRows = children->length();
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;
}
void HTMLTableSectionElement::deleteRow(int index, ExceptionCode& ec)
{
Ref<HTMLCollection> children = rows();
int numRows = children->length();
if (index == -1) {
if (!numRows)
return;
index = numRows - 1;
}
if (index >= 0 && index < numRows)
HTMLElement::removeChild(*children->item(index), 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;
}
const AtomicString& HTMLTableSectionElement::align() const
{
return attributeWithoutSynchronization(alignAttr);
}
void HTMLTableSectionElement::setAlign(const AtomicString& value)
{
setAttributeWithoutSynchronization(alignAttr, value);
}
const AtomicString& HTMLTableSectionElement::ch() const
{
return attributeWithoutSynchronization(charAttr);
}
void HTMLTableSectionElement::setCh(const AtomicString& value)
{
setAttributeWithoutSynchronization(charAttr, value);
}
const AtomicString& HTMLTableSectionElement::chOff() const
{
return attributeWithoutSynchronization(charoffAttr);
}
void HTMLTableSectionElement::setChOff(const AtomicString& value)
{
setAttributeWithoutSynchronization(charoffAttr, value);
}
const AtomicString& HTMLTableSectionElement::vAlign() const
{
return attributeWithoutSynchronization(valignAttr);
}
void HTMLTableSectionElement::setVAlign(const AtomicString& value)
{
setAttributeWithoutSynchronization(valignAttr, value);
}
Ref<HTMLCollection> HTMLTableSectionElement::rows()
{
return ensureRareData().ensureNodeLists().addCachedCollection<GenericCachedHTMLCollection<CollectionTypeTraits<TSectionRows>::traversalType>>(*this, TSectionRows);
}
}