Bug 118574 - SVG stroke-dasharray is not animatable
Summary: SVG stroke-dasharray is not animatable
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL: http://dabblet.com/gist/5978235
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-11 12:12 PDT by Lea Verou
Modified: 2013-08-06 16:16 PDT (History)
11 users (show)

See Also:


Attachments
Patch (7.39 KB, patch)
2013-08-05 10:52 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (9.54 KB, patch)
2013-08-05 12:36 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (10.36 KB, patch)
2013-08-06 07:57 PDT, Rob Buis
krit: review+
krit: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Lea Verou 2013-07-11 12:12:21 PDT
Even though WebKit allows many other SVG properties to be animatable through CSS transitions and animations, stroke-dasharray seems to be the odd one out. All the other stroke properties are animatable.

Firefox animates it.

IE10 doesn’t support CSS transitions & animations in any SVG property it seems.

Issue present in both WebKit nightlies and Blink too.
Comment 1 Rob Buis 2013-08-05 10:52:37 PDT
Created attachment 208136 [details]
Patch
Comment 2 Tim Horton 2013-08-05 10:56:11 PDT
<rdar://problem/14610309>
Comment 3 Dirk Schulze 2013-08-05 11:08:50 PDT
Comment on attachment 208136 [details]
Patch

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

Looks great in general. Some notes inside.

> Source/WebCore/page/animation/CSSPropertyAnimation.cpp:236
> +    if (from.size() != to.size())
> +        return to;

Do we really just want to animate lists of same length? I wonder if it would make sense to 0 the other values.

> Source/WebCore/page/animation/CSSPropertyAnimation.cpp:238
> +    Vector<SVGLength> ret(len);

please use a more meaningful name. result?

> LayoutTests/transitions/svg-transitions.html:18
> +      stroke-dasharray: 10 10;

more tests would be great. Especially with different values, length.
Comment 4 Dean Jackson 2013-08-05 11:59:17 PDT
Comment on attachment 208136 [details]
Patch

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

>> Source/WebCore/page/animation/CSSPropertyAnimation.cpp:236
>> +        return to;
> 
> Do we really just want to animate lists of same length? I wonder if it would make sense to 0 the other values.

I think it would make more sense to repeat values e.g.
5 10 -> 10 20 15 25 would be the same as 5 10 5 10 -> 10 20 15 25
and 5 10 15 20 -> 10 20 would animate as 5 10 15 20 -> 10 20 10 20

However, giving that makes the intermediate getComputedStyle() values a bit confusing, I think it's ok to also say that we don't animate lists of different lengths.
Comment 5 Rob Buis 2013-08-05 12:36:41 PDT
Created attachment 208139 [details]
Patch
Comment 6 Tim Horton 2013-08-05 12:40:47 PDT
Comment on attachment 208139 [details]
Patch

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

> Source/WebCore/page/animation/CSSPropertyAnimation.cpp:55
> +using namespace std;

Please use the namespace explicitly instead of doing this. (http://www.webkit.org/coding/coding-style.html#using-in-cpp)
Comment 7 Rob Buis 2013-08-05 12:41:13 PDT
Hi Dean,

(In reply to comment #4)
> (From update of attachment 208136 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=208136&action=review
> 
> >> Source/WebCore/page/animation/CSSPropertyAnimation.cpp:236
> >> +        return to;
> > 
> > Do we really just want to animate lists of same length? I wonder if it would make sense to 0 the other values.
> 
> I think it would make more sense to repeat values e.g.
> 5 10 -> 10 20 15 25 would be the same as 5 10 5 10 -> 10 20 15 25
> and 5 10 15 20 -> 10 20 would animate as 5 10 15 20 -> 10 20 10 20

Right, the current FireFox implementation seems to do that.

> However, giving that makes the intermediate getComputedStyle() values a bit confusing, I think it's ok to also say that we don't animate lists of different lengths.

I am not in favour of either solution, but for completeness (and because FF supports it) I just uploaded a patch that does the repeating. Worst case we can just revert to my initial patch and fix Dirks's remaining points(variable rename and more tests). Let me know :)
Comment 8 Rob Buis 2013-08-05 12:44:48 PDT
(In reply to comment #6)
> (From update of attachment 208139 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=208139&action=review
> 
> > Source/WebCore/page/animation/CSSPropertyAnimation.cpp:55
> > +using namespace std;
> 
> Please use the namespace explicitly instead of doing this. (http://www.webkit.org/coding/coding-style.html#using-in-cpp)

Strange, I had that earlier but I am pretty sure it gave me a style error at the time :( Will fix.
Comment 9 Dirk Schulze 2013-08-05 13:04:30 PDT
(In reply to comment #7)
> Hi Dean,
> 
> (In reply to comment #4)
> > (From update of attachment 208136 [details] [details])
> > View in context: https://bugs.webkit.org/attachment.cgi?id=208136&action=review
> > 
> > >> Source/WebCore/page/animation/CSSPropertyAnimation.cpp:236
> > >> +        return to;
> > > 
> > > Do we really just want to animate lists of same length? I wonder if it would make sense to 0 the other values.
> > 
> > I think it would make more sense to repeat values e.g.
> > 5 10 -> 10 20 15 25 would be the same as 5 10 5 10 -> 10 20 15 25
> > and 5 10 15 20 -> 10 20 would animate as 5 10 15 20 -> 10 20 10 20
> 
> Right, the current FireFox implementation seems to do that.
> 
> > However, giving that makes the intermediate getComputedStyle() values a bit confusing, I think it's ok to also say that we don't animate lists of different lengths.
> 
> I am not in favour of either solution, but for completeness (and because FF supports it) I just uploaded a patch that does the repeating. Worst case we can just revert to my initial patch and fix Dirks's remaining points(variable rename and more tests). Let me know :)

I don't feel strongly about any solution, we can skip if we do not have the same pattern for now. But please add more tests that cover the cases. Compatibility with FF doesn't seem too bad though.
Comment 10 Rob Buis 2013-08-06 07:57:52 PDT
Created attachment 208192 [details]
Patch
Comment 11 Dirk Schulze 2013-08-06 08:10:55 PDT
Comment on attachment 208192 [details]
Patch

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

r=me with the changes.

> Source/WebCore/page/animation/CSSPropertyAnimation.cpp:236
> +    size_t fromLen = from.size();
> +    size_t toLen = to.size();

fromLength and toLength

> Source/WebCore/page/animation/CSSPropertyAnimation.cpp:241
> +    size_t len = fromLen;

resultLength
Comment 12 Mark Lam 2013-08-06 09:15:10 PDT
This change broke the Windows build:
http://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/50704/steps/compile-webkit/logs/stdio

     1>..\page\animation\CSSPropertyAnimation.cpp(243): error C3861: 'remainder': identifier not found

Please fix.
Comment 13 Mark Lam 2013-08-06 09:29:36 PDT
(In reply to comment #12)
> This change broke the Windows build:
> http://build.webkit.org/builders/Apple%20Win%20Release%20%28Build%29/builds/50704/steps/compile-webkit/logs/stdio
> 
>      1>..\page\animation\CSSPropertyAnimation.cpp(243): error C3861: 'remainder': identifier not found
> 
> Please fix.

FYI, I'm referring to http://trac.webkit.org/changeset/153754 which references this bug.
Comment 14 Rob Buis 2013-08-06 15:54:03 PDT
Committed r153757: <http://trac.webkit.org/changeset/153757>
Comment 15 Mark Lam 2013-08-06 16:04:23 PDT
(In reply to comment #14)
> Committed r153757: <http://trac.webkit.org/changeset/153757>

FYI, the Windows build failure was fixed in <http://trac.webkit.org/changeset/153764>.
Comment 16 Rob Buis 2013-08-06 16:16:28 PDT
(In reply to comment #15)
> (In reply to comment #14)
> > Committed r153757: <http://trac.webkit.org/changeset/153757>
> 
> FYI, the Windows build failure was fixed in <http://trac.webkit.org/changeset/153764>.

I saw, thanks!