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

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

Issue 2578913002: Unify animate motion transform update invalidations (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAnimateMotionElement.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 SVGElement* targetElement = this->targetElement(); 157 SVGElement* targetElement = this->targetElement();
158 if (!targetElement) 158 if (!targetElement)
159 return; 159 return;
160 160
161 AffineTransform* transform = targetElement->animateMotionTransform(); 161 AffineTransform* transform = targetElement->animateMotionTransform();
162 if (!transform) 162 if (!transform)
163 return; 163 return;
164 164
165 transform->makeIdentity(); 165 transform->makeIdentity();
166 166
167 if (LayoutObject* targetLayoutObject = targetElement->layoutObject()) { 167 if (LayoutObject* targetLayoutObject = targetElement->layoutObject())
168 targetLayoutObject->setNeedsTransformUpdate(); 168 invalidateForAnimateMotionTransformChange(*targetLayoutObject);
169 markForLayoutAndParentResourceInvalidation(targetLayoutObject);
170 }
171 } 169 }
172 170
173 bool SVGAnimateMotionElement::calculateToAtEndOfDurationValue( 171 bool SVGAnimateMotionElement::calculateToAtEndOfDurationValue(
174 const String& toAtEndOfDurationString) { 172 const String& toAtEndOfDurationString) {
175 parsePoint(toAtEndOfDurationString, m_toPointAtEndOfDuration); 173 parsePoint(toAtEndOfDurationString, m_toPointAtEndOfDuration);
176 m_hasToPointAtEndOfDuration = true; 174 m_hasToPointAtEndOfDuration = true;
177 return true; 175 return true;
178 } 176 }
179 177
180 bool SVGAnimateMotionElement::calculateFromAndToValues(const String& fromString, 178 bool SVGAnimateMotionElement::calculateFromAndToValues(const String& fromString,
(...skipping 20 matching lines...) Expand all
201 void SVGAnimateMotionElement::calculateAnimatedValue(float percentage, 199 void SVGAnimateMotionElement::calculateAnimatedValue(float percentage,
202 unsigned repeatCount, 200 unsigned repeatCount,
203 SVGSMILElement*) { 201 SVGSMILElement*) {
204 SVGElement* targetElement = this->targetElement(); 202 SVGElement* targetElement = this->targetElement();
205 DCHECK(targetElement); 203 DCHECK(targetElement);
206 AffineTransform* transform = targetElement->animateMotionTransform(); 204 AffineTransform* transform = targetElement->animateMotionTransform();
207 if (!transform) 205 if (!transform)
208 return; 206 return;
209 207
210 if (LayoutObject* targetLayoutObject = targetElement->layoutObject()) 208 if (LayoutObject* targetLayoutObject = targetElement->layoutObject())
211 targetLayoutObject->setNeedsTransformUpdate(); 209 invalidateForAnimateMotionTransformChange(*targetLayoutObject);
212 210
213 if (!isAdditive()) 211 if (!isAdditive())
214 transform->makeIdentity(); 212 transform->makeIdentity();
215 213
216 if (getAnimationMode() != PathAnimation) { 214 if (getAnimationMode() != PathAnimation) {
217 FloatPoint toPointAtEndOfDuration = m_toPoint; 215 FloatPoint toPointAtEndOfDuration = m_toPoint;
218 if (isAccumulated() && repeatCount && m_hasToPointAtEndOfDuration) 216 if (isAccumulated() && repeatCount && m_hasToPointAtEndOfDuration)
219 toPointAtEndOfDuration = m_toPointAtEndOfDuration; 217 toPointAtEndOfDuration = m_toPointAtEndOfDuration;
220 218
221 float animatedX = 0; 219 float animatedX = 0;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 transform->rotate(angle); 252 transform->rotate(angle);
255 } 253 }
256 254
257 void SVGAnimateMotionElement::applyResultsToTarget() { 255 void SVGAnimateMotionElement::applyResultsToTarget() {
258 // We accumulate to the target element transform list so there is not much to 256 // We accumulate to the target element transform list so there is not much to
259 // do here. 257 // do here.
260 SVGElement* targetElement = this->targetElement(); 258 SVGElement* targetElement = this->targetElement();
261 if (!targetElement) 259 if (!targetElement)
262 return; 260 return;
263 261
264 if (LayoutObject* layoutObject = targetElement->layoutObject())
265 markForLayoutAndParentResourceInvalidation(layoutObject);
266
267 AffineTransform* t = targetElement->animateMotionTransform(); 262 AffineTransform* t = targetElement->animateMotionTransform();
268 if (!t) 263 if (!t)
269 return; 264 return;
270 265
271 // ...except in case where we have additional instances in <use> trees. 266 // ...except in case where we have additional instances in <use> trees.
272 const HeapHashSet<WeakMember<SVGElement>>& instances = 267 const HeapHashSet<WeakMember<SVGElement>>& instances =
273 targetElement->instancesForElement(); 268 targetElement->instancesForElement();
274 for (SVGElement* shadowTreeElement : instances) { 269 for (SVGElement* shadowTreeElement : instances) {
275 ASSERT(shadowTreeElement); 270 ASSERT(shadowTreeElement);
276 AffineTransform* transform = shadowTreeElement->animateMotionTransform(); 271 AffineTransform* transform = shadowTreeElement->animateMotionTransform();
277 if (!transform) 272 if (!transform)
278 continue; 273 continue;
279 transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f()); 274 transform->setMatrix(t->a(), t->b(), t->c(), t->d(), t->e(), t->f());
280 if (LayoutObject* layoutObject = shadowTreeElement->layoutObject()) { 275 if (LayoutObject* layoutObject = shadowTreeElement->layoutObject())
281 layoutObject->setNeedsTransformUpdate(); 276 invalidateForAnimateMotionTransformChange(*layoutObject);
282 markForLayoutAndParentResourceInvalidation(layoutObject);
283 }
284 } 277 }
285 } 278 }
286 279
287 float SVGAnimateMotionElement::calculateDistance(const String& fromString, 280 float SVGAnimateMotionElement::calculateDistance(const String& fromString,
288 const String& toString) { 281 const String& toString) {
289 FloatPoint from; 282 FloatPoint from;
290 FloatPoint to; 283 FloatPoint to;
291 if (!parsePoint(fromString, from)) 284 if (!parsePoint(fromString, from))
292 return -1; 285 return -1;
293 if (!parsePoint(toString, to)) 286 if (!parsePoint(toString, to))
294 return -1; 287 return -1;
295 FloatSize diff = to - from; 288 FloatSize diff = to - from;
296 return sqrtf(diff.width() * diff.width() + diff.height() * diff.height()); 289 return sqrtf(diff.width() * diff.width() + diff.height() * diff.height());
297 } 290 }
298 291
299 void SVGAnimateMotionElement::updateAnimationMode() { 292 void SVGAnimateMotionElement::updateAnimationMode() {
300 if (!m_animationPath.isEmpty()) 293 if (!m_animationPath.isEmpty())
301 setAnimationMode(PathAnimation); 294 setAnimationMode(PathAnimation);
302 else 295 else
303 SVGAnimationElement::updateAnimationMode(); 296 SVGAnimationElement::updateAnimationMode();
304 } 297 }
305 298
299 void SVGAnimateMotionElement::invalidateForAnimateMotionTransformChange(
300 LayoutObject& object) {
301 object.setNeedsTransformUpdate();
302 markForLayoutAndParentResourceInvalidation(&object);
303 }
304
306 } // namespace blink 305 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGAnimateMotionElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698