diff options
Diffstat (limited to 'Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp')
-rw-r--r-- | Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp | 80 |
1 files changed, 36 insertions, 44 deletions
diff --git a/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp b/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp index 288e6622e..292c83553 100644 --- a/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLSpace.cpp @@ -29,71 +29,63 @@ #if ENABLE(MATHML) #include "GraphicsContext.h" -#include "MathMLNames.h" -#include "PaintInfo.h" namespace WebCore { - -using namespace MathMLNames; - -RenderMathMLSpace::RenderMathMLSpace(MathMLTextElement& element, PassRef<RenderStyle> style) - : RenderMathMLBlock(element, std::move(style)) - , m_width(0) - , m_height(0) - , m_depth(0) -{ -} -void RenderMathMLSpace::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const +RenderMathMLSpace::RenderMathMLSpace(MathMLSpaceElement& element, RenderStyle&& style) + : RenderMathMLBlock(element, WTFMove(style)) { - minLogicalWidth = m_width; - maxLogicalWidth = m_width; } -void RenderMathMLSpace::updateFromElement() +void RenderMathMLSpace::computePreferredLogicalWidths() { - const auto& spaceElement = element(); - - // This parses the mspace attributes, using 0 as the default values. - m_width = 0; - m_height = 0; - m_depth = 0; - parseMathMLLength(spaceElement.getAttribute(MathMLNames::widthAttr), m_width, &style()); - parseMathMLLength(spaceElement.getAttribute(MathMLNames::heightAttr), m_height, &style()); - parseMathMLLength(spaceElement.getAttribute(MathMLNames::depthAttr), m_depth, &style()); + ASSERT(preferredLogicalWidthsDirty()); - // FIXME: Negative width values should be accepted. - if (m_width < 0) - m_width = 0; - - // If the total height is negative, set vertical dimensions to 0. - if (m_height + m_depth < 0) { - m_height = 0; - m_depth = 0; - } + m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = spaceWidth(); - setNeedsLayoutAndPrefWidthsRecalc(); + setPreferredLogicalWidthsDirty(false); } -void RenderMathMLSpace::updateLogicalWidth() +LayoutUnit RenderMathMLSpace::spaceWidth() const { - setLogicalWidth(m_width); + auto& spaceElement = element(); + // FIXME: Negative width values are not supported yet. + return std::max<LayoutUnit>(0, toUserUnits(spaceElement.width(), style(), 0)); } -void RenderMathMLSpace::updateLogicalHeight() +void RenderMathMLSpace::getSpaceHeightAndDepth(LayoutUnit& height, LayoutUnit& depth) const { - setLogicalHeight(m_height + m_depth); + auto& spaceElement = element(); + height = toUserUnits(spaceElement.height(), style(), 0); + depth = toUserUnits(spaceElement.depth(), style(), 0); + + // If the total height is negative, set vertical dimensions to 0. + if (height + depth < 0) { + height = 0; + depth = 0; + } } -void RenderMathMLSpace::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle) +void RenderMathMLSpace::layoutBlock(bool relayoutChildren, LayoutUnit) { - RenderMathMLBlock::styleDidChange(diff, oldStyle); - updateFromElement(); + ASSERT(needsLayout()); + + if (!relayoutChildren && simplifiedLayout()) + return; + + setLogicalWidth(spaceWidth()); + LayoutUnit height, depth; + getSpaceHeightAndDepth(height, depth); + setLogicalHeight(height + depth); + + clearNeedsLayout(); } -int RenderMathMLSpace::firstLineBaseline() const +std::optional<int> RenderMathMLSpace::firstLineBaseline() const { - return m_height; + LayoutUnit height, depth; + getSpaceHeightAndDepth(height, depth); + return std::optional<int>(height); } } |