| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 #include "core/svg/SVGLengthList.h" | 22 #include "core/svg/SVGLengthList.h" |
| 23 | 23 |
| 24 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 24 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 25 #include "core/svg/SVGAnimationElement.h" | 25 #include "core/svg/SVGAnimationElement.h" |
| 26 #include "core/svg/SVGParserUtilities.h" | 26 #include "core/svg/SVGParserUtilities.h" |
| 27 #include "wtf/text/StringBuilder.h" | 27 #include "wtf/text/StringBuilder.h" |
| 28 | 28 |
| 29 namespace blink { | 29 namespace blink { |
| 30 | 30 |
| 31 inline PassRefPtr<SVGLengthList> toSVGLengthList(PassRefPtr<SVGPropertyBase> pas
sBase) | 31 inline PassRefPtrWillBeRawPtr<SVGLengthList> toSVGLengthList(PassRefPtrWillBeRaw
Ptr<SVGPropertyBase> passBase) |
| 32 { | 32 { |
| 33 RefPtr<SVGPropertyBase> base = passBase; | 33 RefPtrWillBeRawPtr<SVGPropertyBase> base = passBase; |
| 34 ASSERT(base->type() == SVGLengthList::classType()); | 34 ASSERT(base->type() == SVGLengthList::classType()); |
| 35 return static_pointer_cast<SVGLengthList>(base.release()); | 35 return static_pointer_cast<SVGLengthList>(base.release()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 SVGLengthList::SVGLengthList(SVGLengthMode mode) | 38 SVGLengthList::SVGLengthList(SVGLengthMode mode) |
| 39 : m_mode(mode) | 39 : m_mode(mode) |
| 40 { | 40 { |
| 41 } | 41 } |
| 42 | 42 |
| 43 SVGLengthList::~SVGLengthList() | 43 SVGLengthList::~SVGLengthList() |
| 44 { | 44 { |
| 45 } | 45 } |
| 46 | 46 |
| 47 PassRefPtr<SVGLengthList> SVGLengthList::clone() | 47 PassRefPtrWillBeRawPtr<SVGLengthList> SVGLengthList::clone() |
| 48 { | 48 { |
| 49 RefPtr<SVGLengthList> ret = SVGLengthList::create(m_mode); | 49 RefPtrWillBeRawPtr<SVGLengthList> ret = SVGLengthList::create(m_mode); |
| 50 ret->deepCopy(this); | 50 ret->deepCopy(this); |
| 51 return ret.release(); | 51 return ret.release(); |
| 52 } | 52 } |
| 53 | 53 |
| 54 PassRefPtr<SVGPropertyBase> SVGLengthList::cloneForAnimation(const String& value
) const | 54 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGLengthList::cloneForAnimation(const S
tring& value) const |
| 55 { | 55 { |
| 56 RefPtr<SVGLengthList> ret = SVGLengthList::create(m_mode); | 56 RefPtrWillBeRawPtr<SVGLengthList> ret = SVGLengthList::create(m_mode); |
| 57 ret->setValueAsString(value, IGNORE_EXCEPTION); | 57 ret->setValueAsString(value, IGNORE_EXCEPTION); |
| 58 return ret.release(); | 58 return ret.release(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 String SVGLengthList::valueAsString() const | 61 String SVGLengthList::valueAsString() const |
| 62 { | 62 { |
| 63 StringBuilder builder; | 63 StringBuilder builder; |
| 64 | 64 |
| 65 ConstIterator it = begin(); | 65 ConstIterator it = begin(); |
| 66 ConstIterator itEnd = end(); | 66 ConstIterator itEnd = end(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 81 void SVGLengthList::parseInternal(const CharType*& ptr, const CharType* end, Exc
eptionState& exceptionState) | 81 void SVGLengthList::parseInternal(const CharType*& ptr, const CharType* end, Exc
eptionState& exceptionState) |
| 82 { | 82 { |
| 83 clear(); | 83 clear(); |
| 84 while (ptr < end) { | 84 while (ptr < end) { |
| 85 const CharType* start = ptr; | 85 const CharType* start = ptr; |
| 86 while (ptr < end && *ptr != ',' && !isHTMLSpace<CharType>(*ptr)) | 86 while (ptr < end && *ptr != ',' && !isHTMLSpace<CharType>(*ptr)) |
| 87 ptr++; | 87 ptr++; |
| 88 if (ptr == start) | 88 if (ptr == start) |
| 89 break; | 89 break; |
| 90 | 90 |
| 91 RefPtr<SVGLength> length = SVGLength::create(m_mode); | 91 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(m_mode); |
| 92 String valueString(start, ptr - start); | 92 String valueString(start, ptr - start); |
| 93 if (valueString.isEmpty()) | 93 if (valueString.isEmpty()) |
| 94 return; | 94 return; |
| 95 length->setValueAsString(valueString, exceptionState); | 95 length->setValueAsString(valueString, exceptionState); |
| 96 if (exceptionState.hadException()) | 96 if (exceptionState.hadException()) |
| 97 return; | 97 return; |
| 98 append(length); | 98 append(length); |
| 99 skipOptionalSVGSpacesOrDelimiter(ptr, end); | 99 skipOptionalSVGSpacesOrDelimiter(ptr, end); |
| 100 } | 100 } |
| 101 } | 101 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 112 parseInternal(ptr, end, exceptionState); | 112 parseInternal(ptr, end, exceptionState); |
| 113 } else { | 113 } else { |
| 114 const UChar* ptr = value.characters16(); | 114 const UChar* ptr = value.characters16(); |
| 115 const UChar* end = ptr + value.length(); | 115 const UChar* end = ptr + value.length(); |
| 116 parseInternal(ptr, end, exceptionState); | 116 parseInternal(ptr, end, exceptionState); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void SVGLengthList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElemen
t* contextElement) | 120 void SVGLengthList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElemen
t* contextElement) |
| 121 { | 121 { |
| 122 RefPtr<SVGLengthList> otherList = toSVGLengthList(other); | 122 RefPtrWillBeRawPtr<SVGLengthList> otherList = toSVGLengthList(other); |
| 123 | 123 |
| 124 if (length() != otherList->length()) | 124 if (length() != otherList->length()) |
| 125 return; | 125 return; |
| 126 | 126 |
| 127 SVGLengthContext lengthContext(contextElement); | 127 SVGLengthContext lengthContext(contextElement); |
| 128 for (size_t i = 0; i < length(); ++i) | 128 for (size_t i = 0; i < length(); ++i) |
| 129 at(i)->setValue(at(i)->value(lengthContext) + otherList->at(i)->value(le
ngthContext), lengthContext, ASSERT_NO_EXCEPTION); | 129 at(i)->setValue(at(i)->value(lengthContext) + otherList->at(i)->value(le
ngthContext), lengthContext, ASSERT_NO_EXCEPTION); |
| 130 } | 130 } |
| 131 | 131 |
| 132 PassRefPtr<SVGLength> SVGLengthList::createPaddingItem() const | 132 PassRefPtrWillBeRawPtr<SVGLength> SVGLengthList::createPaddingItem() const |
| 133 { | 133 { |
| 134 return SVGLength::create(m_mode); | 134 return SVGLength::create(m_mode); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void SVGLengthList::calculateAnimatedValue(SVGAnimationElement* animationElement
, float percentage, unsigned repeatCount, PassRefPtr<SVGPropertyBase> fromValue,
PassRefPtr<SVGPropertyBase> toValue, PassRefPtr<SVGPropertyBase> toAtEndOfDurat
ionValue, SVGElement* contextElement) | 137 void SVGLengthList::calculateAnimatedValue(SVGAnimationElement* animationElement
, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase
> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeRa
wPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement* contextElement) |
| 138 { | 138 { |
| 139 RefPtr<SVGLengthList> fromList = toSVGLengthList(fromValue); | 139 RefPtrWillBeRawPtr<SVGLengthList> fromList = toSVGLengthList(fromValue); |
| 140 RefPtr<SVGLengthList> toList = toSVGLengthList(toValue); | 140 RefPtrWillBeRawPtr<SVGLengthList> toList = toSVGLengthList(toValue); |
| 141 RefPtr<SVGLengthList> toAtEndOfDurationList = toSVGLengthList(toAtEndOfDurat
ionValue); | 141 RefPtrWillBeRawPtr<SVGLengthList> toAtEndOfDurationList = toSVGLengthList(to
AtEndOfDurationValue); |
| 142 | 142 |
| 143 SVGLengthContext lengthContext(contextElement); | 143 SVGLengthContext lengthContext(contextElement); |
| 144 ASSERT(m_mode == SVGLength::lengthModeForAnimatedLengthAttribute(animationEl
ement->attributeName())); | 144 ASSERT(m_mode == SVGLength::lengthModeForAnimatedLengthAttribute(animationEl
ement->attributeName())); |
| 145 | 145 |
| 146 size_t fromLengthListSize = fromList->length(); | 146 size_t fromLengthListSize = fromList->length(); |
| 147 size_t toLengthListSize = toList->length(); | 147 size_t toLengthListSize = toList->length(); |
| 148 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length(); | 148 size_t toAtEndOfDurationListSize = toAtEndOfDurationList->length(); |
| 149 | 149 |
| 150 if (!adjustFromToListValues(fromList, toList, percentage, animationElement->
animationMode())) | 150 if (!adjustFromToListValues(fromList, toList, percentage, animationElement->
animationMode())) |
| 151 return; | 151 return; |
| 152 | 152 |
| 153 for (size_t i = 0; i < toLengthListSize; ++i) { | 153 for (size_t i = 0; i < toLengthListSize; ++i) { |
| 154 float animatedNumber = at(i)->value(lengthContext); | 154 float animatedNumber = at(i)->value(lengthContext); |
| 155 SVGLengthType unitType = toList->at(i)->unitType(); | 155 SVGLengthType unitType = toList->at(i)->unitType(); |
| 156 float effectiveFrom = 0; | 156 float effectiveFrom = 0; |
| 157 if (fromLengthListSize) { | 157 if (fromLengthListSize) { |
| 158 if (percentage < 0.5) | 158 if (percentage < 0.5) |
| 159 unitType = fromList->at(i)->unitType(); | 159 unitType = fromList->at(i)->unitType(); |
| 160 effectiveFrom = fromList->at(i)->value(lengthContext); | 160 effectiveFrom = fromList->at(i)->value(lengthContext); |
| 161 } | 161 } |
| 162 float effectiveTo = toList->at(i)->value(lengthContext); | 162 float effectiveTo = toList->at(i)->value(lengthContext); |
| 163 float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurati
onList->at(i)->value(lengthContext) : 0; | 163 float effectiveToAtEnd = i < toAtEndOfDurationListSize ? toAtEndOfDurati
onList->at(i)->value(lengthContext) : 0; |
| 164 | 164 |
| 165 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti
veFrom, effectiveTo, effectiveToAtEnd, animatedNumber); | 165 animationElement->animateAdditiveNumber(percentage, repeatCount, effecti
veFrom, effectiveTo, effectiveToAtEnd, animatedNumber); |
| 166 at(i)->setUnitType(unitType); | 166 at(i)->setUnitType(unitType); |
| 167 at(i)->setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION); | 167 at(i)->setValue(animatedNumber, lengthContext, ASSERT_NO_EXCEPTION); |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 float SVGLengthList::calculateDistance(PassRefPtr<SVGPropertyBase> to, SVGElemen
t*) | 171 float SVGLengthList::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> t
o, SVGElement*) |
| 172 { | 172 { |
| 173 // FIXME: Distance calculation is not possible for SVGLengthList right now.
We need the distance for every single value. | 173 // FIXME: Distance calculation is not possible for SVGLengthList right now.
We need the distance for every single value. |
| 174 return -1; | 174 return -1; |
| 175 } | 175 } |
| 176 } | 176 } |
| OLD | NEW |