RenderMathMLFencedOperator.cpp [plain text]
#include "config.h"
#include "RenderMathMLFencedOperator.h"
#if ENABLE(MATHML)
#include "MathMLOperatorDictionary.h"
#include "MathMLOperatorElement.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
using namespace MathMLOperatorDictionary;
WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMathMLFencedOperator);
RenderMathMLFencedOperator::RenderMathMLFencedOperator(Document& document, RenderStyle&& style, const String& operatorString, MathMLOperatorDictionary::Form form, unsigned short flags)
: RenderMathMLOperator(document, WTFMove(style))
, m_operatorForm(form)
, m_operatorFlags(flags)
{
updateOperatorContent(operatorString);
}
void RenderMathMLFencedOperator::updateOperatorContent(const String& operatorString)
{
m_operatorChar = MathMLOperatorElement::parseOperatorChar(operatorString);
if (auto entry = search(m_operatorChar.character, m_operatorForm, true)) {
m_leadingSpaceInMathUnit = entry.value().leadingSpaceInMathUnit;
m_trailingSpaceInMathUnit = entry.value().trailingSpaceInMathUnit;
m_operatorFlags = (m_operatorFlags & (MathMLOperatorDictionary::Fence | MathMLOperatorDictionary::Separator)) | entry.value().flags;
} else {
m_operatorFlags &= MathMLOperatorDictionary::Fence | MathMLOperatorDictionary::Separator; m_leadingSpaceInMathUnit = 5; m_trailingSpaceInMathUnit = 5; }
updateMathOperator();
}
LayoutUnit RenderMathMLFencedOperator::leadingSpace() const
{
MathMLElement::Length leadingSpace;
leadingSpace.type = MathMLElement::LengthType::MathUnit;
leadingSpace.value = static_cast<float>(m_leadingSpaceInMathUnit);
return toUserUnits(leadingSpace, style(), 0);
}
LayoutUnit RenderMathMLFencedOperator::trailingSpace() const
{
MathMLElement::Length trailingSpace;
trailingSpace.type = MathMLElement::LengthType::MathUnit;
trailingSpace.value = static_cast<float>(m_trailingSpaceInMathUnit);
return toUserUnits(trailingSpace, style(), 0);
}
}
#endif