HTMLTableColElement.cpp [plain text]
#include "config.h"
#include "HTMLTableColElement.h"
#include "Attribute.h"
#include "CSSPropertyNames.h"
#include "HTMLNames.h"
#include "HTMLTableElement.h"
#include "RenderTableCol.h"
#include "Text.h"
namespace WebCore {
using namespace HTMLNames;
inline HTMLTableColElement::HTMLTableColElement(const QualifiedName& tagName, Document* document)
: HTMLTablePartElement(tagName, document)
, m_span(1)
{
}
PassRefPtr<HTMLTableColElement> HTMLTableColElement::create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new HTMLTableColElement(tagName, document));
}
bool HTMLTableColElement::isPresentationAttribute(const QualifiedName& name) const
{
if (name == widthAttr)
return true;
return HTMLTablePartElement::isPresentationAttribute(name);
}
void HTMLTableColElement::collectStyleForAttribute(Attribute* attr, StylePropertySet* style)
{
if (attr->name() == widthAttr)
addHTMLLengthToStyle(style, CSSPropertyWidth, attr->value());
else
HTMLTablePartElement::collectStyleForAttribute(attr, style);
}
void HTMLTableColElement::parseAttribute(Attribute* attr)
{
if (attr->name() == spanAttr) {
m_span = !attr->isNull() ? attr->value().toInt() : 1;
if (renderer() && renderer()->isTableCol())
renderer()->updateFromElement();
} else if (attr->name() == widthAttr) {
if (!attr->value().isEmpty()) {
if (renderer() && renderer()->isTableCol()) {
RenderTableCol* col = toRenderTableCol(renderer());
int newWidth = width().toInt();
if (newWidth != col->width())
col->setNeedsLayoutAndPrefWidthsRecalc();
}
}
} else
HTMLTablePartElement::parseAttribute(attr);
}
StylePropertySet* HTMLTableColElement::additionalAttributeStyle()
{
if (!hasLocalName(colgroupTag))
return 0;
if (HTMLTableElement* table = findParentTable())
return table->additionalGroupStyle(false);
return 0;
}
void HTMLTableColElement::setSpan(int n)
{
setAttribute(spanAttr, String::number(n));
}
String HTMLTableColElement::width() const
{
return getAttribute(widthAttr);
}
}