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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); | 89 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); |
90 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { | 90 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { |
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, 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); |
101 float dimension = 0; | 107 float dimension = 0; |
102 if (length.isPercent()) { | 108 if (length.isPercent()) { |
103 FloatSize viewportSize; | 109 FloatSize viewportSize; |
104 determineViewport(viewportSize); | 110 determineViewport(viewportSize); |
105 dimension = dimensionForLengthMode(mode, viewportSize); | 111 // The viewport will be unaffected by zoom. |
| 112 dimension = dimensionForLengthMode(mode, viewportSize) * zoom; |
106 } | 113 } |
107 return floatValueForLength(length, dimension); | 114 return floatValueForLength(length, dimension) / zoom; |
108 } | 115 } |
109 | 116 |
110 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const | 117 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const |
111 { | 118 { |
112 switch (fromUnit) { | 119 switch (fromUnit) { |
113 case LengthTypeUnknown: | 120 case LengthTypeUnknown: |
114 return 0; | 121 return 0; |
115 case LengthTypeNumber: | 122 case LengthTypeNumber: |
116 return value; | 123 return value; |
117 case LengthTypePX: | 124 case LengthTypePX: |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 268 |
262 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); | 269 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); |
263 viewportSize = svg.currentViewBoxRect().size(); | 270 viewportSize = svg.currentViewBoxRect().size(); |
264 if (viewportSize.isEmpty()) | 271 if (viewportSize.isEmpty()) |
265 viewportSize = svg.currentViewportSize(); | 272 viewportSize = svg.currentViewportSize(); |
266 | 273 |
267 return true; | 274 return true; |
268 } | 275 } |
269 | 276 |
270 } | 277 } |
OLD | NEW |