OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. |
3 * Copyright (C) 2005 Nokia. All rights reserved. | 3 * Copyright (C) 2005 Nokia. 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 } | 164 } |
165 | 165 |
166 void FloatRect::scale(float sx, float sy) | 166 void FloatRect::scale(float sx, float sy) |
167 { | 167 { |
168 m_location.setX(x() * sx); | 168 m_location.setX(x() * sx); |
169 m_location.setY(y() * sy); | 169 m_location.setY(y() * sy); |
170 m_size.setWidth(width() * sx); | 170 m_size.setWidth(width() * sx); |
171 m_size.setHeight(height() * sy); | 171 m_size.setHeight(height() * sy); |
172 } | 172 } |
173 | 173 |
| 174 float FloatRect::squaredDistanceTo(const FloatPoint& point) const |
| 175 { |
| 176 FloatPoint closestPoint; |
| 177 closestPoint.setX(clampTo<float>(point.x(), x(), maxX())); |
| 178 closestPoint.setY(clampTo<float>(point.y(), y(), maxY())); |
| 179 return (point - closestPoint).diagonalLengthSquared(); |
| 180 } |
| 181 |
174 FloatRect unionRect(const Vector<FloatRect>& rects) | 182 FloatRect unionRect(const Vector<FloatRect>& rects) |
175 { | 183 { |
176 FloatRect result; | 184 FloatRect result; |
177 | 185 |
178 size_t count = rects.size(); | 186 size_t count = rects.size(); |
179 for (size_t i = 0; i < count; ++i) | 187 for (size_t i = 0; i < count; ++i) |
180 result.unite(rects[i]); | 188 result.unite(rects[i]); |
181 | 189 |
182 return result; | 190 return result; |
183 } | 191 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 return FloatRect(); | 226 return FloatRect(); |
219 | 227 |
220 float widthScale = destRect.width() / srcRect.width(); | 228 float widthScale = destRect.width() / srcRect.width(); |
221 float heightScale = destRect.height() / srcRect.height(); | 229 float heightScale = destRect.height() / srcRect.height(); |
222 return FloatRect(destRect.x() + (r.x() - srcRect.x()) * widthScale, | 230 return FloatRect(destRect.x() + (r.x() - srcRect.x()) * widthScale, |
223 destRect.y() + (r.y() - srcRect.y()) * heightScale, | 231 destRect.y() + (r.y() - srcRect.y()) * heightScale, |
224 r.width() * widthScale, r.height() * heightScale); | 232 r.width() * widthScale, r.height() * heightScale); |
225 } | 233 } |
226 | 234 |
227 } | 235 } |
OLD | NEW |