Bug 81448 - Enable animVal support for SVGNumberOptionalNumber
Summary: Enable animVal support for SVGNumberOptionalNumber
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nikolas Zimmermann
URL:
Keywords:
Depends on: 12437
Blocks: 41761
  Show dependency treegraph
 
Reported: 2012-03-17 04:05 PDT by Nikolas Zimmermann
Modified: 2012-03-17 05:14 PDT (History)
1 user (show)

See Also:


Attachments
Patch (59.68 KB, patch)
2012-03-17 04:13 PDT, Nikolas Zimmermann
koivisto: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolas Zimmermann 2012-03-17 04:05:11 PDT
Certain types like stdDeviationX, stdDeviationY are mapped to a single attribute SVGNames::stdDeviationAttr.
Two SVG DOM properties (two distinctive SVGAnimatedNumbers) have to reflect the changes when an animation is running.
Comment 1 Nikolas Zimmermann 2012-03-17 04:13:46 PDT
Created attachment 132457 [details]
Patch
Comment 2 Antti Koivisto 2012-03-17 04:41:15 PDT
Comment on attachment 132457 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=132457&action=review

> Source/WebCore/svg/SVGAnimateElement.cpp:245
> +    for (size_t i = 0; i < m_animatedProperties.size(); ++i)
> +        ASSERT(m_animatedPropertyType == m_animatedProperties[i]->animatedPropertyType());

You should add an inline function returning bool for this and then assert on that, ASSERT(propertyTypesConsistent()) or similar.

> Source/WebCore/svg/SVGAnimatedTypeAnimator.h:74
> +        AnimatedType* copy = new AnimatedType(*reinterpret_cast<AnimatedType*>(animatedType));
> +        types.append(reinterpret_cast<SVGGenericAnimatedType*>(copy));

Why is this reinterpret_cast needed? Why is it safe?

There should be at least a comment.

> Source/WebCore/svg/SVGAnimationElement.cpp:383
> +        size_t propertiesSize = properties.size();
> +        if (propertiesSize) {

Note that we want to make vectors use 32 bit indexes in the future so the general direction is away from size_t. But probably better use it here for consistency for now.

> Source/WebCore/svg/SVGAnimationElement.cpp:480
> -void SVGAnimationElement::animationStarted(SVGAnimatedProperty* property, SVGAnimatedType* type)
> +void SVGAnimationElement::animationStarted(const Vector<SVGAnimatedProperty*>& properties, const Vector<SVGGenericAnimatedType*>& types)
>  {
> -    ASSERT(type);
> -    notifyAnimatedPropertyAboutAnimationBeginEnd(property, type, targetElement(), attributeName());
> +    notifyAnimatedPropertyAboutAnimationBeginEnd(properties, types, targetElement(), attributeName());

It might be good to add a comment explaining what exactly is the case with more than one property per element.
Comment 3 Nikolas Zimmermann 2012-03-17 04:43:47 PDT
(In reply to comment #2)
> (From update of attachment 132457 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=132457&action=review
> 
> > Source/WebCore/svg/SVGAnimateElement.cpp:245
> > +    for (size_t i = 0; i < m_animatedProperties.size(); ++i)
> > +        ASSERT(m_animatedPropertyType == m_animatedProperties[i]->animatedPropertyType());
> 
> You should add an inline function returning bool for this and then assert on that, ASSERT(propertyTypesConsistent()) or similar.
Good idea.

> > Source/WebCore/svg/SVGAnimatedTypeAnimator.h:74
> Why is this reinterpret_cast needed? Why is it safe?
SVGGenericAnimatedType isn't defined anywhere, we use it as generic variant type. This patch is a first step moving away from that, to avoid reinterpret_casts in future.

> There should be at least a comment.
Ok.
 
> > Source/WebCore/svg/SVGAnimationElement.cpp:383
> Note that we want to make vectors use 32 bit indexes in the future so the general direction is away from size_t. But probably better use it here for consistency for now.
Ok, good to know.

> > Source/WebCore/svg/SVGAnimationElement.cpp:480
> It might be good to add a comment explaining what exactly is the case with more than one property per element.
Ok.
Comment 4 Antti Koivisto 2012-03-17 04:57:27 PDT
Comment on attachment 132457 [details]
Patch

r=me since this is an existing architecture. The code that requires reinterpret_casts here absolutely need to be eliminated soon and replaced with properly designed types. The code is completely unsafe as is.
Comment 5 Nikolas Zimmermann 2012-03-17 05:00:44 PDT
(In reply to comment #4)
> (From update of attachment 132457 [details])
> r=me since this is an existing architecture. The code that requires reinterpret_casts here absolutely need to be eliminated soon and replaced with properly designed types. The code is completely unsafe as is.

Thanks, I'll post the follow-up patch soon.
Comment 6 Nikolas Zimmermann 2012-03-17 05:14:01 PDT
Committed r111120: <http://trac.webkit.org/changeset/111120>