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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 { | 242 { |
243 switch (toUnit) { | 243 switch (toUnit) { |
244 case LengthTypeUnknown: | 244 case LengthTypeUnknown: |
245 return 0; | 245 return 0; |
246 case LengthTypeNumber: | 246 case LengthTypeNumber: |
247 return value; | 247 return value; |
248 case LengthTypePercentage: { | 248 case LengthTypePercentage: { |
249 FloatSize viewportSize; | 249 FloatSize viewportSize; |
250 if (!determineViewport(viewportSize)) | 250 if (!determineViewport(viewportSize)) |
251 return 0; | 251 return 0; |
| 252 float dimension = dimensionForLengthMode(mode, viewportSize); |
| 253 if (!dimension) |
| 254 return 0; |
252 // LengthTypePercentage is represented with 100% = 100.0. | 255 // LengthTypePercentage is represented with 100% = 100.0. |
253 // Good for accuracy but could eventually be changed. | 256 // Good for accuracy but could eventually be changed. |
254 return value * 100 / dimensionForLengthMode(mode, viewportSize); | 257 return value * 100 / dimension; |
255 } | 258 } |
256 case LengthTypeEMS: | 259 case LengthTypeEMS: |
257 return convertValueFromUserUnitsToEMS(computedStyleForLengthResolving(m_
context), value); | 260 return convertValueFromUserUnitsToEMS(computedStyleForLengthResolving(m_
context), value); |
258 case LengthTypeEXS: | 261 case LengthTypeEXS: |
259 return convertValueFromUserUnitsToEXS(value); | 262 return convertValueFromUserUnitsToEXS(value); |
260 case LengthTypeREMS: | 263 case LengthTypeREMS: |
261 return convertValueFromUserUnitsToEMS(rootElementStyle(m_context), value
); | 264 return convertValueFromUserUnitsToEMS(rootElementStyle(m_context), value
); |
262 case LengthTypeCHS: | 265 case LengthTypeCHS: |
263 return convertValueFromUserUnitsToCHS(value); | 266 return convertValueFromUserUnitsToCHS(value); |
264 case LengthTypePX: | 267 case LengthTypePX: |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 | 348 |
346 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); | 349 const SVGSVGElement& svg = toSVGSVGElement(*viewportElement); |
347 viewportSize = svg.currentViewBoxRect().size(); | 350 viewportSize = svg.currentViewBoxRect().size(); |
348 if (viewportSize.isEmpty()) | 351 if (viewportSize.isEmpty()) |
349 viewportSize = svg.currentViewportSize(); | 352 viewportSize = svg.currentViewportSize(); |
350 | 353 |
351 return true; | 354 return true; |
352 } | 355 } |
353 | 356 |
354 } | 357 } |
OLD | NEW |