Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: third_party/WebKit/Source/core/svg/SVGAnimateMotionElement.cpp

Issue 2386013002: Hoist target element null-checks out of SVGAnimateElement::calculate* (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 *
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 DEFINE_NODE_FACTORY(SVGAnimateMotionElement) 45 DEFINE_NODE_FACTORY(SVGAnimateMotionElement)
46 46
47 SVGAnimateMotionElement::~SVGAnimateMotionElement() {} 47 SVGAnimateMotionElement::~SVGAnimateMotionElement() {}
48 48
49 bool SVGAnimateMotionElement::hasValidAttributeType() { 49 bool SVGAnimateMotionElement::hasValidAttributeType() {
50 SVGElement* targetElement = this->targetElement(); 50 SVGElement* targetElement = this->targetElement();
51 if (!targetElement) 51 if (!targetElement)
52 return false; 52 return false;
53 53
54 // We don't have a special attribute name to verify the animation type. Check the element name instead. 54 // We don't have a special attribute name to verify the animation type. Check
55 // the element name instead.
55 if (!targetElement->isSVGGraphicsElement()) 56 if (!targetElement->isSVGGraphicsElement())
56 return false; 57 return false;
57 // Spec: SVG 1.1 section 19.2.15 58 // Spec: SVG 1.1 section 19.2.15
58 // FIXME: svgTag is missing. Needs to be checked, if transforming <svg> could cause problems. 59 // FIXME: svgTag is missing. Needs to be checked, if transforming <svg> could
60 // cause problems.
59 return ( 61 return (
60 isSVGGElement(*targetElement) || isSVGDefsElement(*targetElement) || 62 isSVGGElement(*targetElement) || isSVGDefsElement(*targetElement) ||
61 isSVGUseElement(*targetElement) || isSVGImageElement(*targetElement) || 63 isSVGUseElement(*targetElement) || isSVGImageElement(*targetElement) ||
62 isSVGSwitchElement(*targetElement) || isSVGPathElement(*targetElement) || 64 isSVGSwitchElement(*targetElement) || isSVGPathElement(*targetElement) ||
63 isSVGRectElement(*targetElement) || isSVGCircleElement(*targetElement) || 65 isSVGRectElement(*targetElement) || isSVGCircleElement(*targetElement) ||
64 isSVGEllipseElement(*targetElement) || isSVGLineElement(*targetElement) || 66 isSVGEllipseElement(*targetElement) || isSVGLineElement(*targetElement) ||
65 isSVGPolylineElement(*targetElement) || 67 isSVGPolylineElement(*targetElement) ||
66 isSVGPolygonElement(*targetElement) || isSVGTextElement(*targetElement) || 68 isSVGPolygonElement(*targetElement) || isSVGTextElement(*targetElement) ||
67 isSVGClipPathElement(*targetElement) || 69 isSVGClipPathElement(*targetElement) ||
68 isSVGMaskElement(*targetElement) || isSVGAElement(*targetElement) || 70 isSVGMaskElement(*targetElement) || isSVGAElement(*targetElement) ||
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 parsePoint(byString, byPoint); 202 parsePoint(byString, byPoint);
201 m_toPoint = 203 m_toPoint =
202 FloatPoint(m_fromPoint.x() + byPoint.x(), m_fromPoint.y() + byPoint.y()); 204 FloatPoint(m_fromPoint.x() + byPoint.x(), m_fromPoint.y() + byPoint.y());
203 return true; 205 return true;
204 } 206 }
205 207
206 void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, 208 void SVGAnimateMotionElement::calculateAnimatedValue(float percentage,
207 unsigned repeatCount, 209 unsigned repeatCount,
208 SVGSMILElement*) { 210 SVGSMILElement*) {
209 SVGElement* targetElement = this->targetElement(); 211 SVGElement* targetElement = this->targetElement();
210 if (!targetElement) 212 DCHECK(targetElement);
211 return;
212 AffineTransform* transform = targetElement->animateMotionTransform(); 213 AffineTransform* transform = targetElement->animateMotionTransform();
213 if (!transform) 214 if (!transform)
214 return; 215 return;
215 216
216 if (LayoutObject* targetLayoutObject = targetElement->layoutObject()) 217 if (LayoutObject* targetLayoutObject = targetElement->layoutObject())
217 targetLayoutObject->setNeedsTransformUpdate(); 218 targetLayoutObject->setNeedsTransformUpdate();
218 219
219 if (!isAdditive()) 220 if (!isAdditive())
220 transform->makeIdentity(); 221 transform->makeIdentity();
221 222
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 transform->translate(position.x(), position.y()); 255 transform->translate(position.x(), position.y());
255 RotateMode rotateMode = this->getRotateMode(); 256 RotateMode rotateMode = this->getRotateMode();
256 if (rotateMode != RotateAuto && rotateMode != RotateAutoReverse) 257 if (rotateMode != RotateAuto && rotateMode != RotateAutoReverse)
257 return; 258 return;
258 if (rotateMode == RotateAutoReverse) 259 if (rotateMode == RotateAutoReverse)
259 angle += 180; 260 angle += 180;
260 transform->rotate(angle); 261 transform->rotate(angle);
261 } 262 }
262 263
263 void SVGAnimateMotionElement::applyResultsToTarget() { 264 void SVGAnimateMotionElement::applyResultsToTarget() {
264 // We accumulate to the target element transform list so there is not much to do here. 265 // We accumulate to the target element transform list so there is not much to
266 // do here.
265 SVGElement* targetElement = this->targetElement(); 267 SVGElement* targetElement = this->targetElement();
266 if (!targetElement) 268 if (!targetElement)
267 return; 269 return;
268 270
269 if (LayoutObject* layoutObject = targetElement->layoutObject()) 271 if (LayoutObject* layoutObject = targetElement->layoutObject())
270 markForLayoutAndParentResourceInvalidation(layoutObject); 272 markForLayoutAndParentResourceInvalidation(layoutObject);
271 273
272 AffineTransform* t = targetElement->animateMotionTransform(); 274 AffineTransform* t = targetElement->animateMotionTransform();
273 if (!t) 275 if (!t)
274 return; 276 return;
(...skipping 27 matching lines...) Expand all
302 } 304 }
303 305
304 void SVGAnimateMotionElement::updateAnimationMode() { 306 void SVGAnimateMotionElement::updateAnimationMode() {
305 if (!m_animationPath.isEmpty()) 307 if (!m_animationPath.isEmpty())
306 setAnimationMode(PathAnimation); 308 setAnimationMode(PathAnimation);
307 else 309 else
308 SVGAnimationElement::updateAnimationMode(); 310 SVGAnimationElement::updateAnimationMode();
309 } 311 }
310 312
311 } // namespace blink 313 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAnimateElement.cpp ('k') | third_party/WebKit/Source/core/svg/SVGAnimationElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698