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..07fdb1e70cd9e96aea6773624d6e542975d66b98 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,20 @@ ImageData* ImageData::create(DOMUint8ClampedArray* data, unsigned width, unsigne |
return new ImageData(IntSize(width, height), data); |
} |
+PassRefPtrWillBeRawPtr<ImageBitmap> ImageData::createImageBitmap(EventTarget& eventTarget, ImageBitmapSource* bitmapSource, 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 nullptr; |
+ } |
+ ImageData* data = static_cast<ImageData*>(bitmapSource); |
+ if (data->data()->bufferBase()->isNeutered()) { |
+ exceptionState.throwDOMException(InvalidStateError, "The source data has been neutered."); |
+ return nullptr; |
+ } |
+ return ImageBitmap::create(data, 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); |