summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/mathml/RenderMathMLOperator.h
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/RenderMathMLOperator.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/rendering/mathml/RenderMathMLOperator.h')
-rw-r--r--Source/WebCore/rendering/mathml/RenderMathMLOperator.h126
1 files changed, 53 insertions, 73 deletions
diff --git a/Source/WebCore/rendering/mathml/RenderMathMLOperator.h b/Source/WebCore/rendering/mathml/RenderMathMLOperator.h
index 505277114..02fd44e55 100644
--- a/Source/WebCore/rendering/mathml/RenderMathMLOperator.h
+++ b/Source/WebCore/rendering/mathml/RenderMathMLOperator.h
@@ -23,94 +23,74 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef RenderMathMLOperator_h
-#define RenderMathMLOperator_h
+#pragma once
#if ENABLE(MATHML)
#include "MathMLElement.h"
-#include "RenderMathMLBlock.h"
-#include <wtf/unicode/CharacterNames.h>
+#include "MathMLOperatorDictionary.h"
+#include "MathOperator.h"
+#include "RenderMathMLToken.h"
namespace WebCore {
-
-class RenderMathMLOperator final : public RenderMathMLBlock {
-public:
- RenderMathMLOperator(MathMLElement&, PassRef<RenderStyle>);
- RenderMathMLOperator(MathMLElement&, PassRef<RenderStyle>, UChar operatorChar);
- MathMLElement& element() { return toMathMLElement(nodeForNonAnonymous()); }
+class MathMLOperatorElement;
- void stretchToHeight(int pixelHeight);
- int stretchHeight() { return m_stretchHeight; }
- float expandedStretchHeight() const;
-
- enum OperatorType { Default, Separator, Fence };
- void setOperatorType(OperatorType type) { m_operatorType = type; }
- OperatorType operatorType() const { return m_operatorType; }
- void updateStyle();
+class RenderMathMLOperator : public RenderMathMLToken {
+public:
+ RenderMathMLOperator(MathMLOperatorElement&, RenderStyle&&);
+ RenderMathMLOperator(Document&, RenderStyle&&);
+ MathMLOperatorElement& element() const;
+
+ void stretchTo(LayoutUnit heightAboveBaseline, LayoutUnit depthBelowBaseline);
+ void stretchTo(LayoutUnit width);
+ LayoutUnit stretchSize() const { return isVertical() ? m_stretchHeightAboveBaseline + m_stretchDepthBelowBaseline : m_stretchWidth; }
+ void resetStretchSize();
+
+ virtual bool hasOperatorFlag(MathMLOperatorDictionary::Flag) const;
+ bool isLargeOperatorInDisplayStyle() const { return !hasOperatorFlag(MathMLOperatorDictionary::Stretchy) && hasOperatorFlag(MathMLOperatorDictionary::LargeOp) && mathMLStyle().displayStyle(); }
+ bool shouldMoveLimits() const { return hasOperatorFlag(MathMLOperatorDictionary::MovableLimits) && !mathMLStyle().displayStyle(); }
+ virtual bool isVertical() const;
+ LayoutUnit italicCorrection() const { return m_mathOperator.italicCorrection(); }
+
+ void updateTokenContent() final;
+ void updateFromElement() final;
+ virtual UChar32 textContent() const;
+ bool isStretchy() const { return textContent() && hasOperatorFlag(MathMLOperatorDictionary::Stretchy); }
+
+protected:
+ virtual void updateMathOperator();
+ virtual LayoutUnit leadingSpace() const;
+ virtual LayoutUnit trailingSpace() const;
+ virtual LayoutUnit minSize() const;
+ virtual LayoutUnit maxSize() const;
+ virtual bool useMathOperator() const;
- void paint(PaintInfo&, const LayoutPoint&);
+private:
+ void styleDidChange(StyleDifference, const RenderStyle* oldStyle) final;
+ void computePreferredLogicalWidths() final;
+ void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) final;
+ void paint(PaintInfo&, const LayoutPoint&) final;
- struct StretchyCharacter {
- UChar character;
- UChar topGlyph;
- UChar extensionGlyph;
- UChar bottomGlyph;
- UChar middleGlyph;
- };
+ const char* renderName() const final { return isAnonymous() ? "RenderMathMLOperator (anonymous)" : "RenderMathMLOperator"; }
+ void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect) final;
+ bool isRenderMathMLOperator() const final { return true; }
+ bool isInvisibleOperator() const;
- virtual void updateFromElement() override;
+ std::optional<int> firstLineBaseline() const final;
+ RenderMathMLOperator* unembellishedOperator() final { return this; }
-private:
- virtual const char* renderName() const override { return isAnonymous() ? "RenderMathMLOperator (anonymous)" : "RenderMathMLOperator"; }
- virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) override;
- virtual void paintChildren(PaintInfo& forSelf, const LayoutPoint&, PaintInfo& forChild, bool usePrintRect) override;
- virtual bool isRenderMathMLOperator() const override { return true; }
- virtual bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
- virtual void computePreferredLogicalWidths() override;
- virtual void computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logicalTop, LogicalExtentComputedValues&) const override;
- virtual int firstLineBaseline() const override;
- virtual RenderMathMLOperator* unembellishedOperator() override { return this; }
-
- bool shouldAllowStretching(UChar& characterForStretching);
- StretchyCharacter* findAcceptableStretchyCharacter(UChar);
-
- FloatRect glyphBoundsForCharacter(UChar);
- float glyphHeightForCharacter(UChar);
- float advanceForCharacter(UChar);
-
- enum CharacterPaintTrimming {
- TrimTop,
- TrimBottom,
- TrimTopAndBottom,
- };
-
- LayoutRect paintCharacter(PaintInfo&, UChar, const LayoutPoint& origin, CharacterPaintTrimming);
- void fillWithExtensionGlyph(PaintInfo&, const LayoutPoint& from, const LayoutPoint& to);
-
- int m_stretchHeight;
- bool m_isStretched;
-
- UChar m_operator;
- OperatorType m_operatorType;
- StretchyCharacter* m_stretchyCharacter;
-};
+ LayoutUnit verticalStretchedOperatorShift() const;
-RENDER_OBJECT_TYPE_CASTS(RenderMathMLOperator, isRenderMathMLOperator());
+ LayoutUnit m_stretchHeightAboveBaseline { 0 };
+ LayoutUnit m_stretchDepthBelowBaseline { 0 };
+ LayoutUnit m_stretchWidth;
-template<> inline bool isRendererOfType<const RenderMathMLOperator>(const RenderObject& renderer) { return renderer.isRenderMathMLOperator(); }
+ MathOperator m_mathOperator;
+};
-inline UChar convertHyphenMinusToMinusSign(UChar glyph)
-{
- // When rendered as a mathematical operator, minus glyph should be larger.
- if (glyph == hyphenMinus)
- return minusSign;
-
- return glyph;
-}
+} // namespace WebCore
-}
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLOperator, isRenderMathMLOperator())
#endif // ENABLE(MATHML)
-#endif // RenderMathMLOperator_h