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 | |
24 #include "core/svg/SVGAnimateMotionElement.h" | 23 #include "core/svg/SVGAnimateMotionElement.h" |
25 | 24 |
26 #include "core/SVGNames.h" | 25 #include "core/SVGNames.h" |
27 #include "core/dom/ElementTraversal.h" | 26 #include "core/dom/ElementTraversal.h" |
28 #include "core/rendering/RenderObject.h" | 27 #include "core/rendering/RenderObject.h" |
29 #include "core/rendering/svg/RenderSVGResource.h" | |
30 #include "core/rendering/svg/SVGPathData.h" | 28 #include "core/rendering/svg/SVGPathData.h" |
31 #include "core/svg/SVGMPathElement.h" | 29 #include "core/svg/SVGMPathElement.h" |
32 #include "core/svg/SVGParserUtilities.h" | 30 #include "core/svg/SVGParserUtilities.h" |
33 #include "core/svg/SVGPathElement.h" | 31 #include "core/svg/SVGPathElement.h" |
34 #include "core/svg/SVGPathUtilities.h" | 32 #include "core/svg/SVGPathUtilities.h" |
35 #include "platform/transforms/AffineTransform.h" | 33 #include "platform/transforms/AffineTransform.h" |
36 #include "wtf/MathExtras.h" | 34 #include "wtf/MathExtras.h" |
37 #include "wtf/StdLibExtras.h" | 35 #include "wtf/StdLibExtras.h" |
38 | 36 |
39 namespace blink { | 37 namespace blink { |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 return; | 180 return; |
183 | 181 |
184 AffineTransform* transform = targetElement->animateMotionTransform(); | 182 AffineTransform* transform = targetElement->animateMotionTransform(); |
185 if (!transform) | 183 if (!transform) |
186 return; | 184 return; |
187 | 185 |
188 transform->makeIdentity(); | 186 transform->makeIdentity(); |
189 | 187 |
190 if (RenderObject* targetRenderer = targetElement->renderer()) { | 188 if (RenderObject* targetRenderer = targetElement->renderer()) { |
191 targetRenderer->setNeedsTransformUpdate(); | 189 targetRenderer->setNeedsTransformUpdate(); |
192 RenderSVGResource::markForLayoutAndParentResourceInvalidation(targetRend
erer); | 190 markForLayoutAndParentResourceInvalidation(targetRenderer); |
193 } | 191 } |
194 } | 192 } |
195 | 193 |
196 bool SVGAnimateMotionElement::calculateToAtEndOfDurationValue(const String& toAt
EndOfDurationString) | 194 bool SVGAnimateMotionElement::calculateToAtEndOfDurationValue(const String& toAt
EndOfDurationString) |
197 { | 195 { |
198 parsePoint(toAtEndOfDurationString, m_toPointAtEndOfDuration); | 196 parsePoint(toAtEndOfDurationString, m_toPointAtEndOfDuration); |
199 m_hasToPointAtEndOfDuration = true; | 197 m_hasToPointAtEndOfDuration = true; |
200 return true; | 198 return true; |
201 } | 199 } |
202 | 200 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 } | 274 } |
277 | 275 |
278 void SVGAnimateMotionElement::applyResultsToTarget() | 276 void SVGAnimateMotionElement::applyResultsToTarget() |
279 { | 277 { |
280 // 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. |
281 SVGElement* targetElement = this->targetElement(); | 279 SVGElement* targetElement = this->targetElement(); |
282 if (!targetElement) | 280 if (!targetElement) |
283 return; | 281 return; |
284 | 282 |
285 if (RenderObject* renderer = targetElement->renderer()) | 283 if (RenderObject* renderer = targetElement->renderer()) |
286 RenderSVGResource::markForLayoutAndParentResourceInvalidation(renderer); | 284 markForLayoutAndParentResourceInvalidation(renderer); |
287 | 285 |
288 AffineTransform* t = targetElement->animateMotionTransform(); | 286 AffineTransform* t = targetElement->animateMotionTransform(); |
289 if (!t) | 287 if (!t) |
290 return; | 288 return; |
291 | 289 |
292 // ...except in case where we have additional instances in <use> trees. | 290 // ...except in case where we have additional instances in <use> trees. |
293 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& instances = ta
rgetElement->instancesForElement(); | 291 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >& instances = ta
rgetElement->instancesForElement(); |
294 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator
end = instances.end(); | 292 const WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator
end = instances.end(); |
295 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator
it = instances.begin(); it != end; ++it) { | 293 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<SVGElement> >::const_iterator
it = instances.begin(); it != end; ++it) { |
296 SVGElement* shadowTreeElement = *it; | 294 SVGElement* shadowTreeElement = *it; |
297 ASSERT(shadowTreeElement); | 295 ASSERT(shadowTreeElement); |
298 AffineTransform* transform = shadowTreeElement->animateMotionTransform()
; | 296 AffineTransform* transform = shadowTreeElement->animateMotionTransform()
; |
299 if (!transform) | 297 if (!transform) |
300 continue; | 298 continue; |
301 transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f()); | 299 transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f()); |
302 if (RenderObject* renderer = shadowTreeElement->renderer()) { | 300 if (RenderObject* renderer = shadowTreeElement->renderer()) { |
303 renderer->setNeedsTransformUpdate(); | 301 renderer->setNeedsTransformUpdate(); |
304 RenderSVGResource::markForLayoutAndParentResourceInvalidation(render
er); | 302 markForLayoutAndParentResourceInvalidation(renderer); |
305 } | 303 } |
306 } | 304 } |
307 } | 305 } |
308 | 306 |
309 float SVGAnimateMotionElement::calculateDistance(const String& fromString, const
String& toString) | 307 float SVGAnimateMotionElement::calculateDistance(const String& fromString, const
String& toString) |
310 { | 308 { |
311 FloatPoint from; | 309 FloatPoint from; |
312 FloatPoint to; | 310 FloatPoint to; |
313 if (!parsePoint(fromString, from)) | 311 if (!parsePoint(fromString, from)) |
314 return -1; | 312 return -1; |
315 if (!parsePoint(toString, to)) | 313 if (!parsePoint(toString, to)) |
316 return -1; | 314 return -1; |
317 FloatSize diff = to - from; | 315 FloatSize diff = to - from; |
318 return sqrtf(diff.width() * diff.width() + diff.height() * diff.height()); | 316 return sqrtf(diff.width() * diff.width() + diff.height() * diff.height()); |
319 } | 317 } |
320 | 318 |
321 void SVGAnimateMotionElement::updateAnimationMode() | 319 void SVGAnimateMotionElement::updateAnimationMode() |
322 { | 320 { |
323 if (!m_animationPath.isEmpty()) | 321 if (!m_animationPath.isEmpty()) |
324 setAnimationMode(PathAnimation); | 322 setAnimationMode(PathAnimation); |
325 else | 323 else |
326 SVGAnimationElement::updateAnimationMode(); | 324 SVGAnimationElement::updateAnimationMode(); |
327 } | 325 } |
328 | 326 |
329 } | 327 } |
OLD | NEW |