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

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

Issue 153883003: [SVG] SVGAnimatedTransform{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 10 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, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 4 * Copyright (C) Research In Motion Limited 2010. 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 20 matching lines...) Expand all
31 #include "core/rendering/svg/RenderSVGResourceRadialGradient.h" 31 #include "core/rendering/svg/RenderSVGResourceRadialGradient.h"
32 #include "core/svg/SVGElementInstance.h" 32 #include "core/svg/SVGElementInstance.h"
33 #include "core/svg/SVGStopElement.h" 33 #include "core/svg/SVGStopElement.h"
34 #include "core/svg/SVGTransformList.h" 34 #include "core/svg/SVGTransformList.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 // Animated property definitions 38 // Animated property definitions
39 DEFINE_ANIMATED_ENUMERATION(SVGGradientElement, SVGNames::spreadMethodAttr, Spre adMethod, spreadMethod, SVGSpreadMethodType) 39 DEFINE_ANIMATED_ENUMERATION(SVGGradientElement, SVGNames::spreadMethodAttr, Spre adMethod, spreadMethod, SVGSpreadMethodType)
40 DEFINE_ANIMATED_ENUMERATION(SVGGradientElement, SVGNames::gradientUnitsAttr, Gra dientUnits, gradientUnits, SVGUnitTypes::SVGUnitType) 40 DEFINE_ANIMATED_ENUMERATION(SVGGradientElement, SVGNames::gradientUnitsAttr, Gra dientUnits, gradientUnits, SVGUnitTypes::SVGUnitType)
41 DEFINE_ANIMATED_TRANSFORM_LIST(SVGGradientElement, SVGNames::gradientTransformAt tr, GradientTransform, gradientTransform)
42 41
43 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGradientElement) 42 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGradientElement)
44 REGISTER_LOCAL_ANIMATED_PROPERTY(spreadMethod) 43 REGISTER_LOCAL_ANIMATED_PROPERTY(spreadMethod)
45 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientUnits) 44 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientUnits)
46 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientTransform)
47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) 45 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement)
48 END_REGISTER_ANIMATED_PROPERTIES 46 END_REGISTER_ANIMATED_PROPERTIES
49 47
50 SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document& d ocument) 48 SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document& d ocument)
51 : SVGElement(tagName, document) 49 : SVGElement(tagName, document)
52 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr eate())) 50 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr eate()))
51 , m_gradientTransform(SVGAnimatedTransformList::create(this, SVGNames::gradi entTransformAttr, SVGTransformList::create()))
53 , m_spreadMethod(SVGSpreadMethodPad) 52 , m_spreadMethod(SVGSpreadMethodPad)
54 , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) 53 , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
55 { 54 {
56 ScriptWrappable::init(this); 55 ScriptWrappable::init(this);
57 addToPropertyMap(m_href); 56 addToPropertyMap(m_href);
57 addToPropertyMap(m_gradientTransform);
58 registerAnimatedPropertiesForSVGGradientElement(); 58 registerAnimatedPropertiesForSVGGradientElement();
59 } 59 }
60 60
61 bool SVGGradientElement::isSupportedAttribute(const QualifiedName& attrName) 61 bool SVGGradientElement::isSupportedAttribute(const QualifiedName& attrName)
62 { 62 {
63 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ()); 63 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
64 if (supportedAttributes.isEmpty()) { 64 if (supportedAttributes.isEmpty()) {
65 SVGURIReference::addSupportedAttributes(supportedAttributes); 65 SVGURIReference::addSupportedAttributes(supportedAttributes);
66 supportedAttributes.add(SVGNames::gradientUnitsAttr); 66 supportedAttributes.add(SVGNames::gradientUnitsAttr);
67 supportedAttributes.add(SVGNames::gradientTransformAttr); 67 supportedAttributes.add(SVGNames::gradientTransformAttr);
68 supportedAttributes.add(SVGNames::spreadMethodAttr); 68 supportedAttributes.add(SVGNames::spreadMethodAttr);
69 } 69 }
70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); 70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
71 } 71 }
72 72
73 void SVGGradientElement::parseAttribute(const QualifiedName& name, const AtomicS tring& value) 73 void SVGGradientElement::parseAttribute(const QualifiedName& name, const AtomicS tring& value)
74 { 74 {
75 if (!isSupportedAttribute(name)) { 75 if (!isSupportedAttribute(name)) {
76 SVGElement::parseAttribute(name, value); 76 SVGElement::parseAttribute(name, value);
77 return; 77 return;
78 } 78 }
79 79
80 if (name == SVGNames::gradientUnitsAttr) { 80 if (name == SVGNames::gradientUnitsAttr) {
81 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes ::SVGUnitType>::fromString(value); 81 SVGUnitTypes::SVGUnitType propertyValue = SVGPropertyTraits<SVGUnitTypes ::SVGUnitType>::fromString(value);
82 if (propertyValue > 0) 82 if (propertyValue > 0)
83 setGradientUnitsBaseValue(propertyValue); 83 setGradientUnitsBaseValue(propertyValue);
84 return; 84 return;
85 } 85 }
86 86
87 if (name == SVGNames::gradientTransformAttr) {
88 SVGTransformList newList;
89 newList.parse(value);
90 detachAnimatedGradientTransformListWrappers(newList.size());
91 setGradientTransformBaseValue(newList);
92 return;
93 }
94
95 if (name == SVGNames::spreadMethodAttr) { 87 if (name == SVGNames::spreadMethodAttr) {
96 SVGSpreadMethodType propertyValue = SVGPropertyTraits<SVGSpreadMethodTyp e>::fromString(value); 88 SVGSpreadMethodType propertyValue = SVGPropertyTraits<SVGSpreadMethodTyp e>::fromString(value);
97 if (propertyValue > 0) 89 if (propertyValue > 0)
98 setSpreadMethodBaseValue(propertyValue); 90 setSpreadMethodBaseValue(propertyValue);
99 return; 91 return;
100 } 92 }
101 93
102 SVGParsingError parseError = NoError; 94 SVGParsingError parseError = NoError;
103 95
104 if (name.matches(XLinkNames::hrefAttr)) 96 if (name.matches(XLinkNames::hrefAttr))
105 m_href->setBaseValueAsString(value, parseError); 97 m_href->setBaseValueAsString(value, parseError);
98 else if (name == SVGNames::gradientTransformAttr)
99 m_gradientTransform->setBaseValueAsString(value, parseError);
106 else 100 else
107 ASSERT_NOT_REACHED(); 101 ASSERT_NOT_REACHED();
108 102
109 reportAttributeParsingError(parseError, name, value); 103 reportAttributeParsingError(parseError, name, value);
110 } 104 }
111 105
112 void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName) 106 void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName)
113 { 107 {
114 if (!isSupportedAttribute(attrName)) { 108 if (!isSupportedAttribute(attrName)) {
115 SVGElement::svgAttributeChanged(attrName); 109 SVGElement::svgAttributeChanged(attrName);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 float r, g, b, a; 151 float r, g, b, a;
158 color.getRGBA(r, g, b, a); 152 color.getRGBA(r, g, b, a);
159 153
160 stops.append(Gradient::ColorStop(offset, r, g, b, a)); 154 stops.append(Gradient::ColorStop(offset, r, g, b, a));
161 } 155 }
162 156
163 return stops; 157 return stops;
164 } 158 }
165 159
166 } 160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698