JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, ImageData* imageData) { if (!imageData) return jsNull(); JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), imageData); if (wrapper) return wrapper; wrapper = CREATE_DOM_WRAPPER(exec, globalObject, ImageData, imageData); Identifier dataName(exec, "data"); wrapper->putDirect(exec->globalData(), dataName, toJS(exec, globalObject, imageData->data()), DontDelete | ReadOnly); exec->heap()->reportExtraMemoryCost(imageData->data()->length()); return wrapper; }
JSValue toJS(ExecState* exec, JSDOMGlobalObject* globalObject, ImageData* imageData) { if (!imageData) return jsNull(); JSDOMWrapper* wrapper = getCachedWrapper(currentWorld(exec), imageData); if (wrapper) return wrapper; wrapper = CREATE_DOM_WRAPPER(exec, globalObject, ImageData, imageData); Identifier dataName(exec, "data"); static const ClassInfo cpaClassInfo = { "CanvasPixelArray", &JSByteArray::Base::s_info, 0, 0 }; DEFINE_STATIC_LOCAL(Strong<Structure>, cpaStructure, (exec->globalData(), JSByteArray::createStructure(exec->globalData(), jsNull(), &cpaClassInfo))); wrapper->putDirect(exec->globalData(), dataName, new (exec) JSByteArray(exec, cpaStructure.get(), imageData->data()->data()), DontDelete | ReadOnly); exec->heap()->reportExtraMemoryCost(imageData->data()->length()); return wrapper; }