OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2006 Eric Seidel <eric@webkit.org> |
3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. | 3 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. |
4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 double intrinsicRatio = 0; | 171 double intrinsicRatio = 0; |
172 renderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio); | 172 renderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio); |
173 | 173 |
174 if (intrinsicSize.isEmpty() && intrinsicRatio) { | 174 if (intrinsicSize.isEmpty() && intrinsicRatio) { |
175 if (!intrinsicSize.width() && intrinsicSize.height()) | 175 if (!intrinsicSize.width() && intrinsicSize.height()) |
176 intrinsicSize.setWidth(intrinsicSize.height() * intrinsicRatio); | 176 intrinsicSize.setWidth(intrinsicSize.height() * intrinsicRatio); |
177 else if (intrinsicSize.width() && !intrinsicSize.height()) | 177 else if (intrinsicSize.width() && !intrinsicSize.height()) |
178 intrinsicSize.setHeight(intrinsicSize.width() / intrinsicRatio); | 178 intrinsicSize.setHeight(intrinsicSize.width() / intrinsicRatio); |
179 } | 179 } |
180 | 180 |
| 181 // TODO(davve): In order to maintain aspect ratio the intrinsic |
| 182 // size is faked from the viewBox as a last resort. This may cause |
| 183 // unwanted side effects. Preferably we should be able to signal |
| 184 // the intrinsic ratio in another way. |
| 185 if (intrinsicSize.isEmpty()) |
| 186 intrinsicSize = rootElement->currentViewBoxRect().size(); |
| 187 |
181 if (!intrinsicSize.isEmpty()) | 188 if (!intrinsicSize.isEmpty()) |
182 return expandedIntSize(intrinsicSize); | 189 return expandedIntSize(intrinsicSize); |
183 | 190 |
184 // As last resort, use CSS replaced element fallback size. | 191 // As last resort, use CSS replaced element fallback size. |
185 return IntSize(300, 150); | 192 return IntSize(300, 150); |
186 } | 193 } |
187 | 194 |
188 void SVGImage::drawForContainer(GraphicsContext* context, const FloatSize contai
nerSize, float zoom, const FloatRect& dstRect, | 195 void SVGImage::drawForContainer(GraphicsContext* context, const FloatSize contai
nerSize, float zoom, const FloatRect& dstRect, |
189 const FloatRect& srcRect, SkXfermode::Mode compositeOp) | 196 const FloatRect& srcRect, SkXfermode::Mode compositeOp) |
190 { | 197 { |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 | 467 |
461 return m_page; | 468 return m_page; |
462 } | 469 } |
463 | 470 |
464 String SVGImage::filenameExtension() const | 471 String SVGImage::filenameExtension() const |
465 { | 472 { |
466 return "svg"; | 473 return "svg"; |
467 } | 474 } |
468 | 475 |
469 } | 476 } |
OLD | NEW |