RenderMathMLSpace.cpp [plain text]
#include "config.h"
#include "RenderMathMLSpace.h"
#if ENABLE(MATHML)
#include "GraphicsContext.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMathMLSpace);
RenderMathMLSpace::RenderMathMLSpace(MathMLSpaceElement& element, RenderStyle&& style)
: RenderMathMLBlock(element, WTFMove(style))
{
}
void RenderMathMLSpace::computePreferredLogicalWidths()
{
ASSERT(preferredLogicalWidthsDirty());
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = spaceWidth();
setPreferredLogicalWidthsDirty(false);
}
LayoutUnit RenderMathMLSpace::spaceWidth() const
{
auto& spaceElement = element();
return std::max<LayoutUnit>(0, toUserUnits(spaceElement.width(), style(), 0));
}
void RenderMathMLSpace::getSpaceHeightAndDepth(LayoutUnit& height, LayoutUnit& depth) const
{
auto& spaceElement = element();
height = toUserUnits(spaceElement.height(), style(), 0);
depth = toUserUnits(spaceElement.depth(), style(), 0);
if (height + depth < 0) {
height = 0;
depth = 0;
}
}
void RenderMathMLSpace::layoutBlock(bool relayoutChildren, LayoutUnit)
{
ASSERT(needsLayout());
if (!relayoutChildren && simplifiedLayout())
return;
setLogicalWidth(spaceWidth());
LayoutUnit height, depth;
getSpaceHeightAndDepth(height, depth);
setLogicalHeight(height + depth);
updateScrollInfoAfterLayout();
clearNeedsLayout();
}
Optional<int> RenderMathMLSpace::firstLineBaseline() const
{
LayoutUnit height, depth;
getSpaceHeightAndDepth(height, depth);
return Optional<int>(height);
}
}
#endif