summaryrefslogtreecommitdiff
path: root/Source/WebCore/bindings/js/JSImageDataCustom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/bindings/js/JSImageDataCustom.cpp')
-rw-r--r--Source/WebCore/bindings/js/JSImageDataCustom.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/Source/WebCore/bindings/js/JSImageDataCustom.cpp b/Source/WebCore/bindings/js/JSImageDataCustom.cpp
index 1576d5e58..518b5ef13 100644
--- a/Source/WebCore/bindings/js/JSImageDataCustom.cpp
+++ b/Source/WebCore/bindings/js/JSImageDataCustom.cpp
@@ -26,7 +26,10 @@
#include "config.h"
#include "JSImageData.h"
-#include "ImageData.h"
+#include "JSDOMConvertBufferSource.h"
+#include "JSDOMWrapperCache.h"
+#include <heap/HeapInlines.h>
+#include <runtime/IdentifierInlines.h>
#include <wtf/StdLibExtras.h>
#include <wtf/text/WTFString.h>
@@ -34,21 +37,22 @@ using namespace JSC;
namespace WebCore {
-JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, ImageData* imageData)
+JSValue toJSNewlyCreated(ExecState* state, JSDOMGlobalObject* globalObject, Ref<ImageData>&& imageData)
{
- if (!imageData)
- return jsNull();
-
- JSObject* wrapper = getCachedWrapper(currentWorld(exec), imageData);
- if (wrapper)
- return wrapper;
-
- wrapper = CREATE_DOM_WRAPPER(exec, globalObject, ImageData, imageData);
- Identifier dataName(exec, "data");
- wrapper->putDirect(exec->vm(), dataName, toJS(exec, globalObject, imageData->data()), DontDelete | ReadOnly);
- exec->heap()->reportExtraMemoryCost(imageData->data()->length());
+ auto* data = imageData->data();
+ auto* wrapper = createWrapper<ImageData>(globalObject, WTFMove(imageData));
+ Identifier dataName = Identifier::fromString(state, "data");
+ wrapper->putDirect(state->vm(), dataName, toJS(state, globalObject, data), DontDelete | ReadOnly);
+ // FIXME: Adopt reportExtraMemoryVisited, and switch to reportExtraMemoryAllocated.
+ // https://bugs.webkit.org/show_bug.cgi?id=142595
+ state->heap()->deprecatedReportExtraMemory(data->length());
return wrapper;
}
+JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, ImageData& imageData)
+{
+ return wrap(state, globalObject, imageData);
+}
+
}