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

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

Issue 1541923002: Make SVGElement::propertyFromAttribute return raw pointer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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) 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 } 270 }
271 } 271 }
272 svgRareData()->setWebAnimatedAttributesDirty(false); 272 svgRareData()->setWebAnimatedAttributesDirty(false);
273 } 273 }
274 274
275 template<typename T> 275 template<typename T>
276 static void updateInstancesAnimatedAttribute(SVGElement* element, const Qualifie dName& attribute, T callback) 276 static void updateInstancesAnimatedAttribute(SVGElement* element, const Qualifie dName& attribute, T callback)
277 { 277 {
278 SVGElement::InstanceUpdateBlocker blocker(element); 278 SVGElement::InstanceUpdateBlocker blocker(element);
279 for (SVGElement* instance : SVGAnimateElement::findElementInstances(element) ) { 279 for (SVGElement* instance : SVGAnimateElement::findElementInstances(element) ) {
280 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> animatedProperty = instance- >propertyFromAttribute(attribute); 280 if (SVGAnimatedPropertyBase* animatedProperty = instance->propertyFromAt tribute(attribute)) {
281 if (animatedProperty) {
282 callback(*animatedProperty); 281 callback(*animatedProperty);
283 instance->invalidateSVGAttributes(); 282 instance->invalidateSVGAttributes();
284 instance->svgAttributeChanged(attribute); 283 instance->svgAttributeChanged(attribute);
285 } 284 }
286 } 285 }
287 } 286 }
288 287
289 void SVGElement::setWebAnimatedAttribute(const QualifiedName& attribute, PassRef PtrWillBeRawPtr<SVGPropertyBase> value) 288 void SVGElement::setWebAnimatedAttribute(const QualifiedName& attribute, PassRef PtrWillBeRawPtr<SVGPropertyBase> value)
290 { 289 {
291 updateInstancesAnimatedAttribute(this, attribute, [&value](SVGAnimatedProper tyBase& animatedProperty) { 290 updateInstancesAnimatedAttribute(this, attribute, [&value](SVGAnimatedProper tyBase& animatedProperty) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 ensureSVGRareData()->setCorrespondingElement(correspondingElement); 627 ensureSVGRareData()->setCorrespondingElement(correspondingElement);
629 } 628 }
630 629
631 bool SVGElement::inUseShadowTree() const 630 bool SVGElement::inUseShadowTree() const
632 { 631 {
633 return correspondingUseElement(); 632 return correspondingUseElement();
634 } 633 }
635 634
636 void SVGElement::parseAttribute(const QualifiedName& name, const AtomicString& o ldValue, const AtomicString& value) 635 void SVGElement::parseAttribute(const QualifiedName& name, const AtomicString& o ldValue, const AtomicString& value)
637 { 636 {
638 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property = propertyFromAttribute (name); 637 if (SVGAnimatedPropertyBase* property = propertyFromAttribute(name)) {
639 if (property) {
640 SVGParsingError parseError = NoError; 638 SVGParsingError parseError = NoError;
641 property->setBaseValueAsString(value, parseError); 639 property->setBaseValueAsString(value, parseError);
642 reportAttributeParsingError(parseError, name, value); 640 reportAttributeParsingError(parseError, name, value);
643
644 return; 641 return;
645 } 642 }
646 643
647 if (name == HTMLNames::classAttr) { 644 if (name == HTMLNames::classAttr) {
648 // SVG animation has currently requires special storage of values so we set 645 // SVG animation has currently requires special storage of values so we set
649 // the className here. svgAttributeChanged actually causes the resulting 646 // the className here. svgAttributeChanged actually causes the resulting
650 // style updates (instead of Element::parseAttribute). We don't 647 // style updates (instead of Element::parseAttribute). We don't
651 // tell Element about the change to avoid parsing the class list twice 648 // tell Element about the change to avoid parsing the class list twice
652 SVGParsingError parseError = NoError; 649 SVGParsingError parseError = NoError;
653 m_className->setBaseValueAsString(value, parseError); 650 m_className->setBaseValueAsString(value, parseError);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 return AnimatedUnknown; 737 return AnimatedUnknown;
741 } 738 }
742 739
743 void SVGElement::addToPropertyMap(PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase > passProperty) 740 void SVGElement::addToPropertyMap(PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase > passProperty)
744 { 741 {
745 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property(passProperty); 742 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property(passProperty);
746 QualifiedName attributeName = property->attributeName(); 743 QualifiedName attributeName = property->attributeName();
747 m_attributeToPropertyMap.set(attributeName, property.release()); 744 m_attributeToPropertyMap.set(attributeName, property.release());
748 } 745 }
749 746
750 PassRefPtrWillBeRawPtr<SVGAnimatedPropertyBase> SVGElement::propertyFromAttribut e(const QualifiedName& attributeName) 747 SVGAnimatedPropertyBase* SVGElement::propertyFromAttribute(const QualifiedName& attributeName) const
751 { 748 {
752 AttributeToPropertyMap::iterator it = m_attributeToPropertyMap.find<SVGAttri buteHashTranslator>(attributeName); 749 AttributeToPropertyMap::const_iterator it = m_attributeToPropertyMap.find<SV GAttributeHashTranslator>(attributeName);
753 if (it == m_attributeToPropertyMap.end()) 750 if (it == m_attributeToPropertyMap.end())
754 return nullptr; 751 return nullptr;
755 752
756 return it->value; 753 return it->value.get();
757 } 754 }
758 755
759 bool SVGElement::isAnimatableCSSProperty(const QualifiedName& attrName) 756 bool SVGElement::isAnimatableCSSProperty(const QualifiedName& attrName)
760 { 757 {
761 return animatedPropertyTypeForCSSAttribute(attrName) != AnimatedUnknown; 758 return animatedPropertyTypeForCSSAttribute(attrName) != AnimatedUnknown;
762 } 759 }
763 760
764 bool SVGElement::isPresentationAttribute(const QualifiedName& name) const 761 bool SVGElement::isPresentationAttribute(const QualifiedName& name) const
765 { 762 {
766 return cssPropertyIdForSVGAttributeName(name) > 0; 763 return cssPropertyIdForSVGAttributeName(name) > 0;
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
1246 Element::trace(visitor); 1243 Element::trace(visitor);
1247 } 1244 }
1248 1245
1249 const AtomicString& SVGElement::eventParameterName() 1246 const AtomicString& SVGElement::eventParameterName()
1250 { 1247 {
1251 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con structFromLiteral)); 1248 DEFINE_STATIC_LOCAL(const AtomicString, evtString, ("evt", AtomicString::Con structFromLiteral));
1252 return evtString; 1249 return evtString;
1253 } 1250 }
1254 1251
1255 } // namespace blink 1252 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/svg/SVGElement.h ('k') | third_party/WebKit/Source/core/svg/SVGEllipseElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698