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 29 matching lines...) Expand all Loading... |
40 : m_context(context) | 40 : m_context(context) |
41 { | 41 { |
42 } | 42 } |
43 | 43 |
44 SVGLengthContext::SVGLengthContext(const SVGElement* context, const FloatRect& v
iewport) | 44 SVGLengthContext::SVGLengthContext(const SVGElement* context, const FloatRect& v
iewport) |
45 : m_context(context) | 45 : m_context(context) |
46 , m_overridenViewport(viewport) | 46 , m_overridenViewport(viewport) |
47 { | 47 { |
48 } | 48 } |
49 | 49 |
50 FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitT
ypes::SVGUnitType type, const FloatRect& viewport, const SVGLength& x, const SVG
Length& y, const SVGLength& width, const SVGLength& height) | 50 FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitT
ypes::SVGUnitType type, const FloatRect& viewport, PassRefPtr<SVGLength> passX,
PassRefPtr<SVGLength> passY, PassRefPtr<SVGLength> passWidth, PassRefPtr<SVGLeng
th> passHeight) |
51 { | 51 { |
| 52 RefPtr<SVGLength> x = passX; |
| 53 RefPtr<SVGLength> y = passY; |
| 54 RefPtr<SVGLength> width = passWidth; |
| 55 RefPtr<SVGLength> height = passHeight; |
| 56 |
52 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); | 57 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); |
53 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { | 58 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { |
54 SVGLengthContext lengthContext(context); | 59 SVGLengthContext lengthContext(context); |
55 return FloatRect(x.value(lengthContext), y.value(lengthContext), width.v
alue(lengthContext), height.value(lengthContext)); | 60 return FloatRect(x->value(lengthContext), y->value(lengthContext), width
->value(lengthContext), height->value(lengthContext)); |
56 } | 61 } |
57 | 62 |
58 SVGLengthContext lengthContext(context, viewport); | 63 SVGLengthContext lengthContext(context, viewport); |
59 return FloatRect(x.value(lengthContext) + viewport.x(), | 64 return FloatRect( |
60 y.value(lengthContext) + viewport.y(), | 65 x->value(lengthContext) + viewport.x(), |
61 width.value(lengthContext), | 66 y->value(lengthContext) + viewport.y(), |
62 height.value(lengthContext)); | 67 width->value(lengthContext), |
| 68 height->value(lengthContext)); |
63 } | 69 } |
64 | 70 |
65 FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context, SVGUnitType
s::SVGUnitType type, const SVGLength& x, const SVGLength& y) | 71 FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context, SVGUnitType
s::SVGUnitType type, PassRefPtr<SVGLength> passX, PassRefPtr<SVGLength> passY) |
66 { | 72 { |
| 73 RefPtr<SVGLength> x = passX; |
| 74 RefPtr<SVGLength> y = passY; |
| 75 |
67 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); | 76 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); |
68 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { | 77 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { |
69 SVGLengthContext lengthContext(context); | 78 SVGLengthContext lengthContext(context); |
70 return FloatPoint(x.value(lengthContext), y.value(lengthContext)); | 79 return FloatPoint(x->value(lengthContext), y->value(lengthContext)); |
71 } | 80 } |
72 | 81 |
73 // 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. | 82 // 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. |
74 return FloatPoint(x.valueAsPercentage(), y.valueAsPercentage()); | 83 return FloatPoint(x->valueAsPercentage(), y->valueAsPercentage()); |
75 } | 84 } |
76 | 85 |
77 float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
VGUnitType type, const SVGLength& x) | 86 float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
VGUnitType type, PassRefPtr<SVGLength> passX) |
78 { | 87 { |
| 88 RefPtr<SVGLength> x = passX; |
| 89 |
79 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); | 90 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); |
80 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { | 91 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { |
81 SVGLengthContext lengthContext(context); | 92 SVGLengthContext lengthContext(context); |
82 return x.value(lengthContext); | 93 return x->value(lengthContext); |
83 } | 94 } |
84 | 95 |
85 // 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 // 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. |
86 return x.valueAsPercentage(); | 97 return x->valueAsPercentage(); |
87 } | 98 } |
88 | 99 |
89 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit, ExceptionState& exceptionState) const | 100 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit, ExceptionState& exceptionState) const |
90 { | 101 { |
91 // If the SVGLengthContext carries a custom viewport, force resolving agains
t it. | 102 // If the SVGLengthContext carries a custom viewport, force resolving agains
t it. |
92 if (!m_overridenViewport.isEmpty()) { | 103 if (!m_overridenViewport.isEmpty()) { |
93 // 100% = 100.0 instead of 1.0 for historical reasons, this could eventu
ally be changed | 104 // 100% = 100.0 instead of 1.0 for historical reasons, this could eventu
ally be changed |
94 if (fromUnit == LengthTypePercentage) | 105 if (fromUnit == LengthTypePercentage) |
95 value /= 100; | 106 value /= 100; |
96 return convertValueFromPercentageToUserUnits(value, mode, exceptionState
); | 107 return convertValueFromPercentageToUserUnits(value, mode, exceptionState
); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 312 |
302 const SVGSVGElement* svg = toSVGSVGElement(viewportElement); | 313 const SVGSVGElement* svg = toSVGSVGElement(viewportElement); |
303 viewportSize = svg->currentViewBoxRect().size(); | 314 viewportSize = svg->currentViewBoxRect().size(); |
304 if (viewportSize.isEmpty()) | 315 if (viewportSize.isEmpty()) |
305 viewportSize = svg->currentViewportSize(); | 316 viewportSize = svg->currentViewportSize(); |
306 | 317 |
307 return true; | 318 return true; |
308 } | 319 } |
309 | 320 |
310 } | 321 } |
OLD | NEW |