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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 { | 45 { |
46 RefPtrWillBeRawPtr<SVGLength> x = passX; | 46 RefPtrWillBeRawPtr<SVGLength> x = passX; |
47 RefPtrWillBeRawPtr<SVGLength> y = passY; | 47 RefPtrWillBeRawPtr<SVGLength> y = passY; |
48 RefPtrWillBeRawPtr<SVGLength> width = passWidth; | 48 RefPtrWillBeRawPtr<SVGLength> width = passWidth; |
49 RefPtrWillBeRawPtr<SVGLength> height = passHeight; | 49 RefPtrWillBeRawPtr<SVGLength> height = passHeight; |
50 | 50 |
51 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); | 51 ASSERT(type != SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN); |
52 if (type != SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE && !viewport.isEmpty(
)) { | 52 if (type != SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE && !viewport.isEmpty(
)) { |
53 const FloatSize& viewportSize = viewport.size(); | 53 const FloatSize& viewportSize = viewport.size(); |
54 return FloatRect( | 54 return FloatRect( |
55 convertValueFromPercentageToUserUnits(x->valueAsPercentage(), x->uni
tMode(), viewportSize) + viewport.x(), | 55 convertValueFromPercentageToUserUnits(*x, viewportSize) + viewport.x
(), |
56 convertValueFromPercentageToUserUnits(y->valueAsPercentage(), y->uni
tMode(), viewportSize) + viewport.y(), | 56 convertValueFromPercentageToUserUnits(*y, viewportSize) + viewport.y
(), |
57 convertValueFromPercentageToUserUnits(width->valueAsPercentage(), wi
dth->unitMode(), viewportSize), | 57 convertValueFromPercentageToUserUnits(*width, viewportSize), |
58 convertValueFromPercentageToUserUnits(height->valueAsPercentage(), h
eight->unitMode(), viewportSize)); | 58 convertValueFromPercentageToUserUnits(*height, viewportSize)); |
59 } | 59 } |
60 | 60 |
61 SVGLengthContext lengthContext(context); | 61 SVGLengthContext lengthContext(context); |
62 return FloatRect(x->value(lengthContext), y->value(lengthContext), width->va
lue(lengthContext), height->value(lengthContext)); | 62 return FloatRect(x->value(lengthContext), y->value(lengthContext), width->va
lue(lengthContext), height->value(lengthContext)); |
63 } | 63 } |
64 | 64 |
65 FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context, SVGUnitType
s::SVGUnitType type, PassRefPtrWillBeRawPtr<SVGLength> passX, PassRefPtrWillBeRa
wPtr<SVGLength> passY) | 65 FloatPoint SVGLengthContext::resolvePoint(const SVGElement* context, SVGUnitType
s::SVGUnitType type, PassRefPtrWillBeRawPtr<SVGLength> passX, PassRefPtrWillBeRa
wPtr<SVGLength> passY) |
66 { | 66 { |
67 RefPtrWillBeRawPtr<SVGLength> x = passX; | 67 RefPtrWillBeRawPtr<SVGLength> x = passX; |
68 RefPtrWillBeRawPtr<SVGLength> y = passY; | 68 RefPtrWillBeRawPtr<SVGLength> y = passY; |
(...skipping 26 matching lines...) Expand all Loading... |
95 { | 95 { |
96 switch (fromUnit) { | 96 switch (fromUnit) { |
97 case LengthTypeUnknown: | 97 case LengthTypeUnknown: |
98 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a
rgumentNullOrIncorrectType(3, "SVGLengthType")); | 98 exceptionState.throwDOMException(NotSupportedError, ExceptionMessages::a
rgumentNullOrIncorrectType(3, "SVGLengthType")); |
99 return 0; | 99 return 0; |
100 case LengthTypeNumber: | 100 case LengthTypeNumber: |
101 return value; | 101 return value; |
102 case LengthTypePX: | 102 case LengthTypePX: |
103 return value; | 103 return value; |
104 case LengthTypePercentage: | 104 case LengthTypePercentage: |
105 return convertValueFromPercentageToUserUnits(value / 100, mode, exceptio
nState); | 105 return convertValueFromPercentageToUserUnits(value, mode, exceptionState
) / 100; |
106 case LengthTypeEMS: | 106 case LengthTypeEMS: |
107 return convertValueFromEMSToUserUnits(value, exceptionState); | 107 return convertValueFromEMSToUserUnits(value, exceptionState); |
108 case LengthTypeEXS: | 108 case LengthTypeEXS: |
109 return convertValueFromEXSToUserUnits(value, exceptionState); | 109 return convertValueFromEXSToUserUnits(value, exceptionState); |
110 case LengthTypeCM: | 110 case LengthTypeCM: |
111 return value * cssPixelsPerCentimeter; | 111 return value * cssPixelsPerCentimeter; |
112 case LengthTypeMM: | 112 case LengthTypeMM: |
113 return value * cssPixelsPerMillimeter; | 113 return value * cssPixelsPerMillimeter; |
114 case LengthTypeIN: | 114 case LengthTypeIN: |
115 return value * cssPixelsPerInch; | 115 return value * cssPixelsPerInch; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 float SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLe
ngthMode mode, const FloatSize& viewportSize) | 189 float SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLe
ngthMode mode, const FloatSize& viewportSize) |
190 { | 190 { |
191 switch (mode) { | 191 switch (mode) { |
192 case LengthModeWidth: | 192 case LengthModeWidth: |
193 return value * viewportSize.width(); | 193 return value * viewportSize.width(); |
194 case LengthModeHeight: | 194 case LengthModeHeight: |
195 return value * viewportSize.height(); | 195 return value * viewportSize.height(); |
196 case LengthModeOther: | 196 case LengthModeOther: |
197 return value * sqrtf(viewportSize.diagonalLengthSquared() / 2); | 197 return value * sqrtf(viewportSize.diagonalLengthSquared() / 2); |
198 }; | 198 } |
199 | 199 |
200 ASSERT_NOT_REACHED(); | 200 ASSERT_NOT_REACHED(); |
201 return 0; | 201 return 0; |
| 202 } |
| 203 |
| 204 float SVGLengthContext::convertValueFromPercentageToUserUnits(const SVGLength& v
alue, const FloatSize& viewportSize) |
| 205 { |
| 206 switch (value.unitMode()) { |
| 207 case LengthModeWidth: |
| 208 return value.scaleByPercentage(viewportSize.width()); |
| 209 case LengthModeHeight: |
| 210 return value.scaleByPercentage(viewportSize.height()); |
| 211 case LengthModeOther: |
| 212 return value.scaleByPercentage(sqrtf(viewportSize.diagonalLengthSquared(
) / 2)); |
| 213 } |
| 214 |
| 215 ASSERT_NOT_REACHED(); |
| 216 return 0; |
202 } | 217 } |
203 | 218 |
204 static inline RenderStyle* renderStyleForLengthResolving(const SVGElement* conte
xt) | 219 static inline RenderStyle* renderStyleForLengthResolving(const SVGElement* conte
xt) |
205 { | 220 { |
206 if (!context) | 221 if (!context) |
207 return 0; | 222 return 0; |
208 | 223 |
209 const ContainerNode* currentContext = context; | 224 const ContainerNode* currentContext = context; |
210 do { | 225 do { |
211 if (currentContext->renderer()) | 226 if (currentContext->renderer()) |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 311 |
297 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); | 312 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); |
298 viewportSize = svg.currentViewBoxRect().size(); | 313 viewportSize = svg.currentViewBoxRect().size(); |
299 if (viewportSize.isEmpty()) | 314 if (viewportSize.isEmpty()) |
300 viewportSize = svg.currentViewportSize(); | 315 viewportSize = svg.currentViewportSize(); |
301 | 316 |
302 return true; | 317 return true; |
303 } | 318 } |
304 | 319 |
305 } | 320 } |
OLD | NEW |