RenderMathMLBlock.h [plain text]
#pragma once
#if ENABLE(MATHML)
#include "MathMLElement.h"
#include "MathMLStyle.h"
#include "RenderBlock.h"
#include "RenderTable.h"
#include "StyleInheritedData.h"
namespace WebCore {
class RenderMathMLOperator;
class MathMLPresentationElement;
class RenderMathMLBlock : public RenderBlock {
WTF_MAKE_ISO_ALLOCATED(RenderMathMLBlock);
public:
RenderMathMLBlock(MathMLPresentationElement&, RenderStyle&&);
RenderMathMLBlock(Document&, RenderStyle&&);
virtual ~RenderMathMLBlock();
MathMLStyle& mathMLStyle() const { return m_mathMLStyle; }
bool isChildAllowed(const RenderObject&, const RenderStyle&) const override;
virtual RenderMathMLOperator* unembellishedOperator() const { return 0; }
int baselinePosition(FontBaseline, bool firstLine, LineDirectionMode, LinePositionMode = PositionOnContainingLine) const override;
#if ENABLE(DEBUG_MATH_LAYOUT)
virtual void paint(PaintInfo&, const LayoutPoint&);
#endif
protected:
LayoutUnit ruleThicknessFallback() const
{
return 0.05f * style().fontCascade().size();
}
LayoutUnit mathAxisHeight() const;
LayoutUnit mirrorIfNeeded(LayoutUnit horizontalOffset, LayoutUnit boxWidth = 0) const;
LayoutUnit mirrorIfNeeded(LayoutUnit horizontalOffset, const RenderBox& child) const { return mirrorIfNeeded(horizontalOffset, child.logicalWidth()); }
static LayoutUnit ascentForChild(const RenderBox& child)
{
return child.firstLineBaseline().value_or(child.logicalHeight());
}
void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) override;
void layoutInvalidMarkup(bool relayoutChildren);
private:
bool isRenderMathMLBlock() const final { return true; }
const char* renderName() const override { return "RenderMathMLBlock"; }
bool avoidsFloats() const final { return true; }
bool canDropAnonymousBlockChild() const final { return false; }
void layoutItems(bool relayoutChildren);
Ref<MathMLStyle> m_mathMLStyle;
};
class RenderMathMLTable final : public RenderTable {
WTF_MAKE_ISO_ALLOCATED(RenderMathMLTable);
public:
explicit RenderMathMLTable(MathMLElement& element, RenderStyle&& style)
: RenderTable(element, WTFMove(style))
, m_mathMLStyle(MathMLStyle::create())
{
}
MathMLStyle& mathMLStyle() const { return m_mathMLStyle; }
private:
bool isRenderMathMLTable() const final { return true; }
const char* renderName() const final { return "RenderMathMLTable"; }
std::optional<int> firstLineBaseline() const final;
Ref<MathMLStyle> m_mathMLStyle;
};
LayoutUnit toUserUnits(const MathMLElement::Length&, const RenderStyle&, const LayoutUnit& referenceValue);
}
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLBlock, isRenderMathMLBlock())
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderMathMLTable, isRenderMathMLTable())
#endif // ENABLE(MATHML)