| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 // Circles with keywords for radii or center coordinates cannot be animated. | 51 // Circles with keywords for radii or center coordinates cannot be animated. |
| 52 if (type() == BasicShape::BasicShapeCircleType) { | 52 if (type() == BasicShape::BasicShapeCircleType) { |
| 53 const BasicShapeCircle* thisCircle = static_cast<const BasicShapeCircle*
>(this); | 53 const BasicShapeCircle* thisCircle = static_cast<const BasicShapeCircle*
>(this); |
| 54 const BasicShapeCircle* otherCircle = static_cast<const BasicShapeCircle
*>(other); | 54 const BasicShapeCircle* otherCircle = static_cast<const BasicShapeCircle
*>(other); |
| 55 if (!thisCircle->radius().canBlend(otherCircle->radius()) | 55 if (!thisCircle->radius().canBlend(otherCircle->radius()) |
| 56 || !thisCircle->centerX().canBlend(otherCircle->centerX()) | 56 || !thisCircle->centerX().canBlend(otherCircle->centerX()) |
| 57 || !thisCircle->centerY().canBlend(otherCircle->centerY())) | 57 || !thisCircle->centerY().canBlend(otherCircle->centerY())) |
| 58 return false; | 58 return false; |
| 59 } | 59 } |
| 60 | 60 |
| 61 return true; | 61 // Ellipses with keywords for radii or center coordinates cannot be animated
. |
| 62 if (type() != BasicShape::BasicShapeEllipseType) |
| 63 return true; |
| 64 |
| 65 const BasicShapeEllipse* thisEllipse = static_cast<const BasicShapeEllipse*>
(this); |
| 66 const BasicShapeEllipse* otherEllipse = static_cast<const BasicShapeEllipse*
>(other); |
| 67 return (thisEllipse->radiusX().canBlend(otherEllipse->radiusX()) |
| 68 && thisEllipse->radiusY().canBlend(otherEllipse->radiusY()) |
| 69 && thisEllipse->centerX().canBlend(otherEllipse->centerX()) |
| 70 && thisEllipse->centerY().canBlend(otherEllipse->centerY())); |
| 62 } | 71 } |
| 63 | 72 |
| 64 void BasicShapeRectangle::path(Path& path, const FloatRect& boundingBox) | 73 void BasicShapeRectangle::path(Path& path, const FloatRect& boundingBox) |
| 65 { | 74 { |
| 66 ASSERT(path.isEmpty()); | 75 ASSERT(path.isEmpty()); |
| 67 path.addRoundedRect( | 76 path.addRoundedRect( |
| 68 FloatRect( | 77 FloatRect( |
| 69 floatValueForLength(m_x, boundingBox.width()) + boundingBox.x(), | 78 floatValueForLength(m_x, boundingBox.width()) + boundingBox.x(), |
| 70 floatValueForLength(m_y, boundingBox.height()) + boundingBox.y(), | 79 floatValueForLength(m_y, boundingBox.height()) + boundingBox.y(), |
| 71 floatValueForLength(m_width, boundingBox.width()), | 80 floatValueForLength(m_width, boundingBox.width()), |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 } | 229 } |
| 221 | 230 |
| 222 bool BasicShapeEllipse::operator==(const BasicShape& o) const | 231 bool BasicShapeEllipse::operator==(const BasicShape& o) const |
| 223 { | 232 { |
| 224 if (!isSameType(o)) | 233 if (!isSameType(o)) |
| 225 return false; | 234 return false; |
| 226 const BasicShapeEllipse& other = toBasicShapeEllipse(o); | 235 const BasicShapeEllipse& other = toBasicShapeEllipse(o); |
| 227 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == other.m_radiusY; | 236 return m_centerX == other.m_centerX && m_centerY == other.m_centerY && m_rad
iusX == other.m_radiusX && m_radiusY == other.m_radiusY; |
| 228 } | 237 } |
| 229 | 238 |
| 239 float BasicShapeEllipse::floatValueForRadiusInBox(const BasicShapeRadius& radius
, float center, float boxWidthOrHeight) const |
| 240 { |
| 241 if (radius.type() == BasicShapeRadius::Value) |
| 242 return floatValueForLength(radius.value(), boxWidthOrHeight); |
| 243 |
| 244 if (radius.type() == BasicShapeRadius::ClosestSide) |
| 245 return std::min(center, boxWidthOrHeight - center); |
| 246 |
| 247 ASSERT(radius.type() == BasicShapeRadius::FarthestSide); |
| 248 return std::max(center, boxWidthOrHeight - center); |
| 249 } |
| 250 |
| 230 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) | 251 void BasicShapeEllipse::path(Path& path, const FloatRect& boundingBox) |
| 231 { | 252 { |
| 232 ASSERT(path.isEmpty()); | 253 ASSERT(path.isEmpty()); |
| 233 // FIXME Complete implementation of path. Bug 124619. | 254 FloatPoint center = floatPointForCenterCoordinate(m_centerX, m_centerY, boun
dingBox.size()); |
| 234 // Compute closest-side and farthest-side from boundingBox. | 255 float radiusX = floatValueForRadiusInBox(m_radiusX, center.x(), boundingBox.
width()); |
| 235 // Compute top, left, bottom, right from boundingBox. | 256 float radiusY = floatValueForRadiusInBox(m_radiusY, center.y(), boundingBox.
height()); |
| 236 if (m_radiusX.type() != BasicShapeRadius::Value || m_radiusY.type() != Basic
ShapeRadius::Value) | |
| 237 return; | |
| 238 if (m_centerX.keyword() != BasicShapeCenterCoordinate::None || m_centerY.key
word() != BasicShapeCenterCoordinate::None) | |
| 239 return; | |
| 240 | |
| 241 float diagonal = hypotf(boundingBox.width(), boundingBox.height()) / sqrtf(2
); | |
| 242 float centerX = floatValueForLength(m_centerX.length(), boundingBox.width())
; | |
| 243 float centerY = floatValueForLength(m_centerY.length(), boundingBox.height()
); | |
| 244 float radiusX = floatValueForLength(m_radiusX.value(), diagonal); | |
| 245 float radiusY = floatValueForLength(m_radiusY.value(), diagonal); | |
| 246 path.addEllipse(FloatRect( | 257 path.addEllipse(FloatRect( |
| 247 centerX - radiusX + boundingBox.x(), | 258 center.x() - radiusX + boundingBox.x(), |
| 248 centerY - radiusY + boundingBox.y(), | 259 center.y() - radiusY + boundingBox.y(), |
| 249 radiusX * 2, | 260 radiusX * 2, |
| 250 radiusY * 2 | 261 radiusY * 2 |
| 251 )); | 262 )); |
| 252 } | 263 } |
| 253 | 264 |
| 254 PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double
progress) const | 265 PassRefPtr<BasicShape> BasicShapeEllipse::blend(const BasicShape* other, double
progress) const |
| 255 { | 266 { |
| 256 ASSERT(type() == other->type()); | 267 ASSERT(type() == other->type()); |
| 257 const BasicShapeEllipse* o = static_cast<const BasicShapeEllipse*>(other); | 268 const BasicShapeEllipse* o = static_cast<const BasicShapeEllipse*>(other); |
| 258 RefPtr<BasicShapeEllipse> result = BasicShapeEllipse::create(); | 269 RefPtr<BasicShapeEllipse> result = BasicShapeEllipse::create(); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 } | 368 } |
| 358 | 369 |
| 359 bool BasicShapeInsetRectangle::operator==(const BasicShape& o) const | 370 bool BasicShapeInsetRectangle::operator==(const BasicShape& o) const |
| 360 { | 371 { |
| 361 if (!isSameType(o)) | 372 if (!isSameType(o)) |
| 362 return false; | 373 return false; |
| 363 const BasicShapeInsetRectangle& other = toBasicShapeInsetRectangle(o); | 374 const BasicShapeInsetRectangle& other = toBasicShapeInsetRectangle(o); |
| 364 return m_right == other.m_right && m_top == other.m_top && m_bottom == other
.m_bottom && m_left == other.m_left && m_cornerRadiusX == other.m_cornerRadiusX
&& m_cornerRadiusY == other.m_cornerRadiusY; | 375 return m_right == other.m_right && m_top == other.m_top && m_bottom == other
.m_bottom && m_left == other.m_left && m_cornerRadiusX == other.m_cornerRadiusX
&& m_cornerRadiusY == other.m_cornerRadiusY; |
| 365 } | 376 } |
| 366 } | 377 } |
| OLD | NEW |