#include "config.h"
#if ENABLE(MATHML)
#include "MathMLElement.h"
#include "MathMLNames.h"
#include "RenderObject.h"
#include "RenderTableCell.h"
namespace WebCore {
using namespace MathMLNames;
MathMLElement::MathMLElement(const QualifiedName& tagName, Document* document)
: StyledElement(tagName, document, CreateStyledElement)
{
}
PassRefPtr<MathMLElement> MathMLElement::create(const QualifiedName& tagName, Document* document)
{
return adoptRef(new MathMLElement(tagName, document));
}
int MathMLElement::colSpan() const
{
if (!hasTagName(mtdTag))
return 1;
const AtomicString& colSpanValue = fastGetAttribute(columnspanAttr);
return std::max(1, colSpanValue.toInt());
}
int MathMLElement::rowSpan() const
{
if (!hasTagName(mtdTag))
return 1;
const AtomicString& rowSpanValue = fastGetAttribute(rowspanAttr);
return std::max(1, rowSpanValue.toInt());
}
void MathMLElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == rowspanAttr) {
if (renderer() && renderer()->isTableCell() && hasTagName(mtdTag))
toRenderTableCell(renderer())->colSpanOrRowSpanChanged();
} else if (name == columnspanAttr) {
if (renderer() && renderer()->isTableCell() && hasTagName(mtdTag))
toRenderTableCell(renderer())->colSpanOrRowSpanChanged();
} else
StyledElement::parseAttribute(name, value);
}
bool MathMLElement::isPresentationAttribute(const QualifiedName& name) const
{
if (name == mathbackgroundAttr || name == mathsizeAttr || name == mathcolorAttr || name == fontsizeAttr || name == backgroundAttr || name == colorAttr || name == fontstyleAttr || name == fontweightAttr || name == fontfamilyAttr)
return true;
return StyledElement::isPresentationAttribute(name);
}
void MathMLElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
{
if (name == mathbackgroundAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyBackgroundColor, value);
else if (name == mathsizeAttr) {
if (value != "normal" && value != "small" && value != "big")
addPropertyToPresentationAttributeStyle(style, CSSPropertyFontSize, value);
} else if (name == mathcolorAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyColor, value);
else if (name == fontsizeAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyFontSize, value);
else if (name == backgroundAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyBackgroundColor, value);
else if (name == colorAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyColor, value);
else if (name == fontstyleAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyFontStyle, value);
else if (name == fontweightAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyFontWeight, value);
else if (name == fontfamilyAttr)
addPropertyToPresentationAttributeStyle(style, CSSPropertyFontFamily, value);
else {
ASSERT(!isPresentationAttribute(name));
StyledElement::collectStyleForPresentationAttribute(name, value
, style);
}
}
}
#endif // ENABLE(MATHML)