| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 , m_unitMode(o.m_unitMode) | 46 , m_unitMode(o.m_unitMode) |
| 47 { | 47 { |
| 48 } | 48 } |
| 49 | 49 |
| 50 DEFINE_TRACE(SVGLength) | 50 DEFINE_TRACE(SVGLength) |
| 51 { | 51 { |
| 52 visitor->trace(m_value); | 52 visitor->trace(m_value); |
| 53 SVGPropertyBase::trace(visitor); | 53 SVGPropertyBase::trace(visitor); |
| 54 } | 54 } |
| 55 | 55 |
| 56 PassRefPtrWillBeRawPtr<SVGLength> SVGLength::clone() const | 56 RawPtr<SVGLength> SVGLength::clone() const |
| 57 { | 57 { |
| 58 return adoptRefWillBeNoop(new SVGLength(*this)); | 58 return (new SVGLength(*this)); |
| 59 } | 59 } |
| 60 | 60 |
| 61 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLength::cloneForAnimation(const Strin
g& value) const | 61 RawPtr<SVGPropertyBase> SVGLength::cloneForAnimation(const String& value) const |
| 62 { | 62 { |
| 63 RefPtrWillBeRawPtr<SVGLength> length = create(); | 63 RawPtr<SVGLength> length = create(); |
| 64 length->m_unitMode = m_unitMode; | 64 length->m_unitMode = m_unitMode; |
| 65 | 65 |
| 66 if (length->setValueAsString(value) != SVGParseStatus::NoError) | 66 if (length->setValueAsString(value) != SVGParseStatus::NoError) |
| 67 length->m_value = cssValuePool().createValue(0, CSSPrimitiveValue::UnitT
ype::UserUnits); | 67 length->m_value = cssValuePool().createValue(0, CSSPrimitiveValue::UnitT
ype::UserUnits); |
| 68 | 68 |
| 69 return length.release(); | 69 return length.release(); |
| 70 } | 70 } |
| 71 | 71 |
| 72 bool SVGLength::operator==(const SVGLength& other) const | 72 bool SVGLength::operator==(const SVGLength& other) const |
| 73 { | 73 { |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 } | 130 } |
| 131 | 131 |
| 132 SVGParsingError SVGLength::setValueAsString(const String& string) | 132 SVGParsingError SVGLength::setValueAsString(const String& string) |
| 133 { | 133 { |
| 134 if (string.isEmpty()) { | 134 if (string.isEmpty()) { |
| 135 m_value = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Use
rUnits); | 135 m_value = cssValuePool().createValue(0, CSSPrimitiveValue::UnitType::Use
rUnits); |
| 136 return SVGParseStatus::NoError; | 136 return SVGParseStatus::NoError; |
| 137 } | 137 } |
| 138 | 138 |
| 139 CSSParserContext svgParserContext(SVGAttributeMode, 0); | 139 CSSParserContext svgParserContext(SVGAttributeMode, 0); |
| 140 RefPtrWillBeRawPtr<CSSValue> parsed = CSSParser::parseSingleValue(CSSPropert
yX, string, svgParserContext); | 140 RawPtr<CSSValue> parsed = CSSParser::parseSingleValue(CSSPropertyX, string,
svgParserContext); |
| 141 if (!parsed || !parsed->isPrimitiveValue()) | 141 if (!parsed || !parsed->isPrimitiveValue()) |
| 142 return SVGParseStatus::ExpectedLength; | 142 return SVGParseStatus::ExpectedLength; |
| 143 | 143 |
| 144 CSSPrimitiveValue* newValue = toCSSPrimitiveValue(parsed.get()); | 144 CSSPrimitiveValue* newValue = toCSSPrimitiveValue(parsed.get()); |
| 145 // TODO(fs): Enable calc for SVG lengths | 145 // TODO(fs): Enable calc for SVG lengths |
| 146 if (newValue->isCalculated() || !isSupportedCSSUnitType(newValue->typeWithCa
lcResolved())) | 146 if (newValue->isCalculated() || !isSupportedCSSUnitType(newValue->typeWithCa
lcResolved())) |
| 147 return SVGParseStatus::ExpectedLength; | 147 return SVGParseStatus::ExpectedLength; |
| 148 | 148 |
| 149 m_value = newValue; | 149 m_value = newValue; |
| 150 return SVGParseStatus::NoError; | 150 return SVGParseStatus::NoError; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 s_noNegativeValuesSet.add(SVGNames::widthAttr); | 220 s_noNegativeValuesSet.add(SVGNames::widthAttr); |
| 221 s_noNegativeValuesSet.add(SVGNames::heightAttr); | 221 s_noNegativeValuesSet.add(SVGNames::heightAttr); |
| 222 s_noNegativeValuesSet.add(SVGNames::markerWidthAttr); | 222 s_noNegativeValuesSet.add(SVGNames::markerWidthAttr); |
| 223 s_noNegativeValuesSet.add(SVGNames::markerHeightAttr); | 223 s_noNegativeValuesSet.add(SVGNames::markerHeightAttr); |
| 224 s_noNegativeValuesSet.add(SVGNames::textLengthAttr); | 224 s_noNegativeValuesSet.add(SVGNames::textLengthAttr); |
| 225 } | 225 } |
| 226 | 226 |
| 227 return s_noNegativeValuesSet.contains(attrName); | 227 return s_noNegativeValuesSet.contains(attrName); |
| 228 } | 228 } |
| 229 | 229 |
| 230 void SVGLength::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* c
ontextElement) | 230 void SVGLength::add(RawPtr<SVGPropertyBase> other, SVGElement* contextElement) |
| 231 { | 231 { |
| 232 SVGLengthContext lengthContext(contextElement); | 232 SVGLengthContext lengthContext(contextElement); |
| 233 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext); | 233 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, | 236 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, |
| 237 float percentage, | 237 float percentage, |
| 238 unsigned repeatCount, | 238 unsigned repeatCount, |
| 239 PassRefPtrWillBeRawPtr<SVGPropertyBase> fromValue, | 239 RawPtr<SVGPropertyBase> fromValue, |
| 240 PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, | 240 RawPtr<SVGPropertyBase> toValue, |
| 241 PassRefPtrWillBeRawPtr<SVGPropertyBase> toAtEndOfDurationValue, | 241 RawPtr<SVGPropertyBase> toAtEndOfDurationValue, |
| 242 SVGElement* contextElement) | 242 SVGElement* contextElement) |
| 243 { | 243 { |
| 244 RefPtrWillBeRawPtr<SVGLength> fromLength = toSVGLength(fromValue); | 244 RawPtr<SVGLength> fromLength = toSVGLength(fromValue); |
| 245 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); | 245 RawPtr<SVGLength> toLength = toSVGLength(toValue); |
| 246 RefPtrWillBeRawPtr<SVGLength> toAtEndOfDurationLength = toSVGLength(toAtEndO
fDurationValue); | 246 RawPtr<SVGLength> toAtEndOfDurationLength = toSVGLength(toAtEndOfDurationVal
ue); |
| 247 | 247 |
| 248 SVGLengthContext lengthContext(contextElement); | 248 SVGLengthContext lengthContext(contextElement); |
| 249 float animatedNumber = value(lengthContext); | 249 float animatedNumber = value(lengthContext); |
| 250 animationElement->animateAdditiveNumber(percentage, repeatCount, fromLength-
>value(lengthContext), | 250 animationElement->animateAdditiveNumber(percentage, repeatCount, fromLength-
>value(lengthContext), |
| 251 toLength->value(lengthContext), toAtEndOfDurationLength->value(lengthCon
text), animatedNumber); | 251 toLength->value(lengthContext), toAtEndOfDurationLength->value(lengthCon
text), animatedNumber); |
| 252 | 252 |
| 253 ASSERT(unitMode() == lengthModeForAnimatedLengthAttribute(animationElement->
attributeName())); | 253 ASSERT(unitMode() == lengthModeForAnimatedLengthAttribute(animationElement->
attributeName())); |
| 254 | 254 |
| 255 CSSPrimitiveValue::UnitType newUnit = percentage < 0.5 ? fromLength->typeWit
hCalcResolved() : toLength->typeWithCalcResolved(); | 255 CSSPrimitiveValue::UnitType newUnit = percentage < 0.5 ? fromLength->typeWit
hCalcResolved() : toLength->typeWithCalcResolved(); |
| 256 animatedNumber = lengthContext.convertValueFromUserUnits(animatedNumber, uni
tMode(), newUnit); | 256 animatedNumber = lengthContext.convertValueFromUserUnits(animatedNumber, uni
tMode(), newUnit); |
| 257 m_value = CSSPrimitiveValue::create(animatedNumber, newUnit); | 257 m_value = CSSPrimitiveValue::create(animatedNumber, newUnit); |
| 258 } | 258 } |
| 259 | 259 |
| 260 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) | 260 float SVGLength::calculateDistance(RawPtr<SVGPropertyBase> toValue, SVGElement*
contextElement) |
| 261 { | 261 { |
| 262 SVGLengthContext lengthContext(contextElement); | 262 SVGLengthContext lengthContext(contextElement); |
| 263 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); | 263 RawPtr<SVGLength> toLength = toSVGLength(toValue); |
| 264 | 264 |
| 265 return fabsf(toLength->value(lengthContext) - value(lengthContext)); | 265 return fabsf(toLength->value(lengthContext) - value(lengthContext)); |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace blink | 268 } // namespace blink |
| OLD | NEW |