Discrepancy in exception in Canvas::ToBlob and OffscreenCanvas::ConvertToBlob |
||
Issue descriptionHTMLCanvasElement.toBlob and OffscreenCanvas.convertToBlob appear to handle exception cases differently: 1. Calling toBlob/ConvertToBlob without rendering contexts -> canvas will return a null blob; OffscreenCanvas return with an exception. 2. IsPaintable is implemented differently and resolve with different exception handling methods. etc.
,
Dec 21 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/8dd25838e2d3d498d3801cd6269d7de8a637ce51 commit 8dd25838e2d3d498d3801cd6269d7de8a637ce51 Author: xlai <xlai@chromium.org> Date: Thu Dec 21 16:07:08 2017 Make ConvertToBlob behave the same as toBlob in exception/failure handling The HTMLCanvasElement::toBlob have the following behavior: 1. When it has invalid image size (width/height is zero), it will return a null blob. 2. When it does not have contexts but has valid image size, it will generate a blob representing a transparent image. 3. When it fails encoding, it will return a null blob. This behavior is correctly obeying the spec as in https://html.spec.whatwg.org/multipage/canvas.html#dom-canvas-toblob. But OffscreenCanvas::convertToBlob is currently doing differently: 1. When it has invalid image size (width/height is zero), it throws exception. 2. When it does not have contexts, it throws exception. 3. When it fails encoding, it throws exception. The CL changes all above-mentioned cases in OffscreenCanvas to behave as same as that in HTMLCanvas. This CL also includes a few small fixes to the discrepancy between Offscreen and html canvases (e.g. GetSourceImageForCanvas(), Offscreen2D.GetImage(), IsPaintable()). It also move some functions to CanvasRenderingContextHost to reduce code duplication. TBR=junov@chromium.org Bug: 796202 Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel Change-Id: I1af7f26aa0a6371d03a9a13dfb03f986a1e5ce39 Reviewed-on: https://chromium-review.googlesource.com/834394 Commit-Queue: Olivia Lai <xlai@chromium.org> Reviewed-by: Fernando Serboncini <fserb@chromium.org> Cr-Commit-Position: refs/heads/master@{#525701} [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/LayoutTests/TestExpectations [rename] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/LayoutTests/fast/canvas-api/OffscreenCanvas-convertToBlob-failures.html [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-zero-size-readback.html [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/HTMLCanvasElement.h [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/canvas/CanvasRenderingContextHost.cpp [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/html/canvas/CanvasRenderingContextHost.h [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.h [modify] https://crrev.com/8dd25838e2d3d498d3801cd6269d7de8a637ce51/third_party/WebKit/Source/modules/canvas/offscreencanvas2d/OffscreenCanvasRenderingContext2D.cpp
,
Jan 24 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/6c505104ef0e63f885b3ff712cb3a7701f47e787 commit 6c505104ef0e63f885b3ff712cb3a7701f47e787 Author: xlai <xlai@chromium.org> Date: Wed Jan 24 15:37:09 2018 Keep OffscreenCanvas.ConvertToBlob reject promise whenever necessary Bug: 796202 Change-Id: I6b0fe32e05b8ed69ea35a5e29ec87f8bbbadf536 Reviewed-on: https://chromium-review.googlesource.com/868260 Commit-Queue: Olivia Lai <xlai@chromium.org> Reviewed-by: Justin Novosad <junov@chromium.org> Cr-Commit-Position: refs/heads/master@{#531538} [modify] https://crrev.com/6c505104ef0e63f885b3ff712cb3a7701f47e787/third_party/WebKit/LayoutTests/TestExpectations [modify] https://crrev.com/6c505104ef0e63f885b3ff712cb3a7701f47e787/third_party/WebKit/LayoutTests/fast/canvas-api/OffscreenCanvas-convertToBlob-failures.html [modify] https://crrev.com/6c505104ef0e63f885b3ff712cb3a7701f47e787/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-zero-size-readback.html [modify] https://crrev.com/6c505104ef0e63f885b3ff712cb3a7701f47e787/third_party/WebKit/Source/core/html/canvas/CanvasAsyncBlobCreator.cpp [modify] https://crrev.com/6c505104ef0e63f885b3ff712cb3a7701f47e787/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp
,
Jan 30 2018
|
||
►
Sign in to add a comment |
||
Comment 1 by xlai@chromium.org
, Dec 19 2017