Refactor RenderMathMLMenclose.
[WebKit-https.git] / Source / WebCore / rendering / mathml / RenderMathMLRoot.cpp
index 875a6fd..0176515 100644 (file)
@@ -55,13 +55,8 @@ namespace WebCore {
 // In order to accept invalid markup and to handle <mroot> and <msqrt> consistently, we will allow any number of children in the BaseWrapper of <mroot> too.
 // We will allow the IndexWrapper to be empty and it will always contain the last child of the <mroot> if there are at least 2 elements.
 
-RenderMathMLRoot::RenderMathMLRoot(Element& element, Ref<RenderStyle>&& style)
-    : RenderMathMLBlock(element, WTF::move(style))
-{
-}
-
-RenderMathMLRoot::RenderMathMLRoot(Document& document, Ref<RenderStyle>&& style)
-    : RenderMathMLBlock(document, WTF::move(style))
+RenderMathMLRoot::RenderMathMLRoot(Element& element, std::unique_ptr<RenderStyle> style)
+    : RenderMathMLBlock(element, WTFMove(style))
 {
 }
 
@@ -226,26 +221,26 @@ void RenderMathMLRoot::updateStyle()
 
     auto radical = radicalWrapper();
     auto radicalStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX);
-    radicalStyle.get().setMarginTop(Length(0, Fixed)); // This will be updated in RenderMathMLRoot::layout().
-    radical->setStyle(WTF::move(radicalStyle));
+    radicalStyle->setMarginTop(Length(0, Fixed)); // This will be updated in RenderMathMLRoot::layout().
+    radical->setStyle(WTFMove(radicalStyle));
     radical->setNeedsLayoutAndPrefWidthsRecalc();
 
     auto base = baseWrapper();
     auto baseStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX);
-    baseStyle.get().setMarginTop(Length(0, Fixed)); // This will be updated in RenderMathMLRoot::layout().
-    baseStyle.get().setAlignItems(AlignBaseline);
-    base->setStyle(WTF::move(baseStyle));
+    baseStyle->setMarginTop(Length(0, Fixed)); // This will be updated in RenderMathMLRoot::layout().
+    baseStyle->setAlignItemsPosition(ItemPositionBaseline);
+    base->setStyle(WTFMove(baseStyle));
     base->setNeedsLayoutAndPrefWidthsRecalc();
 
     if (!isRenderMathMLSquareRoot()) {
         // For mroot, we also set the style of the index wrapper.
         auto index = indexWrapper();
         auto indexStyle = RenderStyle::createAnonymousStyleWithDisplay(&style(), FLEX);
-        indexStyle.get().setMarginTop(Length(0, Fixed)); // This will be updated in RenderMathMLRoot::layout().
-        indexStyle.get().setMarginStart(Length(kernBeforeDegree, Fixed));
-        indexStyle.get().setMarginEnd(Length(kernAfterDegree, Fixed));
-        indexStyle.get().setAlignItems(AlignBaseline);
-        index->setStyle(WTF::move(indexStyle));
+        indexStyle->setMarginTop(Length(0, Fixed)); // This will be updated in RenderMathMLRoot::layout().
+        indexStyle->setMarginStart(Length(kernBeforeDegree, Fixed));
+        indexStyle->setMarginEnd(Length(kernAfterDegree, Fixed));
+        indexStyle->setAlignItemsPosition(ItemPositionBaseline);
+        index->setStyle(WTFMove(indexStyle));
         index->setNeedsLayoutAndPrefWidthsRecalc();
     }
 }
@@ -319,7 +314,7 @@ void RenderMathMLRoot::paint(PaintInfo& info, const LayoutPoint& paintOffset)
 {
     RenderMathMLBlock::paint(info, paintOffset);
     
-    if (isEmpty() || info.context->paintingDisabled() || style().visibility() != VISIBLE)
+    if (isEmpty() || info.context().paintingDisabled() || style().visibility() != VISIBLE)
         return;
 
     auto base = baseWrapper();
@@ -328,16 +323,16 @@ void RenderMathMLRoot::paint(PaintInfo& info, const LayoutPoint& paintOffset)
         return;
 
     // We draw the radical line.
-    GraphicsContextStateSaver stateSaver(*info.context);
+    GraphicsContextStateSaver stateSaver(info.context());
 
-    info.context->setStrokeThickness(m_ruleThickness);
-    info.context->setStrokeStyle(SolidStroke);
-    info.context->setStrokeColor(style().visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB);
+    info.context().setStrokeThickness(m_ruleThickness);
+    info.context().setStrokeStyle(SolidStroke);
+    info.context().setStrokeColor(style().visitedDependentColor(CSSPropertyColor));
 
     // The preferred width of the radical is sometimes incorrect, so we draw a slightly longer line to ensure it touches the radical symbol (https://bugs.webkit.org/show_bug.cgi?id=130326).
     LayoutUnit sizeError = radical->trailingSpaceError();
     IntPoint adjustedPaintOffset = roundedIntPoint(paintOffset + location() + base->location() + LayoutPoint(-sizeError, -(m_verticalGap + m_ruleThickness / 2)));
-    info.context->drawLine(adjustedPaintOffset, IntPoint(adjustedPaintOffset.x() + base->pixelSnappedOffsetWidth() + sizeError, adjustedPaintOffset.y()));
+    info.context().drawLine(adjustedPaintOffset, roundedIntPoint(LayoutPoint(adjustedPaintOffset.x() + base->offsetWidth() + sizeError, adjustedPaintOffset.y())));
 }
 
 RenderPtr<RenderMathMLRootWrapper> RenderMathMLRootWrapper::createAnonymousWrapper(RenderMathMLRoot* renderObject)