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

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

Issue 1074813002: Remove isSupportedAttribute in svg (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: invalidation guard tweaks Created 5 years, 8 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, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 visitor->trace(m_baseFrequency); 67 visitor->trace(m_baseFrequency);
68 visitor->trace(m_seed); 68 visitor->trace(m_seed);
69 visitor->trace(m_stitchTiles); 69 visitor->trace(m_stitchTiles);
70 visitor->trace(m_type); 70 visitor->trace(m_type);
71 visitor->trace(m_numOctaves); 71 visitor->trace(m_numOctaves);
72 SVGFilterPrimitiveStandardAttributes::trace(visitor); 72 SVGFilterPrimitiveStandardAttributes::trace(visitor);
73 } 73 }
74 74
75 DEFINE_NODE_FACTORY(SVGFETurbulenceElement) 75 DEFINE_NODE_FACTORY(SVGFETurbulenceElement)
76 76
77 bool SVGFETurbulenceElement::isSupportedAttribute(const QualifiedName& attrName)
78 {
79 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
80 if (supportedAttributes.isEmpty()) {
81 supportedAttributes.add(SVGNames::baseFrequencyAttr);
82 supportedAttributes.add(SVGNames::numOctavesAttr);
83 supportedAttributes.add(SVGNames::seedAttr);
84 supportedAttributes.add(SVGNames::stitchTilesAttr);
85 supportedAttributes.add(SVGNames::typeAttr);
86 }
87 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
88 }
89
90 bool SVGFETurbulenceElement::setFilterEffectAttribute(FilterEffect* effect, cons t QualifiedName& attrName) 77 bool SVGFETurbulenceElement::setFilterEffectAttribute(FilterEffect* effect, cons t QualifiedName& attrName)
91 { 78 {
92 FETurbulence* turbulence = static_cast<FETurbulence*>(effect); 79 FETurbulence* turbulence = static_cast<FETurbulence*>(effect);
93 if (attrName == SVGNames::typeAttr) 80 if (attrName == SVGNames::typeAttr)
94 return turbulence->setType(m_type->currentValue()->enumValue()); 81 return turbulence->setType(m_type->currentValue()->enumValue());
95 if (attrName == SVGNames::stitchTilesAttr) 82 if (attrName == SVGNames::stitchTilesAttr)
96 return turbulence->setStitchTiles(m_stitchTiles->currentValue()->enumVal ue()); 83 return turbulence->setStitchTiles(m_stitchTiles->currentValue()->enumVal ue());
97 if (attrName == SVGNames::baseFrequencyAttr) { 84 if (attrName == SVGNames::baseFrequencyAttr) {
98 bool baseFrequencyXChanged = turbulence->setBaseFrequencyX(baseFrequency X()->currentValue()->value()); 85 bool baseFrequencyXChanged = turbulence->setBaseFrequencyX(baseFrequency X()->currentValue()->value());
99 bool baseFrequencyYChanged = turbulence->setBaseFrequencyY(baseFrequency Y()->currentValue()->value()); 86 bool baseFrequencyYChanged = turbulence->setBaseFrequencyY(baseFrequency Y()->currentValue()->value());
100 return (baseFrequencyXChanged || baseFrequencyYChanged); 87 return (baseFrequencyXChanged || baseFrequencyYChanged);
101 } 88 }
102 if (attrName == SVGNames::seedAttr) 89 if (attrName == SVGNames::seedAttr)
103 return turbulence->setSeed(m_seed->currentValue()->value()); 90 return turbulence->setSeed(m_seed->currentValue()->value());
104 if (attrName == SVGNames::numOctavesAttr) 91 if (attrName == SVGNames::numOctavesAttr)
105 return turbulence->setNumOctaves(m_numOctaves->currentValue()->value()); 92 return turbulence->setNumOctaves(m_numOctaves->currentValue()->value());
106 93
107 ASSERT_NOT_REACHED(); 94 ASSERT_NOT_REACHED();
108 return false; 95 return false;
109 } 96 }
110 97
111 void SVGFETurbulenceElement::svgAttributeChanged(const QualifiedName& attrName) 98 void SVGFETurbulenceElement::svgAttributeChanged(const QualifiedName& attrName)
112 { 99 {
113 if (!isSupportedAttribute(attrName)) {
114 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
115 return;
116 }
117
118 SVGElement::InvalidationGuard invalidationGuard(this);
119
120 if (attrName == SVGNames::baseFrequencyAttr 100 if (attrName == SVGNames::baseFrequencyAttr
121 || attrName == SVGNames::numOctavesAttr 101 || attrName == SVGNames::numOctavesAttr
122 || attrName == SVGNames::seedAttr 102 || attrName == SVGNames::seedAttr
123 || attrName == SVGNames::stitchTilesAttr 103 || attrName == SVGNames::stitchTilesAttr
124 || attrName == SVGNames::typeAttr) { 104 || attrName == SVGNames::typeAttr) {
105 SVGElement::InvalidationGuard invalidationGuard(this);
125 primitiveAttributeChanged(attrName); 106 primitiveAttributeChanged(attrName);
126 return; 107 return;
127 } 108 }
128 109
129 ASSERT_NOT_REACHED(); 110 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
130 } 111 }
131 112
132 PassRefPtrWillBeRawPtr<FilterEffect> SVGFETurbulenceElement::build(SVGFilterBuil der*, Filter* filter) 113 PassRefPtrWillBeRawPtr<FilterEffect> SVGFETurbulenceElement::build(SVGFilterBuil der*, Filter* filter)
133 { 114 {
134 if (baseFrequencyX()->currentValue()->value() < 0 || baseFrequencyY()->curre ntValue()->value() < 0) 115 if (baseFrequencyX()->currentValue()->value() < 0 || baseFrequencyY()->curre ntValue()->value() < 0)
135 return nullptr; 116 return nullptr;
136 return FETurbulence::create(filter, m_type->currentValue()->enumValue(), bas eFrequencyX()->currentValue()->value(), baseFrequencyY()->currentValue()->value( ), m_numOctaves->currentValue()->value(), m_seed->currentValue()->value(), m_sti tchTiles->currentValue()->enumValue() == SVG_STITCHTYPE_STITCH); 117 return FETurbulence::create(filter, m_type->currentValue()->enumValue(), bas eFrequencyX()->currentValue()->value(), baseFrequencyY()->currentValue()->value( ), m_numOctaves->currentValue()->value(), m_seed->currentValue()->value(), m_sti tchTiles->currentValue()->enumValue() == SVG_STITCHTYPE_STITCH);
137 } 118 }
138 119
139 } // namespace blink 120 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698