HTMLTablePartElement.cpp [plain text]
#include "config.h"
#include "HTMLTablePartElement.h"
#include "Attribute.h"
#include "CSSImageValue.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
#include "Document.h"
#include "HTMLNames.h"
#include "HTMLParserIdioms.h"
#include "HTMLTableElement.h"
namespace WebCore {
using namespace HTMLNames;
bool HTMLTablePartElement::isPresentationAttribute(const QualifiedName& name) const
{
if (name == bgcolorAttr || name == backgroundAttr || name == bordercolorAttr || name == valignAttr || name == alignAttr || name == heightAttr)
return true;
return HTMLElement::isPresentationAttribute(name);
}
void HTMLTablePartElement::collectStyleForAttribute(Attribute* attr, StylePropertySet* style)
{
if (attr->name() == bgcolorAttr)
addHTMLColorToStyle(style, CSSPropertyBackgroundColor, attr->value());
else if (attr->name() == backgroundAttr) {
String url = stripLeadingAndTrailingHTMLSpaces(attr->value());
if (!url.isEmpty())
style->setProperty(CSSProperty(CSSPropertyBackgroundImage, CSSImageValue::create(document()->completeURL(url).string())));
} else if (attr->name() == bordercolorAttr) {
if (!attr->value().isEmpty()) {
addHTMLColorToStyle(style, CSSPropertyBorderColor, attr->value());
addPropertyToAttributeStyle(style, CSSPropertyBorderStyle, CSSValueSolid);
}
} else if (attr->name() == valignAttr) {
if (equalIgnoringCase(attr->value(), "top"))
addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueTop);
else if (equalIgnoringCase(attr->value(), "middle"))
addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueMiddle);
else if (equalIgnoringCase(attr->value(), "bottom"))
addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueBottom);
else if (equalIgnoringCase(attr->value(), "baseline"))
addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, CSSValueBaseline);
else
addPropertyToAttributeStyle(style, CSSPropertyVerticalAlign, attr->value());
} else if (attr->name() == alignAttr) {
if (equalIgnoringCase(attr->value(), "middle") || equalIgnoringCase(attr->value(), "center"))
addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitCenter);
else if (equalIgnoringCase(attr->value(), "absmiddle"))
addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueCenter);
else if (equalIgnoringCase(attr->value(), "left"))
addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitLeft);
else if (equalIgnoringCase(attr->value(), "right"))
addPropertyToAttributeStyle(style, CSSPropertyTextAlign, CSSValueWebkitRight);
else
addPropertyToAttributeStyle(style, CSSPropertyTextAlign, attr->value());
} else if (attr->name() == heightAttr) {
if (!attr->value().isEmpty())
addHTMLLengthToStyle(style, CSSPropertyHeight, attr->value());
} else
HTMLElement::collectStyleForAttribute(attr, style);
}
HTMLTableElement* HTMLTablePartElement::findParentTable() const
{
ContainerNode* parent = parentNode();
while (parent && !parent->hasTagName(tableTag))
parent = parent->parentNode();
return static_cast<HTMLTableElement*>(parent);
}
}