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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 svgPathSegList->setValueAsString(value, IGNORE_EXCEPTION); | 75 svgPathSegList->setValueAsString(value, IGNORE_EXCEPTION); |
76 return svgPathSegList; | 76 return svgPathSegList; |
77 } | 77 } |
78 | 78 |
79 const SVGPathByteStream* SVGPathSegList::byteStream() const | 79 const SVGPathByteStream* SVGPathSegList::byteStream() const |
80 { | 80 { |
81 if (!m_byteStream) { | 81 if (!m_byteStream) { |
82 m_byteStream = SVGPathByteStream::create(); | 82 m_byteStream = SVGPathByteStream::create(); |
83 | 83 |
84 if (!Base::isEmpty()) { | 84 if (!Base::isEmpty()) { |
85 SVGPathByteStreamBuilder builder; | 85 SVGPathByteStreamBuilder builder(*m_byteStream); |
86 builder.setCurrentByteStream(m_byteStream.get()); | |
87 | |
88 SVGPathSegListSource source(begin(), end()); | 86 SVGPathSegListSource source(begin(), end()); |
89 | 87 SVGPathParser parser(&source, &builder); |
90 SVGPathParser parser; | |
91 parser.setCurrentConsumer(&builder); | |
92 parser.setCurrentSource(&source); | |
93 parser.parsePathDataFromSource(UnalteredParsing); | 88 parser.parsePathDataFromSource(UnalteredParsing); |
94 } | 89 } |
95 } | 90 } |
96 | 91 |
97 return m_byteStream.get(); | 92 return m_byteStream.get(); |
98 } | 93 } |
99 | 94 |
100 void SVGPathSegList::updateListFromByteStream() | 95 void SVGPathSegList::updateListFromByteStream() |
101 { | 96 { |
102 if (m_listSyncedToByteStream) | 97 if (m_listSyncedToByteStream) |
103 return; | 98 return; |
104 | 99 |
105 Base::clear(); | 100 Base::clear(); |
106 | 101 |
107 if (m_byteStream && !m_byteStream->isEmpty()) { | 102 if (m_byteStream && !m_byteStream->isEmpty()) { |
108 SVGPathSegListBuilder builder; | 103 SVGPathSegListBuilder builder(m_contextElement, this); |
109 builder.setCurrentSVGPathElement(m_contextElement); | 104 SVGPathByteStreamSource source(*m_byteStream); |
110 builder.setCurrentSVGPathSegList(this); | 105 SVGPathParser parser(&source, &builder); |
111 | |
112 SVGPathByteStreamSource source(m_byteStream.get()); | |
113 | |
114 SVGPathParser parser; | |
115 parser.setCurrentConsumer(&builder); | |
116 parser.setCurrentSource(&source); | |
117 parser.parsePathDataFromSource(UnalteredParsing); | 106 parser.parsePathDataFromSource(UnalteredParsing); |
118 } | 107 } |
119 | 108 |
120 m_listSyncedToByteStream = true; | 109 m_listSyncedToByteStream = true; |
121 } | 110 } |
122 | 111 |
123 void SVGPathSegList::invalidateList() | 112 void SVGPathSegList::invalidateList() |
124 { | 113 { |
125 m_listSyncedToByteStream = false; | 114 m_listSyncedToByteStream = false; |
126 Base::clear(); | 115 Base::clear(); |
127 } | 116 } |
128 | 117 |
129 PassRefPtrWillBeRawPtr<SVGPathSeg> SVGPathSegList::appendItem(PassRefPtrWillBeRa
wPtr<SVGPathSeg> passItem) | 118 PassRefPtrWillBeRawPtr<SVGPathSeg> SVGPathSegList::appendItem(PassRefPtrWillBeRa
wPtr<SVGPathSeg> passItem) |
130 { | 119 { |
131 updateListFromByteStream(); | 120 updateListFromByteStream(); |
132 RefPtrWillBeRawPtr<SVGPathSeg> item = Base::appendItem(passItem); | 121 RefPtrWillBeRawPtr<SVGPathSeg> item = Base::appendItem(passItem); |
133 | 122 |
134 if (m_byteStream) { | 123 if (m_byteStream) { |
135 SVGPathByteStreamBuilder builder; | 124 SVGPathByteStreamBuilder builder(*m_byteStream); |
136 builder.setCurrentByteStream(m_byteStream.get()); | |
137 | |
138 SVGPathSegListSource source(lastAppended(), end()); | 125 SVGPathSegListSource source(lastAppended(), end()); |
139 | 126 SVGPathParser parser(&source, &builder); |
140 SVGPathParser parser; | |
141 parser.setCurrentConsumer(&builder); | |
142 parser.setCurrentSource(&source); | |
143 parser.parsePathDataFromSource(UnalteredParsing, false); | 127 parser.parsePathDataFromSource(UnalteredParsing, false); |
144 } | 128 } |
145 | 129 |
146 return item.release(); | 130 return item.release(); |
147 } | 131 } |
148 | 132 |
149 String SVGPathSegList::valueAsString() const | 133 String SVGPathSegList::valueAsString() const |
150 { | 134 { |
151 String string; | 135 String string; |
152 buildStringFromByteStream(byteStream(), string, UnalteredParsing); | 136 buildStringFromByteStream(*byteStream(), string, UnalteredParsing); |
153 return string; | 137 return string; |
154 } | 138 } |
155 | 139 |
156 void SVGPathSegList::setValueAsString(const String& string, ExceptionState& exce
ptionState) | 140 void SVGPathSegList::setValueAsString(const String& string, ExceptionState& exce
ptionState) |
157 { | 141 { |
158 invalidateList(); | 142 invalidateList(); |
159 if (!m_byteStream) | 143 if (!m_byteStream) |
160 m_byteStream = SVGPathByteStream::create(); | 144 m_byteStream = SVGPathByteStream::create(); |
161 if (!buildSVGPathByteStreamFromString(string, m_byteStream.get(), UnalteredP
arsing)) | 145 if (!buildSVGPathByteStreamFromString(string, *m_byteStream, UnalteredParsin
g)) |
162 exceptionState.throwDOMException(SyntaxError, "Problem parsing path \""
+ string + "\""); | 146 exceptionState.throwDOMException(SyntaxError, "Problem parsing path \""
+ string + "\""); |
163 } | 147 } |
164 | 148 |
165 void SVGPathSegList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGEleme
nt*) | 149 void SVGPathSegList::add(PassRefPtrWillBeRawPtr<SVGPropertyBase> other, SVGEleme
nt*) |
166 { | 150 { |
167 RefPtrWillBeRawPtr<SVGPathSegList> otherList = toSVGPathSegList(other); | 151 RefPtrWillBeRawPtr<SVGPathSegList> otherList = toSVGPathSegList(other); |
168 if (length() != otherList->length()) | 152 if (length() != otherList->length()) |
169 return; | 153 return; |
170 | 154 |
171 byteStream(); // create |m_byteStream| if not exist. | 155 byteStream(); // create |m_byteStream| if it does not exist. |
172 addToSVGPathByteStream(m_byteStream.get(), otherList->byteStream()); | 156 addToSVGPathByteStream(*m_byteStream, *otherList->byteStream()); |
173 invalidateList(); | 157 invalidateList(); |
174 } | 158 } |
175 | 159 |
176 void SVGPathSegList::calculateAnimatedValue(SVGAnimationElement* animationElemen
t, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBas
e> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeR
awPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) | 160 void SVGPathSegList::calculateAnimatedValue(SVGAnimationElement* animationElemen
t, float percentage, unsigned repeatCount, PassRefPtrWillBeRawPtr<SVGPropertyBas
e> fromValue, PassRefPtrWillBeRawPtr<SVGPropertyBase> toValue, PassRefPtrWillBeR
awPtr<SVGPropertyBase> toAtEndOfDurationValue, SVGElement*) |
177 { | 161 { |
178 invalidateList(); | 162 invalidateList(); |
179 | 163 |
180 ASSERT(animationElement); | 164 ASSERT(animationElement); |
181 bool isToAnimation = animationElement->animationMode() == ToAnimation; | 165 bool isToAnimation = animationElement->animationMode() == ToAnimation; |
182 | 166 |
(...skipping 23 matching lines...) Expand all Loading... |
206 } | 190 } |
207 } else { | 191 } else { |
208 m_byteStream = toStream->copy(); | 192 m_byteStream = toStream->copy(); |
209 return; | 193 return; |
210 } | 194 } |
211 } | 195 } |
212 | 196 |
213 OwnPtr<SVGPathByteStream> lastAnimatedStream = m_byteStream.release(); | 197 OwnPtr<SVGPathByteStream> lastAnimatedStream = m_byteStream.release(); |
214 | 198 |
215 m_byteStream = SVGPathByteStream::create(); | 199 m_byteStream = SVGPathByteStream::create(); |
216 SVGPathByteStreamBuilder builder; | 200 SVGPathByteStreamBuilder builder(*m_byteStream); |
217 builder.setCurrentByteStream(m_byteStream.get()); | |
218 | 201 |
219 SVGPathByteStreamSource fromSource(fromStream); | 202 SVGPathByteStreamSource fromSource(*fromStream); |
220 SVGPathByteStreamSource toSource(toStream); | 203 SVGPathByteStreamSource toSource(*toStream); |
221 | 204 |
222 SVGPathBlender blender; | 205 SVGPathBlender blender(&fromSource, &toSource, &builder); |
223 blender.blendAnimatedPath(percentage, &fromSource, &toSource, &builder); | 206 blender.blendAnimatedPath(percentage); |
224 | 207 |
225 // Handle additive='sum'. | 208 // Handle additive='sum'. |
226 if (!fromStream->size() || (animationElement->isAdditive() && !isToAnimation
)) | 209 if (!fromStream->size() || (animationElement->isAdditive() && !isToAnimation
)) |
227 addToSVGPathByteStream(m_byteStream.get(), lastAnimatedStream.get()); | 210 addToSVGPathByteStream(*m_byteStream, *lastAnimatedStream); |
228 | 211 |
229 // Handle accumulate='sum'. | 212 // Handle accumulate='sum'. |
230 if (animationElement->isAccumulated() && repeatCount) { | 213 if (animationElement->isAccumulated() && repeatCount) { |
231 const SVGPathByteStream* toAtEndOfDurationStream = toAtEndOfDuration->by
teStream(); | 214 const SVGPathByteStream* toAtEndOfDurationStream = toAtEndOfDuration->by
teStream(); |
232 addToSVGPathByteStream(m_byteStream.get(), toAtEndOfDurationStream, repe
atCount); | 215 addToSVGPathByteStream(*m_byteStream, *toAtEndOfDurationStream, repeatCo
unt); |
233 } | 216 } |
234 } | 217 } |
235 | 218 |
236 float SVGPathSegList::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase>
to, SVGElement*) | 219 float SVGPathSegList::calculateDistance(PassRefPtrWillBeRawPtr<SVGPropertyBase>
to, SVGElement*) |
237 { | 220 { |
238 // FIXME: Support paced animations. | 221 // FIXME: Support paced animations. |
239 return -1; | 222 return -1; |
240 } | 223 } |
241 | 224 |
242 } | 225 } |
OLD | NEW |