Changeset 243259 in webkit
- Timestamp:
- Mar 20, 2019, 4:51:47 PM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 added
- 2 deleted
- 18 edited
-
ChangeLog (modified) (1 diff)
-
Sources.txt (modified) (2 diffs)
-
WebCore.xcodeproj/project.pbxproj (modified) (7 diffs)
-
svg/SVGAnimateColorElement.cpp (modified) (1 diff)
-
svg/SVGAnimateColorElement.h (modified) (1 diff)
-
svg/SVGAnimateElementBase.cpp (modified) (1 diff)
-
svg/SVGAnimatedColor.cpp (deleted)
-
svg/SVGAnimatedColor.h (deleted)
-
svg/SVGAnimatorFactory.h (modified) (3 diffs)
-
svg/SVGAttributeAnimationController.cpp (modified) (1 diff)
-
svg/SVGAttributeAnimationController.h (modified) (1 diff)
-
svg/SVGElement.cpp (modified) (4 diffs)
-
svg/SVGElement.h (modified) (3 diffs)
-
svg/SVGFitToViewBox.h (modified) (2 diffs)
-
svg/SVGMPathElement.cpp (modified) (1 diff)
-
svg/graphics/filters/SVGFEImage.h (modified) (1 diff)
-
svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp (added)
-
svg/properties/SVGAnimationAdditiveValueFunctionImpl.h (modified) (1 diff)
-
svg/properties/SVGAnimationFunction.h (modified) (1 diff)
-
svg/properties/SVGAttributeAnimator.cpp (modified) (1 diff)
-
svg/properties/SVGAttributeAnimator.h (modified) (1 diff)
-
svg/properties/SVGPrimitivePropertyAnimator.h (added)
-
svg/properties/SVGPrimitivePropertyAnimatorImpl.h (added)
-
svg/properties/SVGPropertyAnimator.h (added)
-
svg/properties/SVGPropertyAnimatorFactory.h (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r243252 r243259 1 2019-03-20 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 Remove the SVG tear off objects for SVGColorAnimator 4 https://bugs.webkit.org/show_bug.cgi?id=196025 5 6 Reviewed by Simon Fraser. 7 8 SVG attributes like "fill" and "stroke" do not have reflecting properties 9 in SVGElement but they are animatable by SMIL. Animating such attributes 10 is different from animating the SVG animated properties. These new classes 11 will be added to handle the first type of this kind of attribute: the Color: 12 13 -- SVGPropertyAnimatorCreator is added to SVGElement. It is responsible 14 for creating SVGPropertyAnimators for the attribute which do not have 15 reflecting animated properties stored by SVGElement. It will maintain 16 a HashMap for the animated values for these attributes which is indexed 17 by the attribute name. The animated values has to be RefCounted because 18 the same attribute can be animated by multiple animators. So the values 19 of this HashMap will be of type Ref<SVGProperty>, e.g. 20 <circle cx="80" cy="120" r="35"> 21 <animate attributeName="fill" values="#080" begin="2s" /> 22 <animate attributeName="fill" values="#602;#004" begin="4s" dur="5s"/> 23 </circle> 24 25 -- SVGPropertyAnimator is the a new type which animates an attribute with 26 no reflecting animated property. 27 28 -- SVGPrimitivePropertyAnimator is a template class which is responsible 29 for animating attributes with primitive types, e.g. Color, string and 30 float. It is derived form SVGPropertyAnimator and it is initialized 31 with a Ref<SVGValueProperty<PropertyType>> which is created and maintained 32 by SVGPropertyAnimatorFactory. 33 34 -- SVGAnimationColorFunction is the animation function that animates the 35 attributes whose type are Color. Note the conversion form String to 36 Color in this class has to handle the case when its value is "attributeName=" 37 e.g. <animate attributeName="fill" from="attributeName="r"/> 38 39 -- SVGColorAnimator will be defined to be 40 SVGPrimitivePropertyAnimator<Color, SVGAnimationColorFunction>. 41 42 The life cycle of the RefCounted properties can be explained as follows: 43 44 -- SVGPropertyAnimatorFactory checks whether its HashMap has an entry 45 for the given attribute name. If it does not have, it will create a 46 new value through the value creation method for this attribute. 47 48 -- SVGPropertyAnimatorFactory passes the shared animated value to the 49 animator creation method. So multiple animators will be accessing the 50 same value through their RefCounted pointers. 51 52 -- When the animator is about to be deleted, it will notify the target 53 SVGElement which will notify its SVGPropertyAnimatorFactory. 54 SVGPropertyAnimatorFactory will check its HashMap and retrieves the 55 entry for the given attribute name. If the refCount is 2, it is going 56 to remove the entry form the HashMap. 57 58 * Sources.txt: 59 * WebCore.xcodeproj/project.pbxproj: 60 * svg/SVGAnimateColorElement.cpp: 61 (WebCore::attributeValueIsCurrentColor): Deleted. 62 (WebCore::SVGAnimateColorElement::determinePropertyValueTypes): Deleted. 63 * svg/SVGAnimateColorElement.h: 64 * svg/SVGAnimateElementBase.cpp: 65 (WebCore::SVGAnimateElementBase::attributeAnimationController): 66 * svg/SVGAnimatedColor.cpp: Removed. 67 * svg/SVGAnimatedColor.h: Removed. 68 * svg/SVGAnimatorFactory.h: 69 (WebCore::SVGAnimatorFactory::create): 70 * svg/SVGAttributeAnimationController.cpp: 71 (WebCore::SVGAttributeAnimationController::~SVGAttributeAnimationController): 72 * svg/SVGAttributeAnimationController.h: 73 * svg/SVGElement.cpp: 74 (WebCore::SVGElement::SVGElement): 75 (WebCore::SVGElement::isAnimatedAttribute const): 76 (WebCore::SVGElement::createAnimator): 77 (WebCore::SVGElement::animatorWillBeDeleted): 78 * svg/SVGElement.h: 79 (WebCore::SVGElement::propertyAnimatorFactory): 80 * svg/SVGFitToViewBox.h: 81 * svg/SVGMPathElement.cpp: 82 * svg/graphics/filters/SVGFEImage.h: 83 * svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp: Added. 84 (WebCore::SVGAnimationColorFunction::colorFromString): 85 * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h: 86 (WebCore::SVGAnimationColorFunction::progress): 87 * svg/properties/SVGAnimationFunction.h: 88 * svg/properties/SVGAttributeAnimator.cpp: 89 (WebCore::SVGAttributeAnimator::applyAnimatedStylePropertyChange): 90 (WebCore::SVGAttributeAnimator::removeAnimatedStyleProperty): 91 * svg/properties/SVGAttributeAnimator.h: 92 * svg/properties/SVGPrimitivePropertyAnimator.h: Added. 93 (WebCore::SVGPrimitivePropertyAnimator::create): 94 (WebCore::SVGPrimitivePropertyAnimator::SVGPrimitivePropertyAnimator): 95 * svg/properties/SVGPrimitivePropertyAnimatorImpl.h: Added. 96 * svg/properties/SVGPropertyAnimator.h: Added. 97 (WebCore::SVGPropertyAnimator::SVGPropertyAnimator): 98 (WebCore::SVGPropertyAnimator::adjustForInheritance const): 99 (WebCore::SVGPropertyAnimator::computeCSSPropertyValue const): 100 (WebCore::SVGPropertyAnimator::computeInheritedCSSPropertyValue const): 101 * svg/properties/SVGPropertyAnimatorFactory.h: Added. 102 (WebCore::SVGPropertyAnimatorFactory::isKnownAttribute): 103 (WebCore::SVGPropertyAnimatorFactory::createAnimator): 104 (WebCore::SVGPropertyAnimatorFactory::animatorWillBeDeleted): 105 (WebCore::SVGPropertyAnimatorFactory::createColorAnimator): 106 (WebCore::SVGPropertyAnimatorFactory::attributeAnimatorCreator): 107 1 108 2019-03-20 Alex Christensen <achristensen@webkit.org> 2 109 -
trunk/Source/WebCore/Sources.txt
r243193 r243259 2271 2271 svg/SVGAnimateTransformElement.cpp 2272 2272 svg/SVGAnimatedAngle.cpp 2273 svg/SVGAnimatedColor.cpp2274 2273 svg/SVGAnimatedEnumeration.cpp 2275 2274 svg/SVGAnimatedLength.cpp … … 2423 2422 svg/properties/SVGAnimatedPathSegListPropertyTearOff.cpp 2424 2423 svg/properties/SVGAnimatedProperty.cpp 2424 svg/properties/SVGAnimationAdditiveValueFunctionImpl.cpp 2425 2425 svg/properties/SVGAttributeAnimator.cpp 2426 2426 svg/properties/SVGAttributeOwnerProxy.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r243193 r243259 1224 1224 439D334413A6911C00C20F4F /* SVGAnimatedTypeAnimator.h in Headers */ = {isa = PBXBuildFile; fileRef = 439D334113A6911C00C20F4F /* SVGAnimatedTypeAnimator.h */; }; 1225 1225 439D334513A6911C00C20F4F /* SVGAnimatorFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 439D334213A6911C00C20F4F /* SVGAnimatorFactory.h */; }; 1226 43A625F813B3304000AC94B8 /* SVGAnimatedColor.h in Headers */ = {isa = PBXBuildFile; fileRef = 43A625F613B3304000AC94B8 /* SVGAnimatedColor.h */; };1227 1226 43B85ED418CBEC5200E31AF4 /* SelectorPseudoClassAndCompatibilityElementMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 43B85ED218CBEC5200E31AF4 /* SelectorPseudoClassAndCompatibilityElementMap.cpp */; }; 1228 1227 43B9336913B261B1004584BF /* SVGAnimatedPointList.h in Headers */ = {isa = PBXBuildFile; fileRef = 43B9336713B261B1004584BF /* SVGAnimatedPointList.h */; }; … … 7672 7671 439D334213A6911C00C20F4F /* SVGAnimatorFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatorFactory.h; sourceTree = "<group>"; }; 7673 7672 43A0F0B013AC7D6D00A5F0A7 /* SVGAnimatedNumber.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedNumber.cpp; sourceTree = "<group>"; }; 7674 43A625F613B3304000AC94B8 /* SVGAnimatedColor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedColor.h; sourceTree = "<group>"; };7675 43A625F713B3304000AC94B8 /* SVGAnimatedColor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedColor.cpp; sourceTree = "<group>"; };7676 7673 43A6266613B3D11000AC94B8 /* SVGAnimatedString.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedString.cpp; sourceTree = "<group>"; }; 7677 7674 43B85ED018CBEACE00E31AF4 /* makeSelectorPseudoClassAndCompatibilityElementMap.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = makeSelectorPseudoClassAndCompatibilityElementMap.py; sourceTree = "<group>"; }; … … 9528 9525 724EE54E1DC7F25B00A91FFB /* ActivityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityState.h; sourceTree = "<group>"; }; 9529 9526 724EE54F1DC7F25B00A91FFB /* ActivityStateChangeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityStateChangeObserver.h; sourceTree = "<group>"; }; 9527 7266F0132241BCE200833975 /* SVGPropertyAnimatorFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyAnimatorFactory.h; sourceTree = "<group>"; }; 9528 7266F0142241BFB200833975 /* SVGPrimitivePropertyAnimatorImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimatorImpl.h; sourceTree = "<group>"; }; 9529 7266F0152241C09800833975 /* SVGPrimitivePropertyAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimator.h; sourceTree = "<group>"; }; 9530 7266F0162241C0FE00833975 /* SVGPropertyAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyAnimator.h; sourceTree = "<group>"; }; 9531 7266F01822429CFD00833975 /* SVGAnimationAdditiveValueFunctionImpl.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimationAdditiveValueFunctionImpl.cpp; sourceTree = "<group>"; }; 9530 9532 727AFED11A2EA6A0000442E8 /* EXTsRGB.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTsRGB.cpp; sourceTree = "<group>"; }; 9531 9533 727AFED21A2EA6A0000442E8 /* EXTsRGB.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTsRGB.h; sourceTree = "<group>"; }; … … 16236 16238 55BE025F223B29C50032F08A /* SVGAnimationAdditiveFunction.h */, 16237 16239 55EE535E223B2A0E00FBA944 /* SVGAnimationAdditiveValueFunction.h */, 16240 7266F01822429CFD00833975 /* SVGAnimationAdditiveValueFunctionImpl.cpp */, 16238 16241 55BE0259223B29C10032F08A /* SVGAnimationAdditiveValueFunctionImpl.h */, 16239 16242 55DCC51D2240615500C26E32 /* SVGAnimationDiscreteFunction.h */, … … 16258 16261 55BE025A223B29C20032F08A /* SVGPointerMemberAccessor.h */, 16259 16262 55DCC5252240749E00C26E32 /* SVGPrimitiveList.h */, 16263 7266F0152241C09800833975 /* SVGPrimitivePropertyAnimator.h */, 16264 7266F0142241BFB200833975 /* SVGPrimitivePropertyAnimatorImpl.h */, 16260 16265 55EE5363223B2A2400FBA944 /* SVGProperty.h */, 16261 16266 55DCC526224074FA00C26E32 /* SVGPropertyAccessor.h */, 16262 16267 55DCC5272240750B00C26E32 /* SVGPropertyAccessorImpl.h */, 16268 7266F0162241C0FE00833975 /* SVGPropertyAnimator.h */, 16269 7266F0132241BCE200833975 /* SVGPropertyAnimatorFactory.h */, 16263 16270 55EE5360223B2A2100FBA944 /* SVGPropertyOwner.h */, 16264 16271 55BE025C223B29C30032F08A /* SVGPropertyOwnerRegistry.h */, … … 24130 24137 B22277E60D00BF1F0071B782 /* SVGAnimatedAngle.idl */, 24131 24138 B22277E70D00BF1F0071B782 /* SVGAnimatedBoolean.idl */, 24132 43A625F713B3304000AC94B8 /* SVGAnimatedColor.cpp */,24133 43A625F613B3304000AC94B8 /* SVGAnimatedColor.h */,24134 24139 71CC7A1F152A0BFE009EEAF9 /* SVGAnimatedEnumeration.cpp */, 24135 24140 08D46CE2127AD5FC0089694B /* SVGAnimatedEnumeration.h */, … … 31922 31927 B222797A0D00BF220071B782 /* SVGAnimateColorElement.h in Headers */, 31923 31928 087B84961272CEC800A14417 /* SVGAnimatedAngle.h in Headers */, 31924 43A625F813B3304000AC94B8 /* SVGAnimatedColor.h in Headers */,31925 31929 08D46CE3127AD5FC0089694B /* SVGAnimatedEnumeration.h in Headers */, 31926 31930 71FB967B1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h in Headers */, -
trunk/Source/WebCore/svg/SVGAnimateColorElement.cpp
r229694 r243259 41 41 } 42 42 43 static bool attributeValueIsCurrentColor(const String& value)44 {45 static NeverDestroyed<const AtomicString> currentColor("currentColor", AtomicString::ConstructFromLiteral);46 return value == currentColor;47 43 } 48 49 void SVGAnimateColorElement::determinePropertyValueTypes(const String& from, const String& to)50 {51 SVGAnimateElementBase::determinePropertyValueTypes(from, to);52 if (attributeValueIsCurrentColor(from))53 m_fromPropertyValueType = CurrentColorValue;54 if (attributeValueIsCurrentColor(to))55 m_toPropertyValueType = CurrentColorValue;56 }57 58 } -
trunk/Source/WebCore/svg/SVGAnimateColorElement.h
r229694 r243259 33 33 private: 34 34 SVGAnimateColorElement(const QualifiedName&, Document&); 35 void determinePropertyValueTypes(const String& from, const String& to) override;36 35 }; 37 36 -
trunk/Source/WebCore/svg/SVGAnimateElementBase.cpp
r243036 r243259 50 50 51 51 if (!m_attributeAnimationController) { 52 if (targetElement()->isAnimated PropertyAttribute(attributeName()))52 if (targetElement()->isAnimatedAttribute(attributeName())) 53 53 m_attributeAnimationController = std::make_unique<SVGAttributeAnimationController>(*this, *targetElement()); 54 54 else -
trunk/Source/WebCore/svg/SVGAnimatorFactory.h
r243185 r243259 21 21 22 22 #include "SVGAnimatedAngle.h" 23 #include "SVGAnimatedColor.h"24 23 #include "SVGAnimatedEnumeration.h" 25 24 #include "SVGAnimatedLength.h" … … 45 44 46 45 switch (attributeType) { 46 case AnimatedBoolean: 47 case AnimatedColor: 48 case AnimatedInteger: 49 case AnimatedIntegerOptionalInteger: 50 case AnimatedPreserveAspectRatio: 51 case AnimatedRect: 52 return nullptr; 53 47 54 case AnimatedAngle: 48 55 return std::make_unique<SVGAnimatedAngleAnimator>(animationElement, contextElement); 49 case AnimatedBoolean:50 return nullptr;51 case AnimatedColor:52 return std::make_unique<SVGAnimatedColorAnimator>(*animationElement, *contextElement);53 56 case AnimatedEnumeration: 54 57 return std::make_unique<SVGAnimatedEnumerationAnimator>(animationElement, contextElement); 55 case AnimatedInteger:56 return nullptr;57 case AnimatedIntegerOptionalInteger:58 return nullptr;59 58 case AnimatedLength: 60 59 return std::make_unique<SVGAnimatedLengthAnimator>(animationElement, contextElement); … … 71 70 case AnimatedPoints: 72 71 return std::make_unique<SVGAnimatedPointListAnimator>(animationElement, contextElement); 73 case AnimatedPreserveAspectRatio:74 return nullptr;75 case AnimatedRect:76 return nullptr;77 72 case AnimatedString: 78 73 return std::make_unique<SVGAnimatedStringAnimator>(animationElement, contextElement); -
trunk/Source/WebCore/svg/SVGAttributeAnimationController.cpp
r243183 r243259 37 37 : SVGAttributeAnimationControllerBase(animationElement, targetElement) 38 38 { 39 } 40 41 SVGAttributeAnimationController::~SVGAttributeAnimationController() 42 { 43 if (m_animator) 44 m_targetElement.animatorWillBeDeleted(m_animationElement.attributeName()); 39 45 } 40 46 -
trunk/Source/WebCore/svg/SVGAttributeAnimationController.h
r243183 r243259 38 38 public: 39 39 SVGAttributeAnimationController(SVGAnimationElement&, SVGElement&); 40 ~SVGAttributeAnimationController(); 40 41 41 42 private: -
trunk/Source/WebCore/svg/SVGElement.cpp
r243130 r243259 45 45 #include "SVGImageElement.h" 46 46 #include "SVGNames.h" 47 #include "SVGPropertyAnimatorFactory.h" 47 48 #include "SVGRenderStyle.h" 48 49 #include "SVGRenderSupport.h" … … 276 277 : StyledElement(tagName, document, CreateSVGElement) 277 278 , SVGLangSpace(this) 279 , m_propertyAnimatorFactory(std::make_unique<SVGPropertyAnimatorFactory>()) 278 280 { 279 281 registerAttributes(); … … 757 759 bool SVGElement::isAnimatedAttribute(const QualifiedName& attributeName) const 758 760 { 759 return isAnimatedPropertyAttribute(attributeName);761 return SVGPropertyAnimatorFactory::isKnownAttribute(attributeName) || isAnimatedPropertyAttribute(attributeName); 760 762 } 761 763 762 764 std::unique_ptr<SVGAttributeAnimator> SVGElement::createAnimator(const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) 763 765 { 766 // Property animator, e.g. "fill" or "fill-opacity". 767 if (auto animator = propertyAnimatorFactory().createAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive)) 768 return animator; 769 770 // Animated property animator. 764 771 auto animator = propertyRegistry().createAnimator(attributeName, animationMode, calcMode, isAccumulated, isAdditive); 765 772 if (!animator) … … 768 775 instance->propertyRegistry().appendAnimatedInstance(attributeName, *animator); 769 776 return animator; 777 } 778 779 void SVGElement::animatorWillBeDeleted(const QualifiedName& attributeName) 780 { 781 propertyAnimatorFactory().animatorWillBeDeleted(attributeName); 770 782 } 771 783 -
trunk/Source/WebCore/svg/SVGElement.h
r243130 r243259 43 43 class SVGDocumentExtensions; 44 44 class SVGElementRareData; 45 class SVGPropertyAnimatorFactory; 45 46 class SVGSVGElement; 46 47 class SVGUseElement; … … 162 163 163 164 const SVGElement* attributeContextElement() const override { return this; } 165 SVGPropertyAnimatorFactory& propertyAnimatorFactory() { return *m_propertyAnimatorFactory; } 164 166 std::unique_ptr<SVGAttributeAnimator> createAnimator(const QualifiedName&, AnimationMode, CalcMode, bool isAccumulated, bool isAdditive); 167 void animatorWillBeDeleted(const QualifiedName&); 165 168 166 169 // These are needed for the RenderTree, animation and DOM. … … 215 218 216 219 HashSet<SVGElement*> m_elementsWithRelativeLengths; 220 221 std::unique_ptr<SVGPropertyAnimatorFactory> m_propertyAnimatorFactory; 217 222 218 223 AttributeOwnerProxy m_attributeOwnerProxy { *this }; -
trunk/Source/WebCore/svg/SVGFitToViewBox.h
r243185 r243259 2 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> 3 3 * Copyright (C) 2004, 2005, 2006, 2007, 2010 Rob Buis <buis@kde.org> 4 * Copyright (C) 2018 Apple Inc. All rights reserved.4 * Copyright (C) 2018-2019 Apple Inc. All rights reserved. 5 5 * 6 6 * This library is free software; you can redistribute it and/or … … 24 24 #include "FloatRect.h" 25 25 #include "QualifiedName.h" 26 #include "SVGAnimatedPropertyImpl.h" 27 #include "SVGAttributeOwnerProxyImpl.h" 26 28 #include "SVGAttributeRegistry.h" 27 29 #include "SVGNames.h" 28 30 #include "SVGPreserveAspectRatio.h" 31 #include "SVGPropertyOwnerRegistry.h" 29 32 #include <wtf/HashSet.h> 30 33 -
trunk/Source/WebCore/svg/SVGMPathElement.cpp
r240237 r243259 27 27 #include "SVGNames.h" 28 28 #include "SVGPathElement.h" 29 #include <wtf/IsoMallocInlines.h> 29 30 30 31 namespace WebCore { -
trunk/Source/WebCore/svg/graphics/filters/SVGFEImage.h
r238524 r243259 31 31 class Image; 32 32 class RenderElement; 33 class TreeScope; 33 34 34 35 class FEImage final : public FilterEffect { -
trunk/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h
r243183 r243259 30 30 31 31 namespace WebCore { 32 33 class SVGAnimationColorFunction : public SVGAnimationAdditiveValueFunction<Color> { 34 public: 35 using Base = SVGAnimationAdditiveValueFunction<Color>; 36 using Base::Base; 37 38 void setFromAndToValues(SVGElement* targetElement, const String& from, const String& to) override 39 { 40 m_from = colorFromString(targetElement, from); 41 m_to = colorFromString(targetElement, to); 42 } 43 44 void setToAtEndOfDurationValue(const String& toAtEndOfDuration) override 45 { 46 m_toAtEndOfDuration = SVGPropertyTraits<Color>::fromString(toAtEndOfDuration); 47 } 48 49 void progress(SVGElement*, float percentage, unsigned repeatCount, Color& animated) 50 { 51 Color from = m_animationMode == AnimationMode::To ? animated : m_from; 52 53 float red = Base::progress(percentage, repeatCount, from.red(), m_to.red(), toAtEndOfDuration().red(), animated.red()); 54 float green = Base::progress(percentage, repeatCount, from.green(), m_to.green(), toAtEndOfDuration().green(), animated.green()); 55 float blue = Base::progress(percentage, repeatCount, from.blue(), m_to.blue(), toAtEndOfDuration().blue(), animated.blue()); 56 float alpha = Base::progress(percentage, repeatCount, from.alpha(), m_to.alpha(), toAtEndOfDuration().alpha(), animated.alpha()); 57 58 animated = { roundAndClampColorChannel(red), roundAndClampColorChannel(green), roundAndClampColorChannel(blue), roundAndClampColorChannel(alpha) }; 59 } 60 61 float calculateDistance(SVGElement*, const String& from, const String& to) const override 62 { 63 Color fromColor = CSSParser::parseColor(from.stripWhiteSpace()); 64 if (!fromColor.isValid()) 65 return -1; 66 Color toColor = CSSParser::parseColor(to.stripWhiteSpace()); 67 if (!toColor.isValid()) 68 return -1; 69 float red = fromColor.red() - toColor.red(); 70 float green = fromColor.green() - toColor.green(); 71 float blue = fromColor.blue() - toColor.blue(); 72 return sqrtf(red * red + green * green + blue * blue); 73 } 74 75 private: 76 void addFromAndToValues(SVGElement*) override 77 { 78 // Ignores any alpha and sets alpha on result to 100% opaque. 79 m_to = { 80 roundAndClampColorChannel(m_to.red() + m_from.red()), 81 roundAndClampColorChannel(m_to.green() + m_from.green()), 82 roundAndClampColorChannel(m_to.blue() + m_from.blue()) 83 }; 84 } 85 86 static Color colorFromString(SVGElement*, const String&); 87 }; 32 88 33 89 class SVGAnimationIntegerFunction : public SVGAnimationAdditiveValueFunction<int> { -
trunk/Source/WebCore/svg/properties/SVGAnimationFunction.h
r243036 r243259 26 26 #pragma once 27 27 28 #include "SVGAttributeAnimator.h" 29 28 30 namespace WebCore { 31 32 class SVGElement; 29 33 30 34 class SVGAnimationFunction { -
trunk/Source/WebCore/svg/properties/SVGAttributeAnimator.cpp
r243036 r243259 33 33 namespace WebCore { 34 34 35 void SVGAttributeAnimator::applyAnimatedStylePropertyChange(SVGElement* element, CSSPropertyID id, const String& value) 36 { 37 ASSERT(element); 38 ASSERT(!element->m_deletionHasBegun); 39 40 if (!element->ensureAnimatedSMILStyleProperties().setProperty(id, value, false)) 41 return; 42 element->invalidateStyle(); 43 } 44 45 void SVGAttributeAnimator::applyAnimatedStylePropertyChange(SVGElement* targetElement, const String& value) 46 { 47 ASSERT(targetElement); 48 ASSERT(m_attributeName != anyQName()); 49 50 // FIXME: Do we really need to check both isConnected and !parentNode? 51 if (!targetElement->isConnected() || !targetElement->parentNode()) 52 return; 53 54 CSSPropertyID id = cssPropertyID(m_attributeName.localName()); 55 56 SVGElement::InstanceUpdateBlocker blocker(*targetElement); 57 applyAnimatedStylePropertyChange(targetElement, id, value); 58 59 // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt. 60 for (auto* instance : targetElement->instances()) 61 applyAnimatedStylePropertyChange(instance, id, value); 62 } 63 64 void SVGAttributeAnimator::removeAnimatedStyleProperty(SVGElement* element, CSSPropertyID id) 65 { 66 ASSERT(element); 67 ASSERT(!element->m_deletionHasBegun); 68 69 element->ensureAnimatedSMILStyleProperties().removeProperty(id); 70 element->invalidateStyle(); 71 } 72 73 void SVGAttributeAnimator::removeAnimatedStyleProperty(SVGElement* targetElement) 74 { 75 ASSERT(targetElement); 76 ASSERT(m_attributeName != anyQName()); 77 78 // FIXME: Do we really need to check both isConnected and !parentNode? 79 if (!targetElement->isConnected() || !targetElement->parentNode()) 80 return; 81 82 CSSPropertyID id = cssPropertyID(m_attributeName.localName()); 83 84 SVGElement::InstanceUpdateBlocker blocker(*targetElement); 85 removeAnimatedStyleProperty(targetElement, id); 86 87 // If the target element has instances, update them as well, w/o requiring the <use> tree to be rebuilt. 88 for (auto* instance : targetElement->instances()) 89 removeAnimatedStyleProperty(instance, id); 90 } 91 35 92 void SVGAttributeAnimator::applyAnimatedPropertyChange(SVGElement* element, const QualifiedName& attributeName) 36 93 { -
trunk/Source/WebCore/svg/properties/SVGAttributeAnimator.h
r243036 r243259 75 75 76 76 protected: 77 static void applyAnimatedStylePropertyChange(SVGElement*, CSSPropertyID, const String& value); 78 static void removeAnimatedStyleProperty(SVGElement*, CSSPropertyID); 77 79 static void applyAnimatedPropertyChange(SVGElement*, const QualifiedName&); 78 80 81 void applyAnimatedStylePropertyChange(SVGElement*, const String& value); 82 void removeAnimatedStyleProperty(SVGElement*); 79 83 void applyAnimatedPropertyChange(SVGElement*); 80 84
Note:
See TracChangeset
for help on using the changeset viewer.