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

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

Issue 180113007: [SVG] refactor determineAnimatedPropertyType logic. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 // standard events 665 // standard events
666 const AtomicString& eventName = HTMLElement::eventNameForAttributeName(n ame); 666 const AtomicString& eventName = HTMLElement::eventNameForAttributeName(n ame);
667 if (!eventName.isNull()) 667 if (!eventName.isNull())
668 setAttributeEventListener(eventName, createAttributeEventListener(th is, name, value)); 668 setAttributeEventListener(eventName, createAttributeEventListener(th is, name, value));
669 else 669 else
670 Element::parseAttribute(name, value); 670 Element::parseAttribute(name, value);
671 } 671 }
672 } 672 }
673 673
674 typedef HashMap<QualifiedName, AnimatedPropertyType> AttributeToPropertyTypeMap; 674 typedef HashMap<QualifiedName, AnimatedPropertyType> AttributeToPropertyTypeMap;
675 static inline AttributeToPropertyTypeMap& cssPropertyToTypeMap() 675 AnimatedPropertyType SVGElement::animatedPropertyTypeForCSSAttribute(const Quali fiedName& attributeName)
676 { 676 {
677 DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_cssPropertyMap, ()); 677 DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, cssPropertyMap, ());
678 678
679 if (!s_cssPropertyMap.isEmpty()) 679 if (cssPropertyMap.isEmpty()) {
680 return s_cssPropertyMap; 680 // Fill the map for the first use.
681 681 cssPropertyMap.set(alignment_baselineAttr, AnimatedString);
682 // Fill the map for the first use. 682 cssPropertyMap.set(baseline_shiftAttr, AnimatedString);
683 s_cssPropertyMap.set(alignment_baselineAttr, AnimatedString); 683 cssPropertyMap.set(buffered_renderingAttr, AnimatedString);
684 s_cssPropertyMap.set(baseline_shiftAttr, AnimatedString); 684 cssPropertyMap.set(clipAttr, AnimatedRect);
685 s_cssPropertyMap.set(buffered_renderingAttr, AnimatedString); 685 cssPropertyMap.set(clip_pathAttr, AnimatedString);
686 s_cssPropertyMap.set(clipAttr, AnimatedRect); 686 cssPropertyMap.set(clip_ruleAttr, AnimatedString);
687 s_cssPropertyMap.set(clip_pathAttr, AnimatedString); 687 cssPropertyMap.set(SVGNames::colorAttr, AnimatedColor);
688 s_cssPropertyMap.set(clip_ruleAttr, AnimatedString); 688 cssPropertyMap.set(color_interpolationAttr, AnimatedString);
689 s_cssPropertyMap.set(SVGNames::colorAttr, AnimatedColor); 689 cssPropertyMap.set(color_interpolation_filtersAttr, AnimatedString);
690 s_cssPropertyMap.set(color_interpolationAttr, AnimatedString); 690 cssPropertyMap.set(color_profileAttr, AnimatedString);
691 s_cssPropertyMap.set(color_interpolation_filtersAttr, AnimatedString); 691 cssPropertyMap.set(color_renderingAttr, AnimatedString);
692 s_cssPropertyMap.set(color_profileAttr, AnimatedString); 692 cssPropertyMap.set(cursorAttr, AnimatedString);
693 s_cssPropertyMap.set(color_renderingAttr, AnimatedString); 693 cssPropertyMap.set(displayAttr, AnimatedString);
694 s_cssPropertyMap.set(cursorAttr, AnimatedString); 694 cssPropertyMap.set(dominant_baselineAttr, AnimatedString);
695 s_cssPropertyMap.set(displayAttr, AnimatedString); 695 cssPropertyMap.set(fillAttr, AnimatedColor);
696 s_cssPropertyMap.set(dominant_baselineAttr, AnimatedString); 696 cssPropertyMap.set(fill_opacityAttr, AnimatedNumber);
697 s_cssPropertyMap.set(fillAttr, AnimatedColor); 697 cssPropertyMap.set(fill_ruleAttr, AnimatedString);
698 s_cssPropertyMap.set(fill_opacityAttr, AnimatedNumber); 698 cssPropertyMap.set(filterAttr, AnimatedString);
699 s_cssPropertyMap.set(fill_ruleAttr, AnimatedString); 699 cssPropertyMap.set(flood_colorAttr, AnimatedColor);
700 s_cssPropertyMap.set(filterAttr, AnimatedString); 700 cssPropertyMap.set(flood_opacityAttr, AnimatedNumber);
701 s_cssPropertyMap.set(flood_colorAttr, AnimatedColor); 701 cssPropertyMap.set(font_familyAttr, AnimatedString);
702 s_cssPropertyMap.set(flood_opacityAttr, AnimatedNumber); 702 cssPropertyMap.set(font_sizeAttr, AnimatedLength);
703 s_cssPropertyMap.set(font_familyAttr, AnimatedString); 703 cssPropertyMap.set(font_stretchAttr, AnimatedString);
704 s_cssPropertyMap.set(font_sizeAttr, AnimatedLength); 704 cssPropertyMap.set(font_styleAttr, AnimatedString);
705 s_cssPropertyMap.set(font_stretchAttr, AnimatedString); 705 cssPropertyMap.set(font_variantAttr, AnimatedString);
706 s_cssPropertyMap.set(font_styleAttr, AnimatedString); 706 cssPropertyMap.set(font_weightAttr, AnimatedString);
707 s_cssPropertyMap.set(font_variantAttr, AnimatedString); 707 cssPropertyMap.set(image_renderingAttr, AnimatedString);
708 s_cssPropertyMap.set(font_weightAttr, AnimatedString); 708 cssPropertyMap.set(kerningAttr, AnimatedLength);
709 s_cssPropertyMap.set(image_renderingAttr, AnimatedString); 709 cssPropertyMap.set(letter_spacingAttr, AnimatedLength);
710 s_cssPropertyMap.set(kerningAttr, AnimatedLength); 710 cssPropertyMap.set(lighting_colorAttr, AnimatedColor);
711 s_cssPropertyMap.set(letter_spacingAttr, AnimatedLength); 711 cssPropertyMap.set(marker_endAttr, AnimatedString);
712 s_cssPropertyMap.set(lighting_colorAttr, AnimatedColor); 712 cssPropertyMap.set(marker_midAttr, AnimatedString);
713 s_cssPropertyMap.set(marker_endAttr, AnimatedString); 713 cssPropertyMap.set(marker_startAttr, AnimatedString);
714 s_cssPropertyMap.set(marker_midAttr, AnimatedString); 714 cssPropertyMap.set(maskAttr, AnimatedString);
715 s_cssPropertyMap.set(marker_startAttr, AnimatedString); 715 cssPropertyMap.set(mask_typeAttr, AnimatedString);
716 s_cssPropertyMap.set(maskAttr, AnimatedString); 716 cssPropertyMap.set(opacityAttr, AnimatedNumber);
717 s_cssPropertyMap.set(mask_typeAttr, AnimatedString); 717 cssPropertyMap.set(overflowAttr, AnimatedString);
718 s_cssPropertyMap.set(opacityAttr, AnimatedNumber); 718 cssPropertyMap.set(paint_orderAttr, AnimatedString);
719 s_cssPropertyMap.set(overflowAttr, AnimatedString); 719 cssPropertyMap.set(pointer_eventsAttr, AnimatedString);
720 s_cssPropertyMap.set(paint_orderAttr, AnimatedString); 720 cssPropertyMap.set(shape_renderingAttr, AnimatedString);
721 s_cssPropertyMap.set(pointer_eventsAttr, AnimatedString); 721 cssPropertyMap.set(stop_colorAttr, AnimatedColor);
722 s_cssPropertyMap.set(shape_renderingAttr, AnimatedString); 722 cssPropertyMap.set(stop_opacityAttr, AnimatedNumber);
723 s_cssPropertyMap.set(stop_colorAttr, AnimatedColor); 723 cssPropertyMap.set(strokeAttr, AnimatedColor);
724 s_cssPropertyMap.set(stop_opacityAttr, AnimatedNumber); 724 cssPropertyMap.set(stroke_dasharrayAttr, AnimatedLengthList);
725 s_cssPropertyMap.set(strokeAttr, AnimatedColor); 725 cssPropertyMap.set(stroke_dashoffsetAttr, AnimatedLength);
726 s_cssPropertyMap.set(stroke_dasharrayAttr, AnimatedLengthList); 726 cssPropertyMap.set(stroke_linecapAttr, AnimatedString);
727 s_cssPropertyMap.set(stroke_dashoffsetAttr, AnimatedLength); 727 cssPropertyMap.set(stroke_linejoinAttr, AnimatedString);
728 s_cssPropertyMap.set(stroke_linecapAttr, AnimatedString); 728 cssPropertyMap.set(stroke_miterlimitAttr, AnimatedNumber);
729 s_cssPropertyMap.set(stroke_linejoinAttr, AnimatedString); 729 cssPropertyMap.set(stroke_opacityAttr, AnimatedNumber);
730 s_cssPropertyMap.set(stroke_miterlimitAttr, AnimatedNumber); 730 cssPropertyMap.set(stroke_widthAttr, AnimatedLength);
731 s_cssPropertyMap.set(stroke_opacityAttr, AnimatedNumber); 731 cssPropertyMap.set(text_anchorAttr, AnimatedString);
732 s_cssPropertyMap.set(stroke_widthAttr, AnimatedLength); 732 cssPropertyMap.set(text_decorationAttr, AnimatedString);
733 s_cssPropertyMap.set(text_anchorAttr, AnimatedString); 733 cssPropertyMap.set(text_renderingAttr, AnimatedString);
734 s_cssPropertyMap.set(text_decorationAttr, AnimatedString); 734 cssPropertyMap.set(vector_effectAttr, AnimatedString);
735 s_cssPropertyMap.set(text_renderingAttr, AnimatedString); 735 cssPropertyMap.set(visibilityAttr, AnimatedString);
736 s_cssPropertyMap.set(vector_effectAttr, AnimatedString); 736 cssPropertyMap.set(word_spacingAttr, AnimatedLength);
737 s_cssPropertyMap.set(visibilityAttr, AnimatedString);
738 s_cssPropertyMap.set(word_spacingAttr, AnimatedLength);
739 return s_cssPropertyMap;
740 }
741
742 void SVGElement::animatedPropertyTypeForAttribute(const QualifiedName& attribute Name, Vector<AnimatedPropertyType>& propertyTypes)
743 {
744 localAttributeToPropertyMap().animatedPropertyTypeForAttribute(attributeName , propertyTypes);
745 if (!propertyTypes.isEmpty())
746 return;
747
748 RefPtr<NewSVGAnimatedPropertyBase> animatedProperty = m_newAttributeToProper tyMap.get(attributeName);
749 if (animatedProperty) {
750 propertyTypes.append(animatedProperty->type());
751 return;
752 } 737 }
753 738
754 AttributeToPropertyTypeMap& cssPropertyTypeMap = cssPropertyToTypeMap(); 739 if (cssPropertyMap.contains(attributeName))
755 if (cssPropertyTypeMap.contains(attributeName)) 740 return cssPropertyMap.get(attributeName);
756 propertyTypes.append(cssPropertyTypeMap.get(attributeName)); 741
742 return AnimatedUnknown;
757 } 743 }
758 744
759 void SVGElement::addToPropertyMap(PassRefPtr<NewSVGAnimatedPropertyBase> passPro perty) 745 void SVGElement::addToPropertyMap(PassRefPtr<NewSVGAnimatedPropertyBase> passPro perty)
760 { 746 {
761 RefPtr<NewSVGAnimatedPropertyBase> property(passProperty); 747 RefPtr<NewSVGAnimatedPropertyBase> property(passProperty);
762 QualifiedName attributeName = property->attributeName(); 748 QualifiedName attributeName = property->attributeName();
763 m_newAttributeToPropertyMap.set(attributeName, property.release()); 749 m_newAttributeToPropertyMap.set(attributeName, property.release());
764 } 750 }
765 751
766 PassRefPtr<NewSVGAnimatedPropertyBase> SVGElement::propertyFromAttribute(const Q ualifiedName& attributeName) 752 PassRefPtr<NewSVGAnimatedPropertyBase> SVGElement::propertyFromAttribute(const Q ualifiedName& attributeName)
767 { 753 {
768 return m_newAttributeToPropertyMap.get(attributeName); 754 return m_newAttributeToPropertyMap.get(attributeName);
769 } 755 }
770 756
771 bool SVGElement::isAnimatableCSSProperty(const QualifiedName& attrName) 757 bool SVGElement::isAnimatableCSSProperty(const QualifiedName& attrName)
772 { 758 {
773 return cssPropertyToTypeMap().contains(attrName); 759 return animatedPropertyTypeForCSSAttribute(attrName) != AnimatedUnknown;
774 } 760 }
775 761
776 bool SVGElement::isPresentationAttribute(const QualifiedName& name) const 762 bool SVGElement::isPresentationAttribute(const QualifiedName& name) const
777 { 763 {
778 return cssPropertyIdForSVGAttributeName(name) > 0; 764 return cssPropertyIdForSVGAttributeName(name) > 0;
779 } 765 }
780 766
781 void SVGElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style) 767 void SVGElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
782 { 768 {
783 CSSPropertyID propertyID = cssPropertyIdForSVGAttributeName(name); 769 CSSPropertyID propertyID = cssPropertyIdForSVGAttributeName(name);
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 animatableAttributes.add(SVGNames::zAttr); 1158 animatableAttributes.add(SVGNames::zAttr);
1173 } 1159 }
1174 1160
1175 if (name == classAttr) 1161 if (name == classAttr)
1176 return true; 1162 return true;
1177 1163
1178 return animatableAttributes.contains(name); 1164 return animatableAttributes.contains(name);
1179 } 1165 }
1180 #endif 1166 #endif
1181 } 1167 }
OLDNEW
« Source/core/svg/SVGAnimationElement.cpp ('K') | « Source/core/svg/SVGElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698