Index: third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
index fe5170644016ab7a1e42efe73e22ff1a051996b1..1668a4af2fe35662263c9cd6f4e94fdd24111a53 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLVideoElement.cpp |
@@ -34,6 +34,7 @@ |
#include "core/dom/ExceptionCode.h" |
#include "core/dom/Fullscreen.h" |
#include "core/dom/shadow/ShadowRoot.h" |
+#include "core/frame/ImageBitmap.h" |
#include "core/frame/Settings.h" |
#include "core/html/parser/HTMLParserIdioms.h" |
#include "core/layout/LayoutImage.h" |
@@ -320,4 +321,37 @@ FloatSize HTMLVideoElement::elementSize() const |
return FloatSize(videoWidth(), videoHeight()); |
} |
+IntSize HTMLVideoElement::bitmapSourceSize() |
+{ |
+ return IntSize(videoWidth(), videoHeight()); |
+} |
+ |
+PassRefPtrWillBeRawPtr<ImageBitmap> HTMLVideoElement::createImageBitmap(EventTarget& eventTarget, ImageBitmapSource* bitmapSource, int sx, int sy, int sw, int sh, ExceptionState& exceptionState) |
+{ |
+ ASSERT(eventTarget.toDOMWindow()); |
+ HTMLVideoElement* video = static_cast<HTMLVideoElement*>(bitmapSource); |
+ if (video->networkState() == HTMLMediaElement::NETWORK_EMPTY) { |
+ exceptionState.throwDOMException(InvalidStateError, "The provided element has not retrieved data."); |
+ return nullptr; |
+ } |
+ if (video->readyState() <= HTMLMediaElement::HAVE_METADATA) { |
+ exceptionState.throwDOMException(InvalidStateError, "The provided element's player has no current data."); |
+ return nullptr; |
+ } |
+ if (!sw || !sh) { |
+ exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width")); |
+ return nullptr; |
+ } |
+ if (!video->hasSingleSecurityOrigin()) { |
+ exceptionState.throwSecurityError("The source video contains image data from multiple origins."); |
+ return nullptr; |
+ } |
+ if (!video->webMediaPlayer()->didPassCORSAccessCheck() |
+ && eventTarget.toDOMWindow()->document()->securityOrigin()->taintsCanvas(video->currentSrc())) { |
+ exceptionState.throwSecurityError("Cross-origin access to the source video is denied."); |
+ return nullptr; |
+ } |
+ return ImageBitmap::create(video, IntRect(sx, sy, sw, sh)); |
+} |
+ |
} // namespace blink |