Changeset 53611 in webkit


Ignore:
Timestamp:
Jan 21, 2010 12:25:21 AM (14 years ago)
Author:
Simon Hausmann
Message:

WebCore: [Qt] Adding QPixmap/QImage support for the Qt hybrid layer

Allows accesing QPixmap and QImage based arguments from Qt signals,
slots and properties
This is done by an intermediate object that can be turned into
web-based objects by calling either toHTMLImageElement() or
toDataURL()

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

Patch by No'am Rosenthal <noam.rosenthal@nokia.com> on 2010-01-21
Reviewed by Simon Hausmann.

Tests are in WebKit/qt/tests/hybridPixmap

  • WebCore.pro:
  • bridge/qt/qt_pixmapruntime.cpp: Added.

(JSC::Bindings::QtPixmapWidthField::name): "width"
(JSC::Bindings::QtPixmapWidthField::valueFromInstance): width of
pixmap
(JSC::Bindings::QtPixmapWidthField::setValueToInstance): nothing
(JSC::Bindings::QtPixmapHeightField::name): "height"
(JSC::Bindings::QtPixmapHeightField::valueFromInstance): height of
pixmap
(JSC::Bindings::QtPixmapHeightField::setValueToInstance): nothing
(JSC::Bindings::QtPixmapRuntimeMethod::numParameters): 0
(JSC::Bindings::QtPixmapCreateElementMethod::name): toHTMLImageElement
(JSC::Bindings::QtPixmapCreateElementMethod::invoke): creates an HTML
element from the QPixmap
(JSC::Bindings::QtPixmapToDataUrlMethod::name): "toDataURL"
(JSC::Bindings::QtPixmapToDataUrlMethod::invoke): encodes the image to
a base64 data url
(JSC::Bindings::QtPixmapToStringMethod::name): "toString"
(JSC::Bindings::QtPixmapToStringMethod::invoke): [Qt Native Pixmap
w,h]

(JSC::Bindings::QtPixmapRuntimeObjectImp::createStructure):
runtime-object broilerplate
(JSC::Bindings::QtPixmapRuntimeObjectImp::classInfo): ditto
(JSC::Bindings::QtPixmapRuntimeObjectImp::QtPixmapRuntimeObjectImp):
ditto
(JSC::Bindings::): ditto
(JSC::Bindings::QtPixmapClass::QtPixmapClass): class for the
intermediate pixmap-holder
(JSC::Bindings::QtPixmapInstance::getClass): ditto
(JSC::Bindings::QtPixmapInstance::invokeMethod): ditto
(JSC::Bindings::QtPixmapClass::methodsNamed): toHTMLImageElement,
toDataURL
(JSC::Bindings::QtPixmapClass::fieldNamed): width, height
(JSC::Bindings::QtPixmapInstance::getPropertyNames):

toHTMLImageElement, toDataURL, width, height

(JSC::Bindings::QtPixmapInstance::defaultValue): nothing
(JSC::Bindings::QtPixmapInstance::valueOf): toString
(JSC::Bindings::data): holds a QVariant of type QImage/QPixmap
(JSC::Bindings::QtPixmapInstance::width): width of the image/pixmap
(JSC::Bindings::QtPixmapInstance::height): height of the image/pixmap
(JSC::Bindings::QtPixmapInstance::toPixmap): converts to a QPixmap
(JSC::Bindings::QtPixmapInstance::toImage): converts to a QImage
(JSC::Bindings::QtPixmapInstance::variantFromObject): makes sure this
is the right type of object, and creates a QVariant
(JSC::Bindings::QtPixmapInstance::createRuntimeObject): creates a new
intermediate pixmap holder from a QVariant
(JSC::Bindings::QtPixmapInstance::canHandle): returns true if a
QPixmap/QImage is required

  • bridge/qt/qt_pixmapruntime.h: Added.
  • bridge/qt/qt_runtime.cpp: hooks for the bridge

(JSC::Bindings::convertValueToQVariant): handle QPixmap/QImage if the
object is the intermediate pixmap holder or an HTMLImageElement
(JSC::Bindings::convertQVariantToValue): creates the intermediate
object from a QVariant of type QImage/QPixmap

WebKit/qt: [Qt] Adding QPixmap/QImage support for the Qt hybrid layer
https://bugs.webkit.org/show_bug.cgi?id=32461

Patch by No'am Rosenthal <noam.rosenthal@nokia.com> on 2010-01-21
Reviewed by Simon Hausmann.

  • tests/hybridPixmap: Added.
  • tests/hybridPixmap/hybridPixmap.pro: Added.
  • tests/hybridPixmap/resources.qrc: Added.
  • tests/hybridPixmap/test.html: Added.
  • tests/hybridPixmap/tst_hybridPixmap.cpp: Added.

(tst_hybridPixmap::tst_hybridPixmap): tests most of the use cases for
hybrid pixmap/image manipulation
(tst_hybridPixmap::init): QTestLib initialization
(tst_hybridPixmap::cleanup): QTestLib cleanup
(tst_hybridPixmap::hybridPixmap): run the html file

  • tests/hybridPixmap/widget.cpp: Added.

(Widget::Widget):
(Widget::refreshJS):
(Widget::start):
(Widget::completeTest):
(Widget::setPixmap):
(Widget::pixmap):
(Widget::setImage):
(Widget::image):
(Widget::~Widget):
(Widget::changeEvent):
(Widget::compare):
(Widget::imageSlot):
(Widget::pixmapSlot):
(Widget::randomSlot):

  • tests/hybridPixmap/widget.h: Added.
  • tests/hybridPixmap/widget.ui: Added.
  • tests/tests.pro:
Location:
trunk
Files:
10 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r53610 r53611  
     12010-01-21  No'am Rosenthal  <noam.rosenthal@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Adding QPixmap/QImage support for the Qt hybrid layer
     6        Allows accesing QPixmap and QImage based arguments from Qt signals,
     7        slots and properties
     8        This is done by an intermediate object that can be turned into
     9        web-based objects by calling either toHTMLImageElement() or
     10        toDataURL()
     11        https://bugs.webkit.org/show_bug.cgi?id=32461
     12
     13        Tests are in WebKit/qt/tests/hybridPixmap
     14
     15        * WebCore.pro:
     16        * bridge/qt/qt_pixmapruntime.cpp: Added.
     17        (JSC::Bindings::QtPixmapWidthField::name): "width"
     18        (JSC::Bindings::QtPixmapWidthField::valueFromInstance): width of
     19        pixmap
     20        (JSC::Bindings::QtPixmapWidthField::setValueToInstance): nothing
     21        (JSC::Bindings::QtPixmapHeightField::name): "height"
     22        (JSC::Bindings::QtPixmapHeightField::valueFromInstance): height of
     23        pixmap
     24        (JSC::Bindings::QtPixmapHeightField::setValueToInstance): nothing
     25        (JSC::Bindings::QtPixmapRuntimeMethod::numParameters): 0
     26        (JSC::Bindings::QtPixmapCreateElementMethod::name): toHTMLImageElement
     27        (JSC::Bindings::QtPixmapCreateElementMethod::invoke): creates an HTML
     28        element from the QPixmap
     29        (JSC::Bindings::QtPixmapToDataUrlMethod::name): "toDataURL"
     30        (JSC::Bindings::QtPixmapToDataUrlMethod::invoke): encodes the image to
     31        a base64 data url
     32        (JSC::Bindings::QtPixmapToStringMethod::name): "toString"
     33        (JSC::Bindings::QtPixmapToStringMethod::invoke): [Qt Native Pixmap
     34        w,h]
     35
     36        (JSC::Bindings::QtPixmapRuntimeObjectImp::createStructure):
     37        runtime-object broilerplate
     38        (JSC::Bindings::QtPixmapRuntimeObjectImp::classInfo): ditto
     39        (JSC::Bindings::QtPixmapRuntimeObjectImp::QtPixmapRuntimeObjectImp):
     40        ditto
     41        (JSC::Bindings::): ditto
     42        (JSC::Bindings::QtPixmapClass::QtPixmapClass): class for the
     43        intermediate pixmap-holder
     44        (JSC::Bindings::QtPixmapInstance::getClass): ditto
     45        (JSC::Bindings::QtPixmapInstance::invokeMethod): ditto
     46        (JSC::Bindings::QtPixmapClass::methodsNamed): toHTMLImageElement,
     47        toDataURL
     48        (JSC::Bindings::QtPixmapClass::fieldNamed): width, height
     49        (JSC::Bindings::QtPixmapInstance::getPropertyNames):
     50                toHTMLImageElement, toDataURL, width, height
     51        (JSC::Bindings::QtPixmapInstance::defaultValue): nothing
     52        (JSC::Bindings::QtPixmapInstance::valueOf): toString
     53        (JSC::Bindings::data): holds a QVariant of type QImage/QPixmap
     54        (JSC::Bindings::QtPixmapInstance::width): width of the image/pixmap
     55        (JSC::Bindings::QtPixmapInstance::height): height of the image/pixmap
     56        (JSC::Bindings::QtPixmapInstance::toPixmap): converts to a QPixmap
     57        (JSC::Bindings::QtPixmapInstance::toImage): converts to a QImage
     58        (JSC::Bindings::QtPixmapInstance::variantFromObject): makes sure this
     59        is the right type of object, and creates a QVariant
     60        (JSC::Bindings::QtPixmapInstance::createRuntimeObject): creates a new
     61        intermediate pixmap holder from a QVariant
     62        (JSC::Bindings::QtPixmapInstance::canHandle): returns true if a
     63        QPixmap/QImage is required
     64        * bridge/qt/qt_pixmapruntime.h: Added.
     65        * bridge/qt/qt_runtime.cpp: hooks for the bridge
     66        (JSC::Bindings::convertValueToQVariant): handle QPixmap/QImage if the
     67        object is the intermediate pixmap holder or an HTMLImageElement
     68        (JSC::Bindings::convertQVariantToValue): creates the intermediate
     69        object from a QVariant of type QImage/QPixmap
     70
    1712010-01-21  Luiz Agostini  <luiz.agostini@openbossa.org>
    272
  • trunk/WebCore/WebCore.pro

    r53574 r53611  
    10431043    bridge/qt/qt_instance.h \
    10441044    bridge/qt/qt_runtime.h \
     1045    bridge/qt/qt_pixmapruntime.h \
    10451046    bridge/runtime_array.h \
    10461047    bridge/runtime_method.h \
     
    19441945    bridge/qt/qt_class.cpp \
    19451946    bridge/qt/qt_instance.cpp \
     1947    bridge/qt/qt_pixmapruntime.cpp \
    19461948    bridge/qt/qt_runtime.cpp \
    19471949    page/qt/DragControllerQt.cpp \
  • trunk/WebCore/bridge/qt/qt_runtime.cpp

    r53541 r53611  
    4444#include "qstringlist.h"
    4545#include "qt_instance.h"
     46#include "qt_pixmapruntime.h"
    4647#include "qvarlengtharray.h"
    4748#include <JSFunction.h>
     
    720721                }
    721722                break;
     723            } else if (QtPixmapInstance::canHandle(static_cast<QMetaType::Type>(hint))) {
     724                ret = QtPixmapInstance::variantFromObject(object, static_cast<QMetaType::Type>(hint));
    722725            } else if (hint == (QMetaType::Type) qMetaTypeId<QVariant>()) {
    723726                if (value.isUndefinedOrNull()) {
     
    848851        return QtInstance::getQtInstance(obj, root, QScriptEngine::QtOwnership)->createRuntimeObject(exec);
    849852    }
     853
     854    if (QtPixmapInstance::canHandle(static_cast<QMetaType::Type>(variant.type())))
     855        return QtPixmapInstance::createRuntimeObject(exec, root, variant);
    850856
    851857    if (type == QMetaType::QVariantMap) {
  • trunk/WebKit/qt/ChangeLog

    r53610 r53611  
     12010-01-21  No'am Rosenthal  <noam.rosenthal@nokia.com>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Adding QPixmap/QImage support for the Qt hybrid layer
     6        https://bugs.webkit.org/show_bug.cgi?id=32461
     7
     8        * tests/hybridPixmap: Added.
     9        * tests/hybridPixmap/hybridPixmap.pro: Added.
     10        * tests/hybridPixmap/resources.qrc: Added.
     11        * tests/hybridPixmap/test.html: Added.
     12        * tests/hybridPixmap/tst_hybridPixmap.cpp: Added.
     13        (tst_hybridPixmap::tst_hybridPixmap): tests most of the use cases for
     14        hybrid pixmap/image manipulation
     15        (tst_hybridPixmap::init): QTestLib initialization
     16        (tst_hybridPixmap::cleanup): QTestLib cleanup
     17        (tst_hybridPixmap::hybridPixmap): run the html file
     18        * tests/hybridPixmap/widget.cpp: Added.
     19        (Widget::Widget):
     20        (Widget::refreshJS):
     21        (Widget::start):
     22        (Widget::completeTest):
     23        (Widget::setPixmap):
     24        (Widget::pixmap):
     25        (Widget::setImage):
     26        (Widget::image):
     27        (Widget::~Widget):
     28        (Widget::changeEvent):
     29        (Widget::compare):
     30        (Widget::imageSlot):
     31        (Widget::pixmapSlot):
     32        (Widget::randomSlot):
     33        * tests/hybridPixmap/widget.h: Added.
     34        * tests/hybridPixmap/widget.ui: Added.
     35        * tests/tests.pro:
     36
    1372010-01-21  Luiz Agostini  <luiz.agostini@openbossa.org>
    238
  • trunk/WebKit/qt/tests/tests.pro

    r52444 r53611  
    11
    22TEMPLATE = subdirs
    3 SUBDIRS = qwebframe qwebpage qwebelement qgraphicswebview qwebhistoryinterface qwebview qwebhistory qwebinspector
     3SUBDIRS = qwebframe qwebpage qwebelement qgraphicswebview qwebhistoryinterface qwebview qwebhistory qwebinspector hybridPixmap
    44greaterThan(QT_MINOR_VERSION, 4): SUBDIRS += benchmarks/painting benchmarks/loading
Note: See TracChangeset for help on using the changeset viewer.