Index: third_party/WebKit/Source/core/animation/SVGInterpolationTypesMap.cpp |
diff --git a/third_party/WebKit/Source/core/animation/SVGInterpolationTypesMap.cpp b/third_party/WebKit/Source/core/animation/SVGInterpolationTypesMap.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1aca982f15550eac57e5883b88d9356df61b75e9 |
--- /dev/null |
+++ b/third_party/WebKit/Source/core/animation/SVGInterpolationTypesMap.cpp |
@@ -0,0 +1,166 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "core/animation/SVGInterpolationTypesMap.h" |
+ |
+#include "core/HTMLNames.h" |
+#include "core/animation/SVGAngleInterpolationType.h" |
+#include "core/animation/SVGIntegerInterpolationType.h" |
+#include "core/animation/SVGIntegerOptionalIntegerInterpolationType.h" |
+#include "core/animation/SVGLengthInterpolationType.h" |
+#include "core/animation/SVGLengthListInterpolationType.h" |
+#include "core/animation/SVGNumberInterpolationType.h" |
+#include "core/animation/SVGNumberListInterpolationType.h" |
+#include "core/animation/SVGNumberOptionalNumberInterpolationType.h" |
+#include "core/animation/SVGPathInterpolationType.h" |
+#include "core/animation/SVGPointListInterpolationType.h" |
+#include "core/animation/SVGRectInterpolationType.h" |
+#include "core/animation/SVGTransformListInterpolationType.h" |
+#include "core/animation/SVGValueInterpolationType.h" |
+#include "core/css/CSSPropertyMetadata.h" |
+#include "wtf/PtrUtil.h" |
+#include <memory> |
+ |
+namespace blink { |
+ |
+const InterpolationTypes& SVGInterpolationTypesMap::get( |
+ const PropertyHandle& property) const { |
+ using ApplicableTypesMap = |
+ HashMap<PropertyHandle, std::unique_ptr<const InterpolationTypes>>; |
+ DEFINE_STATIC_LOCAL(ApplicableTypesMap, applicableTypesMap, ()); |
+ auto entry = applicableTypesMap.find(property); |
+ if (entry != applicableTypesMap.end()) |
+ return *entry->value.get(); |
+ |
+ std::unique_ptr<InterpolationTypes> applicableTypes = |
+ WTF::makeUnique<InterpolationTypes>(); |
+ |
+ const QualifiedName& attribute = property.svgAttribute(); |
+ if (attribute == SVGNames::orientAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGAngleInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::numOctavesAttr || |
+ attribute == SVGNames::targetXAttr || |
+ attribute == SVGNames::targetYAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGIntegerInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::orderAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGIntegerOptionalIntegerInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::cxAttr || attribute == SVGNames::cyAttr || |
+ attribute == SVGNames::fxAttr || attribute == SVGNames::fyAttr || |
+ attribute == SVGNames::heightAttr || |
+ attribute == SVGNames::markerHeightAttr || |
+ attribute == SVGNames::markerWidthAttr || |
+ attribute == SVGNames::rAttr || attribute == SVGNames::refXAttr || |
+ attribute == SVGNames::refYAttr || attribute == SVGNames::rxAttr || |
+ attribute == SVGNames::ryAttr || |
+ attribute == SVGNames::startOffsetAttr || |
+ attribute == SVGNames::textLengthAttr || |
+ attribute == SVGNames::widthAttr || |
+ attribute == SVGNames::x1Attr || attribute == SVGNames::x2Attr || |
+ attribute == SVGNames::y1Attr || attribute == SVGNames::y2Attr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGLengthInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::dxAttr || attribute == SVGNames::dyAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGNumberInterpolationType>(attribute)); |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGLengthListInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::xAttr || attribute == SVGNames::yAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGLengthInterpolationType>(attribute)); |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGLengthListInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::amplitudeAttr || |
+ attribute == SVGNames::azimuthAttr || |
+ attribute == SVGNames::biasAttr || |
+ attribute == SVGNames::diffuseConstantAttr || |
+ attribute == SVGNames::divisorAttr || |
+ attribute == SVGNames::elevationAttr || |
+ attribute == SVGNames::exponentAttr || |
+ attribute == SVGNames::interceptAttr || |
+ attribute == SVGNames::k1Attr || attribute == SVGNames::k2Attr || |
+ attribute == SVGNames::k3Attr || attribute == SVGNames::k4Attr || |
+ attribute == SVGNames::limitingConeAngleAttr || |
+ attribute == SVGNames::offsetAttr || |
+ attribute == SVGNames::pathLengthAttr || |
+ attribute == SVGNames::pointsAtXAttr || |
+ attribute == SVGNames::pointsAtYAttr || |
+ attribute == SVGNames::pointsAtZAttr || |
+ attribute == SVGNames::scaleAttr || |
+ attribute == SVGNames::seedAttr || |
+ attribute == SVGNames::slopeAttr || |
+ attribute == SVGNames::specularConstantAttr || |
+ attribute == SVGNames::specularExponentAttr || |
+ attribute == SVGNames::surfaceScaleAttr || |
+ attribute == SVGNames::zAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGNumberInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::kernelMatrixAttr || |
+ attribute == SVGNames::rotateAttr || |
+ attribute == SVGNames::tableValuesAttr || |
+ attribute == SVGNames::valuesAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGNumberListInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::baseFrequencyAttr || |
+ attribute == SVGNames::kernelUnitLengthAttr || |
+ attribute == SVGNames::radiusAttr || |
+ attribute == SVGNames::stdDeviationAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGNumberOptionalNumberInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::dAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGPathInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::pointsAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGPointListInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::viewBoxAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGRectInterpolationType>(attribute)); |
+ } else if (attribute == SVGNames::gradientTransformAttr || |
+ attribute == SVGNames::patternTransformAttr || |
+ attribute == SVGNames::transformAttr) { |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGTransformListInterpolationType>(attribute)); |
+ } else if (attribute == HTMLNames::classAttr || |
+ attribute == SVGNames::clipPathUnitsAttr || |
+ attribute == SVGNames::edgeModeAttr || |
+ attribute == SVGNames::filterUnitsAttr || |
+ attribute == SVGNames::gradientUnitsAttr || |
+ attribute == SVGNames::hrefAttr || attribute == SVGNames::inAttr || |
+ attribute == SVGNames::in2Attr || |
+ attribute == SVGNames::lengthAdjustAttr || |
+ attribute == SVGNames::markerUnitsAttr || |
+ attribute == SVGNames::maskContentUnitsAttr || |
+ attribute == SVGNames::maskUnitsAttr || |
+ attribute == SVGNames::methodAttr || |
+ attribute == SVGNames::modeAttr || |
+ attribute == SVGNames::operatorAttr || |
+ attribute == SVGNames::patternContentUnitsAttr || |
+ attribute == SVGNames::patternUnitsAttr || |
+ attribute == SVGNames::preserveAlphaAttr || |
+ attribute == SVGNames::preserveAspectRatioAttr || |
+ attribute == SVGNames::primitiveUnitsAttr || |
+ attribute == SVGNames::resultAttr || |
+ attribute == SVGNames::spacingAttr || |
+ attribute == SVGNames::spreadMethodAttr || |
+ attribute == SVGNames::stitchTilesAttr || |
+ attribute == SVGNames::targetAttr || |
+ attribute == SVGNames::typeAttr || |
+ attribute == SVGNames::xChannelSelectorAttr || |
+ attribute == SVGNames::yChannelSelectorAttr) { |
+ // Use default SVGValueInterpolationType. |
+ } else { |
+ NOTREACHED(); |
+ } |
+ |
+ applicableTypes->append( |
+ WTF::makeUnique<SVGValueInterpolationType>(attribute)); |
+ |
+ auto addResult = applicableTypesMap.add(property, std::move(applicableTypes)); |
+ return *addResult.storedValue->value.get(); |
+} |
+ |
+} // namespace blink |