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

Side by Side Diff: Source/core/svg/SVGFECompositeElement.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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 visitor->trace(m_k3); 74 visitor->trace(m_k3);
75 visitor->trace(m_k4); 75 visitor->trace(m_k4);
76 visitor->trace(m_in1); 76 visitor->trace(m_in1);
77 visitor->trace(m_in2); 77 visitor->trace(m_in2);
78 visitor->trace(m_svgOperator); 78 visitor->trace(m_svgOperator);
79 SVGFilterPrimitiveStandardAttributes::trace(visitor); 79 SVGFilterPrimitiveStandardAttributes::trace(visitor);
80 } 80 }
81 81
82 DEFINE_NODE_FACTORY(SVGFECompositeElement) 82 DEFINE_NODE_FACTORY(SVGFECompositeElement)
83 83
84 bool SVGFECompositeElement::isSupportedAttribute(const QualifiedName& attrName)
85 {
86 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
87 if (supportedAttributes.isEmpty()) {
88 supportedAttributes.add(SVGNames::inAttr);
89 supportedAttributes.add(SVGNames::in2Attr);
90 supportedAttributes.add(SVGNames::operatorAttr);
91 supportedAttributes.add(SVGNames::k1Attr);
92 supportedAttributes.add(SVGNames::k2Attr);
93 supportedAttributes.add(SVGNames::k3Attr);
94 supportedAttributes.add(SVGNames::k4Attr);
95 }
96 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
97 }
98
99 bool SVGFECompositeElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName) 84 bool SVGFECompositeElement::setFilterEffectAttribute(FilterEffect* effect, const QualifiedName& attrName)
100 { 85 {
101 FEComposite* composite = static_cast<FEComposite*>(effect); 86 FEComposite* composite = static_cast<FEComposite*>(effect);
102 if (attrName == SVGNames::operatorAttr) 87 if (attrName == SVGNames::operatorAttr)
103 return composite->setOperation(m_svgOperator->currentValue()->enumValue( )); 88 return composite->setOperation(m_svgOperator->currentValue()->enumValue( ));
104 if (attrName == SVGNames::k1Attr) 89 if (attrName == SVGNames::k1Attr)
105 return composite->setK1(m_k1->currentValue()->value()); 90 return composite->setK1(m_k1->currentValue()->value());
106 if (attrName == SVGNames::k2Attr) 91 if (attrName == SVGNames::k2Attr)
107 return composite->setK2(m_k2->currentValue()->value()); 92 return composite->setK2(m_k2->currentValue()->value());
108 if (attrName == SVGNames::k3Attr) 93 if (attrName == SVGNames::k3Attr)
109 return composite->setK3(m_k3->currentValue()->value()); 94 return composite->setK3(m_k3->currentValue()->value());
110 if (attrName == SVGNames::k4Attr) 95 if (attrName == SVGNames::k4Attr)
111 return composite->setK4(m_k4->currentValue()->value()); 96 return composite->setK4(m_k4->currentValue()->value());
112 97
113 ASSERT_NOT_REACHED(); 98 ASSERT_NOT_REACHED();
114 return false; 99 return false;
115 } 100 }
116 101
117 102
118 void SVGFECompositeElement::svgAttributeChanged(const QualifiedName& attrName) 103 void SVGFECompositeElement::svgAttributeChanged(const QualifiedName& attrName)
119 { 104 {
120 if (!isSupportedAttribute(attrName)) {
121 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
122 return;
123 }
124
125 SVGElement::InvalidationGuard invalidationGuard(this);
126
127 if (attrName == SVGNames::operatorAttr 105 if (attrName == SVGNames::operatorAttr
128 || attrName == SVGNames::k1Attr 106 || attrName == SVGNames::k1Attr
129 || attrName == SVGNames::k2Attr 107 || attrName == SVGNames::k2Attr
130 || attrName == SVGNames::k3Attr 108 || attrName == SVGNames::k3Attr
131 || attrName == SVGNames::k4Attr) { 109 || attrName == SVGNames::k4Attr) {
110 SVGElement::InvalidationGuard invalidationGuard(this);
132 primitiveAttributeChanged(attrName); 111 primitiveAttributeChanged(attrName);
133 return; 112 return;
134 } 113 }
135 114
136 if (attrName == SVGNames::inAttr || attrName == SVGNames::in2Attr) { 115 if (attrName == SVGNames::inAttr || attrName == SVGNames::in2Attr) {
116 SVGElement::InvalidationGuard invalidationGuard(this);
137 invalidate(); 117 invalidate();
138 return; 118 return;
139 } 119 }
140 120
141 ASSERT_NOT_REACHED(); 121 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
142 } 122 }
143 123
144 PassRefPtrWillBeRawPtr<FilterEffect> SVGFECompositeElement::build(SVGFilterBuild er* filterBuilder, Filter* filter) 124 PassRefPtrWillBeRawPtr<FilterEffect> SVGFECompositeElement::build(SVGFilterBuild er* filterBuilder, Filter* filter)
145 { 125 {
146 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr entValue()->value())); 126 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr entValue()->value()));
147 FilterEffect* input2 = filterBuilder->getEffectById(AtomicString(m_in2->curr entValue()->value())); 127 FilterEffect* input2 = filterBuilder->getEffectById(AtomicString(m_in2->curr entValue()->value()));
148 128
149 if (!input1 || !input2) 129 if (!input1 || !input2)
150 return nullptr; 130 return nullptr;
151 131
152 RefPtrWillBeRawPtr<FilterEffect> effect = FEComposite::create(filter, m_svgO perator->currentValue()->enumValue(), m_k1->currentValue()->value(), m_k2->curre ntValue()->value(), m_k3->currentValue()->value(), m_k4->currentValue()->value() ); 132 RefPtrWillBeRawPtr<FilterEffect> effect = FEComposite::create(filter, m_svgO perator->currentValue()->enumValue(), m_k1->currentValue()->value(), m_k2->curre ntValue()->value(), m_k3->currentValue()->value(), m_k4->currentValue()->value() );
153 FilterEffectVector& inputEffects = effect->inputEffects(); 133 FilterEffectVector& inputEffects = effect->inputEffects();
154 inputEffects.reserveCapacity(2); 134 inputEffects.reserveCapacity(2);
155 inputEffects.append(input1); 135 inputEffects.append(input1);
156 inputEffects.append(input2); 136 inputEffects.append(input2);
157 return effect.release(); 137 return effect.release();
158 } 138 }
159 139
160 } // namespace blink 140 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698