WebKit Bugzilla
Attachment 356351 Details for
Bug 191237
: Remove SVG properties tear-off objects
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
1-SVGProperty
SVGProperty.patch (text/plain), 92.83 KB, created by
Said Abou-Hallawa
on 2018-12-02 17:19:24 PST
(
hide
)
Description:
1-SVGProperty
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-12-02 17:19:24 PST
Size:
92.83 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index dcf602f7fb2..b59afcd7e80 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,211 @@ >+2018-12-02 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ Remove SVG properties tear-off objects >+ https://bugs.webkit.org/show_bug.cgi?id=191237 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ The first step to remove the SVG tear off objects is to make the SVG >+ element own the SVG data types directly without the need to encapsulate >+ the raw data in a tear-off object. >+ >+ For example, the m_baseVal of the SVGAnimatedLength will be of type >+ Ref<SVGLength>. And the m_x of the SVGRectElement will be of type >+ Ref<SVGAnimatedLength>. If the DOM request is "rect.x.baseVal", this >+ will return rectElement->m_x->m_baseVal. >+ >+ In this patch the class SVGProperty is made the base of the SVG types. >+ This changes the base of SVGNumber, SVGPoint, SVGRect, SVGMatrix, >+ SVGTransfrom and SVGLength. >+ >+ Because SVG properties are reflection of the SVG element attributes, a >+ change in an SVG property needs to be committed in the element. This step >+ is managed by SVGPropertyOwner but it is finished in this patch. The plan >+ is to propagate the commitChange request through the owner chain till it >+ reaches the SVGElement. >+ >+ SVGTransfromValue will have a member m_matrix of type Ref<SVGMatrix>. >+ When DOM requests access to the matrix, we will return m_matrix. In the >+ tear-off objects world, we were creating an SVGMatrixTearOff to encapsulate >+ SVGMatrixValue. >+ >+ * WebCore.xcodeproj/project.pbxproj: >+ * svg/SVGAngle.h: >+ (WebCore::SVGAngle::create): >+ (WebCore::SVGAngle::unitType): >+ (WebCore::SVGAngle::setValueForBindings): >+ (WebCore::SVGAngle::valueForBindings): >+ (WebCore::SVGAngle::setValueInSpecifiedUnits): >+ (WebCore::SVGAngle::valueInSpecifiedUnits): >+ (WebCore::SVGAngle::setValueAsString): >+ (WebCore::SVGAngle::newValueSpecifiedUnits): >+ (WebCore::SVGAngle::convertToSpecifiedUnits): >+ (WebCore::SVGAngle::valueAsString): Deleted. >+ (WebCore::SVGAngle::SVGAngle): Deleted. >+ * svg/SVGAngleValue.h: >+ (WebCore::SVGPropertyTraits<SVGAngleValue>::initialValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGAngleValue>::toString): Deleted. >+ * svg/SVGLength.h: >+ (WebCore::SVGLength::create): >+ (WebCore::SVGLength::clone const): >+ (WebCore::SVGLength::unitType): >+ (WebCore::SVGLength::valueForBindings): >+ (WebCore::SVGLength::setValueForBindings): >+ (WebCore::SVGLength::valueInSpecifiedUnits): >+ (WebCore::SVGLength::setValueInSpecifiedUnits): >+ (WebCore::SVGLength::setValueAsString): >+ (WebCore::SVGLength::newValueSpecifiedUnits): >+ (WebCore::SVGLength::convertToSpecifiedUnits): >+ (WebCore::SVGLength::valueAsString): Deleted. >+ (WebCore::SVGLength::SVGLength): Deleted. >+ * svg/SVGMatrix.h: >+ (WebCore::SVGMatrix::create): >+ (WebCore::SVGMatrix::a): >+ (WebCore::SVGMatrix::setA): >+ (WebCore::SVGMatrix::b): >+ (WebCore::SVGMatrix::setB): >+ (WebCore::SVGMatrix::c): >+ (WebCore::SVGMatrix::setC): >+ (WebCore::SVGMatrix::d): >+ (WebCore::SVGMatrix::setD): >+ (WebCore::SVGMatrix::e): >+ (WebCore::SVGMatrix::setE): >+ (WebCore::SVGMatrix::f): >+ (WebCore::SVGMatrix::setF): >+ (WebCore::SVGMatrix::multiply const): >+ (WebCore::SVGMatrix::inverse const): >+ (WebCore::SVGMatrix::translate const): >+ (WebCore::SVGMatrix::scale const): >+ (WebCore::SVGMatrix::scaleNonUniform const): >+ (WebCore::SVGMatrix::rotate const): >+ (WebCore::SVGMatrix::rotateFromVector const): >+ (WebCore::SVGMatrix::flipX const): >+ (WebCore::SVGMatrix::flipY const): >+ (WebCore::SVGMatrix::skewX const): >+ (WebCore::SVGMatrix::skewY const): >+ (WebCore::SVGMatrix::multiply): Deleted. >+ (WebCore::SVGMatrix::inverse): Deleted. >+ (WebCore::SVGMatrix::translate): Deleted. >+ (WebCore::SVGMatrix::scale): Deleted. >+ (WebCore::SVGMatrix::scaleNonUniform): Deleted. >+ (WebCore::SVGMatrix::rotate): Deleted. >+ (WebCore::SVGMatrix::rotateFromVector): Deleted. >+ (WebCore::SVGMatrix::flipX): Deleted. >+ (WebCore::SVGMatrix::flipY): Deleted. >+ (WebCore::SVGMatrix::skewX): Deleted. >+ (WebCore::SVGMatrix::skewY): Deleted. >+ (WebCore::SVGMatrix::SVGMatrix): Deleted. >+ * svg/SVGMatrix.idl: >+ * svg/SVGMatrixValue.h: Removed. >+ * svg/SVGNumber.h: >+ (WebCore::SVGNumber::create): >+ (WebCore::SVGNumber::clone const): >+ (WebCore::SVGNumber::valueForBindings): >+ (WebCore::SVGNumber::setValueForBindings): >+ (WebCore::SVGNumber::SVGNumber): Deleted. >+ * svg/SVGPoint.h: >+ (WebCore::SVGPoint::create): >+ (WebCore::SVGPoint::clone const): >+ (WebCore::SVGPoint::x): >+ (WebCore::SVGPoint::setX): >+ (WebCore::SVGPoint::y): >+ (WebCore::SVGPoint::setY): >+ (WebCore::SVGPoint::matrixTransform const): >+ (WebCore::SVGPoint::matrixTransform): Deleted. >+ (WebCore::SVGPoint::SVGPoint): Deleted. >+ * svg/SVGPoint.idl: >+ * svg/SVGPreserveAspectRatio.h: >+ (WebCore::SVGPreserveAspectRatio::create): >+ (WebCore::SVGPreserveAspectRatio::align): >+ (WebCore::SVGPreserveAspectRatio::setAlign): >+ (WebCore::SVGPreserveAspectRatio::meetOrSlice): >+ (WebCore::SVGPreserveAspectRatio::setMeetOrSlice): >+ (WebCore::SVGPreserveAspectRatio::SVGPreserveAspectRatio): Deleted. >+ * svg/SVGPreserveAspectRatioValue.h: >+ (WebCore::SVGPropertyTraits<SVGPreserveAspectRatioValue>::initialValue): Deleted. >+ (WebCore::SVGPropertyTraits<SVGPreserveAspectRatioValue>::fromString): Deleted. >+ (WebCore::SVGPropertyTraits<SVGPreserveAspectRatioValue>::parse): Deleted. >+ (WebCore::SVGPropertyTraits<SVGPreserveAspectRatioValue>::toString): Deleted. >+ * svg/SVGRect.h: >+ (WebCore::SVGRect::create): >+ (WebCore::SVGRect::x): >+ (WebCore::SVGRect::setX): >+ (WebCore::SVGRect::y): >+ (WebCore::SVGRect::setY): >+ (WebCore::SVGRect::width): >+ (WebCore::SVGRect::setWidth): >+ (WebCore::SVGRect::height): >+ (WebCore::SVGRect::setHeight): >+ (WebCore::SVGRect::SVGRect): Deleted. >+ * svg/SVGTransform.cpp: Removed. >+ * svg/SVGTransform.h: >+ (WebCore::SVGTransform::create): >+ (WebCore::SVGTransform::~SVGTransform): >+ (WebCore::SVGTransform::clone const): >+ (WebCore::SVGTransform::type): >+ (WebCore::SVGTransform::angle): >+ (WebCore::SVGTransform::matrix): >+ (WebCore::SVGTransform::setMatrix): >+ (WebCore::SVGTransform::setTranslate): >+ (WebCore::SVGTransform::setScale): >+ (WebCore::SVGTransform::setRotate): >+ (WebCore::SVGTransform::setSkewX): >+ (WebCore::SVGTransform::setSkewY): >+ (WebCore::SVGTransform::SVGTransform): >+ * svg/SVGTransform.idl: >+ * svg/SVGTransformValue.cpp: Removed. >+ * svg/SVGTransformValue.h: >+ (WebCore::SVGTransformValue::SVGTransformValue): >+ (WebCore::SVGTransformValue::operator=): >+ (WebCore::SVGTransformValue::type const): >+ (WebCore::SVGTransformValue::matrix const): >+ (WebCore::SVGTransformValue::rotationCenter const): >+ (WebCore::SVGTransformValue::isValid const): >+ (WebCore::SVGTransformValue::setMatrix): >+ (WebCore::SVGTransformValue::matrixDidChange): >+ (WebCore::SVGTransformValue::translate const): >+ (WebCore::SVGTransformValue::setTranslate): >+ (WebCore::SVGTransformValue::scale const): >+ (WebCore::SVGTransformValue::setScale): >+ (WebCore::SVGTransformValue::setRotate): >+ (WebCore::SVGTransformValue::setSkewX): >+ (WebCore::SVGTransformValue::setSkewY): >+ (WebCore::SVGTransformValue::valueAsString const): >+ (WebCore::SVGTransformValue::prefixForTransfromType): >+ (WebCore::SVGTransformValue::appendNumbers const): >+ (WebCore::SVGTransformValue::appendMatrix const): >+ (WebCore::SVGTransformValue::appendTranslate const): >+ (WebCore::SVGTransformValue::appendScale const): >+ (WebCore::SVGTransformValue::appendRotate const): >+ (WebCore::SVGTransformValue::appendSkewX const): >+ (WebCore::SVGTransformValue::appendSkewY const): >+ (WebCore::SVGTransformValue::svgMatrix): Deleted. >+ (WebCore::operator==): Deleted. >+ (WebCore::operator!=): Deleted. >+ * svg/properties/SVGProperty.h: >+ (WebCore::SVGProperty::isAttached const): >+ (WebCore::SVGProperty::attach): >+ (WebCore::SVGProperty::detach): >+ (WebCore::SVGProperty::contextElement const): >+ (WebCore::SVGProperty::commitChange): >+ (WebCore::SVGProperty::access const): >+ (WebCore::SVGProperty::isReadOnly const): >+ (WebCore::SVGProperty::isDirty const): >+ (WebCore::SVGProperty::setDirty): >+ (WebCore::SVGProperty::synchronize): >+ (WebCore::SVGProperty::valueAsString const): >+ (WebCore::SVGProperty::SVGProperty): >+ * svg/properties/SVGPropertyOwner.h: Added. >+ (WebCore::SVGPropertyOwner::owner const): >+ (WebCore::SVGPropertyOwner::attributeContextElement const): >+ (WebCore::SVGPropertyOwner::commitPropertyChange): >+ * svg/properties/SVGValueProperty.h: Added. >+ (WebCore::SVGValueProperty::create): >+ (WebCore::SVGValueProperty::value const): >+ (WebCore::SVGValueProperty::setValue): >+ (WebCore::SVGValueProperty::value): >+ (WebCore::SVGValueProperty::SVGValueProperty): >+ > 2018-12-01 Brent Fulgham <bfulgham@apple.com> > > Lifetime of HTMLMediaElement is not properly handled in asynchronous actions >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 9f4c7477cb7..6cdfa8efb4b 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -2330,8 +2330,6 @@ > 7CE1917B1F2ABE7100272F78 /* JSFetchRequestRedirect.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE1916A1F2AB70600272F78 /* JSFetchRequestRedirect.h */; }; > 7CE58D4A1DD64A5B00128552 /* SVGPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D491DD64A5B00128552 /* SVGPoint.h */; }; > 7CE58D501DD69A1E00128552 /* SVGNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D4F1DD69A1E00128552 /* SVGNumber.h */; }; >- 7CE58D581DD7D96D00128552 /* SVGTransformValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D561DD7D96D00128552 /* SVGTransformValue.h */; }; >- 7CE58D5C1DD7EC9C00128552 /* SVGMatrixValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D5B1DD7EC9C00128552 /* SVGMatrixValue.h */; }; > 7CE68344192143A800F4D928 /* UserMessageHandlerDescriptor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CE68342192143A800F4D928 /* UserMessageHandlerDescriptor.cpp */; }; > 7CE68345192143A800F4D928 /* UserMessageHandlerDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE68343192143A800F4D928 /* UserMessageHandlerDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 7CE683471921821500F4D928 /* UserMessageHandlerDescriptorTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE683461921821500F4D928 /* UserMessageHandlerDescriptorTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; >@@ -9345,6 +9343,9 @@ > 71EFCEDE202B39C700D7C411 /* JSAnimationEffectCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSAnimationEffectCustom.cpp; sourceTree = "<group>"; }; > 71F936F71DD4F99B00922CC7 /* tracks-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "tracks-support.js"; sourceTree = "<group>"; }; > 71FB967A1383D64600AC8A4C /* SVGAnimatedEnumerationPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedEnumerationPropertyTearOff.h; sourceTree = "<group>"; }; >+ 72227A6C21B4B1F6008EC3E4 /* SVGPropertyOwner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPropertyOwner.h; sourceTree = "<group>"; }; >+ 72227A6D21B4B1F7008EC3E4 /* SVGValueProperty.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGValueProperty.h; sourceTree = "<group>"; }; >+ 72227A6E21B4B302008EC3E4 /* SVGTransformValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTransformValue.h; sourceTree = "<group>"; }; > 724ED3291A3A7E5400F5F13C /* EXTBlendMinMax.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EXTBlendMinMax.cpp; sourceTree = "<group>"; }; > 724ED32A1A3A7E5400F5F13C /* EXTBlendMinMax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EXTBlendMinMax.h; sourceTree = "<group>"; }; > 724ED32B1A3A7E5400F5F13C /* EXTBlendMinMax.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EXTBlendMinMax.idl; sourceTree = "<group>"; }; >@@ -9822,10 +9823,6 @@ > 7CE58D511DD7B09300128552 /* SVGLength.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGLength.h; sourceTree = "<group>"; }; > 7CE58D521DD7B09300128552 /* SVGLengthValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGLengthValue.cpp; sourceTree = "<group>"; }; > 7CE58D531DD7B09300128552 /* SVGLengthValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGLengthValue.h; sourceTree = "<group>"; }; >- 7CE58D551DD7D96D00128552 /* SVGTransformValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTransformValue.cpp; sourceTree = "<group>"; }; >- 7CE58D561DD7D96D00128552 /* SVGTransformValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGTransformValue.h; sourceTree = "<group>"; }; >- 7CE58D591DD7DE5200128552 /* SVGTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGTransform.cpp; sourceTree = "<group>"; }; >- 7CE58D5B1DD7EC9C00128552 /* SVGMatrixValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGMatrixValue.h; sourceTree = "<group>"; }; > 7CE68342192143A800F4D928 /* UserMessageHandlerDescriptor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMessageHandlerDescriptor.cpp; sourceTree = "<group>"; }; > 7CE68343192143A800F4D928 /* UserMessageHandlerDescriptor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageHandlerDescriptor.h; sourceTree = "<group>"; }; > 7CE683461921821500F4D928 /* UserMessageHandlerDescriptorTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageHandlerDescriptorTypes.h; sourceTree = "<group>"; }; >@@ -15833,10 +15830,12 @@ > 088A0E00126EF1DB00978F7A /* SVGListPropertyTearOff.h */, > 08CA3D4312894A3800FFF260 /* SVGMatrixTearOff.h */, > 088A0E01126EF1DB00978F7A /* SVGProperty.h */, >+ 72227A6C21B4B1F6008EC3E4 /* SVGPropertyOwner.h */, > 088A0E02126EF1DB00978F7A /* SVGPropertyTearOff.h */, > 088A0E03126EF1DB00978F7A /* SVGPropertyTraits.h */, > 0880F70D1282B46D00948505 /* SVGStaticListPropertyTearOff.h */, > 0813A4E91284132600992511 /* SVGStaticPropertyTearOff.h */, >+ 72227A6D21B4B1F7008EC3E4 /* SVGValueProperty.h */, > ); > path = properties; > sourceTree = "<group>"; >@@ -23727,7 +23726,6 @@ > B22278B20D00BF200071B782 /* SVGMaskElement.idl */, > 0806E57912893045007CED32 /* SVGMatrix.h */, > B22278B30D00BF200071B782 /* SVGMatrix.idl */, >- 7CE58D5B1DD7EC9C00128552 /* SVGMatrixValue.h */, > B22278B40D00BF200071B782 /* SVGMetadataElement.cpp */, > B22278B50D00BF200071B782 /* SVGMetadataElement.h */, > B22278B60D00BF200071B782 /* SVGMetadataElement.idl */, >@@ -23903,7 +23901,6 @@ > B222793F0D00BF210071B782 /* SVGTitleElement.idl */, > 1CCDF5BB1990332400BCEBAD /* SVGToOTFFontConversion.cpp */, > 1CCDF5BC1990332400BCEBAD /* SVGToOTFFontConversion.h */, >- 7CE58D591DD7DE5200128552 /* SVGTransform.cpp */, > B22279410D00BF210071B782 /* SVGTransform.h */, > B22279420D00BF210071B782 /* SVGTransform.idl */, > B22279430D00BF210071B782 /* SVGTransformable.cpp */, >@@ -23914,8 +23911,7 @@ > B222794A0D00BF210071B782 /* SVGTransformList.idl */, > 7C39C36C1DDB8BB000FEFB29 /* SVGTransformListValues.cpp */, > 7C39C36D1DDB8BB000FEFB29 /* SVGTransformListValues.h */, >- 7CE58D551DD7D96D00128552 /* SVGTransformValue.cpp */, >- 7CE58D561DD7D96D00128552 /* SVGTransformValue.h */, >+ 72227A6E21B4B302008EC3E4 /* SVGTransformValue.h */, > B222794B0D00BF210071B782 /* SVGTRefElement.cpp */, > B222794C0D00BF210071B782 /* SVGTRefElement.h */, > B222794D0D00BF210071B782 /* SVGTRefElement.idl */, >@@ -27988,8 +27984,8 @@ > CD318623199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.h in Headers */, > CDE595971BF26E2100A1CBE8 /* CDMSessionMediaSourceAVFObjC.h in Headers */, > 5FA904CA178E61F5004C8A2D /* CertificateInfo.h in Headers */, >- 91B8F0B521953D65000C2B00 /* CertificateInfoBase.h in Headers */, >- FE36FD1516C7826500F887C1 /* ChangeVersionData.h in Headers */, >+ 91B8F0B521953D65000C2B00 /* CertificateInfoBase.h in Headers */, >+ FE36FD1516C7826500F887C1 /* ChangeVersionData.h in Headers */, > 97BC69DD1505F076001B74AC /* ChangeVersionWrapper.h in Headers */, > FD315FFF12B0267600C1A359 /* ChannelMergerNode.h in Headers */, > FD31600212B0267600C1A359 /* ChannelSplitterNode.h in Headers */, >@@ -31227,7 +31223,6 @@ > B2227A470D00BF220071B782 /* SVGMaskElement.h in Headers */, > 0806E57A12893045007CED32 /* SVGMatrix.h in Headers */, > 08CA3D4412894A3800FFF260 /* SVGMatrixTearOff.h in Headers */, >- 7CE58D5C1DD7EC9C00128552 /* SVGMatrixValue.h in Headers */, > B2227A4B0D00BF220071B782 /* SVGMetadataElement.h in Headers */, > B2A1F2B10CEF0ABF00442F6A /* SVGMissingGlyphElement.h in Headers */, > B2227A4E0D00BF220071B782 /* SVGMPathElement.h in Headers */, >@@ -31336,7 +31331,6 @@ > B2227ADA0D00BF220071B782 /* SVGTransformable.h in Headers */, > B2227ADD0D00BF220071B782 /* SVGTransformDistance.h in Headers */, > B2227ADF0D00BF220071B782 /* SVGTransformList.h in Headers */, >- 7CE58D581DD7D96D00128552 /* SVGTransformValue.h in Headers */, > B2227AE20D00BF220071B782 /* SVGTRefElement.h in Headers */, > B2227AE50D00BF220071B782 /* SVGTSpanElement.h in Headers */, > B2227AE70D00BF220071B782 /* SVGUnitTypes.h in Headers */, >diff --git a/Source/WebCore/svg/SVGAngle.h b/Source/WebCore/svg/SVGAngle.h >index c02fa04f5fc..013732e2008 100644 >--- a/Source/WebCore/svg/SVGAngle.h >+++ b/Source/WebCore/svg/SVGAngle.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-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 >@@ -26,32 +26,37 @@ > #pragma once > > #include "SVGAngleValue.h" >-#include "SVGPropertyTearOff.h" >+#include "SVGValueProperty.h" > > namespace WebCore { > >-class SVGAngle : public SVGPropertyTearOff<SVGAngleValue> { >+class SVGAngle : public SVGValueProperty<SVGAngleValue> { >+ using Base = SVGValueProperty<SVGAngleValue>; >+ using Base::Base; >+ using Base::m_value; >+ > public: >- static Ref<SVGAngle> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGAngleValue& value) >+ static Ref<SVGAngle> create(const SVGAngleValue& value = { }) > { >- return adoptRef(*new SVGAngle(animatedProperty, role, value)); >+ return adoptRef(*new SVGAngle(value)); > } > >- static Ref<SVGAngle> create(const SVGAngleValue& initialValue = { }) >+ static Ref<SVGAngle> create(SVGPropertyOwner* owner, SVGPropertyAccess access, const SVGAngleValue& value = { }) > { >- return adoptRef(*new SVGAngle(initialValue)); >+ return adoptRef(*new SVGAngle(owner, access, value)); > } > >- template<typename T> static ExceptionOr<Ref<SVGAngle>> create(ExceptionOr<T>&& initialValue) >+ template<typename T> >+ static ExceptionOr<Ref<SVGAngle>> create(ExceptionOr<T>&& value) > { >- if (initialValue.hasException()) >- return initialValue.releaseException(); >- return create(initialValue.releaseReturnValue()); >+ if (value.hasException()) >+ return value.releaseException(); >+ return adoptRef(*new SVGAngle(value.releaseReturnValue())); > } > > SVGAngleValue::Type unitType() > { >- return propertyReference().unitType(); >+ return m_value.unitType(); > } > > ExceptionOr<void> setValueForBindings(float value) >@@ -59,15 +64,14 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setValue(value); >+ m_value.setValue(value); > commitChange(); >- > return { }; > } > > float valueForBindings() > { >- return propertyReference().value(); >+ return m_value.value(); > } > > ExceptionOr<void> setValueInSpecifiedUnits(float valueInSpecifiedUnits) >@@ -75,15 +79,14 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setValueInSpecifiedUnits(valueInSpecifiedUnits); >+ m_value.setValueInSpecifiedUnits(valueInSpecifiedUnits); > commitChange(); >- > return { }; > } > > float valueInSpecifiedUnits() > { >- return propertyReference().valueInSpecifiedUnits(); >+ return m_value.valueInSpecifiedUnits(); > } > > ExceptionOr<void> setValueAsString(const String& value) >@@ -91,7 +94,7 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- auto result = propertyReference().setValueAsString(value); >+ auto result = m_value.setValueAsString(value); > if (result.hasException()) > return result; > >@@ -99,9 +102,9 @@ public: > return result; > } > >- String valueAsString() >+ String valueAsString() const override > { >- return propertyReference().valueAsString(); >+ return m_value.valueAsString(); > } > > ExceptionOr<void> newValueSpecifiedUnits(unsigned short unitType, float valueInSpecifiedUnits) >@@ -109,7 +112,7 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- auto result = propertyReference().newValueSpecifiedUnits(unitType, valueInSpecifiedUnits); >+ auto result = m_value.newValueSpecifiedUnits(unitType, valueInSpecifiedUnits); > if (result.hasException()) > return result; > >@@ -122,24 +125,13 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- auto result = propertyReference().convertToSpecifiedUnits(unitType); >+ auto result = m_value.convertToSpecifiedUnits(unitType); > if (result.hasException()) > return result; > > commitChange(); > return result; > } >- >-private: >- SVGAngle(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGAngleValue& value) >- : SVGPropertyTearOff<SVGAngleValue>(&animatedProperty, role, value) >- { >- } >- >- explicit SVGAngle(const SVGAngleValue& initialValue) >- : SVGPropertyTearOff<SVGAngleValue>(initialValue) >- { >- } > }; > > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGAngleValue.h b/Source/WebCore/svg/SVGAngleValue.h >index 4d402f7fcd4..5978af4278c 100644 >--- a/Source/WebCore/svg/SVGAngleValue.h >+++ b/Source/WebCore/svg/SVGAngleValue.h >@@ -2,6 +2,7 @@ > * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> > * Copyright (C) Research In Motion Limited 2010. All rights reserved. >+ * Copyright (C) 2018 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 >@@ -56,10 +57,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/SVGLength.h b/Source/WebCore/svg/SVGLength.h >index 94529d24e6c..f09a19412f5 100644 >--- a/Source/WebCore/svg/SVGLength.h >+++ b/Source/WebCore/svg/SVGLength.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-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 >@@ -26,11 +26,15 @@ > #pragma once > > #include "SVGLengthValue.h" >-#include "SVGPropertyTearOff.h" >+#include "SVGValueProperty.h" > > namespace WebCore { > >-class SVGLength : public SVGPropertyTearOff<SVGLengthValue> { >+class SVGLength : public SVGValueProperty<SVGLengthValue> { >+ using Base = SVGValueProperty<SVGLengthValue>; >+ using Base::Base; >+ using Base::m_value; >+ > public: > // Forward declare these enums in the w3c naming scheme, for IDL generation > enum { >@@ -47,31 +51,37 @@ public: > SVG_LENGTHTYPE_PC = LengthTypePC > }; > >- static Ref<SVGLength> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGLengthValue& value) >+ static Ref<SVGLength> create(const SVGLengthValue& value = { }) > { >- return adoptRef(*new SVGLength(animatedProperty, role, value)); >+ return adoptRef(*new SVGLength(value)); > } > >- static Ref<SVGLength> create(const SVGLengthValue& initialValue = { }) >+ static Ref<SVGLength> create(SVGPropertyOwner* owner, SVGPropertyAccess access, const SVGLengthValue& value = { }) > { >- return adoptRef(*new SVGLength(initialValue)); >+ return adoptRef(*new SVGLength(owner, access, value)); > } > >- template<typename T> static ExceptionOr<Ref<SVGLength>> create(ExceptionOr<T>&& initialValue) >+ template<typename T> >+ static ExceptionOr<Ref<SVGLength>> create(ExceptionOr<T>&& value) > { >- if (initialValue.hasException()) >- return initialValue.releaseException(); >- return create(initialValue.releaseReturnValue()); >+ if (value.hasException()) >+ return value.releaseException(); >+ return adoptRef(*new SVGLength(value.releaseReturnValue())); > } > >+ Ref<SVGLength> clone() const >+ { >+ return SVGLength::create(m_value); >+ } >+ > unsigned short unitType() > { >- return propertyReference().unitType(); >+ return m_value.unitType(); > } > > ExceptionOr<float> valueForBindings() > { >- return propertyReference().valueForBindings(SVGLengthContext { contextElement() }); >+ return m_value.valueForBindings(SVGLengthContext { contextElement() }); > } > > ExceptionOr<void> setValueForBindings(float value) >@@ -79,7 +89,7 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- auto result = propertyReference().setValue(value, SVGLengthContext { contextElement() }); >+ auto result = m_value.setValue(value, SVGLengthContext { contextElement() }); > if (result.hasException()) > return result; > >@@ -89,7 +99,7 @@ public: > > float valueInSpecifiedUnits() > { >- return propertyReference().valueInSpecifiedUnits(); >+ return m_value.valueInSpecifiedUnits(); > } > > ExceptionOr<void> setValueInSpecifiedUnits(float valueInSpecifiedUnits) >@@ -97,15 +107,14 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setValueInSpecifiedUnits(valueInSpecifiedUnits); >+ m_value.setValueInSpecifiedUnits(valueInSpecifiedUnits); > commitChange(); >- > return { }; > } > >- String valueAsString() >+ String valueAsString() const override > { >- return propertyReference().valueAsString(); >+ return m_value.valueAsString(); > } > > ExceptionOr<void> setValueAsString(const String& value) >@@ -113,10 +122,10 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- auto result = propertyReference().setValueAsString(value); >+ auto result = m_value.setValueAsString(value); > if (result.hasException()) > return result; >- >+ > commitChange(); > return result; > } >@@ -126,7 +135,7 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- auto result = propertyReference().newValueSpecifiedUnits(unitType, valueInSpecifiedUnits); >+ auto result = m_value.newValueSpecifiedUnits(unitType, valueInSpecifiedUnits); > if (result.hasException()) > return result; > >@@ -139,24 +148,13 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- auto result = propertyReference().convertToSpecifiedUnits(unitType, SVGLengthContext { contextElement() }); >+ auto result = m_value.convertToSpecifiedUnits(unitType, SVGLengthContext { contextElement() }); > if (result.hasException()) > return result; > > commitChange(); > return result; > } >- >-private: >- SVGLength(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGLengthValue& value) >- : SVGPropertyTearOff<SVGLengthValue>(&animatedProperty, role, value) >- { >- } >- >- explicit SVGLength(const SVGLengthValue& initialValue) >- : SVGPropertyTearOff<SVGLengthValue>(initialValue) >- { >- } > }; > > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGMatrix.h b/Source/WebCore/svg/SVGMatrix.h >index 772ee5843c0..f3d37b824e4 100644 >--- a/Source/WebCore/svg/SVGMatrix.h >+++ b/Source/WebCore/svg/SVGMatrix.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-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 >@@ -25,266 +25,180 @@ > > #pragma once > >-#include "SVGMatrixValue.h" >-#include "SVGPropertyTearOff.h" >+#include "AffineTransform.h" >+#include "SVGValueProperty.h" > > namespace WebCore { > > // FIXME: Remove this class once SVGMatrix becomes an alias to DOMMatrix. >-class SVGMatrix : public SVGPropertyTearOff<SVGMatrixValue> { >+class SVGMatrix : public SVGValueProperty<AffineTransform> { > public: >- static Ref<SVGMatrix> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGMatrixValue& value) >- { >- return adoptRef(*new SVGMatrix(animatedProperty, role, value)); >- } >+ using Base = SVGValueProperty<AffineTransform>; >+ using Base::Base; > >- static Ref<SVGMatrix> create(const SVGMatrixValue& initialValue = { }) >+ static Ref<SVGMatrix> create(const AffineTransform& value = { }) > { >- return adoptRef(*new SVGMatrix(initialValue)); >+ return adoptRef(*new SVGMatrix(value)); > } > >- template<typename T> static ExceptionOr<Ref<SVGMatrix>> create(ExceptionOr<T>&& initialValue) >+ static Ref<SVGMatrix> create(SVGPropertyOwner* owner, SVGPropertyAccess access, const AffineTransform& value = { }) > { >- if (initialValue.hasException()) >- return initialValue.releaseException(); >- return create(initialValue.releaseReturnValue()); >+ return adoptRef(*new SVGMatrix(owner, access, value)); > } > >- double a() >+ template<typename T> static ExceptionOr<Ref<SVGMatrix>> create(ExceptionOr<T>&& value) > { >- return propertyReference().a(); >+ if (value.hasException()) >+ return value.releaseException(); >+ return create(value.releaseReturnValue()); > } > >- ExceptionOr<void> setA(double value) >+ double a() { return m_value.a(); } >+ ExceptionOr<void> setA(double a) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setA(value); >+ m_value.setA(a); > commitChange(); >- > return { }; > } > >- double b() >- { >- return propertyReference().b(); >- } >- >- ExceptionOr<void> setB(double value) >+ double b() { return m_value.b(); } >+ ExceptionOr<void> setB(double b) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setB(value); >+ m_value.setB(b); > commitChange(); >- > return { }; > } > >- double c() >- { >- return propertyReference().c(); >- } >- >- ExceptionOr<void> setC(double value) >+ double c() { return m_value.c(); } >+ ExceptionOr<void> setC(double c) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setC(value); >+ m_value.setC(c); > commitChange(); >- > return { }; > } > >- double d() >- { >- return propertyReference().d(); >- } >- >- ExceptionOr<void> setD(double value) >+ double d() { return m_value.d(); } >+ ExceptionOr<void> setD(double d) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setD(value); >+ m_value.setD(d); > commitChange(); >- > return { }; > } > >- double e() >- { >- return propertyReference().e(); >- } >- >- ExceptionOr<void> setE(double value) >+ double e() { return m_value.e(); } >+ ExceptionOr<void> setE(double e) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setE(value); >+ m_value.setE(e); > commitChange(); >- > return { }; > } > >- double f() >- { >- return propertyReference().f(); >- } >- >- ExceptionOr<void> setF(double value) >+ double f() { return m_value.f(); } >+ ExceptionOr<void> setF(double f) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setF(value); >+ m_value.setF(f); > commitChange(); >- > return { }; > } > >- ExceptionOr<Ref<SVGMatrix>> multiply(SVGMatrix& secondMatrix) >+ Ref<SVGMatrix> multiply(SVGMatrix& secondMatrix) const > { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().multiply(secondMatrix.propertyReference()); >- commitChange(); >- >- return SVGMatrix::create(result); >+ auto copy = m_value; >+ copy.multiply(secondMatrix.value()); >+ return SVGMatrix::create(copy); > } > >- ExceptionOr<Ref<SVGMatrix>> inverse() >+ ExceptionOr<Ref<SVGMatrix>> inverse() const > { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().inverse(); >- if (result.hasException()) >- return result.releaseException(); >+ auto inverse = m_value.inverse(); >+ if (!inverse) >+ return Exception { InvalidStateError, "Matrix is not invertible"_s }; > >- commitChange(); >- return SVGMatrix::create(result.releaseReturnValue()); >+ return SVGMatrix::create(*inverse); > } > >- ExceptionOr<Ref<SVGMatrix>> translate(float x, float y) >+ Ref<SVGMatrix> translate(float x, float y) const > { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().translate(x, y); >- commitChange(); >- >- return SVGMatrix::create(result); >+ auto copy = m_value; >+ copy.translate(x, y); >+ return SVGMatrix::create(copy); > } > >- ExceptionOr<Ref<SVGMatrix>> scale(float scaleFactor) >+ Ref<SVGMatrix> scale(float scaleFactor) const > { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().scale(scaleFactor); >- commitChange(); >- >- return SVGMatrix::create(result); >+ auto copy = m_value; >+ copy.scale(scaleFactor, scaleFactor); >+ return SVGMatrix::create(copy); > } > >- ExceptionOr<Ref<SVGMatrix>> scaleNonUniform(float scaleFactorX, float scaleFactorY) >+ Ref<SVGMatrix> scaleNonUniform(float scaleFactorX, float scaleFactorY) const > { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().scaleNonUniform(scaleFactorX, scaleFactorY); >- commitChange(); >- >- return SVGMatrix::create(result); >+ auto copy = m_value; >+ copy.scale(scaleFactorX, scaleFactorY); >+ return SVGMatrix::create(copy); > } > >- ExceptionOr<Ref<SVGMatrix>> rotate(float angle) >+ Ref<SVGMatrix> rotate(float angle) const > { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().rotate(angle); >- commitChange(); >- >- return SVGMatrix::create(result); >+ auto copy = m_value; >+ copy.rotate(angle); >+ return SVGMatrix::create(copy); > } > >- ExceptionOr<Ref<SVGMatrix>> rotateFromVector(float x, float y) >+ ExceptionOr<Ref<SVGMatrix>> rotateFromVector(float x, float y) const > { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().rotateFromVector(x, y); >- if (result.hasException()) >- return result.releaseException(); >+ if (!x || !y) >+ return Exception { TypeError }; > >- commitChange(); >- return SVGMatrix::create(result.releaseReturnValue()); >- } >- >- ExceptionOr<Ref<SVGMatrix>> flipX() >- { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().flipX(); >- commitChange(); >- >- return SVGMatrix::create(result); >+ auto copy = m_value; >+ copy.rotateFromVector(x, y); >+ return SVGMatrix::create(copy); > } > >- ExceptionOr<Ref<SVGMatrix>> flipY() >+ Ref<SVGMatrix> flipX() const > { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().flipY(); >- commitChange(); >- >- return SVGMatrix::create(result); >- } >- >- ExceptionOr<Ref<SVGMatrix>> skewX(float angle) >- { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().skewX(angle); >- commitChange(); >- >- return SVGMatrix::create(result); >- } >- >- ExceptionOr<Ref<SVGMatrix>> skewY(float angle) >- { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto result = propertyReference().skewY(angle); >- commitChange(); >- >- return SVGMatrix::create(result); >+ auto copy = m_value; >+ copy.flipX(); >+ return SVGMatrix::create(copy); > } > >-protected: >- SVGMatrix(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGMatrixValue& value) >- : SVGPropertyTearOff<SVGMatrixValue>(&animatedProperty, role, value) >+ Ref<SVGMatrix> flipY() const > { >+ auto copy = m_value; >+ copy.flipY(); >+ return SVGMatrix::create(copy); > } > >- explicit SVGMatrix(const SVGMatrixValue& initialValue) >- : SVGPropertyTearOff<SVGMatrixValue>(initialValue) >+ Ref<SVGMatrix> skewX(float angle) const > { >+ auto copy = m_value; >+ copy.skewX(angle); >+ return SVGMatrix::create(copy); > } > >- explicit SVGMatrix(const SVGMatrixValue* initialValue) >- : SVGPropertyTearOff<SVGMatrixValue>(initialValue) >+ Ref<SVGMatrix> skewY(float angle) const > { >+ auto copy = m_value; >+ copy.skewY(angle); >+ return SVGMatrix::create(copy); > } > }; > >diff --git a/Source/WebCore/svg/SVGMatrix.idl b/Source/WebCore/svg/SVGMatrix.idl >index deff0563ec4..6fa637e14cb 100644 >--- a/Source/WebCore/svg/SVGMatrix.idl >+++ b/Source/WebCore/svg/SVGMatrix.idl >@@ -33,15 +33,15 @@ > attribute unrestricted double e; > attribute unrestricted double f; > >- [MayThrowException] SVGMatrix multiply(SVGMatrix secondMatrix); >- [MayThrowException] SVGMatrix inverse(); >- [MayThrowException] SVGMatrix translate(unrestricted float x, unrestricted float y); >- [MayThrowException] SVGMatrix scale(unrestricted float scaleFactor); >- [MayThrowException] SVGMatrix scaleNonUniform(unrestricted float scaleFactorX, unrestricted float scaleFactorY); >- [MayThrowException] SVGMatrix rotate(unrestricted float angle); >- [MayThrowException] SVGMatrix rotateFromVector(unrestricted float x, unrestricted float y); >- [MayThrowException] SVGMatrix flipX(); >- [MayThrowException] SVGMatrix flipY(); >- [MayThrowException] SVGMatrix skewX(unrestricted float angle); >- [MayThrowException] SVGMatrix skewY(unrestricted float angle); >+ [NewObject] SVGMatrix multiply(SVGMatrix secondMatrix); >+ [MayThrowException, NewObject] SVGMatrix inverse(); >+ [NewObject] SVGMatrix translate(unrestricted float x, unrestricted float y); >+ [NewObject] SVGMatrix scale(unrestricted float scaleFactor); >+ [NewObject] SVGMatrix scaleNonUniform(unrestricted float scaleFactorX, unrestricted float scaleFactorY); >+ [NewObject] SVGMatrix rotate(unrestricted float angle); >+ [MayThrowException, NewObject] SVGMatrix rotateFromVector(unrestricted float x, unrestricted float y); >+ [NewObject] SVGMatrix flipX(); >+ [NewObject] SVGMatrix flipY(); >+ [NewObject] SVGMatrix skewX(unrestricted float angle); >+ [NewObject] SVGMatrix skewY(unrestricted float angle); > }; >diff --git a/Source/WebCore/svg/SVGMatrixValue.h b/Source/WebCore/svg/SVGMatrixValue.h >deleted file mode 100644 >index 1842c650ba4..00000000000 >--- a/Source/WebCore/svg/SVGMatrixValue.h >+++ /dev/null >@@ -1,124 +0,0 @@ >-/* >- * 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 "AffineTransform.h" >-#include "ExceptionOr.h" >- >-namespace WebCore { >- >-class SVGMatrixValue final : public AffineTransform { >-public: >- SVGMatrixValue() = default; >- >- SVGMatrixValue(const AffineTransform& other) >- : AffineTransform(other) >- { >- } >- >- SVGMatrixValue(double a, double b, double c, double d, double e, double f) >- : AffineTransform(a, b, c, d, e, f) >- { >- } >- >- SVGMatrixValue translate(double tx, double ty) >- { >- AffineTransform copy { *this }; >- copy.translate(tx, ty); >- return SVGMatrixValue { copy }; >- } >- >- SVGMatrixValue scale(double s) >- { >- AffineTransform copy { *this }; >- copy.scale(s, s); >- return SVGMatrixValue { copy }; >- } >- >- SVGMatrixValue scaleNonUniform(double sx, double sy) >- { >- AffineTransform copy { *this }; >- copy.scale(sx, sy); >- return SVGMatrixValue { copy }; >- } >- >- SVGMatrixValue rotate(double d) >- { >- AffineTransform copy { *this }; >- copy.rotate(d); >- return SVGMatrixValue { copy }; >- } >- >- SVGMatrixValue flipX() >- { >- AffineTransform copy { *this }; >- copy.flipX(); >- return SVGMatrixValue { copy }; >- } >- >- SVGMatrixValue flipY() >- { >- AffineTransform copy { *this }; >- copy.flipY(); >- return SVGMatrixValue { copy }; >- } >- >- SVGMatrixValue skewX(double angle) >- { >- AffineTransform copy { *this }; >- copy.skewX(angle); >- return SVGMatrixValue { copy }; >- } >- >- SVGMatrixValue skewY(double angle) >- { >- AffineTransform copy { *this }; >- copy.skewY(angle); >- return SVGMatrixValue { copy }; >- } >- >- SVGMatrixValue multiply(const SVGMatrixValue& other) >- { >- AffineTransform copy { *this }; >- copy *= static_cast<const AffineTransform&>(other); >- return SVGMatrixValue { copy }; >- } >- >- ExceptionOr<SVGMatrixValue> inverse() const >- { >- if (auto inverse = AffineTransform::inverse()) >- return SVGMatrixValue { inverse.value() }; >- >- return Exception { InvalidStateError, "Matrix is not invertible"_s }; >- } >- >- ExceptionOr<SVGMatrixValue> rotateFromVector(double x, double y) >- { >- if (!x || !y) >- return Exception { TypeError }; >- >- AffineTransform copy { *this }; >- copy.rotateFromVector(x, y); >- return SVGMatrixValue { copy }; >- } >- >-}; >- >-} // namespace WebCore >diff --git a/Source/WebCore/svg/SVGNumber.h b/Source/WebCore/svg/SVGNumber.h >index d57801491e8..2e018daa9bf 100644 >--- a/Source/WebCore/svg/SVGNumber.h >+++ b/Source/WebCore/svg/SVGNumber.h >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2016 Apple Inc. All rights reserved. >+ * Copyright (C) 2016-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 >@@ -25,32 +25,42 @@ > > #pragma once > >-#include "SVGPropertyTearOff.h" >+#include "SVGValueProperty.h" > > namespace WebCore { > >-class SVGNumber : public SVGPropertyTearOff<float> { >+class SVGNumber : public SVGValueProperty<float> { >+ using Base = SVGValueProperty<float>; >+ using Base::Base; >+ using Base::m_value; >+ > public: >- static Ref<SVGNumber> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, float& value) >+ static Ref<SVGNumber> create(float value = 0) > { >- return adoptRef(*new SVGNumber(animatedProperty, role, value)); >+ return adoptRef(*new SVGNumber(value)); > } > >- static Ref<SVGNumber> create(const float& initialValue = { }) >+ static Ref<SVGNumber> create(SVGPropertyOwner* owner, SVGPropertyAccess access, float value = 0) > { >- return adoptRef(*new SVGNumber(initialValue)); >+ return adoptRef(*new SVGNumber(owner, access, value)); > } > >- template<typename T> static ExceptionOr<Ref<SVGNumber>> create(ExceptionOr<T>&& initialValue) >+ template<typename T> >+ static ExceptionOr<Ref<SVGNumber>> create(ExceptionOr<T>&& value) > { >- if (initialValue.hasException()) >- return initialValue.releaseException(); >- return create(initialValue.releaseReturnValue()); >+ if (value.hasException()) >+ return value.releaseException(); >+ return adoptRef(*new SVGNumber(value.releaseReturnValue())); >+ } >+ >+ Ref<SVGNumber> clone() const >+ { >+ return SVGNumber::create(m_value); > } > > float valueForBindings() > { >- return propertyReference(); >+ return m_value; > } > > ExceptionOr<void> setValueForBindings(float value) >@@ -58,21 +68,14 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference() = value; >+ m_value = value; > commitChange(); >- > return { }; > } >- >-private: >- SVGNumber(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, float& value) >- : SVGPropertyTearOff<float>(&animatedProperty, role, value) >- { >- } >- >- explicit SVGNumber(const float& initialValue) >- : SVGPropertyTearOff<float>(initialValue) >+ >+ String valueAsString() const override > { >+ return SVGPropertyTraits<float>::toString(m_value); > } > }; > >diff --git a/Source/WebCore/svg/SVGPoint.h b/Source/WebCore/svg/SVGPoint.h >index 926c8cb2ddf..4f2949a79ad 100644 >--- a/Source/WebCore/svg/SVGPoint.h >+++ b/Source/WebCore/svg/SVGPoint.h >@@ -28,86 +28,68 @@ > > #include "FloatPoint.h" > #include "SVGMatrix.h" >-#include "SVGPropertyTearOff.h" >+#include "SVGValueProperty.h" > > namespace WebCore { > >-class SVGPoint : public SVGPropertyTearOff<FloatPoint> { >+class SVGPoint : public SVGValueProperty<FloatPoint> { >+ using Base = SVGValueProperty<FloatPoint>; >+ using Base::Base; >+ using Base::m_value; >+ > public: >- static Ref<SVGPoint> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, FloatPoint& value) >+ static Ref<SVGPoint> create(const FloatPoint& value = { }) > { >- return adoptRef(*new SVGPoint(animatedProperty, role, value)); >+ return adoptRef(*new SVGPoint(value)); > } > >- static Ref<SVGPoint> create(const FloatPoint& initialValue = { }) >+ template<typename T> >+ static ExceptionOr<Ref<SVGPoint>> create(ExceptionOr<T>&& value) > { >- return adoptRef(*new SVGPoint(initialValue)); >+ if (value.hasException()) >+ return value.releaseException(); >+ return adoptRef(*new SVGPoint(value.releaseReturnValue())); > } > >- template<typename T> static ExceptionOr<Ref<SVGPoint>> create(ExceptionOr<T>&& initialValue) >+ Ref<SVGPoint> clone() const > { >- if (initialValue.hasException()) >- return initialValue.releaseException(); >- return create(initialValue.releaseReturnValue()); >+ return SVGPoint::create(m_value); > } > >- float x() >- { >- return propertyReference().x(); >- } >+ float x() { return m_value.x(); } > >- ExceptionOr<void> setX(float xValue) >+ ExceptionOr<void> setX(float x) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setX(xValue); >+ m_value.setX(x); > commitChange(); >- > return { }; > } > >- float y() >- { >- return propertyReference().y(); >- } >+ float y() { return m_value.y(); } > >- ExceptionOr<void> setY(float xValue) >+ ExceptionOr<void> setY(float y) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setY(xValue); >+ m_value.setY(y); > commitChange(); >- > return { }; > } > >- ExceptionOr<Ref<SVGPoint>> matrixTransform(SVGMatrix& matrix) >- { >- if (isReadOnly()) >- return Exception { NoModificationAllowedError }; >- >- auto newPoint = propertyReference().matrixTransform(matrix.propertyReference()); >- commitChange(); >- >- return SVGPoint::create(newPoint); >- } >- >-protected: >- SVGPoint(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, FloatPoint& value) >- : SVGPropertyTearOff<FloatPoint>(&animatedProperty, role, value) >- { >- } >- >- SVGPoint(SVGPropertyRole role, FloatPoint& value) >- : SVGPropertyTearOff<FloatPoint>(nullptr, role, value) >+ Ref<SVGPoint> matrixTransform(SVGMatrix& matrix) const > { >+ auto newPoint = m_value.matrixTransform(matrix.value()); >+ return adoptRef(*new SVGPoint(newPoint)); > } > >- explicit SVGPoint(const FloatPoint& initialValue) >- : SVGPropertyTearOff<FloatPoint>(initialValue) >+private: >+ String valueAsString() const override > { >+ return SVGPropertyTraits<FloatPoint>::toString(m_value); > } > }; > >diff --git a/Source/WebCore/svg/SVGPoint.idl b/Source/WebCore/svg/SVGPoint.idl >index 7c84515b5aa..5d822490dbb 100644 >--- a/Source/WebCore/svg/SVGPoint.idl >+++ b/Source/WebCore/svg/SVGPoint.idl >@@ -26,6 +26,6 @@ > attribute unrestricted float x; > attribute unrestricted float y; > >- [MayThrowException, NewObject] SVGPoint matrixTransform(SVGMatrix matrix); >+ [NewObject] SVGPoint matrixTransform(SVGMatrix matrix); > }; > >diff --git a/Source/WebCore/svg/SVGPreserveAspectRatio.h b/Source/WebCore/svg/SVGPreserveAspectRatio.h >index 8839f85792b..da293a1d3aa 100644 >--- a/Source/WebCore/svg/SVGPreserveAspectRatio.h >+++ b/Source/WebCore/svg/SVGPreserveAspectRatio.h >@@ -26,32 +26,32 @@ > #pragma once > > #include "SVGPreserveAspectRatioValue.h" >-#include "SVGPropertyTearOff.h" >+#include "SVGValueProperty.h" > > namespace WebCore { > >-class SVGPreserveAspectRatio : public SVGPropertyTearOff<SVGPreserveAspectRatioValue> { >+class SVGPreserveAspectRatio : public SVGValueProperty<SVGPreserveAspectRatioValue> { > public: >- static Ref<SVGPreserveAspectRatio> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGPreserveAspectRatioValue& value) >- { >- return adoptRef(*new SVGPreserveAspectRatio(animatedProperty, role, value)); >- } >+ using Base = SVGValueProperty<SVGPreserveAspectRatioValue>; >+ using Base::Base; >+ using Base::m_value; > >- static Ref<SVGPreserveAspectRatio> create(const SVGPreserveAspectRatioValue& initialValue = { }) >+ static Ref<SVGPreserveAspectRatio> create(SVGPropertyOwner* owner, SVGPropertyAccess access, const SVGPreserveAspectRatioValue& value = { }) > { >- return adoptRef(*new SVGPreserveAspectRatio(initialValue)); >+ return adoptRef(*new SVGPreserveAspectRatio(owner, access, value)); > } > >- template<typename T> static ExceptionOr<Ref<SVGPreserveAspectRatio>> create(ExceptionOr<T>&& initialValue) >+ template<typename T> >+ static ExceptionOr<Ref<SVGPreserveAspectRatio>> create(ExceptionOr<T>&& value) > { >- if (initialValue.hasException()) >- return initialValue.releaseException(); >- return create(initialValue.releaseReturnValue()); >+ if (value.hasException()) >+ return value.releaseException(); >+ return adoptRef(*new SVGPreserveAspectRatio(value.releaseReturnValue())); > } > > unsigned short align() > { >- return propertyReference().align(); >+ return m_value.align(); > } > > ExceptionOr<void> setAlign(float value) >@@ -59,7 +59,7 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- auto result = propertyReference().setAlign(value); >+ auto result = m_value.setAlign(value); > if (result.hasException()) > return result; > >@@ -69,7 +69,7 @@ public: > > unsigned short meetOrSlice() > { >- return propertyReference().meetOrSlice(); >+ return m_value.meetOrSlice(); > } > > ExceptionOr<void> setMeetOrSlice(float value) >@@ -77,23 +77,17 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- auto result = propertyReference().setMeetOrSlice(value); >+ auto result = m_value.setMeetOrSlice(value); > if (result.hasException()) > return result; > > commitChange(); > return result; > } >- >-private: >- SVGPreserveAspectRatio(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGPreserveAspectRatioValue& value) >- : SVGPropertyTearOff<SVGPreserveAspectRatioValue>(&animatedProperty, role, value) >- { >- } >- >- explicit SVGPreserveAspectRatio(const SVGPreserveAspectRatioValue& initialValue) >- : SVGPropertyTearOff<SVGPreserveAspectRatioValue>(initialValue) >+ >+ String valueAsString() const override > { >+ return m_value.valueAsString(); > } > }; > >diff --git a/Source/WebCore/svg/SVGPreserveAspectRatioValue.h b/Source/WebCore/svg/SVGPreserveAspectRatioValue.h >index 6a7fca24a4d..59c837123f2 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 std::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/SVGRect.h b/Source/WebCore/svg/SVGRect.h >index 5412005de9e..f5bf58cc69f 100644 >--- a/Source/WebCore/svg/SVGRect.h >+++ b/Source/WebCore/svg/SVGRect.h >@@ -20,105 +20,87 @@ > > #pragma once > >-#include "SVGPropertyTearOff.h" > #include "SVGPropertyTraits.h" >+#include "SVGValueProperty.h" > > namespace WebCore { > >-class SVGRect : public SVGPropertyTearOff<FloatRect> { >+class SVGRect : public SVGValueProperty<FloatRect> { >+ using Base = SVGValueProperty<FloatRect>; >+ using Base::Base; >+ using Base::m_value; >+ > public: >- static Ref<SVGRect> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, FloatRect& value) >+ static Ref<SVGRect> create(const FloatRect& value = { }) > { >- return adoptRef(*new SVGRect(animatedProperty, role, value)); >+ return adoptRef(*new SVGRect(value)); > } > >- static Ref<SVGRect> create(const FloatRect& initialValue = { }) >+ static Ref<SVGRect> create(SVGPropertyOwner* owner, SVGPropertyAccess access, const FloatRect& value = { }) > { >- return adoptRef(*new SVGRect(initialValue)); >+ return adoptRef(*new SVGRect(owner, access, value)); > } > >- template<typename T> static ExceptionOr<Ref<SVGRect>> create(ExceptionOr<T>&& initialValue) >+ template<typename T> >+ static ExceptionOr<Ref<SVGRect>> create(ExceptionOr<T>&& value) > { >- if (initialValue.hasException()) >- return initialValue.releaseException(); >- return create(initialValue.releaseReturnValue()); >+ if (value.hasException()) >+ return value.releaseException(); >+ return adoptRef(*new SVGRect(value.releaseReturnValue())); > } > >- float x() >- { >- return propertyReference().x(); >- } >+ float x() { return m_value.x(); } > > ExceptionOr<void> setX(float xValue) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setX(xValue); >+ m_value.setX(xValue); > commitChange(); >- > return { }; > } > >- float y() >- { >- return propertyReference().y(); >- } >+ float y() { return m_value.y(); } > > ExceptionOr<void> setY(float xValue) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setY(xValue); >+ m_value.setY(xValue); > commitChange(); >- > return { }; > } > >- float width() >- { >- return propertyReference().width(); >- } >+ float width() { return m_value.width(); } > > ExceptionOr<void> setWidth(float widthValue) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setWidth(widthValue); >+ m_value.setWidth(widthValue); > commitChange(); >- > return { }; > } > >- float height() >- { >- return propertyReference().height(); >- } >+ float height() { return m_value.height(); } > > ExceptionOr<void> setHeight(float heightValue) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setHeight(heightValue); >+ m_value.setHeight(heightValue); > commitChange(); >- > return { }; > } > >-private: >- SVGRect(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, FloatRect& value) >- : SVGPropertyTearOff<FloatRect>(&animatedProperty, role, value) >- { >- } >- >- explicit SVGRect(const FloatRect& initialValue) >- : SVGPropertyTearOff<FloatRect>(initialValue) >+ String valueAsString() const override > { >+ return SVGPropertyTraits<FloatRect>::toString(m_value); > } > }; > >- > } // namespace WebCore >diff --git a/Source/WebCore/svg/SVGTransform.cpp b/Source/WebCore/svg/SVGTransform.cpp >deleted file mode 100644 >index 59037945ab7..00000000000 >--- a/Source/WebCore/svg/SVGTransform.cpp >+++ /dev/null >@@ -1,38 +0,0 @@ >-/* >- * Copyright (C) 2016 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. AND ITS CONTRIBUTORS ``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 ITS 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. >- */ >- >-#include "config.h" >-#include "SVGTransform.h" >- >-#include "SVGMatrixTearOff.h" >- >-namespace WebCore { >- >-Ref<SVGMatrix> SVGTransform::matrix() >-{ >- return SVGMatrixTearOff::create(*this, propertyReference().svgMatrix()); >-} >- >-} // namespace WebCore >diff --git a/Source/WebCore/svg/SVGTransform.h b/Source/WebCore/svg/SVGTransform.h >index eff8dbcbd90..11e13d7007a 100644 >--- a/Source/WebCore/svg/SVGTransform.h >+++ b/Source/WebCore/svg/SVGTransform.h >@@ -26,50 +26,57 @@ > #pragma once > > #include "SVGMatrix.h" >-#include "SVGPropertyTearOff.h" > #include "SVGTransformValue.h" >+#include "SVGValueProperty.h" > > namespace WebCore { > >-class SVGTransform : public SVGPropertyTearOff<SVGTransformValue> { >+class SVGTransform : public SVGValueProperty<SVGTransformValue>, public SVGPropertyOwner { > public: >- static Ref<SVGTransform> create(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGTransformValue& value) >+ static Ref<SVGTransform> create(SVGTransformValue::SVGTransformType type) > { >- return adoptRef(*new SVGTransform(animatedProperty, role, value)); >+ return adoptRef(*new SVGTransform(type)); > } > >- static Ref<SVGTransform> create(const SVGTransformValue& initialValue = { }) >+ static Ref<SVGTransform> create(const AffineTransform& transform = { }) > { >- return adoptRef(*new SVGTransform(initialValue)); >+ return adoptRef(*new SVGTransform(SVGTransformValue::SVG_TRANSFORM_MATRIX, transform)); > } > >- template<typename T> static ExceptionOr<Ref<SVGTransform>> create(ExceptionOr<T>&& initialValue) >+ static Ref<SVGTransform> create(const SVGTransformValue& value) > { >- if (initialValue.hasException()) >- return initialValue.releaseException(); >- return create(initialValue.releaseReturnValue()); >+ return adoptRef(*new SVGTransform(value.type(), value.matrix()->value(), value.angle(), value.rotationCenter())); > } > >- unsigned short type() >+ template<typename T> >+ static ExceptionOr<Ref<SVGTransform>> create(ExceptionOr<T>&& value) > { >- return propertyReference().type(); >+ if (value.hasException()) >+ return value.releaseException(); >+ return create(value.releaseReturnValue()); > } > >- Ref<SVGMatrix> matrix(); >+ ~SVGTransform() >+ { >+ m_value.matrix()->detach(); >+ } > >- float angle() >+ Ref<SVGTransform> clone() const > { >- return propertyReference().angle(); >+ return SVGTransform::create(m_value); > } > >+ unsigned short type() { return m_value.type(); } >+ float angle() { return m_value.angle(); } >+ const Ref<SVGMatrix>& matrix() { return m_value.matrix(); } >+ > ExceptionOr<void> setMatrix(SVGMatrix& matrix) > { > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setMatrix(matrix.propertyReference()); >+ m_value.setMatrix(matrix.value()); > commitChange(); >- > return { }; > } > >@@ -78,9 +85,8 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setTranslate(tx, ty); >+ m_value.setTranslate(tx, ty); > commitChange(); >- > return { }; > } > >@@ -89,9 +95,8 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setScale(sx, sy); >+ m_value.setScale(sx, sy); > commitChange(); >- > return { }; > } > >@@ -100,9 +105,8 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setRotate(angle, cx, cy); >+ m_value.setRotate(angle, cx, cy); > commitChange(); >- > return { }; > } > >@@ -111,9 +115,8 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setSkewX(angle); >+ m_value.setSkewX(angle); > commitChange(); >- > return { }; > } > >@@ -122,21 +125,32 @@ public: > if (isReadOnly()) > return Exception { NoModificationAllowedError }; > >- propertyReference().setSkewY(angle); >+ m_value.setSkewY(angle); > commitChange(); >- > return { }; > } > > private: >- SVGTransform(SVGAnimatedProperty& animatedProperty, SVGPropertyRole role, SVGTransformValue& value) >- : SVGPropertyTearOff<SVGTransformValue>(&animatedProperty, role, value) >+ using Base = SVGValueProperty<SVGTransformValue>; >+ >+ SVGTransform(SVGTransformValue::SVGTransformType type, const AffineTransform& transform = { }, float angle = 0, const FloatPoint& rotationCenter = { }) >+ : Base(SVGTransformValue(type, SVGMatrix::create(this, SVGPropertyAccess::ReadWrite, transform), angle, rotationCenter)) >+ { >+ } >+ >+ SVGPropertyOwner* owner() const override { return m_owner; } >+ >+ void commitPropertyChange(SVGProperty* property) override > { >+ ASSERT_UNUSED(property, property == m_value.matrix().ptr()); >+ if (owner()) >+ owner()->commitPropertyChange(this); >+ m_value.matrixDidChange(); > } > >- explicit SVGTransform(const SVGTransformValue& initialValue) >- : SVGPropertyTearOff<SVGTransformValue>(initialValue) >+ String valueAsString() const override > { >+ return m_value.valueAsString(); > } > }; > >diff --git a/Source/WebCore/svg/SVGTransform.idl b/Source/WebCore/svg/SVGTransform.idl >index 11974059398..529b0ed50ad 100644 >--- a/Source/WebCore/svg/SVGTransform.idl >+++ b/Source/WebCore/svg/SVGTransform.idl >@@ -32,7 +32,7 @@ > const unsigned short SVG_TRANSFORM_SKEWY = 6; > > readonly attribute unsigned short type; >- [NewObject] readonly attribute SVGMatrix matrix; >+ readonly attribute SVGMatrix matrix; > readonly attribute unrestricted float angle; > > [MayThrowException] void setMatrix(SVGMatrix matrix); >diff --git a/Source/WebCore/svg/SVGTransformValue.cpp b/Source/WebCore/svg/SVGTransformValue.cpp >deleted file mode 100644 >index 63d45a5c64f..00000000000 >--- a/Source/WebCore/svg/SVGTransformValue.cpp >+++ /dev/null >@@ -1,234 +0,0 @@ >-/* >- * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org> >- * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> >- * Copyright (C) 2017 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 >- * 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. >- */ >- >-#include "config.h" >-#include "SVGTransformValue.h" >- >-#include "FloatConversion.h" >-#include "FloatPoint.h" >-#include "FloatSize.h" >-#include <wtf/MathExtras.h> >-#include <wtf/NeverDestroyed.h> >-#include <wtf/text/StringBuilder.h> >-#include <wtf/text/WTFString.h> >- >-namespace WebCore { >- >-SVGTransformValue::SVGTransformValue() = default; >- >-SVGTransformValue::SVGTransformValue(SVGTransformType type, ConstructionMode mode) >- : m_type(type) >-{ >- if (mode == ConstructZeroTransform) >- m_matrix = AffineTransform(0, 0, 0, 0, 0, 0); >-} >- >-SVGTransformValue::SVGTransformValue(const AffineTransform& matrix) >- : m_type(SVG_TRANSFORM_MATRIX) >- , m_matrix(matrix) >-{ >-} >- >-void SVGTransformValue::setMatrix(const AffineTransform& matrix) >-{ >- m_type = SVG_TRANSFORM_MATRIX; >- m_angle = 0; >- m_matrix = matrix; >-} >- >-void SVGTransformValue::updateSVGMatrix() >-{ >- // The underlying matrix has been changed, alter the transformation type. >- // Spec: In case the matrix object is changed directly (i.e., without using the methods on the SVGTransform interface itself) >- // then the type of the SVGTransform changes to SVG_TRANSFORM_MATRIX. >- m_type = SVG_TRANSFORM_MATRIX; >- m_angle = 0; >-} >- >-void SVGTransformValue::setTranslate(float tx, float ty) >-{ >- m_type = SVG_TRANSFORM_TRANSLATE; >- m_angle = 0; >- >- m_matrix.makeIdentity(); >- m_matrix.translate(tx, ty); >-} >- >-FloatPoint SVGTransformValue::translate() const >-{ >- return FloatPoint::narrowPrecision(m_matrix.e(), m_matrix.f()); >-} >- >-void SVGTransformValue::setScale(float sx, float sy) >-{ >- m_type = SVG_TRANSFORM_SCALE; >- m_angle = 0; >- m_center = FloatPoint(); >- >- m_matrix.makeIdentity(); >- m_matrix.scaleNonUniform(sx, sy); >-} >- >-FloatSize SVGTransformValue::scale() const >-{ >- return FloatSize::narrowPrecision(m_matrix.a(), m_matrix.d()); >-} >- >-void SVGTransformValue::setRotate(float angle, float cx, float cy) >-{ >- m_type = SVG_TRANSFORM_ROTATE; >- m_angle = angle; >- m_center = FloatPoint(cx, cy); >- >- // TODO: toString() implementation, which can show cx, cy (need to be stored?) >- m_matrix.makeIdentity(); >- m_matrix.translate(cx, cy); >- m_matrix.rotate(angle); >- m_matrix.translate(-cx, -cy); >-} >- >-void SVGTransformValue::setSkewX(float angle) >-{ >- m_type = SVG_TRANSFORM_SKEWX; >- m_angle = angle; >- >- m_matrix.makeIdentity(); >- m_matrix.skewX(angle); >-} >- >-void SVGTransformValue::setSkewY(float angle) >-{ >- m_type = SVG_TRANSFORM_SKEWY; >- m_angle = angle; >- >- m_matrix.makeIdentity(); >- m_matrix.skewY(angle); >-} >- >-const String& SVGTransformValue::transformTypePrefixForParsing(SVGTransformType type) >-{ >- switch (type) { >- case SVG_TRANSFORM_UNKNOWN: >- return emptyString(); >- case SVG_TRANSFORM_MATRIX: { >- static NeverDestroyed<String> matrixString(MAKE_STATIC_STRING_IMPL("matrix(")); >- return matrixString; >- } >- case SVG_TRANSFORM_TRANSLATE: { >- static NeverDestroyed<String> translateString(MAKE_STATIC_STRING_IMPL("translate(")); >- return translateString; >- } >- case SVG_TRANSFORM_SCALE: { >- static NeverDestroyed<String> scaleString(MAKE_STATIC_STRING_IMPL("scale(")); >- return scaleString; >- } >- case SVG_TRANSFORM_ROTATE: { >- static NeverDestroyed<String> rotateString(MAKE_STATIC_STRING_IMPL("rotate(")); >- return rotateString; >- } >- case SVG_TRANSFORM_SKEWX: { >- static NeverDestroyed<String> skewXString(MAKE_STATIC_STRING_IMPL("skewX(")); >- return skewXString; >- } >- case SVG_TRANSFORM_SKEWY: { >- static NeverDestroyed<String> skewYString(MAKE_STATIC_STRING_IMPL("skewY(")); >- return skewYString; >- } >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >-} >- >-String SVGTransformValue::valueAsString() const >-{ >- const String& prefix = transformTypePrefixForParsing(m_type); >- switch (m_type) { >- case SVG_TRANSFORM_UNKNOWN: >- return prefix; >- case SVG_TRANSFORM_MATRIX: { >- StringBuilder builder; >- builder.append(prefix); >- builder.appendNumber(m_matrix.a()); >- builder.append(' '); >- builder.appendNumber(m_matrix.b()); >- builder.append(' '); >- builder.appendNumber(m_matrix.c()); >- builder.append(' '); >- builder.appendNumber(m_matrix.d()); >- builder.append(' '); >- builder.appendNumber(m_matrix.e()); >- builder.append(' '); >- builder.appendNumber(m_matrix.f()); >- builder.append(')'); >- return builder.toString(); >- } >- case SVG_TRANSFORM_TRANSLATE: { >- StringBuilder builder; >- builder.append(prefix); >- builder.appendNumber(m_matrix.e()); >- builder.append(' '); >- builder.appendNumber(m_matrix.f()); >- builder.append(')'); >- return builder.toString(); >- } >- case SVG_TRANSFORM_SCALE: { >- StringBuilder builder; >- builder.append(prefix); >- builder.appendNumber(m_matrix.xScale()); >- builder.append(' '); >- builder.appendNumber(m_matrix.yScale()); >- builder.append(')'); >- return builder.toString(); >- } >- case SVG_TRANSFORM_ROTATE: { >- double angleInRad = deg2rad(m_angle); >- double cosAngle = std::cos(angleInRad); >- double sinAngle = std::sin(angleInRad); >- float cx = narrowPrecisionToFloat(cosAngle != 1 ? (m_matrix.e() * (1 - cosAngle) - m_matrix.f() * sinAngle) / (1 - cosAngle) / 2 : 0); >- float cy = narrowPrecisionToFloat(cosAngle != 1 ? (m_matrix.e() * sinAngle / (1 - cosAngle) + m_matrix.f()) / 2 : 0); >- StringBuilder builder; >- builder.append(prefix); >- builder.appendNumber(m_angle); >- if (cx || cy) { >- builder.append(' '); >- builder.appendNumber(cx); >- builder.append(' '); >- builder.appendNumber(cy); >- } >- builder.append(')'); >- return builder.toString(); >- } >- case SVG_TRANSFORM_SKEWX: >- case SVG_TRANSFORM_SKEWY: { >- StringBuilder builder; >- builder.append(prefix); >- builder.appendNumber(m_angle); >- builder.append(')'); >- return builder.toString(); >- } >- } >- >- ASSERT_NOT_REACHED(); >- return emptyString(); >-} >- >-} // namespace WebCore >diff --git a/Source/WebCore/svg/SVGTransformValue.h b/Source/WebCore/svg/SVGTransformValue.h >index fadd03a23a1..55285f0a1fa 100644 >--- a/Source/WebCore/svg/SVGTransformValue.h >+++ b/Source/WebCore/svg/SVGTransformValue.h >@@ -1,6 +1,7 @@ > /* > * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> > * Copyright (C) 2004, 2005 Rob Buis <buis@kde.org> >+ * Copyright (C) 2018 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 >@@ -20,8 +21,13 @@ > > #pragma once > >+#include "FloatConversion.h" > #include "FloatPoint.h" >-#include "SVGMatrixValue.h" >+#include "FloatSize.h" >+#include "SVGMatrix.h" >+#include <wtf/HashMap.h> >+#include <wtf/NeverDestroyed.h> >+#include <wtf/text/StringBuilder.h> > > namespace WebCore { > >@@ -39,56 +45,243 @@ public: > SVG_TRANSFORM_SKEWY = 6 > }; > >- enum ConstructionMode { >- ConstructIdentityTransform, >- ConstructZeroTransform >- }; >+ SVGTransformValue(SVGTransformType type = SVG_TRANSFORM_MATRIX, const AffineTransform& transform = { }) >+ : m_type(type) >+ , m_matrix(SVGMatrix::create(transform)) >+ { >+ } > >- SVGTransformValue(); >- SVGTransformValue(SVGTransformType, ConstructionMode = ConstructIdentityTransform); >- explicit SVGTransformValue(const AffineTransform&); >+ SVGTransformValue(const SVGTransformValue& other) >+ : m_type(other.m_type) >+ , m_matrix(SVGMatrix::create(other.matrix()->value())) >+ , m_angle(other.m_angle) >+ , m_rotationCenter(other.m_rotationCenter) >+ { >+ } > >- SVGTransformType type() const { return m_type; } >+ SVGTransformValue(SVGTransformType type, Ref<SVGMatrix>&& matrix, float angle, const FloatPoint& rotationCenter) >+ : m_type(type) >+ , m_matrix(WTFMove(matrix)) >+ , m_angle(angle) >+ , m_rotationCenter(rotationCenter) >+ { >+ } > >- SVGMatrixValue& svgMatrix() { return static_cast<SVGMatrixValue&>(m_matrix); } >- AffineTransform matrix() const { return m_matrix; } >- void updateSVGMatrix(); >+ SVGTransformValue(SVGTransformValue&& other) >+ : m_type(other.m_type) >+ , m_matrix(other.m_matrix.copyRef()) >+ , m_angle(other.m_angle) >+ , m_rotationCenter(other.m_rotationCenter) >+ { >+ } > >+ SVGTransformValue& operator=(const SVGTransformValue& other) >+ { >+ m_type = other.m_type; >+ m_matrix->setValue(other.m_matrix->value()); >+ m_angle = other.m_angle; >+ m_rotationCenter = other.m_rotationCenter; >+ return *this; >+ } >+ >+ SVGTransformType type() const { return m_type; } >+ const Ref<SVGMatrix>& matrix() const { return m_matrix; } > float angle() const { return m_angle; } >- FloatPoint rotationCenter() const { return m_center; } >- >- void setMatrix(const AffineTransform&); >- void setTranslate(float tx, float ty); >- void setScale(float sx, float sy); >- void setRotate(float angle, float cx, float cy); >- void setSkewX(float angle); >- void setSkewY(float angle); >- >- FloatPoint translate() const; >- FloatSize scale() const; >+ FloatPoint rotationCenter() const { return m_rotationCenter; } > > bool isValid() const { return m_type != SVG_TRANSFORM_UNKNOWN; } >- String valueAsString() const; > >- static const String& transformTypePrefixForParsing(SVGTransformType); >+ void setMatrix(const AffineTransform& matrix) >+ { >+ m_type = SVG_TRANSFORM_MATRIX; >+ m_angle = 0; >+ m_rotationCenter = FloatPoint(); >+ m_matrix->setValue(matrix); >+ } >+ >+ void matrixDidChange() >+ { >+ // The underlying matrix has been changed, alter the transformation type. >+ // Spec: In case the matrix object is changed directly (i.e., without using the methods on the SVGTransform interface itself) >+ // then the type of the SVGTransform changes to SVG_TRANSFORM_MATRIX. >+ m_type = SVG_TRANSFORM_MATRIX; >+ m_angle = 0; >+ m_rotationCenter = FloatPoint(); >+ } >+ >+ FloatPoint translate() const >+ { >+ return FloatPoint::narrowPrecision(m_matrix->e(), m_matrix->f()); >+ } >+ >+ void setTranslate(float tx, float ty) >+ { >+ m_type = SVG_TRANSFORM_TRANSLATE; >+ m_angle = 0; >+ m_rotationCenter = FloatPoint(); >+ >+ m_matrix->value().makeIdentity(); >+ m_matrix->value().translate(tx, ty); >+ } >+ >+ FloatSize scale() const >+ { >+ return FloatSize::narrowPrecision(m_matrix->a(), m_matrix->d()); >+ } >+ >+ void setScale(float sx, float sy) >+ { >+ m_type = SVG_TRANSFORM_SCALE; >+ m_angle = 0; >+ m_rotationCenter = FloatPoint(); >+ >+ m_matrix->value().makeIdentity(); >+ m_matrix->value().scaleNonUniform(sx, sy); >+ } >+ >+ void setRotate(float angle, float cx, float cy) >+ { >+ m_type = SVG_TRANSFORM_ROTATE; >+ m_angle = angle; >+ m_rotationCenter = FloatPoint(cx, cy); >+ >+ // TODO: toString() implementation, which can show cx, cy (need to be stored?) >+ m_matrix->value().makeIdentity(); >+ m_matrix->value().translate(cx, cy); >+ m_matrix->value().rotate(angle); >+ m_matrix->value().translate(-cx, -cy); >+ } >+ >+ void setSkewX(float angle) >+ { >+ m_type = SVG_TRANSFORM_SKEWX; >+ m_angle = angle; >+ m_rotationCenter = FloatPoint(); >+ >+ m_matrix->value().makeIdentity(); >+ m_matrix->value().skewX(angle); >+ } >+ >+ void setSkewY(float angle) >+ { >+ m_type = SVG_TRANSFORM_SKEWY; >+ m_angle = angle; >+ m_rotationCenter = FloatPoint(); >+ >+ m_matrix->value().makeIdentity(); >+ m_matrix->value().skewY(angle); >+ } >+ >+ String valueAsString() const >+ { >+ StringBuilder builder; >+ builder.append(prefixForTransfromType(m_type)); >+ switch (m_type) { >+ case SVG_TRANSFORM_UNKNOWN: >+ break; >+ case SVG_TRANSFORM_MATRIX: >+ appendMatrix(builder); >+ break; >+ case SVG_TRANSFORM_TRANSLATE: >+ appendTranslate(builder); >+ break; >+ case SVG_TRANSFORM_SCALE: >+ appendScale(builder); >+ break; >+ case SVG_TRANSFORM_ROTATE: >+ appendRotate(builder); >+ break; >+ case SVG_TRANSFORM_SKEWX: >+ appendSkewX(builder); >+ break; >+ case SVG_TRANSFORM_SKEWY: >+ appendSkewY(builder); >+ break; >+ } >+ return builder.toString(); >+ } >+ >+ static String prefixForTransfromType(SVGTransformType type) >+ { >+ switch (type) { >+ case SVG_TRANSFORM_UNKNOWN: >+ return emptyString(); >+ case SVG_TRANSFORM_MATRIX: >+ return "matrix("_s; >+ case SVG_TRANSFORM_TRANSLATE: >+ return "translate("_s; >+ case SVG_TRANSFORM_SCALE: >+ return "scale("_s; >+ case SVG_TRANSFORM_ROTATE: >+ return "rotate("_s; >+ case SVG_TRANSFORM_SKEWX: >+ return "skewX("_s; >+ case SVG_TRANSFORM_SKEWY: >+ return "skewY("_s; >+ } >+ ASSERT_NOT_REACHED(); >+ return emptyString(); >+ } > > private: >- friend bool operator==(const SVGTransformValue&, const SVGTransformValue&); >+ void appendNumbers(StringBuilder& builder) const >+ { >+ builder.append(')'); >+ } >+ >+ template<typename Number, typename... Numbers> >+ void appendNumbers(StringBuilder& builder, Number number, Numbers... numbers) const >+ { >+ if (builder.length() && builder[builder.length() - 1] != '(') >+ builder.append(' '); >+ builder.appendNumber(number); >+ appendNumbers(builder, numbers...); >+ } >+ >+ void appendMatrix(StringBuilder& builder) const >+ { >+ appendNumbers(builder, m_matrix->a(), m_matrix->b(), m_matrix->c(), m_matrix->d(), m_matrix->e(), m_matrix->f()); >+ } >+ >+ void appendTranslate(StringBuilder& builder) const >+ { >+ appendNumbers(builder, m_matrix->e(), m_matrix->f()); >+ } >+ >+ void appendScale(StringBuilder& builder) const >+ { >+ appendNumbers(builder, m_matrix->value().xScale(), m_matrix->value().yScale()); >+ } >+ >+ void appendRotate(StringBuilder& builder) const >+ { >+ double angleInRad = deg2rad(m_angle); >+ double cosAngle = std::cos(angleInRad); >+ double sinAngle = std::sin(angleInRad); >+ >+ float cx = narrowPrecisionToFloat(cosAngle != 1 ? (m_matrix->e() * (1 - cosAngle) - m_matrix->f() * sinAngle) / (1 - cosAngle) / 2 : 0); >+ float cy = narrowPrecisionToFloat(cosAngle != 1 ? (m_matrix->e() * sinAngle / (1 - cosAngle) + m_matrix->f()) / 2 : 0); >+ >+ if (cx || cy) >+ appendNumbers(builder, m_angle, cx, cy); >+ else >+ appendNumbers(builder, m_angle); >+ } >+ >+ void appendSkewX(StringBuilder& builder) const >+ { >+ appendNumbers(builder, m_angle); >+ } >+ >+ void appendSkewY(StringBuilder& builder) const >+ { >+ appendNumbers(builder, m_angle); >+ } > > SVGTransformType m_type { SVG_TRANSFORM_UNKNOWN }; >+ Ref<SVGMatrix> m_matrix; > float m_angle { 0 }; >- FloatPoint m_center; >- AffineTransform m_matrix; >+ FloatPoint m_rotationCenter; > }; > >-inline bool operator==(const SVGTransformValue& a, const SVGTransformValue& b) >-{ >- return a.m_type == b.m_type && a.m_angle == b.m_angle && a.m_matrix == b.m_matrix; >-} >- >-inline bool operator!=(const SVGTransformValue& a, const SVGTransformValue& b) >-{ >- return !(a == b); >-} >- > } // namespace WebCore >diff --git a/Source/WebCore/svg/properties/SVGProperty.h b/Source/WebCore/svg/properties/SVGProperty.h >index 54b6457df4e..bdb7e913217 100644 >--- a/Source/WebCore/svg/properties/SVGProperty.h >+++ b/Source/WebCore/svg/properties/SVGProperty.h >@@ -1,5 +1,6 @@ > /* > * Copyright (C) Research In Motion Limited 2010. All rights reserved. >+ * Copyright (C) 2018 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 >@@ -19,22 +20,77 @@ > > #pragma once > >+#include "SVGPropertyOwner.h" >+#include "SVGPropertyTraits.h" > #include <wtf/RefCounted.h> > > namespace WebCore { > >-enum SVGPropertyRole { >- UndefinedRole, >- BaseValRole, >- AnimValRole >-}; >+class SVGElement; >+ >+enum class SVGPropertyAccess : uint8_t { ReadWrite, ReadOnly }; >+enum class SVGPropertyState : uint8_t { Clean, Dirty }; > > class SVGProperty : public RefCounted<SVGProperty> { > public: > virtual ~SVGProperty() = default; > >- virtual bool isReadOnly() const = 0; >- virtual void commitChange() = 0; >+ // Managing the relationship with the owner. >+ bool isAttached() const { return m_owner; } >+ void attach(SVGPropertyOwner* owner, SVGPropertyAccess access) >+ { >+ ASSERT(!m_owner); >+ ASSERT(m_state == SVGPropertyState::Clean); >+ m_owner = owner; >+ m_access = access; >+ } >+ void detach() >+ { >+ m_owner = nullptr; >+ m_access = SVGPropertyAccess::ReadWrite; >+ m_state = SVGPropertyState::Clean; >+ } >+ const SVGElement* contextElement() const >+ { >+ if (!m_owner) >+ return nullptr; >+ return m_owner->attributeContextElement(); >+ } >+ void commitChange() >+ { >+ if (!m_owner) >+ return; >+ m_owner->commitPropertyChange(this); >+ } >+ >+ // DOM access. >+ SVGPropertyAccess access() const { return m_access; } >+ bool isReadOnly() const { return m_access == SVGPropertyAccess::ReadOnly; } >+ >+ // Synchronizing the SVG attribute and its reflection here. >+ bool isDirty() const { return m_state == SVGPropertyState::Dirty; } >+ void setDirty() { m_state = SVGPropertyState::Dirty; } >+ std::optional<String> synchronize() >+ { >+ if (m_state == SVGPropertyState::Clean) >+ return std::nullopt; >+ m_state = SVGPropertyState::Clean; >+ return valueAsString(); >+ } >+ >+ // This is used when calling setAttribute(). >+ virtual String valueAsString() const { return emptyString(); } >+ >+protected: >+ SVGProperty(SVGPropertyOwner* owner = nullptr, SVGPropertyAccess access = SVGPropertyAccess::ReadWrite) >+ : m_owner(owner) >+ , m_access(access) >+ { >+ } >+ >+ SVGPropertyOwner* m_owner { nullptr }; >+ SVGPropertyAccess m_access { SVGPropertyAccess::ReadWrite }; >+ SVGPropertyState m_state { SVGPropertyState::Clean }; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/svg/properties/SVGPropertyOwner.h b/Source/WebCore/svg/properties/SVGPropertyOwner.h >new file mode 100644 >index 00000000000..db6f09df977 >--- /dev/null >+++ b/Source/WebCore/svg/properties/SVGPropertyOwner.h >@@ -0,0 +1,59 @@ >+/* >+ * 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 "QualifiedName.h" >+ >+namespace WebCore { >+ >+class SVGElement; >+class SVGProperty; >+ >+class SVGPropertyOwner { >+public: >+ virtual ~SVGPropertyOwner() = default; >+ >+ virtual SVGPropertyOwner* owner() const { return nullptr; } >+ >+ virtual const SVGElement* attributeContextElement() const >+ { >+ if (!owner()) >+ return nullptr; >+ return owner()->attributeContextElement(); >+ } >+ >+ virtual void commitPropertyChange(SVGProperty* property) >+ { >+ if (!owner()) >+ return; >+ owner()->commitPropertyChange(property); >+ } >+ >+protected: >+ SVGPropertyOwner() = default; >+}; >+ >+} >diff --git a/Source/WebCore/svg/properties/SVGValueProperty.h b/Source/WebCore/svg/properties/SVGValueProperty.h >new file mode 100644 >index 00000000000..57dc24d78e0 >--- /dev/null >+++ b/Source/WebCore/svg/properties/SVGValueProperty.h >@@ -0,0 +1,78 @@ >+/* >+ * 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 "SVGProperty.h" >+ >+namespace WebCore { >+ >+template<typename PropertyType> >+class SVGValueProperty : public SVGProperty { >+public: >+ using ValueType = PropertyType; >+ >+ static Ref<SVGValueProperty> create() >+ { >+ return adoptRef(*new SVGValueProperty()); >+ } >+ >+ // Getter/Setter for the value. >+ const PropertyType& value() const { return m_value; } >+ void setValue(const PropertyType& value) { m_value = value; } >+ >+ // Used the SVGAnimatedPropertyAnimator to pass m_value to SVGAnimationFunction. >+ PropertyType& value() { return m_value; } >+ >+protected: >+ // Create an initialized property, e.g creating an item to be appended in an SVGList. >+ SVGValueProperty(const PropertyType& value) >+ : m_value(value) >+ { >+ } >+ >+ // Needed when value should not be copied, e.g. SVGTransfromValue. >+ SVGValueProperty(PropertyType&& value) >+ : m_value(WTFMove(value)) >+ { >+ } >+ >+ // Base and default constructor. Do not use "using SVGProperty::SVGProperty" because of Windows and GTK ports. >+ SVGValueProperty(SVGPropertyOwner* owner = nullptr, SVGPropertyAccess access = SVGPropertyAccess::ReadWrite) >+ : SVGProperty(owner, access) >+ { >+ } >+ >+ // Create an initialized and attached property. >+ SVGValueProperty(SVGPropertyOwner* owner, SVGPropertyAccess access, const PropertyType& value) >+ : SVGProperty(owner, access) >+ , m_value(value) >+ { >+ } >+ >+ PropertyType m_value; >+}; >+ >+}
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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 191237
:
353808
|
353812
|
353815
|
353817
|
353818
|
353820
|
353824
|
353825
|
355382
|
355386
|
355388
|
355393
|
355568
|
355574
|
355575
|
355577
|
355580
|
355582
|
355585
|
355666
|
355672
|
355693
|
355699
|
355711
|
355752
|
355777
|
355820
|
356333
|
356334
|
356338
|
356340
|
356342
|
356344
|
356346
|
356351
|
356352
|
356358
|
356360
|
356380
|
356497
|
356500
|
356507
|
356579
|
356607
|
356728
|
356729
|
356730
|
356731
|
356732
|
356733
|
356752
|
356810
|
356811
|
356879
|
356880
|
356881
|
356882
|
356883
|
356884
|
356885
|
356887
|
356888
|
356889
|
356892
|
356895
|
356896
|
359721
|
359735
|
359747
|
363581
|
363595
|
363613
|
363690
|
364172
|
364180
|
366512
|
366557
|
366636