WebKit Bugzilla
Attachment 370368 Details for
Bug 198073
: SVGPropertyTraits and SVG enum types clean up
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for review
02c.patch (text/plain), 87.85 KB, created by
Said Abou-Hallawa
on 2019-05-21 18:45:11 PDT
(
hide
)
Description:
Patch for review
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2019-05-21 18:45:11 PDT
Size:
87.85 KB
patch
obsolete
>diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 673b4b8aa06..322c9ccaa77 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,17 @@ >+2019-05-21 Said Abou-Hallawa <said@apple.com> >+ >+ SVGPropertyTraits and SVG enum types clean up >+ https://bugs.webkit.org/show_bug.cgi?id=198073 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * svg/animations/svgnumber-animation-3-expected.txt: >+ * svg/animations/svgnumber-animation-3.html: >+ The expected values of this test were wrong. The test is supposed to verify >+ the values at 0%, 50%, just before 100% and 100%. The change in the opacity >+ of the element should be: 0, 0.5, 1, 0. The test was expecting all values >+ to be zeros. >+ > 2019-05-20 Said Abou-Hallawa <sabouhallawa@apple.com> > > Unify the parsing of SVGList super classes >diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog >index d21647aca9d..e0384003aa2 100644 >--- a/LayoutTests/imported/w3c/ChangeLog >+++ b/LayoutTests/imported/w3c/ChangeLog >@@ -1,3 +1,14 @@ >+2019-05-21 Said Abou-Hallawa <said@apple.com> >+ >+ Unify the parsing of SVGList super classes >+ https://bugs.webkit.org/show_bug.cgi?id=198073 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * web-platform-tests/html/syntax/parsing/html5lib_tests11-expected.txt: >+ Report error messages if a SVGPreserveAspectRatio or SVGZoomAndPan parsing >+ error happens. >+ > 2019-05-20 Said Abou-Hallawa <sabouhallawa@apple.com> > > Unify the parsing of SVGList super classes >diff --git a/LayoutTests/svg/animations/svgnumber-animation-3-expected.txt b/LayoutTests/svg/animations/svgnumber-animation-3-expected.txt >index dd3525d1a5b..e9f031b278e 100644 >--- a/LayoutTests/svg/animations/svgnumber-animation-3-expected.txt >+++ b/LayoutTests/svg/animations/svgnumber-animation-3-expected.txt >@@ -6,8 +6,8 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE > > > PASS getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 >-PASS getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 >-PASS getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 >+PASS getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0.5 >+PASS getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 1 > PASS getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 > PASS successfullyParsed is true > >diff --git a/LayoutTests/svg/animations/svgnumber-animation-3.html b/LayoutTests/svg/animations/svgnumber-animation-3.html >index b60da83a74d..8bc442699f4 100644 >--- a/LayoutTests/svg/animations/svgnumber-animation-3.html >+++ b/LayoutTests/svg/animations/svgnumber-animation-3.html >@@ -36,15 +36,15 @@ rootSVGElement.appendChild(rect); > // Setup animation test > function sample1() { > // Check initial/end conditions >- shouldBe("getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0"); >+ shouldBeCloseEnough("getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0"); > } > > function sample2() { >- shouldBe("getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0"); >+ shouldBeCloseEnough("getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0.5"); > } > > function sample3() { >- shouldBe("getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "0"); >+ shouldBeCloseEnough("getComputedStyle(rect).getPropertyCSSValue('opacity').getFloatValue(CSSPrimitiveValue.CSS_NUMBER)", "1"); > } > > function executeTest() { >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 20b3ac3b930..241b546d4e7 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,190 @@ >+2019-05-21 Said Abou-Hallawa <said@apple.com> >+ >+ SVGPropertyTraits and SVG enum types clean up >+ https://bugs.webkit.org/show_bug.cgi?id=198073 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In this patch: >+ >+ -- All SVGPropertyTraits will have two functions for parsing a string to >+ the property type. >+ 1) parse() will return Expected<PropertyType, SVGParsingError>. >+ 2) fromString() will call parse() but will return the default value >+ if parse() returns an error. >+ >+ -- All the SVG enum types are moved to a single file named SVGEnumType.h. >+ A new SVGPropertyTraits is defined for all enum types including the >+ non-SVG enum types, e.g. BlendMode. >+ >+ -- All SVGPropertyTraits for the enum types are removed. Parsing a string >+ to an enum value will be done by SVGEnumValueParser::parse(). Getting >+ a string from an enum value is done by SVGEnumValueComposer::toString(). >+ Each enum type needs to template specialize SVGEnumTraits::values() >+ which associates every emum value with a string. >+ >+ * WebCore.xcodeproj/project.pbxproj: >+ * css/CSSPrimitiveValueMappings.h: >+ (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): >+ * platform/graphics/GraphicsTypes.h: >+ * platform/graphics/cg/GraphicsContextCG.cpp: >+ (WebCore::selectCGBlendMode): >+ * svg/SVGAngleValue.h: >+ (WebCore::SVGPropertyTraits<SVGAngleValue>::initialValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGAngleValue>::toString): Deleted. >+ * svg/SVGComponentTransferFunctionElement.h: >+ (WebCore::SVGPropertyTraits<ComponentTransferType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<ComponentTransferType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<ComponentTransferType>::fromString): Deleted. >+ * svg/SVGFEBlendElement.h: >+ (WebCore::SVGPropertyTraits<BlendMode>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<BlendMode>::fromString): Deleted. >+ (WebCore::SVGPropertyTraits<BlendMode>::toString): Deleted. >+ * svg/SVGFEColorMatrixElement.h: >+ (WebCore::SVGPropertyTraits<ColorMatrixType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<ColorMatrixType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<ColorMatrixType>::fromString): Deleted. >+ * svg/SVGFECompositeElement.h: >+ (WebCore::SVGIDLEnumLimits<CompositeOperationType>::highestExposedEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<CompositeOperationType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<CompositeOperationType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<CompositeOperationType>::fromString): Deleted. >+ * svg/SVGFEConvolveMatrixElement.h: >+ (WebCore::SVGPropertyTraits<EdgeModeType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<EdgeModeType>::initialValue): Deleted. >+ (WebCore::SVGPropertyTraits<EdgeModeType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<EdgeModeType>::fromString): Deleted. >+ * svg/SVGFEDisplacementMapElement.h: >+ (WebCore::SVGPropertyTraits<ChannelSelectorType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<ChannelSelectorType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<ChannelSelectorType>::fromString): Deleted. >+ * svg/SVGFEMorphologyElement.h: >+ (WebCore::SVGPropertyTraits<MorphologyOperatorType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<MorphologyOperatorType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<MorphologyOperatorType>::fromString): Deleted. >+ * svg/SVGFETurbulenceElement.cpp: >+ (WebCore::SVGFETurbulenceElement::build): >+ * svg/SVGFETurbulenceElement.h: >+ (WebCore::SVGPropertyTraits<SVGStitchOptions>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGStitchOptions>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGStitchOptions>::fromString): Deleted. >+ (WebCore::SVGPropertyTraits<TurbulenceType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<TurbulenceType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<TurbulenceType>::fromString): Deleted. >+ * svg/SVGGradientElement.h: >+ (WebCore::SVGPropertyTraits<SVGSpreadMethodType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGSpreadMethodType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGSpreadMethodType>::fromString): Deleted. >+ * svg/SVGLengthValue.h: >+ (WebCore::SVGPropertyTraits<SVGLengthValue>::initialValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGLengthValue>::parse): Deleted. >+ (WebCore::SVGPropertyTraits<SVGLengthValue>::toString): Deleted. >+ * svg/SVGMarkerTypes.h: >+ (WebCore::SVGPropertyTraits<SVGMarkerUnitsType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGMarkerUnitsType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGMarkerUnitsType>::fromString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::autoString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::autoStartReverseString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::fromString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGMarkerOrientType>::toString): Deleted. >+ (WebCore::SVGIDLEnumLimits<SVGMarkerOrientType>::highestExposedEnumValue): Deleted. >+ * svg/SVGParsingError.h: >+ (WebCore::SVGNumericParsingValidator::validate): >+ (WebCore::validateNumeric): >+ * svg/SVGPreserveAspectRatioValue.h: >+ (WebCore::SVGPropertyTraits<SVGPreserveAspectRatioValue>::initialValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGPreserveAspectRatioValue>::fromString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGPreserveAspectRatioValue>::parse): Deleted. >+ (WebCore::SVGPropertyTraits<SVGPreserveAspectRatioValue>::toString): Deleted. >+ * svg/SVGTextContentElement.h: >+ (WebCore::SVGPropertyTraits<SVGLengthAdjustType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGLengthAdjustType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGLengthAdjustType>::fromString): Deleted. >+ * svg/SVGTextPathElement.h: >+ (WebCore::SVGPropertyTraits<SVGTextPathMethodType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGTextPathMethodType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGTextPathMethodType>::fromString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGTextPathSpacingType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGTextPathSpacingType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGTextPathSpacingType>::fromString): Deleted. >+ * svg/SVGUnitTypes.h: >+ (WebCore::SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::highestEnumValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::toString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGUnitTypes::SVGUnitType>::fromString): Deleted. >+ * svg/SVGZoomAndPan.h: >+ (WebCore::SVGZoomAndPan::reset): >+ * svg/SVGZoomAndPanType.h: Deleted. >+ * svg/properties/SVGDecoratedPrimitive.h: >+ * svg/properties/SVGEnumTraits.h: Added. >+ (WebCore::SVGEnumValueChecker::isValidEnum): >+ (WebCore::SVGEnumValueParser::parse): >+ (WebCore::SVGEnumValueComposer::toString): >+ * svg/properties/SVGEnumType.h: Added. >+ * svg/properties/SVGEnumTypeTraits.h: Added. >+ (WebCore::SVGEnumTraits<BlendMode>::values): >+ (WebCore::SVGEnumTraits<BlendMode>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<ChannelSelectorType>::values): >+ (WebCore::SVGEnumTraits<ChannelSelectorType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<ComponentTransferType>::values): >+ (WebCore::SVGEnumTraits<ComponentTransferType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<ColorMatrixType>::values): >+ (WebCore::SVGEnumTraits<ColorMatrixType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<CompositeOperationType>::values): >+ (WebCore::SVGEnumTraits<CompositeOperationType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<EdgeModeType>::values): >+ (WebCore::SVGEnumTraits<EdgeModeType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<MorphologyOperatorType>::values): >+ (WebCore::SVGEnumTraits<MorphologyOperatorType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<TurbulenceType>::values): >+ (WebCore::SVGEnumTraits<TurbulenceType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<SVGLengthAdjustType>::values): >+ (WebCore::SVGEnumTraits<SVGLengthAdjustType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<SVGMarkerUnitsType>::values): >+ (WebCore::SVGEnumTraits<SVGMarkerUnitsType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<SVGMarkerOrientType>::values): >+ (WebCore::SVGEnumTraits<SVGMarkerOrientType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<SVGSpreadMethodType>::values): >+ (WebCore::SVGEnumTraits<SVGSpreadMethodType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<SVGStitchOptions>::values): >+ (WebCore::SVGEnumTraits<SVGStitchOptions>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<SVGTextPathMethodType>::values): >+ (WebCore::SVGEnumTraits<SVGTextPathMethodType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<SVGTextPathSpacingType>::values): >+ (WebCore::SVGEnumTraits<SVGTextPathSpacingType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<SVGUnitTypes::SVGUnitType>::values): >+ (WebCore::SVGEnumTraits<SVGUnitTypes::SVGUnitType>::highestExposedEnumValue): >+ (WebCore::SVGEnumTraits<SVGZoomAndPanType>::values): >+ (WebCore::SVGEnumTraits<SVGZoomAndPanType>::highestExposedEnumValue): >+ * svg/properties/SVGPropertyTraits.h: >+ (WebCore::SVGPropertyTraits<bool>::parse): >+ (WebCore::SVGPropertyTraits<bool>::fromString): >+ (WebCore::SVGPropertyTraits<bool>::toString): >+ (WebCore::SVGPropertyTraits<Color>::parse): >+ (WebCore::SVGPropertyTraits<Color>::fromString): >+ (WebCore::SVGPropertyTraits<Color>::toString): >+ (WebCore::SVGPropertyTraits<String>::initialValue): >+ (WebCore::SVGPropertyTraits<String>::parse): >+ (WebCore::SVGPropertyTraits<String>::fromString): >+ (WebCore::SVGPropertyTraits<String>::toString): >+ (WebCore::SVGPropertyTraits<float>::parse): >+ (WebCore::SVGPropertyTraits<float>::fromString): >+ (WebCore::SVGPropertyTraits<float>::toString): >+ (WebCore::SVGPropertyTraits<int>::initialValue): >+ (WebCore::SVGPropertyTraits<int>::parse): >+ (WebCore::SVGPropertyTraits<int>::fromString): >+ (WebCore::SVGPropertyTraits<int>::toString): >+ (WebCore::SVGPropertyTraits<FloatPoint>::parse): >+ (WebCore::SVGPropertyTraits<FloatPoint>::fromString): >+ (WebCore::SVGPropertyTraits<FloatPoint>::toString): >+ (WebCore::SVGPropertyTraits<FloatRect>::parse): >+ (WebCore::SVGPropertyTraits<FloatRect>::fromString): >+ (WebCore::SVGPropertyTraits<FloatRect>::toString): >+ (WebCore::SVGPropertyTraits<unsigned>::initialValue): Deleted. >+ (WebCore::SVGPropertyTraits<unsigned>::parse): Deleted. >+ (WebCore::SVGPropertyTraits<unsigned>::toString): Deleted. >+ (WebCore::SVGIDLEnumLimits::highestExposedEnumValue): Deleted. >+ > 2019-05-20 Said Abou-Hallawa <said@apple.com> > > Unify the parsing of SVGList super classes >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index f69cff23212..62b8a1f226d 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1738,7 +1738,6 @@ > 55DCC52822407B2000C26E32 /* SVGPrimitiveList.h in Headers */ = {isa = PBXBuildFile; fileRef = 55DCC5252240749E00C26E32 /* SVGPrimitiveList.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 55DCC52922407B2A00C26E32 /* SVGList.h in Headers */ = {isa = PBXBuildFile; fileRef = 55DCC523224073FE00C26E32 /* SVGList.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 55EC9599206AA7A0007DD0A9 /* PaintFrequencyTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 55EC95972069C92D007DD0A9 /* PaintFrequencyTracker.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 55FA7FFB2110ECD7005AEFE7 /* SVGZoomAndPanType.h in Headers */ = {isa = PBXBuildFile; fileRef = 55FA7FFA2110ECD7005AEFE7 /* SVGZoomAndPanType.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 5704405A1E53936200356601 /* JSAesCbcCfbParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 570440591E53936200356601 /* JSAesCbcCfbParams.h */; }; > 5706A6961DDE5C9500A03B14 /* CryptoAlgorithmRsaOaepParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5706A6951DDE5C9500A03B14 /* CryptoAlgorithmRsaOaepParams.h */; }; > 5706A6981DDE5E4600A03B14 /* JSRsaOaepParams.h in Headers */ = {isa = PBXBuildFile; fileRef = 5706A6971DDE5E4600A03B14 /* JSRsaOaepParams.h */; }; >@@ -8534,7 +8533,6 @@ > 55EE5362223B2A2300FBA944 /* SVGAnimatedProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedProperty.h; sourceTree = "<group>"; }; > 55EE5363223B2A2400FBA944 /* SVGProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGProperty.h; sourceTree = "<group>"; }; > 55EE5364223B2A2400FBA944 /* SVGAttributeAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAttributeAnimator.h; sourceTree = "<group>"; }; >- 55FA7FFA2110ECD7005AEFE7 /* SVGZoomAndPanType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGZoomAndPanType.h; sourceTree = "<group>"; }; > 570440571E53851600356601 /* CryptoAlgorithmAES_CFBMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoAlgorithmAES_CFBMac.cpp; sourceTree = "<group>"; }; > 570440591E53936200356601 /* JSAesCbcCfbParams.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSAesCbcCfbParams.h; sourceTree = "<group>"; }; > 5704405B1E53937900356601 /* JSAesCbcCfbParams.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAesCbcCfbParams.cpp; sourceTree = "<group>"; }; >@@ -9367,6 +9365,9 @@ > 724ED3301A3A8B2300F5F13C /* JSEXTBlendMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSEXTBlendMinMax.h; sourceTree = "<group>"; }; > 724EE54E1DC7F25B00A91FFB /* ActivityState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityState.h; sourceTree = "<group>"; }; > 724EE54F1DC7F25B00A91FFB /* ActivityStateChangeObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActivityStateChangeObserver.h; sourceTree = "<group>"; }; >+ 72654AA3228C6B3B00BEB103 /* SVGEnumTraits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGEnumTraits.h; sourceTree = "<group>"; }; >+ 72654AA7228EFDC400BEB103 /* SVGEnumType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGEnumType.h; sourceTree = "<group>"; }; >+ 72654AA8228F383600BEB103 /* SVGEnumTypeTraits.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGEnumTypeTraits.h; sourceTree = "<group>"; }; > 7266F0132241BCE200833975 /* SVGPropertyAnimatorFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPropertyAnimatorFactory.h; sourceTree = "<group>"; }; > 7266F0142241BFB200833975 /* SVGPrimitivePropertyAnimatorImpl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimatorImpl.h; sourceTree = "<group>"; }; > 7266F0152241C09800833975 /* SVGPrimitivePropertyAnimator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGPrimitivePropertyAnimator.h; sourceTree = "<group>"; }; >@@ -16026,6 +16027,9 @@ > 5553592122441B97008F5EC9 /* SVGDecoratedEnumeration.h */, > 5553592222441BE9008F5EC9 /* SVGDecoratedPrimitive.h */, > 5553592322441C18008F5EC9 /* SVGDecoratedProperty.h */, >+ 72654AA3228C6B3B00BEB103 /* SVGEnumTraits.h */, >+ 72654AA7228EFDC400BEB103 /* SVGEnumType.h */, >+ 72654AA8228F383600BEB103 /* SVGEnumTypeTraits.h */, > 55DCC523224073FE00C26E32 /* SVGList.h */, > 55EE5354223B29E900FBA944 /* SVGMemberAccessor.h */, > 55BE025A223B29C20032F08A /* SVGPointerMemberAccessor.h */, >@@ -24177,7 +24181,6 @@ > B222795F0D00BF210071B782 /* SVGZoomAndPan.cpp */, > B22279600D00BF210071B782 /* SVGZoomAndPan.h */, > B22279610D00BF210071B782 /* SVGZoomAndPan.idl */, >- 55FA7FFA2110ECD7005AEFE7 /* SVGZoomAndPanType.h */, > B2E4EC940D00C22B00432643 /* SVGZoomEvent.cpp */, > B2E4EC950D00C22B00432643 /* SVGZoomEvent.h */, > B2E4EC960D00C22B00432643 /* SVGZoomEvent.idl */, >@@ -31704,7 +31707,6 @@ > B2227AF30D00BF220071B782 /* SVGViewSpec.h in Headers */, > 8485228B1190173C006EDC7F /* SVGVKernElement.h in Headers */, > B2227AF60D00BF220071B782 /* SVGZoomAndPan.h in Headers */, >- 55FA7FFB2110ECD7005AEFE7 /* SVGZoomAndPanType.h in Headers */, > B2E4EC980D00C22B00432643 /* SVGZoomEvent.h in Headers */, > 46ECB6381FD0A3C80088E5AD /* SWClientConnection.h in Headers */, > 46658DC91FA24B8700F7DD54 /* SWContextManager.h in Headers */, >diff --git a/Source/WebCore/css/CSSPrimitiveValueMappings.h b/Source/WebCore/css/CSSPrimitiveValueMappings.h >index 9d120ca5e82..8ff4ff03e7c 100644 >--- a/Source/WebCore/css/CSSPrimitiveValueMappings.h >+++ b/Source/WebCore/css/CSSPrimitiveValueMappings.h >@@ -3923,6 +3923,9 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(BlendMode blendMode) > { > m_primitiveUnitType = CSS_VALUE_ID; > switch (blendMode) { >+ case BlendMode::Unknown: >+ ASSERT_NOT_REACHED(); >+ break; > case BlendMode::Normal: > m_value.valueID = CSSValueNormal; > break; >diff --git a/Source/WebCore/platform/graphics/GraphicsTypes.h b/Source/WebCore/platform/graphics/GraphicsTypes.h >index 6e1afee198c..e94223cef64 100644 >--- a/Source/WebCore/platform/graphics/GraphicsTypes.h >+++ b/Source/WebCore/platform/graphics/GraphicsTypes.h >@@ -52,6 +52,7 @@ enum CompositeOperator { > }; > > enum class BlendMode { >+ Unknown = 0, > Normal = 1, // Start with 1 to match SVG's blendmode enumeration. > Multiply, > Screen, >diff --git a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >index 8adf8014df5..c726f9dba2e 100644 >--- a/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >+++ b/Source/WebCore/platform/graphics/cg/GraphicsContextCG.cpp >@@ -154,6 +154,9 @@ static InterpolationQuality convertInterpolationQuality(CGInterpolationQuality q > static CGBlendMode selectCGBlendMode(CompositeOperator compositeOperator, BlendMode blendMode) > { > switch (blendMode) { >+ case BlendMode::Unknown: >+ ASSERT_NOT_REACHED(); >+ return kCGBlendModeNormal; > case BlendMode::Normal: > switch (compositeOperator) { > case CompositeClear: >diff --git a/Source/WebCore/svg/SVGAngleValue.h b/Source/WebCore/svg/SVGAngleValue.h >index 4d402f7fcd4..cc4544183cf 100644 >--- a/Source/WebCore/svg/SVGAngleValue.h >+++ b/Source/WebCore/svg/SVGAngleValue.h >@@ -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(); } >-}; >- > } >diff --git a/Source/WebCore/svg/SVGComponentTransferFunctionElement.h b/Source/WebCore/svg/SVGComponentTransferFunctionElement.h >index a3388f82e28..c5995cd7843 100644 >--- a/Source/WebCore/svg/SVGComponentTransferFunctionElement.h >+++ b/Source/WebCore/svg/SVGComponentTransferFunctionElement.h >@@ -26,47 +26,6 @@ > > namespace WebCore { > >-template<> >-struct SVGPropertyTraits<ComponentTransferType> { >- static unsigned highestEnumValue() { return FECOMPONENTTRANSFER_TYPE_GAMMA; } >- >- static String toString(ComponentTransferType type) >- { >- switch (type) { >- case FECOMPONENTTRANSFER_TYPE_UNKNOWN: >- return emptyString(); >- case FECOMPONENTTRANSFER_TYPE_IDENTITY: >- return "identity"_s; >- case FECOMPONENTTRANSFER_TYPE_TABLE: >- return "table"_s; >- case FECOMPONENTTRANSFER_TYPE_DISCRETE: >- return "discrete"_s; >- case FECOMPONENTTRANSFER_TYPE_LINEAR: >- return "linear"_s; >- case FECOMPONENTTRANSFER_TYPE_GAMMA: >- return "gamma"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static ComponentTransferType fromString(const String& value) >- { >- if (value == "identity") >- return FECOMPONENTTRANSFER_TYPE_IDENTITY; >- if (value == "table") >- return FECOMPONENTTRANSFER_TYPE_TABLE; >- if (value == "discrete") >- return FECOMPONENTTRANSFER_TYPE_DISCRETE; >- if (value == "linear") >- return FECOMPONENTTRANSFER_TYPE_LINEAR; >- if (value == "gamma") >- return FECOMPONENTTRANSFER_TYPE_GAMMA; >- return FECOMPONENTTRANSFER_TYPE_UNKNOWN; >- } >-}; >- > class SVGComponentTransferFunctionElement : public SVGElement { > WTF_MAKE_ISO_ALLOCATED(SVGComponentTransferFunctionElement); > public: >diff --git a/Source/WebCore/svg/SVGFEBlendElement.h b/Source/WebCore/svg/SVGFEBlendElement.h >index a9c98e42766..750a5175989 100644 >--- a/Source/WebCore/svg/SVGFEBlendElement.h >+++ b/Source/WebCore/svg/SVGFEBlendElement.h >@@ -27,26 +27,6 @@ > > namespace WebCore { > >-template<> >-struct SVGPropertyTraits<BlendMode> { >- static unsigned highestEnumValue() { return static_cast<unsigned>(BlendMode::Luminosity); } >- >- static BlendMode fromString(const String& string) >- { >- BlendMode mode = BlendMode::Normal; >- parseBlendMode(string, mode); >- return mode; >- } >- >- static String toString(BlendMode type) >- { >- if (type < BlendMode::PlusDarker) >- return blendModeName(type); >- >- return emptyString(); >- } >-}; >- > class SVGFEBlendElement final : public SVGFilterPrimitiveStandardAttributes { > WTF_MAKE_ISO_ALLOCATED(SVGFEBlendElement); > public: >diff --git a/Source/WebCore/svg/SVGFEColorMatrixElement.h b/Source/WebCore/svg/SVGFEColorMatrixElement.h >index 3ef24c94224..0d227463f0a 100644 >--- a/Source/WebCore/svg/SVGFEColorMatrixElement.h >+++ b/Source/WebCore/svg/SVGFEColorMatrixElement.h >@@ -26,43 +26,6 @@ > > namespace WebCore { > >-template<> >-struct SVGPropertyTraits<ColorMatrixType> { >- static unsigned highestEnumValue() { return FECOLORMATRIX_TYPE_LUMINANCETOALPHA; } >- >- static String toString(ColorMatrixType type) >- { >- switch (type) { >- case FECOLORMATRIX_TYPE_UNKNOWN: >- return emptyString(); >- case FECOLORMATRIX_TYPE_MATRIX: >- return "matrix"_s; >- case FECOLORMATRIX_TYPE_SATURATE: >- return "saturate"_s; >- case FECOLORMATRIX_TYPE_HUEROTATE: >- return "hueRotate"_s; >- case FECOLORMATRIX_TYPE_LUMINANCETOALPHA: >- return "luminanceToAlpha"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static ColorMatrixType fromString(const String& value) >- { >- if (value == "matrix") >- return FECOLORMATRIX_TYPE_MATRIX; >- if (value == "saturate") >- return FECOLORMATRIX_TYPE_SATURATE; >- if (value == "hueRotate") >- return FECOLORMATRIX_TYPE_HUEROTATE; >- if (value == "luminanceToAlpha") >- return FECOLORMATRIX_TYPE_LUMINANCETOALPHA; >- return FECOLORMATRIX_TYPE_UNKNOWN; >- } >-}; >- > class SVGFEColorMatrixElement final : public SVGFilterPrimitiveStandardAttributes { > WTF_MAKE_ISO_ALLOCATED(SVGFEColorMatrixElement); > public: >diff --git a/Source/WebCore/svg/SVGFECompositeElement.h b/Source/WebCore/svg/SVGFECompositeElement.h >index a33c982b349..17462fdc5be 100644 >--- a/Source/WebCore/svg/SVGFECompositeElement.h >+++ b/Source/WebCore/svg/SVGFECompositeElement.h >@@ -26,58 +26,6 @@ > > namespace WebCore { > >-template<> >-inline unsigned SVGIDLEnumLimits<CompositeOperationType>::highestExposedEnumValue() { return FECOMPOSITE_OPERATOR_ARITHMETIC; } >- >-template<> >-struct SVGPropertyTraits<CompositeOperationType> { >- static unsigned highestEnumValue() { return FECOMPOSITE_OPERATOR_LIGHTER; } >- >- static String toString(CompositeOperationType type) >- { >- switch (type) { >- case FECOMPOSITE_OPERATOR_UNKNOWN: >- return emptyString(); >- case FECOMPOSITE_OPERATOR_OVER: >- return "over"_s; >- case FECOMPOSITE_OPERATOR_IN: >- return "in"_s; >- case FECOMPOSITE_OPERATOR_OUT: >- return "out"_s; >- case FECOMPOSITE_OPERATOR_ATOP: >- return "atop"_s; >- case FECOMPOSITE_OPERATOR_XOR: >- return "xor"_s; >- case FECOMPOSITE_OPERATOR_ARITHMETIC: >- return "arithmetic"_s; >- case FECOMPOSITE_OPERATOR_LIGHTER: >- return "lighter"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static CompositeOperationType fromString(const String& value) >- { >- if (value == "over") >- return FECOMPOSITE_OPERATOR_OVER; >- if (value == "in") >- return FECOMPOSITE_OPERATOR_IN; >- if (value == "out") >- return FECOMPOSITE_OPERATOR_OUT; >- if (value == "atop") >- return FECOMPOSITE_OPERATOR_ATOP; >- if (value == "xor") >- return FECOMPOSITE_OPERATOR_XOR; >- if (value == "arithmetic") >- return FECOMPOSITE_OPERATOR_ARITHMETIC; >- if (value == "lighter") >- return FECOMPOSITE_OPERATOR_LIGHTER; >- return FECOMPOSITE_OPERATOR_UNKNOWN; >- } >-}; >- > class SVGFECompositeElement final : public SVGFilterPrimitiveStandardAttributes { > WTF_MAKE_ISO_ALLOCATED(SVGFECompositeElement); > public: >diff --git a/Source/WebCore/svg/SVGFEConvolveMatrixElement.h b/Source/WebCore/svg/SVGFEConvolveMatrixElement.h >index cea1123faa9..e40111a053c 100644 >--- a/Source/WebCore/svg/SVGFEConvolveMatrixElement.h >+++ b/Source/WebCore/svg/SVGFEConvolveMatrixElement.h >@@ -25,40 +25,6 @@ > > namespace WebCore { > >-template<> >-struct SVGPropertyTraits<EdgeModeType> { >- static unsigned highestEnumValue() { return EDGEMODE_NONE; } >- static EdgeModeType initialValue() { return EDGEMODE_NONE; } >- >- static String toString(EdgeModeType type) >- { >- switch (type) { >- case EDGEMODE_UNKNOWN: >- return emptyString(); >- case EDGEMODE_DUPLICATE: >- return "duplicate"_s; >- case EDGEMODE_WRAP: >- return "wrap"_s; >- case EDGEMODE_NONE: >- return "none"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static EdgeModeType fromString(const String& value) >- { >- if (value == "duplicate") >- return EDGEMODE_DUPLICATE; >- if (value == "wrap") >- return EDGEMODE_WRAP; >- if (value == "none") >- return EDGEMODE_NONE; >- return EDGEMODE_UNKNOWN; >- } >-}; >- > class SVGFEConvolveMatrixElement final : public SVGFilterPrimitiveStandardAttributes { > WTF_MAKE_ISO_ALLOCATED(SVGFEConvolveMatrixElement); > public: >diff --git a/Source/WebCore/svg/SVGFEDisplacementMapElement.h b/Source/WebCore/svg/SVGFEDisplacementMapElement.h >index 422f0cf7ea9..c1a70cf5f23 100644 >--- a/Source/WebCore/svg/SVGFEDisplacementMapElement.h >+++ b/Source/WebCore/svg/SVGFEDisplacementMapElement.h >@@ -25,43 +25,6 @@ > > namespace WebCore { > >-template<> >-struct SVGPropertyTraits<ChannelSelectorType> { >- static unsigned highestEnumValue() { return CHANNEL_A; } >- >- static String toString(ChannelSelectorType type) >- { >- switch (type) { >- case CHANNEL_UNKNOWN: >- return emptyString(); >- case CHANNEL_R: >- return "R"_s; >- case CHANNEL_G: >- return "G"_s; >- case CHANNEL_B: >- return "B"_s; >- case CHANNEL_A: >- return "A"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static ChannelSelectorType fromString(const String& value) >- { >- if (value == "R") >- return CHANNEL_R; >- if (value == "G") >- return CHANNEL_G; >- if (value == "B") >- return CHANNEL_B; >- if (value == "A") >- return CHANNEL_A; >- return CHANNEL_UNKNOWN; >- } >-}; >- > class SVGFEDisplacementMapElement final : public SVGFilterPrimitiveStandardAttributes { > WTF_MAKE_ISO_ALLOCATED(SVGFEDisplacementMapElement); > public: >diff --git a/Source/WebCore/svg/SVGFEMorphologyElement.h b/Source/WebCore/svg/SVGFEMorphologyElement.h >index 99933555361..050de080ca3 100644 >--- a/Source/WebCore/svg/SVGFEMorphologyElement.h >+++ b/Source/WebCore/svg/SVGFEMorphologyElement.h >@@ -25,35 +25,6 @@ > > namespace WebCore { > >-template<> >-struct SVGPropertyTraits<MorphologyOperatorType> { >- static unsigned highestEnumValue() { return FEMORPHOLOGY_OPERATOR_DILATE; } >- >- static String toString(MorphologyOperatorType type) >- { >- switch (type) { >- case FEMORPHOLOGY_OPERATOR_UNKNOWN: >- return emptyString(); >- case FEMORPHOLOGY_OPERATOR_ERODE: >- return "erode"_s; >- case FEMORPHOLOGY_OPERATOR_DILATE: >- return "dilate"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static MorphologyOperatorType fromString(const String& value) >- { >- if (value == "erode") >- return FEMORPHOLOGY_OPERATOR_ERODE; >- if (value == "dilate") >- return FEMORPHOLOGY_OPERATOR_DILATE; >- return FEMORPHOLOGY_OPERATOR_UNKNOWN; >- } >-}; >- > class SVGFEMorphologyElement final : public SVGFilterPrimitiveStandardAttributes { > WTF_MAKE_ISO_ALLOCATED(SVGFEMorphologyElement); > public: >diff --git a/Source/WebCore/svg/SVGFETurbulenceElement.cpp b/Source/WebCore/svg/SVGFETurbulenceElement.cpp >index 3e35d220e48..58e7ca678e2 100644 >--- a/Source/WebCore/svg/SVGFETurbulenceElement.cpp >+++ b/Source/WebCore/svg/SVGFETurbulenceElement.cpp >@@ -121,7 +121,7 @@ RefPtr<FilterEffect> SVGFETurbulenceElement::build(SVGFilterBuilder*, Filter& fi > { > if (baseFrequencyX() < 0 || baseFrequencyY() < 0) > return nullptr; >- return FETurbulence::create(filter, type(), baseFrequencyX(), baseFrequencyY(), numOctaves(), seed(), stitchTiles() == SVG_STITCHTYPE_STITCH); >+ return FETurbulence::create(filter, type(), baseFrequencyX(), baseFrequencyY(), numOctaves(), seed(), stitchTiles() == SVGStitchTypeStitch); > } > > } >diff --git a/Source/WebCore/svg/SVGFETurbulenceElement.h b/Source/WebCore/svg/SVGFETurbulenceElement.h >index cca7f85783f..ec3701762df 100644 >--- a/Source/WebCore/svg/SVGFETurbulenceElement.h >+++ b/Source/WebCore/svg/SVGFETurbulenceElement.h >@@ -26,73 +26,16 @@ > > namespace WebCore { > >-enum SVGStitchOptions { >- SVG_STITCHTYPE_UNKNOWN = 0, >- SVG_STITCHTYPE_STITCH = 1, >- SVG_STITCHTYPE_NOSTITCH = 2 >-}; >- >-template<> >-struct SVGPropertyTraits<SVGStitchOptions> { >- static unsigned highestEnumValue() { return SVG_STITCHTYPE_NOSTITCH; } >- >- static String toString(SVGStitchOptions type) >- { >- switch (type) { >- case SVG_STITCHTYPE_UNKNOWN: >- return emptyString(); >- case SVG_STITCHTYPE_STITCH: >- return "stitch"_s; >- case SVG_STITCHTYPE_NOSTITCH: >- return "noStitch"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static SVGStitchOptions fromString(const String& value) >- { >- if (value == "stitch") >- return SVG_STITCHTYPE_STITCH; >- if (value == "noStitch") >- return SVG_STITCHTYPE_NOSTITCH; >- return SVG_STITCHTYPE_UNKNOWN; >- } >-}; >- >-template<> >-struct SVGPropertyTraits<TurbulenceType> { >- static unsigned highestEnumValue() { return static_cast<unsigned>(TurbulenceType::Turbulence); } >- >- static String toString(TurbulenceType type) >- { >- switch (type) { >- case TurbulenceType::Unknown: >- return emptyString(); >- case TurbulenceType::FractalNoise: >- return "fractalNoise"_s; >- case TurbulenceType::Turbulence: >- return "turbulence"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static TurbulenceType fromString(const String& value) >- { >- if (value == "fractalNoise") >- return TurbulenceType::FractalNoise; >- if (value == "turbulence") >- return TurbulenceType::Turbulence; >- return TurbulenceType::Unknown; >- } >-}; >- > class SVGFETurbulenceElement final : public SVGFilterPrimitiveStandardAttributes { > WTF_MAKE_ISO_ALLOCATED(SVGFETurbulenceElement); > public: >+ // Forward declare enumerations in the W3C naming scheme, for IDL generation. >+ enum { >+ SVG_STITCHTYPE_UNKNOWN = SVGStitchTypeUnknown, >+ SVG_STITCHTYPE_STITCH = SVGStitchTypeStitch, >+ SVG_STITCHTYPE_NOSTITCH = SVGStitchTypeNoStitch, >+ }; >+ > static Ref<SVGFETurbulenceElement> create(const QualifiedName&, Document&); > > float baseFrequencyX() const { return m_baseFrequencyX->currentValue(); } >@@ -126,7 +69,7 @@ private: > Ref<SVGAnimatedNumber> m_baseFrequencyY { SVGAnimatedNumber::create(this) }; > Ref<SVGAnimatedInteger> m_numOctaves { SVGAnimatedInteger::create(this, 1) }; > Ref<SVGAnimatedNumber> m_seed { SVGAnimatedNumber::create(this) }; >- Ref<SVGAnimatedEnumeration> m_stitchTiles { SVGAnimatedEnumeration::create(this, SVG_STITCHTYPE_NOSTITCH) }; >+ Ref<SVGAnimatedEnumeration> m_stitchTiles { SVGAnimatedEnumeration::create(this, SVGStitchTypeNoStitch) }; > Ref<SVGAnimatedEnumeration> m_type { SVGAnimatedEnumeration::create(this, TurbulenceType::Turbulence) }; > }; > >diff --git a/Source/WebCore/svg/SVGGradientElement.h b/Source/WebCore/svg/SVGGradientElement.h >index 21b210c5951..2613e886375 100644 >--- a/Source/WebCore/svg/SVGGradientElement.h >+++ b/Source/WebCore/svg/SVGGradientElement.h >@@ -30,46 +30,6 @@ > > namespace WebCore { > >-enum SVGSpreadMethodType { >- SVGSpreadMethodUnknown = 0, >- SVGSpreadMethodPad, >- SVGSpreadMethodReflect, >- SVGSpreadMethodRepeat >-}; >- >-template<> >-struct SVGPropertyTraits<SVGSpreadMethodType> { >- static unsigned highestEnumValue() { return SVGSpreadMethodRepeat; } >- >- static String toString(SVGSpreadMethodType type) >- { >- switch (type) { >- case SVGSpreadMethodUnknown: >- return emptyString(); >- case SVGSpreadMethodPad: >- return "pad"_s; >- case SVGSpreadMethodReflect: >- return "reflect"_s; >- case SVGSpreadMethodRepeat: >- return "repeat"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static SVGSpreadMethodType fromString(const String& value) >- { >- if (value == "pad") >- return SVGSpreadMethodPad; >- if (value == "reflect") >- return SVGSpreadMethodReflect; >- if (value == "repeat") >- return SVGSpreadMethodRepeat; >- return SVGSpreadMethodUnknown; >- } >-}; >- > class SVGGradientElement : public SVGElement, public SVGExternalResourcesRequired, public SVGURIReference { > WTF_MAKE_ISO_ALLOCATED(SVGGradientElement); > public: >diff --git a/Source/WebCore/svg/SVGLengthValue.h b/Source/WebCore/svg/SVGLengthValue.h >index 92661b21e53..97b55137d24 100644 >--- a/Source/WebCore/svg/SVGLengthValue.h >+++ b/Source/WebCore/svg/SVGLengthValue.h >@@ -145,17 +145,6 @@ private: > unsigned m_unit; > }; > >-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(); } >-}; >- > WTF::TextStream& operator<<(WTF::TextStream&, const SVGLengthValue&); > > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGMarkerTypes.h b/Source/WebCore/svg/SVGMarkerTypes.h >index b811d2e9dbc..826a0f54485 100644 >--- a/Source/WebCore/svg/SVGMarkerTypes.h >+++ b/Source/WebCore/svg/SVGMarkerTypes.h >@@ -26,99 +26,32 @@ > #pragma once > > #include "SVGAngleValue.h" >+#include "SVGEnumType.h" > #include "SVGPropertyTraits.h" > > namespace WebCore { > >-enum SVGMarkerUnitsType { >- SVGMarkerUnitsUnknown = 0, >- SVGMarkerUnitsUserSpaceOnUse, >- SVGMarkerUnitsStrokeWidth >-}; >- >-enum SVGMarkerOrientType { >- SVGMarkerOrientUnknown = 0, >- SVGMarkerOrientAuto, >- SVGMarkerOrientAngle, >- SVGMarkerOrientAutoStartReverse, >- >- // Add new elements before here. >- SVGMarkerOrientMax >-}; >- > template<> >-struct SVGPropertyTraits<SVGMarkerUnitsType> { >- static unsigned highestEnumValue() { return SVGMarkerUnitsStrokeWidth; } >- static String toString(SVGMarkerUnitsType type) >- { >- switch (type) { >- case SVGMarkerUnitsUnknown: >- return emptyString(); >- case SVGMarkerUnitsUserSpaceOnUse: >- return "userSpaceOnUse"_s; >- case SVGMarkerUnitsStrokeWidth: >- return "strokeWidth"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- static SVGMarkerUnitsType fromString(const String& value) >+struct SVGPropertyTraits<std::pair<SVGAngleValue, SVGMarkerOrientType>> { >+ static Expected<std::pair<SVGAngleValue, SVGMarkerOrientType>, SVGParsingError> parse(const String& string) > { >- if (value == "userSpaceOnUse") >- return SVGMarkerUnitsUserSpaceOnUse; >- if (value == "strokeWidth") >- return SVGMarkerUnitsStrokeWidth; >- return SVGMarkerUnitsUnknown; >- } >-}; >+ SVGAngleValue angle; >+ if (string.isEmpty()) >+ return std::make_pair(angle, SVGMarkerOrientAngle); > >-template<> >-struct SVGPropertyTraits<SVGMarkerOrientType> { >- static const String autoString() >- { >- static const NeverDestroyed<String> autoString = MAKE_STATIC_STRING_IMPL("auto"); >- return autoString; >- } >- static const String autoStartReverseString() >- { >- static const NeverDestroyed<String> autoStartReverseString = MAKE_STATIC_STRING_IMPL("auto-start-reverse"); >- return autoStartReverseString; >- } >- static unsigned highestEnumValue() { return SVGMarkerOrientAutoStartReverse; } >- static SVGMarkerOrientType fromString(const String& string) >- { >- if (string == autoString()) >- return SVGMarkerOrientAuto; >- if (string == autoStartReverseString()) >- return SVGMarkerOrientAutoStartReverse; >- return SVGMarkerOrientUnknown; >- } >- static String toString(SVGMarkerOrientType type) >- { >- if (type == SVGMarkerOrientAuto) >- return autoString(); >- if (type == SVGMarkerOrientAutoStartReverse) >- return autoStartReverseString(); >- return emptyString(); >- } >-}; >+ SVGMarkerOrientType orientType = SVGPropertyTraits<SVGMarkerOrientType>::fromString(string); >+ if (orientType != SVGMarkerOrientUnknown) >+ return std::make_pair(angle, orientType); > >-template<> >-inline unsigned SVGIDLEnumLimits<SVGMarkerOrientType>::highestExposedEnumValue() { return SVGMarkerOrientAngle; } >+ auto result = angle.setValueAsString(string); >+ if (result.hasException()) >+ return makeUnexpected(ParsingAttributeFailedError); > >-template<> >-struct SVGPropertyTraits<std::pair<SVGAngleValue, SVGMarkerOrientType>> { >+ return std::make_pair(angle, SVGMarkerOrientAngle); >+ } > static std::pair<SVGAngleValue, SVGMarkerOrientType> fromString(const String& string) > { >- SVGAngleValue angle; >- SVGMarkerOrientType orientType = SVGPropertyTraits<SVGMarkerOrientType>::fromString(string); >- if (orientType == SVGMarkerOrientUnknown) { >- auto result = angle.setValueAsString(string); >- if (!result.hasException()) >- orientType = SVGMarkerOrientAngle; >- } >- return std::make_pair(angle, orientType); >+ return parse(string).value_or(std::make_pair<SVGAngleValue, SVGMarkerOrientType>({ }, SVGMarkerOrientUnknown)); > } > }; > >diff --git a/Source/WebCore/svg/SVGParsingError.h b/Source/WebCore/svg/SVGParsingError.h >index 772596099c4..54afdbf7c27 100644 >--- a/Source/WebCore/svg/SVGParsingError.h >+++ b/Source/WebCore/svg/SVGParsingError.h >@@ -1,6 +1,6 @@ > /* > * Copyright (C) Research In Motion Limited 2011. All rights reserved. >- * Copyright (C) 2011 Apple, Inc. All rights reserved. >+ * Copyright (C) 2011-2019 Apple, Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -37,4 +37,33 @@ enum SVGParsingError { > ParsingAttributeFailedError > }; > >+enum SVGParsingOptions { >+ NoOptions = 0, >+ ForbidNegative = 1 << 0, >+ ForbidZero = 1 << 2, >+ ForbidZeroAndNegative = ForbidNegative | ForbidZero, >+ AllowPercentage = 1 << 3 >+}; >+ >+template<typename T> struct SVGNumericParsingValidator; >+ >+template<typename T> >+struct SVGNumericParsingValidator { >+ static constexpr SVGParsingError validate(T t, SVGParsingOptions parsingOptions) >+ { >+ static_assert(std::is_arithmetic<T>::value, "This function can only check the value of a numeric."); >+ if ((parsingOptions & ForbidNegative) && t < 0) >+ return NegativeValueForbiddenError; >+ if ((parsingOptions & ForbidZero) && !t) >+ return ZeroValueForbiddenError; >+ return NoError; >+ } >+}; >+ >+template<typename T> >+constexpr auto validateNumeric(T t, SVGParsingOptions parsingOptions) >+{ >+ return SVGNumericParsingValidator<T>::validate(t, parsingOptions); >+} >+ > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGPreserveAspectRatioValue.h b/Source/WebCore/svg/SVGPreserveAspectRatioValue.h >index 66ed146be7f..f2d6096a336 100644 >--- a/Source/WebCore/svg/SVGPreserveAspectRatioValue.h >+++ b/Source/WebCore/svg/SVGPreserveAspectRatioValue.h >@@ -76,11 +76,4 @@ private: > bool parseInternal(const UChar*& currParam, const UChar* end, bool validate); > }; > >-template<> struct SVGPropertyTraits<SVGPreserveAspectRatioValue> { >- static SVGPreserveAspectRatioValue initialValue() { return SVGPreserveAspectRatioValue(); } >- static SVGPreserveAspectRatioValue fromString(const String& string) { return SVGPreserveAspectRatioValue(string); } >- static Optional<SVGPreserveAspectRatioValue> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); } >- static String toString(const SVGPreserveAspectRatioValue& type) { return type.valueAsString(); } >-}; >- > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGTextContentElement.h b/Source/WebCore/svg/SVGTextContentElement.h >index 0e6da5c6778..411977970b3 100644 >--- a/Source/WebCore/svg/SVGTextContentElement.h >+++ b/Source/WebCore/svg/SVGTextContentElement.h >@@ -28,40 +28,6 @@ namespace WebCore { > > struct DOMPointInit; > >-enum SVGLengthAdjustType { >- SVGLengthAdjustUnknown, >- SVGLengthAdjustSpacing, >- SVGLengthAdjustSpacingAndGlyphs >-}; >- >-template<> struct SVGPropertyTraits<SVGLengthAdjustType> { >- static unsigned highestEnumValue() { return SVGLengthAdjustSpacingAndGlyphs; } >- >- static String toString(SVGLengthAdjustType type) >- { >- switch (type) { >- case SVGLengthAdjustUnknown: >- return emptyString(); >- case SVGLengthAdjustSpacing: >- return "spacing"_s; >- case SVGLengthAdjustSpacingAndGlyphs: >- return "spacingAndGlyphs"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static SVGLengthAdjustType fromString(const String& value) >- { >- if (value == "spacingAndGlyphs") >- return SVGLengthAdjustSpacingAndGlyphs; >- if (value == "spacing") >- return SVGLengthAdjustSpacing; >- return SVGLengthAdjustUnknown; >- } >-}; >- > class SVGTextContentElement : public SVGGraphicsElement, public SVGExternalResourcesRequired { > WTF_MAKE_ISO_ALLOCATED(SVGTextContentElement); > public: >diff --git a/Source/WebCore/svg/SVGTextPathElement.h b/Source/WebCore/svg/SVGTextPathElement.h >index 435387bfaf5..8f295d70e54 100644 >--- a/Source/WebCore/svg/SVGTextPathElement.h >+++ b/Source/WebCore/svg/SVGTextPathElement.h >@@ -26,76 +26,6 @@ > > namespace WebCore { > >-enum SVGTextPathMethodType { >- SVGTextPathMethodUnknown = 0, >- SVGTextPathMethodAlign, >- SVGTextPathMethodStretch >-}; >- >-enum SVGTextPathSpacingType { >- SVGTextPathSpacingUnknown = 0, >- SVGTextPathSpacingAuto, >- SVGTextPathSpacingExact >-}; >- >-template<> >-struct SVGPropertyTraits<SVGTextPathMethodType> { >- static unsigned highestEnumValue() { return SVGTextPathMethodStretch; } >- >- static String toString(SVGTextPathMethodType type) >- { >- switch (type) { >- case SVGTextPathMethodUnknown: >- return emptyString(); >- case SVGTextPathMethodAlign: >- return "align"_s; >- case SVGTextPathMethodStretch: >- return "stretch"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static SVGTextPathMethodType fromString(const String& value) >- { >- if (value == "align") >- return SVGTextPathMethodAlign; >- if (value == "stretch") >- return SVGTextPathMethodStretch; >- return SVGTextPathMethodUnknown; >- } >-}; >- >-template<> >-struct SVGPropertyTraits<SVGTextPathSpacingType> { >- static unsigned highestEnumValue() { return SVGTextPathSpacingExact; } >- >- static String toString(SVGTextPathSpacingType type) >- { >- switch (type) { >- case SVGTextPathSpacingUnknown: >- return emptyString(); >- case SVGTextPathSpacingAuto: >- return "auto"_s; >- case SVGTextPathSpacingExact: >- return "exact"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static SVGTextPathSpacingType fromString(const String& value) >- { >- if (value == "auto") >- return SVGTextPathSpacingAuto; >- if (value == "exact") >- return SVGTextPathSpacingExact; >- return SVGTextPathSpacingUnknown; >- } >-}; >- > class SVGTextPathElement final : public SVGTextContentElement, public SVGURIReference { > WTF_MAKE_ISO_ALLOCATED(SVGTextPathElement); > public: >diff --git a/Source/WebCore/svg/SVGUnitTypes.h b/Source/WebCore/svg/SVGUnitTypes.h >index f44485f7e05..4a989c9dc9b 100644 >--- a/Source/WebCore/svg/SVGUnitTypes.h >+++ b/Source/WebCore/svg/SVGUnitTypes.h >@@ -19,7 +19,6 @@ > > #pragma once > >-#include "SVGPropertyTraits.h" > #include <wtf/RefCounted.h> > > namespace WebCore { >@@ -31,38 +30,8 @@ public: > SVG_UNIT_TYPE_USERSPACEONUSE = 1, > SVG_UNIT_TYPE_OBJECTBOUNDINGBOX = 2 > }; >- > private: >- SVGUnitTypes() { } >-}; >- >-template<> >-struct SVGPropertyTraits<SVGUnitTypes::SVGUnitType> { >- static unsigned highestEnumValue() { return SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; } >- >- static String toString(SVGUnitTypes::SVGUnitType type) >- { >- switch (type) { >- case SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN: >- return emptyString(); >- case SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE: >- return "userSpaceOnUse"_s; >- case SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: >- return "objectBoundingBox"_s; >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >- } >- >- static SVGUnitTypes::SVGUnitType fromString(const String& value) >- { >- if (value == "userSpaceOnUse") >- return SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE; >- if (value == "objectBoundingBox") >- return SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; >- return SVGUnitTypes::SVG_UNIT_TYPE_UNKNOWN; >- } >+ SVGUnitTypes() = default; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGZoomAndPan.h b/Source/WebCore/svg/SVGZoomAndPan.h >index 399b5eac220..90638f9108b 100644 >--- a/Source/WebCore/svg/SVGZoomAndPan.h >+++ b/Source/WebCore/svg/SVGZoomAndPan.h >@@ -23,8 +23,8 @@ > > #include "ExceptionOr.h" > #include "QualifiedName.h" >+#include "SVGEnumType.h" > #include "SVGNames.h" >-#include "SVGZoomAndPanType.h" > > namespace WebCore { > >@@ -41,7 +41,7 @@ public: > SVGZoomAndPanType zoomAndPan() const { return m_zoomAndPan; } > void setZoomAndPan(SVGZoomAndPanType zoomAndPan) { m_zoomAndPan = zoomAndPan; } > ExceptionOr<void> setZoomAndPan(unsigned) { return Exception { NoModificationAllowedError }; } >- void reset() { m_zoomAndPan = SVGPropertyTraits<SVGZoomAndPanType>::initialValue(); } >+ void reset() { m_zoomAndPan = SVGZoomAndPanMagnify; } > > Optional<SVGParsingError> parseAttribute(const QualifiedName&, const AtomicString&); > >@@ -49,7 +49,7 @@ protected: > SVGZoomAndPan() = default; > > private: >- SVGZoomAndPanType m_zoomAndPan { SVGPropertyTraits<SVGZoomAndPanType>::initialValue() }; >+ SVGZoomAndPanType m_zoomAndPan { SVGZoomAndPanMagnify }; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGZoomAndPanType.h b/Source/WebCore/svg/SVGZoomAndPanType.h >deleted file mode 100644 >index 120fa93f637..00000000000 >--- a/Source/WebCore/svg/SVGZoomAndPanType.h >+++ /dev/null >@@ -1,52 +0,0 @@ >-/* >- * Copyright (C) 2018 Apple Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions >- * are met: >- * 1. Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * 2. Redistributions in binary form must reproduce the above copyright >- * notice, this list of conditions and the following disclaimer in the >- * documentation and/or other materials provided with the distribution. >- * >- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#pragma once >- >-#include "SVGPropertyTraits.h" >- >-namespace WebCore { >- >-enum SVGZoomAndPanType { >- SVGZoomAndPanUnknown, >- SVGZoomAndPanDisable, >- SVGZoomAndPanMagnify >-}; >- >-template<> >-struct SVGPropertyTraits<SVGZoomAndPanType> { >- static SVGZoomAndPanType initialValue() { return SVGZoomAndPanMagnify; } >- static String toString(SVGZoomAndPanType) { return emptyString(); } >- static SVGZoomAndPanType fromString(const String& value) >- { >- if (value == "disable") >- return SVGZoomAndPanDisable; >- if (value == "magnify") >- return SVGZoomAndPanMagnify; >- return SVGZoomAndPanUnknown; >- } >-}; >- >-} >diff --git a/Source/WebCore/svg/properties/SVGDecoratedEnumeration.h b/Source/WebCore/svg/properties/SVGDecoratedEnumeration.h >index 264c36b6907..106bcde455b 100644 >--- a/Source/WebCore/svg/properties/SVGDecoratedEnumeration.h >+++ b/Source/WebCore/svg/properties/SVGDecoratedEnumeration.h >@@ -26,6 +26,7 @@ > #pragma once > > #include "SVGDecoratedPrimitive.h" >+#include "SVGEnumTraits.h" > > namespace WebCore { > >@@ -45,7 +46,7 @@ public: > private: > bool setValue(const DecorationType& value) override > { >- if (!value || value > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue()) >+ if (!SVGPropertyTraits<EnumType>::isValidEnum(value)) > return false; > Base::setValueInternal(value); > return true; >@@ -53,7 +54,7 @@ private: > > DecorationType value() const override > { >- if (Base::value() > SVGIDLEnumLimits<EnumType>::highestExposedEnumValue()) >+ if (!SVGPropertyTraits<EnumType>::isValidEnum(Base::value())) > return m_outOfRangeEnumValue; > return Base::value(); > } >diff --git a/Source/WebCore/svg/properties/SVGDecoratedPrimitive.h b/Source/WebCore/svg/properties/SVGDecoratedPrimitive.h >index e2a5243124f..fd243a17d2b 100644 >--- a/Source/WebCore/svg/properties/SVGDecoratedPrimitive.h >+++ b/Source/WebCore/svg/properties/SVGDecoratedPrimitive.h >@@ -26,6 +26,7 @@ > #pragma once > > #include "SVGDecoratedProperty.h" >+#include "SVGEnumTypeTraits.h" > > namespace WebCore { > >diff --git a/Source/WebCore/svg/properties/SVGEnumTraits.h b/Source/WebCore/svg/properties/SVGEnumTraits.h >index 8b137891791..9cb34649199 100644 >--- a/Source/WebCore/svg/properties/SVGEnumTraits.h >+++ b/Source/WebCore/svg/properties/SVGEnumTraits.h >@@ -1 +1,75 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "SVGParsingError.h" >+#include "SVGPropertyTraits.h" >+#include <wtf/Expected.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+template<typename> struct SVGEnumTraits; >+ >+template<typename EnumType> using SVGEnumValue = std::pair<EnumType, String>; >+ >+template<typename EnumType> using SVGEnumValues = Vector<SVGEnumValue<EnumType>>; >+ >+template<typename EnumType> >+struct SVGPropertyTraits<EnumType, std::enable_if_t<std::is_enum<EnumType>::value>> { >+ template<typename T> >+ static constexpr bool isValidEnum(T t) >+ { >+ static_assert(sizeof(T) >= std::underlying_type_t<EnumType>(), "Integral type must be at least the size of the underlying enum type"); >+ >+ if (t > static_cast<T>(SVGEnumTraits<EnumType>::highestExposedEnumValue())) >+ return false; >+ return SVGEnumTraits<EnumType>::values().findMatching([&](auto& item) { >+ return static_cast<T>(item.first) == t; >+ }) != notFound; >+ } >+ >+ static constexpr Expected<EnumType, SVGParsingError> parse(const String& string) >+ { >+ auto find = SVGEnumTraits<EnumType>::values().findMatching([&](auto& item) { >+ return item.second == string; >+ }); >+ if (find != notFound) >+ return SVGEnumTraits<EnumType>::values()[find].first; >+ return makeUnexpected(UnrecognizedEnumValueError); >+ } >+ static constexpr EnumType fromString(const String& string) { return parse(string).value_or(0); } >+ >+ static String toString(EnumType value) >+ { >+ auto find = SVGEnumTraits<EnumType>::values().findMatching([&](auto& item) { >+ return item.first == value; >+ }); >+ return find != notFound ? SVGEnumTraits<EnumType>::values()[find].second : emptyString(); >+ } >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGEnumType.h b/Source/WebCore/svg/properties/SVGEnumType.h >index 8b137891791..e6187a38774 100644 >--- a/Source/WebCore/svg/properties/SVGEnumType.h >+++ b/Source/WebCore/svg/properties/SVGEnumType.h >@@ -1 +1,80 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+namespace WebCore { >+ >+enum SVGLengthAdjustType { >+ SVGLengthAdjustUnknown, >+ SVGLengthAdjustSpacing, >+ SVGLengthAdjustSpacingAndGlyphs >+}; >+ >+enum SVGMarkerUnitsType { >+ SVGMarkerUnitsUnknown = 0, >+ SVGMarkerUnitsUserSpaceOnUse, >+ SVGMarkerUnitsStrokeWidth >+}; >+ >+enum SVGMarkerOrientType { >+ SVGMarkerOrientUnknown = 0, >+ SVGMarkerOrientAuto, >+ SVGMarkerOrientAngle, >+ SVGMarkerOrientAutoStartReverse >+}; >+ >+enum SVGSpreadMethodType { >+ SVGSpreadMethodUnknown = 0, >+ SVGSpreadMethodPad, >+ SVGSpreadMethodReflect, >+ SVGSpreadMethodRepeat >+}; >+ >+enum SVGStitchOptions { >+ SVGStitchTypeUnknown = 0, >+ SVGStitchTypeStitch, >+ SVGStitchTypeNoStitch >+}; >+ >+enum SVGTextPathMethodType { >+ SVGTextPathMethodUnknown = 0, >+ SVGTextPathMethodAlign, >+ SVGTextPathMethodStretch >+}; >+ >+enum SVGTextPathSpacingType { >+ SVGTextPathSpacingUnknown = 0, >+ SVGTextPathSpacingAuto, >+ SVGTextPathSpacingExact >+}; >+ >+enum SVGZoomAndPanType { >+ SVGZoomAndPanUnknown = 0, >+ SVGZoomAndPanDisable, >+ SVGZoomAndPanMagnify >+}; >+ >+}; >diff --git a/Source/WebCore/svg/properties/SVGEnumTypeTraits.h b/Source/WebCore/svg/properties/SVGEnumTypeTraits.h >index 8b137891791..315f9556fa0 100644 >--- a/Source/WebCore/svg/properties/SVGEnumTypeTraits.h >+++ b/Source/WebCore/svg/properties/SVGEnumTypeTraits.h >@@ -1 +1,274 @@ >+/* >+ * Copyright (C) 2019 Apple Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in the >+ * documentation and/or other materials provided with the distribution. >+ * >+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY >+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR >+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, >+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, >+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY >+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ > >+#pragma once >+ >+#include "FEColorMatrix.h" >+#include "FEComponentTransfer.h" >+#include "FEComposite.h" >+#include "FEConvolveMatrix.h" >+#include "FEDisplacementMap.h" >+#include "FEMorphology.h" >+#include "FETurbulence.h" >+#include "SVGEnumTraits.h" >+#include "SVGEnumType.h" >+#include "SVGUnitTypes.h" >+ >+namespace WebCore { >+ >+template<> struct SVGEnumTraits<BlendMode> { >+ static const SVGEnumValues<BlendMode>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<BlendMode>> values(std::initializer_list<SVGEnumValue<BlendMode>> { >+ { BlendMode::Normal, "normal"_s }, >+ { BlendMode::Multiply, "multiply"_s }, >+ { BlendMode::Screen, "screen"_s }, >+ { BlendMode::Darken, "darken"_s }, >+ { BlendMode::Lighten, "lighten"_s }, >+ { BlendMode::Overlay, "overlay"_s }, >+ { BlendMode::ColorDodge, "color-dodge"_s }, >+ { BlendMode::ColorBurn, "color-burn"_s }, >+ { BlendMode::HardLight, "hard-light"_s }, >+ { BlendMode::SoftLight, "soft-light"_s }, >+ { BlendMode::Difference, "difference"_s }, >+ { BlendMode::Exclusion, "exclusion"_s }, >+ { BlendMode::Hue, "hue"_s }, >+ { BlendMode::Saturation, "saturation"_s }, >+ { BlendMode::Color, "color"_s }, >+ { BlendMode::Luminosity, "luminosity"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return BlendMode::Luminosity; } >+}; >+ >+template<> struct SVGEnumTraits<ChannelSelectorType> { >+ static const SVGEnumValues<ChannelSelectorType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<ChannelSelectorType>> values(std::initializer_list<SVGEnumValue<ChannelSelectorType>> { >+ { CHANNEL_R, "R"_s }, >+ { CHANNEL_G, "G"_s }, >+ { CHANNEL_B, "B"_s }, >+ { CHANNEL_A, "A"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return CHANNEL_A; } >+}; >+ >+template<> struct SVGEnumTraits<ComponentTransferType> { >+ static const SVGEnumValues<ComponentTransferType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<ComponentTransferType>> values(std::initializer_list<SVGEnumValue<ComponentTransferType>> { >+ { FECOMPONENTTRANSFER_TYPE_IDENTITY, "identity"_s }, >+ { FECOMPONENTTRANSFER_TYPE_TABLE, "table"_s }, >+ { FECOMPONENTTRANSFER_TYPE_DISCRETE, "discrete"_s }, >+ { FECOMPONENTTRANSFER_TYPE_LINEAR, "linear"_s }, >+ { FECOMPONENTTRANSFER_TYPE_GAMMA, "gamma"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return FECOMPONENTTRANSFER_TYPE_GAMMA; } >+}; >+ >+template<> struct SVGEnumTraits<ColorMatrixType> { >+ static const SVGEnumValues<ColorMatrixType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<ColorMatrixType>> values(std::initializer_list<SVGEnumValue<ColorMatrixType>> { >+ { FECOLORMATRIX_TYPE_MATRIX, "matrix"_s }, >+ { FECOLORMATRIX_TYPE_SATURATE, "saturate"_s }, >+ { FECOLORMATRIX_TYPE_HUEROTATE, "hueRotate"_s }, >+ { FECOLORMATRIX_TYPE_LUMINANCETOALPHA, "luminanceToAlpha"_s }, >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return FECOLORMATRIX_TYPE_LUMINANCETOALPHA; } >+}; >+ >+template<> struct SVGEnumTraits<CompositeOperationType> { >+ static const SVGEnumValues<CompositeOperationType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<CompositeOperationType>> values(std::initializer_list<SVGEnumValue<CompositeOperationType>> { >+ { FECOMPOSITE_OPERATOR_OVER, "over"_s }, >+ { FECOMPOSITE_OPERATOR_IN, "in"_s }, >+ { FECOMPOSITE_OPERATOR_OUT, "out"_s }, >+ { FECOMPOSITE_OPERATOR_ATOP, "atop"_s }, >+ { FECOMPOSITE_OPERATOR_XOR, "xor"_s }, >+ { FECOMPOSITE_OPERATOR_ARITHMETIC, "arithmetic"_s }, >+ { FECOMPOSITE_OPERATOR_LIGHTER, "lighter"_s }, >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return FECOMPOSITE_OPERATOR_ARITHMETIC; } >+}; >+ >+template<> struct SVGEnumTraits<EdgeModeType> { >+ static const SVGEnumValues<EdgeModeType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<EdgeModeType>> values(std::initializer_list<SVGEnumValue<EdgeModeType>> { >+ { EDGEMODE_DUPLICATE, "duplicate"_s }, >+ { EDGEMODE_WRAP, "wrap"_s }, >+ { EDGEMODE_NONE, "none"_s }, >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return EDGEMODE_NONE; } >+}; >+ >+template<> struct SVGEnumTraits<MorphologyOperatorType> { >+ static const SVGEnumValues<MorphologyOperatorType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<MorphologyOperatorType>> values(std::initializer_list<SVGEnumValue<MorphologyOperatorType>> { >+ { FEMORPHOLOGY_OPERATOR_ERODE, "erode"_s }, >+ { FEMORPHOLOGY_OPERATOR_DILATE, "dilate"_s }, >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return FEMORPHOLOGY_OPERATOR_DILATE; } >+}; >+ >+template<> struct SVGEnumTraits<TurbulenceType> { >+ static const SVGEnumValues<TurbulenceType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<TurbulenceType>> values(std::initializer_list<SVGEnumValue<TurbulenceType>> { >+ { TurbulenceType::FractalNoise, "fractalNoise"_s }, >+ { TurbulenceType::Turbulence, "turbulence"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return TurbulenceType::Turbulence; } >+}; >+ >+template<> struct SVGEnumTraits<SVGLengthAdjustType> { >+ static const SVGEnumValues<SVGLengthAdjustType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<SVGLengthAdjustType>> values(std::initializer_list<SVGEnumValue<SVGLengthAdjustType>> { >+ { SVGLengthAdjustSpacing, "spacing"_s }, >+ { SVGLengthAdjustSpacingAndGlyphs, "spacingAndGlyphs"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return SVGLengthAdjustSpacingAndGlyphs; } >+}; >+ >+template<> struct SVGEnumTraits<SVGMarkerUnitsType> { >+ static const SVGEnumValues<SVGMarkerUnitsType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<SVGMarkerUnitsType>> values(std::initializer_list<SVGEnumValue<SVGMarkerUnitsType>> { >+ { SVGMarkerUnitsUserSpaceOnUse, "userSpaceOnUse"_s }, >+ { SVGMarkerUnitsStrokeWidth, "strokeWidth"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return SVGMarkerUnitsStrokeWidth; } >+}; >+ >+template<> struct SVGEnumTraits<SVGMarkerOrientType> { >+ static const SVGEnumValues<SVGMarkerOrientType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<SVGMarkerOrientType>> values(std::initializer_list<SVGEnumValue<SVGMarkerOrientType>> { >+ { SVGMarkerOrientAuto, "auto"_s }, >+ { SVGMarkerOrientAngle, emptyString() }, >+ { SVGMarkerOrientAutoStartReverse, "auto-start-reverse"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return SVGMarkerOrientAngle; } >+}; >+ >+template<> struct SVGEnumTraits<SVGSpreadMethodType> { >+ static const SVGEnumValues<SVGSpreadMethodType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<SVGSpreadMethodType>> values(std::initializer_list<SVGEnumValue<SVGSpreadMethodType>> { >+ { SVGSpreadMethodPad, "pad"_s }, >+ { SVGSpreadMethodReflect, "reflect"_s }, >+ { SVGSpreadMethodRepeat, "repeat"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return SVGSpreadMethodRepeat; } >+}; >+ >+template<> struct SVGEnumTraits<SVGStitchOptions> { >+ static const SVGEnumValues<SVGStitchOptions>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<SVGStitchOptions>> values(std::initializer_list<SVGEnumValue<SVGStitchOptions>> { >+ { SVGStitchTypeStitch, "stitch"_s }, >+ { SVGStitchTypeNoStitch, "noStitch"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return SVGStitchTypeNoStitch; } >+}; >+ >+template<> struct SVGEnumTraits<SVGTextPathMethodType> { >+ static const SVGEnumValues<SVGTextPathMethodType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<SVGTextPathMethodType>> values(std::initializer_list<SVGEnumValue<SVGTextPathMethodType>> { >+ { SVGTextPathMethodAlign, "align"_s }, >+ { SVGTextPathMethodStretch, "stretch"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return SVGTextPathMethodStretch; } >+}; >+ >+template<> struct SVGEnumTraits<SVGTextPathSpacingType> { >+ static const SVGEnumValues<SVGTextPathSpacingType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<SVGTextPathSpacingType>> values(std::initializer_list<SVGEnumValue<SVGTextPathSpacingType>> { >+ { SVGTextPathSpacingAuto, "auto"_s }, >+ { SVGTextPathSpacingExact, "exact"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return SVGTextPathSpacingExact; } >+}; >+ >+template<> struct SVGEnumTraits<SVGUnitTypes::SVGUnitType> { >+ static const SVGEnumValues<SVGUnitTypes::SVGUnitType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<SVGUnitTypes::SVGUnitType>> values(std::initializer_list<SVGEnumValue<SVGUnitTypes::SVGUnitType>> { >+ { SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE, "userSpaceOnUse"_s }, >+ { SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, "objectBoundingBox"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX; } >+}; >+ >+template<> struct SVGEnumTraits<SVGZoomAndPanType> { >+ static const SVGEnumValues<SVGZoomAndPanType>& values() >+ { >+ static NeverDestroyed<SVGEnumValues<SVGZoomAndPanType>> values(std::initializer_list<SVGEnumValue<SVGZoomAndPanType>> { >+ { SVGZoomAndPanDisable, "disable"_s }, >+ { SVGZoomAndPanMagnify, "magnify"_s } >+ }); >+ return values; >+ } >+ static constexpr auto highestExposedEnumValue() { return SVGZoomAndPanMagnify; } >+}; >+ >+}; >diff --git a/Source/WebCore/svg/properties/SVGPropertyTraits.h b/Source/WebCore/svg/properties/SVGPropertyTraits.h >index bb83e77d364..9eadd9e3129 100644 >--- a/Source/WebCore/svg/properties/SVGPropertyTraits.h >+++ b/Source/WebCore/svg/properties/SVGPropertyTraits.h >@@ -1,7 +1,7 @@ > /* > * Copyright (C) 2004, 2005, 2006, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) Research In Motion Limited 2010. All rights reserved. >- * Copyright (C) 2018 Apple Inc. All rights reserved. >+ * Copyright (C) 2018-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 >@@ -25,124 +25,97 @@ > #include "Color.h" > #include "FloatPoint.h" > #include "FloatRect.h" >-#include "QualifiedName.h" > #include "SVGParserUtilities.h" >+#include "SVGParsingError.h" >+#include <wtf/Expected.h> > #include <wtf/text/StringBuilder.h> > #include <wtf/text/WTFString.h> > > namespace WebCore { > >-template<typename PropertyType> >+template<typename PropertyType, class Enabler = void> > struct SVGPropertyTraits { }; > > template<> > struct SVGPropertyTraits<bool> { > static bool initialValue() { return false; } >- static bool fromString(const String& string) { return string == "true"; } >- static Optional<bool> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); } >- static String toString(bool type) { return type ? "true" : "false"; } >+ static Expected<bool, SVGParsingError> parse(const String& string) >+ { >+ if (string == "true") >+ return true; >+ if (string == "false") >+ return false; >+ return makeUnexpected(ParsingAttributeFailedError); >+ } >+ static bool fromString(const String& string) { return parse(string).value_or(initialValue()); } >+ static String toString(bool value) { return value ? "true" : "false"; } > }; > > template<> > struct SVGPropertyTraits<Color> { > static Color initialValue() { return Color(); } >- static Color fromString(const String& string) { return CSSParser::parseColor(string.stripWhiteSpace()); } >- static Optional<Color> parse(const QualifiedName&, const String& string) >+ static Expected<Color, SVGParsingError> parse(const String& string) > { >- Color color = CSSParser::parseColor(string.stripWhiteSpace()); >- if (!color.isValid()) >- return WTF::nullopt; >- return color; >+ Color value = CSSParser::parseColor(string.stripWhiteSpace()); >+ if (!value.isValid()) >+ return makeUnexpected(ParsingAttributeFailedError); >+ return value; > } >- static String toString(const Color& type) { return type.serialized(); } >-}; >- >-template<> >-struct SVGPropertyTraits<unsigned> { >- static unsigned initialValue() { return 0; } >- static Optional<unsigned> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); } >- static String toString(unsigned type) { return String::number(type); } >-}; >- >-template<> >-struct SVGPropertyTraits<int> { >- static int initialValue() { return 0; } >- static int fromString(const String&string) { return string.toIntStrict(); } >- static Optional<int> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); } >- static String toString(int type) { return String::number(type); } >+ static Color fromString(const String& string) { return parse(string).value_or(initialValue()); } >+ static String toString(const Color& value) { return value.serialized(); } > }; > > template<> >-struct SVGPropertyTraits<std::pair<int, int>> { >- static std::pair<int, int> initialValue() { return { }; } >- static std::pair<int, int> fromString(const String& string) >- { >- float firstNumber = 0, secondNumber = 0; >- if (!parseNumberOptionalNumber(string, firstNumber, secondNumber)) >- return { }; >- return std::make_pair(static_cast<int>(roundf(firstNumber)), static_cast<int>(roundf(secondNumber))); >- } >- static Optional<std::pair<int, int>> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); } >- static String toString(std::pair<int, int>) { ASSERT_NOT_REACHED(); return emptyString(); } >+struct SVGPropertyTraits<String> { >+ static String initialValue() { return String(); } >+ static Expected<String, SVGParsingError> parse(const String& string) { return string; } >+ static String fromString(const String& string) { return string; } >+ static String toString(const String& value) { return value; } > }; > > template<> > struct SVGPropertyTraits<float> { > static float initialValue() { return 0; } >- static float fromString(const String& string) >+ static Expected<float, SVGParsingError> parse(const String& string, SVGParsingOptions parsingOptions = NoOptions) > { >- float number = 0; >- if (!parseNumberFromString(string, number)) >- return 0; >- return number; >+ float value; >+ if ((parsingOptions & AllowPercentage) && string.endsWith('%')) >+ value = string.left(string.length() - 1).toFloat() / 100; >+ else >+ value = string.toFloat(); >+ if (auto error = validateNumeric(value, parsingOptions)) >+ return makeUnexpected(error); >+ return value; > } >- static Optional<float> parse(const QualifiedName&, const String& string) >- { >- float number; >- if (!parseNumberFromString(string, number)) >- return WTF::nullopt; >- return number; >- } >- static String toString(float type) { return String::numberToStringFixedPrecision(type); } >+ static float fromString(const String& string) { return parse(string).value_or(initialValue()); } >+ static String toString(float value) { return String::numberToStringFixedPrecision(value); } > }; > > template<> >-struct SVGPropertyTraits<std::pair<float, float>> { >- static std::pair<float, float> initialValue() { return { }; } >- static std::pair<float, float> fromString(const String& string) >- { >- float firstNumber = 0, secondNumber = 0; >- if (!parseNumberOptionalNumber(string, firstNumber, secondNumber)) >- return { }; >- return std::make_pair(firstNumber, secondNumber); >- } >- static Optional<std::pair<float, float>> parse(const QualifiedName&, const String&) { ASSERT_NOT_REACHED(); return initialValue(); } >- static String toString(std::pair<float, float>) { ASSERT_NOT_REACHED(); return emptyString(); } >+struct SVGPropertyTraits<int> { >+ static int initialValue() { return 0; } >+ static Expected<int, SVGParsingError> parse(const String& string) { return string.toIntStrict(); } >+ static int fromString(const String& string) { return parse(string).value_or(initialValue()); } >+ static String toString(int value) { return String::number(value); } > }; > > template<> > struct SVGPropertyTraits<FloatPoint> { > static FloatPoint initialValue() { return FloatPoint(); } >- static FloatPoint fromString(const String& string) >- { >- FloatPoint point; >- if (!parsePoint(string, point)) >- return { }; >- return point; >- } >- static Optional<FloatPoint> parse(const QualifiedName&, const String& string) >+ static Expected<FloatPoint, SVGParsingError> parse(const String& string) > { >- FloatPoint point; >- if (!parsePoint(string, point)) >- return WTF::nullopt; >- return point; >+ FloatPoint value; >+ if (!parsePoint(string, value)) >+ return makeUnexpected(ParsingAttributeFailedError); >+ return value; > } >- static String toString(const FloatPoint& type) >+ static FloatPoint fromString(const String& string) { return parse(string).value_or(initialValue()); } >+ static String toString(const FloatPoint& value) > { > StringBuilder builder; >- builder.appendFixedPrecisionNumber(type.x()); >+ builder.appendFixedPrecisionNumber(value.x()); > builder.append(' '); >- builder.appendFixedPrecisionNumber(type.y()); >+ builder.appendFixedPrecisionNumber(value.y()); > return builder.toString(); > } > }; >@@ -150,46 +123,73 @@ struct SVGPropertyTraits<FloatPoint> { > template<> > struct SVGPropertyTraits<FloatRect> { > static FloatRect initialValue() { return FloatRect(); } >- static FloatRect fromString(const String& string) >- { >- FloatRect rect; >- if (!parseRect(string, rect)) >- return { }; >- return rect; >- } >- static Optional<FloatRect> parse(const QualifiedName&, const String& string) >+ static Expected<FloatRect, SVGParsingError> parse(const String& string, SVGParsingOptions parsingOptions = NoOptions) > { >- FloatRect rect; >- if (!parseRect(string, rect)) >- return WTF::nullopt; >- return rect; >+ FloatRect value; >+ if (!parseRect(string, value)) >+ return makeUnexpected(ParsingAttributeFailedError); >+ if (auto error = validateNumeric(value.width(), parsingOptions)) >+ return makeUnexpected(error); >+ if (auto error = validateNumeric(value.height(), parsingOptions)) >+ return makeUnexpected(error); >+ return value; > } >- static String toString(const FloatRect& type) >+ static FloatRect fromString(const String& string) { return parse(string).value_or(initialValue()); } >+ static String toString(const FloatRect& value) > { > StringBuilder builder; >- builder.appendFixedPrecisionNumber(type.x()); >+ builder.appendFixedPrecisionNumber(value.x()); > builder.append(' '); >- builder.appendFixedPrecisionNumber(type.y()); >+ builder.appendFixedPrecisionNumber(value.y()); > builder.append(' '); >- builder.appendFixedPrecisionNumber(type.width()); >+ builder.appendFixedPrecisionNumber(value.width()); > builder.append(' '); >- builder.appendFixedPrecisionNumber(type.height()); >+ builder.appendFixedPrecisionNumber(value.height()); > return builder.toString(); > } > }; > > template<> >-struct SVGPropertyTraits<String> { >- static String initialValue() { return String(); } >- static String fromString(const String& string) { return string; } >- static Optional<String> parse(const QualifiedName&, const String& string) { return string; } >- static String toString(const String& string) { return string; } >+struct SVGPropertyTraits<std::pair<int, int>> { >+ static std::pair<int, int> initialValue() { return { }; } >+ static Expected<std::pair<int, int>, SVGParsingError> parse(const String& string, SVGParsingOptions parsingOptions = NoOptions) >+ { >+ float valueNumber1 = 0, valueNumber2 = 0; >+ if (!parseNumberOptionalNumber(string, valueNumber1, valueNumber2)) >+ return makeUnexpected(ParsingAttributeFailedError); >+ >+ int valueInteger1 = static_cast<int>(roundf(valueNumber1)); >+ int valueInteger2 = static_cast<int>(roundf(valueNumber2)); >+ >+ if (auto error = validateNumeric(valueInteger1, parsingOptions)) >+ return makeUnexpected(error); >+ if (auto error = validateNumeric(valueInteger2, parsingOptions)) >+ return makeUnexpected(error); >+ >+ return std::make_pair(valueInteger1, valueInteger2); >+ } >+ static std::pair<int, int> fromString(const String& string) { return parse(string).value_or(initialValue()); } >+ static String toString(const std::pair<int, int>& value) { return SVGPropertyTraits<int>::toString(value.first) + ", " + SVGPropertyTraits<int>::toString(value.second); } > }; > >-template<typename EnumType> >-struct SVGIDLEnumLimits { >- // Specialize this function for a particular enumeration to limit the values that are exposed through the DOM. >- static unsigned highestExposedEnumValue() { return SVGPropertyTraits<EnumType>::highestEnumValue(); } >+template<> >+struct SVGPropertyTraits<std::pair<float, float>> { >+ static std::pair<float, float> initialValue() { return { }; } >+ static Expected<std::pair<float, float>, SVGParsingError> parse(const String& string, SVGParsingOptions parsingOptions = NoOptions) >+ { >+ float valueNumber1 = 0, valueNumber2 = 0; >+ if (!parseNumberOptionalNumber(string, valueNumber1, valueNumber2)) >+ return makeUnexpected(ParsingAttributeFailedError); >+ >+ if (auto error = validateNumeric(valueNumber1, parsingOptions)) >+ return makeUnexpected(error); >+ if (auto error = validateNumeric(valueNumber2, parsingOptions)) >+ return makeUnexpected(error); >+ >+ return std::make_pair(valueNumber1, valueNumber2); >+ } >+ static std::pair<float, float> fromString(const String& string) { return parse(string).value_or(initialValue()); } >+ static String toString(const std::pair<float, float>& value) { return SVGPropertyTraits<float>::toString(value.first) + ", " + SVGPropertyTraits<float>::toString(value.second); } > }; > > } // namespace WebCore
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
sabouhallawa
:
review?
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 198073
:
370324
|
370367
| 370368 |
370395