| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2006 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) 2007 Apple Inc. All rights reserved. | 4 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 SVGLengthContext lengthContext(context); | 91 SVGLengthContext lengthContext(context); |
| 92 return x.value(lengthContext); | 92 return x.value(lengthContext); |
| 93 } | 93 } |
| 94 | 94 |
| 95 // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need t
o be resolved in user space and then be considered in objectBoundingBox space. | 95 // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need t
o be resolved in user space and then be considered in objectBoundingBox space. |
| 96 return x.valueAsPercentage(); | 96 return x.valueAsPercentage(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 float SVGLengthContext::valueForLength(const Length& length, const LayoutStyle&
style, SVGLengthMode mode) const | 99 float SVGLengthContext::valueForLength(const Length& length, const LayoutStyle&
style, SVGLengthMode mode) const |
| 100 { | 100 { |
| 101 return valueForLengthWithZoom(length, style.effectiveZoom(), mode); | |
| 102 } | |
| 103 | |
| 104 float SVGLengthContext::valueForLengthWithZoom(const Length& length, float zoom,
SVGLengthMode mode) const | |
| 105 { | |
| 106 ASSERT(zoom != 0); | |
| 107 float dimension = 0; | 101 float dimension = 0; |
| 108 if (length.isPercent()) { | 102 if (length.isPercent()) { |
| 109 FloatSize viewportSize; | 103 FloatSize viewportSize; |
| 110 determineViewport(viewportSize); | 104 determineViewport(viewportSize); |
| 111 // The viewport will be unaffected by zoom. | 105 // The viewport will be unaffected by zoom. |
| 112 dimension = dimensionForLengthMode(mode, viewportSize) * zoom; | 106 dimension = dimensionForLengthMode(mode, viewportSize); |
| 113 } | 107 } |
| 114 return floatValueForLength(length, dimension) / zoom; | 108 return valueForLength(length, style, dimension); |
| 109 } |
| 110 |
| 111 float SVGLengthContext::valueForLength(const Length& length, const LayoutStyle&
style, float dimension) |
| 112 { |
| 113 const float zoom = style.effectiveZoom(); |
| 114 ASSERT(zoom != 0); |
| 115 return floatValueForLength(length, dimension * zoom) / zoom; |
| 115 } | 116 } |
| 116 | 117 |
| 117 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const | 118 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const |
| 118 { | 119 { |
| 119 switch (fromUnit) { | 120 switch (fromUnit) { |
| 120 case LengthTypeUnknown: | 121 case LengthTypeUnknown: |
| 121 return 0; | 122 return 0; |
| 122 case LengthTypeNumber: | 123 case LengthTypeNumber: |
| 123 return value; | 124 return value; |
| 124 case LengthTypePX: | 125 case LengthTypePX: |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 | 269 |
| 269 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); | 270 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); |
| 270 viewportSize = svg.currentViewBoxRect().size(); | 271 viewportSize = svg.currentViewBoxRect().size(); |
| 271 if (viewportSize.isEmpty()) | 272 if (viewportSize.isEmpty()) |
| 272 viewportSize = svg.currentViewportSize(); | 273 viewportSize = svg.currentViewportSize(); |
| 273 | 274 |
| 274 return true; | 275 return true; |
| 275 } | 276 } |
| 276 | 277 |
| 277 } | 278 } |
| OLD | NEW |