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

Side by Side Diff: Source/core/svg/SVGFEDisplacementMapElement.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) 2006 Oliver Hunt <oliver@nerget.com> 2 * Copyright (C) 2006 Oliver Hunt <oliver@nerget.com>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 visitor->trace(m_scale); 59 visitor->trace(m_scale);
60 visitor->trace(m_in1); 60 visitor->trace(m_in1);
61 visitor->trace(m_in2); 61 visitor->trace(m_in2);
62 visitor->trace(m_xChannelSelector); 62 visitor->trace(m_xChannelSelector);
63 visitor->trace(m_yChannelSelector); 63 visitor->trace(m_yChannelSelector);
64 SVGFilterPrimitiveStandardAttributes::trace(visitor); 64 SVGFilterPrimitiveStandardAttributes::trace(visitor);
65 } 65 }
66 66
67 DEFINE_NODE_FACTORY(SVGFEDisplacementMapElement) 67 DEFINE_NODE_FACTORY(SVGFEDisplacementMapElement)
68 68
69 bool SVGFEDisplacementMapElement::isSupportedAttribute(const QualifiedName& attr Name)
70 {
71 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
72 if (supportedAttributes.isEmpty()) {
73 supportedAttributes.add(SVGNames::inAttr);
74 supportedAttributes.add(SVGNames::in2Attr);
75 supportedAttributes.add(SVGNames::xChannelSelectorAttr);
76 supportedAttributes.add(SVGNames::yChannelSelectorAttr);
77 supportedAttributes.add(SVGNames::scaleAttr);
78 }
79 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
80 }
81
82 bool SVGFEDisplacementMapElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName) 69 bool SVGFEDisplacementMapElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName)
83 { 70 {
84 FEDisplacementMap* displacementMap = static_cast<FEDisplacementMap*>(effect) ; 71 FEDisplacementMap* displacementMap = static_cast<FEDisplacementMap*>(effect) ;
85 if (attrName == SVGNames::xChannelSelectorAttr) 72 if (attrName == SVGNames::xChannelSelectorAttr)
86 return displacementMap->setXChannelSelector(m_xChannelSelector->currentV alue()->enumValue()); 73 return displacementMap->setXChannelSelector(m_xChannelSelector->currentV alue()->enumValue());
87 if (attrName == SVGNames::yChannelSelectorAttr) 74 if (attrName == SVGNames::yChannelSelectorAttr)
88 return displacementMap->setYChannelSelector(m_yChannelSelector->currentV alue()->enumValue()); 75 return displacementMap->setYChannelSelector(m_yChannelSelector->currentV alue()->enumValue());
89 if (attrName == SVGNames::scaleAttr) 76 if (attrName == SVGNames::scaleAttr)
90 return displacementMap->setScale(m_scale->currentValue()->value()); 77 return displacementMap->setScale(m_scale->currentValue()->value());
91 78
92 ASSERT_NOT_REACHED(); 79 ASSERT_NOT_REACHED();
93 return false; 80 return false;
94 } 81 }
95 82
96 void SVGFEDisplacementMapElement::svgAttributeChanged(const QualifiedName& attrN ame) 83 void SVGFEDisplacementMapElement::svgAttributeChanged(const QualifiedName& attrN ame)
97 { 84 {
98 if (!isSupportedAttribute(attrName)) {
99 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
100 return;
101 }
102
103 SVGElement::InvalidationGuard invalidationGuard(this);
104
105 if (attrName == SVGNames::xChannelSelectorAttr || attrName == SVGNames::yCha nnelSelectorAttr || attrName == SVGNames::scaleAttr) { 85 if (attrName == SVGNames::xChannelSelectorAttr || attrName == SVGNames::yCha nnelSelectorAttr || attrName == SVGNames::scaleAttr) {
86 SVGElement::InvalidationGuard invalidationGuard(this);
106 primitiveAttributeChanged(attrName); 87 primitiveAttributeChanged(attrName);
107 return; 88 return;
108 } 89 }
109 90
110 if (attrName == SVGNames::inAttr || attrName == SVGNames::in2Attr) { 91 if (attrName == SVGNames::inAttr || attrName == SVGNames::in2Attr) {
92 SVGElement::InvalidationGuard invalidationGuard(this);
111 invalidate(); 93 invalidate();
112 return; 94 return;
113 } 95 }
114 96
115 ASSERT_NOT_REACHED(); 97 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
116 } 98 }
117 99
118 PassRefPtrWillBeRawPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilte rBuilder* filterBuilder, Filter* filter) 100 PassRefPtrWillBeRawPtr<FilterEffect> SVGFEDisplacementMapElement::build(SVGFilte rBuilder* filterBuilder, Filter* filter)
119 { 101 {
120 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr entValue()->value())); 102 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr entValue()->value()));
121 FilterEffect* input2 = filterBuilder->getEffectById(AtomicString(m_in2->curr entValue()->value())); 103 FilterEffect* input2 = filterBuilder->getEffectById(AtomicString(m_in2->curr entValue()->value()));
122 104
123 if (!input1 || !input2) 105 if (!input1 || !input2)
124 return nullptr; 106 return nullptr;
125 107
126 RefPtrWillBeRawPtr<FilterEffect> effect = FEDisplacementMap::create(filter, m_xChannelSelector->currentValue()->enumValue(), m_yChannelSelector->currentValu e()->enumValue(), m_scale->currentValue()->value()); 108 RefPtrWillBeRawPtr<FilterEffect> effect = FEDisplacementMap::create(filter, m_xChannelSelector->currentValue()->enumValue(), m_yChannelSelector->currentValu e()->enumValue(), m_scale->currentValue()->value());
127 FilterEffectVector& inputEffects = effect->inputEffects(); 109 FilterEffectVector& inputEffects = effect->inputEffects();
128 inputEffects.reserveCapacity(2); 110 inputEffects.reserveCapacity(2);
129 inputEffects.append(input1); 111 inputEffects.append(input1);
130 inputEffects.append(input2); 112 inputEffects.append(input2);
131 return effect.release(); 113 return effect.release();
132 } 114 }
133 115
134 } // namespace blink 116 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698