⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 181602 in webkit


Ignore:
Timestamp:
Mar 16, 2015, 5:33:00 PM (11 years ago)
Author:
dino@apple.com
Message:

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:

Take 2 after the previous patch was rolled out.

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.cpp: Make sure to initialise m_trigger and m_triggerSet,

and use them in the operator==.

  • 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:

Take 2.

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.
Location:
trunk
Files:
9 added
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r181600 r181602  
     12015-03-16  Dean Jackson  <dino@apple.com>
     2
     3        Parsing and Style Resolution of Container-based Animation Triggers
     4        https://bugs.webkit.org/show_bug.cgi?id=142687
     5        <rdar://problem/20170007>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Take 2.
     10
     11        New tests that exercise the parser and computed style
     12        of -webkit-animation-trigger.
     13
     14        * animations/script-tests/trigger-computed-style.js: Added.
     15        (testComputedTriggerRule):
     16        * animations/script-tests/trigger-parsing.js: Added.
     17        (testTriggerRule):
     18        * animations/trigger-computed-style-expected.txt: Added.
     19        * animations/trigger-computed-style.html: Added.
     20        * animations/trigger-parsing-expected.txt: Added.
     21        * animations/trigger-parsing.html: Added.
     22
    1232015-03-16  Joanmarie Diggs  <jdiggs@igalia.com>
    224
  • trunk/LayoutTests/platform/efl/TestExpectations

    r181593 r181602  
    6262# Need a scroll snap point implementation
    6363css3/scroll-snap [ Skip ]
     64
     65# TODO Animation triggers not supported
     66animations/trigger-computed-style.html [ Skip ]
     67animations/trigger-parsing.html [ Skip ]
    6468
    6569# ----------------------------------------
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r181593 r181602  
    460460# ENABLE(CSS_SCROLL_SNAP) is disabled.
    461461css3/scroll-snap
     462
     463# TODO Animation triggers not supported
     464animations/trigger-computed-style.html [ Skip ]
     465animations/trigger-parsing.html [ Skip ]
    462466
    463467# ENABLE(SHADOW_DOM) is disabled.
  • trunk/LayoutTests/platform/win/TestExpectations

    r181593 r181602  
    595595# TODO APNG is not supported
    596596webkit.org/b/142731 fast/images/animated-png.html [ Skip ]
     597
     598# TODO Animation triggers not supported
     599animations/trigger-computed-style.html [ Skip ]
     600animations/trigger-parsing.html [ Skip ]
     601
    597602################################################################################
    598603###########    End Missing Functionality Prevents Testing         ##############
  • trunk/Source/WebCore/ChangeLog

    r181601 r181602  
     12015-03-16  Dean Jackson  <dino@apple.com>
     2
     3        Parsing and Style Resolution of Container-based Animation Triggers
     4        https://bugs.webkit.org/show_bug.cgi?id=142687
     5        <rdar://problem/20170007>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Take 2 after the previous patch was rolled out.
     10
     11        This is the beginning of a prototype implementation of
     12        CSS Animation Triggers, as described by
     13        https://lists.w3.org/Archives/Public/www-style/2014Sep/0135.html
     14
     15        In this patch we parse and resolve the value of a new
     16        CSS property "-webkit-animation-trigger". At the moment it
     17        only accepts one function value "container-scroll", which
     18        will trigger the animation at an absolute position within
     19        an element's scrolling container. We expect the syntax to
     20        change in the near future, as the spec is written.
     21
     22        Tests: animations/trigger-computed-style.html
     23               animations/trigger-parsing.html
     24
     25        * WebCore.xcodeproj/project.pbxproj: Add the new files.
     26
     27        * css/CSSAnimationTriggerScrollValue.cpp: Added.
     28        (WebCore::CSSAnimationTriggerScrollValue::customCSSText): Output text for computed style.
     29        (WebCore::CSSAnimationTriggerScrollValue::equals): Compare two values.
     30        * css/CSSAnimationTriggerScrollValue.h: Added. This holds the CSS side of the
     31        scroll trigger. This name may change in the future to better represent the
     32        type of trigger, but it is good enough for now.
     33        (WebCore::CSSAnimationTriggerScrollValue::create):
     34        (WebCore::CSSAnimationTriggerScrollValue::startValue):
     35        (WebCore::CSSAnimationTriggerScrollValue::endValue):
     36        (WebCore::CSSAnimationTriggerScrollValue::CSSAnimationTriggerScrollValue):
     37
     38        * css/CSSComputedStyleDeclaration.cpp:
     39        (WebCore::createAnimationTriggerValue): Maps an AnimationTrigger into a CSSValue.
     40        (WebCore::getAnimationTriggerValue): Gets the current computed style.
     41        (WebCore::ComputedStyleExtractor::propertyValue):
     42
     43        * css/CSSParser.cpp:
     44        (WebCore::CSSParser::parseValue):
     45        (WebCore::CSSParser::parseAnimationTrigger): Parse the "container-scroll" function
     46        and record the value as a CSSAnimationTriggerScrollValue.
     47        (WebCore::CSSParser::parseAnimationProperty): Handle the new property.
     48        * css/CSSParser.h:
     49
     50        * css/CSSPropertyNames.in: Add "-webkit-animation-trigger".
     51
     52        * css/CSSToStyleMap.cpp:
     53        (WebCore::CSSToStyleMap::mapAnimationTrigger): Map a CSSValue into a trigger value on
     54        an Animation object.
     55        * css/CSSToStyleMap.h:
     56
     57        * css/CSSValue.cpp: Handle the new CSSValue type.
     58        (WebCore::CSSValue::equals):
     59        (WebCore::CSSValue::cssText):
     60        (WebCore::CSSValue::destroy):
     61        * css/CSSValue.h:
     62        (WebCore::CSSValue::isAnimationTriggerScrollValue):
     63
     64        * platform/animation/Animation.cpp: Make sure to initialise m_trigger and m_triggerSet,
     65        and use them in the operator==.
     66        * platform/animation/Animation.h: Add AnimationTrigger as a new field.
     67        (WebCore::Animation::isTriggerSet):
     68        (WebCore::Animation::isEmpty):
     69
     70        * platform/animation/AnimationTrigger.h: Added. New base class and subclasses for
     71        "auto" and the scrolling trigger.
     72        (WebCore::AnimationTrigger::~AnimationTrigger):
     73        (WebCore::AnimationTrigger::type):
     74        (WebCore::AnimationTrigger::isAutoAnimationTrigger):
     75        (WebCore::AnimationTrigger::isScrollAnimationTrigger):
     76        (WebCore::AnimationTrigger::AnimationTrigger):
     77        (WebCore::AutoAnimationTrigger::create):
     78        (WebCore::AutoAnimationTrigger::~AutoAnimationTrigger):
     79        (WebCore::AutoAnimationTrigger::AutoAnimationTrigger):
     80        (WebCore::ScrollAnimationTrigger::create):
     81        (WebCore::ScrollAnimationTrigger::~ScrollAnimationTrigger):
     82        (WebCore::ScrollAnimationTrigger::startValue):
     83        (WebCore::ScrollAnimationTrigger::setStartValue):
     84        (WebCore::ScrollAnimationTrigger::endValue):
     85        (WebCore::ScrollAnimationTrigger::setEndValue):
     86        (WebCore::ScrollAnimationTrigger::hasEndValue):
     87        (WebCore::ScrollAnimationTrigger::setHasEndValue):
     88        (WebCore::ScrollAnimationTrigger::ScrollAnimationTrigger):
     89
    1902015-03-16  Alex Christensen  <achristensen@webkit.org>
    291
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r181593 r181602  
    12811281                31A795C81888BCB500382F90 /* ANGLEInstancedArrays.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31A795C11888B72400382F90 /* ANGLEInstancedArrays.cpp */; };
    12821282                31AB5000122878A2001A7DB0 /* GraphicsContext3DIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 31AB4FFF122878A2001A7DB0 /* GraphicsContext3DIOS.h */; };
     1283                31BC742D1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31BC742B1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.cpp */; };
     1284                31BC742E1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 31BC742C1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.h */; };
    12831285                31C0FF210E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */; };
    12841286                31C0FF220E4CEB6E007D6FE5 /* WebKitAnimationEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */; };
     
    12961298                31C0FF4E0E4CEFDD007D6FE5 /* DOMWebKitTransitionEventInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 31C0FF480E4CEFDD007D6FE5 /* DOMWebKitTransitionEventInternal.h */; };
    12971299                31D591B316697A6C00E6BF02 /* PlugInClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 31D591B116697A6C00E6BF02 /* PlugInClient.h */; settings = {ATTRIBUTES = (Private, ); }; };
     1300                31DCD29D1AB4FBDE0072E817 /* AnimationTrigger.h in Headers */ = {isa = PBXBuildFile; fileRef = 31DCD29C1AB4FBDE0072E817 /* AnimationTrigger.h */; settings = {ATTRIBUTES = (Private, ); }; };
    12981301                31EAF97E121435A400E7C1BF /* DeviceMotionClientIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 31EAF97C121435A400E7C1BF /* DeviceMotionClientIOS.h */; };
    12991302                31EAF97F121435A400E7C1BF /* DeviceMotionClientIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 31EAF97D121435A400E7C1BF /* DeviceMotionClientIOS.mm */; };
     
    83788381                31A795C51888BAD100382F90 /* JSANGLEInstancedArrays.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSANGLEInstancedArrays.h; sourceTree = "<group>"; };
    83798382                31AB4FFF122878A2001A7DB0 /* GraphicsContext3DIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GraphicsContext3DIOS.h; sourceTree = "<group>"; };
     8383                31BC742B1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSAnimationTriggerScrollValue.cpp; sourceTree = "<group>"; };
     8384                31BC742C1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSAnimationTriggerScrollValue.h; sourceTree = "<group>"; };
    83808385                31C0FF1B0E4CEB6E007D6FE5 /* WebKitAnimationEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitAnimationEvent.cpp; sourceTree = "<group>"; };
    83818386                31C0FF1C0E4CEB6E007D6FE5 /* WebKitAnimationEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAnimationEvent.h; sourceTree = "<group>"; };
     
    83958400                31C0FF480E4CEFDD007D6FE5 /* DOMWebKitTransitionEventInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DOMWebKitTransitionEventInternal.h; sourceTree = "<group>"; };
    83968401                31D591B116697A6C00E6BF02 /* PlugInClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlugInClient.h; sourceTree = "<group>"; };
     8402                31DCD29C1AB4FBDE0072E817 /* AnimationTrigger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AnimationTrigger.h; path = animation/AnimationTrigger.h; sourceTree = "<group>"; };
    83978403                31E8D8BA160BC94B004CE8F5 /* RenderSnapshottedPlugIn.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSnapshottedPlugIn.cpp; sourceTree = "<group>"; };
    83988404                31E8D8BB160BC94C004CE8F5 /* RenderSnapshottedPlugIn.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderSnapshottedPlugIn.h; sourceTree = "<group>"; };
     
    1607116077                        isa = PBXGroup;
    1607216078                        children = (
    16073                                 498771161242CD7F002226BA /* mac */,
    1607416079                                498770D71242C535002226BA /* Texture.cpp */,
    1607516080                                498770D81242C535002226BA /* Texture.h */,
     
    1614616151                                49E912A70EFAC906009D0CAF /* AnimationList.cpp */,
    1614716152                                49E912A80EFAC906009D0CAF /* AnimationList.h */,
     16153                                31DCD29C1AB4FBDE0072E817 /* AnimationTrigger.h */,
    1614816154                                0F580FAE149800D400FB5BD8 /* AnimationUtilities.h */,
    1614916155                                49E912A90EFAC906009D0CAF /* TimingFunction.h */,
     
    2218622192                        isa = PBXGroup;
    2218722193                        children = (
     22194                                31BC742B1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.cpp */,
     22195                                31BC742C1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.h */,
    2218822196                                83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */,
    2218922197                                FBD6AF8415EF21D4008B7110 /* BasicShapeFunctions.cpp */,
     
    2419024198                                85E711A10AC5D5350053270F /* DOMHTMLButtonElementInternal.h in Headers */,
    2419124199                                93D3C1590F97A9D70053C013 /* DOMHTMLCanvasElement.h in Headers */,
     24200                                31DCD29D1AB4FBDE0072E817 /* AnimationTrigger.h in Headers */,
    2419224201                                93F9B6580BA0F35E00854064 /* DOMHTMLCanvasElementInternal.h in Headers */,
    2419324202                                85DF2F8E0AA3C88100AD64C5 /* DOMHTMLCollection.h in Headers */,
     
    2432224331                                85E711D20AC5D5350053270F /* DOMNamedNodeMapInternal.h in Headers */,
    2432324332                                853BF4DB0ABB6B55008647BB /* DOMNode.h in Headers */,
     24333                                31BC742E1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.h in Headers */,
    2432424334                                854075260AD6C66700620C57 /* DOMNodeFilter.h in Headers */,
    2432524335                                85B498FB0ADB340200925CBB /* DOMNodeInternal.h in Headers */,
     
    2990129911                                B2227A2F0D00BF220071B782 /* SVGLangSpace.cpp in Sources */,
    2990229912                                B2227A320D00BF220071B782 /* SVGLength.cpp in Sources */,
     29913                                31BC742D1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.cpp in Sources */,
    2990329914                                7134496D146941B300720312 /* SVGLengthContext.cpp in Sources */,
    2990429915                                B2227A350D00BF220071B782 /* SVGLengthList.cpp in Sources */,
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r181593 r181602  
    2929#include "BasicShapeFunctions.h"
    3030#include "BasicShapes.h"
     31#include "CSSAnimationTriggerScrollValue.h"
    3132#include "CSSAspectRatioValue.h"
    3233#include "CSSBasicShapes.h"
     
    8687#include "LengthRepeat.h"
    8788#include "StyleScrollSnapPoints.h"
     89#endif
     90
     91#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     92#include "AnimationTrigger.h"
    8893#endif
    8994
     
    12211226    return list;
    12221227}
     1228
     1229#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     1230static Ref<CSSValue> createAnimationTriggerValue(const AnimationTrigger* trigger, const RenderStyle* style)
     1231{
     1232    switch (trigger->type()) {
     1233    case AnimationTrigger::AnimationTriggerType::ScrollAnimationTriggerType: {
     1234        const ScrollAnimationTrigger* scrollAnimationTrigger = static_cast<const ScrollAnimationTrigger*>(trigger);
     1235        if (scrollAnimationTrigger->endValue().isAuto())
     1236            return CSSAnimationTriggerScrollValue::create(zoomAdjustedPixelValueForLength(scrollAnimationTrigger->startValue(), style));
     1237        else
     1238            return CSSAnimationTriggerScrollValue::create(zoomAdjustedPixelValueForLength(scrollAnimationTrigger->startValue(), style),
     1239                                                          zoomAdjustedPixelValueForLength(scrollAnimationTrigger->endValue(), style));
     1240    }
     1241    default:
     1242        ASSERT(trigger->type() == AnimationTrigger::AnimationTriggerType::AutoAnimationTriggerType);
     1243        return cssValuePool().createIdentifierValue(CSSValueAuto);
     1244    }
     1245}
     1246
     1247static Ref<CSSValueList> getAnimationTriggerValue(const AnimationList* animList, const RenderStyle* style)
     1248{
     1249    auto list = CSSValueList::createCommaSeparated();
     1250    if (animList) {
     1251        for (size_t i = 0; i < animList->size(); ++i)
     1252            list.get().append(createAnimationTriggerValue(animList->animation(i).trigger().get(), style));
     1253    } else
     1254        list.get().append(createAnimationTriggerValue(Animation::initialTrigger().get(), style));
     1255
     1256    return list;
     1257}
     1258#endif
    12231259
    12241260static Ref<CSSValue> createLineBoxContainValue(unsigned lineBoxContain)
     
    27212757        case CSSPropertyWebkitAnimationTimingFunction:
    27222758            return getTimingFunctionValue(style->animations());
     2759#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     2760        case CSSPropertyWebkitAnimationTrigger:
     2761            return getAnimationTriggerValue(style->animations(), style.get());
     2762#endif
    27232763        case CSSPropertyWebkitAppearance:
    27242764            return cssValuePool().createValue(style->appearance());
  • trunk/Source/WebCore/css/CSSParser.cpp

    r181593 r181602  
    2929#include "CSSParser.h"
    3030
     31#include "CSSAnimationTriggerScrollValue.h"
    3132#include "CSSAspectRatioValue.h"
    3233#include "CSSBasicShapes.h"
     
    26902691    case CSSPropertyWebkitAnimationIterationCount:
    26912692    case CSSPropertyWebkitAnimationTimingFunction:
     2693#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     2694    case CSSPropertyWebkitAnimationTrigger:
     2695#endif
    26922696    case CSSPropertyTransitionDelay:
    26932697    case CSSPropertyTransitionDuration:
     
    47444748}
    47454749
     4750#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     4751PassRefPtr<CSSValue> CSSParser::parseAnimationTrigger()
     4752{
     4753    CSSParserValue* value = m_valueList->current();
     4754    if (value->id == CSSValueAuto)
     4755        return cssValuePool().createIdentifierValue(CSSValueAuto);
     4756
     4757    if (value->unit != CSSParserValue::Function)
     4758        return nullptr;
     4759
     4760    CSSParserValueList* args = value->function->args.get();
     4761
     4762    if (equalIgnoringCase(value->function->name, "container-scroll(")) {
     4763        if (!args || (args->size() != 1 && args->size() != 3))
     4764            return nullptr;
     4765
     4766        CSSParserValue* argument = args->current();
     4767        ValueWithCalculation firstArgumentWithCalculation(*argument);
     4768        if (!validateUnit(firstArgumentWithCalculation, FLength))
     4769            return nullptr;
     4770
     4771        RefPtr<CSSValue> startValue = createPrimitiveNumericValue(firstArgumentWithCalculation);
     4772
     4773        argument = args->next();
     4774
     4775        if (!argument)
     4776            return CSSAnimationTriggerScrollValue::create(startValue.release());
     4777
     4778        if (!isComma(argument))
     4779            return nullptr;
     4780
     4781        argument = args->next();
     4782        ValueWithCalculation secondArgumentWithCalculation(*argument);
     4783        if (!validateUnit(secondArgumentWithCalculation, FLength))
     4784            return nullptr;
     4785
     4786        RefPtr<CSSValue> endValue = createPrimitiveNumericValue(secondArgumentWithCalculation);
     4787
     4788        return CSSAnimationTriggerScrollValue::create(startValue.release(), endValue.release());
     4789    }
     4790
     4791    return 0;
     4792}
     4793#endif
     4794
    47464795PassRefPtr<CSSValue> CSSParser::parseAnimationProperty(AnimationParseContext& context)
    47474796{
     
    49815030                    m_valueList->next();
    49825031                break;
     5032#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     5033            case CSSPropertyWebkitAnimationTrigger:
     5034                currValue = parseAnimationTrigger();
     5035                if (currValue)
     5036                    m_valueList->next();
     5037                break;
     5038#endif
    49835039            default:
    49845040                ASSERT_NOT_REACHED();
  • trunk/Source/WebCore/css/CSSParser.h

    r181593 r181602  
    182182    PassRefPtr<CSSValue> parseAnimationProperty(AnimationParseContext&);
    183183    PassRefPtr<CSSValue> parseAnimationTimingFunction();
     184#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     185    PassRefPtr<CSSValue> parseAnimationTrigger();
     186#endif
    184187    static Vector<double> parseKeyframeSelector(const String&);
    185188
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r181593 r181602  
    368368-webkit-animation-play-state [AnimationProperty, NameForMethods=PlayState]
    369369-webkit-animation-timing-function [AnimationProperty, NameForMethods=TimingFunction]
     370#if defined(ENABLE_CSS_ANIMATIONS_LEVEL_2) && ENABLE_CSS_ANIMATIONS_LEVEL_2
     371-webkit-animation-trigger [AnimationProperty, NameForMethods=Trigger]
     372#endif
    370373-webkit-appearance
    371374-webkit-aspect-ratio [Inherited, Custom=All]
  • trunk/Source/WebCore/css/CSSToStyleMap.cpp

    r181593 r181602  
    3030
    3131#include "Animation.h"
     32#include "CSSAnimationTriggerScrollValue.h"
    3233#include "CSSBorderImageSliceValue.h"
    3334#include "CSSImageGeneratorValue.h"
     
    514515}
    515516
     517#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     518void CSSToStyleMap::mapAnimationTrigger(Animation& animation, CSSValue& value)
     519{
     520    if (value.isInitialValue()) {
     521        animation.setTrigger(Animation::initialTrigger());
     522        return;
     523    }
     524
     525    if (value.isPrimitiveValue()) {
     526        auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     527        if (primitiveValue.getValueID() == CSSValueAuto)
     528            animation.setTrigger(AutoAnimationTrigger::create());
     529        return;
     530    }
     531
     532    if (value.isAnimationTriggerScrollValue()) {
     533        auto& scrollTrigger = downcast<CSSAnimationTriggerScrollValue>(value);
     534
     535        const CSSPrimitiveValue* startValue = downcast<CSSPrimitiveValue>(scrollTrigger.startValue());
     536        Length startLength = startValue->computeLength<Length>(m_resolver->state().cssToLengthConversionData());
     537
     538        Length endLength;
     539        if (scrollTrigger.hasEndValue()) {
     540            const CSSPrimitiveValue* endValue = downcast<CSSPrimitiveValue>(scrollTrigger.endValue());
     541            endLength = endValue->computeLength<Length>(m_resolver->state().cssToLengthConversionData());
     542        }
     543
     544        animation.setTrigger(ScrollAnimationTrigger::create(startLength, endLength));
     545    }
     546}
     547#endif
     548
    516549void CSSToStyleMap::mapNinePieceImage(CSSPropertyID property, CSSValue* value, NinePieceImage& image)
    517550{
  • trunk/Source/WebCore/css/CSSToStyleMap.h

    r181593 r181602  
    6868    void mapAnimationProperty(Animation&, CSSValue&);
    6969    void mapAnimationTimingFunction(Animation&, CSSValue&);
     70#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     71    void mapAnimationTrigger(Animation&, CSSValue&);
     72#endif
    7073
    7174    void mapNinePieceImage(CSSPropertyID, CSSValue*, NinePieceImage&);
  • trunk/Source/WebCore/css/CSSValue.cpp

    r181593 r181602  
    2929#include "CSSValue.h"
    3030
     31#include "CSSAnimationTriggerScrollValue.h"
    3132#include "CSSAspectRatioValue.h"
    3233#include "CSSBorderImageSliceValue.h"
     
    227228        case SVGPaintClass:
    228229            return compareCSSValues<SVGPaint>(*this, other);
     230#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     231        case AnimationTriggerScrollClass:
     232            return compareCSSValues<CSSAnimationTriggerScrollValue>(*this, other);
     233#endif
    229234        default:
    230235            ASSERT_NOT_REACHED();
     
    313318    case SVGPaintClass:
    314319        return downcast<SVGPaint>(*this).customCSSText();
     320#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     321    case AnimationTriggerScrollClass:
     322        return downcast<CSSAnimationTriggerScrollValue>(*this).customCSSText();
     323#endif
    315324    case WebKitCSSResourceClass:
    316325        return downcast<WebKitCSSResourceValue>(*this).customCSSText();
     
    427436        delete downcast<SVGPaint>(this);
    428437        return;
     438#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     439    case AnimationTriggerScrollClass:
     440        delete downcast<CSSAnimationTriggerScrollValue>(this);
     441        return;
     442#endif
    429443    case WebKitCSSResourceClass:
    430444        delete downcast<WebKitCSSResourceValue>(this);
  • trunk/Source/WebCore/css/CSSValue.h

    r181593 r181602  
    106106    bool isWebKitCSSResourceValue() const { return m_classType == WebKitCSSResourceClass; }
    107107
     108#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     109    bool isAnimationTriggerScrollValue() const { return m_classType == AnimationTriggerScrollClass; }
     110#endif
     111
    108112    bool isCSSOMSafe() const { return m_isCSSOMSafe; }
    109113    bool isSubtypeExposedToCSSOM() const
     
    165169        SVGPaintClass,
    166170        WebKitCSSResourceClass,
     171
     172#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     173        AnimationTriggerScrollClass,
     174#endif
    167175
    168176        // List class types must appear after ValueListClass.
  • trunk/Source/WebCore/platform/animation/Animation.cpp

    r177821 r181602  
    3333    , m_duration(initialDuration())
    3434    , m_timingFunction(initialTimingFunction())
     35#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     36    , m_trigger(initialTrigger())
     37#endif
    3538    , m_direction(initialDirection())
    3639    , m_fillMode(initialFillMode())
     
    4548    , m_propertySet(false)
    4649    , m_timingFunctionSet(false)
     50#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     51    , m_triggerSet(false)
     52#endif
    4753    , m_isNone(false)
    4854{
     
    5864    , m_duration(o.m_duration)
    5965    , m_timingFunction(o.m_timingFunction)
     66#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     67    , m_trigger(o.m_trigger)
     68#endif
    6069    , m_direction(o.m_direction)
    6170    , m_fillMode(o.m_fillMode)
     
    7079    , m_propertySet(o.m_propertySet)
    7180    , m_timingFunctionSet(o.m_timingFunctionSet)
     81#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     82    , m_triggerSet(o.m_triggerSet)
     83#endif
    7284    , m_isNone(o.m_isNone)
    7385{
     
    8698    m_fillMode = o.m_fillMode;
    8799    m_playState = o.m_playState;
     100#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     101    m_trigger = o.m_trigger;
     102#endif
    88103
    89104    m_delaySet = o.m_delaySet;
     
    96111    m_propertySet = o.m_propertySet;
    97112    m_timingFunctionSet = o.m_timingFunctionSet;
     113#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     114    m_triggerSet = o.m_triggerSet;
     115#endif
    98116    m_isNone = o.m_isNone;
    99117
     
    117135                  && m_duration == o->m_duration
    118136                  && *(m_timingFunction.get()) == *(o->m_timingFunction.get())
     137#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     138                  && *(m_trigger.get()) == *(o->m_trigger.get())
     139#endif
    119140                  && m_direction == o->m_direction
    120141                  && m_fillMode == o->m_fillMode
     
    127148                  && m_propertySet == o->m_propertySet
    128149                  && m_timingFunctionSet == o->m_timingFunctionSet
     150#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     151                  && m_triggerSet == o->m_triggerSet
     152#endif
    129153                  && m_isNone == o->m_isNone;
    130154
  • trunk/Source/WebCore/platform/animation/Animation.h

    r181593 r181602  
    2626#define Animation_h
    2727
     28#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     29#include "AnimationTrigger.h"
     30#endif
    2831#include "CSSPropertyNames.h"
    2932#include "RenderStyleConstants.h"
     
    5154    bool isPropertySet() const { return m_propertySet; }
    5255    bool isTimingFunctionSet() const { return m_timingFunctionSet; }
     56#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     57    bool isTriggerSet() const { return m_triggerSet; }
     58#endif
    5359
    5460    // Flags this to be the special "none" animation (animation-name: none)
     
    6268        return (!m_directionSet && !m_durationSet && !m_fillModeSet
    6369                && !m_nameSet && !m_playStateSet && !m_iterationCountSet
    64                 && !m_delaySet && !m_timingFunctionSet && !m_propertySet);
     70                && !m_delaySet && !m_timingFunctionSet && !m_propertySet
     71#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     72                && !m_triggerSet);
     73#else
     74                );
     75#endif
    6576    }
    6677
     
    7990    void clearProperty() { m_propertySet = false; }
    8091    void clearTimingFunction() { m_timingFunctionSet = false; }
     92#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     93    void clearTrigger() { m_triggerSet = false; }
     94#endif
    8195
    8296    void clearAll()
     
    91105        clearProperty();
    92106        clearTimingFunction();
     107#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     108        clearTrigger();
     109#endif
    93110    }
    94111
     
    119136    EAnimPlayState playState() const { return static_cast<EAnimPlayState>(m_playState); }
    120137    CSSPropertyID property() const { return m_property; }
    121     const PassRefPtr<TimingFunction> timingFunction() const { return m_timingFunction; }
     138    PassRefPtr<TimingFunction> timingFunction() const { return m_timingFunction; }
    122139    AnimationMode animationMode() const { return m_mode; }
     140#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     141    PassRefPtr<AnimationTrigger> trigger() const { return m_trigger; }
     142#endif
    123143
    124144    void setDelay(double c) { m_delay = c; m_delaySet = true; }
     
    132152    void setTimingFunction(PassRefPtr<TimingFunction> f) { m_timingFunction = f; m_timingFunctionSet = true; }
    133153    void setAnimationMode(AnimationMode mode) { m_mode = mode; }
     154#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     155    void setTrigger(PassRefPtr<AnimationTrigger> t) { m_trigger = t; m_triggerSet = true; }
     156#endif
    134157
    135158    void setIsNoneAnimation(bool n) { m_isNone = n; }
     
    158181    double m_duration;
    159182    RefPtr<TimingFunction> m_timingFunction;
     183#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     184    RefPtr<AnimationTrigger> m_trigger;
     185#endif
    160186    unsigned m_direction : 2; // AnimationDirection
    161187    unsigned m_fillMode : 2;
     188
    162189
    163190    unsigned m_playState     : 2;
     
    172199    bool m_propertySet       : 1;
    173200    bool m_timingFunctionSet : 1;
    174    
     201#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     202    bool m_triggerSet        : 1;
     203#endif
     204
    175205    bool m_isNone            : 1;
    176206
     
    185215    static CSSPropertyID initialProperty() { return CSSPropertyInvalid; }
    186216    static const PassRefPtr<TimingFunction> initialTimingFunction() { return CubicBezierTimingFunction::create(); }
     217#if ENABLE(CSS_ANIMATIONS_LEVEL_2)
     218    static const PassRefPtr<AnimationTrigger> initialTrigger() { return AutoAnimationTrigger::create(); }
     219#endif
    187220};
    188221
Note: See TracChangeset for help on using the changeset viewer.