| 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 UnzoomedLength& unzoomedLength, SVG
LengthMode mode) const |
| 100 { |
| 101 return valueForLength(unzoomedLength.length(), 1, mode); |
| 102 } |
| 103 |
| 99 float SVGLengthContext::valueForLength(const Length& length, const LayoutStyle&
style, SVGLengthMode mode) const | 104 float SVGLengthContext::valueForLength(const Length& length, const LayoutStyle&
style, SVGLengthMode mode) const |
| 100 { | 105 { |
| 106 return valueForLength(length, style.effectiveZoom(), mode); |
| 107 } |
| 108 |
| 109 float SVGLengthContext::valueForLength(const Length& length, float zoom, SVGLeng
thMode mode) const |
| 110 { |
| 101 float dimension = 0; | 111 float dimension = 0; |
| 102 if (length.isPercent()) { | 112 if (length.isPercent()) { |
| 103 FloatSize viewportSize; | 113 FloatSize viewportSize; |
| 104 determineViewport(viewportSize); | 114 determineViewport(viewportSize); |
| 105 // The viewport will be unaffected by zoom. | 115 // The viewport will be unaffected by zoom. |
| 106 dimension = dimensionForLengthMode(mode, viewportSize); | 116 dimension = dimensionForLengthMode(mode, viewportSize); |
| 107 } | 117 } |
| 108 return valueForLength(length, style, dimension); | 118 return valueForLength(length, zoom, dimension); |
| 109 } | 119 } |
| 110 | 120 |
| 111 float SVGLengthContext::valueForLength(const Length& length, const LayoutStyle&
style, float dimension) | 121 float SVGLengthContext::valueForLength(const Length& length, const LayoutStyle&
style, float dimension) |
| 112 { | 122 { |
| 113 const float zoom = style.effectiveZoom(); | 123 return valueForLength(length, style.effectiveZoom(), dimension); |
| 124 } |
| 125 |
| 126 float SVGLengthContext::valueForLength(const Length& length, float zoom, float d
imension) |
| 127 { |
| 114 ASSERT(zoom != 0); | 128 ASSERT(zoom != 0); |
| 115 return floatValueForLength(length, dimension * zoom) / zoom; | 129 return floatValueForLength(length, dimension * zoom) / zoom; |
| 116 } | 130 } |
| 117 | 131 |
| 118 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const | 132 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const |
| 119 { | 133 { |
| 120 switch (fromUnit) { | 134 switch (fromUnit) { |
| 121 case LengthTypeUnknown: | 135 case LengthTypeUnknown: |
| 122 return 0; | 136 return 0; |
| 123 case LengthTypeNumber: | 137 case LengthTypeNumber: |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 283 |
| 270 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); | 284 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); |
| 271 viewportSize = svg.currentViewBoxRect().size(); | 285 viewportSize = svg.currentViewBoxRect().size(); |
| 272 if (viewportSize.isEmpty()) | 286 if (viewportSize.isEmpty()) |
| 273 viewportSize = svg.currentViewportSize(); | 287 viewportSize = svg.currentViewportSize(); |
| 274 | 288 |
| 275 return true; | 289 return true; |
| 276 } | 290 } |
| 277 | 291 |
| 278 } | 292 } |
| OLD | NEW |