| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2015 Google Inc. All rights reserved. | 3 * Copyright (C) 2015 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 return compare(dx, dy) ? FloatSize(dx, dx) : FloatSize(dy, dy); | 1046 return compare(dx, dy) ? FloatSize(dx, dx) : FloatSize(dy, dy); |
| 1047 | 1047 |
| 1048 ASSERT(shape == EllipseEndShape); | 1048 ASSERT(shape == EllipseEndShape); |
| 1049 return FloatSize(dx, dy); | 1049 return FloatSize(dx, dy); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 // Compute the radius of an ellipse with center at 0,0 which passes through p, a
nd has | 1052 // Compute the radius of an ellipse with center at 0,0 which passes through p, a
nd has |
| 1053 // width/height given by aspectRatio. | 1053 // width/height given by aspectRatio. |
| 1054 inline FloatSize ellipseRadius(const FloatPoint& p, float aspectRatio) | 1054 inline FloatSize ellipseRadius(const FloatPoint& p, float aspectRatio) |
| 1055 { | 1055 { |
| 1056 // If the aspectRatio is 0 or infinite, the ellipse is completely flat. |
| 1057 // TODO(sashab): Implement Degenerate Radial Gradients, see crbug.com/635727
. |
| 1058 if (aspectRatio == 0 || std::isinf(aspectRatio)) |
| 1059 return FloatSize(0, 0); |
| 1060 |
| 1056 // x^2/a^2 + y^2/b^2 = 1 | 1061 // x^2/a^2 + y^2/b^2 = 1 |
| 1057 // a/b = aspectRatio, b = a/aspectRatio | 1062 // a/b = aspectRatio, b = a/aspectRatio |
| 1058 // a = sqrt(x^2 + y^2/(1/r^2)) | 1063 // a = sqrt(x^2 + y^2/(1/r^2)) |
| 1059 float a = sqrtf(p.x() * p.x() + p.y() * p.y() * aspectRatio * aspectRatio); | 1064 float a = sqrtf(p.x() * p.x() + p.y() * p.y() * aspectRatio * aspectRatio); |
| 1060 return FloatSize(clampTo<float>(a), clampTo<float>(a / aspectRatio)); | 1065 return FloatSize(clampTo<float>(a), clampTo<float>(a / aspectRatio)); |
| 1061 } | 1066 } |
| 1062 | 1067 |
| 1063 // Compute the radius to the closest/farthest corner (depending on the compare f
unctor). | 1068 // Compute the radius to the closest/farthest corner (depending on the compare f
unctor). |
| 1064 FloatSize radiusToCorner(const FloatPoint& point, const FloatSize& size, EndShap
eType shape, | 1069 FloatSize radiusToCorner(const FloatPoint& point, const FloatSize& size, EndShap
eType shape, |
| 1065 bool (*compare)(float, float)) | 1070 bool (*compare)(float, float)) |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 visitor->trace(m_firstRadius); | 1227 visitor->trace(m_firstRadius); |
| 1223 visitor->trace(m_secondRadius); | 1228 visitor->trace(m_secondRadius); |
| 1224 visitor->trace(m_shape); | 1229 visitor->trace(m_shape); |
| 1225 visitor->trace(m_sizingBehavior); | 1230 visitor->trace(m_sizingBehavior); |
| 1226 visitor->trace(m_endHorizontalSize); | 1231 visitor->trace(m_endHorizontalSize); |
| 1227 visitor->trace(m_endVerticalSize); | 1232 visitor->trace(m_endVerticalSize); |
| 1228 CSSGradientValue::traceAfterDispatch(visitor); | 1233 CSSGradientValue::traceAfterDispatch(visitor); |
| 1229 } | 1234 } |
| 1230 | 1235 |
| 1231 } // namespace blink | 1236 } // namespace blink |
| OLD | NEW |