Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(691)

Unified Diff: Source/core/testing/Internals.cpp

Issue 1120963003: Implements getImageAnimationPolicy() at ImageLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adds Internals::advanceTimeWithImage Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/testing/Internals.cpp
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index 7fbc89d67dfcf5d943216bb5d87024fda3c2792d..d2df074f34407a87a336383e3577e884b6ca1a0e 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -82,6 +82,7 @@
#include "core/frame/Settings.h"
#include "core/html/HTMLContentElement.h"
#include "core/html/HTMLIFrameElement.h"
+#include "core/html/HTMLImageElement.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/HTMLMediaElement.h"
#include "core/html/HTMLPlugInElement.h"
@@ -421,6 +422,34 @@ void Internals::pauseAnimations(double pauseTime, ExceptionState& exceptionState
frame()->document()->timeline().pauseAnimationsForTesting(pauseTime);
}
+void Internals::advanceTimeWithImage(Element* image, double advancedTime, ExceptionState& exceptionState)
+{
+ ASSERT(image);
+ if (advancedTime < 0) {
+ exceptionState.throwDOMException(InvalidAccessError, ExceptionMessages::indexExceedsMinimumBound("advancedTime", advancedTime, 0.0));
+ return;
+ }
+
+ if (!isHTMLImageElement(*image)) {
+ exceptionState.throwDOMException(InvalidAccessError, "The element provided is not a image element.");
+ return;
+ }
+
+ ImageResource* resource = toHTMLImageElement(*image).cachedImage();
+ if (!resource || !resource->hasImage()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The image resource is not available.");
+ return;
+ }
+
+ Image* imageData = resource->image();
+ if (!imageData->isBitmapImage()) {
+ exceptionState.throwDOMException(InvalidAccessError, "The image resource is not a BitmapImage type.");
+ return;
+ }
+
+ imageData->advanceTime(advancedTime);
+}
+
bool Internals::hasShadowInsertionPoint(const Node* root, ExceptionState& exceptionState) const
{
ASSERT(root);

Powered by Google App Engine
This is Rietveld 408576698