Parsing and Style Resolution of Container-based Animation Triggers
authordino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Mar 2015 19:08:40 +0000 (19:08 +0000)
committerdino@apple.com <dino@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Mar 2015 19:08:40 +0000 (19:08 +0000)
commit2786becee93f629bbb48a37a6677734dd3718355
tree68f4e55cb9c3504b6f17ddfb8b8e8622b8a21c90
parent468d412f2b204193459f7d4d5273294f7602c5b2
Parsing and Style Resolution of Container-based Animation Triggers
https://bugs.webkit.org/show_bug.cgi?id=142687
<rdar://problem/20170007>

Reviewed by Simon Fraser.

Source/WebCore:

This is the beginning of a prototype implementation of
CSS Animation Triggers, as described by
https://lists.w3.org/Archives/Public/www-style/2014Sep/0135.html

In this patch we parse and resolve the value of a new
CSS property "-webkit-animation-trigger". At the moment it
only accepts one function value "container-scroll", which
will trigger the animation at an absolute position within
an element's scrolling container. We expect the syntax to
change in the near future, as the spec is written.

Tests: animations/trigger-computed-style.html
       animations/trigger-parsing.html

* WebCore.xcodeproj/project.pbxproj: Add the new files.

* css/CSSAnimationTriggerScrollValue.cpp: Added.
(WebCore::CSSAnimationTriggerScrollValue::customCSSText): Output text for computed style.
(WebCore::CSSAnimationTriggerScrollValue::equals): Compare two values.
* css/CSSAnimationTriggerScrollValue.h: Added. This holds the CSS side of the
scroll trigger. This name may change in the future to better represent the
type of trigger, but it is good enough for now.
(WebCore::CSSAnimationTriggerScrollValue::create):
(WebCore::CSSAnimationTriggerScrollValue::startValue):
(WebCore::CSSAnimationTriggerScrollValue::endValue):
(WebCore::CSSAnimationTriggerScrollValue::CSSAnimationTriggerScrollValue):

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::createAnimationTriggerValue): Maps an AnimationTrigger into a CSSValue.
(WebCore::getAnimationTriggerValue): Gets the current computed style.
(WebCore::ComputedStyleExtractor::propertyValue):

* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseAnimationTrigger): Parse the "container-scroll" function
and record the value as a CSSAnimationTriggerScrollValue.
(WebCore::CSSParser::parseAnimationProperty): Handle the new property.
* css/CSSParser.h:

* css/CSSPropertyNames.in: Add "-webkit-animation-trigger".

* css/CSSToStyleMap.cpp:
(WebCore::CSSToStyleMap::mapAnimationTrigger): Map a CSSValue into a trigger value on
an Animation object.
* css/CSSToStyleMap.h:

* css/CSSValue.cpp: Handle the new CSSValue type.
(WebCore::CSSValue::equals):
(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):
* css/CSSValue.h:
(WebCore::CSSValue::isAnimationTriggerScrollValue):

* platform/animation/Animation.h: Add AnimationTrigger as a new field.
(WebCore::Animation::isTriggerSet):
(WebCore::Animation::isEmpty):

* platform/animation/AnimationTrigger.h: Added. New base class and subclasses for
"auto" and the scrolling trigger.
(WebCore::AnimationTrigger::~AnimationTrigger):
(WebCore::AnimationTrigger::type):
(WebCore::AnimationTrigger::isAutoAnimationTrigger):
(WebCore::AnimationTrigger::isScrollAnimationTrigger):
(WebCore::AnimationTrigger::AnimationTrigger):
(WebCore::AutoAnimationTrigger::create):
(WebCore::AutoAnimationTrigger::~AutoAnimationTrigger):
(WebCore::AutoAnimationTrigger::AutoAnimationTrigger):
(WebCore::ScrollAnimationTrigger::create):
(WebCore::ScrollAnimationTrigger::~ScrollAnimationTrigger):
(WebCore::ScrollAnimationTrigger::startValue):
(WebCore::ScrollAnimationTrigger::setStartValue):
(WebCore::ScrollAnimationTrigger::endValue):
(WebCore::ScrollAnimationTrigger::setEndValue):
(WebCore::ScrollAnimationTrigger::hasEndValue):
(WebCore::ScrollAnimationTrigger::setHasEndValue):
(WebCore::ScrollAnimationTrigger::ScrollAnimationTrigger):

LayoutTests:

New tests that exercise the parser and computed style
of -webkit-animation-trigger.

* animations/script-tests/trigger-computed-style.js: Added.
(testComputedTriggerRule):
* animations/script-tests/trigger-parsing.js: Added.
(testTriggerRule):
* animations/trigger-computed-style-expected.txt: Added.
* animations/trigger-computed-style.html: Added.
* animations/trigger-parsing-expected.txt: Added.
* animations/trigger-parsing.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181572 268f45cc-cd09-0410-ab3c-d52691b4dbfc
24 files changed:
LayoutTests/ChangeLog
LayoutTests/animations/script-tests/trigger-computed-style.js [new file with mode: 0644]
LayoutTests/animations/script-tests/trigger-parsing.js [new file with mode: 0644]
LayoutTests/animations/trigger-computed-style-expected.txt [new file with mode: 0644]
LayoutTests/animations/trigger-computed-style.html [new file with mode: 0644]
LayoutTests/animations/trigger-parsing-expected.txt [new file with mode: 0644]
LayoutTests/animations/trigger-parsing.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSAnimationTriggerScrollValue.cpp [new file with mode: 0644]
Source/WebCore/css/CSSAnimationTriggerScrollValue.h [new file with mode: 0644]
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSToStyleMap.cpp
Source/WebCore/css/CSSToStyleMap.h
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/platform/animation/Animation.h
Source/WebCore/platform/animation/AnimationTrigger.h [new file with mode: 0644]