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

Side by Side Diff: Source/core/svg/SVGFEMorphologyElement.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) 2009 Dirk Schulze <krit@webkit.org> 2 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org>
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 DEFINE_TRACE(SVGFEMorphologyElement) 52 DEFINE_TRACE(SVGFEMorphologyElement)
53 { 53 {
54 visitor->trace(m_radius); 54 visitor->trace(m_radius);
55 visitor->trace(m_in1); 55 visitor->trace(m_in1);
56 visitor->trace(m_svgOperator); 56 visitor->trace(m_svgOperator);
57 SVGFilterPrimitiveStandardAttributes::trace(visitor); 57 SVGFilterPrimitiveStandardAttributes::trace(visitor);
58 } 58 }
59 59
60 DEFINE_NODE_FACTORY(SVGFEMorphologyElement) 60 DEFINE_NODE_FACTORY(SVGFEMorphologyElement)
61 61
62 bool SVGFEMorphologyElement::isSupportedAttribute(const QualifiedName& attrName)
63 {
64 DEFINE_STATIC_LOCAL(HashSet<QualifiedName>, supportedAttributes, ());
65 if (supportedAttributes.isEmpty()) {
66 supportedAttributes.add(SVGNames::inAttr);
67 supportedAttributes.add(SVGNames::operatorAttr);
68 supportedAttributes.add(SVGNames::radiusAttr);
69 }
70 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName);
71 }
72
73 bool SVGFEMorphologyElement::setFilterEffectAttribute(FilterEffect* effect, cons t QualifiedName& attrName) 62 bool SVGFEMorphologyElement::setFilterEffectAttribute(FilterEffect* effect, cons t QualifiedName& attrName)
74 { 63 {
75 FEMorphology* morphology = static_cast<FEMorphology*>(effect); 64 FEMorphology* morphology = static_cast<FEMorphology*>(effect);
76 if (attrName == SVGNames::operatorAttr) 65 if (attrName == SVGNames::operatorAttr)
77 return morphology->setMorphologyOperator(m_svgOperator->currentValue()-> enumValue()); 66 return morphology->setMorphologyOperator(m_svgOperator->currentValue()-> enumValue());
78 if (attrName == SVGNames::radiusAttr) { 67 if (attrName == SVGNames::radiusAttr) {
79 // Both setRadius functions should be evaluated separately. 68 // Both setRadius functions should be evaluated separately.
80 bool isRadiusXChanged = morphology->setRadiusX(radiusX()->currentValue() ->value()); 69 bool isRadiusXChanged = morphology->setRadiusX(radiusX()->currentValue() ->value());
81 bool isRadiusYChanged = morphology->setRadiusY(radiusY()->currentValue() ->value()); 70 bool isRadiusYChanged = morphology->setRadiusY(radiusY()->currentValue() ->value());
82 return isRadiusXChanged || isRadiusYChanged; 71 return isRadiusXChanged || isRadiusYChanged;
83 } 72 }
84 73
85 ASSERT_NOT_REACHED(); 74 ASSERT_NOT_REACHED();
86 return false; 75 return false;
87 } 76 }
88 77
89 void SVGFEMorphologyElement::svgAttributeChanged(const QualifiedName& attrName) 78 void SVGFEMorphologyElement::svgAttributeChanged(const QualifiedName& attrName)
90 { 79 {
91 if (!isSupportedAttribute(attrName)) {
92 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
93 return;
94 }
95
96 SVGElement::InvalidationGuard invalidationGuard(this);
97
98 if (attrName == SVGNames::operatorAttr || attrName == SVGNames::radiusAttr) { 80 if (attrName == SVGNames::operatorAttr || attrName == SVGNames::radiusAttr) {
81 SVGElement::InvalidationGuard invalidationGuard(this);
99 primitiveAttributeChanged(attrName); 82 primitiveAttributeChanged(attrName);
100 return; 83 return;
101 } 84 }
102 85
103 if (attrName == SVGNames::inAttr) { 86 if (attrName == SVGNames::inAttr) {
87 SVGElement::InvalidationGuard invalidationGuard(this);
104 invalidate(); 88 invalidate();
105 return; 89 return;
106 } 90 }
107 91
108 ASSERT_NOT_REACHED(); 92 SVGFilterPrimitiveStandardAttributes::svgAttributeChanged(attrName);
109 } 93 }
110 94
111 PassRefPtrWillBeRawPtr<FilterEffect> SVGFEMorphologyElement::build(SVGFilterBuil der* filterBuilder, Filter* filter) 95 PassRefPtrWillBeRawPtr<FilterEffect> SVGFEMorphologyElement::build(SVGFilterBuil der* filterBuilder, Filter* filter)
112 { 96 {
113 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr entValue()->value())); 97 FilterEffect* input1 = filterBuilder->getEffectById(AtomicString(m_in1->curr entValue()->value()));
114 float xRadius = radiusX()->currentValue()->value(); 98 float xRadius = radiusX()->currentValue()->value();
115 float yRadius = radiusY()->currentValue()->value(); 99 float yRadius = radiusY()->currentValue()->value();
116 100
117 if (!input1) 101 if (!input1)
118 return nullptr; 102 return nullptr;
119 103
120 if (xRadius < 0 || yRadius < 0) 104 if (xRadius < 0 || yRadius < 0)
121 return nullptr; 105 return nullptr;
122 106
123 RefPtrWillBeRawPtr<FilterEffect> effect = FEMorphology::create(filter, m_svg Operator->currentValue()->enumValue(), xRadius, yRadius); 107 RefPtrWillBeRawPtr<FilterEffect> effect = FEMorphology::create(filter, m_svg Operator->currentValue()->enumValue(), xRadius, yRadius);
124 effect->inputEffects().append(input1); 108 effect->inputEffects().append(input1);
125 return effect.release(); 109 return effect.release();
126 } 110 }
127 111
128 } // namespace blink 112 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698