JSValue invoke(ExecState* exec, QtPixmapInstance* instance) { if (!exec->argumentCount()) return jsUndefined(); JSObject* objectArg = exec->argument(0).toObject(exec); if (!objectArg) return jsUndefined(); if (!objectArg->inherits(&JSHTMLImageElement::s_info)) return jsUndefined(); // we now know that we have a valid <img> element as the argument, we can attach the pixmap to it. PassRefPtr<StillImage> stillImage = WebCore::StillImage::create(instance->toPixmap()); HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(static_cast<JSHTMLImageElement*>(objectArg)->impl()); imageElement->setCachedImage(new CachedImage(stillImage.get())); JSDOMGlobalObject* global = static_cast<JSDOMGlobalObject*>(instance->rootObject()->globalObject()); toJS(exec, global, imageElement->document()); return jsUndefined(); }
static JSValueRef assignToHTMLImageElement(JSContextRef context, JSObjectRef function, JSObjectRef object, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) { if (!argumentCount) return JSValueMakeUndefined(context); JSObjectRef objectArg = JSValueToObject(context, arguments[0], exception); if (!objectArg) return JSValueMakeUndefined(context); JSObject* jsObject = ::toJS(objectArg); if (!jsObject->inherits(&JSHTMLImageElement::s_info)) return JSValueMakeUndefined(context); QVariant& data = *static_cast<QVariant*>(JSObjectGetPrivate(object)); // We now know that we have a valid <img> element as the argument, we can attach the image to it. RefPtr<StillImage> stillImage = WebCore::StillImage::create(toImage(data)); HTMLImageElement* imageElement = static_cast<HTMLImageElement*>(static_cast<JSHTMLImageElement*>(jsObject)->impl()); imageElement->setCachedImage(new CachedImage(stillImage.get())); return JSValueMakeUndefined(context); }