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

Unified Diff: third_party/WebKit/Source/core/html/HTMLVideoElement.cpp

Issue 1455763002: Use union type in ImageBitmapFactories.idl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better argument passing Created 5 years, 1 month 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: 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..9cf6fc1c99bd67c11fd7c240fe1861e8db427e9b 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,36 @@ FloatSize HTMLVideoElement::elementSize() const
return FloatSize(videoWidth(), videoHeight());
}
+IntSize HTMLVideoElement::bitmapSourceSize() const
+{
+ return IntSize(videoWidth(), videoHeight());
+}
+
+ScriptPromise HTMLVideoElement::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, int sx, int sy, int sw, int sh, ExceptionState& exceptionState)
+{
+ ASSERT(eventTarget.toDOMWindow());
+ if (networkState() == HTMLMediaElement::NETWORK_EMPTY) {
+ exceptionState.throwDOMException(InvalidStateError, "The provided element has not retrieved data.");
+ return ScriptPromise();
+ }
+ if (readyState() <= HTMLMediaElement::HAVE_METADATA) {
+ exceptionState.throwDOMException(InvalidStateError, "The provided element's player has no current data.");
+ return ScriptPromise();
+ }
+ if (!sw || !sh) {
+ exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width"));
+ return ScriptPromise();
+ }
+ if (!hasSingleSecurityOrigin()) {
+ exceptionState.throwSecurityError("The source video contains image data from multiple origins.");
+ return ScriptPromise();
+ }
+ if (!webMediaPlayer()->didPassCORSAccessCheck()
+ && eventTarget.toDOMWindow()->document()->securityOrigin()->taintsCanvas(currentSrc())) {
+ exceptionState.throwSecurityError("Cross-origin access to the source video is denied.");
+ return ScriptPromise();
+ }
+ return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::create(this, IntRect(sx, sy, sw, sh)));
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLVideoElement.h ('k') | third_party/WebKit/Source/core/html/ImageData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698