Chromium Code Reviews| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 { | 56 { |
| 57 } | 57 } |
| 58 | 58 |
| 59 DEFINE_TRACE(SVGPathSegList) | 59 DEFINE_TRACE(SVGPathSegList) |
| 60 { | 60 { |
| 61 SVGListPropertyHelper<SVGPathSegList, SVGPathSeg>::trace(visitor); | 61 SVGListPropertyHelper<SVGPathSegList, SVGPathSeg>::trace(visitor); |
| 62 } | 62 } |
| 63 | 63 |
| 64 PassRefPtrWillBeRawPtr<SVGPathSegList> SVGPathSegList::clone() | 64 PassRefPtrWillBeRawPtr<SVGPathSegList> SVGPathSegList::clone() |
| 65 { | 65 { |
| 66 RefPtrWillBeRawPtr<SVGPathSegList> svgPathSegList = adoptRefWillBeNoop(new S VGPathSegList(m_contextElement, byteStream()->copy())); | 66 RefPtrWillBeRawPtr<SVGPathSegList> svgPathSegList = adoptRefWillBeNoop(new S VGPathSegList(m_contextElement, byteStream().copy())); |
| 67 svgPathSegList->invalidateList(); | 67 svgPathSegList->invalidateList(); |
| 68 return svgPathSegList.release(); | 68 return svgPathSegList.release(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPathSegList::cloneForAnimation(const String& value) const | 71 PassRefPtrWillBeRawPtr<SVGPropertyBase> SVGPathSegList::cloneForAnimation(const String& value) const |
| 72 { | 72 { |
| 73 RefPtrWillBeRawPtr<SVGPathSegList> svgPathSegList = SVGPathSegList::create(m _contextElement); | 73 RefPtrWillBeRawPtr<SVGPathSegList> svgPathSegList = SVGPathSegList::create(m _contextElement); |
| 74 svgPathSegList->setValueAsString(value, IGNORE_EXCEPTION); | 74 svgPathSegList->setValueAsString(value, IGNORE_EXCEPTION); |
| 75 return svgPathSegList; | 75 return svgPathSegList; |
| 76 } | 76 } |
| 77 | 77 |
| 78 const SVGPathByteStream* SVGPathSegList::byteStream() const | 78 const SVGPathByteStream& SVGPathSegList::byteStream() const |
| 79 { | 79 { |
| 80 if (!m_byteStream) { | 80 if (!m_byteStream) { |
| 81 m_byteStream = SVGPathByteStream::create(); | 81 m_byteStream = SVGPathByteStream::create(); |
| 82 | 82 |
| 83 if (!Base::isEmpty()) { | 83 if (!Base::isEmpty()) { |
| 84 SVGPathByteStreamBuilder builder(*m_byteStream); | 84 SVGPathByteStreamBuilder builder(*m_byteStream); |
| 85 SVGPathSegListSource source(begin(), end()); | 85 SVGPathSegListSource source(begin(), end()); |
| 86 SVGPathParser parser(&source, &builder); | 86 SVGPathParser parser(&source, &builder); |
| 87 parser.parsePathDataFromSource(UnalteredParsing); | 87 parser.parsePathDataFromSource(UnalteredParsing); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 | 90 |
| 91 return m_byteStream.get(); | 91 return *m_byteStream.get(); |
| 92 } | |
| 93 | |
| 94 SVGPathByteStream& SVGPathSegList::mutableByteStream() | |
| 95 { | |
| 96 ASSERT(Base::isEmpty()); | |
|
pdr.
2015/10/22 04:53:24
We could invalidate the list here instead of expos
fs
2015/10/22 07:44:32
Yes, this (and invalidateList) will be going away
| |
| 97 if (!m_byteStream) | |
| 98 m_byteStream = SVGPathByteStream::create(); | |
| 99 return *m_byteStream.get(); | |
| 92 } | 100 } |
| 93 | 101 |
| 94 void SVGPathSegList::updateListFromByteStream() | 102 void SVGPathSegList::updateListFromByteStream() |
| 95 { | 103 { |
| 96 if (m_listSyncedToByteStream) | 104 if (m_listSyncedToByteStream) |
| 97 return; | 105 return; |
| 98 | 106 |
| 99 Base::clear(); | 107 Base::clear(); |
| 100 | 108 |
| 101 if (m_byteStream && !m_byteStream->isEmpty()) { | 109 if (m_byteStream && !m_byteStream->isEmpty()) { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 125 SVGPathParser parser(&source, &builder); | 133 SVGPathParser parser(&source, &builder); |
| 126 parser.parsePathDataFromSource(UnalteredParsing, false); | 134 parser.parsePathDataFromSource(UnalteredParsing, false); |
| 127 } | 135 } |
| 128 | 136 |
| 129 return item.release(); | 137 return item.release(); |
| 130 } | 138 } |
| 131 | 139 |
| 132 String SVGPathSegList::valueAsString() const | 140 String SVGPathSegList::valueAsString() const |
| 133 { | 141 { |
| 134 String string; | 142 String string; |
| 135 buildStringFromByteStream(*byteStream(), string, UnalteredParsing); | 143 buildStringFromByteStream(byteStream(), string, UnalteredParsing); |
| 136 return string; | 144 return string; |
| 137 } | 145 } |
| 138 | 146 |
| 139 void SVGPathSegList::setValueAsString(const String& string, ExceptionState& exce ptionState) | 147 void SVGPathSegList::setValueAsString(const String& string, ExceptionState& exce ptionState) |
| 140 { | 148 { |
| 141 invalidateList(); | 149 invalidateList(); |
| 142 if (!m_byteStream) | 150 if (!m_byteStream) |
| 143 m_byteStream = SVGPathByteStream::create(); | 151 m_byteStream = SVGPathByteStream::create(); |
| 144 if (!buildSVGPathByteStreamFromString(string, *m_byteStream, UnalteredParsin g)) | 152 if (!buildSVGPathByteStreamFromString(string, *m_byteStream, UnalteredParsin g)) |
| 145 exceptionState.throwDOMException(SyntaxError, "Problem parsing path \"" + string + "\""); | 153 exceptionState.throwDOMException(SyntaxError, "Problem parsing path \"" + string + "\""); |
| 146 } | 154 } |
| 147 | 155 |
| 148 void SVGPathSegList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGEleme nt*) | 156 void SVGPathSegList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGEleme nt*) |
| 149 { | 157 { |
| 150 RefPtrWillBeRawPtr<SVGPathSegList> otherList = toSVGPathSegList(other); | 158 RefPtrWillBeRawPtr<SVGPathSegList> otherList = toSVGPathSegList(other); |
| 151 if (length() != otherList->length()) | 159 if (length() != otherList->length()) |
| 152 return; | 160 return; |
| 153 | 161 |
| 154 byteStream(); // create |m_byteStream| if it does not exist. | 162 byteStream(); // create |m_byteStream| if it does not exist. |
| 155 addToSVGPathByteStream(*m_byteStream, *otherList->byteStream()); | 163 addToSVGPathByteStream(*m_byteStream, otherList->byteStream()); |
| 156 invalidateList(); | 164 invalidateList(); |
| 157 } | 165 } |
| 158 | 166 |
| 159 void SVGPathSegList::calculateAnimatedValue(SVGAnimationElement* animationElemen t, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBas e> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeR awPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) | 167 void SVGPathSegList::calculateAnimatedValue(SVGAnimationElement* animationElemen t, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBas e> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeR awPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) |
| 160 { | 168 { |
| 161 invalidateList(); | 169 invalidateList(); |
| 162 | 170 |
| 163 ASSERT(animationElement); | 171 ASSERT(animationElement); |
| 164 bool isToAnimation = animationElement->animationMode() == ToAnimation; | 172 bool isToAnimation = animationElement->animationMode() == ToAnimation; |
| 165 | 173 |
| 166 const RefPtrWillBeRawPtr<SVGPathSegList> from = toSVGPathSegList(fromValue); | 174 const RefPtrWillBeRawPtr<SVGPathSegList> from = toSVGPathSegList(fromValue); |
| 167 const RefPtrWillBeRawPtr<SVGPathSegList> to = toSVGPathSegList(toValue); | 175 const RefPtrWillBeRawPtr<SVGPathSegList> to = toSVGPathSegList(toValue); |
| 168 const RefPtrWillBeRawPtr<SVGPathSegList> toAtEndOfDuration = toSVGPathSegLis t(toAtEndOfDurationValue); | 176 const RefPtrWillBeRawPtr<SVGPathSegList> toAtEndOfDuration = toSVGPathSegLis t(toAtEndOfDurationValue); |
| 169 | 177 |
| 170 const SVGPathByteStream* toStream = to->byteStream(); | 178 const SVGPathByteStream& toStream = to->byteStream(); |
| 171 const SVGPathByteStream* fromStream = from->byteStream(); | 179 const SVGPathByteStream* fromStream = &from->byteStream(); |
| 172 OwnPtr<SVGPathByteStream> copy; | 180 OwnPtr<SVGPathByteStream> copy; |
| 173 | 181 |
| 174 // If no 'to' value is given, nothing to animate. | 182 // If no 'to' value is given, nothing to animate. |
| 175 if (!toStream->size()) | 183 if (!toStream.size()) |
| 176 return; | 184 return; |
| 177 | 185 |
| 178 if (isToAnimation) { | 186 if (isToAnimation) { |
| 179 copy = byteStream()->copy(); | 187 copy = byteStream().copy(); |
| 180 fromStream = copy.get(); | 188 fromStream = copy.get(); |
| 181 } | 189 } |
| 182 | 190 |
| 183 // If the 'from' value is given and it's length doesn't match the 'to' value list length, fallback to a discrete animation. | 191 // If the 'from' value is given and it's length doesn't match the 'to' value list length, fallback to a discrete animation. |
| 184 if (fromStream->size() != toStream->size() && fromStream->size()) { | 192 if (fromStream->size() != toStream.size() && fromStream->size()) { |
| 185 if (percentage < 0.5) { | 193 if (percentage < 0.5) { |
| 186 if (!isToAnimation) { | 194 if (!isToAnimation) { |
| 187 m_byteStream = fromStream->copy(); | 195 m_byteStream = fromStream->copy(); |
| 188 return; | 196 return; |
| 189 } | 197 } |
| 190 } else { | 198 } else { |
| 191 m_byteStream = toStream->copy(); | 199 m_byteStream = toStream.copy(); |
| 192 return; | 200 return; |
| 193 } | 201 } |
| 194 } | 202 } |
| 195 | 203 |
| 196 OwnPtr<SVGPathByteStream> lastAnimatedStream = m_byteStream.release(); | 204 OwnPtr<SVGPathByteStream> lastAnimatedStream = m_byteStream.release(); |
| 197 | 205 |
| 198 m_byteStream = SVGPathByteStream::create(); | 206 m_byteStream = SVGPathByteStream::create(); |
| 199 SVGPathByteStreamBuilder builder(*m_byteStream); | 207 SVGPathByteStreamBuilder builder(*m_byteStream); |
| 200 | 208 |
| 201 SVGPathByteStreamSource fromSource(*fromStream); | 209 SVGPathByteStreamSource fromSource(*fromStream); |
| 202 SVGPathByteStreamSource toSource(*toStream); | 210 SVGPathByteStreamSource toSource(toStream); |
| 203 | 211 |
| 204 SVGPathBlender blender(&fromSource, &toSource, &builder); | 212 SVGPathBlender blender(&fromSource, &toSource, &builder); |
| 205 blender.blendAnimatedPath(percentage); | 213 blender.blendAnimatedPath(percentage); |
| 206 | 214 |
| 207 // Handle additive='sum'. | 215 // Handle additive='sum'. |
| 208 if (!fromStream->size() || (animationElement->isAdditive() && !isToAnimation )) | 216 if (!fromStream->size() || (animationElement->isAdditive() && !isToAnimation )) |
| 209 addToSVGPathByteStream(*m_byteStream, *lastAnimatedStream); | 217 addToSVGPathByteStream(*m_byteStream, *lastAnimatedStream); |
| 210 | 218 |
| 211 // Handle accumulate='sum'. | 219 // Handle accumulate='sum'. |
| 212 if (animationElement->isAccumulated() && repeatCount) { | 220 if (animationElement->isAccumulated() && repeatCount) |
| 213 const SVGPathByteStream* toAtEndOfDurationStream = toAtEndOfDuration->by teStream(); | 221 addToSVGPathByteStream(*m_byteStream, toAtEndOfDuration->byteStream(), r epeatCount); |
| 214 addToSVGPathByteStream(*m_byteStream, *toAtEndOfDurationStream, repeatCo unt); | |
| 215 } | |
| 216 } | 222 } |
| 217 | 223 |
| 218 float SVGPathSegList::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVGElement*) | 224 float SVGPathSegList::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase> to, SVGElement*) |
| 219 { | 225 { |
| 220 // FIXME: Support paced animations. | 226 // FIXME: Support paced animations. |
| 221 return -1; | 227 return -1; |
| 222 } | 228 } |
| 223 | 229 |
| 224 } | 230 } |
| OLD | NEW |