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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
18 */ | 18 */ |
19 | 19 |
20 #include "core/svg/SVGFEConvolveMatrixElement.h" | 20 #include "core/svg/SVGFEConvolveMatrixElement.h" |
21 | 21 |
22 #include "core/SVGNames.h" | 22 #include "core/SVGNames.h" |
23 #include "core/dom/Document.h" | 23 #include "core/dom/Document.h" |
24 #include "core/svg/SVGDocumentExtensions.h" | |
25 #include "core/svg/SVGParserUtilities.h" | |
26 #include "core/svg/graphics/filters/SVGFilterBuilder.h" | 24 #include "core/svg/graphics/filters/SVGFilterBuilder.h" |
27 #include "platform/geometry/FloatPoint.h" | 25 #include "platform/geometry/FloatPoint.h" |
28 #include "platform/geometry/IntPoint.h" | 26 #include "platform/geometry/IntPoint.h" |
29 #include "platform/geometry/IntSize.h" | 27 #include "platform/geometry/IntSize.h" |
30 #include "platform/graphics/filters/FilterEffect.h" | 28 #include "platform/graphics/filters/FilterEffect.h" |
31 | 29 |
32 namespace blink { | 30 namespace blink { |
33 | 31 |
34 template<> const SVGEnumerationStringEntries& getStaticStringEntries<EdgeModeTyp
e>() | 32 template<> const SVGEnumerationStringEntries& getStaticStringEntries<EdgeModeTyp
e>() |
35 { | 33 { |
(...skipping 13 matching lines...) Expand all Loading... |
49 return adoptRefWillBeNoop(new SVGAnimatedOrder(contextElement)); | 47 return adoptRefWillBeNoop(new SVGAnimatedOrder(contextElement)); |
50 } | 48 } |
51 | 49 |
52 SVGParsingError setBaseValueAsString(const String&) override; | 50 SVGParsingError setBaseValueAsString(const String&) override; |
53 | 51 |
54 protected: | 52 protected: |
55 SVGAnimatedOrder(SVGElement* contextElement) | 53 SVGAnimatedOrder(SVGElement* contextElement) |
56 : SVGAnimatedIntegerOptionalInteger(contextElement, SVGNames::orderAttr,
0, 0) | 54 : SVGAnimatedIntegerOptionalInteger(contextElement, SVGNames::orderAttr,
0, 0) |
57 { | 55 { |
58 } | 56 } |
| 57 |
| 58 static SVGParsingError checkValue(SVGParsingError parseStatus, int value) |
| 59 { |
| 60 if (parseStatus != SVGParseStatus::NoError) |
| 61 return parseStatus; |
| 62 if (value < 0) |
| 63 return SVGParseStatus::NegativeValue; |
| 64 if (value == 0) |
| 65 return SVGParseStatus::ZeroValue; |
| 66 return SVGParseStatus::NoError; |
| 67 } |
59 }; | 68 }; |
60 | 69 |
61 SVGParsingError SVGAnimatedOrder::setBaseValueAsString(const String& value) | 70 SVGParsingError SVGAnimatedOrder::setBaseValueAsString(const String& value) |
62 { | 71 { |
63 SVGParsingError parseStatus = SVGAnimatedIntegerOptionalInteger::setBaseValu
eAsString(value); | 72 SVGParsingError parseStatus = SVGAnimatedIntegerOptionalInteger::setBaseValu
eAsString(value); |
64 | 73 // Check for semantic errors. |
65 ASSERT(contextElement()); | 74 parseStatus = checkValue(parseStatus, firstInteger()->baseValue()->value()); |
66 if (parseStatus == SVGParseStatus::NoError && (firstInteger()->baseValue()->
value() < 1 || secondInteger()->baseValue()->value() < 1)) { | 75 parseStatus = checkValue(parseStatus, secondInteger()->baseValue()->value())
; |
67 contextElement()->document().accessSVGExtensions().reportWarning( | |
68 "feConvolveMatrix: problem parsing order=\"" + value + "\"."); | |
69 } | |
70 return parseStatus; | 76 return parseStatus; |
71 } | 77 } |
72 | 78 |
73 inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(Document& document
) | 79 inline SVGFEConvolveMatrixElement::SVGFEConvolveMatrixElement(Document& document
) |
74 : SVGFilterPrimitiveStandardAttributes(SVGNames::feConvolveMatrixTag, docume
nt) | 80 : SVGFilterPrimitiveStandardAttributes(SVGNames::feConvolveMatrixTag, docume
nt) |
75 , m_bias(SVGAnimatedNumber::create(this, SVGNames::biasAttr, SVGNumber::crea
te())) | 81 , m_bias(SVGAnimatedNumber::create(this, SVGNames::biasAttr, SVGNumber::crea
te())) |
76 , m_divisor(SVGAnimatedNumber::create(this, SVGNames::divisorAttr, SVGNumber
::create())) | 82 , m_divisor(SVGAnimatedNumber::create(this, SVGNames::divisorAttr, SVGNumber
::create())) |
77 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) | 83 , m_in1(SVGAnimatedString::create(this, SVGNames::inAttr, SVGString::create(
))) |
78 , m_edgeMode(SVGAnimatedEnumeration<EdgeModeType>::create(this, SVGNames::ed
geModeAttr, EDGEMODE_DUPLICATE)) | 84 , m_edgeMode(SVGAnimatedEnumeration<EdgeModeType>::create(this, SVGNames::ed
geModeAttr, EDGEMODE_DUPLICATE)) |
79 , m_kernelMatrix(SVGAnimatedNumberList::create(this, SVGNames::kernelMatrixA
ttr, SVGNumberList::create())) | 85 , m_kernelMatrix(SVGAnimatedNumberList::create(this, SVGNames::kernelMatrixA
ttr, SVGNumberList::create())) |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 196 |
191 RefPtrWillBeRawPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, | 197 RefPtrWillBeRawPtr<FilterEffect> effect = FEConvolveMatrix::create(filter, |
192 IntSize(orderXValue, orderYValue), divisorValue, | 198 IntSize(orderXValue, orderYValue), divisorValue, |
193 m_bias->currentValue()->value(), IntPoint(targetXValue, targetYValue), m
_edgeMode->currentValue()->enumValue(), | 199 m_bias->currentValue()->value(), IntPoint(targetXValue, targetYValue), m
_edgeMode->currentValue()->enumValue(), |
194 m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()
->toFloatVector()); | 200 m_preserveAlpha->currentValue()->value(), m_kernelMatrix->currentValue()
->toFloatVector()); |
195 effect->inputEffects().append(input1); | 201 effect->inputEffects().append(input1); |
196 return effect.release(); | 202 return effect.release(); |
197 } | 203 } |
198 | 204 |
199 } // namespace blink | 205 } // namespace blink |
OLD | NEW |