| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return IntSize(); | 146 return IntSize(); |
| 147 | 147 |
| 148 // If a container size is available it has precedence. | 148 // If a container size is available it has precedence. |
| 149 IntSize containerSize = layoutObject->containerSize(); | 149 IntSize containerSize = layoutObject->containerSize(); |
| 150 if (!containerSize.isEmpty()) | 150 if (!containerSize.isEmpty()) |
| 151 return containerSize; | 151 return containerSize; |
| 152 | 152 |
| 153 // Assure that a container size is always given for a non-identity zoom leve
l. | 153 // Assure that a container size is always given for a non-identity zoom leve
l. |
| 154 ASSERT(layoutObject->style()->effectiveZoom() == 1); | 154 ASSERT(layoutObject->style()->effectiveZoom() == 1); |
| 155 | 155 |
| 156 FloatSize intrinsicSize; | 156 LayoutBox::IntrinsicSizingInfo intrinsicSizingInfo; |
| 157 double intrinsicRatio = 0; | 157 layoutObject->computeIntrinsicSizingInfo(intrinsicSizingInfo); |
| 158 layoutObject->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio
); | |
| 159 | 158 |
| 160 if (intrinsicSize.isEmpty() && intrinsicRatio) { | 159 if (intrinsicSizingInfo.size.isEmpty() && intrinsicSizingInfo.aspectRatio) { |
| 161 if (!intrinsicSize.width() && intrinsicSize.height()) | 160 if (!intrinsicSizingInfo.size.width() && intrinsicSizingInfo.size.height
()) |
| 162 intrinsicSize.setWidth(intrinsicSize.height() * intrinsicRatio); | 161 intrinsicSizingInfo.size.setWidth(intrinsicSizingInfo.size.height()
* intrinsicSizingInfo.aspectRatio); |
| 163 else if (intrinsicSize.width() && !intrinsicSize.height()) | 162 else if (intrinsicSizingInfo.size.width() && !intrinsicSizingInfo.size.h
eight()) |
| 164 intrinsicSize.setHeight(intrinsicSize.width() / intrinsicRatio); | 163 intrinsicSizingInfo.size.setHeight(intrinsicSizingInfo.size.width()
/ intrinsicSizingInfo.aspectRatio); |
| 165 } | 164 } |
| 166 | 165 |
| 167 // TODO(davve): In order to maintain aspect ratio the intrinsic | 166 // TODO(davve): In order to maintain aspect ratio the intrinsic |
| 168 // size is faked from the viewBox as a last resort. This may cause | 167 // size is faked from the viewBox as a last resort. This may cause |
| 169 // unwanted side effects. Preferably we should be able to signal | 168 // unwanted side effects. Preferably we should be able to signal |
| 170 // the intrinsic ratio in another way. | 169 // the intrinsic ratio in another way. |
| 171 if (intrinsicSize.isEmpty()) | 170 if (intrinsicSizingInfo.size.isEmpty()) |
| 172 intrinsicSize = rootElement->currentViewBoxRect().size(); | 171 intrinsicSizingInfo.size = rootElement->currentViewBoxRect().size(); |
| 173 | 172 |
| 174 if (!intrinsicSize.isEmpty()) | 173 if (!intrinsicSizingInfo.size.isEmpty()) |
| 175 return expandedIntSize(intrinsicSize); | 174 return expandedIntSize(intrinsicSizingInfo.size); |
| 176 | 175 |
| 177 // As last resort, use CSS replaced element fallback size. | 176 // As last resort, use CSS replaced element fallback size. |
| 178 return IntSize(300, 150); | 177 return IntSize(300, 150); |
| 179 } | 178 } |
| 180 | 179 |
| 181 void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl
oatSize containerSize, float zoom, const FloatRect& dstRect, | 180 void SVGImage::drawForContainer(SkCanvas* canvas, const SkPaint& paint, const Fl
oatSize containerSize, float zoom, const FloatRect& dstRect, |
| 182 const FloatRect& srcRect, const KURL& url) | 181 const FloatRect& srcRect, const KURL& url) |
| 183 { | 182 { |
| 184 if (!m_page) | 183 if (!m_page) |
| 185 return; | 184 return; |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 | 500 |
| 502 return m_page; | 501 return m_page; |
| 503 } | 502 } |
| 504 | 503 |
| 505 String SVGImage::filenameExtension() const | 504 String SVGImage::filenameExtension() const |
| 506 { | 505 { |
| 507 return "svg"; | 506 return "svg"; |
| 508 } | 507 } |
| 509 | 508 |
| 510 } // namespace blink | 509 } // namespace blink |
| OLD | NEW |