Title: [91748] trunk/Source/WebCore
Revision
91748
Author
[email protected]
Date
2011-07-26 03:05:10 -0700 (Tue, 26 Jul 2011)

Log Message

2011-07-26  Nikolas Zimmermann  <[email protected]>

        Prepare animVal support - phase 2
        https://bugs.webkit.org/show_bug.cgi?id=65167

        Reviewed by Dirk Schulze.

        Next patch preparing animVal support. Modify the SVGAnimatedProperty* classes & macros to assure that calling someElement->someProperty()
        will return the animVal, when the property is being animated. Not yet hooked into SVGAnimateElement, this is just a preparation.

        Doesn't affect any tests, yet.

        * svg/SVGPathElement.cpp: Adapt to SVGAnimatedProperty::lookupWrapper changes (new template parameters have been added).
        (WebCore::SVGPathElement::svgAttributeChanged):
        * svg/SVGPathSegWithContext.h: Ditto.
        (WebCore::SVGPathSegWithContext::animatedProperty):
        * svg/SVGPolyElement.cpp: Ditto.
        (WebCore::SVGPolyElement::parseMappedAttribute):
        * svg/properties/SVGAnimatedEnumerationPropertyTearOff.h: Implement currentAnimatedValue, an abstract way to retrieve the underlying animated value for any animated type.
        (WebCore::SVGAnimatedEnumerationPropertyTearOff::currentAnimatedValue): Forward call to SVGAnimatedStaticPropertyTearOff<int>, our base.
        * svg/properties/SVGAnimatedListPropertyTearOff.h:
        (WebCore::SVGAnimatedListPropertyTearOff::isAnimating): Returns whether this property is being animated or not.
        (WebCore::SVGAnimatedListPropertyTearOff::currentAnimatedValue):
        * svg/properties/SVGAnimatedProperty.h:
        (WebCore::SVGAnimatedProperty::updateAnimVal): Will be used from SVGAnim*Element to update the current animVal, exposed to JS.
        (WebCore::SVGAnimatedProperty::lookupOrCreateWrapper): Share more code with lookupWrapper.
        (WebCore::SVGAnimatedProperty::lookupWrapper): Cleanup code, avoid doing any work for non-SVGElement derived objects, like SVGViewSpec.
        * svg/properties/SVGAnimatedPropertyMacros.h: Make all lowerProperty() calls (eg. myRectElement->x()) return the animVal, if the property is being animated.
        * svg/properties/SVGAnimatedPropertyTearOff.h: Main logic for the new animVal stuff.
        (WebCore::SVGAnimatedPropertyTearOff::isAnimating):
        (WebCore::SVGAnimatedPropertyTearOff::currentAnimatedValue):
        (WebCore::SVGAnimatedPropertyTearOff::updateAnimVal):
        (WebCore::SVGAnimatedPropertyTearOff::SVGAnimatedPropertyTearOff):
        * svg/properties/SVGAnimatedStaticPropertyTearOff.h:
        (WebCore::SVGAnimatedStaticPropertyTearOff::isAnimating):
        (WebCore::SVGAnimatedStaticPropertyTearOff::currentAnimatedValue):
        * svg/properties/SVGPropertyTearOff.h:
        (WebCore::SVGPropertyTearOff::updateAnimVal):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (91747 => 91748)


--- trunk/Source/WebCore/ChangeLog	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/ChangeLog	2011-07-26 10:05:10 UTC (rev 91748)
@@ -1,3 +1,42 @@
+2011-07-26  Nikolas Zimmermann  <[email protected]>
+
+        Prepare animVal support - phase 2
+        https://bugs.webkit.org/show_bug.cgi?id=65167
+
+        Reviewed by Dirk Schulze.
+
+        Next patch preparing animVal support. Modify the SVGAnimatedProperty* classes & macros to assure that calling someElement->someProperty()
+        will return the animVal, when the property is being animated. Not yet hooked into SVGAnimateElement, this is just a preparation.
+
+        Doesn't affect any tests, yet.
+
+        * svg/SVGPathElement.cpp: Adapt to SVGAnimatedProperty::lookupWrapper changes (new template parameters have been added).
+        (WebCore::SVGPathElement::svgAttributeChanged):
+        * svg/SVGPathSegWithContext.h: Ditto.
+        (WebCore::SVGPathSegWithContext::animatedProperty):
+        * svg/SVGPolyElement.cpp: Ditto.
+        (WebCore::SVGPolyElement::parseMappedAttribute):
+        * svg/properties/SVGAnimatedEnumerationPropertyTearOff.h: Implement currentAnimatedValue, an abstract way to retrieve the underlying animated value for any animated type.
+        (WebCore::SVGAnimatedEnumerationPropertyTearOff::currentAnimatedValue): Forward call to SVGAnimatedStaticPropertyTearOff<int>, our base.
+        * svg/properties/SVGAnimatedListPropertyTearOff.h:
+        (WebCore::SVGAnimatedListPropertyTearOff::isAnimating): Returns whether this property is being animated or not.
+        (WebCore::SVGAnimatedListPropertyTearOff::currentAnimatedValue):
+        * svg/properties/SVGAnimatedProperty.h:
+        (WebCore::SVGAnimatedProperty::updateAnimVal): Will be used from SVGAnim*Element to update the current animVal, exposed to JS.
+        (WebCore::SVGAnimatedProperty::lookupOrCreateWrapper): Share more code with lookupWrapper.
+        (WebCore::SVGAnimatedProperty::lookupWrapper): Cleanup code, avoid doing any work for non-SVGElement derived objects, like SVGViewSpec.
+        * svg/properties/SVGAnimatedPropertyMacros.h: Make all lowerProperty() calls (eg. myRectElement->x()) return the animVal, if the property is being animated.
+        * svg/properties/SVGAnimatedPropertyTearOff.h: Main logic for the new animVal stuff.
+        (WebCore::SVGAnimatedPropertyTearOff::isAnimating):
+        (WebCore::SVGAnimatedPropertyTearOff::currentAnimatedValue):
+        (WebCore::SVGAnimatedPropertyTearOff::updateAnimVal):
+        (WebCore::SVGAnimatedPropertyTearOff::SVGAnimatedPropertyTearOff):
+        * svg/properties/SVGAnimatedStaticPropertyTearOff.h:
+        (WebCore::SVGAnimatedStaticPropertyTearOff::isAnimating):
+        (WebCore::SVGAnimatedStaticPropertyTearOff::currentAnimatedValue):
+        * svg/properties/SVGPropertyTearOff.h:
+        (WebCore::SVGPropertyTearOff::updateAnimVal):
+
 2011-07-26  Shinya Kawanaka  <[email protected]>
 
         Uses isHTMLSpace to normalize white spaces.

Modified: trunk/Source/WebCore/svg/SVGPathElement.cpp (91747 => 91748)


--- trunk/Source/WebCore/svg/SVGPathElement.cpp	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/SVGPathElement.cpp	2011-07-26 10:05:10 UTC (rev 91748)
@@ -261,7 +261,7 @@
     RenderSVGPath* renderer = static_cast<RenderSVGPath*>(this->renderer());
 
     if (attrName == SVGNames::dAttr) {
-        if (SVGAnimatedProperty::lookupWrapper<SVGAnimatedPathSegListPropertyTearOff>(this, dPropertyInfo())) {
+        if (SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff, true>(this, dPropertyInfo())) {
             SVGPathSegList newList(PathSegUnalteredRole);
             SVGPathParserFactory* factory = SVGPathParserFactory::self();
             factory->buildSVGPathSegListFromByteStream(m_pathByteStream.get(), this, newList, UnalteredParsing);

Modified: trunk/Source/WebCore/svg/SVGPathSegWithContext.h (91747 => 91748)


--- trunk/Source/WebCore/svg/SVGPathSegWithContext.h	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/SVGPathSegWithContext.h	2011-07-26 10:05:10 UTC (rev 91748)
@@ -39,7 +39,7 @@
         case PathSegUndefinedRole:
             return 0;
         case PathSegUnalteredRole:
-            return SVGAnimatedProperty::lookupWrapper<SVGAnimatedPathSegListPropertyTearOff>(m_element.get(), SVGPathElement::dPropertyInfo());
+            return SVGAnimatedProperty::lookupWrapper<SVGPathElement, SVGAnimatedPathSegListPropertyTearOff, true>(m_element.get(), SVGPathElement::dPropertyInfo());
         case PathSegNormalizedRole:
             // FIXME: https://bugs.webkit.org/show_bug.cgi?id=15412 - Implement normalized path segment lists!
             return 0;

Modified: trunk/Source/WebCore/svg/SVGPolyElement.cpp (91747 => 91748)


--- trunk/Source/WebCore/svg/SVGPolyElement.cpp	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/SVGPolyElement.cpp	2011-07-26 10:05:10 UTC (rev 91748)
@@ -90,7 +90,7 @@
         if (!pointsListFromSVGData(newList, value))
             document()->accessSVGExtensions()->reportError("Problem parsing points=\"" + value + "\"");
 
-        if (SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGAnimatedListPropertyTearOff<SVGPointList> >(this, pointsPropertyInfo()))
+        if (SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<SVGPolyElement, SVGAnimatedListPropertyTearOff<SVGPointList>, true>(this, pointsPropertyInfo()))
             static_cast<SVGAnimatedListPropertyTearOff<SVGPointList>*>(wrapper)->detachListWrappers(newList.size());
 
         m_points.value = newList;

Modified: trunk/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h (91747 => 91748)


--- trunk/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/properties/SVGAnimatedEnumerationPropertyTearOff.h	2011-07-26 10:05:10 UTC (rev 91748)
@@ -46,6 +46,8 @@
         return adoptRef(new SVGAnimatedEnumerationPropertyTearOff<EnumType>(contextElement, attributeName, reinterpret_cast<int&>(property)));
     }
 
+    EnumType& currentAnimatedValue() { return reinterpret_cast<EnumType&>(SVGAnimatedStaticPropertyTearOff<int>::currentAnimatedValue()); }
+
 private:
     SVGAnimatedEnumerationPropertyTearOff(SVGElement* contextElement, const QualifiedName& attributeName, int& property)
         : SVGAnimatedStaticPropertyTearOff<int>(contextElement, attributeName, property)

Modified: trunk/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h (91747 => 91748)


--- trunk/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/properties/SVGAnimatedListPropertyTearOff.h	2011-07-26 10:05:10 UTC (rev 91748)
@@ -82,6 +82,10 @@
     PropertyType& values() { return m_values; }
     ListWrapperCache& wrappers() { return m_wrappers; }
 
+    // FIXME: animVal support.
+    bool isAnimating() const { return false; }
+    PropertyType& currentAnimatedValue() { return m_values; }
+
     static PassRefPtr<SVGAnimatedListPropertyTearOff<PropertyType> > create(SVGElement* contextElement, const QualifiedName& attributeName, PropertyType& values)
     {
         ASSERT(contextElement);

Modified: trunk/Source/WebCore/svg/properties/SVGAnimatedProperty.h (91747 => 91748)


--- trunk/Source/WebCore/svg/properties/SVGAnimatedProperty.h	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/properties/SVGAnimatedProperty.h	2011-07-26 10:05:10 UTC (rev 91748)
@@ -43,6 +43,7 @@
     }
 
     virtual bool isAnimatedListTearOff() const { return false; }
+    virtual void updateAnimVal(void*) { ASSERT_NOT_REACHED(); }
 
     // Caching facilities.
     typedef HashMap<SVGAnimatedPropertyDescription, RefPtr<SVGAnimatedProperty>, SVGAnimatedPropertyDescriptionHash, SVGAnimatedPropertyDescriptionHashTraits> Cache;
@@ -60,11 +61,12 @@
         }
     }
 
+    // lookupOrCreateWrapper & helper methods.
     template<typename TearOffType, typename PropertyType, bool isDerivedFromSVGElement>
-    struct Helper;
+    struct LookupOrCreateHelper;
 
     template<typename TearOffType, typename PropertyType>
-    struct Helper<TearOffType, PropertyType, false> {
+    struct LookupOrCreateHelper<TearOffType, PropertyType, false> {
         static PassRefPtr<TearOffType> lookupOrCreateWrapper(void*, const SVGPropertyInfo*, PropertyType&)
         {
             ASSERT_NOT_REACHED();
@@ -73,7 +75,7 @@
     };
 
     template<typename TearOffType, typename PropertyType>
-    struct Helper<TearOffType, PropertyType, true> {
+    struct LookupOrCreateHelper<TearOffType, PropertyType, true> {
         static PassRefPtr<TearOffType> lookupOrCreateWrapper(SVGElement* element, const SVGPropertyInfo* info, PropertyType& property)
         {
             ASSERT(info);
@@ -90,15 +92,35 @@
     template<typename OwnerType, typename TearOffType, typename PropertyType, bool isDerivedFromSVGElement>
     static PassRefPtr<TearOffType> lookupOrCreateWrapper(OwnerType* element, const SVGPropertyInfo* info, PropertyType& property)
     {
-        return Helper<TearOffType, PropertyType, isDerivedFromSVGElement>::lookupOrCreateWrapper(element, info, property);
+        return LookupOrCreateHelper<TearOffType, PropertyType, isDerivedFromSVGElement>::lookupOrCreateWrapper(element, info, property);
     }
 
+    // lookupWrapper & helper methods.
+    template<typename TearOffType, bool isDerivedFromSVGElement>
+    struct LookupHelper;
+
     template<typename TearOffType>
-    static TearOffType* lookupWrapper(SVGElement* element, const SVGPropertyInfo* info)
+    struct LookupHelper<TearOffType, false> {
+        static TearOffType* lookupWrapper(const void*, const SVGPropertyInfo*)
+        {
+            return 0;
+        }
+    };
+
+    template<typename TearOffType>
+    struct LookupHelper<TearOffType, true> {
+        static TearOffType* lookupWrapper(const SVGElement* element, const SVGPropertyInfo* info)
+        {
+            ASSERT(info);
+            SVGAnimatedPropertyDescription key(const_cast<SVGElement*>(element), info->propertyIdentifier);
+            return static_pointer_cast<TearOffType>(animatedPropertyCache()->get(key)).get();
+        }
+    };
+
+    template<typename OwnerType, typename TearOffType, bool isDerivedFromSVGElement>
+    static TearOffType* lookupWrapper(const OwnerType* element, const SVGPropertyInfo* info)
     {
-        ASSERT(info);
-        SVGAnimatedPropertyDescription key(element, info->propertyIdentifier);
-        return static_pointer_cast<TearOffType>(animatedPropertyCache()->get(key)).get();
+        return LookupHelper<TearOffType, isDerivedFromSVGElement>::lookupWrapper(element, info);
     }
 
 protected:

Modified: trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyMacros.h (91747 => 91748)


--- trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyMacros.h	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyMacros.h	2011-07-26 10:05:10 UTC (rev 91748)
@@ -124,6 +124,10 @@
     static const SVGPropertyInfo* LowerProperty##PropertyInfo(); \
     PropertyType& LowerProperty() const \
     { \
+        if (TearOffType* wrapper = SVGAnimatedProperty::lookupWrapper<UseOwnerType, TearOffType, IsDerivedFromSVGElement<UseOwnerType>::value>(this, LowerProperty##PropertyInfo())) { \
+            if (wrapper->isAnimating()) \
+                return wrapper->currentAnimatedValue(); \
+        } \
         return m_##LowerProperty.value; \
     } \
 \
@@ -175,8 +179,8 @@
 DECLARE_ANIMATED_PROPERTY(TearOffType, PropertyType, UpperProperty, LowerProperty) \
 void detachAnimated##UpperProperty##ListWrappers(unsigned newListSize) \
 { \
-    if (SVGAnimatedProperty* wrapper = SVGAnimatedProperty::lookupWrapper<TearOffType>(this, LowerProperty##PropertyInfo())) \
-        static_cast<TearOffType*>(wrapper)->detachListWrappers(newListSize); \
+    if (TearOffType* wrapper = SVGAnimatedProperty::lookupWrapper<UseOwnerType, TearOffType, IsDerivedFromSVGElement<UseOwnerType>::value>(this, LowerProperty##PropertyInfo())) \
+        wrapper->detachListWrappers(newListSize); \
 }
 
 }

Modified: trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyTearOff.h (91747 => 91748)


--- trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyTearOff.h	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/properties/SVGAnimatedPropertyTearOff.h	2011-07-26 10:05:10 UTC (rev 91748)
@@ -49,15 +49,37 @@
         return adoptRef(new SVGAnimatedPropertyTearOff<PropertyType>(contextElement, attributeName, property));
     }
 
+    bool isAnimating() const { return m_isAnimating; }
+
+    PropertyType& currentAnimatedValue()
+    {
+        ASSERT(m_animVal);
+        ASSERT(m_isAnimating);
+        return static_cast<SVGPropertyTearOff<PropertyType>*>(m_animVal.get())->propertyReference();
+    }
+
+    virtual void updateAnimVal(void* value)
+    {
+        if (value) {
+            static_cast<SVGPropertyTearOff<PropertyType>*>(animVal())->updateAnimVal(reinterpret_cast<PropertyType*>(value));
+            m_isAnimating = true;
+            return;
+        }
+
+        static_cast<SVGPropertyTearOff<PropertyType>*>(animVal())->updateAnimVal(&m_property);
+        m_isAnimating = false;
+    }
+
 private:
     SVGAnimatedPropertyTearOff(SVGElement* contextElement, const QualifiedName& attributeName, PropertyType& property)
         : SVGAnimatedProperty(contextElement, attributeName)
         , m_property(property)
+        , m_isAnimating(false)
     {
     }
 
     PropertyType& m_property;
-
+    bool m_isAnimating;
     RefPtr<SVGProperty> m_baseVal;
     RefPtr<SVGProperty> m_animVal;
 };

Modified: trunk/Source/WebCore/svg/properties/SVGAnimatedStaticPropertyTearOff.h (91747 => 91748)


--- trunk/Source/WebCore/svg/properties/SVGAnimatedStaticPropertyTearOff.h	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/properties/SVGAnimatedStaticPropertyTearOff.h	2011-07-26 10:05:10 UTC (rev 91748)
@@ -46,7 +46,8 @@
     }
 
     // FIXME: No animVal support.
-    void setAnimVal(const PropertyType&) { }
+    bool isAnimating() const { return false; }
+    PropertyType& currentAnimatedValue() { return m_property; }
 
     static PassRefPtr<SVGAnimatedStaticPropertyTearOff<PropertyType> > create(SVGElement* contextElement, const QualifiedName& attributeName, PropertyType& property)
     {

Modified: trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h (91747 => 91748)


--- trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h	2011-07-26 09:39:27 UTC (rev 91747)
+++ trunk/Source/WebCore/svg/properties/SVGPropertyTearOff.h	2011-07-26 10:05:10 UTC (rev 91748)
@@ -93,6 +93,13 @@
 
     virtual SVGPropertyRole role() const { return m_role; }
 
+    void updateAnimVal(PropertyType* value)
+    {
+        ASSERT(!m_valueIsCopy);
+        ASSERT(m_role == AnimValRole);
+        m_value = value;
+    }
+
 protected:
     SVGPropertyTearOff(SVGAnimatedProperty* animatedProperty, SVGPropertyRole role, PropertyType& value)
         : m_animatedProperty(animatedProperty)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to