| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #ifndef SVGLengthContext_h | 20 #ifndef SVGLengthContext_h |
| 21 #define SVGLengthContext_h | 21 #define SVGLengthContext_h |
| 22 | 22 |
| 23 #include "core/svg/SVGUnitTypes.h" | 23 #include "core/svg/SVGUnitTypes.h" |
| 24 #include "platform/geometry/FloatRect.h" | 24 #include "platform/geometry/FloatRect.h" |
| 25 | 25 |
| 26 namespace blink { | 26 namespace blink { |
| 27 | 27 |
| 28 class ExceptionState; | |
| 29 class SVGElement; | 28 class SVGElement; |
| 30 class SVGLength; | 29 class SVGLength; |
| 31 | 30 |
| 32 enum SVGLengthType { | 31 enum SVGLengthType { |
| 33 LengthTypeUnknown = 0, | 32 LengthTypeUnknown = 0, |
| 34 LengthTypeNumber, | 33 LengthTypeNumber, |
| 35 LengthTypePercentage, | 34 LengthTypePercentage, |
| 36 LengthTypeEMS, | 35 LengthTypeEMS, |
| 37 LengthTypeEXS, | 36 LengthTypeEXS, |
| 38 LengthTypePX, | 37 LengthTypePX, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 50 }; | 49 }; |
| 51 | 50 |
| 52 class SVGLengthContext { | 51 class SVGLengthContext { |
| 53 STACK_ALLOCATED(); | 52 STACK_ALLOCATED(); |
| 54 public: | 53 public: |
| 55 explicit SVGLengthContext(const SVGElement*); | 54 explicit SVGLengthContext(const SVGElement*); |
| 56 | 55 |
| 57 template<typename T> | 56 template<typename T> |
| 58 static FloatRect resolveRectangle(const T* context, SVGUnitTypes::SVGUnitTyp
e type, const FloatRect& viewport) | 57 static FloatRect resolveRectangle(const T* context, SVGUnitTypes::SVGUnitTyp
e type, const FloatRect& viewport) |
| 59 { | 58 { |
| 60 return SVGLengthContext::resolveRectangle(context, type, viewport, conte
xt->x()->currentValue(), context->y()->currentValue(), context->width()->current
Value(), context->height()->currentValue()); | 59 return resolveRectangle(context, type, viewport, context->x()->currentVa
lue(), context->y()->currentValue(), context->width()->currentValue(), context->
height()->currentValue()); |
| 61 } | 60 } |
| 62 | 61 |
| 63 static FloatRect resolveRectangle(const SVGElement*, SVGUnitTypes::SVGUnitTy
pe, const FloatRect& viewport, PassRefPtrWillBeRawPtr<SVGLength> x, PassRefPtrWi
llBeRawPtr<SVGLength> y, PassRefPtrWillBeRawPtr<SVGLength> width, PassRefPtrWill
BeRawPtr<SVGLength> height); | 62 static FloatRect resolveRectangle(const SVGElement*, SVGUnitTypes::SVGUnitTy
pe, const FloatRect& viewport, PassRefPtrWillBeRawPtr<SVGLength> x, PassRefPtrWi
llBeRawPtr<SVGLength> y, PassRefPtrWillBeRawPtr<SVGLength> width, PassRefPtrWill
BeRawPtr<SVGLength> height); |
| 64 static FloatPoint resolvePoint(const SVGElement*, SVGUnitTypes::SVGUnitType,
PassRefPtrWillBeRawPtr<SVGLength> x, PassRefPtrWillBeRawPtr<SVGLength> y); | 63 static FloatPoint resolvePoint(const SVGElement*, SVGUnitTypes::SVGUnitType,
PassRefPtrWillBeRawPtr<SVGLength> x, PassRefPtrWillBeRawPtr<SVGLength> y); |
| 65 static float resolveLength(const SVGElement*, SVGUnitTypes::SVGUnitType, Pas
sRefPtrWillBeRawPtr<SVGLength>); | 64 static float resolveLength(const SVGElement*, SVGUnitTypes::SVGUnitType, Pas
sRefPtrWillBeRawPtr<SVGLength>); |
| 66 | 65 |
| 67 float convertValueToUserUnits(float, SVGLengthMode, SVGLengthType fromUnit,
ExceptionState&) const; | 66 float convertValueToUserUnits(float, SVGLengthMode, SVGLengthType fromUnit)
const; |
| 68 float convertValueFromUserUnits(float, SVGLengthMode, SVGLengthType toUnit,
ExceptionState&) const; | 67 float convertValueFromUserUnits(float, SVGLengthMode, SVGLengthType toUnit)
const; |
| 69 | 68 |
| 70 bool determineViewport(FloatSize&) const; | 69 bool determineViewport(FloatSize&) const; |
| 71 | 70 |
| 72 private: | 71 private: |
| 73 float convertValueFromUserUnitsToPercentage(float value, SVGLengthMode, Exce
ptionState&) const; | 72 static float convertValueFromUserUnitsToPercentage(float value, SVGLengthMod
e, const FloatSize&); |
| 74 float convertValueFromPercentageToUserUnits(float value, SVGLengthMode, Exce
ptionState&) const; | 73 static float convertValueFromPercentageToUserUnits(float value, SVGLengthMod
e, const FloatSize&); |
| 75 static float convertValueFromPercentageToUserUnits(float value, SVGLengthMod
e, const FloatSize& viewportSize); | |
| 76 static float convertValueFromPercentageToUserUnits(const SVGLength& value, c
onst FloatSize& viewportSize); | 74 static float convertValueFromPercentageToUserUnits(const SVGLength& value, c
onst FloatSize& viewportSize); |
| 77 | 75 |
| 78 float convertValueFromUserUnitsToEMS(float value, ExceptionState&) const; | 76 float convertValueFromUserUnitsToEMS(float value) const; |
| 79 float convertValueFromEMSToUserUnits(float value, ExceptionState&) const; | 77 float convertValueFromEMSToUserUnits(float value) const; |
| 80 | 78 |
| 81 float convertValueFromUserUnitsToEXS(float value, ExceptionState&) const; | 79 float convertValueFromUserUnitsToEXS(float value) const; |
| 82 float convertValueFromEXSToUserUnits(float value, ExceptionState&) const; | 80 float convertValueFromEXSToUserUnits(float value) const; |
| 83 | 81 |
| 84 RawPtrWillBeMember<const SVGElement> m_context; | 82 RawPtrWillBeMember<const SVGElement> m_context; |
| 85 }; | 83 }; |
| 86 | 84 |
| 87 } // namespace blink | 85 } // namespace blink |
| 88 | 86 |
| 89 #endif // SVGLengthContext_h | 87 #endif // SVGLengthContext_h |
| OLD | NEW |