Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2012 Adobe Systems Incorporated. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
| 9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
| 10 * disclaimer. | 10 * disclaimer. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 73 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad ius == other.m_radius; | 73 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad ius == other.m_radius; |
| 74 } | 74 } |
| 75 | 75 |
| 76 float BasicShapeCircle::floatValueForRadiusInBox(FloatSize boxSize) const | 76 float BasicShapeCircle::floatValueForRadiusInBox(FloatSize boxSize) const |
| 77 { | 77 { |
| 78 if (m_radius.type() == BasicShapeRadius::Value) | 78 if (m_radius.type() == BasicShapeRadius::Value) |
| 79 return floatValueForLength(m_radius.value(), hypotf(boxSize.width(), box Size.height()) / sqrtf(2)); | 79 return floatValueForLength(m_radius.value(), hypotf(boxSize.width(), box Size.height()) / sqrtf(2)); |
| 80 | 80 |
| 81 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boxS ize); | 81 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boxS ize); |
| 82 | 82 |
| 83 float radiusX, radiusY; | |
|
Bem Jones-Bey (adobe)
2015/02/19 18:41:06
This naming confused me. What we have here is not
| |
| 84 if (center.x() < boxSize.width()) | |
| 85 radiusX = boxSize.width() - center.x(); | |
| 86 else | |
| 87 radiusX = center.x() - boxSize.width(); | |
| 88 if (center.y() < boxSize.height()) | |
| 89 radiusY = boxSize.height() - center.y(); | |
| 90 else | |
| 91 radiusY = center.y() - boxSize.height(); | |
| 83 if (m_radius.type() == BasicShapeRadius::ClosestSide) | 92 if (m_radius.type() == BasicShapeRadius::ClosestSide) |
| 84 return std::min(std::min(center.x(), boxSize.width() - center.x()), std: :min(center.y(), boxSize.height() - center.y())); | 93 return std::min(std::min(std::abs(center.x()), radiusX), std::min(std::a bs(center.y()), radiusY)); |
| 85 | 94 |
| 86 // If radius.type() == BasicShapeRadius::FarthestSide. | 95 // If radius.type() == BasicShapeRadius::FarthestSide. |
| 87 return std::max(std::max(center.x(), boxSize.width() - center.x()), std::max (center.y(), boxSize.height() - center.y())); | 96 return std::max(std::max(center.x(), radiusX), std::max(center.y(), radiusY) ); |
| 88 } | 97 } |
| 89 | 98 |
| 90 void BasicShapeCircle::path(Path& path, const FloatRect& boundingBox) | 99 void BasicShapeCircle::path(Path& path, const FloatRect& boundingBox) |
| 91 { | 100 { |
| 92 ASSERT(path.isEmpty()); | 101 ASSERT(path.isEmpty()); |
| 93 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun dingBox.size()); | 102 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun dingBox.size()); |
| 94 float radius = floatValueForRadiusInBox(boundingBox.size()); | 103 float radius = floatValueForRadiusInBox(boundingBox.size()); |
| 95 path.addEllipse(FloatRect( | 104 path.addEllipse(FloatRect( |
| 96 center.x() - radius + boundingBox.x(), | 105 center.x() - radius + boundingBox.x(), |
| 97 center.y() - radius + boundingBox.y(), | 106 center.y() - radius + boundingBox.y(), |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 119 const BasicShapeEllipse& other = toBasicShapeEllipse(o); | 128 const BasicShapeEllipse& other = toBasicShapeEllipse(o); |
| 120 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad iusX == other.m_radiusX && m_radiusY == other.m_radiusY; | 129 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad iusX == other.m_radiusX && m_radiusY == other.m_radiusY; |
| 121 } | 130 } |
| 122 | 131 |
| 123 float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius , float center, float boxWidthOrHeight) const | 132 float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius , float center, float boxWidthOrHeight) const |
| 124 { | 133 { |
| 125 if (radius.type() == BasicShapeRadius::Value) | 134 if (radius.type() == BasicShapeRadius::Value) |
| 126 return floatValueForLength(radius.value(), boxWidthOrHeight); | 135 return floatValueForLength(radius.value(), boxWidthOrHeight); |
| 127 | 136 |
| 128 if (radius.type() == BasicShapeRadius::ClosestSide) | 137 if (radius.type() == BasicShapeRadius::ClosestSide) |
| 129 return std::min(center, boxWidthOrHeight - center); | 138 return std::min(std::abs(center), boxWidthOrHeight > center ? boxWidthOr Height - center : center - boxWidthOrHeight); |
| 130 | 139 |
| 131 ASSERT(radius.type() == BasicShapeRadius::FarthestSide); | 140 ASSERT(radius.type() == BasicShapeRadius::FarthestSide); |
| 132 return std::max(center, boxWidthOrHeight - center); | 141 return std::max(center, boxWidthOrHeight > center ? boxWidthOrHeight - cente r : center - boxWidthOrHeight); |
| 133 } | 142 } |
| 134 | 143 |
| 135 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) | 144 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) |
| 136 { | 145 { |
| 137 ASSERT(path.isEmpty()); | 146 ASSERT(path.isEmpty()); |
| 138 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun dingBox.size()); | 147 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun dingBox.size()); |
| 139 float radiusX = floatValueForRadiusInBox(m_radiusX, center.x(), boundingBox. width()); | 148 float radiusX = floatValueForRadiusInBox(m_radiusX, center.x(), boundingBox. width()); |
| 140 float radiusY = floatValueForRadiusInBox(m_radiusY, center.y(), boundingBox. height()); | 149 float radiusY = floatValueForRadiusInBox(m_radiusY, center.y(), boundingBox. height()); |
| 141 path.addEllipse(FloatRect( | 150 path.addEllipse(FloatRect( |
| 142 center.x() - radiusX + boundingBox.x(), | 151 center.x() - radiusX + boundingBox.x(), |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 && m_top == other.m_top | 284 && m_top == other.m_top |
| 276 && m_bottom == other.m_bottom | 285 && m_bottom == other.m_bottom |
| 277 && m_left == other.m_left | 286 && m_left == other.m_left |
| 278 && m_topLeftRadius == other.m_topLeftRadius | 287 && m_topLeftRadius == other.m_topLeftRadius |
| 279 && m_topRightRadius == other.m_topRightRadius | 288 && m_topRightRadius == other.m_topRightRadius |
| 280 && m_bottomRightRadius == other.m_bottomRightRadius | 289 && m_bottomRightRadius == other.m_bottomRightRadius |
| 281 && m_bottomLeftRadius == other.m_bottomLeftRadius; | 290 && m_bottomLeftRadius == other.m_bottomLeftRadius; |
| 282 } | 291 } |
| 283 | 292 |
| 284 } | 293 } |
| OLD | NEW |