Changeset 270126 in webkit


Ignore:
Timestamp:
Nov 20, 2020 11:58:40 AM (20 months ago)
Author:
Lauro Moura
Message:

canvas: drawImage should not raise IndexSizeError on empty sources
https://bugs.webkit.org/show_bug.cgi?id=219068

Reviewed by Noam Rosenthal.

Source/WebCore:

Per 4.12.5.1.14 Drawing images[1] point 5, if the src rect has one of the dimensions zero, return silently.

[1] https://html.spec.whatwg.org/multipage/canvas.html#drawing-images

Covered by existing tests and fixes WPT offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource flakiness

  • html/canvas/CanvasRenderingContext2DBase.cpp:

(WebCore::CanvasRenderingContext2DBase::drawImage): Return early instead of raising an exception if the rect is empty.

LayoutTests:

Update baselines and tests with new drawImage behavior of not raising IndexSizeError on empty src rects.

  • http/wpt/2dcontext/imagebitmap/drawImage-ImageBitmap-expected.txt: Updated with new drawImage behavior
  • http/wpt/2dcontext/imagebitmap/drawImage-ImageBitmap.html: Updated with new drawImage behavior
  • platform/glib/imported/w3c/web-platform-tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource-expected.txt: Renamed from LayoutTests/platform/wpe/imported/w3c/web-platform-tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource-expected.txt.
  • platform/gtk/imported/w3c/web-platform-tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource-expected.txt: Removed.
Location:
trunk
Files:
1 added
1 deleted
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r270124 r270126  
     12020-11-20  Lauro Moura  <lmoura@igalia.com>
     2
     3        canvas: drawImage should not raise IndexSizeError on empty sources
     4        https://bugs.webkit.org/show_bug.cgi?id=219068
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Update baselines and tests with new drawImage behavior of not raising IndexSizeError on empty src rects.
     9
     10        * http/wpt/2dcontext/imagebitmap/drawImage-ImageBitmap-expected.txt: Updated with new drawImage behavior
     11        * http/wpt/2dcontext/imagebitmap/drawImage-ImageBitmap.html:  Updated with new drawImage behavior
     12        * platform/glib/imported/w3c/web-platform-tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource-expected.txt: Renamed from LayoutTests/platform/wpe/imported/w3c/web-platform-tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource-expected.txt.
     13        * platform/gtk/imported/w3c/web-platform-tests/html/canvas/offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource-expected.txt: Removed.
     14
    1152020-11-20  Truitt Savell  <tsavell@apple.com>
    216
  • trunk/LayoutTests/http/wpt/2dcontext/imagebitmap/drawImage-ImageBitmap-expected.txt

    r267644 r270126  
    66PASS drawImage of ImageBitmap from HTMLImageElement with cropping and different non-zero origin
    77PASS drawImage throws with InvalidStateError if the ImageBitmap is closed
    8 PASS drawImage throws with IndexSizeError if the source rectangle of the ImageBitmap is empty
     8PASS drawImage does not draw if the source rectangle of the ImageBitmap is empty
    99
  • trunk/LayoutTests/http/wpt/2dcontext/imagebitmap/drawImage-ImageBitmap.html

    r263438 r270126  
    135135        }).then(function(imageBitmap) {
    136136            let [canvas, ctx] = create9x9CanvasWith2dContext();
    137             assert_throws_dom("IndexSizeError", function () {
    138                 ctx.drawImage(imageBitmap, 0, 0, 0, 0, 0, 0, 9, 9);
    139             }, "drawImage with an empty source rectangle should fail.");
     137            ctx.drawImage(imageBitmap, 0, 0, 0, 0, 0, 0, 9, 9);
     138            _assertPixel(canvas, 0,0, 0,0,0,0, "8,8", "0,0,0,0");
     139            _assertPixel(canvas, 4,4, 0,0,0,0, "8,8", "0,0,0,0");
     140            _assertPixel(canvas, 8,8, 0,0,0,0, "8,8", "0,0,0,0");
    140141        });
    141     }, "drawImage throws with IndexSizeError if the source rectangle of the ImageBitmap is empty");
     142    }, "drawImage does not draw if the source rectangle of the ImageBitmap is empty");
    142143})();
    143144</script>
  • trunk/Source/WebCore/ChangeLog

    r270125 r270126  
     12020-11-20  Lauro Moura  <lmoura@igalia.com>
     2
     3        canvas: drawImage should not raise IndexSizeError on empty sources
     4        https://bugs.webkit.org/show_bug.cgi?id=219068
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Per 4.12.5.1.14 Drawing images[1] point 5, if the src rect has one of the dimensions zero, return silently.
     9
     10        [1] https://html.spec.whatwg.org/multipage/canvas.html#drawing-images
     11
     12        Covered by existing tests and fixes WPT offscreen/drawing-images-to-the-canvas/2d.drawImage.zerosource flakiness
     13
     14        * html/canvas/CanvasRenderingContext2DBase.cpp:
     15        (WebCore::CanvasRenderingContext2DBase::drawImage): Return early instead of raising an exception if the rect is empty.
     16
    1172020-11-20  Simon Fraser  <simon.fraser@apple.com>
    218
  • trunk/Source/WebCore/html/canvas/CanvasRenderingContext2DBase.cpp

    r270102 r270126  
    16661666        return Exception { InvalidStateError };
    16671667
    1668     if (!srcRect.width() || !srcRect.height())
    1669         return Exception { IndexSizeError };
     1668    if (srcRect.isEmpty())
     1669        return { };
    16701670
    16711671    FloatRect srcBitmapRect = FloatRect(FloatPoint(), FloatSize(imageBitmap.width(), imageBitmap.height()));
Note: See TracChangeset for help on using the changeset viewer.