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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 s_lengthModeMap.set(SVGNames::textLengthAttr, SVGLengthMode::Width); | 310 s_lengthModeMap.set(SVGNames::textLengthAttr, SVGLengthMode::Width); |
311 s_lengthModeMap.set(SVGNames::startOffsetAttr, SVGLengthMode::Width); | 311 s_lengthModeMap.set(SVGNames::startOffsetAttr, SVGLengthMode::Width); |
312 } | 312 } |
313 | 313 |
314 if (s_lengthModeMap.contains(attrName)) | 314 if (s_lengthModeMap.contains(attrName)) |
315 return s_lengthModeMap.get(attrName); | 315 return s_lengthModeMap.get(attrName); |
316 | 316 |
317 return SVGLengthMode::Other; | 317 return SVGLengthMode::Other; |
318 } | 318 } |
319 | 319 |
320 PassRefPtrWillBeRawPtr<SVGLength> SVGLength::blend(PassRefPtrWillBeRawPtr<SVGLen
gth> passFrom, float progress) const | |
321 { | |
322 RefPtrWillBeRawPtr<SVGLength> from = passFrom; | |
323 | |
324 SVGLengthType toType = unitType(); | |
325 SVGLengthType fromType = from->unitType(); | |
326 if ((from->isZero() && isZero()) | |
327 || fromType == LengthTypeUnknown | |
328 || toType == LengthTypeUnknown | |
329 || (!from->isZero() && fromType != LengthTypePercentage && toType == Len
gthTypePercentage) | |
330 || (!isZero() && fromType == LengthTypePercentage && toType != LengthTyp
ePercentage) | |
331 || (!from->isZero() && !isZero() && (fromType == LengthTypeEMS || fromTy
pe == LengthTypeEXS || fromType == LengthTypeREMS || fromType == LengthTypeCHS)
&& fromType != toType)) | |
332 return clone(); | |
333 | |
334 RefPtrWillBeRawPtr<SVGLength> length = create(); | |
335 | |
336 if (fromType == LengthTypePercentage || toType == LengthTypePercentage) { | |
337 float fromPercent = from->valueAsPercentage100(); | |
338 float toPercent = valueAsPercentage100(); | |
339 length->newValueSpecifiedUnits(LengthTypePercentage, blink::blend(fromPe
rcent, toPercent, progress)); | |
340 return length; | |
341 } | |
342 | |
343 if (fromType == toType || from->isZero() || isZero() || fromType == LengthTy
peEMS || fromType == LengthTypeEXS || fromType == LengthTypeREMS || fromType ==
LengthTypeCHS) { | |
344 float fromValue = from->valueInSpecifiedUnits(); | |
345 float toValue = valueInSpecifiedUnits(); | |
346 if (isZero()) | |
347 length->newValueSpecifiedUnits(fromType, blink::blend(fromValue, toV
alue, progress)); | |
348 else | |
349 length->newValueSpecifiedUnits(toType, blink::blend(fromValue, toVal
ue, progress)); | |
350 return length; | |
351 } | |
352 | |
353 ASSERT(!isRelative()); | |
354 ASSERT(!from->isRelative()); | |
355 | |
356 SVGLengthContext nonRelativeLengthContext(0); | |
357 float fromValueInUserUnits = nonRelativeLengthContext.convertValueToUserUnit
s(from->valueInSpecifiedUnits(), from->unitMode(), fromType); | |
358 float fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fromVal
ueInUserUnits, unitMode(), toType); | |
359 | |
360 float toValue = valueInSpecifiedUnits(); | |
361 length->newValueSpecifiedUnits(toType, blink::blend(fromValue, toValue, prog
ress)); | |
362 return length; | |
363 } | |
364 | |
365 void SVGLength::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* c
ontextElement) | 320 void SVGLength::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement* c
ontextElement) |
366 { | 321 { |
367 SVGLengthContext lengthContext(contextElement); | 322 SVGLengthContext lengthContext(contextElement); |
368 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext); | 323 setValue(value(lengthContext) + toSVGLength(other)->value(lengthContext), le
ngthContext); |
369 } | 324 } |
370 | 325 |
371 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, fl
oat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fr
omValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeRawPtr
<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) | 326 void SVGLength::calculateAnimatedValue(SVGAnimationElement* animationElement, fl
oat percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> fr
omValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeRawPtr
<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) |
372 { | 327 { |
373 RefPtrWillBeRawPtr<SVGLength> fromLength = toSVGLength(fromValue); | 328 RefPtrWillBeRawPtr<SVGLength> fromLength = toSVGLength(fromValue); |
374 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); | 329 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); |
(...skipping 10 matching lines...) Expand all Loading... |
385 | 340 |
386 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) | 341 float SVGLength::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> toVal
ue, SVGElement* contextElement) |
387 { | 342 { |
388 SVGLengthContext lengthContext(contextElement); | 343 SVGLengthContext lengthContext(contextElement); |
389 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); | 344 RefPtrWillBeRawPtr<SVGLength> toLength = toSVGLength(toValue); |
390 | 345 |
391 return fabsf(toLength->value(lengthContext) - value(lengthContext)); | 346 return fabsf(toLength->value(lengthContext) - value(lengthContext)); |
392 } | 347 } |
393 | 348 |
394 } | 349 } |
OLD | NEW |