Changes between Version 10 and Version 11 of SVG properties


Ignore:
Timestamp:
Mar 9, 2019 11:20:08 PM (5 years ago)
Author:
Said Abou-Hallawa
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SVG properties

    v10 v11  
    3333The goal of the new design is to make the life cycle of the SVG properties clear. It has to well define the relationship between the property and its owner such that synchronizing the change in the property with the SVGElement becomes straightforward.
    3434* The SVGElement will own the RefCounted animated SVG property with will own the RefCounted SVG properties for the baseVal and the animVal. This eliminate the need to cache animated SVG property outside the SVGElement like what the SVG tear off objects were doing.
    35 *
     35* If the property is of list of an SVG type, the items will be RefCounted of the SVG type.
     36* The properties will be registered once by the owner SVGElement to associate a pointer to a member in the SVGElement with an attributeName.
     37* The property registry will create an accessor for every property. The accessor knows how to get the property value when it is given an SVGElement.
     38* The SMIL animation is carried out by an SVGAnimator. The SVGAnimator calculates the new value of the animVal by the SVGAnimationFunction. The SVGAnimator commits the change in the animVal by invalidating the SVGElement. The SVG renderer will get the new animVal when it gets the property value and the SVGElement finds that the property is being animated.
    3639
    3740**Mechanic of the SVG property**
     
    6366}}}
    64677. This registration associates a pointer to a member of SVGRectElement with the attributeName through the SVGAnimatedLengthAccessor.
     688. When the animation of an SVG animated property starts, SVGAnimateElementBase asks the SVGPropertyRegistry to create an SVGAnimator for this property. SVGPropertyRegistry finds the property accessor and asks it to create the SVGAnimator. For example, this is the createAnimator method of SVGAnimatedLengthAccessor:
     69{{{
     70RefPtr<SVGAnimator> createAnimator(OwnerType& owner, const QualifiedName& attributeName, AnimationMode animationMode, CalcMode calcMode, bool isAccumulated, bool isAdditive) const final
     71{
     72    SVGLengthMode lengthMode = property(owner)->baseVal()->value().unitMode();
     73    return SVGAnimatedLengthAnimator::create(attributeName, property(owner), animationMode, calcMode, isAccumulated, isAdditive, lengthMode);
     74}
     75}}}
     769. When SVGAnimateElementBase wants to progress the animation, it asks the animator to calculate a new value of the property based on the timeline of the animation. The SVGAnimator asks the SVGAnimationFunction to do so given a reference to  the animVal of the property. For example here is the progress() method of SVGAnimatedLengthAnimator:
     77{{{
     78\void progress(SVGElement* targetElement, float percentage, unsigned repeatCount) final
     79{
     80    m_function.progress(targetElement, percentage, repeatCount, m_animated->animVal()->value());
     81}
     82}}}