| 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 28 matching lines...) Expand all Loading... |
| 39 static inline float dimensionForLengthMode(SVGLengthMode mode, | 39 static inline float dimensionForLengthMode(SVGLengthMode mode, |
| 40 const FloatSize& viewportSize) { | 40 const FloatSize& viewportSize) { |
| 41 switch (mode) { | 41 switch (mode) { |
| 42 case SVGLengthMode::Width: | 42 case SVGLengthMode::Width: |
| 43 return viewportSize.width(); | 43 return viewportSize.width(); |
| 44 case SVGLengthMode::Height: | 44 case SVGLengthMode::Height: |
| 45 return viewportSize.height(); | 45 return viewportSize.height(); |
| 46 case SVGLengthMode::Other: | 46 case SVGLengthMode::Other: |
| 47 return sqrtf(viewportSize.diagonalLengthSquared() / 2); | 47 return sqrtf(viewportSize.diagonalLengthSquared() / 2); |
| 48 } | 48 } |
| 49 ASSERT_NOT_REACHED(); | 49 NOTREACHED(); |
| 50 return 0; | 50 return 0; |
| 51 } | 51 } |
| 52 | 52 |
| 53 static float convertValueFromPercentageToUserUnits( | 53 static float convertValueFromPercentageToUserUnits( |
| 54 const SVGLength& value, | 54 const SVGLength& value, |
| 55 const FloatSize& viewportSize) { | 55 const FloatSize& viewportSize) { |
| 56 return CSSPrimitiveValue::clampToCSSLengthRange(value.scaleByPercentage( | 56 return CSSPrimitiveValue::clampToCSSLengthRange(value.scaleByPercentage( |
| 57 dimensionForLengthMode(value.unitMode(), viewportSize))); | 57 dimensionForLengthMode(value.unitMode(), viewportSize))); |
| 58 } | 58 } |
| 59 | 59 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 145 |
| 146 case CSSPrimitiveValue::UnitType::ViewportMin: | 146 case CSSPrimitiveValue::UnitType::ViewportMin: |
| 147 return viewportMinPercent(viewportSize) / style->effectiveZoom(); | 147 return viewportMinPercent(viewportSize) / style->effectiveZoom(); |
| 148 | 148 |
| 149 case CSSPrimitiveValue::UnitType::ViewportMax: | 149 case CSSPrimitiveValue::UnitType::ViewportMax: |
| 150 return viewportMaxPercent(viewportSize) / style->effectiveZoom(); | 150 return viewportMaxPercent(viewportSize) / style->effectiveZoom(); |
| 151 default: | 151 default: |
| 152 break; | 152 break; |
| 153 } | 153 } |
| 154 | 154 |
| 155 ASSERT_NOT_REACHED(); | 155 NOTREACHED(); |
| 156 return 0; | 156 return 0; |
| 157 } | 157 } |
| 158 | 158 |
| 159 SVGLengthContext::SVGLengthContext(const SVGElement* context) | 159 SVGLengthContext::SVGLengthContext(const SVGElement* context) |
| 160 : m_context(context) {} | 160 : m_context(context) {} |
| 161 | 161 |
| 162 FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, | 162 FloatRect SVGLengthContext::resolveRectangle(const SVGElement* context, |
| 163 SVGUnitTypes::SVGUnitType type, | 163 SVGUnitTypes::SVGUnitType type, |
| 164 const FloatRect& viewport, | 164 const FloatRect& viewport, |
| 165 const SVGLength& x, | 165 const SVGLength& x, |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 case CSSPrimitiveValue::UnitType::Chs: | 301 case CSSPrimitiveValue::UnitType::Chs: |
| 302 userUnits = convertValueFromCHSToUserUnits(value); | 302 userUnits = convertValueFromCHSToUserUnits(value); |
| 303 break; | 303 break; |
| 304 case CSSPrimitiveValue::UnitType::ViewportWidth: | 304 case CSSPrimitiveValue::UnitType::ViewportWidth: |
| 305 case CSSPrimitiveValue::UnitType::ViewportHeight: | 305 case CSSPrimitiveValue::UnitType::ViewportHeight: |
| 306 case CSSPrimitiveValue::UnitType::ViewportMin: | 306 case CSSPrimitiveValue::UnitType::ViewportMin: |
| 307 case CSSPrimitiveValue::UnitType::ViewportMax: | 307 case CSSPrimitiveValue::UnitType::ViewportMax: |
| 308 userUnits = value * dimensionForViewportUnit(m_context, fromUnit); | 308 userUnits = value * dimensionForViewportUnit(m_context, fromUnit); |
| 309 break; | 309 break; |
| 310 default: | 310 default: |
| 311 ASSERT_NOT_REACHED(); | 311 NOTREACHED(); |
| 312 break; | 312 break; |
| 313 } | 313 } |
| 314 | 314 |
| 315 // Since we mix css <length> values with svg's length values we need to | 315 // Since we mix css <length> values with svg's length values we need to |
| 316 // clamp values to the narrowest range, otherwise it can result in | 316 // clamp values to the narrowest range, otherwise it can result in |
| 317 // rendering issues. | 317 // rendering issues. |
| 318 return CSSPrimitiveValue::clampToCSSLengthRange(userUnits); | 318 return CSSPrimitiveValue::clampToCSSLengthRange(userUnits); |
| 319 } | 319 } |
| 320 | 320 |
| 321 float SVGLengthContext::convertValueFromUserUnits( | 321 float SVGLengthContext::convertValueFromUserUnits( |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 return value / cssPixelsPerPica; | 360 return value / cssPixelsPerPica; |
| 361 case CSSPrimitiveValue::UnitType::ViewportWidth: | 361 case CSSPrimitiveValue::UnitType::ViewportWidth: |
| 362 case CSSPrimitiveValue::UnitType::ViewportHeight: | 362 case CSSPrimitiveValue::UnitType::ViewportHeight: |
| 363 case CSSPrimitiveValue::UnitType::ViewportMin: | 363 case CSSPrimitiveValue::UnitType::ViewportMin: |
| 364 case CSSPrimitiveValue::UnitType::ViewportMax: | 364 case CSSPrimitiveValue::UnitType::ViewportMax: |
| 365 return value / dimensionForViewportUnit(m_context, toUnit); | 365 return value / dimensionForViewportUnit(m_context, toUnit); |
| 366 default: | 366 default: |
| 367 break; | 367 break; |
| 368 } | 368 } |
| 369 | 369 |
| 370 ASSERT_NOT_REACHED(); | 370 NOTREACHED(); |
| 371 return 0; | 371 return 0; |
| 372 } | 372 } |
| 373 | 373 |
| 374 float SVGLengthContext::convertValueFromUserUnitsToCHS(float value) const { | 374 float SVGLengthContext::convertValueFromUserUnitsToCHS(float value) const { |
| 375 const ComputedStyle* style = computedStyleForLengthResolving(m_context); | 375 const ComputedStyle* style = computedStyleForLengthResolving(m_context); |
| 376 if (!style) | 376 if (!style) |
| 377 return 0; | 377 return 0; |
| 378 const SimpleFontData* fontData = style->font().primaryFont(); | 378 const SimpleFontData* fontData = style->font().primaryFont(); |
| 379 if (!fontData) | 379 if (!fontData) |
| 380 return 0; | 380 return 0; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 const ComputedStyle* rootStyle = rootElementStyle(m_context); | 459 const ComputedStyle* rootStyle = rootElementStyle(m_context); |
| 460 if (!rootStyle) | 460 if (!rootStyle) |
| 461 return 0; | 461 return 0; |
| 462 | 462 |
| 463 CSSToLengthConversionData conversionData = CSSToLengthConversionData( | 463 CSSToLengthConversionData conversionData = CSSToLengthConversionData( |
| 464 style, rootStyle, m_context->document().layoutViewItem(), 1.0f); | 464 style, rootStyle, m_context->document().layoutViewItem(), 1.0f); |
| 465 Length length = primitiveValue.convertToLength(conversionData); | 465 Length length = primitiveValue.convertToLength(conversionData); |
| 466 return valueForLength(length, 1.0f, mode); | 466 return valueForLength(length, 1.0f, mode); |
| 467 } | 467 } |
| 468 } // namespace blink | 468 } // namespace blink |
| OLD | NEW |