Skip to content
Permalink
Browse files
Support negative sw/sh values in createImageBitmap().
https://bugs.webkit.org/show_bug.cgi?id=184449

Reviewed by Dean Jackson.

LayoutTests/imported/w3c:

Update expectations.

* web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt:

Source/WebCore:

Tests: LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage.html
       LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap.html

* html/ImageBitmap.cpp:
(WebCore::ImageBitmap::createPromise): handle negative values per spec.

LayoutTests:

* http/wpt/2dcontext/imagebitmap/createImageBitmap-expected.txt: update test name
* http/wpt/2dcontext/imagebitmap/createImageBitmap.html: update expected result


Canonical link: https://commits.webkit.org/200841@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@231440 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Ms2ger committed May 7, 2018
1 parent eb53004 commit 18d281e781dc9891cb919e7f78dfc71678b600ea
@@ -1,3 +1,13 @@
2018-05-07 Ms2ger <Ms2ger@igalia.com>

Support negative sw/sh values in createImageBitmap().
https://bugs.webkit.org/show_bug.cgi?id=184449

Reviewed by Dean Jackson.

* http/wpt/2dcontext/imagebitmap/createImageBitmap-expected.txt: update test name
* http/wpt/2dcontext/imagebitmap/createImageBitmap.html: update expected result

2018-05-04 Youenn Fablet <youenn@apple.com>

webrtc/addICECandidate-closed.html is timing out
@@ -1,8 +1,8 @@

PASS createImageBitmap rejects with RangeError if width is zero
PASS createImageBitmap rejects with RangeError if height is zero
PASS createImageBitmap rejects with RangeError if width is negative
PASS createImageBitmap rejects with RangeError if height is negative
PASS createImageBitmap if width is negative
PASS createImageBitmap if height is negative
PASS createImageBitmap rejects with InvalidStateError on an HTMLImageElement with no image data
PASS createImageBitmap from an HTMLImageElement with image data
PASS createImageBitmap rejects with InvalidStateError from an canvas with zero dimensions
@@ -8,6 +8,13 @@
<body>
<script>
(function() {
let loadImage = new Promise(function(resolve, reject) {
let img = new Image();
img.onload = function() { resolve(img); };
img.onerror = function() { reject(); };
img.src = "/images/pattern.png";
});

promise_test(function(t) {
return promise_rejects(t, new RangeError, createImageBitmap(new Image(), 0, 0, 0, 10));
}, "createImageBitmap rejects with RangeError if width is zero");
@@ -17,23 +24,33 @@
}, "createImageBitmap rejects with RangeError if height is zero");

promise_test(function(t) {
return promise_rejects(t, new RangeError, createImageBitmap(new Image(), 0, 0, -10, 10));
}, "createImageBitmap rejects with RangeError if width is negative");
return loadImage.then(function(img) {
assert_equals(img.width, 20);
assert_equals(img.height, 20);
return createImageBitmap(img, 10, 10, -10, -10);
}).then(function(imageBitmap) {
assert_equals(imageBitmap.width, 10);
assert_equals(imageBitmap.height, 10);
});
}, "createImageBitmap if width is negative");

promise_test(function(t) {
return promise_rejects(t, new RangeError, createImageBitmap(new Image(), 0, 0, 10, -10));
}, "createImageBitmap rejects with RangeError if height is negative");
return loadImage.then(function(img) {
assert_equals(img.width, 20);
assert_equals(img.height, 20);
return createImageBitmap(img, 10, 10, 10, -10);
}).then(function(imageBitmap) {
assert_equals(imageBitmap.width, 10);
assert_equals(imageBitmap.height, 10);
});
}, "createImageBitmap if height is negative");

promise_test(function(t) {
return promise_rejects(t, "InvalidStateError", createImageBitmap(new Image()));
}, "createImageBitmap rejects with InvalidStateError on an HTMLImageElement with no image data");

promise_test(function() {
return new Promise(function(resolve, reject) {
let img = new Image();
img.onload = function() { resolve(img); };
img.src = "/images/pattern.png";
}).then(function(img) {
return loadImage.then(function(img) {
return createImageBitmap(img);
}).then(function(imageBitmap) {
assert_equals(imageBitmap.width, 20, "ImageBitmap width should be 20");
@@ -1,3 +1,14 @@
2018-05-07 Ms2ger <Ms2ger@igalia.com>

Support negative sw/sh values in createImageBitmap().
https://bugs.webkit.org/show_bug.cgi?id=184449

Reviewed by Dean Jackson.

Update expectations.

* web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage-expected.txt:

2018-05-04 Chris Nardi <cnardi@chromium.org>

Serialize all URLs with double-quotes per CSSOM spec
@@ -3,27 +3,27 @@ PASS createImageBitmap from an HTMLCanvasElement, and drawImage on the created I
PASS createImageBitmap from an HTMLCanvasElement scaled down, and drawImage on the created ImageBitmap
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"
PASS createImageBitmap from an HTMLCanvasElement with negative sw/sh, and drawImage on the created ImageBitmap
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"
PASS createImageBitmap from an HTMLVideoElement with negative sw/sh, and drawImage on the created ImageBitmap
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 an HTMLVideoElement from a data URL with negative sw/sh, and drawImage on the created ImageBitmap
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
PASS createImageBitmap from a bitmap HTMLImageElement scaled up, and drawImage on the created ImageBitmap
PASS createImageBitmap from a bitmap HTMLImageElement resized, and drawImage on the created ImageBitmap
FAIL createImageBitmap from a bitmap HTMLImageElement 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 with negative sw/sh, and drawImage on the created ImageBitmap
PASS createImageBitmap from a vector HTMLImageElement, and drawImage on the created ImageBitmap
PASS createImageBitmap from a vector HTMLImageElement scaled down, and drawImage on the created ImageBitmap
PASS createImageBitmap from a vector HTMLImageElement scaled up, and drawImage on the created ImageBitmap
PASS createImageBitmap from a vector HTMLImageElement resized, and drawImage on the created ImageBitmap
FAIL createImageBitmap from a vector HTMLImageElement 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 vector HTMLImageElement with negative sw/sh, and drawImage on the created ImageBitmap
FAIL createImageBitmap from a bitmap SVGImageElement, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
FAIL createImageBitmap from a bitmap SVGImageElement scaled down, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
FAIL createImageBitmap from a bitmap SVGImageElement scaled up, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: Type error"
@@ -43,15 +43,15 @@ FAIL createImageBitmap from an ImageData, and drawImage on the created ImageBitm
FAIL createImageBitmap from an ImageData scaled down, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with ImageData is not implemented"
FAIL createImageBitmap from an ImageData scaled up, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with ImageData is not implemented"
FAIL createImageBitmap from an ImageData resized, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with ImageData is not implemented"
FAIL createImageBitmap from an ImageData 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 ImageData with negative sw/sh, and drawImage on the created ImageBitmap promise_test: Unhandled rejection with value: object "TypeError: createImageBitmap with ImageData is not implemented"
PASS createImageBitmap from an ImageBitmap, and drawImage on the created ImageBitmap
PASS createImageBitmap from an ImageBitmap scaled down, and drawImage on the created ImageBitmap
PASS createImageBitmap from an ImageBitmap scaled up, and drawImage on the created ImageBitmap
PASS createImageBitmap from an ImageBitmap resized, and drawImage on the created ImageBitmap
FAIL createImageBitmap from an ImageBitmap 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 an ImageBitmap with negative sw/sh, and drawImage on the created ImageBitmap
PASS createImageBitmap from a Blob, and drawImage on the created ImageBitmap
PASS createImageBitmap from a Blob scaled down, and drawImage on the created ImageBitmap
PASS createImageBitmap from a Blob scaled up, and drawImage on the created ImageBitmap
PASS createImageBitmap from a Blob resized, and drawImage on the created ImageBitmap
FAIL createImageBitmap from a Blob 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 Blob with negative sw/sh, and drawImage on the created ImageBitmap

@@ -1,3 +1,16 @@
2018-05-07 Ms2ger <Ms2ger@igalia.com>

Support negative sw/sh values in createImageBitmap().
https://bugs.webkit.org/show_bug.cgi?id=184449

Reviewed by Dean Jackson.

Tests: LayoutTests/imported/w3c/web-platform-tests/2dcontext/imagebitmap/createImageBitmap-drawImage.html
LayoutTests/http/wpt/2dcontext/imagebitmap/createImageBitmap.html

* html/ImageBitmap.cpp:
(WebCore::ImageBitmap::createPromise): handle negative values per spec.

2018-05-07 Brian Burg <bburg@apple.com>

Web Inspector: opt out of process swap on navigation if a Web Inspector frontend is connected
@@ -98,14 +98,14 @@ void ImageBitmap::createPromise(ScriptExecutionContext& scriptExecutionContext,
return;
}

if (sw < 0 || sh < 0) {
promise.reject(RangeError, "Cannot create ImageBitmap with a negative width or height");
return;
}
auto left = sw >= 0 ? sx : sx + sw;
auto top = sh >= 0 ? sy : sy + sh;
auto width = std::abs(sw);
auto height = std::abs(sh);

WTF::switchOn(source,
[&] (auto& specificSource) {
createPromise(scriptExecutionContext, specificSource, WTFMove(options), IntRect { sx, sy, sw, sh }, WTFMove(promise));
createPromise(scriptExecutionContext, specificSource, WTFMove(options), IntRect { left, top, width, height }, WTFMove(promise));
}
);
}

0 comments on commit 18d281e

Please sign in to comment.