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 18 matching lines...) Expand all Loading... |
29 #include "core/svg/SVGSVGElement.h" | 29 #include "core/svg/SVGSVGElement.h" |
30 #include "platform/fonts/FontMetrics.h" | 30 #include "platform/fonts/FontMetrics.h" |
31 | 31 |
32 namespace blink { | 32 namespace blink { |
33 | 33 |
34 SVGLengthContext::SVGLengthContext(const SVGElement* context) | 34 SVGLengthContext::SVGLengthContext(const SVGElement* context) |
35 : m_context(context) | 35 : m_context(context) |
36 { | 36 { |
37 } | 37 } |
38 | 38 |
39 FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, SVGUnitT
ypes::SVGUnitType type, const FloatRect& viewport, PassRefPtrWillBeRawPtr<SVGLen
gth> passX, PassRefPtrWillBeRawPtr<SVGLength> passY, PassRefPtrWillBeRawPtr<SVGL
ength> passWidth, PassRefPtrWillBeRawPtr<SVGLength> passHeight) | 39 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) |
40 { | 40 { |
41 RefPtrWillBeRawPtr<SVGLength> x = passX; | |
42 RefPtrWillBeRawPtr<SVGLength> y = passY; | |
43 RefPtrWillBeRawPtr<SVGLength> width = passWidth; | |
44 RefPtrWillBeRawPtr<SVGLength> height = passHeight; | |
45 | |
46 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); | 41 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); |
47 if (type != SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE && !viewport.isEmpty(
)) { | 42 if (type != SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE && !viewport.isEmpty(
)) { |
48 const FloatSize& viewportSize = viewport.size(); | 43 const FloatSize& viewportSize = viewport.size(); |
49 return FloatRect( | 44 return FloatRect( |
50 convertValueFromPercentageToUserUnits(*x, viewportSize) + viewport.x
(), | 45 convertValueFromPercentageToUserUnits(x, viewportSize) + viewport.x(
), |
51 convertValueFromPercentageToUserUnits(*y, viewportSize) + viewport.y
(), | 46 convertValueFromPercentageToUserUnits(y, viewportSize) + viewport.y(
), |
52 convertValueFromPercentageToUserUnits(*width, viewportSize), | 47 convertValueFromPercentageToUserUnits(width, viewportSize), |
53 convertValueFromPercentageToUserUnits(*height, viewportSize)); | 48 convertValueFromPercentageToUserUnits(height, viewportSize)); |
54 } | 49 } |
55 | 50 |
56 SVGLengthContext lengthContext(context); | 51 SVGLengthContext lengthContext(context); |
57 return FloatRect(x->value(lengthContext), y->value(lengthContext), width->va
lue(lengthContext), height->value(lengthContext)); | 52 return FloatRect(x.value(lengthContext), y.value(lengthContext), width.value
(lengthContext), height.value(lengthContext)); |
58 } | 53 } |
59 | 54 |
60 FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context, SVGUnitType
s::SVGUnitType type, PassRefPtrWillBeRawPtr<SVGLength> passX, PassRefPtrWillBeRa
wPtr<SVGLength> passY) | 55 FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context, SVGUnitType
s::SVGUnitType type, const SVGLength& x, const SVGLength& y) |
61 { | 56 { |
62 RefPtrWillBeRawPtr<SVGLength> x = passX; | |
63 RefPtrWillBeRawPtr<SVGLength> y = passY; | |
64 | |
65 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); | 57 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); |
66 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { | 58 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { |
67 SVGLengthContext lengthContext(context); | 59 SVGLengthContext lengthContext(context); |
68 return FloatPoint(x->value(lengthContext), y->value(lengthContext)); | 60 return FloatPoint(x.value(lengthContext), y.value(lengthContext)); |
69 } | 61 } |
70 | 62 |
71 // 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. | 63 // 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. |
72 return FloatPoint(x->valueAsPercentage(), y->valueAsPercentage()); | 64 return FloatPoint(x.valueAsPercentage(), y.valueAsPercentage()); |
73 } | 65 } |
74 | 66 |
75 float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
VGUnitType type, PassRefPtrWillBeRawPtr<SVGLength> passX) | 67 float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
VGUnitType type, const SVGLength& x) |
76 { | 68 { |
77 RefPtrWillBeRawPtr<SVGLength> x = passX; | |
78 | |
79 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); | 69 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); |
80 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { | 70 if (type == SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) { |
81 SVGLengthContext lengthContext(context); | 71 SVGLengthContext lengthContext(context); |
82 return x->value(lengthContext); | 72 return x.value(lengthContext); |
83 } | 73 } |
84 | 74 |
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. | 75 // 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(); | 76 return x.valueAsPercentage(); |
87 } | 77 } |
88 | 78 |
89 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const | 79 float SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode,
SVGLengthType fromUnit) const |
90 { | 80 { |
91 switch (fromUnit) { | 81 switch (fromUnit) { |
92 case LengthTypeUnknown: | 82 case LengthTypeUnknown: |
93 return 0; | 83 return 0; |
94 case LengthTypeNumber: | 84 case LengthTypeNumber: |
95 return value; | 85 return value; |
96 case LengthTypePX: | 86 case LengthTypePX: |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 257 |
268 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); | 258 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); |
269 viewportSize = svg.currentViewBoxRect().size(); | 259 viewportSize = svg.currentViewBoxRect().size(); |
270 if (viewportSize.isEmpty()) | 260 if (viewportSize.isEmpty()) |
271 viewportSize = svg.currentViewportSize(); | 261 viewportSize = svg.currentViewportSize(); |
272 | 262 |
273 return true; | 263 return true; |
274 } | 264 } |
275 | 265 |
276 } | 266 } |
OLD | NEW |