summaryrefslogtreecommitdiffstats
path: root/WebCore/svg/SVGRadialGradientElement.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2009-12-15 10:12:09 +0000
committerSteve Block <steveblock@google.com>2009-12-17 17:41:10 +0000
commit643ca7872b450ea4efacab6188849e5aac2ba161 (patch)
tree6982576c228bcd1a7efe98afed544d840751094c /WebCore/svg/SVGRadialGradientElement.cpp
parentd026980fde6eb3b01c1fe49441174e89cd1be298 (diff)
downloadexternal_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.zip
external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.tar.gz
external_webkit-643ca7872b450ea4efacab6188849e5aac2ba161.tar.bz2
Merge webkit.org at r51976 : Initial merge by git.
Change-Id: Ib0e7e2f0fb4bee5a186610272edf3186f0986b43
Diffstat (limited to 'WebCore/svg/SVGRadialGradientElement.cpp')
-rw-r--r--WebCore/svg/SVGRadialGradientElement.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/WebCore/svg/SVGRadialGradientElement.cpp b/WebCore/svg/SVGRadialGradientElement.cpp
index a9b5cff..270de6f 100644
--- a/WebCore/svg/SVGRadialGradientElement.cpp
+++ b/WebCore/svg/SVGRadialGradientElement.cpp
@@ -105,23 +105,37 @@ void SVGRadialGradientElement::buildGradient() const
radius = attributes.r().value(this);
}
- float adjustedFocusX = focalPoint.x();
- float adjustedFocusY = focalPoint.y();
-
- float fdx = focalPoint.x() - centerPoint.x();
- float fdy = focalPoint.y() - centerPoint.y();
+ FloatPoint adjustedFocalPoint = focalPoint;
+ float dfx = focalPoint.x() - centerPoint.x();
+ float dfy = focalPoint.y() - centerPoint.y();
// Spec: If (fx, fy) lies outside the circle defined by (cx, cy) and
// r, set (fx, fy) to the point of intersection of the line through
// (fx, fy) and the circle.
- if (sqrt(fdx * fdx + fdy * fdy) > radius) {
- float angle = atan2f(focalPoint.y() * 100.0f, focalPoint.x() * 100.0f);
- adjustedFocusX = cosf(angle) * radius;
- adjustedFocusY = sinf(angle) * radius;
+ if (sqrt(dfx * dfx + dfy * dfy) >= radius) {
+ float angle = atan2f(dfx, dfy);
+
+ // The maximum deviation of 0.2% is needed on Cairo, since Cairo
+ // is working with fixed point numbers.
+#if PLATFORM(CAIRO)
+ if (focalPoint.x() < centerPoint.x())
+ dfx = cosf(angle) * radius + 0.002f;
+ else
+ dfx = cosf(angle) * radius - 0.002f;
+ if (focalPoint.y() < centerPoint.y())
+ dfy = sinf(angle) * radius + 0.002f;
+ else
+ dfy = sinf(angle) * radius - 0.002f;
+#else
+ dfx = cosf(angle) * radius;
+ dfy = sinf(angle) * radius;
+#endif
+
+ adjustedFocalPoint = FloatPoint(dfx + centerPoint.x(), dfy + centerPoint.y());
}
RefPtr<Gradient> gradient = Gradient::create(
- FloatPoint(adjustedFocusX, adjustedFocusY),
+ adjustedFocalPoint,
0.f, // SVG does not support a "focus radius"
centerPoint,
radius);