WebKit Bugzilla
Attachment 346177 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]
Add TearOff creation methods
186751-5.patch (text/plain), 17.45 KB, created by
Said Abou-Hallawa
on 2018-07-31 10:41:45 PDT
(
hide
)
Description:
Add TearOff creation methods
Filename:
MIME Type:
Creator:
Said Abou-Hallawa
Created:
2018-07-31 10:41:45 PDT
Size:
17.45 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index f46ea85367a..53dac9edb7c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,36 @@ >+2018-07-31 Said Abou-Hallawa <sabouhallawa@apple.com> >+ >+ [5] Remove the SVG elements' attributes macros >+ https://bugs.webkit.org/show_bug.cgi?id=186751 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Add the TearOff creation methods to the SVGAttributeAccessor and add the >+ necessary wrappers to SVGAttributeRegistry and SVGAttributeOwnerProxy. >+ >+ SVGAttribute can create its TearOff object through SVGAttributeOwnerProxy. >+ Its currentValue() can be either currentAnimatedValue() of the TearOff >+ object or its base value(). >+ >+ * svg/properties/SVGAttribute.h: >+ (WebCore::SVGAnimatedAttribute::currentValue const): >+ (WebCore::SVGAnimatedAttribute::animatedProperty): >+ (WebCore::SVGAnimatedAttributeList::detachAnimatedListWrappers): >+ * svg/properties/SVGAttributeAccessor.h: >+ (WebCore::SVGAttributeAccessor::lookupOrCreateAnimatedProperty const): >+ (WebCore::SVGAttributeAccessor::lookupAnimatedProperty const): >+ (WebCore::SVGAttributeAccessor::lookupOrCreateAnimatedProperties const): >+ (WebCore::SVGAnimatedAttributeAccessor::lookupOrCreateAnimatedProperty): >+ (WebCore::SVGAnimatedAttributeAccessor::lookupAnimatedProperty): >+ * svg/properties/SVGAttributeOwnerProxy.h: >+ * svg/properties/SVGAttributeRegistry.h: >+ (WebCore::SVGAttributeRegistry::lookupOrCreateAnimatedProperty const): >+ (WebCore::SVGAttributeRegistry::lookupAnimatedProperty const): >+ (WebCore::SVGAttributeRegistry::lookupOrCreateAnimatedProperties const): >+ (WebCore::SVGAttributeRegistry::lookupOrCreateAnimatedPropertyBaseTypes): >+ (WebCore::SVGAttributeRegistry::lookupAnimatedPropertyBaseTypes): >+ (WebCore::SVGAttributeRegistry::lookupOrCreateAnimatedPropertiesBaseTypes): >+ > 2018-07-30 Said Abou-Hallawa <sabouhallawa@apple.com> > > [4] Remove the SVG elements' attributes macros >diff --git a/Source/WebCore/svg/properties/SVGAttribute.h b/Source/WebCore/svg/properties/SVGAttribute.h >index 31ca1972a09..b0670c8d12f 100644 >--- a/Source/WebCore/svg/properties/SVGAttribute.h >+++ b/Source/WebCore/svg/properties/SVGAttribute.h >@@ -93,6 +93,24 @@ public: > : Base(attributeOwnerProxy, std::forward<Arguments>(arguments)...) > { > } >+ >+ const PropertyType& currentValue() const >+ { >+ if (auto wrapper = m_attributeOwnerProxy.lookupAnimatedProperty(*this)) { >+ if (wrapper->isAnimating()) >+ return static_pointer_cast<PropertyTearOffType>(wrapper)->currentAnimatedValue(); >+ } >+ return m_property; >+ } >+ >+ RefPtr<PropertyTearOffType> animatedProperty() >+ { >+ m_shouldSynchronize = true; >+ if (auto wrapper = m_attributeOwnerProxy.lookupOrCreateAnimatedProperty(*this)) >+ return static_pointer_cast<PropertyTearOffType>(wrapper); >+ RELEASE_ASSERT_NOT_REACHED(); >+ return nullptr; >+ } > }; > > template<typename TearOffType> >@@ -112,6 +130,12 @@ public: > : Base(attributeOwnerProxy, std::forward<Arguments>(arguments)...) > { > } >+ >+ void detachAnimatedListWrappers(unsigned newListSize) >+ { >+ if (auto wrapper = m_attributeOwnerProxy.lookupAnimatedProperty(*this)) >+ static_pointer_cast<PropertyTearOffType>(wrapper)->detachListWrappers(newListSize); >+ } > }; > > } >diff --git a/Source/WebCore/svg/properties/SVGAttributeAccessor.h b/Source/WebCore/svg/properties/SVGAttributeAccessor.h >index aa3795a7b29..6fe63220fd0 100644 >--- a/Source/WebCore/svg/properties/SVGAttributeAccessor.h >+++ b/Source/WebCore/svg/properties/SVGAttributeAccessor.h >@@ -27,6 +27,7 @@ > > #include "Element.h" > #include "QualifiedName.h" >+#include "SVGAnimatedProperty.h" > #include "SVGAnimatedPropertyType.h" > #include "SVGAttribute.h" > #include "SVGLengthValue.h" >@@ -57,6 +58,10 @@ public: > virtual AnimatedPropertyType animatedType() const { return AnimatedUnknown; } > virtual Vector<AnimatedPropertyType> animatedTypes() const { return { animatedType() }; } > >+ virtual RefPtr<SVGAnimatedProperty> lookupOrCreateAnimatedProperty(OwnerType&, SVGElement&, const SVGAttribute&, AnimatedPropertyState) const { return nullptr; }; >+ virtual RefPtr<SVGAnimatedProperty> lookupAnimatedProperty(const OwnerType&, const SVGElement&, const SVGAttribute&) const { return nullptr; }; >+ virtual Vector<RefPtr<SVGAnimatedProperty>> lookupOrCreateAnimatedProperties(OwnerType&, SVGElement&, AnimatedPropertyState) const { return { }; } >+ > protected: > const QualifiedName m_attributeName; > }; >@@ -128,6 +133,36 @@ public: > : Base(attributeName, identifier, attribute) > { > } >+ >+protected: >+ template<typename PropertyTearOff = PropertyTearOffType, typename Property = PropertyType, AnimatedPropertyType animatedType = type> >+ static RefPtr<SVGAnimatedProperty> lookupOrCreateAnimatedProperty(SVGElement& element, const QualifiedName& attributeName, const AtomicString& identifier, Property& property, AnimatedPropertyState animatedState) >+ { >+ return SVGAnimatedProperty::lookupOrCreateAnimatedProperty<PropertyTearOff, Property, animatedType>(element, attributeName, identifier, property, animatedState); >+ } >+ >+ static RefPtr<SVGAnimatedProperty> lookupAnimatedProperty(const SVGElement& element, const AtomicString& identifier) >+ { >+ return SVGAnimatedProperty::lookupAnimatedProperty(element, identifier); >+ } >+ >+ AnimatedPropertyType animatedType() const override { return type; } >+ >+ RefPtr<SVGAnimatedProperty> lookupOrCreateAnimatedProperty(OwnerType& owner, SVGElement& element, const SVGAttribute& attribute, AnimatedPropertyState animatedState) const override >+ { >+ ASSERT_UNUSED(attribute, isMatched(owner, attribute)); >+ return lookupOrCreateAnimatedProperty(element, m_attributeName, m_identifier, this->attribute(owner).value(), animatedState); >+ } >+ >+ RefPtr<SVGAnimatedProperty> lookupAnimatedProperty(const OwnerType&, const SVGElement& element, const SVGAttribute&) const override >+ { >+ return lookupAnimatedProperty(element, m_identifier); >+ } >+ >+ Vector<RefPtr<SVGAnimatedProperty>> lookupOrCreateAnimatedProperties(OwnerType& owner, SVGElement& element, AnimatedPropertyState animatedState) const override >+ { >+ return { lookupOrCreateAnimatedProperty(element, m_attributeName, m_identifier, attribute(owner).value(), animatedState) }; >+ } > }; > > template<typename OwnerType, typename AnimatedAttributeType, AnimatedPropertyType type, typename SecondAnimatedAttributeType, AnimatedPropertyType secondType> >@@ -176,6 +211,30 @@ private: > > Vector<AnimatedPropertyType> animatedTypes() const override { return { type, secondType }; } > >+ RefPtr<SVGAnimatedProperty> lookupOrCreateAnimatedProperty(OwnerType& owner, SVGElement& element, const SVGAttribute& attribute, AnimatedPropertyState animatedState) const override >+ { >+ if (Base::isMatched(owner, attribute)) >+ return lookupOrCreateAnimatedProperty(element, m_attributeName, m_identifier, this->attribute(owner).value(), animatedState); >+ ASSERT(&secondAttribute(owner) == &attribute); >+ return Base::template lookupOrCreateAnimatedProperty<SecondPropertyTearOffType, SecondPropertyType, secondType>(element, m_attributeName, m_secondIdentifier, secondAttribute(owner).value(), animatedState); >+ } >+ >+ RefPtr<SVGAnimatedProperty> lookupAnimatedProperty(const OwnerType& owner, const SVGElement& element, const SVGAttribute& attribute) const override >+ { >+ if (Base::isMatched(owner, attribute)) >+ return lookupAnimatedProperty(element, m_identifier); >+ ASSERT(&secondAttribute(owner) == &attribute); >+ return lookupAnimatedProperty(element, m_secondIdentifier); >+ } >+ >+ Vector<RefPtr<SVGAnimatedProperty>> lookupOrCreateAnimatedProperties(OwnerType& owner, SVGElement& element, AnimatedPropertyState animatedState) const override >+ { >+ return { >+ lookupOrCreateAnimatedProperty(element, m_attributeName, m_identifier, attribute(owner).value(), animatedState), >+ Base::template lookupOrCreateAnimatedProperty<SecondPropertyTearOffType, SecondPropertyType, secondType>(element, m_attributeName, m_secondIdentifier, secondAttribute(owner).value(), animatedState) >+ }; >+ } >+ > const AtomicString& m_secondIdentifier; > SecondAnimatedAttributeType OwnerType::*m_secondAttribute; > }; >diff --git a/Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h b/Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h >index 727b8e82614..8b357e3d695 100644 >--- a/Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h >+++ b/Source/WebCore/svg/properties/SVGAttributeOwnerProxy.h >@@ -43,6 +43,10 @@ public: > > virtual Vector<AnimatedPropertyType> animatedTypes(const QualifiedName&) const = 0; > >+ virtual RefPtr<SVGAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute&) const = 0; >+ virtual RefPtr<SVGAnimatedProperty> lookupAnimatedProperty(const SVGAttribute&) const = 0; >+ virtual Vector<RefPtr<SVGAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName&) const = 0; >+ > protected: > SVGElement& m_element; > }; >@@ -93,6 +97,21 @@ private: > return attributeRegistry().animatedTypes(attributeName); > } > >+ RefPtr<SVGAnimatedProperty> lookupOrCreateAnimatedProperty(const SVGAttribute& attribute) const override >+ { >+ return attributeRegistry().lookupOrCreateAnimatedProperty(m_owner, m_element, attribute, m_animatedState); >+ } >+ >+ RefPtr<SVGAnimatedProperty> lookupAnimatedProperty(const SVGAttribute& attribute) const override >+ { >+ return attributeRegistry().lookupAnimatedProperty(m_owner, m_element, attribute); >+ } >+ >+ Vector<RefPtr<SVGAnimatedProperty>> lookupOrCreateAnimatedProperties(const QualifiedName& attributeName) const override >+ { >+ return attributeRegistry().lookupOrCreateAnimatedProperties(m_owner, m_element, attributeName, m_animatedState); >+ } >+ > OwnerType& m_owner; > AnimatedPropertyState m_animatedState { PropertyIsReadWrite }; > }; >diff --git a/Source/WebCore/svg/properties/SVGAttributeRegistry.h b/Source/WebCore/svg/properties/SVGAttributeRegistry.h >index 33e31735d39..30ec0652b9e 100644 >--- a/Source/WebCore/svg/properties/SVGAttributeRegistry.h >+++ b/Source/WebCore/svg/properties/SVGAttributeRegistry.h >@@ -50,8 +50,10 @@ public: > > Vector<AnimatedPropertyType> animatedTypes(const QualifiedName& attributeName) const > { >+ // If this registry has an accessor for attributeName, return animatedTypes() of this accessor. > if (const auto* attributeAccessor = findAttributeAccessor(attributeName)) > return attributeAccessor->animatedTypes(); >+ // Otherwise loop through BaeTypes and see if any of them knows attributeName. > return animatedTypesBaseTypes(attributeName); > } > >@@ -59,7 +61,7 @@ public: > { > for (auto* attributeAccessor : m_map.values()) > attributeAccessor->synchronizeProperty(owner, element); >- synchronizeAttributesBaseTypes(owner, element); >+ synchronizeAttributesBaseTypes(owner, element); > } > > bool synchronizeAttribute(OwnerType& owner, SVGElement& element, const QualifiedName& attributeName) const >@@ -71,22 +73,52 @@ public: > return synchronizeAttributeBaseTypes(owner, element, attributeName); > } > >+ RefPtr<SVGAnimatedProperty> lookupOrCreateAnimatedProperty(OwnerType& owner, SVGElement& element, const SVGAttribute& attribute, AnimatedPropertyState animatedState) const >+ { >+ if (const auto* attributeAccessor = findAttributeAccessor(owner, attribute)) >+ return attributeAccessor->lookupOrCreateAnimatedProperty(owner, element, attribute, animatedState); >+ return lookupOrCreateAnimatedPropertyBaseTypes(owner, element, attribute, animatedState); >+ } >+ >+ RefPtr<SVGAnimatedProperty> lookupAnimatedProperty(const OwnerType& owner, const SVGElement& element, const SVGAttribute& attribute) const >+ { >+ if (const auto* attributeAccessor = findAttributeAccessor(owner, attribute)) >+ return attributeAccessor->lookupAnimatedProperty(owner, element, attribute); >+ return lookupAnimatedPropertyBaseTypes(owner, element, attribute); >+ } >+ >+ Vector<RefPtr<SVGAnimatedProperty>> lookupOrCreateAnimatedProperties(OwnerType& owner, SVGElement& element, const QualifiedName& attributeName, AnimatedPropertyState animatedState) const >+ { >+ if (const auto* attributeAccessor = findAttributeAccessor(attributeName)) >+ return attributeAccessor->lookupOrCreateAnimatedProperties(owner, element, animatedState); >+ return lookupOrCreateAnimatedPropertiesBaseTypes(owner, element, attributeName, animatedState); >+ } >+ > void registerAttribute(const SVGAttributeAccessor<OwnerType>& attributeAccessor) > { > m_map.add(attributeAccessor.attributeName(), &attributeAccessor); > } > > private: >+ // It is a template function with parameter 'I' whose default value = 0. So you can call it without any parameter from animatedTypes(). >+ // It returns Vector<AnimatedPropertyType> and is enable_if<I == sizeof...(BaseTypes)>. So it is mainly for breaking the recursion. If >+ // it is called this means no attribute was found in this registry for this QualifiedName. So return empty Vector<AnimatedPropertyType>. > template<size_t I = 0> > static typename std::enable_if<I == sizeof...(BaseTypes), Vector<AnimatedPropertyType>>::type animatedTypesBaseTypes(const QualifiedName&) { return { }; } > >+ // This version of animatedTypesBaseTypes() is enable_if<I < sizeof...(BaseTypes)>. > template<size_t I = 0> > static typename std::enable_if<I < sizeof...(BaseTypes), Vector<AnimatedPropertyType>>::type animatedTypesBaseTypes(const QualifiedName& attributeName) > { >+ // Get the base type at index 'I' using std::tuple and std::tuple_element. > using BaseType = typename std::tuple_element<I, typename std::tuple<BaseTypes...>>::type; >+ >+ // Get the SVGAttributeRegistry of BaseType. If it knows attributeName break the recursion. > auto animatedTypes = BaseType::attributeRegistry().animatedTypes(attributeName); > if (!animatedTypes.isEmpty()) > return animatedTypes; >+ >+ // SVGAttributeRegistry of BaseType does not know attributeName. Recurse to the next BaseType. > return animatedTypesBaseTypes<I + 1>(attributeName); > } > >@@ -113,6 +145,43 @@ private: > return synchronizeAttributeBaseTypes<I + 1>(owner, element, attributeName); > } > >+ template<size_t I = 0> >+ static typename std::enable_if<I == sizeof...(BaseTypes), RefPtr<SVGAnimatedProperty>>::type lookupOrCreateAnimatedPropertyBaseTypes(OwnerType&, SVGElement&, const SVGAttribute&, AnimatedPropertyState) { return nullptr; } >+ >+ template<size_t I = 0> >+ static typename std::enable_if<I < sizeof...(BaseTypes), RefPtr<SVGAnimatedProperty>>::type lookupOrCreateAnimatedPropertyBaseTypes(OwnerType& owner, SVGElement& element, const SVGAttribute& attribute, AnimatedPropertyState animatedState) >+ { >+ using BaseType = typename std::tuple_element<I, typename std::tuple<BaseTypes...>>::type; >+ if (auto animatedProperty = BaseType::attributeRegistry().lookupOrCreateAnimatedProperty(owner, element, attribute, animatedState)) >+ return animatedProperty; >+ return lookupOrCreateAnimatedPropertyBaseTypes<I + 1>(owner, element, attribute, animatedState); >+ } >+ >+ template<size_t I = 0> >+ static typename std::enable_if<I == sizeof...(BaseTypes), RefPtr<SVGAnimatedProperty>>::type lookupAnimatedPropertyBaseTypes(const OwnerType&, const SVGElement&, const SVGAttribute&) { return nullptr; } >+ >+ template<size_t I = 0> >+ static typename std::enable_if<I < sizeof...(BaseTypes), RefPtr<SVGAnimatedProperty>>::type lookupAnimatedPropertyBaseTypes(const OwnerType& owner, const SVGElement& element, const SVGAttribute& attribute) >+ { >+ using BaseType = typename std::tuple_element<I, typename std::tuple<BaseTypes...>>::type; >+ if (auto animatedProperty = BaseType::attributeRegistry().lookupAnimatedProperty(owner, element, attribute)) >+ return animatedProperty; >+ return lookupAnimatedPropertyBaseTypes<I + 1>(owner, element, attribute); >+ } >+ >+ template<size_t I = 0> >+ static typename std::enable_if<I == sizeof...(BaseTypes), Vector<RefPtr<SVGAnimatedProperty>>>::type lookupOrCreateAnimatedPropertiesBaseTypes(OwnerType&, SVGElement&, const QualifiedName&, AnimatedPropertyState) { return { }; } >+ >+ template<size_t I = 0> >+ static typename std::enable_if<I < sizeof...(BaseTypes), Vector<RefPtr<SVGAnimatedProperty>>>::type lookupOrCreateAnimatedPropertiesBaseTypes(OwnerType& owner, SVGElement& element, const QualifiedName& attributeName, AnimatedPropertyState animatedState) >+ { >+ using BaseType = typename std::tuple_element<I, typename std::tuple<BaseTypes...>>::type; >+ auto animatedProperties = BaseType::attributeRegistry().lookupOrCreateAnimatedProperties(owner, element, attributeName, animatedState); >+ if (!animatedProperties.isEmpty()) >+ return animatedProperties; >+ return lookupOrCreateAnimatedPropertiesBaseTypes<I + 1>(owner, element, attributeName, animatedState); >+ } >+ > const SVGAttributeAccessor<OwnerType>* findAttributeAccessor(const OwnerType& owner, const SVGAttribute& attribute) const > { > for (auto* attributeAccessor : m_map.values()) {
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