summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp')
-rw-r--r--Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp b/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp
new file mode 100644
index 000000000..f24417587
--- /dev/null
+++ b/Source/WebCore/rendering/mathml/RenderMathMLFencedOperator.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2016 Igalia S.L. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "RenderMathMLFencedOperator.h"
+
+#if ENABLE(MATHML)
+
+#include "MathMLOperatorDictionary.h"
+#include "MathMLOperatorElement.h"
+
+namespace WebCore {
+
+using namespace MathMLOperatorDictionary;
+
+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);
+
+ // We try and read spacing and boolean properties from the operator dictionary.
+ // However we preserve the Fence and Separator properties specified in the constructor.
+ 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; // Flags are disabled by default.
+ m_leadingSpaceInMathUnit = 5; // Default spacing is thickmathspace.
+ m_trailingSpaceInMathUnit = 5; // Default spacing is thickmathspace.
+ }
+
+ 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