[webkit-changes] [WebKit/WebKit] 5dbd04: drawImage(detachedOffscreenCanvas) is supposed to ...

Tristan Fraipont noreply at github.com
Tue Feb 13 02:52:20 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 5dbd0444ac2e6b126ff88e34c7cf2a785f984cf2
      https://github.com/WebKit/WebKit/commit/5dbd0444ac2e6b126ff88e34c7cf2a785f984cf2
  Author: Kaiido <tristan.fraipont at gmail.com>
  Date:   2024-02-13 (Tue, 13 Feb 2024)

  Changed paths:
    A LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.detachedcanvas-expected.txt
    A LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.detachedcanvas.html
    M LayoutTests/imported/w3c/web-platform-tests/html/canvas/tools/yaml-new/drawing-images-to-the-canvas.yaml
    M Source/WebCore/html/OffscreenCanvas.cpp
    M Source/WebCore/html/OffscreenCanvas.h

  Log Message:
  -----------
  drawImage(detachedOffscreenCanvas) is supposed to throw https://bugs.webkit.org/show_bug.cgi?id=266918

Reviewed by @mattwoodrow.

Explanation of why this fixes the bug.

By setting the OffscreenCanvas's `size()` after the DetachedCanvas has been created we ensure that the DetachedCanvas has the correct size to later create the new OffscreenCanvas, and that any method checking the size of the previous OffscreenCanvas, including `drawImage()`, gets the expected `0` width and height.

Also deletes the custom `width` and `height` getters from OffscreenCanvas since these were only used to return a "fake" `0` in case the OffscreenCanvas got detached, and that they are now truly `0`. The special handling in `setWidth` and `setHeight` is still required though.

Tests are not yet published at https://github.com/web-platform-tests/wpt/pull/43835

* Source/WebCore/html/OffscreenCanvas.cpp:
(WebCore::OffscreenCanvas::detach):
(WebCore::OffscreenCanvas::width const): Deleted.
(WebCore::OffscreenCanvas::height const): Deleted.
* Source/WebCore/html/OffscreenCanvas.h:

import new WPT tests

Manually imported since while https://github.com/web-platform-tests/wpt/pull/43835 has been approved, it still hasn't been merged.

drawImage(detachedOffscreenCanvas) is supposed to throw https://bugs.webkit.org/show_bug.cgi?id=266918

Reviewed by @Ahmad-S792.

Since the previous change this method was failing to trigger the proper exception type when
called on a detached OffscreenCanvas, because now the size is actually empty for detached
OffscreenCanvas. We need to separate the case 'detached' and 'no buffer', because zero size
OffscreenCanvas will match 'no buffer' and we'd throw an InvalidStateError instead of an
IndexSizeError for zero-sized OffscreenCanvas.

* Source/WebCore/html/OffscreenCanvas.cpp:
(WebCore::OffscreenCanvas::convertToBlob):

Canonical link: https://commits.webkit.org/274534@main




More information about the webkit-changes mailing list