RESOLVED FIXED71846
[chromium] Separate image encoding from dataURL construction
https://bugs.webkit.org/show_bug.cgi?id=71846
Summary [chromium] Separate image encoding from dataURL construction
noel gordon
Reported 2011-11-08 12:19:40 PST
Remove the implicit assumption that a dataURL is the only desired output format of the image encoding phase.
Attachments
Patch (4.64 KB, patch)
2011-11-08 12:36 PST, noel gordon
no flags
Patch: linux EWS build fix. (4.65 KB, patch)
2011-11-08 17:25 PST, noel gordon
no flags
noel gordon
Comment 1 2011-11-08 12:36:31 PST
Adam Barth
Comment 2 2011-11-08 12:53:11 PST
Comment on attachment 114135 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=114135&action=review > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:366 > + Vector<unsigned char>* encodedImage = static_cast<Vector<unsigned char>*>(output); Crazy! We can't be consistent about the type? > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:-390 > - base64Encode(*reinterpret_cast<Vector<char>*>(&encodedImage), base64Data); I see. Frowns. > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:401 > + return "data:" + mimeType + ";base64," + base64Data; Should we CRASH or ASSERT or something that mimeType doesn't have a ; or a , character? > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:408 > + Vector<char> encodedImage, base64Data; WebKit doesn't usually use compound declarations.
WebKit Review Bot
Comment 3 2011-11-08 15:14:30 PST
Comment on attachment 114135 [details] Patch Attachment 114135 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/10376193
noel gordon
Comment 4 2011-11-08 17:25:50 PST
Created attachment 114181 [details] Patch: linux EWS build fix.
noel gordon
Comment 5 2011-11-08 17:33:04 PST
(In reply to comment #2) > (From update of attachment 114135 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=114135&action=review > > > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:366 > > + Vector<unsigned char>* encodedImage = static_cast<Vector<unsigned char>*>(output); > > Crazy! We can't be consistent about the type? > > > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:-390 > > - base64Encode(*reinterpret_cast<Vector<char>*>(&encodedImage), base64Data); > > I see. Frowns. The image encoders want unsigned char, the base64 encoder wants char, and we need to marry the two. Those reinterpret_cast gymnastics made me frown too. Hoped that the static_cast would be a little more sane, but the Linux EWS demands a reinterpret_cast *sigh*
noel gordon
Comment 6 2011-11-08 17:42:44 PST
(In reply to comment #2) > > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:401 > > + return "data:" + mimeType + ";base64," + base64Data; > > Should we CRASH or ASSERT or something that mimeType doesn't have a ; or a , character? Good question, but no. The ASSERT guards at the entry to these routines state: ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); the expectation being that the mimeType is already canonical. Caller must do the work to make it so. Only current caller is <canvas>.toDataURL(), it converts the mimeType to canonical & maps bogus user input to "image/png" as required by the standard.
noel gordon
Comment 7 2011-11-08 17:50:34 PST
> > Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp:408 > > + Vector<char> encodedImage, base64Data; > > WebKit doesn't usually use compound declarations. Not something I'd usually do either, maybe ok here since there's no pointer confusion but what I'd really like to write is return "data:" + mimeType + ";base64," + base64Encode(encodedImage); and ditch the temporary variable. Might be a reasonable subject for another patch.
noel gordon
Comment 8 2011-11-08 18:19:32 PST
> Only current caller is <canvas>.toDataURL(), it converts the mimeType to canonical & maps > bogus user input to "image/png" as required by the standard. I used "bogus" here in a technical sense http://trac.webkit.org/browser/trunk/LayoutTests/canvas/philip/tests/toDataURL.bogustype.html
WebKit Review Bot
Comment 9 2011-11-09 14:53:20 PST
Comment on attachment 114181 [details] Patch: linux EWS build fix. Clearing flags on attachment: 114181 Committed r99763: <http://trac.webkit.org/changeset/99763>
WebKit Review Bot
Comment 10 2011-11-09 14:53:26 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.