RenderMathMLFenced.cpp [plain text]
#include "config.h"
#include "RenderMathMLFenced.h"
#if ENABLE(MATHML)
#include "FontSelector.h"
#include "MathMLNames.h"
#include "MathMLRowElement.h"
#include "RenderInline.h"
#include "RenderMathMLFencedOperator.h"
#include "RenderText.h"
#include "RenderTreeBuilder.h"
#include <wtf/IsoMallocInlines.h>
#include <wtf/text/StringBuilder.h>
namespace WebCore {
using namespace MathMLNames;
WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMathMLFenced);
static const char* gOpeningBraceChar = "(";
static const char* gClosingBraceChar = ")";
RenderMathMLFenced::RenderMathMLFenced(MathMLRowElement& element, RenderStyle&& style)
: RenderMathMLRow(element, WTFMove(style))
{
}
void RenderMathMLFenced::updateFromElement()
{
const auto& fenced = element();
auto& open = fenced.attributeWithoutSynchronization(MathMLNames::openAttr);
m_open = open.isNull() ? gOpeningBraceChar : open;
auto& close = fenced.attributeWithoutSynchronization(MathMLNames::closeAttr);
m_close = close.isNull() ? gClosingBraceChar : close;
auto& separators = fenced.attributeWithoutSynchronization(MathMLNames::separatorsAttr);
if (!separators.isNull()) {
StringBuilder characters;
for (unsigned i = 0; i < separators.length(); i++) {
if (!isSpaceOrNewline(separators[i]))
characters.append(separators[i]);
}
m_separators = !characters.length() ? 0 : characters.toString().impl();
} else {
m_separators = StringImpl::create(",");
}
if (firstChild()) {
if (is<RenderMathMLFencedOperator>(*firstChild()))
downcast<RenderMathMLFencedOperator>(*firstChild()).updateOperatorContent(m_open);
m_closeFenceRenderer->updateOperatorContent(m_close);
}
}
}
#endif