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) | 99 float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode)
const |
100 { | 100 { |
101 if (length.isAuto()) | 101 float dimension = 0; |
102 return 0; | 102 if (length.isPercent()) { |
103 | 103 FloatSize viewportSize; |
104 FloatSize viewportSize; | 104 determineViewport(viewportSize); |
105 determineViewport(viewportSize); | 105 dimension = dimensionForLengthMode(mode, viewportSize); |
106 | 106 } |
107 if (length.isPercent()) | 107 return floatValueForLength(length, dimension); |
108 return length.value() * dimensionForLengthMode(mode, viewportSize) / 100
; | |
109 | |
110 return floatValueForLength(length, dimensionForLengthMode(mode, viewportSize
)); | |
111 } | 108 } |
112 | 109 |
113 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const | 110 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const |
114 { | 111 { |
115 switch (fromUnit) { | 112 switch (fromUnit) { |
116 case LengthTypeUnknown: | 113 case LengthTypeUnknown: |
117 return 0; | 114 return 0; |
118 case LengthTypeNumber: | 115 case LengthTypeNumber: |
119 return value; | 116 return value; |
120 case LengthTypePX: | 117 case LengthTypePX: |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 261 |
265 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); | 262 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); |
266 viewportSize = svg.currentViewBoxRect().size(); | 263 viewportSize = svg.currentViewBoxRect().size(); |
267 if (viewportSize.isEmpty()) | 264 if (viewportSize.isEmpty()) |
268 viewportSize = svg.currentViewportSize(); | 265 viewportSize = svg.currentViewportSize(); |
269 | 266 |
270 return true; | 267 return true; |
271 } | 268 } |
272 | 269 |
273 } | 270 } |
OLD | NEW |