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 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 79 |
80 void SVGLength::setValue(float value, const SVGLengthContext& context) | 80 void SVGLength::setValue(float value, const SVGLengthContext& context) |
81 { | 81 { |
82 m_value = CSSPrimitiveValue::create( | 82 m_value = CSSPrimitiveValue::create( |
83 context.convertValueFromUserUnits(value, unitMode(), m_value->typeWithCa lcResolved()), | 83 context.convertValueFromUserUnits(value, unitMode(), m_value->typeWithCa lcResolved()), |
84 m_value->typeWithCalcResolved()); | 84 m_value->typeWithCalcResolved()); |
85 } | 85 } |
86 | 86 |
87 bool isSupportedCSSUnitType(CSSPrimitiveValue::UnitType type) | 87 bool isSupportedCSSUnitType(CSSPrimitiveValue::UnitType type) |
88 { | 88 { |
89 return (CSSPrimitiveValue::isLength(type) || type == CSSPrimitiveValue::Unit Type::Number || type == CSSPrimitiveValue::UnitType::Percentage) | 89 return (CSSPrimitiveValue::isLength(type) || type == CSSPrimitiveValue::Unit Type::Number || type == CSSPrimitiveValue::UnitType::Percentage || (type >= CSSP rimitiveValue::UnitType::Calc && type <= CSSPrimitiveValue::UnitType::CalcPercen tageWithLengthAndNumber)) |
fs
2016/06/29 09:28:17
Suggest you reformat this function, to maybe make
Shanmuga Pandi
2016/07/15 12:18:22
Done.
| |
90 && type != CSSPrimitiveValue::UnitType::QuirkyEms; | 90 && type != CSSPrimitiveValue::UnitType::QuirkyEms; |
91 } | 91 } |
92 | 92 |
93 void SVGLength::setUnitType(CSSPrimitiveValue::UnitType type) | 93 void SVGLength::setUnitType(CSSPrimitiveValue::UnitType type) |
94 { | 94 { |
95 ASSERT(isSupportedCSSUnitType(type)); | 95 ASSERT(isSupportedCSSUnitType(type)); |
96 m_value = CSSPrimitiveValue::create(m_value->getFloatValue(), type); | 96 m_value = CSSPrimitiveValue::create(m_value->getFloatValue(), type); |
97 } | 97 } |
98 | 98 |
99 float SVGLength::valueAsPercentage() const | 99 float SVGLength::valueAsPercentage() const |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
132 m_value = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::User Units); | 132 m_value = CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::User Units); |
133 return SVGParseStatus::NoError; | 133 return SVGParseStatus::NoError; |
134 } | 134 } |
135 | 135 |
136 CSSParserContext svgParserContext(SVGAttributeMode, 0); | 136 CSSParserContext svgParserContext(SVGAttributeMode, 0); |
137 CSSValue* parsed = CSSParser::parseSingleValue(CSSPropertyX, string, svgPars erContext); | 137 CSSValue* parsed = CSSParser::parseSingleValue(CSSPropertyX, string, svgPars erContext); |
138 if (!parsed || !parsed->isPrimitiveValue()) | 138 if (!parsed || !parsed->isPrimitiveValue()) |
139 return SVGParseStatus::ExpectedLength; | 139 return SVGParseStatus::ExpectedLength; |
140 | 140 |
141 CSSPrimitiveValue* newValue = toCSSPrimitiveValue(parsed); | 141 CSSPrimitiveValue* newValue = toCSSPrimitiveValue(parsed); |
142 // TODO(fs): Enable calc for SVG lengths | 142 if (!isSupportedCSSUnitType(newValue->typeWithCalcResolved())) |
143 if (newValue->isCalculated() || !isSupportedCSSUnitType(newValue->typeWithCa lcResolved())) | |
144 return SVGParseStatus::ExpectedLength; | 143 return SVGParseStatus::ExpectedLength; |
145 | 144 |
146 m_value = newValue; | 145 m_value = newValue; |
147 return SVGParseStatus::NoError; | 146 return SVGParseStatus::NoError; |
148 } | 147 } |
149 | 148 |
150 String SVGLength::valueAsString() const | 149 String SVGLength::valueAsString() const |
151 { | 150 { |
152 return m_value->customCSSText(); | 151 return m_value->customCSSText(); |
153 } | 152 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
256 | 255 |
257 float SVGLength::calculateDistance(SVGPropertyBase* toValue, SVGElement* context Element) | 256 float SVGLength::calculateDistance(SVGPropertyBase* toValue, SVGElement* context Element) |
258 { | 257 { |
259 SVGLengthContext lengthContext(contextElement); | 258 SVGLengthContext lengthContext(contextElement); |
260 SVGLength* toLength = toSVGLength(toValue); | 259 SVGLength* toLength = toSVGLength(toValue); |
261 | 260 |
262 return fabsf(toLength->value(lengthContext) - value(lengthContext)); | 261 return fabsf(toLength->value(lengthContext) - value(lengthContext)); |
263 } | 262 } |
264 | 263 |
265 } // namespace blink | 264 } // namespace blink |
OLD | NEW |