WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
94702
[Qt] Port the Qt pixmap JS bindings to use the JSC C API
https://bugs.webkit.org/show_bug.cgi?id=94702
Summary
[Qt] Port the Qt pixmap JS bindings to use the JSC C API
Simon Hausmann
Reported
2012-08-22 06:31:34 PDT
[Qt] Port the Qt pixmap JS bindings to use the JSC C API
Attachments
Patch
(28.39 KB, patch)
2012-08-22 06:34 PDT
,
Simon Hausmann
no flags
Details
Formatted Diff
Diff
Patch
(28.68 KB, patch)
2012-08-29 04:35 PDT
,
Simon Hausmann
kenneth
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Simon Hausmann
Comment 1
2012-08-22 06:34:03 PDT
Created
attachment 159922
[details]
Patch
Kenneth Rohde Christiansen
Comment 2
2012-08-22 07:07:13 PDT
Comment on
attachment 159922
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=159922&action=review
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:137 > + // we now know that we have a valid <img> element as the argument, we can attach the image to it.
uppercase?
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:155 > + copyPixels(image, width, height, imageData->data()->data());
copyPixelsInto ?
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:171 > + JSStringRelease(str); > + return value;
I still prefer a newline before return
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:178 > + QString stringValue = QString::fromLatin1("[Qt Native Pixmap %1,%2]").arg(size.width()).arg(size.height());
[Qt Native Pixmap ? why is that a good description? toString of an images normally doesnt give size does it?
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:207 > + if (hint == qMetaTypeId<QPixmap>()) > + return QVariant::fromValue<QPixmap>(toPixmap(*originalVariant)); > > - if (!imageElement) > - goto returnEmptyVariant; > + if (hint == qMetaTypeId<QImage>()) > + return QVariant::fromValue<QImage>(toImage(*originalVariant));
You had the opposite conversion in a separate method earlier
Caio Marcelo de Oliveira Filho
Comment 3
2012-08-22 12:36:46 PDT
Comment on
attachment 159922
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=159922&action=review
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:109 > +static JSValueRef getPixmapWidth(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
No need for "propertyName" and "exception".
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:143 > + toJS(exec, global, imageElement->document());
Ignoring the return value of the toJS() call seems weird here. Does this have a wanted side-effect? Or maybe this is just a typo / leftover from the past?
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:196 > + JSObject* jsObject; > + JSHTMLImageElement* elementJSWrapper; > + HTMLImageElement* imageElement; > + CachedImage* cachedImage; > + Image* image; > + QImage* nativeImage;
Why declare them here instead of in first use definition?
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:199 > goto returnEmptyVariant;
Just an idea: what about "return emptyVariantForHint(hint)" and the code after "returnEmptyVariant" label becomes a function?
Simon Hausmann
Comment 4
2012-08-29 04:21:16 PDT
Comment on
attachment 159922
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=159922&action=review
> Source/WebCore/ChangeLog:11 > + The conversion uses a simple JSClassRef based binding and only a few > + uses of private JSC API for the HTML element DOM bindings remain.
I'll try to be a bit more elaborate here in the next patch.
>> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:109 >> +static JSValueRef getPixmapWidth(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) > > No need for "propertyName" and "exception".
The parameters are required as part of the JSObjectGetPropertyCallback signature, but I've removed their names now from both getters.
>> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:137 >> + // we now know that we have a valid <img> element as the argument, we can attach the image to it. > > uppercase?
Done
>> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:143 >> + toJS(exec, global, imageElement->document()); > > Ignoring the return value of the toJS() call seems weird here. Does this have a wanted side-effect? Or maybe this is just a typo / leftover from the past?
That does seem rather bogus. I'll remove it :)
>> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:155 >> + copyPixels(image, width, height, imageData->data()->data()); > > copyPixelsInto ?
Good idea :) Done.
>> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:171 >> + return value; > > I still prefer a newline before return
Done. And also used a JSRetainPtr for the string (before Caio sees it ;)
>> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:178 >> + QString stringValue = QString::fromLatin1("[Qt Native Pixmap %1,%2]").arg(size.width()).arg(size.height()); > > [Qt Native Pixmap ? why is that a good description? toString of an images normally doesnt give size does it?
This is almost exclusively used for debug output, so I think it's a convenient output format for debugging.
>> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:196 >> + QImage* nativeImage; > > Why declare them here instead of in first use definition?
Well spotted!
>> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:199 >> goto returnEmptyVariant; > > Just an idea: what about "return emptyVariantForHint(hint)" and the code after "returnEmptyVariant" label becomes a function?
Hmm. Tempting. I'll give it a shot. With tail call optimization it might not be so bad, but I kind of liked the goto :)
>> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:207 >> + return QVariant::fromValue<QImage>(toImage(*originalVariant)); > > You had the opposite conversion in a separate method earlier
I don't quite understand :). What do you mean?
Simon Hausmann
Comment 5
2012-08-29 04:24:22 PDT
Comment on
attachment 159922
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=159922&action=review
> Source/WebCore/bridge/qt/qt_pixmapruntime.cpp:186 > + return JSObjectMake(context, getClassRef(), new QVariant(value));
As it turns out, this is also a leak, because we're missing a finalize callback that deletes the variant.
Simon Hausmann
Comment 6
2012-08-29 04:35:23 PDT
Created
attachment 161183
[details]
Patch
Caio Marcelo de Oliveira Filho
Comment 7
2012-09-03 11:18:34 PDT
LGTM.
Kenneth Rohde Christiansen
Comment 8
2012-09-03 11:20:47 PDT
Comment on
attachment 161183
[details]
Patch to me too
Simon Hausmann
Comment 9
2012-09-03 23:38:01 PDT
Committed
r127440
: <
http://trac.webkit.org/changeset/127440
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug