Skip to content

Commit

Permalink
Implement createImageBitmap(HTMLVideoElement)
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=182388

Reviewed by Žan Doberšek.

LayoutTests/imported/w3c:

* web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt:
* web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage.html:
  Update from upstream to make the test pass on macOS.
* web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:

Source/WebCore:

The implementation is inspired by CanvasRenderingContext2DBase::drawImage().

Tests:

- web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage.html
- web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args.html

* html/ImageBitmap.cpp:
(WebCore::taintsOrigin): Add function to help with the implementation.
(WebCore::ImageBitmap::createPromise): Fill in implementation.

LayoutTests:

* platform/gtk/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:
* platform/ios/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:
* platform/wpe/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@228092 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Ms2ger@igalia.com authored and Ms2ger@igalia.com committed Feb 5, 2018
1 parent ee83b0f commit 45306b5
Show file tree
Hide file tree
Showing 10 changed files with 130 additions and 42 deletions.
11 changes: 11 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,14 @@
2018-02-05 Ms2ger <Ms2ger@igalia.com>

Implement createImageBitmap(HTMLVideoElement)
https://bugs.webkit.org/show_bug.cgi?id=182388

Reviewed by Žan Doberšek.

* platform/gtk/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:
* platform/ios/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:
* platform/wpe/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:

2018-02-02 Ryan Haddad <ryanhaddad@apple.com>

Unreviewed test gardening, skip fast/visual-viewport/resize-event-fired.html on iOS.
Expand Down
12 changes: 12 additions & 0 deletions LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,15 @@
2018-02-05 Ms2ger <Ms2ger@igalia.com>

Implement createImageBitmap(HTMLVideoElement)
https://bugs.webkit.org/show_bug.cgi?id=182388

Reviewed by Žan Doberšek.

* web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt:
* web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage.html:
Update from upstream to make the test pass on macOS.
* web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args-expected.txt:

2018-02-02 Chris Dumez <cdumez@apple.com>

Clearing a registration should null out its workers before setting their state to "redundant"
Expand Down
Expand Up @@ -4,15 +4,15 @@ PASS createImageBitmap from an HTMLCanvasElement scaled down, and drawImage on t
PASS createImageBitmap from an HTMLCanvasElement scaled up, and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLCanvasElement resized, and drawImage on the created ImageBitmap
FAIL createImageBitmap from an HTMLCanvasElement with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
FAIL createImageBitmap from an HTMLVideoElement, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with HTMLVideoElement is not implemented"
FAIL createImageBitmap from an HTMLVideoElement scaled down, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with HTMLVideoElement is not implemented"
FAIL createImageBitmap from an HTMLVideoElement scaled up, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with HTMLVideoElement is not implemented"
FAIL createImageBitmap from an HTMLVideoElement resized, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with HTMLVideoElement is not implemented"
PASS createImageBitmap from an HTMLVideoElement, and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLVideoElement scaled down, and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLVideoElement scaled up, and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLVideoElement resized, and drawImage on the created ImageBitmap
FAIL createImageBitmap from an HTMLVideoElement with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
FAIL createImageBitmap from an HTMLVideoElement from a data URL, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with HTMLVideoElement is not implemented"
FAIL createImageBitmap from an HTMLVideoElement from a data URL scaled down, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with HTMLVideoElement is not implemented"
FAIL createImageBitmap from an HTMLVideoElement from a data URL scaled up, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with HTMLVideoElement is not implemented"
FAIL createImageBitmap from an HTMLVideoElement from a data URL resized, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with HTMLVideoElement is not implemented"
PASS createImageBitmap from an HTMLVideoElement from a data URL, and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLVideoElement from a data URL scaled down, and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLVideoElement from a data URL scaled up, and drawImage on the created ImageBitmap
PASS createImageBitmap from an HTMLVideoElement from a data URL resized, and drawImage on the created ImageBitmap
FAIL createImageBitmap from an HTMLVideoElement from a data URL with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "RangeError: Cannot create ImageBitmap with a negative width or height"
PASS createImageBitmap from a bitmap HTMLImageElement, and drawImage on the created ImageBitmap
PASS createImageBitmap from a bitmap HTMLImageElement scaled down, and drawImage on the created ImageBitmap
Expand Down
Expand Up @@ -12,7 +12,7 @@
<script>
function testCanvasDisplayingPattern(canvas, width, height)
{
var tolerance = 5; // for creating ImageBitmap from a video, the tolerance needs to be high
var tolerance = 10; // for creating ImageBitmap from a video, the tolerance needs to be high
const check = (x, y, r, g, b, a) =>
_assertPixelApprox(canvas, x,y, r,g,b,a, `${x},${y}`, `${r},${g},${b},${a}`, tolerance);
check(1 * width / 4, 1 * height / 4, 255,0,0,255);
Expand Down
Expand Up @@ -5,10 +5,10 @@ PASS createImageBitmap with a an HTMLCanvasElement source and sh set to 0
FAIL createImageBitmap with a an HTMLCanvasElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a an HTMLVideoElement source and sw set to 0
PASS createImageBitmap with a an HTMLVideoElement source and sh set to 0
FAIL createImageBitmap with a an HTMLVideoElement source and oversized (unallocatable) crop region assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" ("TypeError") expected object "InvalidStateError" ("InvalidStateError")
FAIL createImageBitmap with a an HTMLVideoElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a an HTMLVideoElement from a data URL source and sw set to 0
PASS createImageBitmap with a an HTMLVideoElement from a data URL source and sh set to 0
FAIL createImageBitmap with a an HTMLVideoElement from a data URL source and oversized (unallocatable) crop region assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" ("TypeError") expected object "InvalidStateError" ("InvalidStateError")
FAIL createImageBitmap with a an HTMLVideoElement from a data URL source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a a bitmap HTMLImageElement source and sw set to 0
PASS createImageBitmap with a a bitmap HTMLImageElement source and sh set to 0
FAIL createImageBitmap with a a bitmap HTMLImageElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
Expand Down Expand Up @@ -40,7 +40,7 @@ PASS createImageBitmap with WebGLRenderingContext image source.
PASS createImageBitmap with Uint8Array image source.
PASS createImageBitmap with ArrayBuffer image source.
PASS createImageBitmap with empty image source.
FAIL createImageBitmap with empty video source. assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
PASS createImageBitmap with empty video source.
PASS createImageBitmap with an oversized canvas source.
FAIL createImageBitmap with an invalid OffscreenCanvas source. assert_throws: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
FAIL createImageBitmap with an undecodable blob source. assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with ArrayBuffer or Blob is not implemented" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
Expand Down
Expand Up @@ -5,10 +5,10 @@ PASS createImageBitmap with a an HTMLCanvasElement source and sh set to 0
FAIL createImageBitmap with a an HTMLCanvasElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a an HTMLVideoElement source and sw set to 0
PASS createImageBitmap with a an HTMLVideoElement source and sh set to 0
FAIL createImageBitmap with a an HTMLVideoElement source and oversized (unallocatable) crop region assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" ("TypeError") expected object "InvalidStateError" ("InvalidStateError")
FAIL createImageBitmap with a an HTMLVideoElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a an HTMLVideoElement from a data URL source and sw set to 0
PASS createImageBitmap with a an HTMLVideoElement from a data URL source and sh set to 0
FAIL createImageBitmap with a an HTMLVideoElement from a data URL source and oversized (unallocatable) crop region assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" ("TypeError") expected object "InvalidStateError" ("InvalidStateError")
FAIL createImageBitmap with a an HTMLVideoElement from a data URL source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a a bitmap HTMLImageElement source and sw set to 0
PASS createImageBitmap with a a bitmap HTMLImageElement source and sh set to 0
FAIL createImageBitmap with a a bitmap HTMLImageElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
Expand Down Expand Up @@ -40,7 +40,7 @@ PASS createImageBitmap with WebGLRenderingContext image source.
PASS createImageBitmap with Uint8Array image source.
PASS createImageBitmap with ArrayBuffer image source.
PASS createImageBitmap with empty image source.
FAIL createImageBitmap with empty video source. assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
PASS createImageBitmap with empty video source.
PASS createImageBitmap with an oversized canvas source.
FAIL createImageBitmap with an invalid OffscreenCanvas source. assert_throws: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
FAIL createImageBitmap with an undecodable blob source. assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with ArrayBuffer or Blob is not implemented" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
Expand Down
Expand Up @@ -5,10 +5,10 @@ PASS createImageBitmap with a an HTMLCanvasElement source and sh set to 0
FAIL createImageBitmap with a an HTMLCanvasElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a an HTMLVideoElement source and sw set to 0
PASS createImageBitmap with a an HTMLVideoElement source and sh set to 0
FAIL createImageBitmap with a an HTMLVideoElement source and oversized (unallocatable) crop region assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" ("TypeError") expected object "InvalidStateError" ("InvalidStateError")
FAIL createImageBitmap with a an HTMLVideoElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a an HTMLVideoElement from a data URL source and sw set to 0
PASS createImageBitmap with a an HTMLVideoElement from a data URL source and sh set to 0
FAIL createImageBitmap with a an HTMLVideoElement from a data URL source and oversized (unallocatable) crop region assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" ("TypeError") expected object "InvalidStateError" ("InvalidStateError")
FAIL createImageBitmap with a an HTMLVideoElement from a data URL source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a a bitmap HTMLImageElement source and sw set to 0
PASS createImageBitmap with a a bitmap HTMLImageElement source and sh set to 0
FAIL createImageBitmap with a a bitmap HTMLImageElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
Expand Down Expand Up @@ -40,7 +40,7 @@ PASS createImageBitmap with WebGLRenderingContext image source.
PASS createImageBitmap with Uint8Array image source.
PASS createImageBitmap with ArrayBuffer image source.
PASS createImageBitmap with empty image source.
FAIL createImageBitmap with empty video source. assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
PASS createImageBitmap with empty video source.
PASS createImageBitmap with an oversized canvas source.
FAIL createImageBitmap with an invalid OffscreenCanvas source. assert_throws: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
FAIL createImageBitmap with an undecodable blob source. assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with ArrayBuffer or Blob is not implemented" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
Expand Down
Expand Up @@ -5,10 +5,10 @@ PASS createImageBitmap with a an HTMLCanvasElement source and sh set to 0
FAIL createImageBitmap with a an HTMLCanvasElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a an HTMLVideoElement source and sw set to 0
PASS createImageBitmap with a an HTMLVideoElement source and sh set to 0
FAIL createImageBitmap with a an HTMLVideoElement source and oversized (unallocatable) crop region assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" ("TypeError") expected object "InvalidStateError" ("InvalidStateError")
FAIL createImageBitmap with a an HTMLVideoElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a an HTMLVideoElement from a data URL source and sw set to 0
PASS createImageBitmap with a an HTMLVideoElement from a data URL source and sh set to 0
FAIL createImageBitmap with a an HTMLVideoElement from a data URL source and oversized (unallocatable) crop region assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" ("TypeError") expected object "InvalidStateError" ("InvalidStateError")
FAIL createImageBitmap with a an HTMLVideoElement from a data URL source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
PASS createImageBitmap with a a bitmap HTMLImageElement source and sw set to 0
PASS createImageBitmap with a a bitmap HTMLImageElement source and sh set to 0
FAIL createImageBitmap with a a bitmap HTMLImageElement source and oversized (unallocatable) crop region assert_unreached: Should have rejected: undefined Reached unreachable code
Expand Down Expand Up @@ -40,7 +40,7 @@ PASS createImageBitmap with WebGLRenderingContext image source.
PASS createImageBitmap with Uint8Array image source.
PASS createImageBitmap with ArrayBuffer image source.
PASS createImageBitmap with empty image source.
FAIL createImageBitmap with empty video source. assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with HTMLVideoElement is not implemented" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
PASS createImageBitmap with empty video source.
PASS createImageBitmap with an oversized canvas source.
FAIL createImageBitmap with an invalid OffscreenCanvas source. assert_throws: function "function () { throw e }" threw object "TypeError: Type error" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
FAIL createImageBitmap with an undecodable blob source. assert_throws: function "function () { throw e }" threw object "TypeError: createImageBitmap with ArrayBuffer or Blob is not implemented" that is not a DOMException InvalidStateError: property "code" is equal to undefined, expected 11
Expand Down
19 changes: 19 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,22 @@
2018-02-05 Ms2ger <Ms2ger@igalia.com>

Implement createImageBitmap(HTMLVideoElement)
https://bugs.webkit.org/show_bug.cgi?id=182388

Reviewed by Žan Doberšek.

The implementation is inspired by CanvasRenderingContext2DBase::drawImage().

Tests:

- web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage.html
- web-platform-tests/2dcontext/imagebitmap/createImageBitmap-invalid-args.html


* html/ImageBitmap.cpp:
(WebCore::taintsOrigin): Add function to help with the implementation.
(WebCore::ImageBitmap::createPromise): Fill in implementation.

2018-02-05 Zan Dobersek <zdobersek@igalia.com>

Unreviewed, rolling out r228085.
Expand Down

0 comments on commit 45306b5

Please sign in to comment.