| 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if (!usesContainerSize()) | 138 if (!usesContainerSize()) |
| 139 return; | 139 return; |
| 140 | 140 |
| 141 SVGSVGElement* rootElement = svgRootElement(m_page.get()); | 141 SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
| 142 if (!rootElement) | 142 if (!rootElement) |
| 143 return; | 143 return; |
| 144 | 144 |
| 145 FrameView* view = frameView(); | 145 FrameView* view = frameView(); |
| 146 view->resize(this->containerSize()); | 146 view->resize(this->containerSize()); |
| 147 | 147 |
| 148 LayoutSVGRoot* renderer = toLayoutSVGRoot(rootElement->layoutObject()); | 148 LayoutSVGRoot* layoutObject = toLayoutSVGRoot(rootElement->layoutObject()); |
| 149 if (!renderer) | 149 if (!layoutObject) |
| 150 return; | 150 return; |
| 151 renderer->setContainerSize(size); | 151 layoutObject->setContainerSize(size); |
| 152 } | 152 } |
| 153 | 153 |
| 154 IntSize SVGImage::containerSize() const | 154 IntSize SVGImage::containerSize() const |
| 155 { | 155 { |
| 156 SVGSVGElement* rootElement = svgRootElement(m_page.get()); | 156 SVGSVGElement* rootElement = svgRootElement(m_page.get()); |
| 157 if (!rootElement) | 157 if (!rootElement) |
| 158 return IntSize(); | 158 return IntSize(); |
| 159 | 159 |
| 160 LayoutSVGRoot* renderer = toLayoutSVGRoot(rootElement->layoutObject()); | 160 LayoutSVGRoot* layoutObject = toLayoutSVGRoot(rootElement->layoutObject()); |
| 161 if (!renderer) | 161 if (!layoutObject) |
| 162 return IntSize(); | 162 return IntSize(); |
| 163 | 163 |
| 164 // If a container size is available it has precedence. | 164 // If a container size is available it has precedence. |
| 165 IntSize containerSize = renderer->containerSize(); | 165 IntSize containerSize = layoutObject->containerSize(); |
| 166 if (!containerSize.isEmpty()) | 166 if (!containerSize.isEmpty()) |
| 167 return containerSize; | 167 return containerSize; |
| 168 | 168 |
| 169 // Assure that a container size is always given for a non-identity zoom leve
l. | 169 // Assure that a container size is always given for a non-identity zoom leve
l. |
| 170 ASSERT(renderer->style()->effectiveZoom() == 1); | 170 ASSERT(layoutObject->style()->effectiveZoom() == 1); |
| 171 | 171 |
| 172 FloatSize intrinsicSize; | 172 FloatSize intrinsicSize; |
| 173 double intrinsicRatio = 0; | 173 double intrinsicRatio = 0; |
| 174 renderer->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio); | 174 layoutObject->computeIntrinsicRatioInformation(intrinsicSize, intrinsicRatio
); |
| 175 | 175 |
| 176 if (intrinsicSize.isEmpty() && intrinsicRatio) { | 176 if (intrinsicSize.isEmpty() && intrinsicRatio) { |
| 177 if (!intrinsicSize.width() && intrinsicSize.height()) | 177 if (!intrinsicSize.width() && intrinsicSize.height()) |
| 178 intrinsicSize.setWidth(intrinsicSize.height() * intrinsicRatio); | 178 intrinsicSize.setWidth(intrinsicSize.height() * intrinsicRatio); |
| 179 else if (intrinsicSize.width() && !intrinsicSize.height()) | 179 else if (intrinsicSize.width() && !intrinsicSize.height()) |
| 180 intrinsicSize.setHeight(intrinsicSize.width() / intrinsicRatio); | 180 intrinsicSize.setHeight(intrinsicSize.width() / intrinsicRatio); |
| 181 } | 181 } |
| 182 | 182 |
| 183 // TODO(davve): In order to maintain aspect ratio the intrinsic | 183 // TODO(davve): In order to maintain aspect ratio the intrinsic |
| 184 // size is faked from the viewBox as a last resort. This may cause | 184 // size is faked from the viewBox as a last resort. This may cause |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 | 459 |
| 460 return m_page; | 460 return m_page; |
| 461 } | 461 } |
| 462 | 462 |
| 463 String SVGImage::filenameExtension() const | 463 String SVGImage::filenameExtension() const |
| 464 { | 464 { |
| 465 return "svg"; | 465 return "svg"; |
| 466 } | 466 } |
| 467 | 467 |
| 468 } | 468 } |
| OLD | NEW |