| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "core/svg/SVGIntegerOptionalInteger.h" | 31 #include "core/svg/SVGIntegerOptionalInteger.h" |
| 32 | 32 |
| 33 #include "core/svg/SVGAnimationElement.h" | 33 #include "core/svg/SVGAnimationElement.h" |
| 34 #include "core/svg/SVGParserUtilities.h" | 34 #include "core/svg/SVGParserUtilities.h" |
| 35 | 35 |
| 36 namespace blink { | 36 namespace blink { |
| 37 | 37 |
| 38 SVGIntegerOptionalInteger::SVGIntegerOptionalInteger(PassRefPtrWillBeRawPtr<SVGI
nteger> firstInteger, PassRefPtrWillBeRawPtr<SVGInteger> secondInteger) | 38 SVGIntegerOptionalInteger::SVGIntegerOptionalInteger(RawPtr<SVGInteger> firstInt
eger, RawPtr<SVGInteger> secondInteger) |
| 39 : SVGPropertyBase(classType()) | 39 : SVGPropertyBase(classType()) |
| 40 , m_firstInteger(firstInteger) | 40 , m_firstInteger(firstInteger) |
| 41 , m_secondInteger(secondInteger) | 41 , m_secondInteger(secondInteger) |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 DEFINE_TRACE(SVGIntegerOptionalInteger) | 45 DEFINE_TRACE(SVGIntegerOptionalInteger) |
| 46 { | 46 { |
| 47 visitor->trace(m_firstInteger); | 47 visitor->trace(m_firstInteger); |
| 48 visitor->trace(m_secondInteger); | 48 visitor->trace(m_secondInteger); |
| 49 SVGPropertyBase::trace(visitor); | 49 SVGPropertyBase::trace(visitor); |
| 50 } | 50 } |
| 51 | 51 |
| 52 PassRefPtrWillBeRawPtr<SVGIntegerOptionalInteger> SVGIntegerOptionalInteger::clo
ne() const | 52 RawPtr<SVGIntegerOptionalInteger> SVGIntegerOptionalInteger::clone() const |
| 53 { | 53 { |
| 54 return SVGIntegerOptionalInteger::create(m_firstInteger->clone(), m_secondIn
teger->clone()); | 54 return SVGIntegerOptionalInteger::create(m_firstInteger->clone(), m_secondIn
teger->clone()); |
| 55 } | 55 } |
| 56 | 56 |
| 57 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGIntegerOptionalInteger::cloneForAnima
tion(const String& value) const | 57 RawPtr<SVGPropertyBase> SVGIntegerOptionalInteger::cloneForAnimation(const Strin
g& value) const |
| 58 { | 58 { |
| 59 float floatX, floatY; | 59 float floatX, floatY; |
| 60 if (!parseNumberOptionalNumber(value, floatX, floatY)) { | 60 if (!parseNumberOptionalNumber(value, floatX, floatY)) { |
| 61 return SVGIntegerOptionalInteger::create(SVGInteger::create(0), SVGInteg
er::create(0)); | 61 return SVGIntegerOptionalInteger::create(SVGInteger::create(0), SVGInteg
er::create(0)); |
| 62 } | 62 } |
| 63 | 63 |
| 64 int x = static_cast<int>(roundf(floatX)); | 64 int x = static_cast<int>(roundf(floatX)); |
| 65 int y = static_cast<int>(roundf(floatY)); | 65 int y = static_cast<int>(roundf(floatY)); |
| 66 | 66 |
| 67 return SVGIntegerOptionalInteger::create(SVGInteger::create(x), SVGInteger::
create(y)); | 67 return SVGIntegerOptionalInteger::create(SVGInteger::create(x), SVGInteger::
create(y)); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 83 if (!parseNumberOptionalNumber(value, x, y)) { | 83 if (!parseNumberOptionalNumber(value, x, y)) { |
| 84 parseStatus = SVGParseStatus::ExpectedInteger; | 84 parseStatus = SVGParseStatus::ExpectedInteger; |
| 85 x = y = 0; | 85 x = y = 0; |
| 86 } | 86 } |
| 87 | 87 |
| 88 m_firstInteger->setValue(x); | 88 m_firstInteger->setValue(x); |
| 89 m_secondInteger->setValue(y); | 89 m_secondInteger->setValue(y); |
| 90 return parseStatus; | 90 return parseStatus; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void SVGIntegerOptionalInteger::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> othe
r, SVGElement*) | 93 void SVGIntegerOptionalInteger::add(RawPtr<SVGPropertyBase> other, SVGElement*) |
| 94 { | 94 { |
| 95 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> otherIntegerOptionalInteger =
toSVGIntegerOptionalInteger(other); | 95 RawPtr<SVGIntegerOptionalInteger> otherIntegerOptionalInteger = toSVGInteger
OptionalInteger(other); |
| 96 | 96 |
| 97 m_firstInteger->setValue(m_firstInteger->value() + otherIntegerOptionalInteg
er->m_firstInteger->value()); | 97 m_firstInteger->setValue(m_firstInteger->value() + otherIntegerOptionalInteg
er->m_firstInteger->value()); |
| 98 m_secondInteger->setValue(m_secondInteger->value() + otherIntegerOptionalInt
eger->m_secondInteger->value()); | 98 m_secondInteger->setValue(m_secondInteger->value() + otherIntegerOptionalInt
eger->m_secondInteger->value()); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void SVGIntegerOptionalInteger::calculateAnimatedValue(SVGAnimationElement* anim
ationElement, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVG
PropertyBase> from, PassRefPtrWillBeRawPtr<SVGPropertyBase> to, PassRefPtrWillBe
RawPtr<SVGPropertyBase> toAtEndOfDuration, SVGElement*) | 101 void SVGIntegerOptionalInteger::calculateAnimatedValue(SVGAnimationElement* anim
ationElement, float percentage, unsigned repeatCount, RawPtr<SVGPropertyBase> fr
om, RawPtr<SVGPropertyBase> to, RawPtr<SVGPropertyBase> toAtEndOfDuration, SVGEl
ement*) |
| 102 { | 102 { |
| 103 ASSERT(animationElement); | 103 ASSERT(animationElement); |
| 104 | 104 |
| 105 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> fromInteger = toSVGIntegerOpti
onalInteger(from); | 105 RawPtr<SVGIntegerOptionalInteger> fromInteger = toSVGIntegerOptionalInteger(
from); |
| 106 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> toInteger = toSVGIntegerOption
alInteger(to); | 106 RawPtr<SVGIntegerOptionalInteger> toInteger = toSVGIntegerOptionalInteger(to
); |
| 107 RefPtrWillBeRawPtr<SVGIntegerOptionalInteger> toAtEndOfDurationInteger = toS
VGIntegerOptionalInteger(toAtEndOfDuration); | 107 RawPtr<SVGIntegerOptionalInteger> toAtEndOfDurationInteger = toSVGIntegerOpt
ionalInteger(toAtEndOfDuration); |
| 108 | 108 |
| 109 float x = m_firstInteger->value(); | 109 float x = m_firstInteger->value(); |
| 110 float y = m_secondInteger->value(); | 110 float y = m_secondInteger->value(); |
| 111 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->firstInteger()->value(), toInteger->firstInteger()->value(), toAtEndOfDuration
Integer->firstInteger()->value(), x); | 111 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->firstInteger()->value(), toInteger->firstInteger()->value(), toAtEndOfDuration
Integer->firstInteger()->value(), x); |
| 112 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->secondInteger()->value(), toInteger->secondInteger()->value(), toAtEndOfDurati
onInteger->secondInteger()->value(), y); | 112 animationElement->animateAdditiveNumber(percentage, repeatCount, fromInteger
->secondInteger()->value(), toInteger->secondInteger()->value(), toAtEndOfDurati
onInteger->secondInteger()->value(), y); |
| 113 m_firstInteger->setValue(static_cast<int>(roundf(x))); | 113 m_firstInteger->setValue(static_cast<int>(roundf(x))); |
| 114 m_secondInteger->setValue(static_cast<int>(roundf(y))); | 114 m_secondInteger->setValue(static_cast<int>(roundf(y))); |
| 115 } | 115 } |
| 116 | 116 |
| 117 float SVGIntegerOptionalInteger::calculateDistance(PassRefPtrWillBeRawPtr<SVGPro
pertyBase> other, SVGElement*) | 117 float SVGIntegerOptionalInteger::calculateDistance(RawPtr<SVGPropertyBase> other
, SVGElement*) |
| 118 { | 118 { |
| 119 // FIXME: Distance calculation is not possible for SVGIntegerOptionalInteger
right now. We need the distance for every single value. | 119 // FIXME: Distance calculation is not possible for SVGIntegerOptionalInteger
right now. We need the distance for every single value. |
| 120 return -1; | 120 return -1; |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace blink | 123 } // namespace blink |
| OLD | NEW |