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

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: rebased 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
« no previous file with comments | « 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 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 // standard events 655 // standard events
656 const AtomicString& eventName = HTMLElement::eventNameForAttributeName(n ame); 656 const AtomicString& eventName = HTMLElement::eventNameForAttributeName(n ame);
657 if (!eventName.isNull()) 657 if (!eventName.isNull())
658 setAttributeEventListener(eventName, createAttributeEventListener(th is, name, value)); 658 setAttributeEventListener(eventName, createAttributeEventListener(th is, name, value));
659 else 659 else
660 Element::parseAttribute(name, value); 660 Element::parseAttribute(name, value);
661 } 661 }
662 } 662 }
663 663
664 typedef HashMap<QualifiedName, AnimatedPropertyType> AttributeToPropertyTypeMap; 664 typedef HashMap<QualifiedName, AnimatedPropertyType> AttributeToPropertyTypeMap;
665 static inline AttributeToPropertyTypeMap& cssPropertyToTypeMap() 665 AnimatedPropertyType SVGElement::animatedPropertyTypeForCSSAttribute(const Quali fiedName& attributeName)
666 { 666 {
667 DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, s_cssPropertyMap, ()); 667 DEFINE_STATIC_LOCAL(AttributeToPropertyTypeMap, cssPropertyMap, ());
668 668
669 if (!s_cssPropertyMap.isEmpty()) 669 if (cssPropertyMap.isEmpty()) {
670 return s_cssPropertyMap; 670 // Fill the map for the first use.
671 671 cssPropertyMap.set(alignment_baselineAttr, AnimatedString);
672 // Fill the map for the first use. 672 cssPropertyMap.set(baseline_shiftAttr, AnimatedString);
673 s_cssPropertyMap.set(alignment_baselineAttr, AnimatedString); 673 cssPropertyMap.set(buffered_renderingAttr, AnimatedString);
674 s_cssPropertyMap.set(baseline_shiftAttr, AnimatedString); 674 cssPropertyMap.set(clipAttr, AnimatedRect);
675 s_cssPropertyMap.set(buffered_renderingAttr, AnimatedString); 675 cssPropertyMap.set(clip_pathAttr, AnimatedString);
676 s_cssPropertyMap.set(clipAttr, AnimatedRect); 676 cssPropertyMap.set(clip_ruleAttr, AnimatedString);
677 s_cssPropertyMap.set(clip_pathAttr, AnimatedString); 677 cssPropertyMap.set(SVGNames::colorAttr, AnimatedColor);
678 s_cssPropertyMap.set(clip_ruleAttr, AnimatedString); 678 cssPropertyMap.set(color_interpolationAttr, AnimatedString);
679 s_cssPropertyMap.set(SVGNames::colorAttr, AnimatedColor); 679 cssPropertyMap.set(color_interpolation_filtersAttr, AnimatedString);
680 s_cssPropertyMap.set(color_interpolationAttr, AnimatedString); 680 cssPropertyMap.set(color_profileAttr, AnimatedString);
681 s_cssPropertyMap.set(color_interpolation_filtersAttr, AnimatedString); 681 cssPropertyMap.set(color_renderingAttr, AnimatedString);
682 s_cssPropertyMap.set(color_profileAttr, AnimatedString); 682 cssPropertyMap.set(cursorAttr, AnimatedString);
683 s_cssPropertyMap.set(color_renderingAttr, AnimatedString); 683 cssPropertyMap.set(displayAttr, AnimatedString);
684 s_cssPropertyMap.set(cursorAttr, AnimatedString); 684 cssPropertyMap.set(dominant_baselineAttr, AnimatedString);
685 s_cssPropertyMap.set(displayAttr, AnimatedString); 685 cssPropertyMap.set(fillAttr, AnimatedColor);
686 s_cssPropertyMap.set(dominant_baselineAttr, AnimatedString); 686 cssPropertyMap.set(fill_opacityAttr, AnimatedNumber);
687 s_cssPropertyMap.set(fillAttr, AnimatedColor); 687 cssPropertyMap.set(fill_ruleAttr, AnimatedString);
688 s_cssPropertyMap.set(fill_opacityAttr, AnimatedNumber); 688 cssPropertyMap.set(filterAttr, AnimatedString);
689 s_cssPropertyMap.set(fill_ruleAttr, AnimatedString); 689 cssPropertyMap.set(flood_colorAttr, AnimatedColor);
690 s_cssPropertyMap.set(filterAttr, AnimatedString); 690 cssPropertyMap.set(flood_opacityAttr, AnimatedNumber);
691 s_cssPropertyMap.set(flood_colorAttr, AnimatedColor); 691 cssPropertyMap.set(font_familyAttr, AnimatedString);
692 s_cssPropertyMap.set(flood_opacityAttr, AnimatedNumber); 692 cssPropertyMap.set(font_sizeAttr, AnimatedLength);
693 s_cssPropertyMap.set(font_familyAttr, AnimatedString); 693 cssPropertyMap.set(font_stretchAttr, AnimatedString);
694 s_cssPropertyMap.set(font_sizeAttr, AnimatedLength); 694 cssPropertyMap.set(font_styleAttr, AnimatedString);
695 s_cssPropertyMap.set(font_stretchAttr, AnimatedString); 695 cssPropertyMap.set(font_variantAttr, AnimatedString);
696 s_cssPropertyMap.set(font_styleAttr, AnimatedString); 696 cssPropertyMap.set(font_weightAttr, AnimatedString);
697 s_cssPropertyMap.set(font_variantAttr, AnimatedString); 697 cssPropertyMap.set(image_renderingAttr, AnimatedString);
698 s_cssPropertyMap.set(font_weightAttr, AnimatedString); 698 cssPropertyMap.set(kerningAttr, AnimatedLength);
699 s_cssPropertyMap.set(image_renderingAttr, AnimatedString); 699 cssPropertyMap.set(letter_spacingAttr, AnimatedLength);
700 s_cssPropertyMap.set(kerningAttr, AnimatedLength); 700 cssPropertyMap.set(lighting_colorAttr, AnimatedColor);
701 s_cssPropertyMap.set(letter_spacingAttr, AnimatedLength); 701 cssPropertyMap.set(marker_endAttr, AnimatedString);
702 s_cssPropertyMap.set(lighting_colorAttr, AnimatedColor); 702 cssPropertyMap.set(marker_midAttr, AnimatedString);
703 s_cssPropertyMap.set(marker_endAttr, AnimatedString); 703 cssPropertyMap.set(marker_startAttr, AnimatedString);
704 s_cssPropertyMap.set(marker_midAttr, AnimatedString); 704 cssPropertyMap.set(maskAttr, AnimatedString);
705 s_cssPropertyMap.set(marker_startAttr, AnimatedString); 705 cssPropertyMap.set(mask_typeAttr, AnimatedString);
706 s_cssPropertyMap.set(maskAttr, AnimatedString); 706 cssPropertyMap.set(opacityAttr, AnimatedNumber);
707 s_cssPropertyMap.set(mask_typeAttr, AnimatedString); 707 cssPropertyMap.set(overflowAttr, AnimatedString);
708 s_cssPropertyMap.set(opacityAttr, AnimatedNumber); 708 cssPropertyMap.set(paint_orderAttr, AnimatedString);
709 s_cssPropertyMap.set(overflowAttr, AnimatedString); 709 cssPropertyMap.set(pointer_eventsAttr, AnimatedString);
710 s_cssPropertyMap.set(paint_orderAttr, AnimatedString); 710 cssPropertyMap.set(shape_renderingAttr, AnimatedString);
711 s_cssPropertyMap.set(pointer_eventsAttr, AnimatedString); 711 cssPropertyMap.set(stop_colorAttr, AnimatedColor);
712 s_cssPropertyMap.set(shape_renderingAttr, AnimatedString); 712 cssPropertyMap.set(stop_opacityAttr, AnimatedNumber);
713 s_cssPropertyMap.set(stop_colorAttr, AnimatedColor); 713 cssPropertyMap.set(strokeAttr, AnimatedColor);
714 s_cssPropertyMap.set(stop_opacityAttr, AnimatedNumber); 714 cssPropertyMap.set(stroke_dasharrayAttr, AnimatedLengthList);
715 s_cssPropertyMap.set(strokeAttr, AnimatedColor); 715 cssPropertyMap.set(stroke_dashoffsetAttr, AnimatedLength);
716 s_cssPropertyMap.set(stroke_dasharrayAttr, AnimatedLengthList); 716 cssPropertyMap.set(stroke_linecapAttr, AnimatedString);
717 s_cssPropertyMap.set(stroke_dashoffsetAttr, AnimatedLength); 717 cssPropertyMap.set(stroke_linejoinAttr, AnimatedString);
718 s_cssPropertyMap.set(stroke_linecapAttr, AnimatedString); 718 cssPropertyMap.set(stroke_miterlimitAttr, AnimatedNumber);
719 s_cssPropertyMap.set(stroke_linejoinAttr, AnimatedString); 719 cssPropertyMap.set(stroke_opacityAttr, AnimatedNumber);
720 s_cssPropertyMap.set(stroke_miterlimitAttr, AnimatedNumber); 720 cssPropertyMap.set(stroke_widthAttr, AnimatedLength);
721 s_cssPropertyMap.set(stroke_opacityAttr, AnimatedNumber); 721 cssPropertyMap.set(text_anchorAttr, AnimatedString);
722 s_cssPropertyMap.set(stroke_widthAttr, AnimatedLength); 722 cssPropertyMap.set(text_decorationAttr, AnimatedString);
723 s_cssPropertyMap.set(text_anchorAttr, AnimatedString); 723 cssPropertyMap.set(text_renderingAttr, AnimatedString);
724 s_cssPropertyMap.set(text_decorationAttr, AnimatedString); 724 cssPropertyMap.set(vector_effectAttr, AnimatedString);
725 s_cssPropertyMap.set(text_renderingAttr, AnimatedString); 725 cssPropertyMap.set(visibilityAttr, AnimatedString);
726 s_cssPropertyMap.set(vector_effectAttr, AnimatedString); 726 cssPropertyMap.set(word_spacingAttr, AnimatedLength);
727 s_cssPropertyMap.set(visibilityAttr, AnimatedString);
728 s_cssPropertyMap.set(word_spacingAttr, AnimatedLength);
729 return s_cssPropertyMap;
730 }
731
732 void SVGElement::animatedPropertyTypeForAttribute(const QualifiedName& attribute Name, Vector<AnimatedPropertyType>& propertyTypes)
733 {
734 RefPtr<NewSVGAnimatedPropertyBase> animatedProperty = m_newAttributeToProper tyMap.get(attributeName);
735 if (animatedProperty) {
736 propertyTypes.append(animatedProperty->type());
737 return;
738 } 727 }
739 728
740 AttributeToPropertyTypeMap& cssPropertyTypeMap = cssPropertyToTypeMap(); 729 if (cssPropertyMap.contains(attributeName))
741 if (cssPropertyTypeMap.contains(attributeName)) 730 return cssPropertyMap.get(attributeName);
742 propertyTypes.append(cssPropertyTypeMap.get(attributeName)); 731
732 return AnimatedUnknown;
743 } 733 }
744 734
745 void SVGElement::addToPropertyMap(PassRefPtr<NewSVGAnimatedPropertyBase> passPro perty) 735 void SVGElement::addToPropertyMap(PassRefPtr<NewSVGAnimatedPropertyBase> passPro perty)
746 { 736 {
747 RefPtr<NewSVGAnimatedPropertyBase> property(passProperty); 737 RefPtr<NewSVGAnimatedPropertyBase> property(passProperty);
748 QualifiedName attributeName = property->attributeName(); 738 QualifiedName attributeName = property->attributeName();
749 m_newAttributeToPropertyMap.set(attributeName, property.release()); 739 m_newAttributeToPropertyMap.set(attributeName, property.release());
750 } 740 }
751 741
752 PassRefPtr<NewSVGAnimatedPropertyBase> SVGElement::propertyFromAttribute(const Q ualifiedName& attributeName) 742 PassRefPtr<NewSVGAnimatedPropertyBase> SVGElement::propertyFromAttribute(const Q ualifiedName& attributeName)
753 { 743 {
754 return m_newAttributeToPropertyMap.get(attributeName); 744 return m_newAttributeToPropertyMap.get(attributeName);
755 } 745 }
756 746
757 bool SVGElement::isAnimatableCSSProperty(const QualifiedName& attrName) 747 bool SVGElement::isAnimatableCSSProperty(const QualifiedName& attrName)
758 { 748 {
759 return cssPropertyToTypeMap().contains(attrName); 749 return animatedPropertyTypeForCSSAttribute(attrName) != AnimatedUnknown;
760 } 750 }
761 751
762 bool SVGElement::isPresentationAttribute(const QualifiedName& name) const 752 bool SVGElement::isPresentationAttribute(const QualifiedName& name) const
763 { 753 {
764 return cssPropertyIdForSVGAttributeName(name) > 0; 754 return cssPropertyIdForSVGAttributeName(name) > 0;
765 } 755 }
766 756
767 void SVGElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style) 757 void SVGElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style)
768 { 758 {
769 CSSPropertyID propertyID = cssPropertyIdForSVGAttributeName(name); 759 CSSPropertyID propertyID = cssPropertyIdForSVGAttributeName(name);
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 animatableAttributes.add(SVGNames::zAttr); 1143 animatableAttributes.add(SVGNames::zAttr);
1154 } 1144 }
1155 1145
1156 if (name == classAttr) 1146 if (name == classAttr)
1157 return true; 1147 return true;
1158 1148
1159 return animatableAttributes.contains(name); 1149 return animatableAttributes.contains(name);
1160 } 1150 }
1161 #endif 1151 #endif
1162 } 1152 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698