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

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

Issue 148173018: [SVG] SVGAnimatedString{,List} migration to new SVG property impl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: remove debug print 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
« no previous file with comments | « Source/core/svg/SVGGradientElement.h ('k') | Source/core/svg/SVGGraphicsElement.h » ('j') | 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, 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 21 matching lines...) Expand all
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) 41 DEFINE_ANIMATED_TRANSFORM_LIST(SVGGradientElement, SVGNames::gradientTransformAt tr, GradientTransform, gradientTransform)
42 DEFINE_ANIMATED_STRING(SVGGradientElement, XLinkNames::hrefAttr, Href, href)
43 42
44 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGradientElement) 43 BEGIN_REGISTER_ANIMATED_PROPERTIES(SVGGradientElement)
45 REGISTER_LOCAL_ANIMATED_PROPERTY(spreadMethod) 44 REGISTER_LOCAL_ANIMATED_PROPERTY(spreadMethod)
46 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientUnits) 45 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientUnits)
47 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientTransform) 46 REGISTER_LOCAL_ANIMATED_PROPERTY(gradientTransform)
48 REGISTER_LOCAL_ANIMATED_PROPERTY(href)
49 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement) 47 REGISTER_PARENT_ANIMATED_PROPERTIES(SVGElement)
50 END_REGISTER_ANIMATED_PROPERTIES 48 END_REGISTER_ANIMATED_PROPERTIES
51 49
52 SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document& d ocument) 50 SVGGradientElement::SVGGradientElement(const QualifiedName& tagName, Document& d ocument)
53 : SVGElement(tagName, document) 51 : SVGElement(tagName, document)
52 , m_href(SVGAnimatedString::create(this, XLinkNames::hrefAttr, SVGString::cr eate()))
54 , m_spreadMethod(SVGSpreadMethodPad) 53 , m_spreadMethod(SVGSpreadMethodPad)
55 , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) 54 , m_gradientUnits(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX)
56 { 55 {
57 ScriptWrappable::init(this); 56 ScriptWrappable::init(this);
57 addToPropertyMap(m_href);
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);
(...skipping 24 matching lines...) Expand all
92 return; 92 return;
93 } 93 }
94 94
95 if (name == SVGNames::spreadMethodAttr) { 95 if (name == SVGNames::spreadMethodAttr) {
96 SVGSpreadMethodType propertyValue = SVGPropertyTraits<SVGSpreadMethodTyp e>::fromString(value); 96 SVGSpreadMethodType propertyValue = SVGPropertyTraits<SVGSpreadMethodTyp e>::fromString(value);
97 if (propertyValue > 0) 97 if (propertyValue > 0)
98 setSpreadMethodBaseValue(propertyValue); 98 setSpreadMethodBaseValue(propertyValue);
99 return; 99 return;
100 } 100 }
101 101
102 if (SVGURIReference::parseAttribute(name, value)) 102 SVGParsingError parseError = NoError;
103 return;
104 103
105 ASSERT_NOT_REACHED(); 104 if (name.matches(XLinkNames::hrefAttr))
105 m_href->setBaseValueAsString(value, parseError);
106 else
107 ASSERT_NOT_REACHED();
108
109 reportAttributeParsingError(parseError, name, value);
106 } 110 }
107 111
108 void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName) 112 void SVGGradientElement::svgAttributeChanged(const QualifiedName& attrName)
109 { 113 {
110 if (!isSupportedAttribute(attrName)) { 114 if (!isSupportedAttribute(attrName)) {
111 SVGElement::svgAttributeChanged(attrName); 115 SVGElement::svgAttributeChanged(attrName);
112 return; 116 return;
113 } 117 }
114 118
115 SVGElementInstance::InvalidationGuard invalidationGuard(this); 119 SVGElementInstance::InvalidationGuard invalidationGuard(this);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 float r, g, b, a; 157 float r, g, b, a;
154 color.getRGBA(r, g, b, a); 158 color.getRGBA(r, g, b, a);
155 159
156 stops.append(Gradient::ColorStop(offset, r, g, b, a)); 160 stops.append(Gradient::ColorStop(offset, r, g, b, a));
157 } 161 }
158 162
159 return stops; 163 return stops;
160 } 164 }
161 165
162 } 166 }
OLDNEW
« no previous file with comments | « Source/core/svg/SVGGradientElement.h ('k') | Source/core/svg/SVGGraphicsElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698