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

noam.rosenthal at nokia.com noam.rosenthal at nokia.com
Sun Dec 13 12:28:16 PST 2009



>-----Original Message-----
>From: webkit-qt-bounces at lists.webkit.org 
>[mailto:webkit-qt-bounces at lists.webkit.org] On Behalf Of 
>Hausmann Simon (Nokia-D-Qt/Oslo)
>
>Ideally we can find a solution that we can implement now but 
>that we know _will_ be compatible with #31863.

How about the following alternative:

Instead of creating an HTMLImageElement implicitly, we create an intermediary element that can explicitly create an HTMLImageElement, or be encoded into a data URL. A Javascript app using it would look something like:

	var pxm = myQObject.someQPixmapProperty;

	var img = pxm.createImageElement(); 
		// or
	someOtherImg.style.backgroundImage = "url("+ pxm.toDataURL("image/jpeg")+ ")";

	So it's basically a custom JS object that looks like:
	{ 	
		width: ..., 
		height: ...,  
		createImageElement: function() {...},
		toDataUrl: function(mimeType) {...}
	}

Is this a workable approach?
I'm not really particular about the implementation detail myself... Any way that would allow me to transport pixmaps between Qt and webkit without having to encode/decode/memcpy them would work :) I'm willing to implement this API myself, or any other alternative, if we agree that they're the right one and are a good candidate to go upstream in a timely manner.


>
>On second thought I _think_ the resulting API should not be a 
>direct conversion from QImage/QPixmap to HTMLImageElement, as 
>they are not equivalent. The latter has a lot more attributes 
>to specific that are not part of QPixmap/QImage.
>

That's what I was thinking, but apparently there's no image object accessible to Javascript except HTMLImageElement.
Even when you create an image in javascript (var img = new Image()) and draw it in canvas, you end up with an implicit HTMLImageElement... This is perhaps a deficiency in webkit but I don't think we can fix it in the hybrid layer.

Does the proposed alternative above look more like how we'd end up doing it with QtScript style APIs? It will require more work for sending pixmaps from webkit to Qt, but that's actually not as important.

Cheers
No'am







More information about the webkit-qt mailing list