[webkit-qt] Extending the hybrid support of QtWebkit to more types: feedback please!

noam.rosenthal at nokia.com noam.rosenthal at nokia.com
Sat Dec 12 17:00:33 PST 2009


Hi all
I'm requesting your feedback on an extension I'm adding to the QtWebkit hybrid mechanism (qt_runtime.cpp):
I want it to support pixmaps (and potentially QWebElement in the future), in addition to the current support for core types.

Please see patch at https://bugs.webkit.org/show_bug.cgi?id=32461

The patch enables sending/receiving QPixmaps and QImages between webkit and Qt signals/slots/properties.

This tries to solve two problems:
1) Getting pixmaps from a native Qt application, and trying to layout and display them in webkit: 
	currently the only way to do so is by encoding the image in Qt and then decoding it in webkit, which is, as you might imagine, very slow.

2) Allow Qt to override the complex webkit rendering path, when things are two complicated for webkit to handle:
	With QWebElement::render, I can actually have Qt handle some complex rendering tasks in C++, without having to go through the process of modifying the webkit rendering path.

Though in the future we might want to do something like a QtScript-like API (https://bugs.webkit.org/show_bug.cgi?id=31863), right now the QObject mechanism is very convenient and actually makes more since in some use-cases, because it allows you to avoid application specific "glue-layers" which convert QObject-style definitions to JS-style definitions.

Risks:
- qt_runtime.cpp is pretty old, and the features it provides are "silent" (not part of any traditional API).
- This creates HTML DOM-elements in a rather implicit way.
- <add your risk that I haven't thought about here>

Note that since we're not adding a new C++ API, and the JS-API extension we're adding is pretty straightforward (if your Qobject's slot receives a QPixmap, and your JS function sends an HTMLImageElement, the conversion would be done), the risk of breaking things in the future might not be so high.

Alternatives:
- Use something like a new QWebElement::pixmap() / QWebElement::setPixmap() function
- Use a source-string mechanism, something like <img src="qpixmap://1acd0339" />, and have the QtWebkit image decoders to handle that somehow (this would probably require a much bigger fix than my patch).
- Wait till #31863 is fixed, and find a way to do it then: the solution would probably look a lot like the proposed patch, as eventually the feature of converting an HTMLImageElement to Qpixmap would have to happen somewhere:)

So,
If you have comments on this approach, have major objections to it, or can propose an alternative approach that would be better, 
Please reply!

Thanks
No'am






	Noam Rosenthal
	Business Development
	Nokia, Qt Development Frameworks
	Email: noam.rosenthal at nokia.com
	Mob: +1 650 995 6106
	http://qt.nokia.com 


More information about the webkit-qt mailing list