Index: third_party/WebKit/Source/core/html/ImageData.cpp |
diff --git a/third_party/WebKit/Source/core/html/ImageData.cpp b/third_party/WebKit/Source/core/html/ImageData.cpp |
index f0cec65d2ecd00cf4d5c6b57a1d593615b16ecda..d44a311b2fecd1259ac6c44dfcdb2542ac9f27ca 100644 |
--- a/third_party/WebKit/Source/core/html/ImageData.cpp |
+++ b/third_party/WebKit/Source/core/html/ImageData.cpp |
@@ -32,6 +32,7 @@ |
#include "bindings/core/v8/ExceptionState.h" |
#include "bindings/core/v8/V8Uint8ClampedArray.h" |
#include "core/dom/ExceptionCode.h" |
+#include "core/frame/ImageBitmap.h" |
#include "platform/RuntimeEnabledFeatures.h" |
namespace blink { |
@@ -146,6 +147,19 @@ ImageData* ImageData::create(DOMUint8ClampedArray* data, unsigned width, unsigne |
return new ImageData(IntSize(width, height), data); |
} |
+ScriptPromise ImageData::createImageBitmap(ScriptState* scriptState, EventTarget& eventTarget, int sx, int sy, int sw, int sh, ExceptionState& exceptionState) |
+{ |
+ if (!sw || !sh) { |
+ exceptionState.throwDOMException(IndexSizeError, String::format("The source %s provided is 0.", sw ? "height" : "width")); |
+ return ScriptPromise(); |
+ } |
+ if (data()->bufferBase()->isNeutered()) { |
+ exceptionState.throwDOMException(InvalidStateError, "The source data has been neutered."); |
+ return ScriptPromise(); |
+ } |
+ return ImageBitmapSource::fulfillImageBitmap(scriptState, ImageBitmap::create(this, IntRect(sx, sy, sw, sh))); |
+} |
+ |
v8::Local<v8::Object> ImageData::associateWithWrapper(v8::Isolate* isolate, const WrapperTypeInfo* wrapperType, v8::Local<v8::Object> wrapper) |
{ |
wrapper = ScriptWrappable::associateWithWrapper(isolate, wrapperType, wrapper); |