Commit 6a8271a7 authored by hausmann@webkit.org's avatar hausmann@webkit.org
Browse files

[Qt] Port the Qt pixmap JS bindings to use the JSC C API

https://bugs.webkit.org/show_bug.cgi?id=94702

Reviewed by Kenneth Rohde Christiansen.

Based on patch by Noam Rosenthal.

The conversion uses a simple JSClassRef based binding and only a few
uses of private JSC API for the HTML element DOM bindings remain.

This is essentially used for wrapping QPixmap and QImage types in
JavaScript and the other way around, for retrieving the image data
out of a HTML image element when converting from JS/DOM to Qt.

* bridge/qt/qt_pixmapruntime.cpp:
(JSC::Bindings::copyPixels):
(JSC::Bindings::toPixmap):
(JSC::Bindings::toImage):
(JSC::Bindings::imageSizeForVariant):
(JSC::Bindings::getPixmapWidth):
(JSC::Bindings::getPixmapHeight):
(JSC::Bindings::assignToHTMLImageElement):
(JSC::Bindings::pixmapToImageData):
(JSC::Bindings::pixmapToDataUrl):
(JSC::Bindings::pixmapToString):
(JSC::Bindings::QtPixmapRuntime::toJS):
(JSC::Bindings::QtPixmapRuntime::toQt):
(JSC::Bindings::QtPixmapRuntime::canHandle):
(JSC::Bindings::QtPixmapRuntime::getClassRef):
* bridge/qt/qt_pixmapruntime.h:
(QtPixmapRuntime):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertValueToQVariant):
(JSC::Bindings::convertQVariantToValue):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127440 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2c4064a2
2012-08-31 Simon Hausmann <simon.hausmann@nokia.com>
[Qt] Port the Qt pixmap JS bindings to use the JSC C API
https://bugs.webkit.org/show_bug.cgi?id=94702
Reviewed by Kenneth Rohde Christiansen.
Based on patch by Noam Rosenthal.
The conversion uses a simple JSClassRef based binding and only a few
uses of private JSC API for the HTML element DOM bindings remain.
This is essentially used for wrapping QPixmap and QImage types in
JavaScript and the other way around, for retrieving the image data
out of a HTML image element when converting from JS/DOM to Qt.
* bridge/qt/qt_pixmapruntime.cpp:
(JSC::Bindings::copyPixels):
(JSC::Bindings::toPixmap):
(JSC::Bindings::toImage):
(JSC::Bindings::imageSizeForVariant):
(JSC::Bindings::getPixmapWidth):
(JSC::Bindings::getPixmapHeight):
(JSC::Bindings::assignToHTMLImageElement):
(JSC::Bindings::pixmapToImageData):
(JSC::Bindings::pixmapToDataUrl):
(JSC::Bindings::pixmapToString):
(JSC::Bindings::QtPixmapRuntime::toJS):
(JSC::Bindings::QtPixmapRuntime::toQt):
(JSC::Bindings::QtPixmapRuntime::canHandle):
(JSC::Bindings::QtPixmapRuntime::getClassRef):
* bridge/qt/qt_pixmapruntime.h:
(QtPixmapRuntime):
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertValueToQVariant):
(JSC::Bindings::convertQVariantToValue):
2012-09-03 Andreas Kling <kling@webkit.org>
 
Share immutable ElementAttributeData between elements with identical attributes.
......@@ -21,31 +21,20 @@
#define qt_pixmapruntime_h
#include "BridgeJSC.h"
#include "JavaScript.h"
#include <QVariant>
namespace JSC {
namespace Bindings {
class QtPixmapInstance : public Instance {
QVariant data;
class QtPixmapRuntime {
public:
QtPixmapInstance(PassRefPtr<RootObject> rootObj, const QVariant& newData);
virtual Class* getClass() const;
virtual JSValue getMethod(ExecState*, PropertyName);
virtual JSValue invokeMethod(ExecState*, RuntimeMethod*);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const;
virtual JSValue valueOf(ExecState*) const;
int width() const;
int height() const;
QPixmap toPixmap();
QImage toImage();
RuntimeObject* newRuntimeObject(ExecState*);
static JSObject* createPixmapRuntimeObject(ExecState*, PassRefPtr<RootObject>, const QVariant&);
static QVariant variantFromObject(JSObject*, QMetaType::Type hint);
static JSObjectRef toJS(JSContextRef, const QVariant&, JSValueRef* exception);
static QVariant toQt(JSContextRef, JSObjectRef, QMetaType::Type hint, JSValueRef* exception);
static bool canHandle(QMetaType::Type hint);
static JSClassRef getClassRef();
};
}
......
......@@ -623,8 +623,8 @@ QVariant convertValueToQVariant(JSContextRef context, JSValueRef value, QMetaTyp
ret = QVariant::fromValue(convertToList<int>(context, type, object, value, &dist, exception));
break;
}
if (QtPixmapInstance::canHandle(static_cast<QMetaType::Type>(hint))) {
ret = QtPixmapInstance::variantFromObject(toJS(object), static_cast<QMetaType::Type>(hint));
if (QtPixmapRuntime::canHandle(static_cast<QMetaType::Type>(hint))) {
ret = QtPixmapRuntime::toQt(context, object, static_cast<QMetaType::Type>(hint), exception);
} else if (customRuntimeConversions()->contains(hint)) {
ret = customRuntimeConversions()->value(hint).toVariantFunc(toJS(object), &dist, visitedObjects);
if (dist == 0)
......@@ -740,10 +740,8 @@ JSValueRef convertQVariantToValue(JSContextRef context, PassRefPtr<RootObject> r
return toRef(exec, QtInstance::getQtInstance(obj, root, QtInstance::QtOwnership)->createRuntimeObject(exec));
}
if (QtPixmapInstance::canHandle(static_cast<QMetaType::Type>(variant.type()))) {
ExecState* exec = toJS(context);
return toRef(exec, QtPixmapInstance::createPixmapRuntimeObject(exec, root, variant));
}
if (QtPixmapRuntime::canHandle(static_cast<QMetaType::Type>(variant.type())))
return QtPixmapRuntime::toJS(context, variant, exception);
if (customRuntimeConversions()->contains(type)) {
if (!root->globalObject()->inherits(&JSDOMWindow::s_info))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment