Diff
Modified: trunk/Source/WebCore/ChangeLog (129004 => 129005)
--- trunk/Source/WebCore/ChangeLog 2012-09-19 14:37:11 UTC (rev 129004)
+++ trunk/Source/WebCore/ChangeLog 2012-09-19 14:42:52 UTC (rev 129005)
@@ -1,3 +1,27 @@
+2012-09-19 Patrick Gansterer <[email protected]>
+
+ Remove all usages of M_PI from WebCore
+ https://bugs.webkit.org/show_bug.cgi?id=93109
+
+ Reviewed by Dirk Schulze.
+
+ <wtf/MathExtras.h> implements many functions dealing with M_PI.
+ Use them in WebCore instead of duplicating the functionality.
+
+ * platform/blackberry/PlatformTouchEventBlackBerry.cpp:
+ (WebCore::PlatformTouchEvent::PlatformTouchEvent):
+ * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+ (PlatformCALayer::setFilters):
+ * platform/graphics/cairo/GraphicsContextCairo.cpp:
+ (WebCore::GraphicsContext::drawEllipse):
+ (WebCore::GraphicsContext::strokeArc):
+ * platform/graphics/wx/FontPlatformDataWxMac.mm:
+ * platform/mac/WebWindowAnimation.mm:
+ (-[WebWindowScaleAnimation currentValue]):
+ * platform/wx/wxcode/gdiplus/non-kerned-drawing.cpp:
+ (DegToRad):
+ (RadToDeg):
+
2012-09-10 Vsevolod Vlasov <[email protected]>
Web Inspector: Network request headers text fallback has typo.
Modified: trunk/Source/WebCore/platform/blackberry/PlatformTouchEventBlackBerry.cpp (129004 => 129005)
--- trunk/Source/WebCore/platform/blackberry/PlatformTouchEventBlackBerry.cpp 2012-09-19 14:37:11 UTC (rev 129004)
+++ trunk/Source/WebCore/platform/blackberry/PlatformTouchEventBlackBerry.cpp 2012-09-19 14:42:52 UTC (rev 129005)
@@ -22,12 +22,12 @@
#include "config.h"
#include "PlatformTouchEvent.h"
+#if ENABLE(TOUCH_EVENTS)
+
#include <BlackBerryPlatformTouchEvent.h>
-
#include <wtf/CurrentTime.h>
+#include <wtf/MathExtras.h>
-#if ENABLE(TOUCH_EVENTS)
-
namespace WebCore {
static PlatformEvent::Type touchEventType(BlackBerry::Platform::TouchEvent* event)
@@ -66,7 +66,7 @@
if (event->hasGesture(BlackBerry::Platform::Gesture::Pinch, &pinch)) {
BlackBerry::Platform::PinchGestureData* data = ""
if (data) {
- m_rotation = data->m_angle * 180 / M_PI;
+ m_rotation = rad2deg(data->m_angle);
m_scale = data->m_scale;
}
} else if (event->hasGesture(BlackBerry::Platform::Gesture::DoubleTap))
Modified: trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm (129004 => 129005)
--- trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm 2012-09-19 14:37:11 UTC (rev 129004)
+++ trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm 2012-09-19 14:42:52 UTC (rev 129005)
@@ -42,6 +42,7 @@
#import <objc/objc-runtime.h>
#import <QuartzCore/QuartzCore.h>
#import <wtf/CurrentTime.h>
+#import <wtf/MathExtras.h>
#import <wtf/UnusedParam.h>
using std::min;
@@ -755,7 +756,7 @@
[caFilter setDefaults];
// The CIHueAdjust value is in radians
- [caFilter setValue:[NSNumber numberWithFloat:op->amount() * M_PI * 2 / 360] forKey:@"inputAngle"];
+ [caFilter setValue:[NSNumber numberWithFloat:deg2rad(op->amount())] forKey:@"inputAngle"];
[caFilter setName:filterName];
[array.get() addObject:caFilter];
break;
Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (129004 => 129005)
--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2012-09-19 14:37:11 UTC (rev 129004)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp 2012-09-19 14:42:52 UTC (rev 129005)
@@ -65,10 +65,6 @@
using namespace std;
-#ifndef M_PI
-#define M_PI 3.14159265358979323846
-#endif
-
namespace WebCore {
// A helper which quickly fills a rectangle with a simple color fill.
@@ -353,7 +349,7 @@
float xRadius = .5 * rect.width();
cairo_translate(cr, rect.x() + xRadius, rect.y() + yRadius);
cairo_scale(cr, xRadius, yRadius);
- cairo_arc(cr, 0., 0., 1., 0., 2 * M_PI);
+ cairo_arc(cr, 0., 0., 1., 0., 2 * piFloat);
cairo_restore(cr);
if (fillColor().alpha()) {
@@ -392,7 +388,7 @@
if (w != h)
cairo_scale(cr, 1., scaleFactor);
- cairo_arc_negative(cr, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, -fa * M_PI/180, -falen * M_PI/180);
+ cairo_arc_negative(cr, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, deg2rad(-fa), deg2rad(-falen));
if (w != h)
cairo_scale(cr, 1., reverseScaleFactor);
Modified: trunk/Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm (129004 => 129005)
--- trunk/Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm 2012-09-19 14:37:11 UTC (rev 129004)
+++ trunk/Source/WebCore/platform/graphics/wx/FontPlatformDataWxMac.mm 2012-09-19 14:42:52 UTC (rev 129005)
@@ -29,6 +29,7 @@
#include "config.h"
#include "FontPlatformData.h"
+#include <wtf/MathExtras.h>
#include <wx/defs.h>
#include <wx/font.h>
#include <wx/fontutil.h>
@@ -41,13 +42,8 @@
#if !wxCHECK_VERSION(2,9,0) || !wxOSX_USE_COCOA
-static inline double DegToRad(double deg)
-{
- return (deg * M_PI) / 180.0;
-}
+static const NSAffineTransformStruct kSlantNSTransformStruct = { 1, 0, tan(deg2rad(11)), 1, 0, 0 };
-static const NSAffineTransformStruct kSlantNSTransformStruct = { 1, 0, tan(DegToRad(11)), 1, 0, 0 };
-
NSFont* OSXCreateNSFont(const wxNativeFontInfo* info)
{
NSFont* nsFont;
Modified: trunk/Source/WebCore/platform/mac/WebWindowAnimation.mm (129004 => 129005)
--- trunk/Source/WebCore/platform/mac/WebWindowAnimation.mm 2012-09-19 14:37:11 UTC (rev 129004)
+++ trunk/Source/WebCore/platform/mac/WebWindowAnimation.mm 2012-09-19 14:42:52 UTC (rev 129005)
@@ -30,6 +30,7 @@
#import "FloatConversion.h"
#import "WebCoreSystemInterface.h"
#import <wtf/Assertions.h>
+#import <wtf/MathExtras.h>
#import <wtf/UnusedParam.h>
using namespace WebCore;
@@ -101,7 +102,7 @@
- (float)currentValue
{
- return narrowPrecisionToFloat(0.5 - 0.5 * cos(M_PI * (1 - [self currentProgress])));
+ return narrowPrecisionToFloat(0.5 - 0.5 * cos(piDouble * (1 - [self currentProgress])));
}
- (NSRect)currentFrame
Modified: trunk/Source/WebCore/platform/wx/wxcode/gdiplus/non-kerned-drawing.cpp (129004 => 129005)
--- trunk/Source/WebCore/platform/wx/wxcode/gdiplus/non-kerned-drawing.cpp 2012-09-19 14:37:11 UTC (rev 129004)
+++ trunk/Source/WebCore/platform/wx/wxcode/gdiplus/non-kerned-drawing.cpp 2012-09-19 14:42:52 UTC (rev 129005)
@@ -29,7 +29,7 @@
#include "GlyphBuffer.h"
#include "GraphicsContext.h"
#include "SimpleFontData.h"
-
+#include <wtf/MathExtras.h>
#include <wx/defs.h>
#if 1 // !wxUSE_CAIRO
@@ -45,7 +45,7 @@
// constants
//-----------------------------------------------------------------------------
-const double RAD2DEG = 180.0 / M_PI;
+const double RAD2DEG = 180.0 / piDouble;
//-----------------------------------------------------------------------------
// Local functions
@@ -54,8 +54,8 @@
static inline double dmin(double a, double b) { return a < b ? a : b; }
static inline double dmax(double a, double b) { return a > b ? a : b; }
-static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
-static inline double RadToDeg(double deg) { return (deg * 180.0) / M_PI; }
+static inline double DegToRad(double deg) { return deg2rad(deg); }
+static inline double RadToDeg(double rad) { return rad2deg(rad); }
#include "wx/msw/private.h"