| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org> | 4 * Copyright (C) 2010 Dirk Schulze <krit@webkit.org> |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 destRect.setX(destRect.x() + origDestWidth - destRect.width()); | 230 destRect.setX(destRect.x() + origDestWidth - destRect.width()); |
| 231 break; | 231 break; |
| 232 default: | 232 default: |
| 233 break; | 233 break; |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 break; | 236 break; |
| 237 } | 237 } |
| 238 case SVGPreserveAspectRatio::kSvgMeetorsliceSlice: { | 238 case SVGPreserveAspectRatio::kSvgMeetorsliceSlice: { |
| 239 float widthToHeightMultiplier = srcRect.height() / srcRect.width(); | 239 float widthToHeightMultiplier = srcRect.height() / srcRect.width(); |
| 240 // if the destination height is less than the height of the image we'll be
drawing | 240 // If the destination height is less than the height of the image we'll be |
| 241 // drawing. |
| 241 if (origDestHeight < origDestWidth * widthToHeightMultiplier) { | 242 if (origDestHeight < origDestWidth * widthToHeightMultiplier) { |
| 242 float destToSrcMultiplier = srcRect.width() / destRect.width(); | 243 float destToSrcMultiplier = srcRect.width() / destRect.width(); |
| 243 srcRect.setHeight(destRect.height() * destToSrcMultiplier); | 244 srcRect.setHeight(destRect.height() * destToSrcMultiplier); |
| 244 switch (m_align) { | 245 switch (m_align) { |
| 245 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXminymid: | 246 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXminymid: |
| 246 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymid: | 247 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymid: |
| 247 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmaxymid: | 248 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmaxymid: |
| 248 srcRect.setY(srcRect.y() + imageSize.height() / 2 - | 249 srcRect.setY(srcRect.y() + imageSize.height() / 2 - |
| 249 srcRect.height() / 2); | 250 srcRect.height() / 2); |
| 250 break; | 251 break; |
| 251 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXminymax: | 252 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXminymax: |
| 252 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymax: | 253 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymax: |
| 253 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmaxymax: | 254 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmaxymax: |
| 254 srcRect.setY(srcRect.y() + imageSize.height() - srcRect.height()); | 255 srcRect.setY(srcRect.y() + imageSize.height() - srcRect.height()); |
| 255 break; | 256 break; |
| 256 default: | 257 default: |
| 257 break; | 258 break; |
| 258 } | 259 } |
| 259 } | 260 } |
| 260 // if the destination width is less than the width of the image we'll be d
rawing | 261 // If the destination width is less than the width of the image we'll be |
| 262 // drawing. |
| 261 if (origDestWidth < origDestHeight / widthToHeightMultiplier) { | 263 if (origDestWidth < origDestHeight / widthToHeightMultiplier) { |
| 262 float destToSrcMultiplier = srcRect.height() / destRect.height(); | 264 float destToSrcMultiplier = srcRect.height() / destRect.height(); |
| 263 srcRect.setWidth(destRect.width() * destToSrcMultiplier); | 265 srcRect.setWidth(destRect.width() * destToSrcMultiplier); |
| 264 switch (m_align) { | 266 switch (m_align) { |
| 265 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymin: | 267 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymin: |
| 266 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymid: | 268 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymid: |
| 267 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymax: | 269 case SVGPreserveAspectRatio::kSvgPreserveaspectratioXmidymax: |
| 268 srcRect.setX(srcRect.x() + imageSize.width() / 2 - | 270 srcRect.setX(srcRect.x() + imageSize.width() / 2 - |
| 269 srcRect.width() / 2); | 271 srcRect.width() / 2); |
| 270 break; | 272 break; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 m_meetOrSlice = preserveAspectRatioToUse->m_meetOrSlice; | 453 m_meetOrSlice = preserveAspectRatioToUse->m_meetOrSlice; |
| 452 } | 454 } |
| 453 | 455 |
| 454 float SVGPreserveAspectRatio::calculateDistance(SVGPropertyBase* toValue, | 456 float SVGPreserveAspectRatio::calculateDistance(SVGPropertyBase* toValue, |
| 455 SVGElement* contextElement) { | 457 SVGElement* contextElement) { |
| 456 // No paced animations for SVGPreserveAspectRatio. | 458 // No paced animations for SVGPreserveAspectRatio. |
| 457 return -1; | 459 return -1; |
| 458 } | 460 } |
| 459 | 461 |
| 460 } // namespace blink | 462 } // namespace blink |
| OLD | NEW |