| OLD | NEW |
| 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 25 matching lines...) Expand all Loading... |
| 36 { | 36 { |
| 37 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); | 37 DEFINE_STATIC_LOCAL(SVGEnumerationStringEntries, entries, ()); |
| 38 if (entries.isEmpty()) { | 38 if (entries.isEmpty()) { |
| 39 entries.append(std::make_pair(EDGEMODE_DUPLICATE, "duplicate")); | 39 entries.append(std::make_pair(EDGEMODE_DUPLICATE, "duplicate")); |
| 40 entries.append(std::make_pair(EDGEMODE_WRAP, "wrap")); | 40 entries.append(std::make_pair(EDGEMODE_WRAP, "wrap")); |
| 41 entries.append(std::make_pair(EDGEMODE_NONE, "none")); | 41 entries.append(std::make_pair(EDGEMODE_NONE, "none")); |
| 42 } | 42 } |
| 43 return entries; | 43 return entries; |
| 44 } | 44 } |
| 45 | 45 |
| 46 class SVGAnimatedOrder : public SVGAnimatedIntegerOptionalInteger { |
| 47 public: |
| 48 static PassRefPtr<SVGAnimatedOrder> create(SVGElement* contextElement) |
| 49 { |
| 50 return adoptRef(new SVGAnimatedOrder(contextElement)); |
| 51 } |
| 52 |
| 53 void setBaseValueAsString(const String&, SVGParsingError&) override; |
| 54 |
| 55 protected: |
| 56 SVGAnimatedOrder(SVGElement* contextElement) |
| 57 : SVGAnimatedIntegerOptionalInteger(contextElement, SVGNames::orderAttr,
0, 0) |
| 58 { |
| 59 } |
| 60 }; |
| 61 |
| 62 void SVGAnimatedOrder::setBaseValueAsString(const String& value, SVGParsingError
& parseError) |
| 63 { |
| 64 SVGAnimatedIntegerOptionalInteger::setBaseValueAsString(value, parseError); |
| 65 |
| 66 ASSERT(contextElement()); |
| 67 if (parseError == NoError && (firstInteger()->baseValue()->value() < 1 || se
condInteger()->baseValue()->value() < 1)) { |
| 68 contextElement()->document().accessSVGExtensions().reportWarning( |
| 69 "feConvolveMatrix: problem parsing order=\"" + value |
| 70 + "\". Filtered element will not be displayed."); |
| 71 } |
| 72 } |
| 73 |
| 46 inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(Document& document
) | 74 inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(Document& document
) |
| 47 : SVGFilterPrimitiveStandardAttributes(SVGNames::feConvolveMatrixTag, docume
nt) | 75 : SVGFilterPrimitiveStandardAttributes(SVGNames::feConvolveMatrixTag, docume
nt) |
| 48 , m_bias(SVGAnimatedNumber::create(this, SVGNames::biasAttr, SVGNumber::crea
te())) | 76 , m_bias(SVGAnimatedNumber::create(this, SVGNames::biasAttr, SVGNumber::crea
te())) |
| 49 , m_divisor(SVGAnimatedNumber::create(this, SVGNames::divisorAttr, SVGNumber
::create())) | 77 , m_divisor(SVGAnimatedNumber::create(this, SVGNames::divisorAttr, SVGNumber
::create())) |
| 50 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) | 78 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
| 51 , m_edgeMode(SVGAnimatedEnumeration<EdgeModeType>::create(this, SVGNames::ed
geModeAttr, EDGEMODE_DUPLICATE)) | 79 , m_edgeMode(SVGAnimatedEnumeration<EdgeModeType>::create(this, SVGNames::ed
geModeAttr, EDGEMODE_DUPLICATE)) |
| 52 , m_kernelMatrix(SVGAnimatedNumberList::create(this, SVGNames::kernelMatrixA
ttr, SVGNumberList::create())) | 80 , m_kernelMatrix(SVGAnimatedNumberList::create(this, SVGNames::kernelMatrixA
ttr, SVGNumberList::create())) |
| 53 , m_kernelUnitLength(SVGAnimatedNumberOptionalNumber::create(this, SVGNames:
:kernelUnitLengthAttr)) | 81 , m_kernelUnitLength(SVGAnimatedNumberOptionalNumber::create(this, SVGNames:
:kernelUnitLengthAttr)) |
| 54 , m_order(SVGAnimatedIntegerOptionalInteger::create(this, SVGNames::orderAtt
r)) | 82 , m_order(SVGAnimatedOrder::create(this)) |
| 55 , m_preserveAlpha(SVGAnimatedBoolean::create(this, SVGNames::preserveAlphaAt
tr, SVGBoolean::create())) | 83 , m_preserveAlpha(SVGAnimatedBoolean::create(this, SVGNames::preserveAlphaAt
tr, SVGBoolean::create())) |
| 56 , m_targetX(SVGAnimatedInteger::create(this, SVGNames::targetXAttr, SVGInteg
er::create())) | 84 , m_targetX(SVGAnimatedInteger::create(this, SVGNames::targetXAttr, SVGInteg
er::create())) |
| 57 , m_targetY(SVGAnimatedInteger::create(this, SVGNames::targetYAttr, SVGInteg
er::create())) | 85 , m_targetY(SVGAnimatedInteger::create(this, SVGNames::targetYAttr, SVGInteg
er::create())) |
| 58 { | 86 { |
| 59 addToPropertyMap(m_preserveAlpha); | 87 addToPropertyMap(m_preserveAlpha); |
| 60 addToPropertyMap(m_divisor); | 88 addToPropertyMap(m_divisor); |
| 61 addToPropertyMap(m_bias); | 89 addToPropertyMap(m_bias); |
| 62 addToPropertyMap(m_kernelUnitLength); | 90 addToPropertyMap(m_kernelUnitLength); |
| 63 addToPropertyMap(m_kernelMatrix); | 91 addToPropertyMap(m_kernelMatrix); |
| 64 addToPropertyMap(m_in1); | 92 addToPropertyMap(m_in1); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 83 supportedAttributes.add(SVGNames::targetXAttr); | 111 supportedAttributes.add(SVGNames::targetXAttr); |
| 84 supportedAttributes.add(SVGNames::targetYAttr); | 112 supportedAttributes.add(SVGNames::targetYAttr); |
| 85 supportedAttributes.add(SVGNames::kernelUnitLengthAttr); | 113 supportedAttributes.add(SVGNames::kernelUnitLengthAttr); |
| 86 supportedAttributes.add(SVGNames::preserveAlphaAttr); | 114 supportedAttributes.add(SVGNames::preserveAlphaAttr); |
| 87 } | 115 } |
| 88 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 116 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
| 89 } | 117 } |
| 90 | 118 |
| 91 void SVGFEConvolveMatrixElement::parseAttribute(const QualifiedName& name, const
AtomicString& value) | 119 void SVGFEConvolveMatrixElement::parseAttribute(const QualifiedName& name, const
AtomicString& value) |
| 92 { | 120 { |
| 93 if (!isSupportedAttribute(name)) { | 121 parseAttributeNew(name, value); |
| 94 SVGFilterPrimitiveStandardAttributes::parseAttribute(name, value); | |
| 95 return; | |
| 96 } | |
| 97 | |
| 98 SVGParsingError parseError = NoError; | |
| 99 | |
| 100 if (name == SVGNames::inAttr) | |
| 101 m_in1->setBaseValueAsString(value, parseError); | |
| 102 else if (name == SVGNames::divisorAttr) | |
| 103 m_divisor->setBaseValueAsString(value, parseError); | |
| 104 else if (name == SVGNames::biasAttr) | |
| 105 m_bias->setBaseValueAsString(value, parseError); | |
| 106 else if (name == SVGNames::kernelUnitLengthAttr) | |
| 107 m_kernelUnitLength->setBaseValueAsString(value, parseError); | |
| 108 else if (name == SVGNames::kernelMatrixAttr) | |
| 109 m_kernelMatrix->setBaseValueAsString(value, parseError); | |
| 110 else if (name == SVGNames::preserveAlphaAttr) | |
| 111 m_preserveAlpha->setBaseValueAsString(value, parseError); | |
| 112 else if (name == SVGNames::edgeModeAttr) | |
| 113 m_edgeMode->setBaseValueAsString(value, parseError); | |
| 114 else if (name == SVGNames::targetXAttr) | |
| 115 m_targetX->setBaseValueAsString(value, parseError); | |
| 116 else if (name == SVGNames::targetYAttr) | |
| 117 m_targetY->setBaseValueAsString(value, parseError); | |
| 118 else if (name == SVGNames::orderAttr) { | |
| 119 m_order->setBaseValueAsString(value, parseError); | |
| 120 if (parseError == NoError && (orderX()->baseValue()->value() < 1 || orde
rY()->baseValue()->value() < 1)) { | |
| 121 document().accessSVGExtensions().reportWarning( | |
| 122 "feConvolveMatrix: problem parsing order=\"" + value | |
| 123 + "\". Filtered element will not be displayed."); | |
| 124 } | |
| 125 } else | |
| 126 ASSERT_NOT_REACHED(); | |
| 127 | |
| 128 reportAttributeParsingError(parseError, name, value); | |
| 129 } | 122 } |
| 130 | 123 |
| 131 bool SVGFEConvolveMatrixElement::setFilterEffectAttribute(FilterEffect* effect,
const QualifiedName& attrName) | 124 bool SVGFEConvolveMatrixElement::setFilterEffectAttribute(FilterEffect* effect,
const QualifiedName& attrName) |
| 132 { | 125 { |
| 133 FEConvolveMatrix* convolveMatrix = static_cast<FEConvolveMatrix*>(effect); | 126 FEConvolveMatrix* convolveMatrix = static_cast<FEConvolveMatrix*>(effect); |
| 134 if (attrName == SVGNames::edgeModeAttr) | 127 if (attrName == SVGNames::edgeModeAttr) |
| 135 return convolveMatrix->setEdgeMode(m_edgeMode->currentValue()->enumValue
()); | 128 return convolveMatrix->setEdgeMode(m_edgeMode->currentValue()->enumValue
()); |
| 136 if (attrName == SVGNames::divisorAttr) | 129 if (attrName == SVGNames::divisorAttr) |
| 137 return convolveMatrix->setDivisor(m_divisor->currentValue()->value()); | 130 return convolveMatrix->setDivisor(m_divisor->currentValue()->value()); |
| 138 if (attrName == SVGNames::biasAttr) | 131 if (attrName == SVGNames::biasAttr) |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 231 |
| 239 RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, | 232 RefPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, |
| 240 IntSize(orderXValue, orderYValue), divisorValue, | 233 IntSize(orderXValue, orderYValue), divisorValue, |
| 241 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), m_edgeMode->currentValue()->enumValue(), | 234 m_bias->currentValue()->value(), IntPoint(targetXValue, targ
etYValue), m_edgeMode->currentValue()->enumValue(), |
| 242 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); | 235 FloatPoint(kernelUnitLengthXValue, kernelUnitLengthYValue),
m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()->toFloa
tVector()); |
| 243 effect->inputEffects().append(input1); | 236 effect->inputEffects().append(input1); |
| 244 return effect.release(); | 237 return effect.release(); |
| 245 } | 238 } |
| 246 | 239 |
| 247 } // namespace blink | 240 } // namespace blink |
| OLD | NEW |