OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> | 2 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> |
3 * Copyright (C) 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2007 Rob Buis <buis@kde.org> |
4 * Copyright (C) 2008 Apple Inc. All rights reserved. | 4 * Copyright (C) 2008 Apple Inc. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
20 */ | 20 */ |
21 | 21 |
22 #include "config.h" | 22 #include "config.h" |
23 #include "core/svg/SVGAnimateMotionElement.h" | 23 #include "core/svg/SVGAnimateMotionElement.h" |
24 | 24 |
25 #include "core/SVGNames.h" | 25 #include "core/SVGNames.h" |
26 #include "core/dom/ElementTraversal.h" | 26 #include "core/dom/ElementTraversal.h" |
27 #include "core/rendering/RenderObject.h" | 27 #include "core/layout/LayoutObject.h" |
28 #include "core/rendering/svg/SVGPathData.h" | 28 #include "core/rendering/svg/SVGPathData.h" |
29 #include "core/svg/SVGMPathElement.h" | 29 #include "core/svg/SVGMPathElement.h" |
30 #include "core/svg/SVGParserUtilities.h" | 30 #include "core/svg/SVGParserUtilities.h" |
31 #include "core/svg/SVGPathElement.h" | 31 #include "core/svg/SVGPathElement.h" |
32 #include "core/svg/SVGPathUtilities.h" | 32 #include "core/svg/SVGPathUtilities.h" |
33 #include "platform/transforms/AffineTransform.h" | 33 #include "platform/transforms/AffineTransform.h" |
34 #include "wtf/MathExtras.h" | 34 #include "wtf/MathExtras.h" |
35 #include "wtf/StdLibExtras.h" | 35 #include "wtf/StdLibExtras.h" |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 { | 178 { |
179 if (!targetElement) | 179 if (!targetElement) |
180 return; | 180 return; |
181 | 181 |
182 AffineTransform* transform = targetElement->animateMotionTransform(); | 182 AffineTransform* transform = targetElement->animateMotionTransform(); |
183 if (!transform) | 183 if (!transform) |
184 return; | 184 return; |
185 | 185 |
186 transform->makeIdentity(); | 186 transform->makeIdentity(); |
187 | 187 |
188 if (RenderObject* targetRenderer = targetElement->renderer()) { | 188 if (LayoutObject* targetRenderer = targetElement->renderer()) { |
189 targetRenderer->setNeedsTransformUpdate(); | 189 targetRenderer->setNeedsTransformUpdate(); |
190 markForLayoutAndParentResourceInvalidation(targetRenderer); | 190 markForLayoutAndParentResourceInvalidation(targetRenderer); |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
194 bool SVGAnimateMotionElement::calculateToAtEndOfDurationValue(const String& toAt
EndOfDurationString) | 194 bool SVGAnimateMotionElement::calculateToAtEndOfDurationValue(const String& toAt
EndOfDurationString) |
195 { | 195 { |
196 parsePoint(toAtEndOfDurationString, m_toPointAtEndOfDuration); | 196 parsePoint(toAtEndOfDurationString, m_toPointAtEndOfDuration); |
197 m_hasToPointAtEndOfDuration = true; | 197 m_hasToPointAtEndOfDuration = true; |
198 return true; | 198 return true; |
(...skipping 21 matching lines...) Expand all Loading... |
220 | 220 |
221 void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned
repeatCount, SVGSMILElement*) | 221 void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, unsigned
repeatCount, SVGSMILElement*) |
222 { | 222 { |
223 SVGElement* targetElement = this->targetElement(); | 223 SVGElement* targetElement = this->targetElement(); |
224 if (!targetElement) | 224 if (!targetElement) |
225 return; | 225 return; |
226 AffineTransform* transform = targetElement->animateMotionTransform(); | 226 AffineTransform* transform = targetElement->animateMotionTransform(); |
227 if (!transform) | 227 if (!transform) |
228 return; | 228 return; |
229 | 229 |
230 if (RenderObject* targetRenderer = targetElement->renderer()) | 230 if (LayoutObject* targetRenderer = targetElement->renderer()) |
231 targetRenderer->setNeedsTransformUpdate(); | 231 targetRenderer->setNeedsTransformUpdate(); |
232 | 232 |
233 if (!isAdditive()) | 233 if (!isAdditive()) |
234 transform->makeIdentity(); | 234 transform->makeIdentity(); |
235 | 235 |
236 if (animationMode() != PathAnimation) { | 236 if (animationMode() != PathAnimation) { |
237 FloatPoint toPointAtEndOfDuration = m_toPoint; | 237 FloatPoint toPointAtEndOfDuration = m_toPoint; |
238 if (isAccumulated() && repeatCount && m_hasToPointAtEndOfDuration) | 238 if (isAccumulated() && repeatCount && m_hasToPointAtEndOfDuration) |
239 toPointAtEndOfDuration = m_toPointAtEndOfDuration; | 239 toPointAtEndOfDuration = m_toPointAtEndOfDuration; |
240 | 240 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 transform->rotate(angle); | 273 transform->rotate(angle); |
274 } | 274 } |
275 | 275 |
276 void SVGAnimateMotionElement::applyResultsToTarget() | 276 void SVGAnimateMotionElement::applyResultsToTarget() |
277 { | 277 { |
278 // We accumulate to the target element transform list so there is not much t
o do here. | 278 // We accumulate to the target element transform list so there is not much t
o do here. |
279 SVGElement* targetElement = this->targetElement(); | 279 SVGElement* targetElement = this->targetElement(); |
280 if (!targetElement) | 280 if (!targetElement) |
281 return; | 281 return; |
282 | 282 |
283 if (RenderObject* renderer = targetElement->renderer()) | 283 if (LayoutObject* renderer = targetElement->renderer()) |
284 markForLayoutAndParentResourceInvalidation(renderer); | 284 markForLayoutAndParentResourceInvalidation(renderer); |
285 | 285 |
286 AffineTransform* t = targetElement->animateMotionTransform(); | 286 AffineTransform* t = targetElement->animateMotionTransform(); |
287 if (!t) | 287 if (!t) |
288 return; | 288 return; |
289 | 289 |
290 // ...except in case where we have additional instances in <use> trees. | 290 // ...except in case where we have additional instances in <use> trees. |
291 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& instances = ta
rgetElement->instancesForElement(); | 291 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& instances = ta
rgetElement->instancesForElement(); |
292 for (SVGElement* shadowTreeElement : instances) { | 292 for (SVGElement* shadowTreeElement : instances) { |
293 ASSERT(shadowTreeElement); | 293 ASSERT(shadowTreeElement); |
294 AffineTransform* transform = shadowTreeElement->animateMotionTransform()
; | 294 AffineTransform* transform = shadowTreeElement->animateMotionTransform()
; |
295 if (!transform) | 295 if (!transform) |
296 continue; | 296 continue; |
297 transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f()); | 297 transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f()); |
298 if (RenderObject* renderer = shadowTreeElement->renderer()) { | 298 if (LayoutObject* renderer = shadowTreeElement->renderer()) { |
299 renderer->setNeedsTransformUpdate(); | 299 renderer->setNeedsTransformUpdate(); |
300 markForLayoutAndParentResourceInvalidation(renderer); | 300 markForLayoutAndParentResourceInvalidation(renderer); |
301 } | 301 } |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 float SVGAnimateMotionElement::calculateDistance(const String& fromString, const
String& toString) | 305 float SVGAnimateMotionElement::calculateDistance(const String& fromString, const
String& toString) |
306 { | 306 { |
307 FloatPoint from; | 307 FloatPoint from; |
308 FloatPoint to; | 308 FloatPoint to; |
309 if (!parsePoint(fromString, from)) | 309 if (!parsePoint(fromString, from)) |
310 return -1; | 310 return -1; |
311 if (!parsePoint(toString, to)) | 311 if (!parsePoint(toString, to)) |
312 return -1; | 312 return -1; |
313 FloatSize diff = to - from; | 313 FloatSize diff = to - from; |
314 return sqrtf(diff.width() * diff.width() + diff.height() * diff.height()); | 314 return sqrtf(diff.width() * diff.width() + diff.height() * diff.height()); |
315 } | 315 } |
316 | 316 |
317 void SVGAnimateMotionElement::updateAnimationMode() | 317 void SVGAnimateMotionElement::updateAnimationMode() |
318 { | 318 { |
319 if (!m_animationPath.isEmpty()) | 319 if (!m_animationPath.isEmpty()) |
320 setAnimationMode(PathAnimation); | 320 setAnimationMode(PathAnimation); |
321 else | 321 else |
322 SVGAnimationElement::updateAnimationMode(); | 322 SVGAnimationElement::updateAnimationMode(); |
323 } | 323 } |
324 | 324 |
325 } | 325 } |
OLD | NEW |