Bug 142870 - CSS Animations with triggers should map scroll position to duration
Summary: CSS Animations with triggers should map scroll position to duration
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Animations (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Dean Jackson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-03-19 11:26 PDT by Dean Jackson
Modified: 2015-03-20 10:28 PDT (History)
4 users (show)

See Also:


Attachments
Patch (17.74 KB, patch)
2015-03-19 15:42 PDT, Dean Jackson
simon.fraser: review+
Details | Formatted Diff | Diff
Patch (25.52 KB, patch)
2015-03-19 18:52 PDT, Dean Jackson
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dean Jackson 2015-03-19 11:26:37 PDT
Expose a prototype implementation of what will eventually be called animation-timebase, mapping the scroll location to the duration of an animation. This only applies if the animation has a start and end trigger.
Comment 1 Radar WebKit Bug Importer 2015-03-19 11:48:52 PDT
<rdar://problem/20227244>
Comment 2 Dean Jackson 2015-03-19 15:42:22 PDT
Created attachment 249067 [details]
Patch
Comment 3 Simon Fraser (smfr) 2015-03-19 15:53:32 PDT
Comment on attachment 249067 [details]
Patch

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

> Source/WebCore/css/CSSToStyleMap.cpp:539
> +        bool hasEnd = false;

I don't think you need the hasEnd variable.

> Source/WebCore/page/animation/AnimationBase.cpp:482
> +    // time is determined by the scroll position.

We should stop calling this elapsedTime

> Source/WebCore/page/animation/AnimationBase.cpp:710
> +        if (scrollTrigger.hasEndValue() && m_object) {

Can we make m_object a reference (later)?

> Source/WebCore/page/animation/AnimationBase.cpp:711
> +            float offset = m_object->view().frameView().scrollOffsetForFixedPosition().height().toFloat();

I think we should snapshot the scroll position when we snapshot the animation time. Fetching it all over the place feels error-prone.

> Source/WebCore/page/animation/AnimationBase.cpp:718
> +            return m_animation->duration() * (offset - startValue) / (endValue - startValue);

What if endValue == startValue?

Please add a test for this case.

> Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp:871
> +        ScrollAnimationTrigger& scrollTrigger = downcast<ScrollAnimationTrigger>(*anim->trigger().get());
> +        if (scrollTrigger.hasEndValue())

What about startValue?
Comment 4 Dean Jackson 2015-03-19 18:52:07 PDT
Created attachment 249076 [details]
Patch
Comment 5 Dean Jackson 2015-03-19 18:52:20 PDT
Comment on attachment 249067 [details]
Patch

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

>> Source/WebCore/css/CSSToStyleMap.cpp:539
>> +        bool hasEnd = false;
> 
> I don't think you need the hasEnd variable.

I removed it but it means I have two calls to setTrigger, each side of the conditional.

>> Source/WebCore/page/animation/AnimationBase.cpp:482
>> +    // time is determined by the scroll position.
> 
> We should stop calling this elapsedTime

Agreed. I'll do that in a followup patch.

>> Source/WebCore/page/animation/AnimationBase.cpp:710
>> +        if (scrollTrigger.hasEndValue() && m_object) {
> 
> Can we make m_object a reference (later)?

Yes.

>> Source/WebCore/page/animation/AnimationBase.cpp:711
>> +            float offset = m_object->view().frameView().scrollOffsetForFixedPosition().height().toFloat();
> 
> I think we should snapshot the scroll position when we snapshot the animation time. Fetching it all over the place feels error-prone.

Done

>> Source/WebCore/page/animation/AnimationBase.cpp:718
>> +            return m_animation->duration() * (offset - startValue) / (endValue - startValue);
> 
> What if endValue == startValue?
> 
> Please add a test for this case.

OK!
Comment 6 Dean Jackson 2015-03-19 18:52:42 PDT
Checking the patch on EWS before landing.
Comment 7 WebKit Commit Bot 2015-03-19 18:54:40 PDT
Attachment 249076 [details] did not pass style-queue:


ERROR: Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1241:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
Total errors found: 1 in 15 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Dean Jackson 2015-03-19 21:48:38 PDT
Committed r181778: <http://trac.webkit.org/changeset/181778>
Comment 9 Alexey Proskuryakov 2015-03-20 10:28:22 PDT
(In reply to comment #8)
> Committed r181778: <http://trac.webkit.org/changeset/181778>

This broke animations/trigger-container-scroll-empty.html on Windows and EFL:

https://webkit-test-results.appspot.com/dashboards/flakiness_dashboard.html#showAllRuns=true&tests=animations%2Ftrigger-container-scroll-empty.html