WebKit Bugzilla
Attachment 346103 Details for
Bug 186751
: Remove the SVG elements' attributes macros
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Introduce SVGAttributeAccessor
186751-2.patch (text/plain), 14.81 KB, created by
Said Abou-Hallawa
on 2018-07-30 14:42:27 PDT
(
hide
)
Description:
Introduce SVGAttributeAccessor
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-07-30 14:42:27 PDT
Size:
14.81 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 7c341b95760..0a6c87af7c8 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,48 @@ >+2018-07-30 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ [2] Remove the SVG elements' attributes macros >+ https://bugs.webkit.org/show_bug.cgi?id=186751 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ This patch introduces SVGAttributeAccessor which is the base class of a >+ set of classes. These classes are the accessors of all the SVG attributes >+ inside an owner object. This owner is not necessarily a super class of >+ SVGElement. The purpose of these accessors is to be able to deal with all >+ the attributes uniformly. For example, all the attributes of any super >+ class of SVGElement can be synchronized by looping through the accessors >+ of this element. >+ >+ -- SVGAttributeAccessor: It acts as the interface of all the accessors for >+ a given owner. >+ >+ -- SVGPropertyAttributeAccessor: It is a template class which represents >+ an accessor of non animate-able attribute, e.g. requiredFeatures of SVGTests. >+ It needs to know the type of the owner and the type of the attribute. >+ >+ -- SVGAnimatedAttributeAccessor: Derived from SVGPropertyAttributeAccessor. >+ In following patches new methods will be added to create the TearOff object >+ of the underlying attribute. >+ >+ -- SVGAnimatedPairAttributeAccessor: Derived from SVGAnimatedAttributeAccessor. >+ It is an accessor to an optional attribute, e.g. 'stdDeviation' of >+ SVGFEGaussianBlurElement and 'orientAngle' and 'orientType' of SVGMarkerElement. >+ The TearOff objects creation methods will be added later. >+ >+ * WebCore.xcodeproj/project.pbxproj: >+ * svg/properties/SVGAttributeAccessor.h: Added. >+ (WebCore::SVGAttributeAccessor::SVGAttributeAccessor): >+ (WebCore::SVGAttributeAccessor::attributeName const): >+ (WebCore::SVGAttributeAccessor::animatedType const): >+ (WebCore::SVGAttributeAccessor::animatedTypes const): >+ (WebCore::SVGPropertyAttributeAccessor::singleton): >+ (WebCore::SVGPropertyAttributeAccessor::SVGPropertyAttributeAccessor): >+ (WebCore::SVGPropertyAttributeAccessor::attribute const): >+ (WebCore::SVGAnimatedAttributeAccessor::singleton): >+ (WebCore::SVGAnimatedAttributeAccessor::SVGAnimatedAttributeAccessor): >+ (WebCore::SVGAnimatedPairAttributeAccessor::SVGAnimatedPairAttributeAccessor): >+ (WebCore::SVGAnimatedPairAttributeAccessor::secondAttribute const): >+ > 2018-07-30 Said Abou-Hallawa <sabouhallawa@apple.com> > > [1] Remove the SVG elements' attributes macros >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index d31e5d3f170..2f680ed4647 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1722,6 +1722,7 @@ > 55AF14E61EAAC59B0026EEAA /* UTIRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 55AF14E41EAAC59B0026EEAA /* UTIRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 55EC9599206AA7A0007DD0A9 /* PaintFrequencyTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 55EC95972069C92D007DD0A9 /* PaintFrequencyTracker.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 55FA7FF0210FA386005AEFE7 /* SVGAttribute.h in Headers */ = {isa = PBXBuildFile; fileRef = 55FA7FEF210FA386005AEFE7 /* SVGAttribute.h */; settings = {ATTRIBUTES = (Private, ); }; }; >+ 55FA7FF5210FB6B1005AEFE7 /* SVGAttributeAccessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 55FA7FF4210FB688005AEFE7 /* SVGAttributeAccessor.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 */; }; >@@ -8397,6 +8398,7 @@ > 55D408F71A7C631800C78450 /* SVGImageClients.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGImageClients.h; sourceTree = "<group>"; }; > 55EC95972069C92D007DD0A9 /* PaintFrequencyTracker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaintFrequencyTracker.h; sourceTree = "<group>"; }; > 55FA7FEF210FA386005AEFE7 /* SVGAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SVGAttribute.h; sourceTree = "<group>"; }; >+ 55FA7FF4210FB688005AEFE7 /* SVGAttributeAccessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAttributeAccessor.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>"; }; >@@ -15457,6 +15459,7 @@ > 08525E621278C00100A84778 /* SVGAnimatedStaticPropertyTearOff.h */, > 085A15921289A8DD002710E3 /* SVGAnimatedTransformListPropertyTearOff.h */, > 55FA7FEF210FA386005AEFE7 /* SVGAttribute.h */, >+ 55FA7FF4210FB688005AEFE7 /* SVGAttributeAccessor.h */, > 08FB17C013BC7E9100040086 /* SVGAttributeToPropertyMap.cpp */, > 08FB3F8313BC754C0099FC18 /* SVGAttributeToPropertyMap.h */, > 0810764312828556007C63BA /* SVGListProperty.h */, >@@ -29502,6 +29505,7 @@ > 07D6A4F41BED5F8800174146 /* MockRealtimeAudioSource.h in Headers */, > 07D6A4F01BECF2D200174146 /* MockRealtimeMediaSource.h in Headers */, > 4A0FFA9E1AAF5E7E0062803B /* MockRealtimeMediaSourceCenter.h in Headers */, >+ 55FA7FF5210FB6B1005AEFE7 /* SVGAttributeAccessor.h in Headers */, > 07EE76EC1BE96DB000F89133 /* MockRealtimeVideoSource.h in Headers */, > 07EE76EF1BEA619800F89133 /* MockRealtimeVideoSourceMac.h in Headers */, > CDF2B0171820540700F2B424 /* MockSourceBufferPrivate.h in Headers */, >diff --git a/Source/WebCore/svg/properties/SVGAttributeAccessor.h b/Source/WebCore/svg/properties/SVGAttributeAccessor.h >index 8b137891791..0e482e4f717 100644 >--- a/Source/WebCore/svg/properties/SVGAttributeAccessor.h >+++ b/Source/WebCore/svg/properties/SVGAttributeAccessor.h >@@ -1 +1,186 @@ >+/* >+ * 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 "Element.h" >+#include "QualifiedName.h" >+#include "SVGAnimatedPropertyType.h" >+#include "SVGAttribute.h" >+#include "SVGLengthValue.h" >+#include "SVGNames.h" >+#include "SVGPropertyTraits.h" >+ >+namespace WebCore { >+ >+class SVGElement; >+ >+struct SVGAttribute; >+ >+template<typename OwnerType> >+class SVGAttributeAccessor { >+ WTF_MAKE_FAST_ALLOCATED; >+public: >+ SVGAttributeAccessor(const QualifiedName& attributeName) >+ : m_attributeName(attributeName) >+ { >+ } >+ >+ const QualifiedName& attributeName() const { return m_attributeName; } >+ >+ virtual ~SVGAttributeAccessor() = default; >+ virtual bool isMatched(const OwnerType&, const SVGAttribute&) const = 0; >+ virtual void synchronizeProperty(OwnerType&, Element&) const = 0; >+ >+ virtual AnimatedPropertyType animatedType() const { return AnimatedUnknown; } >+ virtual Vector<AnimatedPropertyType> animatedTypes() const { return { animatedType() }; } >+ >+protected: >+ const QualifiedName& m_attributeName; >+}; >+ >+template<typename OwnerType, typename AttributeType> >+class SVGPropertyAttributeAccessor : public SVGAttributeAccessor<OwnerType> { >+ using Base = SVGAttributeAccessor<OwnerType>; >+ using Base::m_attributeName; >+ >+public: >+ template<const LazyNeverDestroyed<const QualifiedName>& attributeName, AttributeType OwnerType::*attribute> >+ static SVGAttributeAccessor<OwnerType>& singleton() >+ { >+ static NeverDestroyed<SVGPropertyAttributeAccessor> attributeAccessor { attributeName, attributeName->localName(), attribute }; >+ return attributeAccessor; >+ } >+ >+ SVGPropertyAttributeAccessor(const QualifiedName& attributeName, const AtomicString& identifier, AttributeType OwnerType::*attribute) >+ : Base(attributeName) >+ , m_identifier(identifier) >+ , m_attribute(attribute) >+ { >+ } >+ >+protected: >+ auto& attribute(OwnerType& owner) const { return owner.*m_attribute; } >+ const auto& attribute(const OwnerType& owner) const { return owner.*m_attribute; } >+ >+ bool isMatched(const OwnerType& owner, const SVGAttribute& attribute) const override >+ { >+ return &this->attribute(owner) == &attribute; >+ } >+ >+ void synchronizeProperty(OwnerType& owner, Element& element) const override >+ { >+ attribute(owner).synchronize(element, m_attributeName); >+ } >+ >+ const AtomicString& m_identifier; >+ AttributeType OwnerType::*m_attribute; >+}; >+ >+template<typename OwnerType, typename AnimatedAttributeType, AnimatedPropertyType type> >+class SVGAnimatedAttributeAccessor : public SVGPropertyAttributeAccessor<OwnerType, AnimatedAttributeType> { >+ using PropertyTearOffType = typename AnimatedAttributeType::PropertyTearOffType; >+ using PropertyType = typename AnimatedAttributeType::PropertyType; >+ using Base = SVGPropertyAttributeAccessor<OwnerType, AnimatedAttributeType>; >+ using Base::attribute; >+ using Base::isMatched; >+ using Base::m_attributeName; >+ using Base::m_identifier; >+ >+public: >+ template<const LazyNeverDestroyed<const QualifiedName>& attributeName, AnimatedAttributeType OwnerType::*attribute> >+ static SVGAttributeAccessor<OwnerType>& singleton() >+ { >+ static NeverDestroyed<SVGAnimatedAttributeAccessor> attributeAccessor { attributeName, attributeName->localName(), attribute }; >+ return attributeAccessor; >+ } >+ >+ template<const LazyNeverDestroyed<const QualifiedName>& attributeName, const AtomicString& (*identifier)(), AnimatedAttributeType OwnerType::*attribute> >+ static SVGAttributeAccessor<OwnerType>& singleton() >+ { >+ static NeverDestroyed<SVGAnimatedAttributeAccessor> attributeAccessor { attributeName, identifier(), attribute }; >+ return attributeAccessor; >+ } >+ >+ SVGAnimatedAttributeAccessor(const QualifiedName& attributeName, const AtomicString& identifier, AnimatedAttributeType OwnerType::*attribute) >+ : Base(attributeName, identifier, attribute) >+ { >+ } >+}; >+ >+template<typename OwnerType, typename AnimatedAttributeType, AnimatedPropertyType type, typename SecondAnimatedAttributeType, AnimatedPropertyType secondType> >+class SVGAnimatedPairAttributeAccessor : public SVGAnimatedAttributeAccessor<OwnerType, AnimatedAttributeType, type> { >+ using PropertyTearOffType = typename AnimatedAttributeType::PropertyTearOffType; >+ using SecondPropertyTearOffType = typename SecondAnimatedAttributeType::PropertyTearOffType; >+ using SecondPropertyType = typename SecondAnimatedAttributeType::PropertyType; >+ using Base = SVGAnimatedAttributeAccessor<OwnerType, AnimatedAttributeType, type>; >+ using Base::attribute; >+ using Base::m_attributeName; >+ using Base::m_identifier; >+ >+public: >+ template< >+ const LazyNeverDestroyed<const QualifiedName>& attributeName, >+ const AtomicString& (*identifier)(), AnimatedAttributeType OwnerType::*attribute, >+ const AtomicString& (*secondIdentifier)(), SecondAnimatedAttributeType OwnerType::*secondAttribute >+ > >+ static SVGAttributeAccessor<OwnerType>& singleton() >+ { >+ static NeverDestroyed<SVGAnimatedPairAttributeAccessor> attributeAccessor { attributeName, identifier(), attribute, secondIdentifier(), secondAttribute }; >+ return attributeAccessor; >+ } >+ >+ SVGAnimatedPairAttributeAccessor(const QualifiedName& attributeName, const AtomicString& identifier, AnimatedAttributeType OwnerType::*attribute, const AtomicString& secondIdentifier, SecondAnimatedAttributeType OwnerType::*secondAttribute) >+ : Base(attributeName, identifier, attribute) >+ , m_secondIdentifier(secondIdentifier) >+ , m_secondAttribute(secondAttribute) >+ { >+ } >+ >+private: >+ auto& secondAttribute(OwnerType& owner) const { return owner.*m_secondAttribute; } >+ const auto& secondAttribute(const OwnerType& owner) const { return owner.*m_secondAttribute; } >+ >+ bool isMatched(const OwnerType& owner, const SVGAttribute& attribute) const override >+ { >+ return Base::isMatched(owner, attribute) || &secondAttribute(owner) == &attribute; >+ } >+ >+ void synchronizeProperty(OwnerType& owner, Element& element) const override >+ { >+ attribute(owner).synchronize(element, m_attributeName); >+ secondAttribute(owner).synchronize(element, m_attributeName); >+ } >+ >+ Vector<AnimatedPropertyType> animatedTypes() const override { return { type, secondType }; } >+ >+ const AtomicString& m_secondIdentifier; >+ SecondAnimatedAttributeType OwnerType::*m_secondAttribute; >+}; >+ >+template<typename OwnerType, typename AnimatedAttributeType, AnimatedPropertyType type> >+using SVGAnimatedOptionalAttributeAccessor = SVGAnimatedPairAttributeAccessor<OwnerType, AnimatedAttributeType, type, AnimatedAttributeType, type>; >+ >+} // 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
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 186751
:
342916
|
342917
|
342985
|
343001
|
343114
|
343123
|
343124
|
343127
|
343129
|
343162
|
343167
|
343169
|
343171
|
343174
|
343213
|
343217
|
343327
|
343335
|
343338
|
343339
|
343343
|
343415
|
343979
|
343989
|
344002
|
344513
|
344516
|
344523
|
344534
|
344536
|
344988
|
344990
|
346097
|
346103
|
346124
|
346129
|
346177
|
346179
|
346180
|
346182
|
346185
|
346188
|
346190
|
346192
|
346193
|
346197
|
346199
|
346201
|
346202
|
346203
|
346204
|
346205
|
346206
|
346207
|
346211
|
346212
|
346217
|
346224
|
346230
|
346233
|
346241
|
346244
|
346245
|
346315
|
346316
|
346317
|
346318
|
346319
|
346320
|
346322
|
346323
|
346324
|
346325
|
346326
|
346327
|
346328
|
346329
|
346330
|
346331
|
346332
|
346333
|
346334
|
346335
|
346336
|
346337
|
346338
|
346339
|
346340
|
346341
|
346342
|
346343
|
346344
|
346345
|
346346
|
346347
|
346348
|
346349
|
346350
|
346518
|
346519
|
346520
|
346521
|
346522
|
346524
|
346525
|
346526
|
346527
|
346528
|
346529
|
346530
|
346531
|
346532
|
346533
|
346534
|
346535
|
346536
|
346537
|
346538
|
346539
|
346540
|
346541
|
346545
|
346546
|
346549
|
346551
|
346552
|
346601
|
346602
|
346611
|
346636
|
346642