Index: third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
diff --git a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
index 47dfe4296a9a8aeefa3b9b225774817d354caf02..e04ea2b304f96f0bc3e3c80e013ff43918bbac47 100644 |
--- a/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
+++ b/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp |
@@ -35,6 +35,7 @@ |
#include "core/dom/Document.h" |
#include "core/dom/ExceptionCode.h" |
#include "core/fileapi/File.h" |
+#include "core/frame/ImageBitmap.h" |
#include "core/frame/LocalFrame.h" |
#include "core/frame/Settings.h" |
#include "core/html/ImageData.h" |
@@ -933,6 +934,25 @@ FloatSize HTMLCanvasElement::elementSize() const |
return FloatSize(width(), height()); |
} |
+IntSize HTMLCanvasElement::bitmapSourceSize() const |
+{ |
+ return IntSize(width(), height()); |
+} |
+ |
+ScriptPromise HTMLCanvasElement::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, int sx, int sy, int sw, int sh, ExceptionState& exceptionState) |
+{ |
+ ASSERT(eventTarget.toDOMWindow()); |
+ if (!originClean()) { |
+ exceptionState.throwSecurityError("The canvas element provided is tainted with cross-origin data."); |
+ return ScriptPromise(); |
+ } |
+ if (!sw || !sh) { |
+ exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width")); |
+ return ScriptPromise(); |
+ } |
+ return ImageBitmapSource::fulfillImageBitmap(scriptState, isPaintable() ? ImageBitmap::create(this, IntRect(sx, sy, sw, sh)) : nullptr); |
+} |
+ |
bool HTMLCanvasElement::isOpaque() const |
{ |
return m_context && !m_context->hasAlpha(); |