diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2016-04-10 09:28:39 +0000 |
commit | 32761a6cee1d0dee366b885b7b9c777e67885688 (patch) | |
tree | d6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp | |
parent | a4e969f4965059196ca948db781e52f7cfebf19e (diff) | |
download | WebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz |
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp')
-rwxr-xr-x[-rw-r--r--] | Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp b/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp index c3ea23925..5cb924f03 100644..100755 --- a/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp +++ b/Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp @@ -23,6 +23,7 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define _USE_MATH_DEFINES 1 #include "config.h" #if ENABLE(MATHML) @@ -38,14 +39,14 @@ namespace WebCore { using namespace MathMLNames; -RenderMathMLMenclose::RenderMathMLMenclose(Element& element, Ref<RenderStyle>&& style) - : RenderMathMLRow(element, WTFMove(style)) +RenderMathMLMenclose::RenderMathMLMenclose(Element& element, PassRef<RenderStyle> style) + : RenderMathMLRow(element, std::move(style)) { } void RenderMathMLMenclose::addChild(RenderObject* newChild, RenderObject* beforeChild) { - MathMLMencloseElement* menclose = downcast<MathMLMencloseElement>(element()); + MathMLMencloseElement* menclose = toMathMLMencloseElement(element()); // Allow an anonymous RenderMathMLSquareRoot to handle drawing the radical // notation, rather than duplicating the code needed to paint a root. if (!firstChild() && menclose->isRadical()) @@ -53,7 +54,7 @@ void RenderMathMLMenclose::addChild(RenderObject* newChild, RenderObject* before if (newChild) { if (firstChild() && menclose->isRadical()) - downcast<RenderElement>(*firstChild()).addChild(newChild, beforeChild && beforeChild->parent() == firstChild() ? beforeChild : nullptr); + toRenderElement(firstChild())->addChild(newChild, beforeChild && beforeChild->parent() == firstChild() ? beforeChild : nullptr); else RenderMathMLBlock::addChild(newChild, beforeChild); } @@ -64,47 +65,42 @@ void RenderMathMLMenclose::computePreferredLogicalWidths() ASSERT(preferredLogicalWidthsDirty()); RenderMathMLBlock::computePreferredLogicalWidths(); - const int paddingTop = 6; - MathMLMencloseElement* menclose = downcast<MathMLMencloseElement>(element()); + MathMLMencloseElement* menclose = toMathMLMencloseElement(element()); const Vector<String>& notationValues = menclose->notationValues(); size_t notationalValueSize = notationValues.size(); for (size_t i = 0; i < notationalValueSize; i++) { if (notationValues[i] == "circle") { - m_minPreferredLogicalWidth = minPreferredLogicalWidth() * sqrtOfTwoFloat; - m_maxPreferredLogicalWidth = maxPreferredLogicalWidth() * sqrtOfTwoFloat; + m_minPreferredLogicalWidth = minPreferredLogicalWidth() * float(sqrtOfTwoDouble); + m_maxPreferredLogicalWidth = maxPreferredLogicalWidth() * float(sqrtOfTwoDouble); } } - if (menclose->isDefaultLongDiv()) { - style().setPaddingTop(Length(paddingTop, Fixed)); - style().setPaddingLeft(Length(menclose->longDivLeftPadding().toInt(), Fixed)); - } setPreferredLogicalWidthsDirty(false); } void RenderMathMLMenclose::updateLogicalHeight() { - MathMLMencloseElement* menclose = downcast<MathMLMencloseElement>(element()); + MathMLMencloseElement* menclose = toMathMLMencloseElement(element()); const Vector<String>& notationValues = menclose->notationValues(); size_t notationalValueSize = notationValues.size(); for (size_t i = 0; i < notationalValueSize; i++) if (notationValues[i] == "circle") - setLogicalHeight(logicalHeight() * sqrtOfTwoFloat); + setLogicalHeight(logicalHeight() * float(sqrtOfTwoDouble)); } void RenderMathMLMenclose::paint(PaintInfo& info, const LayoutPoint& paintOffset) { RenderMathMLBlock::paint(info, paintOffset); - if (info.context().paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE) + if (info.context->paintingDisabled() || info.phase != PaintPhaseForeground || style().visibility() != VISIBLE) return; - MathMLMencloseElement* menclose = downcast<MathMLMencloseElement>(element()); + MathMLMencloseElement* menclose = toMathMLMencloseElement(element()); const Vector<String>& notationValues = menclose->notationValues(); size_t notationalValueSize = notationValues.size(); - bool isDefaultLongDiv = menclose->isDefaultLongDiv(); - if ((notationalValueSize && checkNotationalValuesValidity(notationValues)) || isDefaultLongDiv) { + bool isDefaultLongDiv = !notationalValueSize; + if (notationalValueSize && checkNotationalValuesValidity(notationValues)) { IntRect rect = absoluteBoundingBoxRect(); int left = rect.x(); int top = rect.y(); @@ -113,23 +109,23 @@ void RenderMathMLMenclose::paint(PaintInfo& info, const LayoutPoint& paintOffset int halfboxWidth = rect.width() / 2; int halfboxHeight = rect.height() / 2; - GraphicsContextStateSaver stateSaver(info.context()); - info.context().setStrokeThickness(1); - info.context().setStrokeStyle(SolidStroke); - info.context().setStrokeColor(style().visitedDependentColor(CSSPropertyColor)); + GraphicsContextStateSaver stateSaver(*info.context); + info.context->setStrokeThickness(1); + info.context->setStrokeStyle(SolidStroke); + info.context->setStrokeColor(style().visitedDependentColor(CSSPropertyColor), ColorSpaceDeviceRGB); // TODO add support for notation value updiagonalarrow https://bugs.webkit.org/show_bug.cgi?id=127466 for (size_t i = 0; i < notationalValueSize; i++) { if (notationValues[i] == "updiagonalstrike") - info.context().drawLine(IntPoint(left, top + boxHeight), IntPoint(left + boxWidth, top)); + info.context->drawLine(IntPoint(left, top + boxHeight), IntPoint(left + boxWidth, top)); else if (notationValues[i] == "downdiagonalstrike") - info.context().drawLine(IntPoint(left, top), IntPoint(left + boxWidth, top + boxHeight)); + info.context->drawLine(IntPoint(left, top), IntPoint(left + boxWidth, top + boxHeight)); else if (notationValues[i] == "verticalstrike") - info.context().drawLine(IntPoint(left + halfboxWidth, top), IntPoint(left + halfboxWidth, top + boxHeight)); + info.context->drawLine(IntPoint(left + halfboxWidth, top), IntPoint(left + halfboxWidth, top + boxHeight)); else if (notationValues[i] == "horizontalstrike") - info.context().drawLine(IntPoint(left, top + halfboxHeight), IntPoint(left + boxWidth, top + halfboxHeight)); + info.context->drawLine(IntPoint(left, top + halfboxHeight), IntPoint(left + boxWidth, top + halfboxHeight)); else if (notationValues[i] == "circle") { - info.context().setFillColor(Color::transparent); - info.context().drawEllipse(rect); + info.context->setFillColor(Color::transparent, ColorSpaceDeviceRGB); + info.context->drawEllipse(rect); } else if (notationValues[i] == "longdiv") isDefaultLongDiv = true; } @@ -143,9 +139,7 @@ void RenderMathMLMenclose::paint(PaintInfo& info, const LayoutPoint& paintOffset else midxPoint = style().paddingLeft().value(); root.addBezierCurveTo(FloatPoint(left, top), FloatPoint(left + midxPoint, top + halfboxHeight), FloatPoint(left, top + boxHeight)); - info.context().strokePath(root); - if (isDefaultLongDiv) - info.context().drawLine(IntPoint(left, top), IntPoint(left + boxWidth + midxPoint, top)); + info.context->strokePath(root); } } } |