SVGLengthValue should use two enums for 'type' and 'mode' instead of one unsigned...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Sep 2019 00:39:54 +0000 (00:39 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Sep 2019 00:39:54 +0000 (00:39 +0000)
https://bugs.webkit.org/show_bug.cgi?id=201663

Patch by Said Abou-Hallawa <sabouhallawa@apple.com> on 2019-09-12
Reviewed by Simon Fraser, Nikolas Zimmermann.

SVGLengthValue had one unsigned to store SVGLengthMode and SVGLengthType.
It used to allocate the least significant 4 bits of this unsigned to the
SVGLengthMode while it leaves the rest for SVGLengthType.

This will not be needed if SVGLengthMode and SVGLengthType are made of
size uint_8.

Also in this patch:

-- SVGLengthNegativeValuesMode is made enum class.

-- SVGLengthValue::blend() is moved to SVGLengthValue.cpp so we do not
   need to include SVGLengthContext.h in SVGLengthValue.h.

-- SVGLengthType and SVGLengthMode are moved to SVGLengthValue.h. Instead
   of having SVGLengthValue.h includes SVGLengthConttext.h, the opposite
   will happen.

-- SVGAnimatedPropertyDescription.h is deleted. It should have been deleted
   with the SVG tear off objects removal.

-- SVGPropertyTraits<SVGAngleValue> and SVGPropertyTraits<SVGLengthValue>
   are deleted. They should have been deleted with SVGAnimatedType removal.

-- SVGLengthValue::lengthModeForAnimatedLengthAttribute() is deleted. It
   was only called from SVGPropertyTraits<SVGLengthValue>.

* WebCore.xcodeproj/project.pbxproj:
* css/StyleResolver.h:
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::blendFunc):
* rendering/style/SVGRenderStyle.h:
(WebCore::SVGRenderStyle::initialBaselineShiftValue):
(WebCore::SVGRenderStyle::initialKerning):
* rendering/svg/RenderSVGEllipse.cpp:
(WebCore::RenderSVGEllipse::calculateRadiiAndCenter):
* rendering/svg/RenderSVGRect.cpp:
(WebCore::RenderSVGRect::updateShapeFromElement):
* rendering/svg/SVGPathData.cpp:
(WebCore::pathFromCircleElement):
(WebCore::pathFromEllipseElement):
(WebCore::pathFromRectElement):
* rendering/svg/SVGTextLayoutEngineBaseline.cpp:
(WebCore::SVGTextLayoutEngineBaseline::calculateBaselineShift const):
* rendering/svg/SVGTextLayoutEngineSpacing.cpp:
(WebCore::SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing):
* svg/LinearGradientAttributes.h:
(WebCore::LinearGradientAttributes::LinearGradientAttributes):
* svg/RadialGradientAttributes.h:
(WebCore::RadialGradientAttributes::RadialGradientAttributes):
* svg/SVGAngleValue.h:
(WebCore::SVGPropertyTraits<SVGAngleValue>::initialValue): Deleted.
(WebCore::SVGPropertyTraits<SVGAngleValue>::toString): Deleted.
* svg/SVGCircleElement.cpp:
(WebCore::SVGCircleElement::parseAttribute):
* svg/SVGCircleElement.h:
* svg/SVGCursorElement.cpp:
(WebCore::SVGCursorElement::parseAttribute):
* svg/SVGCursorElement.h:
* svg/SVGEllipseElement.cpp:
(WebCore::SVGEllipseElement::parseAttribute):
* svg/SVGEllipseElement.h:
* svg/SVGFilterElement.cpp:
(WebCore::SVGFilterElement::parseAttribute):
* svg/SVGFilterElement.h:
* svg/SVGFilterPrimitiveStandardAttributes.cpp:
(WebCore::SVGFilterPrimitiveStandardAttributes::parseAttribute):
* svg/SVGFilterPrimitiveStandardAttributes.h:
* svg/SVGForeignObjectElement.cpp:
(WebCore::SVGForeignObjectElement::parseAttribute):
* svg/SVGForeignObjectElement.h:
* svg/SVGImageElement.cpp:
(WebCore::SVGImageElement::parseAttribute):
* svg/SVGImageElement.h:
* svg/SVGLength.h:
(WebCore::SVGLength::unitType const):
(WebCore::SVGLength::setValueForBindings):
(WebCore::SVGLength::newValueSpecifiedUnits):
(WebCore::SVGLength::convertToSpecifiedUnits):
(WebCore::SVGLength::unitType): Deleted.
* svg/SVGLengthContext.cpp:
(WebCore::SVGLengthContext::valueForLength):
(WebCore::SVGLengthContext::convertValueToUserUnits const):
(WebCore::SVGLengthContext::convertValueFromUserUnits const):
(WebCore::SVGLengthContext::convertValueFromUserUnitsToPercentage const):
(WebCore::SVGLengthContext::convertValueFromPercentageToUserUnits const):
* svg/SVGLengthContext.h:
(): Deleted.
* svg/SVGLengthList.h:
(WebCore::SVGLengthList::create):
* svg/SVGLengthValue.cpp:
(WebCore::lengthTypeToString):
(WebCore::parseLengthType):
(WebCore::primitiveTypeToLengthType):
(WebCore::lengthTypeToPrimitiveType):
(WebCore::SVGLengthValue::SVGLengthValue):
(WebCore::SVGLengthValue::construct):
(WebCore::SVGLengthValue::blend):
(WebCore::SVGLengthValue::fromCSSPrimitiveValue):
(WebCore::SVGLengthValue::toCSSPrimitiveValue):
(WebCore::SVGLengthValue::setValueAsString):
(WebCore::SVGLengthValue::valueAsString const):
(WebCore::SVGLengthValue::valueForBindings const):
(WebCore::SVGLengthValue::setValue):
(WebCore::SVGLengthValue::convertToSpecifiedUnits):
(WebCore::storeUnit): Deleted.
(WebCore::extractMode): Deleted.
(WebCore::extractType): Deleted.
(WebCore::SVGLengthValue::operator== const): Deleted.
(WebCore::SVGLengthValue::operator!= const): Deleted.
(WebCore::SVGLengthValue::unitType const): Deleted.
(WebCore::SVGLengthValue::unitMode const): Deleted.
(WebCore::SVGLengthValue::valueAsPercentage const): Deleted.
(WebCore::SVGLengthValue::newValueSpecifiedUnits): Deleted.
(WebCore::SVGLengthValue::lengthModeForAnimatedLengthAttribute): Deleted.
* svg/SVGLengthValue.h:
(WebCore::SVGLengthValue::lengthType const):
(WebCore::SVGLengthValue::lengthMode const):
(WebCore::SVGLengthValue::isZero const):
(WebCore::SVGLengthValue::isRelative const):
(WebCore::SVGLengthValue::valueAsPercentage const):
(WebCore::SVGLengthValue::valueInSpecifiedUnits const):
(WebCore::operator==):
(WebCore::operator!=):
(WebCore::SVGLengthValue::blend const): Deleted.
(WebCore::SVGPropertyTraits<SVGLengthValue>::initialValue): Deleted.
(WebCore::SVGPropertyTraits<SVGLengthValue>::parse): Deleted.
(WebCore::SVGPropertyTraits<SVGLengthValue>::toString): Deleted.
* svg/SVGLineElement.cpp:
(WebCore::SVGLineElement::parseAttribute):
* svg/SVGLineElement.h:
* svg/SVGLinearGradientElement.cpp:
(WebCore::SVGLinearGradientElement::parseAttribute):
* svg/SVGLinearGradientElement.h:
* svg/SVGMarkerElement.cpp:
(WebCore::SVGMarkerElement::parseAttribute):
* svg/SVGMarkerElement.h:
* svg/SVGMaskElement.cpp:
(WebCore::SVGMaskElement::parseAttribute):
* svg/SVGMaskElement.h:
* svg/SVGPatternElement.cpp:
(WebCore::SVGPatternElement::parseAttribute):
* svg/SVGPatternElement.h:
* svg/SVGRadialGradientElement.cpp:
(WebCore::SVGRadialGradientElement::parseAttribute):
* svg/SVGRadialGradientElement.h:
* svg/SVGRectElement.cpp:
(WebCore::SVGRectElement::parseAttribute):
* svg/SVGRectElement.h:
* svg/SVGSVGElement.cpp:
(WebCore::SVGSVGElement::parseAttribute):
(WebCore::SVGSVGElement::hasIntrinsicWidth const):
(WebCore::SVGSVGElement::hasIntrinsicHeight const):
(WebCore::SVGSVGElement::intrinsicWidth const):
(WebCore::SVGSVGElement::intrinsicHeight const):
* svg/SVGSVGElement.h:
* svg/SVGTextContentElement.cpp:
(WebCore::SVGTextContentElement::parseAttribute):
(WebCore::SVGTextContentElement::textLengthAnimated):
* svg/SVGTextContentElement.h:
* svg/SVGTextPathElement.cpp:
(WebCore::SVGTextPathElement::parseAttribute):
* svg/SVGTextPathElement.h:
* svg/SVGTextPositioningElement.h:
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::parseAttribute):
* svg/SVGUseElement.h:
* svg/properties/SVGAnimatedPropertyAccessorImpl.h:
* svg/properties/SVGAnimatedPropertyDescription.h: Removed.
* svg/properties/SVGAnimationAdditiveListFunctionImpl.h:
(WebCore::SVGAnimationLengthListFunction::animate):
* svg/properties/SVGAnimationAdditiveValueFunctionImpl.h:
(WebCore::SVGAnimationLengthFunction::animate):
* svg/properties/SVGValuePropertyAnimatorImpl.h:
* svg/properties/SVGValuePropertyListAnimatorImpl.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@249822 268f45cc-cd09-0410-ab3c-d52691b4dbfc

62 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/StyleResolver.h
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/rendering/style/SVGRenderStyle.h
Source/WebCore/rendering/svg/RenderSVGEllipse.cpp
Source/WebCore/rendering/svg/RenderSVGRect.cpp
Source/WebCore/rendering/svg/SVGPathData.cpp
Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
Source/WebCore/rendering/svg/SVGTextLayoutEngineSpacing.cpp
Source/WebCore/svg/LinearGradientAttributes.h
Source/WebCore/svg/RadialGradientAttributes.h
Source/WebCore/svg/SVGAngleValue.h
Source/WebCore/svg/SVGCircleElement.cpp
Source/WebCore/svg/SVGCircleElement.h
Source/WebCore/svg/SVGCursorElement.cpp
Source/WebCore/svg/SVGCursorElement.h
Source/WebCore/svg/SVGEllipseElement.cpp
Source/WebCore/svg/SVGEllipseElement.h
Source/WebCore/svg/SVGFilterElement.cpp
Source/WebCore/svg/SVGFilterElement.h
Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.cpp
Source/WebCore/svg/SVGFilterPrimitiveStandardAttributes.h
Source/WebCore/svg/SVGForeignObjectElement.cpp
Source/WebCore/svg/SVGForeignObjectElement.h
Source/WebCore/svg/SVGImageElement.cpp
Source/WebCore/svg/SVGImageElement.h
Source/WebCore/svg/SVGLength.h
Source/WebCore/svg/SVGLengthContext.cpp
Source/WebCore/svg/SVGLengthContext.h
Source/WebCore/svg/SVGLengthList.h
Source/WebCore/svg/SVGLengthValue.cpp
Source/WebCore/svg/SVGLengthValue.h
Source/WebCore/svg/SVGLineElement.cpp
Source/WebCore/svg/SVGLineElement.h
Source/WebCore/svg/SVGLinearGradientElement.cpp
Source/WebCore/svg/SVGLinearGradientElement.h
Source/WebCore/svg/SVGMarkerElement.cpp
Source/WebCore/svg/SVGMarkerElement.h
Source/WebCore/svg/SVGMaskElement.cpp
Source/WebCore/svg/SVGMaskElement.h
Source/WebCore/svg/SVGPatternElement.cpp
Source/WebCore/svg/SVGPatternElement.h
Source/WebCore/svg/SVGRadialGradientElement.cpp
Source/WebCore/svg/SVGRadialGradientElement.h
Source/WebCore/svg/SVGRectElement.cpp
Source/WebCore/svg/SVGRectElement.h
Source/WebCore/svg/SVGSVGElement.cpp
Source/WebCore/svg/SVGSVGElement.h
Source/WebCore/svg/SVGTextContentElement.cpp
Source/WebCore/svg/SVGTextContentElement.h
Source/WebCore/svg/SVGTextPathElement.cpp
Source/WebCore/svg/SVGTextPathElement.h
Source/WebCore/svg/SVGTextPositioningElement.h
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/SVGUseElement.h
Source/WebCore/svg/properties/SVGAnimatedPropertyAccessorImpl.h
Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h [deleted file]
Source/WebCore/svg/properties/SVGAnimationAdditiveListFunctionImpl.h
Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h
Source/WebCore/svg/properties/SVGValuePropertyAnimatorImpl.h
Source/WebCore/svg/properties/SVGValuePropertyListAnimatorImpl.h

index 9254ea6..a69e227 100644 (file)
@@ -1,3 +1,186 @@
+2019-09-12  Said Abou-Hallawa  <sabouhallawa@apple.com>
+
+        SVGLengthValue should use two enums for 'type' and 'mode' instead of one unsigned for 'units'
+        https://bugs.webkit.org/show_bug.cgi?id=201663
+
+        Reviewed by Simon Fraser, Nikolas Zimmermann.
+
+        SVGLengthValue had one unsigned to store SVGLengthMode and SVGLengthType.
+        It used to allocate the least significant 4 bits of this unsigned to the
+        SVGLengthMode while it leaves the rest for SVGLengthType.
+
+        This will not be needed if SVGLengthMode and SVGLengthType are made of
+        size uint_8.
+
+        Also in this patch:
+
+        -- SVGLengthNegativeValuesMode is made enum class.
+
+        -- SVGLengthValue::blend() is moved to SVGLengthValue.cpp so we do not
+           need to include SVGLengthContext.h in SVGLengthValue.h.
+
+        -- SVGLengthType and SVGLengthMode are moved to SVGLengthValue.h. Instead
+           of having SVGLengthValue.h includes SVGLengthConttext.h, the opposite
+           will happen.
+
+        -- SVGAnimatedPropertyDescription.h is deleted. It should have been deleted
+           with the SVG tear off objects removal.
+
+        -- SVGPropertyTraits<SVGAngleValue> and SVGPropertyTraits<SVGLengthValue>
+           are deleted. They should have been deleted with SVGAnimatedType removal.
+
+        -- SVGLengthValue::lengthModeForAnimatedLengthAttribute() is deleted. It
+           was only called from SVGPropertyTraits<SVGLengthValue>.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/StyleResolver.h:
+        * page/animation/CSSPropertyAnimation.cpp:
+        (WebCore::blendFunc):
+        * rendering/style/SVGRenderStyle.h:
+        (WebCore::SVGRenderStyle::initialBaselineShiftValue):
+        (WebCore::SVGRenderStyle::initialKerning):
+        * rendering/svg/RenderSVGEllipse.cpp:
+        (WebCore::RenderSVGEllipse::calculateRadiiAndCenter):
+        * rendering/svg/RenderSVGRect.cpp:
+        (WebCore::RenderSVGRect::updateShapeFromElement):
+        * rendering/svg/SVGPathData.cpp:
+        (WebCore::pathFromCircleElement):
+        (WebCore::pathFromEllipseElement):
+        (WebCore::pathFromRectElement):
+        * rendering/svg/SVGTextLayoutEngineBaseline.cpp:
+        (WebCore::SVGTextLayoutEngineBaseline::calculateBaselineShift const):
+        * rendering/svg/SVGTextLayoutEngineSpacing.cpp:
+        (WebCore::SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing):
+        * svg/LinearGradientAttributes.h:
+        (WebCore::LinearGradientAttributes::LinearGradientAttributes):
+        * svg/RadialGradientAttributes.h:
+        (WebCore::RadialGradientAttributes::RadialGradientAttributes):
+        * svg/SVGAngleValue.h:
+        (WebCore::SVGPropertyTraits<SVGAngleValue>::initialValue): Deleted.
+        (WebCore::SVGPropertyTraits<SVGAngleValue>::toString): Deleted.
+        * svg/SVGCircleElement.cpp:
+        (WebCore::SVGCircleElement::parseAttribute):
+        * svg/SVGCircleElement.h:
+        * svg/SVGCursorElement.cpp:
+        (WebCore::SVGCursorElement::parseAttribute):
+        * svg/SVGCursorElement.h:
+        * svg/SVGEllipseElement.cpp:
+        (WebCore::SVGEllipseElement::parseAttribute):
+        * svg/SVGEllipseElement.h:
+        * svg/SVGFilterElement.cpp:
+        (WebCore::SVGFilterElement::parseAttribute):
+        * svg/SVGFilterElement.h:
+        * svg/SVGFilterPrimitiveStandardAttributes.cpp:
+        (WebCore::SVGFilterPrimitiveStandardAttributes::parseAttribute):
+        * svg/SVGFilterPrimitiveStandardAttributes.h:
+        * svg/SVGForeignObjectElement.cpp:
+        (WebCore::SVGForeignObjectElement::parseAttribute):
+        * svg/SVGForeignObjectElement.h:
+        * svg/SVGImageElement.cpp:
+        (WebCore::SVGImageElement::parseAttribute):
+        * svg/SVGImageElement.h:
+        * svg/SVGLength.h:
+        (WebCore::SVGLength::unitType const):
+        (WebCore::SVGLength::setValueForBindings):
+        (WebCore::SVGLength::newValueSpecifiedUnits):
+        (WebCore::SVGLength::convertToSpecifiedUnits):
+        (WebCore::SVGLength::unitType): Deleted.
+        * svg/SVGLengthContext.cpp:
+        (WebCore::SVGLengthContext::valueForLength):
+        (WebCore::SVGLengthContext::convertValueToUserUnits const):
+        (WebCore::SVGLengthContext::convertValueFromUserUnits const):
+        (WebCore::SVGLengthContext::convertValueFromUserUnitsToPercentage const):
+        (WebCore::SVGLengthContext::convertValueFromPercentageToUserUnits const):
+        * svg/SVGLengthContext.h:
+        (): Deleted.
+        * svg/SVGLengthList.h:
+        (WebCore::SVGLengthList::create):
+        * svg/SVGLengthValue.cpp:
+        (WebCore::lengthTypeToString):
+        (WebCore::parseLengthType):
+        (WebCore::primitiveTypeToLengthType):
+        (WebCore::lengthTypeToPrimitiveType):
+        (WebCore::SVGLengthValue::SVGLengthValue):
+        (WebCore::SVGLengthValue::construct):
+        (WebCore::SVGLengthValue::blend):
+        (WebCore::SVGLengthValue::fromCSSPrimitiveValue):
+        (WebCore::SVGLengthValue::toCSSPrimitiveValue):
+        (WebCore::SVGLengthValue::setValueAsString):
+        (WebCore::SVGLengthValue::valueAsString const):
+        (WebCore::SVGLengthValue::valueForBindings const):
+        (WebCore::SVGLengthValue::setValue):
+        (WebCore::SVGLengthValue::convertToSpecifiedUnits):
+        (WebCore::storeUnit): Deleted.
+        (WebCore::extractMode): Deleted.
+        (WebCore::extractType): Deleted.
+        (WebCore::SVGLengthValue::operator== const): Deleted.
+        (WebCore::SVGLengthValue::operator!= const): Deleted.
+        (WebCore::SVGLengthValue::unitType const): Deleted.
+        (WebCore::SVGLengthValue::unitMode const): Deleted.
+        (WebCore::SVGLengthValue::valueAsPercentage const): Deleted.
+        (WebCore::SVGLengthValue::newValueSpecifiedUnits): Deleted.
+        (WebCore::SVGLengthValue::lengthModeForAnimatedLengthAttribute): Deleted.
+        * svg/SVGLengthValue.h:
+        (WebCore::SVGLengthValue::lengthType const):
+        (WebCore::SVGLengthValue::lengthMode const):
+        (WebCore::SVGLengthValue::isZero const):
+        (WebCore::SVGLengthValue::isRelative const):
+        (WebCore::SVGLengthValue::valueAsPercentage const):
+        (WebCore::SVGLengthValue::valueInSpecifiedUnits const):
+        (WebCore::operator==):
+        (WebCore::operator!=):
+        (WebCore::SVGLengthValue::blend const): Deleted.
+        (WebCore::SVGPropertyTraits<SVGLengthValue>::initialValue): Deleted.
+        (WebCore::SVGPropertyTraits<SVGLengthValue>::parse): Deleted.
+        (WebCore::SVGPropertyTraits<SVGLengthValue>::toString): Deleted.
+        * svg/SVGLineElement.cpp:
+        (WebCore::SVGLineElement::parseAttribute):
+        * svg/SVGLineElement.h:
+        * svg/SVGLinearGradientElement.cpp:
+        (WebCore::SVGLinearGradientElement::parseAttribute):
+        * svg/SVGLinearGradientElement.h:
+        * svg/SVGMarkerElement.cpp:
+        (WebCore::SVGMarkerElement::parseAttribute):
+        * svg/SVGMarkerElement.h:
+        * svg/SVGMaskElement.cpp:
+        (WebCore::SVGMaskElement::parseAttribute):
+        * svg/SVGMaskElement.h:
+        * svg/SVGPatternElement.cpp:
+        (WebCore::SVGPatternElement::parseAttribute):
+        * svg/SVGPatternElement.h:
+        * svg/SVGRadialGradientElement.cpp:
+        (WebCore::SVGRadialGradientElement::parseAttribute):
+        * svg/SVGRadialGradientElement.h:
+        * svg/SVGRectElement.cpp:
+        (WebCore::SVGRectElement::parseAttribute):
+        * svg/SVGRectElement.h:
+        * svg/SVGSVGElement.cpp:
+        (WebCore::SVGSVGElement::parseAttribute):
+        (WebCore::SVGSVGElement::hasIntrinsicWidth const):
+        (WebCore::SVGSVGElement::hasIntrinsicHeight const):
+        (WebCore::SVGSVGElement::intrinsicWidth const):
+        (WebCore::SVGSVGElement::intrinsicHeight const):
+        * svg/SVGSVGElement.h:
+        * svg/SVGTextContentElement.cpp:
+        (WebCore::SVGTextContentElement::parseAttribute):
+        (WebCore::SVGTextContentElement::textLengthAnimated):
+        * svg/SVGTextContentElement.h:
+        * svg/SVGTextPathElement.cpp:
+        (WebCore::SVGTextPathElement::parseAttribute):
+        * svg/SVGTextPathElement.h:
+        * svg/SVGTextPositioningElement.h:
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::parseAttribute):
+        * svg/SVGUseElement.h:
+        * svg/properties/SVGAnimatedPropertyAccessorImpl.h:
+        * svg/properties/SVGAnimatedPropertyDescription.h: Removed.
+        * svg/properties/SVGAnimationAdditiveListFunctionImpl.h:
+        (WebCore::SVGAnimationLengthListFunction::animate):
+        * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h:
+        (WebCore::SVGAnimationLengthFunction::animate):
+        * svg/properties/SVGValuePropertyAnimatorImpl.h:
+        * svg/properties/SVGValuePropertyListAnimatorImpl.h:
+
 2019-09-12  Chris Dumez  <cdumez@apple.com>
 
         Node.replaceChild()'s pre-replacement validations are not done in the right order
index f874214..2b1d5ce 100644 (file)
                087558C613B4A57D00F49307 /* SurrogatePairAwareTextIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 087558C413B4A57D00F49307 /* SurrogatePairAwareTextIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0885067F11DA045B00182B98 /* PaintInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 0885067D11DA045B00182B98 /* PaintInfo.h */; settings = {ATTRIBUTES = (Private, ); }; };
                0885068011DA045B00182B98 /* PaintPhase.h in Headers */ = {isa = PBXBuildFile; fileRef = 0885067E11DA045B00182B98 /* PaintPhase.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               088A0E06126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = 088A0DFD126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h */; settings = {ATTRIBUTES = (Private, ); }; };
                088A0E0C126EF1DB00978F7A /* SVGPropertyTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 088A0E03126EF1DB00978F7A /* SVGPropertyTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
                088C2F7A12390081003D65CE /* SVGTextLayoutAttributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 088C2F7612390080003D65CE /* SVGTextLayoutAttributes.h */; };
                089582560E857A7E00F82C83 /* ImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 089582540E857A7E00F82C83 /* ImageLoader.h */; settings = {ATTRIBUTES = (Private, ); }; };
                087558C413B4A57D00F49307 /* SurrogatePairAwareTextIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SurrogatePairAwareTextIterator.h; sourceTree = "<group>"; };
                0885067D11DA045B00182B98 /* PaintInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PaintInfo.h; sourceTree = "<group>"; };
                0885067E11DA045B00182B98 /* PaintPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PaintPhase.h; sourceTree = "<group>"; };
-               088A0DFD126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPropertyDescription.h; sourceTree = "<group>"; };
                088A0E03126EF1DB00978F7A /* SVGPropertyTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPropertyTraits.h; sourceTree = "<group>"; };
                088C2F7512390080003D65CE /* SVGTextLayoutAttributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTextLayoutAttributes.cpp; sourceTree = "<group>"; };
                088C2F7612390080003D65CE /* SVGTextLayoutAttributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTextLayoutAttributes.h; sourceTree = "<group>"; };
                                55EE5358223B29F900FBA944 /* SVGAnimatedPropertyAccessorImpl.h */,
                                55EE535A223B29FB00FBA944 /* SVGAnimatedPropertyAnimator.h */,
                                55EE5356223B29F700FBA944 /* SVGAnimatedPropertyAnimatorImpl.h */,
-                               088A0DFD126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h */,
                                55EE535C223B2A0D00FBA944 /* SVGAnimatedPropertyImpl.h */,
                                7266F02A2243149B00833975 /* SVGAnimatedPropertyList.h */,
                                55BE025E223B29C40032F08A /* SVGAnimatedPropertyPairAccessor.h */,
                                C234A9AE21E92C1A003C984D /* WHLSLCheckDuplicateFunctions.h */,
                                1C840B9B21EC400900D0500D /* WHLSLChecker.cpp */,
                                1C840B9721EC400700D0500D /* WHLSLChecker.h */,
-                               1C281C6D22B87B9800691C00 /* WHLSLCheckTextureReferences.cpp */,
-                               1C281C6E22B87B9800691C00 /* WHLSLCheckTextureReferences.h */,
                                524BD47E23277E15008F56C1 /* WHLSLCheckReferenceTypes.cpp */,
                                524BD48023277E16008F56C1 /* WHLSLCheckReferenceTypes.h */,
+                               1C281C6D22B87B9800691C00 /* WHLSLCheckTextureReferences.cpp */,
+                               1C281C6E22B87B9800691C00 /* WHLSLCheckTextureReferences.h */,
                                522BAB9622E6A36200C54CE9 /* WHLSLCodeLocation.h */,
                                1C86CA4B22AA19FF001BF961 /* WHLSLComputeDimensions.cpp */,
                                1C86CA4C22AA19FF001BF961 /* WHLSLComputeDimensions.h */,
                                24D912B813CA9A6900D21915 /* SVGAltGlyphItemElement.h in Headers */,
                                B22279770D00BF220071B782 /* SVGAngle.h in Headers */,
                                B222797A0D00BF220071B782 /* SVGAnimateColorElement.h in Headers */,
-                               088A0E06126EF1DB00978F7A /* SVGAnimatedPropertyDescription.h in Headers */,
                                B22279900D00BF220071B782 /* SVGAnimateElement.h in Headers */,
                                832B843419D8E55100B26055 /* SVGAnimateElementBase.h in Headers */,
                                B22279930D00BF220071B782 /* SVGAnimateMotionElement.h in Headers */,
index d8ac328..e0c318e 100644 (file)
@@ -78,6 +78,7 @@ class StyleRulePage;
 class StyleSheet;
 class StyleSheetList;
 class StyledElement;
+class SVGElement;
 class SVGSVGElement;
 class ViewportStyleResolver;
 struct ResourceLoaderOptions;
index baeb247..6f64cc6 100644 (file)
@@ -285,7 +285,7 @@ static inline LengthBox blendFunc(const CSSPropertyBlendingClient* anim, const L
 
 static inline SVGLengthValue blendFunc(const CSSPropertyBlendingClient*, const SVGLengthValue& from, const SVGLengthValue& to, double progress)
 {
-    return to.blend(from, narrowPrecisionToFloat(progress));
+    return SVGLengthValue::blend(from, to, narrowPrecisionToFloat(progress));
 }
 
 static inline Vector<SVGLengthValue> blendFunc(const CSSPropertyBlendingClient*, const Vector<SVGLengthValue>& from, const Vector<SVGLengthValue>& to, double progress)
@@ -305,7 +305,7 @@ static inline Vector<SVGLengthValue> blendFunc(const CSSPropertyBlendingClient*,
     }
     Vector<SVGLengthValue> result(resultLength);
     for (size_t i = 0; i < resultLength; ++i)
-        result[i] = to[i % toLength].blend(from[i % fromLength], narrowPrecisionToFloat(progress));
+        result[i] = SVGLengthValue::blend(from[i % fromLength], to[i % toLength], narrowPrecisionToFloat(progress));
     return result;
 }
 
index 4244ca6..9532129 100644 (file)
@@ -82,8 +82,8 @@ public:
     static String initialMarkerMidResource() { return String(); }
     static String initialMarkerEndResource() { return String(); }
     static MaskType initialMaskType() { return MaskType::Luminance; }
-    static SVGLengthValue initialBaselineShiftValue();
-    static SVGLengthValue initialKerning();
+    static SVGLengthValue initialBaselineShiftValue() { return SVGLengthValue(0, SVGLengthType::Number); }
+    static SVGLengthValue initialKerning() { return SVGLengthValue(0, SVGLengthType::Number); }
 
     // SVG CSS Property setters
     void setAlignmentBaseline(AlignmentBaseline val) { m_nonInheritedFlags.flagBits.alignmentBaseline = static_cast<unsigned>(val); }
@@ -256,20 +256,6 @@ private:
     DataRef<StyleResourceData> m_nonInheritedResourceData;
 };
 
-inline SVGLengthValue SVGRenderStyle::initialBaselineShiftValue()
-{
-    SVGLengthValue length;
-    length.newValueSpecifiedUnits(LengthTypeNumber, 0);
-    return length;
-}
-
-inline SVGLengthValue SVGRenderStyle::initialKerning()
-{
-    SVGLengthValue length;
-    length.newValueSpecifiedUnits(LengthTypeNumber, 0);
-    return length;
-}
-
 inline void SVGRenderStyle::setCx(const Length& length)
 {
     if (!(m_layoutData->cx == length))
index 7da9199..177c395 100644 (file)
@@ -79,8 +79,8 @@ void RenderSVGEllipse::calculateRadiiAndCenter()
 {
     SVGLengthContext lengthContext(&graphicsElement());
     m_center = FloatPoint(
-        lengthContext.valueForLength(style().svgStyle().cx(), LengthModeWidth),
-        lengthContext.valueForLength(style().svgStyle().cy(), LengthModeHeight));
+        lengthContext.valueForLength(style().svgStyle().cx(), SVGLengthMode::Width),
+        lengthContext.valueForLength(style().svgStyle().cy(), SVGLengthMode::Height));
     if (is<SVGCircleElement>(graphicsElement())) {
         float radius = lengthContext.valueForLength(style().svgStyle().r());
         m_radii = FloatSize(radius, radius);
@@ -89,8 +89,8 @@ void RenderSVGEllipse::calculateRadiiAndCenter()
 
     ASSERT(is<SVGEllipseElement>(graphicsElement()));
     m_radii = FloatSize(
-        lengthContext.valueForLength(style().svgStyle().rx(), LengthModeWidth),
-        lengthContext.valueForLength(style().svgStyle().ry(), LengthModeHeight));
+        lengthContext.valueForLength(style().svgStyle().rx(), SVGLengthMode::Width),
+        lengthContext.valueForLength(style().svgStyle().ry(), SVGLengthMode::Height));
 }
 
 void RenderSVGEllipse::fillShape(GraphicsContext& context) const
index 4b24dfd..661d219 100644 (file)
@@ -58,7 +58,7 @@ void RenderSVGRect::updateShapeFromElement()
     m_usePathFallback = false;
 
     SVGLengthContext lengthContext(&rectElement());
-    FloatSize boundingBoxSize(lengthContext.valueForLength(style().width(), LengthModeWidth), lengthContext.valueForLength(style().height(), LengthModeHeight));
+    FloatSize boundingBoxSize(lengthContext.valueForLength(style().width(), SVGLengthMode::Width), lengthContext.valueForLength(style().height(), SVGLengthMode::Height));
 
     // Element is invalid if either dimension is negative.
     if (boundingBoxSize.width() < 0 || boundingBoxSize.height() < 0)
@@ -74,8 +74,8 @@ void RenderSVGRect::updateShapeFromElement()
         }
     }
 
-    m_fillBoundingBox = FloatRect(FloatPoint(lengthContext.valueForLength(style().svgStyle().x(), LengthModeWidth),
-        lengthContext.valueForLength(style().svgStyle().y(), LengthModeHeight)),
+    m_fillBoundingBox = FloatRect(FloatPoint(lengthContext.valueForLength(style().svgStyle().x(), SVGLengthMode::Width),
+        lengthContext.valueForLength(style().svgStyle().y(), SVGLengthMode::Height)),
         boundingBoxSize);
 
     // To decide if the stroke contains a point we create two rects which represent the inner and
index 0f8499e..2bab180 100644 (file)
@@ -52,8 +52,8 @@ static Path pathFromCircleElement(const SVGElement& element)
     SVGLengthContext lengthContext(&element);
     float r = lengthContext.valueForLength(style.svgStyle().r());
     if (r > 0) {
-        float cx = lengthContext.valueForLength(style.svgStyle().cx(), LengthModeWidth);
-        float cy = lengthContext.valueForLength(style.svgStyle().cy(), LengthModeHeight);
+        float cx = lengthContext.valueForLength(style.svgStyle().cx(), SVGLengthMode::Width);
+        float cy = lengthContext.valueForLength(style.svgStyle().cy(), SVGLengthMode::Height);
         path.addEllipse(FloatRect(cx - r, cy - r, r * 2, r * 2));
     }
     return path;
@@ -67,17 +67,17 @@ static Path pathFromEllipseElement(const SVGElement& element)
 
     auto& style = renderer->style();
     SVGLengthContext lengthContext(&element);
-    float rx = lengthContext.valueForLength(style.svgStyle().rx(), LengthModeWidth);
+    float rx = lengthContext.valueForLength(style.svgStyle().rx(), SVGLengthMode::Width);
     if (rx <= 0)
         return { };
 
-    float ry = lengthContext.valueForLength(style.svgStyle().ry(), LengthModeHeight);
+    float ry = lengthContext.valueForLength(style.svgStyle().ry(), SVGLengthMode::Height);
     if (ry <= 0)
         return { };
 
     Path path;
-    float cx = lengthContext.valueForLength(style.svgStyle().cx(), LengthModeWidth);
-    float cy = lengthContext.valueForLength(style.svgStyle().cy(), LengthModeHeight);
+    float cx = lengthContext.valueForLength(style.svgStyle().cx(), SVGLengthMode::Width);
+    float cy = lengthContext.valueForLength(style.svgStyle().cy(), SVGLengthMode::Height);
     path.addEllipse(FloatRect(cx - rx, cy - ry, rx * 2, ry * 2));
     return path;
 }
@@ -138,19 +138,19 @@ static Path pathFromRectElement(const SVGElement& element)
 
     auto& style = renderer->style();
     SVGLengthContext lengthContext(&element);
-    float width = lengthContext.valueForLength(style.width(), LengthModeWidth);
+    float width = lengthContext.valueForLength(style.width(), SVGLengthMode::Width);
     if (width <= 0)
         return { };
 
-    float height = lengthContext.valueForLength(style.height(), LengthModeHeight);
+    float height = lengthContext.valueForLength(style.height(), SVGLengthMode::Height);
     if (height <= 0)
         return { };
 
     Path path;
-    float x = lengthContext.valueForLength(style.svgStyle().x(), LengthModeWidth);
-    float y = lengthContext.valueForLength(style.svgStyle().y(), LengthModeHeight);
-    float rx = lengthContext.valueForLength(style.svgStyle().rx(), LengthModeWidth);
-    float ry = lengthContext.valueForLength(style.svgStyle().ry(), LengthModeHeight);
+    float x = lengthContext.valueForLength(style.svgStyle().x(), SVGLengthMode::Width);
+    float y = lengthContext.valueForLength(style.svgStyle().y(), SVGLengthMode::Height);
+    float rx = lengthContext.valueForLength(style.svgStyle().rx(), SVGLengthMode::Width);
+    float ry = lengthContext.valueForLength(style.svgStyle().ry(), SVGLengthMode::Height);
     bool hasRx = rx > 0;
     bool hasRy = ry > 0;
     if (hasRx || hasRy) {
index 0b63d6c..ed57eab 100644 (file)
@@ -37,7 +37,7 @@ float SVGTextLayoutEngineBaseline::calculateBaselineShift(const SVGRenderStyle&
 {
     if (style.baselineShift() == BaselineShift::Length) {
         auto baselineShiftValueLength = style.baselineShiftValue();
-        if (baselineShiftValueLength.unitType() == LengthTypePercentage)
+        if (baselineShiftValueLength.lengthType() == SVGLengthType::Percentage)
             return baselineShiftValueLength.valueAsPercentage() * m_font.pixelSize();
 
         SVGLengthContext lengthContext(context);
index 48d80ae..bcf356a 100644 (file)
@@ -41,7 +41,7 @@ float SVGTextLayoutEngineSpacing::calculateCSSKerningAndSpacing(const SVGRenderS
 {
     float kerning = 0;
     auto kerningLength = style->kerning();
-    if (kerningLength.unitType() == LengthTypePercentage)
+    if (kerningLength.lengthType() == SVGLengthType::Percentage)
         kerning = kerningLength.valueAsPercentage() * m_font.pixelSize();
     else {
         SVGLengthContext lengthContext(contextElement);
index f52019f..6fd95bd 100644 (file)
@@ -26,7 +26,7 @@ struct LinearGradientAttributes : GradientAttributes {
     LinearGradientAttributes()
         : m_x1()
         , m_y1()
-        , m_x2(LengthModeWidth, "100%")
+        , m_x2(SVGLengthMode::Width, "100%")
         , m_y2()
         , m_x1Set(false)
         , m_y1Set(false)
index 87be722..6123dbe 100644 (file)
@@ -25,9 +25,9 @@ namespace WebCore {
 
 struct RadialGradientAttributes : GradientAttributes {
     RadialGradientAttributes()
-        : m_cx(LengthModeWidth, "50%")
-        , m_cy(LengthModeWidth, "50%")
-        , m_r(LengthModeWidth, "50%")
+        : m_cx(SVGLengthMode::Width, "50%")
+        , m_cy(SVGLengthMode::Width, "50%")
+        , m_r(SVGLengthMode::Width, "50%")
         , m_cxSet(false)
         , m_cySet(false)
         , m_rSet(false)
index 4d402f7..cc45441 100644 (file)
@@ -56,10 +56,4 @@ private:
     float m_valueInSpecifiedUnits { 0 };
 };
 
-template<>
-struct SVGPropertyTraits<SVGAngleValue> {
-    static SVGAngleValue initialValue() { return SVGAngleValue(); }
-    static String toString(const SVGAngleValue& type) { return type.valueAsString(); }
-};
-
 }
index d93040a..49d4593 100644 (file)
@@ -54,11 +54,11 @@ void SVGCircleElement::parseAttribute(const QualifiedName& name, const AtomStrin
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::cxAttr)
-        m_cx->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_cx->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::cyAttr)
-        m_cy->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_cy->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::rAttr)
-        m_r->setBaseValInternal(SVGLengthValue::construct(LengthModeOther, value, parseError, ForbidNegativeLengths));
+        m_r->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Other, value, parseError, SVGLengthNegativeValuesMode::Forbid));
 
     reportAttributeParsingError(parseError, name, value);
 
index 720f310..71b7630 100644 (file)
@@ -55,9 +55,9 @@ private:
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_cx { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_cy { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_r { SVGAnimatedLength::create(this, LengthModeOther) };
+    Ref<SVGAnimatedLength> m_cx { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_cy { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_r { SVGAnimatedLength::create(this, SVGLengthMode::Other) };
 };
 
 } // namespace WebCore
index 5cd7d19..2fd5766 100644 (file)
@@ -64,9 +64,9 @@ void SVGCursorElement::parseAttribute(const QualifiedName& name, const AtomStrin
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
 
     reportAttributeParsingError(parseError, name, value);
 
index ed64d5f..5dd4d4b 100644 (file)
@@ -61,8 +61,8 @@ private:
     void addSubresourceAttributeURLs(ListHashSet<URL>&) const final;
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
     HashSet<CSSCursorImageValue*> m_clients;
 };
 
index 8332eb5..adb6cbc 100644 (file)
@@ -55,13 +55,13 @@ void SVGEllipseElement::parseAttribute(const QualifiedName& name, const AtomStri
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::cxAttr)
-        m_cx->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_cx->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::cyAttr)
-        m_cy->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_cy->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::rxAttr)
-        m_rx->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths));
+        m_rx->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError, SVGLengthNegativeValuesMode::Forbid));
     else if (name == SVGNames::ryAttr)
-        m_ry->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
+        m_ry->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError, SVGLengthNegativeValuesMode::Forbid));
 
     reportAttributeParsingError(parseError, name, value);
 
index 303558e..ca07b3f 100644 (file)
@@ -57,10 +57,10 @@ private:
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_cx { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_cy { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_rx { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_ry { SVGAnimatedLength::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLength> m_cx { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_cy { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_rx { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_ry { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
 };
 
 } // namespace WebCore
index 24c6c52..186b771 100644 (file)
@@ -76,13 +76,13 @@ void SVGFilterElement::parseAttribute(const QualifiedName& name, const AtomStrin
         if (propertyValue > 0)
             m_primitiveUnits->setBaseValInternal<SVGUnitTypes::SVGUnitType>(propertyValue);
     } else if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::widthAttr)
-        m_width->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_width->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::heightAttr)
-        m_height->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_height->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
 
     reportAttributeParsingError(parseError, name, value);
 
index 1589a6c..5903209 100644 (file)
@@ -69,10 +69,10 @@ private:
     PropertyRegistry m_propertyRegistry { *this };
     Ref<SVGAnimatedEnumeration> m_filterUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) };
     Ref<SVGAnimatedEnumeration> m_primitiveUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) };
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth, "-10%") };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight, "-10%") };
-    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth, "120%") };
-    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight, "120%") };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width, "-10%") };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height, "-10%") };
+    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, SVGLengthMode::Width, "120%") };
+    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height, "120%") };
 };
 
 } // namespace WebCore
index 364cb28..30da434 100644 (file)
@@ -51,13 +51,13 @@ void SVGFilterPrimitiveStandardAttributes::parseAttribute(const QualifiedName& n
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::widthAttr)
-        m_width->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_width->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::heightAttr)
-        m_height->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_height->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::resultAttr)
         m_result->setBaseValInternal(value);
 
index c2816da..c98b13e 100644 (file)
@@ -75,10 +75,10 @@ private:
 
     // Spec: If the x/y attribute is not specified, the effect is as if a value of "0%" were specified.
     // Spec: If the width/height attribute is not specified, the effect is as if a value of "100%" were specified.
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth, "0%") };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight, "0%") };
-    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth, "100%") };
-    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight, "100%") };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width, "0%") };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height, "0%") };
+    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, SVGLengthMode::Width, "100%") };
+    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height, "100%") };
     Ref<SVGAnimatedString> m_result { SVGAnimatedString::create(this) };
 };
 
index 5acd5fc..7ff3b86 100644 (file)
@@ -59,13 +59,13 @@ void SVGForeignObjectElement::parseAttribute(const QualifiedName& name, const At
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::widthAttr)
-        m_width->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_width->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::heightAttr)
-        m_height->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_height->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
 
     reportAttributeParsingError(parseError, name, value);
 
index 02a194c..db20433 100644 (file)
@@ -58,10 +58,10 @@ private:
     bool selfHasRelativeLengths() const final { return true; }
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
 };
 
 } // namespace WebCore
index 9670e26..7b64a02 100644 (file)
@@ -79,13 +79,13 @@ void SVGImageElement::parseAttribute(const QualifiedName& name, const AtomString
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::widthAttr)
-        m_width->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths));
+        m_width->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError, SVGLengthNegativeValuesMode::Forbid));
     else if (name == SVGNames::heightAttr)
-        m_height->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
+        m_height->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError, SVGLengthNegativeValuesMode::Forbid));
 
     reportAttributeParsingError(parseError, name, value);
 
index 9fb5786..eaff618 100644 (file)
@@ -69,10 +69,10 @@ private:
     void didMoveToNewDocument(Document& oldDocument, Document& newDocument) final;
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
     Ref<SVGAnimatedPreserveAspectRatio> m_preserveAspectRatio { SVGAnimatedPreserveAspectRatio::create(this) };
     SVGImageLoader m_imageLoader;
 };
index ff0fd35..ed50038 100644 (file)
@@ -25,6 +25,7 @@
 
 #pragma once
 
+#include "SVGLengthContext.h"
 #include "SVGLengthValue.h"
 #include "SVGValueProperty.h"
 
@@ -38,17 +39,17 @@ class SVGLength : public SVGValueProperty<SVGLengthValue> {
 public:
     // Forward declare these enums in the w3c naming scheme, for IDL generation
     enum {
-        SVG_LENGTHTYPE_UNKNOWN = LengthTypeUnknown,
-        SVG_LENGTHTYPE_NUMBER = LengthTypeNumber,
-        SVG_LENGTHTYPE_PERCENTAGE = LengthTypePercentage,
-        SVG_LENGTHTYPE_EMS = LengthTypeEMS,
-        SVG_LENGTHTYPE_EXS = LengthTypeEXS,
-        SVG_LENGTHTYPE_PX = LengthTypePX,
-        SVG_LENGTHTYPE_CM = LengthTypeCM,
-        SVG_LENGTHTYPE_MM = LengthTypeMM,
-        SVG_LENGTHTYPE_IN = LengthTypeIN,
-        SVG_LENGTHTYPE_PT = LengthTypePT,
-        SVG_LENGTHTYPE_PC = LengthTypePC
+        SVG_LENGTHTYPE_UNKNOWN      = static_cast<unsigned>(SVGLengthType::Unknown),
+        SVG_LENGTHTYPE_NUMBER       = static_cast<unsigned>(SVGLengthType::Number),
+        SVG_LENGTHTYPE_PERCENTAGE   = static_cast<unsigned>(SVGLengthType::Percentage),
+        SVG_LENGTHTYPE_EMS          = static_cast<unsigned>(SVGLengthType::Ems),
+        SVG_LENGTHTYPE_EXS          = static_cast<unsigned>(SVGLengthType::Exs),
+        SVG_LENGTHTYPE_PX           = static_cast<unsigned>(SVGLengthType::Pixels),
+        SVG_LENGTHTYPE_CM           = static_cast<unsigned>(SVGLengthType::Centimeters),
+        SVG_LENGTHTYPE_MM           = static_cast<unsigned>(SVGLengthType::Millimeters),
+        SVG_LENGTHTYPE_IN           = static_cast<unsigned>(SVGLengthType::Inches),
+        SVG_LENGTHTYPE_PT           = static_cast<unsigned>(SVGLengthType::Points),
+        SVG_LENGTHTYPE_PC           = static_cast<unsigned>(SVGLengthType::Picas)
     };
 
     static Ref<SVGLength> create()
@@ -79,9 +80,9 @@ public:
         return SVGLength::create(m_value);
     }
 
-    unsigned short unitType()
+    unsigned short unitType()  const
     {
-        return m_value.unitType();
+        return static_cast<unsigned>(m_value.lengthType());
     }
 
     ExceptionOr<float> valueForBindings()
@@ -94,7 +95,7 @@ public:
         if (isReadOnly())
             return Exception { NoModificationAllowedError };
 
-        auto result = m_value.setValue(value, SVGLengthContext { contextElement() });
+        auto result = m_value.setValue(SVGLengthContext { contextElement() }, value);
         if (result.hasException())
             return result;
         
@@ -135,12 +136,12 @@ public:
         if (isReadOnly())
             return Exception { NoModificationAllowedError };
 
-        auto result = m_value.newValueSpecifiedUnits(unitType, valueInSpecifiedUnits);
-        if (result.hasException())
-            return result;
-        
+        if (unitType == SVG_LENGTHTYPE_UNKNOWN || unitType > SVG_LENGTHTYPE_PC)
+            return Exception { NotSupportedError };
+
+        m_value = { valueInSpecifiedUnits, static_cast<SVGLengthType>(unitType), m_value.lengthMode() };
         commitChange();
-        return result;
+        return { };
     }
     
     ExceptionOr<void> convertToSpecifiedUnits(unsigned short unitType)
@@ -148,10 +149,13 @@ public:
         if (isReadOnly())
             return Exception { NoModificationAllowedError };
 
-        auto result = m_value.convertToSpecifiedUnits(unitType, SVGLengthContext { contextElement() });
+        if (unitType == SVG_LENGTHTYPE_UNKNOWN || unitType > SVG_LENGTHTYPE_PC)
+            return Exception { NotSupportedError };
+
+        auto result = m_value.convertToSpecifiedUnits(SVGLengthContext { contextElement() }, static_cast<SVGLengthType>(unitType));
         if (result.hasException())
             return result;
-        
+
         commitChange();
         return result;
     }
index 0800017..2322fa2 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
  * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2019 Apple Inc. All rights reserved.
  * Copyright (C) Research In Motion Limited 2011. All rights reserved.
  * Copyright (C) 2014 Adobe Systems Incorporated. All rights reserved.
  *
@@ -85,10 +85,10 @@ float SVGLengthContext::resolveLength(const SVGElement* context, SVGUnitTypes::S
     return x.valueAsPercentage();
 }
 
-float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode)
+float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode lengthMode)
 {
     if (length.isPercent()) {
-        auto result = convertValueFromPercentageToUserUnits(length.value() / 100, mode);
+        auto result = convertValueFromPercentageToUserUnits(length.value() / 100, lengthMode);
         if (result.hasException())
             return 0;
         return result.releaseReturnValue();
@@ -99,49 +99,49 @@ float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode)
     FloatSize viewportSize;
     determineViewport(viewportSize);
 
-    switch (mode) {
-    case LengthModeWidth:
+    switch (lengthMode) {
+    case SVGLengthMode::Width:
         return floatValueForLength(length, viewportSize.width());
-    case LengthModeHeight:
+    case SVGLengthMode::Height:
         return floatValueForLength(length, viewportSize.height());
-    case LengthModeOther:
+    case SVGLengthMode::Other:
         return floatValueForLength(length, std::sqrt(viewportSize.diagonalLengthSquared() / 2));
     };
     return 0;
 }
 
-ExceptionOr<float> SVGLengthContext::convertValueToUserUnits(float value, SVGLengthMode mode, SVGLengthType fromUnit) const
+ExceptionOr<float> SVGLengthContext::convertValueToUserUnits(float value, SVGLengthType lengthType, SVGLengthMode lengthMode) const
 {
     // If the SVGLengthContext carries a custom viewport, force resolving against it.
     if (!m_overriddenViewport.isEmpty()) {
         // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
-        if (fromUnit == LengthTypePercentage)
+        if (lengthType == SVGLengthType::Percentage)
             value /= 100;
-        return convertValueFromPercentageToUserUnits(value, mode);
+        return convertValueFromPercentageToUserUnits(value, lengthMode);
     }
 
-    switch (fromUnit) {
-    case LengthTypeUnknown:
+    switch (lengthType) {
+    case SVGLengthType::Unknown:
         return Exception { NotSupportedError };
-    case LengthTypeNumber:
+    case SVGLengthType::Number:
         return value;
-    case LengthTypePX:
+    case SVGLengthType::Pixels:
         return value;
-    case LengthTypePercentage:
-        return convertValueFromPercentageToUserUnits(value / 100, mode);
-    case LengthTypeEMS:
+    case SVGLengthType::Percentage:
+        return convertValueFromPercentageToUserUnits(value / 100, lengthMode);
+    case SVGLengthType::Ems:
         return convertValueFromEMSToUserUnits(value);
-    case LengthTypeEXS:
+    case SVGLengthType::Exs:
         return convertValueFromEXSToUserUnits(value);
-    case LengthTypeCM:
+    case SVGLengthType::Centimeters:
         return value * cssPixelsPerInch / 2.54f;
-    case LengthTypeMM:
+    case SVGLengthType::Millimeters:
         return value * cssPixelsPerInch / 25.4f;
-    case LengthTypeIN:
+    case SVGLengthType::Inches:
         return value * cssPixelsPerInch;
-    case LengthTypePT:
+    case SVGLengthType::Points:
         return value * cssPixelsPerInch / 72;
-    case LengthTypePC:
+    case SVGLengthType::Picas:
         return value * cssPixelsPerInch / 6;
     }
 
@@ -149,30 +149,30 @@ ExceptionOr<float> SVGLengthContext::convertValueToUserUnits(float value, SVGLen
     return 0;
 }
 
-ExceptionOr<float> SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthMode mode, SVGLengthType toUnit) const
+ExceptionOr<float> SVGLengthContext::convertValueFromUserUnits(float value, SVGLengthType lengthType, SVGLengthMode lengthMode) const
 {
-    switch (toUnit) {
-    case LengthTypeUnknown:
+    switch (lengthType) {
+    case SVGLengthType::Unknown:
         return Exception { NotSupportedError };
-    case LengthTypeNumber:
+    case SVGLengthType::Number:
         return value;
-    case LengthTypePercentage:
-        return convertValueFromUserUnitsToPercentage(value * 100, mode);
-    case LengthTypeEMS:
+    case SVGLengthType::Percentage:
+        return convertValueFromUserUnitsToPercentage(value * 100, lengthMode);
+    case SVGLengthType::Ems:
         return convertValueFromUserUnitsToEMS(value);
-    case LengthTypeEXS:
+    case SVGLengthType::Exs:
         return convertValueFromUserUnitsToEXS(value);
-    case LengthTypePX:
+    case SVGLengthType::Pixels:
         return value;
-    case LengthTypeCM:
+    case SVGLengthType::Centimeters:
         return value * 2.54f / cssPixelsPerInch;
-    case LengthTypeMM:
+    case SVGLengthType::Millimeters:
         return value * 25.4f / cssPixelsPerInch;
-    case LengthTypeIN:
+    case SVGLengthType::Inches:
         return value / cssPixelsPerInch;
-    case LengthTypePT:
+    case SVGLengthType::Points:
         return value * 72 / cssPixelsPerInch;
-    case LengthTypePC:
+    case SVGLengthType::Picas:
         return value * 6 / cssPixelsPerInch;
     }
 
@@ -180,18 +180,18 @@ ExceptionOr<float> SVGLengthContext::convertValueFromUserUnits(float value, SVGL
     return 0;
 }
 
-ExceptionOr<float> SVGLengthContext::convertValueFromUserUnitsToPercentage(float value, SVGLengthMode mode) const
+ExceptionOr<float> SVGLengthContext::convertValueFromUserUnitsToPercentage(float value, SVGLengthMode lengthMode) const
 {
     FloatSize viewportSize;
     if (!determineViewport(viewportSize))
         return Exception { NotSupportedError };
 
-    switch (mode) {
-    case LengthModeWidth:
+    switch (lengthMode) {
+    case SVGLengthMode::Width:
         return value / viewportSize.width() * 100;
-    case LengthModeHeight:
+    case SVGLengthMode::Height:
         return value / viewportSize.height() * 100;
-    case LengthModeOther:
+    case SVGLengthMode::Other:
         return value / (std::sqrt(viewportSize.diagonalLengthSquared() / 2)) * 100;
     };
 
@@ -199,18 +199,18 @@ ExceptionOr<float> SVGLengthContext::convertValueFromUserUnitsToPercentage(float
     return 0;
 }
 
-ExceptionOr<float> SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLengthMode mode) const
+ExceptionOr<float> SVGLengthContext::convertValueFromPercentageToUserUnits(float value, SVGLengthMode lengthMode) const
 {
     FloatSize viewportSize;
     if (!determineViewport(viewportSize))
         return Exception { NotSupportedError };
 
-    switch (mode) {
-    case LengthModeWidth:
+    switch (lengthMode) {
+    case SVGLengthMode::Width:
         return value * viewportSize.width();
-    case LengthModeHeight:
+    case SVGLengthMode::Height:
         return value * viewportSize.height();
-    case LengthModeOther:
+    case SVGLengthMode::Other:
         return value * std::sqrt(viewportSize.diagonalLengthSquared() / 2);
     };
 
index 8e97e21..d3cc4fa 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) Research In Motion Limited 2011. All rights reserved.
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 #include "ExceptionOr.h"
 #include "FloatRect.h"
+#include "SVGLengthValue.h"
 #include "SVGUnitTypes.h"
 
 namespace WebCore {
 
 class SVGElement;
-class SVGLengthValue;
 
 struct Length;
 
-enum SVGLengthType {
-    LengthTypeUnknown = 0,
-    LengthTypeNumber,
-    LengthTypePercentage,
-    LengthTypeEMS,
-    LengthTypeEXS,
-    LengthTypePX,
-    LengthTypeCM,
-    LengthTypeMM,
-    LengthTypeIN,
-    LengthTypePT,
-    LengthTypePC
-};
-
-enum SVGLengthMode {
-    LengthModeWidth = 0,
-    LengthModeHeight,
-    LengthModeOther
-};
-
 class SVGLengthContext {
 public:
     explicit SVGLengthContext(const SVGElement*);
@@ -64,9 +45,9 @@ public:
     static FloatPoint resolvePoint(const SVGElement*, SVGUnitTypes::SVGUnitType, const SVGLengthValue& x, const SVGLengthValue& y);
     static float resolveLength(const SVGElement*, SVGUnitTypes::SVGUnitType, const SVGLengthValue&);
 
-    float valueForLength(const Length&, SVGLengthMode = LengthModeOther);
-    ExceptionOr<float> convertValueToUserUnits(float, SVGLengthMode, SVGLengthType fromUnit) const;
-    ExceptionOr<float> convertValueFromUserUnits(float, SVGLengthMode, SVGLengthType toUnit) const;
+    float valueForLength(const Length&, SVGLengthMode = SVGLengthMode::Other);
+    ExceptionOr<float> convertValueToUserUnits(float, SVGLengthType, SVGLengthMode) const;
+    ExceptionOr<float> convertValueFromUserUnits(float, SVGLengthType, SVGLengthMode) const;
 
     bool determineViewport(FloatSize&) const;
 
index b0147fa..5eb5701 100644 (file)
@@ -35,7 +35,7 @@ class SVGLengthList : public SVGValuePropertyList<SVGLength> {
     using Base::Base;
 
 public:
-    static Ref<SVGLengthList> create(SVGLengthMode lengthMode = LengthModeOther)
+    static Ref<SVGLengthList> create(SVGLengthMode lengthMode = SVGLengthMode::Other)
     {
         return adoptRef(*new SVGLengthList(lengthMode));
     }
@@ -110,7 +110,7 @@ private:
     {
     }
 
-    SVGLengthMode m_lengthMode { LengthModeOther };
+    SVGLengthMode m_lengthMode { SVGLengthMode::Other };
 };
 
 } // namespace WebCore
index dd2ede1..ab6b149 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright (C) 2004, 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
  * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
- * Copyright (C) 2007 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2019 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 #include "config.h"
 #include "SVGLengthValue.h"
 
-#include "CSSHelper.h"
+#include "AnimationUtilities.h"
 #include "CSSPrimitiveValue.h"
-#include "FloatConversion.h"
-#include "SVGNames.h"
 #include "SVGParserUtilities.h"
-#include <wtf/MathExtras.h>
-#include <wtf/NeverDestroyed.h>
 #include <wtf/text/StringConcatenateNumbers.h>
 #include <wtf/text/TextStream.h>
 
 namespace WebCore {
 
-// Helper functions
-static inline unsigned storeUnit(SVGLengthMode mode, SVGLengthType type)
+static inline const char* lengthTypeToString(SVGLengthType lengthType)
 {
-    return (mode << 4) | type;
-}
-
-static inline SVGLengthMode extractMode(unsigned unit)
-{
-    unsigned mode = unit >> 4;    
-    return static_cast<SVGLengthMode>(mode);
-}
-
-static inline SVGLengthType extractType(unsigned unit)
-{
-    return static_cast<SVGLengthType>(unit & ((1 << 4) - 1));
-}
-
-static inline const char* lengthTypeToString(SVGLengthType type)
-{
-    switch (type) {
-    case LengthTypeUnknown:
-    case LengthTypeNumber:
+    switch (lengthType) {
+    case SVGLengthType::Unknown:
+    case SVGLengthType::Number:
         return "";    
-    case LengthTypePercentage:
+    case SVGLengthType::Percentage:
         return "%";
-    case LengthTypeEMS:
+    case SVGLengthType::Ems:
         return "em";
-    case LengthTypeEXS:
+    case SVGLengthType::Exs:
         return "ex";
-    case LengthTypePX:
+    case SVGLengthType::Pixels:
         return "px";
-    case LengthTypeCM:
+    case SVGLengthType::Centimeters:
         return "cm";
-    case LengthTypeMM:
+    case SVGLengthType::Millimeters:
         return "mm";
-    case LengthTypeIN:
+    case SVGLengthType::Inches:
         return "in";
-    case LengthTypePT:
+    case SVGLengthType::Points:
         return "pt";
-    case LengthTypePC:
+    case SVGLengthType::Picas:
         return "pc";
     }
 
@@ -81,90 +60,187 @@ static inline const char* lengthTypeToString(SVGLengthType type)
     return "";
 }
 
-inline SVGLengthType parseLengthType(const UChar* ptr, const UChar* end)
+static inline SVGLengthType parseLengthType(const UChar* ptr, const UChar* end)
 {
     if (ptr == end)
-        return LengthTypeNumber;
+        return SVGLengthType::Number;
 
     const UChar firstChar = *ptr;
 
     if (++ptr == end)
-        return firstChar == '%' ? LengthTypePercentage : LengthTypeUnknown;
+        return firstChar == '%' ? SVGLengthType::Percentage : SVGLengthType::Unknown;
 
     const UChar secondChar = *ptr;
 
     if (++ptr != end)
-        return LengthTypeUnknown;
+        return SVGLengthType::Unknown;
 
     if (firstChar == 'e' && secondChar == 'm')
-        return LengthTypeEMS;
+        return SVGLengthType::Ems;
     if (firstChar == 'e' && secondChar == 'x')
-        return LengthTypeEXS;
+        return SVGLengthType::Exs;
     if (firstChar == 'p' && secondChar == 'x')
-        return LengthTypePX;
+        return SVGLengthType::Pixels;
     if (firstChar == 'c' && secondChar == 'm')
-        return LengthTypeCM;
+        return SVGLengthType::Centimeters;
     if (firstChar == 'm' && secondChar == 'm')
-        return LengthTypeMM;
+        return SVGLengthType::Millimeters;
     if (firstChar == 'i' && secondChar == 'n')
-        return LengthTypeIN;
+        return SVGLengthType::Inches;
     if (firstChar == 'p' && secondChar == 't')
-        return LengthTypePT;
+        return SVGLengthType::Points;
     if (firstChar == 'p' && secondChar == 'c')
-        return LengthTypePC;
+        return SVGLengthType::Picas;
 
-    return LengthTypeUnknown;
+    return SVGLengthType::Unknown;
 }
 
-SVGLengthValue::SVGLengthValue(SVGLengthMode mode, const String& valueAsString)
-    : m_unit(storeUnit(mode, LengthTypeNumber))
+static inline SVGLengthType primitiveTypeToLengthType(unsigned short primitiveType)
 {
-    setValueAsString(valueAsString);
+    switch (primitiveType) {
+    case CSSPrimitiveValue::CSS_UNKNOWN:
+        return SVGLengthType::Unknown;
+    case CSSPrimitiveValue::CSS_NUMBER:
+        return SVGLengthType::Number;
+    case CSSPrimitiveValue::CSS_PERCENTAGE:
+        return SVGLengthType::Percentage;
+    case CSSPrimitiveValue::CSS_EMS:
+        return SVGLengthType::Ems;
+    case CSSPrimitiveValue::CSS_EXS:
+        return SVGLengthType::Exs;
+    case CSSPrimitiveValue::CSS_PX:
+        return SVGLengthType::Pixels;
+    case CSSPrimitiveValue::CSS_CM:
+        return SVGLengthType::Centimeters;
+    case CSSPrimitiveValue::CSS_MM:
+        return SVGLengthType::Millimeters;
+    case CSSPrimitiveValue::CSS_IN:
+        return SVGLengthType::Inches;
+    case CSSPrimitiveValue::CSS_PT:
+        return SVGLengthType::Points;
+    case CSSPrimitiveValue::CSS_PC:
+        return SVGLengthType::Picas;
+    }
+
+    return SVGLengthType::Unknown;
 }
 
-SVGLengthValue::SVGLengthValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType)
-    : m_unit(storeUnit(mode, unitType))
+static inline CSSPrimitiveValue::UnitType lengthTypeToPrimitiveType(SVGLengthType lengthType)
 {
-    setValue(value, context);
+    switch (lengthType) {
+    case SVGLengthType::Unknown:
+        return CSSPrimitiveValue::CSS_UNKNOWN;
+    case SVGLengthType::Number:
+        return CSSPrimitiveValue::CSS_NUMBER;
+    case SVGLengthType::Percentage:
+        return CSSPrimitiveValue::CSS_PERCENTAGE;
+    case SVGLengthType::Ems:
+        return CSSPrimitiveValue::CSS_EMS;
+    case SVGLengthType::Exs:
+        return CSSPrimitiveValue::CSS_EXS;
+    case SVGLengthType::Pixels:
+        return CSSPrimitiveValue::CSS_PX;
+    case SVGLengthType::Centimeters:
+        return CSSPrimitiveValue::CSS_CM;
+    case SVGLengthType::Millimeters:
+        return CSSPrimitiveValue::CSS_MM;
+    case SVGLengthType::Inches:
+        return CSSPrimitiveValue::CSS_IN;
+    case SVGLengthType::Points:
+        return CSSPrimitiveValue::CSS_PT;
+    case SVGLengthType::Picas:
+        return CSSPrimitiveValue::CSS_PC;
+    }
+
+    ASSERT_NOT_REACHED();
+    return CSSPrimitiveValue::CSS_UNKNOWN;
 }
 
-ExceptionOr<void> SVGLengthValue::setValueAsString(const String& valueAsString, SVGLengthMode mode)
+SVGLengthValue::SVGLengthValue(SVGLengthMode lengthMode, const String& valueAsString)
+    : m_lengthMode(lengthMode)
 {
-    m_valueInSpecifiedUnits = 0;
-    m_unit = storeUnit(mode, LengthTypeNumber);
-    return setValueAsString(valueAsString);
+    setValueAsString(valueAsString);
 }
 
-bool SVGLengthValue::operator==(const SVGLengthValue& other) const
+SVGLengthValue::SVGLengthValue(float valueInSpecifiedUnits, SVGLengthType lengthType, SVGLengthMode lengthMode)
+    : m_valueInSpecifiedUnits(valueInSpecifiedUnits)
+    , m_lengthType(lengthType)
+    , m_lengthMode(lengthMode)
 {
-    return m_unit == other.m_unit && m_valueInSpecifiedUnits == other.m_valueInSpecifiedUnits;
+    ASSERT(m_lengthType != SVGLengthType::Unknown);
 }
 
-bool SVGLengthValue::operator!=(const SVGLengthValue& other) const
+SVGLengthValue::SVGLengthValue(const SVGLengthContext& context, float value, SVGLengthType lengthType, SVGLengthMode lengthMode)
+    : m_lengthType(lengthType)
+    , m_lengthMode(lengthMode)
 {
-    return !operator==(other);
+    setValue(context, value);
 }
 
-SVGLengthValue SVGLengthValue::construct(SVGLengthMode mode, const String& valueAsString, SVGParsingError& parseError, SVGLengthNegativeValuesMode negativeValuesMode)
+SVGLengthValue SVGLengthValue::construct(SVGLengthMode lengthMode, const String& valueAsString, SVGParsingError& parseError, SVGLengthNegativeValuesMode negativeValuesMode)
 {
-    SVGLengthValue length(mode);
+    SVGLengthValue length(lengthMode);
 
     if (length.setValueAsString(valueAsString).hasException())
         parseError = ParsingAttributeFailedError;
-    else if (negativeValuesMode == ForbidNegativeLengths && length.valueInSpecifiedUnits() < 0)
+    else if (negativeValuesMode == SVGLengthNegativeValuesMode::Forbid && length.valueInSpecifiedUnits() < 0)
         parseError = NegativeValueForbiddenError;
 
     return length;
 }
 
-SVGLengthType SVGLengthValue::unitType() const
+SVGLengthValue SVGLengthValue::blend(const SVGLengthValue& from, const SVGLengthValue& to, float progress)
 {
-    return extractType(m_unit);
+    if ((from.isZero() && to.isZero())
+        || from.lengthType() == SVGLengthType::Unknown
+        || to.lengthType() == SVGLengthType::Unknown
+        || (!from.isZero() && from.lengthType() != SVGLengthType::Percentage && to.lengthType() == SVGLengthType::Percentage)
+        || (!to.isZero() && from.lengthType() == SVGLengthType::Percentage && to.lengthType() != SVGLengthType::Percentage)
+        || (!from.isZero() && !to.isZero() && (from.lengthType() == SVGLengthType::Ems || from.lengthType() == SVGLengthType::Exs) && from.lengthType() != to.lengthType()))
+        return to;
+
+    if (from.lengthType() == SVGLengthType::Percentage || to.lengthType() == SVGLengthType::Percentage) {
+        auto fromPercent = from.valueAsPercentage() * 100;
+        auto toPercent = to.valueAsPercentage() * 100;
+        return { WebCore::blend(fromPercent, toPercent, progress), SVGLengthType::Percentage };
+    }
+
+    if (from.lengthType() == to.lengthType() || from.isZero() || to.isZero() || from.isRelative()) {
+        auto fromValue = from.valueInSpecifiedUnits();
+        auto toValue = to.valueInSpecifiedUnits();
+        return { WebCore::blend(fromValue, toValue, progress), to.isZero() ? from.lengthType() : to.lengthType() };
+    }
+
+    SVGLengthContext nonRelativeLengthContext(nullptr);
+    auto fromValueInUserUnits = nonRelativeLengthContext.convertValueToUserUnits(from.valueInSpecifiedUnits(), from.lengthType(), from.lengthMode());
+    if (fromValueInUserUnits.hasException())
+        return { };
+
+    auto fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fromValueInUserUnits.releaseReturnValue(), to.lengthType(), to.lengthMode());
+    if (fromValue.hasException())
+        return { };
+
+    float toValue = to.valueInSpecifiedUnits();
+    return { WebCore::blend(fromValue.releaseReturnValue(), toValue, progress), to.lengthType() };
 }
 
-SVGLengthMode SVGLengthValue::unitMode() const
+SVGLengthValue SVGLengthValue::fromCSSPrimitiveValue(const CSSPrimitiveValue& value)
 {
-    return extractMode(m_unit);
+    SVGLengthType lengthType = primitiveTypeToLengthType(value.primitiveType());
+    return lengthType == SVGLengthType::Unknown ? SVGLengthValue() : SVGLengthValue(value.floatValue(), lengthType);
+}
+
+Ref<CSSPrimitiveValue> SVGLengthValue::toCSSPrimitiveValue(const SVGLengthValue& length)
+{
+    return CSSPrimitiveValue::create(length.valueInSpecifiedUnits(), lengthTypeToPrimitiveType(length.lengthType()));
+}
+
+ExceptionOr<void> SVGLengthValue::setValueAsString(const String& valueAsString, SVGLengthMode lengthMode)
+{
+    m_valueInSpecifiedUnits = 0;
+    m_lengthMode = lengthMode;
+    m_lengthType = SVGLengthType::Number;
+    return setValueAsString(valueAsString);
 }
 
 float SVGLengthValue::value(const SVGLengthContext& context) const
@@ -175,37 +251,35 @@ float SVGLengthValue::value(const SVGLengthContext& context) const
     return result.releaseReturnValue();
 }
 
-ExceptionOr<float> SVGLengthValue::valueForBindings(const SVGLengthContext& context) const
+String SVGLengthValue::valueAsString() const
 {
-    return context.convertValueToUserUnits(m_valueInSpecifiedUnits, extractMode(m_unit), extractType(m_unit));
+    return makeString(FormattedNumber::fixedPrecision(m_valueInSpecifiedUnits), lengthTypeToString(m_lengthType));
 }
 
-ExceptionOr<void> SVGLengthValue::setValue(const SVGLengthContext& context, float value, SVGLengthMode mode, SVGLengthType unitType)
+ExceptionOr<float> SVGLengthValue::valueForBindings(const SVGLengthContext& context) const
 {
-    // FIXME: Seems like a bug that we change the value of m_unit even if setValue throws an exception.
-    m_unit = storeUnit(mode, unitType);
-    return setValue(value, context);
+    return context.convertValueToUserUnits(m_valueInSpecifiedUnits, m_lengthType, m_lengthMode);
 }
 
-ExceptionOr<void> SVGLengthValue::setValue(float value, const SVGLengthContext& context)
+ExceptionOr<void> SVGLengthValue::setValue(const SVGLengthContext& context, float value)
 {
     // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
-    if (extractType(m_unit) == LengthTypePercentage)
+    if (m_lengthType == SVGLengthType::Percentage)
         value = value / 100;
 
-    auto convertedValue = context.convertValueFromUserUnits(value, extractMode(m_unit), extractType(m_unit));
+    auto convertedValue = context.convertValueFromUserUnits(value, m_lengthType, m_lengthMode);
     if (convertedValue.hasException())
         return convertedValue.releaseException();
     m_valueInSpecifiedUnits = convertedValue.releaseReturnValue();
     return { };
 }
-float SVGLengthValue::valueAsPercentage() const
-{
-    // 100% = 100.0 instead of 1.0 for historical reasons, this could eventually be changed
-    if (extractType(m_unit) == LengthTypePercentage)
-        return m_valueInSpecifiedUnits / 100;
 
-    return m_valueInSpecifiedUnits;
+ExceptionOr<void> SVGLengthValue::setValue(const SVGLengthContext& context, float value, SVGLengthType lengthType, SVGLengthMode lengthMode)
+{
+    // FIXME: Seems like a bug that we change the value of m_unit even if setValue throws an exception.
+    m_lengthMode = lengthMode;
+    m_lengthType = lengthType;
+    return setValue(context, value);
 }
 
 ExceptionOr<void> SVGLengthValue::setValueAsString(const String& string)
@@ -221,175 +295,29 @@ ExceptionOr<void> SVGLengthValue::setValueAsString(const String& string)
     if (!parseNumber(ptr, end, convertedNumber, false))
         return Exception { SyntaxError };
 
-    auto type = parseLengthType(ptr, end);
-    if (type == LengthTypeUnknown)
+    auto lengthType = parseLengthType(ptr, end);
+    if (lengthType == SVGLengthType::Unknown)
         return Exception { SyntaxError };
 
-    m_unit = storeUnit(extractMode(m_unit), type);
+    m_lengthType = lengthType;
     m_valueInSpecifiedUnits = convertedNumber;
     return { };
 }
 
-String SVGLengthValue::valueAsString() const
+ExceptionOr<void> SVGLengthValue::convertToSpecifiedUnits(const SVGLengthContext& context, SVGLengthType lengthType)
 {
-    return makeString(FormattedNumber::fixedPrecision(m_valueInSpecifiedUnits), lengthTypeToString(extractType(m_unit)));
-}
-
-ExceptionOr<void> SVGLengthValue::newValueSpecifiedUnits(unsigned short type, float value)
-{
-    if (type == LengthTypeUnknown || type > LengthTypePC)
-        return Exception { NotSupportedError };
-
-    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
-    m_valueInSpecifiedUnits = value;
-    return { };
-}
-
-ExceptionOr<void> SVGLengthValue::convertToSpecifiedUnits(unsigned short type, const SVGLengthContext& context)
-{
-    if (type == LengthTypeUnknown || type > LengthTypePC)
-        return Exception { NotSupportedError };
-
     auto valueInUserUnits = valueForBindings(context);
     if (valueInUserUnits.hasException())
         return valueInUserUnits.releaseException();
 
-    auto originalUnitAndType = m_unit;
-    m_unit = storeUnit(extractMode(m_unit), static_cast<SVGLengthType>(type));
-    auto result = setValue(valueInUserUnits.releaseReturnValue(), context);
-    if (result.hasException()) {
-        m_unit = originalUnitAndType;
-        return result.releaseException();
-    }
-
-    return { };
-}
-
-SVGLengthValue SVGLengthValue::fromCSSPrimitiveValue(const CSSPrimitiveValue& value)
-{
-    SVGLengthType type;
-    switch (value.primitiveType()) {
-    case CSSPrimitiveValue::CSS_NUMBER:
-        type = LengthTypeNumber;
-        break;
-    case CSSPrimitiveValue::CSS_PERCENTAGE:
-        type = LengthTypePercentage;
-        break;
-    case CSSPrimitiveValue::CSS_EMS:
-        type = LengthTypeEMS;
-        break;
-    case CSSPrimitiveValue::CSS_EXS:
-        type = LengthTypeEXS;
-        break;
-    case CSSPrimitiveValue::CSS_PX:
-        type = LengthTypePX;
-        break;
-    case CSSPrimitiveValue::CSS_CM:
-        type = LengthTypeCM;
-        break;
-    case CSSPrimitiveValue::CSS_MM:
-        type = LengthTypeMM;
-        break;
-    case CSSPrimitiveValue::CSS_IN:
-        type = LengthTypeIN;
-        break;
-    case CSSPrimitiveValue::CSS_PT:
-        type = LengthTypePT;
-        break;
-    case CSSPrimitiveValue::CSS_PC:
-        type = LengthTypePC;
-        break;
-    case CSSPrimitiveValue::CSS_UNKNOWN:
-    default:
+    auto originalLengthType = m_lengthType;
+    m_lengthType = lengthType;
+    auto result = setValue(context, valueInUserUnits.releaseReturnValue());
+    if (!result.hasException())
         return { };
-    };
-
-    SVGLengthValue length;
-    length.newValueSpecifiedUnits(type, value.floatValue());
-    return length;
-}
 
-Ref<CSSPrimitiveValue> SVGLengthValue::toCSSPrimitiveValue(const SVGLengthValue& length)
-{
-    CSSPrimitiveValue::UnitType cssType = CSSPrimitiveValue::CSS_UNKNOWN;
-    switch (length.unitType()) {
-    case LengthTypeUnknown:
-        break;
-    case LengthTypeNumber:
-        cssType = CSSPrimitiveValue::CSS_NUMBER;
-        break;
-    case LengthTypePercentage:
-        cssType = CSSPrimitiveValue::CSS_PERCENTAGE;
-        break;
-    case LengthTypeEMS:
-        cssType = CSSPrimitiveValue::CSS_EMS;
-        break;
-    case LengthTypeEXS:
-        cssType = CSSPrimitiveValue::CSS_EXS;
-        break;
-    case LengthTypePX:
-        cssType = CSSPrimitiveValue::CSS_PX;
-        break;
-    case LengthTypeCM:
-        cssType = CSSPrimitiveValue::CSS_CM;
-        break;
-    case LengthTypeMM:
-        cssType = CSSPrimitiveValue::CSS_MM;
-        break;
-    case LengthTypeIN:
-        cssType = CSSPrimitiveValue::CSS_IN;
-        break;
-    case LengthTypePT:
-        cssType = CSSPrimitiveValue::CSS_PT;
-        break;
-    case LengthTypePC:
-        cssType = CSSPrimitiveValue::CSS_PC;
-        break;
-    };
-
-    return CSSPrimitiveValue::create(length.valueInSpecifiedUnits(), cssType);
-}
-
-SVGLengthMode SVGLengthValue::lengthModeForAnimatedLengthAttribute(const QualifiedName& attrName)
-{
-    using Map = HashMap<QualifiedName, SVGLengthMode>;
-    static NeverDestroyed<Map> map = [] {
-        struct Mode {
-            const QualifiedName& name;
-            SVGLengthMode mode;
-        };
-        static const Mode modes[] = {
-            { SVGNames::xAttr, LengthModeWidth },
-            { SVGNames::yAttr, LengthModeHeight },
-            { SVGNames::cxAttr, LengthModeWidth },
-            { SVGNames::cyAttr, LengthModeHeight },
-            { SVGNames::dxAttr, LengthModeWidth },
-            { SVGNames::dyAttr, LengthModeHeight },
-            { SVGNames::fxAttr, LengthModeWidth },
-            { SVGNames::fyAttr, LengthModeHeight },
-            { SVGNames::widthAttr, LengthModeWidth },
-            { SVGNames::heightAttr, LengthModeHeight },
-            { SVGNames::x1Attr, LengthModeWidth },
-            { SVGNames::x2Attr, LengthModeWidth },
-            { SVGNames::y1Attr, LengthModeHeight },
-            { SVGNames::y2Attr, LengthModeHeight },
-            { SVGNames::refXAttr, LengthModeWidth },
-            { SVGNames::refYAttr, LengthModeHeight },
-            { SVGNames::markerWidthAttr, LengthModeWidth },
-            { SVGNames::markerHeightAttr, LengthModeHeight },
-            { SVGNames::textLengthAttr, LengthModeWidth },
-            { SVGNames::startOffsetAttr, LengthModeWidth },
-        };
-        Map map;
-        for (auto& mode : modes)
-            map.add(mode.name, mode.mode);
-        return map;
-    }();
-    
-    auto result = map.get().find(attrName);
-    if (result == map.get().end())
-        return LengthModeOther;
-    return result->value;
+    m_lengthType = originalLengthType;
+    return result.releaseException();
 }
 
 TextStream& operator<<(TextStream& ts, const SVGLengthValue& length)
index 92661b2..70db967 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
  * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org>
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
 
 #pragma once
 
-#include "AnimationUtilities.h"
-#include "SVGLengthContext.h"
+#include "ExceptionOr.h"
 #include "SVGParsingError.h"
 #include "SVGPropertyTraits.h"
 
 namespace WebCore {
 
 class CSSPrimitiveValue;
-class QualifiedName;
+class SVGLengthContext;
+
+enum class SVGLengthType : uint8_t {
+    Unknown = 0,
+    Number,
+    Percentage,
+    Ems,
+    Exs,
+    Pixels,
+    Centimeters,
+    Millimeters,
+    Inches,
+    Points,
+    Picas
+};
+
+enum class SVGLengthMode : uint8_t {
+    Width,
+    Height,
+    Other
+};
 
-enum SVGLengthNegativeValuesMode {
-    AllowNegativeLengths,
-    ForbidNegativeLengths
+enum class SVGLengthNegativeValuesMode : uint8_t {
+    Allow,
+    Forbid
 };
 
 class SVGLengthValue {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    // FIXME: Once all SVGLengthValue users use Length internally, we make this a wrapper for Length.
-    SVGLengthValue(SVGLengthMode = LengthModeOther, const String& valueAsString = String());
-    SVGLengthValue(const SVGLengthContext&, float, SVGLengthMode = LengthModeOther, SVGLengthType = LengthTypeNumber);
+    SVGLengthValue(SVGLengthMode = SVGLengthMode::Other, const String& valueAsString = String());
+    SVGLengthValue(float valueInSpecifiedUnits, SVGLengthType, SVGLengthMode = SVGLengthMode::Other);
+    SVGLengthValue(const SVGLengthContext&, float, SVGLengthType = SVGLengthType::Number, SVGLengthMode = SVGLengthMode::Other);
 
-    SVGLengthType unitType() const;
-    SVGLengthMode unitMode() const;
+    static SVGLengthValue construct(SVGLengthMode, const String&, SVGParsingError&, SVGLengthNegativeValuesMode = SVGLengthNegativeValuesMode::Allow);
+    static SVGLengthValue blend(const SVGLengthValue& from, const SVGLengthValue& to, float progress);
+    
+    static SVGLengthValue fromCSSPrimitiveValue(const CSSPrimitiveValue&);
+    static Ref<CSSPrimitiveValue> toCSSPrimitiveValue(const SVGLengthValue&);
 
-    bool operator==(const SVGLengthValue&) const;
-    bool operator!=(const SVGLengthValue&) const;
+    SVGLengthType lengthType() const { return m_lengthType; }
+    SVGLengthMode lengthMode() const { return m_lengthMode; }
 
-    static SVGLengthValue construct(SVGLengthMode, const String&, SVGParsingError&, SVGLengthNegativeValuesMode = AllowNegativeLengths);
+    bool isZero() const { return !m_valueInSpecifiedUnits;  }
+    bool isRelative() const { return m_lengthType == SVGLengthType::Percentage || m_lengthType == SVGLengthType::Ems || m_lengthType == SVGLengthType::Exs; }
 
     float value(const SVGLengthContext&) const;
+    float valueAsPercentage() const { return m_lengthType == SVGLengthType::Percentage ? m_valueInSpecifiedUnits / 100 : m_valueInSpecifiedUnits; }
+    float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; }
+    
+    String valueAsString() const;
     ExceptionOr<float> valueForBindings(const SVGLengthContext&) const;
-    ExceptionOr<void> setValue(float, const SVGLengthContext&);
-    ExceptionOr<void> setValue(const SVGLengthContext&, float, SVGLengthMode, SVGLengthType);
 
-    float valueInSpecifiedUnits() const { return m_valueInSpecifiedUnits; }
     void setValueInSpecifiedUnits(float value) { m_valueInSpecifiedUnits = value; }
+    ExceptionOr<void> setValue(const SVGLengthContext&, float);
+    ExceptionOr<void> setValue(const SVGLengthContext&, float, SVGLengthType, SVGLengthMode);
 
-    float valueAsPercentage() const;
-
-    String valueAsString() const;
     ExceptionOr<void> setValueAsString(const String&);
     ExceptionOr<void> setValueAsString(const String&, SVGLengthMode);
-    
-    ExceptionOr<void> newValueSpecifiedUnits(unsigned short, float valueInSpecifiedUnits);
-    ExceptionOr<void> convertToSpecifiedUnits(unsigned short, const SVGLengthContext&);
 
-    // Helper functions
-    bool isRelative() const
-    {
-        auto type = unitType();
-        return type == LengthTypePercentage || type == LengthTypeEMS || type == LengthTypeEXS;
-    }
-
-    bool isZero() const 
-    {
-        return !m_valueInSpecifiedUnits;
-    }
-
-    static SVGLengthValue fromCSSPrimitiveValue(const CSSPrimitiveValue&);
-    static Ref<CSSPrimitiveValue> toCSSPrimitiveValue(const SVGLengthValue&);
-    static SVGLengthMode lengthModeForAnimatedLengthAttribute(const QualifiedName&);
-
-    SVGLengthValue blend(const SVGLengthValue& from, float progress) const
-    {
-        auto toType = unitType();
-        auto fromType = from.unitType();
-        if ((from.isZero() && isZero())
-            || fromType == LengthTypeUnknown
-            || toType == LengthTypeUnknown
-            || (!from.isZero() && fromType != LengthTypePercentage && toType == LengthTypePercentage)
-            || (!isZero() && fromType == LengthTypePercentage && toType != LengthTypePercentage)
-            || (!from.isZero() && !isZero() && (fromType == LengthTypeEMS || fromType == LengthTypeEXS) && fromType != toType))
-            return *this;
-
-        SVGLengthValue length;
-
-        if (fromType == LengthTypePercentage || toType == LengthTypePercentage) {
-            auto fromPercent = from.valueAsPercentage() * 100;
-            auto toPercent = valueAsPercentage() * 100;
-            auto result = length.newValueSpecifiedUnits(LengthTypePercentage, WebCore::blend(fromPercent, toPercent, progress));
-            if (result.hasException())
-                return { };
-            return length;
-        }
-
-        if (fromType == toType || from.isZero() || isZero() || fromType == LengthTypeEMS || fromType == LengthTypeEXS) {
-            auto fromValue = from.valueInSpecifiedUnits();
-            auto toValue = valueInSpecifiedUnits();
-            if (isZero()) {
-                auto result = length.newValueSpecifiedUnits(fromType, WebCore::blend(fromValue, toValue, progress));
-                if (result.hasException())
-                    return { };
-            } else {
-                auto result = length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue, toValue, progress));
-                if (result.hasException())
-                    return { };
-            }
-            return length;
-        }
-
-        ASSERT(!isRelative());
-        ASSERT(!from.isRelative());
-
-        SVGLengthContext nonRelativeLengthContext(nullptr);
-        auto fromValueInUserUnits = nonRelativeLengthContext.convertValueToUserUnits(from.valueInSpecifiedUnits(), from.unitMode(), fromType);
-        if (fromValueInUserUnits.hasException())
-            return { };
-
-        auto fromValue = nonRelativeLengthContext.convertValueFromUserUnits(fromValueInUserUnits.releaseReturnValue(), unitMode(), toType);
-        if (fromValue.hasException())
-            return { };
-
-        float toValue = valueInSpecifiedUnits();
-        auto result = length.newValueSpecifiedUnits(toType, WebCore::blend(fromValue.releaseReturnValue(), toValue, progress));
-        if (result.hasException())
-            return { };
-        return length;
-    }
+    ExceptionOr<void> convertToSpecifiedUnits(const SVGLengthContext&, SVGLengthType);
 
 private:
     float m_valueInSpecifiedUnits { 0 };
-    unsigned m_unit;
+    SVGLengthType m_lengthType { SVGLengthType::Number };
+    SVGLengthMode m_lengthMode { SVGLengthMode::Other };
 };
 
-template<> struct SVGPropertyTraits<SVGLengthValue> {
-    static SVGLengthValue initialValue() { return { }; }
-    static Optional<SVGLengthValue> parse(const QualifiedName& attrName, const String& string)
-    {
-        SVGLengthValue length;
-        length.setValueAsString(string, SVGLengthValue::lengthModeForAnimatedLengthAttribute(attrName)).hasException();
-        return length;
-    }
-    static String toString(const SVGLengthValue& length) { return length.valueAsString(); }
-};
+inline bool operator==(const SVGLengthValue& a, const SVGLengthValue& b)
+{
+    return a.valueInSpecifiedUnits() == b.valueInSpecifiedUnits() && a.lengthType() == b.lengthType() && a.lengthMode() == b.lengthMode();
+}
+
+inline bool operator!=(const SVGLengthValue& a, const SVGLengthValue& b)
+{
+    return a.valueInSpecifiedUnits() != b.valueInSpecifiedUnits() || a.lengthType() != b.lengthType() || a.lengthMode() != b.lengthMode();
+}
 
 WTF::TextStream& operator<<(WTF::TextStream&, const SVGLengthValue&);
 
index 65fe54f..3c4d39e 100644 (file)
@@ -55,13 +55,13 @@ void SVGLineElement::parseAttribute(const QualifiedName& name, const AtomString&
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::x1Attr)
-        m_x1->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x1->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::y1Attr)
-        m_y1->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y1->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::x2Attr)
-        m_x2->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x2->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::y2Attr)
-        m_y2->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y2->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
 
     reportAttributeParsingError(parseError, name, value);
 
index 582777a..36a0bb4 100644 (file)
@@ -56,10 +56,10 @@ private:
     bool selfHasRelativeLengths() const final;
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x1 { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y1 { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_x2 { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y2 { SVGAnimatedLength::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLength> m_x1 { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y1 { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_x2 { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y2 { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
 };
 
 } // namespace WebCore
index 7d7d7c2..9fa95ce 100644 (file)
@@ -64,13 +64,13 @@ void SVGLinearGradientElement::parseAttribute(const QualifiedName& name, const A
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::x1Attr)
-        m_x1->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x1->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::y1Attr)
-        m_y1->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y1->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::x2Attr)
-        m_x2->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x2->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::y2Attr)
-        m_y2->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y2->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
 
     reportAttributeParsingError(parseError, name, value);
 
index b0e6eb5..aefe64c 100644 (file)
@@ -59,10 +59,10 @@ private:
     bool selfHasRelativeLengths() const override;
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x1 { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y1 { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_x2 { SVGAnimatedLength::create(this, LengthModeWidth, "100%") };
-    Ref<SVGAnimatedLength> m_y2 { SVGAnimatedLength::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLength> m_x1 { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y1 { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_x2 { SVGAnimatedLength::create(this, SVGLengthMode::Width, "100%") };
+    Ref<SVGAnimatedLength> m_y2 { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
 };
 
 } // namespace WebCore
index f534624..8306fd7 100644 (file)
@@ -79,13 +79,13 @@ void SVGMarkerElement::parseAttribute(const QualifiedName& name, const AtomStrin
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::refXAttr)
-        m_refX->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_refX->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::refYAttr)
-        m_refY->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_refY->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::markerWidthAttr)
-        m_markerWidth->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_markerWidth->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::markerHeightAttr)
-        m_markerHeight->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_markerHeight->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
 
     reportAttributeParsingError(parseError, name, value);
 
index 1c86e75..ff76b07 100644 (file)
@@ -88,10 +88,10 @@ private:
     void setOrient(SVGMarkerOrientType, const SVGAngleValue&);
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_refX { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_refY { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_markerWidth { SVGAnimatedLength::create(this, LengthModeWidth, "3") };
-    Ref<SVGAnimatedLength> m_markerHeight { SVGAnimatedLength::create(this, LengthModeHeight, "3") };
+    Ref<SVGAnimatedLength> m_refX { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_refY { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_markerWidth { SVGAnimatedLength::create(this, SVGLengthMode::Width, "3") };
+    Ref<SVGAnimatedLength> m_markerHeight { SVGAnimatedLength::create(this, SVGLengthMode::Height, "3") };
     Ref<SVGAnimatedEnumeration> m_markerUnits { SVGAnimatedEnumeration::create(this, SVGMarkerUnitsStrokeWidth) };
     Ref<SVGAnimatedAngle> m_orientAngle { SVGAnimatedAngle::create(this) };
     Ref<SVGAnimatedOrientType> m_orientType { SVGAnimatedOrientType::create(this, SVGMarkerOrientAngle) };
index 8f2a802..b7a0f11 100644 (file)
@@ -82,13 +82,13 @@ void SVGMaskElement::parseAttribute(const QualifiedName& name, const AtomString&
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::widthAttr)
-        m_width->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_width->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::heightAttr)
-        m_height->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_height->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
 
     reportAttributeParsingError(parseError, name, value);
 
index 9564649..c3e49ba 100644 (file)
@@ -64,10 +64,10 @@ private:
     bool selfHasRelativeLengths() const final { return true; }
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth, "-10%") };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight, "-10%") };
-    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth, "120%") };
-    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight, "120%") };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width, "-10%") };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height, "-10%") };
+    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, SVGLengthMode::Width, "120%") };
+    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height, "120%") };
     Ref<SVGAnimatedEnumeration> m_maskUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) };
     Ref<SVGAnimatedEnumeration> m_maskContentUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) };
 };
index cddc3a3..8389a71 100644 (file)
@@ -93,13 +93,13 @@ void SVGPatternElement::parseAttribute(const QualifiedName& name, const AtomStri
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::widthAttr)
-        m_width->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths));
+        m_width->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError, SVGLengthNegativeValuesMode::Forbid));
     else if (name == SVGNames::heightAttr)
-        m_height->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
+        m_height->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError, SVGLengthNegativeValuesMode::Forbid));
 
     reportAttributeParsingError(parseError, name, value);
 
index d1ad59c..1e661d7 100644 (file)
@@ -75,10 +75,10 @@ private:
     bool selfHasRelativeLengths() const final { return true; }
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
     Ref<SVGAnimatedEnumeration> m_patternUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) };
     Ref<SVGAnimatedEnumeration> m_patternContentUnits { SVGAnimatedEnumeration::create(this, SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE) };
     Ref<SVGAnimatedTransformList> m_patternTransform { SVGAnimatedTransformList::create(this) };
index b11d875..fe1d498 100644 (file)
@@ -66,17 +66,17 @@ void SVGRadialGradientElement::parseAttribute(const QualifiedName& name, const A
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::cxAttr)
-        m_cx->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_cx->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::cyAttr)
-        m_cy->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_cy->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::rAttr)
-        m_r->setBaseValInternal(SVGLengthValue::construct(LengthModeOther, value, parseError, ForbidNegativeLengths));
+        m_r->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Other, value, parseError, SVGLengthNegativeValuesMode::Forbid));
     else if (name == SVGNames::fxAttr)
-        m_fx->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_fx->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::fyAttr)
-        m_fy->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_fy->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::frAttr)
-        m_fr->setBaseValInternal(SVGLengthValue::construct(LengthModeOther, value, parseError, ForbidNegativeLengths));
+        m_fr->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Other, value, parseError, SVGLengthNegativeValuesMode::Forbid));
 
     reportAttributeParsingError(parseError, name, value);
 
index f315d94..84f1158 100644 (file)
@@ -63,12 +63,12 @@ private:
     bool selfHasRelativeLengths() const override;
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_cx { SVGAnimatedLength::create(this, LengthModeWidth, "50%") };
-    Ref<SVGAnimatedLength> m_cy { SVGAnimatedLength::create(this, LengthModeHeight, "50%") };
-    Ref<SVGAnimatedLength> m_r { SVGAnimatedLength::create(this, LengthModeOther, "50%") };
-    Ref<SVGAnimatedLength> m_fx { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_fy { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_fr { SVGAnimatedLength::create(this, LengthModeOther, "0%") };
+    Ref<SVGAnimatedLength> m_cx { SVGAnimatedLength::create(this, SVGLengthMode::Width, "50%") };
+    Ref<SVGAnimatedLength> m_cy { SVGAnimatedLength::create(this, SVGLengthMode::Height, "50%") };
+    Ref<SVGAnimatedLength> m_r { SVGAnimatedLength::create(this, SVGLengthMode::Other, "50%") };
+    Ref<SVGAnimatedLength> m_fx { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_fy { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_fr { SVGAnimatedLength::create(this, SVGLengthMode::Other, "0%") };
 };
 
 } // namespace WebCore
index eb53998..eca13f0 100644 (file)
@@ -58,17 +58,17 @@ void SVGRectElement::parseAttribute(const QualifiedName& name, const AtomString&
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::rxAttr)
-        m_rx->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths));
+        m_rx->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError, SVGLengthNegativeValuesMode::Forbid));
     else if (name == SVGNames::ryAttr)
-        m_ry->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
+        m_ry->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError, SVGLengthNegativeValuesMode::Forbid));
     else if (name == SVGNames::widthAttr)
-        m_width->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths));
+        m_width->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError, SVGLengthNegativeValuesMode::Forbid));
     else if (name == SVGNames::heightAttr)
-        m_height->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
+        m_height->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError, SVGLengthNegativeValuesMode::Forbid));
 
     reportAttributeParsingError(parseError, name, value);
 
index fc24792..c5f5f2c 100644 (file)
@@ -61,12 +61,12 @@ private:
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_rx { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_ry { SVGAnimatedLength::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_rx { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_ry { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
 };
 
 } // namespace WebCore
index c57cffc..d757eac 100644 (file)
@@ -231,23 +231,23 @@ void SVGSVGElement::parseAttribute(const QualifiedName& name, const AtomString&
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::widthAttr) {
-        auto length = SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths);
+        auto length = SVGLengthValue::construct(SVGLengthMode::Width, value, parseError, SVGLengthNegativeValuesMode::Forbid);
         if (parseError != NoError || value.isEmpty()) {
             // FIXME: This is definitely the correct behavior for a missing/removed attribute.
             // Not sure it's correct for the empty string or for something that can't be parsed.
-            length = SVGLengthValue(LengthModeWidth, "100%"_s);
+            length = SVGLengthValue(SVGLengthMode::Width, "100%"_s);
         }
         m_width->setBaseValInternal(length);
     } else if (name == SVGNames::heightAttr) {
-        auto length = SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths);
+        auto length = SVGLengthValue::construct(SVGLengthMode::Height, value, parseError, SVGLengthNegativeValuesMode::Forbid);
         if (parseError != NoError || value.isEmpty()) {
             // FIXME: This is definitely the correct behavior for a removed attribute.
             // Not sure it's correct for the empty string or for something that can't be parsed.
-            length = SVGLengthValue(LengthModeHeight, "100%"_s);
+            length = SVGLengthValue(SVGLengthMode::Height, "100%"_s);
         }
         m_height->setBaseValInternal(length);
     }
@@ -576,17 +576,17 @@ FloatSize SVGSVGElement::currentViewportSize() const
 
 bool SVGSVGElement::hasIntrinsicWidth() const
 {
-    return width().unitType() != LengthTypePercentage;
+    return width().lengthType() != SVGLengthType::Percentage;
 }
 
 bool SVGSVGElement::hasIntrinsicHeight() const
 {
-    return height().unitType() != LengthTypePercentage;
+    return height().lengthType() != SVGLengthType::Percentage;
 }
 
 Length SVGSVGElement::intrinsicWidth() const
 {
-    if (width().unitType() == LengthTypePercentage)
+    if (width().lengthType() == SVGLengthType::Percentage)
         return Length(0, Fixed);
 
     SVGLengthContext lengthContext(this);
@@ -595,7 +595,7 @@ Length SVGSVGElement::intrinsicWidth() const
 
 Length SVGSVGElement::intrinsicHeight() const
 {
-    if (height().unitType() == LengthTypePercentage)
+    if (height().lengthType() == SVGLengthType::Percentage)
         return Length(0, Fixed);
 
     SVGLengthContext lengthContext(this);
index 9eacd80..d46b428 100644 (file)
@@ -164,10 +164,10 @@ private:
     Ref<SVGPoint> m_currentTranslate { SVGPoint::create() };
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth, "100%"_s) };
-    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight, "100%"_s) };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, SVGLengthMode::Width, "100%"_s) };
+    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height, "100%"_s) };
 };
 
 } // namespace WebCore
index 1820b3c..d59891e 100644 (file)
@@ -170,7 +170,7 @@ void SVGTextContentElement::parseAttribute(const QualifiedName& name, const Atom
         if (propertyValue > 0)
             m_lengthAdjust->setBaseValInternal<SVGLengthAdjustType>(propertyValue);
     } else if (name == SVGNames::textLengthAttr)
-        m_textLength->setBaseValInternal(SVGLengthValue::construct(LengthModeOther, value, parseError, ForbidNegativeLengths));
+        m_textLength->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Other, value, parseError, SVGLengthNegativeValuesMode::Forbid));
 
     reportAttributeParsingError(parseError, name, value);
 
@@ -197,9 +197,9 @@ void SVGTextContentElement::svgAttributeChanged(const QualifiedName& attrName)
 
 SVGAnimatedLength& SVGTextContentElement::textLengthAnimated()
 {
-    static NeverDestroyed<SVGLengthValue> defaultTextLength(LengthModeOther);
+    static NeverDestroyed<SVGLengthValue> defaultTextLength(SVGLengthMode::Other);
     if (m_textLength->baseVal()->value() == defaultTextLength)
-        m_textLength->baseVal()->value().newValueSpecifiedUnits(LengthTypeNumber, getComputedTextLength());
+        m_textLength->baseVal()->value() = { getComputedTextLength(), SVGLengthType::Number };
     return m_textLength;
 }
 
index 58a7d37..db0fef2 100644 (file)
@@ -107,9 +107,9 @@ protected:
 private:
     bool isTextContent() const final { return true; }
 
-    Ref<SVGAnimatedLength> m_textLength { SVGAnimatedLength::create(this, LengthModeOther) };
+    Ref<SVGAnimatedLength> m_textLength { SVGAnimatedLength::create(this, SVGLengthMode::Other) };
     Ref<SVGAnimatedEnumeration> m_lengthAdjust { SVGAnimatedEnumeration::create(this, SVGLengthAdjustSpacing) };
-    SVGLengthValue m_specifiedTextLength { LengthModeOther };
+    SVGLengthValue m_specifiedTextLength { SVGLengthMode::Other };
 };
 
 } // namespace WebCore
index 76fbba7..d9fe1f4 100644 (file)
@@ -67,7 +67,7 @@ void SVGTextPathElement::parseAttribute(const QualifiedName& name, const AtomStr
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::startOffsetAttr)
-        m_startOffset->setBaseValInternal(SVGLengthValue::construct(LengthModeOther, value, parseError));
+        m_startOffset->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Other, value, parseError));
     else if (name == SVGNames::methodAttr) {
         SVGTextPathMethodType propertyValue = SVGPropertyTraits<SVGTextPathMethodType>::fromString(value);
         if (propertyValue > 0)
index 5677f5b..78f07f0 100644 (file)
@@ -144,7 +144,7 @@ private:
     bool selfHasRelativeLengths() const override;
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_startOffset { SVGAnimatedLength::create(this, LengthModeOther) };
+    Ref<SVGAnimatedLength> m_startOffset { SVGAnimatedLength::create(this, SVGLengthMode::Other) };
     Ref<SVGAnimatedEnumeration> m_method { SVGAnimatedEnumeration::create(this, SVGTextPathMethodAlign) };
     Ref<SVGAnimatedEnumeration> m_spacing { SVGAnimatedEnumeration::create(this, SVGTextPathSpacingExact) };
 };
index 0e7134c..379c5a6 100644 (file)
@@ -57,10 +57,10 @@ private:
     const SVGPropertyRegistry& propertyRegistry() const override { return m_propertyRegistry; }
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLengthList> m_x { SVGAnimatedLengthList::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLengthList> m_y { SVGAnimatedLengthList::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLengthList> m_dx { SVGAnimatedLengthList::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLengthList> m_dy { SVGAnimatedLengthList::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLengthList> m_x { SVGAnimatedLengthList::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLengthList> m_y { SVGAnimatedLengthList::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLengthList> m_dx { SVGAnimatedLengthList::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLengthList> m_dy { SVGAnimatedLengthList::create(this, SVGLengthMode::Height) };
     Ref<SVGAnimatedNumberList> m_rotate { SVGAnimatedNumberList::create(this) };
 };
 
index 9a72984..ad92384 100644 (file)
@@ -80,13 +80,13 @@ void SVGUseElement::parseAttribute(const QualifiedName& name, const AtomString&
     SVGParsingError parseError = NoError;
 
     if (name == SVGNames::xAttr)
-        m_x->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError));
+        m_x->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError));
     else if (name == SVGNames::yAttr)
-        m_y->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError));
+        m_y->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError));
     else if (name == SVGNames::widthAttr)
-        m_width->setBaseValInternal(SVGLengthValue::construct(LengthModeWidth, value, parseError, ForbidNegativeLengths));
+        m_width->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Width, value, parseError, SVGLengthNegativeValuesMode::Forbid));
     else if (name == SVGNames::heightAttr)
-        m_height->setBaseValInternal(SVGLengthValue::construct(LengthModeHeight, value, parseError, ForbidNegativeLengths));
+        m_height->setBaseValInternal(SVGLengthValue::construct(SVGLengthMode::Height, value, parseError, SVGLengthNegativeValuesMode::Forbid));
 
     reportAttributeParsingError(parseError, name, value);
 
index 1f52bc1..ab59cd3 100644 (file)
@@ -96,10 +96,10 @@ private:
     void invalidateDependentShadowTrees();
 
     PropertyRegistry m_propertyRegistry { *this };
-    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, LengthModeHeight) };
-    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, LengthModeWidth) };
-    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, LengthModeHeight) };
+    Ref<SVGAnimatedLength> m_x { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_y { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
+    Ref<SVGAnimatedLength> m_width { SVGAnimatedLength::create(this, SVGLengthMode::Width) };
+    Ref<SVGAnimatedLength> m_height { SVGAnimatedLength::create(this, SVGLengthMode::Height) };
 
     bool m_haveFiredLoadEvent { false };
     bool m_shadowTreeNeedsUpdate { true };
index d32678c..99b2aa9 100644 (file)
@@ -123,7 +123,7 @@ private:
 
     std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
     {
-        SVGLengthMode lengthMode = property(owner)->baseVal()->value().unitMode();
+        SVGLengthMode lengthMode = property(owner)->baseVal()->value().lengthMode();
         return SVGAnimatedLengthAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive, lengthMode);
     }
 
@@ -146,7 +146,7 @@ public:
 private:
     std::unique_ptr<SVGAttributeAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
     {
-        return SVGAnimatedLengthListAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive, LengthModeWidth);
+        return SVGAnimatedLengthListAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive, SVGLengthMode::Width);
     }
 
     void appendAnimatedInstance(OwnerType& owner, SVGAttributeAnimator& animator) const final
diff --git a/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h b/Source/WebCore/svg/properties/SVGAnimatedPropertyDescription.h
deleted file mode 100644 (file)
index 7fa82c6..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org>
- * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org>
- * Copyright (C) Research In Motion Limited 2010. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB.  If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#pragma once
-
-#include <wtf/HashMap.h>
-#include <wtf/text/AtomString.h>
-
-namespace WebCore {
-
-class SVGElement;
-
-struct SVGAnimatedPropertyDescription {            
-    // Empty value
-    SVGAnimatedPropertyDescription()
-        : m_element(nullptr)
-        , m_attributeName(nullptr)
-    {
-    }
-
-    // Deleted value
-    SVGAnimatedPropertyDescription(WTF::HashTableDeletedValueType)
-        : m_element(reinterpret_cast<SVGElement*>(-1))
-    {
-    }
-
-    bool isHashTableDeletedValue() const
-    {
-        return m_element == reinterpret_cast<SVGElement*>(-1);
-    }
-
-    SVGAnimatedPropertyDescription(SVGElement* element, const AtomString& attributeName)
-        : m_element(element)
-        , m_attributeName(attributeName.impl())
-    {
-        ASSERT(m_element);
-        ASSERT(m_attributeName);
-    }
-
-    bool operator==(const SVGAnimatedPropertyDescription& other) const
-    {
-        return m_element == other.m_element && m_attributeName == other.m_attributeName;
-    }
-
-    SVGElement* m_element;
-    AtomStringImpl* m_attributeName;
-};
-
-struct SVGAnimatedPropertyDescriptionHash {
-    static unsigned hash(const SVGAnimatedPropertyDescription& key)
-    {
-        return StringHasher::hashMemory<sizeof(SVGAnimatedPropertyDescription)>(&key);
-    }
-
-    static bool equal(const SVGAnimatedPropertyDescription& a, const SVGAnimatedPropertyDescription& b)
-    {
-        return a == b;
-    }
-
-    static const bool safeToCompareToEmptyOrDeleted = true;
-};
-
-struct SVGAnimatedPropertyDescriptionHashTraits : WTF::SimpleClassHashTraits<SVGAnimatedPropertyDescription> { };
-} // namespace WebCore
index 9233ae9..61a1d03 100644 (file)
@@ -69,7 +69,7 @@ public:
 
         SVGLengthContext lengthContext(targetElement);
         for (unsigned i = 0; i < toItems.size(); ++i) {
-            SVGLengthType unitType = (i < fromItems.size() && progress < 0.5 ? fromItems : toItems)[i]->value().unitType();
+            SVGLengthType lengthType = (i < fromItems.size() && progress < 0.5 ? fromItems : toItems)[i]->value().lengthType();
 
             float from = i < fromItems.size() ? fromItems[i]->value().value(lengthContext) : 0;
             float to = toItems[i]->value().value(lengthContext);
@@ -77,7 +77,7 @@ public:
             float value = animatedItems[i]->value().value(lengthContext);
 
             value = Base::animate(progress, repeatCount, from, to, toAtEndOfDuration, value);
-            animatedItems[i]->value().setValue(lengthContext, value, lengthMode, unitType);
+            animatedItems[i]->value().setValue(lengthContext, value, lengthType, lengthMode);
         }
     }
 
@@ -94,7 +94,7 @@ private:
         for (unsigned i = 0; i < fromItems.size(); ++i) {
             const SVGLengthValue& fromValue = fromItems[i]->value();
             SVGLengthValue& toValue = toItems[i]->value();
-            toValue.setValue(toValue.value(lengthContext) + fromValue.value(lengthContext), lengthContext);
+            toValue.setValue(lengthContext, toValue.value(lengthContext) + fromValue.value(lengthContext));
         }
     }
 };
index 28c512a..cee15e4 100644 (file)
@@ -177,7 +177,7 @@ public:
     void animate(SVGElement* targetElement, float progress, unsigned repeatCount, SVGLengthValue& animated)
     {
         SVGLengthContext lengthContext(targetElement);
-        SVGLengthType unitType = progress < 0.5 ? m_from.unitType() : m_to.unitType();
+        SVGLengthType lengthType = progress < 0.5 ? m_from.lengthType() : m_to.lengthType();
 
         float from = (m_animationMode == AnimationMode::To ? animated : m_from).value(lengthContext);
         float to = m_to.value(lengthContext);
@@ -185,7 +185,7 @@ public:
         float value = animated.value(lengthContext);
 
         value = Base::animate(progress, repeatCount, from, to, toAtEndOfDuration, value);
-        animated = { lengthContext, value, m_lengthMode, unitType };
+        animated = { lengthContext, value, lengthType, m_lengthMode };
     }
 
     Optional<float> calculateDistance(SVGElement* targetElement, const String& from, const String& to) const override
@@ -200,7 +200,7 @@ private:
     void addFromAndToValues(SVGElement* targetElement) override
     {
         SVGLengthContext lengthContext(targetElement);
-        m_to.setValue(m_to.value(lengthContext) + m_from.value(lengthContext), lengthContext);
+        m_to.setValue(lengthContext, m_to.value(lengthContext) + m_from.value(lengthContext));
     }
 
     SVGLengthMode m_lengthMode;
index fd3dc96..6276784 100644 (file)
@@ -39,13 +39,13 @@ class SVGLengthAnimator final : public SVGValuePropertyAnimator<SVGLength, SVGAn
 public:
     static auto create(const QualifiedName& attributeName, Ref<SVGProperty>&& property, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive)
     {
-        return makeUnique<SVGLengthAnimator>(attributeName, WTFMove(property), animationMode, calcMode, isAccumulated, isAdditive, LengthModeOther);
+        return makeUnique<SVGLengthAnimator>(attributeName, WTFMove(property), animationMode, calcMode, isAccumulated, isAdditive, SVGLengthMode::Other);
     }
 
     void start(SVGElement* targetElement) override
     {
         String baseValue = computeCSSPropertyValue(targetElement, cssPropertyID(m_attributeName.localName()));
-        SVGLengthValue value(LengthModeOther);
+        SVGLengthValue value(SVGLengthMode::Other);
         if (!value.setValueAsString(baseValue).hasException())
             m_property->setValue(value);
     }
index ae94e29..1598f56 100644 (file)
@@ -39,7 +39,7 @@ class SVGLengthListAnimator final : public SVGValuePropertyListAnimator<SVGLengt
 public:
     static auto create(const QualifiedName& attributeName, Ref<SVGProperty>&& property, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive)
     {
-        return makeUnique<SVGLengthListAnimator>(attributeName, WTFMove(property), animationMode, calcMode, isAccumulated, isAdditive, LengthModeOther);
+        return makeUnique<SVGLengthListAnimator>(attributeName, WTFMove(property), animationMode, calcMode, isAccumulated, isAdditive, SVGLengthMode::Other);
     }
 
     void start(SVGElement* targetElement) override