MathMLTextElement.cpp [plain text]
#include "config.h"
#if ENABLE(MATHML)
#include "MathMLTextElement.h"
#include "MathMLNames.h"
#include "RenderMathMLOperator.h"
#include "RenderMathMLSpace.h"
#include "RenderMathMLToken.h"
namespace WebCore {
using namespace MathMLNames;
inline MathMLTextElement::MathMLTextElement(const QualifiedName& tagName, Document& document)
: MathMLElement(tagName, document)
{
setHasCustomStyleResolveCallbacks();
}
PassRefPtr<MathMLTextElement> MathMLTextElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(new MathMLTextElement(tagName, document));
}
void MathMLTextElement::didAttachRenderers()
{
MathMLElement::didAttachRenderers();
if (renderer() && renderer()->isRenderMathMLToken())
toRenderMathMLToken(renderer())->updateTokenContent();
}
void MathMLTextElement::childrenChanged(const ChildChange& change)
{
MathMLElement::childrenChanged(change);
if (renderer() && renderer()->isRenderMathMLToken())
toRenderMathMLToken(renderer())->updateTokenContent();
}
RenderPtr<RenderElement> MathMLTextElement::createElementRenderer(PassRef<RenderStyle> style)
{
if (hasTagName(MathMLNames::moTag))
return createRenderer<RenderMathMLOperator>(*this, WTF::move(style));
if (hasTagName(MathMLNames::mspaceTag))
return createRenderer<RenderMathMLSpace>(*this, WTF::move(style));
if (hasTagName(MathMLNames::annotationTag))
return MathMLElement::createElementRenderer(WTF::move(style));
ASSERT(hasTagName(MathMLNames::miTag) || hasTagName(MathMLNames::mnTag) || hasTagName(MathMLNames::msTag) || hasTagName(MathMLNames::mtextTag));
return createRenderer<RenderMathMLToken>(*this, WTF::move(style));
}
bool MathMLTextElement::childShouldCreateRenderer(const Node& child) const
{
if (hasTagName(MathMLNames::mspaceTag))
return false;
if (hasTagName(MathMLNames::annotationTag) || hasTagName(MathMLNames::moTag))
return child.isTextNode();
return isPhrasingContent(child) && StyledElement::childShouldCreateRenderer(child);
}
}
#endif // ENABLE(MATHML)