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();
}
Ref<MathMLTextElement> MathMLTextElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new MathMLTextElement(tagName, document));
}
void MathMLTextElement::didAttachRenderers()
{
MathMLElement::didAttachRenderers();
if (is<RenderMathMLToken>(renderer()))
downcast<RenderMathMLToken>(*renderer()).updateTokenContent();
}
void MathMLTextElement::childrenChanged(const ChildChange& change)
{
MathMLElement::childrenChanged(change);
if (is<RenderMathMLToken>(renderer()))
downcast<RenderMathMLToken>(*renderer()).updateTokenContent();
}
void MathMLTextElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
{
if (name == stretchyAttr) {
if (is<RenderMathMLOperator>(renderer()))
downcast<RenderMathMLOperator>(*renderer()).setOperatorFlagAndScheduleLayoutIfNeeded(MathMLOperatorDictionary::Stretchy, value);
return;
}
MathMLElement::parseAttribute(name, value);
}
RenderPtr<RenderElement> MathMLTextElement::createElementRenderer(Ref<RenderStyle>&& style, const RenderTreePosition& insertionPosition)
{
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), insertionPosition);
ASSERT(hasTagName(MathMLNames::miTag) || hasTagName(MathMLNames::mnTag) || hasTagName(MathMLNames::msTag) || hasTagName(MathMLNames::mtextTag));
style.get().setAlignItemsPosition(ItemPositionStretch);
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)