| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde
.org> |
| 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
| 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
| 6 * | 6 * |
| 7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 65 } |
| 66 | 66 |
| 67 } // namespace | 67 } // namespace |
| 68 | 68 |
| 69 SVGPath::SVGPath() | 69 SVGPath::SVGPath() |
| 70 : SVGPropertyBase(classType()) | 70 : SVGPropertyBase(classType()) |
| 71 , m_pathValue(CSSPathValue::emptyPathValue()) | 71 , m_pathValue(CSSPathValue::emptyPathValue()) |
| 72 { | 72 { |
| 73 } | 73 } |
| 74 | 74 |
| 75 SVGPath::SVGPath(PassRefPtrWillBeRawPtr<CSSPathValue> pathValue) | 75 SVGPath::SVGPath(RawPtr<CSSPathValue> pathValue) |
| 76 : SVGPropertyBase(classType()) | 76 : SVGPropertyBase(classType()) |
| 77 , m_pathValue(pathValue) | 77 , m_pathValue(pathValue) |
| 78 { | 78 { |
| 79 } | 79 } |
| 80 | 80 |
| 81 SVGPath::~SVGPath() | 81 SVGPath::~SVGPath() |
| 82 { | 82 { |
| 83 } | 83 } |
| 84 | 84 |
| 85 String SVGPath::valueAsString() const | 85 String SVGPath::valueAsString() const |
| 86 { | 86 { |
| 87 return m_pathValue->pathString(); | 87 return m_pathValue->pathString(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 | 90 |
| 91 PassRefPtrWillBeRawPtr<SVGPath> SVGPath::clone() const | 91 RawPtr<SVGPath> SVGPath::clone() const |
| 92 { | 92 { |
| 93 return SVGPath::create(m_pathValue); | 93 return SVGPath::create(m_pathValue); |
| 94 } | 94 } |
| 95 | 95 |
| 96 SVGParsingError SVGPath::setValueAsString(const String& string) | 96 SVGParsingError SVGPath::setValueAsString(const String& string) |
| 97 { | 97 { |
| 98 RefPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); | 98 RefPtr<SVGPathByteStream> byteStream = SVGPathByteStream::create(); |
| 99 SVGParsingError parseStatus = buildByteStreamFromString(string, *byteStream)
; | 99 SVGParsingError parseStatus = buildByteStreamFromString(string, *byteStream)
; |
| 100 m_pathValue = CSSPathValue::create(byteStream.release()); | 100 m_pathValue = CSSPathValue::create(byteStream.release()); |
| 101 return parseStatus; | 101 return parseStatus; |
| 102 } | 102 } |
| 103 | 103 |
| 104 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPath::cloneForAnimation(const String&
value) const | 104 RawPtr<SVGPropertyBase> SVGPath::cloneForAnimation(const String& value) const |
| 105 { | 105 { |
| 106 return SVGPath::create(CSSPathValue::create(value)); | 106 return SVGPath::create(CSSPathValue::create(value)); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void SVGPath::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGElement*) | 109 void SVGPath::add(RawPtr<SVGPropertyBase> other, SVGElement*) |
| 110 { | 110 { |
| 111 const SVGPathByteStream& otherPathByteStream = toSVGPath(other)->byteStream(
); | 111 const SVGPathByteStream& otherPathByteStream = toSVGPath(other)->byteStream(
); |
| 112 if (byteStream().size() != otherPathByteStream.size() | 112 if (byteStream().size() != otherPathByteStream.size() |
| 113 || byteStream().isEmpty() | 113 || byteStream().isEmpty() |
| 114 || otherPathByteStream.isEmpty()) | 114 || otherPathByteStream.isEmpty()) |
| 115 return; | 115 return; |
| 116 | 116 |
| 117 m_pathValue = CSSPathValue::create(addPathByteStreams(byteStream(), otherPat
hByteStream)); | 117 m_pathValue = CSSPathValue::create(addPathByteStreams(byteStream(), otherPat
hByteStream)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 void SVGPath::calculateAnimatedValue(SVGAnimationElement* animationElement, floa
t percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBase> from
Value, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeRawPtr<S
VGPropertyBase> toAtEndOfDurationValue, SVGElement*) | 120 void SVGPath::calculateAnimatedValue(SVGAnimationElement* animationElement, floa
t percentage, unsigned repeatCount, RawPtr<SVGPropertyBase> fromValue, RawPtr<SV
GPropertyBase> toValue, RawPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGEleme
nt*) |
| 121 { | 121 { |
| 122 ASSERT(animationElement); | 122 ASSERT(animationElement); |
| 123 bool isToAnimation = animationElement->animationMode() == ToAnimation; | 123 bool isToAnimation = animationElement->animationMode() == ToAnimation; |
| 124 | 124 |
| 125 const RefPtrWillBeRawPtr<SVGPath> to = toSVGPath(toValue); | 125 const RawPtr<SVGPath> to = toSVGPath(toValue); |
| 126 const SVGPathByteStream& toStream = to->byteStream(); | 126 const SVGPathByteStream& toStream = to->byteStream(); |
| 127 | 127 |
| 128 // If no 'to' value is given, nothing to animate. | 128 // If no 'to' value is given, nothing to animate. |
| 129 if (!toStream.size()) | 129 if (!toStream.size()) |
| 130 return; | 130 return; |
| 131 | 131 |
| 132 const RefPtrWillBeRawPtr<SVGPath> from = toSVGPath(fromValue); | 132 const RawPtr<SVGPath> from = toSVGPath(fromValue); |
| 133 const SVGPathByteStream* fromStream = &from->byteStream(); | 133 const SVGPathByteStream* fromStream = &from->byteStream(); |
| 134 | 134 |
| 135 RefPtr<SVGPathByteStream> copy; | 135 RefPtr<SVGPathByteStream> copy; |
| 136 if (isToAnimation) { | 136 if (isToAnimation) { |
| 137 copy = byteStream().clone(); | 137 copy = byteStream().clone(); |
| 138 fromStream = copy.get(); | 138 fromStream = copy.get(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 // If the 'from' value is given and it's length doesn't match the 'to' value
list length, fallback to a discrete animation. | 141 // If the 'from' value is given and it's length doesn't match the 'to' value
list length, fallback to a discrete animation. |
| 142 if (fromStream->size() != toStream.size() && fromStream->size()) { | 142 if (fromStream->size() != toStream.size() && fromStream->size()) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 157 if (animationElement->isAdditive() && !isToAnimation) | 157 if (animationElement->isAdditive() && !isToAnimation) |
| 158 newStream = conditionallyAddPathByteStreams(newStream.release(), byteStr
eam()); | 158 newStream = conditionallyAddPathByteStreams(newStream.release(), byteStr
eam()); |
| 159 | 159 |
| 160 // Handle accumulate='sum'. | 160 // Handle accumulate='sum'. |
| 161 if (animationElement->isAccumulated() && repeatCount) | 161 if (animationElement->isAccumulated() && repeatCount) |
| 162 newStream = conditionallyAddPathByteStreams(newStream.release(), toSVGPa
th(toAtEndOfDurationValue)->byteStream(), repeatCount); | 162 newStream = conditionallyAddPathByteStreams(newStream.release(), toSVGPa
th(toAtEndOfDurationValue)->byteStream(), repeatCount); |
| 163 | 163 |
| 164 m_pathValue = CSSPathValue::create(newStream.release()); | 164 m_pathValue = CSSPathValue::create(newStream.release()); |
| 165 } | 165 } |
| 166 | 166 |
| 167 float SVGPath::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVG
Element*) | 167 float SVGPath::calculateDistance(RawPtr<SVGPropertyBase> to, SVGElement*) |
| 168 { | 168 { |
| 169 // FIXME: Support paced animations. | 169 // FIXME: Support paced animations. |
| 170 return -1; | 170 return -1; |
| 171 } | 171 } |
| 172 | 172 |
| 173 DEFINE_TRACE(SVGPath) | 173 DEFINE_TRACE(SVGPath) |
| 174 { | 174 { |
| 175 visitor->trace(m_pathValue); | 175 visitor->trace(m_pathValue); |
| 176 SVGPropertyBase::trace(visitor); | 176 SVGPropertyBase::trace(visitor); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace blink | 179 } // namespace blink |
| OLD | NEW |