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

Unified Diff: third_party/WebKit/Source/core/html/HTMLCanvasElement.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/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();
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLCanvasElement.h ('k') | third_party/WebKit/Source/core/html/HTMLImageElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698