Use constants from wtf/MathExtras.h
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Oct 2014 18:00:09 +0000 (18:00 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Oct 2014 18:00:09 +0000 (18:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137967

Patch by Milan Crha <mcrha@redhat.com> on 2014-10-28
Reviewed by Darin Adler.

Source/WebCore:

* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::rotateCairoMatrixForVerticalOrientation):
* rendering/mathml/RenderMathMLMenclose.cpp:
(WebCore::RenderMathMLMenclose::computePreferredLogicalWidths):
(WebCore::RenderMathMLMenclose::updateLogicalHeight):
* rendering/mathml/RenderMathMLOperator.cpp:
(WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator):

Source/WTF:

* wtf/MathExtras.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175261 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WTF/ChangeLog
Source/WTF/wtf/MathExtras.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
Source/WebCore/rendering/mathml/RenderMathMLMenclose.cpp
Source/WebCore/rendering/mathml/RenderMathMLOperator.cpp

index 8390b84..65de657 100644 (file)
@@ -1,3 +1,12 @@
+2014-10-28  Milan Crha  <mcrha@redhat.com>
+
+        Use constants from wtf/MathExtras.h
+        https://bugs.webkit.org/show_bug.cgi?id=137967
+
+        Reviewed by Darin Adler.
+
+        * wtf/MathExtras.h:
+
 2014-10-28  Tibor Meszaros  <tmeszaros.u-szeged@partner.samsung.com>
 
         [EFL] Remove unnecessary defines from OptionsEfl.cmake
index 9762928..a43f5d0 100644 (file)
@@ -67,6 +67,14 @@ const double piOverFourDouble = M_PI_4;
 const float piOverFourFloat = static_cast<float>(M_PI_4);
 #endif
 
+#ifndef M_SQRT2
+const double sqrtOfTwoDouble = 1.41421356237309504880;
+const float sqrtOfTwoFloat = 1.41421356237309504880f;
+#else
+const double sqrtOfTwoDouble = M_SQRT2;
+const float sqrtOfTwoFloat = static_cast<float>(M_SQRT2);
+#endif
+
 #if OS(DARWIN)
 
 // Work around a bug in the Mac OS X libc where ceil(-0.1) return +0.
index 0bb03bd..4fbdde9 100644 (file)
@@ -1,3 +1,18 @@
+2014-10-28  Milan Crha  <mcrha@redhat.com>
+
+        Use constants from wtf/MathExtras.h
+        https://bugs.webkit.org/show_bug.cgi?id=137967
+
+        Reviewed by Darin Adler.
+
+        * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
+        (WebCore::rotateCairoMatrixForVerticalOrientation):
+        * rendering/mathml/RenderMathMLMenclose.cpp:
+        (WebCore::RenderMathMLMenclose::computePreferredLogicalWidths):
+        (WebCore::RenderMathMLMenclose::updateLogicalHeight):
+        * rendering/mathml/RenderMathMLOperator.cpp:
+        (WebCore::RenderMathMLOperator::getDisplayStyleLargeOperator):
+
 2014-10-28  David Hyatt  <hyatt@apple.com>
 
         Selection gap painting is ugly for ruby bases.
index 1d4f24d..6f69b07 100644 (file)
@@ -31,6 +31,7 @@
 #include <fontconfig/fcfreetype.h>
 #include <ft2build.h>
 #include FT_TRUETYPE_TABLES_H
+#include <wtf/MathExtras.h>
 #include <wtf/text/WTFString.h>
 
 #if !PLATFORM(EFL)
@@ -120,7 +121,7 @@ static void rotateCairoMatrixForVerticalOrientation(cairo_matrix_t* matrix)
     // combination of rotation (R) and translation (T) applied on the
     // horizontal matrix (H). V = H . R . T, where R rotates by -90 degrees
     // and T translates by font size towards y axis.
-    cairo_matrix_rotate(matrix, -M_PI_2);
+    cairo_matrix_rotate(matrix, -piOverTwoDouble);
     cairo_matrix_translate(matrix, 0.0, 1.0);
 }
 
index f5caae7..6fad22e 100755 (executable)
@@ -72,8 +72,8 @@ void RenderMathMLMenclose::computePreferredLogicalWidths()
     size_t notationalValueSize = notationValues.size();
     for (size_t i = 0; i < notationalValueSize; i++) {
         if (notationValues[i] == "circle") {
-            m_minPreferredLogicalWidth = minPreferredLogicalWidth() * float(M_SQRT2);
-            m_maxPreferredLogicalWidth = maxPreferredLogicalWidth() * float(M_SQRT2);
+            m_minPreferredLogicalWidth = minPreferredLogicalWidth() * sqrtOfTwoFloat;
+            m_maxPreferredLogicalWidth = maxPreferredLogicalWidth() * sqrtOfTwoFloat;
         }
     }
 
@@ -91,7 +91,7 @@ void RenderMathMLMenclose::updateLogicalHeight()
     size_t notationalValueSize = notationValues.size();
     for (size_t i = 0; i < notationalValueSize; i++)
         if (notationValues[i] == "circle")
-            setLogicalHeight(logicalHeight() * float(M_SQRT2));
+            setLogicalHeight(logicalHeight() * sqrtOfTwoFloat);
 }
 
 void RenderMathMLMenclose::paint(PaintInfo& info, const LayoutPoint& paintOffset)
index 3f39d0e..85e1efe 100644 (file)
@@ -1548,7 +1548,7 @@ RenderMathMLOperator::StretchyData RenderMathMLOperator::getDisplayStyleLargeOpe
     Vector<OpenTypeMathData::AssemblyPart> assemblyParts;
 
     // The value of displayOperatorMinHeight is sometimes too small, so we ensure that it is at least \sqrt{2} times the size of the base glyph.
-    float displayOperatorMinHeight = std::max(baseGlyph.fontData->boundsForGlyph(baseGlyph.glyph).height() * float(M_SQRT2), primaryFontData->mathData()->getMathConstant(primaryFontData, OpenTypeMathData::DisplayOperatorMinHeight));
+    float displayOperatorMinHeight = std::max(baseGlyph.fontData->boundsForGlyph(baseGlyph.glyph).height() * sqrtOfTwoFloat, primaryFontData->mathData()->getMathConstant(primaryFontData, OpenTypeMathData::DisplayOperatorMinHeight));
 
     primaryFontData->mathData()->getMathVariants(baseGlyph.glyph, true, sizeVariants, assemblyParts);