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

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

Issue 2281643003: Move animVal invalidation from SVGAnimateElement to SVGElement (Closed)
Patch Set: Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGElement.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) 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, 2006, 2008 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2008 Rob Buis <buis@kde.org>
4 * Copyright (C) 2008 Apple Inc. All rights reserved. 4 * Copyright (C) 2008 Apple Inc. All rights reserved.
5 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 5 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 6 * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 template<typename T> 240 template<typename T>
241 static void updateInstancesAnimatedAttributeNoInvalidate(SVGElement* element, co nst QualifiedName& attribute, T callback) 241 static void updateInstancesAnimatedAttributeNoInvalidate(SVGElement* element, co nst QualifiedName& attribute, T callback)
242 { 242 {
243 SVGElement::InstanceUpdateBlocker blocker(element); 243 SVGElement::InstanceUpdateBlocker blocker(element);
244 for (SVGElement* instance : SVGAnimateElement::findElementInstances(element) ) { 244 for (SVGElement* instance : SVGAnimateElement::findElementInstances(element) ) {
245 if (SVGAnimatedPropertyBase* animatedProperty = instance->propertyFromAt tribute(attribute)) 245 if (SVGAnimatedPropertyBase* animatedProperty = instance->propertyFromAt tribute(attribute))
246 callback(*animatedProperty); 246 callback(*animatedProperty);
247 } 247 }
248 } 248 }
249 249
250 static inline void notifyAnimValChanged(SVGElement* targetElement, const Qualifi edName& attributeName)
251 {
252 targetElement->invalidateSVGAttributes();
253 targetElement->svgAttributeChanged(attributeName);
254 }
255
250 template<typename T> 256 template<typename T>
251 static void updateInstancesAnimatedAttribute(SVGElement* element, const Qualifie dName& attribute, T callback) 257 static void updateInstancesAnimatedAttribute(SVGElement* element, const Qualifie dName& attribute, T callback)
252 { 258 {
253 SVGElement::InstanceUpdateBlocker blocker(element); 259 SVGElement::InstanceUpdateBlocker blocker(element);
254 for (SVGElement* instance : SVGAnimateElement::findElementInstances(element) ) { 260 for (SVGElement* instance : SVGAnimateElement::findElementInstances(element) ) {
255 if (SVGAnimatedPropertyBase* animatedProperty = instance->propertyFromAt tribute(attribute)) { 261 if (SVGAnimatedPropertyBase* animatedProperty = instance->propertyFromAt tribute(attribute)) {
256 callback(*animatedProperty); 262 callback(*animatedProperty);
257 instance->invalidateSVGAttributes(); 263 notifyAnimValChanged(instance, attribute);
258 instance->svgAttributeChanged(attribute);
259 } 264 }
260 } 265 }
261 } 266 }
262 267
263 void SVGElement::setWebAnimatedAttribute(const QualifiedName& attribute, SVGProp ertyBase* value) 268 void SVGElement::setWebAnimatedAttribute(const QualifiedName& attribute, SVGProp ertyBase* value)
264 { 269 {
265 updateInstancesAnimatedAttribute(this, attribute, [&value](SVGAnimatedProper tyBase& animatedProperty) { 270 updateInstancesAnimatedAttribute(this, attribute, [&value](SVGAnimatedProper tyBase& animatedProperty) {
266 animatedProperty.setAnimatedValue(value); 271 animatedProperty.setAnimatedValue(value);
267 }); 272 });
268 ensureSVGRareData()->webAnimatedAttributes().add(&attribute); 273 ensureSVGRareData()->webAnimatedAttributes().add(&attribute);
(...skipping 11 matching lines...) Expand all
280 svgRareData()->webAnimatedAttributes().clear(); 285 svgRareData()->webAnimatedAttributes().clear();
281 } 286 }
282 287
283 void SVGElement::setAnimatedAttribute(const QualifiedName& attribute, SVGPropert yBase* value) 288 void SVGElement::setAnimatedAttribute(const QualifiedName& attribute, SVGPropert yBase* value)
284 { 289 {
285 updateInstancesAnimatedAttributeNoInvalidate(this, attribute, [&value](SVGAn imatedPropertyBase& animatedProperty) { 290 updateInstancesAnimatedAttributeNoInvalidate(this, attribute, [&value](SVGAn imatedPropertyBase& animatedProperty) {
286 animatedProperty.setAnimatedValue(value); 291 animatedProperty.setAnimatedValue(value);
287 }); 292 });
288 } 293 }
289 294
295 void SVGElement::invalidateAnimatedAttribute(const QualifiedName& attribute)
296 {
297 InstanceUpdateBlocker blocker(this);
298 notifyAnimValChanged(this, attribute);
299
300 for (SVGElement* element : instancesForElement())
301 notifyAnimValChanged(element, attribute);
302 }
303
290 void SVGElement::clearAnimatedAttribute(const QualifiedName& attribute) 304 void SVGElement::clearAnimatedAttribute(const QualifiedName& attribute)
291 { 305 {
292 updateInstancesAnimatedAttributeNoInvalidate(this, attribute, [](SVGAnimated PropertyBase& animatedProperty) { 306 updateInstancesAnimatedAttributeNoInvalidate(this, attribute, [](SVGAnimated PropertyBase& animatedProperty) {
293 animatedProperty.animationEnded(); 307 animatedProperty.animationEnded();
294 }); 308 });
295 } 309 }
296 310
297 AffineTransform SVGElement::localCoordinateSpaceTransform(CTMScope) const 311 AffineTransform SVGElement::localCoordinateSpaceTransform(CTMScope) const
298 { 312 {
299 // To be overriden by SVGGraphicsElement (or as special case SVGTextElement and SVGPatternElement) 313 // To be overriden by SVGGraphicsElement (or as special case SVGTextElement and SVGPatternElement)
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 Element::trace(visitor); 1217 Element::trace(visitor);
1204 } 1218 }
1205 1219
1206 const AtomicString& SVGElement::eventParameterName() 1220 const AtomicString& SVGElement::eventParameterName()
1207 { 1221 {
1208 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt")); 1222 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt"));
1209 return evtString; 1223 return evtString;
1210 } 1224 }
1211 1225
1212 } // namespace blink 1226 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698