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

Changeset 236247 in webkit


Ignore:
Timestamp:
Sep 20, 2018, 12:33:42 AM (8 years ago)
Author:
graouts@webkit.org
Message:

[Web Animations] Provide a way to query accelerated animations for internal testing
​https://bugs.webkit.org/show_bug.cgi?id=189762

Reviewed by Dean Jackson.

Expose a new internals.acceleratedAnimationsForElement(element) method to allow layout tests to query the current list
of accelerated animations for a given element. Currently only the animated property and animation speed are exposed, which
will allow us to identify missing, running and paused accelerated animations.

  • animation/DocumentTimeline.cpp:

(WebCore::DocumentTimeline::acceleratedAnimationsForElement const):

  • animation/DocumentTimeline.h:
  • platform/graphics/GraphicsLayer.h:

(WebCore::GraphicsLayer::acceleratedAnimationsForTesting const):

  • platform/graphics/ca/GraphicsLayerCA.cpp:

(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):

  • platform/graphics/ca/GraphicsLayerCA.h:
  • testing/Internals.cpp:

(WebCore::Internals::acceleratedAnimationsForElement):

  • testing/Internals.h:
  • testing/Internals.idl:
Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r236241 r236247  
     12018-09-20  Antoine Quint  <graouts@apple.com>
     2
     3        [Web Animations] Provide a way to query accelerated animations for internal testing
     4        https://bugs.webkit.org/show_bug.cgi?id=189762
     5
     6        Reviewed by Dean Jackson.
     7
     8        Expose a new internals.acceleratedAnimationsForElement(element) method to allow layout tests to query the current list
     9        of accelerated animations for a given element. Currently only the animated property and animation speed are exposed, which
     10        will allow us to identify missing, running and paused accelerated animations.
     11
     12        * animation/DocumentTimeline.cpp:
     13        (WebCore::DocumentTimeline::acceleratedAnimationsForElement const):
     14        * animation/DocumentTimeline.h:
     15        * platform/graphics/GraphicsLayer.h:
     16        (WebCore::GraphicsLayer::acceleratedAnimationsForTesting const):
     17        * platform/graphics/ca/GraphicsLayerCA.cpp:
     18        (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
     19        * platform/graphics/ca/GraphicsLayerCA.h:
     20        * testing/Internals.cpp:
     21        (WebCore::Internals::acceleratedAnimationsForElement):
     22        * testing/Internals.h:
     23        * testing/Internals.idl:
     24
    1252018-09-19  Ryosuke Niwa  <rniwa@webkit.org>
    226
  • trunk/Source/WebCore/animation/DocumentTimeline.cpp

    r234279 r236247  
    3232#include "DeclarativeAnimation.h"
    3333#include "Document.h"
     34#include "GraphicsLayer.h"
    3435#include "KeyframeEffect.h"
    3536#include "Microtasks.h"
    3637#include "Page.h"
    3738#include "RenderElement.h"
     39#include "RenderLayer.h"
     40#include "RenderLayerBacking.h"
    3841
    3942static const Seconds defaultAnimationInterval { 15_ms };
    … …  
    486489}
    487490
     491Vector<std::pair<String, double>> DocumentTimeline::acceleratedAnimationsForElement(Element& element) const
     492{
     493    auto* renderer = element.renderer();
     494    if (renderer && renderer->isComposited()) {
     495        auto* compositedRenderer = downcast<RenderBoxModelObject>(renderer);
     496        if (auto* graphicsLayer = compositedRenderer->layer()->backing()->graphicsLayer())
     497            return graphicsLayer->acceleratedAnimationsForTesting();
     498    }
     499    return { };
     500}
     501
    488502} // namespace WebCore
  • trunk/Source/WebCore/animation/DocumentTimeline.h

    r234250 r236247  
    7676    WEBCORE_EXPORT bool animationsAreSuspended();
    7777    WEBCORE_EXPORT unsigned numberOfActiveAnimationsForTesting() const;
     78    WEBCORE_EXPORT Vector<std::pair<String, double>> acceleratedAnimationsForElement(Element&) const;   
    7879
    7980private:
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r236016 r236247  
    462462    WEBCORE_EXPORT virtual void resumeAnimations();
    463463
     464    virtual Vector<std::pair<String, double>> acceleratedAnimationsForTesting() const { return { }; }
     465
    464466    // Layer contents
    465467    virtual void setContentsToImage(Image*) { }
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r236016 r236247  
    42174217}
    42184218
     4219static String animatedPropertyIDAsString(AnimatedPropertyID property)
     4220{
     4221    if (property == AnimatedPropertyTransform)
     4222        return "transform";
     4223    if (property == AnimatedPropertyOpacity)
     4224        return "opacity";
     4225    if (property == AnimatedPropertyBackgroundColor)
     4226        return "background-color";
     4227    if (property == AnimatedPropertyFilter)
     4228        return "filter";
     4229    if (property == AnimatedPropertyInvalid)
     4230        return "invalid";
     4231#if ENABLE(FILTERS_LEVEL_2)
     4232    if (property == AnimatedPropertyWebkitBackdropFilter)
     4233        return "backdrop-filter";
     4234#endif
     4235    return "";
     4236}
     4237
     4238Vector<std::pair<String, double>> GraphicsLayerCA::acceleratedAnimationsForTesting() const
     4239{
     4240    Vector<std::pair<String, double>> animations;
     4241
     4242    if (hasAnimations()) {
     4243        for (auto it : m_animations->runningAnimations) {
     4244            auto& propertyAnimations = it.value;
     4245            size_t numAnimations = propertyAnimations.size();
     4246            for (size_t i = 0; i < numAnimations; ++i) {
     4247                const LayerPropertyAnimation& currAnimation = propertyAnimations[i];
     4248                animations.append({ animatedPropertyIDAsString(currAnimation.m_property), currAnimation.m_animation->speed() });
     4249            }
     4250        }
     4251    }
     4252
     4253    return animations;
     4254}
     4255
    42194256} // namespace WebCore
    42204257
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r236016 r236247  
    171171
    172172    WEBCORE_EXPORT TiledBacking* tiledBacking() const override;
     173
     174    WEBCORE_EXPORT Vector<std::pair<String, double>> acceleratedAnimationsForTesting() const final;
    173175
    174176protected:
  • trunk/Source/WebCore/testing/Internals.cpp

    r236094 r236247  
    10661066}
    10671067
     1068Vector<Internals::AcceleratedAnimation> Internals::acceleratedAnimationsForElement(Element& element)
     1069{
     1070    if (!RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled())
     1071        return { };
     1072
     1073    Vector<Internals::AcceleratedAnimation> animations;
     1074    for (auto animationAsPair : element.document().timeline().acceleratedAnimationsForElement(element))
     1075        animations.append({ animationAsPair.first, animationAsPair.second });
     1076    return animations;
     1077}
     1078
    10681079ExceptionOr<RefPtr<Element>> Internals::pseudoElement(Element& element, const String& pseudoId)
    10691080{
  • trunk/Source/WebCore/testing/Internals.h

    r236094 r236247  
    201201    ExceptionOr<bool> pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element&, const String& pseudoId);
    202202
     203    // Web Animations testing.
     204    struct AcceleratedAnimation {
     205        String property;
     206        double speed;
     207    };
     208    Vector<AcceleratedAnimation> acceleratedAnimationsForElement(Element&);
     209
    203210    // For animations testing, we need a way to get at pseudo elements.
    204211    ExceptionOr<RefPtr<Element>> pseudoElement(Element&, const String&);
  • trunk/Source/WebCore/testing/Internals.idl

    r236094 r236247  
    138138[
    139139    ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
     140    JSGenerateToJSObject,
     141] dictionary AcceleratedAnimation {
     142    DOMString property;
     143    double speed;
     144};
     145
     146[
     147    ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
    140148    NoInterfaceObject,
    141149] interface Internals {
    … …  
    201209    [MayThrowException] boolean pauseTransitionAtTimeOnElement(DOMString propertyName, unrestricted double pauseTime, Element element);
    202210    [MayThrowException] boolean pauseTransitionAtTimeOnPseudoElement(DOMString property, unrestricted double pauseTime, Element element, DOMString pseudoId);
     211
     212    // Web Animations testing.
     213    sequence<AcceleratedAnimation> acceleratedAnimationsForElement(Element element);
    203214
    204215    // For animations testing, we need a way to get at pseudo elements.
Note: See TracChangeset for help on using the changeset viewer.