diff options
author | Vivin Paliath <vivin.paliath@gmail.com> | 2015-10-24 17:36:27 -0700 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-12-14 13:54:50 +0000 |
commit | 7f70d2b795976c1ddbe9c2866012f91b7e0eafd0 (patch) | |
tree | a82294e56c96c186d773705992e8391cf5808aa2 /Source/JavaScriptCore/runtime/JSWeakMap.cpp | |
parent | c255643360af6b7067ab97687f3724418eee2dd6 (diff) | |
download | qtwebkit-7f70d2b795976c1ddbe9c2866012f91b7e0eafd0.tar.gz |
Quality in toDataURL only applies to JPEGs now
Prior to the fix, quality would default to 100 irrespective of the image
type, if an explicit quality-argument was not provided, or if the
quality was outside the valid range. In the case where toDataURL is
called without any arguments, the image type defaults to "image/png" and
quality eventually defaults to 100. However, quality in the context of a
PNG applies to the quality of compression and not the quality of the
image. Since PNG is a lossless format, compression only affects the size
of the image and not its quality. This resulted in PNG images of a large
size, with no compression at all. The same behavior could be observed
when toDataURL is called with the image type explicitly set to
"image/png", without a quality argument. The expected behavior is only
observed if toDataURL is called with the image type set to "image/png"
and the quality set to 0, since this provides the highest level of
compression. According to section 4.12.4.4 of the HTML5 spec, the
quality argument should only apply to images of type "image/jpeg", and
if quality is not provided, the user-agent should use a default value.
This means that the spec was being violated, since the quality was set
to 100 regardless of the image type.
The fix was to consider the quality argument (along with the associated
sanity-checks) only if the image type is "jpeg"; otherwise quality is
set to -1. This change results in PNG images being encoded to
properly-sized base64 strings.
[ChangeLog][WebKit][Behavior Change] The quality parameter
in canvas.toDataURL only applies to JPEG images now, in accordance with
section 4.12.4.4 of the HTML5 spec.
Change-Id: Ie87a32ec368e70e7736d4d2e684e2528ce37f745
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'Source/JavaScriptCore/runtime/JSWeakMap.cpp')
0 files changed, 0 insertions, 0 deletions