Diff
Modified: trunk/Source/WebCore/ChangeLog (236246 => 236247)
--- trunk/Source/WebCore/ChangeLog 2018-09-20 07:21:05 UTC (rev 236246)
+++ trunk/Source/WebCore/ChangeLog 2018-09-20 07:33:42 UTC (rev 236247)
@@ -1,3 +1,27 @@
+2018-09-20 Antoine Quint <[email protected]>
+
+ [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:
+
2018-09-19 Ryosuke Niwa <[email protected]>
Improve node statistics for rare data
Modified: trunk/Source/WebCore/animation/DocumentTimeline.cpp (236246 => 236247)
--- trunk/Source/WebCore/animation/DocumentTimeline.cpp 2018-09-20 07:21:05 UTC (rev 236246)
+++ trunk/Source/WebCore/animation/DocumentTimeline.cpp 2018-09-20 07:33:42 UTC (rev 236247)
@@ -31,10 +31,13 @@
#include "DOMWindow.h"
#include "DeclarativeAnimation.h"
#include "Document.h"
+#include "GraphicsLayer.h"
#include "KeyframeEffect.h"
#include "Microtasks.h"
#include "Page.h"
#include "RenderElement.h"
+#include "RenderLayer.h"
+#include "RenderLayerBacking.h"
static const Seconds defaultAnimationInterval { 15_ms };
static const Seconds throttledAnimationInterval { 30_ms };
@@ -485,4 +488,15 @@
pendingEvent->target()->dispatchEvent(pendingEvent);
}
+Vector<std::pair<String, double>> DocumentTimeline::acceleratedAnimationsForElement(Element& element) const
+{
+ auto* renderer = element.renderer();
+ if (renderer && renderer->isComposited()) {
+ auto* compositedRenderer = downcast<RenderBoxModelObject>(renderer);
+ if (auto* graphicsLayer = compositedRenderer->layer()->backing()->graphicsLayer())
+ return graphicsLayer->acceleratedAnimationsForTesting();
+ }
+ return { };
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/animation/DocumentTimeline.h (236246 => 236247)
--- trunk/Source/WebCore/animation/DocumentTimeline.h 2018-09-20 07:21:05 UTC (rev 236246)
+++ trunk/Source/WebCore/animation/DocumentTimeline.h 2018-09-20 07:33:42 UTC (rev 236247)
@@ -75,6 +75,7 @@
WEBCORE_EXPORT void resumeAnimations();
WEBCORE_EXPORT bool animationsAreSuspended();
WEBCORE_EXPORT unsigned numberOfActiveAnimationsForTesting() const;
+ WEBCORE_EXPORT Vector<std::pair<String, double>> acceleratedAnimationsForElement(Element&) const;
private:
DocumentTimeline(Document&, Seconds);
Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (236246 => 236247)
--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h 2018-09-20 07:21:05 UTC (rev 236246)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h 2018-09-20 07:33:42 UTC (rev 236247)
@@ -461,6 +461,8 @@
WEBCORE_EXPORT virtual void suspendAnimations(MonotonicTime);
WEBCORE_EXPORT virtual void resumeAnimations();
+ virtual Vector<std::pair<String, double>> acceleratedAnimationsForTesting() const { return { }; }
+
// Layer contents
virtual void setContentsToImage(Image*) { }
virtual bool shouldDirectlyCompositeImage(Image*) const { return true; }
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (236246 => 236247)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2018-09-20 07:21:05 UTC (rev 236246)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp 2018-09-20 07:33:42 UTC (rev 236247)
@@ -4216,6 +4216,43 @@
return m_layer->backingStoreBytesPerPixel() * size().width() * m_layer->contentsScale() * size().height() * m_layer->contentsScale();
}
+static String animatedPropertyIDAsString(AnimatedPropertyID property)
+{
+ if (property == AnimatedPropertyTransform)
+ return "transform";
+ if (property == AnimatedPropertyOpacity)
+ return "opacity";
+ if (property == AnimatedPropertyBackgroundColor)
+ return "background-color";
+ if (property == AnimatedPropertyFilter)
+ return "filter";
+ if (property == AnimatedPropertyInvalid)
+ return "invalid";
+#if ENABLE(FILTERS_LEVEL_2)
+ if (property == AnimatedPropertyWebkitBackdropFilter)
+ return "backdrop-filter";
+#endif
+ return "";
+}
+
+Vector<std::pair<String, double>> GraphicsLayerCA::acceleratedAnimationsForTesting() const
+{
+ Vector<std::pair<String, double>> animations;
+
+ if (hasAnimations()) {
+ for (auto it : m_animations->runningAnimations) {
+ auto& propertyAnimations = it.value;
+ size_t numAnimations = propertyAnimations.size();
+ for (size_t i = 0; i < numAnimations; ++i) {
+ const LayerPropertyAnimation& currAnimation = propertyAnimations[i];
+ animations.append({ animatedPropertyIDAsString(currAnimation.m_property), currAnimation.m_animation->speed() });
+ }
+ }
+ }
+
+ return animations;
+}
+
} // namespace WebCore
#endif
Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (236246 => 236247)
--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2018-09-20 07:21:05 UTC (rev 236246)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h 2018-09-20 07:33:42 UTC (rev 236247)
@@ -171,6 +171,8 @@
WEBCORE_EXPORT TiledBacking* tiledBacking() const override;
+ WEBCORE_EXPORT Vector<std::pair<String, double>> acceleratedAnimationsForTesting() const final;
+
protected:
WEBCORE_EXPORT void setOpacityInternal(float) override;
Modified: trunk/Source/WebCore/testing/Internals.cpp (236246 => 236247)
--- trunk/Source/WebCore/testing/Internals.cpp 2018-09-20 07:21:05 UTC (rev 236246)
+++ trunk/Source/WebCore/testing/Internals.cpp 2018-09-20 07:33:42 UTC (rev 236247)
@@ -1065,6 +1065,17 @@
return frame()->animation().pauseTransitionAtTime(*pseudoElement, property, pauseTime);
}
+Vector<Internals::AcceleratedAnimation> Internals::acceleratedAnimationsForElement(Element& element)
+{
+ if (!RuntimeEnabledFeatures::sharedFeatures().webAnimationsCSSIntegrationEnabled())
+ return { };
+
+ Vector<Internals::AcceleratedAnimation> animations;
+ for (auto animationAsPair : element.document().timeline().acceleratedAnimationsForElement(element))
+ animations.append({ animationAsPair.first, animationAsPair.second });
+ return animations;
+}
+
ExceptionOr<RefPtr<Element>> Internals::pseudoElement(Element& element, const String& pseudoId)
{
if (pseudoId != "before" && pseudoId != "after")
Modified: trunk/Source/WebCore/testing/Internals.h (236246 => 236247)
--- trunk/Source/WebCore/testing/Internals.h 2018-09-20 07:21:05 UTC (rev 236246)
+++ trunk/Source/WebCore/testing/Internals.h 2018-09-20 07:33:42 UTC (rev 236247)
@@ -200,6 +200,13 @@
ExceptionOr<bool> pauseTransitionAtTimeOnElement(const String& propertyName, double pauseTime, Element&);
ExceptionOr<bool> pauseTransitionAtTimeOnPseudoElement(const String& property, double pauseTime, Element&, const String& pseudoId);
+ // Web Animations testing.
+ struct AcceleratedAnimation {
+ String property;
+ double speed;
+ };
+ Vector<AcceleratedAnimation> acceleratedAnimationsForElement(Element&);
+
// For animations testing, we need a way to get at pseudo elements.
ExceptionOr<RefPtr<Element>> pseudoElement(Element&, const String&);
Modified: trunk/Source/WebCore/testing/Internals.idl (236246 => 236247)
--- trunk/Source/WebCore/testing/Internals.idl 2018-09-20 07:21:05 UTC (rev 236246)
+++ trunk/Source/WebCore/testing/Internals.idl 2018-09-20 07:33:42 UTC (rev 236247)
@@ -137,6 +137,14 @@
[
ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
+ JSGenerateToJSObject,
+] dictionary AcceleratedAnimation {
+ DOMString property;
+ double speed;
+};
+
+[
+ ExportMacro=WEBCORE_TESTSUPPORT_EXPORT,
NoInterfaceObject,
] interface Internals {
DOMString address(Node node);
@@ -201,6 +209,9 @@
[MayThrowException] boolean pauseTransitionAtTimeOnElement(DOMString propertyName, unrestricted double pauseTime, Element element);
[MayThrowException] boolean pauseTransitionAtTimeOnPseudoElement(DOMString property, unrestricted double pauseTime, Element element, DOMString pseudoId);
+ // Web Animations testing.
+ sequence<AcceleratedAnimation> acceleratedAnimationsForElement(Element element);
+
// For animations testing, we need a way to get at pseudo elements.
[MayThrowException] Element? pseudoElement(Element element, DOMString pseudoId);